Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Dec 18, 2023
1 parent 98a8c34 commit 574911b
Show file tree
Hide file tree
Showing 36 changed files with 381 additions and 288 deletions.
2 changes: 1 addition & 1 deletion latest/.buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 98e18e9ad981a7f935ef93afd2e98182
config: 465db01b7fc789821df6887aef033977
tags: 645f666f9bcd5a90fca523b33c5a78b7
Binary file modified latest/.doctrees/commands/networks.doctree
Binary file not shown.
Binary file modified latest/.doctrees/environment.pickle
Binary file not shown.
Binary file modified latest/.doctrees/methoddocs/ape.doctree
Binary file not shown.
Binary file modified latest/.doctrees/methoddocs/api.doctree
Binary file not shown.
Binary file modified latest/.doctrees/methoddocs/cli.doctree
Binary file not shown.
Binary file modified latest/.doctrees/methoddocs/contracts.doctree
Binary file not shown.
Binary file modified latest/.doctrees/methoddocs/exceptions.doctree
Binary file not shown.
Binary file modified latest/.doctrees/methoddocs/managers.doctree
Binary file not shown.
Binary file modified latest/.doctrees/methoddocs/plugins.doctree
Binary file not shown.
Binary file modified latest/.doctrees/methoddocs/types.doctree
Binary file not shown.
Binary file modified latest/.doctrees/methoddocs/utils.doctree
Binary file not shown.
Binary file modified latest/.doctrees/userguides/accounts.doctree
Binary file not shown.
Binary file modified latest/.doctrees/userguides/clis.doctree
Binary file not shown.
Binary file modified latest/.doctrees/userguides/networks.doctree
Binary file not shown.
Binary file modified latest/.doctrees/userguides/testing.doctree
Binary file not shown.
8 changes: 0 additions & 8 deletions latest/_sources/methoddocs/contracts.md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,3 @@
:special-members:
:exclude-members: __repr__, __weakref__, __metaclass__, __call__, __init__
```

```{eval-rst}
.. autoclass:: ape.contracts.base.ContractError
:members:
:show-inheritance:
:special-members:
:exclude-members: __repr__, __weakref__, __metaclass__, __call__, __init__
```
13 changes: 10 additions & 3 deletions latest/_sources/methoddocs/types.md.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# ape.types

## Miscellaneous
## Address

```{eval-rst}
.. automodule:: ape.types
:members: BlockID, AddressType, BaseContractLog, ContractLog, MockContractLog
.. automodule:: ape.types.address
:members: AddressType, RawAddress
```

## Signatures
Expand All @@ -14,3 +14,10 @@
:members:
:show-inheritance:
```

## Miscellaneous

