@owney/sdk 0.7.11 → 0.7.12-beta.1
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/dist/chunk-PWIKIQOX.js +140 -0
- package/dist/index.cjs +930 -222
- package/dist/index.d.cts +52 -2
- package/dist/index.d.ts +52 -2
- package/dist/index.js +249 -198
- package/dist/surfliquid.agent-VNGQUSXN.js +473 -0
- package/package.json +3 -1
package/dist/index.d.cts
CHANGED
|
@@ -21,6 +21,16 @@ interface OwneySDKConfig {
|
|
|
21
21
|
* `createOwneySIWX` for apps that don't use the AppKit SIWX modal.
|
|
22
22
|
*/
|
|
23
23
|
referralSource?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Optional override for the SurfLiquid API base URL (defaults to the
|
|
26
|
+
* SurfLiquid SDK's production URL). SurfLiquid auth is an httpOnly
|
|
27
|
+
* SameSite=None cookie set by api.surfliquid.com — a THIRD-PARTY cookie from
|
|
28
|
+
* the embedding app's origin, which WebKit (all iOS browsers) discards, so
|
|
29
|
+
* every authenticated SurfLiquid call 401s on iOS. Point this at a
|
|
30
|
+
* same-origin reverse proxy (e.g. "/api/surf") so the session cookie becomes
|
|
31
|
+
* first-party. Relative paths resolve against the page origin.
|
|
32
|
+
*/
|
|
33
|
+
surfliquidApiBaseUrl?: string;
|
|
24
34
|
/**
|
|
25
35
|
* Turn on the SDK's debug logging (default false). Traces the decisions that
|
|
26
36
|
* are otherwise invisible — notably how the organization's agent policy is
|
|
@@ -54,7 +64,7 @@ type OwneySupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];
|
|
|
54
64
|
type OwneySupportedChains = (typeof SUPPORTED_CHAINS)[number];
|
|
55
65
|
type OwneySupportedTokens = (typeof SUPPORTED_TOKENS)[number];
|
|
56
66
|
|
|
57
|
-
type AgentId = "zyfai" | "sail";
|
|
67
|
+
type AgentId = "zyfai" | "sail" | "surfliquid";
|
|
58
68
|
type Asset = string;
|
|
59
69
|
type AgentSupportedAsset = {
|
|
60
70
|
readonly symbol: string;
|
|
@@ -170,6 +180,12 @@ interface OwneyDepositResult {
|
|
|
170
180
|
}
|
|
171
181
|
interface OwneyMultiDepositResult {
|
|
172
182
|
agentResults: Record<string, OwneyDepositResult>;
|
|
183
|
+
/**
|
|
184
|
+
* Per-agent failure messages for agents that errored during a diversified
|
|
185
|
+
* deposit. Present only when at least one (but not all) agents failed —
|
|
186
|
+
* the deposit is partial, not total. Omitted when every agent succeeded.
|
|
187
|
+
*/
|
|
188
|
+
agentErrors?: Record<string, string>;
|
|
173
189
|
}
|
|
174
190
|
interface AgentWithdrawResult {
|
|
175
191
|
txHash?: string;
|
|
@@ -441,6 +457,7 @@ declare class OwneySDK {
|
|
|
441
457
|
private zyfaiRpcUrls?;
|
|
442
458
|
private routingApiBaseUrl?;
|
|
443
459
|
private referralSource?;
|
|
460
|
+
private surfliquidApiBaseUrl?;
|
|
444
461
|
private cachedSponsoredCallback;
|
|
445
462
|
private cachedWethSponsoredCallback;
|
|
446
463
|
private paymasterServiceUrl?;
|
|
@@ -522,6 +539,28 @@ declare class OwneySDK {
|
|
|
522
539
|
* throws before activating any agent.
|
|
523
540
|
*/
|
|
524
541
|
activateAgent(chainId: number, agentId?: AgentId[]): Promise<void>;
|
|
542
|
+
/**
|
|
543
|
+
* Activate agents ONE AT A TIME, each followed by its org policy.
|
|
544
|
+
*
|
|
545
|
+
* Every agent opens its activation with its own wallet signature — Zyfai's
|
|
546
|
+
* SIWX (exchanged for a JWT) and SurfLiquid's SIWE (exchanged for an httpOnly
|
|
547
|
+
* cookie). Run in parallel, that puts two `personal_sign` requests on one
|
|
548
|
+
* wallet connection in the same instant. Over WalletConnect both are
|
|
549
|
+
* delivered to the wallet, which renders one signing request at a time and
|
|
550
|
+
* queues or silently drops the other: neither promise settles, so activation
|
|
551
|
+
* hangs until the caller's timeout with no prompt the user can act on. The
|
|
552
|
+
* single-agent era never hit this — there was no second prompt to collide
|
|
553
|
+
* with — so it appeared the moment a second agent became eligible.
|
|
554
|
+
*
|
|
555
|
+
* Serializing costs no real wall-clock: the user can only approve one prompt
|
|
556
|
+
* at a time anyway.
|
|
557
|
+
*
|
|
558
|
+
* Every agent is attempted even if an earlier one fails, so one declined
|
|
559
|
+
* signature can't deny the remaining agents their turn. The first failure is
|
|
560
|
+
* rethrown (matching the previous `Promise.all` rejection) once all agents
|
|
561
|
+
* have had a chance to activate.
|
|
562
|
+
*/
|
|
563
|
+
private activateAgentsInTurn;
|
|
525
564
|
/**
|
|
526
565
|
* Deposit funds into a specific agent, or split equally across all agents if agentId is omitted.
|
|
527
566
|
* Validates that the asset is supported and amount meets minimums for the target agent(s).
|
|
@@ -573,6 +612,17 @@ declare class OwneySDK {
|
|
|
573
612
|
private hasExistingBalance;
|
|
574
613
|
private validateAssetSupport;
|
|
575
614
|
private getEligibleAgents;
|
|
615
|
+
/**
|
|
616
|
+
* Agent ids the routing API provisioned for this org that support the given
|
|
617
|
+
* chain + asset, ordered by preference ({@link AGENT_ELIGIBILITY_ORDER},
|
|
618
|
+
* surfliquid first). Returns `[]` when the org has no compatible agent — never
|
|
619
|
+
* throws on an empty org. Loads agent keys on first call (apiKey only, no
|
|
620
|
+
* wallet), so the UI can resolve which agent to use before the user connects.
|
|
621
|
+
*
|
|
622
|
+
* This is the source of truth for agent availability: an agent appears here
|
|
623
|
+
* iff the routing API returned its key. No per-app feature flags.
|
|
624
|
+
*/
|
|
625
|
+
getEligibleAgentIds(chainId: number, asset: string): Promise<AgentId[]>;
|
|
576
626
|
/**
|
|
577
627
|
* Withdraw funds from a specific agent, or all agents that support the active chain+asset if agentId is omitted.
|
|
578
628
|
* Validates that the asset is supported by the target agent(s) on the active chain.
|
|
@@ -673,7 +723,7 @@ declare class OwneySDK {
|
|
|
673
723
|
getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
|
|
674
724
|
}
|
|
675
725
|
|
|
676
|
-
type OwneyErrorCode = "NOT_CONNECTED" | "NO_ACTIVE_CHAIN" | "WALLET_NO_ACCOUNTS" | "WALLET_ADDRESS_REQUIRED" | "WALLET_NOT_DEPLOYED" | "AGENT_NOT_FOUND" | "AGENT_CHAIN_INCOMPATIBLE" | "AGENT_EMPTY_LIST" | "AGENT_DISABLED" | "CHAIN_UNSUPPORTED" | "CHAIN_NO_COMPATIBLE_AGENTS" | "CHAIN_MISMATCH" | "ASSET_UNSUPPORTED" | "ASSET_NO_COMPATIBLE_AGENTS" | "DEPOSIT_AMOUNT_BELOW_MINIMUM" | "DEPOSIT_CALLBACK_REQUIRED" | "DEPOSIT_CALLBACK_INVALID" | "DEPOSIT_NO_PERMITTED_TOKENS" | "DEPOSIT_INSUFFICIENT_BALANCE" | "WITHDRAW_NO_PERMITTED_TOKENS" | "WITHDRAW_INSUFFICIENT_BALANCE" | "WITHDRAW_ALL_FAILED" | "WITHDRAW_PARTIAL_FAILURE" | "WITHDRAW_FAILED" | "API_ROUTING_ERROR" | "API_ROUTING_FAILED" | "API_SAIL_ERROR" | "API_SAIL_TIMEOUT" | "API_NO_AGENTS" | "SPONSOR_REQUEST_FAILED" | "PERMIT2_APPROVAL_REQUIRED" | "SPONSORED_CALLS_UNSUPPORTED" | "SPONSORED_CALLS_NO_ID" | "SPONSORED_CALLS_NO_RECEIPT" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
|
|
726
|
+
type OwneyErrorCode = "NOT_CONNECTED" | "NO_ACTIVE_CHAIN" | "WALLET_NO_ACCOUNTS" | "WALLET_ADDRESS_REQUIRED" | "WALLET_NOT_DEPLOYED" | "AGENT_NOT_FOUND" | "AGENT_CHAIN_INCOMPATIBLE" | "AGENT_EMPTY_LIST" | "AGENT_DISABLED" | "CHAIN_UNSUPPORTED" | "CHAIN_NO_COMPATIBLE_AGENTS" | "CHAIN_MISMATCH" | "ASSET_UNSUPPORTED" | "ASSET_NO_COMPATIBLE_AGENTS" | "DEPOSIT_AMOUNT_BELOW_MINIMUM" | "DEPOSIT_CALLBACK_REQUIRED" | "DEPOSIT_CALLBACK_INVALID" | "DEPOSIT_NO_PERMITTED_TOKENS" | "DEPOSIT_ALL_FAILED" | "DEPOSIT_INSUFFICIENT_BALANCE" | "WITHDRAW_NO_PERMITTED_TOKENS" | "WITHDRAW_INSUFFICIENT_BALANCE" | "WITHDRAW_ALL_FAILED" | "WITHDRAW_PARTIAL_FAILURE" | "WITHDRAW_FAILED" | "API_ROUTING_ERROR" | "API_ROUTING_FAILED" | "API_SAIL_ERROR" | "API_SAIL_TIMEOUT" | "API_NO_AGENTS" | "SPONSOR_REQUEST_FAILED" | "PERMIT2_APPROVAL_REQUIRED" | "SPONSORED_CALLS_UNSUPPORTED" | "SPONSORED_CALLS_NO_ID" | "SPONSORED_CALLS_NO_RECEIPT" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
|
|
677
727
|
declare class OwneyError extends Error {
|
|
678
728
|
readonly code: OwneyErrorCode;
|
|
679
729
|
readonly details?: Record<string, unknown>;
|
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,16 @@ interface OwneySDKConfig {
|
|
|
21
21
|
* `createOwneySIWX` for apps that don't use the AppKit SIWX modal.
|
|
22
22
|
*/
|
|
23
23
|
referralSource?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Optional override for the SurfLiquid API base URL (defaults to the
|
|
26
|
+
* SurfLiquid SDK's production URL). SurfLiquid auth is an httpOnly
|
|
27
|
+
* SameSite=None cookie set by api.surfliquid.com — a THIRD-PARTY cookie from
|
|
28
|
+
* the embedding app's origin, which WebKit (all iOS browsers) discards, so
|
|
29
|
+
* every authenticated SurfLiquid call 401s on iOS. Point this at a
|
|
30
|
+
* same-origin reverse proxy (e.g. "/api/surf") so the session cookie becomes
|
|
31
|
+
* first-party. Relative paths resolve against the page origin.
|
|
32
|
+
*/
|
|
33
|
+
surfliquidApiBaseUrl?: string;
|
|
24
34
|
/**
|
|
25
35
|
* Turn on the SDK's debug logging (default false). Traces the decisions that
|
|
26
36
|
* are otherwise invisible — notably how the organization's agent policy is
|
|
@@ -54,7 +64,7 @@ type OwneySupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];
|
|
|
54
64
|
type OwneySupportedChains = (typeof SUPPORTED_CHAINS)[number];
|
|
55
65
|
type OwneySupportedTokens = (typeof SUPPORTED_TOKENS)[number];
|
|
56
66
|
|
|
57
|
-
type AgentId = "zyfai" | "sail";
|
|
67
|
+
type AgentId = "zyfai" | "sail" | "surfliquid";
|
|
58
68
|
type Asset = string;
|
|
59
69
|
type AgentSupportedAsset = {
|
|
60
70
|
readonly symbol: string;
|
|
@@ -170,6 +180,12 @@ interface OwneyDepositResult {
|
|
|
170
180
|
}
|
|
171
181
|
interface OwneyMultiDepositResult {
|
|
172
182
|
agentResults: Record<string, OwneyDepositResult>;
|
|
183
|
+
/**
|
|
184
|
+
* Per-agent failure messages for agents that errored during a diversified
|
|
185
|
+
* deposit. Present only when at least one (but not all) agents failed —
|
|
186
|
+
* the deposit is partial, not total. Omitted when every agent succeeded.
|
|
187
|
+
*/
|
|
188
|
+
agentErrors?: Record<string, string>;
|
|
173
189
|
}
|
|
174
190
|
interface AgentWithdrawResult {
|
|
175
191
|
txHash?: string;
|
|
@@ -441,6 +457,7 @@ declare class OwneySDK {
|
|
|
441
457
|
private zyfaiRpcUrls?;
|
|
442
458
|
private routingApiBaseUrl?;
|
|
443
459
|
private referralSource?;
|
|
460
|
+
private surfliquidApiBaseUrl?;
|
|
444
461
|
private cachedSponsoredCallback;
|
|
445
462
|
private cachedWethSponsoredCallback;
|
|
446
463
|
private paymasterServiceUrl?;
|
|
@@ -522,6 +539,28 @@ declare class OwneySDK {
|
|
|
522
539
|
* throws before activating any agent.
|
|
523
540
|
*/
|
|
524
541
|
activateAgent(chainId: number, agentId?: AgentId[]): Promise<void>;
|
|
542
|
+
/**
|
|
543
|
+
* Activate agents ONE AT A TIME, each followed by its org policy.
|
|
544
|
+
*
|
|
545
|
+
* Every agent opens its activation with its own wallet signature — Zyfai's
|
|
546
|
+
* SIWX (exchanged for a JWT) and SurfLiquid's SIWE (exchanged for an httpOnly
|
|
547
|
+
* cookie). Run in parallel, that puts two `personal_sign` requests on one
|
|
548
|
+
* wallet connection in the same instant. Over WalletConnect both are
|
|
549
|
+
* delivered to the wallet, which renders one signing request at a time and
|
|
550
|
+
* queues or silently drops the other: neither promise settles, so activation
|
|
551
|
+
* hangs until the caller's timeout with no prompt the user can act on. The
|
|
552
|
+
* single-agent era never hit this — there was no second prompt to collide
|
|
553
|
+
* with — so it appeared the moment a second agent became eligible.
|
|
554
|
+
*
|
|
555
|
+
* Serializing costs no real wall-clock: the user can only approve one prompt
|
|
556
|
+
* at a time anyway.
|
|
557
|
+
*
|
|
558
|
+
* Every agent is attempted even if an earlier one fails, so one declined
|
|
559
|
+
* signature can't deny the remaining agents their turn. The first failure is
|
|
560
|
+
* rethrown (matching the previous `Promise.all` rejection) once all agents
|
|
561
|
+
* have had a chance to activate.
|
|
562
|
+
*/
|
|
563
|
+
private activateAgentsInTurn;
|
|
525
564
|
/**
|
|
526
565
|
* Deposit funds into a specific agent, or split equally across all agents if agentId is omitted.
|
|
527
566
|
* Validates that the asset is supported and amount meets minimums for the target agent(s).
|
|
@@ -573,6 +612,17 @@ declare class OwneySDK {
|
|
|
573
612
|
private hasExistingBalance;
|
|
574
613
|
private validateAssetSupport;
|
|
575
614
|
private getEligibleAgents;
|
|
615
|
+
/**
|
|
616
|
+
* Agent ids the routing API provisioned for this org that support the given
|
|
617
|
+
* chain + asset, ordered by preference ({@link AGENT_ELIGIBILITY_ORDER},
|
|
618
|
+
* surfliquid first). Returns `[]` when the org has no compatible agent — never
|
|
619
|
+
* throws on an empty org. Loads agent keys on first call (apiKey only, no
|
|
620
|
+
* wallet), so the UI can resolve which agent to use before the user connects.
|
|
621
|
+
*
|
|
622
|
+
* This is the source of truth for agent availability: an agent appears here
|
|
623
|
+
* iff the routing API returned its key. No per-app feature flags.
|
|
624
|
+
*/
|
|
625
|
+
getEligibleAgentIds(chainId: number, asset: string): Promise<AgentId[]>;
|
|
576
626
|
/**
|
|
577
627
|
* Withdraw funds from a specific agent, or all agents that support the active chain+asset if agentId is omitted.
|
|
578
628
|
* Validates that the asset is supported by the target agent(s) on the active chain.
|
|
@@ -673,7 +723,7 @@ declare class OwneySDK {
|
|
|
673
723
|
getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
|
|
674
724
|
}
|
|
675
725
|
|
|
676
|
-
type OwneyErrorCode = "NOT_CONNECTED" | "NO_ACTIVE_CHAIN" | "WALLET_NO_ACCOUNTS" | "WALLET_ADDRESS_REQUIRED" | "WALLET_NOT_DEPLOYED" | "AGENT_NOT_FOUND" | "AGENT_CHAIN_INCOMPATIBLE" | "AGENT_EMPTY_LIST" | "AGENT_DISABLED" | "CHAIN_UNSUPPORTED" | "CHAIN_NO_COMPATIBLE_AGENTS" | "CHAIN_MISMATCH" | "ASSET_UNSUPPORTED" | "ASSET_NO_COMPATIBLE_AGENTS" | "DEPOSIT_AMOUNT_BELOW_MINIMUM" | "DEPOSIT_CALLBACK_REQUIRED" | "DEPOSIT_CALLBACK_INVALID" | "DEPOSIT_NO_PERMITTED_TOKENS" | "DEPOSIT_INSUFFICIENT_BALANCE" | "WITHDRAW_NO_PERMITTED_TOKENS" | "WITHDRAW_INSUFFICIENT_BALANCE" | "WITHDRAW_ALL_FAILED" | "WITHDRAW_PARTIAL_FAILURE" | "WITHDRAW_FAILED" | "API_ROUTING_ERROR" | "API_ROUTING_FAILED" | "API_SAIL_ERROR" | "API_SAIL_TIMEOUT" | "API_NO_AGENTS" | "SPONSOR_REQUEST_FAILED" | "PERMIT2_APPROVAL_REQUIRED" | "SPONSORED_CALLS_UNSUPPORTED" | "SPONSORED_CALLS_NO_ID" | "SPONSORED_CALLS_NO_RECEIPT" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
|
|
726
|
+
type OwneyErrorCode = "NOT_CONNECTED" | "NO_ACTIVE_CHAIN" | "WALLET_NO_ACCOUNTS" | "WALLET_ADDRESS_REQUIRED" | "WALLET_NOT_DEPLOYED" | "AGENT_NOT_FOUND" | "AGENT_CHAIN_INCOMPATIBLE" | "AGENT_EMPTY_LIST" | "AGENT_DISABLED" | "CHAIN_UNSUPPORTED" | "CHAIN_NO_COMPATIBLE_AGENTS" | "CHAIN_MISMATCH" | "ASSET_UNSUPPORTED" | "ASSET_NO_COMPATIBLE_AGENTS" | "DEPOSIT_AMOUNT_BELOW_MINIMUM" | "DEPOSIT_CALLBACK_REQUIRED" | "DEPOSIT_CALLBACK_INVALID" | "DEPOSIT_NO_PERMITTED_TOKENS" | "DEPOSIT_ALL_FAILED" | "DEPOSIT_INSUFFICIENT_BALANCE" | "WITHDRAW_NO_PERMITTED_TOKENS" | "WITHDRAW_INSUFFICIENT_BALANCE" | "WITHDRAW_ALL_FAILED" | "WITHDRAW_PARTIAL_FAILURE" | "WITHDRAW_FAILED" | "API_ROUTING_ERROR" | "API_ROUTING_FAILED" | "API_SAIL_ERROR" | "API_SAIL_TIMEOUT" | "API_NO_AGENTS" | "SPONSOR_REQUEST_FAILED" | "PERMIT2_APPROVAL_REQUIRED" | "SPONSORED_CALLS_UNSUPPORTED" | "SPONSORED_CALLS_NO_ID" | "SPONSORED_CALLS_NO_RECEIPT" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
|
|
677
727
|
declare class OwneyError extends Error {
|
|
678
728
|
readonly code: OwneyErrorCode;
|
|
679
729
|
readonly details?: Record<string, unknown>;
|