@seedprotocol/publish 0.7.3-next.654.g52217f6 → 0.7.3
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/README.md +4 -2
- package/dist/chainConfig-RhKIuGtN.js +5289 -0
- package/dist/chainConfig-RhKIuGtN.js.map +1 -0
- package/dist/config.d.ts +3 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/{ensureAutomationSessionKey-D0bbWT8e.js → ensureAutomationSessionKey-CvUntLne.js} +25 -26
- package/dist/{ensureAutomationSessionKey-D0bbWT8e.js.map → ensureAutomationSessionKey-CvUntLne.js.map} +1 -1
- package/dist/{ensureModularPublishBootstrap-x1bmc__0.js → ensureModularPublishBootstrap-D9q246TT.js} +9 -11
- package/dist/{ensureModularPublishBootstrap-x1bmc__0.js.map → ensureModularPublishBootstrap-D9q246TT.js.map} +1 -1
- package/dist/ensureSmartWalletThenPublish-C_iS5Wb-.js +52 -0
- package/dist/ensureSmartWalletThenPublish-C_iS5Wb-.js.map +1 -0
- package/dist/helpers/ensureSmartWalletThenPublish.d.ts +1 -0
- package/dist/helpers/ensureSmartWalletThenPublish.d.ts.map +1 -1
- package/dist/helpers/ensureWalletThenPublish.d.ts +7 -0
- package/dist/helpers/ensureWalletThenPublish.d.ts.map +1 -1
- package/dist/helpers/publishItem.d.ts +21 -0
- package/dist/helpers/publishItem.d.ts.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +341 -476
- package/dist/index.js.map +1 -1
- package/dist/managedAccountAdmin-CLVRJEKI.js +26 -0
- package/dist/{managedAccountAdmin-CdS1SCA_.js.map → managedAccountAdmin-CLVRJEKI.js.map} +1 -1
- package/dist/publishAuthorization-DAarz1JK.js +176 -0
- package/dist/publishAuthorization-DAarz1JK.js.map +1 -0
- package/dist/{resolveRevokeAccount-D2RP6qcU.js → resolveRevokeAccount-TRcqJtIO.js} +13 -15
- package/dist/{resolveRevokeAccount-D2RP6qcU.js.map → resolveRevokeAccount-TRcqJtIO.js.map} +1 -1
- package/dist/services/upload/uploadMachine.d.ts +1 -1
- package/dist/thirdweb.js +144 -145
- package/dist/thirdweb.js.map +1 -1
- package/dist/{worker-BIQLQSjk.js → worker-CyuMiBB-.js} +2 -2
- package/dist/{worker-BIQLQSjk.js.map → worker-CyuMiBB-.js.map} +1 -1
- package/package.json +6 -6
- package/dist/chainConfig-bc_6IgAw.js +0 -1455
- package/dist/chainConfig-bc_6IgAw.js.map +0 -1
- package/dist/ensureSmartWalletThenPublish-DNkeFWvC.js +0 -47
- package/dist/ensureSmartWalletThenPublish-DNkeFWvC.js.map +0 -1
- package/dist/managedAccountAdmin-CdS1SCA_.js +0 -28
- package/dist/publishAuthorization-C5kXlbOT.js +0 -3833
- package/dist/publishAuthorization-C5kXlbOT.js.map +0 -1
- package/dist/publishThirdwebClient-VSG2MC38.js +0 -18
- package/dist/publishThirdwebClient-VSG2MC38.js.map +0 -1
|
@@ -1,3833 +0,0 @@
|
|
|
1
|
-
import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
|
|
2
|
-
import { At as t, B as n, Ct as r, D as i, Dt as a, Et as o, F as s, G as c, H as l, I as u, J as d, K as f, L as p, O as m, Ot as h, P as g, Q as _, R as v, St as y, V as b, X as x, Y as S, Z as ee, _ as C, _t as te, a as w, at as ne, b as re, bt as ie, c as ae, ct as oe, dt as T, et as se, f as ce, ft as le, h as ue, ht as de, it as fe, j as pe, jt as me, k as he, lt as ge, mt as E, o as D, ot as _e, q as ve, r as ye, rt as be, st as xe, t as O, u as Se, ut as Ce, v as k, wt as we, xt as Te, y as A, yt as Ee, z as De } from "./chainConfig-bc_6IgAw.js";
|
|
3
|
-
import { t as j } from "./publishThirdwebClient-VSG2MC38.js";
|
|
4
|
-
import { BaseArweaveClient as Oe, BaseDb as ke, INTERNAL_DATA_TYPES as Ae, Item as M, ModelPropertyDataTypes as je, RelatedItemUnpublishedError as Me, applyPropertyAttestationUidsFromPublish as Ne, arweaveL1FinalizeJobs as Pe, assertLocalDbChain as Fe, getEasSchemaForItemProperty as Ie, getItemPropertiesFromEas as Le, getPublishUploadData as Re, getRelatedItemsForPublish as ze, getSegmentedItemProperties as Be, getUnpublishedRelatedItems as Ve, getUploadPipelineTransactionStatus as He, isItemOwned as Ue, itemHasPublishUploadCandidates as We, listRelationEasPropertyName as Ge, normalizeDataType as Ke, prepareHtmlEmbeddedImagesForPublish as qe, publishProcesses as N, resolvePublishPayloadValues as Je, rewriteHtmlEmbeddedImagesOnDisk as Ye, setSchemaUidForModel as Xe, setSchemaUidForSchemaDefinition as Ze, updateVersionUid as Qe, validateItemForPublish as $e } from "@seedprotocol/sdk";
|
|
5
|
-
import { BaseError as et, decodeAbiParameters as tt, decodeErrorResult as nt, isAddressEqual as rt, parseEther as it, parseEventLogs as at, toFunctionSelector as ot, zeroAddress as st } from "viem";
|
|
6
|
-
import { deploySmartAccount as ct, getContract as lt } from "thirdweb";
|
|
7
|
-
import { ethers as P, keccak256 as ut, toUtf8Bytes as dt } from "ethers";
|
|
8
|
-
import { PUBLISH_AUTHORIZATION_DEFAULT_EXPIRATION_SECS as ft, PUBLISH_AUTHORIZATION_SCHEMA_DEF as pt, PUBLISH_AUTHORIZATION_SCHEMA_DEF as mt, PUBLISH_AUTHORIZATION_SCHEMA_NAME as ht, PUBLISH_AUTHORIZATION_SCHEMA_NAME as gt, PUBLISH_AUTHORIZATION_SCOPES as _t, PUBLISH_AUTHORIZATION_SCOPES as vt, assessPublishAuthorization as yt, decodePublishAuthorizationData as bt, getPublishAuthorizationFromEas as xt, isValidEasAttestationUid as St, normalizeBytes32Hex as Ct } from "@seedprotocol/eas";
|
|
9
|
-
import { createContext as wt, useContext as Tt, useEffect as Et, useRef as Dt, useState as Ot } from "react";
|
|
10
|
-
import kt from "arweave";
|
|
11
|
-
import { NO_EXPIRATION as At, SchemaEncoder as jt, SchemaRegistry as Mt, ZERO_ADDRESS as Nt, ZERO_BYTES32 as Pt } from "@ethereum-attestation-service/eas-sdk";
|
|
12
|
-
import { assign as F, createActor as Ft, enqueueActions as It, fromCallback as Lt, fromPromise as I, setup as Rt } from "xstate";
|
|
13
|
-
import L from "debug";
|
|
14
|
-
import { createWallet as zt, inAppWallet as Bt } from "thirdweb/wallets";
|
|
15
|
-
import { useActiveAccount as Vt } from "thirdweb/react";
|
|
16
|
-
import { estimateUserOpGas as Ht, getPaymasterAndData as Ut } from "thirdweb/wallets/smart";
|
|
17
|
-
import { and as Wt, desc as Gt, eq as R } from "drizzle-orm";
|
|
18
|
-
//#region src/react/PublishConfigContext.tsx
|
|
19
|
-
var Kt = wt(null);
|
|
20
|
-
function qt() {
|
|
21
|
-
let e = Tt(Kt);
|
|
22
|
-
if (!e) throw Error("usePublishConfig: PublishConfig is missing. Pass config to PublishProvider or call initPublish() before render.");
|
|
23
|
-
return e;
|
|
24
|
-
}
|
|
25
|
-
//#endregion
|
|
26
|
-
//#region src/helpers/describeRevert.ts
|
|
27
|
-
var Jt = [
|
|
28
|
-
{
|
|
29
|
-
type: "error",
|
|
30
|
-
name: "PublishIndexOutOfBounds",
|
|
31
|
-
inputs: [{
|
|
32
|
-
name: "targetIndex",
|
|
33
|
-
type: "uint256"
|
|
34
|
-
}, {
|
|
35
|
-
name: "length",
|
|
36
|
-
type: "uint256"
|
|
37
|
-
}]
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
type: "error",
|
|
41
|
-
name: "UnknownPublishLocalId",
|
|
42
|
-
inputs: [{
|
|
43
|
-
name: "publishLocalId",
|
|
44
|
-
type: "string"
|
|
45
|
-
}]
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
type: "error",
|
|
49
|
-
name: "PublishTargetAlreadyAttested",
|
|
50
|
-
inputs: [{
|
|
51
|
-
name: "requestIndex",
|
|
52
|
-
type: "uint256"
|
|
53
|
-
}, {
|
|
54
|
-
name: "targetIndex",
|
|
55
|
-
type: "uint256"
|
|
56
|
-
}]
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
type: "error",
|
|
60
|
-
name: "EmptyAttestationData",
|
|
61
|
-
inputs: [{
|
|
62
|
-
name: "targetIndex",
|
|
63
|
-
type: "uint256"
|
|
64
|
-
}, {
|
|
65
|
-
name: "propertySchemaUid",
|
|
66
|
-
type: "bytes32"
|
|
67
|
-
}]
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
type: "error",
|
|
71
|
-
name: "PropertyToUpdateNotFound",
|
|
72
|
-
inputs: [
|
|
73
|
-
{
|
|
74
|
-
name: "requestIndex",
|
|
75
|
-
type: "uint256"
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
name: "targetIndex",
|
|
79
|
-
type: "uint256"
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
name: "propertySchemaUid",
|
|
83
|
-
type: "bytes32"
|
|
84
|
-
}
|
|
85
|
-
]
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
type: "error",
|
|
89
|
-
name: "AmbiguousPropertyToUpdate",
|
|
90
|
-
inputs: [{
|
|
91
|
-
name: "targetIndex",
|
|
92
|
-
type: "uint256"
|
|
93
|
-
}, {
|
|
94
|
-
name: "propertySchemaUid",
|
|
95
|
-
type: "bytes32"
|
|
96
|
-
}]
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
type: "error",
|
|
100
|
-
name: "InvalidEAS",
|
|
101
|
-
inputs: [{
|
|
102
|
-
name: "eas",
|
|
103
|
-
type: "address"
|
|
104
|
-
}]
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
type: "error",
|
|
108
|
-
name: "AttestationFailed",
|
|
109
|
-
inputs: [{
|
|
110
|
-
name: "schemaUid",
|
|
111
|
-
type: "bytes32"
|
|
112
|
-
}]
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
type: "error",
|
|
116
|
-
name: "Unauthorized",
|
|
117
|
-
inputs: [{
|
|
118
|
-
name: "caller",
|
|
119
|
-
type: "address"
|
|
120
|
-
}]
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
type: "error",
|
|
124
|
-
name: "InvalidAddress",
|
|
125
|
-
inputs: [{
|
|
126
|
-
name: "addr",
|
|
127
|
-
type: "address"
|
|
128
|
-
}]
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
type: "error",
|
|
132
|
-
name: "SeedExecutorAlreadyInstalled",
|
|
133
|
-
inputs: []
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
type: "error",
|
|
137
|
-
name: "SeedExecutorNotInstalled",
|
|
138
|
-
inputs: []
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
type: "error",
|
|
142
|
-
name: "NotSeedExecutor",
|
|
143
|
-
inputs: [{
|
|
144
|
-
name: "caller",
|
|
145
|
-
type: "address"
|
|
146
|
-
}]
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
type: "error",
|
|
150
|
-
name: "UnsupportedExecutionMode",
|
|
151
|
-
inputs: [{
|
|
152
|
-
name: "mode",
|
|
153
|
-
type: "bytes32"
|
|
154
|
-
}]
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
type: "error",
|
|
158
|
-
name: "TargetNotAllowed",
|
|
159
|
-
inputs: [{
|
|
160
|
-
name: "target",
|
|
161
|
-
type: "address"
|
|
162
|
-
}]
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
type: "error",
|
|
166
|
-
name: "SelectorNotAllowed",
|
|
167
|
-
inputs: [{
|
|
168
|
-
name: "selector",
|
|
169
|
-
type: "bytes4"
|
|
170
|
-
}]
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
type: "error",
|
|
174
|
-
name: "ValueMismatch",
|
|
175
|
-
inputs: [{
|
|
176
|
-
name: "encodedValue",
|
|
177
|
-
type: "uint256"
|
|
178
|
-
}, {
|
|
179
|
-
name: "sentValue",
|
|
180
|
-
type: "uint256"
|
|
181
|
-
}]
|
|
182
|
-
},
|
|
183
|
-
...y,
|
|
184
|
-
...we
|
|
185
|
-
];
|
|
186
|
-
function Yt(e) {
|
|
187
|
-
if (e instanceof et) return e.walk((e) => {
|
|
188
|
-
let t = e.data;
|
|
189
|
-
return typeof t == "string" && t.startsWith("0x") && t.length > 2;
|
|
190
|
-
})?.data;
|
|
191
|
-
}
|
|
192
|
-
function Xt(e) {
|
|
193
|
-
if (Yt(e)) return !0;
|
|
194
|
-
let t = e instanceof et ? `${e.shortMessage} ${e.details}` : String(e);
|
|
195
|
-
return /revert/i.test(t);
|
|
196
|
-
}
|
|
197
|
-
var Zt = "reverted with no data. The target likely has no matching function or the account cannot run executor calls";
|
|
198
|
-
function Qt(e, t = Zt) {
|
|
199
|
-
if (!e || e === "0x") return t;
|
|
200
|
-
try {
|
|
201
|
-
let t = nt({
|
|
202
|
-
abi: Jt,
|
|
203
|
-
data: e
|
|
204
|
-
}), n = t.args?.length ? `(${t.args.map(String).join(", ")})` : "";
|
|
205
|
-
return `reverted with ${t.errorName}${n}`;
|
|
206
|
-
} catch {
|
|
207
|
-
return `reverted with data ${e}`;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
function $t(e, t) {
|
|
211
|
-
return t && t !== "0x" ? `The publish UserOp in transaction ${e} ${Qt(t)}.` : `The publish UserOp in transaction ${e} failed with no revert reason. That usually means it ran out of gas (the bundler's gas estimate was too low), not that the publish data is wrong. To confirm, run \`npx hardhat seed:explain-userop --network <network> --tx ${e}\` in seed-protocol.`;
|
|
212
|
-
}
|
|
213
|
-
function en(e) {
|
|
214
|
-
let { txHash: t, revertData: n, sender: r, cause: i } = e, a = !!n && n !== "0x";
|
|
215
|
-
return new E($t(t, n), a ? "USEROP_REVERTED" : "USEROP_FAILED_NO_REASON", r, i);
|
|
216
|
-
}
|
|
217
|
-
function tn(e) {
|
|
218
|
-
let t = [];
|
|
219
|
-
for (let n = e; n && t.length < 6; n = n.cause) t.push(n);
|
|
220
|
-
return t;
|
|
221
|
-
}
|
|
222
|
-
var nn;
|
|
223
|
-
function rn(e) {
|
|
224
|
-
return nn ??= new Map(Jt.filter((e) => e.type === "error").map((e) => [ot(`${e.name}(${e.inputs.map((e) => e.type).join(",")})`), e.name])), nn.get(e.toLowerCase());
|
|
225
|
-
}
|
|
226
|
-
function an(e, t) {
|
|
227
|
-
for (let n of tn(e)) {
|
|
228
|
-
let r = String(n.message ?? "").match(/UserOp failed at txHash: (0x[0-9a-f]{64})/i);
|
|
229
|
-
if (r) return en({
|
|
230
|
-
txHash: r[1],
|
|
231
|
-
sender: t,
|
|
232
|
-
cause: e
|
|
233
|
-
});
|
|
234
|
-
let i = n.signature;
|
|
235
|
-
if (n.name === "AbiErrorSignatureNotFoundError" && typeof i == "string") {
|
|
236
|
-
let n = rn(i);
|
|
237
|
-
if (n) return new E(`The publish transaction reverted with ${n} (its arguments were not decoded).`, "USEROP_REVERTED", t, e);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
return e;
|
|
241
|
-
}
|
|
242
|
-
//#endregion
|
|
243
|
-
//#region src/helpers/blockchain.ts
|
|
244
|
-
var z = () => {
|
|
245
|
-
let e = Oe.getArweaveJsApiConfig(), t = kt;
|
|
246
|
-
return Object.keys(t).includes("default") && t.default ? t.default.init(e) : t.init(e);
|
|
247
|
-
};
|
|
248
|
-
//#endregion
|
|
249
|
-
//#region src/helpers/schemaRegistry.ts
|
|
250
|
-
async function B(e) {
|
|
251
|
-
return be(e);
|
|
252
|
-
}
|
|
253
|
-
function on(e) {
|
|
254
|
-
return d(e);
|
|
255
|
-
}
|
|
256
|
-
//#endregion
|
|
257
|
-
//#region src/helpers/nameSchemaAttestation.ts
|
|
258
|
-
var sn = "0x0000000000000000000000000000000000000000";
|
|
259
|
-
function cn(e) {
|
|
260
|
-
let t = new jt("bytes32 schemaId,string name").encodeData([{
|
|
261
|
-
name: "schemaId",
|
|
262
|
-
value: e.schemaUid,
|
|
263
|
-
type: "bytes32"
|
|
264
|
-
}, {
|
|
265
|
-
name: "name",
|
|
266
|
-
value: e.schemaName,
|
|
267
|
-
type: "string"
|
|
268
|
-
}]);
|
|
269
|
-
return l({
|
|
270
|
-
schema: o,
|
|
271
|
-
data: {
|
|
272
|
-
recipient: sn,
|
|
273
|
-
expirationTime: BigInt(At),
|
|
274
|
-
revocable: !0,
|
|
275
|
-
refUID: Pt,
|
|
276
|
-
data: t,
|
|
277
|
-
value: 0n
|
|
278
|
-
}
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
//#endregion
|
|
282
|
-
//#region src/services/publish/helpers/ensureEasSchemas.ts
|
|
283
|
-
var V = "0x0000000000000000000000000000000000000000", H = !0, ln = "bytes32 schemaId,string name", un = "bytes32 version", dn = /* @__PURE__ */ new Set();
|
|
284
|
-
function fn(e) {
|
|
285
|
-
return e.replace(/([a-z])([A-Z])/g, "$1_$2").toLowerCase();
|
|
286
|
-
}
|
|
287
|
-
async function pn(e) {
|
|
288
|
-
let { itemRelationProperties: t, itemImageProperties: n, itemListProperties: r } = await Be(e), i = /* @__PURE__ */ new Set();
|
|
289
|
-
e.modelName && i.add(e.modelName);
|
|
290
|
-
for (let e of t) {
|
|
291
|
-
let t = e.propertyDef?.ref;
|
|
292
|
-
t && i.add(t);
|
|
293
|
-
}
|
|
294
|
-
for (let e of n) {
|
|
295
|
-
let t = Ke(e.propertyDef?.dataType);
|
|
296
|
-
t === je.File ? i.add("File") : t === je.Html ? i.add("Html") : i.add("Image");
|
|
297
|
-
}
|
|
298
|
-
for (let e of r) {
|
|
299
|
-
let t = e.propertyDef?.ref;
|
|
300
|
-
t && i.add(t);
|
|
301
|
-
}
|
|
302
|
-
return i;
|
|
303
|
-
}
|
|
304
|
-
async function mn(e, t) {
|
|
305
|
-
let n = await e.sendTransaction(t);
|
|
306
|
-
await T(n.transactionHash);
|
|
307
|
-
}
|
|
308
|
-
function hn(e) {
|
|
309
|
-
let t = Ke(e);
|
|
310
|
-
return Ae[t]?.eas ?? "string";
|
|
311
|
-
}
|
|
312
|
-
function gn(e, t) {
|
|
313
|
-
if (e) throw Error(`schema "${t}" is not registered; automation keys can't register schemas. Call ensureEasSchemasForItem with the owner wallet first.`);
|
|
314
|
-
}
|
|
315
|
-
async function _n() {
|
|
316
|
-
let e = ye().id;
|
|
317
|
-
if (dn.has(e)) return;
|
|
318
|
-
let t = Mt.getSchemaUID(un, V, H), n = [[ln, o], [un, t]], r = [];
|
|
319
|
-
for (let [e, t] of n) await B(t) || r.push(`"${e}" (${t})`);
|
|
320
|
-
if (r.length > 0) throw Error(`Seed base schema${r.length > 1 ? "s" : ""} ${r.join(" and ")} not registered on chain ${e}. The protocol registers base schemas for each supported chain (seed-protocol: bun run seed:ensure-schemas).`);
|
|
321
|
-
dn.add(e);
|
|
322
|
-
}
|
|
323
|
-
async function vn(e, t) {
|
|
324
|
-
if (typeof t?.blockSchemaRegistration == "boolean") return t.blockSchemaRegistration;
|
|
325
|
-
let n = t?.managedAddress?.trim();
|
|
326
|
-
if (!n || !i(e)) return !1;
|
|
327
|
-
let { isAutomationSessionActive: r } = await import("./ensureAutomationSessionKey-D0bbWT8e.js").then((e) => e.n);
|
|
328
|
-
return r(n, e.signer.address);
|
|
329
|
-
}
|
|
330
|
-
async function yn(e, t, n) {
|
|
331
|
-
await bn(e, t, n);
|
|
332
|
-
}
|
|
333
|
-
async function bn(e, t, n) {
|
|
334
|
-
let r = await vn(t, n), a = i(t) ? t.txSender : he(t) ? t : (() => {
|
|
335
|
-
throw Error("@seedprotocol/publish: ensureEasSchemasForItem requires a PublishWallet or SeedTxSender");
|
|
336
|
-
})();
|
|
337
|
-
await _n();
|
|
338
|
-
let { itemBasicProperties: o, itemRelationProperties: s, itemImageProperties: c, itemListProperties: l } = await Be(e), u = [
|
|
339
|
-
...o,
|
|
340
|
-
...s,
|
|
341
|
-
...c,
|
|
342
|
-
...l
|
|
343
|
-
], d = /* @__PURE__ */ new Set(), f = await pn(e), p = /* @__PURE__ */ new Set();
|
|
344
|
-
for (let e of f) {
|
|
345
|
-
let t = `bytes32 ${fn(e)}`, n = Mt.getSchemaUID(t, V, H);
|
|
346
|
-
if (await B(n)) Xe({
|
|
347
|
-
modelName: e,
|
|
348
|
-
schemaUid: n
|
|
349
|
-
});
|
|
350
|
-
else if (p.has(n)) Xe({
|
|
351
|
-
modelName: e,
|
|
352
|
-
schemaUid: n
|
|
353
|
-
});
|
|
354
|
-
else {
|
|
355
|
-
gn(r, t);
|
|
356
|
-
try {
|
|
357
|
-
await mn(a, on({
|
|
358
|
-
schema: t,
|
|
359
|
-
resolverAddress: V,
|
|
360
|
-
revocable: H
|
|
361
|
-
}));
|
|
362
|
-
} catch (t) {
|
|
363
|
-
throw Error(`Failed to register EAS schema for model ${e}: ${t instanceof Error ? t.message : String(t)}`);
|
|
364
|
-
}
|
|
365
|
-
try {
|
|
366
|
-
await mn(a, cn({
|
|
367
|
-
schemaUid: n,
|
|
368
|
-
schemaName: fn(e)
|
|
369
|
-
}));
|
|
370
|
-
} catch (t) {
|
|
371
|
-
throw Error(`Failed to name EAS schema for model ${e}: ${t instanceof Error ? t.message : String(t)}`);
|
|
372
|
-
}
|
|
373
|
-
p.add(n), Xe({
|
|
374
|
-
modelName: e,
|
|
375
|
-
schemaUid: n
|
|
376
|
-
});
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
let m = "string storage_transaction_id", h = Mt.getSchemaUID(m, V, H);
|
|
380
|
-
if (await B(h)) Ze({
|
|
381
|
-
text: m,
|
|
382
|
-
schemaUid: h
|
|
383
|
-
});
|
|
384
|
-
else if (!d.has(h) && (f.has("Image") || f.has("File") || f.has("Html"))) {
|
|
385
|
-
gn(r, m);
|
|
386
|
-
try {
|
|
387
|
-
await mn(a, on({
|
|
388
|
-
schema: m,
|
|
389
|
-
resolverAddress: V,
|
|
390
|
-
revocable: H
|
|
391
|
-
})), await mn(a, cn({
|
|
392
|
-
schemaUid: h,
|
|
393
|
-
schemaName: "storage_transaction_id"
|
|
394
|
-
}));
|
|
395
|
-
} catch (e) {
|
|
396
|
-
throw Error(`Failed to register EAS schema for storageTransactionId: ${e instanceof Error ? e.message : String(e)}`);
|
|
397
|
-
}
|
|
398
|
-
d.add(h), Ze({
|
|
399
|
-
text: m,
|
|
400
|
-
schemaUid: h
|
|
401
|
-
});
|
|
402
|
-
}
|
|
403
|
-
for (let e of u) {
|
|
404
|
-
if (!e.propertyDef) continue;
|
|
405
|
-
let t = hn(e.propertyDef.dataType), n = e, i = Ge(e.propertyName, e.propertyDef), o = i ?? (n.storagePropertyName && n.storagePropertyName.length > 0 ? n.storagePropertyName : e.propertyName), s = fn(o), c = `${t} ${s}`;
|
|
406
|
-
if (i && !s.endsWith("_ids")) throw Error(`Refusing to register "${c}" for list-relation property ${e.propertyName}: list relations attest as <singular>_<ref>_ids.`);
|
|
407
|
-
let l = [
|
|
408
|
-
"string",
|
|
409
|
-
"address",
|
|
410
|
-
"bool",
|
|
411
|
-
"bytes",
|
|
412
|
-
"bytes32",
|
|
413
|
-
"uint8",
|
|
414
|
-
"uint16",
|
|
415
|
-
"uint32",
|
|
416
|
-
"uint64",
|
|
417
|
-
"uint128",
|
|
418
|
-
"uint256"
|
|
419
|
-
].includes(t) ? t : void 0, u = await Ie({
|
|
420
|
-
schemaUid: i ? void 0 : e.schemaUid,
|
|
421
|
-
propertyName: o,
|
|
422
|
-
easDataType: l
|
|
423
|
-
});
|
|
424
|
-
if (u) {
|
|
425
|
-
let e = await B(u.id);
|
|
426
|
-
if (e && e.schema === c) {
|
|
427
|
-
Ze({
|
|
428
|
-
text: c,
|
|
429
|
-
schemaUid: u.id
|
|
430
|
-
});
|
|
431
|
-
continue;
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
let f = Mt.getSchemaUID(c, V, H);
|
|
435
|
-
if (await B(f)) Ze({
|
|
436
|
-
text: c,
|
|
437
|
-
schemaUid: f
|
|
438
|
-
});
|
|
439
|
-
else if (d.has(f)) Ze({
|
|
440
|
-
text: c,
|
|
441
|
-
schemaUid: f
|
|
442
|
-
});
|
|
443
|
-
else {
|
|
444
|
-
gn(r, c);
|
|
445
|
-
try {
|
|
446
|
-
await mn(a, on({
|
|
447
|
-
schema: c,
|
|
448
|
-
resolverAddress: V,
|
|
449
|
-
revocable: H
|
|
450
|
-
}));
|
|
451
|
-
} catch (t) {
|
|
452
|
-
throw Error(`Failed to register EAS schema for property ${e.propertyName}: ${t instanceof Error ? t.message : String(t)}`);
|
|
453
|
-
}
|
|
454
|
-
try {
|
|
455
|
-
await mn(a, cn({
|
|
456
|
-
schemaUid: f,
|
|
457
|
-
schemaName: s
|
|
458
|
-
}));
|
|
459
|
-
} catch (t) {
|
|
460
|
-
throw Error(`Failed to name EAS schema for property ${e.propertyName}: ${t instanceof Error ? t.message : String(t)}`);
|
|
461
|
-
}
|
|
462
|
-
d.add(f), Ze({
|
|
463
|
-
text: c,
|
|
464
|
-
schemaUid: f
|
|
465
|
-
});
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
let g = await ze(e);
|
|
469
|
-
for (let e of g) await bn(e, t, {
|
|
470
|
-
managedAddress: n?.managedAddress,
|
|
471
|
-
blockSchemaRegistration: r
|
|
472
|
-
});
|
|
473
|
-
}
|
|
474
|
-
//#endregion
|
|
475
|
-
//#region src/services/publish/actors/utils.ts
|
|
476
|
-
var U = "0x" + "0".repeat(64), xn = async (e) => {
|
|
477
|
-
let t;
|
|
478
|
-
try {
|
|
479
|
-
t = await M.find({ seedLocalId: e });
|
|
480
|
-
} catch {}
|
|
481
|
-
return t || new Promise((t) => {
|
|
482
|
-
let n = setInterval(() => {
|
|
483
|
-
try {
|
|
484
|
-
M.find({ seedLocalId: e }).then((e) => {
|
|
485
|
-
e && (clearInterval(n), t(e));
|
|
486
|
-
});
|
|
487
|
-
} catch {}
|
|
488
|
-
}, 200);
|
|
489
|
-
});
|
|
490
|
-
};
|
|
491
|
-
function Sn(e) {
|
|
492
|
-
if (!e || typeof e != "object") return;
|
|
493
|
-
let t = e;
|
|
494
|
-
if (Array.isArray(t.data_root)) return {
|
|
495
|
-
data_root: new Uint8Array(t.data_root),
|
|
496
|
-
chunks: (t.chunks ?? []).map((e) => ({
|
|
497
|
-
...e,
|
|
498
|
-
dataHash: new Uint8Array(e.dataHash ?? [])
|
|
499
|
-
})),
|
|
500
|
-
proofs: (t.proofs ?? []).map((e) => ({
|
|
501
|
-
...e,
|
|
502
|
-
proof: new Uint8Array(e.proof ?? [])
|
|
503
|
-
}))
|
|
504
|
-
};
|
|
505
|
-
}
|
|
506
|
-
function Cn(e) {
|
|
507
|
-
return {
|
|
508
|
-
data_root: Array.from(e.data_root),
|
|
509
|
-
chunks: e.chunks.map((e) => ({
|
|
510
|
-
...e,
|
|
511
|
-
dataHash: Array.from(e.dataHash)
|
|
512
|
-
})),
|
|
513
|
-
proofs: e.proofs.map((e) => ({
|
|
514
|
-
...e,
|
|
515
|
-
proof: Array.from(e.proof)
|
|
516
|
-
}))
|
|
517
|
-
};
|
|
518
|
-
}
|
|
519
|
-
//#endregion
|
|
520
|
-
//#region src/services/publish/actors/createArweaveTransactions.ts
|
|
521
|
-
var wn = I(async ({ input: { context: e } }) => {
|
|
522
|
-
let { item: t } = e;
|
|
523
|
-
t.getPublishUploads || (t = await xn(t.seedLocalId));
|
|
524
|
-
let n = {};
|
|
525
|
-
e.arweaveUploadTags?.length && (n.arweaveUploadTags = e.arweaveUploadTags);
|
|
526
|
-
let r = e.htmlEmbeddedDeferredHtmlSeedLocalIds;
|
|
527
|
-
r?.length && (n.deferHtmlStorageSeedLocalIds = r);
|
|
528
|
-
let i = await t.getPublishUploads(Object.keys(n).length ? n : void 0), a = D(), o = e.signArweaveTransactions ?? a.signArweaveTransactions, s = e.arweaveJwk ?? a.arweaveJwk, c = i.map((e) => ({
|
|
529
|
-
versionLocalId: e.versionLocalId,
|
|
530
|
-
itemPropertyName: e.itemPropertyName,
|
|
531
|
-
transactionJson: e.transactionToSign.toJSON()
|
|
532
|
-
})), l;
|
|
533
|
-
if (o) l = await o(c);
|
|
534
|
-
else if (s) {
|
|
535
|
-
let e = z(), t = s;
|
|
536
|
-
l = [];
|
|
537
|
-
for (let n of c) {
|
|
538
|
-
let r = e.transactions.fromRaw(n.transactionJson);
|
|
539
|
-
r.data && r.data.byteLength > 0 && !r.chunks && await r.prepareChunks(r.data), await e.transactions.sign(r, t);
|
|
540
|
-
let i = r.toJSON();
|
|
541
|
-
l.push({
|
|
542
|
-
transaction: {
|
|
543
|
-
...i,
|
|
544
|
-
chunks: r.chunks ? Cn(r.chunks) : void 0
|
|
545
|
-
},
|
|
546
|
-
versionId: n.versionLocalId,
|
|
547
|
-
modelName: n.itemPropertyName
|
|
548
|
-
});
|
|
549
|
-
}
|
|
550
|
-
} else throw Error("Arweave signing not configured. Provide signArweaveTransactions or arweaveJwk at createPublish or in PublishProvider config.");
|
|
551
|
-
let u = z();
|
|
552
|
-
return {
|
|
553
|
-
arweaveTransactions: l.map((e) => {
|
|
554
|
-
let { chunks: t, ...n } = e.transaction, r = { ...n }, i = Sn(t);
|
|
555
|
-
return i && (r.chunks = i), {
|
|
556
|
-
transaction: u.transactions.fromRaw(r),
|
|
557
|
-
versionId: e.versionId,
|
|
558
|
-
modelName: e.modelName
|
|
559
|
-
};
|
|
560
|
-
}),
|
|
561
|
-
publishUploads: i
|
|
562
|
-
};
|
|
563
|
-
}), Tn = I(async ({ input: { context: e } }) => {
|
|
564
|
-
let { item: t } = e;
|
|
565
|
-
t.getPublishUploads || (t = await xn(t.seedLocalId));
|
|
566
|
-
let n = {};
|
|
567
|
-
e.arweaveUploadTags?.length && (n.arweaveUploadTags = e.arweaveUploadTags);
|
|
568
|
-
let r = e.htmlEmbeddedDeferredHtmlSeedLocalIds;
|
|
569
|
-
r?.length && (n.onlyHtmlStorageSeedLocalIds = r);
|
|
570
|
-
let i = await t.getPublishUploads(Object.keys(n).length ? n : void 0), a = D(), o = e.signArweaveTransactions ?? a.signArweaveTransactions, s = e.arweaveJwk ?? a.arweaveJwk, c = i.map((e) => ({
|
|
571
|
-
versionLocalId: e.versionLocalId,
|
|
572
|
-
itemPropertyName: e.itemPropertyName,
|
|
573
|
-
transactionJson: e.transactionToSign.toJSON()
|
|
574
|
-
})), l;
|
|
575
|
-
if (o) l = await o(c);
|
|
576
|
-
else if (s) {
|
|
577
|
-
let e = z(), t = s;
|
|
578
|
-
l = [];
|
|
579
|
-
for (let n of c) {
|
|
580
|
-
let r = e.transactions.fromRaw(n.transactionJson);
|
|
581
|
-
r.data && r.data.byteLength > 0 && !r.chunks && await r.prepareChunks(r.data), await e.transactions.sign(r, t);
|
|
582
|
-
let i = r.toJSON();
|
|
583
|
-
l.push({
|
|
584
|
-
transaction: {
|
|
585
|
-
...i,
|
|
586
|
-
chunks: r.chunks ? Cn(r.chunks) : void 0
|
|
587
|
-
},
|
|
588
|
-
versionId: n.versionLocalId,
|
|
589
|
-
modelName: n.itemPropertyName
|
|
590
|
-
});
|
|
591
|
-
}
|
|
592
|
-
} else throw Error("Arweave signing not configured. Provide signArweaveTransactions or arweaveJwk at createPublish or in PublishProvider config.");
|
|
593
|
-
let u = z();
|
|
594
|
-
return {
|
|
595
|
-
arweaveTransactions: l.map((e) => {
|
|
596
|
-
let { chunks: t, ...n } = e.transaction, r = { ...n }, i = Sn(t);
|
|
597
|
-
return i && (r.chunks = i), {
|
|
598
|
-
transaction: u.transactions.fromRaw(r),
|
|
599
|
-
versionId: e.versionId,
|
|
600
|
-
modelName: e.modelName
|
|
601
|
-
};
|
|
602
|
-
}),
|
|
603
|
-
publishUploads: i
|
|
604
|
-
};
|
|
605
|
-
}), En = I(async ({ input: { context: e } }) => {
|
|
606
|
-
let t = e.htmlEmbeddedDataUriPolicy ?? "materialize";
|
|
607
|
-
return { deferredHtmlSeedLocalIds: (await qe(e.item, t)).deferredHtmlSeedLocalIds };
|
|
608
|
-
});
|
|
609
|
-
//#endregion
|
|
610
|
-
//#region src/services/publish/actors/rewritingHtmlEmbedded.ts
|
|
611
|
-
function Dn(e, t) {
|
|
612
|
-
let n = [], r = Math.min(e?.length ?? 0, t?.length ?? 0);
|
|
613
|
-
for (let i = 0; i < r; i++) {
|
|
614
|
-
let r = e[i], a = t[i], o = r.transaction?.id;
|
|
615
|
-
typeof o == "string" && o.length > 0 && n.push({
|
|
616
|
-
txId: o,
|
|
617
|
-
seedLocalId: a.seedLocalId,
|
|
618
|
-
versionLocalId: a.versionLocalId
|
|
619
|
-
});
|
|
620
|
-
}
|
|
621
|
-
return n;
|
|
622
|
-
}
|
|
623
|
-
var On = I(async ({ input: { context: e } }) => {
|
|
624
|
-
let t = Dn(e.htmlEmbeddedPhase1ArweaveTransactions, e.htmlEmbeddedPhase1PublishUploads);
|
|
625
|
-
await Ye(e.item.seedLocalId, t, e.htmlEmbeddedDeferredHtmlSeedLocalIds);
|
|
626
|
-
}), kn = (...e) => Re(...e), An = 3, jn = new TextEncoder().encode("seed-recovery"), Mn = 32, Nn = 18446744073709551615n;
|
|
627
|
-
function Pn(e, t, n) {
|
|
628
|
-
let r = P.solidityPackedKeccak256([
|
|
629
|
-
"uint256",
|
|
630
|
-
"address",
|
|
631
|
-
"uint64"
|
|
632
|
-
], [
|
|
633
|
-
BigInt(t),
|
|
634
|
-
e,
|
|
635
|
-
n & Nn
|
|
636
|
-
]);
|
|
637
|
-
return P.getBytes(r);
|
|
638
|
-
}
|
|
639
|
-
function Fn(e) {
|
|
640
|
-
if (e.length === 0) return new Uint8Array([0]);
|
|
641
|
-
if (e.length !== Mn) throw Error(`ANS-104 target/anchor must be empty or ${Mn} bytes, got ${e.length}`);
|
|
642
|
-
let t = /* @__PURE__ */ new Uint8Array(33);
|
|
643
|
-
return t[0] = 1, t.set(e, 1), t;
|
|
644
|
-
}
|
|
645
|
-
function In(e) {
|
|
646
|
-
return typeof e == "object" && !!e && "privateKey" in e && typeof e.privateKey == "string";
|
|
647
|
-
}
|
|
648
|
-
function Ln(e, t, n) {
|
|
649
|
-
let r = e >= 0 ? e << 1 : ~e << 1 | 1, i = n;
|
|
650
|
-
do {
|
|
651
|
-
let e = r & 127;
|
|
652
|
-
r >>>= 7, t[i++] = r ? e | 128 : e;
|
|
653
|
-
} while (r);
|
|
654
|
-
return i - n;
|
|
655
|
-
}
|
|
656
|
-
var Rn = (e) => {
|
|
657
|
-
if (!e?.length) return /* @__PURE__ */ new Uint8Array();
|
|
658
|
-
let t = new TextEncoder(), n = /* @__PURE__ */ new Uint8Array(16), r = [], i = (e) => {
|
|
659
|
-
let t = Ln(e, n, 0);
|
|
660
|
-
r.push(n.slice(0, t));
|
|
661
|
-
};
|
|
662
|
-
i(e.length);
|
|
663
|
-
for (let n of e) {
|
|
664
|
-
let e = t.encode(n.name), a = t.encode(n.value);
|
|
665
|
-
i(e.length), r.push(e), i(a.length), r.push(a);
|
|
666
|
-
}
|
|
667
|
-
i(0);
|
|
668
|
-
let a = r.reduce((e, t) => e + t.length, 0), o = new Uint8Array(a), s = 0;
|
|
669
|
-
for (let e of r) o.set(e, s), s += e.length;
|
|
670
|
-
return o;
|
|
671
|
-
}, zn = (e) => {
|
|
672
|
-
let t = /* @__PURE__ */ new Uint8Array(8), n = new DataView(t.buffer);
|
|
673
|
-
return n.setUint32(0, e | 0, !0), n.setUint32(4, Math.floor(e / 4294967296), !0), t;
|
|
674
|
-
};
|
|
675
|
-
async function Bn(e) {
|
|
676
|
-
return new Uint8Array(await crypto.subtle.digest("SHA-384", e));
|
|
677
|
-
}
|
|
678
|
-
function Vn(e, t) {
|
|
679
|
-
let n = new Uint8Array(e.length + t.length);
|
|
680
|
-
return n.set(e, 0), n.set(t, e.length), n;
|
|
681
|
-
}
|
|
682
|
-
async function Hn(e) {
|
|
683
|
-
let t = new TextEncoder();
|
|
684
|
-
if (Array.isArray(e)) {
|
|
685
|
-
let n = await Bn(Vn(t.encode("list"), t.encode(e.length.toString())));
|
|
686
|
-
for (let t of e) {
|
|
687
|
-
let e = await Hn(t);
|
|
688
|
-
n = await Bn(Vn(n, e));
|
|
689
|
-
}
|
|
690
|
-
return n;
|
|
691
|
-
}
|
|
692
|
-
return Bn(Vn(await Bn(Vn(t.encode("blob"), t.encode(e.byteLength.toString()))), await Bn(e)));
|
|
693
|
-
}
|
|
694
|
-
async function Un(e, t, n, r, i) {
|
|
695
|
-
let a = new TextEncoder();
|
|
696
|
-
return Hn([
|
|
697
|
-
a.encode("dataitem"),
|
|
698
|
-
a.encode("1"),
|
|
699
|
-
a.encode(An.toString()),
|
|
700
|
-
e,
|
|
701
|
-
t,
|
|
702
|
-
n,
|
|
703
|
-
r,
|
|
704
|
-
i
|
|
705
|
-
]);
|
|
706
|
-
}
|
|
707
|
-
function Wn(e, t, n, r, i) {
|
|
708
|
-
let a = Rn(t), o = zn(t.length), s = zn(a.length), c = [
|
|
709
|
-
e,
|
|
710
|
-
Fn(r),
|
|
711
|
-
Fn(i),
|
|
712
|
-
o,
|
|
713
|
-
s,
|
|
714
|
-
a,
|
|
715
|
-
n
|
|
716
|
-
], l = c.reduce((e, t) => e + t.length, 0), u = new Uint8Array(l), d = 0;
|
|
717
|
-
for (let e of c) u.set(e, d), d += e.length;
|
|
718
|
-
return u;
|
|
719
|
-
}
|
|
720
|
-
async function Gn(e, t) {
|
|
721
|
-
let n = /* @__PURE__ */ new Uint8Array(2);
|
|
722
|
-
new DataView(n.buffer).setUint16(0, An, !0);
|
|
723
|
-
let r = 67 + t.length, i = new Uint8Array(r);
|
|
724
|
-
i.set(n, 0), i.set(e, 2), i.set(t, 67);
|
|
725
|
-
let a = await crypto.subtle.digest("SHA-256", new Uint8Array(e));
|
|
726
|
-
return {
|
|
727
|
-
id: Zn(new Uint8Array(a)),
|
|
728
|
-
raw: i
|
|
729
|
-
};
|
|
730
|
-
}
|
|
731
|
-
var Kn = async (e, t, n, r = /* @__PURE__ */ new Uint8Array()) => {
|
|
732
|
-
let i = P.SigningKey.computePublicKey(t.privateKey, !1), a = P.getBytes(i), o = Rn(n), s = /* @__PURE__ */ new Uint8Array(), c = await Un(a, s, r, o, e);
|
|
733
|
-
return Gn(P.getBytes(await t.signMessage(c)), Wn(a, n, e, s, r));
|
|
734
|
-
}, qn = async (e, t, n, r = /* @__PURE__ */ new Uint8Array()) => {
|
|
735
|
-
let i = P.hexlify(jn), a = await t.signMessage({ message: { raw: i } }), o = P.hashMessage(jn), s = P.SigningKey.recoverPublicKey(o, a), c = P.getBytes(s), l = Rn(n), u = /* @__PURE__ */ new Uint8Array(), d = await Un(c, u, r, l, e), f = P.hexlify(d), p = await t.signMessage({ message: { raw: f } });
|
|
736
|
-
return Gn(P.getBytes(p), Wn(c, n, e, u, r));
|
|
737
|
-
};
|
|
738
|
-
function Jn(e) {
|
|
739
|
-
if (e.length < 133) return null;
|
|
740
|
-
let t = e[132];
|
|
741
|
-
if (t !== 0 && t !== 1) return null;
|
|
742
|
-
let n = t === 1;
|
|
743
|
-
if (n && e.length < 165) return null;
|
|
744
|
-
let r = 132 + (n ? 33 : 1);
|
|
745
|
-
if (e.length < r + 1) return null;
|
|
746
|
-
let i = e[r];
|
|
747
|
-
if (i !== 0 && i !== 1) return null;
|
|
748
|
-
let a = i === 1;
|
|
749
|
-
return a && e.length < r + 33 ? null : r + (a ? 33 : 1);
|
|
750
|
-
}
|
|
751
|
-
function Yn(e) {
|
|
752
|
-
let t = Jn(e);
|
|
753
|
-
if (t == null) return null;
|
|
754
|
-
let n = e[132] === 1, r = n ? e.slice(133, 165) : /* @__PURE__ */ new Uint8Array(), i = 132 + (n ? 33 : 1);
|
|
755
|
-
return {
|
|
756
|
-
rawTarget: r,
|
|
757
|
-
rawAnchor: e[i] === 1 ? e.slice(i + 1, i + 33) : /* @__PURE__ */ new Uint8Array(),
|
|
758
|
-
tagsStart: t
|
|
759
|
-
};
|
|
760
|
-
}
|
|
761
|
-
async function Xn(e) {
|
|
762
|
-
let t = Yn(e);
|
|
763
|
-
if (t == null) return !1;
|
|
764
|
-
let { rawTarget: n, rawAnchor: r, tagsStart: i } = t, a = i + 16;
|
|
765
|
-
if (e.length < a) return !1;
|
|
766
|
-
let o = new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
767
|
-
if (o.getUint16(0, !0) !== An) return !1;
|
|
768
|
-
let s = e.slice(2, 67), c = e.slice(67, 132), l = Number(o.getUint32(i + 8, !0) + o.getUint32(i + 12, !0) * 4294967296), u = i + 16 + l;
|
|
769
|
-
if (e.length < u) return !1;
|
|
770
|
-
let d = e.slice(i + 16, u), f = e.slice(u);
|
|
771
|
-
try {
|
|
772
|
-
let e = await Un(c, n, r, d, f), t = P.hashMessage(e), i = P.hexlify(s), a = P.SigningKey.recoverPublicKey(t, i), o = P.getBytes(a);
|
|
773
|
-
return o.length === c.length && o.every((e, t) => e === c[t]);
|
|
774
|
-
} catch {
|
|
775
|
-
return !1;
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
var Zn = (e) => {
|
|
779
|
-
let t = "";
|
|
780
|
-
for (let n of e) t += String.fromCharCode(n);
|
|
781
|
-
return btoa(t).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
782
|
-
}, Qn = L("seedProtocol:createArweaveDataItems");
|
|
783
|
-
async function $n(e, t, n) {
|
|
784
|
-
let r, a;
|
|
785
|
-
if (t) r = (await t(e)).map((e) => ({
|
|
786
|
-
transaction: { id: e.transaction.id },
|
|
787
|
-
versionId: e.versionId,
|
|
788
|
-
modelName: e.modelName
|
|
789
|
-
}));
|
|
790
|
-
else if (n) {
|
|
791
|
-
let t = [], o = Date.now();
|
|
792
|
-
for (let r = 0; r < e.length; r++) {
|
|
793
|
-
let a = e[r], s = a.tags, c = /* @__PURE__ */ new Uint8Array(8);
|
|
794
|
-
crypto.getRandomValues(c);
|
|
795
|
-
let l = (new DataView(c.buffer).getBigUint64(0, !1) ^ BigInt(r)) & 18446744073709551615n, u;
|
|
796
|
-
if (In(n)) {
|
|
797
|
-
let e = Pn(n.address, o, l);
|
|
798
|
-
u = await Kn(a.data, n, s, e);
|
|
799
|
-
} else {
|
|
800
|
-
let e = i(n) ? n.signer : n, t = Pn(e.address, o, l);
|
|
801
|
-
u = await qn(a.data, e, s, t);
|
|
802
|
-
}
|
|
803
|
-
if (!await Xn(u.raw)) throw Qn("DataItem verification failed: id=%s modelName=%s", u.id, a.itemPropertyName), Error(`DataItem signature verification failed for ${a.itemPropertyName}. The signing key may not match the owner, or the payload may have been modified.`);
|
|
804
|
-
t.push(u);
|
|
805
|
-
}
|
|
806
|
-
a = t, r = t.map((t, n) => ({
|
|
807
|
-
transaction: { id: t.id },
|
|
808
|
-
versionId: e[n]?.versionLocalId,
|
|
809
|
-
modelName: e[n]?.itemPropertyName
|
|
810
|
-
}));
|
|
811
|
-
} else throw Error("@seedprotocol/publish: useArweaveBundler requires signDataItems or dataItemSigner (pass at createPublish or in PublishProvider config)");
|
|
812
|
-
let o = e.map((e) => ({
|
|
813
|
-
itemPropertyName: e.itemPropertyName,
|
|
814
|
-
itemPropertyLocalId: e.itemPropertyLocalId,
|
|
815
|
-
seedLocalId: e.seedLocalId,
|
|
816
|
-
versionLocalId: e.versionLocalId,
|
|
817
|
-
transactionToSign: null
|
|
818
|
-
}));
|
|
819
|
-
return {
|
|
820
|
-
arweaveTransactions: r,
|
|
821
|
-
publishUploads: o,
|
|
822
|
-
signedDataItems: a
|
|
823
|
-
};
|
|
824
|
-
}
|
|
825
|
-
var er = I(async ({ input: { context: e } }) => {
|
|
826
|
-
let { item: t } = e;
|
|
827
|
-
t.getPublishUploads || (t = await xn(t.seedLocalId));
|
|
828
|
-
let n = {};
|
|
829
|
-
e.arweaveUploadTags?.length && (n.arweaveUploadTags = e.arweaveUploadTags);
|
|
830
|
-
let r = e.htmlEmbeddedDeferredHtmlSeedLocalIds;
|
|
831
|
-
r?.length && (n.deferHtmlStorageSeedLocalIds = r);
|
|
832
|
-
let i = await kn(t, [], void 0, Object.keys(n).length ? n : void 0), a = D();
|
|
833
|
-
return $n(i, e.signDataItems ?? a.signDataItems, e.dataItemSigner ?? a.dataItemSigner);
|
|
834
|
-
});
|
|
835
|
-
//#endregion
|
|
836
|
-
//#region src/services/publish/actors/createArweaveDataItemsPhase2.ts
|
|
837
|
-
async function tr(e) {
|
|
838
|
-
let { item: t } = e;
|
|
839
|
-
t.getPublishUploads || (t = await xn(t.seedLocalId));
|
|
840
|
-
let n = {};
|
|
841
|
-
e.arweaveUploadTags?.length && (n.arweaveUploadTags = e.arweaveUploadTags);
|
|
842
|
-
let r = e.htmlEmbeddedDeferredHtmlSeedLocalIds;
|
|
843
|
-
r?.length && (n.onlyHtmlStorageSeedLocalIds = r);
|
|
844
|
-
let i = await kn(t, [], void 0, Object.keys(n).length ? n : void 0), a = D(), o = e.signDataItems ?? a.signDataItems, s = e.dataItemSigner ?? a.dataItemSigner;
|
|
845
|
-
return i.length === 0 ? {
|
|
846
|
-
arweaveTransactions: [],
|
|
847
|
-
publishUploads: [],
|
|
848
|
-
signedDataItems: void 0
|
|
849
|
-
} : $n(i, o, s);
|
|
850
|
-
}
|
|
851
|
-
var nr = I(async ({ input: { context: e } }) => tr(e)), rr = 8192;
|
|
852
|
-
function ir(e) {
|
|
853
|
-
let t = new Uint8Array(e), n = "";
|
|
854
|
-
for (let e = 0; e < t.length; e += rr) {
|
|
855
|
-
let r = t.subarray(e, Math.min(e + rr, t.length));
|
|
856
|
-
n += String.fromCharCode.apply(null, r);
|
|
857
|
-
}
|
|
858
|
-
return btoa(n);
|
|
859
|
-
}
|
|
860
|
-
async function ar(e) {
|
|
861
|
-
let t = [];
|
|
862
|
-
for (let [n, r] of e.entries()) {
|
|
863
|
-
let e = r;
|
|
864
|
-
if (typeof e == "object" && e && "arrayBuffer" in e) {
|
|
865
|
-
let r = ir(await e.arrayBuffer()), i = e;
|
|
866
|
-
t.push({
|
|
867
|
-
name: n,
|
|
868
|
-
value: r,
|
|
869
|
-
encoding: "base64",
|
|
870
|
-
filename: i.name || void 0
|
|
871
|
-
});
|
|
872
|
-
} else t.push({
|
|
873
|
-
name: n,
|
|
874
|
-
value: String(r)
|
|
875
|
-
});
|
|
876
|
-
}
|
|
877
|
-
return t;
|
|
878
|
-
}
|
|
879
|
-
function or(e, t, n) {
|
|
880
|
-
let r = ["Upload server returned ", String(e)], i = t && typeof t == "object" && "message" in t ? String(t.message) : t && typeof t == "object" && "error" in t ? String(t.error) : null;
|
|
881
|
-
return i ? r.push(`: ${i}`) : n && r.push(` (${n})`), r.join("");
|
|
882
|
-
}
|
|
883
|
-
function sr(e) {
|
|
884
|
-
if (!e) return "Upload server unavailable. Please try again or check your connection.";
|
|
885
|
-
let t = e.toLowerCase();
|
|
886
|
-
return /other side closed|econnreset|socket hang up|connection closed/i.test(t) ? "Upload server closed the connection. It may be busy or the request may be too large—try again." : /etimedout|timeout/i.test(t) ? "Upload request timed out. Please try again." : /enotfound|getaddrinfo|dns/i.test(t) ? "Upload server could not be reached. Check the upload URL and your network." : "Upload failed. Please try again or check the upload server.";
|
|
887
|
-
}
|
|
888
|
-
async function cr(e, t, n) {
|
|
889
|
-
let r = typeof window < "u" ? window.Main : void 0;
|
|
890
|
-
if (r?.uploadArweaveStart) {
|
|
891
|
-
let n = await ar(t);
|
|
892
|
-
return r.uploadArweaveStart(e, n);
|
|
893
|
-
}
|
|
894
|
-
let i = await fetch(e, {
|
|
895
|
-
method: "POST",
|
|
896
|
-
body: t
|
|
897
|
-
}), a = await i.json().catch(() => ({}));
|
|
898
|
-
return {
|
|
899
|
-
status: i.status,
|
|
900
|
-
body: a
|
|
901
|
-
};
|
|
902
|
-
}
|
|
903
|
-
//#endregion
|
|
904
|
-
//#region src/services/publish/actors/sendReimbursementRequest.ts
|
|
905
|
-
var lr = I(async ({ input: { context: e, event: t } }) => {
|
|
906
|
-
let { arweaveTransactions: n = [], transactionKeys: r, reimbursementTransactionId: i } = e;
|
|
907
|
-
if (i) return { transactionId: i };
|
|
908
|
-
let a = n.map(({ transaction: e }) => e), o = new FormData();
|
|
909
|
-
for (let e of a) {
|
|
910
|
-
let { data: t, chunks: n, ...r } = e, i = t instanceof Blob ? t : new Blob([t]);
|
|
911
|
-
o.append(`${e.id}-data`, i, `${e.id}-data`);
|
|
912
|
-
let a = new Blob([JSON.stringify(n)], { type: "application/json" });
|
|
913
|
-
o.append(`${e.id}-chunks`, a, `${e.id}-chunks`);
|
|
914
|
-
let s = new Blob([JSON.stringify(r)], { type: "application/json" });
|
|
915
|
-
o.append(`${e.id}-json`, s, `${e.id}-json`);
|
|
916
|
-
}
|
|
917
|
-
let { uploadApiBaseUrl: s } = D(), { status: c, body: l, message: u } = await cr(`${s}/api/upload/arweave/start`, o, s);
|
|
918
|
-
if (c >= 300 || c < 200) {
|
|
919
|
-
let e = c === 0 ? u : null;
|
|
920
|
-
e && console.error("[upload]", e);
|
|
921
|
-
let t = c === 0 ? sr(e) : or(c, l, r);
|
|
922
|
-
throw Error(t);
|
|
923
|
-
}
|
|
924
|
-
return l;
|
|
925
|
-
}), ur = I(async ({ input: { context: e, event: t } }) => {
|
|
926
|
-
let { requestResponse: n, reimbursementTransactionId: r } = e;
|
|
927
|
-
if (!n) throw Error("No request response");
|
|
928
|
-
if (!r) throw Error("No reimbursement transaction id");
|
|
929
|
-
let i = z();
|
|
930
|
-
await new Promise((e, t) => {
|
|
931
|
-
let n = setInterval(async () => {
|
|
932
|
-
let t;
|
|
933
|
-
try {
|
|
934
|
-
t = await i.transactions.getStatus(r);
|
|
935
|
-
} catch {
|
|
936
|
-
return;
|
|
937
|
-
}
|
|
938
|
-
t && t.confirmed && (clearInterval(n), e());
|
|
939
|
-
}, 5e3);
|
|
940
|
-
});
|
|
941
|
-
}), W = L("seedProtocol:services:publish:actors");
|
|
942
|
-
function dr(e) {
|
|
943
|
-
if (e instanceof Uint8Array) return e;
|
|
944
|
-
if (e instanceof ArrayBuffer) return new Uint8Array(e);
|
|
945
|
-
throw Error("Transaction data must be Uint8Array or ArrayBuffer for upload resume");
|
|
946
|
-
}
|
|
947
|
-
var fr = Lt(({ sendBack: e, input: t }) => {
|
|
948
|
-
let n = t.context, r = (n.arweaveTransactions ?? []).map(({ transaction: e }) => e), i = z(), a = n.uploaderState && typeof n.currentTransactionIndex == "number", o = a ? n.currentTransactionIndex : 0;
|
|
949
|
-
(async () => {
|
|
950
|
-
let t = r.length;
|
|
951
|
-
for (let s = o; s < t; s++) {
|
|
952
|
-
let c = r[s];
|
|
953
|
-
if (!c) continue;
|
|
954
|
-
let l = i.transactions.fromRaw(c);
|
|
955
|
-
if (!await i.transactions.verify(l)) throw Error("Transaction verification failed");
|
|
956
|
-
let u, d = n.uploaderState;
|
|
957
|
-
if (a && s === o && d) {
|
|
958
|
-
let e = l.data, t = e instanceof Uint8Array ? e : dr(e);
|
|
959
|
-
u = await i.transactions.getUploader(d, t);
|
|
960
|
-
} else u = await i.transactions.getUploader(l, l.data);
|
|
961
|
-
for (; !u.isComplete;) {
|
|
962
|
-
W("uploading chunk"), W(`uploader.pctComplete: ${u.pctComplete}`), W(`uploader.uploadedChunks: ${u.uploadedChunks}`), W(`uploader.totalChunks: ${u.totalChunks}`), W(u.lastResponseError), W(u.lastResponseStatus);
|
|
963
|
-
try {
|
|
964
|
-
await u.uploadChunk(), e({
|
|
965
|
-
type: "updatePercentage",
|
|
966
|
-
completionPercentage: Math.trunc((s + u.pctComplete / 100) / t * 100),
|
|
967
|
-
uploaderState: u.toJSON(),
|
|
968
|
-
currentTransactionIndex: s
|
|
969
|
-
}), W(`${u.pctComplete}% complete, ${u.uploadedChunks}/${u.totalChunks}`);
|
|
970
|
-
} catch (e) {
|
|
971
|
-
W(e);
|
|
972
|
-
}
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
return "done";
|
|
976
|
-
})().then((t) => {
|
|
977
|
-
e({
|
|
978
|
-
type: "uploadComplete",
|
|
979
|
-
result: t
|
|
980
|
-
});
|
|
981
|
-
}).catch((t) => {
|
|
982
|
-
e({
|
|
983
|
-
type: "uploadError",
|
|
984
|
-
error: t
|
|
985
|
-
});
|
|
986
|
-
});
|
|
987
|
-
}), pr = 12e4, mr = Function("s", "return import(s)"), hr = null, gr = async () => {
|
|
988
|
-
if (hr) return hr;
|
|
989
|
-
if (typeof window < "u") return null;
|
|
990
|
-
try {
|
|
991
|
-
let e = await mr(`node:${["fs", "promises"].join("/")}`);
|
|
992
|
-
return hr = {
|
|
993
|
-
readFile: e.readFile,
|
|
994
|
-
stat: e.stat
|
|
995
|
-
}, hr;
|
|
996
|
-
} catch {
|
|
997
|
-
return null;
|
|
998
|
-
}
|
|
999
|
-
}, _r = Lt(({ sendBack: e, input: { context: t } }) => {
|
|
1000
|
-
let { signedDataItems: n } = t, { uploadApiBaseUrl: r, useArweaveBundler: i } = D();
|
|
1001
|
-
if (!i || !r) {
|
|
1002
|
-
e({
|
|
1003
|
-
type: "uploadError",
|
|
1004
|
-
error: /* @__PURE__ */ Error("Arweave bundler not configured. Set useArweaveBundler and uploadApiBaseUrl.")
|
|
1005
|
-
});
|
|
1006
|
-
return;
|
|
1007
|
-
}
|
|
1008
|
-
let a = `${r.replace(/\/$/, "")}/api/upload/arweave/batch`;
|
|
1009
|
-
!n || n.length === 0 ? e({
|
|
1010
|
-
type: "uploadComplete",
|
|
1011
|
-
result: "done"
|
|
1012
|
-
}) : (async () => {
|
|
1013
|
-
let e = n, t = e.length, r = Array(t).fill(null), i = async (e, t) => {
|
|
1014
|
-
let n = e;
|
|
1015
|
-
if (n.raw != null && (n.raw instanceof Uint8Array || Buffer.isBuffer(n.raw))) return n.raw.byteLength;
|
|
1016
|
-
if (typeof n.getRaw == "function") {
|
|
1017
|
-
let e = n.getRaw(), i = e instanceof Promise ? await e : e, a = Buffer.isBuffer(i) ? i : Buffer.from(i);
|
|
1018
|
-
return r[t] = a, a.length;
|
|
1019
|
-
}
|
|
1020
|
-
if (n.filename != null) {
|
|
1021
|
-
let e = await gr();
|
|
1022
|
-
if (!e) throw Error("DataItem.filename requires Node.js fs access. In browser runtime, provide DataItem.raw or DataItem.getRaw().");
|
|
1023
|
-
return (await e.stat(n.filename)).size;
|
|
1024
|
-
}
|
|
1025
|
-
throw Error("Cannot get raw bytes from DataItem");
|
|
1026
|
-
}, o = 4, s = [];
|
|
1027
|
-
for (let n = 0; n < t; n++) {
|
|
1028
|
-
let t = await i(e[n], n);
|
|
1029
|
-
s.push(t), o += 4 + t;
|
|
1030
|
-
}
|
|
1031
|
-
let c = Buffer.alloc(o), l = 0;
|
|
1032
|
-
c.writeUInt32BE(t, l), l += 4;
|
|
1033
|
-
for (let n = 0; n < t; n++) {
|
|
1034
|
-
let t = s[n], i = r[n];
|
|
1035
|
-
if (i) {
|
|
1036
|
-
c.writeUInt32BE(t, l), l += 4, i.copy(c, l), l += t;
|
|
1037
|
-
continue;
|
|
1038
|
-
}
|
|
1039
|
-
let a = e[n];
|
|
1040
|
-
if (a.raw != null && (a.raw instanceof Uint8Array || Buffer.isBuffer(a.raw))) c.writeUInt32BE(t, l), l += 4, c.set(a.raw, l), l += t;
|
|
1041
|
-
else if (a.filename != null) {
|
|
1042
|
-
let e = await gr();
|
|
1043
|
-
if (!e) throw Error("DataItem.filename requires Node.js fs access. In browser runtime, provide DataItem.raw or DataItem.getRaw().");
|
|
1044
|
-
let t = await e.readFile(a.filename);
|
|
1045
|
-
c.writeUInt32BE(t.length, l), l += 4, t.copy(c, l), l += t.length;
|
|
1046
|
-
} else throw Error("Cannot get raw bytes from DataItem");
|
|
1047
|
-
}
|
|
1048
|
-
let u = new AbortController(), d = setTimeout(() => u.abort(), pr), f;
|
|
1049
|
-
try {
|
|
1050
|
-
f = await fetch(a, {
|
|
1051
|
-
method: "POST",
|
|
1052
|
-
headers: { "Content-Type": "application/octet-stream" },
|
|
1053
|
-
body: c,
|
|
1054
|
-
signal: u.signal
|
|
1055
|
-
});
|
|
1056
|
-
} catch (e) {
|
|
1057
|
-
throw clearTimeout(d), e instanceof Error && e.name === "AbortError" ? Error(`Arweave batch upload timed out after ${pr / 1e3}s (upload API did not respond). Check uploadApiBaseUrl and network.`) : e;
|
|
1058
|
-
}
|
|
1059
|
-
if (clearTimeout(d), !f.ok) throw Error(`Batch upload failed: ${f.status}`);
|
|
1060
|
-
let p = await f.json().catch(() => ({})), m = typeof p.failed == "number" ? p.failed : 0;
|
|
1061
|
-
if (m > 0) {
|
|
1062
|
-
let e = p.total ?? "?", t = p.succeeded ?? 0;
|
|
1063
|
-
throw Error(`Arweave batch upload failed: ${m} of ${e} item(s) failed (${t} succeeded)`);
|
|
1064
|
-
}
|
|
1065
|
-
})().then(() => e({
|
|
1066
|
-
type: "uploadComplete",
|
|
1067
|
-
result: "done"
|
|
1068
|
-
})).catch((t) => e({
|
|
1069
|
-
type: "uploadError",
|
|
1070
|
-
error: t
|
|
1071
|
-
}));
|
|
1072
|
-
});
|
|
1073
|
-
//#endregion
|
|
1074
|
-
//#region src/services/publish/helpers/receiptAttestationMs.ts
|
|
1075
|
-
async function vr(e) {
|
|
1076
|
-
let t = e?.blockNumber;
|
|
1077
|
-
return t == null ? Date.now() : await _e(t) ?? Date.now();
|
|
1078
|
-
}
|
|
1079
|
-
//#endregion
|
|
1080
|
-
//#region src/services/publish/actors/seedUidHelpers.ts
|
|
1081
|
-
function G(e) {
|
|
1082
|
-
return e == null || e === "" ? U : ("0x" + (e.startsWith("0x") ? e.slice(2) : e).replace(/[^0-9a-fA-F]/g, "0").padStart(64, "0").slice(-64)).toLowerCase();
|
|
1083
|
-
}
|
|
1084
|
-
function yr(e, t) {
|
|
1085
|
-
if (!e.logs?.length) return [];
|
|
1086
|
-
let n = t ? Te : r;
|
|
1087
|
-
try {
|
|
1088
|
-
let t = at({
|
|
1089
|
-
abi: n,
|
|
1090
|
-
eventName: "CreatedAttestation",
|
|
1091
|
-
logs: e.logs,
|
|
1092
|
-
strict: !1
|
|
1093
|
-
}), r = [];
|
|
1094
|
-
for (let e of t) {
|
|
1095
|
-
let t = e.args?.result;
|
|
1096
|
-
if (!t?.attestationUid) continue;
|
|
1097
|
-
let n = t.attestationUid;
|
|
1098
|
-
if (!n || G(n) === U) continue;
|
|
1099
|
-
let i = t.schemaUid;
|
|
1100
|
-
i && r.push({
|
|
1101
|
-
schemaUid: i,
|
|
1102
|
-
attestationUid: n
|
|
1103
|
-
});
|
|
1104
|
-
}
|
|
1105
|
-
return r;
|
|
1106
|
-
} catch {
|
|
1107
|
-
return [];
|
|
1108
|
-
}
|
|
1109
|
-
}
|
|
1110
|
-
//#endregion
|
|
1111
|
-
//#region src/services/publish/actors/multiPublishReceipt.ts
|
|
1112
|
-
var K = (e) => !e || G(e) === U, br = (e, t) => !!e && !!t && G(e) === G(t);
|
|
1113
|
-
function xr(e) {
|
|
1114
|
-
let t = [];
|
|
1115
|
-
for (let n of e.listOfAttestations ?? []) {
|
|
1116
|
-
let e = Array.isArray(n?.data) ? n.data.length : 1, r = typeof n?._propertyName == "string" && n._propertyName !== "" ? n._propertyName : void 0;
|
|
1117
|
-
for (let i = 0; i < e; i++) t.push({
|
|
1118
|
-
schema: n?.schema,
|
|
1119
|
-
propertyName: r
|
|
1120
|
-
});
|
|
1121
|
-
}
|
|
1122
|
-
return t;
|
|
1123
|
-
}
|
|
1124
|
-
function Sr(e, t, n) {
|
|
1125
|
-
let i = t.toLowerCase(), a = e.logs?.filter((e) => e.address && e.address.toLowerCase() === i);
|
|
1126
|
-
if (!a?.length) return [];
|
|
1127
|
-
try {
|
|
1128
|
-
return n ? at({
|
|
1129
|
-
abi: Te,
|
|
1130
|
-
eventName: "SeedPublished",
|
|
1131
|
-
logs: a,
|
|
1132
|
-
strict: !1
|
|
1133
|
-
}).map((e) => {
|
|
1134
|
-
let t = e.args;
|
|
1135
|
-
return {
|
|
1136
|
-
seedUid: K(t?.seedUid) ? void 0 : t.seedUid,
|
|
1137
|
-
versionUid: K(t?.versionUid) ? void 0 : t.versionUid
|
|
1138
|
-
};
|
|
1139
|
-
}) : at({
|
|
1140
|
-
abi: r,
|
|
1141
|
-
eventName: "SeedPublished",
|
|
1142
|
-
logs: a,
|
|
1143
|
-
strict: !1
|
|
1144
|
-
}).map((e) => {
|
|
1145
|
-
let t = e.args?.returnedDataFromEAS;
|
|
1146
|
-
if (!t || t === "0x") return { uids: [] };
|
|
1147
|
-
try {
|
|
1148
|
-
return { uids: tt([{ type: "bytes32[]" }], t)[0] ?? [] };
|
|
1149
|
-
} catch {
|
|
1150
|
-
return { uids: [] };
|
|
1151
|
-
}
|
|
1152
|
-
});
|
|
1153
|
-
} catch {
|
|
1154
|
-
return [];
|
|
1155
|
-
}
|
|
1156
|
-
}
|
|
1157
|
-
function Cr(e) {
|
|
1158
|
-
let { receipt: t, requests: n, useModularExecutor: r, easContractAddress: i, contractAddressForEvents: a } = e, o = yr(t, r), s = new Set(o.map((e) => G(e.attestationUid))), c = /* @__PURE__ */ new Set();
|
|
1159
|
-
for (let e of n) K(e.seedUid) && e.seedSchemaUid && c.add(G(e.seedSchemaUid)), K(e.versionUid) && e.versionSchemaUid && c.add(G(e.versionSchemaUid));
|
|
1160
|
-
let l = p(t, i).filter((e) => !s.has(G(e.uid)) && !c.has(G(e.schemaUid))).map((e) => ({
|
|
1161
|
-
schemaUid: e.schemaUid,
|
|
1162
|
-
attestationUid: e.uid
|
|
1163
|
-
})), u = Sr(t, a, r), d = n.map(xr), f = n.reduce((e, t) => e + +!!K(t.seedUid) + +!!K(t.versionUid), 0), m = d.reduce((e, t) => e + t.length, 0), h = m > 0 && o.length >= f + m, g = 0, _ = 0, v = 0, y = (e) => {
|
|
1164
|
-
let t = o[g];
|
|
1165
|
-
if (t) return g += 1, br(t.schemaUid, e) ? t.attestationUid : void 0;
|
|
1166
|
-
};
|
|
1167
|
-
return n.map((e, t) => {
|
|
1168
|
-
let n = d[t], i = { propertyPairs: [] };
|
|
1169
|
-
K(e.seedUid) && (i.seedUid = y(e.seedSchemaUid)), K(e.versionUid) && (i.versionUid = y(e.versionSchemaUid));
|
|
1170
|
-
let a = [];
|
|
1171
|
-
h ? (a = o.slice(g, g + n.length), g += n.length) : l.length && (a = l.slice(_, _ + n.length), _ += n.length);
|
|
1172
|
-
let s = !r || n.length > 0 ? u[v++] : void 0;
|
|
1173
|
-
if (s) {
|
|
1174
|
-
if (r) K(e.seedUid) && !i.seedUid && (i.seedUid = s.seedUid), K(e.versionUid) && !i.versionUid && (i.versionUid = s.versionUid);
|
|
1175
|
-
else if (s.uids?.length) {
|
|
1176
|
-
!a.length && s.uids.length >= n.length && (a = s.uids.slice(0, n.length).map((e) => ({ attestationUid: e })));
|
|
1177
|
-
let t = s.uids[n.length], r = s.uids[n.length + 1];
|
|
1178
|
-
K(e.seedUid) && !i.seedUid && !K(t) && (i.seedUid = t), K(e.versionUid) && !i.versionUid && !K(r) && (i.versionUid = r);
|
|
1179
|
-
}
|
|
1180
|
-
}
|
|
1181
|
-
return n.forEach((e, t) => {
|
|
1182
|
-
let n = a[t];
|
|
1183
|
-
if (!n || K(n.attestationUid) || n.schemaUid && !br(n.schemaUid, e.schema)) return;
|
|
1184
|
-
let r = n.schemaUid ?? e.schema;
|
|
1185
|
-
r && i.propertyPairs.push({
|
|
1186
|
-
schemaUid: r,
|
|
1187
|
-
attestationUid: n.attestationUid,
|
|
1188
|
-
...e.propertyName ? { propertyName: e.propertyName } : {}
|
|
1189
|
-
});
|
|
1190
|
-
}), i;
|
|
1191
|
-
});
|
|
1192
|
-
}
|
|
1193
|
-
//#endregion
|
|
1194
|
-
//#region src/services/publish/actors/persistSeedUid.ts
|
|
1195
|
-
var wr = L("seedProtocol:services:publish:actors:persistSeedUid"), Tr = "0x" + "0".repeat(64), Er = 15e3;
|
|
1196
|
-
function Dr(e, t) {
|
|
1197
|
-
let n = e.seedLocalId, r = n ? t.find((e) => e?.localId === n) : void 0, i = r ? r.seedUid : t[0]?.seedUid;
|
|
1198
|
-
i && i !== Tr && (e.seedUid = i);
|
|
1199
|
-
}
|
|
1200
|
-
async function Or(e, t, n) {
|
|
1201
|
-
let r = e.persistSeedUid;
|
|
1202
|
-
if (typeof r != "function") return;
|
|
1203
|
-
let i = new Promise((e, t) => setTimeout(() => t(/* @__PURE__ */ Error("persistSeedUid timed out")), Er));
|
|
1204
|
-
try {
|
|
1205
|
-
await Promise.race([r.call(e, t, n), i]);
|
|
1206
|
-
} catch (e) {
|
|
1207
|
-
wr("persistSeedUid failed (attestations already on-chain):", e);
|
|
1208
|
-
}
|
|
1209
|
-
}
|
|
1210
|
-
//#endregion
|
|
1211
|
-
//#region src/services/publish/actors/publishRequestNormalize.ts
|
|
1212
|
-
var kr = 64, q = (e) => {
|
|
1213
|
-
if (e == null) return "0x" + "0".repeat(kr);
|
|
1214
|
-
if (typeof e == "string") return "0x" + (e.startsWith("0x") ? e.slice(2) : e).replace(/[^0-9a-fA-F]/g, "0").padStart(kr, "0").slice(-64);
|
|
1215
|
-
if (e instanceof Uint8Array || typeof ArrayBuffer < "u" && e instanceof ArrayBuffer) {
|
|
1216
|
-
let t = e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1217
|
-
return "0x" + Array.from(t).map((e) => e.toString(16).padStart(2, "0")).join("").padStart(kr, "0").slice(-64);
|
|
1218
|
-
}
|
|
1219
|
-
return "0x" + "0".repeat(kr);
|
|
1220
|
-
}, Ar = (e) => {
|
|
1221
|
-
if (e == null || typeof e == "string" && (e === "" || e === "0x")) return "0x";
|
|
1222
|
-
if (typeof e == "string") {
|
|
1223
|
-
let t = (e.startsWith("0x") ? e.slice(2) : e).replace(/[^0-9a-fA-F]/g, "0");
|
|
1224
|
-
return "0x" + (t.length % 2 == 1 ? "0" + t : t);
|
|
1225
|
-
}
|
|
1226
|
-
if (e instanceof Uint8Array || typeof ArrayBuffer < "u" && e instanceof ArrayBuffer) {
|
|
1227
|
-
let t = e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1228
|
-
return "0x" + Array.from(t).map((e) => e.toString(16).padStart(2, "0")).join("");
|
|
1229
|
-
}
|
|
1230
|
-
return "0x";
|
|
1231
|
-
};
|
|
1232
|
-
function jr(e) {
|
|
1233
|
-
let t = new Set(e.map((e) => e?.localId).filter((e) => !!e));
|
|
1234
|
-
return e.some((e) => (e?.listOfAttestations ?? []).some((e) => {
|
|
1235
|
-
let n = e;
|
|
1236
|
-
return n._unresolvedValue && t.has(n._unresolvedValue) ? !0 : Array.isArray(n._rawListIdsForResolve) ? n._rawListIdsForResolve.some((e) => e && t.has(String(e).trim())) : !1;
|
|
1237
|
-
}));
|
|
1238
|
-
}
|
|
1239
|
-
function Mr(e, t) {
|
|
1240
|
-
return (e ?? []).filter((e) => e.publishLocalId && t.has(e.publishLocalId));
|
|
1241
|
-
}
|
|
1242
|
-
var Nr = {
|
|
1243
|
-
recipient: Nt,
|
|
1244
|
-
expirationTime: BigInt(0),
|
|
1245
|
-
revocable: !0,
|
|
1246
|
-
refUID: U,
|
|
1247
|
-
data: U,
|
|
1248
|
-
value: BigInt(0)
|
|
1249
|
-
};
|
|
1250
|
-
function Pr(e) {
|
|
1251
|
-
let t = (e?.listOfAttestations ?? []).map((e) => {
|
|
1252
|
-
let t = Array.isArray(e?.data) ? e.data : [];
|
|
1253
|
-
return {
|
|
1254
|
-
schema: q(e?.schema),
|
|
1255
|
-
data: t.map((e) => ({
|
|
1256
|
-
...e,
|
|
1257
|
-
refUID: q(e?.refUID),
|
|
1258
|
-
data: Ar(e?.data),
|
|
1259
|
-
expirationTime: e?.expirationTime == null ? BigInt(0) : BigInt(e.expirationTime),
|
|
1260
|
-
value: e?.value == null ? BigInt(0) : BigInt(e.value)
|
|
1261
|
-
})),
|
|
1262
|
-
...typeof e?._propertyName == "string" && e._propertyName !== "" ? { _propertyName: e._propertyName } : {},
|
|
1263
|
-
...typeof e?._propertyNameForSchema == "string" && e._propertyNameForSchema !== "" ? { _propertyNameForSchema: e._propertyNameForSchema } : {}
|
|
1264
|
-
};
|
|
1265
|
-
}), n = (e?.propertiesToUpdate ?? []).map((e) => ({
|
|
1266
|
-
...e,
|
|
1267
|
-
propertySchemaUid: q(e?.propertySchemaUid)
|
|
1268
|
-
}));
|
|
1269
|
-
return {
|
|
1270
|
-
...e,
|
|
1271
|
-
seedUid: q(e?.seedUid),
|
|
1272
|
-
seedSchemaUid: q(e?.seedSchemaUid),
|
|
1273
|
-
versionUid: q(e?.versionUid),
|
|
1274
|
-
versionSchemaUid: q(e?.versionSchemaUid),
|
|
1275
|
-
listOfAttestations: t,
|
|
1276
|
-
propertiesToUpdate: n
|
|
1277
|
-
};
|
|
1278
|
-
}
|
|
1279
|
-
function Fr(e, t) {
|
|
1280
|
-
for (let n of e) for (let e of n?.propertiesToUpdate ?? []) {
|
|
1281
|
-
let n = e?.publishLocalId, r = q(e?.propertySchemaUid);
|
|
1282
|
-
if (!n || !r) continue;
|
|
1283
|
-
let i = t.get(n);
|
|
1284
|
-
if (!i?.listOfAttestations) continue;
|
|
1285
|
-
let a = i.listOfAttestations.find((e) => q(e?.schema)?.toLowerCase() === r?.toLowerCase());
|
|
1286
|
-
a && (!Array.isArray(a.data) || a.data.length === 0) && (a.data = [{
|
|
1287
|
-
...Nr,
|
|
1288
|
-
refUID: U
|
|
1289
|
-
}]);
|
|
1290
|
-
}
|
|
1291
|
-
}
|
|
1292
|
-
//#endregion
|
|
1293
|
-
//#region src/services/publish/actors/recordMultiPublishReceipt.ts
|
|
1294
|
-
var Ir = L("seedProtocol:services:publish:actors:recordMultiPublishReceipt"), J = (e) => !e || q(e) === U, Lr = (e) => J(e) ? void 0 : q(e);
|
|
1295
|
-
async function Rr(e) {
|
|
1296
|
-
let { receipt: t, requests: n, rootSeedLocalId: r, useModularExecutor: i, contractAddressForEvents: a, publisherAddress: o } = e, { easContractAddress: s } = D(), c = Cr({
|
|
1297
|
-
receipt: t,
|
|
1298
|
-
requests: n,
|
|
1299
|
-
useModularExecutor: i,
|
|
1300
|
-
easContractAddress: s,
|
|
1301
|
-
contractAddressForEvents: a
|
|
1302
|
-
}), l = await vr(t);
|
|
1303
|
-
for (let e = 0; e < n.length; e++) {
|
|
1304
|
-
let t = n[e], r = c[e].versionUid;
|
|
1305
|
-
t.localId && J(t.versionUid) && !J(r) && await Qe({
|
|
1306
|
-
seedLocalId: t.localId,
|
|
1307
|
-
versionUid: q(r),
|
|
1308
|
-
publisher: o,
|
|
1309
|
-
attestationCreatedAt: l
|
|
1310
|
-
});
|
|
1311
|
-
}
|
|
1312
|
-
for (let e = 0; e < n.length; e++) {
|
|
1313
|
-
let t = n[e], { propertyPairs: r, versionUid: i } = c[e];
|
|
1314
|
-
t.localId && r.length && await Ne({
|
|
1315
|
-
seedLocalId: t.localId,
|
|
1316
|
-
attestationCreatedAtMs: l ?? null,
|
|
1317
|
-
versionUid: Lr(t.versionUid) ?? Lr(i) ?? null,
|
|
1318
|
-
pairs: r
|
|
1319
|
-
});
|
|
1320
|
-
}
|
|
1321
|
-
for (let e = 0; e < n.length; e++) {
|
|
1322
|
-
let t = n[e], i = c[e].seedUid;
|
|
1323
|
-
t.localId && t.localId !== r && J(t.seedUid) && !J(i) && await zr({
|
|
1324
|
-
seedLocalId: t.localId,
|
|
1325
|
-
seedUid: i,
|
|
1326
|
-
publisherAddress: o,
|
|
1327
|
-
attestationCreatedAtMs: l
|
|
1328
|
-
});
|
|
1329
|
-
}
|
|
1330
|
-
return {
|
|
1331
|
-
attributed: c,
|
|
1332
|
-
requests: n.map((e, t) => {
|
|
1333
|
-
let { seedUid: n, versionUid: r } = c[t];
|
|
1334
|
-
return {
|
|
1335
|
-
...e,
|
|
1336
|
-
...J(e.seedUid) && !J(n) ? { seedUid: n } : {},
|
|
1337
|
-
...J(e.versionUid) && !J(r) ? { versionUid: r } : {}
|
|
1338
|
-
};
|
|
1339
|
-
})
|
|
1340
|
-
};
|
|
1341
|
-
}
|
|
1342
|
-
async function zr(e) {
|
|
1343
|
-
let { seedLocalId: t, seedUid: n, publisherAddress: r, attestationCreatedAtMs: i } = e;
|
|
1344
|
-
try {
|
|
1345
|
-
let e = await M.find({ seedLocalId: t });
|
|
1346
|
-
if (!e) {
|
|
1347
|
-
Ir("related item %s not found; its seed uid is not recorded", t);
|
|
1348
|
-
return;
|
|
1349
|
-
}
|
|
1350
|
-
e.seedUid = n, await Or(e, r, i);
|
|
1351
|
-
} catch (e) {
|
|
1352
|
-
Ir("recording seed uid of related item %s failed: %O", t, e);
|
|
1353
|
-
}
|
|
1354
|
-
}
|
|
1355
|
-
//#endregion
|
|
1356
|
-
//#region src/helpers/seedPaymaster.ts
|
|
1357
|
-
var Br = 12000n;
|
|
1358
|
-
function Vr(e) {
|
|
1359
|
-
return "paymasterAndData" in e && e.paymasterAndData ? e.paymasterAndData : "0x";
|
|
1360
|
-
}
|
|
1361
|
-
function Hr(e, t, n) {
|
|
1362
|
-
return async (r) => {
|
|
1363
|
-
if (k("paymaster hook called (userOp from thirdweb; callGasLimit is tx.gas or 0)", {
|
|
1364
|
-
sender: r.sender,
|
|
1365
|
-
chainId: t.id,
|
|
1366
|
-
bundlerUrl: n ?? "(thirdweb default)",
|
|
1367
|
-
entryPoint: "initCode" in r ? "v0.6" : "v0.7",
|
|
1368
|
-
...C(r)
|
|
1369
|
-
}), !("initCode" in r)) throw Error("@seedprotocol/publish: the managed account sent an EntryPoint v0.7 UserOp; its sponsored gas handling only supports EntryPoint v0.6.");
|
|
1370
|
-
let i = typeof e == "function" ? e() : e, a = await Ut({
|
|
1371
|
-
userOp: r,
|
|
1372
|
-
client: i,
|
|
1373
|
-
chain: t
|
|
1374
|
-
});
|
|
1375
|
-
k("1/3 paymaster sponsored (limits here are ignored)", C(a));
|
|
1376
|
-
let o = {
|
|
1377
|
-
...r,
|
|
1378
|
-
paymasterAndData: Vr(a)
|
|
1379
|
-
}, s = await Ht({
|
|
1380
|
-
userOp: o,
|
|
1381
|
-
options: {
|
|
1382
|
-
client: i,
|
|
1383
|
-
chain: t,
|
|
1384
|
-
bundlerUrl: n
|
|
1385
|
-
}
|
|
1386
|
-
});
|
|
1387
|
-
k("2/3 bundler estimate (callGasLimit includes thirdweb's +50k)", C(s));
|
|
1388
|
-
let c = s.callGasLimit * Br / 10000n;
|
|
1389
|
-
o.callGasLimit = r.callGasLimit > c ? r.callGasLimit : c, o.verificationGasLimit = s.verificationGasLimit, o.preVerificationGas = s.preVerificationGas, k("raised limits sent to the paymaster for signing", {
|
|
1390
|
-
...C(o),
|
|
1391
|
-
headroomBps: Br,
|
|
1392
|
-
raisedEstimate: c,
|
|
1393
|
-
txGas: r.callGasLimit
|
|
1394
|
-
});
|
|
1395
|
-
let l = await Ut({
|
|
1396
|
-
userOp: o,
|
|
1397
|
-
client: i,
|
|
1398
|
-
chain: t
|
|
1399
|
-
});
|
|
1400
|
-
if (k("3/3 paymaster signed", C(l)), l.callGasLimit && l.verificationGasLimit && l.preVerificationGas) return k("returning to thirdweb: the PAYMASTER's own limits (its signature covers them)", {
|
|
1401
|
-
...C(l),
|
|
1402
|
-
requestedCallGasLimit: o.callGasLimit
|
|
1403
|
-
}), l;
|
|
1404
|
-
let u = {
|
|
1405
|
-
paymasterAndData: Vr(l),
|
|
1406
|
-
callGasLimit: o.callGasLimit,
|
|
1407
|
-
verificationGasLimit: o.verificationGasLimit,
|
|
1408
|
-
preVerificationGas: o.preVerificationGas
|
|
1409
|
-
};
|
|
1410
|
-
return k("returning to thirdweb: our raised limits (thirdweb should send exactly these)", C(u)), u;
|
|
1411
|
-
};
|
|
1412
|
-
}
|
|
1413
|
-
//#endregion
|
|
1414
|
-
//#region src/helpers/thirdweb.ts
|
|
1415
|
-
var Ur = /* @__PURE__ */ e({
|
|
1416
|
-
ExternalWalletsForDeploy: () => ri,
|
|
1417
|
-
appMetadata: () => oi,
|
|
1418
|
-
deployManagedAccountViaFactory: () => ai,
|
|
1419
|
-
deploySmartWalletContract: () => ii,
|
|
1420
|
-
getConnectedAccount: () => ci,
|
|
1421
|
-
getConnectedManagedAccountAddress: () => si,
|
|
1422
|
-
getConnectedModularAccount: () => li,
|
|
1423
|
-
getManagedAccountWallet: () => pi,
|
|
1424
|
-
getModularAccountWallet: () => hi,
|
|
1425
|
-
getSharedPublishInAppWalletStorage: () => qr,
|
|
1426
|
-
getSmartWalletAddressForAdmin: () => $r,
|
|
1427
|
-
getWalletsForConnectButton: () => gi,
|
|
1428
|
-
isSmartWalletDeployed: () => ei,
|
|
1429
|
-
pollSmartWalletDeployed: () => ti,
|
|
1430
|
-
resolveSmartWalletForPublish: () => ni,
|
|
1431
|
-
syncPublishInAppAuthToken: () => Jr,
|
|
1432
|
-
useActiveSmartWalletContract: () => Qr,
|
|
1433
|
-
useLocalWalletAccount: () => Zr,
|
|
1434
|
-
wallets: () => Xr
|
|
1435
|
-
}), Wr = L("permaPress:helpers:thirdweb"), Gr = "seedProtocol:inAppPublish:", Kr = null;
|
|
1436
|
-
function qr() {
|
|
1437
|
-
return Kr ||= {
|
|
1438
|
-
getItem: async (e) => typeof window > "u" ? null : localStorage.getItem(Gr + e),
|
|
1439
|
-
setItem: async (e, t) => {
|
|
1440
|
-
typeof window < "u" && localStorage.setItem(Gr + e, t);
|
|
1441
|
-
},
|
|
1442
|
-
removeItem: async (e) => {
|
|
1443
|
-
typeof window < "u" && localStorage.removeItem(Gr + e);
|
|
1444
|
-
}
|
|
1445
|
-
}, Kr;
|
|
1446
|
-
}
|
|
1447
|
-
function Jr() {
|
|
1448
|
-
if (typeof window > "u") return {
|
|
1449
|
-
syncedBareToPrefixed: !1,
|
|
1450
|
-
syncedPrefixedToBare: !1
|
|
1451
|
-
};
|
|
1452
|
-
let { thirdwebClientId: e } = D();
|
|
1453
|
-
if (!e) return {
|
|
1454
|
-
syncedBareToPrefixed: !1,
|
|
1455
|
-
syncedPrefixedToBare: !1
|
|
1456
|
-
};
|
|
1457
|
-
try {
|
|
1458
|
-
let t = `walletToken-${e}`, n = `${Gr}${t}`, r = localStorage.getItem(t), i = localStorage.getItem(n), a = !1, o = !1;
|
|
1459
|
-
return r && !i && (localStorage.setItem(n, r), a = !0), i && !r && (localStorage.setItem(t, i), o = !0), i && r && r !== i && (localStorage.setItem(t, i), o = !0), {
|
|
1460
|
-
syncedBareToPrefixed: a,
|
|
1461
|
-
syncedPrefixedToBare: o
|
|
1462
|
-
};
|
|
1463
|
-
} catch {
|
|
1464
|
-
return {
|
|
1465
|
-
syncedBareToPrefixed: !1,
|
|
1466
|
-
syncedPrefixedToBare: !1
|
|
1467
|
-
};
|
|
1468
|
-
}
|
|
1469
|
-
}
|
|
1470
|
-
async function Yr(e = A()) {
|
|
1471
|
-
Jr();
|
|
1472
|
-
let t = pi();
|
|
1473
|
-
return await t.autoConnect({
|
|
1474
|
-
client: j(),
|
|
1475
|
-
chain: e
|
|
1476
|
-
}), t;
|
|
1477
|
-
}
|
|
1478
|
-
var Xr = [zt("io.metamask")], Zr = () => {
|
|
1479
|
-
let [e, t] = Ot(null);
|
|
1480
|
-
return zt("io.metamask"), Dt(!1), Et(() => {}, []), e;
|
|
1481
|
-
}, Qr = () => {
|
|
1482
|
-
let e = Vt(), [t, n] = Ot(null);
|
|
1483
|
-
return Et(() => {
|
|
1484
|
-
e && e.address && n(lt({
|
|
1485
|
-
client: j(),
|
|
1486
|
-
chain: A(),
|
|
1487
|
-
address: e.address
|
|
1488
|
-
}));
|
|
1489
|
-
}, [e]), t;
|
|
1490
|
-
};
|
|
1491
|
-
async function $r(e, t = "0x") {
|
|
1492
|
-
return _(e, t);
|
|
1493
|
-
}
|
|
1494
|
-
async function ei(e) {
|
|
1495
|
-
return oe(e);
|
|
1496
|
-
}
|
|
1497
|
-
async function ti(e, t, n) {
|
|
1498
|
-
return ge(e, t, n);
|
|
1499
|
-
}
|
|
1500
|
-
async function ni(e) {
|
|
1501
|
-
if (!e) return { needsDeploy: !0 };
|
|
1502
|
-
if (await ei(e.address)) return {
|
|
1503
|
-
address: e.address,
|
|
1504
|
-
account: e
|
|
1505
|
-
};
|
|
1506
|
-
let t = await $r(e.address);
|
|
1507
|
-
return await ei(t) ? {
|
|
1508
|
-
address: t,
|
|
1509
|
-
account: e
|
|
1510
|
-
} : { needsDeploy: !0 };
|
|
1511
|
-
}
|
|
1512
|
-
var ri = [zt("io.metamask"), zt("me.rainbow")], ii = async (e) => {
|
|
1513
|
-
let t = lt({
|
|
1514
|
-
client: j(),
|
|
1515
|
-
chain: A(),
|
|
1516
|
-
address: e.address
|
|
1517
|
-
}), n = await ct({
|
|
1518
|
-
smartAccount: e,
|
|
1519
|
-
chain: A(),
|
|
1520
|
-
client: j(),
|
|
1521
|
-
accountContract: t
|
|
1522
|
-
});
|
|
1523
|
-
return Wr("deploySmartAccount result:", n), n;
|
|
1524
|
-
};
|
|
1525
|
-
async function ai(e) {
|
|
1526
|
-
let { asThirdwebPublishWallet: t } = await import("./chainConfig-bc_6IgAw.js").then((e) => e.g), n = t(e.signingAccount), r = b(e.adminAddress, e.data ?? "0x");
|
|
1527
|
-
await n.txSender.sendTransaction(r);
|
|
1528
|
-
}
|
|
1529
|
-
var oi = {
|
|
1530
|
-
name: "Seed Protocol",
|
|
1531
|
-
description: "Seed Protocol",
|
|
1532
|
-
url: "https://seedprotocol.io"
|
|
1533
|
-
};
|
|
1534
|
-
async function si(e = A()) {
|
|
1535
|
-
let t = (await Yr(e)).getAccount();
|
|
1536
|
-
if (!t) throw Error("Failed to get managed account");
|
|
1537
|
-
return t.address;
|
|
1538
|
-
}
|
|
1539
|
-
async function ci() {
|
|
1540
|
-
try {
|
|
1541
|
-
let e = hi();
|
|
1542
|
-
return await e.autoConnect({
|
|
1543
|
-
client: j(),
|
|
1544
|
-
chain: A()
|
|
1545
|
-
}), e.getAccount() ?? null;
|
|
1546
|
-
} catch {
|
|
1547
|
-
return null;
|
|
1548
|
-
}
|
|
1549
|
-
}
|
|
1550
|
-
async function li() {
|
|
1551
|
-
return ci();
|
|
1552
|
-
}
|
|
1553
|
-
function ui(e) {
|
|
1554
|
-
let t = A(e).id, n = e.managedAccountFactoryAddress ?? h[t];
|
|
1555
|
-
if (!n) throw Error(`@seedprotocol/publish: no ManagedAccount factory is known for chain ${t}. Pass managedAccountFactoryAddress in publish config, or use the EOA / direct EAS path.`);
|
|
1556
|
-
return n;
|
|
1557
|
-
}
|
|
1558
|
-
var di = [
|
|
1559
|
-
"farcaster",
|
|
1560
|
-
"email",
|
|
1561
|
-
"passkey",
|
|
1562
|
-
"phone"
|
|
1563
|
-
], fi = null, pi = (e) => {
|
|
1564
|
-
let t = e ?? w(), n = A(t ?? void 0), r = t ? ui(t) : ae(), { bundlerUrl: i, sponsorGas: a } = Se(t);
|
|
1565
|
-
if (!i && re(n)) throw Error(`@seedprotocol/publish: chain ${n.id} is local, so Thirdweb's hosted bundler cannot reach it. Set PublishConfig.thirdweb.bundlerUrl to the chain's bundler (seedTwinConfig does this for the twin).`);
|
|
1566
|
-
let o = [
|
|
1567
|
-
n.id,
|
|
1568
|
-
n.rpc,
|
|
1569
|
-
r,
|
|
1570
|
-
i ?? "",
|
|
1571
|
-
a
|
|
1572
|
-
].join("|").toLowerCase();
|
|
1573
|
-
return fi?.key !== o && (k("managed wallet built", {
|
|
1574
|
-
chainId: n.id,
|
|
1575
|
-
sponsorGas: a,
|
|
1576
|
-
bundlerUrl: i ?? "(thirdweb default)",
|
|
1577
|
-
paymasterHook: a ? "installed" : "none (thirdweb estimates callGasLimit itself)"
|
|
1578
|
-
}), fi = {
|
|
1579
|
-
key: o,
|
|
1580
|
-
wallet: Bt({
|
|
1581
|
-
storage: qr(),
|
|
1582
|
-
auth: { options: [...di] },
|
|
1583
|
-
executionMode: {
|
|
1584
|
-
mode: "EIP4337",
|
|
1585
|
-
smartAccount: {
|
|
1586
|
-
chain: n,
|
|
1587
|
-
factoryAddress: r,
|
|
1588
|
-
sponsorGas: a,
|
|
1589
|
-
...i || a ? { overrides: {
|
|
1590
|
-
...i ? { bundlerUrl: i } : {},
|
|
1591
|
-
...a ? { paymaster: Hr(j, n, i) } : {}
|
|
1592
|
-
} } : {}
|
|
1593
|
-
}
|
|
1594
|
-
}
|
|
1595
|
-
})
|
|
1596
|
-
}), fi.wallet;
|
|
1597
|
-
}, mi = null, hi = (e) => {
|
|
1598
|
-
let t = e ?? w(), { modularWalletMode: n, sponsorGas: r } = Se(t);
|
|
1599
|
-
if (n === "EIP7702") {
|
|
1600
|
-
let e = A(t ?? void 0);
|
|
1601
|
-
if (re(e)) throw Error(`@seedprotocol/publish: chain ${e.id} is local, and Thirdweb's EIP-7702 mode needs its hosted bundler, which cannot reach it. Set PublishConfig.thirdweb.modularWalletMode to 'EOA' and fund the in-app EOA (seedTwinConfig does this for the twin).`);
|
|
1602
|
-
}
|
|
1603
|
-
let i = `${n}|${r}`;
|
|
1604
|
-
return mi?.key !== i && (mi = {
|
|
1605
|
-
key: i,
|
|
1606
|
-
wallet: Bt({
|
|
1607
|
-
storage: qr(),
|
|
1608
|
-
auth: { options: [...di] },
|
|
1609
|
-
executionMode: n === "EOA" ? { mode: "EOA" } : {
|
|
1610
|
-
mode: "EIP7702",
|
|
1611
|
-
sponsorGas: r
|
|
1612
|
-
}
|
|
1613
|
-
})
|
|
1614
|
-
}), mi.wallet;
|
|
1615
|
-
}, gi = (e) => {
|
|
1616
|
-
let t = e ?? w() ?? void 0;
|
|
1617
|
-
return t?.useModularExecutor ? [hi(t)] : [pi(t)];
|
|
1618
|
-
}, _i = "This ManagedAccount predates the Seed executor router extension, so the Seed executor cannot act for it and publish automation is not available for this account.", vi = "The Seed executor is not installed for this ManagedAccount, so automation session keys cannot publish through it. The account admin installs it (installSeedExecutor), which enrollPublishAutomation does.", yi = "The Seed executor module is configured with a different EAS contract for this ManagedAccount than publish config. Automation session keys cannot change it.", bi = "Could not read the Seed executor module state for this ManagedAccount.";
|
|
1619
|
-
function xi() {
|
|
1620
|
-
let e = D().modularAccountModuleContract?.trim();
|
|
1621
|
-
if (!e || !/^0x[0-9a-fA-F]{40}$/.test(e)) throw Error("@seedprotocol/publish: publish automation requires PublishConfig.modularAccountModuleContract (executor module).");
|
|
1622
|
-
return e;
|
|
1623
|
-
}
|
|
1624
|
-
async function Si(e) {
|
|
1625
|
-
return await ne(e) === null;
|
|
1626
|
-
}
|
|
1627
|
-
async function Ci(e, t = {}) {
|
|
1628
|
-
let n = xi(), r = e, i, a;
|
|
1629
|
-
if (t.installedEas) i = !0, a = t.installedEas;
|
|
1630
|
-
else try {
|
|
1631
|
-
i = await Ce(() => ee(n, r), Boolean, { attempts: t.readAttempts ?? 1 }), a = i ? await x(n, r) : st;
|
|
1632
|
-
} catch (t) {
|
|
1633
|
-
throw new E(bi, "AUTOMATION_UNSUPPORTED_ACCOUNT", e, t);
|
|
1634
|
-
}
|
|
1635
|
-
if (!i) {
|
|
1636
|
-
let t = await Si(r) ? _i : vi;
|
|
1637
|
-
throw new E(t, "AUTOMATION_UNSUPPORTED_ACCOUNT", e);
|
|
1638
|
-
}
|
|
1639
|
-
let o = D().easContractAddress?.toLowerCase();
|
|
1640
|
-
if (o && a.toLowerCase() !== o) throw new E(yi, "AUTOMATION_UNSUPPORTED_ACCOUNT", e);
|
|
1641
|
-
}
|
|
1642
|
-
function wi(e) {
|
|
1643
|
-
let t = e instanceof et ? `${e.shortMessage} ${e.details} ${e.message}` : String(e);
|
|
1644
|
-
return /insufficient funds|insufficient balance/i.test(t);
|
|
1645
|
-
}
|
|
1646
|
-
async function Ti(e) {
|
|
1647
|
-
let { managedAddress: t, tx: n, action: r, code: i = "AUTOMATION_PREFLIGHT_FAILED", requireSimulation: a = !0 } = e, o = (e) => xe().call({
|
|
1648
|
-
account: t,
|
|
1649
|
-
to: n.to,
|
|
1650
|
-
data: n.data,
|
|
1651
|
-
value: n.value,
|
|
1652
|
-
...e ? { stateOverride: [{
|
|
1653
|
-
address: t,
|
|
1654
|
-
balance: it("1000")
|
|
1655
|
-
}] } : {}
|
|
1656
|
-
});
|
|
1657
|
-
try {
|
|
1658
|
-
try {
|
|
1659
|
-
await o(!1);
|
|
1660
|
-
} catch (e) {
|
|
1661
|
-
if (!wi(e)) throw e;
|
|
1662
|
-
await o(!0);
|
|
1663
|
-
}
|
|
1664
|
-
} catch (e) {
|
|
1665
|
-
let n = Xt(e);
|
|
1666
|
-
if (!n && !a) return;
|
|
1667
|
-
let o = n ? Qt(Yt(e)) : "could not be simulated";
|
|
1668
|
-
throw new E(`Simulated ${r} from ${t} ${o}; nothing was sent.`, i, t, e);
|
|
1669
|
-
}
|
|
1670
|
-
}
|
|
1671
|
-
//#endregion
|
|
1672
|
-
//#region src/helpers/ensureExecutorModule.ts
|
|
1673
|
-
var Ei = () => `The executor module could not be installed on your publishing account on ${O()}. Reconnect and try again, or contact support if this persists.`;
|
|
1674
|
-
async function Di(e, t, n) {
|
|
1675
|
-
let { modularAccountModuleContract: r } = n;
|
|
1676
|
-
if (!r || !await oe(e)) return { status: "skipped" };
|
|
1677
|
-
let i = await ne(e);
|
|
1678
|
-
return i ? Oi(e, i.executor, r) : { status: "skipped" };
|
|
1679
|
-
}
|
|
1680
|
-
async function Oi(e, t, n) {
|
|
1681
|
-
if (t.toLowerCase() !== n.trim().toLowerCase()) throw new E(`Your publishing account's Seed executor is ${t}, but publish config sets modularAccountModuleContract to ${n}. Point modularAccountModuleContract at the account's executor.`, "EXECUTOR_MODULE_NOT_INSTALLED", e);
|
|
1682
|
-
let r = e, i, a, o;
|
|
1683
|
-
try {
|
|
1684
|
-
if (await fe(r, t)) return { status: "already-installed" };
|
|
1685
|
-
let { getManagedAccountAdmin: n } = await import("./managedAccountAdmin-CdS1SCA_.js").then((e) => e.n), s = ue(await n(e));
|
|
1686
|
-
i = s.txSender.address;
|
|
1687
|
-
let c = await s.txSender.sendTransaction(f(r));
|
|
1688
|
-
o = c.transactionHash;
|
|
1689
|
-
try {
|
|
1690
|
-
a = await T(c.transactionHash);
|
|
1691
|
-
} catch (e) {
|
|
1692
|
-
if (!(e instanceof de)) throw e;
|
|
1693
|
-
}
|
|
1694
|
-
} catch (t) {
|
|
1695
|
-
throw t instanceof E ? t : new E(Ei(), "EXECUTOR_MODULE_NOT_INSTALLED", e, t);
|
|
1696
|
-
}
|
|
1697
|
-
let s = a && ki(a, r, t);
|
|
1698
|
-
if (s) return {
|
|
1699
|
-
status: "installed",
|
|
1700
|
-
eas: s,
|
|
1701
|
-
transactionHash: o
|
|
1702
|
-
};
|
|
1703
|
-
let c = await Ai(r, i);
|
|
1704
|
-
if (c === "already-installed") return { status: "already-installed" };
|
|
1705
|
-
throw new E(`installSeedExecutor in transaction ${o} did not install the Seed executor on ${e}${c ? `: ${c}` : ""}.`, "EXECUTOR_MODULE_NOT_INSTALLED", e);
|
|
1706
|
-
}
|
|
1707
|
-
function ki(e, t, n) {
|
|
1708
|
-
if (at({
|
|
1709
|
-
abi: ie,
|
|
1710
|
-
eventName: "SeedExecutorInstalled",
|
|
1711
|
-
logs: e.logs,
|
|
1712
|
-
strict: !1
|
|
1713
|
-
}).some((e) => rt(e.address, t) && e.args.executor && rt(e.args.executor, n))) return at({
|
|
1714
|
-
abi: y,
|
|
1715
|
-
eventName: "ModuleInitialized",
|
|
1716
|
-
logs: e.logs,
|
|
1717
|
-
strict: !1
|
|
1718
|
-
}).find((e) => rt(e.address, n) && e.args.account && rt(e.args.account, t))?.args.eas;
|
|
1719
|
-
}
|
|
1720
|
-
async function Ai(e, t) {
|
|
1721
|
-
try {
|
|
1722
|
-
await Ti({
|
|
1723
|
-
managedAddress: t,
|
|
1724
|
-
tx: f(e),
|
|
1725
|
-
action: "installSeedExecutor",
|
|
1726
|
-
requireSimulation: !1
|
|
1727
|
-
});
|
|
1728
|
-
return;
|
|
1729
|
-
} catch (e) {
|
|
1730
|
-
let t = Qt(Yt(e instanceof E ? e.underlyingCause : e));
|
|
1731
|
-
return t === "reverted with SeedExecutorAlreadyInstalled" ? "already-installed" : t;
|
|
1732
|
-
}
|
|
1733
|
-
}
|
|
1734
|
-
//#endregion
|
|
1735
|
-
//#region src/helpers/ensureManagedAccountReady.ts
|
|
1736
|
-
var ji = () => `Could not connect the managed publishing account on ${O()}. Reconnect with the same sign-in method and try again.`, Mi = () => `Your publishing smart account is not deployed on ${O()} yet. Complete wallet setup, enable autoDeployManagedAccount in config if appropriate, then try again.`, Ni = () => `The managed account could not be confirmed on ${O()} after deployment. Wait a moment and retry, or check your network connection.`, Pi = () => `Automatic deployment of the managed publishing account failed on ${O()}. Retry or deploy the account through your wallet provider.`;
|
|
1737
|
-
async function Fi() {
|
|
1738
|
-
let { useModularExecutor: e } = D();
|
|
1739
|
-
if (!e) return { kind: "skip" };
|
|
1740
|
-
let t;
|
|
1741
|
-
try {
|
|
1742
|
-
t = await si(A());
|
|
1743
|
-
} catch (e) {
|
|
1744
|
-
return {
|
|
1745
|
-
kind: "unavailable",
|
|
1746
|
-
cause: e
|
|
1747
|
-
};
|
|
1748
|
-
}
|
|
1749
|
-
return await ei(t) ? {
|
|
1750
|
-
kind: "ready",
|
|
1751
|
-
managedAddress: t
|
|
1752
|
-
} : {
|
|
1753
|
-
kind: "not_deployed",
|
|
1754
|
-
managedAddress: t
|
|
1755
|
-
};
|
|
1756
|
-
}
|
|
1757
|
-
async function Ii() {
|
|
1758
|
-
Jr();
|
|
1759
|
-
let e = pi();
|
|
1760
|
-
await e.autoConnect({
|
|
1761
|
-
client: j(),
|
|
1762
|
-
chain: A()
|
|
1763
|
-
});
|
|
1764
|
-
let t = e.getAccount();
|
|
1765
|
-
if (!t) throw new E(ji(), "MANAGED_ACCOUNT_UNAVAILABLE");
|
|
1766
|
-
return t;
|
|
1767
|
-
}
|
|
1768
|
-
var Li = 9e4;
|
|
1769
|
-
async function Ri(e) {
|
|
1770
|
-
let t;
|
|
1771
|
-
try {
|
|
1772
|
-
await Promise.race([ii(e), new Promise((e, n) => {
|
|
1773
|
-
t = setTimeout(() => n(/* @__PURE__ */ Error(`Managed account deploy timed out after ${Li / 1e3}s`)), Li);
|
|
1774
|
-
})]);
|
|
1775
|
-
} finally {
|
|
1776
|
-
t != null && clearTimeout(t);
|
|
1777
|
-
}
|
|
1778
|
-
}
|
|
1779
|
-
async function zi(e) {
|
|
1780
|
-
let t = D(), n = await Ii(), { fromThirdwebAccount: r } = await import("./chainConfig-bc_6IgAw.js").then((e) => e.g), i = {
|
|
1781
|
-
managedAddress: e,
|
|
1782
|
-
managedSigningAccount: r(n)
|
|
1783
|
-
};
|
|
1784
|
-
try {
|
|
1785
|
-
if (t.deployManagedAccount) await t.deployManagedAccount(i);
|
|
1786
|
-
else {
|
|
1787
|
-
let e = await li();
|
|
1788
|
-
if (e) {
|
|
1789
|
-
let t = hi();
|
|
1790
|
-
await t.autoConnect({
|
|
1791
|
-
client: j(),
|
|
1792
|
-
chain: A()
|
|
1793
|
-
}), await ai({
|
|
1794
|
-
adminAddress: t.getAdminAccount?.()?.address ?? e.address,
|
|
1795
|
-
signingAccount: e
|
|
1796
|
-
});
|
|
1797
|
-
} else await Ri(n);
|
|
1798
|
-
}
|
|
1799
|
-
} catch (t) {
|
|
1800
|
-
if (await ti(e, /UserOp|user operation/i.test(Ee(t)) ? 15 : 5)) return;
|
|
1801
|
-
throw new E(Pi(), "MANAGED_ACCOUNT_NOT_DEPLOYED", e, t);
|
|
1802
|
-
}
|
|
1803
|
-
if (!await ti(e)) throw new E(Ni(), "MANAGED_ACCOUNT_NOT_DEPLOYED", e);
|
|
1804
|
-
}
|
|
1805
|
-
async function Bi() {
|
|
1806
|
-
let e = D();
|
|
1807
|
-
if (!e.useModularExecutor) throw Error("runModularExecutorPublishPrep: useModularExecutor is false");
|
|
1808
|
-
let t = await Fi();
|
|
1809
|
-
if (t.kind === "unavailable") return {
|
|
1810
|
-
ok: !1,
|
|
1811
|
-
error: new E(ji(), "MANAGED_ACCOUNT_UNAVAILABLE", void 0, t.cause)
|
|
1812
|
-
};
|
|
1813
|
-
if (t.kind === "not_deployed") {
|
|
1814
|
-
if (e.autoDeployManagedAccount) {
|
|
1815
|
-
try {
|
|
1816
|
-
await zi(t.managedAddress);
|
|
1817
|
-
} catch (e) {
|
|
1818
|
-
return {
|
|
1819
|
-
ok: !1,
|
|
1820
|
-
error: te(e) ? e : new E(Pi(), "MANAGED_ACCOUNT_NOT_DEPLOYED", t.managedAddress, e)
|
|
1821
|
-
};
|
|
1822
|
-
}
|
|
1823
|
-
if (t = await Fi(), t.kind !== "ready") return {
|
|
1824
|
-
ok: !1,
|
|
1825
|
-
error: new E(Ni(), "MANAGED_ACCOUNT_NOT_DEPLOYED", t.kind === "not_deployed" ? t.managedAddress : void 0)
|
|
1826
|
-
};
|
|
1827
|
-
} else return {
|
|
1828
|
-
ok: !1,
|
|
1829
|
-
error: new E(Mi(), "MANAGED_ACCOUNT_NOT_DEPLOYED", t.managedAddress)
|
|
1830
|
-
};
|
|
1831
|
-
}
|
|
1832
|
-
if (t.kind === "ready") {
|
|
1833
|
-
if (e.modularAccountModuleContract) try {
|
|
1834
|
-
let n = await Ii();
|
|
1835
|
-
await Di(t.managedAddress, n, e);
|
|
1836
|
-
} catch (e) {
|
|
1837
|
-
console.warn(`[@seedprotocol/publish] Executor module setup failed on ${O()}; publishing continues, but publish automation needs it.`, e);
|
|
1838
|
-
}
|
|
1839
|
-
return {
|
|
1840
|
-
ok: !0,
|
|
1841
|
-
managedAddress: t.managedAddress
|
|
1842
|
-
};
|
|
1843
|
-
}
|
|
1844
|
-
throw Error("runModularExecutorPublishPrep: unexpected readiness state");
|
|
1845
|
-
}
|
|
1846
|
-
//#endregion
|
|
1847
|
-
//#region src/helpers/resolvePublishWallet.ts
|
|
1848
|
-
function Vi(e) {
|
|
1849
|
-
if (i(e.wallet)) return e.wallet;
|
|
1850
|
-
if (i(e.account)) return e.account;
|
|
1851
|
-
let t = pe();
|
|
1852
|
-
if (t) return t;
|
|
1853
|
-
throw Error("@seedprotocol/publish: no PublishWallet available. Pass fromEthersWallet / fromEip1193Provider / fromThirdwebAccount, or call setPublishWallet / useSeedWallet.");
|
|
1854
|
-
}
|
|
1855
|
-
//#endregion
|
|
1856
|
-
//#region src/services/publish/helpers/verifyArweaveTransactionsExist.ts
|
|
1857
|
-
async function Hi(e) {
|
|
1858
|
-
if (e.length === 0) return;
|
|
1859
|
-
let { arweaveUploadVerificationBaseUrl: t } = D(), n = await Promise.all(e.map((e) => He(t, e)));
|
|
1860
|
-
for (let t = 0; t < e.length; t++) {
|
|
1861
|
-
let r = e[t], i = n[t];
|
|
1862
|
-
if (i) {
|
|
1863
|
-
if (i.status === 404) throw Error(`Arweave transaction ${r} not found. Upload may have failed. Delete this publish record and try again.`);
|
|
1864
|
-
if (i.status !== 200) {
|
|
1865
|
-
let e = i.status === 504 ? "request timed out (upload service did not respond in time)" : `status: ${i.status}`;
|
|
1866
|
-
throw Error(`Arweave transaction ${r} is not yet available from the upload service (${e}). Wait and retry.`);
|
|
1867
|
-
}
|
|
1868
|
-
}
|
|
1869
|
-
}
|
|
1870
|
-
}
|
|
1871
|
-
//#endregion
|
|
1872
|
-
//#region src/services/arweaveL1Finalize/enqueue.ts
|
|
1873
|
-
var Ui = "pending_l1";
|
|
1874
|
-
async function Wi(e) {
|
|
1875
|
-
let { useArweaveBundler: t } = D();
|
|
1876
|
-
if (!t) return;
|
|
1877
|
-
let n = e.arweaveTransactions ?? [], r = e.publishUploads ?? [];
|
|
1878
|
-
if (n.length === 0 || n.length !== r.length) return;
|
|
1879
|
-
let i = ke.getAppDb();
|
|
1880
|
-
if (!i) return;
|
|
1881
|
-
let a = Date.now();
|
|
1882
|
-
for (let e = 0; e < n.length; e++) {
|
|
1883
|
-
let t = n[e], o = r[e];
|
|
1884
|
-
if (!o) continue;
|
|
1885
|
-
let s = t.transaction?.id;
|
|
1886
|
-
if (s && typeof s == "string") try {
|
|
1887
|
-
await i.insert(Pe).values({
|
|
1888
|
-
seedLocalId: o.seedLocalId,
|
|
1889
|
-
dataItemId: s,
|
|
1890
|
-
versionLocalId: o.versionLocalId ?? null,
|
|
1891
|
-
itemPropertyName: o.itemPropertyName ?? null,
|
|
1892
|
-
phase: Ui,
|
|
1893
|
-
createdAt: a,
|
|
1894
|
-
updatedAt: a
|
|
1895
|
-
}).onConflictDoNothing();
|
|
1896
|
-
} catch {}
|
|
1897
|
-
}
|
|
1898
|
-
}
|
|
1899
|
-
//#endregion
|
|
1900
|
-
//#region src/helpers/ensureManagedAccountEasConfigured.ts
|
|
1901
|
-
var Gi = () => `Could not verify or set the EAS contract address on your publishing account on ${O()}.`, Ki = "ManagedAccount EAS pointer does not match publish config. Configure EAS with the user’s ManagedAccount wallet before automation publish (session keys cannot call setEas).", qi = (e) => `Your publishing account's Seed extension uses EAS ${e}, but publish config sets easContractAddress to a different contract. The extension's EAS is fixed at deployment; fix easContractAddress.`;
|
|
1902
|
-
function Ji(e) {
|
|
1903
|
-
return e.toLowerCase();
|
|
1904
|
-
}
|
|
1905
|
-
function Yi(e) {
|
|
1906
|
-
let { easContractAddress: t } = D(), n = Ji(t);
|
|
1907
|
-
if (!n || n === Ji(st)) throw new E("Publish config is missing a valid easContractAddress.", "MANAGED_ACCOUNT_SET_EAS_FAILED", e);
|
|
1908
|
-
return n;
|
|
1909
|
-
}
|
|
1910
|
-
async function Xi(e) {
|
|
1911
|
-
try {
|
|
1912
|
-
let t = await se(e);
|
|
1913
|
-
return Ji(typeof t == "string" ? t : String(t));
|
|
1914
|
-
} catch (t) {
|
|
1915
|
-
throw new E(Gi(), "MANAGED_ACCOUNT_SET_EAS_FAILED", e, t);
|
|
1916
|
-
}
|
|
1917
|
-
}
|
|
1918
|
-
async function Zi(e) {
|
|
1919
|
-
let t = Yi(e);
|
|
1920
|
-
if (await Xi(e) !== t) throw new E(Ki, "MANAGED_ACCOUNT_SET_EAS_FAILED", e);
|
|
1921
|
-
}
|
|
1922
|
-
async function Qi(e, t) {
|
|
1923
|
-
let n = Yi(e), r = await Xi(e);
|
|
1924
|
-
if (r !== n) {
|
|
1925
|
-
if (r !== Ji(st)) throw new E(qi(r), "MANAGED_ACCOUNT_SET_EAS_FAILED", e);
|
|
1926
|
-
try {
|
|
1927
|
-
let n = typeof t == "function" ? await t() : t, r = i(n) ? n.txSender : he(n) ? n : (() => {
|
|
1928
|
-
throw Error("@seedprotocol/publish: ensureManagedAccountEasConfigured requires PublishWallet or SeedTxSender");
|
|
1929
|
-
})(), { easContractAddress: a } = D(), o = S(e, a), s = await r.sendTransaction(o);
|
|
1930
|
-
await T(s.transactionHash);
|
|
1931
|
-
} catch (t) {
|
|
1932
|
-
throw new E(Gi(), "MANAGED_ACCOUNT_SET_EAS_FAILED", e, t);
|
|
1933
|
-
}
|
|
1934
|
-
}
|
|
1935
|
-
}
|
|
1936
|
-
//#endregion
|
|
1937
|
-
//#region src/services/publish/actors/createAttestations.ts
|
|
1938
|
-
var $i = L("seedProtocol:services:publish:actors");
|
|
1939
|
-
function ea(e) {
|
|
1940
|
-
return !!e && /^0x[0-9a-fA-F]{40}$/.test(e.trim());
|
|
1941
|
-
}
|
|
1942
|
-
function ta(e) {
|
|
1943
|
-
let { useModularExecutor: t, publisherAddress: n, modularAccountModuleContract: r, managedAddress: i, routeToExecutorModule: a } = e;
|
|
1944
|
-
if (t) {
|
|
1945
|
-
if (!i) throw Error("resolvePublishRouting: managedAddress is required when useModularExecutor is true");
|
|
1946
|
-
let e = r?.trim();
|
|
1947
|
-
if (a) {
|
|
1948
|
-
if (!ea(e)) throw Error("resolvePublishRouting: modularAccountModuleContract is required when routeToExecutorModule is true");
|
|
1949
|
-
return {
|
|
1950
|
-
txTargetAddress: e,
|
|
1951
|
-
contractAddressForEvents: e
|
|
1952
|
-
};
|
|
1953
|
-
}
|
|
1954
|
-
return {
|
|
1955
|
-
txTargetAddress: i,
|
|
1956
|
-
contractAddressForEvents: e || i
|
|
1957
|
-
};
|
|
1958
|
-
}
|
|
1959
|
-
return {
|
|
1960
|
-
txTargetAddress: n,
|
|
1961
|
-
contractAddressForEvents: n
|
|
1962
|
-
};
|
|
1963
|
-
}
|
|
1964
|
-
var na = I(async ({ input: { context: e } }) => {
|
|
1965
|
-
let { address: t, account: n, wallet: r } = e, i = e.arweaveTransactions ?? [], a = e.publishUploads ?? [], { item: o } = e, { modularAccountModuleContract: s, useModularExecutor: l } = D();
|
|
1966
|
-
if (!t || typeof t != "string" || !t.trim()) throw Error("No wallet address for publish. Connect a wallet and try again.");
|
|
1967
|
-
if (!r && !n) throw Error("Wallet session is missing. Reconnect your wallet and retry the publish.");
|
|
1968
|
-
if (!l && !await oe(t)) throw Error("EOA publishing must use the direct EAS path (multiPublish requires a deployed publisher contract). If you see this, attestation routing is misconfigured.");
|
|
1969
|
-
if (!o?.seedLocalId) throw Error("Attestation recovery failed: Item data is missing. Delete this publish record and try a full publish from the beginning.");
|
|
1970
|
-
if (typeof o.getPublishUploads != "function" && (o = await xn(o.seedLocalId)), i.length !== a.length) throw Error("Attestation recovery failed: Arweave transaction data is missing or incomplete. Delete this publish record and try a full publish from the beginning.");
|
|
1971
|
-
let u = ta({
|
|
1972
|
-
useModularExecutor: !1,
|
|
1973
|
-
publisherAddress: t
|
|
1974
|
-
}), d = Vi(e), f = !1;
|
|
1975
|
-
await yn(o, d, { managedAddress: t });
|
|
1976
|
-
let p = i.map((e, t) => {
|
|
1977
|
-
let n = e.transaction?.id;
|
|
1978
|
-
if (!n || typeof n != "string") throw Error("Attestation recovery failed: Arweave transaction data did not survive restore. Delete this publish record and try a full publish from the beginning.");
|
|
1979
|
-
let r = a[t];
|
|
1980
|
-
if (!r) throw Error("Publish upload index mismatch");
|
|
1981
|
-
return {
|
|
1982
|
-
...r,
|
|
1983
|
-
txId: n
|
|
1984
|
-
};
|
|
1985
|
-
});
|
|
1986
|
-
await Hi(p.map((e) => e.txId));
|
|
1987
|
-
let m = await o.getPublishPayload(p, { publishMode: e.publishMode ?? "patch" }), h = Array.isArray(m) ? m : [m];
|
|
1988
|
-
if (l) {
|
|
1989
|
-
let e = d?.signer?.address, n = !1;
|
|
1990
|
-
if (t && e) {
|
|
1991
|
-
let { isAutomationSessionActive: r } = await import("./ensureAutomationSessionKey-D0bbWT8e.js").then((e) => e.n);
|
|
1992
|
-
n = await r(t, e);
|
|
1993
|
-
}
|
|
1994
|
-
if (n) {
|
|
1995
|
-
let e = s?.trim();
|
|
1996
|
-
if (!ea(e)) throw Error("@seedprotocol/publish: automation publish requires PublishConfig.modularAccountModuleContract (executor module). Session keys are module-only and cannot call the ManagedAccount directly.");
|
|
1997
|
-
u = ta({
|
|
1998
|
-
useModularExecutor: l,
|
|
1999
|
-
publisherAddress: t,
|
|
2000
|
-
modularAccountModuleContract: e,
|
|
2001
|
-
managedAddress: t,
|
|
2002
|
-
routeToExecutorModule: !0
|
|
2003
|
-
}), f = !0, await Ci(t);
|
|
2004
|
-
} else {
|
|
2005
|
-
let e = await Bi();
|
|
2006
|
-
if (!e.ok) throw e.error;
|
|
2007
|
-
u = ta({
|
|
2008
|
-
useModularExecutor: l,
|
|
2009
|
-
publisherAddress: t,
|
|
2010
|
-
modularAccountModuleContract: s,
|
|
2011
|
-
managedAddress: e.managedAddress
|
|
2012
|
-
});
|
|
2013
|
-
let { ensureModularPublishBootstrap: n } = await import("./ensureModularPublishBootstrap-x1bmc__0.js").then((e) => e.n), { fromThirdwebAccount: r } = await import("./chainConfig-bc_6IgAw.js").then((e) => e.g);
|
|
2014
|
-
d = r(await n(e.managedAddress));
|
|
2015
|
-
}
|
|
2016
|
-
} else await Qi(t, d);
|
|
2017
|
-
let g = async (e) => {
|
|
2018
|
-
let n = u.txTargetAddress, r = f ? c(n, e, 5000000n) : ve(n, e, 5000000n);
|
|
2019
|
-
await Ti(f ? {
|
|
2020
|
-
managedAddress: t,
|
|
2021
|
-
tx: r,
|
|
2022
|
-
action: "multiPublish via the executor module"
|
|
2023
|
-
} : {
|
|
2024
|
-
managedAddress: d.txSender.address,
|
|
2025
|
-
tx: r,
|
|
2026
|
-
action: "multiPublish",
|
|
2027
|
-
code: "PUBLISH_PREFLIGHT_FAILED",
|
|
2028
|
-
requireSimulation: !1
|
|
2029
|
-
});
|
|
2030
|
-
try {
|
|
2031
|
-
return await d.txSender.sendTransaction(r);
|
|
2032
|
-
} catch (e) {
|
|
2033
|
-
throw an(e, d.txSender.address);
|
|
2034
|
-
}
|
|
2035
|
-
}, _ = h.length > 1 && jr(h), v, y = null, b = [];
|
|
2036
|
-
if (_) {
|
|
2037
|
-
let e = structuredClone(h), n = {}, r = {};
|
|
2038
|
-
for (let i = 0; i < e.length; i++) {
|
|
2039
|
-
e = await Je(e, n);
|
|
2040
|
-
let a = e[i], s = /* @__PURE__ */ new Set([a.localId]), c = Pr({
|
|
2041
|
-
...a,
|
|
2042
|
-
propertiesToUpdate: Mr(a.propertiesToUpdate, s)
|
|
2043
|
-
}), d = /* @__PURE__ */ new Map([[c.localId, c]]);
|
|
2044
|
-
Fr([c], d);
|
|
2045
|
-
let f = await g([c]), p = await T(f.transactionHash);
|
|
2046
|
-
if (!p) throw Error("Failed to send transaction");
|
|
2047
|
-
y = p;
|
|
2048
|
-
for (let e of yr(p, l)) e.attestationUid && b.push(e.attestationUid);
|
|
2049
|
-
let { requests: [m] } = await Rr({
|
|
2050
|
-
receipt: p,
|
|
2051
|
-
requests: [c],
|
|
2052
|
-
rootSeedLocalId: o.seedLocalId,
|
|
2053
|
-
useModularExecutor: l,
|
|
2054
|
-
contractAddressForEvents: u.contractAddressForEvents,
|
|
2055
|
-
publisherAddress: t
|
|
2056
|
-
});
|
|
2057
|
-
m?.versionUid && q(m.versionUid) !== U && (r[a.localId] = m.versionUid);
|
|
2058
|
-
let h = !c.seedUid || q(c.seedUid) === U ? m?.seedUid : void 0;
|
|
2059
|
-
h && q(h) !== U && (n[a.localId] = h, e[i] = {
|
|
2060
|
-
...e[i],
|
|
2061
|
-
seedUid: h
|
|
2062
|
-
}, b.push(h));
|
|
2063
|
-
}
|
|
2064
|
-
for (let t of e) {
|
|
2065
|
-
let e = t?.localId, r = t?.seedUid;
|
|
2066
|
-
e && r && q(r) !== U && (n[e] = q(r));
|
|
2067
|
-
}
|
|
2068
|
-
v = (await Je(structuredClone(h), n)).map((e) => Pr({
|
|
2069
|
-
...e,
|
|
2070
|
-
seedUid: n[e.localId] ?? e.seedUid,
|
|
2071
|
-
versionUid: r[e.localId] ?? e.versionUid
|
|
2072
|
-
}));
|
|
2073
|
-
} else {
|
|
2074
|
-
let e = h.map((e) => Pr(e));
|
|
2075
|
-
Fr(e, new Map(e.map((e) => [e?.localId, e])));
|
|
2076
|
-
let n = Array.isArray(m) ? e : [e[0]], r = await g(n), i = await T(r.transactionHash);
|
|
2077
|
-
if (!i) throw Error("Failed to send transaction");
|
|
2078
|
-
y = i;
|
|
2079
|
-
for (let e of yr(i, l)) e.attestationUid && b.push(e.attestationUid);
|
|
2080
|
-
v = (await Rr({
|
|
2081
|
-
receipt: i,
|
|
2082
|
-
requests: n,
|
|
2083
|
-
rootSeedLocalId: o.seedLocalId,
|
|
2084
|
-
useModularExecutor: l,
|
|
2085
|
-
contractAddressForEvents: u.contractAddressForEvents,
|
|
2086
|
-
publisherAddress: t
|
|
2087
|
-
})).requests;
|
|
2088
|
-
}
|
|
2089
|
-
Dr(o, v);
|
|
2090
|
-
let x = o, S = v.find((e) => e?.localId === o.seedLocalId)?.seedUid;
|
|
2091
|
-
S && S !== U && await Or(x, t, y ? await vr(y) : void 0), $i("requestData", m), Wi(e);
|
|
2092
|
-
try {
|
|
2093
|
-
let { clearHtmlEmbeddedImageCoPublishRows: e } = await import("@seedprotocol/sdk"), t = /* @__PURE__ */ new Set([o.seedLocalId]);
|
|
2094
|
-
for (let e of v) e?.localId && t.add(e.localId);
|
|
2095
|
-
for (let n of t) await e(n);
|
|
2096
|
-
} catch {}
|
|
2097
|
-
let { collectPublishedBatch: ee } = await import("./collectBatchUids-CnIe9jUB.js").then((e) => e.t), C = v.find((e) => e?.localId === o.seedLocalId) ?? v[0];
|
|
2098
|
-
for (let e of v) e?.seedUid && b.push(String(e.seedUid)), e?.versionUid && b.push(String(e.versionUid));
|
|
2099
|
-
return {
|
|
2100
|
-
easPayload: m,
|
|
2101
|
-
publishedBatch: C?.seedUid ? ee({
|
|
2102
|
-
seedUid: String(C.seedUid),
|
|
2103
|
-
versionUid: C.versionUid ? String(C.versionUid) : void 0,
|
|
2104
|
-
extraUids: b
|
|
2105
|
-
}) : null
|
|
2106
|
-
};
|
|
2107
|
-
}), ra = L("seedProtocol:services:publish:verifyAttestations"), ia = "0x" + "0".repeat(64), aa = 64, oa = (e) => e == null ? "0x" + "0".repeat(aa) : typeof e == "string" ? "0x" + (e.startsWith("0x") ? e.slice(2) : e).replace(/[^0-9a-fA-F]/g, "0").padStart(aa, "0").slice(-64) : "0x" + "0".repeat(aa), sa = 5e3, ca = 6;
|
|
2108
|
-
async function la({ normalizedRequests: e, item: t }) {
|
|
2109
|
-
let n = t.seedLocalId;
|
|
2110
|
-
for (let t of e) {
|
|
2111
|
-
if (t.listOfAttestations.length === 0 || t.versionUid === ia) continue;
|
|
2112
|
-
let e = t.listOfAttestations.map((e) => oa(e.schema).toLowerCase()), r = [], i;
|
|
2113
|
-
for (let e = 1; e <= ca; e++) try {
|
|
2114
|
-
e > 1 && await new Promise((e) => setTimeout(e, sa)), r = await Le({ versionUids: [t.versionUid] });
|
|
2115
|
-
break;
|
|
2116
|
-
} catch (t) {
|
|
2117
|
-
if (i = t, ra("verifyAttestations attempt %d failed:", e, t), e === ca) throw ra("verifyAttestations: giving up after %d attempts", ca), i;
|
|
2118
|
-
}
|
|
2119
|
-
let a = r.map((e) => e.schemaId ? oa(e.schemaId).toLowerCase() : "").filter(Boolean), o = new Set(a);
|
|
2120
|
-
if (e.filter((e) => !o.has(e)).length > 0) throw new le(`Publish verification failed: Seed and Version attestations were created, but property/metadata attestations are missing or incomplete. Expected ${e.length} property attestations for schema(s) ${e.join(", ")}; found ${a.length}. Use PublishManager.retryAttestations('${n}') to retry.`, n, e, a, "METADATA_PROPERTIES_MISSING");
|
|
2121
|
-
}
|
|
2122
|
-
}
|
|
2123
|
-
//#endregion
|
|
2124
|
-
//#region src/services/publish/actors/createAttestationsDirectToEas.ts
|
|
2125
|
-
var ua = L("seedProtocol:services:publish:createAttestationsDirectToEas"), da = 64, Y = (e) => {
|
|
2126
|
-
if (e == null) return "0x" + "0".repeat(da);
|
|
2127
|
-
if (typeof e == "string") return "0x" + (e.startsWith("0x") ? e.slice(2) : e).replace(/[^0-9a-fA-F]/g, "0").padStart(da, "0").slice(-64);
|
|
2128
|
-
if (e instanceof Uint8Array || typeof ArrayBuffer < "u" && e instanceof ArrayBuffer) {
|
|
2129
|
-
let t = e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
2130
|
-
return "0x" + Array.from(t).map((e) => e.toString(16).padStart(2, "0")).join("").padStart(da, "0").slice(-64);
|
|
2131
|
-
}
|
|
2132
|
-
return "0x" + "0".repeat(da);
|
|
2133
|
-
}, fa = (e) => {
|
|
2134
|
-
if (e == null || typeof e == "string" && (e === "" || e === "0x")) return "0x";
|
|
2135
|
-
if (typeof e == "string") {
|
|
2136
|
-
let t = (e.startsWith("0x") ? e.slice(2) : e).replace(/[^0-9a-fA-F]/g, "0");
|
|
2137
|
-
return "0x" + (t.length % 2 == 1 ? "0" + t : t);
|
|
2138
|
-
}
|
|
2139
|
-
if (e instanceof Uint8Array || typeof ArrayBuffer < "u" && e instanceof ArrayBuffer) {
|
|
2140
|
-
let t = e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
2141
|
-
return "0x" + Array.from(t).map((e) => e.toString(16).padStart(2, "0")).join("");
|
|
2142
|
-
}
|
|
2143
|
-
return "0x";
|
|
2144
|
-
}, pa = async (e) => {
|
|
2145
|
-
let t;
|
|
2146
|
-
try {
|
|
2147
|
-
t = await M.find({ seedLocalId: e });
|
|
2148
|
-
} catch {}
|
|
2149
|
-
return t || new Promise((t) => {
|
|
2150
|
-
let n = setInterval(() => {
|
|
2151
|
-
try {
|
|
2152
|
-
M.find({ seedLocalId: e }).then((e) => {
|
|
2153
|
-
e && (clearInterval(n), t(e));
|
|
2154
|
-
});
|
|
2155
|
-
} catch {}
|
|
2156
|
-
}, 200);
|
|
2157
|
-
});
|
|
2158
|
-
}, ma = (e) => Array.isArray(e?._rawListIdsForResolve) || e?._easDataType === "bytes32[]" || typeof e?._schemaDef == "string" && e._schemaDef.startsWith("bytes32[]"), ha = (e) => Array.isArray(e?._rawListIdsForResolve) && e._rawListIdsForResolve.length > 0 || !!e?._unresolvedValue;
|
|
2159
|
-
async function ga(e, t, n) {
|
|
2160
|
-
let r = e?.listOfAttestations ?? [];
|
|
2161
|
-
if (!r.some(ha)) return;
|
|
2162
|
-
let [i] = await Je([e], n);
|
|
2163
|
-
r.forEach((e, n) => {
|
|
2164
|
-
let r = i?.listOfAttestations?.[n];
|
|
2165
|
-
if (!ha(e) || !r || ha(r)) return;
|
|
2166
|
-
let a = Array.isArray(r.data) ? r.data[0]?.data : r.data?.data, o = t.listOfAttestations[n]?.data?.[0];
|
|
2167
|
-
o && a != null && (o.data = fa(a));
|
|
2168
|
-
});
|
|
2169
|
-
}
|
|
2170
|
-
var _a = I(async ({ input: { context: e, event: t } }) => {
|
|
2171
|
-
let { address: n, account: r, wallet: i } = e, a = e.arweaveTransactions ?? [], o = e.publishUploads ?? [], { item: c } = e;
|
|
2172
|
-
if (!n || typeof n != "string" || !n.trim()) throw Error("No wallet address for publish. Connect a wallet and try again.");
|
|
2173
|
-
if (!i && !r) throw Error("Wallet session is missing. Reconnect your wallet and retry the publish.");
|
|
2174
|
-
if (!c?.seedLocalId) throw Error("Attestation recovery failed: Item data is missing. Delete this publish record and try a full publish from the beginning.");
|
|
2175
|
-
if (typeof c.getPublishUploads != "function" && (c = await pa(c.seedLocalId)), a.length !== o.length) throw Error("Attestation recovery failed: Arweave transaction data is missing or incomplete. Delete this publish record and try a full publish from the beginning.");
|
|
2176
|
-
let l = Vi(e), d = l.txSender;
|
|
2177
|
-
await yn(c, l, { managedAddress: n });
|
|
2178
|
-
let f = a.map((e, t) => {
|
|
2179
|
-
let n = e.transaction?.id;
|
|
2180
|
-
if (!n || typeof n != "string") throw Error("Attestation recovery failed: Arweave transaction data did not survive restore. Delete this publish record and try a full publish from the beginning.");
|
|
2181
|
-
let r = o[t];
|
|
2182
|
-
if (!r) throw Error("Publish upload index mismatch");
|
|
2183
|
-
return {
|
|
2184
|
-
...r,
|
|
2185
|
-
txId: n
|
|
2186
|
-
};
|
|
2187
|
-
});
|
|
2188
|
-
await Hi(f.map((e) => e.txId));
|
|
2189
|
-
let m = await c.getPublishPayload(f, { publishMode: e.publishMode ?? "patch" }), h = Array.isArray(m) ? m : [m], _ = h.map((e) => {
|
|
2190
|
-
let t = (e?.listOfAttestations ?? []).map((e) => {
|
|
2191
|
-
let t = Array.isArray(e?.data) ? e.data : [];
|
|
2192
|
-
return {
|
|
2193
|
-
schema: Y(e?.schema),
|
|
2194
|
-
data: t.map((e) => ({
|
|
2195
|
-
...e,
|
|
2196
|
-
refUID: Y(e?.refUID),
|
|
2197
|
-
data: fa(e?.data)
|
|
2198
|
-
})),
|
|
2199
|
-
...typeof e?._propertyName == "string" && e._propertyName !== "" ? { _propertyName: e._propertyName } : {},
|
|
2200
|
-
...typeof e?._propertyNameForSchema == "string" && e._propertyNameForSchema !== "" ? { _propertyNameForSchema: e._propertyNameForSchema } : {},
|
|
2201
|
-
...ma(e) ? { _isList: !0 } : {}
|
|
2202
|
-
};
|
|
2203
|
-
}), n = (e?.propertiesToUpdate ?? []).map((e) => ({
|
|
2204
|
-
...e,
|
|
2205
|
-
propertySchemaUid: Y(e?.propertySchemaUid)
|
|
2206
|
-
}));
|
|
2207
|
-
return {
|
|
2208
|
-
...e,
|
|
2209
|
-
seedUid: Y(e?.seedUid),
|
|
2210
|
-
seedSchemaUid: Y(e?.seedSchemaUid),
|
|
2211
|
-
versionUid: Y(e?.versionUid),
|
|
2212
|
-
versionSchemaUid: Y(e?.versionSchemaUid),
|
|
2213
|
-
listOfAttestations: t,
|
|
2214
|
-
propertiesToUpdate: n
|
|
2215
|
-
};
|
|
2216
|
-
}), y = new Map(_.map((e) => [e.localId, e])), b = {
|
|
2217
|
-
recipient: Nt,
|
|
2218
|
-
expirationTime: BigInt(0),
|
|
2219
|
-
revocable: !0,
|
|
2220
|
-
refUID: g,
|
|
2221
|
-
data: g,
|
|
2222
|
-
value: BigInt(0)
|
|
2223
|
-
};
|
|
2224
|
-
for (let e of _) for (let t of e.propertiesToUpdate ?? []) {
|
|
2225
|
-
let e = t.publishLocalId, n = Y(t.propertySchemaUid);
|
|
2226
|
-
if (!e || !n) continue;
|
|
2227
|
-
let r = y.get(e);
|
|
2228
|
-
if (!r?.listOfAttestations) continue;
|
|
2229
|
-
let i = r.listOfAttestations.find((e) => Y(e?.schema)?.toLowerCase() === n?.toLowerCase());
|
|
2230
|
-
i && !i._isList && (!Array.isArray(i.data) || i.data.length === 0) && (i.data = [{
|
|
2231
|
-
...b,
|
|
2232
|
-
refUID: g
|
|
2233
|
-
}]);
|
|
2234
|
-
}
|
|
2235
|
-
let x = Date.now(), S = [], ee = /* @__PURE__ */ new Map(), C = {};
|
|
2236
|
-
for (let e of _) e.localId && e.seedUid !== g && (C[e.localId] = e.seedUid);
|
|
2237
|
-
for (let e = 0; e < _.length; e++) {
|
|
2238
|
-
let t = _[e], r = t.seedUid, i = t.versionUid;
|
|
2239
|
-
if (r === g) {
|
|
2240
|
-
let e = v({
|
|
2241
|
-
schema: t.seedSchemaUid,
|
|
2242
|
-
data: {
|
|
2243
|
-
refUID: g,
|
|
2244
|
-
data: s(t.seedSchemaUid),
|
|
2245
|
-
revocable: t.seedIsRevocable
|
|
2246
|
-
}
|
|
2247
|
-
}), n = await d.sendTransaction(e), i = await T(n.transactionHash);
|
|
2248
|
-
if (!i) throw Error("Failed to create Seed attestation");
|
|
2249
|
-
x = await vr(i);
|
|
2250
|
-
let { easContractAddress: a } = D(), o = u(i, a);
|
|
2251
|
-
if (!o || o === g) throw Error("Failed to get Seed UID from attestation receipt");
|
|
2252
|
-
r = o, t.seedUid = o, t.localId && (ee.set(t.localId, {
|
|
2253
|
-
seedUid: o,
|
|
2254
|
-
attestationMs: x
|
|
2255
|
-
}), C[t.localId] = o), S.push(o), ua("created Seed attestation", r);
|
|
2256
|
-
} else r !== g && S.push(r);
|
|
2257
|
-
if (r !== g && i === g) {
|
|
2258
|
-
let e = v({
|
|
2259
|
-
schema: t.versionSchemaUid,
|
|
2260
|
-
data: {
|
|
2261
|
-
refUID: r,
|
|
2262
|
-
data: s(t.versionSchemaUid),
|
|
2263
|
-
revocable: !0
|
|
2264
|
-
}
|
|
2265
|
-
}), a = await d.sendTransaction(e), o = await T(a.transactionHash);
|
|
2266
|
-
if (!o) throw Error("Failed to create Version attestation");
|
|
2267
|
-
x = await vr(o);
|
|
2268
|
-
let { easContractAddress: c } = D(), l = u(o, c);
|
|
2269
|
-
if (!l || l === g) throw Error("Failed to get Version UID from attestation receipt");
|
|
2270
|
-
i = l, t.versionUid = l, S.push(l), await Qe({
|
|
2271
|
-
seedLocalId: t.localId,
|
|
2272
|
-
versionUid: l,
|
|
2273
|
-
publisher: n,
|
|
2274
|
-
attestationCreatedAt: x
|
|
2275
|
-
}), ua("created Version attestation", i);
|
|
2276
|
-
} else i !== g && S.push(i);
|
|
2277
|
-
for (let e of t.listOfAttestations) for (let t of e.data) t.refUID = i;
|
|
2278
|
-
await ga(h[e], t, C);
|
|
2279
|
-
for (let e of t.propertiesToUpdate ?? []) {
|
|
2280
|
-
let t = y.get(e.publishLocalId);
|
|
2281
|
-
if (!t?.listOfAttestations) continue;
|
|
2282
|
-
let n = Y(e.propertySchemaUid), i = t.listOfAttestations.find((e) => Y(e?.schema)?.toLowerCase() === n?.toLowerCase());
|
|
2283
|
-
i?.data?.[0] && !i._isList && (i.data[0].data = s(r));
|
|
2284
|
-
}
|
|
2285
|
-
let a = t.listOfAttestations.map((e) => ({
|
|
2286
|
-
schema: e.schema,
|
|
2287
|
-
data: e.data.map((e) => ({
|
|
2288
|
-
recipient: e.recipient ?? Nt,
|
|
2289
|
-
expirationTime: e.expirationTime ?? 0n,
|
|
2290
|
-
revocable: e.revocable ?? !0,
|
|
2291
|
-
refUID: e.refUID ?? g,
|
|
2292
|
-
data: e.data ?? "0x",
|
|
2293
|
-
value: e.value ?? 0n
|
|
2294
|
-
}))
|
|
2295
|
-
}));
|
|
2296
|
-
if (a.length > 0) {
|
|
2297
|
-
let n = De(a), r = await d.sendTransaction(n), o = await T(r.transactionHash);
|
|
2298
|
-
if (!o) throw Error("Failed to create property attestations");
|
|
2299
|
-
x = await vr(o), ua("created property attestations for request", e);
|
|
2300
|
-
let { easContractAddress: s } = D(), c = p(o, s);
|
|
2301
|
-
for (let e of c) e.uid && S.push(e.uid);
|
|
2302
|
-
let l = t.listOfAttestations, u = c.length === l.length;
|
|
2303
|
-
await Ne({
|
|
2304
|
-
seedLocalId: t.localId,
|
|
2305
|
-
attestationCreatedAtMs: x ?? null,
|
|
2306
|
-
versionUid: i === g ? null : i,
|
|
2307
|
-
pairs: c.map((e, t) => ({
|
|
2308
|
-
schemaUid: e.schemaUid,
|
|
2309
|
-
attestationUid: e.uid,
|
|
2310
|
-
propertyName: u && typeof l[t]?._propertyName == "string" && l[t]._propertyName !== "" ? l[t]._propertyName : void 0
|
|
2311
|
-
}))
|
|
2312
|
-
});
|
|
2313
|
-
}
|
|
2314
|
-
}
|
|
2315
|
-
Dr(c, _);
|
|
2316
|
-
let te = c, w = _.find((e) => e.localId === c.seedLocalId) ?? _[0];
|
|
2317
|
-
w?.seedUid && w.seedUid !== g && await Or(te, n, ee.get(w.localId)?.attestationMs ?? x);
|
|
2318
|
-
for (let [e, { seedUid: t, attestationMs: r }] of ee) e !== w?.localId && await zr({
|
|
2319
|
-
seedLocalId: e,
|
|
2320
|
-
seedUid: t,
|
|
2321
|
-
publisherAddress: n,
|
|
2322
|
-
attestationCreatedAtMs: r
|
|
2323
|
-
});
|
|
2324
|
-
try {
|
|
2325
|
-
await la({
|
|
2326
|
-
normalizedRequests: _,
|
|
2327
|
-
item: c
|
|
2328
|
-
});
|
|
2329
|
-
} catch (e) {
|
|
2330
|
-
throw e instanceof le || ua("verifyAttestations failed (non-verification error):", e), e;
|
|
2331
|
-
}
|
|
2332
|
-
ua("direct EAS publish complete"), Wi(e);
|
|
2333
|
-
try {
|
|
2334
|
-
let { clearHtmlEmbeddedImageCoPublishRows: e } = await import("@seedprotocol/sdk"), t = /* @__PURE__ */ new Set([c.seedLocalId]);
|
|
2335
|
-
for (let e of _) e?.localId && t.add(e.localId);
|
|
2336
|
-
for (let n of t) await e(n);
|
|
2337
|
-
} catch {}
|
|
2338
|
-
let { collectPublishedBatch: ne } = await import("./collectBatchUids-CnIe9jUB.js").then((e) => e.t), re = w;
|
|
2339
|
-
return {
|
|
2340
|
-
easPayload: m,
|
|
2341
|
-
publishedBatch: re?.seedUid ? ne({
|
|
2342
|
-
seedUid: String(re.seedUid),
|
|
2343
|
-
versionUid: re.versionUid ? String(re.versionUid) : void 0,
|
|
2344
|
-
extraUids: S
|
|
2345
|
-
}) : null
|
|
2346
|
-
};
|
|
2347
|
-
}), va = async (e) => {
|
|
2348
|
-
let t;
|
|
2349
|
-
try {
|
|
2350
|
-
t = await M.find({ seedLocalId: e });
|
|
2351
|
-
} catch {}
|
|
2352
|
-
return t || new Promise((t) => {
|
|
2353
|
-
let n = setInterval(() => {
|
|
2354
|
-
M.find({ seedLocalId: e }).then((e) => {
|
|
2355
|
-
e && (clearInterval(n), t(e));
|
|
2356
|
-
}).catch(() => {});
|
|
2357
|
-
}, 200);
|
|
2358
|
-
});
|
|
2359
|
-
};
|
|
2360
|
-
async function ya(e) {
|
|
2361
|
-
let t = typeof e.getPublishUploads == "function" ? e : await va(e.seedLocalId);
|
|
2362
|
-
return await We(t);
|
|
2363
|
-
}
|
|
2364
|
-
//#endregion
|
|
2365
|
-
//#region src/services/publish/actors/checking.ts
|
|
2366
|
-
var X = /* @__PURE__ */ new Set();
|
|
2367
|
-
async function ba(e) {
|
|
2368
|
-
let t = D();
|
|
2369
|
-
return t.useDirectEas ? "directEas" : t.useModularExecutor || await oe(e) ? "multiPublish" : "directEas";
|
|
2370
|
-
}
|
|
2371
|
-
var xa = Lt(({ sendBack: e, input: { context: t } }) => {
|
|
2372
|
-
let { item: n, account: r, wallet: i, publishMode: a, address: o } = t;
|
|
2373
|
-
return (async () => {
|
|
2374
|
-
if (!await Ue(n)) e({ type: "notOwner" });
|
|
2375
|
-
else if (X.has(n.seedLocalId)) e({ type: "redundantPublishProcess" });
|
|
2376
|
-
else {
|
|
2377
|
-
X.add(n.seedLocalId);
|
|
2378
|
-
try {
|
|
2379
|
-
await Fe(), await ce();
|
|
2380
|
-
let t = await Ve(n, { publishMode: a ?? "patch" });
|
|
2381
|
-
if (t.length > 0) {
|
|
2382
|
-
X.delete(n.seedLocalId), e({
|
|
2383
|
-
type: "validationFailed",
|
|
2384
|
-
errors: new Me(t).validationErrors
|
|
2385
|
-
});
|
|
2386
|
-
return;
|
|
2387
|
-
}
|
|
2388
|
-
let s = i ?? r;
|
|
2389
|
-
s && await yn(n, s, { managedAddress: typeof o == "string" ? o : void 0 });
|
|
2390
|
-
let c = await $e(n, [], { publishMode: a ?? "patch" });
|
|
2391
|
-
if (!c.isValid) {
|
|
2392
|
-
X.delete(n.seedLocalId), e({
|
|
2393
|
-
type: "validationFailed",
|
|
2394
|
-
errors: c.errors
|
|
2395
|
-
});
|
|
2396
|
-
return;
|
|
2397
|
-
}
|
|
2398
|
-
if (!o || typeof o != "string" || !o.trim()) {
|
|
2399
|
-
X.delete(n.seedLocalId), e({
|
|
2400
|
-
type: "validationFailed",
|
|
2401
|
-
errors: [{ message: "No publisher address for publish. Connect a wallet and try again." }]
|
|
2402
|
-
});
|
|
2403
|
-
return;
|
|
2404
|
-
}
|
|
2405
|
-
let l;
|
|
2406
|
-
try {
|
|
2407
|
-
l = await ba(o.trim());
|
|
2408
|
-
} catch (t) {
|
|
2409
|
-
X.delete(n.seedLocalId), e({
|
|
2410
|
-
type: "checkingFailed",
|
|
2411
|
-
error: Error(`Could not verify whether the publisher is a deployed contract on ${O()}. Check your RPC connection and retry.`, { cause: t })
|
|
2412
|
-
});
|
|
2413
|
-
return;
|
|
2414
|
-
}
|
|
2415
|
-
let u = await ya(n), d = D().useArweaveBundler, f = { attestationStrategy: l };
|
|
2416
|
-
e(u ? d ? {
|
|
2417
|
-
type: "validPublishProcessBundler",
|
|
2418
|
-
...f
|
|
2419
|
-
} : {
|
|
2420
|
-
type: "validPublishProcess",
|
|
2421
|
-
...f
|
|
2422
|
-
} : {
|
|
2423
|
-
type: "skipArweave",
|
|
2424
|
-
...f
|
|
2425
|
-
});
|
|
2426
|
-
} catch (t) {
|
|
2427
|
-
X.delete(n.seedLocalId), console.error("[checking] failed", t), e({
|
|
2428
|
-
type: "checkingFailed",
|
|
2429
|
-
error: t instanceof Error ? t : Error(String(t))
|
|
2430
|
-
});
|
|
2431
|
-
}
|
|
2432
|
-
}
|
|
2433
|
-
})().catch((t) => {
|
|
2434
|
-
X.delete(n.seedLocalId), console.error("[checking] unhandled rejection", t), e({
|
|
2435
|
-
type: "checkingFailed",
|
|
2436
|
-
error: t instanceof Error ? t : Error(String(t))
|
|
2437
|
-
});
|
|
2438
|
-
}), () => {
|
|
2439
|
-
X.delete(n.seedLocalId);
|
|
2440
|
-
};
|
|
2441
|
-
}), { SUCCESS: Sa, FAILURE: Z } = me;
|
|
2442
|
-
function Ca(e) {
|
|
2443
|
-
let t = e.attestationStrategy;
|
|
2444
|
-
return t === "directEas" || t !== "multiPublish" && D().useDirectEas;
|
|
2445
|
-
}
|
|
2446
|
-
function wa(e) {
|
|
2447
|
-
let t = e.attestationStrategy;
|
|
2448
|
-
return t === "multiPublish" || t !== "directEas" && !D().useDirectEas;
|
|
2449
|
-
}
|
|
2450
|
-
function Q(e) {
|
|
2451
|
-
let t = e;
|
|
2452
|
-
return t.error ?? t.data;
|
|
2453
|
-
}
|
|
2454
|
-
var Ta = Rt({
|
|
2455
|
-
types: {
|
|
2456
|
-
context: {},
|
|
2457
|
-
input: {}
|
|
2458
|
-
},
|
|
2459
|
-
actors: {
|
|
2460
|
-
createArweaveTransactions: wn,
|
|
2461
|
-
createArweaveTransactionsPhase2: Tn,
|
|
2462
|
-
createArweaveDataItems: er,
|
|
2463
|
-
createArweaveDataItemsPhase2: nr,
|
|
2464
|
-
sendReimbursementRequest: lr,
|
|
2465
|
-
pollForConfirmation: ur,
|
|
2466
|
-
uploadData: fr,
|
|
2467
|
-
uploadViaBundler: _r,
|
|
2468
|
-
createAttestations: na,
|
|
2469
|
-
createAttestationsDirectToEas: _a,
|
|
2470
|
-
checking: xa,
|
|
2471
|
-
preparingHtmlEmbedded: En,
|
|
2472
|
-
rewritingHtmlEmbedded: On
|
|
2473
|
-
},
|
|
2474
|
-
actions: {
|
|
2475
|
-
handleError: ({ event: e }) => {
|
|
2476
|
-
let t = Q(e);
|
|
2477
|
-
t == null ? console.error("Unknown error (full event):", e) : console.error(t);
|
|
2478
|
-
},
|
|
2479
|
-
assignErrorCreatingArweaveTransactions: F({
|
|
2480
|
-
error: ({ event: e }) => Q(e),
|
|
2481
|
-
errorStep: () => "creatingArweaveTransactions"
|
|
2482
|
-
}),
|
|
2483
|
-
assignErrorCreatingArweaveDataItems: F({
|
|
2484
|
-
error: ({ event: e }) => Q(e),
|
|
2485
|
-
errorStep: () => "creatingArweaveDataItems"
|
|
2486
|
-
}),
|
|
2487
|
-
assignErrorSendingReimbursementRequest: F({
|
|
2488
|
-
error: ({ event: e }) => Q(e),
|
|
2489
|
-
errorStep: () => "sendingReimbursementRequest"
|
|
2490
|
-
}),
|
|
2491
|
-
assignErrorPollingForConfirmation: F({
|
|
2492
|
-
error: ({ event: e }) => Q(e),
|
|
2493
|
-
errorStep: () => "pollingForConfirmation"
|
|
2494
|
-
}),
|
|
2495
|
-
assignErrorUploadingData: F({
|
|
2496
|
-
error: ({ event: e }) => Q(e),
|
|
2497
|
-
errorStep: () => "uploadingData"
|
|
2498
|
-
}),
|
|
2499
|
-
assignErrorPreparingHtmlEmbedded: F({
|
|
2500
|
-
error: ({ event: e }) => Q(e),
|
|
2501
|
-
errorStep: () => "preparingHtmlEmbedded"
|
|
2502
|
-
}),
|
|
2503
|
-
assignErrorRewritingHtmlEmbedded: F({
|
|
2504
|
-
error: ({ event: e }) => Q(e),
|
|
2505
|
-
errorStep: () => "rewritingHtmlEmbedded"
|
|
2506
|
-
}),
|
|
2507
|
-
assignErrorCreatingArweaveTransactionsPhase2: F({
|
|
2508
|
-
error: ({ event: e }) => Q(e),
|
|
2509
|
-
errorStep: () => "creatingArweaveTransactionsPhase2"
|
|
2510
|
-
}),
|
|
2511
|
-
assignErrorUploadingDataPhase2: F({
|
|
2512
|
-
error: ({ event: e }) => Q(e),
|
|
2513
|
-
errorStep: () => "uploadingDataPhase2"
|
|
2514
|
-
}),
|
|
2515
|
-
assignErrorUploadingViaBundler: F({
|
|
2516
|
-
error: ({ event: e }) => Q(e),
|
|
2517
|
-
errorStep: () => "uploadingViaBundler"
|
|
2518
|
-
}),
|
|
2519
|
-
assignErrorCreatingArweaveDataItemsPhase2: F({
|
|
2520
|
-
error: ({ event: e }) => Q(e),
|
|
2521
|
-
errorStep: () => "creatingArweaveDataItemsPhase2"
|
|
2522
|
-
}),
|
|
2523
|
-
assignErrorUploadingViaBundlerPhase2: F({
|
|
2524
|
-
error: ({ event: e }) => Q(e),
|
|
2525
|
-
errorStep: () => "uploadingViaBundlerPhase2"
|
|
2526
|
-
}),
|
|
2527
|
-
assignErrorCreatingAttestations: F({
|
|
2528
|
-
error: ({ event: e }) => Q(e),
|
|
2529
|
-
errorStep: () => "creatingAttestations"
|
|
2530
|
-
}),
|
|
2531
|
-
assignErrorCreatingAttestationsDirectToEas: F({
|
|
2532
|
-
error: ({ event: e }) => Q(e),
|
|
2533
|
-
errorStep: () => "creatingAttestationsDirectToEas"
|
|
2534
|
-
}),
|
|
2535
|
-
assignAccountFromRetry: F({
|
|
2536
|
-
wallet: ({ event: e }) => {
|
|
2537
|
-
let t = e;
|
|
2538
|
-
return t.wallet ?? t.account;
|
|
2539
|
-
},
|
|
2540
|
-
account: ({ event: e }) => {
|
|
2541
|
-
let t = e;
|
|
2542
|
-
return t.wallet ?? t.account;
|
|
2543
|
-
}
|
|
2544
|
-
}),
|
|
2545
|
-
assignErrorNotOwner: F({
|
|
2546
|
-
error: () => /* @__PURE__ */ Error("Item is read-only: you do not own this item. Only the publisher can publish."),
|
|
2547
|
-
errorStep: () => "checking"
|
|
2548
|
-
}),
|
|
2549
|
-
assignErrorValidationFailed: F({
|
|
2550
|
-
error: ({ event: e }) => {
|
|
2551
|
-
let t = e.errors ?? [], n = t.length > 0 ? `Validation failed (${t.length} error${t.length === 1 ? "" : "s"}):\n${t.map((e) => e.message).join("\n")}` : "Validation failed", r = Error(n);
|
|
2552
|
-
return r.validationErrors = t, r;
|
|
2553
|
-
},
|
|
2554
|
-
errorStep: () => "checking"
|
|
2555
|
-
}),
|
|
2556
|
-
assignErrorCheckingFailed: F({
|
|
2557
|
-
error: ({ event: e }) => {
|
|
2558
|
-
let t = e.error;
|
|
2559
|
-
return t instanceof Error ? t : Error(String(t ?? "Publish check failed"));
|
|
2560
|
-
},
|
|
2561
|
-
errorStep: () => "checking"
|
|
2562
|
-
})
|
|
2563
|
-
}
|
|
2564
|
-
}).createMachine({
|
|
2565
|
-
id: "publish",
|
|
2566
|
-
initial: "checking",
|
|
2567
|
-
context: ({ input: e }) => e,
|
|
2568
|
-
states: {
|
|
2569
|
-
checking: {
|
|
2570
|
-
on: {
|
|
2571
|
-
notOwner: {
|
|
2572
|
-
target: Z,
|
|
2573
|
-
actions: ["assignErrorNotOwner", "handleError"]
|
|
2574
|
-
},
|
|
2575
|
-
validationFailed: {
|
|
2576
|
-
target: Z,
|
|
2577
|
-
actions: ["assignErrorValidationFailed", "handleError"]
|
|
2578
|
-
},
|
|
2579
|
-
redundantPublishProcess: { target: "stopping" },
|
|
2580
|
-
checkingFailed: {
|
|
2581
|
-
target: Z,
|
|
2582
|
-
actions: ["assignErrorCheckingFailed", "handleError"]
|
|
2583
|
-
},
|
|
2584
|
-
validPublishProcess: {
|
|
2585
|
-
target: "preparingHtmlEmbedded",
|
|
2586
|
-
actions: F({ attestationStrategy: ({ event: e }) => e.attestationStrategy })
|
|
2587
|
-
},
|
|
2588
|
-
validPublishProcessBundler: {
|
|
2589
|
-
target: "preparingHtmlEmbedded",
|
|
2590
|
-
actions: F({ attestationStrategy: ({ event: e }) => e.attestationStrategy })
|
|
2591
|
-
},
|
|
2592
|
-
skipArweave: [{
|
|
2593
|
-
guard: ({ context: e }) => Ca(e),
|
|
2594
|
-
target: "creatingAttestationsDirectToEas",
|
|
2595
|
-
actions: F({
|
|
2596
|
-
arweaveTransactions: () => [],
|
|
2597
|
-
publishUploads: () => [],
|
|
2598
|
-
attestationStrategy: ({ event: e }) => e.attestationStrategy
|
|
2599
|
-
})
|
|
2600
|
-
}, {
|
|
2601
|
-
guard: ({ context: e }) => wa(e),
|
|
2602
|
-
target: "creatingAttestations",
|
|
2603
|
-
actions: F({
|
|
2604
|
-
arweaveTransactions: () => [],
|
|
2605
|
-
publishUploads: () => [],
|
|
2606
|
-
attestationStrategy: ({ event: e }) => e.attestationStrategy
|
|
2607
|
-
})
|
|
2608
|
-
}]
|
|
2609
|
-
},
|
|
2610
|
-
invoke: {
|
|
2611
|
-
src: "checking",
|
|
2612
|
-
input: ({ context: e }) => ({ context: e })
|
|
2613
|
-
}
|
|
2614
|
-
},
|
|
2615
|
-
preparingHtmlEmbedded: { invoke: {
|
|
2616
|
-
src: "preparingHtmlEmbedded",
|
|
2617
|
-
input: ({ context: e }) => ({ context: e }),
|
|
2618
|
-
onDone: [{
|
|
2619
|
-
guard: () => D().useArweaveBundler,
|
|
2620
|
-
target: "creatingArweaveDataItems",
|
|
2621
|
-
actions: F({ htmlEmbeddedDeferredHtmlSeedLocalIds: ({ event: e }) => e.output.deferredHtmlSeedLocalIds })
|
|
2622
|
-
}, {
|
|
2623
|
-
target: "creatingArweaveTransactions",
|
|
2624
|
-
actions: F({ htmlEmbeddedDeferredHtmlSeedLocalIds: ({ event: e }) => e.output.deferredHtmlSeedLocalIds })
|
|
2625
|
-
}],
|
|
2626
|
-
onError: {
|
|
2627
|
-
target: Z,
|
|
2628
|
-
actions: ["assignErrorPreparingHtmlEmbedded", "handleError"]
|
|
2629
|
-
}
|
|
2630
|
-
} },
|
|
2631
|
-
creatingArweaveTransactions: { invoke: {
|
|
2632
|
-
src: "createArweaveTransactions",
|
|
2633
|
-
input: ({ context: e, event: t }) => ({
|
|
2634
|
-
context: e,
|
|
2635
|
-
event: t
|
|
2636
|
-
}),
|
|
2637
|
-
onDone: {
|
|
2638
|
-
target: "sendingReimbursementRequest",
|
|
2639
|
-
actions: F({
|
|
2640
|
-
arweaveTransactions: ({ event: e }) => e.output.arweaveTransactions,
|
|
2641
|
-
publishUploads: ({ event: e }) => e.output.publishUploads
|
|
2642
|
-
})
|
|
2643
|
-
},
|
|
2644
|
-
onError: {
|
|
2645
|
-
target: "failure",
|
|
2646
|
-
actions: ["assignErrorCreatingArweaveTransactions", "handleError"]
|
|
2647
|
-
}
|
|
2648
|
-
} },
|
|
2649
|
-
creatingArweaveDataItems: { invoke: {
|
|
2650
|
-
src: "createArweaveDataItems",
|
|
2651
|
-
input: ({ context: e, event: t }) => ({
|
|
2652
|
-
context: e,
|
|
2653
|
-
event: t
|
|
2654
|
-
}),
|
|
2655
|
-
onDone: {
|
|
2656
|
-
target: "uploadingViaBundler",
|
|
2657
|
-
actions: F({
|
|
2658
|
-
arweaveTransactions: ({ event: e }) => e.output.arweaveTransactions,
|
|
2659
|
-
publishUploads: ({ event: e }) => e.output.publishUploads,
|
|
2660
|
-
signedDataItems: ({ event: e }) => e.output.signedDataItems
|
|
2661
|
-
})
|
|
2662
|
-
},
|
|
2663
|
-
onError: {
|
|
2664
|
-
target: "failure",
|
|
2665
|
-
actions: ["assignErrorCreatingArweaveDataItems", "handleError"]
|
|
2666
|
-
}
|
|
2667
|
-
} },
|
|
2668
|
-
sendingReimbursementRequest: { invoke: {
|
|
2669
|
-
src: "sendReimbursementRequest",
|
|
2670
|
-
input: ({ context: e, event: t }) => ({
|
|
2671
|
-
context: e,
|
|
2672
|
-
event: t
|
|
2673
|
-
}),
|
|
2674
|
-
onDone: {
|
|
2675
|
-
target: "pollingForConfirmation",
|
|
2676
|
-
actions: F({
|
|
2677
|
-
requestResponse: ({ event: e }) => e.output,
|
|
2678
|
-
reimbursementTransactionId: ({ event: e }) => e.output.transactionId
|
|
2679
|
-
})
|
|
2680
|
-
},
|
|
2681
|
-
onError: {
|
|
2682
|
-
target: "failure",
|
|
2683
|
-
actions: ["assignErrorSendingReimbursementRequest", "handleError"]
|
|
2684
|
-
}
|
|
2685
|
-
} },
|
|
2686
|
-
pollingForConfirmation: { invoke: {
|
|
2687
|
-
src: "pollForConfirmation",
|
|
2688
|
-
input: ({ context: e, event: t }) => ({
|
|
2689
|
-
context: e,
|
|
2690
|
-
event: t
|
|
2691
|
-
}),
|
|
2692
|
-
onDone: {
|
|
2693
|
-
target: "uploadingData",
|
|
2694
|
-
actions: F({ reimbursementConfirmed: !0 })
|
|
2695
|
-
},
|
|
2696
|
-
onError: {
|
|
2697
|
-
target: "failure",
|
|
2698
|
-
actions: ["assignErrorPollingForConfirmation", "handleError"]
|
|
2699
|
-
}
|
|
2700
|
-
} },
|
|
2701
|
-
uploadingViaBundler: {
|
|
2702
|
-
on: {
|
|
2703
|
-
uploadComplete: [
|
|
2704
|
-
{
|
|
2705
|
-
guard: ({ context: e }) => Ca(e),
|
|
2706
|
-
target: "creatingAttestationsDirectToEas",
|
|
2707
|
-
actions: F({
|
|
2708
|
-
completionPercentage: 100,
|
|
2709
|
-
signedDataItems: () => void 0,
|
|
2710
|
-
arweaveUploadData: () => void 0
|
|
2711
|
-
})
|
|
2712
|
-
},
|
|
2713
|
-
{
|
|
2714
|
-
guard: (e) => (e.context?.htmlEmbeddedDeferredHtmlSeedLocalIds?.length ?? 0) > 0,
|
|
2715
|
-
target: "rewritingHtmlEmbedded",
|
|
2716
|
-
actions: F({
|
|
2717
|
-
htmlEmbeddedPhase1PublishUploads: ({ context: e }) => e.publishUploads ?? [],
|
|
2718
|
-
htmlEmbeddedPhase1ArweaveTransactions: ({ context: e }) => e.arweaveTransactions ?? [],
|
|
2719
|
-
signedDataItems: () => void 0,
|
|
2720
|
-
arweaveUploadData: () => void 0
|
|
2721
|
-
})
|
|
2722
|
-
},
|
|
2723
|
-
{
|
|
2724
|
-
guard: ({ context: e }) => wa(e),
|
|
2725
|
-
target: "creatingAttestations",
|
|
2726
|
-
actions: F({
|
|
2727
|
-
completionPercentage: 100,
|
|
2728
|
-
signedDataItems: () => void 0,
|
|
2729
|
-
arweaveUploadData: () => void 0
|
|
2730
|
-
})
|
|
2731
|
-
}
|
|
2732
|
-
],
|
|
2733
|
-
uploadError: {
|
|
2734
|
-
target: "failure",
|
|
2735
|
-
actions: ["assignErrorUploadingViaBundler", "handleError"]
|
|
2736
|
-
}
|
|
2737
|
-
},
|
|
2738
|
-
invoke: {
|
|
2739
|
-
src: "uploadViaBundler",
|
|
2740
|
-
input: ({ context: e }) => ({ context: e })
|
|
2741
|
-
}
|
|
2742
|
-
},
|
|
2743
|
-
creatingArweaveDataItemsPhase2: { invoke: {
|
|
2744
|
-
src: "createArweaveDataItemsPhase2",
|
|
2745
|
-
input: ({ context: e, event: t }) => ({
|
|
2746
|
-
context: e,
|
|
2747
|
-
event: t
|
|
2748
|
-
}),
|
|
2749
|
-
onDone: {
|
|
2750
|
-
target: "uploadingViaBundlerPhase2",
|
|
2751
|
-
actions: F({
|
|
2752
|
-
arweaveTransactions: ({ event: e }) => e.output.arweaveTransactions,
|
|
2753
|
-
publishUploads: ({ event: e }) => e.output.publishUploads,
|
|
2754
|
-
signedDataItems: ({ event: e }) => e.output.signedDataItems,
|
|
2755
|
-
uploaderState: () => void 0,
|
|
2756
|
-
currentTransactionIndex: () => void 0
|
|
2757
|
-
})
|
|
2758
|
-
},
|
|
2759
|
-
onError: {
|
|
2760
|
-
target: Z,
|
|
2761
|
-
actions: ["assignErrorCreatingArweaveDataItemsPhase2", "handleError"]
|
|
2762
|
-
}
|
|
2763
|
-
} },
|
|
2764
|
-
uploadingViaBundlerPhase2: {
|
|
2765
|
-
on: {
|
|
2766
|
-
uploadComplete: [{
|
|
2767
|
-
guard: ({ context: e }) => Ca(e),
|
|
2768
|
-
target: "creatingAttestationsDirectToEas",
|
|
2769
|
-
actions: F({
|
|
2770
|
-
completionPercentage: 100,
|
|
2771
|
-
signedDataItems: () => void 0,
|
|
2772
|
-
arweaveUploadData: () => void 0
|
|
2773
|
-
})
|
|
2774
|
-
}, {
|
|
2775
|
-
guard: ({ context: e }) => wa(e),
|
|
2776
|
-
target: "creatingAttestations",
|
|
2777
|
-
actions: F({
|
|
2778
|
-
completionPercentage: 100,
|
|
2779
|
-
signedDataItems: () => void 0,
|
|
2780
|
-
arweaveUploadData: () => void 0,
|
|
2781
|
-
publishUploads: ({ context: e }) => [...e.htmlEmbeddedPhase1PublishUploads ?? [], ...e.publishUploads ?? []],
|
|
2782
|
-
arweaveTransactions: ({ context: e }) => [...e.htmlEmbeddedPhase1ArweaveTransactions ?? [], ...e.arweaveTransactions ?? []]
|
|
2783
|
-
})
|
|
2784
|
-
}],
|
|
2785
|
-
uploadError: {
|
|
2786
|
-
target: Z,
|
|
2787
|
-
actions: ["assignErrorUploadingViaBundlerPhase2", "handleError"]
|
|
2788
|
-
}
|
|
2789
|
-
},
|
|
2790
|
-
invoke: {
|
|
2791
|
-
src: "uploadViaBundler",
|
|
2792
|
-
input: ({ context: e }) => ({ context: e })
|
|
2793
|
-
}
|
|
2794
|
-
},
|
|
2795
|
-
uploadingData: {
|
|
2796
|
-
on: {
|
|
2797
|
-
updatePercentage: { actions: F({
|
|
2798
|
-
completionPercentage: ({ event: e }) => e.completionPercentage,
|
|
2799
|
-
uploaderState: ({ event: e }) => e.uploaderState,
|
|
2800
|
-
currentTransactionIndex: ({ event: e }) => e.currentTransactionIndex
|
|
2801
|
-
}) },
|
|
2802
|
-
uploadComplete: [
|
|
2803
|
-
{
|
|
2804
|
-
guard: ({ context: e }) => Ca(e),
|
|
2805
|
-
target: "creatingAttestationsDirectToEas",
|
|
2806
|
-
actions: F({ completionPercentage: 100 })
|
|
2807
|
-
},
|
|
2808
|
-
{
|
|
2809
|
-
guard: (e) => (e.context?.htmlEmbeddedDeferredHtmlSeedLocalIds?.length ?? 0) > 0,
|
|
2810
|
-
target: "rewritingHtmlEmbedded",
|
|
2811
|
-
actions: F({
|
|
2812
|
-
htmlEmbeddedPhase1PublishUploads: ({ context: e }) => e.publishUploads ?? [],
|
|
2813
|
-
htmlEmbeddedPhase1ArweaveTransactions: ({ context: e }) => e.arweaveTransactions ?? []
|
|
2814
|
-
})
|
|
2815
|
-
},
|
|
2816
|
-
{
|
|
2817
|
-
guard: ({ context: e }) => wa(e),
|
|
2818
|
-
target: "creatingAttestations",
|
|
2819
|
-
actions: F({ completionPercentage: 100 })
|
|
2820
|
-
}
|
|
2821
|
-
],
|
|
2822
|
-
uploadError: {
|
|
2823
|
-
target: "failure",
|
|
2824
|
-
actions: ["assignErrorUploadingData", "handleError"]
|
|
2825
|
-
}
|
|
2826
|
-
},
|
|
2827
|
-
invoke: {
|
|
2828
|
-
src: "uploadData",
|
|
2829
|
-
input: ({ context: e }) => ({ context: e })
|
|
2830
|
-
}
|
|
2831
|
-
},
|
|
2832
|
-
rewritingHtmlEmbedded: { invoke: {
|
|
2833
|
-
src: "rewritingHtmlEmbedded",
|
|
2834
|
-
input: ({ context: e }) => ({ context: e }),
|
|
2835
|
-
onDone: [{
|
|
2836
|
-
guard: () => !D().useArweaveBundler,
|
|
2837
|
-
target: "creatingArweaveTransactionsPhase2"
|
|
2838
|
-
}, {
|
|
2839
|
-
guard: () => D().useArweaveBundler,
|
|
2840
|
-
target: "creatingArweaveDataItemsPhase2"
|
|
2841
|
-
}],
|
|
2842
|
-
onError: {
|
|
2843
|
-
target: Z,
|
|
2844
|
-
actions: ["assignErrorRewritingHtmlEmbedded", "handleError"]
|
|
2845
|
-
}
|
|
2846
|
-
} },
|
|
2847
|
-
creatingArweaveTransactionsPhase2: { invoke: {
|
|
2848
|
-
src: "createArweaveTransactionsPhase2",
|
|
2849
|
-
input: ({ context: e, event: t }) => ({
|
|
2850
|
-
context: e,
|
|
2851
|
-
event: t
|
|
2852
|
-
}),
|
|
2853
|
-
onDone: {
|
|
2854
|
-
target: "uploadingDataPhase2",
|
|
2855
|
-
actions: F({
|
|
2856
|
-
arweaveTransactions: ({ event: e }) => e.output.arweaveTransactions,
|
|
2857
|
-
publishUploads: ({ event: e }) => e.output.publishUploads,
|
|
2858
|
-
uploaderState: () => void 0,
|
|
2859
|
-
currentTransactionIndex: () => void 0
|
|
2860
|
-
})
|
|
2861
|
-
},
|
|
2862
|
-
onError: {
|
|
2863
|
-
target: Z,
|
|
2864
|
-
actions: ["assignErrorCreatingArweaveTransactionsPhase2", "handleError"]
|
|
2865
|
-
}
|
|
2866
|
-
} },
|
|
2867
|
-
uploadingDataPhase2: {
|
|
2868
|
-
on: {
|
|
2869
|
-
updatePercentage: { actions: F({
|
|
2870
|
-
completionPercentage: ({ event: e }) => e.completionPercentage,
|
|
2871
|
-
uploaderState: ({ event: e }) => e.uploaderState,
|
|
2872
|
-
currentTransactionIndex: ({ event: e }) => e.currentTransactionIndex
|
|
2873
|
-
}) },
|
|
2874
|
-
uploadComplete: [{
|
|
2875
|
-
guard: ({ context: e }) => Ca(e),
|
|
2876
|
-
target: "creatingAttestationsDirectToEas",
|
|
2877
|
-
actions: F({ completionPercentage: 100 })
|
|
2878
|
-
}, {
|
|
2879
|
-
guard: ({ context: e }) => wa(e),
|
|
2880
|
-
target: "creatingAttestations",
|
|
2881
|
-
actions: F({
|
|
2882
|
-
completionPercentage: 100,
|
|
2883
|
-
publishUploads: ({ context: e }) => [...e.htmlEmbeddedPhase1PublishUploads ?? [], ...e.publishUploads ?? []],
|
|
2884
|
-
arweaveTransactions: ({ context: e }) => [...e.htmlEmbeddedPhase1ArweaveTransactions ?? [], ...e.arweaveTransactions ?? []]
|
|
2885
|
-
})
|
|
2886
|
-
}],
|
|
2887
|
-
uploadError: {
|
|
2888
|
-
target: Z,
|
|
2889
|
-
actions: ["assignErrorUploadingDataPhase2", "handleError"]
|
|
2890
|
-
}
|
|
2891
|
-
},
|
|
2892
|
-
invoke: {
|
|
2893
|
-
src: "uploadData",
|
|
2894
|
-
input: ({ context: e }) => ({ context: e })
|
|
2895
|
-
}
|
|
2896
|
-
},
|
|
2897
|
-
creatingAttestations: { invoke: {
|
|
2898
|
-
src: "createAttestations",
|
|
2899
|
-
input: ({ context: e, event: t }) => ({
|
|
2900
|
-
context: e,
|
|
2901
|
-
event: t
|
|
2902
|
-
}),
|
|
2903
|
-
onDone: {
|
|
2904
|
-
target: Sa,
|
|
2905
|
-
actions: F({
|
|
2906
|
-
easPayload: ({ event: e }) => e.output?.easPayload,
|
|
2907
|
-
publishedBatch: ({ event: e }) => e.output?.publishedBatch ?? null
|
|
2908
|
-
})
|
|
2909
|
-
},
|
|
2910
|
-
onError: {
|
|
2911
|
-
target: "attestationFailureRecoverable",
|
|
2912
|
-
actions: ["assignErrorCreatingAttestations", "handleError"]
|
|
2913
|
-
}
|
|
2914
|
-
} },
|
|
2915
|
-
attestationFailureRecoverable: { on: { retry: {
|
|
2916
|
-
target: "creatingAttestations",
|
|
2917
|
-
actions: ["assignAccountFromRetry"]
|
|
2918
|
-
} } },
|
|
2919
|
-
creatingAttestationsDirectToEas: { invoke: {
|
|
2920
|
-
src: "createAttestationsDirectToEas",
|
|
2921
|
-
input: ({ context: e, event: t }) => ({
|
|
2922
|
-
context: e,
|
|
2923
|
-
event: t
|
|
2924
|
-
}),
|
|
2925
|
-
onDone: {
|
|
2926
|
-
target: Sa,
|
|
2927
|
-
actions: F({
|
|
2928
|
-
easPayload: ({ event: e }) => e.output?.easPayload,
|
|
2929
|
-
publishedBatch: ({ event: e }) => e.output?.publishedBatch ?? null
|
|
2930
|
-
})
|
|
2931
|
-
},
|
|
2932
|
-
onError: {
|
|
2933
|
-
target: "attestationFailureRecoverableDirectToEas",
|
|
2934
|
-
actions: ["assignErrorCreatingAttestationsDirectToEas", "handleError"]
|
|
2935
|
-
}
|
|
2936
|
-
} },
|
|
2937
|
-
attestationFailureRecoverableDirectToEas: { on: { retry: {
|
|
2938
|
-
target: "creatingAttestationsDirectToEas",
|
|
2939
|
-
actions: ["assignAccountFromRetry"]
|
|
2940
|
-
} } },
|
|
2941
|
-
stopping: {
|
|
2942
|
-
entry: ({ context: e }) => {
|
|
2943
|
-
console.log(`Actor for ${e.item?.seedLocalId} stopped`);
|
|
2944
|
-
},
|
|
2945
|
-
type: "final"
|
|
2946
|
-
},
|
|
2947
|
-
[Sa]: {
|
|
2948
|
-
entry: ({ context: e }) => {
|
|
2949
|
-
let t = e.publishedBatch, n = e.onPublished;
|
|
2950
|
-
if (!n || !t?.seedUid) return;
|
|
2951
|
-
let r = e.item?.seedLocalId;
|
|
2952
|
-
r && Promise.resolve(n({
|
|
2953
|
-
seedLocalId: r,
|
|
2954
|
-
seedUid: t.seedUid,
|
|
2955
|
-
versionUid: t.versionUid,
|
|
2956
|
-
attestationUids: t.attestationUids
|
|
2957
|
-
})).catch((e) => {
|
|
2958
|
-
console.warn("[publish] onPublished callback failed:", e);
|
|
2959
|
-
});
|
|
2960
|
-
},
|
|
2961
|
-
type: "final"
|
|
2962
|
-
},
|
|
2963
|
-
[Z]: {
|
|
2964
|
-
entry: ({ context: e }) => {},
|
|
2965
|
-
type: "final"
|
|
2966
|
-
}
|
|
2967
|
-
}
|
|
2968
|
-
}), Ea = F(({ context: e, event: t }) => {
|
|
2969
|
-
let n = t, r = n.publishProcesses ?? /* @__PURE__ */ new Map(), i = n.subscriptions ?? /* @__PURE__ */ new Map();
|
|
2970
|
-
return {
|
|
2971
|
-
publishProcesses: new Map(r),
|
|
2972
|
-
subscriptions: new Map(i)
|
|
2973
|
-
};
|
|
2974
|
-
}), Da = null;
|
|
2975
|
-
function Oa(e) {
|
|
2976
|
-
Da = e;
|
|
2977
|
-
}
|
|
2978
|
-
function ka() {
|
|
2979
|
-
return Da;
|
|
2980
|
-
}
|
|
2981
|
-
//#endregion
|
|
2982
|
-
//#region src/services/publishManager/actors/subscribe.ts
|
|
2983
|
-
var Aa = L("seedProtocol:services:PublishManager:actors:subscribe");
|
|
2984
|
-
function ja(e) {
|
|
2985
|
-
let t = e.value;
|
|
2986
|
-
return typeof t == "string" ? t : t && typeof t == "object" ? Object.keys(t)[0] ?? "" : "";
|
|
2987
|
-
}
|
|
2988
|
-
function Ma(e) {
|
|
2989
|
-
return a.includes(e);
|
|
2990
|
-
}
|
|
2991
|
-
var Na = Lt(({ receive: e, input: { publishProcess: n, seedLocalId: r } }) => {
|
|
2992
|
-
let i = ka(), a = null, o = () => {
|
|
2993
|
-
a != null && (clearInterval(a), a = null);
|
|
2994
|
-
}, s = (e) => {
|
|
2995
|
-
let s = ja(e);
|
|
2996
|
-
Ma(s) && a == null && i ? a = setInterval(() => {
|
|
2997
|
-
try {
|
|
2998
|
-
let e = n.getSnapshot();
|
|
2999
|
-
if (e.status === "done" || !Ma(ja(e))) {
|
|
3000
|
-
o();
|
|
3001
|
-
return;
|
|
3002
|
-
}
|
|
3003
|
-
} catch {
|
|
3004
|
-
return;
|
|
3005
|
-
}
|
|
3006
|
-
i?.savePublish(r, n);
|
|
3007
|
-
}, t) : Ma(s) || o();
|
|
3008
|
-
}, c = n.subscribe(async (e) => {
|
|
3009
|
-
Aa("Publish state:", e.value), i && (e.status === "done" ? (o(), i.savePublish(r, n, { triggerPublishDone: !0 })) : (i.savePublish(r, n), s(e)));
|
|
3010
|
-
});
|
|
3011
|
-
e(({ type: e }) => {
|
|
3012
|
-
e === "UNSUBSCRIBE" && (Aa("Received UNSUBSCRIBE event"), o(), c.unsubscribe(), i?.removeSubscription(r));
|
|
3013
|
-
});
|
|
3014
|
-
}), Pa = /* @__PURE__ */ new Map(), Fa = 1;
|
|
3015
|
-
function Ia(e) {
|
|
3016
|
-
let t = Fa++;
|
|
3017
|
-
return Pa.set(t, e), t;
|
|
3018
|
-
}
|
|
3019
|
-
function La(e, t) {
|
|
3020
|
-
if (e == null) return;
|
|
3021
|
-
let n = Pa.get(e);
|
|
3022
|
-
n && (Pa.delete(e), n(t));
|
|
3023
|
-
}
|
|
3024
|
-
//#endregion
|
|
3025
|
-
//#region src/services/publishManager/actions/createPublish.ts
|
|
3026
|
-
function Ra(e) {
|
|
3027
|
-
if (e) {
|
|
3028
|
-
if (i(e)) return e;
|
|
3029
|
-
if (m(e)) {
|
|
3030
|
-
let t = pe();
|
|
3031
|
-
if (t && t.signer.address.toLowerCase() === e.address.toLowerCase()) return t;
|
|
3032
|
-
throw Error("@seedprotocol/publish: createPublish requires a PublishWallet (signer + txSender). Use fromEthersWallet, fromEip1193Provider, or fromThirdwebAccount.");
|
|
3033
|
-
}
|
|
3034
|
-
throw Error("@seedprotocol/publish: createPublish account must be a PublishWallet. Thirdweb Account must be wrapped with fromThirdwebAccount from @seedprotocol/publish/thirdweb.");
|
|
3035
|
-
}
|
|
3036
|
-
}
|
|
3037
|
-
function za(e) {
|
|
3038
|
-
if (e) {
|
|
3039
|
-
if (e instanceof P.Wallet) return e;
|
|
3040
|
-
if (i(e)) return e.signer;
|
|
3041
|
-
if (m(e)) return e;
|
|
3042
|
-
}
|
|
3043
|
-
}
|
|
3044
|
-
var Ba = It(({ event: e, enqueue: t }) => {
|
|
3045
|
-
let { item: n, address: r, account: i, options: a, createToken: o } = e;
|
|
3046
|
-
r != null && typeof r == "string" && r.trim().length > 0 ? (t.assign(({ context: e, spawn: t }) => {
|
|
3047
|
-
let { publishProcesses: s } = e;
|
|
3048
|
-
if (s && s.has(n.seedLocalId)) return console.warn(`Publish process with seedLocalId "${n.seedLocalId}" already exists.`), La(o, void 0), e;
|
|
3049
|
-
let c = typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `run_${Date.now()}_${Math.random().toString(36).slice(2, 11)}`, l = D(), u = [...l.arweaveUploadTags ?? [], ...a?.arweaveUploadTags ?? []], d = Ra(i) ?? pe() ?? void 0, f = t(Ta, { input: {
|
|
3050
|
-
item: n,
|
|
3051
|
-
address: r,
|
|
3052
|
-
wallet: d,
|
|
3053
|
-
account: d,
|
|
3054
|
-
modelName: n.modelName,
|
|
3055
|
-
schemaId: n.schemaUid,
|
|
3056
|
-
signDataItems: a?.signDataItems,
|
|
3057
|
-
dataItemSigner: za(a?.dataItemSigner),
|
|
3058
|
-
signArweaveTransactions: a?.signArweaveTransactions,
|
|
3059
|
-
arweaveJwk: a?.arweaveJwk,
|
|
3060
|
-
publishMode: a?.publishMode ?? "patch",
|
|
3061
|
-
publishRunId: c,
|
|
3062
|
-
arweaveUploadTags: u.length ? u : void 0,
|
|
3063
|
-
htmlEmbeddedDataUriPolicy: a?.htmlEmbeddedDataUriPolicy ?? l.htmlEmbeddedDataUriPolicy ?? "materialize",
|
|
3064
|
-
onPublished: a?.onPublished ?? l.onPublished
|
|
3065
|
-
} });
|
|
3066
|
-
s.set(n.seedLocalId, f);
|
|
3067
|
-
let p = new Map(e.settledPublishes);
|
|
3068
|
-
return p.delete(n.seedLocalId), La(o, f), {
|
|
3069
|
-
...e,
|
|
3070
|
-
publishProcesses: s,
|
|
3071
|
-
settledPublishes: p
|
|
3072
|
-
};
|
|
3073
|
-
}), t.assign(({ context: e, spawn: t }) => {
|
|
3074
|
-
let { subscriptions: r, publishProcesses: i } = e, a = i.get(n.seedLocalId);
|
|
3075
|
-
if (!a) return console.warn(`Publish process with seedLocalId "${n.seedLocalId}" does not exist.`), e;
|
|
3076
|
-
if (r.has(n.seedLocalId)) return console.warn(`Subscription with seedLocalId "${n.seedLocalId}" already exists.`), e;
|
|
3077
|
-
let o = t(Na, { input: {
|
|
3078
|
-
publishProcess: a,
|
|
3079
|
-
seedLocalId: n.seedLocalId
|
|
3080
|
-
} });
|
|
3081
|
-
return r.set(n.seedLocalId, o), {
|
|
3082
|
-
...e,
|
|
3083
|
-
subscriptions: new Map(r)
|
|
3084
|
-
};
|
|
3085
|
-
})) : (console.warn("[createPublish] No valid wallet address; skipping spawn."), La(o, void 0));
|
|
3086
|
-
}), Va = ({ context: e, event: t }) => {
|
|
3087
|
-
let { seedLocalId: n, account: r } = t, a = e.publishProcesses.get(n);
|
|
3088
|
-
if (!a) {
|
|
3089
|
-
console.warn(`Publish process with seedLocalId "${n}" does not exist.`);
|
|
3090
|
-
return;
|
|
3091
|
-
}
|
|
3092
|
-
let o = r == null ? pe() ?? void 0 : i(r) ? r : void 0;
|
|
3093
|
-
r != null && !o && console.warn("[retryAttestations] account must be a PublishWallet. Use fromThirdwebAccount / fromEip1193Provider / fromEthersWallet."), a.send({
|
|
3094
|
-
type: "retry",
|
|
3095
|
-
account: o,
|
|
3096
|
-
wallet: o
|
|
3097
|
-
});
|
|
3098
|
-
};
|
|
3099
|
-
//#endregion
|
|
3100
|
-
//#region src/services/publishManager/actions/stopScopedOrStandaloneChild.ts
|
|
3101
|
-
function Ha(e, t, n) {
|
|
3102
|
-
t._parent === e ? n.stopChild(t) : t.stop();
|
|
3103
|
-
}
|
|
3104
|
-
//#endregion
|
|
3105
|
-
//#region src/services/publishManager/actors/savePublish.ts
|
|
3106
|
-
var Ua = L("seedProtocol:services:PublishManager:actors:savePublish"), Wa = /* @__PURE__ */ new Map();
|
|
3107
|
-
function Ga(e, t) {
|
|
3108
|
-
let n = (Wa.get(e) ?? Promise.resolve()).then(t);
|
|
3109
|
-
return Wa.set(e, n.catch(() => {})), n;
|
|
3110
|
-
}
|
|
3111
|
-
function Ka(e) {
|
|
3112
|
-
return e === "completed" || e === "failed" || e === "interrupted";
|
|
3113
|
-
}
|
|
3114
|
-
function qa(e) {
|
|
3115
|
-
return e.status === "done" ? e.value === "success" ? "completed" : e.value === "failure" ? "failed" : "completed" : "in_progress";
|
|
3116
|
-
}
|
|
3117
|
-
var Ja = 500, Ya = 2e3, Xa = 100;
|
|
3118
|
-
function Za(e) {
|
|
3119
|
-
return JSON.stringify(e, (e, t) => typeof t == "bigint" ? t.toString() : t);
|
|
3120
|
-
}
|
|
3121
|
-
function Qa(e) {
|
|
3122
|
-
if (typeof e != "object" || !e) return;
|
|
3123
|
-
let t = e, n = t.snapshot, r = (t.context ?? n?.context)?.publishRunId;
|
|
3124
|
-
return typeof r == "string" && r.length > 0 ? r : void 0;
|
|
3125
|
-
}
|
|
3126
|
-
function $a(e) {
|
|
3127
|
-
if (e instanceof Error) return e.message;
|
|
3128
|
-
if (typeof e == "object") {
|
|
3129
|
-
let t = e.message;
|
|
3130
|
-
return typeof t == "string" ? t : void 0;
|
|
3131
|
-
}
|
|
3132
|
-
return String(e);
|
|
3133
|
-
}
|
|
3134
|
-
function eo(e) {
|
|
3135
|
-
if (typeof e != "object" || !e) return;
|
|
3136
|
-
let t = e.code;
|
|
3137
|
-
return typeof t == "string" && t.length > 0 ? t.slice(0, Xa) : void 0;
|
|
3138
|
-
}
|
|
3139
|
-
function to(e, t) {
|
|
3140
|
-
if (!e?.error || t !== "failed" && t !== "in_progress") return {};
|
|
3141
|
-
let n = e.error, r = $a(n)?.slice(0, Ja), i = e.errorStep, a = eo(n), o;
|
|
3142
|
-
if (n instanceof Error && n.stack) o = n.stack.slice(0, Ya);
|
|
3143
|
-
else if (typeof n == "object" && n) try {
|
|
3144
|
-
o = JSON.stringify(n).slice(0, Ya);
|
|
3145
|
-
} catch {
|
|
3146
|
-
o = String(n).slice(0, Ya);
|
|
3147
|
-
}
|
|
3148
|
-
else n != null && (o = String(n).slice(0, Ya));
|
|
3149
|
-
return {
|
|
3150
|
-
...r === void 0 ? {} : { errorMessage: r },
|
|
3151
|
-
errorStep: i,
|
|
3152
|
-
...n instanceof Error || r !== void 0 ? { errorDetails: o } : {},
|
|
3153
|
-
errorCode: a ?? null
|
|
3154
|
-
};
|
|
3155
|
-
}
|
|
3156
|
-
function no(e) {
|
|
3157
|
-
return Ga(e, async () => {
|
|
3158
|
-
let t = ke.getAppDb();
|
|
3159
|
-
if (!t) {
|
|
3160
|
-
Ua("markInProgressPublishInterrupted: DB not ready, skipping");
|
|
3161
|
-
return;
|
|
3162
|
-
}
|
|
3163
|
-
let n = await t.select().from(N).where(Wt(R(N.seedLocalId, e), R(N.status, "in_progress"))).orderBy(Gt(N.updatedAt)).limit(1);
|
|
3164
|
-
if (n.length === 0) return;
|
|
3165
|
-
let r = Date.now();
|
|
3166
|
-
await t.update(N).set({
|
|
3167
|
-
status: "interrupted",
|
|
3168
|
-
completedAt: r,
|
|
3169
|
-
updatedAt: r,
|
|
3170
|
-
errorMessage: null,
|
|
3171
|
-
errorStep: null,
|
|
3172
|
-
errorDetails: null,
|
|
3173
|
-
errorCode: null
|
|
3174
|
-
}).where(R(N.id, n[0].id));
|
|
3175
|
-
});
|
|
3176
|
-
}
|
|
3177
|
-
var ro = Lt(({ sendBack: e, input: { persistedSnapshot: t, seedLocalId: n, triggerPublishDone: r } }) => {
|
|
3178
|
-
Ua("savePublish seedLocalId", n);
|
|
3179
|
-
let i = t;
|
|
3180
|
-
Ga(n, async () => {
|
|
3181
|
-
let a = ke.getAppDb();
|
|
3182
|
-
if (!a) {
|
|
3183
|
-
Ua("savePublish: DB not ready, skipping"), e({
|
|
3184
|
-
type: "SAVE_PUBLISH_DONE",
|
|
3185
|
-
seedLocalId: n,
|
|
3186
|
-
triggerPublishDone: r
|
|
3187
|
-
});
|
|
3188
|
-
return;
|
|
3189
|
-
}
|
|
3190
|
-
let o = await a.select().from(N).where(Wt(R(N.seedLocalId, n), R(N.status, "in_progress"))).orderBy(Gt(N.updatedAt)).limit(1), s = typeof t == "string" ? t : Za(t), c = qa(i), l = Date.now(), u = to(i.context, c);
|
|
3191
|
-
if (o.length > 0) {
|
|
3192
|
-
let e = o[0];
|
|
3193
|
-
await a.update(N).set({
|
|
3194
|
-
persistedSnapshot: s,
|
|
3195
|
-
status: c,
|
|
3196
|
-
updatedAt: l,
|
|
3197
|
-
...i.status === "done" && c !== "in_progress" ? { completedAt: l } : {},
|
|
3198
|
-
...u
|
|
3199
|
-
}).where(R(N.id, e.id));
|
|
3200
|
-
} else {
|
|
3201
|
-
let e = Qa(i);
|
|
3202
|
-
if (e != null && c === "in_progress" && i.status !== "done") {
|
|
3203
|
-
let t = (await a.select().from(N).where(R(N.seedLocalId, n)).orderBy(Gt(N.startedAt)).limit(1))[0];
|
|
3204
|
-
if (t && Ka(t.status)) try {
|
|
3205
|
-
if (Qa(JSON.parse(t.persistedSnapshot)) === e) {
|
|
3206
|
-
Ua("savePublish: skip stale insert — same publishRunId as latest terminal row", n, e);
|
|
3207
|
-
return;
|
|
3208
|
-
}
|
|
3209
|
-
} catch {}
|
|
3210
|
-
}
|
|
3211
|
-
let t = i.context?.item, r = i.context?.modelName ?? t?.modelName ?? "", o = i.context?.schemaId ?? t?.schemaId;
|
|
3212
|
-
await a.insert(N).values({
|
|
3213
|
-
seedLocalId: n,
|
|
3214
|
-
modelName: r,
|
|
3215
|
-
schemaId: o ?? null,
|
|
3216
|
-
status: c,
|
|
3217
|
-
startedAt: l,
|
|
3218
|
-
persistedSnapshot: s,
|
|
3219
|
-
createdAt: l,
|
|
3220
|
-
updatedAt: l,
|
|
3221
|
-
...u
|
|
3222
|
-
});
|
|
3223
|
-
}
|
|
3224
|
-
}).then(() => {
|
|
3225
|
-
e({
|
|
3226
|
-
type: "SAVE_PUBLISH_DONE",
|
|
3227
|
-
seedLocalId: n,
|
|
3228
|
-
triggerPublishDone: r
|
|
3229
|
-
});
|
|
3230
|
-
}).catch((t) => {
|
|
3231
|
-
Ua("savePublish error", t), e({
|
|
3232
|
-
type: "SAVE_PUBLISH_DONE",
|
|
3233
|
-
seedLocalId: n,
|
|
3234
|
-
triggerPublishDone: r
|
|
3235
|
-
});
|
|
3236
|
-
});
|
|
3237
|
-
}), io = L("seedProtocol:PublishManager:publishLocks"), ao = () => typeof navigator < "u" ? navigator.locks : void 0, oo = /* @__PURE__ */ new Map();
|
|
3238
|
-
function so(e) {
|
|
3239
|
-
return `seed:publish:${e}`;
|
|
3240
|
-
}
|
|
3241
|
-
async function co(e) {
|
|
3242
|
-
if (oo.has(e)) return !0;
|
|
3243
|
-
let t = ao();
|
|
3244
|
-
return !t || new Promise((n, r) => {
|
|
3245
|
-
t.request(so(e), {
|
|
3246
|
-
mode: "exclusive",
|
|
3247
|
-
ifAvailable: !0
|
|
3248
|
-
}, (t) => {
|
|
3249
|
-
if (!t) n(!1);
|
|
3250
|
-
else return new Promise((t) => {
|
|
3251
|
-
oo.set(e, () => {
|
|
3252
|
-
oo.delete(e), t();
|
|
3253
|
-
}), n(!0);
|
|
3254
|
-
});
|
|
3255
|
-
}).catch((t) => {
|
|
3256
|
-
io(`publish lock request for ${e} failed`, t), r(t);
|
|
3257
|
-
});
|
|
3258
|
-
});
|
|
3259
|
-
}
|
|
3260
|
-
function lo(e) {
|
|
3261
|
-
oo.get(e)?.();
|
|
3262
|
-
}
|
|
3263
|
-
function uo() {
|
|
3264
|
-
for (let e of [...oo.values()]) e();
|
|
3265
|
-
}
|
|
3266
|
-
function fo(e) {
|
|
3267
|
-
return oo.has(e);
|
|
3268
|
-
}
|
|
3269
|
-
//#endregion
|
|
3270
|
-
//#region src/services/publishManager/actions/stopPublish.ts
|
|
3271
|
-
var po = It(({ context: e, event: t, enqueue: n, self: r }) => {
|
|
3272
|
-
let { publishProcesses: i, subscriptions: a } = e, { seedLocalId: o } = t;
|
|
3273
|
-
no(o).catch((e) => {
|
|
3274
|
-
console.warn(`[stopPublish] Failed to mark publish_processes row interrupted for "${o}":`, e);
|
|
3275
|
-
}), lo(o);
|
|
3276
|
-
let s = i.get(o);
|
|
3277
|
-
if (!s) {
|
|
3278
|
-
console.warn(`Publish process with seedLocalId "${o}" does not exist.`);
|
|
3279
|
-
return;
|
|
3280
|
-
}
|
|
3281
|
-
Ha(r, s, n);
|
|
3282
|
-
let c = a.get(o);
|
|
3283
|
-
c && Ha(r, c, n);
|
|
3284
|
-
let l = new Map(i);
|
|
3285
|
-
l.delete(o);
|
|
3286
|
-
let u = new Map(a);
|
|
3287
|
-
u.delete(o), n.assign({
|
|
3288
|
-
publishProcesses: l,
|
|
3289
|
-
subscriptions: u
|
|
3290
|
-
});
|
|
3291
|
-
}), mo = L("seedProtocol:PublishManager:index"), ho = It(({ context: e, enqueue: t, self: n }) => {
|
|
3292
|
-
mo("Stopping all actors..."), e.publishProcesses.forEach((e) => {
|
|
3293
|
-
Ha(n, e, t);
|
|
3294
|
-
}), e.subscriptions.forEach((e) => {
|
|
3295
|
-
Ha(n, e, t);
|
|
3296
|
-
}), uo(), t.assign({
|
|
3297
|
-
publishProcesses: /* @__PURE__ */ new Map(),
|
|
3298
|
-
subscriptions: /* @__PURE__ */ new Map()
|
|
3299
|
-
});
|
|
3300
|
-
}), go = It(({ context: e, event: t, enqueue: n }) => {
|
|
3301
|
-
let { seedLocalId: r } = t, i = e.publishProcesses.get(r);
|
|
3302
|
-
if (!i) {
|
|
3303
|
-
console.warn(`Publish process with seedLocalId "${r}" does not exist.`);
|
|
3304
|
-
return;
|
|
3305
|
-
}
|
|
3306
|
-
n.stopChild(i);
|
|
3307
|
-
let a = e.subscriptions.get(r);
|
|
3308
|
-
a && n.stopChild(a);
|
|
3309
|
-
let o = new Map(e.publishProcesses);
|
|
3310
|
-
o.delete(r);
|
|
3311
|
-
let s = new Map(e.subscriptions);
|
|
3312
|
-
s.delete(r), n.assign({
|
|
3313
|
-
publishProcesses: o,
|
|
3314
|
-
subscriptions: s
|
|
3315
|
-
});
|
|
3316
|
-
}), _o = F(({ context: e, event: t }) => {
|
|
3317
|
-
let { subscriptions: n } = e, { seedLocalId: r, newSubscription: i } = t;
|
|
3318
|
-
return i && n.set(r, i), { subscriptions: new Map(n) };
|
|
3319
|
-
}), vo = ["signedDataItems", "arweaveUploadData"];
|
|
3320
|
-
function yo(e) {
|
|
3321
|
-
if (typeof e != "object" || !e) return e;
|
|
3322
|
-
let t = { ...e };
|
|
3323
|
-
for (let e of vo) delete t[e];
|
|
3324
|
-
return t;
|
|
3325
|
-
}
|
|
3326
|
-
function bo(e) {
|
|
3327
|
-
if (typeof e != "object" || !e) return e;
|
|
3328
|
-
let t = e, n = { ...t };
|
|
3329
|
-
t.context != null && typeof t.context == "object" && (n.context = yo(t.context));
|
|
3330
|
-
let r = t.snapshot;
|
|
3331
|
-
if (typeof r == "object" && r) {
|
|
3332
|
-
let e = r, t = { ...e };
|
|
3333
|
-
e.context != null && typeof e.context == "object" && (t.context = yo(e.context)), n.snapshot = t;
|
|
3334
|
-
}
|
|
3335
|
-
return n;
|
|
3336
|
-
}
|
|
3337
|
-
function xo(e) {
|
|
3338
|
-
try {
|
|
3339
|
-
return bo(e.getPersistedSnapshot?.() ?? e.getSnapshot());
|
|
3340
|
-
} catch {
|
|
3341
|
-
let t = e.getSnapshot(), n = t.context;
|
|
3342
|
-
if (!n?.item) return bo(t);
|
|
3343
|
-
let r = n.item;
|
|
3344
|
-
return bo({
|
|
3345
|
-
...t,
|
|
3346
|
-
context: {
|
|
3347
|
-
...n,
|
|
3348
|
-
item: {
|
|
3349
|
-
seedLocalId: r.seedLocalId,
|
|
3350
|
-
modelName: r.modelName,
|
|
3351
|
-
schemaId: r.schemaId
|
|
3352
|
-
}
|
|
3353
|
-
}
|
|
3354
|
-
});
|
|
3355
|
-
}
|
|
3356
|
-
}
|
|
3357
|
-
var So = F(({ context: e, event: t, spawn: n }) => {
|
|
3358
|
-
let { publishProcesses: r } = e, { seedLocalId: i, publishProcess: a, triggerPublishDone: o } = t;
|
|
3359
|
-
if (!a) return e;
|
|
3360
|
-
let s = new Map(r);
|
|
3361
|
-
s.set(i, a);
|
|
3362
|
-
let c = xo(a);
|
|
3363
|
-
return n(ro, {
|
|
3364
|
-
id: `savePublish_${i}_${Date.now()}`,
|
|
3365
|
-
input: {
|
|
3366
|
-
persistedSnapshot: c,
|
|
3367
|
-
seedLocalId: i,
|
|
3368
|
-
triggerPublishDone: o
|
|
3369
|
-
}
|
|
3370
|
-
}), { publishProcesses: s };
|
|
3371
|
-
}), Co = F(({ context: e, event: t }) => {
|
|
3372
|
-
let { publishProcesses: n, subscriptions: r, settledPublishes: i } = e, a = t.seedLocalId;
|
|
3373
|
-
lo(a);
|
|
3374
|
-
let o = r.get(a);
|
|
3375
|
-
o && o.send({ type: "UNSUBSCRIBE" });
|
|
3376
|
-
let s = n.get(a), c = new Map(n);
|
|
3377
|
-
c.delete(a);
|
|
3378
|
-
let l = new Map(r);
|
|
3379
|
-
l.delete(a);
|
|
3380
|
-
let u = new Map(i);
|
|
3381
|
-
return s && u.set(a, s), {
|
|
3382
|
-
publishProcesses: c,
|
|
3383
|
-
subscriptions: l,
|
|
3384
|
-
settledPublishes: u
|
|
3385
|
-
};
|
|
3386
|
-
}), wo = F(({ context: e, event: t }) => {
|
|
3387
|
-
let { subscriptions: n } = e, r = t.seedLocalId, i = new Map(n);
|
|
3388
|
-
return i.delete(r), { subscriptions: i };
|
|
3389
|
-
}), To = 6e4, Eo = 2e3;
|
|
3390
|
-
function Do(e, t) {
|
|
3391
|
-
let n = typeof process < "u" ? process.env[e] : void 0;
|
|
3392
|
-
if (n == null || n === "") return t;
|
|
3393
|
-
let r = Number(n);
|
|
3394
|
-
return Number.isFinite(r) && r >= 0 ? r : t;
|
|
3395
|
-
}
|
|
3396
|
-
async function Oo(e, t) {
|
|
3397
|
-
let n = Date.now() + e;
|
|
3398
|
-
for (; Date.now() < n;) {
|
|
3399
|
-
try {
|
|
3400
|
-
if (ke.isAppDbReady() && ke.getAppDb()) return !0;
|
|
3401
|
-
} catch {}
|
|
3402
|
-
await new Promise((e) => setTimeout(e, t));
|
|
3403
|
-
}
|
|
3404
|
-
return !1;
|
|
3405
|
-
}
|
|
3406
|
-
function ko(e) {
|
|
3407
|
-
let t = e.value;
|
|
3408
|
-
return typeof t == "string" ? t : t && typeof t == "object" ? Object.keys(t)[0] ?? "" : "";
|
|
3409
|
-
}
|
|
3410
|
-
function Ao(e) {
|
|
3411
|
-
let t = ko(e);
|
|
3412
|
-
if (t === "pollingForConfirmation" && (!e.context?.reimbursementTransactionId || !e.context?.requestResponse)) return !1;
|
|
3413
|
-
if (t === "uploadingData") {
|
|
3414
|
-
let t = e.context?.arweaveTransactions, n = e.context?.publishUploads;
|
|
3415
|
-
if (!Array.isArray(t) || t.length === 0 || !Array.isArray(n)) return !1;
|
|
3416
|
-
}
|
|
3417
|
-
return !0;
|
|
3418
|
-
}
|
|
3419
|
-
function jo(e) {
|
|
3420
|
-
return typeof e == "object" && !!e && "xstate$$type" in e && e.xstate$$type === 1 && typeof e.id == "string";
|
|
3421
|
-
}
|
|
3422
|
-
function Mo(e, t, n) {
|
|
3423
|
-
e.context = e.context ?? {};
|
|
3424
|
-
let r = e.context.item;
|
|
3425
|
-
jo(r) ? e.context.item = {
|
|
3426
|
-
seedLocalId: t,
|
|
3427
|
-
modelName: e.context.modelName ?? n.modelName ?? "",
|
|
3428
|
-
schemaId: e.context.schemaId ?? n.schemaId ?? void 0
|
|
3429
|
-
} : e.context.item = {
|
|
3430
|
-
...typeof r == "object" && r && !Array.isArray(r) ? r : {},
|
|
3431
|
-
seedLocalId: t,
|
|
3432
|
-
modelName: r?.modelName ?? e.context.modelName ?? n.modelName ?? "",
|
|
3433
|
-
schemaId: r?.schemaId ?? e.context.schemaId ?? n.schemaId ?? void 0
|
|
3434
|
-
};
|
|
3435
|
-
}
|
|
3436
|
-
var No = Lt(({ sendBack: e, input: { context: t } }) => {
|
|
3437
|
-
let n = async () => {
|
|
3438
|
-
let e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map();
|
|
3439
|
-
if (!await Oo(Do("SEED_PUBLISH_RESTORE_WAIT_MS", To), Do("SEED_PUBLISH_RESTORE_POLL_MS", Eo))) return {
|
|
3440
|
-
newPublishProcesses: e,
|
|
3441
|
-
newSubscriptions: t
|
|
3442
|
-
};
|
|
3443
|
-
let n = ke.getAppDb();
|
|
3444
|
-
if (!n) return {
|
|
3445
|
-
newPublishProcesses: e,
|
|
3446
|
-
newSubscriptions: t
|
|
3447
|
-
};
|
|
3448
|
-
let r = await n.select().from(N).where(R(N.status, "in_progress")), i = /* @__PURE__ */ new Map(), a = [...r].sort((e, t) => (t.updatedAt ?? t.createdAt ?? 0) - (e.updatedAt ?? e.createdAt ?? 0));
|
|
3449
|
-
for (let e of a) i.has(e.seedLocalId) || i.set(e.seedLocalId, e);
|
|
3450
|
-
let o = Array.from(i.values());
|
|
3451
|
-
for (let n of o) {
|
|
3452
|
-
let r;
|
|
3453
|
-
try {
|
|
3454
|
-
r = JSON.parse(n.persistedSnapshot);
|
|
3455
|
-
} catch {
|
|
3456
|
-
continue;
|
|
3457
|
-
}
|
|
3458
|
-
if (r.status === "done") continue;
|
|
3459
|
-
let i = r.context?.item?.seedLocalId ?? n.seedLocalId;
|
|
3460
|
-
if (!i || !Ao(r) || !await co(i)) continue;
|
|
3461
|
-
Mo(r, i, n);
|
|
3462
|
-
let a = Ft(Ta, {
|
|
3463
|
-
snapshot: r,
|
|
3464
|
-
input: void 0
|
|
3465
|
-
}), o = Ft(Na, { input: {
|
|
3466
|
-
publishProcess: a,
|
|
3467
|
-
seedLocalId: i
|
|
3468
|
-
} });
|
|
3469
|
-
e.set(i, a), t.set(i, o), a.start(), o.start();
|
|
3470
|
-
}
|
|
3471
|
-
return {
|
|
3472
|
-
newPublishProcesses: e,
|
|
3473
|
-
newSubscriptions: t
|
|
3474
|
-
};
|
|
3475
|
-
}, r = () => ({
|
|
3476
|
-
newPublishProcesses: /* @__PURE__ */ new Map(),
|
|
3477
|
-
newSubscriptions: /* @__PURE__ */ new Map()
|
|
3478
|
-
});
|
|
3479
|
-
n().then((t) => {
|
|
3480
|
-
let { newPublishProcesses: n, newSubscriptions: i } = t ?? r();
|
|
3481
|
-
e({
|
|
3482
|
-
type: "RESTORE_FROM_DB_DONE",
|
|
3483
|
-
publishProcesses: n,
|
|
3484
|
-
subscriptions: i
|
|
3485
|
-
});
|
|
3486
|
-
}).catch(() => {
|
|
3487
|
-
let { newPublishProcesses: t, newSubscriptions: n } = r();
|
|
3488
|
-
e({
|
|
3489
|
-
type: "RESTORE_FROM_DB_DONE",
|
|
3490
|
-
publishProcesses: t,
|
|
3491
|
-
subscriptions: n
|
|
3492
|
-
});
|
|
3493
|
-
});
|
|
3494
|
-
}), Po = F(({ context: e, event: t }) => ({ pendingCreates: [...e.pendingCreates ?? [], t] })), Fo = It(({ context: e, enqueue: t }) => {
|
|
3495
|
-
let n = e.pendingCreates ?? [];
|
|
3496
|
-
if (n.length !== 0) {
|
|
3497
|
-
t.assign({ pendingCreates: [] });
|
|
3498
|
-
for (let e of n) t.raise(e);
|
|
3499
|
-
}
|
|
3500
|
-
}), Io = L("seedProtocol:PublishManager:index"), Lo = Rt({
|
|
3501
|
-
types: {
|
|
3502
|
-
context: {},
|
|
3503
|
-
input: {},
|
|
3504
|
-
events: {}
|
|
3505
|
-
},
|
|
3506
|
-
actors: { restoreFromDb: No },
|
|
3507
|
-
actions: {
|
|
3508
|
-
assignRestoreFromDb: Ea,
|
|
3509
|
-
createPublish: Ba,
|
|
3510
|
-
queueCreatePublish: Po,
|
|
3511
|
-
drainPendingCreates: Fo,
|
|
3512
|
-
addSubscription: _o,
|
|
3513
|
-
requestSavePublish: So,
|
|
3514
|
-
publishDone: Co,
|
|
3515
|
-
removeSubscription: wo,
|
|
3516
|
-
retryAttestations: Va,
|
|
3517
|
-
stopPublish: po,
|
|
3518
|
-
stopAll: ho,
|
|
3519
|
-
query: go
|
|
3520
|
-
}
|
|
3521
|
-
}).createMachine({
|
|
3522
|
-
id: "publishManager",
|
|
3523
|
-
initial: "restoreFromDb",
|
|
3524
|
-
context: {
|
|
3525
|
-
publishProcesses: /* @__PURE__ */ new Map(),
|
|
3526
|
-
subscriptions: /* @__PURE__ */ new Map(),
|
|
3527
|
-
pendingCreates: [],
|
|
3528
|
-
settledPublishes: /* @__PURE__ */ new Map()
|
|
3529
|
-
},
|
|
3530
|
-
states: {
|
|
3531
|
-
restoreFromDb: {
|
|
3532
|
-
on: {
|
|
3533
|
-
RESTORE_FROM_DB_DONE: {
|
|
3534
|
-
target: "active",
|
|
3535
|
-
actions: ["assignRestoreFromDb"]
|
|
3536
|
-
},
|
|
3537
|
-
CREATE_PUBLISH: { actions: ["queueCreatePublish"] }
|
|
3538
|
-
},
|
|
3539
|
-
invoke: {
|
|
3540
|
-
src: "restoreFromDb",
|
|
3541
|
-
input: ({ context: e }) => ({ context: e })
|
|
3542
|
-
}
|
|
3543
|
-
},
|
|
3544
|
-
active: {
|
|
3545
|
-
entry: "drainPendingCreates",
|
|
3546
|
-
on: {
|
|
3547
|
-
CREATE_PUBLISH: { actions: ["createPublish"] },
|
|
3548
|
-
ADD_SUBSCRIPTION: { actions: ["addSubscription"] },
|
|
3549
|
-
REQUEST_SAVE_PUBLISH: { actions: ["requestSavePublish"] },
|
|
3550
|
-
SAVE_PUBLISH_DONE: [{
|
|
3551
|
-
guard: ({ event: e }) => e.triggerPublishDone === !0,
|
|
3552
|
-
actions: ["publishDone"]
|
|
3553
|
-
}],
|
|
3554
|
-
PUBLISH_DONE: { actions: ["publishDone"] },
|
|
3555
|
-
REMOVE_SUBSCRIPTION: { actions: ["removeSubscription"] },
|
|
3556
|
-
RETRY_ATTESTATIONS: { actions: ["retryAttestations"] },
|
|
3557
|
-
STOP_PUBLISH: { actions: ["stopPublish"] },
|
|
3558
|
-
QUERY: { actions: ["query"] },
|
|
3559
|
-
STOP_ALL: { actions: ["stopAll"] }
|
|
3560
|
-
}
|
|
3561
|
-
}
|
|
3562
|
-
}
|
|
3563
|
-
}), $ = Ft(Lo, { input: {
|
|
3564
|
-
publishProcesses: /* @__PURE__ */ new Map(),
|
|
3565
|
-
subscriptions: /* @__PURE__ */ new Map(),
|
|
3566
|
-
pendingCreates: [],
|
|
3567
|
-
settledPublishes: /* @__PURE__ */ new Map()
|
|
3568
|
-
} }), Ro = !1;
|
|
3569
|
-
function zo() {
|
|
3570
|
-
if (!Ro) {
|
|
3571
|
-
try {
|
|
3572
|
-
$.start();
|
|
3573
|
-
} catch (e) {
|
|
3574
|
-
let t = e instanceof Error ? e.message : String(e);
|
|
3575
|
-
if (!/already started/i.test(t)) throw e;
|
|
3576
|
-
}
|
|
3577
|
-
Ro = !0;
|
|
3578
|
-
}
|
|
3579
|
-
}
|
|
3580
|
-
Oa({
|
|
3581
|
-
savePublish: (e, t, n) => {
|
|
3582
|
-
$.send({
|
|
3583
|
-
type: "REQUEST_SAVE_PUBLISH",
|
|
3584
|
-
seedLocalId: e,
|
|
3585
|
-
publishProcess: t,
|
|
3586
|
-
triggerPublishDone: n?.triggerPublishDone
|
|
3587
|
-
});
|
|
3588
|
-
},
|
|
3589
|
-
onPublishDone: (e) => {
|
|
3590
|
-
$.send({
|
|
3591
|
-
type: "PUBLISH_DONE",
|
|
3592
|
-
seedLocalId: e
|
|
3593
|
-
});
|
|
3594
|
-
},
|
|
3595
|
-
removeSubscription: (e) => {
|
|
3596
|
-
$.send({
|
|
3597
|
-
type: "REMOVE_SUBSCRIPTION",
|
|
3598
|
-
seedLocalId: e
|
|
3599
|
-
});
|
|
3600
|
-
}
|
|
3601
|
-
});
|
|
3602
|
-
var Bo = $.subscribe((e) => {
|
|
3603
|
-
Io("PublishManager snapshot:", e);
|
|
3604
|
-
});
|
|
3605
|
-
typeof document < "u" && (zo(), window.addEventListener("load", () => {
|
|
3606
|
-
Io("PublishManager started");
|
|
3607
|
-
}), window.addEventListener("beforeunload", () => {
|
|
3608
|
-
Bo.unsubscribe(), $.stop();
|
|
3609
|
-
}));
|
|
3610
|
-
var Vo = {
|
|
3611
|
-
getService: () => $,
|
|
3612
|
-
ready: () => (zo(), $.getSnapshot().value === "active" ? Promise.resolve() : new Promise((e) => {
|
|
3613
|
-
let t = $.subscribe((n) => {
|
|
3614
|
-
n.value === "active" && (t.unsubscribe(), e());
|
|
3615
|
-
});
|
|
3616
|
-
$.getSnapshot().value === "active" && (t.unsubscribe(), e());
|
|
3617
|
-
})),
|
|
3618
|
-
createPublish: async (e, t, n, r) => {
|
|
3619
|
-
let { seedLocalId: i } = e, a = fo(i);
|
|
3620
|
-
if (!await co(i)) {
|
|
3621
|
-
console.warn(`[createPublish] "${i}" is already publishing in another tab; skipping.`);
|
|
3622
|
-
return;
|
|
3623
|
-
}
|
|
3624
|
-
let o = await new Promise((i) => {
|
|
3625
|
-
let a = Ia(i);
|
|
3626
|
-
$.send({
|
|
3627
|
-
type: "CREATE_PUBLISH",
|
|
3628
|
-
item: e,
|
|
3629
|
-
address: t,
|
|
3630
|
-
account: n,
|
|
3631
|
-
options: r,
|
|
3632
|
-
createToken: a
|
|
3633
|
-
});
|
|
3634
|
-
});
|
|
3635
|
-
return !o && !a && lo(i), o;
|
|
3636
|
-
},
|
|
3637
|
-
retryAttestations: (e, t) => $.send({
|
|
3638
|
-
type: "RETRY_ATTESTATIONS",
|
|
3639
|
-
seedLocalId: e,
|
|
3640
|
-
account: t
|
|
3641
|
-
}),
|
|
3642
|
-
stopPublish: (e) => $.send({
|
|
3643
|
-
type: "STOP_PUBLISH",
|
|
3644
|
-
seedLocalId: e
|
|
3645
|
-
}),
|
|
3646
|
-
query: (e) => $.send({
|
|
3647
|
-
type: "QUERY",
|
|
3648
|
-
seedLocalId: e
|
|
3649
|
-
}),
|
|
3650
|
-
stopAll: () => $.send({ type: "STOP_ALL" }),
|
|
3651
|
-
getPublish: (e) => {
|
|
3652
|
-
let t = $.getSnapshot().context;
|
|
3653
|
-
return t.publishProcesses.get(e) ?? t.settledPublishes.get(e);
|
|
3654
|
-
},
|
|
3655
|
-
savePublish: (e, t) => $.send({
|
|
3656
|
-
type: "REQUEST_SAVE_PUBLISH",
|
|
3657
|
-
seedLocalId: e,
|
|
3658
|
-
publishProcess: t
|
|
3659
|
-
}),
|
|
3660
|
-
addSubscription: (e, t) => $.send({
|
|
3661
|
-
type: "ADD_SUBSCRIPTION",
|
|
3662
|
-
seedLocalId: e,
|
|
3663
|
-
newSubscription: t
|
|
3664
|
-
}),
|
|
3665
|
-
removeSubscription: (e) => $.send({
|
|
3666
|
-
type: "REMOVE_SUBSCRIPTION",
|
|
3667
|
-
seedLocalId: e
|
|
3668
|
-
})
|
|
3669
|
-
};
|
|
3670
|
-
//#endregion
|
|
3671
|
-
//#region src/helpers/approvedTargetsForAutomationPublish.ts
|
|
3672
|
-
function Ho() {
|
|
3673
|
-
let e = D().modularAccountModuleContract?.trim();
|
|
3674
|
-
if (!e || !/^0x[0-9a-fA-F]{40}$/.test(e)) throw Error("@seedprotocol/publish: session keys require PublishConfig.modularAccountModuleContract (their only approved target is the Seed executor module).");
|
|
3675
|
-
return [e.toLowerCase()];
|
|
3676
|
-
}
|
|
3677
|
-
//#endregion
|
|
3678
|
-
//#region src/helpers/automationSessionKeyPermissions.ts
|
|
3679
|
-
var Uo = "publish,revoke";
|
|
3680
|
-
function Wo(e) {
|
|
3681
|
-
let t = {
|
|
3682
|
-
approvedTargets: Ho(),
|
|
3683
|
-
nativeTokenLimitPerTransaction: 0
|
|
3684
|
-
};
|
|
3685
|
-
return typeof e?.expiresAt == "number" && e.expiresAt > 0 && (t.expiresAt = Math.trunc(e.expiresAt)), t;
|
|
3686
|
-
}
|
|
3687
|
-
function Go(e, t = Uo) {
|
|
3688
|
-
let n = `${[...e.approvedTargets].map((e) => e.toLowerCase()).sort().join(",")}|${e.nativeTokenLimitPerTransaction}|${e.expiresAt ?? 0}|${t.trim()}`;
|
|
3689
|
-
return ut(dt(n));
|
|
3690
|
-
}
|
|
3691
|
-
function Ko(e) {
|
|
3692
|
-
let t = {
|
|
3693
|
-
approvedTargets: e.approvedTargets,
|
|
3694
|
-
nativeTokenLimitPerTransaction: e.nativeTokenLimitPerTransaction
|
|
3695
|
-
};
|
|
3696
|
-
return e.expiresAt != null && e.expiresAt > 0 ? {
|
|
3697
|
-
...t,
|
|
3698
|
-
permissionEndTimestamp: /* @__PURE__ */ new Date(e.expiresAt * 1e3)
|
|
3699
|
-
} : t;
|
|
3700
|
-
}
|
|
3701
|
-
//#endregion
|
|
3702
|
-
//#region src/services/publishAuthorization/index.ts
|
|
3703
|
-
var qo = "0x0000000000000000000000000000000000000000", Jo = !0, Yo = "0x0000000000000000000000000000000000000000";
|
|
3704
|
-
function Xo(e) {
|
|
3705
|
-
if (i(e)) return e.txSender;
|
|
3706
|
-
if (he(e)) return e;
|
|
3707
|
-
throw Error("@seedprotocol/publish: publish authorization write APIs require a PublishWallet or SeedTxSender");
|
|
3708
|
-
}
|
|
3709
|
-
async function Zo(e, t) {
|
|
3710
|
-
let n = await e.sendTransaction(t);
|
|
3711
|
-
return T(n.transactionHash);
|
|
3712
|
-
}
|
|
3713
|
-
function Qo(e, t) {
|
|
3714
|
-
let n = t.trim();
|
|
3715
|
-
if (!/^0x[0-9a-fA-F]{40}$/.test(n)) throw Error(`@seedprotocol/publish: ${e} must be a valid address`);
|
|
3716
|
-
return n;
|
|
3717
|
-
}
|
|
3718
|
-
function $o() {
|
|
3719
|
-
return Mt.getSchemaUID(pt, qo, Jo);
|
|
3720
|
-
}
|
|
3721
|
-
async function es(e) {
|
|
3722
|
-
let t = Xo(e), n = $o();
|
|
3723
|
-
return await B(n) || (await Zo(t, on({
|
|
3724
|
-
schema: pt,
|
|
3725
|
-
resolverAddress: qo,
|
|
3726
|
-
revocable: Jo
|
|
3727
|
-
})), await Zo(t, cn({
|
|
3728
|
-
schemaUid: n,
|
|
3729
|
-
schemaName: ht
|
|
3730
|
-
}))), n;
|
|
3731
|
-
}
|
|
3732
|
-
function ts(e) {
|
|
3733
|
-
return new jt(pt).encodeData([
|
|
3734
|
-
{
|
|
3735
|
-
name: "identity",
|
|
3736
|
-
value: e.identity,
|
|
3737
|
-
type: "address"
|
|
3738
|
-
},
|
|
3739
|
-
{
|
|
3740
|
-
name: "sessionKey",
|
|
3741
|
-
value: e.sessionKey,
|
|
3742
|
-
type: "address"
|
|
3743
|
-
},
|
|
3744
|
-
{
|
|
3745
|
-
name: "app",
|
|
3746
|
-
value: e.app,
|
|
3747
|
-
type: "address"
|
|
3748
|
-
},
|
|
3749
|
-
{
|
|
3750
|
-
name: "scopes",
|
|
3751
|
-
value: e.scopes,
|
|
3752
|
-
type: "string"
|
|
3753
|
-
},
|
|
3754
|
-
{
|
|
3755
|
-
name: "grantedAt",
|
|
3756
|
-
value: e.grantedAt,
|
|
3757
|
-
type: "uint64"
|
|
3758
|
-
},
|
|
3759
|
-
{
|
|
3760
|
-
name: "expiresAt",
|
|
3761
|
-
value: e.expiresAt,
|
|
3762
|
-
type: "uint64"
|
|
3763
|
-
},
|
|
3764
|
-
{
|
|
3765
|
-
name: "permissionsHash",
|
|
3766
|
-
value: Ct(e.permissionsHash),
|
|
3767
|
-
type: "bytes32"
|
|
3768
|
-
}
|
|
3769
|
-
]);
|
|
3770
|
-
}
|
|
3771
|
-
async function ns(e) {
|
|
3772
|
-
let t = Xo(e.wallet), n = e.ensureSchema === !1 ? $o() : await es(e.wallet), r = Qo("identity", e.identity), i = Qo("sessionKey", e.sessionKey), a = e.app?.trim() ? Qo("app", e.app) : Yo, o = e.grantedAt ?? Math.floor(Date.now() / 1e3), s = typeof e.expiresAt == "number" && e.expiresAt > 0 ? Math.trunc(e.expiresAt) : 0, c = e.scopes ?? _t, l = Ct(e.permissionsHash ?? Go(Wo({ expiresAt: s > 0 ? s : void 0 }), c === _t ? "publish,revoke" : c));
|
|
3773
|
-
if (l === Pt) throw Error("@seedprotocol/publish: attestPublishAuthorization requires a non-zero permissionsHash");
|
|
3774
|
-
let d = typeof e.expirationTime == "number" && e.expirationTime > 0 ? e.expirationTime : s > 0 ? s : o + ft, f = ts({
|
|
3775
|
-
identity: r,
|
|
3776
|
-
sessionKey: i,
|
|
3777
|
-
app: a,
|
|
3778
|
-
scopes: c,
|
|
3779
|
-
grantedAt: o,
|
|
3780
|
-
expiresAt: s,
|
|
3781
|
-
permissionsHash: l
|
|
3782
|
-
}), p = await Zo(t, v({
|
|
3783
|
-
schema: n,
|
|
3784
|
-
data: {
|
|
3785
|
-
recipient: i,
|
|
3786
|
-
expirationTime: BigInt(d),
|
|
3787
|
-
revocable: !0,
|
|
3788
|
-
refUID: Pt,
|
|
3789
|
-
data: f,
|
|
3790
|
-
value: 0n
|
|
3791
|
-
}
|
|
3792
|
-
}));
|
|
3793
|
-
if (!p) throw Error("@seedprotocol/publish: attestPublishAuthorization failed — no receipt");
|
|
3794
|
-
let { easContractAddress: m } = D(), h = u(p, m);
|
|
3795
|
-
if (!h || !St(h)) throw Error("@seedprotocol/publish: attestPublishAuthorization failed — could not parse attestation UID");
|
|
3796
|
-
return {
|
|
3797
|
-
uid: h,
|
|
3798
|
-
schemaUid: n,
|
|
3799
|
-
permissionsHash: l,
|
|
3800
|
-
grantedAt: o,
|
|
3801
|
-
expiresAt: s,
|
|
3802
|
-
expirationTime: d
|
|
3803
|
-
};
|
|
3804
|
-
}
|
|
3805
|
-
async function rs(e) {
|
|
3806
|
-
let t = Xo(e.wallet), r = e.schemaUid ?? $o(), i = Ct(e.uid);
|
|
3807
|
-
if (!St(i)) throw Error("@seedprotocol/publish: revokePublishAuthorization requires a valid attestation uid");
|
|
3808
|
-
if (!await Zo(t, n([{
|
|
3809
|
-
schema: r,
|
|
3810
|
-
data: [{ uid: i }]
|
|
3811
|
-
}]))) throw Error("@seedprotocol/publish: revokePublishAuthorization failed — no receipt");
|
|
3812
|
-
}
|
|
3813
|
-
async function is(e) {
|
|
3814
|
-
let t = (await xt({
|
|
3815
|
-
identities: e.identities,
|
|
3816
|
-
excludeRevoked: !1
|
|
3817
|
-
})).find((t) => t.id?.toLowerCase() === e.uid.toLowerCase());
|
|
3818
|
-
if (!t) return null;
|
|
3819
|
-
let n = bt(t.decodedDataJson ?? "[]"), r = typeof t.expirationTime == "number" ? t.expirationTime : typeof t.expirationTime == "string" ? Number(t.expirationTime) : null;
|
|
3820
|
-
return {
|
|
3821
|
-
uid: t.id,
|
|
3822
|
-
decoded: n,
|
|
3823
|
-
assess: yt({
|
|
3824
|
-
decoded: n,
|
|
3825
|
-
expirationTime: r
|
|
3826
|
-
}),
|
|
3827
|
-
expirationTime: r
|
|
3828
|
-
};
|
|
3829
|
-
}
|
|
3830
|
-
//#endregion
|
|
3831
|
-
export { z as $, si as A, Jr as B, Ci as C, ai as D, oi as E, $r as F, Br as G, Qr as H, gi as I, Xn as J, Hr as K, ei as L, pi as M, hi as N, ii as O, qr as P, on as Q, ti as R, Di as S, ri as T, Zr as U, Ur as V, Xr as W, cn as X, yn as Y, B as Z, Zi as _, ns as a, Bi as b, $o as c, Wo as d, en as et, Go as f, Ta as g, Vo as h, is as i, li as j, ci as k, rs as l, Ho as m, gt as n, qt as nt, ts as o, Ko as p, Pn as q, vt as r, es as s, mt as t, Kt as tt, Uo as u, Qi as v, Ti as w, zi as x, Fi as y, ni as z };
|
|
3832
|
-
|
|
3833
|
-
//# sourceMappingURL=publishAuthorization-C5kXlbOT.js.map
|