-
Notifications
You must be signed in to change notification settings - Fork 529
Expand file tree
/
Copy pathrocketh.ts
More file actions
80 lines (72 loc) · 2.86 KB
/
rocketh.ts
File metadata and controls
80 lines (72 loc) · 2.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// ------------------------------------------------------------------------------------------------
// Typed Config
// ------------------------------------------------------------------------------------------------
import type { UserConfig } from 'rocketh'
export const config = {
accounts: {
deployer: {
default: 0,
},
owner: {
default: 1,
1: '0xFe89cc7aBB2C4183683ab71653C4cdc9B02D44b7', // mainnet
},
},
networks: {
hardhat: {
rpcUrl: 'http://127.0.0.1:8545',
tags: ['test', 'legacy', 'use_root'],
},
localhost: {
rpcUrl: 'http://127.0.0.1:8545',
tags: ['test', 'legacy', 'use_root', 'allow_unsafe'],
},
sepolia: {
rpcUrl: `https://sepolia.infura.io/v3/${process.env.INFURA_API_KEY}`,
tags: ['test', 'legacy', 'use_root'],
},
mainnet: {
rpcUrl: `https://mainnet.infura.io/v3/${process.env.INFURA_API_KEY}`,
tags: ['legacy', 'use_root'],
},
},
} as const satisfies UserConfig
// ------------------------------------------------------------------------------------------------
// Imports and Re-exports
// ------------------------------------------------------------------------------------------------
// We regroup all what is needed for the deploy scripts
// so that they just need to import this file
import * as deployFunctions from '@rocketh/deploy'
import * as readExecuteFunctions from '@rocketh/read-execute'
import * as viemFunctions from '@rocketh/viem'
// ------------------------------------------------------------------------------------------------
// we re-export the artifacts, so they are easily available from the alias
import artifacts from './generated/artifacts.js'
export { artifacts }
// ------------------------------------------------------------------------------------------------
// while not necessary, we also converted the execution function type to know about the named accounts
// this way you get type safe accounts
import {
setup,
type CurriedFunctions,
type Environment as Environment_,
} from 'rocketh'
type HookFunctions = {
createLegacyRegistryNames?: (env: Environment_) => () => Promise<void>
registerLegacyNames?: (env: Environment_) => () => Promise<void>
registerWrappedNames?: (env: Environment_) => () => Promise<void>
registerUnwrappedNames?: (env: Environment_) => () => Promise<void>
}
const functions = {
...deployFunctions,
...readExecuteFunctions,
...viemFunctions,
}
export type Environment = Environment_<typeof config.accounts> &
CurriedFunctions<typeof functions>
export const { deployScript, loadAndExecuteDeployments, loadEnvironment } =
process.env.ROCKETH_CONFIG_FILE
? ((await import(process.env.ROCKETH_CONFIG_FILE)) as ReturnType<
typeof setup<typeof functions & HookFunctions, typeof config.accounts>
>)
: setup<typeof functions & HookFunctions, typeof config.accounts>(functions)