@bananapus/nana-sdk-core 2.8.0 → 2.10.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 +9 -0
- package/dist/cjs/jbcenter/decode.d.ts.map +1 -1
- package/dist/cjs/jbcenter/decode.js +76 -0
- package/dist/cjs/jbcenter/decode.js.map +1 -1
- package/dist/cjs/jbcenter/ensureDeployed.d.ts +25 -6
- package/dist/cjs/jbcenter/ensureDeployed.d.ts.map +1 -1
- package/dist/cjs/jbcenter/ensureDeployed.js +111 -25
- package/dist/cjs/jbcenter/ensureDeployed.js.map +1 -1
- package/dist/cjs/jbcenter/setupCalls.d.ts +26 -0
- package/dist/cjs/jbcenter/setupCalls.d.ts.map +1 -0
- package/dist/cjs/jbcenter/setupCalls.js +57 -0
- package/dist/cjs/jbcenter/setupCalls.js.map +1 -0
- package/dist/cjs/jbcenter.d.ts +53 -2
- package/dist/cjs/jbcenter.d.ts.map +1 -1
- package/dist/cjs/jbcenter.js +89 -13
- package/dist/cjs/jbcenter.js.map +1 -1
- package/dist/cjs/safe.d.ts +8 -0
- package/dist/cjs/safe.d.ts.map +1 -1
- package/dist/cjs/safe.js +9 -1
- package/dist/cjs/safe.js.map +1 -1
- package/dist/esm/jbcenter/decode.d.ts +9 -0
- package/dist/esm/jbcenter/decode.d.ts.map +1 -1
- package/dist/esm/jbcenter/decode.js +77 -1
- package/dist/esm/jbcenter/decode.js.map +1 -1
- package/dist/esm/jbcenter/ensureDeployed.d.ts +25 -6
- package/dist/esm/jbcenter/ensureDeployed.d.ts.map +1 -1
- package/dist/esm/jbcenter/ensureDeployed.js +113 -27
- package/dist/esm/jbcenter/ensureDeployed.js.map +1 -1
- package/dist/esm/jbcenter/setupCalls.d.ts +26 -0
- package/dist/esm/jbcenter/setupCalls.d.ts.map +1 -0
- package/dist/esm/jbcenter/setupCalls.js +52 -0
- package/dist/esm/jbcenter/setupCalls.js.map +1 -0
- package/dist/esm/jbcenter.d.ts +53 -2
- package/dist/esm/jbcenter.d.ts.map +1 -1
- package/dist/esm/jbcenter.js +85 -12
- package/dist/esm/jbcenter.js.map +1 -1
- package/dist/esm/safe.d.ts +8 -0
- package/dist/esm/safe.d.ts.map +1 -1
- package/dist/esm/safe.js +8 -0
- package/dist/esm/safe.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensureDeployed.d.ts","sourceRoot":"","sources":["../../../src/jbcenter/ensureDeployed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAKhC,OAAO,
|
|
1
|
+
{"version":3,"file":"ensureDeployed.d.ts","sourceRoot":"","sources":["../../../src/jbcenter/ensureDeployed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAKhC,OAAO,EAKL,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,cAAc,EAEnB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EAC1B,MAAM,gBAAgB,CAAC;AAOxB,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EACF,QAAQ,GACR,MAAM,GACN,WAAW,GACX,QAAQ,GACR,WAAW,GACX,YAAY,CAAC;IACjB,eAAe,CAAC,EAAE,GAAG,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,cAAc,CAAC;IACvB,MAAM,EAAE,cAAc,CAAC,kBAAkB,CAAC,CAAC;IAC3C;;;OAGG;IACH,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7B;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,CACV,OAAO,EAAE,oBAAoB,KAC1B,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACtC;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,CACT,KAAK,EAAE,sBAAsB,EAAE,KAC5B,OAAO,CAAC,uBAAuB,EAAE,CAAC,CAAC;IACxC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAC5C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,qBAAa,mBAAoB,SAAQ,KAAK;IAG1C,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM;gBADzB,OAAO,EAAE,MAAM,EACN,OAAO,CAAC,EAAE,MAAM,YAAA;CAK5B;AAuRD;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAsEjC"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// every value either side takes from the other inside a function body: a
|
|
3
3
|
// top-level read of `JBCenterRequestError` or `isSponsorable` would resolve
|
|
4
4
|
// before `jbcenter.ts` finishes evaluating under CJS.
|
|
5
|
-
import { JBCenterRequestError, isSponsorable, } from "../jbcenter.js";
|
|
6
|
-
import { deployedChains
|
|
5
|
+
import { JBCenterRequestError, isSponsorable, sponsorableChains, unsponsoredChains, } from "../jbcenter.js";
|
|
6
|
+
import { deployedChains } from "./merge.js";
|
|
7
7
|
const DEFAULT_POLL_MS = 4_000;
|
|
8
8
|
const DEFAULT_TIMEOUT_MS = 600_000;
|
|
9
9
|
const SELF_PAID_FALLBACK_STATUSES = new Set([400, 429, 503]);
|
|
@@ -32,6 +32,29 @@ function sleep(ms, signal) {
|
|
|
32
32
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* The chains this run covers, in the intent's own order. Naming a chain the
|
|
37
|
+
* intent does not carry is a caller mistake, not a deploy failure.
|
|
38
|
+
*/
|
|
39
|
+
function runChains(intent, chainIds) {
|
|
40
|
+
if (!chainIds)
|
|
41
|
+
return [...intent.envelope.chainIds];
|
|
42
|
+
const requested = new Set(chainIds);
|
|
43
|
+
for (const chainId of requested) {
|
|
44
|
+
if (!intent.envelope.chainIds.includes(chainId)) {
|
|
45
|
+
throw new EnsureDeployedError(`Chain ${chainId} is not part of this intent`, chainId);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const run = intent.envelope.chainIds.filter((id) => requested.has(id));
|
|
49
|
+
if (run.length === 0) {
|
|
50
|
+
throw new EnsureDeployedError("ensureDeployed was given no chains to run");
|
|
51
|
+
}
|
|
52
|
+
return run;
|
|
53
|
+
}
|
|
54
|
+
function isRunDeployed(intent, run) {
|
|
55
|
+
const deployed = deployedChains(intent);
|
|
56
|
+
return run.every((chainId) => chainId in deployed);
|
|
57
|
+
}
|
|
35
58
|
function reportSteps(deploys, seen, onStep) {
|
|
36
59
|
let failedChainId;
|
|
37
60
|
for (const deploy of deploys) {
|
|
@@ -51,14 +74,14 @@ function reportSteps(deploys, seen, onStep) {
|
|
|
51
74
|
throw new EnsureDeployedError(`JB Center could not deploy chain ${failedChainId}`, failedChainId);
|
|
52
75
|
}
|
|
53
76
|
}
|
|
54
|
-
async function pollUntilDeployed(client, seed, pollMs, timeoutMs, signal, onStep) {
|
|
77
|
+
async function pollUntilDeployed(client, seed, run, pollMs, timeoutMs, signal, onStep) {
|
|
55
78
|
const seen = new Map();
|
|
56
79
|
const startedAt = Date.now();
|
|
57
80
|
let current = seed;
|
|
58
81
|
while (true) {
|
|
59
82
|
checkAborted(signal);
|
|
60
83
|
reportSteps(current.deploys, seen, onStep);
|
|
61
|
-
if (
|
|
84
|
+
if (isRunDeployed(current, run)) {
|
|
62
85
|
return deployedChains(current);
|
|
63
86
|
}
|
|
64
87
|
if (Date.now() - startedAt >= timeoutMs) {
|
|
@@ -68,13 +91,13 @@ async function pollUntilDeployed(client, seed, pollMs, timeoutMs, signal, onStep
|
|
|
68
91
|
current = await client.getIntent(current.id, { signal });
|
|
69
92
|
}
|
|
70
93
|
}
|
|
71
|
-
async function runSelfPaid(client, intent, selfPaid, onStep, signal) {
|
|
94
|
+
async function runSelfPaid(client, intent, run, selfPaid, onStep, signal) {
|
|
72
95
|
if (!selfPaid) {
|
|
73
96
|
throw new EnsureDeployedError("JB Center cannot sponsor this deploy and no self-paid fallback was provided");
|
|
74
97
|
}
|
|
75
98
|
checkAborted(signal);
|
|
76
99
|
const deployed = deployedChains(intent);
|
|
77
|
-
const remainingCalls = intent.envelope.deploymentCalls.filter((call) => !(call.chainId in deployed));
|
|
100
|
+
const remainingCalls = intent.envelope.deploymentCalls.filter((call) => run.includes(call.chainId) && !(call.chainId in deployed));
|
|
78
101
|
const deployments = await selfPaid(remainingCalls);
|
|
79
102
|
const remainingChainIds = new Set(remainingCalls.map((call) => call.chainId));
|
|
80
103
|
const returnedChainIds = new Set();
|
|
@@ -106,43 +129,101 @@ async function runSelfPaid(client, intent, selfPaid, onStep, signal) {
|
|
|
106
129
|
return result;
|
|
107
130
|
}
|
|
108
131
|
/**
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
132
|
+
* Whether a wallet sent one of the chains an intent has already landed. Every
|
|
133
|
+
* chain in an intent belongs to one sender, and a deployment JB Center's
|
|
134
|
+
* forwarder did not carry was sent by the caller's own wallet.
|
|
135
|
+
*/
|
|
136
|
+
function walletSent(intent) {
|
|
137
|
+
return intent.deployments.some((deployment) => deployment.forwarded !== true);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* The sender an intent already has, or `undefined` when JB Center's sponsor is
|
|
141
|
+
* still free to take the run. A deployment a wallet sent pins the intent to
|
|
142
|
+
* `selfPaid`; deployments the forwarder carried leave the sponsor path open,
|
|
143
|
+
* because every one of them reports Center's sponsor as the sender.
|
|
112
144
|
*/
|
|
113
|
-
function existingSender(options, intent,
|
|
145
|
+
function existingSender(options, intent, run) {
|
|
114
146
|
const { client, onStep, selfPaid, signal } = options;
|
|
115
|
-
if (
|
|
147
|
+
if (isRunDeployed(intent, run)) {
|
|
116
148
|
return Promise.resolve(deployedChains(intent));
|
|
117
149
|
}
|
|
118
|
-
if (intent
|
|
119
|
-
return
|
|
120
|
-
}
|
|
121
|
-
if (intent.deployments.length > 0) {
|
|
122
|
-
return runSelfPaid(client, intent, selfPaid, onStep, signal);
|
|
150
|
+
if (walletSent(intent)) {
|
|
151
|
+
return runSelfPaid(client, intent, run, selfPaid, onStep, signal);
|
|
123
152
|
}
|
|
124
153
|
return undefined;
|
|
125
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* Center's lane for the chains it sponsors and the caller's own sender for
|
|
157
|
+
* the chains it does not, in one run. The sponsored chains are queued first,
|
|
158
|
+
* in one request, so Center works while the visitor is still signing.
|
|
159
|
+
*/
|
|
160
|
+
async function runRelayPaid(options, relayPaid, run, pollMs, timeoutMs) {
|
|
161
|
+
const { client, intent, onStep, signal } = options;
|
|
162
|
+
checkAborted(signal);
|
|
163
|
+
const result = deployedChains(intent);
|
|
164
|
+
const remaining = run.filter((chainId) => !(chainId in result));
|
|
165
|
+
const sponsored = sponsorableChains(remaining);
|
|
166
|
+
let deploys = [];
|
|
167
|
+
if (sponsored.length > 0) {
|
|
168
|
+
({ deploys } = await client.requestDeploy(intent.id, {
|
|
169
|
+
chainIds: sponsored,
|
|
170
|
+
signal,
|
|
171
|
+
}));
|
|
172
|
+
}
|
|
173
|
+
for (const chainId of unsponsoredChains(remaining)) {
|
|
174
|
+
checkAborted(signal);
|
|
175
|
+
const request = await client.requestRelay(intent.id, chainId, { signal });
|
|
176
|
+
const deployment = await relayPaid(request);
|
|
177
|
+
if (deployment.chainId !== chainId) {
|
|
178
|
+
throw new EnsureDeployedError(`Relay-paid deploy returned chain ${deployment.chainId} for chain ${chainId}`, chainId);
|
|
179
|
+
}
|
|
180
|
+
await client.recordDeployment(intent.id, deployment, { signal });
|
|
181
|
+
result[chainId] = deployment.projectId;
|
|
182
|
+
onStep?.({
|
|
183
|
+
chainId,
|
|
184
|
+
status: "relay-paid",
|
|
185
|
+
transactionHash: deployment.transactionHash,
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
if (sponsored.length === 0)
|
|
189
|
+
return result;
|
|
190
|
+
return {
|
|
191
|
+
...result,
|
|
192
|
+
...(await pollUntilDeployed(client, { ...intent, deploys }, remaining, pollMs, timeoutMs, signal, onStep)),
|
|
193
|
+
};
|
|
194
|
+
}
|
|
126
195
|
/**
|
|
127
196
|
* The pre-step every webclient runs before the first on-chain write against
|
|
128
|
-
* an undeployed intent: sponsor the deploy through JB Center
|
|
129
|
-
*
|
|
130
|
-
*
|
|
197
|
+
* an undeployed intent: sponsor the deploy through JB Center for the chains
|
|
198
|
+
* it covers, hand the rest to the caller's own sender, and poll until the
|
|
199
|
+
* run's chains land. `chainIds` narrows the run to part of the intent.
|
|
131
200
|
*/
|
|
132
201
|
export async function ensureDeployed(options) {
|
|
133
|
-
const { client, intent, onStep, selfPaid, signal } = options;
|
|
202
|
+
const { client, intent, onStep, relayPaid, selfPaid, signal } = options;
|
|
134
203
|
const pollMs = options.pollMs ?? DEFAULT_POLL_MS;
|
|
135
204
|
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
136
|
-
|
|
205
|
+
if (relayPaid && selfPaid) {
|
|
206
|
+
throw new EnsureDeployedError("ensureDeployed takes relayPaid or selfPaid, never both");
|
|
207
|
+
}
|
|
208
|
+
const run = runChains(intent, options.chainIds);
|
|
209
|
+
const started = existingSender(options, intent, run);
|
|
137
210
|
if (started)
|
|
138
211
|
return started;
|
|
139
|
-
if (
|
|
140
|
-
return
|
|
212
|
+
if (relayPaid) {
|
|
213
|
+
return runRelayPaid(options, relayPaid, run, pollMs, timeoutMs);
|
|
214
|
+
}
|
|
215
|
+
if (!isSponsorable(run)) {
|
|
216
|
+
return runSelfPaid(client, intent, run, selfPaid, onStep, signal);
|
|
141
217
|
}
|
|
218
|
+
const deployed = deployedChains(intent);
|
|
219
|
+
const pending = run.filter((chainId) => !(chainId in deployed));
|
|
142
220
|
let deploys;
|
|
143
221
|
try {
|
|
144
222
|
checkAborted(signal);
|
|
145
|
-
({ deploys } = await client.requestDeploy(intent.id, {
|
|
223
|
+
({ deploys } = await client.requestDeploy(intent.id, {
|
|
224
|
+
chainIds: pending,
|
|
225
|
+
signal,
|
|
226
|
+
}));
|
|
146
227
|
}
|
|
147
228
|
catch (error) {
|
|
148
229
|
if (error instanceof JBCenterRequestError &&
|
|
@@ -151,11 +232,16 @@ export async function ensureDeployed(options) {
|
|
|
151
232
|
// intent back and follow whatever sender it now has instead of adding a
|
|
152
233
|
// second one.
|
|
153
234
|
const fresh = await client.getIntent(intent.id, { signal });
|
|
154
|
-
|
|
155
|
-
|
|
235
|
+
const resumed = existingSender(options, fresh, run);
|
|
236
|
+
if (resumed)
|
|
237
|
+
return resumed;
|
|
238
|
+
if (fresh.deploys.length > 0) {
|
|
239
|
+
return pollUntilDeployed(client, fresh, run, pollMs, timeoutMs, signal, onStep);
|
|
240
|
+
}
|
|
241
|
+
return runSelfPaid(client, fresh, run, selfPaid, onStep, signal);
|
|
156
242
|
}
|
|
157
243
|
throw error;
|
|
158
244
|
}
|
|
159
|
-
return pollUntilDeployed(client, { ...intent, deploys }, pollMs, timeoutMs, signal, onStep);
|
|
245
|
+
return pollUntilDeployed(client, { ...intent, deploys }, run, pollMs, timeoutMs, signal, onStep);
|
|
160
246
|
}
|
|
161
247
|
//# sourceMappingURL=ensureDeployed.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensureDeployed.js","sourceRoot":"","sources":["../../../src/jbcenter/ensureDeployed.ts"],"names":[],"mappings":"AACA,8EAA8E;AAC9E,yEAAyE;AACzE,4EAA4E;AAC5E,sDAAsD;AACtD,OAAO,EACL,oBAAoB,EACpB,aAAa,
|
|
1
|
+
{"version":3,"file":"ensureDeploy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AAM,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;YAC5D,MAAM,OAAO,GAAG,cAAc,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;YACpD,IAAI,OAAO;gBAAE,OAAO,OAAO,CAAC;YAC5B,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC7B,OAAO,iBAAiB,CACtB,MAAM,EACN,KAAK,EACL,GAAG,EACH,MAAM,EACN,SAAS,EACT,MAAM,EACN,MAAM,CACP,CAAC;YACJ,CAAC;YACD,OAAO,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QACnE,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;IAED,OAAO,iBAAiB,CACtB,MAAM,EACN,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,EACtB,GAAG,EACH,MAAM,EACN,SAAS,EACT,MAAM,EACN,MAAM,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { JBCenterDeploymentCall, JBCenterIntent, JBCenterJsonObject } from "../jbcenter.js";
|
|
2
|
+
import type { JBCenterDecodedLaunch } from "./decode.js";
|
|
3
|
+
/** An intent's `deploymentCalls` per chain, each chain's calls in order. */
|
|
4
|
+
export declare function groupDeploymentCalls(calls: readonly JBCenterDeploymentCall[]): Map<number, JBCenterDeploymentCall[]>;
|
|
5
|
+
/**
|
|
6
|
+
* JB Center's rule, mirrored: a chain carries 1 to 4 calls, the last call for
|
|
7
|
+
* a chain is its launch, and every call before it creates a Safe through the
|
|
8
|
+
* canonical factory. Whether the chains named match the calls is the
|
|
9
|
+
* envelope's own check.
|
|
10
|
+
*/
|
|
11
|
+
export declare function isValidDeploymentCalls(calls: readonly JBCenterDeploymentCall[]): boolean;
|
|
12
|
+
/** One of an intent's calls, with the launch or Safe creation it carries. */
|
|
13
|
+
export type JBCenterDecodedCall = JBCenterDeploymentCall & {
|
|
14
|
+
decoded: JBCenterDecodedLaunch;
|
|
15
|
+
};
|
|
16
|
+
export type JBCenterChainCalls = {
|
|
17
|
+
setup: JBCenterDecodedCall[];
|
|
18
|
+
launch: JBCenterDecodedCall;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* An intent's calls per chain, decoded, so a client renders "creates this
|
|
22
|
+
* Safe, then launches" without repeating the rule: the last call for a chain
|
|
23
|
+
* is its launch and every call before it is a setup call.
|
|
24
|
+
*/
|
|
25
|
+
export declare function intentCalls(intent: JBCenterIntent<JBCenterJsonObject>): Map<number, JBCenterChainCalls>;
|
|
26
|
+
//# sourceMappingURL=setupCalls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setupCalls.d.ts","sourceRoot":"","sources":["../../../src/jbcenter/setupCalls.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,sBAAsB,EACtB,cAAc,EACd,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAKzD,4EAA4E;AAC5E,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,SAAS,sBAAsB,EAAE,GACvC,GAAG,CAAC,MAAM,EAAE,sBAAsB,EAAE,CAAC,CAUvC;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,SAAS,sBAAsB,EAAE,GACvC,OAAO,CAST;AAED,6EAA6E;AAC7E,MAAM,MAAM,mBAAmB,GAAG,sBAAsB,GAAG;IACzD,OAAO,EAAE,qBAAqB,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,mBAAmB,EAAE,CAAC;IAC7B,MAAM,EAAE,mBAAmB,CAAC;CAC7B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,cAAc,CAAC,kBAAkB,CAAC,GACzC,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAiBjC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { decodeDeploymentCall } from "./decode.js";
|
|
2
|
+
/** JB Center's ceiling: one launch per chain, with up to three setup calls. */
|
|
3
|
+
const MAX_CALLS_PER_CHAIN = 4;
|
|
4
|
+
/** An intent's `deploymentCalls` per chain, each chain's calls in order. */
|
|
5
|
+
export function groupDeploymentCalls(calls) {
|
|
6
|
+
const groups = new Map();
|
|
7
|
+
for (const call of calls) {
|
|
8
|
+
const group = groups.get(call.chainId);
|
|
9
|
+
if (group)
|
|
10
|
+
group.push(call);
|
|
11
|
+
else
|
|
12
|
+
groups.set(call.chainId, [call]);
|
|
13
|
+
}
|
|
14
|
+
return groups;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* JB Center's rule, mirrored: a chain carries 1 to 4 calls, the last call for
|
|
18
|
+
* a chain is its launch, and every call before it creates a Safe through the
|
|
19
|
+
* canonical factory. Whether the chains named match the calls is the
|
|
20
|
+
* envelope's own check.
|
|
21
|
+
*/
|
|
22
|
+
export function isValidDeploymentCalls(calls) {
|
|
23
|
+
for (const group of groupDeploymentCalls(calls).values()) {
|
|
24
|
+
if (group.length > MAX_CALLS_PER_CHAIN)
|
|
25
|
+
return false;
|
|
26
|
+
for (const call of group.slice(0, -1)) {
|
|
27
|
+
if (decodeDeploymentCall(call).flavor !== "safe-create")
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* An intent's calls per chain, decoded, so a client renders "creates this
|
|
35
|
+
* Safe, then launches" without repeating the rule: the last call for a chain
|
|
36
|
+
* is its launch and every call before it is a setup call.
|
|
37
|
+
*/
|
|
38
|
+
export function intentCalls(intent) {
|
|
39
|
+
const result = new Map();
|
|
40
|
+
for (const [chainId, calls] of groupDeploymentCalls(intent.envelope.deploymentCalls)) {
|
|
41
|
+
const decoded = calls.map((call) => ({
|
|
42
|
+
...call,
|
|
43
|
+
decoded: decodeDeploymentCall(call),
|
|
44
|
+
}));
|
|
45
|
+
result.set(chainId, {
|
|
46
|
+
setup: decoded.slice(0, -1),
|
|
47
|
+
launch: decoded[decoded.length - 1],
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=setupCalls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setupCalls.js","sourceRoot":"","sources":["../../../src/jbcenter/setupCalls.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGnD,+EAA+E;AAC/E,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAE9B,4EAA4E;AAC5E,MAAM,UAAU,oBAAoB,CAClC,KAAwC;IAExC,MAAM,MAAM,GAAG,IAAI,GAAG,EAAoC,CAAC;IAE3D,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvC,IAAI,KAAK;YAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;;YACvB,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IACxC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CACpC,KAAwC;IAExC,KAAK,MAAM,KAAK,IAAI,oBAAoB,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;QACzD,IAAI,KAAK,CAAC,MAAM,GAAG,mBAAmB;YAAE,OAAO,KAAK,CAAC;QACrD,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACtC,IAAI,oBAAoB,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,aAAa;gBAAE,OAAO,KAAK,CAAC;QACxE,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAYD;;;;GAIG;AACH,MAAM,UAAU,WAAW,CACzB,MAA0C;IAE1C,MAAM,MAAM,GAAG,IAAI,GAAG,EAA8B,CAAC;IAErD,KAAK,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,oBAAoB,CACjD,MAAM,CAAC,QAAQ,CAAC,eAAe,CAChC,EAAE,CAAC;QACF,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACnC,GAAG,IAAI;YACP,OAAO,EAAE,oBAAoB,CAAC,IAAI,CAAC;SACpC,CAAC,CAAC,CAAC;QACJ,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE;YAClB,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YAC3B,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;SACpC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/esm/jbcenter.d.ts
CHANGED
|
@@ -28,6 +28,8 @@ export type JBCenterDeploymentCall = {
|
|
|
28
28
|
};
|
|
29
29
|
export type { JBCenterDecodedLaunch } from "./jbcenter/decode.js";
|
|
30
30
|
export { decodeDeploymentCall } from "./jbcenter/decode.js";
|
|
31
|
+
export type { JBCenterChainCalls, JBCenterDecodedCall, } from "./jbcenter/setupCalls.js";
|
|
32
|
+
export { intentCalls } from "./jbcenter/setupCalls.js";
|
|
31
33
|
export type { JBCenterIntentRow } from "./jbcenter/merge.js";
|
|
32
34
|
export { deployedChains, intentPath, intentRow, isFullyDeployed, mergeSearch, } from "./jbcenter/merge.js";
|
|
33
35
|
export type { EnsureDeployedOptions, EnsureDeployedStep, } from "./jbcenter/ensureDeployed.js";
|
|
@@ -72,8 +74,37 @@ export type JBCenterDeployment = {
|
|
|
72
74
|
projectId: string;
|
|
73
75
|
transactionHash: Hex;
|
|
74
76
|
createdAt: string;
|
|
77
|
+
/**
|
|
78
|
+
* Whether the launch reached the chain through JB Center's forwarder, so its
|
|
79
|
+
* sender was Center's sponsor. Absent means a wallet sent it directly.
|
|
80
|
+
*/
|
|
81
|
+
forwarded?: boolean;
|
|
82
|
+
};
|
|
83
|
+
export type JBCenterDeploymentInput = Omit<JBCenterDeployment, "createdAt" | "forwarded">;
|
|
84
|
+
/** One call a relay request asks the sender to make before the launch. */
|
|
85
|
+
export type JBCenterRelayCall = {
|
|
86
|
+
to: Address;
|
|
87
|
+
data: Hex;
|
|
88
|
+
value: bigint;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* The forward request JB Center's sponsor signed for a chain it does not
|
|
92
|
+
* sponsor. The forwarder reports the sponsor as the sender, so a chain
|
|
93
|
+
* deployed this way keeps the token and sucker addresses every sponsored
|
|
94
|
+
* chain in the intent gets; whoever sends it supplies only gas and the
|
|
95
|
+
* creation fee. `setup` runs first, from the same wallet, in order.
|
|
96
|
+
*/
|
|
97
|
+
export type JBCenterRelayRequest = {
|
|
98
|
+
chainId: number;
|
|
99
|
+
to: Address;
|
|
100
|
+
data: Hex;
|
|
101
|
+
/** Wei the forwarder requires with the call: the chain's creation fee. */
|
|
102
|
+
value: bigint;
|
|
103
|
+
gas: bigint;
|
|
104
|
+
/** Unix seconds after which the forwarder refuses the request. */
|
|
105
|
+
deadline: number;
|
|
106
|
+
setup: JBCenterRelayCall[];
|
|
75
107
|
};
|
|
76
|
-
export type JBCenterDeploymentInput = Omit<JBCenterDeployment, "createdAt">;
|
|
77
108
|
export type JBCenterIntentDeploy = {
|
|
78
109
|
chainId: number;
|
|
79
110
|
status: "queued" | "sent" | "confirmed" | "failed";
|
|
@@ -95,6 +126,11 @@ export type JBCenterIntent<TJb extends JBCenterJsonObject = JBCenterJsonObject>
|
|
|
95
126
|
deploys: JBCenterIntentDeploy[];
|
|
96
127
|
};
|
|
97
128
|
export declare const JBCENTER_SPONSORED_CHAIN_IDS: readonly number[];
|
|
129
|
+
/** The chains in the list JB Center's sponsor covers, in the order given. */
|
|
130
|
+
export declare function sponsorableChains(chainIds: readonly number[]): number[];
|
|
131
|
+
/** The chains in the list JB Center's sponsor does not cover. */
|
|
132
|
+
export declare function unsponsoredChains(chainIds: readonly number[]): number[];
|
|
133
|
+
/** Whether JB Center's sponsor covers every chain in a non-empty list. */
|
|
98
134
|
export declare function isSponsorable(chainIds: readonly number[]): boolean;
|
|
99
135
|
export type JBCenterSearchItem = JBCenterIntentMetadata & {
|
|
100
136
|
source: "jbcenter";
|
|
@@ -165,9 +201,24 @@ export declare class JBCenterClient {
|
|
|
165
201
|
getIntent<TJb extends JBCenterJsonObject = JBCenterJsonObject>(intentId: string, options?: JBCenterRequestOptions): Promise<JBCenterIntent<TJb>>;
|
|
166
202
|
searchIntents(params?: JBCenterSearchParams, options?: JBCenterRequestOptions): Promise<JBCenterSearchPage>;
|
|
167
203
|
recordDeployment(intentId: string, deployment: JBCenterDeploymentInput, options?: JBCenterRequestOptions): Promise<JBCenterDeployment>;
|
|
168
|
-
|
|
204
|
+
/**
|
|
205
|
+
* Asks JB Center's sponsor to deploy the intent. `chainIds` narrows the
|
|
206
|
+
* request to those chains; omitted or empty, it means every sponsored chain
|
|
207
|
+
* that has no deployment yet. Chains already queued or sent come back as
|
|
208
|
+
* they are.
|
|
209
|
+
*/
|
|
210
|
+
requestDeploy(intentId: string, options?: JBCenterRequestOptions & {
|
|
211
|
+
chainIds?: readonly number[];
|
|
212
|
+
}): Promise<{
|
|
169
213
|
deploys: JBCenterIntentDeploy[];
|
|
170
214
|
}>;
|
|
215
|
+
/**
|
|
216
|
+
* The forward request JB Center's sponsor signed for one chain it does not
|
|
217
|
+
* sponsor. Nothing is stored and nothing is paid until someone sends it.
|
|
218
|
+
* Two callers who ask for the same chain get the same forwarder nonce, so
|
|
219
|
+
* the second transaction reverts and the caller asks again.
|
|
220
|
+
*/
|
|
221
|
+
requestRelay(intentId: string, chainId: number, options?: JBCenterRequestOptions): Promise<JBCenterRelayRequest>;
|
|
171
222
|
pinJson(value: JBCenterJsonObject, options?: JBCenterRequestOptions): Promise<JBCenterPin>;
|
|
172
223
|
pinImage(content: Blob, options?: JBCenterRequestOptions & {
|
|
173
224
|
filename?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jbcenter.d.ts","sourceRoot":"","sources":["../../src/jbcenter.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,GAAG,EACR,KAAK,OAAO,EACZ,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,GAAG,EACT,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"jbcenter.d.ts","sourceRoot":"","sources":["../../src/jbcenter.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,GAAG,EACR,KAAK,OAAO,EACZ,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,GAAG,EACT,MAAM,MAAM,CAAC;AAMd,eAAO,MAAM,oBAAoB,4BAA4B,CAAC;AAC9D,eAAO,MAAM,2BAA2B,QAAS,CAAC;AAClD,eAAO,MAAM,8BAA8B,QAAS,CAAC;AACrD,eAAO,MAAM,uBAAuB,SAAU,CAAC;AAC/C,eAAO,MAAM,2BAA2B,QAAmB,CAAC;AAE5D,eAAO,MAAM,oBAAoB,qnBA4BvB,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;CAC7B,CAAC;AAEF,kFAAkF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D,OAAO,CAAC,OAAO;YAkBD,SAAS;CAyExB;AAED,wBAAgB,oBAAoB,CAClC,OAAO,GAAE,qBAA0B,GAClC,cAAc,CAEhB;AAED,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,qBAA0B,GAClC,mBAAmB,CAErB"}
|
package/dist/esm/jbcenter.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { encodeFunctionData, } from "viem";
|
|
2
|
+
import { groupDeploymentCalls, isValidDeploymentCalls, } from "./jbcenter/setupCalls.js";
|
|
2
3
|
export const JBCENTER_DEFAULT_URL = "https://juicebox.center";
|
|
3
4
|
export const JBCENTER_REQUEST_TIMEOUT_MS = 15_000;
|
|
4
5
|
export const JBCENTER_DEPLOYMENT_TIMEOUT_MS = 45_000;
|
|
@@ -34,6 +35,7 @@ export const JBCENTER_RPC_METHODS = [
|
|
|
34
35
|
"net_version",
|
|
35
36
|
];
|
|
36
37
|
export { decodeDeploymentCall } from "./jbcenter/decode.js";
|
|
38
|
+
export { intentCalls } from "./jbcenter/setupCalls.js";
|
|
37
39
|
export { deployedChains, intentPath, intentRow, isFullyDeployed, mergeSearch, } from "./jbcenter/merge.js";
|
|
38
40
|
export { EnsureDeployedError, ensureDeployed, } from "./jbcenter/ensureDeployed.js";
|
|
39
41
|
export { JBCenterIntentMismatchError, publishSignedIntent, } from "./jbcenter/publish.js";
|
|
@@ -50,9 +52,17 @@ export function createJBCenterDeploymentCall(request) {
|
|
|
50
52
|
export const JBCENTER_SPONSORED_CHAIN_IDS = Object.freeze([
|
|
51
53
|
10, 8453, 42161, 11155111, 11155420, 84532, 421614,
|
|
52
54
|
]);
|
|
55
|
+
/** The chains in the list JB Center's sponsor covers, in the order given. */
|
|
56
|
+
export function sponsorableChains(chainIds) {
|
|
57
|
+
return chainIds.filter((id) => JBCENTER_SPONSORED_CHAIN_IDS.includes(id));
|
|
58
|
+
}
|
|
59
|
+
/** The chains in the list JB Center's sponsor does not cover. */
|
|
60
|
+
export function unsponsoredChains(chainIds) {
|
|
61
|
+
return chainIds.filter((id) => !JBCENTER_SPONSORED_CHAIN_IDS.includes(id));
|
|
62
|
+
}
|
|
63
|
+
/** Whether JB Center's sponsor covers every chain in a non-empty list. */
|
|
53
64
|
export function isSponsorable(chainIds) {
|
|
54
|
-
return
|
|
55
|
-
chainIds.every((id) => JBCENTER_SPONSORED_CHAIN_IDS.includes(id)));
|
|
65
|
+
return chainIds.length > 0 && unsponsoredChains(chainIds).length === 0;
|
|
56
66
|
}
|
|
57
67
|
export class JBCenterRequestError extends Error {
|
|
58
68
|
constructor(message, status, code, requestId, retryAfter) {
|
|
@@ -119,13 +129,39 @@ function isNumberArray(value) {
|
|
|
119
129
|
return (Array.isArray(value) &&
|
|
120
130
|
value.every((item) => Number.isSafeInteger(item) && Number(item) > 0));
|
|
121
131
|
}
|
|
132
|
+
function isCalldata(value) {
|
|
133
|
+
return typeof value === "string" && /^0x(?:[0-9a-f]{2}){4,}$/iu.test(value);
|
|
134
|
+
}
|
|
135
|
+
function isDecimalString(value) {
|
|
136
|
+
return typeof value === "string" && /^(?:0|[1-9][0-9]*)$/u.test(value);
|
|
137
|
+
}
|
|
122
138
|
function isDeploymentCall(value) {
|
|
123
139
|
return (record(value) &&
|
|
124
140
|
Number.isSafeInteger(value.chainId) &&
|
|
125
141
|
Number(value.chainId) > 0 &&
|
|
126
142
|
isAddress(value.to) &&
|
|
127
|
-
|
|
128
|
-
|
|
143
|
+
isCalldata(value.data));
|
|
144
|
+
}
|
|
145
|
+
/** Setup calls carry no value of their own; only the forwarder call does. */
|
|
146
|
+
function isRelayCall(value) {
|
|
147
|
+
return (record(value) &&
|
|
148
|
+
isAddress(value.to) &&
|
|
149
|
+
isCalldata(value.data) &&
|
|
150
|
+
value.value === "0");
|
|
151
|
+
}
|
|
152
|
+
/** Wei and gas cross the wire as decimal strings, so no precision is lost. */
|
|
153
|
+
function relayRequest(chainId) {
|
|
154
|
+
return (value) => record(value) &&
|
|
155
|
+
value.chainId === chainId &&
|
|
156
|
+
isAddress(value.to) &&
|
|
157
|
+
isCalldata(value.data) &&
|
|
158
|
+
isDecimalString(value.value) &&
|
|
159
|
+
isDecimalString(value.gas) &&
|
|
160
|
+
value.gas !== "0" &&
|
|
161
|
+
Number.isSafeInteger(value.deadline) &&
|
|
162
|
+
Number(value.deadline) > 0 &&
|
|
163
|
+
Array.isArray(value.setup) &&
|
|
164
|
+
value.setup.every(isRelayCall);
|
|
129
165
|
}
|
|
130
166
|
function isEnvelope(value) {
|
|
131
167
|
if (!record(value) ||
|
|
@@ -138,15 +174,15 @@ function isEnvelope(value) {
|
|
|
138
174
|
return false;
|
|
139
175
|
}
|
|
140
176
|
if (!Array.isArray(value.deploymentCalls) ||
|
|
141
|
-
!value.deploymentCalls.every(isDeploymentCall)
|
|
142
|
-
value.deploymentCalls.length !== value.chainIds.length) {
|
|
177
|
+
!value.deploymentCalls.every(isDeploymentCall)) {
|
|
143
178
|
return false;
|
|
144
179
|
}
|
|
180
|
+
const calls = value.deploymentCalls;
|
|
181
|
+
if (!isValidDeploymentCalls(calls))
|
|
182
|
+
return false;
|
|
145
183
|
const chains = [...value.chainIds].sort((a, b) => a - b);
|
|
146
|
-
const callChains =
|
|
147
|
-
|
|
148
|
-
.sort((a, b) => a - b);
|
|
149
|
-
return (new Set(callChains).size === callChains.length &&
|
|
184
|
+
const callChains = [...groupDeploymentCalls(calls).keys()].sort((a, b) => a - b);
|
|
185
|
+
return (callChains.length === chains.length &&
|
|
150
186
|
chains.every((chainId, index) => callChains[index] === chainId));
|
|
151
187
|
}
|
|
152
188
|
function isMetadata(value) {
|
|
@@ -164,7 +200,8 @@ function isDeployment(value) {
|
|
|
164
200
|
typeof value.projectId === "string" &&
|
|
165
201
|
/^[0-9]+$/u.test(value.projectId) &&
|
|
166
202
|
isHash(value.transactionHash) &&
|
|
167
|
-
typeof value.createdAt === "string"
|
|
203
|
+
typeof value.createdAt === "string" &&
|
|
204
|
+
(value.forwarded === undefined || typeof value.forwarded === "boolean"));
|
|
168
205
|
}
|
|
169
206
|
const JBCENTER_DEPLOY_STATUSES = [
|
|
170
207
|
"queued",
|
|
@@ -352,8 +389,44 @@ export class JBCenterClient {
|
|
|
352
389
|
timeoutMs: options?.timeoutMs ?? JBCENTER_DEPLOYMENT_TIMEOUT_MS,
|
|
353
390
|
});
|
|
354
391
|
}
|
|
392
|
+
/**
|
|
393
|
+
* Asks JB Center's sponsor to deploy the intent. `chainIds` narrows the
|
|
394
|
+
* request to those chains; omitted or empty, it means every sponsored chain
|
|
395
|
+
* that has no deployment yet. Chains already queued or sent come back as
|
|
396
|
+
* they are.
|
|
397
|
+
*/
|
|
355
398
|
requestDeploy(intentId, options) {
|
|
356
|
-
return this.fetchJson(`v1/intents/${encodeURIComponent(intentId)}/deploy`,
|
|
399
|
+
return this.fetchJson(`v1/intents/${encodeURIComponent(intentId)}/deploy`, options?.chainIds?.length
|
|
400
|
+
? {
|
|
401
|
+
method: "POST",
|
|
402
|
+
body: JSON.stringify({ chainIds: options.chainIds }),
|
|
403
|
+
}
|
|
404
|
+
: { method: "POST" }, isDeployResponse, options);
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* The forward request JB Center's sponsor signed for one chain it does not
|
|
408
|
+
* sponsor. Nothing is stored and nothing is paid until someone sends it.
|
|
409
|
+
* Two callers who ask for the same chain get the same forwarder nonce, so
|
|
410
|
+
* the second transaction reverts and the caller asks again.
|
|
411
|
+
*/
|
|
412
|
+
async requestRelay(intentId, chainId, options) {
|
|
413
|
+
if (!Number.isSafeInteger(chainId) || chainId <= 0) {
|
|
414
|
+
throw new TypeError("chainId must be a positive safe integer");
|
|
415
|
+
}
|
|
416
|
+
const body = await this.fetchJson(`v1/intents/${encodeURIComponent(intentId)}/relay`, { method: "POST", body: JSON.stringify({ chainId }) }, relayRequest(chainId), options);
|
|
417
|
+
return {
|
|
418
|
+
chainId: body.chainId,
|
|
419
|
+
to: body.to,
|
|
420
|
+
data: body.data,
|
|
421
|
+
value: BigInt(body.value),
|
|
422
|
+
gas: BigInt(body.gas),
|
|
423
|
+
deadline: body.deadline,
|
|
424
|
+
setup: body.setup.map((call) => ({
|
|
425
|
+
to: call.to,
|
|
426
|
+
data: call.data,
|
|
427
|
+
value: BigInt(call.value),
|
|
428
|
+
})),
|
|
429
|
+
};
|
|
357
430
|
}
|
|
358
431
|
pinJson(value, options) {
|
|
359
432
|
return this.fetchJson("v1/pins/json", { method: "POST", body: JSON.stringify(value) }, isPin, { ...options, timeoutMs: options?.timeoutMs ?? JBCENTER_PIN_TIMEOUT_MS });
|