@seedprotocol/publish 0.7.4-next.711.gce2b766 → 0.7.4-next.793.g6dd83dd

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.
Files changed (88) hide show
  1. package/README.md +75 -0
  2. package/dist/authorization.d.ts +41 -0
  3. package/dist/authorization.d.ts.map +1 -0
  4. package/dist/{chainConfig-RhKIuGtN.js → chainConfig-BKuFZqOU.js} +2025 -1488
  5. package/dist/chainConfig-BKuFZqOU.js.map +1 -0
  6. package/dist/config.d.ts +25 -4
  7. package/dist/config.d.ts.map +1 -1
  8. package/dist/{ensureAutomationSessionKey-CvUntLne.js → ensureAutomationSessionKey-DgpGcDDd.js} +31 -31
  9. package/dist/{ensureAutomationSessionKey-CvUntLne.js.map → ensureAutomationSessionKey-DgpGcDDd.js.map} +1 -1
  10. package/dist/ensureModularPublishBootstrap-C-z64vF-.js +21 -0
  11. package/dist/{ensureModularPublishBootstrap-D9q246TT.js.map → ensureModularPublishBootstrap-C-z64vF-.js.map} +1 -1
  12. package/dist/{ensureSmartWalletThenPublish-C_iS5Wb-.js → ensureSmartWalletThenPublish-YoUtjqRN.js} +15 -15
  13. package/dist/{ensureSmartWalletThenPublish-C_iS5Wb-.js.map → ensureSmartWalletThenPublish-YoUtjqRN.js.map} +1 -1
  14. package/dist/helpers/abi/eas.d.ts +42 -0
  15. package/dist/helpers/abi/eas.d.ts.map +1 -1
  16. package/dist/helpers/adapters/permissionlessTxSender.d.ts +5 -1
  17. package/dist/helpers/adapters/permissionlessTxSender.d.ts.map +1 -1
  18. package/dist/helpers/ensureWalletThenPublish.d.ts.map +1 -1
  19. package/dist/helpers/publishWalletRegistry.d.ts +11 -1
  20. package/dist/helpers/publishWalletRegistry.d.ts.map +1 -1
  21. package/dist/helpers/resolveRevokeAccount.d.ts.map +1 -1
  22. package/dist/helpers/turbo.d.ts +55 -0
  23. package/dist/helpers/turbo.d.ts.map +1 -0
  24. package/dist/helpers/uploadApi.d.ts +3 -1
  25. package/dist/helpers/uploadApi.d.ts.map +1 -1
  26. package/dist/index.d.ts +3 -0
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +338 -479
  29. package/dist/index.js.map +1 -1
  30. package/dist/{managedAccountAdmin-CLVRJEKI.js → managedAccountAdmin-C2sRBf9X.js} +10 -10
  31. package/dist/{managedAccountAdmin-CLVRJEKI.js.map → managedAccountAdmin-C2sRBf9X.js.map} +1 -1
  32. package/dist/payment.d.ts +106 -0
  33. package/dist/payment.d.ts.map +1 -0
  34. package/dist/{publishAuthorization-DAarz1JK.js → publishAuthorization-Dprnd1G4.js} +25 -25
  35. package/dist/{publishAuthorization-DAarz1JK.js.map → publishAuthorization-Dprnd1G4.js.map} +1 -1
  36. package/dist/react/ConnectButton.d.ts.map +1 -1
  37. package/dist/react/useSeedWallet.d.ts.map +1 -1
  38. package/dist/resolveRevokeAccount-BQWdziaJ.js +37 -0
  39. package/dist/resolveRevokeAccount-BQWdziaJ.js.map +1 -0
  40. package/dist/services/arweaveL1Finalize/worker.d.ts.map +1 -1
  41. package/dist/services/domainOwnership/challenge.d.ts +4 -1
  42. package/dist/services/domainOwnership/challenge.d.ts.map +1 -1
  43. package/dist/services/domainOwnership/index.d.ts +1 -1
  44. package/dist/services/domainOwnership/index.d.ts.map +1 -1
  45. package/dist/services/domainOwnership/public.d.ts +1 -1
  46. package/dist/services/domainOwnership/public.d.ts.map +1 -1
  47. package/dist/services/domainOwnership/registry.d.ts +2 -0
  48. package/dist/services/domainOwnership/registry.d.ts.map +1 -1
  49. package/dist/services/publish/actors/authorizing.d.ts +10 -0
  50. package/dist/services/publish/actors/authorizing.d.ts.map +1 -0
  51. package/dist/services/publish/actors/checking.d.ts.map +1 -1
  52. package/dist/services/publish/actors/createAttestationsDirectToEas.d.ts.map +1 -1
  53. package/dist/services/publish/actors/index.d.ts +1 -0
  54. package/dist/services/publish/actors/index.d.ts.map +1 -1
  55. package/dist/services/publish/actors/sendReimbursementRequest.d.ts.map +1 -1
  56. package/dist/services/publish/actors/uploadViaBundler.d.ts.map +1 -1
  57. package/dist/services/publish/helpers/undeployedSmartAccount.d.ts +15 -0
  58. package/dist/services/publish/helpers/undeployedSmartAccount.d.ts.map +1 -0
  59. package/dist/services/publish/helpers/uploadToTurbo.d.ts +8 -0
  60. package/dist/services/publish/helpers/uploadToTurbo.d.ts.map +1 -0
  61. package/dist/services/publish/helpers/verifyArweaveTransactionsExist.d.ts +2 -1
  62. package/dist/services/publish/helpers/verifyArweaveTransactionsExist.d.ts.map +1 -1
  63. package/dist/services/publish/index.d.ts +13 -1
  64. package/dist/services/publish/index.d.ts.map +1 -1
  65. package/dist/services/publishCost/estimatePublishCost.d.ts +1 -0
  66. package/dist/services/publishCost/estimatePublishCost.d.ts.map +1 -1
  67. package/dist/services/publishCost/types.d.ts +7 -0
  68. package/dist/services/publishCost/types.d.ts.map +1 -1
  69. package/dist/services/publishManager/actions/createPublish.d.ts.map +1 -1
  70. package/dist/services/publishManager/actions/requestSavePublish.d.ts +10 -0
  71. package/dist/services/publishManager/actions/requestSavePublish.d.ts.map +1 -1
  72. package/dist/services/revoke/revokeAttestations.d.ts +2 -1
  73. package/dist/services/revoke/revokeAttestations.d.ts.map +1 -1
  74. package/dist/thirdweb.js +106 -105
  75. package/dist/thirdweb.js.map +1 -1
  76. package/dist/types.d.ts +4 -0
  77. package/dist/types.d.ts.map +1 -1
  78. package/dist/undeployedSmartAccount-96Jwrrl6.js +24 -0
  79. package/dist/undeployedSmartAccount-96Jwrrl6.js.map +1 -0
  80. package/dist/worker-CcBaiQEh.js +88 -0
  81. package/dist/worker-CcBaiQEh.js.map +1 -0
  82. package/package.json +6 -6
  83. package/dist/chainConfig-RhKIuGtN.js.map +0 -1
  84. package/dist/ensureModularPublishBootstrap-D9q246TT.js +0 -21
  85. package/dist/resolveRevokeAccount-TRcqJtIO.js +0 -36
  86. package/dist/resolveRevokeAccount-TRcqJtIO.js.map +0 -1
  87. package/dist/worker-CyuMiBB-.js +0 -72
  88. package/dist/worker-CyuMiBB-.js.map +0 -1