```{eval-rst}
.. automodule:: ape.types
:members: BlockID, BaseContractLog, ContractLog, MockContractLog
```
59 changes: 16 additions & 43 deletions latest/_sources/userguides/accounts.md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ To learn more about Ethereum accounts, see [the Ethereum documentation](https://
## Test Accounts

Ape ships with pytest fixtures to assist in writing your tests.

### Use test accounts in tests

Pre-funded test accounts are accessible via the [accounts fixture](./testing.html#accounts-fixture).

```python
Expand All @@ -22,6 +25,8 @@ def test_my_contract_method(accounts):
...
```

### Use test accounts outside of tests

To access the same prefunded accounts in your scripts or console, use the root `accounts` object and the [test_accounts](../methoddocs/managers.html#ape.managers.accounts.AccountManager.test_accounts) property:

```python
Expand All @@ -41,9 +46,13 @@ test:
**WARN**: NEVER put a seed phrase with real funds here.
The accounts generated from this seed are solely for testing and debugging purposes.

### Creating new test accounts

You can create a new test account by doing the following:

```python
from ape import accounts

account = accounts.test_accounts.generate_test_account()
```

Expand Down Expand Up @@ -76,7 +85,7 @@ with accounts.use_sender(a): # a is a `TestAccountAPI` object

When using live networks, you need to get your accounts into Ape.
Ape ships with a keyfile accounts plugin to assist with this.
All the available CLI commands for this accounts plugin can be found [here](../commands/accounts.html).
All the available CLI commands for this account's plugin can be found [here](../commands/accounts.html).

For example, you can [generate](../commands/accounts.html#accounts-generate) an account:

Expand All @@ -85,87 +94,67 @@ ape accounts generate <ALIAS>
```

Ape will prompt you for entropy which is used to increase randomness when creating your account.

Ape will then prompt you whether you want to show your mnemonic.

If you do not want to see your mnemonic you can select `n`.

Alternatively you can use the `--hide-mnemonic` option to skip the prompt.
Alternatively, you can use the `--hide-mnemonic` option to skip the prompt.

```bash
ape accounts generate <ALIAS> --hide-mnemonic
```

If you elected to show your mnemonic Ape will then show you your newly generated mnemonic.

Ape will then prompt you for a passphrase which you will need to enter twice to confirm.

This passphrase is used to encrypt your account on disk, for extra security.

You will be prompted for it each time you load your account, so make sure to remember it.

After entering the passphrase Ape will then show you your new account address, HDPath, and account alias.

If you want to use a custom HDPath, use the `--hd-path` option:

```bash
ape accounts generate <ALIAS> --hd-path <HDPATH>
```

If you do not use the `--hd-path` option, Ape will use the default HDPath of (Ethereum network, first account).

If you want to use a custom mnemonic phrase word length, use the `--word-count` option:

```bash
ape accounts generate <ALIAS> --word-count <WORDCOUNT>
```

If you do not use the `--word-count` option, Ape will use the default word count of 12.

You can use all of these together or separately to control the way Ape creates and displays your account information.

If you already have an account and you wish to import it into Ape (say, from Metamask), you can use the [import command](../commands/accounts.html#accounts-import):
If you already have an account and wish to import it into Ape (say, from Metamask), you can use the [import command](../commands/accounts.html#accounts-import):

```bash
ape accounts import <ALIAS>
```

It will prompt you for the private key.

If you need help exporting your private key from Metamask, see [this guide](https://metamask.zendesk.com/hc/en-us/articles/360015289632-How-to-export-an-account-s-private-key).

You can also import accounts from mnemonic seed by using the `--use-mnemonic` flag:

```bash
ape accounts import <ALIAS> --use-mnemonic
```

It will then prompt you for the [mnemonic seed](https://en.bitcoin.it/wiki/Seed_phrase).

If you need help finding your mnemonic seed (Secret Recovery Phrase) in Metamask, see [this guide](https://metamask.zendesk.com/hc/en-us/articles/360015290032-How-to-reveal-your-Secret-Recovery-Phrase).

In addition, you can also use a custom HDPath by using the `--hd-path` option:

```bash
ape accounts import <ALIAS> --use-mnemonic --hd-path <HDPATH>
```

If you use the `--hd-path` option, you will need to pass the [HDPath](https://help.myetherwallet.com/en/articles/5867305-hd-wallets-and-derivation-paths) you'd like to use as an argument in the command.

If you do not use the `--hd-path` option, Ape will use the default HDPath of (Ethereum network, first account).

You can also [export](../commands/accounts.html#accounts-export) the private key of an account:

```bash
ape accounts export <ALIAS>
```

Ape will ask you for the password to the account and then give you the private key of that account.

You can then use that private key with [import](../commands/accounts.html#accounts-import).

You can alternatively load the private key into [Metamask wallet](https://metamask.zendesk.com/hc/en-us/articles/360015489331-How-to-import-an-account#h_01G01W07NV7Q94M7P1EBD5BYM4).

Then, in your scripts, you can [load](../methoddocs/managers.html#ape.managers.accounts.AccountManager.load) an account:

```python
Expand Down Expand Up @@ -194,26 +183,8 @@ with accounts.use_sender(a): # a is a `AccountAPI` object

## Automation

If you use your keyfile accounts in automation, such as CI/CD, you may need to programmatically unlock them and enable autosign.
**WARNING**: We don't recommend using this approach but it is possible due to sometimes being needed.
Ensure you are using a secure environment and are aware of what you are doing.

```python
from ape import accounts
from eth_account.messages import encode_defunct

account = accounts.load("<ALIAS>")
account.set_autosign(True, passphrase="<PASSPHRASE>")

# Now, you will not be prompted to sign messages or transactions
message = encode_defunct(text="Hello Apes!")
signature = account.sign_message(message)
```

## Keyfile Passphrase Environment Variable (more secure)

Another, more secure approach is to use an environment variable.
Set your passphrase in an environment variable by following this template:
If you use your keyfile accounts in automation, such as CI/CD, you may need to programmatically unlock them and enable auto-sign.
To do this, use a special environment variable for the account's passphrase:

```bash
export APE_ACCOUNTS_<alias>_PASSPHRASE="a"
Expand All @@ -234,6 +205,8 @@ message = encode_defunct(text="Hello Apes!")
signature = account.sign_message(message)
```

**NOTE**: Alternatively, you may use the `passphrase=` kwarg on methods `account.set_autosign()` and `account.unlock()`, but we highly recommend using the environment variable approach to avoid accidentally leaking your passphrase.

## Hardware Wallets

Because of the plugin system in Ape, we are able to support other types of accounts including hardware wallet accounts.
Expand Down
2 changes: 1 addition & 1 deletion latest/_sources/userguides/clis.md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def cmd(provider):

@click.command(cls=ConnectedProviderCommand)
def cmd():
click.echo("Using params is from ConnectedProviderCommand is optional")
click.echo("Using params from ConnectedProviderCommand is optional")
```

## Account Tools
Expand Down
4 changes: 2 additions & 2 deletions latest/_sources/userguides/networks.md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ as a short-cut for `ethereum:local:foundry`.
## Configuring Networks

Change network defaults using your project's `ape-config.yaml` file.
The following configuration changes the default ecosystem, network, and provider such that if you omitted the `--network` option on network-bound commands, it would use the value `<ecosystem-name>:<network-name>:<provider-name>`.
The following configuration changes the default ecosystem, network, and provider such that if you omitted the `--network` option on connected-provider commands, it would use the value `<ecosystem-name>:<network-name>:<provider-name>`.

```yaml
default_ecosystem: <ecosystem-name>
Expand All @@ -53,7 +53,7 @@ You may use one of:
- `"max"` - the maximum block gas limit is used
- A number or numeric string, base 10 or 16 (e.g. `1234`, `"1234"`, `0x1234`, `"0x1234"`)

For the local network configuration, the default is `"max"`. Otherwise it is `"auto"`.
For the local network configuration, the default is `"max"`. Otherwise, it is `"auto"`.

## Local Network

Expand Down
2 changes: 2 additions & 0 deletions latest/_sources/userguides/testing.md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ If the sender of the transaction is not the owner, the transaction will fail to
This is an example of how that test may look:

```python
import ape

def test_authorization(my_contract, owner, not_owner):
my_contract.set_owner(sender=owner)
assert owner == my_contract.owner()
Expand Down
10 changes: 5 additions & 5 deletions latest/commands/networks.html
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ <h1>networks<a class="headerlink" href="#networks" title="Permalink to this head
</div>
<section id="networks-list">
<h2>list<a class="headerlink" href="#networks-list" title="Permalink to this heading"></a></h2>
<p>List registered networks</p>
<p>List all the registered ecosystems, networks, and providers.</p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>networks<span class="w"> </span>list<span class="w"> </span><span class="o">[</span>OPTIONS<span class="o">]</span>
</pre></div>
</div>
Expand Down Expand Up @@ -246,7 +246,7 @@ <h2>list<a class="headerlink" href="#networks-list" title="Permalink to this hea
<dd><p>Filter the results by network</p>
<dl class="field-list simple">
<dt class="field-odd">Options<span class="colon">:</span></dt>
<dd class="field-odd"><p>local | mainnet-fork | goerli | mainnet | sepolia | sepolia-fork | goerli-fork</p>
<dd class="field-odd"><p>local | goerli-fork | sepolia-fork | mainnet-fork | mainnet | goerli | sepolia</p>
</dd>
</dl>
</dd></dl>
Expand All @@ -257,16 +257,16 @@ <h2>list<a class="headerlink" href="#networks-list" title="Permalink to this hea
<dd><p>Filter the results by provider</p>
<dl class="field-list simple">
<dt class="field-odd">Options<span class="colon">:</span></dt>
<dd class="field-odd"><p>test | geth</p>
<dd class="field-odd"><p>geth | test</p>
</dd>
</dl>
</dd></dl>

</section>
<section id="networks-run">
<h2>run<a class="headerlink" href="#networks-run" title="Permalink to this heading"></a></h2>
<p>partial(func, <a href="#id1"><span class="problematic" id="id2">*</span></a>args, <a href="#id3"><span class="problematic" id="id4">**</span></a>keywords) - new function with partial application
of the given arguments and keywords.</p>
<p>Start a subprocess node as if running independently
and stream stdout and stderr.</p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>networks<span class="w"> </span>run<span class="w"> </span><span class="o">[</span>OPTIONS<span class="o">]</span>
</pre></div>
</div>
Expand Down
Loading

0 comments on commit 574911b

Please sign in to comment.