Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Commit

Permalink
Support Cairo 0.10.1 (#268)
Browse files Browse the repository at this point in the history
* add async deps

* update funcs to async

* adjust run_cmd, add helper funcs

* adjust methods to async

* adjust nre to async

* fix formatting

* replace arg object, fix nre and output

* fix formatting

* add rstrip to capture

* async get-nonce

* remove comments

* fix formatting

* add event loop

* update tests without subprocess

* update cli tests with asyncclick

* adjust tests to async

* add set_args func

* simplify context with set_args

* remove subprocess, add set_args

* add tests for common funcs

* async debug, remove subprocess

* fix test

* bump cairo-lang

* fix conflicts

* fix conflicts

* fix account test conflicts

* add sign_deployment

* bump tox version

* update account tests to async

* update debug test to async

* update get_accounts to async

* start test refactor

* add async to nre snippets

* add language to code block

* fix url tests

* fix tests

* fix formatting

* fix get_gateway handling

* remove redundant mock

* fix formatting

* remove unused func

* fix linter

* bump devnet (to support depploy_account)

* bump devnet (to support depploy_account)

* clean up test

* fix network handling

* fix tx_status calls

* add account.deploy with __validate_deploy__

* support mainnet token

* add call_cli func

* abstract command args

* fix tests with call_cli

* fix tests with call_cli

* fix formatting

* remove unnecessary hex

* remove async from simulate methods

* remove unnecessary int conversion

* add comment regarding AsyncObject in Account

* handle async logging

* fix formatting

* refactor _process_arguments

* fix formatting

* test account.deploy

* test deploy_account

* fix linting

* add salt and max_fee to Account constructor

* fix linting

* fix _process_arguments

* fix test

* fix tx output and error handling

* fix formatting

* add starknet_cli module

* improve command_args handling

* fix sender param

* fix docstring formatting

* add starknet_cli tests

* fix status test

* move tests to starknet_cli

* update patch location

* test args in execute_call

* add comments

* remove comments

* fix conflicts. address review comments

* fix linting

* fix merge

* add gateway response tests

* update account artifacts w/vali_deploy

* add get_balance and conterfactual_address

* fix tests and implementations

* fix linting

* fix tests

* add README

* fix typo

* Update README.md

Co-authored-by: Eric Nordelo <[email protected]>

* Update src/nile/signer.py

Co-authored-by: Andrew Fleming <[email protected]>

* apply review comments

* fix linting

* fix linting

* fix linting

* test get_balance, fix circular depedency

* fix linting

* improve get-balance logging

* fix tests

* fix linting

* fix tests

* fix tests

* fix linting

* apply review suggestions

* fix linting

Co-authored-by: Andrew <[email protected]>
Co-authored-by: Eric Nordelo <[email protected]>
  • Loading branch information
3 people authored Nov 21, 2022
1 parent 6fee778 commit b81dce8
Show file tree
Hide file tree
Showing 21 changed files with 4,421 additions and 1,954 deletions.
33 changes: 31 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ Deploy an Account associated with a given private key.
To avoid accidentally leaking private keys, this command takes an alias instead of the actual private key. This alias is associated with an environmental variable of the same name, whose value is the actual private key.

```sh
nile setup <private_key_alias>
nile setup <private_key_alias> [--salt SALT] [--max_fee MAX_FEE] [--network NETWORK]

🚀 Deploying Account
⏳ ️Deployment of Account successfully sent at 0x07db6b52c8ab888183277bc6411c400136fe566c0eebfb96fffa559b2e60e794
Expand All @@ -166,11 +166,28 @@ nile setup <private_key_alias>

A few things to note here:

- This is a counterfactual deployment, meaning the deployed account pays for its own deployment. You can use [`nile counterfactual-address`](#counterfactual-address) to predict the account address and send the necessary funds beforehand.
- `nile setup <private_key_alias>` looks for an environment variable with the name of the private key alias.
- This creates or updates `localhost.accounts.json` file storing all data related to accounts management.
- This creates or updates `localhost.accounts.json` file storing all data related to account management.
- The creates or updates `localhost.deployments.txt` file storing all data related to deployments.
- `--track` and `--debug` flags can be used to watch the status of the account deployment transaction. See `status` below for a complete description.

### `counterfactual-address`

Precompute the deployment address of an Account contract, for a given signer and salt. If not provided, `salt` defaults to `0`.

```sh
nile counterfactual-address <private_key_alias> [--salt SALT]
```

For example:

```sh
nile counterfactual-address <private_key_alias> --salt 123

0x00193c9bf3f66f556b40f0e95dffdd07db2cd6b10552a75048b71550049d1246
```

### `send`

Execute a transaction through the `Account` associated with the private key provided. The syntax is:
Expand Down Expand Up @@ -436,6 +453,18 @@ async def run(nre):
await bob.send(...)
```

### `get-balance`

Retrieves the Ether balance for a given contract address.

```sh
nile get-balance <contract_address> [--network NETWORK]

nile get-balance 0x053edde5384e39bad137d3c4130c708fb96ee28a4c80bf28049c486d3f36992e
🕵️ 0x053ed...6992e balance is:
💰 4444.555501003 gwei
```

### `get-nonce`

Retrieves the nonce for the given contract address (usually an account).
Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ install_requires =
click>=8.0,<9.0
importlib-metadata>=4.0
python-dotenv>=0.19.2
starknet-devnet>=0.3.1,<0.3.4
cairo-lang==0.10.0
starknet-devnet>=0.3.5
cairo-lang>=0.10.1
pytest>=7.1.3
pytest-asyncio>=0.19.0
requests>=2.28.1
Expand Down
5,431 changes: 3,572 additions & 1,859 deletions src/nile/artifacts/Account.json

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions src/nile/artifacts/abis/Account.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,25 @@
"outputs": [],
"type": "function"
},
{
"inputs": [
{
"name": "class_hash",
"type": "felt"
},
{
"name": "salt",
"type": "felt"
},
{
"name": "publicKey",
"type": "felt"
}
],
"name": "__validate_deploy__",
"outputs": [],
"type": "function"
},
{
"inputs": [
{
Expand Down
274 changes: 274 additions & 0 deletions src/nile/artifacts/abis/ERC20.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,274 @@
[
{
"members": [
{
"name": "low",
"offset": 0,
"type": "felt"
},
{
"name": "high",
"offset": 1,
"type": "felt"
}
],
"name": "Uint256",
"size": 2,
"type": "struct"
},
{
"data": [
{
"name": "from_",
"type": "felt"
},
{
"name": "to",
"type": "felt"
},
{
"name": "value",
"type": "Uint256"
}
],
"keys": [],
"name": "Transfer",
"type": "event"
},
{
"data": [
{
"name": "owner",
"type": "felt"
},
{
"name": "spender",
"type": "felt"
},
{
"name": "value",
"type": "Uint256"
}
],
"keys": [],
"name": "Approval",
"type": "event"
},
{
"inputs": [
{
"name": "name",
"type": "felt"
},
{
"name": "symbol",
"type": "felt"
},
{
"name": "decimals",
"type": "felt"
},
{
"name": "initial_supply",
"type": "Uint256"
},
{
"name": "recipient",
"type": "felt"
}
],
"name": "constructor",
"outputs": [],
"type": "constructor"
},
{
"inputs": [],
"name": "name",
"outputs": [
{
"name": "name",
"type": "felt"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "symbol",
"outputs": [
{
"name": "symbol",
"type": "felt"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "totalSupply",
"outputs": [
{
"name": "totalSupply",
"type": "Uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "decimals",
"outputs": [
{
"name": "decimals",
"type": "felt"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"name": "account",
"type": "felt"
}
],
"name": "balanceOf",
"outputs": [
{
"name": "balance",
"type": "Uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"name": "owner",
"type": "felt"
},
{
"name": "spender",
"type": "felt"
}
],
"name": "allowance",
"outputs": [
{
"name": "remaining",
"type": "Uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"name": "recipient",
"type": "felt"
},
{
"name": "amount",
"type": "Uint256"
}
],
"name": "transfer",
"outputs": [
{
"name": "success",
"type": "felt"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "sender",
"type": "felt"
},
{
"name": "recipient",
"type": "felt"
},
{
"name": "amount",
"type": "Uint256"
}
],
"name": "transferFrom",
"outputs": [
{
"name": "success",
"type": "felt"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "spender",
"type": "felt"
},
{
"name": "amount",
"type": "Uint256"
}
],
"name": "approve",
"outputs": [
{
"name": "success",
"type": "felt"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "spender",
"type": "felt"
},
{
"name": "added_value",
"type": "Uint256"
}
],
"name": "increaseAllowance",
"outputs": [
{
"name": "success",
"type": "felt"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "spender",
"type": "felt"
},
{
"name": "subtracted_value",
"type": "Uint256"
}
],
"name": "decreaseAllowance",
"outputs": [
{
"name": "success",
"type": "felt"
}
],
"type": "function"
}
]
Loading

0 comments on commit b81dce8

Please sign in to comment.