@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.
- package/dist/cjs/jbcenter/decode.d.ts +59 -0
- package/dist/cjs/jbcenter/decode.d.ts.map +1 -0
- package/dist/cjs/jbcenter/decode.js +199 -0
- package/dist/cjs/jbcenter/decode.js.map +1 -0
- package/dist/cjs/jbcenter/ensureDeployed.d.ts +29 -0
- package/dist/cjs/jbcenter/ensureDeployed.d.ts.map +1 -0
- package/dist/cjs/jbcenter/ensureDeployed.js +166 -0
- package/dist/cjs/jbcenter/ensureDeployed.js.map +1 -0
- package/dist/cjs/jbcenter/merge.d.ts +21 -0
- package/dist/cjs/jbcenter/merge.d.ts.map +1 -0
- package/dist/cjs/jbcenter/merge.js +51 -0
- package/dist/cjs/jbcenter/merge.js.map +1 -0
- package/dist/cjs/jbcenter/publish.d.ts +26 -0
- package/dist/cjs/jbcenter/publish.d.ts.map +1 -0
- package/dist/cjs/jbcenter/publish.js +86 -0
- package/dist/cjs/jbcenter/publish.js.map +1 -0
- package/dist/cjs/jbcenter/refusal.d.ts +12 -0
- package/dist/cjs/jbcenter/refusal.d.ts.map +1 -0
- package/dist/cjs/jbcenter/refusal.js +37 -0
- package/dist/cjs/jbcenter/refusal.js.map +1 -0
- package/dist/cjs/jbcenter.d.ts +29 -0
- package/dist/cjs/jbcenter.d.ts.map +1 -1
- package/dist/cjs/jbcenter.js +65 -3
- package/dist/cjs/jbcenter.js.map +1 -1
- package/dist/esm/jbcenter/decode.d.ts +59 -0
- package/dist/esm/jbcenter/decode.d.ts.map +1 -0
- package/dist/esm/jbcenter/decode.js +196 -0
- package/dist/esm/jbcenter/decode.js.map +1 -0
- package/dist/esm/jbcenter/ensureDeployed.d.ts +29 -0
- package/dist/esm/jbcenter/ensureDeployed.d.ts.map +1 -0
- package/dist/esm/jbcenter/ensureDeployed.js +161 -0
- package/dist/esm/jbcenter/ensureDeployed.js.map +1 -0
- package/dist/esm/jbcenter/merge.d.ts +21 -0
- package/dist/esm/jbcenter/merge.d.ts.map +1 -0
- package/dist/esm/jbcenter/merge.js +44 -0
- package/dist/esm/jbcenter/merge.js.map +1 -0
- package/dist/esm/jbcenter/publish.d.ts +26 -0
- package/dist/esm/jbcenter/publish.d.ts.map +1 -0
- package/dist/esm/jbcenter/publish.js +81 -0
- package/dist/esm/jbcenter/publish.js.map +1 -0
- package/dist/esm/jbcenter/refusal.d.ts +12 -0
- package/dist/esm/jbcenter/refusal.d.ts.map +1 -0
- package/dist/esm/jbcenter/refusal.js +34 -0
- package/dist/esm/jbcenter/refusal.js.map +1 -0
- package/dist/esm/jbcenter.d.ts +29 -0
- package/dist/esm/jbcenter.d.ts.map +1 -1
- package/dist/esm/jbcenter.js +52 -2
- package/dist/esm/jbcenter.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { decodeFunctionData, isAddressEqual, parseAbi, slice, } from "viem";
|
|
2
|
+
import { jb721TiersHookProjectDeployerAbi, jbControllerAbi, jbOmnichainDeployerAbi, revDeployerAbi, } from "../generated/juicebox.js";
|
|
3
|
+
import { v6Address } from "../v6/types.js";
|
|
4
|
+
/** The address of `contract` on `chainId`, or null when it isn't deployed there. */
|
|
5
|
+
function addressFor(contract, chainId) {
|
|
6
|
+
try {
|
|
7
|
+
return v6Address(contract, chainId);
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function decodeProjectLaunch(call) {
|
|
14
|
+
try {
|
|
15
|
+
const address = addressFor("JBController", call.chainId);
|
|
16
|
+
if (!address || !isAddressEqual(address, call.to))
|
|
17
|
+
return null;
|
|
18
|
+
const decoded = decodeFunctionData({
|
|
19
|
+
abi: jbControllerAbi,
|
|
20
|
+
data: call.data,
|
|
21
|
+
});
|
|
22
|
+
if (decoded.functionName !== "launchProjectFor")
|
|
23
|
+
return null;
|
|
24
|
+
const [owner, projectUri, rulesetConfigurations, terminalConfigurations, memo,] = decoded.args;
|
|
25
|
+
return {
|
|
26
|
+
flavor: "project",
|
|
27
|
+
owner,
|
|
28
|
+
projectUri,
|
|
29
|
+
rulesetConfigurations,
|
|
30
|
+
terminalConfigurations,
|
|
31
|
+
memo,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function decodeProject721Launch(call) {
|
|
39
|
+
try {
|
|
40
|
+
const address = addressFor("JB721TiersHookProjectDeployer", call.chainId);
|
|
41
|
+
if (!address || !isAddressEqual(address, call.to))
|
|
42
|
+
return null;
|
|
43
|
+
const decoded = decodeFunctionData({
|
|
44
|
+
abi: jb721TiersHookProjectDeployerAbi,
|
|
45
|
+
data: call.data,
|
|
46
|
+
});
|
|
47
|
+
if (decoded.functionName !== "launchProjectFor")
|
|
48
|
+
return null;
|
|
49
|
+
const [owner, , launchProjectConfig, , salt] = decoded.args;
|
|
50
|
+
return {
|
|
51
|
+
flavor: "project-721",
|
|
52
|
+
owner,
|
|
53
|
+
projectUri: launchProjectConfig.projectUri,
|
|
54
|
+
// This deployer's ruleset metadata always turns the pay data hook on and
|
|
55
|
+
// points it at the hook it deploys, so `dataHook`/`useDataHookForPay`
|
|
56
|
+
// aren't inputs here — they read as `undefined` on this flavor's shell.
|
|
57
|
+
rulesetConfigurations: launchProjectConfig.rulesetConfigurations,
|
|
58
|
+
terminalConfigurations: launchProjectConfig.terminalConfigurations,
|
|
59
|
+
memo: launchProjectConfig.memo,
|
|
60
|
+
salt,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function decodeOmnichainLaunch(call) {
|
|
68
|
+
try {
|
|
69
|
+
const address = addressFor("JBOmnichainDeployer", call.chainId);
|
|
70
|
+
if (!address || !isAddressEqual(address, call.to))
|
|
71
|
+
return null;
|
|
72
|
+
const decoded = decodeFunctionData({
|
|
73
|
+
abi: jbOmnichainDeployerAbi,
|
|
74
|
+
data: call.data,
|
|
75
|
+
});
|
|
76
|
+
if (decoded.functionName !== "launchProjectFor")
|
|
77
|
+
return null;
|
|
78
|
+
const args = decoded.args;
|
|
79
|
+
if (args.length === 7) {
|
|
80
|
+
const [owner, projectUri, , rulesetConfigurations, terminalConfigurations, memo,] = args;
|
|
81
|
+
return {
|
|
82
|
+
flavor: "omnichain",
|
|
83
|
+
owner,
|
|
84
|
+
projectUri,
|
|
85
|
+
rulesetConfigurations,
|
|
86
|
+
terminalConfigurations,
|
|
87
|
+
memo,
|
|
88
|
+
has721: true,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
const [owner, projectUri, rulesetConfigurations, terminalConfigurations, memo,] = args;
|
|
92
|
+
return {
|
|
93
|
+
flavor: "omnichain",
|
|
94
|
+
owner,
|
|
95
|
+
projectUri,
|
|
96
|
+
rulesetConfigurations,
|
|
97
|
+
terminalConfigurations,
|
|
98
|
+
memo,
|
|
99
|
+
has721: false,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function decodeRevnetDeploy(call) {
|
|
107
|
+
try {
|
|
108
|
+
const address = addressFor("REVDeployer", call.chainId);
|
|
109
|
+
if (!address || !isAddressEqual(address, call.to))
|
|
110
|
+
return null;
|
|
111
|
+
const decoded = decodeFunctionData({
|
|
112
|
+
abi: revDeployerAbi,
|
|
113
|
+
data: call.data,
|
|
114
|
+
});
|
|
115
|
+
if (decoded.functionName !== "deployFor")
|
|
116
|
+
return null;
|
|
117
|
+
const [, config, accountingContexts] = decoded.args;
|
|
118
|
+
return {
|
|
119
|
+
flavor: "revnet",
|
|
120
|
+
operator: config.operator,
|
|
121
|
+
projectUri: config.description.uri,
|
|
122
|
+
stages: config.stageConfigurations,
|
|
123
|
+
description: config.description,
|
|
124
|
+
accountingContexts,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/** Source: HomerunDeployer.sol. Carried here because Homerun deploys its own
|
|
132
|
+
* per-chain deployer, which the V6 address registry does not name. */
|
|
133
|
+
const homerunLaunchFundAbi = parseAbi([
|
|
134
|
+
"function launchFundFor(address owner, string projectUri, string name, string ticker, uint48 mustStartAtOrAfter, bytes32 salt, address[] peerSuckerDeployers) payable returns (uint256 projectId, address token)",
|
|
135
|
+
]);
|
|
136
|
+
/** HomerunDeployer's address on each chain it is deployed to: one salt across
|
|
137
|
+
* the mainnets, another across the testnets. Source: Homerun's
|
|
138
|
+
* `deployments/<chain>/HomerunDeployer.json`. */
|
|
139
|
+
const HOMERUN_DEPLOYER_ADDRESSES = {
|
|
140
|
+
1: "0xac9250654ea223513ffee25fdb647dc016873905",
|
|
141
|
+
10: "0xac9250654ea223513ffee25fdb647dc016873905",
|
|
142
|
+
8453: "0xac9250654ea223513ffee25fdb647dc016873905",
|
|
143
|
+
42161: "0xac9250654ea223513ffee25fdb647dc016873905",
|
|
144
|
+
11155111: "0xe944fe96765450877f95cc36aa36ec72b4388721",
|
|
145
|
+
11155420: "0xe944fe96765450877f95cc36aa36ec72b4388721",
|
|
146
|
+
84532: "0xe944fe96765450877f95cc36aa36ec72b4388721",
|
|
147
|
+
421614: "0xe944fe96765450877f95cc36aa36ec72b4388721",
|
|
148
|
+
};
|
|
149
|
+
function decodeHomerunFundLaunch(call) {
|
|
150
|
+
try {
|
|
151
|
+
const address = HOMERUN_DEPLOYER_ADDRESSES[call.chainId];
|
|
152
|
+
if (!address || !isAddressEqual(address, call.to))
|
|
153
|
+
return null;
|
|
154
|
+
const decoded = decodeFunctionData({
|
|
155
|
+
abi: homerunLaunchFundAbi,
|
|
156
|
+
data: call.data,
|
|
157
|
+
});
|
|
158
|
+
const [owner, projectUri, tokenName, ticker, mustStartAtOrAfter, salt, peerSuckerDeployers,] = decoded.args;
|
|
159
|
+
return {
|
|
160
|
+
flavor: "homerun-fund",
|
|
161
|
+
owner,
|
|
162
|
+
projectUri,
|
|
163
|
+
tokenName,
|
|
164
|
+
ticker,
|
|
165
|
+
to: call.to,
|
|
166
|
+
mustStartAtOrAfter,
|
|
167
|
+
salt,
|
|
168
|
+
peerSuckerDeployers,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
const DECODERS = [
|
|
176
|
+
decodeProjectLaunch,
|
|
177
|
+
decodeProject721Launch,
|
|
178
|
+
decodeOmnichainLaunch,
|
|
179
|
+
decodeRevnetDeploy,
|
|
180
|
+
decodeHomerunFundLaunch,
|
|
181
|
+
];
|
|
182
|
+
/**
|
|
183
|
+
* Recognize a frozen `{ chainId, to, data }` deployment call (as produced by
|
|
184
|
+
* {@link createJBCenterDeploymentCall}) as one of the known v6 launch
|
|
185
|
+
* flavors, or `"unknown"` when the target address or selector isn't
|
|
186
|
+
* recognized.
|
|
187
|
+
*/
|
|
188
|
+
export function decodeDeploymentCall(call) {
|
|
189
|
+
for (const decode of DECODERS) {
|
|
190
|
+
const decoded = decode(call);
|
|
191
|
+
if (decoded)
|
|
192
|
+
return decoded;
|
|
193
|
+
}
|
|
194
|
+
return { flavor: "unknown", to: call.to, selector: slice(call.data, 0, 4) };
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=decode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode.js","sourceRoot":"","sources":["../../../src/jbcenter/decode.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,QAAQ,EACR,KAAK,GAGN,MAAM,MAAM,CAAC;AACd,OAAO,EACL,gCAAgC,EAChC,eAAe,EACf,sBAAsB,EACtB,cAAc,GACf,MAAM,0BAA0B,C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kB;IAClB,uBAAuB;CACxB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAClC,IAA4B;IAE5B,KAAK,MAAM,MAAM,IAAI,QAAQ,EAAE,CAAC;QAC9B,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;QAC7B,IAAI,OAAO;YAAE,OAAO,OAAO,CAAC;IAC9B,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Hex } from "viem";
|
|
2
|
+
import { type JBCenterClient, type JBCenterDeploymentCall, type JBCenterDeploymentInput, type JBCenterIntent, type JBCenterJsonObject } from "../jbcenter.js";
|
|
3
|
+
export type EnsureDeployedStep = {
|
|
4
|
+
chainId: number;
|
|
5
|
+
status: "queued" | "sent" | "confirmed" | "failed" | "self-paid";
|
|
6
|
+
transactionHash?: Hex;
|
|
7
|
+
};
|
|
8
|
+
export type EnsureDeployedOptions = {
|
|
9
|
+
client: JBCenterClient;
|
|
10
|
+
intent: JBCenterIntent<JBCenterJsonObject>;
|
|
11
|
+
/** Runs the client's own launch pipeline for every remaining chain. */
|
|
12
|
+
selfPaid?: (calls: JBCenterDeploymentCall[]) => Promise<JBCenterDeploymentInput[]>;
|
|
13
|
+
onStep?: (step: EnsureDeployedStep) => void;
|
|
14
|
+
pollMs?: number;
|
|
15
|
+
timeoutMs?: number;
|
|
16
|
+
signal?: AbortSignal;
|
|
17
|
+
};
|
|
18
|
+
export declare class EnsureDeployedError extends Error {
|
|
19
|
+
readonly chainId?: number | undefined;
|
|
20
|
+
constructor(message: string, chainId?: number | undefined);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The pre-step every webclient runs before the first on-chain write against
|
|
24
|
+
* an undeployed intent: sponsor the deploy through JB Center when eligible
|
|
25
|
+
* and poll until every chain lands, or fall back to the caller's own launch
|
|
26
|
+
* pipeline when JB Center can't or won't sponsor it.
|
|
27
|
+
*/
|
|
28
|
+
export declare function ensureDeployed(options: EnsureDeployedOptions): Promise<Record<number, string>>;
|
|
29
|
+
//# sourceMappingURL=ensureDeployed.d.ts.map
|
|
@@ -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,161 @@
|
|
|
1
|
+
// `jbcenter.ts` re-exports this module, so the two form an import cycle. Keep
|
|
2
|
+
// every value either side takes from the other inside a function body: a
|
|
3
|
+
// top-level read of `JBCenterRequestError` or `isSponsorable` would resolve
|
|
4
|
+
// before `jbcenter.ts` finishes evaluating under CJS.
|
|
5
|
+
import { JBCenterRequestError, isSponsorable, } from "../jbcenter.js";
|
|
6
|
+
import { deployedChains, isFullyDeployed } from "./merge.js";
|
|
7
|
+
const DEFAULT_POLL_MS = 4_000;
|
|
8
|
+
const DEFAULT_TIMEOUT_MS = 600_000;
|
|
9
|
+
const SELF_PAID_FALLBACK_STATUSES = new Set([400, 429, 503]);
|
|
10
|
+
export class EnsureDeployedError extends Error {
|
|
11
|
+
constructor(message, chainId) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.chainId = chainId;
|
|
14
|
+
this.name = "EnsureDeployedError";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function checkAborted(signal) {
|
|
18
|
+
if (signal?.aborted) {
|
|
19
|
+
throw signal.reason;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function sleep(ms, signal) {
|
|
23
|
+
return new Promise((resolve, reject) => {
|
|
24
|
+
const onAbort = () => {
|
|
25
|
+
clearTimeout(timer);
|
|
26
|
+
reject(signal?.reason);
|
|
27
|
+
};
|
|
28
|
+
const timer = setTimeout(() => {
|
|
29
|
+
signal?.removeEventListener("abort", onAbort);
|
|
30
|
+
resolve();
|
|
31
|
+
}, ms);
|
|
32
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function reportSteps(deploys, seen, onStep) {
|
|
36
|
+
let failedChainId;
|
|
37
|
+
for (const deploy of deploys) {
|
|
38
|
+
if (seen.get(deploy.chainId) === deploy.status)
|
|
39
|
+
continue;
|
|
40
|
+
seen.set(deploy.chainId, deploy.status);
|
|
41
|
+
onStep?.({
|
|
42
|
+
chainId: deploy.chainId,
|
|
43
|
+
status: deploy.status,
|
|
44
|
+
transactionHash: deploy.transactionHash ?? undefined,
|
|
45
|
+
});
|
|
46
|
+
if (deploy.status === "failed" && failedChainId === undefined) {
|
|
47
|
+
failedChainId = deploy.chainId;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (failedChainId !== undefined) {
|
|
51
|
+
throw new EnsureDeployedError(`JB Center could not deploy chain ${failedChainId}`, failedChainId);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async function pollUntilDeployed(client, seed, pollMs, timeoutMs, signal, onStep) {
|
|
55
|
+
const seen = new Map();
|
|
56
|
+
const startedAt = Date.now();
|
|
57
|
+
let current = seed;
|
|
58
|
+
while (true) {
|
|
59
|
+
checkAborted(signal);
|
|
60
|
+
reportSteps(current.deploys, seen, onStep);
|
|
61
|
+
if (isFullyDeployed(current)) {
|
|
62
|
+
return deployedChains(current);
|
|
63
|
+
}
|
|
64
|
+
if (Date.now() - startedAt >= timeoutMs) {
|
|
65
|
+
throw new EnsureDeployedError("JB Center deploy polling timed out");
|
|
66
|
+
}
|
|
67
|
+
await sleep(pollMs, signal);
|
|
68
|
+
current = await client.getIntent(current.id, { signal });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async function runSelfPaid(client, intent, selfPaid, onStep, signal) {
|
|
72
|
+
if (!selfPaid) {
|
|
73
|
+
throw new EnsureDeployedError("JB Center cannot sponsor this deploy and no self-paid fallback was provided");
|
|
74
|
+
}
|
|
75
|
+
checkAborted(signal);
|
|
76
|
+
const deployed = deployedChains(intent);
|
|
77
|
+
const remainingCalls = intent.envelope.deploymentCalls.filter((call) => !(call.chainId in deployed));
|
|
78
|
+
const deployments = await selfPaid(remainingCalls);
|
|
79
|
+
const remainingChainIds = new Set(remainingCalls.map((call) => call.chainId));
|
|
80
|
+
const returnedChainIds = new Set();
|
|
81
|
+
for (const deployment of deployments) {
|
|
82
|
+
if (!remainingChainIds.has(deployment.chainId)) {
|
|
83
|
+
throw new EnsureDeployedError(`Self-paid deploy returned an unexpected chain ${deployment.chainId}`, deployment.chainId);
|
|
84
|
+
}
|
|
85
|
+
if (returnedChainIds.has(deployment.chainId)) {
|
|
86
|
+
throw new EnsureDeployedError(`Self-paid deploy returned chain ${deployment.chainId} more than once`, deployment.chainId);
|
|
87
|
+
}
|
|
88
|
+
returnedChainIds.add(deployment.chainId);
|
|
89
|
+
}
|
|
90
|
+
for (const chainId of remainingChainIds) {
|
|
91
|
+
if (!returnedChainIds.has(chainId)) {
|
|
92
|
+
throw new EnsureDeployedError(`Self-paid deploy left chain ${chainId} undeployed`, chainId);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const result = { ...deployed };
|
|
96
|
+
for (const deployment of deployments) {
|
|
97
|
+
checkAborted(signal);
|
|
98
|
+
await client.recordDeployment(intent.id, deployment, { signal });
|
|
99
|
+
result[deployment.chainId] = deployment.projectId;
|
|
100
|
+
onStep?.({
|
|
101
|
+
chainId: deployment.chainId,
|
|
102
|
+
status: "self-paid",
|
|
103
|
+
transactionHash: deployment.transactionHash,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return result;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* The sender an intent already has, or `undefined` when nothing has started
|
|
110
|
+
* it yet. Every chain in an intent belongs to one sender, so this decides the
|
|
111
|
+
* route before any new request goes out.
|
|
112
|
+
*/
|
|
113
|
+
function existingSender(options, intent, pollMs, timeoutMs) {
|
|
114
|
+
const { client, onStep, selfPaid, signal } = options;
|
|
115
|
+
if (isFullyDeployed(intent)) {
|
|
116
|
+
return Promise.resolve(deployedChains(intent));
|
|
117
|
+
}
|
|
118
|
+
if (intent.deploys.length > 0) {
|
|
119
|
+
return pollUntilDeployed(client, intent, pollMs, timeoutMs, signal, onStep);
|
|
120
|
+
}
|
|
121
|
+
if (intent.deployments.length > 0) {
|
|
122
|
+
return runSelfPaid(client, intent, selfPaid, onStep, signal);
|
|
123
|
+
}
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* The pre-step every webclient runs before the first on-chain write against
|
|
128
|
+
* an undeployed intent: sponsor the deploy through JB Center when eligible
|
|
129
|
+
* and poll until every chain lands, or fall back to the caller's own launch
|
|
130
|
+
* pipeline when JB Center can't or won't sponsor it.
|
|
131
|
+
*/
|
|
132
|
+
export async function ensureDeployed(options) {
|
|
133
|
+
const { client, intent, onStep, selfPaid, signal } = options;
|
|
134
|
+
const pollMs = options.pollMs ?? DEFAULT_POLL_MS;
|
|
135
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
136
|
+
const started = existingSender(options, intent, pollMs, timeoutMs);
|
|
137
|
+
if (started)
|
|
138
|
+
return started;
|
|
139
|
+
if (!isSponsorable(intent.envelope.chainIds)) {
|
|
140
|
+
return runSelfPaid(client, intent, selfPaid, onStep, signal);
|
|
141
|
+
}
|
|
142
|
+
let deploys;
|
|
143
|
+
try {
|
|
144
|
+
checkAborted(signal);
|
|
145
|
+
({ deploys } = await client.requestDeploy(intent.id, { signal }));
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
if (error instanceof JBCenterRequestError &&
|
|
149
|
+
SELF_PAID_FALLBACK_STATUSES.has(error.status)) {
|
|
150
|
+
// The refusal may mean the sponsor already took this intent, so read the
|
|
151
|
+
// intent back and follow whatever sender it now has instead of adding a
|
|
152
|
+
// second one.
|
|
153
|
+
const fresh = await client.getIntent(intent.id, { signal });
|
|
154
|
+
return (existingSender(options, fresh, pollMs, timeoutMs) ??
|
|
155
|
+
runSelfPaid(client, fresh, selfPaid, onStep, signal));
|
|
156
|
+
}
|
|
157
|
+
throw error;
|
|
158
|
+
}
|
|
159
|
+
return pollUntilDeployed(client, { ...intent, deploys }, pollMs, timeoutMs, signal, onStep);
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=ensureDeployed.js.map
|
|
@@ -0,0 +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,GAOd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7D,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;AAqB7D,MAAM,OAAO,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;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,CAAC,KAAK,CAAC,CAAC;YACpB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;Q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O,CAAC;IAE5B,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7C,OAAO,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/D,CAAC;IAED,IAAI,OAA+B,CAAC;IACpC,IAAI,CAAC;QACH,YAAY,CAAC,MAAM,CAAC,CAAC;QACrB,CAAC,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IACpE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IACE,KAAK,YAAY,oBAAoB;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,44 @@
|
|
|
1
|
+
export function intentRow(item) {
|
|
2
|
+
const createdAt = Date.parse(item.createdAt);
|
|
3
|
+
return {
|
|
4
|
+
undeployed: true,
|
|
5
|
+
intentId: item.intentId,
|
|
6
|
+
name: item.name,
|
|
7
|
+
tagline: item.tagline,
|
|
8
|
+
logoUri: item.logoUri,
|
|
9
|
+
owner: item.owner,
|
|
10
|
+
chainIds: item.chainIds,
|
|
11
|
+
createdAt: Number.isNaN(createdAt) ? 0 : Math.floor(createdAt / 1000),
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/** Deployed rows win ties so a list never reorders once an intent lands. */
|
|
15
|
+
export function mergeSearch(rows, items) {
|
|
16
|
+
const entries = [
|
|
17
|
+
...rows.map((value) => ({ value, isRow: true })),
|
|
18
|
+
...items.map((item) => ({ value: intentRow(item), isRow: false })),
|
|
19
|
+
];
|
|
20
|
+
entries.sort((a, b) => {
|
|
21
|
+
if (a.value.createdAt !== b.value.createdAt) {
|
|
22
|
+
return b.value.createdAt - a.value.createdAt;
|
|
23
|
+
}
|
|
24
|
+
if (a.isRow !== b.isRow)
|
|
25
|
+
return a.isRow ? -1 : 1;
|
|
26
|
+
return 0;
|
|
27
|
+
});
|
|
28
|
+
return entries.map((entry) => entry.value);
|
|
29
|
+
}
|
|
30
|
+
export function intentPath(intentId) {
|
|
31
|
+
return `/intent/${encodeURIComponent(intentId)}`;
|
|
32
|
+
}
|
|
33
|
+
export function deployedChains(intent) {
|
|
34
|
+
const result = {};
|
|
35
|
+
for (const deployment of intent.deployments) {
|
|
36
|
+
result[deployment.chainId] = deployment.projectId;
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
export function isFullyDeployed(intent) {
|
|
41
|
+
const deployed = deployedChains(intent);
|
|
42
|
+
return intent.envelope.chainIds.every((chainId) => chainId in deployed);
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=merge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge.js","sourceRoot":"","sources":["../../../src/jbcenter/merge.ts"],"names":[],"mappings":"AAkBA,MAAM,UAAU,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,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC;KACtE,CAAC;AACJ,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,WAAW,CACzB,IAAkB,EAClB,KAAoC;IAIpC,MAAM,OAAO,GAAY;QACvB,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,EAA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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"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Key order and the casing of addresses and calldata are JB Center's to
|
|
3
|
+
* choose; the values are not. Sorting keys and lowercasing hex long enough to
|
|
4
|
+
* be an address or calldata puts both sides in one form so the comparison
|
|
5
|
+
* reads values only. Shorter hex-looking text is a value like any other and is
|
|
6
|
+
* compared as written.
|
|
7
|
+
*/
|
|
8
|
+
function canonical(value) {
|
|
9
|
+
return JSON.stringify(value, (_key, item) => {
|
|
10
|
+
if (typeof item === "string") {
|
|
11
|
+
return /^0x[0-9a-fA-F]{40,}$/u.test(item) ? item.toLowerCase() : item;
|
|
12
|
+
}
|
|
13
|
+
if (!item || typeof item !== "object" || Array.isArray(item))
|
|
14
|
+
return item;
|
|
15
|
+
return Object.fromEntries(Object.entries(item).sort(([a], [b]) => a < b ? -1 : 1));
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The shape JB Center normalizes an envelope into before it hashes: unique
|
|
20
|
+
* chain ids in ascending order, deployment calls in the same order, and
|
|
21
|
+
* `format` and `deploymentVersion` without surrounding space.
|
|
22
|
+
*/
|
|
23
|
+
function normalized(envelope) {
|
|
24
|
+
return {
|
|
25
|
+
...envelope,
|
|
26
|
+
format: envelope.format.trim(),
|
|
27
|
+
deploymentVersion: envelope.deploymentVersion.trim(),
|
|
28
|
+
chainIds: [...new Set(envelope.chainIds)].sort((a, b) => a - b),
|
|
29
|
+
deploymentCalls: [...envelope.deploymentCalls].sort((a, b) => a.chainId - b.chainId),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/** A copy of its own, so what is checked is what is published even if the
|
|
33
|
+
* caller keeps writing to its object while the signer is open. */
|
|
34
|
+
function snapshot(envelope) {
|
|
35
|
+
return JSON.parse(JSON.stringify(envelope));
|
|
36
|
+
}
|
|
37
|
+
/** JB Center's own signing message, word for word. */
|
|
38
|
+
function centerSigningMessage(contentHash) {
|
|
39
|
+
return `Juice Central project intent\nVersion: 1\nContent hash: ${contentHash}`;
|
|
40
|
+
}
|
|
41
|
+
/** The casing of the hash JB Center echoes is its to choose; every other
|
|
42
|
+
* character of the message is not. */
|
|
43
|
+
function withLowercaseHash(message, contentHash) {
|
|
44
|
+
const at = message.toLowerCase().indexOf(contentHash);
|
|
45
|
+
if (at === -1)
|
|
46
|
+
return message;
|
|
47
|
+
return `${message.slice(0, at)}${contentHash}${message.slice(at + contentHash.length)}`;
|
|
48
|
+
}
|
|
49
|
+
/** JB Center prepared something other than the intent the caller built. */
|
|
50
|
+
export class JBCenterIntentMismatchError extends Error {
|
|
51
|
+
constructor(reason) {
|
|
52
|
+
super(reason === "envelope"
|
|
53
|
+
? "JB Center prepared a different intent than the one built here"
|
|
54
|
+
: "JB Center's prepared message is not Center's signing message for that content hash");
|
|
55
|
+
this.reason = reason;
|
|
56
|
+
this.name = "JBCenterIntentMismatchError";
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Publish an intent, signing only JB Center's prepared message and only once
|
|
61
|
+
* it has been checked: the prepared envelope must carry the same values as
|
|
62
|
+
* the intent built here, and the message must be the whole signing message
|
|
63
|
+
* for the content hash of what is being signed. `sign` is the caller's own
|
|
64
|
+
* signer; this package never reaches a wallet itself.
|
|
65
|
+
*/
|
|
66
|
+
export async function publishSignedIntent(client, intent, sign, options) {
|
|
67
|
+
const checked = snapshot(normalized(intent));
|
|
68
|
+
const prepared = await client.prepareIntent(checked, options.request);
|
|
69
|
+
if (canonical(normalized(prepared.envelope)) !== canonical(checked)) {
|
|
70
|
+
throw new JBCenterIntentMismatchError("envelope");
|
|
71
|
+
}
|
|
72
|
+
const contentHash = prepared.contentHash.toLowerCase();
|
|
73
|
+
const expected = (options.expectMessage ?? centerSigningMessage)(contentHash);
|
|
74
|
+
if (withLowercaseHash(prepared.message, contentHash) !==
|
|
75
|
+
withLowercaseHash(expected, contentHash)) {
|
|
76
|
+
throw new JBCenterIntentMismatchError("message");
|
|
77
|
+
}
|
|
78
|
+
const signature = await sign(prepared.message);
|
|
79
|
+
return client.publishIntent({ ...checked, publisher: options.publisher, signature }, options.request);
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=publish.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish.js","sourceRoot":"","sources":["../../../src/jbcenter/publish.ts"],"names":[],"mappings":"AASA;;;;;;GAMG;AACH,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,IAAa,EAAE,EAAE;QACnD,IAAI,O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AAM,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC,WAAW,EAAS,CAAC;IAC9D,MAAM,QAAQ,GAAG,CAAC,OAAO,CAAC,aAAa,IAAI,oBAAoB,CAAC,CAAC,WAAW,CAAC,CAAC;IAC9E,IACE,iBAAiB,CAAC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;QAChD,iBAAiB,CAAC,QAAQ,EAAE,WAAW,CAAC,EACxC,CAAC;QACD,MAAM,IAAI,2BAA2B,CAAC,SAAS,CAAC,CAAC;IACnD,CAAC;IACD,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC/C,OAAO,MAAM,CAAC,aAAa,CACzB,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,SAAS,EAAE,EACvD,OAAO,CAAC,OAAO,CAChB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type JBCenterRefusalCode = "sponsor_quota" | "sponsor_budget" | "unavailable" | "rate_limited";
|
|
2
|
+
export type JBCenterRefusal = {
|
|
3
|
+
code: JBCenterRefusalCode;
|
|
4
|
+
message: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* The sentence to show when JB Center declines to sponsor a deploy, or `null`
|
|
8
|
+
* when the failure is something else and the caller should keep its own
|
|
9
|
+
* wording.
|
|
10
|
+
*/
|
|
11
|
+
export declare function describeCenterRefusal(error: unknown): JBCenterRefusal | null;
|
|
12
|
+
//# sourceMappingURL=refusal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refusal.d.ts","sourceRoot":"","sources":["../../../src/jbcenter/refusal.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,mBAAmB,GAC3B,eAAe,GACf,gBAAgB,GAChB,aAAa,GACb,cAAc,CAAC;AAEnB,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,mBAAmB,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAgBF;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAY5E"}
|