@seedprotocol/publish 0.7.11-next.1384.g8b47246 → 0.7.11
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 +20 -1
- package/dist/{chainConfig-DK_5pgXF.js → chainConfig-nYXoVL1s.js} +9 -9
- package/dist/{chainConfig-DK_5pgXF.js.map → chainConfig-nYXoVL1s.js.map} +1 -1
- package/dist/{ensureAutomationSessionKey-BwCXLjcX.js → ensureAutomationSessionKey-BaaHU2Wb.js} +3 -3
- package/dist/{ensureAutomationSessionKey-BwCXLjcX.js.map → ensureAutomationSessionKey-BaaHU2Wb.js.map} +1 -1
- package/dist/{ensureModularPublishBootstrap-DZcceVDq.js → ensureModularPublishBootstrap-NzYQ1MfY.js} +3 -3
- package/dist/{ensureModularPublishBootstrap-DZcceVDq.js.map → ensureModularPublishBootstrap-NzYQ1MfY.js.map} +1 -1
- package/dist/{ensureSmartWalletThenPublish-BW1_dW3n.js → ensureSmartWalletThenPublish-CpuDoo5O.js} +2 -2
- package/dist/{ensureSmartWalletThenPublish-BW1_dW3n.js.map → ensureSmartWalletThenPublish-CpuDoo5O.js.map} +1 -1
- package/dist/helpers/assertStorageBoundToIdentity.d.ts.map +1 -1
- package/dist/helpers/enrollPublishAutomation.d.ts +5 -1
- package/dist/helpers/enrollPublishAutomation.d.ts.map +1 -1
- package/dist/index.js +50 -50
- package/dist/index.js.map +1 -1
- package/dist/{managedAccountAdmin-Cb1ut9V4.js → managedAccountAdmin-BeSXTCeH.js} +2 -2
- package/dist/{managedAccountAdmin-Cb1ut9V4.js.map → managedAccountAdmin-BeSXTCeH.js.map} +1 -1
- package/dist/{publishAuthorization-C_VidnTq.js → publishAuthorization-CVl5ZK5B.js} +24 -21
- package/dist/publishAuthorization-CVl5ZK5B.js.map +1 -0
- package/dist/{resolveRevokeAccount-CCJ_7quC.js → resolveRevokeAccount-DRrUY9FR.js} +2 -2
- package/dist/{resolveRevokeAccount-CCJ_7quC.js.map → resolveRevokeAccount-DRrUY9FR.js.map} +1 -1
- package/dist/services/domainOwnership/index.d.ts.map +1 -1
- package/dist/services/publishAuthorization/index.d.ts +1 -1
- package/dist/services/publishAuthorization/index.d.ts.map +1 -1
- package/dist/services/publishedBy/index.d.ts.map +1 -1
- package/dist/thirdweb.js +39 -38
- package/dist/thirdweb.js.map +1 -1
- package/dist/{worker-C7XeFMWh.js → worker-D1czx7Yg.js} +2 -2
- package/dist/{worker-C7XeFMWh.js.map → worker-D1czx7Yg.js.map} +1 -1
- package/package.json +7 -7
- package/dist/publishAuthorization-C_VidnTq.js.map +0 -1
package/dist/thirdweb.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thirdweb.js","names":["seedClient","ConnectButtonThirdweb","pollSmartWalletDeployed","useLocalWalletAccount","ensureManagedAccountReady","getConnectedAccount","isContractDeployed","getSharedPublishInAppWalletStorage","Eip7702ModularAccountPublishError","getConnectedModularAccount","ExternalWalletsForDeploy","isSmartWalletDeployed","getSmartWalletAddressForAdmin","ManagedAccountPublishError","appMetadata","readIsActiveSigner","tryDeployManagedAccount","ensureExecutorModuleInstalled","assertExecutorModuleReadyForAccount","useActiveSmartWalletContract","deployManagedAccountViaFactory","getManagedAccountWallet","waitForPublishReceipt","getConnectedManagedAccountAddress","pollSmartWalletDeployed$1","getModularAccountWallet","resolveSmartWalletForPublish","pollSmartWalletDeployed","syncPublishInAppAuthToken","initPublish","wallets","getPublishThirdwebChain","fromThirdwebAccount","getPublishConfig","runModularExecutorPublishPrep","asThirdwebPublishWallet","seedPaymaster","PublishManager","asSeedSignerFromThirdweb","getWalletsForConnectButton","getConfigRef","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","adminAccount","dataItemSigner","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 deploySmartWalletContract,\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 // Data items need an ECDSA signer. With the modular executor the connected account is an\n // EOA (or EIP-7702 on one) acting for the ManagedAccount; otherwise a smart wallet's admin\n // EOA signs them.\n const adminAccount = activeWallet.getAdminAccount?.()\n const dataItemSigner = managedAddress\n ? publishWallet.signer\n : isSmart && adminAccount && adminAccount.address.toLowerCase() !== account.address.toLowerCase()\n ? fromThirdwebAccount(adminAccount, { kind: \"eoa\" }).signer\n : undefined\n await setPublishWallet({\n ...publishWallet,\n ownedAddresses: [...owned],\n publisherAddress: managedAddress ?? account.address,\n ...(dataItemSigner ? { dataItemSigner } : {}),\n // A new user's smart wallet has no code until its first transaction: publish deploys it.\n ...(isSmart && !managedAddress\n ? { deploy: async () => { await deploySmartWalletContract(account) } }\n : {}),\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 { 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 }\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":";;;;;;;;;;;;;;;AA+BA,IAAM8D,IAAgC;AAEtC,SAASC,GAAyB,GAAc;CAG9C,AADA,QAAQ,KAAK,0DAA0DC,CAAG,GAC1E/B,EAAi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AAI,CAAC,sBAAsB,KAAKkF,CAAK,KAAK,CAAC,sBAAsB,KAAKE,CAAQ,GAC5E,OAAO;EAAE,OAAO;EAAO,KAAK;EAAM,UAAU,CAAC,yCAAyC;CAAE;CAG1F,IAAIC,GACF,IAAI;EAEF,IAAI,MADiBhG,EAA0BW,GAAgBmF,CAAa,GAE1E,OAAO;GAAE,OAAO;GAAM,KAAK;GAAsB;EAAS;CAE9D,SAAS,GAAG;EACV,EAAS,KACP,aAAa,QAAQ,EAAE,UAAU,6BACnC;CACF;CAGF,IAAIG,GACF,IAAI;EACF,IAAMC,IAAO,MAAMC,GAA+B;GAChD,YAAY,CAACxF,CAAc;GAC3B,aAAa,CAACmF,CAAa;GAC3B,gBAAgB;EAClB,CAAC,GACKM,IAAQC,KAAU,OAAuB,KAAK,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","isContractDeployed","getSharedPublishInAppWalletStorage","Eip7702ModularAccountPublishError","getConnectedModularAccount","ExternalWalletsForDeploy","isSmartWalletDeployed","getSmartWalletAddressForAdmin","ManagedAccountPublishError","appMetadata","readIsActiveSigner","tryDeployManagedAccount","ensureExecutorModuleInstalled","assertExecutorModuleReadyForAccount","useActiveSmartWalletContract","deployManagedAccountViaFactory","getManagedAccountWallet","waitForPublishReceipt","getConnectedManagedAccountAddress","pollSmartWalletDeployed$1","getModularAccountWallet","resolveSmartWalletForPublish","pollSmartWalletDeployed","syncPublishInAppAuthToken","initPublish","wallets","getPublishThirdwebChain","fromThirdwebAccount","getPublishConfig","runModularExecutorPublishPrep","asThirdwebPublishWallet","seedPaymaster","PublishManager","asSeedSignerFromThirdweb","getWalletsForConnectButton","getConfigRef","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","adminAccount","dataItemSigner","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","expiresAt","PUBLISH_AUTHORIZATION_DEFAULT_EXPIRATION_SECS","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 deploySmartWalletContract,\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 // Data items need an ECDSA signer. With the modular executor the connected account is an\n // EOA (or EIP-7702 on one) acting for the ManagedAccount; otherwise a smart wallet's admin\n // EOA signs them.\n const adminAccount = activeWallet.getAdminAccount?.()\n const dataItemSigner = managedAddress\n ? publishWallet.signer\n : isSmart && adminAccount && adminAccount.address.toLowerCase() !== account.address.toLowerCase()\n ? fromThirdwebAccount(adminAccount, { kind: \"eoa\" }).signer\n : undefined\n await setPublishWallet({\n ...publishWallet,\n ownedAddresses: [...owned],\n publisherAddress: managedAddress ?? account.address,\n ...(dataItemSigner ? { dataItemSigner } : {}),\n // A new user's smart wallet has no code until its first transaction: publish deploys it.\n ...(isSmart && !managedAddress\n ? { deploy: async () => { await deploySmartWalletContract(account) } }\n : {}),\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 { 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 }\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 { PUBLISH_AUTHORIZATION_DEFAULT_EXPIRATION_SECS } from '@seedprotocol/eas'\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 /**\n * Unix seconds when the session key and the grant end. Defaults to 365 days from now\n * ({@link PUBLISH_AUTHORIZATION_DEFAULT_EXPIRATION_SECS}); the same value goes to both, so the\n * on-chain key never outlives its PublishAuthorization.\n */\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 } = params\n const expiresAt =\n typeof params.expiresAt === 'number' && params.expiresAt > 0\n ? Math.trunc(params.expiresAt)\n : Math.floor(Date.now() / 1000) + PUBLISH_AUTHORIZATION_DEFAULT_EXPIRATION_SECS\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 revoked: row.revoked,\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":";;;;;;;;;;;;;;;AA+BA,IAAM8D,IAAgC;AAEtC,SAASC,GAAyB,GAAc;CAG9C,AADA,QAAQ,KAAK,0DAA0DC,CAAG,GAC1E/B,EAAiB,CAAC,CAAC,uBAAuB+B,CAAG;AAC/C;AAGA,SAASC,KAA0C;CAEjD,OADIjE,EAAW,cAAc,IAAU,QAAQ,QAAQ,IAChD,IAAI,SAAS,MAAY;EAC9B,EAAW,cAAcmE,EAAQ,CAAC;CACpC,CAAC;AACH;AAOA,eA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,CAAQ,GAC5E,OAAO;EAAE,OAAO;EAAO,KAAK;EAAM,UAAU,CAAC,yCAAyC;CAAE;CAG1F,IAAIC,GACF,IAAI;EAEF,IAAI,MADiBlG,EAA0BW,GAAgBqF,CAAa,GAE1E,OAAO;GAAE,OAAO;GAAM,KAAK;GAAsB;EAAS;CAE9D,SAAS,GAAG;EACV,EAAS,KACP,aAAa,QAAQ,EAAE,UAAU,6BACnC;CACF;CAGF,IAAIG,GACF,IAAI;EACF,IAAMC,IAAO,MAAMC,GAA+B;GAChD,YAAY,CAAC1F,CAAc;GAC3B,aAAa,CAACqF,CAAa;GAC3B,gBAAgB;EAClB,CAAC,GACKM,IAAQC,KAAU,OAAuB,KAAK,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,SAASL,EAAI;IACb,KAAKF;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,4 +1,4 @@
|
|
|
1
|
-
import { i as e, tn as t } from "./chainConfig-
|
|
1
|
+
import { i as e, tn as t } from "./chainConfig-nYXoVL1s.js";
|
|
2
2
|
import { BaseDb as n, arweaveL1FinalizeJobs as r, getArweaveUploadStatus as i, isArweaveL1AnchoringComplete as a, queryArweaveGatewayTransactionWithFallback as o } from "@seedprotocol/sdk";
|
|
3
3
|
import s from "debug";
|
|
4
4
|
import { eq as c } from "drizzle-orm";
|
|
@@ -75,4 +75,4 @@ async function m() {
|
|
|
75
75
|
//#endregion
|
|
76
76
|
export { f as startArweaveL1FinalizeWorker, p as stopArweaveL1FinalizeWorker };
|
|
77
77
|
|
|
78
|
-
//# sourceMappingURL=worker-
|
|
78
|
+
//# sourceMappingURL=worker-D1czx7Yg.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-
|
|
1
|
+
{"version":3,"file":"worker-D1czx7Yg.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","status","getArweaveUploadStatus","statusStr","isArweaveL1AnchoringComplete","resolvedL1","err"],"sources":["../src/services/arweaveL1Finalize/worker.ts"],"sourcesContent":["import {\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\n/**\n * Tracks bundler uploads until their bundle is anchored on Arweave L1, recording the L1 / bundle id\n * in `arweave_l1_finalize_jobs`. Local metadata keeps the data item id, which is what was attested\n * and what gateways serve the item under.\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\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 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 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(eq(arweaveL1FinalizeJobs.id, job.id!))\n }\n }\n}\n"],"mappings":";;;;;AAYA,IAAMG,IAASD,EAAM,uCAAuC,GAOtDE,IAAU,MAEZC,IAAoD;AAExD,SAAgBC,IAAqC;CACnD,AAAID,MACJ,IAAa,kBAAkB;EAC7B,EAA8B;CAChC,GAAGD,CAAO,GACVG,EAA8B;AAChC;AAEA,SAAgBC,IAAoC;CAClD,AAAIH,KAAc,SAChB,cAAcA,CAAU,GACxB,IAAa;AAEjB;AAEA,eAAeE,IAA0C;CACvD,IAAIE;CACJ,IAAI;EACF,IAAST,EAAiB;CAC5B,QAAQ;EACN;CACF;CAGA,IAAI,CAACU,EAAO,aAAa,GAAG;CAC5B,IAAMC,IAAKD,EAAO,SAAS;CAC3B,IAAI,CAACC,GAAI;CAET,IAAMC,IAAU,MAAMD,EACnB,OAAO,CAAC,CACR,KAAKE,CAAqB,CAAC,CAC3B,MAAMC,EAAGD,EAAsB,OAAO,YAAY,CAAC,CAAC,CACpD,MAAM,EAAE;CAEX,IAAID,EAAQ,WAAW,GAAG;CAE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AAC,CAAC,CACD,MAAMJ,EAAGD,EAAsB,IAAIK,EAAI,EAAG,CAAC;IAC9C;GACF;GAEA,MAAMP,EACH,OAAOE,CAAqB,CAAC,CAC7B,IAAI;IACH,YAAYa;IACZ,WAAW,KAAK,IAAI;GACtB,CAAC,CAAC,CACD,MAAMZ,EAAGD,EAAsB,IAAIK,EAAI,EAAG,CAAC;EAChD,SAASW,GAAK;GAEZ,AADA1B,EAAO,sBAAsBe,EAAI,IAAIW,CAAG,GACxC,MAAMlB,EACH,OAAOE,CAAqB,CAAC,CAC7B,IAAI;IACH,cAAcgB,aAAe,QAAQA,EAAI,UAAU,OAAOA,CAAG;IAC7D,WAAW,KAAK,IAAI;GACtB,CAAC,CAAC,CACD,MAAMf,EAAGD,EAAsB,IAAIK,EAAI,EAAG,CAAC;EAChD;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seedprotocol/publish",
|
|
3
|
-
"version": "0.7.11
|
|
3
|
+
"version": "0.7.11",
|
|
4
4
|
"description": "Publish Seed Protocol items to Arweave and EAS: publish state machine, React provider and hooks, wallet integration and optional thirdweb adapters",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"seed-protocol",
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
"scripts": {
|
|
47
47
|
"build": "tsc -p tsconfig.build.json && vite build",
|
|
48
48
|
"prepublishOnly": "npm run build && node ../../scripts/sync-versions.js",
|
|
49
|
-
"test": "bun test src/helpers/defaultApprovedTargetsForModularPublish.test.ts && bun test src/helpers/arweave.test.ts src/helpers/ensureManagedAccountReady.test.ts src/helpers/ensureEip7702ModularAccountReady.test.ts src/helpers/ensureManagedSignerSessionKey.test.ts src/helpers/publishDisplayHelpers.test.ts src/services/publish/actors/createAttestationsRouting.test.ts src/services/publish/actors/seedUidHelpers.test.ts src/config.autoDeployEip7702.test.ts src/config.chain.test.ts && bun test src/helpers/ensureSmartWalletThenPublish.test.ts && bun test src/helpers/ensureManagedAccountEasConfigured.test.ts && bun test src/services/domainOwnership/domainOwnership.test.ts src/services/domainOwnership/domainOwnership.scope.test.ts && bun test src/services/publishAuthorization/publishAuthorization.test.ts && bun test src/helpers/approvedTargetsForAutomationPublish.test.ts && bun test src/helpers/easDirect.multiRevoke.test.ts && bun test src/helpers/ensureAutomationSessionKey.test.ts && bun test src/helpers/enrollPublishAutomation.test.ts && bun test src/helpers/executorModuleReadiness.test.ts src/helpers/describeRevert.test.ts && bun test src/helpers/contracts/encodeMultiPublish.test.ts && bun test src/helpers/assertStorageBoundToIdentity.test.ts && bun test src/payment.test.ts && bun test src/authorization.test.ts && bun test src/services/publish/authorizing.test.ts && bun test src/helpers/turbo.test.ts && bun test src/services/publish/helpers/uploadToTurbo.test.ts && bun test src/services/publishCost/estimatePublishCost.test.ts && bun test src/services/publishCost/watchPublishCost.test.ts src/hooks/usePublishCostEstimate.test.tsx && bun test src/services/publishedBy/publishedBy.test.ts && bun test src/helpers/publishThirdwebClient.test.ts src/helpers/chainClient.secretKey.test.ts src/helpers/chainClient.receipt.test.ts && bun test src/helpers/adapters/thirdwebAccount.test.ts && bun test src/services/publishManager/publishManager.node.test.ts && bun test src/services/publishManager/publishLocks.node.test.ts && bun test src/services/publishManager/actors/savePublish.test.ts src/services/publishManager/actions/requestSavePublish.test.ts && bun test src/services/publish/helpers/ensureEasSchemas.test.ts && bun test src/services/publish/helpers/verifyAttestations.test.ts && bun test src/services/publish/actors/checking.unpublishedRelated.test.ts && bun test src/services/publish/actors/checking.directEas.test.ts && bun test src/services/publish/actors/recordMultiPublishReceipt.test.ts && bun test src/services/publish/actors/createAttestations.batch.test.ts && bun test src/services/publish/actors/createAttestationsDirectToEas.batch.test.ts && bun test src/services/publish/actors/createAttestationsDirectToEas.lists.test.ts && bun test src/helpers/verifyPublishChain.test.ts && bun test src/helpers/thirdwebWallets.test.ts && bun test src/helpers/seedPaymaster.test.ts && bun test src/helpers/ensureExecutorModule.test.ts && bun test src/services/revoke/revokeAttestations.test.ts && bun test src/services/publish/actors/revokeRetractedProperties.test.ts && bun test src/helpers/ensureModularPublishBootstrap.test.ts && bun test src/helpers/blockchain.test.ts src/helpers/retryNonceTooLow.test.ts src/helpers/seedTwin.test.ts && bun test src/helpers/runModularExecutorPublishPrep.test.ts && bun test src/helpers/adapters/permissionlessTxSender.test.ts && bun test src/helpers/publishItem.test.ts && bun test src/helpers/publishWalletRegistry.test.ts && bun test src/config.uploadApiBaseUrl.test.ts src/react/PublishProvider.initOrder.test.tsx && bun test src/services/publish/actors/uploadViaBundler.resume.test.ts && bun test src/services/publishManager/actors/restorableSnapshot.test.ts && bun test src/helpers/defaultDataItemSigner.test.ts && bun test src/services/publish/htmlPhase2.flow.test.ts src/helpers/accountCodeKind.test.ts"
|
|
49
|
+
"test": "bun test src/helpers/defaultApprovedTargetsForModularPublish.test.ts && bun test src/helpers/arweave.test.ts src/helpers/ensureManagedAccountReady.test.ts src/helpers/ensureEip7702ModularAccountReady.test.ts src/helpers/ensureManagedSignerSessionKey.test.ts src/helpers/publishDisplayHelpers.test.ts src/services/publish/actors/createAttestationsRouting.test.ts src/services/publish/actors/seedUidHelpers.test.ts src/config.autoDeployEip7702.test.ts src/config.chain.test.ts && bun test src/helpers/ensureSmartWalletThenPublish.test.ts && bun test src/helpers/ensureManagedAccountEasConfigured.test.ts && bun test src/services/domainOwnership/domainOwnership.test.ts src/services/domainOwnership/domainOwnership.scope.test.ts && bun test src/services/publishAuthorization/publishAuthorization.test.ts && bun test src/services/publishAuthorization/assessLive.test.ts && bun test src/services/attestInputOrder.test.ts && bun test src/helpers/approvedTargetsForAutomationPublish.test.ts && bun test src/helpers/easDirect.multiRevoke.test.ts && bun test src/helpers/ensureAutomationSessionKey.test.ts && bun test src/helpers/enrollPublishAutomation.test.ts && bun test src/helpers/executorModuleReadiness.test.ts src/helpers/describeRevert.test.ts && bun test src/helpers/contracts/encodeMultiPublish.test.ts && bun test src/helpers/assertStorageBoundToIdentity.test.ts && bun test src/payment.test.ts && bun test src/authorization.test.ts && bun test src/services/publish/authorizing.test.ts && bun test src/helpers/turbo.test.ts && bun test src/services/publish/helpers/uploadToTurbo.test.ts && bun test src/services/publishCost/estimatePublishCost.test.ts && bun test src/services/publishCost/watchPublishCost.test.ts src/hooks/usePublishCostEstimate.test.tsx && bun test src/services/publishedBy/publishedBy.test.ts && bun test src/helpers/publishThirdwebClient.test.ts src/helpers/chainClient.secretKey.test.ts src/helpers/chainClient.receipt.test.ts && bun test src/helpers/adapters/thirdwebAccount.test.ts && bun test src/services/publishManager/publishManager.node.test.ts && bun test src/services/publishManager/publishLocks.node.test.ts && bun test src/services/publishManager/actors/savePublish.test.ts src/services/publishManager/actions/requestSavePublish.test.ts && bun test src/services/publish/helpers/ensureEasSchemas.test.ts && bun test src/services/publish/helpers/verifyAttestations.test.ts && bun test src/services/publish/actors/checking.unpublishedRelated.test.ts && bun test src/services/publish/actors/checking.directEas.test.ts && bun test src/services/publish/actors/recordMultiPublishReceipt.test.ts && bun test src/services/publish/actors/createAttestations.batch.test.ts && bun test src/services/publish/actors/createAttestationsDirectToEas.batch.test.ts && bun test src/services/publish/actors/createAttestationsDirectToEas.lists.test.ts && bun test src/helpers/verifyPublishChain.test.ts && bun test src/helpers/thirdwebWallets.test.ts && bun test src/helpers/seedPaymaster.test.ts && bun test src/helpers/ensureExecutorModule.test.ts && bun test src/services/revoke/revokeAttestations.test.ts && bun test src/services/publish/actors/revokeRetractedProperties.test.ts && bun test src/helpers/ensureModularPublishBootstrap.test.ts && bun test src/helpers/blockchain.test.ts src/helpers/retryNonceTooLow.test.ts src/helpers/seedTwin.test.ts && bun test src/helpers/runModularExecutorPublishPrep.test.ts && bun test src/helpers/adapters/permissionlessTxSender.test.ts && bun test src/helpers/publishItem.test.ts && bun test src/helpers/publishWalletRegistry.test.ts && bun test src/config.uploadApiBaseUrl.test.ts src/react/PublishProvider.initOrder.test.tsx && bun test src/services/publish/actors/uploadViaBundler.resume.test.ts && bun test src/services/publishManager/actors/restorableSnapshot.test.ts && bun test src/helpers/defaultDataItemSigner.test.ts && bun test src/services/publish/htmlPhase2.flow.test.ts src/helpers/accountCodeKind.test.ts"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@ethereum-attestation-service/eas-sdk": "^2.9.0",
|
|
53
|
-
"@seedprotocol/eas": "0.7.11
|
|
53
|
+
"@seedprotocol/eas": "0.7.11",
|
|
54
54
|
"@xstate/react": "^6.1.0",
|
|
55
55
|
"arweave": "^1.15.7",
|
|
56
56
|
"debug": "^4.4.1",
|
|
@@ -62,8 +62,8 @@
|
|
|
62
62
|
"xstate": "^5.28.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@seedprotocol/react": "0.7.11
|
|
66
|
-
"@seedprotocol/sdk": "0.7.11
|
|
65
|
+
"@seedprotocol/react": "0.7.11",
|
|
66
|
+
"@seedprotocol/sdk": "0.7.11",
|
|
67
67
|
"@types/bun": "1.4.3",
|
|
68
68
|
"@types/react": "^19.2.14",
|
|
69
69
|
"@types/react-dom": "^19.2.3",
|
|
@@ -75,8 +75,8 @@
|
|
|
75
75
|
"vite": "^8.0.0"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
|
-
"@seedprotocol/sdk": "0.7.11
|
|
79
|
-
"@seedprotocol/react": "0.7.11
|
|
78
|
+
"@seedprotocol/sdk": "0.7.11",
|
|
79
|
+
"@seedprotocol/react": "0.7.11",
|
|
80
80
|
"react": "^18 || ^19",
|
|
81
81
|
"react-dom": "^18 || ^19",
|
|
82
82
|
"thirdweb": "^5",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"publishAuthorization-C_VidnTq.js","names":["ZERO_ADDRESS","isPublishWallet","prepareNameSchemaAttestation","getAttestationUidFromReceipt","getSchemaRecord","prepareEasAttest","isSeedTxSender","waitForPublishReceipt","getPublishConfig","registerSchema","prepareEasMultiRevoke","PUBLISH_AUTHORIZATION_SCHEMA_DEF$1","PUBLISH_AUTHORIZATION_SCHEMA_NAME$1","PUBLISH_AUTHORIZATION_SCOPES$1","PublishConfigContext","createContext","usePublishConfig","config","useContext","approvedTargetsForAutomationPublish","module","PUBLISH_AUTOMATION_SCOPES","buildAutomationSessionKeyPermissions","out","params","hashAutomationSessionKeyPermissions","material","permissions","a","scopes","keccak256","toUtf8Bytes","toThirdwebSessionKeyPermissions","base","RESOLVER_ADDRESS","REVOCABLE","ZERO_ADDRESS$1","resolveTxSender","account","sendAndWait","result","txSender","tx","assertAddress","t","addr","label","getPublishAuthorizationSchemaUid","SchemaRegistry","PUBLISH_AUTHORIZATION_SCHEMA_DEF","ensurePublishAuthorizationSchema","sender","schemaUid","PUBLISH_AUTHORIZATION_SCHEMA_NAME","encodePublishAuthorizationAttestationData","SchemaEncoder","normalizeBytes32Hex","attestPublishAuthorization","identity","sessionKey","app","grantedAt","expiresAt","PUBLISH_AUTHORIZATION_SCOPES","permissionsHash","ZERO_BYTES32","expirationTime","PUBLISH_AUTHORIZATION_DEFAULT_EXPIRATION_SECS","data","receipt","uid","easContractAddress","isValidEasAttestationUid","revokePublishAuthorization","assessPublishAuthorizationLive","row","getPublishAuthorizationFromEas","r","decoded","decodePublishAuthorizationData","assessPublishAuthorization"],"sources":["../src/react/PublishConfigContext.tsx","../src/helpers/approvedTargetsForAutomationPublish.ts","../src/helpers/automationSessionKeyPermissions.ts","../src/services/publishAuthorization/index.ts"],"sourcesContent":["import { createContext, useContext } from 'react'\nimport type { PublishConfig } from '../config'\n\nexport const PublishConfigContext = createContext<PublishConfig | null>(null)\n\nexport function usePublishConfig(): PublishConfig {\n const config = useContext(PublishConfigContext)\n if (!config) {\n throw new Error(\n 'usePublishConfig: PublishConfig is missing. Pass config to PublishProvider or call initPublish() before render.',\n )\n }\n return config\n}\n","import { getPublishConfig } from '../config'\n\n/**\n * Allowlisted call targets for session keys on a ManagedAccount.\n * Returns only the configured Seed executor module — never the ManagedAccount or raw EAS\n * (those would allow `setEas` / arbitrary attestations).\n *\n * @throws if `modularAccountModuleContract` is unset or invalid\n */\nexport function approvedTargetsForAutomationPublish(): `0x${string}`[] {\n const module = getPublishConfig().modularAccountModuleContract?.trim()\n if (!module || !/^0x[0-9a-fA-F]{40}$/.test(module)) {\n throw new Error(\n '@seedprotocol/publish: session keys require PublishConfig.modularAccountModuleContract ' +\n '(their only approved target is the Seed executor module).',\n )\n }\n return [module.toLowerCase() as `0x${string}`]\n}\n","import { keccak256, toUtf8Bytes } from 'ethers'\nimport { approvedTargetsForAutomationPublish } from './approvedTargetsForAutomationPublish'\n\n/** Fixed v1 scopes for publish automation grants. */\nexport const PUBLISH_AUTOMATION_SCOPES = 'publish,revoke' as const\n\nexport type AutomationSessionKeyPermissions = {\n approvedTargets: `0x${string}`[]\n nativeTokenLimitPerTransaction: number\n /** Unix seconds; omit for Thirdweb default long window. */\n expiresAt?: number\n}\n\n/**\n * Canonical permissions for an automation session key (module-only targets).\n */\nexport function buildAutomationSessionKeyPermissions(params?: {\n expiresAt?: number\n}): AutomationSessionKeyPermissions {\n const approvedTargets = approvedTargetsForAutomationPublish()\n const out: AutomationSessionKeyPermissions = {\n approvedTargets,\n nativeTokenLimitPerTransaction: 0,\n }\n if (typeof params?.expiresAt === 'number' && params.expiresAt > 0) {\n out.expiresAt = Math.trunc(params.expiresAt)\n }\n return out\n}\n\n/**\n * Deterministic permissions hash for the PublishAuthorization sidecar.\n * Material: sorted targets | nativeLimit | expiresAt (0 if unset) | scopes\n */\nexport function hashAutomationSessionKeyPermissions(\n permissions: AutomationSessionKeyPermissions,\n scopes: string = PUBLISH_AUTOMATION_SCOPES,\n): `0x${string}` {\n const targets = [...permissions.approvedTargets].map((a) => a.toLowerCase()).sort().join(',')\n const limit = permissions.nativeTokenLimitPerTransaction\n const expiresAt = permissions.expiresAt ?? 0\n const material = `${targets}|${limit}|${expiresAt}|${scopes.trim()}`\n return keccak256(toUtf8Bytes(material)) as `0x${string}`\n}\n\n/** Shape passed to Thirdweb `addSessionKey` / `shouldUpdateSessionKey`. */\nexport function toThirdwebSessionKeyPermissions(permissions: AutomationSessionKeyPermissions): {\n approvedTargets: `0x${string}`[]\n nativeTokenLimitPerTransaction: number\n permissionEndTimestamp?: Date\n} {\n const base = {\n approvedTargets: permissions.approvedTargets,\n nativeTokenLimitPerTransaction: permissions.nativeTokenLimitPerTransaction,\n }\n if (permissions.expiresAt != null && permissions.expiresAt > 0) {\n return {\n ...base,\n permissionEndTimestamp: new Date(permissions.expiresAt * 1000),\n }\n }\n return base\n}\n","import {\n PUBLISH_AUTHORIZATION_DEFAULT_EXPIRATION_SECS,\n PUBLISH_AUTHORIZATION_SCHEMA_DEF,\n PUBLISH_AUTHORIZATION_SCHEMA_NAME,\n PUBLISH_AUTHORIZATION_SCOPES,\n assessPublishAuthorization,\n decodePublishAuthorizationData,\n getPublishAuthorizationFromEas,\n type PublishAuthorizationAssessResult,\n type PublishAuthorizationDecoded,\n} from '@seedprotocol/eas'\nimport { SchemaEncoder, ZERO_BYTES32 } from '@ethereum-attestation-service/eas-sdk'\nimport { SchemaRegistry } from '@ethereum-attestation-service/eas-sdk'\nimport { prepareEasAttest, prepareEasMultiRevoke } from '~/helpers/easDirect'\nimport { getSchemaRecord, registerSchema } from '~/helpers/schemaRegistry'\nimport { prepareNameSchemaAttestation } from '~/helpers/nameSchemaAttestation'\nimport { waitForPublishReceipt } from '~/helpers/chainClient'\nimport { getPublishConfig } from '~/config'\nimport {\n isPublishWallet,\n isSeedTxSender,\n type PublishWallet,\n type SeedTxSender,\n} from '~/helpers/seedSigner'\nimport { getAttestationUidFromReceipt } from '~/helpers/easDirect'\nimport { normalizeBytes32Hex, isValidEasAttestationUid } from '@seedprotocol/eas'\nimport {\n buildAutomationSessionKeyPermissions,\n hashAutomationSessionKeyPermissions,\n PUBLISH_AUTOMATION_SCOPES,\n} from '~/helpers/automationSessionKeyPermissions'\n\nexport {\n PUBLISH_AUTHORIZATION_SCHEMA_DEF,\n PUBLISH_AUTHORIZATION_SCHEMA_NAME,\n PUBLISH_AUTHORIZATION_SCOPES,\n} from '@seedprotocol/eas'\n\nconst RESOLVER_ADDRESS = '0x0000000000000000000000000000000000000000'\nconst REVOCABLE = true\nconst ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'\n\nfunction resolveTxSender(account: PublishWallet | SeedTxSender): SeedTxSender {\n if (isPublishWallet(account)) return account.txSender\n if (isSeedTxSender(account)) return account\n throw new Error(\n '@seedprotocol/publish: publish authorization write APIs require a PublishWallet or SeedTxSender',\n )\n}\n\nasync function sendAndWait(\n txSender: SeedTxSender,\n tx: Parameters<SeedTxSender['sendTransaction']>[0],\n) {\n const result = await txSender.sendTransaction(tx)\n return waitForPublishReceipt(result.transactionHash)\n}\n\nfunction assertAddress(label: string, addr: string): `0x${string}` {\n const t = addr.trim()\n if (!/^0x[0-9a-fA-F]{40}$/.test(t)) {\n throw new Error(`@seedprotocol/publish: ${label} must be a valid address`)\n }\n return t as `0x${string}`\n}\n\n/** Deterministic on-chain schema UID for {@link PUBLISH_AUTHORIZATION_SCHEMA_DEF}. */\nexport function getPublishAuthorizationSchemaUid(): `0x${string}` {\n return SchemaRegistry.getSchemaUID(\n PUBLISH_AUTHORIZATION_SCHEMA_DEF,\n RESOLVER_ADDRESS as `0x${string}`,\n REVOCABLE,\n ) as `0x${string}`\n}\n\n/**\n * Registers the PublishAuthorization EAS schema (if missing) and creates a Schema #1 name attestation.\n */\nexport async function ensurePublishAuthorizationSchema(\n account: PublishWallet | SeedTxSender,\n): Promise<`0x${string}`> {\n const sender = resolveTxSender(account)\n const schemaUid = getPublishAuthorizationSchemaUid()\n const onChain = await getSchemaRecord(schemaUid)\n if (!onChain) {\n await sendAndWait(\n sender,\n registerSchema({\n schema: PUBLISH_AUTHORIZATION_SCHEMA_DEF,\n resolverAddress: RESOLVER_ADDRESS,\n revocable: REVOCABLE,\n }),\n )\n await sendAndWait(\n sender,\n prepareNameSchemaAttestation({\n schemaUid,\n schemaName: PUBLISH_AUTHORIZATION_SCHEMA_NAME,\n }),\n )\n }\n return schemaUid\n}\n\nexport function encodePublishAuthorizationAttestationData(params: {\n identity: string\n sessionKey: string\n app: string\n scopes: string\n grantedAt: number\n expiresAt: number\n permissionsHash: string\n}): `0x${string}` {\n const schemaEncoder = new SchemaEncoder(PUBLISH_AUTHORIZATION_SCHEMA_DEF)\n const encodedData = schemaEncoder.encodeData([\n { name: 'identity', value: params.identity as `0x${string}`, type: 'address' },\n { name: 'sessionKey', value: params.sessionKey as `0x${string}`, type: 'address' },\n { name: 'app', value: params.app as `0x${string}`, type: 'address' },\n { name: 'scopes', value: params.scopes, type: 'string' },\n { name: 'grantedAt', value: params.grantedAt, type: 'uint64' },\n { name: 'expiresAt', value: params.expiresAt, type: 'uint64' },\n {\n name: 'permissionsHash',\n value: normalizeBytes32Hex(params.permissionsHash) as `0x${string}`,\n type: 'bytes32',\n },\n ])\n return encodedData as `0x${string}`\n}\n\nexport type AttestPublishAuthorizationParams = {\n /** Must be the ManagedAccount (identity) wallet — becomes EAS attester. */\n wallet: PublishWallet | SeedTxSender\n identity: string\n sessionKey: string\n /** Optional app label address; defaults to zero address. */\n app?: string\n scopes?: string\n grantedAt?: number\n expiresAt?: number\n permissionsHash?: string\n ensureSchema?: boolean\n /** Override EAS expirationTime (unix seconds). */\n expirationTime?: number\n}\n\nexport type AttestPublishAuthorizationResult = {\n uid: `0x${string}`\n schemaUid: `0x${string}`\n permissionsHash: `0x${string}`\n grantedAt: number\n expiresAt: number\n expirationTime: number\n}\n\n/**\n * ManagedAccount attests a PublishAuthorization grant (recipient = session key).\n */\nexport async function attestPublishAuthorization(\n params: AttestPublishAuthorizationParams,\n): Promise<AttestPublishAuthorizationResult> {\n const sender = resolveTxSender(params.wallet)\n const schemaUid =\n params.ensureSchema === false\n ? getPublishAuthorizationSchemaUid()\n : await ensurePublishAuthorizationSchema(params.wallet)\n\n const identity = assertAddress('identity', params.identity)\n const sessionKey = assertAddress('sessionKey', params.sessionKey)\n const app = params.app?.trim()\n ? assertAddress('app', params.app)\n : (ZERO_ADDRESS as `0x${string}`)\n\n const grantedAt = params.grantedAt ?? Math.floor(Date.now() / 1000)\n const expiresAt =\n typeof params.expiresAt === 'number' && params.expiresAt > 0\n ? Math.trunc(params.expiresAt)\n : 0\n const scopes = params.scopes ?? PUBLISH_AUTHORIZATION_SCOPES\n\n const permissionsHash = normalizeBytes32Hex(\n params.permissionsHash ??\n hashAutomationSessionKeyPermissions(\n buildAutomationSessionKeyPermissions({\n expiresAt: expiresAt > 0 ? expiresAt : undefined,\n }),\n scopes === PUBLISH_AUTHORIZATION_SCOPES ? PUBLISH_AUTOMATION_SCOPES : scopes,\n ),\n ) as `0x${string}`\n\n if (permissionsHash === ZERO_BYTES32) {\n throw new Error(\n '@seedprotocol/publish: attestPublishAuthorization requires a non-zero permissionsHash',\n )\n }\n\n const expirationTime =\n typeof params.expirationTime === 'number' && params.expirationTime > 0\n ? params.expirationTime\n : expiresAt > 0\n ? expiresAt\n : grantedAt + PUBLISH_AUTHORIZATION_DEFAULT_EXPIRATION_SECS\n\n const data = encodePublishAuthorizationAttestationData({\n identity,\n sessionKey,\n app,\n scopes,\n grantedAt,\n expiresAt,\n permissionsHash,\n })\n\n const tx = prepareEasAttest({\n schema: schemaUid,\n data: {\n recipient: sessionKey,\n expirationTime: BigInt(expirationTime),\n revocable: true,\n refUID: ZERO_BYTES32 as `0x${string}`,\n data,\n value: 0n,\n },\n })\n\n const receipt = await sendAndWait(sender, tx)\n if (!receipt) {\n throw new Error('@seedprotocol/publish: attestPublishAuthorization failed — no receipt')\n }\n const { easContractAddress } = getPublishConfig()\n const uid = getAttestationUidFromReceipt(receipt, easContractAddress)\n if (!uid || !isValidEasAttestationUid(uid)) {\n throw new Error(\n '@seedprotocol/publish: attestPublishAuthorization failed — could not parse attestation UID',\n )\n }\n\n return {\n uid: uid as `0x${string}`,\n schemaUid,\n permissionsHash,\n grantedAt,\n expiresAt,\n expirationTime,\n }\n}\n\n/**\n * Revoke a PublishAuthorization sidecar (must be signed by the original ManagedAccount attester).\n */\nexport async function revokePublishAuthorization(params: {\n wallet: PublishWallet | SeedTxSender\n uid: string\n schemaUid?: string\n}): Promise<void> {\n const sender = resolveTxSender(params.wallet)\n const schemaUid = (params.schemaUid ?? getPublishAuthorizationSchemaUid()) as `0x${string}`\n const uid = normalizeBytes32Hex(params.uid) as `0x${string}`\n if (!isValidEasAttestationUid(uid)) {\n throw new Error(\n '@seedprotocol/publish: revokePublishAuthorization requires a valid attestation uid',\n )\n }\n\n const tx = prepareEasMultiRevoke([\n {\n schema: schemaUid,\n data: [{ uid }],\n },\n ])\n const receipt = await sendAndWait(sender, tx)\n if (!receipt) {\n throw new Error('@seedprotocol/publish: revokePublishAuthorization failed — no receipt')\n }\n}\n\nexport type AssessPublishAuthorizationLiveResult = {\n uid: string\n decoded: PublishAuthorizationDecoded\n assess: PublishAuthorizationAssessResult\n expirationTime?: number | null\n}\n\n/**\n * Load a PublishAuthorization attestation by uid (via identity filter + client match) and assess.\n * Prefer filtering with {@link getPublishAuthorizationFromEas} when you know identity/sessionKey.\n */\nexport async function assessPublishAuthorizationLive(params: {\n uid: string\n identities: string[]\n}): Promise<AssessPublishAuthorizationLiveResult | null> {\n const rows = await getPublishAuthorizationFromEas({\n identities: params.identities,\n excludeRevoked: false,\n })\n const row = rows.find((r) => r.id?.toLowerCase() === params.uid.toLowerCase())\n if (!row) return null\n const decoded = decodePublishAuthorizationData(row.decodedDataJson ?? '[]')\n const expirationTime =\n typeof row.expirationTime === 'number'\n ? row.expirationTime\n : typeof row.expirationTime === 'string'\n ? Number(row.expirationTime)\n : null\n return {\n uid: row.id,\n decoded,\n assess: assessPublishAuthorization({ decoded, expirationTime }),\n expirationTime,\n }\n}\n"],"mappings":";;;;;;AAGA,IAAac,IAAuBC,EAAoC,IAAI;AAE5E,SAAgBC,IAAkC;CAChD,IAAMC,IAASC,EAAWJ,CAAoB;CAC9C,IAAI,CAACG,GACH,MAAU,MACR,iH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