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