@seedprotocol/publish 0.7.4 → 0.7.5-next.871.g8788c94
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/CHANGELOG.md +229 -3
- package/README.md +31 -8
- package/dist/{chainConfig-DM9RSIMT.js → chainConfig-CY22-kWO.js} +1534 -1458
- package/dist/chainConfig-CY22-kWO.js.map +1 -0
- package/dist/config.d.ts +11 -5
- package/dist/config.d.ts.map +1 -1
- package/dist/{ensureAutomationSessionKey-DTO5lxXB.js → ensureAutomationSessionKey-CKFyZNj7.js} +22 -22
- package/dist/{ensureAutomationSessionKey-DTO5lxXB.js.map → ensureAutomationSessionKey-CKFyZNj7.js.map} +1 -1
- package/dist/{ensureModularPublishBootstrap-BYySx3sx.js → ensureModularPublishBootstrap-DQDSbkQy.js} +9 -9
- package/dist/{ensureModularPublishBootstrap-BYySx3sx.js.map → ensureModularPublishBootstrap-DQDSbkQy.js.map} +1 -1
- package/dist/ensureSmartWalletThenPublish-By_Xv7xG.js +47 -0
- package/dist/ensureSmartWalletThenPublish-By_Xv7xG.js.map +1 -0
- package/dist/helpers/adapters/thirdwebAccount.d.ts +3 -1
- package/dist/helpers/adapters/thirdwebAccount.d.ts.map +1 -1
- package/dist/helpers/arweave.d.ts.map +1 -1
- package/dist/helpers/chainClient.d.ts +6 -0
- package/dist/helpers/chainClient.d.ts.map +1 -1
- package/dist/helpers/ensureSmartWalletThenPublish.d.ts +3 -4
- package/dist/helpers/ensureSmartWalletThenPublish.d.ts.map +1 -1
- package/dist/helpers/ensureWalletThenPublish.d.ts +18 -4
- package/dist/helpers/ensureWalletThenPublish.d.ts.map +1 -1
- package/dist/helpers/publishItem.d.ts.map +1 -1
- package/dist/helpers/publishWalletRegistry.d.ts +17 -0
- package/dist/helpers/publishWalletRegistry.d.ts.map +1 -1
- package/dist/helpers/seedSigner.d.ts +8 -0
- package/dist/helpers/seedSigner.d.ts.map +1 -1
- package/dist/helpers/thirdweb.d.ts +4 -0
- package/dist/helpers/thirdweb.d.ts.map +1 -1
- package/dist/hooks/useCanPublishItem.d.ts +5 -0
- package/dist/hooks/useCanPublishItem.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +274 -260
- package/dist/index.js.map +1 -1
- package/dist/{managedAccountAdmin-rhHtJC4y.js → managedAccountAdmin-DBAX8yny.js} +9 -9
- package/dist/{managedAccountAdmin-rhHtJC4y.js.map → managedAccountAdmin-DBAX8yny.js.map} +1 -1
- package/dist/{publishAuthorization-Dx-4adsz.js → publishAuthorization-D2wbNc-H.js} +24 -24
- package/dist/{publishAuthorization-Dx-4adsz.js.map → publishAuthorization-D2wbNc-H.js.map} +1 -1
- package/dist/publishWalletRegistry-BaQe9rIR.js +48 -0
- package/dist/publishWalletRegistry-BaQe9rIR.js.map +1 -0
- package/dist/react/ConnectButton.d.ts.map +1 -1
- package/dist/react/PublishProvider.d.ts.map +1 -1
- package/dist/react/PublishProvider.initOrder.test.d.ts +2 -0
- package/dist/react/PublishProvider.initOrder.test.d.ts.map +1 -0
- package/dist/react/PublishProvider.thirdweb.d.ts.map +1 -1
- package/dist/{resolveRevokeAccount-CC9X1H9x.js → resolveRevokeAccount-B7cj6OyT.js} +9 -9
- package/dist/{resolveRevokeAccount-CC9X1H9x.js.map → resolveRevokeAccount-B7cj6OyT.js.map} +1 -1
- package/dist/services/arweaveL1Finalize/worker.d.ts.map +1 -1
- package/dist/services/publish/actors/checking.d.ts.map +1 -1
- package/dist/services/publish/actors/createArweaveDataItems.d.ts +2 -0
- package/dist/services/publish/actors/createArweaveDataItems.d.ts.map +1 -1
- package/dist/services/publish/actors/createArweaveDataItemsPhase2.d.ts.map +1 -1
- package/dist/services/publish/actors/pollForConfirmation.d.ts +14 -0
- package/dist/services/publish/actors/pollForConfirmation.d.ts.map +1 -1
- package/dist/services/publish/actors/uploadViaBundler.d.ts +5 -0
- package/dist/services/publish/actors/uploadViaBundler.d.ts.map +1 -1
- package/dist/services/publish/helpers/undeployedSmartAccount.d.ts +11 -7
- package/dist/services/publish/helpers/undeployedSmartAccount.d.ts.map +1 -1
- package/dist/services/publish/index.d.ts +3 -1
- package/dist/services/publish/index.d.ts.map +1 -1
- package/dist/services/publishCost/estimatePublishCost.d.ts +14 -2
- package/dist/services/publishCost/estimatePublishCost.d.ts.map +1 -1
- package/dist/services/publishCost/types.d.ts +10 -0
- package/dist/services/publishCost/types.d.ts.map +1 -1
- package/dist/services/publishManager/actors/restorableSnapshot.d.ts +22 -0
- package/dist/services/publishManager/actors/restorableSnapshot.d.ts.map +1 -0
- package/dist/services/publishManager/actors/restoreFromDb.d.ts.map +1 -1
- package/dist/services/publishManager/index.d.ts +6 -10
- package/dist/services/publishManager/index.d.ts.map +1 -1
- package/dist/thirdweb.js +98 -92
- package/dist/thirdweb.js.map +1 -1
- package/dist/types.d.ts +6 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/undeployedSmartAccount-pbMpi4PV.js +15 -0
- package/dist/undeployedSmartAccount-pbMpi4PV.js.map +1 -0
- package/dist/worker-CBBwWaxo.js +87 -0
- package/dist/worker-CBBwWaxo.js.map +1 -0
- package/package.json +25 -7
- package/dist/chainConfig-DM9RSIMT.js.map +0 -1
- package/dist/ensureSmartWalletThenPublish-DiH5CKLY.js +0 -52
- package/dist/ensureSmartWalletThenPublish-DiH5CKLY.js.map +0 -1
- package/dist/services/publishManager/actions/query.d.ts +0 -2
- package/dist/services/publishManager/actions/query.d.ts.map +0 -1
- package/dist/undeployedSmartAccount-uDk6iZjl.js +0 -24
- package/dist/undeployedSmartAccount-uDk6iZjl.js.map +0 -1
- package/dist/worker-Bv_xadel.js +0 -88
- package/dist/worker-Bv_xadel.js.map +0 -1
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
|
|
2
|
-
import { B as t, Ct as n, V as r, Xt as i, Y as a, a as o, gt as s, ht as c, p as l, t as u, wt as d } from "./chainConfig-DM9RSIMT.js";
|
|
3
|
-
import { ethers as f } from "ethers";
|
|
4
|
-
//#region src/helpers/ensureSmartWalletThenPublish.ts
|
|
5
|
-
var p = /* @__PURE__ */ e({ ensureSmartWalletThenPublish: () => _ }), m = "A connected wallet is required for publishing with the modular executor. Connect your wallet and try again.", h = () => `Could not connect the managed publishing account on ${u()}. Reconnect with the same sign-in method and try again.`;
|
|
6
|
-
function g(e) {
|
|
7
|
-
if (e) return e instanceof f.Wallet ? e : n(e) ? e.signer : d(e) ? e : c(e).signer;
|
|
8
|
-
}
|
|
9
|
-
async function _(e, n, u, d) {
|
|
10
|
-
let f = o(), p = await u();
|
|
11
|
-
if (!p || !p.trim()) return { outcome: "no_address" };
|
|
12
|
-
if (f.useModularExecutor) {
|
|
13
|
-
let n = await r();
|
|
14
|
-
if (!n) return {
|
|
15
|
-
outcome: "managed_not_ready",
|
|
16
|
-
error: new i(m, "MANAGED_ACCOUNT_UNAVAILABLE")
|
|
17
|
-
};
|
|
18
|
-
let a;
|
|
19
|
-
try {
|
|
20
|
-
a = await t(s());
|
|
21
|
-
} catch (e) {
|
|
22
|
-
return {
|
|
23
|
-
outcome: "managed_not_ready",
|
|
24
|
-
error: new i(h(), "MANAGED_ACCOUNT_UNAVAILABLE", void 0, e)
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
let o = c(n);
|
|
28
|
-
return {
|
|
29
|
-
outcome: "started",
|
|
30
|
-
started: l.createPublish(e, a, o, {
|
|
31
|
-
...d,
|
|
32
|
-
dataItemSigner: g(d?.dataItemSigner) ?? o.signer
|
|
33
|
-
})
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
let _ = await a(n ?? null);
|
|
37
|
-
if ("address" in _) {
|
|
38
|
-
let t = c(_.account);
|
|
39
|
-
return {
|
|
40
|
-
outcome: "started",
|
|
41
|
-
started: l.createPublish(e, _.address, t, {
|
|
42
|
-
...d,
|
|
43
|
-
dataItemSigner: g(d?.dataItemSigner) ?? t.signer
|
|
44
|
-
})
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
return { outcome: "needs_deploy" };
|
|
48
|
-
}
|
|
49
|
-
//#endregion
|
|
50
|
-
export { p as n, _ as t };
|
|
51
|
-
|
|
52
|
-
//# sourceMappingURL=ensureSmartWalletThenPublish-DiH5CKLY.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ensureSmartWalletThenPublish-DiH5CKLY.js","names":["__exportAll","getConnectedManagedAccountAddress","isPublishWallet","getConnectedModularAccount","ManagedAccountPublishError","resolveSmartWalletForPublish","getPublishConfig","getPublishThirdwebChain","fromThirdwebAccount","PublishManager","getPublishChainName","isSeedSigner","ensureSmartWalletThenPublish_exports","ensureSmartWalletThenPublish","MSG_NO_ACCOUNT_MODULAR","MSG_MANAGED_UNAVAILABLE","coerceDataItemSigner","signer","ethers","config","address","getAddress","modularAccount","managedAddress","cause","wallet","item","options","resolved","activeAccount"],"sources":["../src/helpers/ensureSmartWalletThenPublish.ts"],"sourcesContent":["import type { Item } from '@seedprotocol/sdk'\nimport type { Account } from 'thirdweb/wallets'\nimport {\n getConnectedManagedAccountAddress,\n getConnectedModularAccount,\n resolveSmartWalletForPublish,\n} from './thirdweb'\nimport { fromThirdwebAccount } from './adapters/thirdwebAccount'\nimport { isPublishWallet, isSeedSigner, type PublishWallet, type SeedSigner } from './seedSigner'\nimport { ethers } from 'ethers'\nimport { PublishManager } from '../services/publishManager'\nimport type { CreatePublishOptions } from '../config'\nimport { getPublishConfig } from '../config'\nimport { ManagedAccountPublishError } from '../errors'\nimport { getPublishThirdwebChain } from './thirdwebChain'\nimport { getPublishChainName } from './chainConfig'\n\nexport type EnsureSmartWalletResult =\n | { outcome: 'started'; started: import('./ensureWalletThenPublish').PublishStarted }\n | { outcome: 'no_address' }\n | { outcome: 'needs_deploy' }\n | { outcome: 'managed_not_ready'; error: ManagedAccountPublishError }\n\nconst MSG_NO_ACCOUNT_MODULAR =\n 'A connected wallet is required for publishing with the modular executor. Connect your wallet and try again.'\n\nconst MSG_MANAGED_UNAVAILABLE = () =>\n `Could not connect the managed publishing account on ${getPublishChainName()}. Reconnect with the same sign-in method and try again.`\n\nfunction coerceDataItemSigner(\n signer: CreatePublishOptions['dataItemSigner'] | Account | SeedSigner | PublishWallet | undefined,\n): CreatePublishOptions['dataItemSigner'] {\n if (!signer) return undefined\n if (signer instanceof ethers.Wallet) return signer\n if (isPublishWallet(signer)) return signer.signer\n if (isSeedSigner(signer)) return signer\n return fromThirdwebAccount(signer as Account).signer\n}\n\n/**\n * Thirdweb path: resolves the smart wallet for the current account; if deployed, starts publish.\n * Prefer {@link ensureWalletThenPublish} for vendor-neutral entry.\n */\nexport async function ensureSmartWalletThenPublish(\n item: Item<any>,\n activeAccount: Account | null | undefined,\n getAddress: () => Promise<string | null>,\n options?: CreatePublishOptions,\n): Promise<EnsureSmartWalletResult> {\n const config = getPublishConfig()\n const address = await getAddress()\n if (!address || !address.trim()) {\n return { outcome: 'no_address' }\n }\n\n if (config.useModularExecutor) {\n const modularAccount = await getConnectedModularAccount()\n if (!modularAccount) {\n return {\n outcome: 'managed_not_ready',\n error: new ManagedAccountPublishError(MSG_NO_ACCOUNT_MODULAR, 'MANAGED_ACCOUNT_UNAVAILABLE'),\n }\n }\n\n let managedAddress: string\n try {\n managedAddress = await getConnectedManagedAccountAddress(getPublishThirdwebChain())\n } catch (cause) {\n return {\n outcome: 'managed_not_ready',\n error: new ManagedAccountPublishError(\n MSG_MANAGED_UNAVAILABLE(),\n 'MANAGED_ACCOUNT_UNAVAILABLE',\n undefined,\n cause,\n ),\n }\n }\n\n const wallet = fromThirdwebAccount(modularAccount)\n const started = PublishManager.createPublish(item, managedAddress, wallet, {\n ...options,\n dataItemSigner: coerceDataItemSigner(options?.dataItemSigner) ?? wallet.signer,\n })\n return { outcome: 'started', started }\n }\n\n const resolved = await resolveSmartWalletForPublish(activeAccount ?? null)\n if ('address' in resolved) {\n const wallet = fromThirdwebAccount(resolved.account)\n const started = PublishManager.createPublish(item, resolved.address, wallet, {\n ...options,\n dataItemSigner: coerceDataItemSigner(options?.dataItemSigner) ?? wallet.signer,\n })\n return { outcome: 'started', started }\n }\n return { outcome: 'needs_deploy' }\n}\n"],"mappings":";;;;sEAuBMc,IACJ,+GAEIC,UACJ,uDAAuDL,EAAoB,EAAE;AAE/E,SAASM,EACP,GACwC;CACxC,IAAKC,GAIL,OAHIA,aAAkBC,EAAO,SAAeD,IACxCf,EAAgBe,CAAM,IAAUA,EAAO,SACvCN,EAAaM,CAAM,IAAUA,IAC1BT,EAAoBS,CAAiB,CAAC,CAAC;AAChD;AAMA,eAAsBJ,EACpB,GACA,GACA,GACA,GACkC;CAClC,IAAMM,IAASb,EAAiB,GAC1Bc,IAAU,MAAMC,EAAW;CACjC,IAAI,CAACD,KAAW,CAACA,EAAQ,KAAK,GAC5B,OAAO,EAAE,SAAS,aAAa;CAGjC,IAAID,EAAO,oBAAoB;EAC7B,IAAMG,IAAiB,MAAMnB,EAA2B;EACxD,IAAI,CAACmB,GACH,OAAO;GACL,SAAS;GACT,OAAO,IAAIlB,EAA2BU,GAAwB,6BAA6B;EAC7F;EAGF,IAAIS;EACJ,IAAI;GACF,IAAiB,MAAMtB,EAAkCM,EAAwB,CAAC;EACpF,SAASiB,GAAO;GACd,OAAO;IACL,SAAS;IACT,OAAO,IAAIpB,EACTW,EAAwB,GACxB,+BACA,KAAA,GACAS,CACF;GACF;EACF;EAEA,IAAMC,IAASjB,EAAoBc,CAAc;EAKjD,OAAO;GAAE,SAAS;GAAW,SAJbb,EAAe,cAAciB,GAAMH,GAAgBE,GAAQ;IACzE,GAAGE;IACH,gBAAgBX,EAAqBW,GAAS,cAAc,KAAKF,EAAO;GAC1E,CAC6B;EAAQ;CACvC;CAEA,IAAMG,IAAW,MAAMvB,EAA6BwB,KAAiB,IAAI;CACzE,IAAI,aAAaD,GAAU;EACzB,IAAMH,IAASjB,EAAoBoB,EAAS,OAAO;EAKnD,OAAO;GAAE,SAAS;GAAW,SAJbnB,EAAe,cAAciB,GAAME,EAAS,SAASH,GAAQ;IAC3E,GAAGE;IACH,gBAAgBX,EAAqBW,GAAS,cAAc,KAAKF,EAAO;GAC1E,CAC6B;EAAQ;CACvC;CACA,OAAO,EAAE,SAAS,eAAe;AACnC"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export declare const query: import("xstate").ActionFunction<import("xstate").MachineContext, import("xstate").EventObject, import("xstate").EventObject, import("xstate").NonReducibleUnknown, import("xstate").ProvidedActor, import("xstate").ParameterizedObject, import("xstate").ParameterizedObject, never, import("xstate").EventObject>;
|
|
2
|
-
//# sourceMappingURL=query.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../../src/services/publishManager/actions/query.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,KAAK,qTAwBhB,CAAA"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Dt as e, Rt as t } from "./chainConfig-DM9RSIMT.js";
|
|
2
|
-
//#region src/services/publish/helpers/undeployedSmartAccount.ts
|
|
3
|
-
function n(e, t) {
|
|
4
|
-
return !!e && !!t && e.toLowerCase() === t.toLowerCase();
|
|
5
|
-
}
|
|
6
|
-
async function r(r, i) {
|
|
7
|
-
let a = i?.txSender?.address;
|
|
8
|
-
if (a && !n(a, r)) return "sender_is_not_publisher";
|
|
9
|
-
let o = e(), s = /* @__PURE__ */ new Set();
|
|
10
|
-
for (let e of [
|
|
11
|
-
i?.signer?.address,
|
|
12
|
-
o?.adminAddress,
|
|
13
|
-
o?.signer.address,
|
|
14
|
-
...o?.ownedAddresses ?? []
|
|
15
|
-
]) e && !n(e, r) && s.add(e.toLowerCase());
|
|
16
|
-
for (let e of s) try {
|
|
17
|
-
if (n(await t(e), r)) return "undeployed_smart_account";
|
|
18
|
-
} catch {}
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
//#endregion
|
|
22
|
-
export { r as undeployedPublisherProblem };
|
|
23
|
-
|
|
24
|
-
//# sourceMappingURL=undeployedSmartAccount-uDk6iZjl.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"undeployedSmartAccount-uDk6iZjl.js","names":["getPublishWallet","readFactoryGetAddress","sameAddress","a","b","undeployedPublisherProblem","sender","wallet","publisherAddress","session","candidates","admin"],"sources":["../src/services/publish/helpers/undeployedSmartAccount.ts"],"sourcesContent":["import type { Address } from 'viem'\nimport { readFactoryGetAddress } from '~/helpers/contracts'\nimport { getPublishWallet } from '~/helpers/publishWalletRegistry'\nimport type { PublishWallet } from '~/helpers/seedSigner'\n\nfunction sameAddress(a: string | undefined, b: string | undefined): boolean {\n return !!a && !!b && a.toLowerCase() === b.toLowerCase()\n}\n\n/**\n * For a publisher address with no bytecode, says why it must not attest straight to EAS, or\n * returns null when it can (an EOA).\n *\n * - The wallet sends from another address: EAS would record that address as the attester.\n * - The publisher is the ManagedAccount factory address of a known admin (the wallet's signer,\n * or an admin / owned address of the registered session): it is a smart account that is not\n * deployed yet. Direct EAS would attest one transaction per Seed and deploy the account as a\n * side effect, instead of the account's multiPublish.\n *\n * Factory reads that fail (no factory configured, RPC error) rule that admin out.\n */\nexport async function undeployedPublisherProblem(\n publisherAddress: string,\n wallet: Partial<PublishWallet> | undefined,\n): Promise<'sender_is_not_publisher' | 'undeployed_smart_account' | null> {\n const sender = wallet?.txSender?.address\n if (sender && !sameAddress(sender, publisherAddress)) return 'sender_is_not_publisher'\n\n const session = getPublishWallet()\n const candidates = new Set<string>()\n for (const a of [\n wallet?.signer?.address,\n session?.adminAddress,\n session?.signer.address,\n ...(session?.ownedAddresses ?? []),\n ]) {\n if (a && !sameAddress(a, publisherAddress)) candidates.add(a.toLowerCase())\n }\n for (const admin of candidates) {\n try {\n const predicted = await readFactoryGetAddress(admin as Address)\n if (sameAddress(predicted, publisherAddress)) return 'undeployed_smart_account'\n } catch {\n // Not a factory account for this admin, or no factory on this chain.\n }\n }\n return null\n}\n"],"mappings":";;AAKA,SAASE,EAAY,GAAuB,GAAgC;CAC1E,OAAO,CAAC,CAACC,KAAK,CAAC,CAACC,KAAKD,EAAE,YAAY,MAAMC,EAAE,YAAY;AACzD;AAcA,eAAsBC,EACpB,GACA,GACwE;CACxE,IAAMC,IAASC,GAAQ,UAAU;CACjC,IAAID,KAAU,CAACJ,EAAYI,GAAQE,CAAgB,GAAG,OAAO;CAE7D,IAAMC,IAAUT,EAAiB,GAC3BU,oBAAa,IAAI,IAAY;CACnC,KAAK,IAAMP,KAAK;EACdI,GAAQ,QAAQ;EAChBE,GAAS;EACTA,GAAS,OAAO;EAChB,GAAIA,GAAS,kBAAkB,CAAC;CAClC,GACE,AAAIN,KAAK,CAACD,EAAYC,GAAGK,CAAgB,KAAGE,EAAW,IAAIP,EAAE,YAAY,CAAC;CAE5E,KAAK,IAAMQ,KAASD,GAClB,IAAI;EAEF,IAAIR,EAAY,MADQD,EAAsBU,CAAgB,GACnCH,CAAgB,GAAG,OAAO;CACvD,QAAQ,CAER;CAEF,OAAO;AACT"}
|
package/dist/worker-Bv_xadel.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { a as e, an as t } from "./chainConfig-DM9RSIMT.js";
|
|
2
|
-
import { BaseDb as n, applyArweaveL1TransactionIdLocal as r, arweaveL1FinalizeJobs as i, getArweaveUploadStatus as a, isArweaveL1AnchoringComplete as o, queryArweaveGatewayTransactionWithFallback as s } from "@seedprotocol/sdk";
|
|
3
|
-
import c from "debug";
|
|
4
|
-
import { eq as l } from "drizzle-orm";
|
|
5
|
-
//#region src/services/arweaveL1Finalize/worker.ts
|
|
6
|
-
var u = c("seedProtocol:arweaveL1Finalize:worker"), d = 45e3, f = null;
|
|
7
|
-
function p() {
|
|
8
|
-
f ?? (f = setInterval(() => {
|
|
9
|
-
h();
|
|
10
|
-
}, d), h());
|
|
11
|
-
}
|
|
12
|
-
function m() {
|
|
13
|
-
f != null && (clearInterval(f), f = null);
|
|
14
|
-
}
|
|
15
|
-
async function h() {
|
|
16
|
-
let c;
|
|
17
|
-
try {
|
|
18
|
-
c = e();
|
|
19
|
-
} catch {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
if (!c.useArweaveBundler || !n.isAppDbReady()) return;
|
|
23
|
-
let d = n.getAppDb();
|
|
24
|
-
if (!d) return;
|
|
25
|
-
let f = await d.select().from(i).where(l(i.phase, "pending_l1")).limit(25);
|
|
26
|
-
if (f.length === 0) return;
|
|
27
|
-
let p = c.arweaveUploadVerificationBaseUrl, m = c.arweaveGraphqlUrl, h = t(c).storage.uploadTo === "turbo";
|
|
28
|
-
for (let e of f) {
|
|
29
|
-
let t = e.dataItemId;
|
|
30
|
-
try {
|
|
31
|
-
let n = e.l1TransactionId;
|
|
32
|
-
if (h) {
|
|
33
|
-
let a = await s(m, t), o = a?.bundledInId ?? n ?? null;
|
|
34
|
-
o && a?.blockHeight != null && (await r({
|
|
35
|
-
seedLocalId: e.seedLocalId,
|
|
36
|
-
versionLocalId: e.versionLocalId,
|
|
37
|
-
dataItemId: t,
|
|
38
|
-
l1TransactionId: o
|
|
39
|
-
}), await d.update(i).set({
|
|
40
|
-
phase: "confirmed",
|
|
41
|
-
statusJson: JSON.stringify(a),
|
|
42
|
-
l1TransactionId: o,
|
|
43
|
-
bundleId: o,
|
|
44
|
-
updatedAt: Date.now()
|
|
45
|
-
}).where(l(i.id, e.id)));
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
if (!n) {
|
|
49
|
-
let r = (await s(m, t))?.bundledInId ?? null;
|
|
50
|
-
r && (n = r, await d.update(i).set({
|
|
51
|
-
l1TransactionId: r,
|
|
52
|
-
bundleId: r,
|
|
53
|
-
updatedAt: Date.now()
|
|
54
|
-
}).where(l(i.id, e.id)));
|
|
55
|
-
}
|
|
56
|
-
let c = await a(p, t), u = c ? JSON.stringify(c) : null;
|
|
57
|
-
if (c && o(c)) {
|
|
58
|
-
let a = n ?? c.bundleId ?? c.turbo?.bundleId ?? e.l1TransactionId ?? null;
|
|
59
|
-
a && await r({
|
|
60
|
-
seedLocalId: e.seedLocalId,
|
|
61
|
-
versionLocalId: e.versionLocalId,
|
|
62
|
-
dataItemId: t,
|
|
63
|
-
l1TransactionId: a
|
|
64
|
-
}), await d.update(i).set({
|
|
65
|
-
phase: "confirmed",
|
|
66
|
-
statusJson: u,
|
|
67
|
-
l1TransactionId: a ?? e.l1TransactionId,
|
|
68
|
-
bundleId: c.bundleId ?? e.bundleId,
|
|
69
|
-
updatedAt: Date.now()
|
|
70
|
-
}).where(l(i.id, e.id));
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
await d.update(i).set({
|
|
74
|
-
statusJson: u,
|
|
75
|
-
updatedAt: Date.now()
|
|
76
|
-
}).where(l(i.id, e.id));
|
|
77
|
-
} catch (t) {
|
|
78
|
-
u("tick error for job", e.id, t), await d.update(i).set({
|
|
79
|
-
errorMessage: t instanceof Error ? t.message : String(t),
|
|
80
|
-
updatedAt: Date.now()
|
|
81
|
-
}).where(l(i.id, e.id));
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
//#endregion
|
|
86
|
-
export { p as startArweaveL1FinalizeWorker, m as stopArweaveL1FinalizeWorker };
|
|
87
|
-
|
|
88
|
-
//# sourceMappingURL=worker-Bv_xadel.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"worker-Bv_xadel.js","names":["getPublishConfig","resolvePublishPayment","debug","logger","TICK_MS","intervalId","startArweaveL1FinalizeWorker","runArweaveL1FinalizeTick","stopArweaveL1FinalizeWorker","config","BaseDb","db","pending","arweaveL1FinalizeJobs","eq","uploadBase","graphqlUrl","uploadedToTurbo","job","dataItemId","l1TxId","gql","queryArweaveGatewayTransactionWithFallback","bundled","applyArweaveL1TransactionIdLocal","status","getArweaveUploadStatus","statusStr","isArweaveL1AnchoringComplete","resolvedL1","err"],"sources":["../src/services/arweaveL1Finalize/worker.ts"],"sourcesContent":["import {\n applyArweaveL1TransactionIdLocal,\n arweaveL1FinalizeJobs,\n BaseDb,\n getArweaveUploadStatus,\n isArweaveL1AnchoringComplete,\n queryArweaveGatewayTransactionWithFallback,\n} from '@seedprotocol/sdk'\nimport { eq } from 'drizzle-orm'\nimport { getPublishConfig } from '~/config'\nimport { resolvePublishPayment } from '~/payment'\nimport debug from 'debug'\n\nconst logger = debug('seedProtocol:arweaveL1Finalize:worker')\n\nconst TICK_MS = 45_000\n\nlet intervalId: ReturnType<typeof setInterval> | null = null\n\nexport function startArweaveL1FinalizeWorker(): void {\n if (intervalId != null) return\n intervalId = setInterval(() => {\n void runArweaveL1FinalizeTick()\n }, TICK_MS)\n void runArweaveL1FinalizeTick()\n}\n\nexport function stopArweaveL1FinalizeWorker(): void {\n if (intervalId != null) {\n clearInterval(intervalId)\n intervalId = null\n }\n}\n\nasync function runArweaveL1FinalizeTick(): Promise<void> {\n let config: ReturnType<typeof getPublishConfig>\n try {\n config = getPublishConfig()\n } catch {\n return\n }\n if (!config.useArweaveBundler) return\n\n // initPublish may start this worker before Seed platformClassesInit configures BaseDb.\n if (!BaseDb.isAppDbReady()) return\n const db = BaseDb.getAppDb()\n if (!db) return\n\n const pending = await db\n .select()\n .from(arweaveL1FinalizeJobs)\n .where(eq(arweaveL1FinalizeJobs.phase, 'pending_l1'))\n .limit(25)\n\n if (pending.length === 0) return\n\n const uploadBase = config.arweaveUploadVerificationBaseUrl\n const graphqlUrl = config.arweaveGraphqlUrl\n // User-paid uploads went to Turbo; the upload API doesn't know them, so finish from GraphQL.\n const uploadedToTurbo = resolvePublishPayment(config).storage.uploadTo === 'turbo'\n\n for (const job of pending) {\n const dataItemId = job.dataItemId\n try {\n let l1TxId = job.l1TransactionId\n\n if (uploadedToTurbo) {\n const gql = await queryArweaveGatewayTransactionWithFallback(graphqlUrl, dataItemId)\n const bundled = gql?.bundledInId ?? l1TxId ?? null\n if (bundled && gql?.blockHeight != null) {\n await applyArweaveL1TransactionIdLocal({\n seedLocalId: job.seedLocalId,\n versionLocalId: job.versionLocalId,\n dataItemId,\n l1TransactionId: bundled,\n })\n await db\n .update(arweaveL1FinalizeJobs)\n .set({\n phase: 'confirmed',\n statusJson: JSON.stringify(gql),\n l1TransactionId: bundled,\n bundleId: bundled,\n updatedAt: Date.now(),\n })\n .where(eq(arweaveL1FinalizeJobs.id, job.id!))\n }\n continue\n }\n\n if (!l1TxId) {\n const gql = await queryArweaveGatewayTransactionWithFallback(graphqlUrl, dataItemId)\n const bundled = gql?.bundledInId ?? null\n if (bundled) {\n l1TxId = bundled\n await db\n .update(arweaveL1FinalizeJobs)\n .set({\n l1TransactionId: bundled,\n bundleId: bundled,\n updatedAt: Date.now(),\n })\n .where(eq(arweaveL1FinalizeJobs.id, job.id!))\n }\n }\n\n const status = await getArweaveUploadStatus(uploadBase, dataItemId)\n const statusStr = status ? JSON.stringify(status) : null\n\n if (status && isArweaveL1AnchoringComplete(status)) {\n const resolvedL1 =\n l1TxId ??\n status.bundleId ??\n status.turbo?.bundleId ??\n job.l1TransactionId ??\n null\n\n if (resolvedL1) {\n await applyArweaveL1TransactionIdLocal({\n seedLocalId: job.seedLocalId,\n versionLocalId: job.versionLocalId,\n dataItemId,\n l1TransactionId: resolvedL1,\n })\n }\n\n await db\n .update(arweaveL1FinalizeJobs)\n .set({\n phase: 'confirmed',\n statusJson: statusStr,\n l1TransactionId: resolvedL1 ?? job.l1TransactionId,\n bundleId: status.bundleId ?? job.bundleId,\n updatedAt: Date.now(),\n })\n .where(eq(arweaveL1FinalizeJobs.id, job.id!))\n continue\n }\n\n await db\n .update(arweaveL1FinalizeJobs)\n .set({\n statusJson: statusStr,\n updatedAt: Date.now(),\n })\n .where(eq(arweaveL1FinalizeJobs.id, job.id!))\n } catch (err) {\n logger('tick error for job', job.id, err)\n await db\n .update(arweaveL1FinalizeJobs)\n .set({\n errorMessage: err instanceof Error ? err.message : String(err),\n updatedAt: Date.now(),\n })\n .where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