@rocketh/deploy 0.10.7 → 0.10.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/package.json +9 -14
- package/tsconfig.json +13 -10
- package/dist/index.cjs +0 -352
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts +0 -325
- package/dist/index.mjs +0 -350
- package/dist/index.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @rocketh/deploy
|
|
2
2
|
|
|
3
|
+
## 0.10.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- use tsx
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- rocketh@0.10.16
|
|
10
|
+
|
|
11
|
+
## 0.10.8
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
- rocketh@0.10.15
|
|
17
|
+
|
|
3
18
|
## 0.10.7
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,41 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rocketh/deploy",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.9",
|
|
4
4
|
"description": "provide deploy function for rocketh",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
8
|
"type": "module",
|
|
9
|
-
"
|
|
10
|
-
"module": "dist/index.mjs",
|
|
9
|
+
"module": "dist/esm/index.js",
|
|
11
10
|
"types": "dist/index.d.ts",
|
|
12
11
|
".": {
|
|
13
|
-
"require": {
|
|
14
|
-
"types": "./dist/index.d.ts",
|
|
15
|
-
"default": "./dist/index.cjs"
|
|
16
|
-
},
|
|
17
12
|
"import": {
|
|
18
|
-
"types": "./dist/index.d.ts",
|
|
19
|
-
"default": "./dist/index.
|
|
13
|
+
"types": "./dist/esm/index.d.ts",
|
|
14
|
+
"default": "./dist/esm/index.js"
|
|
20
15
|
}
|
|
21
16
|
},
|
|
22
17
|
"devDependencies": {
|
|
23
18
|
"abitype": "^1.0.4",
|
|
19
|
+
"as-soon": "^0.0.11",
|
|
24
20
|
"eip-1193": "^0.5.0",
|
|
25
|
-
"pkgroll": "^2.1.1",
|
|
26
21
|
"rimraf": "^5.0.7",
|
|
27
22
|
"typescript": "^5.5.2",
|
|
28
|
-
"rocketh": "0.10.
|
|
23
|
+
"rocketh": "0.10.16"
|
|
29
24
|
},
|
|
30
25
|
"peerDependencies": {
|
|
31
|
-
"rocketh": "0.10.
|
|
26
|
+
"rocketh": "0.10.16"
|
|
32
27
|
},
|
|
33
28
|
"dependencies": {
|
|
34
29
|
"named-logs": "^0.2.4",
|
|
35
30
|
"viem": "^2.16.2"
|
|
36
31
|
},
|
|
37
32
|
"scripts": {
|
|
38
|
-
"build": "
|
|
39
|
-
"dev": "
|
|
33
|
+
"build": "tsc --project tsconfig.json",
|
|
34
|
+
"dev": "as-soon -w src pnpm build"
|
|
40
35
|
}
|
|
41
36
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"moduleResolution": "Node",
|
|
4
|
-
"lib": ["ES2020", "dom"],
|
|
5
|
-
"target": "ES2020",
|
|
6
|
-
"declaration": true,
|
|
7
|
-
"declarationMap": true,
|
|
8
|
-
"sourceMap": true,
|
|
9
3
|
"strict": true,
|
|
10
|
-
"
|
|
11
|
-
"
|
|
4
|
+
"strictNullChecks": true,
|
|
5
|
+
"target": "ESNext",
|
|
6
|
+
"module": "NodeNext",
|
|
7
|
+
"lib": ["ESNext", "dom"],
|
|
8
|
+
"moduleResolution": "NodeNext",
|
|
12
9
|
"resolveJsonModule": true,
|
|
13
|
-
"
|
|
14
|
-
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"sourceMap": true,
|
|
12
|
+
"declaration": true,
|
|
13
|
+
"declarationMap": true,
|
|
14
|
+
"rootDir": "./src",
|
|
15
|
+
"outDir": "./dist/esm"
|
|
16
|
+
},
|
|
17
|
+
"include": ["src/**/*.ts"]
|
|
15
18
|
}
|
package/dist/index.cjs
DELETED
|
@@ -1,352 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var rocketh = require('rocketh');
|
|
4
|
-
var viem = require('viem');
|
|
5
|
-
var namedLogs = require('named-logs');
|
|
6
|
-
|
|
7
|
-
const logger = namedLogs.logs("rocketh-deploy");
|
|
8
|
-
async function broadcastTransaction(env, signer, params) {
|
|
9
|
-
if (signer.type === "wallet" || signer.type === "remote") {
|
|
10
|
-
return signer.signer.request({
|
|
11
|
-
method: "eth_sendTransaction",
|
|
12
|
-
params
|
|
13
|
-
});
|
|
14
|
-
} else {
|
|
15
|
-
const rawTx = await signer.signer.request({
|
|
16
|
-
method: "eth_signTransaction",
|
|
17
|
-
params
|
|
18
|
-
});
|
|
19
|
-
return env.network.provider.request({
|
|
20
|
-
method: "eth_sendRawTransaction",
|
|
21
|
-
params: [rawTx]
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
function linkRawLibrary(bytecode, libraryName, libraryAddress) {
|
|
26
|
-
const address = libraryAddress.replace("0x", "");
|
|
27
|
-
let encodedLibraryName;
|
|
28
|
-
if (libraryName.startsWith("$") && libraryName.endsWith("$")) {
|
|
29
|
-
encodedLibraryName = libraryName.slice(1, libraryName.length - 1);
|
|
30
|
-
} else {
|
|
31
|
-
encodedLibraryName = viem.keccak256(viem.encodePacked(["string"], [libraryName])).slice(2, 36);
|
|
32
|
-
}
|
|
33
|
-
const pattern = new RegExp(`_+\\$${encodedLibraryName}\\$_+`, "g");
|
|
34
|
-
if (!pattern.exec(bytecode)) {
|
|
35
|
-
throw new Error(`Can't link '${libraryName}' (${encodedLibraryName}) in
|
|
36
|
-
----
|
|
37
|
-
${bytecode}
|
|
38
|
-
----
|
|
39
|
-
`);
|
|
40
|
-
}
|
|
41
|
-
return bytecode.replace(pattern, address);
|
|
42
|
-
}
|
|
43
|
-
function linkRawLibraries(bytecode, libraries) {
|
|
44
|
-
for (const libName of Object.keys(libraries)) {
|
|
45
|
-
const libAddress = libraries[libName];
|
|
46
|
-
bytecode = linkRawLibrary(bytecode, libName, libAddress);
|
|
47
|
-
}
|
|
48
|
-
return bytecode;
|
|
49
|
-
}
|
|
50
|
-
function linkLibraries(artifact, libraries) {
|
|
51
|
-
let bytecode = artifact.bytecode;
|
|
52
|
-
if (libraries) {
|
|
53
|
-
if (artifact.linkReferences) {
|
|
54
|
-
for (const [fileName, fileReferences] of Object.entries(artifact.linkReferences)) {
|
|
55
|
-
for (const [libName, fixups] of Object.entries(fileReferences)) {
|
|
56
|
-
const addr = libraries[libName];
|
|
57
|
-
if (addr === void 0) {
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
for (const fixup of fixups) {
|
|
61
|
-
bytecode = bytecode.substring(0, 2 + fixup.start * 2) + addr.substring(2) + bytecode.substring(2 + (fixup.start + fixup.length) * 2);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
} else {
|
|
66
|
-
bytecode = linkRawLibraries(bytecode, libraries);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return bytecode;
|
|
70
|
-
}
|
|
71
|
-
rocketh.extendEnvironment((env) => {
|
|
72
|
-
async function execute(deployment, args) {
|
|
73
|
-
const { account, ...viemArgs } = args;
|
|
74
|
-
let address;
|
|
75
|
-
if (account.startsWith("0x")) {
|
|
76
|
-
address = account;
|
|
77
|
-
} else {
|
|
78
|
-
if (env.namedAccounts) {
|
|
79
|
-
address = env.namedAccounts[account];
|
|
80
|
-
if (!address) {
|
|
81
|
-
throw new Error(`no address for ${account}`);
|
|
82
|
-
}
|
|
83
|
-
} else {
|
|
84
|
-
throw new Error(`no accounts setup, cannot get address for ${account}`);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
const artifactToUse = deployment;
|
|
88
|
-
const abi = artifactToUse.abi;
|
|
89
|
-
const calldata = viem.encodeFunctionData({
|
|
90
|
-
abi,
|
|
91
|
-
functionName: viemArgs.functionName,
|
|
92
|
-
args: viemArgs.args
|
|
93
|
-
});
|
|
94
|
-
const signer = env.addressSigners[address];
|
|
95
|
-
const txParam = {
|
|
96
|
-
to: deployment.address,
|
|
97
|
-
type: "0x2",
|
|
98
|
-
from: address,
|
|
99
|
-
chainId: `0x${env.network.chain.id.toString(16)}`,
|
|
100
|
-
data: calldata,
|
|
101
|
-
gas: viemArgs.gas && `0x${viemArgs.gas.toString(16)}`,
|
|
102
|
-
// gasPrice: viemArgs.gasPrice && `0x${viemArgs.gasPrice.toString(16)}` as `0x${string}`,
|
|
103
|
-
maxFeePerGas: viemArgs.maxFeePerGas && `0x${viemArgs.maxFeePerGas.toString(16)}`,
|
|
104
|
-
maxPriorityFeePerGas: viemArgs.maxPriorityFeePerGas && `0x${viemArgs.maxPriorityFeePerGas.toString(16)}`
|
|
105
|
-
// nonce: viemArgs.nonce && (`0x${viemArgs.nonce.toString(16)}` as `0x${string}`),
|
|
106
|
-
};
|
|
107
|
-
if (viemArgs.value) {
|
|
108
|
-
txParam.value = `0x${viemArgs.value?.toString(16)}`;
|
|
109
|
-
}
|
|
110
|
-
let txHash;
|
|
111
|
-
if (signer.type === "wallet" || signer.type === "remote") {
|
|
112
|
-
txHash = await signer.signer.request({
|
|
113
|
-
method: "eth_sendTransaction",
|
|
114
|
-
params: [txParam]
|
|
115
|
-
});
|
|
116
|
-
} else {
|
|
117
|
-
const rawTx = await signer.signer.request({
|
|
118
|
-
method: "eth_signTransaction",
|
|
119
|
-
params: [txParam]
|
|
120
|
-
});
|
|
121
|
-
txHash = await env.network.provider.request({
|
|
122
|
-
method: "eth_sendRawTransaction",
|
|
123
|
-
params: [rawTx]
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
const pendingExecution = {
|
|
127
|
-
type: "execution",
|
|
128
|
-
transaction: { hash: txHash, origin: address }
|
|
129
|
-
// description, // TODO
|
|
130
|
-
// TODO we should have the nonce, except for wallet like metamask where it is not usre you get the nonce you start with
|
|
131
|
-
};
|
|
132
|
-
await env.savePendingExecution(pendingExecution);
|
|
133
|
-
return txHash;
|
|
134
|
-
}
|
|
135
|
-
async function executeByName(name, args) {
|
|
136
|
-
const deployment = env.getOrNull(name);
|
|
137
|
-
if (!deployment) {
|
|
138
|
-
throw new Error(`no deployment named ${name}`);
|
|
139
|
-
}
|
|
140
|
-
return execute(deployment, args);
|
|
141
|
-
}
|
|
142
|
-
async function read(deployment, args) {
|
|
143
|
-
const { account, ...viemArgs } = args;
|
|
144
|
-
let address;
|
|
145
|
-
if (account) {
|
|
146
|
-
if (account.startsWith("0x")) {
|
|
147
|
-
address = account;
|
|
148
|
-
} else {
|
|
149
|
-
if (env.namedAccounts) {
|
|
150
|
-
address = env.namedAccounts[account];
|
|
151
|
-
if (!address) {
|
|
152
|
-
throw new Error(`no address for ${account}`);
|
|
153
|
-
}
|
|
154
|
-
} else {
|
|
155
|
-
throw new Error(`no accounts setup, cannot get address for ${account}`);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
const artifactToUse = deployment;
|
|
160
|
-
const abi = artifactToUse.abi;
|
|
161
|
-
const calldata = viem.encodeFunctionData({
|
|
162
|
-
abi,
|
|
163
|
-
functionName: viemArgs.functionName,
|
|
164
|
-
args: viemArgs.args
|
|
165
|
-
});
|
|
166
|
-
const result = await env.network.provider.request({
|
|
167
|
-
method: "eth_call",
|
|
168
|
-
params: [
|
|
169
|
-
{
|
|
170
|
-
to: deployment.address,
|
|
171
|
-
type: "0x2",
|
|
172
|
-
from: address,
|
|
173
|
-
chainId: `0x${env.network.chain.id.toString(16)}`,
|
|
174
|
-
data: calldata
|
|
175
|
-
// value: `0x${viemArgs.value?.toString(16)}` as `0x${string}`,
|
|
176
|
-
}
|
|
177
|
-
]
|
|
178
|
-
});
|
|
179
|
-
const parsed = viem.decodeFunctionResult({
|
|
180
|
-
abi,
|
|
181
|
-
functionName: viemArgs.functionName,
|
|
182
|
-
data: result,
|
|
183
|
-
args: viemArgs.args
|
|
184
|
-
});
|
|
185
|
-
return parsed;
|
|
186
|
-
}
|
|
187
|
-
async function readByName(name, args) {
|
|
188
|
-
const deployment = env.getOrNull(name);
|
|
189
|
-
if (!deployment) {
|
|
190
|
-
throw new Error(`no deployment named ${name}`);
|
|
191
|
-
}
|
|
192
|
-
return read(deployment, args);
|
|
193
|
-
}
|
|
194
|
-
async function deploy(name, args, options) {
|
|
195
|
-
const skipIfAlreadyDeployed = options && "skipIfAlreadyDeployed" in options && options.skipIfAlreadyDeployed;
|
|
196
|
-
const allwaysOverride = options && "allwaysOverride" in options && options.allwaysOverride;
|
|
197
|
-
if (allwaysOverride && skipIfAlreadyDeployed) {
|
|
198
|
-
throw new Error(`conflicting options: "allwaysOverride" and "skipIfAlreadyDeployed"`);
|
|
199
|
-
}
|
|
200
|
-
const existingDeployment = env.getOrNull(name);
|
|
201
|
-
if (existingDeployment && skipIfAlreadyDeployed) {
|
|
202
|
-
logger.info(`deployment for ${name} at ${existingDeployment.address}, skipIfAlreadyDeployed: true => we skip`);
|
|
203
|
-
return { ...existingDeployment, updated: false };
|
|
204
|
-
}
|
|
205
|
-
const { account, artifact, ...viemArgs } = args;
|
|
206
|
-
let address;
|
|
207
|
-
if (account.startsWith("0x")) {
|
|
208
|
-
address = account;
|
|
209
|
-
} else {
|
|
210
|
-
if (env.namedAccounts) {
|
|
211
|
-
address = env.namedAccounts[account];
|
|
212
|
-
if (!address) {
|
|
213
|
-
throw new Error(`no address for ${account}`);
|
|
214
|
-
}
|
|
215
|
-
} else {
|
|
216
|
-
throw new Error(`no accounts setup, cannot get address for ${account}`);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
const artifactToUse = typeof artifact === "string" ? env.artifacts[artifact] : artifact;
|
|
220
|
-
const bytecode = linkLibraries(artifactToUse, options?.libraries);
|
|
221
|
-
const abi = artifactToUse.abi;
|
|
222
|
-
const argsToUse = {
|
|
223
|
-
...viemArgs,
|
|
224
|
-
account,
|
|
225
|
-
abi,
|
|
226
|
-
bytecode
|
|
227
|
-
};
|
|
228
|
-
const calldata = viem.encodeDeployData(argsToUse);
|
|
229
|
-
const argsData = `0x${calldata.replace(bytecode, "")}`;
|
|
230
|
-
if (existingDeployment) {
|
|
231
|
-
logger.info(`existing deployment for ${name} at ${existingDeployment.address}`);
|
|
232
|
-
}
|
|
233
|
-
if (existingDeployment && !allwaysOverride) {
|
|
234
|
-
const previousBytecode = existingDeployment.bytecode;
|
|
235
|
-
const previousArgsData = existingDeployment.argsData;
|
|
236
|
-
const last2Bytes = previousBytecode.slice(-4);
|
|
237
|
-
const cborLength = parseInt(last2Bytes, 16);
|
|
238
|
-
const previousBytecodeWithoutCBOR = previousBytecode.slice(0, -cborLength * 2);
|
|
239
|
-
const newBytecodeWithoutCBOR = bytecode.slice(0, -cborLength * 2);
|
|
240
|
-
if (previousBytecodeWithoutCBOR === newBytecodeWithoutCBOR && previousArgsData === argsData) {
|
|
241
|
-
return { ...existingDeployment, updated: false };
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
const partialDeployment = {
|
|
245
|
-
...artifactToUse,
|
|
246
|
-
argsData,
|
|
247
|
-
linkedData: options?.linkedData
|
|
248
|
-
};
|
|
249
|
-
const signer = env.addressSigners[address];
|
|
250
|
-
const chainId = `0x${env.network.chain.id.toString(16)}`;
|
|
251
|
-
const maxFeePerGas = viemArgs.maxFeePerGas && `0x${viemArgs.maxFeePerGas.toString(16)}`;
|
|
252
|
-
const maxPriorityFeePerGas = viemArgs.maxPriorityFeePerGas && `0x${viemArgs.maxPriorityFeePerGas.toString(16)}`;
|
|
253
|
-
const params = [
|
|
254
|
-
{
|
|
255
|
-
type: "0x2",
|
|
256
|
-
from: address,
|
|
257
|
-
chainId,
|
|
258
|
-
data: calldata,
|
|
259
|
-
gas: viemArgs.gas && `0x${viemArgs.gas.toString(16)}`,
|
|
260
|
-
maxFeePerGas,
|
|
261
|
-
maxPriorityFeePerGas
|
|
262
|
-
// gasPrice: viemArgs.gasPrice && `0x${viemArgs.gasPrice.toString(16)}` as `0x${string}`,
|
|
263
|
-
// value: `0x${viemArgs.value?.toString(16)}` as `0x${string}`,
|
|
264
|
-
// nonce: viemArgs.nonce && (`0x${viemArgs.nonce.toString(16)}` as `0x${string}`),
|
|
265
|
-
}
|
|
266
|
-
];
|
|
267
|
-
let expectedAddress = void 0;
|
|
268
|
-
if (options?.deterministic) {
|
|
269
|
-
const deterministicFactoryAddress = `0x4e59b44847b379578588920ca78fbf26c0b4956c`;
|
|
270
|
-
const deterministicFactoryDeployerAddress = `0x3fab184622dc19b6109349b94811493bf2a45362`;
|
|
271
|
-
const factoryDeploymentData = `0xf8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222`;
|
|
272
|
-
const code = await env.network.provider.request({
|
|
273
|
-
method: "eth_getCode",
|
|
274
|
-
params: [deterministicFactoryAddress, "latest"]
|
|
275
|
-
});
|
|
276
|
-
if (code === "0x") {
|
|
277
|
-
const balanceHexString = await env.network.provider.request({
|
|
278
|
-
method: "eth_getBalance",
|
|
279
|
-
params: [deterministicFactoryDeployerAddress, "latest"]
|
|
280
|
-
});
|
|
281
|
-
const balance = BigInt(balanceHexString);
|
|
282
|
-
if (balance < 10000000000000000n) {
|
|
283
|
-
const need = 10000000000000000n - balance;
|
|
284
|
-
const balanceToSend = `0x${need.toString(16)}`;
|
|
285
|
-
const txHash3 = await broadcastTransaction(env, signer, [
|
|
286
|
-
{
|
|
287
|
-
type: "0x2",
|
|
288
|
-
chainId,
|
|
289
|
-
from: address,
|
|
290
|
-
to: deterministicFactoryDeployerAddress,
|
|
291
|
-
value: balanceToSend,
|
|
292
|
-
gas: `0x${BigInt(21e3).toString(16)}`,
|
|
293
|
-
maxFeePerGas,
|
|
294
|
-
maxPriorityFeePerGas
|
|
295
|
-
}
|
|
296
|
-
]);
|
|
297
|
-
await env.savePendingExecution({
|
|
298
|
-
type: "execution",
|
|
299
|
-
// TODO different type ?
|
|
300
|
-
transaction: { hash: txHash3, origin: address }
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
const txHash2 = await env.network.provider.request({
|
|
304
|
-
method: "eth_sendRawTransaction",
|
|
305
|
-
params: [factoryDeploymentData]
|
|
306
|
-
});
|
|
307
|
-
await env.savePendingExecution({
|
|
308
|
-
type: "execution",
|
|
309
|
-
// TODO different type ?
|
|
310
|
-
transaction: { hash: txHash2, origin: address }
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
const salt = typeof options.deterministic === "string" ? `0x${options.deterministic.slice(2).padStart(64, "0")}` : "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
314
|
-
const bytecode2 = params[0].data || "0x";
|
|
315
|
-
expectedAddress = "0x" + viem.keccak256(`0xff${deterministicFactoryAddress.slice(2)}${salt.slice(2)}${viem.keccak256(bytecode2).slice(2)}`).slice(
|
|
316
|
-
-40
|
|
317
|
-
);
|
|
318
|
-
const codeAlreadyDeployed = await env.network.provider.request({
|
|
319
|
-
method: "eth_getCode",
|
|
320
|
-
params: [expectedAddress, "latest"]
|
|
321
|
-
});
|
|
322
|
-
if (codeAlreadyDeployed !== "0x") {
|
|
323
|
-
env.showMessage(`contract was already deterministically deployed at ${expectedAddress}`);
|
|
324
|
-
const deployment2 = await env.save(name, {
|
|
325
|
-
address: expectedAddress,
|
|
326
|
-
...partialDeployment
|
|
327
|
-
});
|
|
328
|
-
return { ...deployment2, updated: true };
|
|
329
|
-
}
|
|
330
|
-
params[0].data = salt + (bytecode2.slice(2) || "");
|
|
331
|
-
params[0].to = deterministicFactoryAddress;
|
|
332
|
-
}
|
|
333
|
-
const txHash = await broadcastTransaction(env, signer, params);
|
|
334
|
-
const pendingDeployment = {
|
|
335
|
-
type: "deployment",
|
|
336
|
-
expectedAddress,
|
|
337
|
-
partialDeployment,
|
|
338
|
-
transaction: { hash: txHash, origin: address },
|
|
339
|
-
name
|
|
340
|
-
// TODO we should have the nonce, except for wallet like metamask where it is not usre you get the nonce you start with
|
|
341
|
-
};
|
|
342
|
-
const deployment = await env.savePendingDeployment(pendingDeployment);
|
|
343
|
-
return { ...deployment, updated: true };
|
|
344
|
-
}
|
|
345
|
-
env.deploy = deploy;
|
|
346
|
-
env.execute = execute;
|
|
347
|
-
env.executeByName = executeByName;
|
|
348
|
-
env.read = read;
|
|
349
|
-
env.readByName = readByName;
|
|
350
|
-
return env;
|
|
351
|
-
});
|
|
352
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import {Abi} from 'abitype';\nimport {EIP1193DATA, EIP1193TransactionData} from 'eip-1193';\nimport type {\n\tArtifact,\n\tDeploymentConstruction,\n\tDeployment,\n\tEnvironment,\n\tPendingDeployment,\n\tPartialDeployment,\n\tPendingExecution,\n\tSigner,\n} from 'rocketh';\nimport {extendEnvironment} from 'rocketh';\nimport {\n\tAddress,\n\tChain,\n\tContractFunctionArgs,\n\tContractFunctionName,\n\tDecodeFunctionResultReturnType,\n\tEncodeDeployDataParameters,\n\tReadContractParameters,\n\tWriteContractParameters,\n\tdecodeFunctionResult,\n\tencodeFunctionData,\n\tencodePacked,\n\tkeccak256,\n} from 'viem';\nimport {DeployContractParameters, encodeDeployData} from 'viem';\nimport {logs} from 'named-logs';\n\nconst logger = logs('rocketh-deploy');\n\ndeclare module 'rocketh' {\n\tinterface Environment {\n\t\tdeploy: DeployFunction;\n\t\texecute: ExecuteFunction;\n\t\tread: ReadFunction;\n\t\texecuteByName: ExecuteFunctionByName;\n\t\treadByName: ReadFunctionByName;\n\t}\n}\n\nexport type DeployFunction = <TAbi extends Abi, TChain extends Chain = Chain>(\n\tname: string,\n\targs: DeploymentConstruction<TAbi>,\n\toptions?: DeployOptions\n) => Promise<Deployment<TAbi> & {updated: boolean}>;\n\nexport type ExecuteFunction = <\n\tTAbi extends Abi,\n\tTFunctionName extends ContractFunctionName<TAbi, 'nonpayable' | 'payable'>,\n\tTArgs extends ContractFunctionArgs<TAbi, 'nonpayable' | 'payable', TFunctionName> = ContractFunctionArgs<\n\t\tTAbi,\n\t\t'nonpayable' | 'payable',\n\t\tTFunctionName\n\t>\n>(\n\tdeployment: Deployment<TAbi>,\n\targs: ExecutionArgs<TAbi, TFunctionName, TArgs>\n) => Promise<EIP1193DATA>;\n\nexport type ExecuteFunctionByName = <\n\tTAbi extends Abi,\n\tTFunctionName extends ContractFunctionName<TAbi, 'nonpayable' | 'payable'>,\n\tTArgs extends ContractFunctionArgs<TAbi, 'nonpayable' | 'payable', TFunctionName> = ContractFunctionArgs<\n\t\tTAbi,\n\t\t'nonpayable' | 'payable',\n\t\tTFunctionName\n\t>\n>(\n\tname: string,\n\targs: ExecutionArgs<TAbi, TFunctionName, TArgs>\n) => Promise<EIP1193DATA>;\n\nexport type ReadFunction = <\n\tTAbi extends Abi,\n\tTFunctionName extends ContractFunctionName<TAbi, 'pure' | 'view'>,\n\tTArgs extends ContractFunctionArgs<TAbi, 'pure' | 'view', TFunctionName> = ContractFunctionArgs<\n\t\tTAbi,\n\t\t'pure' | 'view',\n\t\tTFunctionName\n\t>\n>(\n\tdeployment: Deployment<TAbi>,\n\targs: ReadingArgs<TAbi, TFunctionName, TArgs>\n) => Promise<DecodeFunctionResultReturnType<TAbi, TFunctionName>>;\n\nexport type ReadFunctionByName = <\n\tTAbi extends Abi,\n\tTFunctionName extends ContractFunctionName<TAbi, 'pure' | 'view'>,\n\tTArgs extends ContractFunctionArgs<TAbi, 'pure' | 'view', TFunctionName> = ContractFunctionArgs<\n\t\tTAbi,\n\t\t'pure' | 'view',\n\t\tTFunctionName\n\t>\n>(\n\tname: string,\n\targs: ReadingArgs<TAbi, TFunctionName, TArgs>\n) => Promise<DecodeFunctionResultReturnType<TAbi, TFunctionName>>;\n\nexport type ExecutionArgs<\n\tTAbi extends Abi,\n\tTFunctionName extends ContractFunctionName<TAbi, 'nonpayable' | 'payable'>,\n\tTArgs extends ContractFunctionArgs<TAbi, 'nonpayable' | 'payable', TFunctionName> = ContractFunctionArgs<\n\t\tTAbi,\n\t\t'nonpayable' | 'payable',\n\t\tTFunctionName\n\t>\n> = Omit<WriteContractParameters<TAbi, TFunctionName, TArgs>, 'address' | 'abi' | 'account' | 'nonce' | 'chain'> & {\n\taccount: string;\n};\n\nexport type ReadingArgs<\n\tTAbi extends Abi,\n\tTFunctionName extends ContractFunctionName<TAbi, 'pure' | 'view'>,\n\tTArgs extends ContractFunctionArgs<TAbi, 'pure' | 'view', TFunctionName> = ContractFunctionArgs<\n\t\tTAbi,\n\t\t'pure' | 'view',\n\t\tTFunctionName\n\t>\n> = Omit<ReadContractParameters<TAbi, TFunctionName, TArgs>, 'address' | 'abi' | 'account' | 'nonce'> & {\n\taccount?: string;\n};\n\nexport type DeployOptions = {\n\tlinkedData?: any;\n\tdeterministic?: boolean | `0x${string}`;\n\tlibraries?: {[name: string]: Address};\n} & (\n\t| {\n\t\t\tskipIfAlreadyDeployed?: boolean;\n\t }\n\t| {\n\t\t\talwaysOverride?: boolean;\n\t }\n);\n\nasync function broadcastTransaction(\n\tenv: Environment,\n\tsigner: Signer,\n\tparams: [EIP1193TransactionData]\n): Promise<`0x${string}`> {\n\tif (signer.type === 'wallet' || signer.type === 'remote') {\n\t\treturn signer.signer.request({\n\t\t\tmethod: 'eth_sendTransaction',\n\t\t\tparams,\n\t\t});\n\t} else {\n\t\tconst rawTx = await signer.signer.request({\n\t\t\tmethod: 'eth_signTransaction',\n\t\t\tparams,\n\t\t});\n\n\t\treturn env.network.provider.request({\n\t\t\tmethod: 'eth_sendRawTransaction',\n\t\t\tparams: [rawTx],\n\t\t});\n\t}\n}\n\nfunction linkRawLibrary(bytecode: string, libraryName: string, libraryAddress: string): string {\n\tconst address = libraryAddress.replace('0x', '');\n\tlet encodedLibraryName;\n\tif (libraryName.startsWith('$') && libraryName.endsWith('$')) {\n\t\tencodedLibraryName = libraryName.slice(1, libraryName.length - 1);\n\t} else {\n\t\tencodedLibraryName = keccak256(encodePacked(['string'], [libraryName])).slice(2, 36);\n\t}\n\tconst pattern = new RegExp(`_+\\\\$${encodedLibraryName}\\\\$_+`, 'g');\n\tif (!pattern.exec(bytecode)) {\n\t\tthrow new Error(`Can't link '${libraryName}' (${encodedLibraryName}) in \\n----\\n ${bytecode}\\n----\\n`);\n\t}\n\treturn bytecode.replace(pattern, address);\n}\n\nfunction linkRawLibraries(bytecode: string, libraries: {[libraryName: string]: Address}): string {\n\tfor (const libName of Object.keys(libraries)) {\n\t\tconst libAddress = libraries[libName];\n\t\tbytecode = linkRawLibrary(bytecode, libName, libAddress);\n\t}\n\treturn bytecode;\n}\n\nfunction linkLibraries(\n\tartifact: {\n\t\tbytecode: string;\n\t\tlinkReferences?: {\n\t\t\t[libraryFileName: string]: {\n\t\t\t\t[libraryName: string]: Array<{length: number; start: number}>;\n\t\t\t};\n\t\t};\n\t},\n\tlibraries?: {[libraryName: string]: Address}\n) {\n\tlet bytecode = artifact.bytecode;\n\n\tif (libraries) {\n\t\tif (artifact.linkReferences) {\n\t\t\tfor (const [fileName, fileReferences] of Object.entries(artifact.linkReferences)) {\n\t\t\t\tfor (const [libName, fixups] of Object.entries(fileReferences)) {\n\t\t\t\t\tconst addr = libraries[libName];\n\t\t\t\t\tif (addr === undefined) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tfor (const fixup of fixups) {\n\t\t\t\t\t\tbytecode =\n\t\t\t\t\t\t\tbytecode.substring(0, 2 + fixup.start * 2) +\n\t\t\t\t\t\t\taddr.substring(2) +\n\t\t\t\t\t\t\tbytecode.substring(2 + (fixup.start + fixup.length) * 2);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tbytecode = linkRawLibraries(bytecode, libraries);\n\t\t}\n\t}\n\n\t// TODO return libraries object with path name <filepath.sol>:<name> for names\n\n\treturn bytecode;\n}\n\nextendEnvironment((env: Environment) => {\n\tasync function execute<\n\t\tTAbi extends Abi,\n\t\tTFunctionName extends ContractFunctionName<TAbi, 'nonpayable' | 'payable'>,\n\t\tTArgs extends ContractFunctionArgs<TAbi, 'nonpayable' | 'payable', TFunctionName> = ContractFunctionArgs<\n\t\t\tTAbi,\n\t\t\t'nonpayable' | 'payable',\n\t\t\tTFunctionName\n\t\t>\n\t>(deployment: Deployment<TAbi>, args: ExecutionArgs<TAbi, TFunctionName, TArgs>) {\n\t\tconst {account, ...viemArgs} = args;\n\t\tlet address: `0x${string}`;\n\t\tif (account.startsWith('0x')) {\n\t\t\taddress = account as `0x${string}`;\n\t\t} else {\n\t\t\tif (env.namedAccounts) {\n\t\t\t\taddress = env.namedAccounts[account];\n\t\t\t\tif (!address) {\n\t\t\t\t\tthrow new Error(`no address for ${account}`);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthrow new Error(`no accounts setup, cannot get address for ${account}`);\n\t\t\t}\n\t\t}\n\n\t\tconst artifactToUse = deployment as unknown as Artifact<TAbi>;\n\t\tconst abi = artifactToUse.abi;\n\t\tconst calldata = encodeFunctionData<TAbi, TFunctionName>({\n\t\t\tabi,\n\t\t\tfunctionName: viemArgs.functionName,\n\t\t\targs: viemArgs.args,\n\t\t} as any);\n\n\t\tconst signer = env.addressSigners[address];\n\n\t\tconst txParam: EIP1193TransactionData = {\n\t\t\tto: deployment.address,\n\t\t\ttype: '0x2',\n\t\t\tfrom: address,\n\t\t\tchainId: `0x${env.network.chain.id.toString(16)}` as `0x${string}`,\n\t\t\tdata: calldata,\n\t\t\tgas: viemArgs.gas && (`0x${viemArgs.gas.toString(16)}` as `0x${string}`),\n\t\t\t// gasPrice: viemArgs.gasPrice && `0x${viemArgs.gasPrice.toString(16)}` as `0x${string}`,\n\t\t\tmaxFeePerGas: viemArgs.maxFeePerGas && (`0x${viemArgs.maxFeePerGas.toString(16)}` as `0x${string}`),\n\t\t\tmaxPriorityFeePerGas:\n\t\t\t\tviemArgs.maxPriorityFeePerGas && (`0x${viemArgs.maxPriorityFeePerGas.toString(16)}` as `0x${string}`),\n\t\t\t// nonce: viemArgs.nonce && (`0x${viemArgs.nonce.toString(16)}` as `0x${string}`),\n\t\t};\n\t\tif (viemArgs.value) {\n\t\t\ttxParam.value = `0x${viemArgs.value?.toString(16)}` as `0x${string}`;\n\t\t}\n\n\t\tlet txHash: `0x${string}`;\n\t\tif (signer.type === 'wallet' || signer.type === 'remote') {\n\t\t\ttxHash = await signer.signer.request({\n\t\t\t\tmethod: 'eth_sendTransaction',\n\t\t\t\tparams: [txParam],\n\t\t\t});\n\t\t} else {\n\t\t\tconst rawTx = await signer.signer.request({\n\t\t\t\tmethod: 'eth_signTransaction',\n\t\t\t\tparams: [txParam],\n\t\t\t});\n\n\t\t\ttxHash = await env.network.provider.request({\n\t\t\t\tmethod: 'eth_sendRawTransaction',\n\t\t\t\tparams: [rawTx],\n\t\t\t});\n\t\t}\n\n\t\tconst pendingExecution: PendingExecution = {\n\t\t\ttype: 'execution',\n\t\t\ttransaction: {hash: txHash, origin: address},\n\t\t\t// description, // TODO\n\t\t\t// TODO we should have the nonce, except for wallet like metamask where it is not usre you get the nonce you start with\n\t\t};\n\t\tawait env.savePendingExecution(pendingExecution);\n\t\treturn txHash;\n\t}\n\n\tasync function executeByName<\n\t\tTAbi extends Abi,\n\t\tTFunctionName extends ContractFunctionName<TAbi, 'nonpayable' | 'payable'>,\n\t\tTArgs extends ContractFunctionArgs<TAbi, 'nonpayable' | 'payable', TFunctionName> = ContractFunctionArgs<\n\t\t\tTAbi,\n\t\t\t'nonpayable' | 'payable',\n\t\t\tTFunctionName\n\t\t>\n\t>(name: string, args: ExecutionArgs<TAbi, TFunctionName, TArgs>) {\n\t\tconst deployment = env.getOrNull<TAbi>(name);\n\t\tif (!deployment) {\n\t\t\tthrow new Error(`no deployment named ${name}`);\n\t\t}\n\n\t\treturn execute(deployment, args);\n\t}\n\n\tasync function read<\n\t\tTAbi extends Abi,\n\t\tTFunctionName extends ContractFunctionName<TAbi, 'pure' | 'view'>,\n\t\tTArgs extends ContractFunctionArgs<TAbi, 'pure' | 'view', TFunctionName> = ContractFunctionArgs<\n\t\t\tTAbi,\n\t\t\t'pure' | 'view',\n\t\t\tTFunctionName\n\t\t>\n\t>(\n\t\tdeployment: Deployment<TAbi>,\n\t\targs: ReadingArgs<TAbi, TFunctionName, TArgs>\n\t): Promise<DecodeFunctionResultReturnType<TAbi, TFunctionName>> {\n\t\tconst {account, ...viemArgs} = args;\n\t\tlet address: `0x${string}` | undefined;\n\t\tif (account) {\n\t\t\tif (account.startsWith('0x')) {\n\t\t\t\taddress = account as `0x${string}`;\n\t\t\t} else {\n\t\t\t\tif (env.namedAccounts) {\n\t\t\t\t\taddress = env.namedAccounts[account];\n\t\t\t\t\tif (!address) {\n\t\t\t\t\t\tthrow new Error(`no address for ${account}`);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(`no accounts setup, cannot get address for ${account}`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst artifactToUse = deployment as unknown as Artifact<TAbi>;\n\t\tconst abi = artifactToUse.abi;\n\t\tconst calldata = encodeFunctionData<TAbi, TFunctionName>({\n\t\t\tabi,\n\t\t\tfunctionName: viemArgs.functionName,\n\t\t\targs: viemArgs.args,\n\t\t} as any);\n\n\t\tconst result: `0x${string}` = (await env.network.provider.request({\n\t\t\tmethod: 'eth_call',\n\t\t\tparams: [\n\t\t\t\t{\n\t\t\t\t\tto: deployment.address,\n\t\t\t\t\ttype: '0x2',\n\t\t\t\t\tfrom: address,\n\t\t\t\t\tchainId: `0x${env.network.chain.id.toString(16)}` as `0x${string}`,\n\t\t\t\t\tdata: calldata,\n\t\t\t\t\t// value: `0x${viemArgs.value?.toString(16)}` as `0x${string}`,\n\t\t\t\t},\n\t\t\t],\n\t\t})) as `0x${string}`;\n\n\t\tconst parsed = decodeFunctionResult<TAbi, TFunctionName>({\n\t\t\tabi,\n\t\t\tfunctionName: viemArgs.functionName,\n\t\t\tdata: result,\n\t\t\targs: viemArgs.args,\n\t\t} as any);\n\n\t\treturn parsed as DecodeFunctionResultReturnType<TAbi, TFunctionName>;\n\t}\n\n\tasync function readByName<\n\t\tTAbi extends Abi,\n\t\tTFunctionName extends ContractFunctionName<TAbi, 'pure' | 'view'>,\n\t\tTArgs extends ContractFunctionArgs<TAbi, 'pure' | 'view', TFunctionName> = ContractFunctionArgs<\n\t\t\tTAbi,\n\t\t\t'pure' | 'view',\n\t\t\tTFunctionName\n\t\t>\n\t>(\n\t\tname: string,\n\t\targs: ReadingArgs<TAbi, TFunctionName, TArgs>\n\t): Promise<DecodeFunctionResultReturnType<TAbi, TFunctionName>> {\n\t\tconst deployment = env.getOrNull<TAbi>(name);\n\t\tif (!deployment) {\n\t\t\tthrow new Error(`no deployment named ${name}`);\n\t\t}\n\n\t\treturn read(deployment, args);\n\t}\n\tasync function deploy<TAbi extends Abi>(\n\t\tname: string,\n\t\targs: DeploymentConstruction<TAbi>,\n\t\toptions?: DeployOptions\n\t): Promise<Deployment<TAbi> & {updated: boolean}> {\n\t\tconst skipIfAlreadyDeployed = options && 'skipIfAlreadyDeployed' in options && options.skipIfAlreadyDeployed;\n\t\tconst allwaysOverride = options && 'allwaysOverride' in options && options.allwaysOverride;\n\n\t\tif (allwaysOverride && skipIfAlreadyDeployed) {\n\t\t\tthrow new Error(`conflicting options: \"allwaysOverride\" and \"skipIfAlreadyDeployed\"`);\n\t\t}\n\n\t\tconst existingDeployment = env.getOrNull(name);\n\t\tif (existingDeployment && skipIfAlreadyDeployed) {\n\t\t\tlogger.info(`deployment for ${name} at ${existingDeployment.address}, skipIfAlreadyDeployed: true => we skip`);\n\t\t\treturn {...(existingDeployment as Deployment<TAbi>), updated: false};\n\t\t}\n\n\t\tconst {account, artifact, ...viemArgs} = args;\n\t\tlet address: `0x${string}`;\n\t\tif (account.startsWith('0x')) {\n\t\t\taddress = account as `0x${string}`;\n\t\t} else {\n\t\t\tif (env.namedAccounts) {\n\t\t\t\taddress = env.namedAccounts[account];\n\t\t\t\tif (!address) {\n\t\t\t\t\tthrow new Error(`no address for ${account}`);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthrow new Error(`no accounts setup, cannot get address for ${account}`);\n\t\t\t}\n\t\t}\n\n\t\t// TODO throw specific error if artifact not found\n\t\tconst artifactToUse = (typeof artifact === 'string' ? env.artifacts[artifact] : artifact) as Artifact<TAbi>;\n\n\t\tconst bytecode = linkLibraries(artifactToUse, options?.libraries);\n\n\t\tconst abi = artifactToUse.abi;\n\n\t\tconst argsToUse = {\n\t\t\t...viemArgs,\n\t\t\taccount,\n\t\t\tabi,\n\t\t\tbytecode,\n\t\t};\n\n\t\tconst calldata = encodeDeployData(argsToUse as any); // TODO any\n\t\tconst argsData = `0x${calldata.replace(bytecode, '')}` as `0x${string}`;\n\n\t\tif (existingDeployment) {\n\t\t\tlogger.info(`existing deployment for ${name} at ${existingDeployment.address}`);\n\t\t}\n\n\t\tif (existingDeployment && !allwaysOverride) {\n\t\t\tconst previousBytecode = existingDeployment.bytecode;\n\t\t\tconst previousArgsData = existingDeployment.argsData;\n\t\t\t// we assume cbor encoding of hash at the end\n\t\t\t// TODO option to remove it, can parse metadata but would rather avoid this here\n\t\t\tconst last2Bytes = previousBytecode.slice(-4);\n\t\t\tconst cborLength = parseInt(last2Bytes, 16);\n\t\t\tconst previousBytecodeWithoutCBOR = previousBytecode.slice(0, -cborLength * 2);\n\t\t\tconst newBytecodeWithoutCBOR = bytecode.slice(0, -cborLength * 2);\n\t\t\tif (previousBytecodeWithoutCBOR === newBytecodeWithoutCBOR && previousArgsData === argsData) {\n\t\t\t\treturn {...(existingDeployment as Deployment<TAbi>), updated: false};\n\t\t\t} else {\n\t\t\t\t// logger.info(`-------------- WITHOUT CBOR---------------------`);\n\t\t\t\t// logger.info(previousBytecodeWithoutCBOR);\n\t\t\t\t// logger.info(newBytecodeWithoutCBOR);\n\t\t\t\t// logger.info(`-----------------------------------`);\n\t\t\t\t// logger.info(`-------------- ARGS DATA ---------------------`);\n\t\t\t\t// logger.info(previousArgsData);\n\t\t\t\t// logger.info(argsData);\n\t\t\t\t// logger.info(`-----------------------------------`);\n\t\t\t}\n\t\t}\n\n\t\tconst partialDeployment: PartialDeployment<TAbi> = {\n\t\t\t...artifactToUse,\n\t\t\targsData,\n\t\t\tlinkedData: options?.linkedData,\n\t\t};\n\n\t\tconst signer = env.addressSigners[address];\n\n\t\tconst chainId = `0x${env.network.chain.id.toString(16)}` as `0x${string}`;\n\t\tconst maxFeePerGas = viemArgs.maxFeePerGas && (`0x${viemArgs.maxFeePerGas.toString(16)}` as `0x${string}`);\n\t\tconst maxPriorityFeePerGas =\n\t\t\tviemArgs.maxPriorityFeePerGas && (`0x${viemArgs.maxPriorityFeePerGas.toString(16)}` as `0x${string}`);\n\n\t\tconst params: [EIP1193TransactionData] = [\n\t\t\t{\n\t\t\t\ttype: '0x2',\n\t\t\t\tfrom: address,\n\t\t\t\tchainId,\n\t\t\t\tdata: calldata,\n\t\t\t\tgas: viemArgs.gas && (`0x${viemArgs.gas.toString(16)}` as `0x${string}`),\n\t\t\t\tmaxFeePerGas,\n\t\t\t\tmaxPriorityFeePerGas,\n\t\t\t\t// gasPrice: viemArgs.gasPrice && `0x${viemArgs.gasPrice.toString(16)}` as `0x${string}`,\n\t\t\t\t// value: `0x${viemArgs.value?.toString(16)}` as `0x${string}`,\n\t\t\t\t// nonce: viemArgs.nonce && (`0x${viemArgs.nonce.toString(16)}` as `0x${string}`),\n\t\t\t},\n\t\t];\n\n\t\tlet expectedAddress: `0x${string}` | undefined = undefined;\n\t\tif (options?.deterministic) {\n\t\t\t// TODO make these configurable\n\t\t\tconst deterministicFactoryAddress = `0x4e59b44847b379578588920ca78fbf26c0b4956c`;\n\t\t\tconst deterministicFactoryDeployerAddress = `0x3fab184622dc19b6109349b94811493bf2a45362`;\n\t\t\tconst factoryDeploymentData = `0xf8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222`;\n\n\t\t\tconst code = await env.network.provider.request({\n\t\t\t\tmethod: 'eth_getCode',\n\t\t\t\tparams: [deterministicFactoryAddress, 'latest'],\n\t\t\t});\n\t\t\tif (code === '0x') {\n\t\t\t\tconst balanceHexString = await env.network.provider.request({\n\t\t\t\t\tmethod: 'eth_getBalance',\n\t\t\t\t\tparams: [deterministicFactoryDeployerAddress, 'latest'],\n\t\t\t\t});\n\t\t\t\tconst balance = BigInt(balanceHexString);\n\t\t\t\tif (balance < 10000000000000000n) {\n\t\t\t\t\tconst need = 10000000000000000n - balance;\n\t\t\t\t\tconst balanceToSend = `0x${need.toString(16)}` as `0x${string}`;\n\t\t\t\t\tconst txHash = await broadcastTransaction(env, signer, [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: '0x2',\n\t\t\t\t\t\t\tchainId,\n\t\t\t\t\t\t\tfrom: address,\n\t\t\t\t\t\t\tto: deterministicFactoryDeployerAddress,\n\t\t\t\t\t\t\tvalue: balanceToSend,\n\t\t\t\t\t\t\tgas: `0x${BigInt(21000).toString(16)}`,\n\t\t\t\t\t\t\tmaxFeePerGas,\n\t\t\t\t\t\t\tmaxPriorityFeePerGas,\n\t\t\t\t\t\t},\n\t\t\t\t\t]);\n\t\t\t\t\tawait env.savePendingExecution({\n\t\t\t\t\t\ttype: 'execution', // TODO different type ?\n\t\t\t\t\t\ttransaction: {hash: txHash, origin: address},\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tconst txHash = await env.network.provider.request({\n\t\t\t\t\tmethod: 'eth_sendRawTransaction',\n\t\t\t\t\tparams: [factoryDeploymentData],\n\t\t\t\t});\n\t\t\t\tawait env.savePendingExecution({\n\t\t\t\t\ttype: 'execution', // TODO different type ?\n\t\t\t\t\ttransaction: {hash: txHash, origin: address},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// prepending the salt\n\t\t\tconst salt = (\n\t\t\t\ttypeof options.deterministic === 'string'\n\t\t\t\t\t? `0x${options.deterministic.slice(2).padStart(64, '0')}`\n\t\t\t\t\t: '0x0000000000000000000000000000000000000000000000000000000000000000'\n\t\t\t) as `0x${string}`;\n\n\t\t\tconst bytecode = params[0].data || '0x';\n\n\t\t\texpectedAddress = ('0x' +\n\t\t\t\tkeccak256(`0xff${deterministicFactoryAddress.slice(2)}${salt.slice(2)}${keccak256(bytecode).slice(2)}`).slice(\n\t\t\t\t\t-40\n\t\t\t\t)) as `0x${string}`;\n\n\t\t\tconst codeAlreadyDeployed = await env.network.provider.request({\n\t\t\t\tmethod: 'eth_getCode',\n\t\t\t\tparams: [expectedAddress, 'latest'],\n\t\t\t});\n\n\t\t\tif (codeAlreadyDeployed !== '0x') {\n\t\t\t\tenv.showMessage(`contract was already deterministically deployed at ${expectedAddress}`);\n\t\t\t\tconst deployment = await env.save(name, {\n\t\t\t\t\taddress: expectedAddress,\n\t\t\t\t\t...partialDeployment,\n\t\t\t\t});\n\t\t\t\treturn {...(deployment as Deployment<TAbi>), updated: true};\n\t\t\t}\n\n\t\t\tparams[0].data = (salt + (bytecode.slice(2) || '')) as `0x${string}`;\n\t\t\tparams[0].to = deterministicFactoryAddress;\n\t\t}\n\n\t\tconst txHash = await broadcastTransaction(env, signer, params);\n\n\t\tconst pendingDeployment: PendingDeployment<TAbi> = {\n\t\t\ttype: 'deployment',\n\t\t\texpectedAddress,\n\t\t\tpartialDeployment,\n\t\t\ttransaction: {hash: txHash, origin: address},\n\t\t\tname,\n\t\t\t// TODO we should have the nonce, except for wallet like metamask where it is not usre you get the nonce you start with\n\t\t};\n\t\tconst deployment = await env.savePendingDeployment(pendingDeployment);\n\t\treturn {...(deployment as Deployment<TAbi>), updated: true};\n\t}\n\n\tenv.deploy = deploy;\n\tenv.execute = execute;\n\tenv.executeByName = executeByName;\n\tenv.read = read;\n\tenv.readByName = readByName;\n\treturn env;\n});\n"],"names":["logs","keccak256","encodePacked","extendEnvironment","encodeFunctionData","decodeFunctionResult","encodeDeployData"],"mappings":";;;;;;AAUA,MAAM,MAAM,GAAGA,cAAI,CAAC,gBAAgB,CAAC,CAAC;AACtC,eAAe,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE;AACzD,EAAE,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE;AAC5D,IAAI,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;AACjC,MAAM,MAAM,EAAE,qBAAqB;AACnC,MAAM,MAAM;AACZ,KAAK,CAAC,CAAC;AACP,GAAG,MAAM;AACT,IAAI,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;AAC9C,MAAM,MAAM,EAAE,qBAAqB;AACnC,MAAM,MAAM;AACZ,KAAK,CAAC,CAAC;AACP,IAAI,OAAO,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;AACxC,MAAM,MAAM,EAAE,wBAAwB;AACtC,MAAM,MAAM,EAAE,CAAC,KAAK,CAAC;AACrB,KAAK,CAAC,CAAC;AACP,GAAG;AACH,CAAC;AACD,SAAS,cAAc,CAAC,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE;AAC/D,EAAE,MAAM,OAAO,GAAG,cAAc,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AACnD,EAAE,IAAI,kBAAkB,CAAC;AACz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E;AACpD,MAAM,IAAI;AACV;AACA,KAAK,CAAC;AACN,IAAI,MAAM,UAAU,GAAG,MAAM,GAAG,CAAC,qBAAqB,CAAC,iBAAiB,CAAC,CAAC;AAC1E,IAAI,OAAO,EAAE,GAAG,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC5C,GAAG;AACH,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC;AACtB,EAAE,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;AACxB,EAAE,GAAG,CAAC,aAAa,GAAG,aAAa,CAAC;AACpC,EAAE,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC;AAClB,EAAE,GAAG,CAAC,UAAU,GAAG,UAAU,CAAC;AAC9B,EAAE,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;;"}
|
package/dist/index.d.ts
DELETED
|
@@ -1,325 +0,0 @@
|
|
|
1
|
-
import { DeploymentConstruction, Deployment } from 'rocketh';
|
|
2
|
-
import { Chain, ContractFunctionName, ContractFunctionArgs, DecodeFunctionResultReturnType, WriteContractParameters, ReadContractParameters, Address } from 'viem';
|
|
3
|
-
|
|
4
|
-
interface Register {
|
|
5
|
-
}
|
|
6
|
-
type ResolvedRegister = {
|
|
7
|
-
/**
|
|
8
|
-
* TypeScript type to use for `address` values
|
|
9
|
-
* @default `0x${string}`
|
|
10
|
-
*/
|
|
11
|
-
addressType: Register extends {
|
|
12
|
-
addressType: infer type;
|
|
13
|
-
} ? type : Register extends {
|
|
14
|
-
AddressType: infer type;
|
|
15
|
-
} ? type : DefaultRegister['addressType'];
|
|
16
|
-
/**
|
|
17
|
-
* TypeScript type to use for `int<M>` and `uint<M>` values, where `M > 48`
|
|
18
|
-
* @default bigint
|
|
19
|
-
*/
|
|
20
|
-
bigIntType: Register extends {
|
|
21
|
-
bigIntType: infer type;
|
|
22
|
-
} ? type : Register extends {
|
|
23
|
-
BigIntType: infer type;
|
|
24
|
-
} ? type : DefaultRegister['bigIntType'];
|
|
25
|
-
/**
|
|
26
|
-
* TypeScript type to use for `bytes` values
|
|
27
|
-
* @default { inputs: `0x${string}`; outputs: `0x${string}`; }
|
|
28
|
-
*/
|
|
29
|
-
bytesType: Register extends {
|
|
30
|
-
bytesType: infer type extends {
|
|
31
|
-
inputs: unknown;
|
|
32
|
-
outputs: unknown;
|
|
33
|
-
};
|
|
34
|
-
} ? type : Register extends {
|
|
35
|
-
BytesType: infer type extends {
|
|
36
|
-
inputs: unknown;
|
|
37
|
-
outputs: unknown;
|
|
38
|
-
};
|
|
39
|
-
} ? type : DefaultRegister['bytesType'];
|
|
40
|
-
/**
|
|
41
|
-
* TypeScript type to use for `int<M>` and `uint<M>` values, where `M <= 48`
|
|
42
|
-
* @default number
|
|
43
|
-
*/
|
|
44
|
-
intType: Register extends {
|
|
45
|
-
intType: infer type;
|
|
46
|
-
} ? type : Register extends {
|
|
47
|
-
IntType: infer type;
|
|
48
|
-
} ? type : DefaultRegister['intType'];
|
|
49
|
-
/**
|
|
50
|
-
* Maximum depth for nested array types (e.g. string[][])
|
|
51
|
-
*
|
|
52
|
-
* Note: You probably only want to set this to a specific number if parsed types are returning as `unknown`
|
|
53
|
-
* and you want to figure out why. If you set this, you should probably also reduce `FixedArrayMaxLength`.
|
|
54
|
-
*
|
|
55
|
-
* @default false
|
|
56
|
-
*/
|
|
57
|
-
arrayMaxDepth: Register extends {
|
|
58
|
-
arrayMaxDepth: infer type extends number | false;
|
|
59
|
-
} ? type : Register extends {
|
|
60
|
-
ArrayMaxDepth: infer type extends number | false;
|
|
61
|
-
} ? type : DefaultRegister['arrayMaxDepth'];
|
|
62
|
-
/**
|
|
63
|
-
* Lower bound for fixed array length
|
|
64
|
-
* @default 1
|
|
65
|
-
*/
|
|
66
|
-
fixedArrayMinLength: Register extends {
|
|
67
|
-
fixedArrayMinLength: infer type extends number;
|
|
68
|
-
} ? type : Register extends {
|
|
69
|
-
FixedArrayMinLength: infer type extends number;
|
|
70
|
-
} ? type : DefaultRegister['fixedArrayMinLength'];
|
|
71
|
-
/**
|
|
72
|
-
* Upper bound for fixed array length
|
|
73
|
-
* @default 99
|
|
74
|
-
*/
|
|
75
|
-
fixedArrayMaxLength: Register extends {
|
|
76
|
-
fixedArrayMaxLength: infer type extends number;
|
|
77
|
-
} ? type : Register extends {
|
|
78
|
-
FixedArrayMaxLength: infer type extends number;
|
|
79
|
-
} ? type : DefaultRegister['fixedArrayMaxLength'];
|
|
80
|
-
/**
|
|
81
|
-
* When set, validates {@link AbiParameter}'s `type` against {@link AbiType}
|
|
82
|
-
*
|
|
83
|
-
* Note: You probably only want to set this to `true` if parsed types are returning as `unknown`
|
|
84
|
-
* and you want to figure out why.
|
|
85
|
-
*
|
|
86
|
-
* @default false
|
|
87
|
-
*/
|
|
88
|
-
strictAbiType: Register extends {
|
|
89
|
-
strictAbiType: infer type extends boolean;
|
|
90
|
-
} ? type : Register extends {
|
|
91
|
-
StrictAbiType: infer type extends boolean;
|
|
92
|
-
} ? type : DefaultRegister['strictAbiType'];
|
|
93
|
-
/** @deprecated Use `addressType` instead */
|
|
94
|
-
AddressType: ResolvedRegister['addressType'];
|
|
95
|
-
/** @deprecated Use `addressType` instead */
|
|
96
|
-
BigIntType: ResolvedRegister['bigIntType'];
|
|
97
|
-
/** @deprecated Use `bytesType` instead */
|
|
98
|
-
BytesType: ResolvedRegister['bytesType'];
|
|
99
|
-
/** @deprecated Use `intType` instead */
|
|
100
|
-
IntType: ResolvedRegister['intType'];
|
|
101
|
-
/** @deprecated Use `arrayMaxDepth` instead */
|
|
102
|
-
ArrayMaxDepth: ResolvedRegister['arrayMaxDepth'];
|
|
103
|
-
/** @deprecated Use `fixedArrayMinLength` instead */
|
|
104
|
-
FixedArrayMinLength: ResolvedRegister['fixedArrayMinLength'];
|
|
105
|
-
/** @deprecated Use `fixedArrayMaxLength` instead */
|
|
106
|
-
FixedArrayMaxLength: ResolvedRegister['fixedArrayMaxLength'];
|
|
107
|
-
/** @deprecated Use `strictAbiType` instead */
|
|
108
|
-
StrictAbiType: ResolvedRegister['strictAbiType'];
|
|
109
|
-
};
|
|
110
|
-
type DefaultRegister = {
|
|
111
|
-
/** Maximum depth for nested array types (e.g. string[][]) */
|
|
112
|
-
arrayMaxDepth: false;
|
|
113
|
-
/** Lower bound for fixed array length */
|
|
114
|
-
fixedArrayMinLength: 1;
|
|
115
|
-
/** Upper bound for fixed array length */
|
|
116
|
-
fixedArrayMaxLength: 99;
|
|
117
|
-
/** TypeScript type to use for `address` values */
|
|
118
|
-
addressType: `0x${string}`;
|
|
119
|
-
/** TypeScript type to use for `bytes` values */
|
|
120
|
-
bytesType: {
|
|
121
|
-
/** TypeScript type to use for `bytes` input values */
|
|
122
|
-
inputs: `0x${string}`;
|
|
123
|
-
/** TypeScript type to use for `bytes` output values */
|
|
124
|
-
outputs: `0x${string}`;
|
|
125
|
-
};
|
|
126
|
-
/** TypeScript type to use for `int<M>` and `uint<M>` values, where `M > 48` */
|
|
127
|
-
bigIntType: bigint;
|
|
128
|
-
/** TypeScript type to use for `int<M>` and `uint<M>` values, where `M <= 48` */
|
|
129
|
-
intType: number;
|
|
130
|
-
/** When set, validates {@link AbiParameter}'s `type` against {@link AbiType} */
|
|
131
|
-
strictAbiType: false;
|
|
132
|
-
/** @deprecated Use `arrayMaxDepth` instead */
|
|
133
|
-
ArrayMaxDepth: DefaultRegister['arrayMaxDepth'];
|
|
134
|
-
/** @deprecated Use `fixedArrayMinLength` instead */
|
|
135
|
-
FixedArrayMinLength: DefaultRegister['fixedArrayMinLength'];
|
|
136
|
-
/** @deprecated Use `fixedArrayMaxLength` instead */
|
|
137
|
-
FixedArrayMaxLength: DefaultRegister['fixedArrayMaxLength'];
|
|
138
|
-
/** @deprecated Use `addressType` instead */
|
|
139
|
-
AddressType: DefaultRegister['addressType'];
|
|
140
|
-
/** @deprecated Use `bytesType` instead */
|
|
141
|
-
BytesType: {
|
|
142
|
-
inputs: DefaultRegister['bytesType']['inputs'];
|
|
143
|
-
outputs: DefaultRegister['bytesType']['outputs'];
|
|
144
|
-
};
|
|
145
|
-
/** @deprecated Use `bigIntType` instead */
|
|
146
|
-
BigIntType: DefaultRegister['bigIntType'];
|
|
147
|
-
/** @deprecated Use `intType` instead */
|
|
148
|
-
IntType: DefaultRegister['intType'];
|
|
149
|
-
/** @deprecated Use `strictAbiType` instead */
|
|
150
|
-
StrictAbiType: DefaultRegister['strictAbiType'];
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Combines members of an intersection into a readable type.
|
|
155
|
-
*
|
|
156
|
-
* @link https://twitter.com/mattpocockuk/status/1622730173446557697?s=20&t=NdpAcmEFXY01xkqU3KO0Mg
|
|
157
|
-
* @example
|
|
158
|
-
* type Result = Pretty<{ a: string } | { b: string } | { c: number, d: bigint }>
|
|
159
|
-
* // ^? type Result = { a: string; b: string; c: number; d: bigint }
|
|
160
|
-
*/
|
|
161
|
-
type Pretty<type> = {
|
|
162
|
-
[key in keyof type]: type[key];
|
|
163
|
-
} & unknown;
|
|
164
|
-
/**
|
|
165
|
-
* Creates range between two positive numbers using [tail recursion](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-5.html#tail-recursion-elimination-on-conditional-types).
|
|
166
|
-
*
|
|
167
|
-
* @param start - Number to start range
|
|
168
|
-
* @param stop - Number to end range
|
|
169
|
-
* @returns Array with inclusive range from {@link start} to {@link stop}
|
|
170
|
-
*
|
|
171
|
-
* @example
|
|
172
|
-
* type Result = Range<1, 3>
|
|
173
|
-
* // ^? type Result = [1, 2, 3]
|
|
174
|
-
*/
|
|
175
|
-
type Range<start extends number, stop extends number, result extends number[] = [], padding extends 0[] = [], current extends number = [...padding, ...result]['length'] & number> = current extends stop ? current extends start ? [current] : result extends [] ? [] : [...result, current] : current extends start ? Range<start, stop, [current], padding> : result extends [] ? Range<start, stop, [], [...padding, 0]> : Range<start, stop, [...result, current], padding>;
|
|
176
|
-
|
|
177
|
-
type MBytes = '' | 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;
|
|
178
|
-
type MBits = '' | 8 | 16 | 24 | 32 | 40 | 48 | 56 | 64 | 72 | 80 | 88 | 96 | 104 | 112 | 120 | 128 | 136 | 144 | 152 | 160 | 168 | 176 | 184 | 192 | 200 | 208 | 216 | 224 | 232 | 240 | 248 | 256;
|
|
179
|
-
type SolidityAddress = 'address';
|
|
180
|
-
type SolidityBool = 'bool';
|
|
181
|
-
type SolidityBytes = `bytes${MBytes}`;
|
|
182
|
-
type SolidityFunction = 'function';
|
|
183
|
-
type SolidityString = 'string';
|
|
184
|
-
type SolidityTuple = 'tuple';
|
|
185
|
-
type SolidityInt = `${'u' | ''}int${MBits}`;
|
|
186
|
-
type SolidityFixedArrayRange = Range<ResolvedRegister['fixedArrayMinLength'], ResolvedRegister['fixedArrayMaxLength']>[number];
|
|
187
|
-
/**
|
|
188
|
-
* Recursively build arrays up to maximum depth
|
|
189
|
-
* or use a more broad type when maximum depth is switched "off"
|
|
190
|
-
*/
|
|
191
|
-
type _BuildArrayTypes<T extends string, Depth extends readonly number[] = []> = ResolvedRegister['arrayMaxDepth'] extends false ? `${T}[${string}]` : Depth['length'] extends ResolvedRegister['arrayMaxDepth'] ? T : T extends `${any}[${SolidityFixedArrayRange | ''}]` ? _BuildArrayTypes<T | `${T}[${SolidityFixedArrayRange | ''}]`, [
|
|
192
|
-
...Depth,
|
|
193
|
-
1
|
|
194
|
-
]> : _BuildArrayTypes<`${T}[${SolidityFixedArrayRange | ''}]`, [...Depth, 1]>;
|
|
195
|
-
type SolidityArrayWithoutTuple = _BuildArrayTypes<SolidityAddress | SolidityBool | SolidityBytes | SolidityFunction | SolidityInt | SolidityString>;
|
|
196
|
-
type SolidityArrayWithTuple = _BuildArrayTypes<SolidityTuple>;
|
|
197
|
-
type SolidityArray = SolidityArrayWithoutTuple | SolidityArrayWithTuple;
|
|
198
|
-
type AbiType = SolidityArray | SolidityAddress | SolidityBool | SolidityBytes | SolidityFunction | SolidityInt | SolidityString | SolidityTuple;
|
|
199
|
-
type ResolvedAbiType = ResolvedRegister['strictAbiType'] extends true ? AbiType : string;
|
|
200
|
-
type AbiInternalType = ResolvedAbiType | `address ${string}` | `contract ${string}` | `enum ${string}` | `struct ${string}`;
|
|
201
|
-
type AbiParameter = Pretty<{
|
|
202
|
-
type: ResolvedAbiType;
|
|
203
|
-
name?: string | undefined;
|
|
204
|
-
/** Representation used by Solidity compiler */
|
|
205
|
-
internalType?: AbiInternalType | undefined;
|
|
206
|
-
} & ({
|
|
207
|
-
type: Exclude<ResolvedAbiType, SolidityTuple | SolidityArrayWithTuple>;
|
|
208
|
-
} | {
|
|
209
|
-
type: SolidityTuple | SolidityArrayWithTuple;
|
|
210
|
-
components: readonly AbiParameter[];
|
|
211
|
-
})>;
|
|
212
|
-
type AbiEventParameter = AbiParameter & {
|
|
213
|
-
indexed?: boolean | undefined;
|
|
214
|
-
};
|
|
215
|
-
/**
|
|
216
|
-
* State mutability for {@link AbiFunction}
|
|
217
|
-
*
|
|
218
|
-
* @see https://docs.soliditylang.org/en/latest/contracts.html#state-mutability
|
|
219
|
-
*/
|
|
220
|
-
type AbiStateMutability = 'pure' | 'view' | 'nonpayable' | 'payable';
|
|
221
|
-
/** ABI ["function"](https://docs.soliditylang.org/en/latest/abi-spec.html#json) type */
|
|
222
|
-
type AbiFunction = {
|
|
223
|
-
type: 'function';
|
|
224
|
-
/**
|
|
225
|
-
* @deprecated use `pure` or `view` from {@link AbiStateMutability} instead
|
|
226
|
-
* @see https://github.com/ethereum/solidity/issues/992
|
|
227
|
-
*/
|
|
228
|
-
constant?: boolean | undefined;
|
|
229
|
-
/**
|
|
230
|
-
* @deprecated Vyper used to provide gas estimates
|
|
231
|
-
* @see https://github.com/vyperlang/vyper/issues/2151
|
|
232
|
-
*/
|
|
233
|
-
gas?: number | undefined;
|
|
234
|
-
inputs: readonly AbiParameter[];
|
|
235
|
-
name: string;
|
|
236
|
-
outputs: readonly AbiParameter[];
|
|
237
|
-
/**
|
|
238
|
-
* @deprecated use `payable` or `nonpayable` from {@link AbiStateMutability} instead
|
|
239
|
-
* @see https://github.com/ethereum/solidity/issues/992
|
|
240
|
-
*/
|
|
241
|
-
payable?: boolean | undefined;
|
|
242
|
-
stateMutability: AbiStateMutability;
|
|
243
|
-
};
|
|
244
|
-
/** ABI ["constructor"](https://docs.soliditylang.org/en/latest/abi-spec.html#json) type */
|
|
245
|
-
type AbiConstructor = {
|
|
246
|
-
type: 'constructor';
|
|
247
|
-
inputs: readonly AbiParameter[];
|
|
248
|
-
/**
|
|
249
|
-
* @deprecated use `payable` or `nonpayable` from {@link AbiStateMutability} instead
|
|
250
|
-
* @see https://github.com/ethereum/solidity/issues/992
|
|
251
|
-
*/
|
|
252
|
-
payable?: boolean | undefined;
|
|
253
|
-
stateMutability: Extract<AbiStateMutability, 'payable' | 'nonpayable'>;
|
|
254
|
-
};
|
|
255
|
-
/** ABI ["fallback"](https://docs.soliditylang.org/en/latest/abi-spec.html#json) type */
|
|
256
|
-
type AbiFallback = {
|
|
257
|
-
type: 'fallback';
|
|
258
|
-
inputs?: readonly [] | undefined;
|
|
259
|
-
/**
|
|
260
|
-
* @deprecated use `payable` or `nonpayable` from {@link AbiStateMutability} instead
|
|
261
|
-
* @see https://github.com/ethereum/solidity/issues/992
|
|
262
|
-
*/
|
|
263
|
-
payable?: boolean | undefined;
|
|
264
|
-
stateMutability: Extract<AbiStateMutability, 'payable' | 'nonpayable'>;
|
|
265
|
-
};
|
|
266
|
-
/** ABI ["receive"](https://docs.soliditylang.org/en/latest/contracts.html#receive-ether-function) type */
|
|
267
|
-
type AbiReceive = {
|
|
268
|
-
type: 'receive';
|
|
269
|
-
stateMutability: Extract<AbiStateMutability, 'payable'>;
|
|
270
|
-
};
|
|
271
|
-
/** ABI ["event"](https://docs.soliditylang.org/en/latest/abi-spec.html#events) type */
|
|
272
|
-
type AbiEvent = {
|
|
273
|
-
type: 'event';
|
|
274
|
-
anonymous?: boolean | undefined;
|
|
275
|
-
inputs: readonly AbiEventParameter[];
|
|
276
|
-
name: string;
|
|
277
|
-
};
|
|
278
|
-
/** ABI ["error"](https://docs.soliditylang.org/en/latest/abi-spec.html#errors) type */
|
|
279
|
-
type AbiError = {
|
|
280
|
-
type: 'error';
|
|
281
|
-
inputs: readonly AbiParameter[];
|
|
282
|
-
name: string;
|
|
283
|
-
};
|
|
284
|
-
/**
|
|
285
|
-
* Contract [ABI Specification](https://docs.soliditylang.org/en/latest/abi-spec.html#json)
|
|
286
|
-
*/
|
|
287
|
-
type Abi = readonly (AbiConstructor | AbiError | AbiEvent | AbiFallback | AbiFunction | AbiReceive)[];
|
|
288
|
-
|
|
289
|
-
type EIP1193DATA = `0x${string}`;
|
|
290
|
-
|
|
291
|
-
declare module 'rocketh' {
|
|
292
|
-
interface Environment {
|
|
293
|
-
deploy: DeployFunction;
|
|
294
|
-
execute: ExecuteFunction;
|
|
295
|
-
read: ReadFunction;
|
|
296
|
-
executeByName: ExecuteFunctionByName;
|
|
297
|
-
readByName: ReadFunctionByName;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
type DeployFunction = <TAbi extends Abi, TChain extends Chain = Chain>(name: string, args: DeploymentConstruction<TAbi>, options?: DeployOptions) => Promise<Deployment<TAbi> & {
|
|
301
|
-
updated: boolean;
|
|
302
|
-
}>;
|
|
303
|
-
type ExecuteFunction = <TAbi extends Abi, TFunctionName extends ContractFunctionName<TAbi, 'nonpayable' | 'payable'>, TArgs extends ContractFunctionArgs<TAbi, 'nonpayable' | 'payable', TFunctionName> = ContractFunctionArgs<TAbi, 'nonpayable' | 'payable', TFunctionName>>(deployment: Deployment<TAbi>, args: ExecutionArgs<TAbi, TFunctionName, TArgs>) => Promise<EIP1193DATA>;
|
|
304
|
-
type ExecuteFunctionByName = <TAbi extends Abi, TFunctionName extends ContractFunctionName<TAbi, 'nonpayable' | 'payable'>, TArgs extends ContractFunctionArgs<TAbi, 'nonpayable' | 'payable', TFunctionName> = ContractFunctionArgs<TAbi, 'nonpayable' | 'payable', TFunctionName>>(name: string, args: ExecutionArgs<TAbi, TFunctionName, TArgs>) => Promise<EIP1193DATA>;
|
|
305
|
-
type ReadFunction = <TAbi extends Abi, TFunctionName extends ContractFunctionName<TAbi, 'pure' | 'view'>, TArgs extends ContractFunctionArgs<TAbi, 'pure' | 'view', TFunctionName> = ContractFunctionArgs<TAbi, 'pure' | 'view', TFunctionName>>(deployment: Deployment<TAbi>, args: ReadingArgs<TAbi, TFunctionName, TArgs>) => Promise<DecodeFunctionResultReturnType<TAbi, TFunctionName>>;
|
|
306
|
-
type ReadFunctionByName = <TAbi extends Abi, TFunctionName extends ContractFunctionName<TAbi, 'pure' | 'view'>, TArgs extends ContractFunctionArgs<TAbi, 'pure' | 'view', TFunctionName> = ContractFunctionArgs<TAbi, 'pure' | 'view', TFunctionName>>(name: string, args: ReadingArgs<TAbi, TFunctionName, TArgs>) => Promise<DecodeFunctionResultReturnType<TAbi, TFunctionName>>;
|
|
307
|
-
type ExecutionArgs<TAbi extends Abi, TFunctionName extends ContractFunctionName<TAbi, 'nonpayable' | 'payable'>, TArgs extends ContractFunctionArgs<TAbi, 'nonpayable' | 'payable', TFunctionName> = ContractFunctionArgs<TAbi, 'nonpayable' | 'payable', TFunctionName>> = Omit<WriteContractParameters<TAbi, TFunctionName, TArgs>, 'address' | 'abi' | 'account' | 'nonce' | 'chain'> & {
|
|
308
|
-
account: string;
|
|
309
|
-
};
|
|
310
|
-
type ReadingArgs<TAbi extends Abi, TFunctionName extends ContractFunctionName<TAbi, 'pure' | 'view'>, TArgs extends ContractFunctionArgs<TAbi, 'pure' | 'view', TFunctionName> = ContractFunctionArgs<TAbi, 'pure' | 'view', TFunctionName>> = Omit<ReadContractParameters<TAbi, TFunctionName, TArgs>, 'address' | 'abi' | 'account' | 'nonce'> & {
|
|
311
|
-
account?: string;
|
|
312
|
-
};
|
|
313
|
-
type DeployOptions = {
|
|
314
|
-
linkedData?: any;
|
|
315
|
-
deterministic?: boolean | `0x${string}`;
|
|
316
|
-
libraries?: {
|
|
317
|
-
[name: string]: Address;
|
|
318
|
-
};
|
|
319
|
-
} & ({
|
|
320
|
-
skipIfAlreadyDeployed?: boolean;
|
|
321
|
-
} | {
|
|
322
|
-
alwaysOverride?: boolean;
|
|
323
|
-
});
|
|
324
|
-
|
|
325
|
-
export type { DeployFunction, DeployOptions, ExecuteFunction, ExecuteFunctionByName, ExecutionArgs, ReadFunction, ReadFunctionByName, ReadingArgs };
|
package/dist/index.mjs
DELETED
|
@@ -1,350 +0,0 @@
|
|
|
1
|
-
import { extendEnvironment } from 'rocketh';
|
|
2
|
-
import { encodeFunctionData, decodeFunctionResult, encodeDeployData, keccak256, encodePacked } from 'viem';
|
|
3
|
-
import { logs } from 'named-logs';
|
|
4
|
-
|
|
5
|
-
const logger = logs("rocketh-deploy");
|
|
6
|
-
async function broadcastTransaction(env, signer, params) {
|
|
7
|
-
if (signer.type === "wallet" || signer.type === "remote") {
|
|
8
|
-
return signer.signer.request({
|
|
9
|
-
method: "eth_sendTransaction",
|
|
10
|
-
params
|
|
11
|
-
});
|
|
12
|
-
} else {
|
|
13
|
-
const rawTx = await signer.signer.request({
|
|
14
|
-
method: "eth_signTransaction",
|
|
15
|
-
params
|
|
16
|
-
});
|
|
17
|
-
return env.network.provider.request({
|
|
18
|
-
method: "eth_sendRawTransaction",
|
|
19
|
-
params: [rawTx]
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function linkRawLibrary(bytecode, libraryName, libraryAddress) {
|
|
24
|
-
const address = libraryAddress.replace("0x", "");
|
|
25
|
-
let encodedLibraryName;
|
|
26
|
-
if (libraryName.startsWith("$") && libraryName.endsWith("$")) {
|
|
27
|
-
encodedLibraryName = libraryName.slice(1, libraryName.length - 1);
|
|
28
|
-
} else {
|
|
29
|
-
encodedLibraryName = keccak256(encodePacked(["string"], [libraryName])).slice(2, 36);
|
|
30
|
-
}
|
|
31
|
-
const pattern = new RegExp(`_+\\$${encodedLibraryName}\\$_+`, "g");
|
|
32
|
-
if (!pattern.exec(bytecode)) {
|
|
33
|
-
throw new Error(`Can't link '${libraryName}' (${encodedLibraryName}) in
|
|
34
|
-
----
|
|
35
|
-
${bytecode}
|
|
36
|
-
----
|
|
37
|
-
`);
|
|
38
|
-
}
|
|
39
|
-
return bytecode.replace(pattern, address);
|
|
40
|
-
}
|
|
41
|
-
function linkRawLibraries(bytecode, libraries) {
|
|
42
|
-
for (const libName of Object.keys(libraries)) {
|
|
43
|
-
const libAddress = libraries[libName];
|
|
44
|
-
bytecode = linkRawLibrary(bytecode, libName, libAddress);
|
|
45
|
-
}
|
|
46
|
-
return bytecode;
|
|
47
|
-
}
|
|
48
|
-
function linkLibraries(artifact, libraries) {
|
|
49
|
-
let bytecode = artifact.bytecode;
|
|
50
|
-
if (libraries) {
|
|
51
|
-
if (artifact.linkReferences) {
|
|
52
|
-
for (const [fileName, fileReferences] of Object.entries(artifact.linkReferences)) {
|
|
53
|
-
for (const [libName, fixups] of Object.entries(fileReferences)) {
|
|
54
|
-
const addr = libraries[libName];
|
|
55
|
-
if (addr === void 0) {
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
for (const fixup of fixups) {
|
|
59
|
-
bytecode = bytecode.substring(0, 2 + fixup.start * 2) + addr.substring(2) + bytecode.substring(2 + (fixup.start + fixup.length) * 2);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
} else {
|
|
64
|
-
bytecode = linkRawLibraries(bytecode, libraries);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return bytecode;
|
|
68
|
-
}
|
|
69
|
-
extendEnvironment((env) => {
|
|
70
|
-
async function execute(deployment, args) {
|
|
71
|
-
const { account, ...viemArgs } = args;
|
|
72
|
-
let address;
|
|
73
|
-
if (account.startsWith("0x")) {
|
|
74
|
-
address = account;
|
|
75
|
-
} else {
|
|
76
|
-
if (env.namedAccounts) {
|
|
77
|
-
address = env.namedAccounts[account];
|
|
78
|
-
if (!address) {
|
|
79
|
-
throw new Error(`no address for ${account}`);
|
|
80
|
-
}
|
|
81
|
-
} else {
|
|
82
|
-
throw new Error(`no accounts setup, cannot get address for ${account}`);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
const artifactToUse = deployment;
|
|
86
|
-
const abi = artifactToUse.abi;
|
|
87
|
-
const calldata = encodeFunctionData({
|
|
88
|
-
abi,
|
|
89
|
-
functionName: viemArgs.functionName,
|
|
90
|
-
args: viemArgs.args
|
|
91
|
-
});
|
|
92
|
-
const signer = env.addressSigners[address];
|
|
93
|
-
const txParam = {
|
|
94
|
-
to: deployment.address,
|
|
95
|
-
type: "0x2",
|
|
96
|
-
from: address,
|
|
97
|
-
chainId: `0x${env.network.chain.id.toString(16)}`,
|
|
98
|
-
data: calldata,
|
|
99
|
-
gas: viemArgs.gas && `0x${viemArgs.gas.toString(16)}`,
|
|
100
|
-
// gasPrice: viemArgs.gasPrice && `0x${viemArgs.gasPrice.toString(16)}` as `0x${string}`,
|
|
101
|
-
maxFeePerGas: viemArgs.maxFeePerGas && `0x${viemArgs.maxFeePerGas.toString(16)}`,
|
|
102
|
-
maxPriorityFeePerGas: viemArgs.maxPriorityFeePerGas && `0x${viemArgs.maxPriorityFeePerGas.toString(16)}`
|
|
103
|
-
// nonce: viemArgs.nonce && (`0x${viemArgs.nonce.toString(16)}` as `0x${string}`),
|
|
104
|
-
};
|
|
105
|
-
if (viemArgs.value) {
|
|
106
|
-
txParam.value = `0x${viemArgs.value?.toString(16)}`;
|
|
107
|
-
}
|
|
108
|
-
let txHash;
|
|
109
|
-
if (signer.type === "wallet" || signer.type === "remote") {
|
|
110
|
-
txHash = await signer.signer.request({
|
|
111
|
-
method: "eth_sendTransaction",
|
|
112
|
-
params: [txParam]
|
|
113
|
-
});
|
|
114
|
-
} else {
|
|
115
|
-
const rawTx = await signer.signer.request({
|
|
116
|
-
method: "eth_signTransaction",
|
|
117
|
-
params: [txParam]
|
|
118
|
-
});
|
|
119
|
-
txHash = await env.network.provider.request({
|
|
120
|
-
method: "eth_sendRawTransaction",
|
|
121
|
-
params: [rawTx]
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
const pendingExecution = {
|
|
125
|
-
type: "execution",
|
|
126
|
-
transaction: { hash: txHash, origin: address }
|
|
127
|
-
// description, // TODO
|
|
128
|
-
// TODO we should have the nonce, except for wallet like metamask where it is not usre you get the nonce you start with
|
|
129
|
-
};
|
|
130
|
-
await env.savePendingExecution(pendingExecution);
|
|
131
|
-
return txHash;
|
|
132
|
-
}
|
|
133
|
-
async function executeByName(name, args) {
|
|
134
|
-
const deployment = env.getOrNull(name);
|
|
135
|
-
if (!deployment) {
|
|
136
|
-
throw new Error(`no deployment named ${name}`);
|
|
137
|
-
}
|
|
138
|
-
return execute(deployment, args);
|
|
139
|
-
}
|
|
140
|
-
async function read(deployment, args) {
|
|
141
|
-
const { account, ...viemArgs } = args;
|
|
142
|
-
let address;
|
|
143
|
-
if (account) {
|
|
144
|
-
if (account.startsWith("0x")) {
|
|
145
|
-
address = account;
|
|
146
|
-
} else {
|
|
147
|
-
if (env.namedAccounts) {
|
|
148
|
-
address = env.namedAccounts[account];
|
|
149
|
-
if (!address) {
|
|
150
|
-
throw new Error(`no address for ${account}`);
|
|
151
|
-
}
|
|
152
|
-
} else {
|
|
153
|
-
throw new Error(`no accounts setup, cannot get address for ${account}`);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
const artifactToUse = deployment;
|
|
158
|
-
const abi = artifactToUse.abi;
|
|
159
|
-
const calldata = encodeFunctionData({
|
|
160
|
-
abi,
|
|
161
|
-
functionName: viemArgs.functionName,
|
|
162
|
-
args: viemArgs.args
|
|
163
|
-
});
|
|
164
|
-
const result = await env.network.provider.request({
|
|
165
|
-
method: "eth_call",
|
|
166
|
-
params: [
|
|
167
|
-
{
|
|
168
|
-
to: deployment.address,
|
|
169
|
-
type: "0x2",
|
|
170
|
-
from: address,
|
|
171
|
-
chainId: `0x${env.network.chain.id.toString(16)}`,
|
|
172
|
-
data: calldata
|
|
173
|
-
// value: `0x${viemArgs.value?.toString(16)}` as `0x${string}`,
|
|
174
|
-
}
|
|
175
|
-
]
|
|
176
|
-
});
|
|
177
|
-
const parsed = decodeFunctionResult({
|
|
178
|
-
abi,
|
|
179
|
-
functionName: viemArgs.functionName,
|
|
180
|
-
data: result,
|
|
181
|
-
args: viemArgs.args
|
|
182
|
-
});
|
|
183
|
-
return parsed;
|
|
184
|
-
}
|
|
185
|
-
async function readByName(name, args) {
|
|
186
|
-
const deployment = env.getOrNull(name);
|
|
187
|
-
if (!deployment) {
|
|
188
|
-
throw new Error(`no deployment named ${name}`);
|
|
189
|
-
}
|
|
190
|
-
return read(deployment, args);
|
|
191
|
-
}
|
|
192
|
-
async function deploy(name, args, options) {
|
|
193
|
-
const skipIfAlreadyDeployed = options && "skipIfAlreadyDeployed" in options && options.skipIfAlreadyDeployed;
|
|
194
|
-
const allwaysOverride = options && "allwaysOverride" in options && options.allwaysOverride;
|
|
195
|
-
if (allwaysOverride && skipIfAlreadyDeployed) {
|
|
196
|
-
throw new Error(`conflicting options: "allwaysOverride" and "skipIfAlreadyDeployed"`);
|
|
197
|
-
}
|
|
198
|
-
const existingDeployment = env.getOrNull(name);
|
|
199
|
-
if (existingDeployment && skipIfAlreadyDeployed) {
|
|
200
|
-
logger.info(`deployment for ${name} at ${existingDeployment.address}, skipIfAlreadyDeployed: true => we skip`);
|
|
201
|
-
return { ...existingDeployment, updated: false };
|
|
202
|
-
}
|
|
203
|
-
const { account, artifact, ...viemArgs } = args;
|
|
204
|
-
let address;
|
|
205
|
-
if (account.startsWith("0x")) {
|
|
206
|
-
address = account;
|
|
207
|
-
} else {
|
|
208
|
-
if (env.namedAccounts) {
|
|
209
|
-
address = env.namedAccounts[account];
|
|
210
|
-
if (!address) {
|
|
211
|
-
throw new Error(`no address for ${account}`);
|
|
212
|
-
}
|
|
213
|
-
} else {
|
|
214
|
-
throw new Error(`no accounts setup, cannot get address for ${account}`);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
const artifactToUse = typeof artifact === "string" ? env.artifacts[artifact] : artifact;
|
|
218
|
-
const bytecode = linkLibraries(artifactToUse, options?.libraries);
|
|
219
|
-
const abi = artifactToUse.abi;
|
|
220
|
-
const argsToUse = {
|
|
221
|
-
...viemArgs,
|
|
222
|
-
account,
|
|
223
|
-
abi,
|
|
224
|
-
bytecode
|
|
225
|
-
};
|
|
226
|
-
const calldata = encodeDeployData(argsToUse);
|
|
227
|
-
const argsData = `0x${calldata.replace(bytecode, "")}`;
|
|
228
|
-
if (existingDeployment) {
|
|
229
|
-
logger.info(`existing deployment for ${name} at ${existingDeployment.address}`);
|
|
230
|
-
}
|
|
231
|
-
if (existingDeployment && !allwaysOverride) {
|
|
232
|
-
const previousBytecode = existingDeployment.bytecode;
|
|
233
|
-
const previousArgsData = existingDeployment.argsData;
|
|
234
|
-
const last2Bytes = previousBytecode.slice(-4);
|
|
235
|
-
const cborLength = parseInt(last2Bytes, 16);
|
|
236
|
-
const previousBytecodeWithoutCBOR = previousBytecode.slice(0, -cborLength * 2);
|
|
237
|
-
const newBytecodeWithoutCBOR = bytecode.slice(0, -cborLength * 2);
|
|
238
|
-
if (previousBytecodeWithoutCBOR === newBytecodeWithoutCBOR && previousArgsData === argsData) {
|
|
239
|
-
return { ...existingDeployment, updated: false };
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
const partialDeployment = {
|
|
243
|
-
...artifactToUse,
|
|
244
|
-
argsData,
|
|
245
|
-
linkedData: options?.linkedData
|
|
246
|
-
};
|
|
247
|
-
const signer = env.addressSigners[address];
|
|
248
|
-
const chainId = `0x${env.network.chain.id.toString(16)}`;
|
|
249
|
-
const maxFeePerGas = viemArgs.maxFeePerGas && `0x${viemArgs.maxFeePerGas.toString(16)}`;
|
|
250
|
-
const maxPriorityFeePerGas = viemArgs.maxPriorityFeePerGas && `0x${viemArgs.maxPriorityFeePerGas.toString(16)}`;
|
|
251
|
-
const params = [
|
|
252
|
-
{
|
|
253
|
-
type: "0x2",
|
|
254
|
-
from: address,
|
|
255
|
-
chainId,
|
|
256
|
-
data: calldata,
|
|
257
|
-
gas: viemArgs.gas && `0x${viemArgs.gas.toString(16)}`,
|
|
258
|
-
maxFeePerGas,
|
|
259
|
-
maxPriorityFeePerGas
|
|
260
|
-
// gasPrice: viemArgs.gasPrice && `0x${viemArgs.gasPrice.toString(16)}` as `0x${string}`,
|
|
261
|
-
// value: `0x${viemArgs.value?.toString(16)}` as `0x${string}`,
|
|
262
|
-
// nonce: viemArgs.nonce && (`0x${viemArgs.nonce.toString(16)}` as `0x${string}`),
|
|
263
|
-
}
|
|
264
|
-
];
|
|
265
|
-
let expectedAddress = void 0;
|
|
266
|
-
if (options?.deterministic) {
|
|
267
|
-
const deterministicFactoryAddress = `0x4e59b44847b379578588920ca78fbf26c0b4956c`;
|
|
268
|
-
const deterministicFactoryDeployerAddress = `0x3fab184622dc19b6109349b94811493bf2a45362`;
|
|
269
|
-
const factoryDeploymentData = `0xf8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222`;
|
|
270
|
-
const code = await env.network.provider.request({
|
|
271
|
-
method: "eth_getCode",
|
|
272
|
-
params: [deterministicFactoryAddress, "latest"]
|
|
273
|
-
});
|
|
274
|
-
if (code === "0x") {
|
|
275
|
-
const balanceHexString = await env.network.provider.request({
|
|
276
|
-
method: "eth_getBalance",
|
|
277
|
-
params: [deterministicFactoryDeployerAddress, "latest"]
|
|
278
|
-
});
|
|
279
|
-
const balance = BigInt(balanceHexString);
|
|
280
|
-
if (balance < 10000000000000000n) {
|
|
281
|
-
const need = 10000000000000000n - balance;
|
|
282
|
-
const balanceToSend = `0x${need.toString(16)}`;
|
|
283
|
-
const txHash3 = await broadcastTransaction(env, signer, [
|
|
284
|
-
{
|
|
285
|
-
type: "0x2",
|
|
286
|
-
chainId,
|
|
287
|
-
from: address,
|
|
288
|
-
to: deterministicFactoryDeployerAddress,
|
|
289
|
-
value: balanceToSend,
|
|
290
|
-
gas: `0x${BigInt(21e3).toString(16)}`,
|
|
291
|
-
maxFeePerGas,
|
|
292
|
-
maxPriorityFeePerGas
|
|
293
|
-
}
|
|
294
|
-
]);
|
|
295
|
-
await env.savePendingExecution({
|
|
296
|
-
type: "execution",
|
|
297
|
-
// TODO different type ?
|
|
298
|
-
transaction: { hash: txHash3, origin: address }
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
const txHash2 = await env.network.provider.request({
|
|
302
|
-
method: "eth_sendRawTransaction",
|
|
303
|
-
params: [factoryDeploymentData]
|
|
304
|
-
});
|
|
305
|
-
await env.savePendingExecution({
|
|
306
|
-
type: "execution",
|
|
307
|
-
// TODO different type ?
|
|
308
|
-
transaction: { hash: txHash2, origin: address }
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
const salt = typeof options.deterministic === "string" ? `0x${options.deterministic.slice(2).padStart(64, "0")}` : "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
312
|
-
const bytecode2 = params[0].data || "0x";
|
|
313
|
-
expectedAddress = "0x" + keccak256(`0xff${deterministicFactoryAddress.slice(2)}${salt.slice(2)}${keccak256(bytecode2).slice(2)}`).slice(
|
|
314
|
-
-40
|
|
315
|
-
);
|
|
316
|
-
const codeAlreadyDeployed = await env.network.provider.request({
|
|
317
|
-
method: "eth_getCode",
|
|
318
|
-
params: [expectedAddress, "latest"]
|
|
319
|
-
});
|
|
320
|
-
if (codeAlreadyDeployed !== "0x") {
|
|
321
|
-
env.showMessage(`contract was already deterministically deployed at ${expectedAddress}`);
|
|
322
|
-
const deployment2 = await env.save(name, {
|
|
323
|
-
address: expectedAddress,
|
|
324
|
-
...partialDeployment
|
|
325
|
-
});
|
|
326
|
-
return { ...deployment2, updated: true };
|
|
327
|
-
}
|
|
328
|
-
params[0].data = salt + (bytecode2.slice(2) || "");
|
|
329
|
-
params[0].to = deterministicFactoryAddress;
|
|
330
|
-
}
|
|
331
|
-
const txHash = await broadcastTransaction(env, signer, params);
|
|
332
|
-
const pendingDeployment = {
|
|
333
|
-
type: "deployment",
|
|
334
|
-
expectedAddress,
|
|
335
|
-
partialDeployment,
|
|
336
|
-
transaction: { hash: txHash, origin: address },
|
|
337
|
-
name
|
|
338
|
-
// TODO we should have the nonce, except for wallet like metamask where it is not usre you get the nonce you start with
|
|
339
|
-
};
|
|
340
|
-
const deployment = await env.savePendingDeployment(pendingDeployment);
|
|
341
|
-
return { ...deployment, updated: true };
|
|
342
|
-
}
|
|
343
|
-
env.deploy = deploy;
|
|
344
|
-
env.execute = execute;
|
|
345
|
-
env.executeByName = executeByName;
|
|
346
|
-
env.read = read;
|
|
347
|
-
env.readByName = readByName;
|
|
348
|
-
return env;
|
|
349
|
-
});
|
|
350
|
-
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["import {Abi} from 'abitype';\nimport {EIP1193DATA, EIP1193TransactionData} from 'eip-1193';\nimport type {\n\tArtifact,\n\tDeploymentConstruction,\n\tDeployment,\n\tEnvironment,\n\tPendingDeployment,\n\tPartialDeployment,\n\tPendingExecution,\n\tSigner,\n} from 'rocketh';\nimport {extendEnvironment} from 'rocketh';\nimport {\n\tAddress,\n\tChain,\n\tContractFunctionArgs,\n\tContractFunctionName,\n\tDecodeFunctionResultReturnType,\n\tEncodeDeployDataParameters,\n\tReadContractParameters,\n\tWriteContractParameters,\n\tdecodeFunctionResult,\n\tencodeFunctionData,\n\tencodePacked,\n\tkeccak256,\n} from 'viem';\nimport {DeployContractParameters, encodeDeployData} from 'viem';\nimport {logs} from 'named-logs';\n\nconst logger = logs('rocketh-deploy');\n\ndeclare module 'rocketh' {\n\tinterface Environment {\n\t\tdeploy: DeployFunction;\n\t\texecute: ExecuteFunction;\n\t\tread: ReadFunction;\n\t\texecuteByName: ExecuteFunctionByName;\n\t\treadByName: ReadFunctionByName;\n\t}\n}\n\nexport type DeployFunction = <TAbi extends Abi, TChain extends Chain = Chain>(\n\tname: string,\n\targs: DeploymentConstruction<TAbi>,\n\toptions?: DeployOptions\n) => Promise<Deployment<TAbi> & {updated: boolean}>;\n\nexport type ExecuteFunction = <\n\tTAbi extends Abi,\n\tTFunctionName extends ContractFunctionName<TAbi, 'nonpayable' | 'payable'>,\n\tTArgs extends ContractFunctionArgs<TAbi, 'nonpayable' | 'payable', TFunctionName> = ContractFunctionArgs<\n\t\tTAbi,\n\t\t'nonpayable' | 'payable',\n\t\tTFunctionName\n\t>\n>(\n\tdeployment: Deployment<TAbi>,\n\targs: ExecutionArgs<TAbi, TFunctionName, TArgs>\n) => Promise<EIP1193DATA>;\n\nexport type ExecuteFunctionByName = <\n\tTAbi extends Abi,\n\tTFunctionName extends ContractFunctionName<TAbi, 'nonpayable' | 'payable'>,\n\tTArgs extends ContractFunctionArgs<TAbi, 'nonpayable' | 'payable', TFunctionName> = ContractFunctionArgs<\n\t\tTAbi,\n\t\t'nonpayable' | 'payable',\n\t\tTFunctionName\n\t>\n>(\n\tname: string,\n\targs: ExecutionArgs<TAbi, TFunctionName, TArgs>\n) => Promise<EIP1193DATA>;\n\nexport type ReadFunction = <\n\tTAbi extends Abi,\n\tTFunctionName extends ContractFunctionName<TAbi, 'pure' | 'view'>,\n\tTArgs extends ContractFunctionArgs<TAbi, 'pure' | 'view', TFunctionName> = ContractFunctionArgs<\n\t\tTAbi,\n\t\t'pure' | 'view',\n\t\tTFunctionName\n\t>\n>(\n\tdeployment: Deployment<TAbi>,\n\targs: ReadingArgs<TAbi, TFunctionName, TArgs>\n) => Promise<DecodeFunctionResultReturnType<TAbi, TFunctionName>>;\n\nexport type ReadFunctionByName = <\n\tTAbi extends Abi,\n\tTFunctionName extends ContractFunctionName<TAbi, 'pure' | 'view'>,\n\tTArgs extends ContractFunctionArgs<TAbi, 'pure' | 'view', TFunctionName> = ContractFunctionArgs<\n\t\tTAbi,\n\t\t'pure' | 'view',\n\t\tTFunctionName\n\t>\n>(\n\tname: string,\n\targs: ReadingArgs<TAbi, TFunctionName, TArgs>\n) => Promise<DecodeFunctionResultReturnType<TAbi, TFunctionName>>;\n\nexport type ExecutionArgs<\n\tTAbi extends Abi,\n\tTFunctionName extends ContractFunctionName<TAbi, 'nonpayable' | 'payable'>,\n\tTArgs extends ContractFunctionArgs<TAbi, 'nonpayable' | 'payable', TFunctionName> = ContractFunctionArgs<\n\t\tTAbi,\n\t\t'nonpayable' | 'payable',\n\t\tTFunctionName\n\t>\n> = Omit<WriteContractParameters<TAbi, TFunctionName, TArgs>, 'address' | 'abi' | 'account' | 'nonce' | 'chain'> & {\n\taccount: string;\n};\n\nexport type ReadingArgs<\n\tTAbi extends Abi,\n\tTFunctionName extends ContractFunctionName<TAbi, 'pure' | 'view'>,\n\tTArgs extends ContractFunctionArgs<TAbi, 'pure' | 'view', TFunctionName> = ContractFunctionArgs<\n\t\tTAbi,\n\t\t'pure' | 'view',\n\t\tTFunctionName\n\t>\n> = Omit<ReadContractParameters<TAbi, TFunctionName, TArgs>, 'address' | 'abi' | 'account' | 'nonce'> & {\n\taccount?: string;\n};\n\nexport type DeployOptions = {\n\tlinkedData?: any;\n\tdeterministic?: boolean | `0x${string}`;\n\tlibraries?: {[name: string]: Address};\n} & (\n\t| {\n\t\t\tskipIfAlreadyDeployed?: boolean;\n\t }\n\t| {\n\t\t\talwaysOverride?: boolean;\n\t }\n);\n\nasync function broadcastTransaction(\n\tenv: Environment,\n\tsigner: Signer,\n\tparams: [EIP1193TransactionData]\n): Promise<`0x${string}`> {\n\tif (signer.type === 'wallet' || signer.type === 'remote') {\n\t\treturn signer.signer.request({\n\t\t\tmethod: 'eth_sendTransaction',\n\t\t\tparams,\n\t\t});\n\t} else {\n\t\tconst rawTx = await signer.signer.request({\n\t\t\tmethod: 'eth_signTransaction',\n\t\t\tparams,\n\t\t});\n\n\t\treturn env.network.provider.request({\n\t\t\tmethod: 'eth_sendRawTransaction',\n\t\t\tparams: [rawTx],\n\t\t});\n\t}\n}\n\nfunction linkRawLibrary(bytecode: string, libraryName: string, libraryAddress: string): string {\n\tconst address = libraryAddress.replace('0x', '');\n\tlet encodedLibraryName;\n\tif (libraryName.startsWith('$') && libraryName.endsWith('$')) {\n\t\tencodedLibraryName = libraryName.slice(1, libraryName.length - 1);\n\t} else {\n\t\tencodedLibraryName = keccak256(encodePacked(['string'], [libraryName])).slice(2, 36);\n\t}\n\tconst pattern = new RegExp(`_+\\\\$${encodedLibraryName}\\\\$_+`, 'g');\n\tif (!pattern.exec(bytecode)) {\n\t\tthrow new Error(`Can't link '${libraryName}' (${encodedLibraryName}) in \\n----\\n ${bytecode}\\n----\\n`);\n\t}\n\treturn bytecode.replace(pattern, address);\n}\n\nfunction linkRawLibraries(bytecode: string, libraries: {[libraryName: string]: Address}): string {\n\tfor (const libName of Object.keys(libraries)) {\n\t\tconst libAddress = libraries[libName];\n\t\tbytecode = linkRawLibrary(bytecode, libName, libAddress);\n\t}\n\treturn bytecode;\n}\n\nfunction linkLibraries(\n\tartifact: {\n\t\tbytecode: string;\n\t\tlinkReferences?: {\n\t\t\t[libraryFileName: string]: {\n\t\t\t\t[libraryName: string]: Array<{length: number; start: number}>;\n\t\t\t};\n\t\t};\n\t},\n\tlibraries?: {[libraryName: string]: Address}\n) {\n\tlet bytecode = artifact.bytecode;\n\n\tif (libraries) {\n\t\tif (artifact.linkReferences) {\n\t\t\tfor (const [fileName, fileReferences] of Object.entries(artifact.linkReferences)) {\n\t\t\t\tfor (const [libName, fixups] of Object.entries(fileReferences)) {\n\t\t\t\t\tconst addr = libraries[libName];\n\t\t\t\t\tif (addr === undefined) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tfor (const fixup of fixups) {\n\t\t\t\t\t\tbytecode =\n\t\t\t\t\t\t\tbytecode.substring(0, 2 + fixup.start * 2) +\n\t\t\t\t\t\t\taddr.substring(2) +\n\t\t\t\t\t\t\tbytecode.substring(2 + (fixup.start + fixup.length) * 2);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tbytecode = linkRawLibraries(bytecode, libraries);\n\t\t}\n\t}\n\n\t// TODO return libraries object with path name <filepath.sol>:<name> for names\n\n\treturn bytecode;\n}\n\nextendEnvironment((env: Environment) => {\n\tasync function execute<\n\t\tTAbi extends Abi,\n\t\tTFunctionName extends ContractFunctionName<TAbi, 'nonpayable' | 'payable'>,\n\t\tTArgs extends ContractFunctionArgs<TAbi, 'nonpayable' | 'payable', TFunctionName> = ContractFunctionArgs<\n\t\t\tTAbi,\n\t\t\t'nonpayable' | 'payable',\n\t\t\tTFunctionName\n\t\t>\n\t>(deployment: Deployment<TAbi>, args: ExecutionArgs<TAbi, TFunctionName, TArgs>) {\n\t\tconst {account, ...viemArgs} = args;\n\t\tlet address: `0x${string}`;\n\t\tif (account.startsWith('0x')) {\n\t\t\taddress = account as `0x${string}`;\n\t\t} else {\n\t\t\tif (env.namedAccounts) {\n\t\t\t\taddress = env.namedAccounts[account];\n\t\t\t\tif (!address) {\n\t\t\t\t\tthrow new Error(`no address for ${account}`);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthrow new Error(`no accounts setup, cannot get address for ${account}`);\n\t\t\t}\n\t\t}\n\n\t\tconst artifactToUse = deployment as unknown as Artifact<TAbi>;\n\t\tconst abi = artifactToUse.abi;\n\t\tconst calldata = encodeFunctionData<TAbi, TFunctionName>({\n\t\t\tabi,\n\t\t\tfunctionName: viemArgs.functionName,\n\t\t\targs: viemArgs.args,\n\t\t} as any);\n\n\t\tconst signer = env.addressSigners[address];\n\n\t\tconst txParam: EIP1193TransactionData = {\n\t\t\tto: deployment.address,\n\t\t\ttype: '0x2',\n\t\t\tfrom: address,\n\t\t\tchainId: `0x${env.network.chain.id.toString(16)}` as `0x${string}`,\n\t\t\tdata: calldata,\n\t\t\tgas: viemArgs.gas && (`0x${viemArgs.gas.toString(16)}` as `0x${string}`),\n\t\t\t// gasPrice: viemArgs.gasPrice && `0x${viemArgs.gasPrice.toString(16)}` as `0x${string}`,\n\t\t\tmaxFeePerGas: viemArgs.maxFeePerGas && (`0x${viemArgs.maxFeePerGas.toString(16)}` as `0x${string}`),\n\t\t\tmaxPriorityFeePerGas:\n\t\t\t\tviemArgs.maxPriorityFeePerGas && (`0x${viemArgs.maxPriorityFeePerGas.toString(16)}` as `0x${string}`),\n\t\t\t// nonce: viemArgs.nonce && (`0x${viemArgs.nonce.toString(16)}` as `0x${string}`),\n\t\t};\n\t\tif (viemArgs.value) {\n\t\t\ttxParam.value = `0x${viemArgs.value?.toString(16)}` as `0x${string}`;\n\t\t}\n\n\t\tlet txHash: `0x${string}`;\n\t\tif (signer.type === 'wallet' || signer.type === 'remote') {\n\t\t\ttxHash = await signer.signer.request({\n\t\t\t\tmethod: 'eth_sendTransaction',\n\t\t\t\tparams: [txParam],\n\t\t\t});\n\t\t} else {\n\t\t\tconst rawTx = await signer.signer.request({\n\t\t\t\tmethod: 'eth_signTransaction',\n\t\t\t\tparams: [txParam],\n\t\t\t});\n\n\t\t\ttxHash = await env.network.provider.request({\n\t\t\t\tmethod: 'eth_sendRawTransaction',\n\t\t\t\tparams: [rawTx],\n\t\t\t});\n\t\t}\n\n\t\tconst pendingExecution: PendingExecution = {\n\t\t\ttype: 'execution',\n\t\t\ttransaction: {hash: txHash, origin: address},\n\t\t\t// description, // TODO\n\t\t\t// TODO we should have the nonce, except for wallet like metamask where it is not usre you get the nonce you start with\n\t\t};\n\t\tawait env.savePendingExecution(pendingExecution);\n\t\treturn txHash;\n\t}\n\n\tasync function executeByName<\n\t\tTAbi extends Abi,\n\t\tTFunctionName extends ContractFunctionName<TAbi, 'nonpayable' | 'payable'>,\n\t\tTArgs extends ContractFunctionArgs<TAbi, 'nonpayable' | 'payable', TFunctionName> = ContractFunctionArgs<\n\t\t\tTAbi,\n\t\t\t'nonpayable' | 'payable',\n\t\t\tTFunctionName\n\t\t>\n\t>(name: string, args: ExecutionArgs<TAbi, TFunctionName, TArgs>) {\n\t\tconst deployment = env.getOrNull<TAbi>(name);\n\t\tif (!deployment) {\n\t\t\tthrow new Error(`no deployment named ${name}`);\n\t\t}\n\n\t\treturn execute(deployment, args);\n\t}\n\n\tasync function read<\n\t\tTAbi extends Abi,\n\t\tTFunctionName extends ContractFunctionName<TAbi, 'pure' | 'view'>,\n\t\tTArgs extends ContractFunctionArgs<TAbi, 'pure' | 'view', TFunctionName> = ContractFunctionArgs<\n\t\t\tTAbi,\n\t\t\t'pure' | 'view',\n\t\t\tTFunctionName\n\t\t>\n\t>(\n\t\tdeployment: Deployment<TAbi>,\n\t\targs: ReadingArgs<TAbi, TFunctionName, TArgs>\n\t): Promise<DecodeFunctionResultReturnType<TAbi, TFunctionName>> {\n\t\tconst {account, ...viemArgs} = args;\n\t\tlet address: `0x${string}` | undefined;\n\t\tif (account) {\n\t\t\tif (account.startsWith('0x')) {\n\t\t\t\taddress = account as `0x${string}`;\n\t\t\t} else {\n\t\t\t\tif (env.namedAccounts) {\n\t\t\t\t\taddress = env.namedAccounts[account];\n\t\t\t\t\tif (!address) {\n\t\t\t\t\t\tthrow new Error(`no address for ${account}`);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(`no accounts setup, cannot get address for ${account}`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst artifactToUse = deployment as unknown as Artifact<TAbi>;\n\t\tconst abi = artifactToUse.abi;\n\t\tconst calldata = encodeFunctionData<TAbi, TFunctionName>({\n\t\t\tabi,\n\t\t\tfunctionName: viemArgs.functionName,\n\t\t\targs: viemArgs.args,\n\t\t} as any);\n\n\t\tconst result: `0x${string}` = (await env.network.provider.request({\n\t\t\tmethod: 'eth_call',\n\t\t\tparams: [\n\t\t\t\t{\n\t\t\t\t\tto: deployment.address,\n\t\t\t\t\ttype: '0x2',\n\t\t\t\t\tfrom: address,\n\t\t\t\t\tchainId: `0x${env.network.chain.id.toString(16)}` as `0x${string}`,\n\t\t\t\t\tdata: calldata,\n\t\t\t\t\t// value: `0x${viemArgs.value?.toString(16)}` as `0x${string}`,\n\t\t\t\t},\n\t\t\t],\n\t\t})) as `0x${string}`;\n\n\t\tconst parsed = decodeFunctionResult<TAbi, TFunctionName>({\n\t\t\tabi,\n\t\t\tfunctionName: viemArgs.functionName,\n\t\t\tdata: result,\n\t\t\targs: viemArgs.args,\n\t\t} as any);\n\n\t\treturn parsed as DecodeFunctionResultReturnType<TAbi, TFunctionName>;\n\t}\n\n\tasync function readByName<\n\t\tTAbi extends Abi,\n\t\tTFunctionName extends ContractFunctionName<TAbi, 'pure' | 'view'>,\n\t\tTArgs extends ContractFunctionArgs<TAbi, 'pure' | 'view', TFunctionName> = ContractFunctionArgs<\n\t\t\tTAbi,\n\t\t\t'pure' | 'view',\n\t\t\tTFunctionName\n\t\t>\n\t>(\n\t\tname: string,\n\t\targs: ReadingArgs<TAbi, TFunctionName, TArgs>\n\t): Promise<DecodeFunctionResultReturnType<TAbi, TFunctionName>> {\n\t\tconst deployment = env.getOrNull<TAbi>(name);\n\t\tif (!deployment) {\n\t\t\tthrow new Error(`no deployment named ${name}`);\n\t\t}\n\n\t\treturn read(deployment, args);\n\t}\n\tasync function deploy<TAbi extends Abi>(\n\t\tname: string,\n\t\targs: DeploymentConstruction<TAbi>,\n\t\toptions?: DeployOptions\n\t): Promise<Deployment<TAbi> & {updated: boolean}> {\n\t\tconst skipIfAlreadyDeployed = options && 'skipIfAlreadyDeployed' in options && options.skipIfAlreadyDeployed;\n\t\tconst allwaysOverride = options && 'allwaysOverride' in options && options.allwaysOverride;\n\n\t\tif (allwaysOverride && skipIfAlreadyDeployed) {\n\t\t\tthrow new Error(`conflicting options: \"allwaysOverride\" and \"skipIfAlreadyDeployed\"`);\n\t\t}\n\n\t\tconst existingDeployment = env.getOrNull(name);\n\t\tif (existingDeployment && skipIfAlreadyDeployed) {\n\t\t\tlogger.info(`deployment for ${name} at ${existingDeployment.address}, skipIfAlreadyDeployed: true => we skip`);\n\t\t\treturn {...(existingDeployment as Deployment<TAbi>), updated: false};\n\t\t}\n\n\t\tconst {account, artifact, ...viemArgs} = args;\n\t\tlet address: `0x${string}`;\n\t\tif (account.startsWith('0x')) {\n\t\t\taddress = account as `0x${string}`;\n\t\t} else {\n\t\t\tif (env.namedAccounts) {\n\t\t\t\taddress = env.namedAccounts[account];\n\t\t\t\tif (!address) {\n\t\t\t\t\tthrow new Error(`no address for ${account}`);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthrow new Error(`no accounts setup, cannot get address for ${account}`);\n\t\t\t}\n\t\t}\n\n\t\t// TODO throw specific error if artifact not found\n\t\tconst artifactToUse = (typeof artifact === 'string' ? env.artifacts[artifact] : artifact) as Artifact<TAbi>;\n\n\t\tconst bytecode = linkLibraries(artifactToUse, options?.libraries);\n\n\t\tconst abi = artifactToUse.abi;\n\n\t\tconst argsToUse = {\n\t\t\t...viemArgs,\n\t\t\taccount,\n\t\t\tabi,\n\t\t\tbytecode,\n\t\t};\n\n\t\tconst calldata = encodeDeployData(argsToUse as any); // TODO any\n\t\tconst argsData = `0x${calldata.replace(bytecode, '')}` as `0x${string}`;\n\n\t\tif (existingDeployment) {\n\t\t\tlogger.info(`existing deployment for ${name} at ${existingDeployment.address}`);\n\t\t}\n\n\t\tif (existingDeployment && !allwaysOverride) {\n\t\t\tconst previousBytecode = existingDeployment.bytecode;\n\t\t\tconst previousArgsData = existingDeployment.argsData;\n\t\t\t// we assume cbor encoding of hash at the end\n\t\t\t// TODO option to remove it, can parse metadata but would rather avoid this here\n\t\t\tconst last2Bytes = previousBytecode.slice(-4);\n\t\t\tconst cborLength = parseInt(last2Bytes, 16);\n\t\t\tconst previousBytecodeWithoutCBOR = previousBytecode.slice(0, -cborLength * 2);\n\t\t\tconst newBytecodeWithoutCBOR = bytecode.slice(0, -cborLength * 2);\n\t\t\tif (previousBytecodeWithoutCBOR === newBytecodeWithoutCBOR && previousArgsData === argsData) {\n\t\t\t\treturn {...(existingDeployment as Deployment<TAbi>), updated: false};\n\t\t\t} else {\n\t\t\t\t// logger.info(`-------------- WITHOUT CBOR---------------------`);\n\t\t\t\t// logger.info(previousBytecodeWithoutCBOR);\n\t\t\t\t// logger.info(newBytecodeWithoutCBOR);\n\t\t\t\t// logger.info(`-----------------------------------`);\n\t\t\t\t// logger.info(`-------------- ARGS DATA ---------------------`);\n\t\t\t\t// logger.info(previousArgsData);\n\t\t\t\t// logger.info(argsData);\n\t\t\t\t// logger.info(`-----------------------------------`);\n\t\t\t}\n\t\t}\n\n\t\tconst partialDeployment: PartialDeployment<TAbi> = {\n\t\t\t...artifactToUse,\n\t\t\targsData,\n\t\t\tlinkedData: options?.linkedData,\n\t\t};\n\n\t\tconst signer = env.addressSigners[address];\n\n\t\tconst chainId = `0x${env.network.chain.id.toString(16)}` as `0x${string}`;\n\t\tconst maxFeePerGas = viemArgs.maxFeePerGas && (`0x${viemArgs.maxFeePerGas.toString(16)}` as `0x${string}`);\n\t\tconst maxPriorityFeePerGas =\n\t\t\tviemArgs.maxPriorityFeePerGas && (`0x${viemArgs.maxPriorityFeePerGas.toString(16)}` as `0x${string}`);\n\n\t\tconst params: [EIP1193TransactionData] = [\n\t\t\t{\n\t\t\t\ttype: '0x2',\n\t\t\t\tfrom: address,\n\t\t\t\tchainId,\n\t\t\t\tdata: calldata,\n\t\t\t\tgas: viemArgs.gas && (`0x${viemArgs.gas.toString(16)}` as `0x${string}`),\n\t\t\t\tmaxFeePerGas,\n\t\t\t\tmaxPriorityFeePerGas,\n\t\t\t\t// gasPrice: viemArgs.gasPrice && `0x${viemArgs.gasPrice.toString(16)}` as `0x${string}`,\n\t\t\t\t// value: `0x${viemArgs.value?.toString(16)}` as `0x${string}`,\n\t\t\t\t// nonce: viemArgs.nonce && (`0x${viemArgs.nonce.toString(16)}` as `0x${string}`),\n\t\t\t},\n\t\t];\n\n\t\tlet expectedAddress: `0x${string}` | undefined = undefined;\n\t\tif (options?.deterministic) {\n\t\t\t// TODO make these configurable\n\t\t\tconst deterministicFactoryAddress = `0x4e59b44847b379578588920ca78fbf26c0b4956c`;\n\t\t\tconst deterministicFactoryDeployerAddress = `0x3fab184622dc19b6109349b94811493bf2a45362`;\n\t\t\tconst factoryDeploymentData = `0xf8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222`;\n\n\t\t\tconst code = await env.network.provider.request({\n\t\t\t\tmethod: 'eth_getCode',\n\t\t\t\tparams: [deterministicFactoryAddress, 'latest'],\n\t\t\t});\n\t\t\tif (code === '0x') {\n\t\t\t\tconst balanceHexString = await env.network.provider.request({\n\t\t\t\t\tmethod: 'eth_getBalance',\n\t\t\t\t\tparams: [deterministicFactoryDeployerAddress, 'latest'],\n\t\t\t\t});\n\t\t\t\tconst balance = BigInt(balanceHexString);\n\t\t\t\tif (balance < 10000000000000000n) {\n\t\t\t\t\tconst need = 10000000000000000n - balance;\n\t\t\t\t\tconst balanceToSend = `0x${need.toString(16)}` as `0x${string}`;\n\t\t\t\t\tconst txHash = await broadcastTransaction(env, signer, [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: '0x2',\n\t\t\t\t\t\t\tchainId,\n\t\t\t\t\t\t\tfrom: address,\n\t\t\t\t\t\t\tto: deterministicFactoryDeployerAddress,\n\t\t\t\t\t\t\tvalue: balanceToSend,\n\t\t\t\t\t\t\tgas: `0x${BigInt(21000).toString(16)}`,\n\t\t\t\t\t\t\tmaxFeePerGas,\n\t\t\t\t\t\t\tmaxPriorityFeePerGas,\n\t\t\t\t\t\t},\n\t\t\t\t\t]);\n\t\t\t\t\tawait env.savePendingExecution({\n\t\t\t\t\t\ttype: 'execution', // TODO different type ?\n\t\t\t\t\t\ttransaction: {hash: txHash, origin: address},\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tconst txHash = await env.network.provider.request({\n\t\t\t\t\tmethod: 'eth_sendRawTransaction',\n\t\t\t\t\tparams: [factoryDeploymentData],\n\t\t\t\t});\n\t\t\t\tawait env.savePendingExecution({\n\t\t\t\t\ttype: 'execution', // TODO different type ?\n\t\t\t\t\ttransaction: {hash: txHash, origin: address},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// prepending the salt\n\t\t\tconst salt = (\n\t\t\t\ttypeof options.deterministic === 'string'\n\t\t\t\t\t? `0x${options.deterministic.slice(2).padStart(64, '0')}`\n\t\t\t\t\t: '0x0000000000000000000000000000000000000000000000000000000000000000'\n\t\t\t) as `0x${string}`;\n\n\t\t\tconst bytecode = params[0].data || '0x';\n\n\t\t\texpectedAddress = ('0x' +\n\t\t\t\tkeccak256(`0xff${deterministicFactoryAddress.slice(2)}${salt.slice(2)}${keccak256(bytecode).slice(2)}`).slice(\n\t\t\t\t\t-40\n\t\t\t\t)) as `0x${string}`;\n\n\t\t\tconst codeAlreadyDeployed = await env.network.provider.request({\n\t\t\t\tmethod: 'eth_getCode',\n\t\t\t\tparams: [expectedAddress, 'latest'],\n\t\t\t});\n\n\t\t\tif (codeAlreadyDeployed !== '0x') {\n\t\t\t\tenv.showMessage(`contract was already deterministically deployed at ${expectedAddress}`);\n\t\t\t\tconst deployment = await env.save(name, {\n\t\t\t\t\taddress: expectedAddress,\n\t\t\t\t\t...partialDeployment,\n\t\t\t\t});\n\t\t\t\treturn {...(deployment as Deployment<TAbi>), updated: true};\n\t\t\t}\n\n\t\t\tparams[0].data = (salt + (bytecode.slice(2) || '')) as `0x${string}`;\n\t\t\tparams[0].to = deterministicFactoryAddress;\n\t\t}\n\n\t\tconst txHash = await broadcastTransaction(env, signer, params);\n\n\t\tconst pendingDeployment: PendingDeployment<TAbi> = {\n\t\t\ttype: 'deployment',\n\t\t\texpectedAddress,\n\t\t\tpartialDeployment,\n\t\t\ttransaction: {hash: txHash, origin: address},\n\t\t\tname,\n\t\t\t// TODO we should have the nonce, except for wallet like metamask where it is not usre you get the nonce you start with\n\t\t};\n\t\tconst deployment = await env.savePendingDeployment(pendingDeployment);\n\t\treturn {...(deployment as Deployment<TAbi>), updated: true};\n\t}\n\n\tenv.deploy = deploy;\n\tenv.execute = execute;\n\tenv.executeByName = executeByName;\n\tenv.read = read;\n\tenv.readByName = readByName;\n\treturn env;\n});\n"],"names":[],"mappings":";;;;AAUA,MAAM,MAAM,GAAG,IAAI,CAAC,gBAAgB,CAAC,CAAC;AACtC,eAAe,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE;AACzD,EAAE,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE;AAC5D,IAAI,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;AACjC,MAAM,MAAM,EAAE,qBAAqB;AACnC,MAAM,MAAM;AACZ,KAAK,CAAC,CAAC;AACP,GAAG,MAAM;AACT,IAAI,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;AAC9C,MAAM,MAAM,EAAE,qBAAqB;AACnC,MAAM,MAAM;AACZ,KAAK,CAAC,CAAC;AACP,IAAI,OAAO,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;AACxC,MAAM,MAAM,EAAE,wBAAwB;AACtC,MAAM,MAAM,EAAE,CAAC,KAAK,CAAC;AACrB,KAAK,CAAC,CAAC;AACP,GAAG;AACH,CAAC;AACD,SAAS,cAAc,CAAC,QAAQ,EAAE,WAAW,EAAE,cAAc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