@seedprotocol/publish 0.7.4 → 0.7.5-next.850.g9ab585b
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 +223 -3
- package/README.md +31 -8
- package/dist/{chainConfig-DM9RSIMT.js → chainConfig-BWzE8DIF.js} +1347 -1356
- package/dist/chainConfig-BWzE8DIF.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-BenLVZk4.js} +22 -22
- package/dist/{ensureAutomationSessionKey-DTO5lxXB.js.map → ensureAutomationSessionKey-BenLVZk4.js.map} +1 -1
- package/dist/{ensureModularPublishBootstrap-BYySx3sx.js → ensureModularPublishBootstrap-CngVyk4c.js} +9 -9
- package/dist/{ensureModularPublishBootstrap-BYySx3sx.js.map → ensureModularPublishBootstrap-CngVyk4c.js.map} +1 -1
- package/dist/{ensureSmartWalletThenPublish-DiH5CKLY.js → ensureSmartWalletThenPublish-3Q_vA8mD.js} +19 -25
- package/dist/ensureSmartWalletThenPublish-3Q_vA8mD.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/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/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-CW1P40qh.js} +9 -9
- package/dist/{managedAccountAdmin-rhHtJC4y.js.map → managedAccountAdmin-CW1P40qh.js.map} +1 -1
- package/dist/{publishAuthorization-Dx-4adsz.js → publishAuthorization-BOalFNvQ.js} +24 -24
- package/dist/{publishAuthorization-Dx-4adsz.js.map → publishAuthorization-BOalFNvQ.js.map} +1 -1
- package/dist/publishWalletRegistry-Bf_Nvf_3.js +45 -0
- package/dist/publishWalletRegistry-Bf_Nvf_3.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-BUK9i1T4.js} +9 -9
- package/dist/{resolveRevokeAccount-CC9X1H9x.js.map → resolveRevokeAccount-BUK9i1T4.js.map} +1 -1
- package/dist/services/publish/actors/checking.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/helpers/undeployedSmartAccount.d.ts +11 -7
- package/dist/services/publish/helpers/undeployedSmartAccount.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/index.d.ts +6 -10
- package/dist/services/publishManager/index.d.ts.map +1 -1
- package/dist/thirdweb.js +97 -95
- package/dist/thirdweb.js.map +1 -1
- package/dist/undeployedSmartAccount-B6KSTipF.js +15 -0
- package/dist/undeployedSmartAccount-B6KSTipF.js.map +1 -0
- package/dist/{worker-Bv_xadel.js → worker-DAciYSNY.js} +2 -2
- package/dist/{worker-Bv_xadel.js.map → worker-DAciYSNY.js.map} +1 -1
- package/package.json +25 -7
- package/dist/chainConfig-DM9RSIMT.js.map +0 -1
- 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/thirdweb.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { $ as e, A as t, B as n,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { t as
|
|
5
|
-
import {
|
|
1
|
+
import { $ as e, A as t, B as n, G as r, H as i, Ht as a, I as o, J as s, K as c, Kt as l, L as u, M as ee, N as d, P as te, Q as ne, R as f, Rt as p, U as m, V as h, Vt as re, W as g, Wt as ie, X as ae, Y as oe, Z as _, _t as v, a as y, et as se, gt as b, ht as ce, i as le, j as ue, m as x, mt as de, nt as fe, o as pe, q as S, qt as C, rt as w, t as T, tt as me, z as he } from "./chainConfig-BWzE8DIF.js";
|
|
2
|
+
import { r as E, t as D } from "./publishWalletRegistry-Bf_Nvf_3.js";
|
|
3
|
+
import { a as O, d as k, f as A, g as j, h as M, l as N, m as P, p as F, u as I } from "./publishAuthorization-BOalFNvQ.js";
|
|
4
|
+
import { t as L } from "./ensureSmartWalletThenPublish-3Q_vA8mD.js";
|
|
5
|
+
import { t as R } from "./ensureModularPublishBootstrap-CngVyk4c.js";
|
|
6
|
+
import { i as z, r as B, t as V } from "./ensureAutomationSessionKey-BenLVZk4.js";
|
|
6
7
|
import { client as H } from "@seedprotocol/sdk";
|
|
7
8
|
import { deploySmartAccount as ge, getContract as U, sendTransaction as _e } from "thirdweb";
|
|
8
9
|
import { ConnectButton as ve, ThirdwebProvider as ye, darkTheme as be, useActiveAccount as xe, useActiveWallet as Se, useActiveWalletConnectionStatus as Ce, useIsAutoConnecting as we } from "thirdweb/react";
|
|
@@ -14,7 +15,7 @@ import { addSessionKey as Ae, shouldUpdateSessionKey as je } from "thirdweb/exte
|
|
|
14
15
|
//#region src/react/ConnectButton.tsx
|
|
15
16
|
var q = "seedProtocol:publish:userChoseWalletDisconnect";
|
|
16
17
|
function Me(e) {
|
|
17
|
-
console.warn("[ConnectButton] Wallet setup / module install skipped:", e),
|
|
18
|
+
console.warn("[ConnectButton] Wallet setup / module install skipped:", e), y().onWalletSetupWarning?.(e);
|
|
18
19
|
}
|
|
19
20
|
function Ne() {
|
|
20
21
|
return H.isInitialized() ? Promise.resolve() : new Promise((e) => {
|
|
@@ -27,28 +28,28 @@ async function Pe(e, t, n) {
|
|
|
27
28
|
if (!t) return;
|
|
28
29
|
try {
|
|
29
30
|
_();
|
|
30
|
-
let e =
|
|
31
|
+
let e = m();
|
|
31
32
|
await e.autoConnect({
|
|
32
33
|
client: w(),
|
|
33
|
-
chain:
|
|
34
|
+
chain: v(n)
|
|
34
35
|
});
|
|
35
36
|
let r = e.getAccount();
|
|
36
37
|
if (!r) return;
|
|
37
|
-
await
|
|
38
|
+
await d(t, r, n);
|
|
38
39
|
} catch {}
|
|
39
40
|
} else try {
|
|
40
|
-
await
|
|
41
|
+
await d(e.address, e, n);
|
|
41
42
|
} catch (e) {
|
|
42
43
|
Me(e);
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
var Fe = () => {
|
|
47
|
-
let e = j(), t =
|
|
48
|
+
let e = j(), t = v(e), n = Se(), r = xe(), i = Ce(), a = we(), o = G(null), s = G(!1), l = G(!1);
|
|
48
49
|
W(() => {
|
|
49
50
|
if (typeof window > "u") return;
|
|
50
|
-
let n =
|
|
51
|
-
|
|
51
|
+
let n = s.current;
|
|
52
|
+
s.current = a;
|
|
52
53
|
let r;
|
|
53
54
|
try {
|
|
54
55
|
r = performance.getEntriesByType("navigation")[0]?.type;
|
|
@@ -56,84 +57,84 @@ var Fe = () => {
|
|
|
56
57
|
r = void 0;
|
|
57
58
|
}
|
|
58
59
|
if (r !== "reload") return;
|
|
59
|
-
let
|
|
60
|
+
let o = !1;
|
|
60
61
|
try {
|
|
61
|
-
|
|
62
|
+
o = sessionStorage.getItem(q) === "1";
|
|
62
63
|
} catch {
|
|
63
|
-
|
|
64
|
+
o = !1;
|
|
64
65
|
}
|
|
65
|
-
|
|
66
|
+
o || n && !a && i === "disconnected" && (l.current || (l.current = !0, (e.useModularExecutor ? g() : m()).autoConnect({
|
|
66
67
|
client: w(),
|
|
67
68
|
chain: t
|
|
68
69
|
}).catch(() => {})));
|
|
69
70
|
}, [
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
i,
|
|
72
|
+
a,
|
|
72
73
|
e.useModularExecutor,
|
|
73
74
|
t
|
|
74
75
|
]);
|
|
75
|
-
let
|
|
76
|
-
let
|
|
77
|
-
if (!
|
|
78
|
-
await Ne()
|
|
79
|
-
let
|
|
76
|
+
let u = Te(async (n) => {
|
|
77
|
+
let r = n.getAccount();
|
|
78
|
+
if (!r) return;
|
|
79
|
+
await Ne();
|
|
80
|
+
let i = /* @__PURE__ */ new Set([r.address.toLowerCase()]), a;
|
|
80
81
|
if (e.useModularExecutor) {
|
|
81
82
|
_();
|
|
82
|
-
let e =
|
|
83
|
+
let e = n.getAdminAccount?.()?.address ?? r.address, o = async () => {
|
|
83
84
|
try {
|
|
84
|
-
return await
|
|
85
|
+
return await h(t);
|
|
85
86
|
} catch {
|
|
86
87
|
try {
|
|
87
|
-
return await
|
|
88
|
+
return await c(e);
|
|
88
89
|
} catch {
|
|
89
90
|
return;
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
93
|
};
|
|
93
|
-
|
|
94
|
+
a = await o(), a ||= (await new Promise((e) => queueMicrotask(() => e())), await o()), a && i.add(a.toLowerCase());
|
|
94
95
|
}
|
|
95
|
-
let
|
|
96
|
-
if (
|
|
97
|
-
|
|
96
|
+
let s = [...i].sort().join(",");
|
|
97
|
+
if (o.current !== s) {
|
|
98
|
+
o.current !== null && x.stopAll(), o.current = s;
|
|
98
99
|
try {
|
|
99
|
-
let e =
|
|
100
|
-
await
|
|
101
|
-
...
|
|
102
|
-
ownedAddresses: [...
|
|
103
|
-
publisherAddress:
|
|
104
|
-
...
|
|
100
|
+
let e = n.getAdminAccount?.()?.address, t = !!a || !!e && e.toLowerCase() !== r.address.toLowerCase(), o = b(r, { kind: t ? "smart" : "eoa" });
|
|
101
|
+
await E({
|
|
102
|
+
...o,
|
|
103
|
+
ownedAddresses: [...i],
|
|
104
|
+
publisherAddress: a ?? r.address,
|
|
105
|
+
...e && e.toLowerCase() !== r.address.toLowerCase() ? { adminAddress: e } : {}
|
|
105
106
|
});
|
|
106
107
|
} catch (e) {
|
|
107
|
-
throw
|
|
108
|
+
throw o.current = null, console.warn("[ConnectButton] Failed to set seed client addresses:", e), e;
|
|
108
109
|
}
|
|
109
|
-
await Pe(
|
|
110
|
+
await Pe(r, a, e);
|
|
110
111
|
}
|
|
111
112
|
}, [e]);
|
|
112
113
|
return W(() => {
|
|
113
|
-
if (
|
|
114
|
-
if (
|
|
115
|
-
|
|
114
|
+
if (a) return;
|
|
115
|
+
if (i !== "connected") {
|
|
116
|
+
o.current = null;
|
|
116
117
|
return;
|
|
117
118
|
}
|
|
118
|
-
if (!
|
|
119
|
+
if (!n) return;
|
|
119
120
|
let e = !1;
|
|
120
121
|
return (async () => {
|
|
121
122
|
try {
|
|
122
123
|
if (e) return;
|
|
123
|
-
await
|
|
124
|
+
await u(n);
|
|
124
125
|
} catch {}
|
|
125
126
|
})(), () => {
|
|
126
127
|
e = !0;
|
|
127
128
|
};
|
|
128
129
|
}, [
|
|
130
|
+
n,
|
|
131
|
+
r?.address,
|
|
129
132
|
i,
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
l,
|
|
133
|
-
m
|
|
133
|
+
a,
|
|
134
|
+
u
|
|
134
135
|
]), /* @__PURE__ */ K(ve, {
|
|
135
136
|
client: w(),
|
|
136
|
-
wallets:
|
|
137
|
+
wallets: S(e),
|
|
137
138
|
autoConnect: !0,
|
|
138
139
|
chain: t,
|
|
139
140
|
chains: [t],
|
|
@@ -145,7 +146,7 @@ var Fe = () => {
|
|
|
145
146
|
} catch {}
|
|
146
147
|
console.log("[ConnectButton] Connected", n.address);
|
|
147
148
|
try {
|
|
148
|
-
await
|
|
149
|
+
await u(e);
|
|
149
150
|
} catch {}
|
|
150
151
|
}
|
|
151
152
|
},
|
|
@@ -153,7 +154,7 @@ var Fe = () => {
|
|
|
153
154
|
try {
|
|
154
155
|
sessionStorage.setItem(q, "1");
|
|
155
156
|
} catch {}
|
|
156
|
-
|
|
157
|
+
D(), x.stopAll();
|
|
157
158
|
},
|
|
158
159
|
theme: be({ colors: {
|
|
159
160
|
primaryButtonBg: "#1D2939",
|
|
@@ -164,43 +165,44 @@ var Fe = () => {
|
|
|
164
165
|
borderColor: "#344054"
|
|
165
166
|
} })
|
|
166
167
|
});
|
|
167
|
-
}, Ie = ({ children: e, config: t, queryClient: n, queryClientRef: r }) =>
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
})
|
|
168
|
+
}, Ie = ({ children: e, config: t, queryClient: n, queryClientRef: r }) => {
|
|
169
|
+
let i = G(void 0);
|
|
170
|
+
return t && i.current !== t && (pe(t), i.current = t), /* @__PURE__ */ K(M.Provider, {
|
|
171
|
+
value: t ?? le(),
|
|
172
|
+
children: /* @__PURE__ */ K(ye, { children: /* @__PURE__ */ K(ke, {
|
|
173
|
+
queryClient: n,
|
|
174
|
+
queryClientRef: r,
|
|
175
|
+
children: e
|
|
176
|
+
}) })
|
|
177
|
+
});
|
|
178
|
+
}, Le = "Modular (EIP-7702) wallet is not connected. Sign in with the same method and try again.", Re = () => `Your modular account is not upgraded to an EIP-7702 smart account on ${T()} yet. Enable autoDeployEip7702ModularAccount in publish config or complete wallet setup, then retry.`, ze = () => `Automatic EIP-7702 smart account setup failed on ${T()}. Retry or reconnect your wallet.`, J = "EIP-7702 upgrade was sent but on-chain bytecode was not detected yet. Wait a moment and retry.", Y = 5;
|
|
177
179
|
async function Be() {
|
|
178
|
-
let { autoDeployEip7702ModularAccount: e } =
|
|
180
|
+
let { autoDeployEip7702ModularAccount: e } = y(), t = g();
|
|
179
181
|
await t.autoConnect({
|
|
180
182
|
client: w(),
|
|
181
|
-
chain:
|
|
183
|
+
chain: v()
|
|
182
184
|
});
|
|
183
185
|
let n = t.getAccount();
|
|
184
|
-
if (!n) throw new
|
|
186
|
+
if (!n) throw new l(Le, "EIP7702_MODULAR_ACCOUNT_UNAVAILABLE");
|
|
185
187
|
let r = w(), i = U({
|
|
186
188
|
client: r,
|
|
187
|
-
chain:
|
|
189
|
+
chain: v(),
|
|
188
190
|
address: n.address
|
|
189
191
|
});
|
|
190
|
-
if (!await
|
|
191
|
-
if (!e) throw new
|
|
192
|
+
if (!await re(n.address)) {
|
|
193
|
+
if (!e) throw new l(Re(), "EIP7702_MODULAR_NOT_UPGRADED", n.address);
|
|
192
194
|
try {
|
|
193
195
|
await ge({
|
|
194
196
|
smartAccount: n,
|
|
195
|
-
chain:
|
|
197
|
+
chain: v(),
|
|
196
198
|
client: r,
|
|
197
199
|
accountContract: i
|
|
198
200
|
});
|
|
199
201
|
} catch (e) {
|
|
200
|
-
if (await
|
|
201
|
-
throw new
|
|
202
|
+
if (await a(n.address, Y)) return;
|
|
203
|
+
throw new l(ze(), "EIP7702_MODULAR_DEPLOY_FAILED", n.address, e);
|
|
202
204
|
}
|
|
203
|
-
if (!await
|
|
205
|
+
if (!await a(n.address, Y)) throw new l(J, "EIP7702_MODULAR_NOT_CONFIRMED", n.address);
|
|
204
206
|
}
|
|
205
207
|
}
|
|
206
208
|
//#endregion
|
|
@@ -210,33 +212,33 @@ function X(e) {
|
|
|
210
212
|
}
|
|
211
213
|
//#endregion
|
|
212
214
|
//#region src/helpers/ensureManagedSignerSessionKey.ts
|
|
213
|
-
var Ve = () => `Could not connect the managed publishing account to authorize the modular signer on ${
|
|
215
|
+
var Ve = () => `Could not connect the managed publishing account to authorize the modular signer on ${T()}. Reconnect and try again.`, Z = () => `Could not authorize the modular wallet as a session signer on your publishing account on ${T()}.`;
|
|
214
216
|
async function He(e) {
|
|
215
|
-
let { managedAddress: t, signerAddress: n } = e, r =
|
|
217
|
+
let { managedAddress: t, signerAddress: n } = e, r = m();
|
|
216
218
|
await r.autoConnect({
|
|
217
219
|
client: w(),
|
|
218
|
-
chain:
|
|
220
|
+
chain: v()
|
|
219
221
|
});
|
|
220
222
|
let i = r.getAccount();
|
|
221
|
-
if (!i) throw new
|
|
223
|
+
if (!i) throw new C(Ve(), "MODULAR_SIGNER_ACTIVATION_FAILED", t);
|
|
222
224
|
let a = U({
|
|
223
225
|
client: w(),
|
|
224
|
-
chain:
|
|
226
|
+
chain: v(),
|
|
225
227
|
address: t
|
|
226
228
|
}), o = {
|
|
227
229
|
approvedTargets: X(t),
|
|
228
230
|
nativeTokenLimitPerTransaction: 0
|
|
229
|
-
},
|
|
231
|
+
}, s = !1;
|
|
230
232
|
try {
|
|
231
|
-
|
|
233
|
+
s = await je({
|
|
232
234
|
accountContract: a,
|
|
233
235
|
sessionKeyAddress: n,
|
|
234
236
|
newPermissions: o
|
|
235
237
|
});
|
|
236
238
|
} catch (e) {
|
|
237
|
-
throw new
|
|
239
|
+
throw new C(Z(), "MODULAR_SIGNER_ACTIVATION_FAILED", t, e);
|
|
238
240
|
}
|
|
239
|
-
if (
|
|
241
|
+
if (s) try {
|
|
240
242
|
let e = Ae({
|
|
241
243
|
contract: a,
|
|
242
244
|
account: i,
|
|
@@ -246,43 +248,43 @@ async function He(e) {
|
|
|
246
248
|
account: i,
|
|
247
249
|
transaction: e
|
|
248
250
|
});
|
|
249
|
-
await
|
|
251
|
+
await ie(t.transactionHash);
|
|
250
252
|
} catch (e) {
|
|
251
|
-
throw new
|
|
253
|
+
throw new C(Z(), "MODULAR_SIGNER_ACTIVATION_FAILED", t, e);
|
|
252
254
|
}
|
|
253
|
-
let
|
|
255
|
+
let c = !1;
|
|
254
256
|
try {
|
|
255
|
-
|
|
257
|
+
c = await p(t, n);
|
|
256
258
|
} catch (e) {
|
|
257
|
-
throw new
|
|
259
|
+
throw new C(Z(), "MODULAR_SIGNER_ACTIVATION_FAILED", t, e);
|
|
258
260
|
}
|
|
259
|
-
if (!
|
|
261
|
+
if (!c) throw new C(Z(), "MODULAR_SIGNER_ACTIVATION_FAILED", t);
|
|
260
262
|
}
|
|
261
263
|
//#endregion
|
|
262
264
|
//#region src/helpers/enrollPublishAutomation.ts
|
|
263
265
|
async function Q(e) {
|
|
264
|
-
let t =
|
|
266
|
+
let t = m();
|
|
265
267
|
await t.autoConnect({
|
|
266
268
|
client: w(),
|
|
267
|
-
chain:
|
|
269
|
+
chain: v()
|
|
268
270
|
});
|
|
269
271
|
let n = t.getAccount();
|
|
270
|
-
if (!n) throw new
|
|
272
|
+
if (!n) throw new C("Could not connect the managed publishing account to enroll or revoke publish automation.", "MANAGED_ACCOUNT_UNAVAILABLE", e);
|
|
271
273
|
return n;
|
|
272
274
|
}
|
|
273
275
|
async function $(e, t) {
|
|
274
|
-
return t ||
|
|
276
|
+
return t || b(await Q(e), { kind: "smart" });
|
|
275
277
|
}
|
|
276
278
|
async function Ue(e) {
|
|
277
|
-
let t =
|
|
279
|
+
let t = y();
|
|
278
280
|
if (!t.modularAccountModuleContract?.trim()) throw Error("@seedprotocol/publish: enrollPublishAutomation requires PublishConfig.modularAccountModuleContract");
|
|
279
281
|
let n = await Q(e), r;
|
|
280
282
|
try {
|
|
281
|
-
r = await
|
|
283
|
+
r = await d(e, n, t);
|
|
282
284
|
} catch (t) {
|
|
283
|
-
throw t instanceof
|
|
285
|
+
throw t instanceof C ? t : new C("Executor module setup failed for publish automation.", "EXECUTOR_MODULE_NOT_INSTALLED", e, t);
|
|
284
286
|
}
|
|
285
|
-
await
|
|
287
|
+
await te(e, r.status === "installed" ? { installedEas: r.eas } : { readAttempts: r.status === "already-installed" ? 5 : 1 });
|
|
286
288
|
}
|
|
287
289
|
async function We(e) {
|
|
288
290
|
let { managedAddress: t, sessionKeyAddress: n, appAddress: r, expiresAt: i } = e;
|
|
@@ -363,6 +365,6 @@ async function Ke(e) {
|
|
|
363
365
|
};
|
|
364
366
|
}
|
|
365
367
|
//#endregion
|
|
366
|
-
export {
|
|
368
|
+
export { me as CALL_GAS_HEADROOM_BPS, Fe as ConnectButton, o as ExternalWalletsForDeploy, I as PUBLISH_AUTOMATION_SCOPES, Ie as PublishProvider, u as appMetadata, P as approvedTargetsForAutomationPublish, de as asSeedSignerFromThirdweb, ce as asThirdwebPublishWallet, Ke as assertStorageBoundToIdentity, k as buildAutomationSessionKeyPermissions, X as defaultApprovedTargetsForModularPublish, f as deployManagedAccountViaFactory, he as deploySmartWalletContract, We as enrollPublishAutomation, V as ensureAutomationSessionKey, Be as ensureEip7702ModularAccountReady, d as ensureExecutorModuleInstalled, t as ensureManagedAccountReady, He as ensureManagedSignerSessionKey, R as ensureModularPublishBootstrap, L as ensureSmartWalletThenPublish, b as fromThirdwebAccount, w as getClient, n as getConnectedAccount, h as getConnectedManagedAccountAddress, i as getConnectedModularAccount, m as getManagedAccountWallet, g as getModularAccountWallet, v as getPublishThirdwebChain, r as getSharedPublishInAppWalletStorage, c as getSmartWalletAddressForAdmin, S as getWalletsForConnectButton, A as hashAutomationSessionKeyPermissions, B as isAutomationSessionActive, s as isSmartWalletDeployed, oe as pollSmartWalletDeployed, z as removeAutomationSessionKey, ae as resolveSmartWalletForPublish, Ge as revokePublishAutomation, ue as runModularExecutorPublishPrep, fe as seedPaymaster, F as toThirdwebSessionKeyPermissions, ee as tryDeployManagedAccount, ne as useActiveSmartWalletContract, e as useLocalWalletAccount, j as usePublishConfig, se as wallets };
|
|
367
369
|
|
|
368
370
|
//# sourceMappingURL=thirdweb.js.map
|
package/dist/thirdweb.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thirdweb.js","names":["seedClient","ConnectButtonThirdweb","pollSmartWalletDeployed","wallets","runModularExecutorPublishPrep","getConnectedManagedAccountAddress","clearPublishWallet","ExternalWalletsForDeploy","getSmartWalletAddressForAdmin","pollSmartWalletDeployed$1","getManagedAccountWallet","appMetadata","pollSmartWalletDeployed","getWalletsForConnectButton","deployManagedAccountViaFactory","ensureExecutorModuleInstalled","assertExecutorModuleReadyForAccount","setPublishWallet","useLocalWalletAccount","deploySmartWalletContract","getModularAccountWallet","getConnectedModularAccount","readIsActiveSigner","getSharedPublishInAppWalletStorage","isContractDeployed","syncPublishInAppAuthToken","ManagedAccountPublishError","resolveSmartWalletForPublish","Eip7702ModularAccountPublishError","useActiveSmartWalletContract","getPublishConfig","CALL_GAS_HEADROOM_BPS","getPublishThirdwebChain","fromThirdwebAccount","getConfigRef","tryDeployManagedAccount","ensureManagedAccountReady","asThirdwebPublishWallet","getClient","initPublish","PublishManager","asSeedSignerFromThirdweb","isSmartWalletDeployed","waitForPublishReceipt","getPublishChainName","seedPaymaster","getConnectedAccount","attestPublishAuthorization","buildAutomationSessionKeyPermissions","hashAutomationSessionKeyPermissions","usePublishConfig","PublishConfigContext","revokePublishAuthorization","approvedTargetsForAutomationPublish","toThirdwebSessionKeyPermissions","PUBLISH_AUTOMATION_SCOPES","ensureSmartWalletThenPublish","ensureModularPublishBootstrap","removeAutomationSessionKey","isAutomationSessionActive","ensureAutomationSessionKey","ConnectButton$1","USER_DISCONNECTED_SESSION_KEY","reportWalletSetupWarning","err","waitUntilSeedInitialized","client","resolve","ensureExecutorModulesForConnect","config","managedAddress","mw","ma","modularAccount","ConnectButton","thirdwebChain","wallet","useActiveWallet","activeAccount","useActiveAccount","connectionStatus","useActiveWalletConnectionStatus","isAutoConnecting","useIsAutoConnecting","lastSyncedOwnedKey","useRef","prevIsAutoConnecting","reloadAutoConnectRetried","prev","navType","userChoseDisconnect","syncActiveWalletToSeed","useCallback","account","activeWallet","owned","adminAddress","tryManaged","r","ownedKey","publishWallet","useEffect","cancelled","darkTheme","PublishProviderThirdweb","ThirdwebProvider","SeedProvider","MSG_NO_ACCOUNT","MSG_NOT_UPGRADED","MSG_DEPLOY_FAILED","MSG_NOT_CONFIRMED","DEPLOY_POLL_ATTEMPTS","ensureEip7702ModularAccountReady","modularAccountWallet","accountContract","getContract","autoDeployEip7702ModularAccount","deploySmartAccount","cause","defaultApprovedTargetsForModularPublish","MSG_UNAVAILABLE","MSG_ACTIVATION_FAILED","ensureManagedSignerSessionKey","params","managedWallet","managedAccount","permissions","shouldUpdate","shouldUpdateSessionKey","signerAddress","tx","addSessionKey","result","sendTransaction","active","connectManagedAccount","resolveUserWallet","userWallet","assertExecutorModuleInstalled","twAccount","install","enrollPublishAutomation","sessionKeyAddress","appAddress","revokePublishAutomation","authorizationUid","assertStorageBoundToIdentity","warnings","owner","dataItemOwner","identity","allowActiveSessionKey","allowSidecar","rows","getPublishAuthorizationFromEas","nowMs","atTime","row","decoded","decodePublishAuthorizationData","expirationTime","assess","assessPublishAuthorization"],"sources":["../src/react/ConnectButton.tsx","../src/react/PublishProvider.thirdweb.tsx","../src/helpers/ensureEip7702ModularAccountReady.ts","../src/helpers/defaultApprovedTargetsForModularPublish.ts","../src/helpers/ensureManagedSignerSessionKey.ts","../src/helpers/enrollPublishAutomation.ts","../src/helpers/assertStorageBoundToIdentity.ts"],"sourcesContent":["import React, { FC, useCallback, useEffect, useRef } from \"react\"\nimport {\n ConnectButton as ConnectButtonThirdweb,\n darkTheme,\n useActiveAccount,\n useActiveWallet,\n useActiveWalletConnectionStatus,\n useIsAutoConnecting,\n} from \"thirdweb/react\"\nimport { client as seedClient } from \"@seedprotocol/sdk\"\nimport {\n getClient,\n getConnectedManagedAccountAddress,\n getManagedAccountWallet,\n getModularAccountWallet,\n getSmartWalletAddressForAdmin,\n getWalletsForConnectButton,\n syncPublishInAppAuthToken,\n} from \"../helpers/thirdweb\"\nimport { fromThirdwebAccount } from \"../helpers/adapters/thirdwebAccount\"\nimport { setPublishWallet, clearPublishWallet } from \"../helpers/publishWalletRegistry\"\nimport { usePublishConfig } from \"./PublishConfigContext\"\nimport { getPublishConfig } from \"../config\"\nimport type { Account, Wallet } from \"thirdweb/wallets\"\nimport type { PublishConfig } from \"../config\"\nimport { ensureExecutorModuleInstalled } from \"../helpers/ensureExecutorModule\"\nimport { PublishManager } from \"../services/publishManager\"\nimport { getPublishThirdwebChain } from '../helpers/thirdwebChain'\n\n/** Session flag so we do not force autoConnect after an explicit UI disconnect (survives reload). */\nconst USER_DISCONNECTED_SESSION_KEY = \"seedProtocol:publish:userChoseWalletDisconnect\"\n\nfunction reportWalletSetupWarning(err: unknown) {\n // Expected when managed-wallet autoConnect is still catching up; publish prep retries.\n console.warn(\"[ConnectButton] Wallet setup / module install skipped:\", err)\n getPublishConfig().onWalletSetupWarning?.(err)\n}\n\n/** Resolves after `ClientManager.init()` has finished; `setAddresses` requires this. */\nfunction waitUntilSeedInitialized(): Promise<void> {\n if (seedClient.isInitialized()) return Promise.resolve()\n return new Promise((resolve) => {\n seedClient.onReady(() => resolve())\n })\n}\n\n/**\n * Installs the Seed executor on the **ManagedAccount** (EIP-4337 Router) contract via its\n * `SeedExecutorRouterExtension`. Other accounts, such as the EIP-7702 modular wallet, have no\n * extension, so `ensureExecutorModuleInstalled` skips them.\n */\nasync function ensureExecutorModulesForConnect(\n modularAccount: Account,\n managedAddress: string | undefined,\n config: PublishConfig,\n): Promise<void> {\n if (!config.modularAccountModuleContract) {\n return\n }\n\n if (config.useModularExecutor) {\n if (!managedAddress) {\n return\n }\n try {\n syncPublishInAppAuthToken()\n const mw = getManagedAccountWallet()\n await mw.autoConnect({ client: getClient(), chain: getPublishThirdwebChain(config) })\n const ma = mw.getAccount()\n if (!ma) {\n return\n }\n await ensureExecutorModuleInstalled(managedAddress, ma, config)\n } catch {\n /* managed wallet session may lag modular connect; publish prep retries module install */\n }\n return\n }\n\n try {\n await ensureExecutorModuleInstalled(modularAccount.address, modularAccount, config)\n } catch (err) {\n reportWalletSetupWarning(err)\n }\n}\n\nconst ConnectButton: FC = () => {\n const config = usePublishConfig()\n const thirdwebChain = getPublishThirdwebChain(config)\n const wallet = useActiveWallet()\n const activeAccount = useActiveAccount()\n const connectionStatus = useActiveWalletConnectionStatus()\n const isAutoConnecting = useIsAutoConnecting()\n /** Avoid duplicate setAddresses when onConnect and the reconcile effect both run. */\n const lastSyncedOwnedKey = useRef<string | null>(null)\n const prevIsAutoConnecting = useRef(false)\n const reloadAutoConnectRetried = useRef(false)\n\n /**\n * Thirdweb sometimes finishes autoConnect on full reload with `disconnected` and no wallet\n * (see debug: isAutoConnecting true→false then disconnected). One explicit in-app autoConnect\n * retry recovers without affecting users who chose Disconnect (sessionStorage gate).\n */\n useEffect(() => {\n if (typeof window === \"undefined\") return\n const prev = prevIsAutoConnecting.current\n prevIsAutoConnecting.current = isAutoConnecting\n\n let navType: string | undefined\n try {\n navType = (\n performance.getEntriesByType(\"navigation\")[0] as\n | PerformanceNavigationTiming\n | undefined\n )?.type\n } catch {\n navType = undefined\n }\n if (navType !== \"reload\") return\n\n let userChoseDisconnect = false\n try {\n userChoseDisconnect =\n sessionStorage.getItem(USER_DISCONNECTED_SESSION_KEY) === \"1\"\n } catch {\n userChoseDisconnect = false\n }\n if (userChoseDisconnect) return\n\n if (!prev || isAutoConnecting || connectionStatus !== \"disconnected\") return\n if (reloadAutoConnectRetried.current) return\n reloadAutoConnectRetried.current = true\n\n void (config.useModularExecutor ? getModularAccountWallet() : getManagedAccountWallet())\n .autoConnect({ client: getClient(), chain: thirdwebChain })\n .catch(() => {\n /* no session or iframe not ready; Connect UI can still sign in */\n })\n }, [connectionStatus, isAutoConnecting, config.useModularExecutor, thirdwebChain])\n\n const syncActiveWalletToSeed = useCallback(\n async (activeWallet: Wallet) => {\n const account = activeWallet.getAccount()\n if (!account) {\n return\n }\n await waitUntilSeedInitialized()\n PublishManager.stopAll()\n const owned = new Set<string>([account.address.toLowerCase()])\n let managedAddress: string | undefined\n if (config.useModularExecutor) {\n syncPublishInAppAuthToken()\n const adminAddress =\n activeWallet.getAdminAccount?.()?.address ?? account.address\n const tryManaged = async () => {\n try {\n return await getConnectedManagedAccountAddress(thirdwebChain)\n } catch {\n try {\n return await getSmartWalletAddressForAdmin(adminAddress)\n } catch {\n return undefined\n }\n }\n }\n managedAddress = await tryManaged()\n if (!managedAddress) {\n await new Promise<void>((r) => queueMicrotask(() => r()))\n managedAddress = await tryManaged()\n }\n if (managedAddress) {\n owned.add(managedAddress.toLowerCase())\n }\n }\n const ownedKey = [...owned].sort().join(\",\")\n if (lastSyncedOwnedKey.current === ownedKey) {\n return\n }\n lastSyncedOwnedKey.current = ownedKey\n try {\n const publishWallet = fromThirdwebAccount(account)\n const adminAddress = activeWallet.getAdminAccount?.()?.address\n await setPublishWallet({\n ...publishWallet,\n ownedAddresses: [...owned],\n publisherAddress: managedAddress ?? account.address,\n ...(adminAddress && adminAddress.toLowerCase() !== account.address.toLowerCase()\n ? { adminAddress }\n : {}),\n })\n } catch (err) {\n lastSyncedOwnedKey.current = null\n console.warn(\"[ConnectButton] Failed to set seed client addresses:\", err)\n throw err\n }\n await ensureExecutorModulesForConnect(account, managedAddress, config)\n },\n [config],\n )\n\n /**\n * Thirdweb autoConnect restores the wallet without calling onConnect. Seed addresses live in\n * SQLite (OPFS); after a wipe there is no app_state row until setAddresses runs again.\n */\n useEffect(() => {\n if (isAutoConnecting) {\n return\n }\n if (connectionStatus !== \"connected\") {\n lastSyncedOwnedKey.current = null\n return\n }\n if (!wallet) {\n return\n }\n let cancelled = false\n void (async () => {\n try {\n if (cancelled) return\n await syncActiveWalletToSeed(wallet)\n } catch {\n /* logged in syncActiveWalletToSeed */\n }\n })()\n return () => {\n cancelled = true\n }\n }, [\n wallet,\n activeAccount?.address,\n connectionStatus,\n isAutoConnecting,\n syncActiveWalletToSeed,\n ])\n\n const handleDisconnect = () => {\n try {\n sessionStorage.setItem(USER_DISCONNECTED_SESSION_KEY, \"1\")\n } catch {\n /* private mode / SSR */\n }\n void clearPublishWallet()\n PublishManager.stopAll()\n }\n\n const handleConnect = async (activeWallet: Wallet, _allConnectedWallets: Wallet[]) => {\n const account = activeWallet.getAccount()\n if (!account) return\n try {\n sessionStorage.removeItem(USER_DISCONNECTED_SESSION_KEY)\n } catch {\n /* ignore */\n }\n console.log('[ConnectButton] Connected', account.address)\n try {\n await syncActiveWalletToSeed(activeWallet)\n } catch {\n /* syncActiveWalletToSeed logs */\n }\n }\n\n return (\n <ConnectButtonThirdweb\n client={getClient()}\n wallets={getWalletsForConnectButton(config)}\n autoConnect={true}\n chain={thirdwebChain}\n chains={[ thirdwebChain, ]}\n onConnect={handleConnect}\n onDisconnect={handleDisconnect}\n theme={darkTheme({\n colors: {\n primaryButtonBg: '#1D2939',\n primaryButtonText: '#FFFFFF',\n secondaryButtonHoverBg: '#1D2939',\n connectedButtonBg: '#101828',\n connectedButtonBgHover: '#1D2939',\n borderColor: '#344054',\n },\n })}\n />\n )\n}\n\nexport default ConnectButton\n","import React, { FC, useEffect } from \"react\"\nimport type { MutableRefObject } from \"react\"\nimport type { QueryClient } from \"@tanstack/react-query\"\nimport { ThirdwebProvider } from \"thirdweb/react\"\nimport { SeedProvider } from '@seedprotocol/react'\nimport { initPublish, getConfigRef, type PublishConfig } from \"../config\"\nimport { PublishConfigContext, usePublishConfig } from \"./PublishConfigContext\"\nimport type { PublishProviderProps } from \"./PublishProvider\"\n\nexport { usePublishConfig }\nexport type { PublishProviderProps }\n\n/**\n * Thirdweb-backed PublishProvider (includes ThirdwebProvider).\n */\nconst PublishProviderThirdweb: FC<PublishProviderProps> = ({\n children,\n config,\n queryClient,\n queryClientRef,\n}) => {\n useEffect(() => {\n if (config) {\n initPublish(config)\n }\n }, [config])\n\n return (\n <PublishConfigContext.Provider value={config ?? getConfigRef()}>\n <ThirdwebProvider>\n <SeedProvider queryClient={queryClient} queryClientRef={queryClientRef}>\n {children}\n </SeedProvider>\n </ThirdwebProvider>\n </PublishConfigContext.Provider>\n )\n}\n\nexport default PublishProviderThirdweb\n","import { deploySmartAccount, getContract } from 'thirdweb'\nimport { getPublishConfig } from '../config'\nimport { Eip7702ModularAccountPublishError } from '../errors'\nimport { isContractDeployed, pollSmartWalletDeployed } from './chainClient'\nimport { getClient, getModularAccountWallet } from './thirdweb'\nimport { getPublishThirdwebChain } from './thirdwebChain'\nimport { getPublishChainName } from './chainConfig'\n\nconst MSG_NO_ACCOUNT =\n 'Modular (EIP-7702) wallet is not connected. Sign in with the same method and try again.'\nconst MSG_NOT_UPGRADED = () =>\n `Your modular account is not upgraded to an EIP-7702 smart account on ${getPublishChainName()} yet. Enable autoDeployEip7702ModularAccount in publish config or complete wallet setup, then retry.`\nconst MSG_DEPLOY_FAILED = () =>\n `Automatic EIP-7702 smart account setup failed on ${getPublishChainName()}. Retry or reconnect your wallet.`\nconst MSG_NOT_CONFIRMED =\n 'EIP-7702 upgrade was sent but on-chain bytecode was not detected yet. Wait a moment and retry.'\n\nconst DEPLOY_POLL_ATTEMPTS = 5\n\n/**\n * Ensures the Thirdweb in-app modular wallet (EIP-7702) has non-empty bytecode at its address\n * on the publish chain. deploySmartAccount remains Thirdweb; bytecode checks use viem.\n */\nexport async function ensureEip7702ModularAccountReady(): Promise<void> {\n const { autoDeployEip7702ModularAccount } = getPublishConfig()\n const modularAccountWallet = getModularAccountWallet()\n await modularAccountWallet.autoConnect({ client: getClient(), chain: getPublishThirdwebChain() })\n const modularAccount = modularAccountWallet.getAccount()\n if (!modularAccount) {\n throw new Eip7702ModularAccountPublishError(MSG_NO_ACCOUNT, 'EIP7702_MODULAR_ACCOUNT_UNAVAILABLE')\n }\n\n const client = getClient()\n const accountContract = getContract({\n client,\n chain: getPublishThirdwebChain(),\n address: modularAccount.address,\n })\n\n if (await isContractDeployed(modularAccount.address)) {\n return\n }\n\n if (!autoDeployEip7702ModularAccount) {\n throw new Eip7702ModularAccountPublishError(\n MSG_NOT_UPGRADED(),\n 'EIP7702_MODULAR_NOT_UPGRADED',\n modularAccount.address,\n )\n }\n\n try {\n await deploySmartAccount({\n smartAccount: modularAccount,\n chain: getPublishThirdwebChain(),\n client,\n accountContract,\n })\n } catch (cause) {\n if (await pollSmartWalletDeployed(modularAccount.address, DEPLOY_POLL_ATTEMPTS)) {\n return\n }\n throw new Eip7702ModularAccountPublishError(\n MSG_DEPLOY_FAILED(),\n 'EIP7702_MODULAR_DEPLOY_FAILED',\n modularAccount.address,\n cause,\n )\n }\n\n if (!(await pollSmartWalletDeployed(modularAccount.address, DEPLOY_POLL_ATTEMPTS))) {\n throw new Eip7702ModularAccountPublishError(\n MSG_NOT_CONFIRMED,\n 'EIP7702_MODULAR_NOT_CONFIRMED',\n modularAccount.address,\n )\n }\n}\n","import { approvedTargetsForAutomationPublish } from './approvedTargetsForAutomationPublish'\n\n/**\n * Allowlisted call targets for a modular session signer: only the Seed executor module.\n *\n * Never the ManagedAccount (a key could then make any self-call, which the account trusts) and\n * never EAS (a direct EAS target bypasses the Seed extension's forced revocability).\n *\n * @deprecated Interactive publishing is a UserOp from the ManagedAccount itself and needs no\n * session key; automation keys use {@link approvedTargetsForAutomationPublish}, which this now\n * returns. `managedAddress` is ignored.\n * @throws if `modularAccountModuleContract` is unset or invalid\n */\nexport function defaultApprovedTargetsForModularPublish(_managedAddress?: string): `0x${string}`[] {\n return approvedTargetsForAutomationPublish()\n}\n","import { getContract, sendTransaction } from 'thirdweb'\nimport { addSessionKey, shouldUpdateSessionKey } from 'thirdweb/extensions/erc4337'\nimport type { Address } from 'viem'\nimport { ManagedAccountPublishError } from '../errors'\nimport { waitForPublishReceipt } from './chainClient'\nimport { readIsActiveSigner } from './contracts'\nimport { defaultApprovedTargetsForModularPublish } from './defaultApprovedTargetsForModularPublish'\nimport { getClient, getManagedAccountWallet } from './thirdweb'\nimport { getPublishThirdwebChain } from './thirdwebChain'\nimport { getPublishChainName } from './chainConfig'\n\nconst MSG_UNAVAILABLE = () =>\n `Could not connect the managed publishing account to authorize the modular signer on ${getPublishChainName()}. Reconnect and try again.`\nconst MSG_ACTIVATION_FAILED = () =>\n `Could not authorize the modular wallet as a session signer on your publishing account on ${getPublishChainName()}.`\n\n/**\n * Ensures the modular (EIP-7702) wallet is an active session signer on the ManagedAccount.\n * If permissions are missing or stale, sends `addSessionKey` signed by the managed EIP-4337 wallet.\n * Session-key AA extensions remain on Thirdweb; verification uses viem.\n *\n * The key may call only the Seed executor module ({@link defaultApprovedTargetsForModularPublish}).\n *\n * @deprecated Interactive publishing is a UserOp from the ManagedAccount itself and needs no\n * session key. For server-held keys use `enrollPublishAutomation`.\n */\nexport async function ensureManagedSignerSessionKey(params: {\n managedAddress: string\n signerAddress: string\n}): Promise<void> {\n const { managedAddress, signerAddress } = params\n const managedWallet = getManagedAccountWallet()\n await managedWallet.autoConnect({ client: getClient(), chain: getPublishThirdwebChain() })\n const managedAccount = managedWallet.getAccount()\n if (!managedAccount) {\n throw new ManagedAccountPublishError(\n MSG_UNAVAILABLE(),\n 'MODULAR_SIGNER_ACTIVATION_FAILED',\n managedAddress,\n )\n }\n\n const accountContract = getContract({\n client: getClient(),\n chain: getPublishThirdwebChain(),\n address: managedAddress,\n })\n const permissions = {\n approvedTargets: defaultApprovedTargetsForModularPublish(managedAddress),\n nativeTokenLimitPerTransaction: 0,\n }\n\n let shouldUpdate = false\n try {\n shouldUpdate = await shouldUpdateSessionKey({\n accountContract,\n sessionKeyAddress: signerAddress,\n newPermissions: permissions,\n })\n } catch (cause) {\n throw new ManagedAccountPublishError(\n MSG_ACTIVATION_FAILED(),\n 'MODULAR_SIGNER_ACTIVATION_FAILED',\n managedAddress,\n cause,\n )\n }\n\n if (shouldUpdate) {\n try {\n const tx = addSessionKey({\n contract: accountContract,\n account: managedAccount,\n sessionKeyAddress: signerAddress,\n permissions,\n })\n const result = await sendTransaction({ account: managedAccount, transaction: tx })\n await waitForPublishReceipt(result.transactionHash as `0x${string}`)\n } catch (cause) {\n throw new ManagedAccountPublishError(\n MSG_ACTIVATION_FAILED(),\n 'MODULAR_SIGNER_ACTIVATION_FAILED',\n managedAddress,\n cause,\n )\n }\n }\n\n let active = false\n try {\n active = await readIsActiveSigner(managedAddress as Address, signerAddress as Address)\n } catch (cause) {\n throw new ManagedAccountPublishError(\n MSG_ACTIVATION_FAILED(),\n 'MODULAR_SIGNER_ACTIVATION_FAILED',\n managedAddress,\n cause,\n )\n }\n\n if (!active) {\n throw new ManagedAccountPublishError(\n MSG_ACTIVATION_FAILED(),\n 'MODULAR_SIGNER_ACTIVATION_FAILED',\n managedAddress,\n )\n }\n}\n","import type { Account } from 'thirdweb/wallets'\nimport type { PublishWallet } from './seedSigner'\nimport { fromThirdwebAccount } from './adapters/thirdwebAccount'\nimport { getPublishConfig } from '../config'\nimport { ManagedAccountPublishError } from '../errors'\nimport { ensureExecutorModuleInstalled, type EnsureExecutorModuleResult } from './ensureExecutorModule'\nimport { assertExecutorModuleReadyForAccount } from './executorModuleReadiness'\nimport {\n ensureAutomationSessionKey,\n removeAutomationSessionKey,\n} from './ensureAutomationSessionKey'\nimport {\n attestPublishAuthorization,\n revokePublishAuthorization,\n type AttestPublishAuthorizationResult,\n} from '../services/publishAuthorization'\nimport { getClient, getManagedAccountWallet } from './thirdweb'\nimport { getPublishThirdwebChain } from './thirdwebChain'\n\nexport type EnrollPublishAutomationParams = {\n managedAddress: string\n sessionKeyAddress: string\n /** Optional app label stored in the sidecar (defaults to zero address). */\n appAddress?: string\n /** Unix seconds session / grant end (optional). */\n expiresAt?: number\n /**\n * User-controlled ManagedAccount wallet used to add the session key and attest the sidecar.\n * When omitted, uses the connected managed in-app wallet.\n */\n userWallet?: PublishWallet\n}\n\nexport type EnrollPublishAutomationResult = {\n managedAddress: string\n sessionKeyAddress: string\n authorization: AttestPublishAuthorizationResult\n}\n\nexport type RevokePublishAutomationParams = {\n managedAddress: string\n sessionKeyAddress: string\n authorizationUid: string\n userWallet?: PublishWallet\n}\n\nasync function connectManagedAccount(managedAddress: string): Promise<Account> {\n const managedWallet = getManagedAccountWallet()\n await managedWallet.autoConnect({ client: getClient(), chain: getPublishThirdwebChain() })\n const account = managedWallet.getAccount()\n if (!account) {\n throw new ManagedAccountPublishError(\n 'Could not connect the managed publishing account to enroll or revoke publish automation.',\n 'MANAGED_ACCOUNT_UNAVAILABLE',\n managedAddress,\n )\n }\n return account\n}\n\nasync function resolveUserWallet(\n managedAddress: string,\n userWallet?: PublishWallet,\n): Promise<PublishWallet> {\n if (userWallet) return userWallet\n return fromThirdwebAccount(await connectManagedAccount(managedAddress))\n}\n\nasync function assertExecutorModuleInstalled(managedAddress: string): Promise<void> {\n const config = getPublishConfig()\n const moduleAddr = config.modularAccountModuleContract?.trim()\n if (!moduleAddr) {\n throw new Error(\n '@seedprotocol/publish: enrollPublishAutomation requires PublishConfig.modularAccountModuleContract',\n )\n }\n\n const twAccount = await connectManagedAccount(managedAddress)\n let install: EnsureExecutorModuleResult\n try {\n install = await ensureExecutorModuleInstalled(managedAddress, twAccount, config)\n } catch (cause) {\n if (cause instanceof ManagedAccountPublishError) throw cause\n throw new ManagedAccountPublishError(\n 'Executor module setup failed for publish automation.',\n 'EXECUTOR_MODULE_NOT_INSTALLED',\n managedAddress,\n cause,\n )\n }\n\n // The session key may only call the module, so refuse to enroll unless the module can act\n // for this account. Otherwise every automation publish would revert. A fresh install is\n // confirmed from its receipt; otherwise the read may still trail an install that just landed.\n await assertExecutorModuleReadyForAccount(\n managedAddress,\n install.status === 'installed'\n ? { installedEas: install.eas }\n : { readAttempts: install.status === 'already-installed' ? 5 : 1 },\n )\n}\n\n/**\n * Enroll an app automation key: install the Seed executor (`installSeedExecutor` on Router\n * accounts with the executor router extension), add an executor-only session key, then attest\n * the PublishAuthorization sidecar (ManagedAccount attester).\n *\n * @throws ManagedAccountPublishError `AUTOMATION_UNSUPPORTED_ACCOUNT` before adding the session\n * key when the executor cannot act for the account (e.g. Router accounts without the extension)\n */\nexport async function enrollPublishAutomation(\n params: EnrollPublishAutomationParams,\n): Promise<EnrollPublishAutomationResult> {\n const { managedAddress, sessionKeyAddress, appAddress, expiresAt } = params\n\n await assertExecutorModuleInstalled(managedAddress)\n await ensureAutomationSessionKey({\n managedAddress,\n sessionKeyAddress,\n expiresAt,\n })\n\n const userWallet = await resolveUserWallet(managedAddress, params.userWallet)\n const authorization = await attestPublishAuthorization({\n wallet: userWallet,\n identity: managedAddress,\n sessionKey: sessionKeyAddress,\n app: appAddress,\n expiresAt,\n })\n\n return {\n managedAddress,\n sessionKeyAddress,\n authorization,\n }\n}\n\n/**\n * Disconnect automation: remove session key, then revoke PublishAuthorization sidecar.\n */\nexport async function revokePublishAutomation(\n params: RevokePublishAutomationParams,\n): Promise<void> {\n const { managedAddress, sessionKeyAddress, authorizationUid } = params\n const userWallet = await resolveUserWallet(managedAddress, params.userWallet)\n\n await removeAutomationSessionKey({\n managedAddress,\n sessionKeyAddress,\n })\n\n await revokePublishAuthorization({\n wallet: userWallet,\n uid: authorizationUid,\n })\n}\n","import {\n assessPublishAuthorization,\n decodePublishAuthorizationData,\n getPublishAuthorizationFromEas,\n} from '@seedprotocol/eas'\nimport { isAutomationSessionActive } from './ensureAutomationSessionKey'\n\nexport type AssertStorageBoundToIdentityParams = {\n managedAddress: string\n /** Recovered ANS-104 DataItem owner (Ethereum address). */\n dataItemOwner: string\n /**\n * Unix seconds for historical binding checks against PublishAuthorization expiry.\n * Defaults to now. Session-key live check always uses current `isActiveSigner`.\n */\n atTime?: number\n /**\n * When true (default), accept a live active session key on the ManagedAccount.\n */\n allowActiveSessionKey?: boolean\n /**\n * When true (default), accept a non-revoked PublishAuthorization sidecar valid at `atTime`.\n */\n allowSidecar?: boolean\n}\n\nexport type AssertStorageBoundToIdentityResult = {\n bound: boolean\n via: 'active_session_key' | 'publish_authorization' | null\n warnings: string[]\n}\n\n/**\n * Whether an Arweave DataItem owner is bound to a ManagedAccount identity for authorship.\n * Prefer live `isActiveSigner` for current publishes; use the PublishAuthorization sidecar\n * for discoverability / historical grants (revoking the session key stops new binds via\n * active check; sidecar validity is assessed at `atTime`).\n */\nexport async function assertStorageBoundToIdentity(\n params: AssertStorageBoundToIdentityParams,\n): Promise<AssertStorageBoundToIdentityResult> {\n const {\n managedAddress,\n dataItemOwner,\n atTime,\n allowActiveSessionKey = true,\n allowSidecar = true,\n } = params\n const warnings: string[] = []\n const owner = dataItemOwner.trim().toLowerCase()\n const identity = managedAddress.trim().toLowerCase()\n\n if (!/^0x[0-9a-fA-F]{40}$/.test(owner) || !/^0x[0-9a-fA-F]{40}$/.test(identity)) {\n return { bound: false, via: null, warnings: ['Invalid managedAddress or dataItemOwner'] }\n }\n\n if (allowActiveSessionKey) {\n try {\n const active = await isAutomationSessionActive(managedAddress, dataItemOwner)\n if (active) {\n return { bound: true, via: 'active_session_key', warnings }\n }\n } catch (e) {\n warnings.push(\n e instanceof Error ? e.message : 'isActiveSigner check failed',\n )\n }\n }\n\n if (allowSidecar) {\n try {\n const rows = await getPublishAuthorizationFromEas({\n identities: [managedAddress],\n sessionKeys: [dataItemOwner],\n excludeRevoked: true,\n })\n const nowMs = atTime != null ? atTime * 1000 : Date.now()\n for (const row of rows) {\n try {\n const decoded = decodePublishAuthorizationData(row.decodedDataJson ?? '[]')\n if (decoded.identity.toLowerCase() !== identity) continue\n if (decoded.sessionKey.toLowerCase() !== owner) continue\n const expirationTime =\n typeof row.expirationTime === 'number' ? row.expirationTime : null\n const assess = assessPublishAuthorization({\n decoded,\n expirationTime,\n now: nowMs,\n })\n if (assess.status === 'valid') {\n return {\n bound: true,\n via: 'publish_authorization',\n warnings: [...warnings, ...assess.warnings],\n }\n }\n warnings.push(...assess.warnings)\n } catch {\n // skip undecodable row\n }\n }\n } catch (e) {\n warnings.push(\n e instanceof Error ? e.message : 'PublishAuthorization query failed',\n )\n }\n }\n\n return { bound: false, via: null, warnings }\n}\n"],"mappings":";;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K,IAAI,IAAzBA,IAAS;EACxC,KAAK,IAAMC,KAAOJ,GAChB,IAAI;GACF,IAAMK,IAAUC,GAA+BF,EAAI,mBAAmB,IAAI;GAE1E,IADIC,EAAQ,SAAS,YAAY,MAAMR,KACnCQ,EAAQ,WAAW,YAAY,MAAMV,GAAO;GAChD,IAAMY,IACJ,OAAOH,EAAI,kBAAmB,WAAWA,EAAI,iBAAiB,MAC1DI,IAASC,GAA2B;IACxC;IACA;IACA,KAAKP;GACP,CAAC;GACD,IAAIM,EAAO,WAAW,SACpB,OAAO;IACL,OAAO;IACP,KAAK;IACL,UAAU,CAAC,GAAGd,GAAU,GAAGc,EAAO,QAAQ;GAC5C;GAEF,EAAS,KAAK,GAAGA,EAAO,QAAQ;EAClC,QAAQ,CAER;CAEJ,SAAS,GAAG;EACV,EAAS,KACP,aAAa,QAAQ,EAAE,UAAU,mCACnC;CACF;CAGF,OAAO;EAAE,OAAO;EAAO,KAAK;EAAM;CAAS;AAC7C"}
|
|
1
|
+
{"version":3,"file":"thirdweb.js","names":["seedClient","ConnectButtonThirdweb","pollSmartWalletDeployed","useLocalWalletAccount","ensureManagedAccountReady","getConnectedAccount","getSharedPublishInAppWalletStorage","getConnectedModularAccount","pollSmartWalletDeployed$1","ExternalWalletsForDeploy","isSmartWalletDeployed","getSmartWalletAddressForAdmin","Eip7702ModularAccountPublishError","appMetadata","tryDeployManagedAccount","ensureExecutorModuleInstalled","assertExecutorModuleReadyForAccount","useActiveSmartWalletContract","deployManagedAccountViaFactory","readIsActiveSigner","getManagedAccountWallet","getConnectedManagedAccountAddress","isContractDeployed","getModularAccountWallet","waitForPublishReceipt","resolveSmartWalletForPublish","pollSmartWalletDeployed","syncPublishInAppAuthToken","getPublishThirdwebChain","getPublishConfig","wallets","fromThirdwebAccount","asThirdwebPublishWallet","getConfigRef","runModularExecutorPublishPrep","PublishManager","asSeedSignerFromThirdweb","seedPaymaster","initPublish","getWalletsForConnectButton","ManagedAccountPublishError","getClient","getPublishChainName","CALL_GAS_HEADROOM_BPS","deploySmartWalletContract","setPublishWallet","clearPublishWallet","attestPublishAuthorization","buildAutomationSessionKeyPermissions","hashAutomationSessionKeyPermissions","usePublishConfig","PublishConfigContext","revokePublishAuthorization","approvedTargetsForAutomationPublish","toThirdwebSessionKeyPermissions","PUBLISH_AUTOMATION_SCOPES","ensureSmartWalletThenPublish","ensureModularPublishBootstrap","removeAutomationSessionKey","isAutomationSessionActive","ensureAutomationSessionKey","ConnectButton$1","USER_DISCONNECTED_SESSION_KEY","reportWalletSetupWarning","err","waitUntilSeedInitialized","client","resolve","ensureExecutorModulesForConnect","config","managedAddress","mw","ma","modularAccount","ConnectButton","thirdwebChain","wallet","useActiveWallet","activeAccount","useActiveAccount","connectionStatus","useActiveWalletConnectionStatus","isAutoConnecting","useIsAutoConnecting","lastSyncedOwnedKey","useRef","prevIsAutoConnecting","reloadAutoConnectRetried","prev","navType","userChoseDisconnect","syncActiveWalletToSeed","useCallback","account","activeWallet","owned","adminAddress","tryManaged","r","ownedKey","isSmart","publishWallet","useEffect","cancelled","darkTheme","PublishProviderThirdweb","initializedConfig","ThirdwebProvider","SeedProvider","MSG_NO_ACCOUNT","MSG_NOT_UPGRADED","MSG_DEPLOY_FAILED","MSG_NOT_CONFIRMED","DEPLOY_POLL_ATTEMPTS","ensureEip7702ModularAccountReady","modularAccountWallet","accountContract","getContract","autoDeployEip7702ModularAccount","deploySmartAccount","cause","defaultApprovedTargetsForModularPublish","MSG_UNAVAILABLE","MSG_ACTIVATION_FAILED","ensureManagedSignerSessionKey","params","managedWallet","managedAccount","permissions","shouldUpdate","shouldUpdateSessionKey","signerAddress","tx","addSessionKey","result","sendTransaction","active","connectManagedAccount","resolveUserWallet","userWallet","assertExecutorModuleInstalled","twAccount","install","enrollPublishAutomation","sessionKeyAddress","appAddress","revokePublishAutomation","authorizationUid","assertStorageBoundToIdentity","warnings","owner","dataItemOwner","identity","allowActiveSessionKey","allowSidecar","rows","getPublishAuthorizationFromEas","nowMs","atTime","row","decoded","decodePublishAuthorizationData","expirationTime","assess","assessPublishAuthorization"],"sources":["../src/react/ConnectButton.tsx","../src/react/PublishProvider.thirdweb.tsx","../src/helpers/ensureEip7702ModularAccountReady.ts","../src/helpers/defaultApprovedTargetsForModularPublish.ts","../src/helpers/ensureManagedSignerSessionKey.ts","../src/helpers/enrollPublishAutomation.ts","../src/helpers/assertStorageBoundToIdentity.ts"],"sourcesContent":["import React, { FC, useCallback, useEffect, useRef } from \"react\"\nimport {\n ConnectButton as ConnectButtonThirdweb,\n darkTheme,\n useActiveAccount,\n useActiveWallet,\n useActiveWalletConnectionStatus,\n useIsAutoConnecting,\n} from \"thirdweb/react\"\nimport { client as seedClient } from \"@seedprotocol/sdk\"\nimport {\n getClient,\n getConnectedManagedAccountAddress,\n getManagedAccountWallet,\n getModularAccountWallet,\n getSmartWalletAddressForAdmin,\n getWalletsForConnectButton,\n syncPublishInAppAuthToken,\n} from \"../helpers/thirdweb\"\nimport { fromThirdwebAccount } from \"../helpers/adapters/thirdwebAccount\"\nimport { setPublishWallet, clearPublishWallet } from \"../helpers/publishWalletRegistry\"\nimport { usePublishConfig } from \"./PublishConfigContext\"\nimport { getPublishConfig } from \"../config\"\nimport type { Account, Wallet } from \"thirdweb/wallets\"\nimport type { PublishConfig } from \"../config\"\nimport { ensureExecutorModuleInstalled } from \"../helpers/ensureExecutorModule\"\nimport { PublishManager } from \"../services/publishManager\"\nimport { getPublishThirdwebChain } from '../helpers/thirdwebChain'\n\n/** Session flag so we do not force autoConnect after an explicit UI disconnect (survives reload). */\nconst USER_DISCONNECTED_SESSION_KEY = \"seedProtocol:publish:userChoseWalletDisconnect\"\n\nfunction reportWalletSetupWarning(err: unknown) {\n // Expected when managed-wallet autoConnect is still catching up; publish prep retries.\n console.warn(\"[ConnectButton] Wallet setup / module install skipped:\", err)\n getPublishConfig().onWalletSetupWarning?.(err)\n}\n\n/** Resolves after `ClientManager.init()` has finished; `setAddresses` requires this. */\nfunction waitUntilSeedInitialized(): Promise<void> {\n if (seedClient.isInitialized()) return Promise.resolve()\n return new Promise((resolve) => {\n seedClient.onReady(() => resolve())\n })\n}\n\n/**\n * Installs the Seed executor on the **ManagedAccount** (EIP-4337 Router) contract via its\n * `SeedExecutorRouterExtension`. Other accounts, such as the EIP-7702 modular wallet, have no\n * extension, so `ensureExecutorModuleInstalled` skips them.\n */\nasync function ensureExecutorModulesForConnect(\n modularAccount: Account,\n managedAddress: string | undefined,\n config: PublishConfig,\n): Promise<void> {\n if (!config.modularAccountModuleContract) {\n return\n }\n\n if (config.useModularExecutor) {\n if (!managedAddress) {\n return\n }\n try {\n syncPublishInAppAuthToken()\n const mw = getManagedAccountWallet()\n await mw.autoConnect({ client: getClient(), chain: getPublishThirdwebChain(config) })\n const ma = mw.getAccount()\n if (!ma) {\n return\n }\n await ensureExecutorModuleInstalled(managedAddress, ma, config)\n } catch {\n /* managed wallet session may lag modular connect; publish prep retries module install */\n }\n return\n }\n\n try {\n await ensureExecutorModuleInstalled(modularAccount.address, modularAccount, config)\n } catch (err) {\n reportWalletSetupWarning(err)\n }\n}\n\nconst ConnectButton: FC = () => {\n const config = usePublishConfig()\n const thirdwebChain = getPublishThirdwebChain(config)\n const wallet = useActiveWallet()\n const activeAccount = useActiveAccount()\n const connectionStatus = useActiveWalletConnectionStatus()\n const isAutoConnecting = useIsAutoConnecting()\n /** Avoid duplicate setAddresses when onConnect and the reconcile effect both run. */\n const lastSyncedOwnedKey = useRef<string | null>(null)\n const prevIsAutoConnecting = useRef(false)\n const reloadAutoConnectRetried = useRef(false)\n\n /**\n * Thirdweb sometimes finishes autoConnect on full reload with `disconnected` and no wallet\n * (see debug: isAutoConnecting true→false then disconnected). One explicit in-app autoConnect\n * retry recovers without affecting users who chose Disconnect (sessionStorage gate).\n */\n useEffect(() => {\n if (typeof window === \"undefined\") return\n const prev = prevIsAutoConnecting.current\n prevIsAutoConnecting.current = isAutoConnecting\n\n let navType: string | undefined\n try {\n navType = (\n performance.getEntriesByType(\"navigation\")[0] as\n | PerformanceNavigationTiming\n | undefined\n )?.type\n } catch {\n navType = undefined\n }\n if (navType !== \"reload\") return\n\n let userChoseDisconnect = false\n try {\n userChoseDisconnect =\n sessionStorage.getItem(USER_DISCONNECTED_SESSION_KEY) === \"1\"\n } catch {\n userChoseDisconnect = false\n }\n if (userChoseDisconnect) return\n\n if (!prev || isAutoConnecting || connectionStatus !== \"disconnected\") return\n if (reloadAutoConnectRetried.current) return\n reloadAutoConnectRetried.current = true\n\n void (config.useModularExecutor ? getModularAccountWallet() : getManagedAccountWallet())\n .autoConnect({ client: getClient(), chain: thirdwebChain })\n .catch(() => {\n /* no session or iframe not ready; Connect UI can still sign in */\n })\n }, [connectionStatus, isAutoConnecting, config.useModularExecutor, thirdwebChain])\n\n const syncActiveWalletToSeed = useCallback(\n async (activeWallet: Wallet) => {\n const account = activeWallet.getAccount()\n if (!account) {\n return\n }\n await waitUntilSeedInitialized()\n const owned = new Set<string>([account.address.toLowerCase()])\n let managedAddress: string | undefined\n if (config.useModularExecutor) {\n syncPublishInAppAuthToken()\n const adminAddress =\n activeWallet.getAdminAccount?.()?.address ?? account.address\n const tryManaged = async () => {\n try {\n return await getConnectedManagedAccountAddress(thirdwebChain)\n } catch {\n try {\n return await getSmartWalletAddressForAdmin(adminAddress)\n } catch {\n return undefined\n }\n }\n }\n managedAddress = await tryManaged()\n if (!managedAddress) {\n await new Promise<void>((r) => queueMicrotask(() => r()))\n managedAddress = await tryManaged()\n }\n if (managedAddress) {\n owned.add(managedAddress.toLowerCase())\n }\n }\n const ownedKey = [...owned].sort().join(\",\")\n if (lastSyncedOwnedKey.current === ownedKey) {\n return\n }\n // Another wallet took over: publishes started for the previous one stop (their rows stay\n // for it to resume). Not on the first sync, where publishes restored from the DB need this\n // wallet, nor on a re-sync of the same wallet.\n if (lastSyncedOwnedKey.current !== null) {\n PublishManager.stopAll()\n }\n lastSyncedOwnedKey.current = ownedKey\n try {\n const adminAddress = activeWallet.getAdminAccount?.()?.address\n // A wallet with a separate admin account, or the modular executor's ManagedAccount, is a\n // smart account; otherwise the connected account is a plain key (in-app or injected).\n const isSmart =\n !!managedAddress ||\n (!!adminAddress && adminAddress.toLowerCase() !== account.address.toLowerCase())\n const publishWallet = fromThirdwebAccount(account, { kind: isSmart ? \"smart\" : \"eoa\" })\n await setPublishWallet({\n ...publishWallet,\n ownedAddresses: [...owned],\n publisherAddress: managedAddress ?? account.address,\n ...(adminAddress && adminAddress.toLowerCase() !== account.address.toLowerCase()\n ? { adminAddress }\n : {}),\n })\n } catch (err) {\n lastSyncedOwnedKey.current = null\n console.warn(\"[ConnectButton] Failed to set seed client addresses:\", err)\n throw err\n }\n await ensureExecutorModulesForConnect(account, managedAddress, config)\n },\n [config],\n )\n\n /**\n * Thirdweb autoConnect restores the wallet without calling onConnect. Seed addresses live in\n * SQLite (OPFS); after a wipe there is no app_state row until setAddresses runs again.\n */\n useEffect(() => {\n if (isAutoConnecting) {\n return\n }\n if (connectionStatus !== \"connected\") {\n lastSyncedOwnedKey.current = null\n return\n }\n if (!wallet) {\n return\n }\n let cancelled = false\n void (async () => {\n try {\n if (cancelled) return\n await syncActiveWalletToSeed(wallet)\n } catch {\n /* logged in syncActiveWalletToSeed */\n }\n })()\n return () => {\n cancelled = true\n }\n }, [\n wallet,\n activeAccount?.address,\n connectionStatus,\n isAutoConnecting,\n syncActiveWalletToSeed,\n ])\n\n const handleDisconnect = () => {\n try {\n sessionStorage.setItem(USER_DISCONNECTED_SESSION_KEY, \"1\")\n } catch {\n /* private mode / SSR */\n }\n void clearPublishWallet()\n PublishManager.stopAll()\n }\n\n const handleConnect = async (activeWallet: Wallet, _allConnectedWallets: Wallet[]) => {\n const account = activeWallet.getAccount()\n if (!account) return\n try {\n sessionStorage.removeItem(USER_DISCONNECTED_SESSION_KEY)\n } catch {\n /* ignore */\n }\n console.log('[ConnectButton] Connected', account.address)\n try {\n await syncActiveWalletToSeed(activeWallet)\n } catch {\n /* syncActiveWalletToSeed logs */\n }\n }\n\n return (\n <ConnectButtonThirdweb\n client={getClient()}\n wallets={getWalletsForConnectButton(config)}\n autoConnect={true}\n chain={thirdwebChain}\n chains={[ thirdwebChain, ]}\n onConnect={handleConnect}\n onDisconnect={handleDisconnect}\n theme={darkTheme({\n colors: {\n primaryButtonBg: '#1D2939',\n primaryButtonText: '#FFFFFF',\n secondaryButtonHoverBg: '#1D2939',\n connectedButtonBg: '#101828',\n connectedButtonBgHover: '#1D2939',\n borderColor: '#344054',\n },\n })}\n />\n )\n}\n\nexport default ConnectButton\n","import React, { FC, useRef } from \"react\"\nimport type { MutableRefObject } from \"react\"\nimport type { QueryClient } from \"@tanstack/react-query\"\nimport { ThirdwebProvider } from \"thirdweb/react\"\nimport { SeedProvider } from '@seedprotocol/react'\nimport { initPublish, getConfigRef, type PublishConfig } from \"../config\"\nimport { PublishConfigContext, usePublishConfig } from \"./PublishConfigContext\"\nimport type { PublishProviderProps } from \"./PublishProvider\"\n\nexport { usePublishConfig }\nexport type { PublishProviderProps }\n\n/**\n * Thirdweb-backed PublishProvider (includes ThirdwebProvider).\n */\nconst PublishProviderThirdweb: FC<PublishProviderProps> = ({\n children,\n config,\n queryClient,\n queryClientRef,\n}) => {\n // During render, not in an effect: children such as ConnectButton read the config on their\n // first render, which runs before this provider's effects. Once per config object.\n const initializedConfig = useRef<PublishConfig | undefined>(undefined)\n if (config && initializedConfig.current !== config) {\n initPublish(config)\n initializedConfig.current = config\n }\n\n return (\n <PublishConfigContext.Provider value={config ?? getConfigRef()}>\n <ThirdwebProvider>\n <SeedProvider queryClient={queryClient} queryClientRef={queryClientRef}>\n {children}\n </SeedProvider>\n </ThirdwebProvider>\n </PublishConfigContext.Provider>\n )\n}\n\nexport default PublishProviderThirdweb\n","import { deploySmartAccount, getContract } from 'thirdweb'\nimport { getPublishConfig } from '../config'\nimport { Eip7702ModularAccountPublishError } from '../errors'\nimport { isContractDeployed, pollSmartWalletDeployed } from './chainClient'\nimport { getClient, getModularAccountWallet } from './thirdweb'\nimport { getPublishThirdwebChain } from './thirdwebChain'\nimport { getPublishChainName } from './chainConfig'\n\nconst MSG_NO_ACCOUNT =\n 'Modular (EIP-7702) wallet is not connected. Sign in with the same method and try again.'\nconst MSG_NOT_UPGRADED = () =>\n `Your modular account is not upgraded to an EIP-7702 smart account on ${getPublishChainName()} yet. Enable autoDeployEip7702ModularAccount in publish config or complete wallet setup, then retry.`\nconst MSG_DEPLOY_FAILED = () =>\n `Automatic EIP-7702 smart account setup failed on ${getPublishChainName()}. Retry or reconnect your wallet.`\nconst MSG_NOT_CONFIRMED =\n 'EIP-7702 upgrade was sent but on-chain bytecode was not detected yet. Wait a moment and retry.'\n\nconst DEPLOY_POLL_ATTEMPTS = 5\n\n/**\n * Ensures the Thirdweb in-app modular wallet (EIP-7702) has non-empty bytecode at its address\n * on the publish chain. deploySmartAccount remains Thirdweb; bytecode checks use viem.\n */\nexport async function ensureEip7702ModularAccountReady(): Promise<void> {\n const { autoDeployEip7702ModularAccount } = getPublishConfig()\n const modularAccountWallet = getModularAccountWallet()\n await modularAccountWallet.autoConnect({ client: getClient(), chain: getPublishThirdwebChain() })\n const modularAccount = modularAccountWallet.getAccount()\n if (!modularAccount) {\n throw new Eip7702ModularAccountPublishError(MSG_NO_ACCOUNT, 'EIP7702_MODULAR_ACCOUNT_UNAVAILABLE')\n }\n\n const client = getClient()\n const accountContract = getContract({\n client,\n chain: getPublishThirdwebChain(),\n address: modularAccount.address,\n })\n\n if (await isContractDeployed(modularAccount.address)) {\n return\n }\n\n if (!autoDeployEip7702ModularAccount) {\n throw new Eip7702ModularAccountPublishError(\n MSG_NOT_UPGRADED(),\n 'EIP7702_MODULAR_NOT_UPGRADED',\n modularAccount.address,\n )\n }\n\n try {\n await deploySmartAccount({\n smartAccount: modularAccount,\n chain: getPublishThirdwebChain(),\n client,\n accountContract,\n })\n } catch (cause) {\n if (await pollSmartWalletDeployed(modularAccount.address, DEPLOY_POLL_ATTEMPTS)) {\n return\n }\n throw new Eip7702ModularAccountPublishError(\n MSG_DEPLOY_FAILED(),\n 'EIP7702_MODULAR_DEPLOY_FAILED',\n modularAccount.address,\n cause,\n )\n }\n\n if (!(await pollSmartWalletDeployed(modularAccount.address, DEPLOY_POLL_ATTEMPTS))) {\n throw new Eip7702ModularAccountPublishError(\n MSG_NOT_CONFIRMED,\n 'EIP7702_MODULAR_NOT_CONFIRMED',\n modularAccount.address,\n )\n }\n}\n","import { approvedTargetsForAutomationPublish } from './approvedTargetsForAutomationPublish'\n\n/**\n * Allowlisted call targets for a modular session signer: only the Seed executor module.\n *\n * Never the ManagedAccount (a key could then make any self-call, which the account trusts) and\n * never EAS (a direct EAS target bypasses the Seed extension's forced revocability).\n *\n * @deprecated Interactive publishing is a UserOp from the ManagedAccount itself and needs no\n * session key; automation keys use {@link approvedTargetsForAutomationPublish}, which this now\n * returns. `managedAddress` is ignored.\n * @throws if `modularAccountModuleContract` is unset or invalid\n */\nexport function defaultApprovedTargetsForModularPublish(_managedAddress?: string): `0x${string}`[] {\n return approvedTargetsForAutomationPublish()\n}\n","import { getContract, sendTransaction } from 'thirdweb'\nimport { addSessionKey, shouldUpdateSessionKey } from 'thirdweb/extensions/erc4337'\nimport type { Address } from 'viem'\nimport { ManagedAccountPublishError } from '../errors'\nimport { waitForPublishReceipt } from './chainClient'\nimport { readIsActiveSigner } from './contracts'\nimport { defaultApprovedTargetsForModularPublish } from './defaultApprovedTargetsForModularPublish'\nimport { getClient, getManagedAccountWallet } from './thirdweb'\nimport { getPublishThirdwebChain } from './thirdwebChain'\nimport { getPublishChainName } from './chainConfig'\n\nconst MSG_UNAVAILABLE = () =>\n `Could not connect the managed publishing account to authorize the modular signer on ${getPublishChainName()}. Reconnect and try again.`\nconst MSG_ACTIVATION_FAILED = () =>\n `Could not authorize the modular wallet as a session signer on your publishing account on ${getPublishChainName()}.`\n\n/**\n * Ensures the modular (EIP-7702) wallet is an active session signer on the ManagedAccount.\n * If permissions are missing or stale, sends `addSessionKey` signed by the managed EIP-4337 wallet.\n * Session-key AA extensions remain on Thirdweb; verification uses viem.\n *\n * The key may call only the Seed executor module ({@link defaultApprovedTargetsForModularPublish}).\n *\n * @deprecated Interactive publishing is a UserOp from the ManagedAccount itself and needs no\n * session key. For server-held keys use `enrollPublishAutomation`.\n */\nexport async function ensureManagedSignerSessionKey(params: {\n managedAddress: string\n signerAddress: string\n}): Promise<void> {\n const { managedAddress, signerAddress } = params\n const managedWallet = getManagedAccountWallet()\n await managedWallet.autoConnect({ client: getClient(), chain: getPublishThirdwebChain() })\n const managedAccount = managedWallet.getAccount()\n if (!managedAccount) {\n throw new ManagedAccountPublishError(\n MSG_UNAVAILABLE(),\n 'MODULAR_SIGNER_ACTIVATION_FAILED',\n managedAddress,\n )\n }\n\n const accountContract = getContract({\n client: getClient(),\n chain: getPublishThirdwebChain(),\n address: managedAddress,\n })\n const permissions = {\n approvedTargets: defaultApprovedTargetsForModularPublish(managedAddress),\n nativeTokenLimitPerTransaction: 0,\n }\n\n let shouldUpdate = false\n try {\n shouldUpdate = await shouldUpdateSessionKey({\n accountContract,\n sessionKeyAddress: signerAddress,\n newPermissions: permissions,\n })\n } catch (cause) {\n throw new ManagedAccountPublishError(\n MSG_ACTIVATION_FAILED(),\n 'MODULAR_SIGNER_ACTIVATION_FAILED',\n managedAddress,\n cause,\n )\n }\n\n if (shouldUpdate) {\n try {\n const tx = addSessionKey({\n contract: accountContract,\n account: managedAccount,\n sessionKeyAddress: signerAddress,\n permissions,\n })\n const result = await sendTransaction({ account: managedAccount, transaction: tx })\n await waitForPublishReceipt(result.transactionHash as `0x${string}`)\n } catch (cause) {\n throw new ManagedAccountPublishError(\n MSG_ACTIVATION_FAILED(),\n 'MODULAR_SIGNER_ACTIVATION_FAILED',\n managedAddress,\n cause,\n )\n }\n }\n\n let active = false\n try {\n active = await readIsActiveSigner(managedAddress as Address, signerAddress as Address)\n } catch (cause) {\n throw new ManagedAccountPublishError(\n MSG_ACTIVATION_FAILED(),\n 'MODULAR_SIGNER_ACTIVATION_FAILED',\n managedAddress,\n cause,\n )\n }\n\n if (!active) {\n throw new ManagedAccountPublishError(\n MSG_ACTIVATION_FAILED(),\n 'MODULAR_SIGNER_ACTIVATION_FAILED',\n managedAddress,\n )\n }\n}\n","import type { Account } from 'thirdweb/wallets'\nimport type { PublishWallet } from './seedSigner'\nimport { fromThirdwebAccount } from './adapters/thirdwebAccount'\nimport { getPublishConfig } from '../config'\nimport { ManagedAccountPublishError } from '../errors'\nimport { ensureExecutorModuleInstalled, type EnsureExecutorModuleResult } from './ensureExecutorModule'\nimport { assertExecutorModuleReadyForAccount } from './executorModuleReadiness'\nimport {\n ensureAutomationSessionKey,\n removeAutomationSessionKey,\n} from './ensureAutomationSessionKey'\nimport {\n attestPublishAuthorization,\n revokePublishAuthorization,\n type AttestPublishAuthorizationResult,\n} from '../services/publishAuthorization'\nimport { getClient, getManagedAccountWallet } from './thirdweb'\nimport { getPublishThirdwebChain } from './thirdwebChain'\n\nexport type EnrollPublishAutomationParams = {\n managedAddress: string\n sessionKeyAddress: string\n /** Optional app label stored in the sidecar (defaults to zero address). */\n appAddress?: string\n /** Unix seconds session / grant end (optional). */\n expiresAt?: number\n /**\n * User-controlled ManagedAccount wallet used to add the session key and attest the sidecar.\n * When omitted, uses the connected managed in-app wallet.\n */\n userWallet?: PublishWallet\n}\n\nexport type EnrollPublishAutomationResult = {\n managedAddress: string\n sessionKeyAddress: string\n authorization: AttestPublishAuthorizationResult\n}\n\nexport type RevokePublishAutomationParams = {\n managedAddress: string\n sessionKeyAddress: string\n authorizationUid: string\n userWallet?: PublishWallet\n}\n\nasync function connectManagedAccount(managedAddress: string): Promise<Account> {\n const managedWallet = getManagedAccountWallet()\n await managedWallet.autoConnect({ client: getClient(), chain: getPublishThirdwebChain() })\n const account = managedWallet.getAccount()\n if (!account) {\n throw new ManagedAccountPublishError(\n 'Could not connect the managed publishing account to enroll or revoke publish automation.',\n 'MANAGED_ACCOUNT_UNAVAILABLE',\n managedAddress,\n )\n }\n return account\n}\n\nasync function resolveUserWallet(\n managedAddress: string,\n userWallet?: PublishWallet,\n): Promise<PublishWallet> {\n if (userWallet) return userWallet\n return fromThirdwebAccount(await connectManagedAccount(managedAddress), { kind: 'smart' })\n}\n\nasync function assertExecutorModuleInstalled(managedAddress: string): Promise<void> {\n const config = getPublishConfig()\n const moduleAddr = config.modularAccountModuleContract?.trim()\n if (!moduleAddr) {\n throw new Error(\n '@seedprotocol/publish: enrollPublishAutomation requires PublishConfig.modularAccountModuleContract',\n )\n }\n\n const twAccount = await connectManagedAccount(managedAddress)\n let install: EnsureExecutorModuleResult\n try {\n install = await ensureExecutorModuleInstalled(managedAddress, twAccount, config)\n } catch (cause) {\n if (cause instanceof ManagedAccountPublishError) throw cause\n throw new ManagedAccountPublishError(\n 'Executor module setup failed for publish automation.',\n 'EXECUTOR_MODULE_NOT_INSTALLED',\n managedAddress,\n cause,\n )\n }\n\n // The session key may only call the module, so refuse to enroll unless the module can act\n // for this account. Otherwise every automation publish would revert. A fresh install is\n // confirmed from its receipt; otherwise the read may still trail an install that just landed.\n await assertExecutorModuleReadyForAccount(\n managedAddress,\n install.status === 'installed'\n ? { installedEas: install.eas }\n : { readAttempts: install.status === 'already-installed' ? 5 : 1 },\n )\n}\n\n/**\n * Enroll an app automation key: install the Seed executor (`installSeedExecutor` on Router\n * accounts with the executor router extension), add an executor-only session key, then attest\n * the PublishAuthorization sidecar (ManagedAccount attester).\n *\n * @throws ManagedAccountPublishError `AUTOMATION_UNSUPPORTED_ACCOUNT` before adding the session\n * key when the executor cannot act for the account (e.g. Router accounts without the extension)\n */\nexport async function enrollPublishAutomation(\n params: EnrollPublishAutomationParams,\n): Promise<EnrollPublishAutomationResult> {\n const { managedAddress, sessionKeyAddress, appAddress, expiresAt } = params\n\n await assertExecutorModuleInstalled(managedAddress)\n await ensureAutomationSessionKey({\n managedAddress,\n sessionKeyAddress,\n expiresAt,\n })\n\n const userWallet = await resolveUserWallet(managedAddress, params.userWallet)\n const authorization = await attestPublishAuthorization({\n wallet: userWallet,\n identity: managedAddress,\n sessionKey: sessionKeyAddress,\n app: appAddress,\n expiresAt,\n })\n\n return {\n managedAddress,\n sessionKeyAddress,\n authorization,\n }\n}\n\n/**\n * Disconnect automation: remove session key, then revoke PublishAuthorization sidecar.\n */\nexport async function revokePublishAutomation(\n params: RevokePublishAutomationParams,\n): Promise<void> {\n const { managedAddress, sessionKeyAddress, authorizationUid } = params\n const userWallet = await resolveUserWallet(managedAddress, params.userWallet)\n\n await removeAutomationSessionKey({\n managedAddress,\n sessionKeyAddress,\n })\n\n await revokePublishAuthorization({\n wallet: userWallet,\n uid: authorizationUid,\n })\n}\n","import {\n assessPublishAuthorization,\n decodePublishAuthorizationData,\n getPublishAuthorizationFromEas,\n} from '@seedprotocol/eas'\nimport { isAutomationSessionActive } from './ensureAutomationSessionKey'\n\nexport type AssertStorageBoundToIdentityParams = {\n managedAddress: string\n /** Recovered ANS-104 DataItem owner (Ethereum address). */\n dataItemOwner: string\n /**\n * Unix seconds for historical binding checks against PublishAuthorization expiry.\n * Defaults to now. Session-key live check always uses current `isActiveSigner`.\n */\n atTime?: number\n /**\n * When true (default), accept a live active session key on the ManagedAccount.\n */\n allowActiveSessionKey?: boolean\n /**\n * When true (default), accept a non-revoked PublishAuthorization sidecar valid at `atTime`.\n */\n allowSidecar?: boolean\n}\n\nexport type AssertStorageBoundToIdentityResult = {\n bound: boolean\n via: 'active_session_key' | 'publish_authorization' | null\n warnings: string[]\n}\n\n/**\n * Whether an Arweave DataItem owner is bound to a ManagedAccount identity for authorship.\n * Prefer live `isActiveSigner` for current publishes; use the PublishAuthorization sidecar\n * for discoverability / historical grants (revoking the session key stops new binds via\n * active check; sidecar validity is assessed at `atTime`).\n */\nexport async function assertStorageBoundToIdentity(\n params: AssertStorageBoundToIdentityParams,\n): Promise<AssertStorageBoundToIdentityResult> {\n const {\n managedAddress,\n dataItemOwner,\n atTime,\n allowActiveSessionKey = true,\n allowSidecar = true,\n } = params\n const warnings: string[] = []\n const owner = dataItemOwner.trim().toLowerCase()\n const identity = managedAddress.trim().toLowerCase()\n\n if (!/^0x[0-9a-fA-F]{40}$/.test(owner) || !/^0x[0-9a-fA-F]{40}$/.test(identity)) {\n return { bound: false, via: null, warnings: ['Invalid managedAddress or dataItemOwner'] }\n }\n\n if (allowActiveSessionKey) {\n try {\n const active = await isAutomationSessionActive(managedAddress, dataItemOwner)\n if (active) {\n return { bound: true, via: 'active_session_key', warnings }\n }\n } catch (e) {\n warnings.push(\n e instanceof Error ? e.message : 'isActiveSigner check failed',\n )\n }\n }\n\n if (allowSidecar) {\n try {\n const rows = await getPublishAuthorizationFromEas({\n identities: [managedAddress],\n sessionKeys: [dataItemOwner],\n excludeRevoked: true,\n })\n const nowMs = atTime != null ? atTime * 1000 : Date.now()\n for (const row of rows) {\n try {\n const decoded = decodePublishAuthorizationData(row.decodedDataJson ?? '[]')\n if (decoded.identity.toLowerCase() !== identity) continue\n if (decoded.sessionKey.toLowerCase() !== owner) continue\n const expirationTime =\n typeof row.expirationTime === 'number' ? row.expirationTime : null\n const assess = assessPublishAuthorization({\n decoded,\n expirationTime,\n now: nowMs,\n })\n if (assess.status === 'valid') {\n return {\n bound: true,\n via: 'publish_authorization',\n warnings: [...warnings, ...assess.warnings],\n }\n }\n warnings.push(...assess.warnings)\n } catch {\n // skip undecodable row\n }\n }\n } catch (e) {\n warnings.push(\n e instanceof Error ? e.message : 'PublishAuthorization query failed',\n )\n }\n }\n\n return { bound: false, via: null, warnings }\n}\n"],"mappings":";;;;;;;;;;;;;;;AA8BA,IAAM8D,IAAgC;AAEtC,SAASC,GAAyB,GAAc;CAG9C,AADA,QAAQ,KAAK,0DAA0DC,CAAG,GAC1EnC,EAAiB,CAAC,CAAC,uBAAuBmC,CAAG;AAC/C;AAGA,SAASC,KAA0C;CAEjD,OADIjE,EAAW,cAAc,IAAU,QAAQ,QAAQ,IAChD,IAAI,SAAS,MAAY;EAC9B,EAAW,cAAcmE,EAAQ,CAAC;CACpC,CA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AMC,KAAOJ,GAChB,IAAI;GACF,IAAMK,IAAUC,GAA+BF,EAAI,mBAAmB,IAAI;GAE1E,IADIC,EAAQ,SAAS,YAAY,MAAMR,KACnCQ,EAAQ,WAAW,YAAY,MAAMV,GAAO;GAChD,IAAMY,IACJ,OAAOH,EAAI,kBAAmB,WAAWA,EAAI,iBAAiB,MAC1DI,IAASC,GAA2B;IACxC;IACA;IACA,KAAKP;GACP,CAAC;GACD,IAAIM,EAAO,WAAW,SACpB,OAAO;IACL,OAAO;IACP,KAAK;IACL,UAAU,CAAC,GAAGd,GAAU,GAAGc,EAAO,QAAQ;GAC5C;GAEF,EAAS,KAAK,GAAGA,EAAO,QAAQ;EAClC,QAAQ,CAER;CAEJ,SAAS,GAAG;EACV,EAAS,KACP,aAAa,QAAQ,EAAE,UAAU,mCACnC;CACF;CAGF,OAAO;EAAE,OAAO;EAAO,KAAK;EAAM;CAAS;AAC7C"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { n as e } from "./publishWalletRegistry-Bf_Nvf_3.js";
|
|
2
|
+
//#region src/services/publish/helpers/undeployedSmartAccount.ts
|
|
3
|
+
function t(e, t) {
|
|
4
|
+
return !!e && !!t && e.toLowerCase() === t.toLowerCase();
|
|
5
|
+
}
|
|
6
|
+
function n(n, r) {
|
|
7
|
+
let i = r?.txSender?.address;
|
|
8
|
+
if (i && !t(i, n)) return "sender_is_not_publisher";
|
|
9
|
+
let a = e(), o = r?.kind ?? (a && t(a.signer.address, r?.signer?.address) ? a.kind : void 0);
|
|
10
|
+
return o === "smart" ? "smart_account" : o === "eoa" ? t(r?.signer?.address, n) ? null : "signer_is_not_publisher" : "unknown_wallet_kind";
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { n as directEasProblem };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=undeployedSmartAccount-B6KSTipF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"undeployedSmartAccount-B6KSTipF.js","names":["getPublishWallet","sameAddress","a","b","directEasProblem","sender","wallet","publisherAddress","session","kind"],"sources":["../src/services/publish/helpers/undeployedSmartAccount.ts"],"sourcesContent":["import { 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\nexport type DirectEasProblem =\n | 'sender_is_not_publisher'\n | 'smart_account'\n | 'unknown_wallet_kind'\n | 'signer_is_not_publisher'\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 may: the wallet says it is an EOA (`kind: 'eoa'`) and its signer is the\n * publisher. An address with no code can be an EOA or an undeployed smart account, and the\n * address alone can't tell (a thirdweb smart wallet's signer address is the smart account), so\n * the wallet has to say (`useDirectEas` skips this check).\n *\n * - The wallet sends from another address: EAS would record that address as the attester.\n * - `kind: 'smart'`: an undeployed smart account; direct EAS would attest one transaction per Seed\n * instead of the account's multiPublish.\n * - No kind: unknown, refused rather than guessed.\n * - An EOA whose signer isn't the publisher: it would attest as someone else.\n *\n * A wallet passed without a kind takes the registered session's kind when it's the same signer.\n */\nexport function directEasProblem(\n publisherAddress: string,\n wallet: Partial<PublishWallet> | undefined,\n): DirectEasProblem | 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 kind =\n wallet?.kind ??\n (session && sameAddress(session.signer.address, wallet?.signer?.address) ? session.kind : undefined)\n if (kind === 'smart') return 'smart_account'\n if (kind !== 'eoa') return 'unknown_wallet_kind'\n if (!sameAddress(wallet?.signer?.address, publisherAddress)) return 'signer_is_not_publisher'\n return null\n}\n"],"mappings":";;AAGA,SAASC,EAAY,GAAuB,GAAgC;CAC1E,OAAO,CAAC,CAACC,KAAK,CAAC,CAACC,KAAKD,EAAE,YAAY,MAAMC,EAAE,YAAY;AACzD;AAuBA,SAAgBC,EACd,GACA,GACyB;CACzB,IAAMC,IAASC,GAAQ,UAAU;CACjC,IAAID,KAAU,CAACJ,EAAYI,GAAQE,CAAgB,GAAG,OAAO;CAE7D,IAAMC,IAAUR,EAAiB,GAC3BS,IACJH,GAAQ,SACPE,KAAWP,EAAYO,EAAQ,OAAO,SAASF,GAAQ,QAAQ,OAAO,IAAIE,EAAQ,OAAO,KAAA;CAI5F,OAHIC,MAAS,UAAgB,kBACzBA,MAAS,QACRR,EAAYK,GAAQ,QAAQ,SAASC,CAAgB,IACnD,OAD6D,4BADzC;AAG7B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as e,
|
|
1
|
+
import { a as e, nn as t } from "./chainConfig-BWzE8DIF.js";
|
|
2
2
|
import { BaseDb as n, applyArweaveL1TransactionIdLocal as r, arweaveL1FinalizeJobs as i, getArweaveUploadStatus as a, isArweaveL1AnchoringComplete as o, queryArweaveGatewayTransactionWithFallback as s } from "@seedprotocol/sdk";
|
|
3
3
|
import c from "debug";
|
|
4
4
|
import { eq as l } from "drizzle-orm";
|
|
@@ -85,4 +85,4 @@ async function h() {
|
|
|
85
85
|
//#endregion
|
|
86
86
|
export { p as startArweaveL1FinalizeWorker, m as stopArweaveL1FinalizeWorker };
|
|
87
87
|
|
|
88
|
-
//# sourceMappingURL=worker-
|
|
88
|
+
//# sourceMappingURL=worker-DAciYSNY.js.map
|