@bananapus/nana-sdk-core 2.5.1 → 2.7.0
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/dist/cjs/jbcenter/decode.d.ts +49 -0
- package/dist/cjs/jbcenter/decode.d.ts.map +1 -0
- package/dist/cjs/jbcenter/decode.js +154 -0
- package/dist/cjs/jbcenter/decode.js.map +1 -0
- package/dist/cjs/jbcenter/ensureDeployed.d.ts +29 -0
- package/dist/cjs/jbcenter/ensureDeployed.d.ts.map +1 -0
- package/dist/cjs/jbcenter/ensureDeployed.js +166 -0
- package/dist/cjs/jbcenter/ensureDeployed.js.map +1 -0
- package/dist/cjs/jbcenter/merge.d.ts +21 -0
- package/dist/cjs/jbcenter/merge.d.ts.map +1 -0
- package/dist/cjs/jbcenter/merge.js +51 -0
- package/dist/cjs/jbcenter/merge.js.map +1 -0
- package/dist/cjs/jbcenter.d.ts +21 -0
- package/dist/cjs/jbcenter.d.ts.map +1 -1
- package/dist/cjs/jbcenter.js +56 -3
- package/dist/cjs/jbcenter.js.map +1 -1
- package/dist/cjs/safe.d.ts +208 -0
- package/dist/cjs/safe.d.ts.map +1 -0
- package/dist/cjs/safe.js +396 -0
- package/dist/cjs/safe.js.map +1 -0
- package/dist/esm/jbcenter/decode.d.ts +49 -0
- package/dist/esm/jbcenter/decode.d.ts.map +1 -0
- package/dist/esm/jbcenter/decode.js +151 -0
- package/dist/esm/jbcenter/decode.js.map +1 -0
- package/dist/esm/jbcenter/ensureDeployed.d.ts +29 -0
- package/dist/esm/jbcenter/ensureDeployed.d.ts.map +1 -0
- package/dist/esm/jbcenter/ensureDeployed.js +161 -0
- package/dist/esm/jbcenter/ensureDeployed.js.map +1 -0
- package/dist/esm/jbcenter/merge.d.ts +21 -0
- package/dist/esm/jbcenter/merge.d.ts.map +1 -0
- package/dist/esm/jbcenter/merge.js +44 -0
- package/dist/esm/jbcenter/merge.js.map +1 -0
- package/dist/esm/jbcenter.d.ts +21 -0
- package/dist/esm/jbcenter.d.ts.map +1 -1
- package/dist/esm/jbcenter.js +46 -2
- package/dist/esm/jbcenter.js.map +1 -1
- package/dist/esm/safe.d.ts +208 -0
- package/dist/esm/safe.d.ts.map +1 -0
- package/dist/esm/safe.js +381 -0
- package/dist/esm/safe.js.map +1 -0
- package/package.json +6 -1
package/dist/cjs/safe.js
ADDED
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CREATE_BATCH_ABI = exports.SAFE_CREATE_ABI = exports.MAX_SAFE_OWNERS = exports.MULTICALL3 = exports.SAFE_FALLBACK = exports.SAFE_SINGLETON = exports.SAFE_FACTORY = void 0;
|
|
4
|
+
exports.buildSafeInitializer = buildSafeInitializer;
|
|
5
|
+
exports.predictSafeAddress = predictSafeAddress;
|
|
6
|
+
exports.validateSafeDeploymentPlan = validateSafeDeploymentPlan;
|
|
7
|
+
exports.readSafeCreationCode = readSafeCreationCode;
|
|
8
|
+
exports.resolveSafeAddress = resolveSafeAddress;
|
|
9
|
+
exports.verifySafeDeployments = verifySafeDeployments;
|
|
10
|
+
exports.checkSafeDeployments = checkSafeDeployments;
|
|
11
|
+
exports.buildSafeDeploymentCalls = buildSafeDeploymentCalls;
|
|
12
|
+
exports.buildSafeDeploymentTx = buildSafeDeploymentTx;
|
|
13
|
+
exports.bundleSafeLaunch = bundleSafeLaunch;
|
|
14
|
+
exports.unbundleSafeLaunch = unbundleSafeLaunch;
|
|
15
|
+
exports.verifySafeLaunchSimulation = verifySafeLaunchSimulation;
|
|
16
|
+
const viem_1 = require("viem");
|
|
17
|
+
// Canonical Safe 1.4.1 deployments, from safe-global/safe-deployments.
|
|
18
|
+
// A fixed singleton and initializer preserve CREATE2 addresses across chains.
|
|
19
|
+
exports.SAFE_FACTORY = (0, viem_1.getAddress)("0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67");
|
|
20
|
+
exports.SAFE_SINGLETON = (0, viem_1.getAddress)("0x41675C099F32341bf84BFc5382aF534df5C7461a");
|
|
21
|
+
exports.SAFE_FALLBACK = (0, viem_1.getAddress)("0xfd0732Dc9E303f09fCEf3a7388Ad10A83459Ec99");
|
|
22
|
+
exports.MULTICALL3 = (0, viem_1.getAddress)("0xcA11bde05977b3631167028862bE2a173976CA11");
|
|
23
|
+
exports.MAX_SAFE_OWNERS = 50;
|
|
24
|
+
const contracts = [
|
|
25
|
+
[
|
|
26
|
+
exports.SAFE_FACTORY,
|
|
27
|
+
"0x50c3cdc4074750a7a974204a716c999edd37482f907608d960b2b025ee0b3317",
|
|
28
|
+
],
|
|
29
|
+
[
|
|
30
|
+
exports.SAFE_SINGLETON,
|
|
31
|
+
"0x1fe2df852ba3299d6534ef416eefa406e56ced995bca886ab7a553e6d0c5e1c4",
|
|
32
|
+
],
|
|
33
|
+
[
|
|
34
|
+
exports.SAFE_FALLBACK,
|
|
35
|
+
"0x7c6007a5d711cea8dfd5d91f5940ec29c7f200fe511eb1fc1397b367af3c42f9",
|
|
36
|
+
],
|
|
37
|
+
];
|
|
38
|
+
const PROXY_CODE_HASH = "0xd7d408ebcd99b2b70be43e20253d6d92a8ea8fab29bd3be7f55b10032331fb4c";
|
|
39
|
+
const SENTINEL = "0x0000000000000000000000000000000000000001";
|
|
40
|
+
const SINGLETON_SLOT = (0, viem_1.toHex)(0n, { size: 32 });
|
|
41
|
+
const GUARD_SLOT = "0x4a204f620c8c5ccdca3fd54d003badd85ba500436a431f0cbda4f558c93c34c8";
|
|
42
|
+
const FALLBACK_SLOT = "0x6c9a6c4a39284e37ed1cf53d337577d14212a4870fb976a4366c693b939918d5";
|
|
43
|
+
exports.SAFE_CREATE_ABI = (0, viem_1.parseAbi)([
|
|
44
|
+
"function proxyCreationCode() pure returns (bytes)",
|
|
45
|
+
"function createProxyWithNonce(address singleton, bytes initializer, uint256 saltNonce) returns (address proxy)",
|
|
46
|
+
"function setup(address[] owners,uint256 threshold,address to,bytes data,address fallbackHandler,address paymentToken,uint256 payment,address paymentReceiver)",
|
|
47
|
+
]);
|
|
48
|
+
exports.CREATE_BATCH_ABI = (0, viem_1.parseAbi)([
|
|
49
|
+
"function aggregate3Value((address target,bool allowFailure,uint256 value,bytes callData)[] calls) payable returns ((bool success,bytes returnData)[] returnData)",
|
|
50
|
+
]);
|
|
51
|
+
const READ_ABI = (0, viem_1.parseAbi)([
|
|
52
|
+
"function masterCopy() view returns (address)",
|
|
53
|
+
"function VERSION() view returns (string)",
|
|
54
|
+
"function getThreshold() view returns (uint256)",
|
|
55
|
+
"function getOwners() view returns (address[])",
|
|
56
|
+
"function getModulesPaginated(address start,uint256 pageSize) view returns (address[],address)",
|
|
57
|
+
]);
|
|
58
|
+
function validAddress(address) {
|
|
59
|
+
return (0, viem_1.isAddress)(address) && BigInt(address) > 1n;
|
|
60
|
+
}
|
|
61
|
+
/** Plain Safe only: no delegatecall hook, modules, guard, or setup payments. */
|
|
62
|
+
function buildSafeInitializer(policy) {
|
|
63
|
+
if (!Array.isArray(policy.owners) ||
|
|
64
|
+
policy.owners.length < 1 ||
|
|
65
|
+
policy.owners.length > exports.MAX_SAFE_OWNERS ||
|
|
66
|
+
policy.owners.some((owner) => !validAddress(owner)) ||
|
|
67
|
+
new Set(policy.owners.map((owner) => owner.toLowerCase())).size !==
|
|
68
|
+
policy.owners.length)
|
|
69
|
+
throw new Error("A Safe needs 1–50 unique nonzero, nonsentinel owner addresses.");
|
|
70
|
+
if (!Number.isInteger(policy.threshold) ||
|
|
71
|
+
policy.threshold < 1 ||
|
|
72
|
+
policy.threshold > policy.owners.length) {
|
|
73
|
+
throw new Error("Invalid Safe approval policy.");
|
|
74
|
+
}
|
|
75
|
+
return (0, viem_1.encodeFunctionData)({
|
|
76
|
+
abi: exports.SAFE_CREATE_ABI,
|
|
77
|
+
functionName: "setup",
|
|
78
|
+
args: [
|
|
79
|
+
policy.owners,
|
|
80
|
+
BigInt(policy.threshold),
|
|
81
|
+
viem_1.zeroAddress,
|
|
82
|
+
"0x",
|
|
83
|
+
exports.SAFE_FALLBACK,
|
|
84
|
+
viem_1.zeroAddress,
|
|
85
|
+
0n,
|
|
86
|
+
viem_1.zeroAddress,
|
|
87
|
+
],
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/** Owner order and the original 32-byte salt are part of the deterministic address. */
|
|
91
|
+
function predictSafeAddress(plan) {
|
|
92
|
+
if (!/^0x[\da-f]{64}$/i.test(plan.saltNonce) ||
|
|
93
|
+
!/^0x(?:[\da-f]{2}){1,2048}$/i.test(plan.proxyCreationCode)) {
|
|
94
|
+
throw new Error("Invalid Safe deployment record.");
|
|
95
|
+
}
|
|
96
|
+
const salt = (0, viem_1.keccak256)((0, viem_1.encodePacked)(["bytes32", "uint256"], [(0, viem_1.keccak256)(buildSafeInitializer(plan)), BigInt(plan.saltNonce)]));
|
|
97
|
+
return (0, viem_1.getContractAddress)({
|
|
98
|
+
opcode: "CREATE2",
|
|
99
|
+
from: exports.SAFE_FACTORY,
|
|
100
|
+
salt,
|
|
101
|
+
bytecode: (0, viem_1.concatHex)([
|
|
102
|
+
plan.proxyCreationCode,
|
|
103
|
+
(0, viem_1.toHex)(BigInt(exports.SAFE_SINGLETON), { size: 32 }),
|
|
104
|
+
]),
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
function validateSafeDeploymentPlan(plan) {
|
|
108
|
+
if (!validAddress(plan.address) ||
|
|
109
|
+
!(0, viem_1.isAddressEqual)(predictSafeAddress(plan), plan.address)) {
|
|
110
|
+
throw new Error("The Safe address differs from its saved owners and policy.");
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function validatePlans(plans) {
|
|
114
|
+
if (!Array.isArray(plans))
|
|
115
|
+
throw new Error("Invalid Safe deployment plans.");
|
|
116
|
+
plans.forEach(validateSafeDeploymentPlan);
|
|
117
|
+
if (new Set(plans.map((plan) => plan.address.toLowerCase())).size !==
|
|
118
|
+
plans.length) {
|
|
119
|
+
throw new Error("Duplicate Safe deployment plans.");
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function codeMatches(code, hash) {
|
|
123
|
+
return (typeof code === "string" &&
|
|
124
|
+
/^0x(?:[\da-f]{2}){1,24576}$/i.test(code) &&
|
|
125
|
+
(0, viem_1.keccak256)(code) === hash);
|
|
126
|
+
}
|
|
127
|
+
/** Check canonical dependencies before trusting factory-returned creation code. */
|
|
128
|
+
async function readSafeCreationCode(client) {
|
|
129
|
+
await Promise.all(contracts.map(async ([address, hash]) => {
|
|
130
|
+
if (!codeMatches(await client.getCode({ address }), hash)) {
|
|
131
|
+
throw new Error(`The canonical Safe 1.4.1 contract is unavailable at ${address}.`);
|
|
132
|
+
}
|
|
133
|
+
}));
|
|
134
|
+
const proxyCreationCode = await client.readContract({
|
|
135
|
+
address: exports.SAFE_FACTORY,
|
|
136
|
+
abi: exports.SAFE_CREATE_ABI,
|
|
137
|
+
functionName: "proxyCreationCode",
|
|
138
|
+
});
|
|
139
|
+
if (!/^0x(?:[\da-f]{2}){1,2048}$/i.test(proxyCreationCode))
|
|
140
|
+
throw new Error("Invalid Safe proxy creation code.");
|
|
141
|
+
return proxyCreationCode;
|
|
142
|
+
}
|
|
143
|
+
/** Existing inputs are address-only: this does not certify an arbitrary address as a Safe. */
|
|
144
|
+
async function resolveSafeAddress(input, clients) {
|
|
145
|
+
if (input.kind === "existing") {
|
|
146
|
+
if (!validAddress(input.address))
|
|
147
|
+
throw new Error("Enter a valid existing Safe address.");
|
|
148
|
+
return { address: (0, viem_1.getAddress)(input.address) };
|
|
149
|
+
}
|
|
150
|
+
if (input.kind !== "create")
|
|
151
|
+
throw new Error("Invalid Safe address input.");
|
|
152
|
+
// Validate local inputs before any network request.
|
|
153
|
+
buildSafeInitializer(input);
|
|
154
|
+
if (!/^0x[\da-f]{64}$/i.test(input.saltNonce))
|
|
155
|
+
throw new Error("Invalid Safe deployment salt.");
|
|
156
|
+
if (!clients.length)
|
|
157
|
+
throw new Error("Select at least one network to create a Safe.");
|
|
158
|
+
const codes = await Promise.all(clients.map(readSafeCreationCode));
|
|
159
|
+
if (codes.some((code) => code.toLowerCase() !== codes[0].toLowerCase()))
|
|
160
|
+
throw new Error("Safe creation code differs across the selected networks.");
|
|
161
|
+
const policy = {
|
|
162
|
+
owners: input.owners.map((owner) => (0, viem_1.getAddress)(owner)),
|
|
163
|
+
threshold: input.threshold,
|
|
164
|
+
saltNonce: input.saltNonce,
|
|
165
|
+
proxyCreationCode: codes[0],
|
|
166
|
+
};
|
|
167
|
+
const plan = { ...policy, address: predictSafeAddress(policy) };
|
|
168
|
+
return { address: plan.address, plan };
|
|
169
|
+
}
|
|
170
|
+
async function boundedCall(client, address, data, gas, maxBytes, blockNumber) {
|
|
171
|
+
// Raw RPC cannot follow a contract-selected CCIP/OffchainLookup URL.
|
|
172
|
+
const result = await client.request({
|
|
173
|
+
method: "eth_call",
|
|
174
|
+
params: [
|
|
175
|
+
{ to: address, data, gas: (0, viem_1.toHex)(gas) },
|
|
176
|
+
blockNumber === undefined ? "latest" : (0, viem_1.toHex)(blockNumber),
|
|
177
|
+
],
|
|
178
|
+
});
|
|
179
|
+
if (typeof result !== "string" ||
|
|
180
|
+
!/^0x(?:[\da-f]{2})*$/i.test(result) ||
|
|
181
|
+
result.length > 2 + maxBytes * 2) {
|
|
182
|
+
throw new Error("Invalid or oversized Safe policy response.");
|
|
183
|
+
}
|
|
184
|
+
return result;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Certify this module's plain Safe profile, failing closed on malformed state or RPC errors.
|
|
188
|
+
* Receipt recovery pins every code, storage, and raw policy read to blockNumber.
|
|
189
|
+
* Contract signers are supported; this verifies their membership, not their own policy.
|
|
190
|
+
*/
|
|
191
|
+
async function verifySafeDeployments(client, plans, options = {}) {
|
|
192
|
+
validatePlans(plans);
|
|
193
|
+
const { blockNumber, allowMissing = false } = options;
|
|
194
|
+
if (blockNumber !== undefined && blockNumber < 0n)
|
|
195
|
+
throw new Error("Invalid Safe verification block.");
|
|
196
|
+
let complete = true;
|
|
197
|
+
for (const plan of plans) {
|
|
198
|
+
const code = await client.getCode({ address: plan.address, blockNumber });
|
|
199
|
+
if (allowMissing && (code === undefined || code === "0x")) {
|
|
200
|
+
complete = false;
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
const mismatch = () => new Error(`The Safe at ${plan.address} does not match its reviewed owners and policy.`);
|
|
204
|
+
if (!codeMatches(code, PROXY_CODE_HASH))
|
|
205
|
+
throw mismatch();
|
|
206
|
+
const singleton = await client.getStorageAt({
|
|
207
|
+
address: plan.address,
|
|
208
|
+
slot: SINGLETON_SLOT,
|
|
209
|
+
blockNumber,
|
|
210
|
+
});
|
|
211
|
+
if (singleton?.toLowerCase() !==
|
|
212
|
+
(0, viem_1.toHex)(BigInt(exports.SAFE_SINGLETON), { size: 32 }).toLowerCase())
|
|
213
|
+
throw mismatch();
|
|
214
|
+
// Do not delegate through a claimed implementation before checking its exact runtime.
|
|
215
|
+
for (const [address, hash] of contracts.slice(1)) {
|
|
216
|
+
if (!codeMatches(await client.getCode({ address, blockNumber }), hash))
|
|
217
|
+
throw mismatch();
|
|
218
|
+
}
|
|
219
|
+
const call = (data, maxBytes, gas = 100000n) => boundedCall(client, plan.address, data, gas, maxBytes, blockNumber);
|
|
220
|
+
const [masterCopy, version, threshold, ownersData, modules, guard, fallback,] = await Promise.all([
|
|
221
|
+
call((0, viem_1.encodeFunctionData)({ abi: READ_ABI, functionName: "masterCopy" }), 32),
|
|
222
|
+
call((0, viem_1.encodeFunctionData)({ abi: READ_ABI, functionName: "VERSION" }), 96),
|
|
223
|
+
call((0, viem_1.encodeFunctionData)({ abi: READ_ABI, functionName: "getThreshold" }), 32),
|
|
224
|
+
call((0, viem_1.encodeFunctionData)({ abi: READ_ABI, functionName: "getOwners" }), 64 + exports.MAX_SAFE_OWNERS * 32, 400000n),
|
|
225
|
+
call((0, viem_1.encodeFunctionData)({
|
|
226
|
+
abi: READ_ABI,
|
|
227
|
+
functionName: "getModulesPaginated",
|
|
228
|
+
args: [SENTINEL, 1n],
|
|
229
|
+
}), 128, 500000n),
|
|
230
|
+
client.getStorageAt({
|
|
231
|
+
address: plan.address,
|
|
232
|
+
slot: GUARD_SLOT,
|
|
233
|
+
blockNumber,
|
|
234
|
+
}),
|
|
235
|
+
client.getStorageAt({
|
|
236
|
+
address: plan.address,
|
|
237
|
+
slot: FALLBACK_SLOT,
|
|
238
|
+
blockNumber,
|
|
239
|
+
}),
|
|
240
|
+
]);
|
|
241
|
+
if (masterCopy.toLowerCase() !==
|
|
242
|
+
(0, viem_1.toHex)(BigInt(exports.SAFE_SINGLETON), { size: 32 }).toLowerCase() ||
|
|
243
|
+
version.toLowerCase() !==
|
|
244
|
+
(0, viem_1.encodeFunctionResult)({
|
|
245
|
+
abi: READ_ABI,
|
|
246
|
+
functionName: "VERSION",
|
|
247
|
+
result: "1.4.1",
|
|
248
|
+
}).toLowerCase() ||
|
|
249
|
+
threshold.toLowerCase() !==
|
|
250
|
+
(0, viem_1.toHex)(BigInt(plan.threshold), { size: 32 }).toLowerCase() ||
|
|
251
|
+
modules.toLowerCase() !==
|
|
252
|
+
(0, viem_1.encodeFunctionResult)({
|
|
253
|
+
abi: READ_ABI,
|
|
254
|
+
functionName: "getModulesPaginated",
|
|
255
|
+
result: [[], SENTINEL],
|
|
256
|
+
}).toLowerCase() ||
|
|
257
|
+
guard?.toLowerCase() !== (0, viem_1.toHex)(0n, { size: 32 }) ||
|
|
258
|
+
fallback?.toLowerCase() !==
|
|
259
|
+
(0, viem_1.toHex)(BigInt(exports.SAFE_FALLBACK), { size: 32 }).toLowerCase() ||
|
|
260
|
+
ownersData.length !== 2 + (64 + plan.owners.length * 32) * 2 ||
|
|
261
|
+
ownersData.slice(2, 66).toLowerCase() !==
|
|
262
|
+
(0, viem_1.toHex)(32n, { size: 32 }).slice(2) ||
|
|
263
|
+
ownersData.slice(66, 130).toLowerCase() !==
|
|
264
|
+
(0, viem_1.toHex)(BigInt(plan.owners.length), { size: 32 }).slice(2))
|
|
265
|
+
throw mismatch();
|
|
266
|
+
const owners = (0, viem_1.decodeFunctionResult)({
|
|
267
|
+
abi: READ_ABI,
|
|
268
|
+
functionName: "getOwners",
|
|
269
|
+
data: ownersData,
|
|
270
|
+
});
|
|
271
|
+
if (new Set(owners.map((owner) => owner.toLowerCase())).size !==
|
|
272
|
+
plan.owners.length ||
|
|
273
|
+
plan.owners.some((owner) => !owners.some((actual) => (0, viem_1.isAddressEqual)(actual, owner))))
|
|
274
|
+
throw mismatch();
|
|
275
|
+
}
|
|
276
|
+
return complete;
|
|
277
|
+
}
|
|
278
|
+
async function checkSafeDeployments(client, plans = []) {
|
|
279
|
+
if (!plans.length)
|
|
280
|
+
return;
|
|
281
|
+
validatePlans(plans);
|
|
282
|
+
const code = await readSafeCreationCode(client);
|
|
283
|
+
if (plans.some((plan) => plan.proxyCreationCode.toLowerCase() !== code.toLowerCase()))
|
|
284
|
+
throw new Error("The saved Safe creation code changed.");
|
|
285
|
+
await verifySafeDeployments(client, plans, { allowMissing: true });
|
|
286
|
+
}
|
|
287
|
+
/** Optional factory calls are idempotent only with preflight, simulation, and receipt verification. */
|
|
288
|
+
function buildSafeDeploymentCalls(plans) {
|
|
289
|
+
validatePlans(plans);
|
|
290
|
+
return plans.map((plan) => ({
|
|
291
|
+
target: exports.SAFE_FACTORY,
|
|
292
|
+
allowFailure: true,
|
|
293
|
+
value: 0n,
|
|
294
|
+
callData: (0, viem_1.encodeFunctionData)({
|
|
295
|
+
abi: exports.SAFE_CREATE_ABI,
|
|
296
|
+
functionName: "createProxyWithNonce",
|
|
297
|
+
args: [
|
|
298
|
+
exports.SAFE_SINGLETON,
|
|
299
|
+
buildSafeInitializer(plan),
|
|
300
|
+
BigInt(plan.saltNonce),
|
|
301
|
+
],
|
|
302
|
+
}),
|
|
303
|
+
}));
|
|
304
|
+
}
|
|
305
|
+
function buildSafeDeploymentTx(chainId, plans) {
|
|
306
|
+
if (!Number.isSafeInteger(chainId) || chainId <= 0)
|
|
307
|
+
throw new Error("Invalid Safe deployment chain.");
|
|
308
|
+
return {
|
|
309
|
+
chainId,
|
|
310
|
+
address: exports.MULTICALL3,
|
|
311
|
+
abi: exports.CREATE_BATCH_ABI,
|
|
312
|
+
functionName: "aggregate3Value",
|
|
313
|
+
args: [buildSafeDeploymentCalls(plans)],
|
|
314
|
+
value: 0n,
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Multicall3 changes msg.sender. Use only a sender-independent or already authenticated
|
|
319
|
+
* forwarded launch. This helper cannot decide the launch contract's authorization semantics.
|
|
320
|
+
* Simulate the returned call, verifySafeLaunchSimulation, then verify receipt-block state.
|
|
321
|
+
*/
|
|
322
|
+
function bundleSafeLaunch(call, plans = []) {
|
|
323
|
+
if (!plans.length)
|
|
324
|
+
return call;
|
|
325
|
+
if (!validAddress(call.to) ||
|
|
326
|
+
!/^0x(?:[\da-f]{2})*$/i.test(call.data) ||
|
|
327
|
+
typeof call.value !== "bigint" ||
|
|
328
|
+
call.value < 0n)
|
|
329
|
+
throw new Error("Invalid Safe launch call.");
|
|
330
|
+
const calls = [
|
|
331
|
+
...buildSafeDeploymentCalls(plans),
|
|
332
|
+
{
|
|
333
|
+
target: call.to,
|
|
334
|
+
allowFailure: false,
|
|
335
|
+
value: call.value,
|
|
336
|
+
callData: call.data,
|
|
337
|
+
},
|
|
338
|
+
];
|
|
339
|
+
return {
|
|
340
|
+
to: exports.MULTICALL3,
|
|
341
|
+
value: call.value,
|
|
342
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
343
|
+
abi: exports.CREATE_BATCH_ABI,
|
|
344
|
+
functionName: "aggregate3Value",
|
|
345
|
+
args: [calls],
|
|
346
|
+
}),
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
/** Require the exact reviewed factory calls, their order, one mandatory launch, and its value. */
|
|
350
|
+
function unbundleSafeLaunch(call, plans = []) {
|
|
351
|
+
if (!plans.length)
|
|
352
|
+
return call;
|
|
353
|
+
if (!(0, viem_1.isAddressEqual)(call.to, exports.MULTICALL3))
|
|
354
|
+
throw new Error("The saved Safe launch is not a creation batch.");
|
|
355
|
+
const { args } = (0, viem_1.decodeFunctionData)({
|
|
356
|
+
abi: exports.CREATE_BATCH_ABI,
|
|
357
|
+
data: call.data,
|
|
358
|
+
});
|
|
359
|
+
const last = args[0][args[0].length - 1];
|
|
360
|
+
if (!last)
|
|
361
|
+
throw new Error("The saved creation batch is empty.");
|
|
362
|
+
const inner = { to: last.target, data: last.callData, value: call.value };
|
|
363
|
+
if (bundleSafeLaunch(inner, plans).data.toLowerCase() !==
|
|
364
|
+
call.data.toLowerCase())
|
|
365
|
+
throw new Error("The saved creation batch differs from its reviewed Safes and launch.");
|
|
366
|
+
return inner;
|
|
367
|
+
}
|
|
368
|
+
/** Outer simulation success is insufficient: an optional deployment may have failed. */
|
|
369
|
+
async function verifySafeLaunchSimulation(client, plans = [], data) {
|
|
370
|
+
if (!plans.length)
|
|
371
|
+
return;
|
|
372
|
+
validatePlans(plans);
|
|
373
|
+
if (!data)
|
|
374
|
+
throw new Error("The Safe creation simulation returned no results.");
|
|
375
|
+
const results = (0, viem_1.decodeFunctionResult)({
|
|
376
|
+
abi: exports.CREATE_BATCH_ABI,
|
|
377
|
+
functionName: "aggregate3Value",
|
|
378
|
+
data,
|
|
379
|
+
});
|
|
380
|
+
if (results.length !== plans.length + 1 ||
|
|
381
|
+
!results[results.length - 1].success)
|
|
382
|
+
throw new Error("The creation batch did not simulate every required call.");
|
|
383
|
+
for (const [index, plan] of plans.entries()) {
|
|
384
|
+
const result = results[index];
|
|
385
|
+
if (result.success) {
|
|
386
|
+
if (result.returnData.toLowerCase() !==
|
|
387
|
+
(0, viem_1.toHex)(BigInt(plan.address), { size: 32 }).toLowerCase())
|
|
388
|
+
throw new Error("The simulated factory returned a different Safe address.");
|
|
389
|
+
}
|
|
390
|
+
else {
|
|
391
|
+
// Only an already-deployed Safe with the exact policy can explain an accepted failure.
|
|
392
|
+
await verifySafeDeployments(client, [plan]);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
//# sourceMappingURL=safe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safe.js","sourceRoot":"","sources":["../../src/safe.ts"],"names":[],"mappings":";;;AAkGA,oDAoCC;AAGD,gDAwBC;AAED,gEASC;AAsBD,oDAkBC;AAGD,gDA2BC;AAiCD,sDA2HC;AAED,oDAcC;AAGD,4DAgBC;AAED,sDAcC;AAOD,4CA8BC;AAGD,gDAsBC;AAGD,gEAkCC;AApiBD,+BAkBc;AAEd,uEAAuE;AACvE,8EAA8E;AACjE,QAAA,YAAY,GAAG,IAAA,iBAAU,EACpC,4CAA4C,CAC7C,CAAC;AACW,QAAA,cAAc,GAAG,IAAA,iBAAU,EACtC,4CAA4C,CAC7C,CAAC;AACW,QAAA,aAAa,GAAG,IAAA,iBAAU,EACrC,4CAA4C,CAC7C,CAAC;AACW,QAAA,UAAU,GAAG,IAAA,iBAAU,EAClC,4CAA4C,CAC7C,CAAC;AACW,QAAA,eAAe,GAAG,EAAE,CAAC;AAElC,MAAM,SAAS,GAAG;IAChB;QACE,oBAAY;QACZ,oEAAoE;KACrE;IACD;QACE,sBAAc;QACd,oEAAoE;KACrE;IACD;QACE,qBAAa;QACb,oEAAoE;KACrE;CACO,CAAC;AACX,MAAM,eAAe,GACnB,oEAAoE,CAAC;AACvE,MAAM,QAAQ,GAAG,4CAAqD,CAAC;AACvE,MAAM,cAAc,GAAG,IAAA,YAAK,EAAC,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;AAC/C,MAAM,UAAU,GACd,oEAA6E,CAAC;AAChF,MAAM,aAAa,GACjB,oEAA6E,CAAC;AAEnE,QAAA,eAAe,GAAG,IAAA,eAAQ,EAAC;IACtC,mDAAmD;IACnD,gHAAgH;IAChH,+JAA+J;CAChK,CAAC,CAA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QAC9C,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type Address, type Hex } from "viem";
|
|
2
|
+
import type { JBTerminalConfig } from "../v6/launch.js";
|
|
3
|
+
import type { REVConfig } from "../v6/revnets.js";
|
|
4
|
+
import type { JBRulesetConfig } from "../v6/rulesets.js";
|
|
5
|
+
import type { JBAccountingContext } from "../v6/terminals.js";
|
|
6
|
+
import type { JBCenterDeploymentCall } from "../jbcenter.js";
|
|
7
|
+
export type JBCenterDecodedLaunch = {
|
|
8
|
+
flavor: "project";
|
|
9
|
+
owner: Address;
|
|
10
|
+
projectUri: string;
|
|
11
|
+
rulesetConfigurations: readonly JBRulesetConfig[];
|
|
12
|
+
terminalConfigurations: readonly JBTerminalConfig[];
|
|
13
|
+
memo: string;
|
|
14
|
+
} | {
|
|
15
|
+
flavor: "project-721";
|
|
16
|
+
owner: Address;
|
|
17
|
+
projectUri: string;
|
|
18
|
+
rulesetConfigurations: readonly JBRulesetConfig[];
|
|
19
|
+
terminalConfigurations: readonly JBTerminalConfig[];
|
|
20
|
+
memo: string;
|
|
21
|
+
salt: Hex;
|
|
22
|
+
} | {
|
|
23
|
+
flavor: "omnichain";
|
|
24
|
+
owner: Address;
|
|
25
|
+
projectUri: string;
|
|
26
|
+
rulesetConfigurations: readonly JBRulesetConfig[];
|
|
27
|
+
terminalConfigurations: readonly JBTerminalConfig[];
|
|
28
|
+
memo: string;
|
|
29
|
+
has721: boolean;
|
|
30
|
+
} | {
|
|
31
|
+
flavor: "revnet";
|
|
32
|
+
operator: Address;
|
|
33
|
+
projectUri: string;
|
|
34
|
+
stages: REVConfig["stageConfigurations"];
|
|
35
|
+
description: REVConfig["description"];
|
|
36
|
+
accountingContexts: readonly JBAccountingContext[];
|
|
37
|
+
} | {
|
|
38
|
+
flavor: "unknown";
|
|
39
|
+
to: Address;
|
|
40
|
+
selector: Hex;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Recognize a frozen `{ chainId, to, data }` deployment call (as produced by
|
|
44
|
+
* {@link createJBCenterDeploymentCall}) as one of the known v6 launch
|
|
45
|
+
* flavors, or `"unknown"` when the target address or selector isn't
|
|
46
|
+
* recognized.
|
|
47
|
+
*/
|
|
48
|
+
export declare function decodeDeploymentCall(call: JBCenterDeploymentCall): JBCenterDecodedLaunch;
|
|
49
|
+
//# sourceMappingURL=decode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode.d.ts","sourceRoot":"","sources":["../../../src/jbcenter/decode.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,OAAO,EACZ,KAAK,GAAG,EACT,MAAM,MAAM,CAAC;AAQd,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAE7D,MAAM,MAAM,qBAAqB,GAC7B;IACE,MAAM,EAAE,SAAS,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,qBAAqB,EAAE,SAAS,eAAe,EAAE,CAAC;IAClD,sBAAsB,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACpD,IAAI,EAAE,MAAM,CAAC;CACd,GACD;IACE,MAAM,EAAE,aAAa,CAAC;IACtB,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,qBAAqB,EAAE,SAAS,eAAe,EAAE,CAAC;IAClD,sBAAsB,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,GAAG,CAAC;CACX,GACD;IACE,MAAM,EAAE,WAAW,CAAC;IACpB,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,qBAAqB,EAAE,SAAS,eAAe,EAAE,CAAC;IAClD,sBAAsB,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;CACjB,GACD;IACE,MAAM,EAAE,QAAQ,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,SAAS,CAAC,qBAAqB,CAAC,CAAC;IACzC,WAAW,EAAE,SAAS,CAAC,aAAa,CAAC,CAAC;IACtC,kBAAkB,EAAE,SAAS,mBAAmB,EAAE,CAAC;CACpD,GACD;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,EAAE,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,GAAG,CAAA;CAAE,CAAC;AA4JtD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,sBAAsB,GAC3B,qBAAqB,CAMvB"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { decodeFunctionData, isAddressEqual, slice, } from "viem";
|
|
2
|
+
import { jb721TiersHookProjectDeployerAbi, jbControllerAbi, jbOmnichainDeployerAbi, revDeployerAbi, } from "../generated/juicebox.js";
|
|
3
|
+
import { v6Address } from "../v6/types.js";
|
|
4
|
+
/** The address of `contract` on `chainId`, or null when it isn't deployed there. */
|
|
5
|
+
function addressFor(contract, chainId) {
|
|
6
|
+
try {
|
|
7
|
+
return v6Address(contract, chainId);
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function decodeProjectLaunch(call) {
|
|
14
|
+
try {
|
|
15
|
+
const address = addressFor("JBController", call.chainId);
|
|
16
|
+
if (!address || !isAddressEqual(address, call.to))
|
|
17
|
+
return null;
|
|
18
|
+
const decoded = decodeFunctionData({
|
|
19
|
+
abi: jbControllerAbi,
|
|
20
|
+
data: call.data,
|
|
21
|
+
});
|
|
22
|
+
if (decoded.functionName !== "launchProjectFor")
|
|
23
|
+
return null;
|
|
24
|
+
const [owner, projectUri, rulesetConfigurations, terminalConfigurations, memo,] = decoded.args;
|
|
25
|
+
return {
|
|
26
|
+
flavor: "project",
|
|
27
|
+
owner,
|
|
28
|
+
projectUri,
|
|
29
|
+
rulesetConfigurations,
|
|
30
|
+
terminalConfigurations,
|
|
31
|
+
memo,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function decodeProject721Launch(call) {
|
|
39
|
+
try {
|
|
40
|
+
const address = addressFor("JB721TiersHookProjectDeployer", call.chainId);
|
|
41
|
+
if (!address || !isAddressEqual(address, call.to))
|
|
42
|
+
return null;
|
|
43
|
+
const decoded = decodeFunctionData({
|
|
44
|
+
abi: jb721TiersHookProjectDeployerAbi,
|
|
45
|
+
data: call.data,
|
|
46
|
+
});
|
|
47
|
+
if (decoded.functionName !== "launchProjectFor")
|
|
48
|
+
return null;
|
|
49
|
+
const [owner, , launchProjectConfig, , salt] = decoded.args;
|
|
50
|
+
return {
|
|
51
|
+
flavor: "project-721",
|
|
52
|
+
owner,
|
|
53
|
+
projectUri: launchProjectConfig.projectUri,
|
|
54
|
+
// This deployer's ruleset metadata always turns the pay data hook on and
|
|
55
|
+
// points it at the hook it deploys, so `dataHook`/`useDataHookForPay`
|
|
56
|
+
// aren't inputs here — they read as `undefined` on this flavor's shell.
|
|
57
|
+
rulesetConfigurations: launchProjectConfig.rulesetConfigurations,
|
|
58
|
+
terminalConfigurations: launchProjectConfig.terminalConfigurations,
|
|
59
|
+
memo: launchProjectConfig.memo,
|
|
60
|
+
salt,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function decodeOmnichainLaunch(call) {
|
|
68
|
+
try {
|
|
69
|
+
const address = addressFor("JBOmnichainDeployer", call.chainId);
|
|
70
|
+
if (!address || !isAddressEqual(address, call.to))
|
|
71
|
+
return null;
|
|
72
|
+
const decoded = decodeFunctionData({
|
|
73
|
+
abi: jbOmnichainDeployerAbi,
|
|
74
|
+
data: call.data,
|
|
75
|
+
});
|
|
76
|
+
if (decoded.functionName !== "launchProjectFor")
|
|
77
|
+
return null;
|
|
78
|
+
const args = decoded.args;
|
|
79
|
+
if (args.length === 7) {
|
|
80
|
+
const [owner, projectUri, , rulesetConfigurations, terminalConfigurations, memo,] = args;
|
|
81
|
+
return {
|
|
82
|
+
flavor: "omnichain",
|
|
83
|
+
owner,
|
|
84
|
+
projectUri,
|
|
85
|
+
rulesetConfigurations,
|
|
86
|
+
terminalConfigurations,
|
|
87
|
+
memo,
|
|
88
|
+
has721: true,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
const [owner, projectUri, rulesetConfigurations, terminalConfigurations, memo,] = args;
|
|
92
|
+
return {
|
|
93
|
+
flavor: "omnichain",
|
|
94
|
+
owner,
|
|
95
|
+
projectUri,
|
|
96
|
+
rulesetConfigurations,
|
|
97
|
+
terminalConfigurations,
|
|
98
|
+
memo,
|
|
99
|
+
has721: false,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function decodeRevnetDeploy(call) {
|
|
107
|
+
try {
|
|
108
|
+
const address = addressFor("REVDeployer", call.chainId);
|
|
109
|
+
if (!address || !isAddressEqual(address, call.to))
|
|
110
|
+
return null;
|
|
111
|
+
const decoded = decodeFunctionData({
|
|
112
|
+
abi: revDeployerAbi,
|
|
113
|
+
data: call.data,
|
|
114
|
+
});
|
|
115
|
+
if (decoded.functionName !== "deployFor")
|
|
116
|
+
return null;
|
|
117
|
+
const [, config, accountingContexts] = decoded.args;
|
|
118
|
+
return {
|
|
119
|
+
flavor: "revnet",
|
|
120
|
+
operator: config.operator,
|
|
121
|
+
projectUri: config.description.uri,
|
|
122
|
+
stages: config.stageConfigurations,
|
|
123
|
+
description: config.description,
|
|
124
|
+
accountingContexts,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const DECODERS = [
|
|
132
|
+
decodeProjectLaunch,
|
|
133
|
+
decodeProject721Launch,
|
|
134
|
+
decodeOmnichainLaunch,
|
|
135
|
+
decodeRevnetDeploy,
|
|
136
|
+
];
|
|
137
|
+
/**
|
|
138
|
+
* Recognize a frozen `{ chainId, to, data }` deployment call (as produced by
|
|
139
|
+
* {@link createJBCenterDeploymentCall}) as one of the known v6 launch
|
|
140
|
+
* flavors, or `"unknown"` when the target address or selector isn't
|
|
141
|
+
* recognized.
|
|
142
|
+
*/
|
|
143
|
+
export function decodeDeploymentCall(call) {
|
|
144
|
+
for (const decode of DECODERS) {
|
|
145
|
+
const decoded = decode(call);
|
|
146
|
+
if (decoded)
|
|
147
|
+
return decoded;
|
|
148
|
+
}
|
|
149
|
+
return { flavor: "unknown", to: call.to, selector: slice(call.data, 0, 4) };
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=decode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode.js","sourceRoot":"","sources":["../../../src/jbcenter/decode.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,KAAK,GAGN,MAAM,MAAM,CAAC;AACd,OAAO,EACL,gCAAgC,EAChC,eAAe,EACf,sBAAsB,EACtB,cAAc,GACf,MAAM,0BAA0B,CAAC;AAMlC,OAAO,EAAE,SAAS,EAAmB,MAAM,gBAAgB,CAAC;AAwC5D,oFAAoF;AACpF,SAAS,UAAU,CAAC,QAAoB,EAAE,OAAe;IACv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sBAAsB;IACtB,qBAAqB;IACrB,kBAAkB;CACnB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAClC,IAA4B;IAE5B,KAAK,MAAM,MAAM,IAAI,QAAQ,EAAE,CAAC;QAC9B,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;QAC7B,IAAI,OAAO;YAAE,OAAO,OAAO,CAAC;IAC9B,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Hex } from "viem";
|
|
2
|
+
import { type JBCenterClient, type JBCenterDeploymentCall, type JBCenterDeploymentInput, type JBCenterIntent, type JBCenterJsonObject } from "../jbcenter.js";
|
|
3
|
+
export type EnsureDeployedStep = {
|
|
4
|
+
chainId: number;
|
|
5
|
+
status: "queued" | "sent" | "confirmed" | "failed" | "self-paid";
|
|
6
|
+
transactionHash?: Hex;
|
|
7
|
+
};
|
|
8
|
+
export type EnsureDeployedOptions = {
|
|
9
|
+
client: JBCenterClient;
|
|
10
|
+
intent: JBCenterIntent<JBCenterJsonObject>;
|
|
11
|
+
/** Runs the client's own launch pipeline for every remaining chain. */
|
|
12
|
+
selfPaid?: (calls: JBCenterDeploymentCall[]) => Promise<JBCenterDeploymentInput[]>;
|
|
13
|
+
onStep?: (step: EnsureDeployedStep) => void;
|
|
14
|
+
pollMs?: number;
|
|
15
|
+
timeoutMs?: number;
|
|
16
|
+
signal?: AbortSignal;
|
|
17
|
+
};
|
|
18
|
+
export declare class EnsureDeployedError extends Error {
|
|
19
|
+
readonly chainId?: number | undefined;
|
|
20
|
+
constructor(message: string, chainId?: number | undefined);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The pre-step every webclient runs before the first on-chain write against
|
|
24
|
+
* an undeployed intent: sponsor the deploy through JB Center when eligible
|
|
25
|
+
* and poll until every chain lands, or fall back to the caller's own launch
|
|
26
|
+
* pipeline when JB Center can't or won't sponsor it.
|
|
27
|
+
*/
|
|
28
|
+
export declare function ensureDeployed(options: EnsureDeployedOptions): Promise<Record<number, string>>;
|
|
29
|
+
//# sourceMappingURL=ensureDeployed.d.ts.map
|