package/README.md CHANGED
@@ -107,6 +107,81 @@ function App() {
107
107
 
108
108
  You can optionally pass `queryClient` or `queryClientRef` to customize the Seed QueryClient.
109
109
 
110
+ ### Who pays
111
+
112
+ A publish costs EVM gas (attestations, schema registration) and Arweave storage. Who pays follows
113
+ from the sender your config selects:
114
+
115
+ | Sender | Selected by | Gas |
116
+ |---|---|---|
117
+ | Thirdweb managed account | `useModularExecutor: true` | sponsored by Thirdweb unless `thirdweb.sponsorGas: false` |
118
+ | Permissionless EIP-7702 | `bundlerUrl` (Recipe 2) | sponsored by `paymasterUrl`, else the bundler |
119
+ | Connected wallet | neither | the user's ETH |
120
+
121
+ Storage goes through the upload API at `uploadApiBaseUrl`, and its operator pays: directly on the
122
+ bundler path, and on the L1 path by reimbursing the user's Arweave key before the upload.
123
+
124
+ To state the intent instead, set `payment`. It fills in those settings' defaults, and `initPublish`
125
+ throws `PublishPaymentConfigError` when a setting contradicts it:
126
+
127
+ ```typescript
128
+ initPublish({
129
+ // ...
130
+ bundlerUrl: import.meta.env.VITE_BUNDLER_URL,
131
+ payment: { gas: 'user', storage: 'operator' }, // EIP-7702 sender without a paymaster
132
+ })
133
+ ```
134
+
135
+ `resolvePublishPayment(getPublishConfig())` returns the resolved sender and payers; `estimatePublishCost`
136
+ reports the same in `evm.userPays` / `arweave.userPays`.
137
+
138
+ #### Users pay for storage (Turbo)
139
+
140
+ `payment: { storage: 'user' }` sends data items (signed by the user's EVM key, as on the bundler path)
141
+ straight to [Turbo](https://docs.ar.io/build/upload/bundling-services/), which charges that address's
142
+ Turbo credits. Users top up through Turbo with a card or crypto. Items under Turbo's free-tier size
143
+ cost nothing. Before uploading, the publish checks the balance covers the items and fails with
144
+ `InsufficientStorageCreditsError` (with `address`, `requiredWinc`, `balanceWinc`) if not, so nothing
145
+ is half-uploaded.
146
+
147
+ ```typescript
148
+ initPublish({
149
+ // ...
150
+ payment: {
151
+ storage: 'user',
152
+ // Optional: other Turbo endpoints, or app wallets whose shared credits pay first (x-paid-by)
153
+ userStorage: { provider: 'turbo', paidBy: ['0xYourAppWallet'] },
154
+ },
155
+ })
156
+ ```
157
+
158
+ `getTurboBalanceWinc(endpoints, address)` and `getTurboPriceWinc(endpoints, bytes)` help show a
159
+ balance or price before publishing.
160
+
161
+ #### Approving and billing publishes
162
+
163
+ `authorizePublish` runs before a publish spends anything (before schema registration, uploads and
164
+ attestations). Use it to confirm the cost with the user, check a quota, or charge them. Return
165
+ `false` or throw to refuse (the publish fails with `PublishNotAuthorizedError`); return `true` or
166
+ nothing to go ahead; return `{ token }` to also send the token to the upload API as the
167
+ `X-Seed-Publish-Authorization` header on that publish's requests, so the operator can meter or
168
+ bill against it.
169
+
170
+ ```typescript
171
+ initPublish({
172
+ // ...
173
+ authorizePublish: async ({ item, payment, getEstimate }) => {
174
+ const estimate = await getEstimate() // fetches prices; skip it if you don't need it
175
+ const { approved, receiptId } = await myBilling.charge(item.seedLocalId, estimate.totalUsd)
176
+ return approved ? { token: receiptId } : false
177
+ },
178
+ })
179
+ ```
180
+
181
+ It can also be passed per publish (`CreatePublishOptions.authorizePublish`). A publish resumed
182
+ after a reload is not asked again once it got past this step; one restored before approval asks
183
+ the config hook. The token is not sent to Turbo.
184
+
110
185
  ### Choosing a chain
111
186
 
112
187
  Publishing works on any EVM chain with [EAS](https://github.com/ethereum-attestation-service/eas-contracts#deployments) deployed. Pass a viem `chain`; it defaults to Optimism Sepolia. The same chain drives viem reads, transaction routing and the Thirdweb wallet / ConnectButton. When `rpcUrl` is set, Thirdweb uses it too, so Seed's checks and Thirdweb's calls always reach the same node.
@@ -0,0 +1,41 @@
1
+ import type { IItem } from '@seedprotocol/sdk';
2
+ import type { ResolvedPublishPayment } from './payment';
3
+ import type { PublishCostEstimate, PublishMode } from './services/publishCost/types';
4
+ /** What an {@link AuthorizePublish} hook is asked to approve. */
5
+ export interface PublishAuthorizationRequest {
6
+ item: IItem<any>;
7
+ seedLocalId: string;
8
+ publishMode: PublishMode;
9
+ /** Who will pay gas and storage (see `resolvePublishPayment`). */
10
+ payment: ResolvedPublishPayment;
11
+ /** Cost estimate for this publish. Fetches market prices, so call it only if you need it. */
12
+ getEstimate: () => Promise<PublishCostEstimate>;
13
+ }
14
+ /** An approval. `token` goes to the upload API with this publish's requests. */
15
+ export interface PublishAuthorization {
16
+ /**
17
+ * Sent as the {@link PUBLISH_AUTHORIZATION_HEADER} header on upload API requests (not to Turbo),
18
+ * so an operator can meter or bill the publish against it.
19
+ */
20
+ token?: string;
21
+ }
22
+ /**
23
+ * Runs before a publish spends anything (before schema registration, uploads and attestations).
24
+ * Return `false` or throw to refuse: the publish fails with {@link PublishNotAuthorizedError}.
25
+ * Return `true`, nothing, or a {@link PublishAuthorization} to go ahead. A resumed publish that
26
+ * already got past this step is not asked again.
27
+ */
28
+ export type AuthorizePublish = (request: PublishAuthorizationRequest) => PublishAuthorization | boolean | void | Promise<PublishAuthorization | boolean | void>;
29
+ /** Header carrying {@link PublishAuthorization.token} to the upload API. */
30
+ export declare const PUBLISH_AUTHORIZATION_HEADER = "X-Seed-Publish-Authorization";
31
+ export declare class PublishNotAuthorizedError extends Error {
32
+ constructor(seedLocalId: string, cause?: unknown);
33
+ }
34
+ /**
35
+ * Calls the hook and normalizes its answer. Without a hook every publish is approved.
36
+ * @throws PublishNotAuthorizedError when the hook returns false or throws
37
+ */
38
+ export declare function runAuthorizePublish(hook: AuthorizePublish | undefined, request: PublishAuthorizationRequest): Promise<PublishAuthorization>;
39
+ /** Headers to add to upload API requests for a publish with this authorization. */
40
+ export declare function publishAuthorizationHeaders(authorization: PublishAuthorization | undefined): Record<string, string>;
41
+ //# sourceMappingURL=authorization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorization.d.ts","sourceRoot":"","sources":["../src/authorization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,KAAK,EA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