@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
|
@@ -44,6 +44,15 @@ export type JBCenterDecodedLaunch = {
|
|
|
44
44
|
mustStartAtOrAfter: number;
|
|
45
45
|
salt: Hex;
|
|
46
46
|
peerSuckerDeployers: readonly Address[];
|
|
47
|
+
} | {
|
|
48
|
+
flavor: "safe-create";
|
|
49
|
+
to: Address;
|
|
50
|
+
singleton: Address;
|
|
51
|
+
saltNonce: Hex;
|
|
52
|
+
owners: readonly Address[];
|
|
53
|
+
threshold: number;
|
|
54
|
+
fallbackHandler: Address;
|
|
55
|
+
address: Address;
|
|
47
56
|
} | {
|
|
48
57
|
flavor: "unknown";
|
|
49
58
|
to: Address;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decode.d.ts","sourceRoot":"","sources":["../../../src/jbcenter/decode.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"decode.d.ts","sourceRoot":"","sources":["../../../src/jbcenter/decode.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,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;AAW7D,MAAM,MAAM,qBAAqB,GAC7B;I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O,EAAE,CAAC;CACzC,GACD;IACE,MAAM,EAAE,aAAa,CAAC;IACtB,EAAE,EAAE,OAAO,CAAC;IACZ,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,GAAG,CAAC;IACf,MAAM,EAAE,SAAS,OAAO,EAAE,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,OAAO,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;CAClB,GACD;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,EAAE,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,GAAG,CAAA;CAAE,CAAC;AA2StD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,sBAAsB,GAC3B,qBAAqB,CAMvB"}
|
|
@@ -4,6 +4,7 @@ exports.decodeDeploymentCall = decodeDeploymentCall;
|
|
|
4
4
|
const viem_1 = require("viem");
|
|
5
5
|
const juicebox_js_1 = require("../generated/juicebox.js");
|
|
6
6
|
const types_js_1 = require("../v6/types.js");
|
|
7
|
+
const safe_js_1 = require("../safe.js");
|
|
7
8
|
/** The address of `contract` on `chainId`, or null when it isn't deployed there. */
|
|
8
9
|
function addressFor(contract, chainId) {
|
|
9
10
|
try {
|
|
@@ -175,7 +176,82 @@ function decodeHomerunFundLaunch(call) {
|
|
|
175
176
|
return null;
|
|
176
177
|
}
|
|
177
178
|
}
|
|
179
|
+
/** JB Center's ceiling on the owners one intent's Safe may carry. */
|
|
180
|
+
const MAX_INTENT_SAFE_OWNERS = 20;
|
|
181
|
+
/**
|
|
182
|
+
* A setup call: `createProxyWithNonce` to the canonical Safe factory, for the
|
|
183
|
+
* canonical singleton and fallback handler, with no delegatecall hook and no
|
|
184
|
+
* setup payment. The address is the one the factory would compute, derived
|
|
185
|
+
* from the pinned proxy creation code, so nothing here reaches a chain.
|
|
186
|
+
*/
|
|
187
|
+
function decodeSafeCreate(call) {
|
|
188
|
+
try {
|
|
189
|
+
if (!(0, viem_1.isAddressEqual)(safe_js_1.SAFE_FACTORY, call.to))
|
|
190
|
+
return null;
|
|
191
|
+
const create = (0, viem_1.decodeFunctionData)({
|
|
192
|
+
abi: safe_js_1.SAFE_CREATE_ABI,
|
|
193
|
+
data: call.data,
|
|
194
|
+
});
|
|
195
|
+
if (create.functionName !== "createProxyWithNonce")
|
|
196
|
+
return null;
|
|
197
|
+
const [singleton, initializer, nonce] = create.args;
|
|
198
|
+
if (!(0, viem_1.isAddressEqual)(singleton, safe_js_1.SAFE_SINGLETON))
|
|
199
|
+
return null;
|
|
200
|
+
const setup = (0, viem_1.decodeFunctionData)({
|
|
201
|
+
abi: safe_js_1.SAFE_CREATE_ABI,
|
|
202
|
+
data: initializer,
|
|
203
|
+
});
|
|
204
|
+
if (setup.functionName !== "setup")
|
|
205
|
+
return null;
|
|
206
|
+
const [owners, threshold, to, data, fallbackHandler, paymentToken, payment, paymentReceiver,] = setup.args;
|
|
207
|
+
if (owners.length < 1 ||
|
|
208
|
+
owners.length > MAX_INTENT_SAFE_OWNERS ||
|
|
209
|
+
owners.some((owner) => BigInt(owner) === 0n) ||
|
|
210
|
+
new Set(owners.map((owner) => owner.toLowerCase())).size !==
|
|
211
|
+
owners.length ||
|
|
212
|
+
threshold < 1n ||
|
|
213
|
+
threshold > BigInt(owners.length) ||
|
|
214
|
+
!(0, viem_1.isAddressEqual)(to, viem_1.zeroAddress) ||
|
|
215
|
+
data !== "0x" ||
|
|
216
|
+
!(0, viem_1.isAddressEqual)(fallbackHandler, safe_js_1.SAFE_FALLBACK) ||
|
|
217
|
+
!(0, viem_1.isAddressEqual)(paymentToken, viem_1.zeroAddress) ||
|
|
218
|
+
payment !== 0n ||
|
|
219
|
+
!(0, viem_1.isAddressEqual)(paymentReceiver, viem_1.zeroAddress)) {
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
const plan = {
|
|
223
|
+
owners: [...owners],
|
|
224
|
+
threshold: Number(threshold),
|
|
225
|
+
saltNonce: (0, viem_1.toHex)(nonce, { size: 32 }),
|
|
226
|
+
proxyCreationCode: safe_js_1.SAFE_PROXY_CREATION_CODE,
|
|
227
|
+
};
|
|
228
|
+
// Only the canonical encoding predicts the address the factory computes,
|
|
229
|
+
// so the call has to be exactly what this plan re-encodes to. This also
|
|
230
|
+
// refuses the sentinel owner, which `buildSafeInitializer` rejects.
|
|
231
|
+
if ((0, viem_1.encodeFunctionData)({
|
|
232
|
+
abi: safe_js_1.SAFE_CREATE_ABI,
|
|
233
|
+
functionName: "createProxyWithNonce",
|
|
234
|
+
args: [safe_js_1.SAFE_SINGLETON, (0, safe_js_1.buildSafeInitializer)(plan), nonce],
|
|
235
|
+
}).toLowerCase() !== call.data.toLowerCase()) {
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
return {
|
|
239
|
+
flavor: "safe-create",
|
|
240
|
+
to: call.to,
|
|
241
|
+
singleton,
|
|
242
|
+
saltNonce: plan.saltNonce,
|
|
243
|
+
owners: plan.owners,
|
|
244
|
+
threshold: plan.threshold,
|
|
245
|
+
fallbackHandler,
|
|
246
|
+
address: (0, safe_js_1.predictSafeAddress)(plan),
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
catch {
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
178
253
|
const DECODERS = [
|
|
254
|
+
decodeSafeCreate,
|
|
179
255
|
decodeProjectLaunch,
|
|
180
256
|
decodeProject721Launch,
|
|
181
257
|
decodeOmnichainLaunch,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decode.js","sourceRoot":"","sources":["../../../src/jbcenter/decode.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"decode.js","sourceRoot":"","sources":["../../../src/jbcenter/decode.ts"],"names":[],"mappings":";;AA2YA,oDAQC;AAnZD,+BAUc;AACd,0DAKkC;AAMlC,6CAA4D;AAE5D,wCAQoB;AA4DpB,oFAAoF;AACpF,SAAS,UAAU,CAAC,QAAoB,EA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IAChB,mBAAmB;IACnB,sBAAsB;IACtB,qBAAqB;IACrB,kBAAkB;IAClB,uBAAuB;CACxB,CAAC;AAEF;;;;;GAKG;AACH,SAAgB,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,IAAA,YAAK,EAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;AAC9E,CAAC"}
|
|
@@ -1,14 +1,33 @@
|
|
|
1
1
|
import type { Hex } from "viem";
|
|
2
|
-
import { type JBCenterClient, type JBCenterDeploymentCall, type JBCenterDeploymentInput, type JBCenterIntent, type JBCenterJsonObject } from "../jbcenter.js";
|
|
2
|
+
import { type JBCenterClient, type JBCenterDeploymentCall, type JBCenterDeploymentInput, type JBCenterIntent, type JBCenterJsonObject, type JBCenterRelayRequest } from "../jbcenter.js";
|
|
3
3
|
export type EnsureDeployedStep = {
|
|
4
4
|
chainId: number;
|
|
5
|
-
status: "queued" | "sent" | "confirmed" | "failed" | "self-paid";
|
|
5
|
+
status: "queued" | "sent" | "confirmed" | "failed" | "self-paid" | "relay-paid";
|
|
6
6
|
transactionHash?: Hex;
|
|
7
7
|
};
|
|
8
8
|
export type EnsureDeployedOptions = {
|
|
9
9
|
client: JBCenterClient;
|
|
10
10
|
intent: JBCenterIntent<JBCenterJsonObject>;
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* The chains this run covers, each one of the intent's own. Omitted, the
|
|
13
|
+
* run is every chain in the intent.
|
|
14
|
+
*/
|
|
15
|
+
chainIds?: readonly number[];
|
|
16
|
+
/**
|
|
17
|
+
* Sends the forward request JB Center signed for a chain it does not
|
|
18
|
+
* sponsor, and returns the deployment that transaction produced. The
|
|
19
|
+
* request's `setup` calls go first, from the same wallet, in order. The
|
|
20
|
+
* forwarder keeps Center's sponsor as the sender, so a chain paid for this
|
|
21
|
+
* way pairs with every sponsored chain in the intent.
|
|
22
|
+
*/
|
|
23
|
+
relayPaid?: (request: JBCenterRelayRequest) => Promise<JBCenterDeploymentInput>;
|
|
24
|
+
/**
|
|
25
|
+
* Runs the client's own launch pipeline for every remaining chain in the
|
|
26
|
+
* run. The caller's wallet is then the sender, which a deployer that scopes
|
|
27
|
+
* its token and sucker salt to the sender turns into a different token and
|
|
28
|
+
* sucker address per chain; `relayPaid` keeps Center's sponsor as the
|
|
29
|
+
* sender instead.
|
|
30
|
+
*/
|
|
12
31
|
selfPaid?: (calls: JBCenterDeploymentCall[]) => Promise<JBCenterDeploymentInput[]>;
|
|
13
32
|
onStep?: (step: EnsureDeployedStep) => void;
|
|
14
33
|
pollMs?: number;
|
|
@@ -21,9 +40,9 @@ export declare class EnsureDeployedError extends Error {
|
|
|
21
40
|
}
|
|
22
41
|
/**
|
|
23
42
|
* The pre-step every webclient runs before the first on-chain write against
|
|
24
|
-
* an undeployed intent: sponsor the deploy through JB Center
|
|
25
|
-
*
|
|
26
|
-
*
|
|
43
|
+
* an undeployed intent: sponsor the deploy through JB Center for the chains
|
|
44
|
+
* it covers, hand the rest to the caller's own sender, and poll until the
|
|
45
|
+
* run's chains land. `chainIds` narrows the run to part of the intent.
|
|
27
46
|
*/
|
|
28
47
|
export declare function ensureDeployed(options: EnsureDeployedOptions): Promise<Record<number, string>>;
|
|
29
48
|
//# sourceMappingURL=ensureDeployed.d.ts.map
|
|
@@ -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,
|
|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M,YAAA;CAK5B;AAuRD;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAsEjC"}
|
|
@@ -37,6 +37,29 @@ function sleep(ms, signal) {
|
|
|
37
37
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* The chains this run covers, in the intent's own order. Naming a chain the
|
|
42
|
+
* intent does not carry is a caller mistake, not a deploy failure.
|
|
43
|
+
*/
|
|
44
|
+
function runChains(intent, chainIds) {
|
|
45
|
+
if (!chainIds)
|
|
46
|
+
return [...intent.envelope.chainIds];
|
|
47
|
+
const requested = new Set(chainIds);
|
|
48
|
+
for (const chainId of requested) {
|
|
49
|
+
if (!intent.envelope.chainIds.includes(chainId)) {
|
|
50
|
+
throw new EnsureDeployedError(`Chain ${chainId} is not part of this intent`, chainId);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const run = intent.envelope.chainIds.filter((id) => requested.has(id));
|
|
54
|
+
if (run.length === 0) {
|
|
55
|
+
throw new EnsureDeployedError("ensureDeployed was given no chains to run");
|
|
56
|
+
}
|
|
57
|
+
return run;
|
|
58
|
+
}
|
|
59
|
+
function isRunDeployed(intent, run) {
|
|
60
|
+
const deployed = (0, merge_js_1.deployedChains)(intent);
|
|
61
|
+
return run.every((chainId) => chainId in deployed);
|
|
62
|
+
}
|
|
40
63
|
function reportSteps(deploys, seen, onStep) {
|
|
41
64
|
let failedChainId;
|
|
42
65
|
for (const deploy of deploys) {
|
|
@@ -56,14 +79,14 @@ function reportSteps(deploys, seen, onStep) {
|
|
|
56
79
|
throw new EnsureDeployedError(`JB Center could not deploy chain ${failedChainId}`, failedChainId);
|
|
57
80
|
}
|
|
58
81
|
}
|
|
59
|
-
async function pollUntilDeployed(client, seed, pollMs, timeoutMs, signal, onStep) {
|
|
82
|
+
async function pollUntilDeployed(client, seed, run, pollMs, timeoutMs, signal, onStep) {
|
|
60
83
|
const seen = new Map();
|
|
61
84
|
const startedAt = Date.now();
|
|
62
85
|
let current = seed;
|
|
63
86
|
while (true) {
|
|
64
87
|
checkAborted(signal);
|
|
65
88
|
reportSteps(current.deploys, seen, onStep);
|
|
66
|
-
if ((
|
|
89
|
+
if (isRunDeployed(current, run)) {
|
|
67
90
|
return (0, merge_js_1.deployedChains)(current);
|
|
68
91
|
}
|
|
69
92
|
if (Date.now() - startedAt >= timeoutMs) {
|
|
@@ -73,13 +96,13 @@ async function pollUntilDeployed(client, seed, pollMs, timeoutMs, signal, onStep
|
|
|
73
96
|
current = await client.getIntent(current.id, { signal });
|
|
74
97
|
}
|
|
75
98
|
}
|
|
76
|
-
async function runSelfPaid(client, intent, selfPaid, onStep, signal) {
|
|
99
|
+
async function runSelfPaid(client, intent, run, selfPaid, onStep, signal) {
|
|
77
100
|
if (!selfPaid) {
|
|
78
101
|
throw new EnsureDeployedError("JB Center cannot sponsor this deploy and no self-paid fallback was provided");
|
|
79
102
|
}
|
|
80
103
|
checkAborted(signal);
|
|
81
104
|
const deployed = (0, merge_js_1.deployedChains)(intent);
|
|
82
|
-
const remainingCalls = intent.envelope.deploymentCalls.filter((call) => !(call.chainId in deployed));
|
|
105
|
+
const remainingCalls = intent.envelope.deploymentCalls.filter((call) => run.includes(call.chainId) && !(call.chainId in deployed));
|
|
83
106
|
const deployments = await selfPaid(remainingCalls);
|
|
84
107
|
const remainingChainIds = new Set(remainingCalls.map((call) => call.chainId));
|
|
85
108
|
const returnedChainIds = new Set();
|
|
@@ -111,43 +134,101 @@ async function runSelfPaid(client, intent, selfPaid, onStep, signal) {
|
|
|
111
134
|
return result;
|
|
112
135
|
}
|
|
113
136
|
/**
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
137
|
+
* Whether a wallet sent one of the chains an intent has already landed. Every
|
|
138
|
+
* chain in an intent belongs to one sender, and a deployment JB Center's
|
|
139
|
+
* forwarder did not carry was sent by the caller's own wallet.
|
|
140
|
+
*/
|
|
141
|
+
function walletSent(intent) {
|
|
142
|
+
return intent.deployments.some((deployment) => deployment.forwarded !== true);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* The sender an intent already has, or `undefined` when JB Center's sponsor is
|
|
146
|
+
* still free to take the run. A deployment a wallet sent pins the intent to
|
|
147
|
+
* `selfPaid`; deployments the forwarder carried leave the sponsor path open,
|
|
148
|
+
* because every one of them reports Center's sponsor as the sender.
|
|
117
149
|
*/
|
|
118
|
-
function existingSender(options, intent,
|
|
150
|
+
function existingSender(options, intent, run) {
|
|
119
151
|
const { client, onStep, selfPaid, signal } = options;
|
|
120
|
-
if ((
|
|
152
|
+
if (isRunDeployed(intent, run)) {
|
|
121
153
|
return Promise.resolve((0, merge_js_1.deployedChains)(intent));
|
|
122
154
|
}
|
|
123
|
-
if (intent
|
|
124
|
-
return
|
|
125
|
-
}
|
|
126
|
-
if (intent.deployments.length > 0) {
|
|
127
|
-
return runSelfPaid(client, intent, selfPaid, onStep, signal);
|
|
155
|
+
if (walletSent(intent)) {
|
|
156
|
+
return runSelfPaid(client, intent, run, selfPaid, onStep, signal);
|
|
128
157
|
}
|
|
129
158
|
return undefined;
|
|
130
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* Center's lane for the chains it sponsors and the caller's own sender for
|
|
162
|
+
* the chains it does not, in one run. The sponsored chains are queued first,
|
|
163
|
+
* in one request, so Center works while the visitor is still signing.
|
|
164
|
+
*/
|
|
165
|
+
async function runRelayPaid(options, relayPaid, run, pollMs, timeoutMs) {
|
|
166
|
+
const { client, intent, onStep, signal } = options;
|
|
167
|
+
checkAborted(signal);
|
|
168
|
+
const result = (0, merge_js_1.deployedChains)(intent);
|
|
169
|
+
const remaining = run.filter((chainId) => !(chainId in result));
|
|
170
|
+
const sponsored = (0, jbcenter_js_1.sponsorableChains)(remaining);
|
|
171
|
+
let deploys = [];
|
|
172
|
+
if (sponsored.length > 0) {
|
|
173
|
+
({ deploys } = await client.requestDeploy(intent.id, {
|
|
174
|
+
chainIds: sponsored,
|
|
175
|
+
signal,
|
|
176
|
+
}));
|
|
177
|
+
}
|
|
178
|
+
for (const chainId of (0, jbcenter_js_1.unsponsoredChains)(remaining)) {
|
|
179
|
+
checkAborted(signal);
|
|
180
|
+
const request = await client.requestRelay(intent.id, chainId, { signal });
|
|
181
|
+
const deployment = await relayPaid(request);
|
|
182
|
+
if (deployment.chainId !== chainId) {
|
|
183
|
+
throw new EnsureDeployedError(`Relay-paid deploy returned chain ${deployment.chainId} for chain ${chainId}`, chainId);
|
|
184
|
+
}
|
|
185
|
+
await client.recordDeployment(intent.id, deployment, { signal });
|
|
186
|
+
result[chainId] = deployment.projectId;
|
|
187
|
+
onStep?.({
|
|
188
|
+
chainId,
|
|
189
|
+
status: "relay-paid",
|
|
190
|
+
transactionHash: deployment.transactionHash,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
if (sponsored.length === 0)
|
|
194
|
+
return result;
|
|
195
|
+
return {
|
|
196
|
+
...result,
|
|
197
|
+
...(await pollUntilDeployed(client, { ...intent, deploys }, remaining, pollMs, timeoutMs, signal, onStep)),
|
|
198
|
+
};
|
|
199
|
+
}
|
|
131
200
|
/**
|
|
132
201
|
* The pre-step every webclient runs before the first on-chain write against
|
|
133
|
-
* an undeployed intent: sponsor the deploy through JB Center
|
|
134
|
-
*
|
|
135
|
-
*
|
|
202
|
+
* an undeployed intent: sponsor the deploy through JB Center for the chains
|
|
203
|
+
* it covers, hand the rest to the caller's own sender, and poll until the
|
|
204
|
+
* run's chains land. `chainIds` narrows the run to part of the intent.
|
|
136
205
|
*/
|
|
137
206
|
async function ensureDeployed(options) {
|
|
138
|
-
const { client, intent, onStep, selfPaid, signal } = options;
|
|
207
|
+
const { client, intent, onStep, relayPaid, selfPaid, signal } = options;
|
|
139
208
|
const pollMs = options.pollMs ?? DEFAULT_POLL_MS;
|
|
140
209
|
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
141
|
-
|
|
210
|
+
if (relayPaid && selfPaid) {
|
|
211
|
+
throw new EnsureDeployedError("ensureDeployed takes relayPaid or selfPaid, never both");
|
|
212
|
+
}
|
|
213
|
+
const run = runChains(intent, options.chainIds);
|
|
214
|
+
const started = existingSender(options, intent, run);
|
|
142
215
|
if (started)
|
|
143
216
|
return started;
|
|
144
|
-
if (
|
|
145
|
-
return
|
|
217
|
+
if (relayPaid) {
|
|
218
|
+
return runRelayPaid(options, relayPaid, run, pollMs, timeoutMs);
|
|
219
|
+
}
|
|
220
|
+
if (!(0, jbcenter_js_1.isSponsorable)(run)) {
|
|
221
|
+
return runSelfPaid(client, intent, run, selfPaid, onStep, signal);
|
|
146
222
|
}
|
|
223
|
+
const deployed = (0, merge_js_1.deployedChains)(intent);
|
|
224
|
+
const pending = run.filter((chainId) => !(chainId in deployed));
|
|
147
225
|
let deploys;
|
|
148
226
|
try {
|
|
149
227
|
checkAborted(signal);
|
|
150
|
-
({ deploys } = await client.requestDeploy(intent.id, {
|
|
228
|
+
({ deploys } = await client.requestDeploy(intent.id, {
|
|
229
|
+
chainIds: pending,
|
|
230
|
+
signal,
|
|
231
|
+
}));
|
|
151
232
|
}
|
|
152
233
|
catch (error) {
|
|
153
234
|
if (error instanceof jbcenter_js_1.JBCenterRequestError &&
|
|
@@ -156,11 +237,16 @@ async function ensureDeployed(options) {
|
|
|
156
237
|
// intent back and follow whatever sender it now has instead of adding a
|
|
157
238
|
// second one.
|
|
158
239
|
const fresh = await client.getIntent(intent.id, { signal });
|
|
159
|
-
|
|
160
|
-
|
|
240
|
+
const resumed = existingSender(options, fresh, run);
|
|
241
|
+
if (resumed)
|
|
242
|
+
return resumed;
|
|
243
|
+
if (fresh.deploys.length > 0) {
|
|
244
|
+
return pollUntilDeployed(client, fresh, run, pollMs, timeoutMs, signal, onStep);
|
|
245
|
+
}
|
|
246
|
+
return runSelfPaid(client, fresh, run, selfPaid, onStep, signal);
|
|
161
247
|
}
|
|
162
248
|
throw error;
|
|
163
249
|
}
|
|
164
|
-
return pollUntilDeployed(client, { ...intent, deploys }, pollMs, timeoutMs, signal, onStep);
|
|
250
|
+
return pollUntilDeployed(client, { ...intent, deploys }, run, pollMs, timeoutMs, signal, onStep);
|
|
165
251
|
}
|
|
166
252
|
//# sourceMappingURL=ensureDeployed.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensureDeployed.js","sourceRoot":"","sources":["../../../src/jbcenter/ensureDeployed.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"ensureDeployed.js","sourceRoot":"","sources":["../../../src/jbcenter/ensureDeployed.ts"],"names":[],"mappings":";;;AA2WA,wCAwEC;AAlbD,8EAA8E;AAC9E,yEAAyE;AACzE,4EAA4E;AAC5E,sDAAsD;AACtD,gDAYwB;AACxB,yCAA4C;AAE5C,MAAM,eAAe,GAAG,KAAK,CAAC;AAC9B,MAAM,kBAAkB,GAAG,OAAO,CAAC;AACnC,MAAM,2BAA2B,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAgD7D,MAAa,mBAAoB,SAAQ,KAAK;IAC5C,YACE,OAAe,EACN,OAAgB;QAEzB,KAAK,CAAC,OAAO,CAAC,CAAC;QAFN,YAAO,GAAP,OAAO,CAAS;QAGzB,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AARD,kDAQC;AAED,SAAS,YAAY,CAAC,MAA+B;IACnD,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;QACpB,MAAM,MAAM,CAAC,MAAM,CAAC;IACtB,CAAC;AACH,CAAC;AAED,SAAS,KAAK,CAAC,EAAU,EAAE,MAA+B;IACxD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,OAAO,GAAG,GAAG,EAAE;YACnB,YAAY,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,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,EAAE;YACnD,QAAQ,EAAE,OAAO;YACjB,MAAM;SACP,CAAC,CAAC,CAAC;IACN,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IACE,KAAK,YAAY,kCAAoB;YACrC,2BAA2B,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,EAC7C,CAAC;YACD,yEAAyE;YACzE,wEAAwE;YACxE,cAAc;YACd,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,MAAM,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,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.groupDeploymentCalls = groupDeploymentCalls;
|
|
4
|
+
exports.isValidDeploymentCalls = isValidDeploymentCalls;
|
|
5
|
+
exports.intentCalls = intentCalls;
|
|
6
|
+
const decode_js_1 = require("./decode.js");
|
|
7
|
+
/** JB Center's ceiling: one launch per chain, with up to three setup calls. */
|
|
8
|
+
const MAX_CALLS_PER_CHAIN = 4;
|
|
9
|
+
/** An intent's `deploymentCalls` per chain, each chain's calls in order. */
|
|
10
|
+
function groupDeploymentCalls(calls) {
|
|
11
|
+
const groups = new Map();
|
|
12
|
+
for (const call of calls) {
|
|
13
|
+
const group = groups.get(call.chainId);
|
|
14
|
+
if (group)
|
|
15
|
+
group.push(call);
|
|
16
|
+
else
|
|
17
|
+
groups.set(call.chainId, [call]);
|
|
18
|
+
}
|
|
19
|
+
return groups;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* JB Center's rule, mirrored: a chain carries 1 to 4 calls, the last call for
|
|
23
|
+
* a chain is its launch, and every call before it creates a Safe through the
|
|
24
|
+
* canonical factory. Whether the chains named match the calls is the
|
|
25
|
+
* envelope's own check.
|
|
26
|
+
*/
|
|
27
|
+
function isValidDeploymentCalls(calls) {
|
|
28
|
+
for (const group of groupDeploymentCalls(calls).values()) {
|
|
29
|
+
if (group.length > MAX_CALLS_PER_CHAIN)
|
|
30
|
+
return false;
|
|
31
|
+
for (const call of group.slice(0, -1)) {
|
|
32
|
+
if ((0, decode_js_1.decodeDeploymentCall)(call).flavor !== "safe-create")
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* An intent's calls per chain, decoded, so a client renders "creates this
|
|
40
|
+
* Safe, then launches" without repeating the rule: the last call for a chain
|
|
41
|
+
* is its launch and every call before it is a setup call.
|
|
42
|
+
*/
|
|
43
|
+
function intentCalls(intent) {
|
|
44
|
+
const result = new Map();
|
|
45
|
+
for (const [chainId, calls] of groupDeploymentCalls(intent.envelope.deploymentCalls)) {
|
|
46
|
+
const decoded = calls.map((call) => ({
|
|
47
|
+
...call,
|
|
48
|
+
decoded: (0, decode_js_1.decodeDeploymentCall)(call),
|
|
49
|
+
}));
|
|
50
|
+
result.set(chainId, {
|
|
51
|
+
setup: decoded.slice(0, -1),
|
|
52
|
+
launch: decoded[decoded.length - 1],
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=setupCalls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setupCalls.js","sourceRoot":"","sources":["../../../src/jbcenter/setupCalls.ts"],"names":[],"mappings":";;AAeA,oDAYC;AAQD,wDAWC;AAiBD,kCAmBC;AA1ED,2CAAmD;AAGnD,+EAA+E;AAC/E,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAE9B,4EAA4E;AAC5E,SAAgB,oBAAoB,CAClC,KAAwC;IAExC,MAAM,MAAM,GAAG,IAAI,GAAG,EAAoC,CAAC;IAE3D,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;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YAC3B,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;SACpC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/cjs/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;
|