@bananapus/nana-sdk-core 2.6.0 → 2.8.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.
Files changed (49) hide show
  1. package/dist/cjs/jbcenter/decode.d.ts +59 -0
  2. package/dist/cjs/jbcenter/decode.d.ts.map +1 -0
  3. package/dist/cjs/jbcenter/decode.js +199 -0
  4. package/dist/cjs/jbcenter/decode.js.map +1 -0
  5. package/dist/cjs/jbcenter/ensureDeployed.d.ts +29 -0
  6. package/dist/cjs/jbcenter/ensureDeployed.d.ts.map +1 -0
  7. package/dist/cjs/jbcenter/ensureDeployed.js +166 -0
  8. package/dist/cjs/jbcenter/ensureDeployed.js.map +1 -0
  9. package/dist/cjs/jbcenter/merge.d.ts +21 -0
  10. package/dist/cjs/jbcenter/merge.d.ts.map +1 -0
  11. package/dist/cjs/jbcenter/merge.js +51 -0
  12. package/dist/cjs/jbcenter/merge.js.map +1 -0
  13. package/dist/cjs/jbcenter/publish.d.ts +26 -0
  14. package/dist/cjs/jbcenter/publish.d.ts.map +1 -0
  15. package/dist/cjs/jbcenter/publish.js +86 -0
  16. package/dist/cjs/jbcenter/publish.js.map +1 -0
  17. package/dist/cjs/jbcenter/refusal.d.ts +12 -0
  18. package/dist/cjs/jbcenter/refusal.d.ts.map +1 -0
  19. package/dist/cjs/jbcenter/refusal.js +37 -0
  20. package/dist/cjs/jbcenter/refusal.js.map +1 -0
  21. package/dist/cjs/jbcenter.d.ts +29 -0
  22. package/dist/cjs/jbcenter.d.ts.map +1 -1
  23. package/dist/cjs/jbcenter.js +65 -3
  24. package/dist/cjs/jbcenter.js.map +1 -1
  25. package/dist/esm/jbcenter/decode.d.ts +59 -0
  26. package/dist/esm/jbcenter/decode.d.ts.map +1 -0
  27. package/dist/esm/jbcenter/decode.js +196 -0
  28. package/dist/esm/jbcenter/decode.js.map +1 -0
  29. package/dist/esm/jbcenter/ensureDeployed.d.ts +29 -0
  30. package/dist/esm/jbcenter/ensureDeployed.d.ts.map +1 -0
  31. package/dist/esm/jbcenter/ensureDeployed.js +161 -0
  32. package/dist/esm/jbcenter/ensureDeployed.js.map +1 -0
  33. package/dist/esm/jbcenter/merge.d.ts +21 -0
  34. package/dist/esm/jbcenter/merge.d.ts.map +1 -0
  35. package/dist/esm/jbcenter/merge.js +44 -0
  36. package/dist/esm/jbcenter/merge.js.map +1 -0
  37. package/dist/esm/jbcenter/publish.d.ts +26 -0
  38. package/dist/esm/jbcenter/publish.d.ts.map +1 -0
  39. package/dist/esm/jbcenter/publish.js +81 -0
  40. package/dist/esm/jbcenter/publish.js.map +1 -0
  41. package/dist/esm/jbcenter/refusal.d.ts +12 -0
  42. package/dist/esm/jbcenter/refusal.d.ts.map +1 -0
  43. package/dist/esm/jbcenter/refusal.js +34 -0
  44. package/dist/esm/jbcenter/refusal.js.map +1 -0
  45. package/dist/esm/jbcenter.d.ts +29 -0
  46. package/dist/esm/jbcenter.d.ts.map +1 -1
  47. package/dist/esm/jbcenter.js +52 -2
  48. package/dist/esm/jbcenter.js.map +1 -1
  49. package/package.json +1 -1
