Skip to content

Commit 0f68e02

Browse files
authored
Merge pull request #15 from smartcontractkit/gauntlet-erc20
Gauntlet Starkgate ERC20 and Argent Account support
2 parents 7035f66 + 068e0a4 commit 0f68e02

File tree

44 files changed

+675
-139
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+675
-139
lines changed

docs/gauntlet/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
- [Basic Setup](./getting_started.md#basic-setup)
77
- [CLI](../../packages-ts/gauntlet-starknet-cli/README.md)
88
- [Example Contract](../../packages-ts/gauntlet-starknet-example/README.md)
9-
- [Account Contract](../../packages-ts/gauntlet-starknet-account/README.md)
9+
- [OZ Contracts](../../packages-ts/gauntlet-starknet-oz/README.md)
10+
- [Starkgate Contracts](../../packages-ts/gauntlet-starknet-starkgate/README.md)
11+
- [Argent Contracts](../../packages-ts/gauntlet-starknet-argent/README.md)
1012
- [OCR2 Contracts](../../packages-ts/gauntlet-starknet-ocr2/README.md)
1113
- Contribute
File renamed without changes.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Gauntlet Starknet Commands for Argent Contracts
2+
3+
## Account
4+
5+
### Deploy
6+
7+
```
8+
yarn gauntlet argent_account:deploy --network=<NETWORK>
9+
```
10+
11+
Note the contract address. The contract is not configured yet. A signer needs to be specified in it:
12+
13+
### Initialize
14+
15+
```bash
16+
yarn gauntlet argent_account:initialize --network=<NETWORK> <CONTRACT_ADDRESS>
17+
# OR If you already have a private key
18+
yarn gauntlet argent_account:initialize --network=<NETWORK> --publicKey=<PUBLIC_KEY> <CONTRACT_ADDRESS>
19+
```
20+
21+
If no public key is provided, the command will generate a new Keypair and will give the details during the execution.
22+
23+
You need to pay some fee to call initialize, but as this could be the first account wallet you are deploying, use the `--noWallet` option to bypass the fee. This will be soon deprecated
24+
25+
At the end of the process, you will want to include the account contract and the private key to your `.env` configuration file.
26+
27+
```bash
28+
# .env
29+
PRIVATE_KEY=0x...
30+
ACCOUNT=0x...
31+
```

packages-ts/gauntlet-starknet-account/package.json renamed to packages-ts/gauntlet-starknet-argent/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "@chainlink/gauntlet-starknet-account",
2+
"name": "@chainlink/gauntlet-starknet-argent",
33
"version": "0.0.1",
4-
"description": "Gauntlet Starknet Account",
4+
"description": "Gauntlet Starknet Argent contracts",
55
"keywords": [
66
"typescript",
77
"cli"
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import {
2+
BeforeExecute,
3+
ExecuteCommandConfig,
4+
ExecutionContext,
5+
makeExecuteCommand,
6+
Validation,
7+
} from '@chainlink/gauntlet-starknet'
8+
import { CATEGORIES } from '../../lib/categories'
9+
import { accountContractLoader } from '../../lib/contracts'
10+
11+
type UserInput = {}
12+
13+
type ContractInput = []
14+
15+
const makeUserInput = async (flags, args): Promise<UserInput> => ({})
16+
17+
const makeContractInput = async (input: UserInput, context: ExecutionContext): Promise<ContractInput> => {
18+
return []
19+
}
20+
21+
const beforeExecute: BeforeExecute<UserInput, ContractInput> = (context, input, deps) => async () => {
22+
deps.logger.info(`About to deploy an Argent Account Contract`)
23+
}
24+
25+
const commandConfig: ExecuteCommandConfig<UserInput, ContractInput> = {
26+
ux: {
27+
category: CATEGORIES.ACCOUNT,
28+
function: 'deploy',
29+
examples: [`${CATEGORIES.ACCOUNT}:deploy --network=<NETWORK>`],
30+
},
31+
makeUserInput,
32+
makeContractInput,
33+
validations: [],
34+
loadContract: accountContractLoader,
35+
hooks: {
36+
beforeExecute,
37+
},
38+
}
39+
40+
export default makeExecuteCommand(commandConfig)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import Deploy from './deploy'
2+
import Initialize from './initialize'
3+
4+
export default [Deploy, Initialize]
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import {
2+
AfterExecute,
3+
BeforeExecute,
4+
ExecuteCommandConfig,
5+
makeExecuteCommand,
6+
Validation,
7+
} from '@chainlink/gauntlet-starknet'
8+
import { ec } from 'starknet'
9+
import { CATEGORIES } from '../../lib/categories'
10+
import { accountContractLoader } from '../../lib/contracts'
11+
12+
type UserInput = {
13+
publicKey: string
14+
privateKey?: string
15+
}
16+
17+
type ContractInput = [string, 0]
18+
19+
const makeUserInput = async (flags, args): Promise<UserInput> => {
20+
if (flags.input) return flags.input as UserInput
21+
22+
// If public key is not provided, generate a new address
23+
const keypair = ec.genKeyPair()
24+
const generatedPK = '0x' + keypair.getPrivate('hex')
25+
const pubkey = flags.publicKey || ec.getStarkKey(ec.getKeyPair(generatedPK))
26+
return {
27+
publicKey: pubkey,
28+
privateKey: !flags.publicKey && generatedPK,
29+
}
30+
}
31+
32+
const makeContractInput = async (input: UserInput): Promise<ContractInput> => {
33+
return [input.publicKey, 0]
34+
}
35+
36+
const beforeExecute: BeforeExecute<UserInput, ContractInput> = (context, input, deps) => async () => {
37+
deps.logger.info(`About to deploy an Account Contract with public key ${input.contract[0]}`)
38+
if (input.user.privateKey) {
39+
await deps.prompt(`The generated private key will be shown next, continue?`)
40+
deps.logger.line()
41+
42+
deps.logger.info(`To sign future transactions, store the Private Key`)
43+
deps.logger.info(`PRIVATE_KEY: ${input.user.privateKey}`)
44+
45+
deps.logger.line()
46+
}
47+
}
48+
49+
const afterExecute: AfterExecute<UserInput, ContractInput> = (context, input, deps) => async (result) => {
50+
deps.logger.success(`Account contract located at ${result.responses[0].tx.address}`)
51+
return {
52+
publicKey: input.user.publicKey,
53+
privateKey: input.user.privateKey,
54+
}
55+
}
56+
57+
const commandConfig: ExecuteCommandConfig<UserInput, ContractInput> = {
58+
ux: {
59+
category: CATEGORIES.ACCOUNT,
60+
function: 'initialize',
61+
examples: [`${CATEGORIES.ACCOUNT}:initialize --network=<NETWORK> --publicKey=<ADDRESS> <CONTRACT_ADDRESS>`],
62+
},
63+
makeUserInput,
64+
makeContractInput,
65+
validations: [],
66+
loadContract: accountContractLoader,
67+
hooks: {
68+
beforeExecute,
69+
afterExecute,
70+
},
71+
}
72+
73+
export default makeExecuteCommand(commandConfig)

packages-ts/gauntlet-starknet-account/src/commands/index.ts renamed to packages-ts/gauntlet-starknet-argent/src/commands/index.ts

File renamed without changes.
File renamed without changes.

packages-ts/gauntlet-starknet-account/src/lib/categories.ts renamed to packages-ts/gauntlet-starknet-argent/src/lib/categories.ts

File renamed without changes.

0 commit comments

Comments
 (0)