@owney/sdk 0.7.32-beta.5 → 0.7.32-beta.7
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 +23 -1
- package/dist/index.cjs +1480 -135
- package/dist/index.d.cts +473 -22
- package/dist/index.d.ts +473 -22
- package/dist/index.js +1479 -135
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -152,7 +152,7 @@ if (chainId) {
|
|
|
152
152
|
}
|
|
153
153
|
```
|
|
154
154
|
|
|
155
|
-
### `activateAgent(chainId, agentId?)`
|
|
155
|
+
### `activateAgent(chainId, agentId?, options?)`
|
|
156
156
|
|
|
157
157
|
Activate the user's smart wallet for the specified agents, or all chain-compatible agents if omitted. Activation performs each provider's required setup before deposits are allowed. For Yieldseeker, this creates the user and agent when needed and calls the agent `/deploy` endpoint before any funding transfer. Saves the chainId for use by all subsequent SDK calls.
|
|
158
158
|
|
|
@@ -160,6 +160,7 @@ Activate the user's smart wallet for the specified agents, or all chain-compatib
|
|
|
160
160
|
| --------- | ---------------------- | ----------------------------------------------------------------------------- |
|
|
161
161
|
| `chainId` | `number` | Target chain ID (e.g. `8453` for Base, `42161` for Arbitrum) |
|
|
162
162
|
| `agentId` | `AgentId[]` (optional) | Agents to activate. Omit to activate all agents that support the given chain. |
|
|
163
|
+
| `options` | `ActivateAgentOptions` (optional) | `asset` limits setup to that asset. `onAgentsSelected` fires once reads can start. |
|
|
163
164
|
|
|
164
165
|
```typescript
|
|
165
166
|
// Activate specific agents on Base
|
|
@@ -169,6 +170,24 @@ await sdk.activateAgent(8453, ["zyfai"]);
|
|
|
169
170
|
await sdk.activateAgent(42161);
|
|
170
171
|
```
|
|
171
172
|
|
|
173
|
+
Agents sign in one at a time, and activation stops at the first agent that fails, so no later agent's wallet prompt opens. A connect needs every agent: the app should end the session on any activation error. When an earlier agent activated, it throws `AGENT_ACTIVATION_PARTIAL_FAILURE` with `details: { activatedAgentIds, failedAgentIds, failures }`, plus `details.walletRejected: true` when the user rejected the signature. When the agent can never be readied (`details.permanent`), it throws `AGENT_ACTIVATION_BLOCKED`. Otherwise the agent's own error is thrown. Until it signs in, an agent whose signature the user rejected is read from a saved sign-in only (a read that would need a wallet prompt fails for that agent instead of opening one).
|
|
174
|
+
|
|
175
|
+
### `getUnavailableAgentIds(chainId, asset?)`
|
|
176
|
+
|
|
177
|
+
The agents that take no new deposits on this chain and asset this session, so the app can show them as unavailable: each agent whose provider has no agent for that slot (`IAgent.isSlotUnavailable`). They stay withdrawable.
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
180
|
+
const unavailable = sdk.getUnavailableAgentIds(8453, "USDC"); // e.g. ["yieldseeker"]
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### `getAvailableAgents({ chainId?, asset?, includeDisabled?, includeUnavailable? })`
|
|
184
|
+
|
|
185
|
+
Lists the configured agents. Disabled agents and agents unavailable on `chainId` (and `asset`) this session are omitted by default, because neither takes deposits. Pass `includeUnavailable: true` to list the unavailable ones too; `includeDisabled: true` lists both, since a disabled or unavailable agent may still hold funds to withdraw.
|
|
186
|
+
|
|
187
|
+
An adapter may implement the optional `IAgent.isSlotUnavailable(state, chainId, asset)`: true when its provider reported this session that the user cannot have an agent for that chain and asset. That is not a failure: `activateAgent` returns normally for it, deposits leave the slot out, and withdrawals without an explicit agent skip it.
|
|
188
|
+
|
|
189
|
+
Yieldseeker closes (deactivates) agents that stayed empty. The SDK reopens the user's verified agent when it finds it closed, at sign-in, on reads and before a deposit (at most one reopen request per slot per 120 s, and none after a permanent refusal). An agent that cannot be reopened fails with `YIELDSEEKER_AGENT_CLOSED`; at Yieldseeker's active-agent limit the slot reports `YIELDSEEKER_SLOT_UNAVAILABLE` and is unavailable for the session. A deposit is never sent to a closed agent.
|
|
190
|
+
|
|
172
191
|
### `deposit(options)`
|
|
173
192
|
|
|
174
193
|
Deposit funds into a specific agent, or split equally across all agents if `agentId` is omitted. Validates that the asset is supported by the target agent(s) on the active chain, and per-agent minimum deposit amounts (defined per chain+asset on `agent.supportedAssets[].assets[].minDepositAmount`) are taken into account. Custom `depositCallback` implementations run once per final valid agent. The default Permit2 flow signs one recipient-bound batch authorization for every agent share. On the first Base USDC deposit, the SDK first requests an ERC-2612 signature; the relayer then submits the Permit2 approval and deposit as two sponsored transactions. Later deposits need only the batch signature.
|
|
@@ -769,6 +788,9 @@ type OwneyErrorCode =
|
|
|
769
788
|
| "AGENT_NOT_FOUND" // Unknown agent ID passed
|
|
770
789
|
| "AGENT_CHAIN_INCOMPATIBLE" // Agent(s) don't support the given chain
|
|
771
790
|
| "AGENT_EMPTY_LIST" // Empty agentId array passed to activateAgent()
|
|
791
|
+
| "AGENT_ACTIVATION_PARTIAL_FAILURE" // An earlier agent activated, then one failed and activation stopped; details.walletRejected when the user rejected a signature
|
|
792
|
+
| "YIELDSEEKER_AGENT_CLOSED" // Yieldseeker closed the slot's agent and it cannot be reopened; before a deposit details carry notSubmitted: true, safeToFallback: false (nothing was sent)
|
|
793
|
+
| "YIELDSEEKER_SLOT_UNAVAILABLE" // No Yieldseeker agent for this slot this session (the user's active-agent limit); details.providerCode names the limit
|
|
772
794
|
// Chain
|
|
773
795
|
| "CHAIN_UNSUPPORTED" // Chain ID not in supported list (8453, 42161)
|
|
774
796
|
| "CHAIN_NO_COMPATIBLE_AGENTS" // No agents support the given chain
|