@gol/sdk 0.2.0 → 0.4.0
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 +8 -5
- package/dist/generated/platform.d.ts +1517 -613
- package/dist/generated/platform.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/owner.d.ts +9 -1
- package/dist/owner.d.ts.map +1 -1
- package/dist/owner.js +45 -0
- package/dist/owner.js.map +1 -1
- package/dist/server.d.ts +14 -4
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +42 -2
- package/dist/server.js.map +1 -1
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
TypeScript SDK for GOL Network bounded mandates with hosted, owner-reimbursed gas on Base Sepolia testnet (chain `84532`).
|
|
4
4
|
|
|
5
|
-
A developer's agent sends bounded USDC transfers from an end user's existing smart account. GOL's relayer pays the network gas first. After the action
|
|
5
|
+
A developer's agent sends bounded USDC transfers from an end user's existing smart account. GOL's relayer pays the network gas first. After the action reaches the hosted profile's selected Base head, GOL claims the actual gas back in native ETH from the same account, within caps the owner signed. The owner signs every authority in their own wallet and can pause, resume, or revoke without GOL.
|
|
6
6
|
|
|
7
7
|
Supported accounts are four exact configurations: Safe 1.4.1, Biconomy Nexus 1.0.0, ZeroDev Kernel v0.3.1, and Alchemy Modular Account v2. The transfer asset is Circle USDC on Base Sepolia. Read deployed addresses and limits from `getGasConfiguration`; do not hard-code them.
|
|
8
8
|
|
|
@@ -14,6 +14,8 @@ pnpm add @gol/sdk@next
|
|
|
14
14
|
|
|
15
15
|
Use Node.js 22 or later. The root entry point (`@gol/sdk`) is browser-safe: policy encoding, owner wallet payloads, owner operations, and verification. API clients and webhook verification are in `@gol/sdk/server` and must run on your server, because they hold your API key.
|
|
16
16
|
|
|
17
|
+
`GolManagementClient` also wraps developer session routes for server use: `startEmailChallenge`, `verifyEmailChallenge`, `createGoogleSession`, `renewSession`, and `revokeSession`. Google ID tokens come from a server-side OAuth code exchange. Keep the resulting GOL session token in an HTTP-only cookie and do not expose it to client JavaScript.
|
|
18
|
+
|
|
17
19
|
## Integration flow
|
|
18
20
|
|
|
19
21
|
Create a test project and an API key with `project:read`, `accounts:read`, `mandates:read`, `mandates:write`, `actions:submit`, and `webhooks:manage` at [console.gol.network](https://console.gol.network).
|
|
@@ -21,10 +23,11 @@ Create a test project and an API key with `project:read`, `accounts:read`, `mand
|
|
|
21
23
|
1. **Install the core on the owner's account.** `getAccountStatus` reports the detected family and whether the core is installed. If not, build the owner operation in the browser with `prepareOwnerInstallation` and `prepareOwnerOperation`, have the owner sign it with `signOwnerOperation`, and submit the returned transaction (a Safe transaction, or an EntryPoint v0.7 user operation for Nexus, Kernel, and Alchemy).
|
|
22
24
|
2. **Prepare the approval on your server.** `prepareGasPolicy` compiles the exact mandate policy (allowed recipients, per-action and total USDC caps) and gas policy (per-action and total ETH reimbursement caps, expiry, chargeable outcomes).
|
|
23
25
|
3. **Have the owner sign in the browser.** `signPreparedGasPolicy(ownerWallet, prepared, expectations)` independently recomputes every ID, digest, and wallet payload, asks the wallet for one `eth_signTypedData_v4` signature, and returns a `createMandateWithGas` call. Any address may send it; authority comes only from the owner's signature.
|
|
24
|
-
4. **Confirm.** `confirmGasPolicy` (or `waitForGasPolicyConfirmation`) returns the policy once the approval
|
|
26
|
+
4. **Confirm.** `confirmGasPolicy` (or `waitForGasPolicyConfirmation`) returns the policy once both receipt providers observe the approval at the hosted profile's selected Base head. Profile 3 uses the lower `safe` head, usually tens of seconds behind the latest head on Base Sepolia. This is earlier than Ethereum finality, and timing varies with network conditions.
|
|
25
27
|
5. **Submit actions from your agent.** `prepareGasExecution` returns EIP-712 typed data; your agent signs it and you call `submitGasExecution` with the same 32-byte action ID as the idempotency key. A retry with the same ID and signature returns the original execution and moves no additional value.
|
|
26
28
|
6. **Observe.** Poll `getGasExecution` or `waitForGasExecution`, or receive signed webhooks. Network cost, owner reimbursement, and GOL cost are reported separately.
|
|
27
|
-
7. **
|
|
29
|
+
7. **Pause or resume.** On your server, call `prepareGasPolicySafetyAction(projectId, gasPolicyId, { action: "pause" })` or use `"resume"`. In the owner's browser, `signPreparedSafetyAction(walletClient, prepared)` verifies the digest and wallet payload before signing and returns a core call that any address may relay. Alternatively, submit `prepared.directOwnerCall` through the owner's account. Confirm the transaction with `waitForGasPolicySafetyAction`. A paused policy refuses new submissions. An accepted action waiting to be sent remains held while paused, proceeds if the owner resumes before its quote expires, or closes without owner liability at quote expiry.
|
|
30
|
+
8. **Revoke.** `prepareGasPolicyRevocation` returns both owner paths: a relayed owner signature (`signPreparedRevocation`) and a direct account call. Either works without GOL or the agent.
|
|
28
31
|
|
|
29
32
|
```ts
|
|
30
33
|
// Server
|
|
@@ -81,7 +84,7 @@ const event = verifyWebhook(
|
|
|
81
84
|
|
|
82
85
|
Each family's owner path is fixed: Safe `SafeMessage` under the account's domain, Nexus ERC-7739 `PersonalSign` with the K1 validator prefix, Kernel `Kernel(bytes32 hash)` with the root locator, and Alchemy `ReplaySafeHash` with the entity-zero prefix. `buildWalletSigningPayload` and `verifyWalletSigningPayload` expose them. The SDK never signs a raw hash with `personal_sign` for an approval, and never receives an owner key. Owner user operations for Nexus, Kernel, and Alchemy are signed with `personal_sign` over the EntryPoint v0.7 user operation hash. An Alchemy account can hold one GOL validation at entity 1; remove an earlier GOL core with `preparePermanentRemoval` before installing this one.
|
|
83
86
|
|
|
84
|
-
The encoders are checked against the independent Python reference vectors in `contracts/tools/encoding/gol_encoding.py`, and `pnpm verify:owner-fork` drives installation, approval, and both revocation paths for the four families on an anvil fork of Base Sepolia.
|
|
87
|
+
The encoders are checked against the independent Python reference vectors in `contracts/tools/encoding/gol_encoding.py`, and `pnpm verify:owner-fork` drives installation, approval, relayed and direct pause and resume, and both revocation paths for the four families on an anvil fork of Base Sepolia.
|
|
85
88
|
|
|
86
89
|
## API key authentication
|
|
87
90
|
|
|
@@ -136,7 +139,7 @@ pnpm verify:account-dialects
|
|
|
136
139
|
pnpm format:check
|
|
137
140
|
```
|
|
138
141
|
|
|
139
|
-
`pnpm upstream:check` and `pnpm verify:gas-encoding` need sibling `platform` and `contracts` checkouts. `pnpm verify:account-dialects` reads Base Sepolia over RPC, using `BASE_SEPOLIA_RPC_URL`
|
|
142
|
+
`pnpm upstream:check` and `pnpm verify:gas-encoding` need sibling `platform` and `contracts` checkouts. `pnpm verify:account-dialects` reads Base Sepolia over RPC, using `BASE_SEPOLIA_RPC_URL`, else an Alchemy endpoint built from `ALCHEMY_API_KEY`, else the public endpoint. CI runs `generate:check`, `typecheck`, `lint`, `test`, `format:check`, and `verify:pack` on Node.js 22; it does not run the sibling or RPC checks.
|
|
140
143
|
|
|
141
144
|
`openapi/platform.json` is a versioned snapshot of the platform contract. `pnpm sync:openapi` refreshes the snapshot from `../platform/openapi/openapi.json` by default and regenerates TypeScript declarations. Set `GOL_PLATFORM_OPENAPI_PATH` when the platform repository is elsewhere.
|
|
142
145
|
|