@seedprotocol/publish 0.7.3 → 0.7.4-next.784.g879c6a3
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/README.md +75 -0
- package/dist/authorization.d.ts +41 -0
- package/dist/authorization.d.ts.map +1 -0
- package/dist/{chainConfig-RhKIuGtN.js → chainConfig-BHTH_BGB.js} +2012 -1488
- package/dist/chainConfig-BHTH_BGB.js.map +1 -0
- package/dist/config.d.ts +25 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/{ensureAutomationSessionKey-CvUntLne.js → ensureAutomationSessionKey-DITIsceC.js} +31 -31
- package/dist/{ensureAutomationSessionKey-CvUntLne.js.map → ensureAutomationSessionKey-DITIsceC.js.map} +1 -1
- package/dist/ensureModularPublishBootstrap-sAAJn75c.js +21 -0
- package/dist/{ensureModularPublishBootstrap-D9q246TT.js.map → ensureModularPublishBootstrap-sAAJn75c.js.map} +1 -1
- package/dist/{ensureSmartWalletThenPublish-C_iS5Wb-.js → ensureSmartWalletThenPublish-hRJ9T0f8.js} +15 -15
- package/dist/{ensureSmartWalletThenPublish-C_iS5Wb-.js.map → ensureSmartWalletThenPublish-hRJ9T0f8.js.map} +1 -1
- package/dist/helpers/abi/eas.d.ts +42 -0
- package/dist/helpers/abi/eas.d.ts.map +1 -1
- package/dist/helpers/adapters/permissionlessTxSender.d.ts +5 -1
- package/dist/helpers/adapters/permissionlessTxSender.d.ts.map +1 -1
- package/dist/helpers/ensureWalletThenPublish.d.ts.map +1 -1
- package/dist/helpers/publishWalletRegistry.d.ts +5 -0
- package/dist/helpers/publishWalletRegistry.d.ts.map +1 -1
- package/dist/helpers/resolveRevokeAccount.d.ts.map +1 -1
- package/dist/helpers/turbo.d.ts +55 -0
- package/dist/helpers/turbo.d.ts.map +1 -0
- package/dist/helpers/uploadApi.d.ts +3 -1
- package/dist/helpers/uploadApi.d.ts.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +338 -479
- package/dist/index.js.map +1 -1
- package/dist/{managedAccountAdmin-CLVRJEKI.js → managedAccountAdmin-CSBb6NaZ.js} +10 -10
- package/dist/{managedAccountAdmin-CLVRJEKI.js.map → managedAccountAdmin-CSBb6NaZ.js.map} +1 -1
- package/dist/payment.d.ts +106 -0
- package/dist/payment.d.ts.map +1 -0
- package/dist/{publishAuthorization-DAarz1JK.js → publishAuthorization-CZyvsNGG.js} +25 -25
- package/dist/{publishAuthorization-DAarz1JK.js.map → publishAuthorization-CZyvsNGG.js.map} +1 -1
- package/dist/react/ConnectButton.d.ts.map +1 -1
- package/dist/react/useSeedWallet.d.ts.map +1 -1
- package/dist/resolveRevokeAccount-CbQiAEZp.js +37 -0
- package/dist/resolveRevokeAccount-CbQiAEZp.js.map +1 -0
- package/dist/services/arweaveL1Finalize/worker.d.ts.map +1 -1
- package/dist/services/domainOwnership/challenge.d.ts +4 -1
- package/dist/services/domainOwnership/challenge.d.ts.map +1 -1
- package/dist/services/domainOwnership/index.d.ts +1 -1
- package/dist/services/domainOwnership/index.d.ts.map +1 -1
- package/dist/services/domainOwnership/public.d.ts +1 -1
- package/dist/services/domainOwnership/public.d.ts.map +1 -1
- package/dist/services/domainOwnership/registry.d.ts +2 -0
- package/dist/services/domainOwnership/registry.d.ts.map +1 -1
- package/dist/services/publish/actors/authorizing.d.ts +10 -0
- package/dist/services/publish/actors/authorizing.d.ts.map +1 -0
- package/dist/services/publish/actors/checking.d.ts.map +1 -1
- package/dist/services/publish/actors/createAttestationsDirectToEas.d.ts.map +1 -1
- package/dist/services/publish/actors/index.d.ts +1 -0
- package/dist/services/publish/actors/index.d.ts.map +1 -1
- package/dist/services/publish/actors/sendReimbursementRequest.d.ts.map +1 -1
- package/dist/services/publish/actors/uploadViaBundler.d.ts.map +1 -1
- package/dist/services/publish/helpers/undeployedSmartAccount.d.ts +15 -0
- package/dist/services/publish/helpers/undeployedSmartAccount.d.ts.map +1 -0
- package/dist/services/publish/helpers/uploadToTurbo.d.ts +8 -0
- package/dist/services/publish/helpers/uploadToTurbo.d.ts.map +1 -0
- package/dist/services/publish/helpers/verifyArweaveTransactionsExist.d.ts +2 -1
- package/dist/services/publish/helpers/verifyArweaveTransactionsExist.d.ts.map +1 -1
- package/dist/services/publish/index.d.ts +13 -1
- package/dist/services/publish/index.d.ts.map +1 -1
- package/dist/services/publishCost/estimatePublishCost.d.ts +1 -0
- package/dist/services/publishCost/estimatePublishCost.d.ts.map +1 -1
- package/dist/services/publishCost/types.d.ts +7 -0
- package/dist/services/publishCost/types.d.ts.map +1 -1
- package/dist/services/publishManager/actions/createPublish.d.ts.map +1 -1
- package/dist/services/publishManager/actions/requestSavePublish.d.ts +10 -0
- package/dist/services/publishManager/actions/requestSavePublish.d.ts.map +1 -1
- package/dist/services/revoke/revokeAttestations.d.ts +2 -1
- package/dist/services/revoke/revokeAttestations.d.ts.map +1 -1
- package/dist/thirdweb.js +106 -105
- package/dist/thirdweb.js.map +1 -1
- package/dist/types.d.ts +4 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/undeployedSmartAccount-DwGsM3K1.js +24 -0
- package/dist/undeployedSmartAccount-DwGsM3K1.js.map +1 -0
- package/dist/worker--EZUESZk.js +88 -0
- package/dist/worker--EZUESZk.js.map +1 -0
- package/package.json +6 -6
- package/dist/chainConfig-RhKIuGtN.js.map +0 -1
- package/dist/ensureModularPublishBootstrap-D9q246TT.js +0 -21
- package/dist/resolveRevokeAccount-TRcqJtIO.js +0 -36
- package/dist/resolveRevokeAccount-TRcqJtIO.js.map +0 -1
- package/dist/worker-CyuMiBB-.js +0 -72
- 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,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAA;AACvD,OAAO,KAAK,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAEpF,iEAAiE;AACjE,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,WAAW,CAAA;IACxB,kEAAkE;IAClE,OAAO,EAAE,sBAAsB,CAAA;IAC/B,6FAA6F;IAC7F,WAAW,EAAE,MAAM,OAAO,CAAC,mBAAmB,CAAC,CAAA;CAChD;AAED,gFAAgF;AAChF,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAC7B,OAAO,EAAE,2BAA2B,KACjC,oBAAoB,GAAG,OAAO,GAAG,IAAI,GAAG,OAAO,CAAC,oBAAoB,GAAG,OAAO,GAAG,IAAI,CAAC,CAAA;AAE3F,4EAA4E;AAC5E,eAAO,MAAM,4BAA4B,iCAAiC,CAAA;AAE1E,qBAAa,yBAA0B,SAAQ,KAAK;gBACtC,WAAW,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAKjD;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,gBAAgB,GAAG,SAAS,EAClC,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,oBAAoB,CAAC,CAa/B;AAED,mFAAmF;AACnF,wBAAgB,2BAA2B,CAAC,aAAa,EAAE,oBAAoB,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAEnH"}
|