Skip to content

Commit 7efbe06

Browse files
committed
Delete cli/contracts folder. move all files into cli/commands/contracts
1 parent bf87260 commit 7efbe06

18 files changed

+407
-1363
lines changed

scripts/README.md

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ These are convenience scripts for interacting with the contracts.
44

55
The scripts expect a `.env` file with the following setup:
66
```
7-
INFURA_KEY= <INSERT_INFURA_API_KEY>
8-
MNEMONIC= <INSERT_12_WORD_MNEMONIC>
7+
MNEMONIC=
8+
ETHERSCAN_API_KEY=
9+
INFURA_KEY=
10+
ADDRESS_BOOK="addresses.json"
11+
GRAPH_CONFIG=""graph.config.yml""
12+
PROVIDER_URL="http://localhost:8545"
913
```
1014

1115
Also, run the following:
@@ -19,9 +23,18 @@ the script calls.
1923
## Usage
2024
There are two aspects to the CLI right now
2125
- `/cli`
22-
- This folder is a CLI that allows for deploying contracts to ethereum networks
23-
- `/contracts`
24-
- This is a CLI that allows for single calls to interact with deployed contracts
25-
- It also has `populateData` , which calls all functions the subgraph ingests, so that whenever
26-
contracts are lauched on a new network, we can quickly test, and get the front end filled
27-
with data. This data is in `/mockdata`
26+
- This folder is a CLI that allows for deploying contracts to ethereum networks. It uses yargs
27+
- `cli/cli.ts`
28+
- This is the main entry point for the CLI
29+
- `/cli/contracts`
30+
- This has functions to call the contract functions directly to interact on chain
31+
- `/cli/scenarios`
32+
- This is where scenarios live. Scenarios are pre-planned interactions of many txs on chain.
33+
They are useful for populating data in our contracts to see the subgraph, or to simulate
34+
real world scenarios on chain
35+
- There are also single files that provide a command for the cli, which are:
36+
- `deploy.ts` - helper to deploy a single contract
37+
- `migrate.ts` - helper to migrate all contracts for a new network on chain
38+
- `protocol.ts` - set or get with any protocol parameter on any contract
39+
- `mintTeamTokens.ts` - mint tokens for the whole team for testing purposes
40+
- `verify.ts` - verify a contract is on chain

scripts/cli/cli.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { upgradeCommand } from './commands/upgrade'
88
import { verifyCommand } from './commands/verify'
99
import { protocolCommand } from './commands/protocol'
1010
import { contractsCommand } from './commands/contracts/contracts'
11+
import { mintTeamTokensCommand } from './commands/mintTeamTokens'
12+
1113
import { cliOpts } from './constants'
1214

1315
dotenv.config()
@@ -23,5 +25,6 @@ yargs
2325
.command(verifyCommand)
2426
.command(protocolCommand)
2527
.command(contractsCommand)
28+
.command(mintTeamTokensCommand)
2629
.demandCommand(1, 'Choose a command from the above list')
2730
.help().argv
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import consola from 'consola'
2+
import { Argv } from 'yargs'
3+
import { parseGRT } from '@graphprotocol/common-ts'
4+
5+
import { sendTransaction } from '../network'
6+
import { loadEnv, CLIArgs, CLIEnvironment } from '../env'
7+
import { teamAddresses } from '../../mockData/teamAddresses'
8+
9+
const logger = consola.create({})
10+
11+
export const mintTeamTokens = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<void> => {
12+
// const amount = parseGRT(cliArgs.amount)
13+
// const graphToken = cli.contracts.GraphToken
14+
console.log(JSON.stringify(cliArgs, null, 2))
15+
16+
// for (const member of teamAddresses) {
17+
// logger.log(`First approving ${cliArgs.amount} tokens for user ${member.name}...`)
18+
// logger.log(`Now minting ${cliArgs.amount} tokens for user ${member.name}...`)
19+
// await sendTransaction(cli.wallet, graphToken, 'mint', ...[member.address, amount])
20+
// }
21+
}
22+
23+
export const mintTeamTokensCommand = {
24+
command: 'mintTeamTokens',
25+
describe: 'Mint tokens for the whole team at the start of new contracts',
26+
builder: (yargs: Argv) => {
27+
return yargs.option('amount', {
28+
description: 'Amount of tokens. CLI converts to a BN with 10^18',
29+
type: 'string',
30+
requiresArg: true,
31+
demandOption: true,
32+
})
33+
},
34+
handler: async (argv: CLIArgs): Promise<void> => {
35+
console.log(argv)
36+
return mintTeamTokens(await loadEnv(argv), argv)
37+
},
38+
}

0 commit comments

Comments
 (0)