@@ -0,0 +1,59 @@
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: "homerun-fund";
39
+ owner: Address;
40
+ projectUri: string;
41
+ tokenName: string;
42
+ ticker: string;
43
+ to: Address;
44
+ mustStartAtOrAfter: number;
45
+ salt: Hex;
46
+ peerSuckerDeployers: readonly Address[];
47
+ } | {
48
+ flavor: "unknown";
49
+ to: Address;
50
+ selector: Hex;
51
+ };
52
+ /**
53
+ * Recognize a frozen `{ chainId, to, data }` deployment call (as produced by
54
+ * {@link createJBCenterDeploymentCall}) as one of the known v6 launch
55
+ * flavors, or `"unknown"` when the target address or selector isn't
56
+ * recognized.
57
+ */
58
+ export declare function decodeDeploymentCall(call: JBCenterDeploymentCall): JBCenterDecodedLaunch;
59
+ //# 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,EAKL,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,KAA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EAAE,SAAS,CAAC;IAAC,EAAE,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,GAAG,CAAA;CAAE,CAAC;AAoNtD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,sBAAsB,GAC3B,qBAAqB,CAMvB"}
@@ -0,0 +1,199 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.decodeDeploymentCall = decodeDeploymentCall;
4
+ const viem_1 = require("viem");
5
+ const juicebox_js_1 = require("../generated/juicebox.js");
6
+ const types_js_1 = require("../v6/types.js");
7
+ /** The address of `contract` on `chainId`, or null when it isn't deployed there. */
8
+ function addressFor(contract, chainId) {
9
+ try {
10
+ return (0, types_js_1.v6Address)(contract, chainId);
11
+ }
12
+ catch {
13
+ return null;
14
+ }
15
+ }
16
+ function decodeProjectLaunch(call) {
17
+ try {
18
+ const address = addressFor("JBController", call.chainId);
19
+ if (!address || !(0, viem_1.isAddressEqual)(address, call.to))
20
+ return null;
21
+ const decoded = (0, viem_1.decodeFunctionData)({
22
+ abi: juicebox_js_1.jbControllerAbi,
23
+ data: call.data,
24
+ });
25
+ if (decoded.functionName !== "launchProjectFor")
26
+ return null;
27
+ const [owner, projectUri, rulesetConfigurations, terminalConfigurations, memo,] = decoded.args;
28
+ return {
29
+ flavor: "project",
30
+ owner,
31
+ projectUri,
32
+ rulesetConfigurations,
33
+ terminalConfigurations,
34
+ memo,
35
+ };
36
+ }
37
+ catch {
38
+ return null;
39
+ }
40
+ }
41
+ function decodeProject721Launch(call) {
42
+ try {
43
+ const address = addressFor("JB721TiersHookProjectDeployer", call.chainId);
44
+ if (!address || !(0, viem_1.isAddressEqual)(address, call.to))
45
+ return null;
46
+ const decoded = (0, viem_1.decodeFunctionData)({
47
+ abi: juicebox_js_1.jb721TiersHookProjectDeployerAbi,
48
+ data: call.data,
49
+ });
50
+ if (decoded.functionName !== "launchProjectFor")
51
+ return null;
52
+ const [owner, , launchProjectConfig, , salt] = decoded.args;
53
+ return {
54
+ flavor: "project-721",
55
+ owner,
56
+ projectUri: launchProjectConfig.projectUri,
57
+ // This deployer's ruleset metadata always turns the pay data hook on and
58
+ // points it at the hook it deploys, so `dataHook`/`useDataHookForPay`
59
+ // aren't inputs here — they read as `undefined` on this flavor's shell.
60
+ rulesetConfigurations: launchProjectConfig.rulesetConfigurations,
61
+ terminalConfigurations: launchProjectConfig.terminalConfigurations,
62
+ memo: launchProjectConfig.memo,
63
+ salt,
64
+ };
65
+ }
66
+ catch {
67
+ return null;
68
+ }
69
+ }
70
+ function decodeOmnichainLaunch(call) {
71
+ try {
72
+ const address = addressFor("JBOmnichainDeployer", call.chainId);
73
+ if (!address || !(0, viem_1.isAddressEqual)(address, call.to))
74
+ return null;
75
+ const decoded = (0, viem_1.decodeFunctionData)({
76
+ abi: juicebox_js_1.jbOmnichainDeployerAbi,
77
+ data: call.data,
78
+ });
79
+ if (decoded.functionName !== "launchProjectFor")
80
+ return null;
81
+ const args = decoded.args;
82
+ if (args.length === 7) {
83
+ const [owner, projectUri, , rulesetConfigurations, terminalConfigurations, memo,] = args;
84
+ return {
85
+ flavor: "omnichain",
86
+ owner,
87
+ projectUri,
88
+ rulesetConfigurations,
89
+ terminalConfigurations,
90
+ memo,
91
+ has721: true,
92
+ };
93
+ }
94
+ const [owner, projectUri, rulesetConfigurations, terminalConfigurations, memo,] = args;
95
+ return {
96
+ flavor: "omnichain",
97
+ owner,
98
+ projectUri,
99
+ rulesetConfigurations,
100
+ terminalConfigurations,
101
+ memo,
102
+ has721: false,
103
+ };
104
+ }
105
+ catch {
106
+ return null;
107
+ }
108
+ }
109
+ function decodeRevnetDeploy(call) {
110
+ try {
111
+ const address = addressFor("REVDeployer", call.chainId);
112
+ if (!address || !(0, viem_1.isAddressEqual)(address, call.to))
113
+ return null;
114
+ const decoded = (0, viem_1.decodeFunctionData)({
115
+ abi: juicebox_js_1.revDeployerAbi,
116
+ data: call.data,
117
+ });
118
+ if (decoded.functionName !== "deployFor")
119
+ return null;
120
+ const [, config, accountingContexts] = decoded.args;
121
+ return {
122
+ flavor: "revnet",
123
+ operator: config.operator,
124
+ projectUri: config.description.uri,
125
+ stages: config.stageConfigurations,
126
+ description: config.description,
127
+ accountingContexts,
128
+ };
129
+ }
130
+ catch {
131
+ return null;
132
+ }
133
+ }
134
+ /** Source: HomerunDeployer.sol. Carried here because Homerun deploys its own
135
+ * per-chain deployer, which the V6 address registry does not name. */
136
+ const homerunLaunchFundAbi = (0, viem_1.parseAbi)([
137
+ "function launchFundFor(address owner, string projectUri, string name, string ticker, uint48 mustStartAtOrAfter, bytes32 salt, address[] peerSuckerDeployers) payable returns (uint256 projectId, address token)",
138
+ ]);
139
+ /** HomerunDeployer's address on each chain it is deployed to: one salt across
140
+ * the mainnets, another across the testnets. Source: Homerun's
141
+ * `deployments/<chain>/HomerunDeployer.json`. */
142
+ const HOMERUN_DEPLOYER_ADDRESSES = {
143
+ 1: "0xac9250654ea223513ffee25fdb647dc016873905",
144
+ 10: "0xac9250654ea223513ffee25fdb647dc016873905",
145
+ 8453: "0xac9250654ea223513ffee25fdb647dc016873905",
146
+ 42161: "0xac9250654ea223513ffee25fdb647dc016873905",
147
+ 11155111: "0xe944fe96765450877f95cc36aa36ec72b4388721",
148
+ 11155420: "0xe944fe96765450877f95cc36aa36ec72b4388721",
149
+ 84532: "0xe944fe96765450877f95cc36aa36ec72b4388721",
150
+ 421614: "0xe944fe96765450877f95cc36aa36ec72b4388721",
151
+ };
152
+ function decodeHomerunFundLaunch(call) {
153
+ try {
154
+ const address = HOMERUN_DEPLOYER_ADDRESSES[call.chainId];
155
+ if (!address || !(0, viem_1.isAddressEqual)(address, call.to))
156
+ return null;
157
+ const decoded = (0, viem_1.decodeFunctionData)({
158
+ abi: homerunLaunchFundAbi,
159
+ data: call.data,
160
+ });
161
+ const [owner, projectUri, tokenName, ticker, mustStartAtOrAfter, salt, peerSuckerDeployers,] = decoded.args;
162
+ return {
163
+ flavor: "homerun-fund",
164
+ owner,
165
+ projectUri,
166
+ tokenName,
167
+ ticker,
168
+ to: call.to,
169
+ mustStartAtOrAfter,
170
+ salt,
171
+ peerSuckerDeployers,
172
+ };
173
+ }
174
+ catch {
175
+ return null;
176
+ }
177
+ }
178
+ const DECODERS = [
179
+ decodeProjectLaunch,
180
+ decodeProject721Launch,
181
+ decodeOmnichainLaunch,
182
+ decodeRevnetDeploy,
183
+ decodeHomerunFundLaunch,
184
+ ];
185
+ /**
186
+ * Recognize a frozen `{ chainId, to, data }` deployment call (as produced by
187
+ * {@link createJBCenterDeploymentCall}) as one of the known v6 launch
188
+ * flavors, or `"unknown"` when the target address or selector isn't
189
+ * recognized.
190
+ */
191
+ function decodeDeploymentCall(call) {
192
+ for (const decode of DECODERS) {
193
+ const decoded = decode(call);
194
+ if (decoded)
195
+ return decoded;
196
+ }
197
+ return { flavor: "unknown", to: call.to, selector: (0, viem_1.slice)(call.data, 0, 4) };
198
+ }
199
+ //# sourceMappingURL=decode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decode.js","sourceRoot":"","sources":["../../../src/jbcenter/decode.ts"],"names":[],"mappings":";;AA8RA,oDAQC;AAtSD,+BAOc;AACd,0DAKkC;AAMlC,6CAA4D;AAmD5D,oFAAoF;AACpF,SAAS,UAAU,CAAC,QAAoB,EAAE,OAAe;IACvD,IAAI,CAAC;QACH,OAAO,IAAA,oBAAS,EAAC,QAAQ,EAAE,OAAoB,CAAC,CAAC;IACnD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,SAAS,mBAAmB,CAC1B,IAA4B;IAE5B,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,UAAU,CAAC,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACzD,IAAI,CAAC,OAAO,IAAI,CAAC,IAAA,qBAAc,EAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC;YAAE,OAAO,IAAI,CAAC;QAC/D,MAAM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+ 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
@@ -0,0 +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,EAGL,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,cAAc,EAEnB,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAC;AAOxB,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAC;IACjE,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,uEAAuE;IACvE,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;AA4KD;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAyCjC"}
@@ -0,0 +1,166 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EnsureDeployedError = void 0;
4
+ exports.ensureDeployed = ensureDeployed;
5
+ // `jbcenter.ts` re-exports this module, so the two form an import cycle. Keep
6
+ // every value either side takes from the other inside a function body: a
7
+ // top-level read of `JBCenterRequestError` or `isSponsorable` would resolve
8
+ // before `jbcenter.ts` finishes evaluating under CJS.
9
+ const jbcenter_js_1 = require("../jbcenter.js");
10
+ const merge_js_1 = require("./merge.js");
11
+ const DEFAULT_POLL_MS = 4_000;
12
+ const DEFAULT_TIMEOUT_MS = 600_000;
13
+ const SELF_PAID_FALLBACK_STATUSES = new Set([400, 429, 503]);
14
+ class EnsureDeployedError extends Error {
15
+ constructor(message, chainId) {
16
+ super(message);
17
+ this.chainId = chainId;
18
+ this.name = "EnsureDeployedError";
19
+ }
20
+ }
21
+ exports.EnsureDeployedError = EnsureDeployedError;
22
+ function checkAborted(signal) {
23
+ if (signal?.aborted) {
24
+ throw signal.reason;
25
+ }
26
+ }
27
+ function sleep(ms, signal) {
28
+ return new Promise((resolve, reject) => {
29
+ const onAbort = () => {
30
+ clearTimeout(timer);
31
+ reject(signal?.reason);
32
+ };
33
+ const timer = setTimeout(() => {
34
+ signal?.removeEventListener("abort", onAbort);
35
+ resolve();
36
+ }, ms);
37
+ signal?.addEventListener("abort", onAbort, { once: true });
38
+ });
39
+ }
40
+ function reportSteps(deploys, seen, onStep) {
41
+ let failedChainId;
42
+ for (const deploy of deploys) {
43
+ if (seen.get(deploy.chainId) === deploy.status)
44
+ continue;
45
+ seen.set(deploy.chainId, deploy.status);
46
+ onStep?.({
47
+ chainId: deploy.chainId,
48
+ status: deploy.status,
49
+ transactionHash: deploy.transactionHash ?? undefined,
50
+ });
51
+ if (deploy.status === "failed" && failedChainId === undefined) {
52
+ failedChainId = deploy.chainId;
53
+ }
54
+ }
55
+ if (failedChainId !== undefined) {
56
+ throw new EnsureDeployedError(`JB Center could not deploy chain ${failedChainId}`, failedChainId);
57
+ }
58
+ }
59
+ async function pollUntilDeployed(client, seed, pollMs, timeoutMs, signal, onStep) {
60
+ const seen = new Map();
61
+ const startedAt = Date.now();
62
+ let current = seed;
63
+ while (true) {
64
+ checkAborted(signal);
65
+ reportSteps(current.deploys, seen, onStep);
66
+ if ((0, merge_js_1.isFullyDeployed)(current)) {
67
+ return (0, merge_js_1.deployedChains)(current);
68
+ }
69
+ if (Date.now() - startedAt >= timeoutMs) {
70
+ throw new EnsureDeployedError("JB Center deploy polling timed out");
71
+ }
72
+ await sleep(pollMs, signal);
73
+ current = await client.getIntent(current.id, { signal });
74
+ }
75
+ }
76
+ async function runSelfPaid(client, intent, selfPaid, onStep, signal) {
77
+ if (!selfPaid) {
78
+ throw new EnsureDeployedError("JB Center cannot sponsor this deploy and no self-paid fallback was provided");
79
+ }
80
+ checkAborted(signal);
81
+ const deployed = (0, merge_js_1.deployedChains)(intent);
82
+ const remainingCalls = intent.envelope.deploymentCalls.filter((call) => !(call.chainId in deployed));
83
+ const deployments = await selfPaid(remainingCalls);
84
+ const remainingChainIds = new Set(remainingCalls.map((call) => call.chainId));
85
+ const returnedChainIds = new Set();
86
+ for (const deployment of deployments) {
87
+ if (!remainingChainIds.has(deployment.chainId)) {
88
+ throw new EnsureDeployedError(`Self-paid deploy returned an unexpected chain ${deployment.chainId}`, deployment.chainId);
89
+ }
90
+ if (returnedChainIds.has(deployment.chainId)) {
91
+ throw new EnsureDeployedError(`Self-paid deploy returned chain ${deployment.chainId} more than once`, deployment.chainId);
92
+ }
93
+ returnedChainIds.add(deployment.chainId);
94
+ }
95
+ for (const chainId of remainingChainIds) {
96
+ if (!returnedChainIds.has(chainId)) {
97
+ throw new EnsureDeployedError(`Self-paid deploy left chain ${chainId} undeployed`, chainId);
98
+ }
99
+ }
100
+ const result = { ...deployed };
101
+ for (const deployment of deployments) {
102
+ checkAborted(signal);
103
+ await client.recordDeployment(intent.id, deployment, { signal });
104
+ result[deployment.chainId] = deployment.projectId;
105
+ onStep?.({
106
+ chainId: deployment.chainId,
107
+ status: "self-paid",
108
+ transactionHash: deployment.transactionHash,
109
+ });
110
+ }
111
+ return result;
112
+ }
113
+ /**
114
+ * The sender an intent already has, or `undefined` when nothing has started
115
+ * it yet. Every chain in an intent belongs to one sender, so this decides the
116
+ * route before any new request goes out.
117
+ */
118
+ function existingSender(options, intent, pollMs, timeoutMs) {
119
+ const { client, onStep, selfPaid, signal } = options;
120
+ if ((0, merge_js_1.isFullyDeployed)(intent)) {
121
+ return Promise.resolve((0, merge_js_1.deployedChains)(intent));
122
+ }
123
+ if (intent.deploys.length > 0) {
124
+ return pollUntilDeployed(client, intent, pollMs, timeoutMs, signal, onStep);
125
+ }
126
+ if (intent.deployments.length > 0) {
127
+ return runSelfPaid(client, intent, selfPaid, onStep, signal);
128
+ }
129
+ return undefined;
130
+ }
131
+ /**
132
+ * The pre-step every webclient runs before the first on-chain write against
133
+ * an undeployed intent: sponsor the deploy through JB Center when eligible
134
+ * and poll until every chain lands, or fall back to the caller's own launch
135
+ * pipeline when JB Center can't or won't sponsor it.
136
+ */
137
+ async function ensureDeployed(options) {
138
+ const { client, intent, onStep, selfPaid, signal } = options;
139
+ const pollMs = options.pollMs ?? DEFAULT_POLL_MS;
140
+ const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
141
+ const started = existingSender(options, intent, pollMs, timeoutMs);
142
+ if (started)
143
+ return started;
144
+ if (!(0, jbcenter_js_1.isSponsorable)(intent.envelope.chainIds)) {
145
+ return runSelfPaid(client, intent, selfPaid, onStep, signal);
146
+ }
147
+ let deploys;
148
+ try {
149
+ checkAborted(signal);
150
+ ({ deploys } = await client.requestDeploy(intent.id, { signal }));
151
+ }
152
+ catch (error) {
153
+ if (error instanceof jbcenter_js_1.JBCenterRequestError &&
154
+ SELF_PAID_FALLBACK_STATUSES.has(error.status)) {
155
+ // The refusal may mean the sponsor already took this intent, so read the
156
+ // intent back and follow whatever sender it now has instead of adding a
157
+ // second one.
158
+ const fresh = await client.getIntent(intent.id, { signal });
159
+ return (existingSender(options, fresh, pollMs, timeoutMs) ??
160
+ runSelfPaid(client, fresh, selfPaid, onStep, signal));
161
+ }
162
+ throw error;
163
+ }
164
+ return pollUntilDeployed(client, { ...intent, deploys }, pollMs, timeoutMs, signal, onStep);
165
+ }
166
+ //# sourceMappingURL=ensureDeployed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ensureDeployed.js","sourceRoot":"","sources":["../../../src/jbcenter/ensureDeployed.ts"],"names":[],"mappings":";;;AAkOA,wCA2CC;AA5QD,8EAA8E;AAC9E,yEAAyE;AACzE,4EAA4E;AAC5E,sDAAsD;AACtD,gDASwB;AACxB,yCAA6D;AAE7D,M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CAAoB;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,OAAO,CACL,cAAc,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC;gBACjD,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CACrD,CAAC;QACJ,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;IAED,OAAO,iBAAiB,CACtB,MAAM,EACN,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,EACtB,MAAM,EACN,SAAS,EACT,MAAM,EACN,MAAM,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { Address } from "viem";
2
+ import type { JBCenterIntent, JBCenterSearchItem, JBCenterJsonObject } from "../jbcenter.js";
3
+ export type JBCenterIntentRow = {
4
+ undeployed: true;
5
+ intentId: string;
6
+ name: string;
7
+ tagline: string | null;
8
+ logoUri: string | null;
9
+ owner: Address | null;
10
+ chainIds: number[];
11
+ createdAt: number;
12
+ };
13
+ export declare function intentRow(item: JBCenterSearchItem): JBCenterIntentRow;
14
+ /** Deployed rows win ties so a list never reorders once an intent lands. */
15
+ export declare function mergeSearch<T extends {
16
+ createdAt: number;
17
+ }>(rows: readonly T[], items: readonly JBCenterSearchItem[]): (T | JBCenterIntentRow)[];
18
+ export declare function intentPath(intentId: string): string;
19
+ export declare function deployedChains(intent: JBCenterIntent<JBCenterJsonObject>): Record<number, string>;
20
+ export declare function isFullyDeployed(intent: JBCenterIntent<JBCenterJsonObject>): boolean;
21
+ //# sourceMappingURL=merge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../../src/jbcenter/merge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AAExB,MAAM,MAAM,iBAAiB,GAAG;IAC9B,UAAU,EAAE,IAAI,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IACtB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,wBAAgB,SAAS,CAAC,IAAI,EAAE,kBAAkB,GAAG,iBAAiB,CAarE;AAED,4EAA4E;AAC5E,wBAAgB,WAAW,CAAC,CAAC,SAAS;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,EACzD,IAAI,EAAE,SAAS,CAAC,EAAE,EAClB,KAAK,EAAE,SAAS,kBAAkB,EAAE,GACnC,CAAC,CAAC,GAAG,iBAAiB,CAAC,EAAE,CAiB3B;AAED,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED,wBAAgB,cAAc,CAC5B,MAAM,EAAE,cAAc,CAAC,kBAAkB,CAAC,GACzC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQxB;AAED,wBAAgB,eAAe,CAC7B,MAAM,EAAE,cAAc,CAAC,kBAAkB,CAAC,GACzC,OAAO,CAIT"}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.intentRow = intentRow;
4
+ exports.mergeSearch = mergeSearch;
5
+ exports.intentPath = intentPath;
6
+ exports.deployedChains = deployedChains;
7
+ exports.isFullyDeployed = isFullyDeployed;
8
+ function intentRow(item) {
9
+ const createdAt = Date.parse(item.createdAt);
10
+ return {
11
+ undeployed: true,
12
+ intentId: item.intentId,
13
+ name: item.name,
14
+ tagline: item.tagline,
15
+ logoUri: item.logoUri,
16
+ owner: item.owner,
17
+ chainIds: item.chainIds,
18
+ createdAt: Number.isNaN(createdAt) ? 0 : Math.floor(createdAt / 1000),
19
+ };
20
+ }
21
+ /** Deployed rows win ties so a list never reorders once an intent lands. */
22
+ function mergeSearch(rows, items) {
23
+ const entries = [
24
+ ...rows.map((value) => ({ value, isRow: true })),
25
+ ...items.map((item) => ({ value: intentRow(item), isRow: false })),
26
+ ];
27
+ entries.sort((a, b) => {
28
+ if (a.value.createdAt !== b.value.createdAt) {
29
+ return b.value.createdAt - a.value.createdAt;
30
+ }
31
+ if (a.isRow !== b.isRow)
32
+ return a.isRow ? -1 : 1;
33
+ return 0;
34
+ });
35
+ return entries.map((entry) => entry.value);
36
+ }
37
+ function intentPath(intentId) {
38
+ return `/intent/${encodeURIComponent(intentId)}`;
39
+ }
40
+ function deployedChains(intent) {
41
+ const result = {};
42
+ for (const deployment of intent.deployments) {
43
+ result[deployment.chainId] = deployment.projectId;
44
+ }
45
+ return result;
46
+ }
47
+ function isFullyDeployed(intent) {
48
+ const deployed = deployedChains(intent);
49
+ return intent.envelope.chainIds.every((chainId) => chainId in deployed);
50
+ }
51
+ //# sourceMappingURL=merge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge.js","sourceRoot":"","sources":["../../../src/jbcenter/merge.ts"],"names":[],"mappings":";;AAkBA,8BAaC;AAGD,kCAoBC;AAED,gCAEC;AAED,wCAUC;AAED,0CAMC;AA5DD,SAAgB,SAAS,CAAC,IAAwB;IAChD,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAE7C,OAAO;QACL,UAAU,EAAE,IAAI;QAChB,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,I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AC,KAAK,CAAC,KAAK,CAAC,CAAC;AAC7C,CAAC;AAED,SAAgB,UAAU,CAAC,QAAgB;IACzC,OAAO,WAAW,kBAAkB,CAAC,QAAQ,CAAC,EAAE,CAAC;AACnD,CAAC;AAED,SAAgB,cAAc,CAC5B,MAA0C;IAE1C,MAAM,MAAM,GAA2B,EAAE,CAAC;IAE1C,KAAK,MAAM,UAAU,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;QAC5C,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,UAAU,CAAC,SAAS,CAAC;IACpD,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAgB,eAAe,CAC7B,MAA0C;IAE1C,MAAM,QAAQ,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IAExC,OAAO,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,IAAI,QAAQ,CAAC,CAAC;AAC1E,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type { Address, Hex } from "viem";
2
+ import type { JBCenterClient, JBCenterIntent, JBCenterIntentInput, JBCenterJsonObject, JBCenterRequestOptions } from "../jbcenter.js";
3
+ /** JB Center prepared something other than the intent the caller built. */
4
+ export declare class JBCenterIntentMismatchError extends Error {
5
+ readonly reason: "envelope" | "message";
6
+ constructor(reason: "envelope" | "message");
7
+ }
8
+ export type PublishSignedIntentOptions = {
9
+ /** The address whose signature `sign` returns. */
10
+ publisher: Address;
11
+ /**
12
+ * The whole message the publisher may be asked to sign for a content hash.
13
+ * Defaults to JB Center's own signing message.
14
+ */
15
+ expectMessage?: (contentHash: Hex) => string;
16
+ request?: JBCenterRequestOptions;
17
+ };
18
+ /**
19
+ * Publish an intent, signing only JB Center's prepared message and only once
20
+ * it has been checked: the prepared envelope must carry the same values as
21
+ * the intent built here, and the message must be the whole signing message
22
+ * for the content hash of what is being signed. `sign` is the caller's own
23
+ * signer; this package never reaches a wallet itself.
24
+ */
25
+ export declare function publishSignedIntent<TJb extends JBCenterJsonObject>(client: JBCenterClient, intent: JBCenterIntentInput<TJb>, sign: (message: string) => Promise<Hex>, options: PublishSignedIntentOptions): Promise<JBCenterIntent<TJb>>;
26
+ //# sourceMappingURL=publish.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../../src/jbcenter/publish.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,EACvB,MAAM,gBAAgB,CAAC;AA+DxB,2EAA2E;AAC3E,qBAAa,2BAA4B,SAAQ,KAAK;IACxC,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,SAAS;gBAA9B,MAAM,EAAE,UAAU,GAAG,SAAS;CAQpD;AAED,MAAM,MAAM,0BAA0B,GAAG;IACvC,kDAAkD;IAClD,SAAS,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,aAAa,CAAC,EAAE,CAAC,WAAW,EAAE,GAAG,KAAK,MAAM,CAAC;IAC7C,OAAO,CAAC,EAAE,sBAAsB,CAAC;CAClC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CAAC,GAAG,SAAS,kBAAkB,EACtE,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,mBAAmB,CAAC,GAAG,CAAC,EAChC,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,EACvC,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAmB9B"}