@owney/sdk 0.7.32-beta.10 → 0.7.32-beta.11
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/index.cjs +87 -1
- package/dist/index.d.cts +48 -1
- package/dist/index.d.ts +48 -1
- package/dist/index.js +87 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1683,7 +1683,7 @@ var SnapshotHistory = class {
|
|
|
1683
1683
|
};
|
|
1684
1684
|
|
|
1685
1685
|
// src/lib/funding-ledger.ts
|
|
1686
|
-
var SDK_VERSION = "0.7.32-beta.
|
|
1686
|
+
var SDK_VERSION = "0.7.32-beta.11";
|
|
1687
1687
|
var SCOPE2 = "funding-ledger";
|
|
1688
1688
|
var REQUEST_TIMEOUT_MS2 = 5e3;
|
|
1689
1689
|
var RETRY_DELAYS_MS = [1e3, 4e3, 16e3];
|
|
@@ -5206,6 +5206,16 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
5206
5206
|
}
|
|
5207
5207
|
return this.connectedAddress;
|
|
5208
5208
|
}
|
|
5209
|
+
/**
|
|
5210
|
+
* Whether connecting now would ask the wallet to sign in: not connected for
|
|
5211
|
+
* this wallet and chain (the check `connectAuth` returns early on) and no
|
|
5212
|
+
* fresh saved session. Never prompts; reads only what is saved.
|
|
5213
|
+
*/
|
|
5214
|
+
needsSignIn(state, chainId) {
|
|
5215
|
+
const owner = state.walletAddress.toLowerCase();
|
|
5216
|
+
if (this.connectedAddress?.toLowerCase() === owner && this.connectedChainId === chainId) return false;
|
|
5217
|
+
return readSession(state.walletAddress, chainId) === null;
|
|
5218
|
+
}
|
|
5209
5219
|
/** Light connect: SIWE auth only. Re-auths if chain changed. */
|
|
5210
5220
|
async connectAuth(state, chainId) {
|
|
5211
5221
|
const validChainId = isValidChainId(chainId);
|
|
@@ -10310,6 +10320,13 @@ var YieldseekerAgent = class {
|
|
|
10310
10320
|
this.planHistoryKeys.clear();
|
|
10311
10321
|
this.lastLedgerRows.clear();
|
|
10312
10322
|
}
|
|
10323
|
+
/**
|
|
10324
|
+
* Whether connecting now would ask the wallet to sign in: no reusable saved
|
|
10325
|
+
* sign-in for this wallet and chain. Never prompts; reads only what is saved.
|
|
10326
|
+
*/
|
|
10327
|
+
needsSignIn(state, chainId) {
|
|
10328
|
+
return !this.auth.peekToken(state, chainId);
|
|
10329
|
+
}
|
|
10313
10330
|
/**
|
|
10314
10331
|
* The connect's account check (2026-11-13), run before any agent activates:
|
|
10315
10332
|
* sign in (a saved sign-in, else login-with-wallet, else POST /users for a
|
|
@@ -17398,6 +17415,7 @@ var OwneySDK = class {
|
|
|
17398
17415
|
*/
|
|
17399
17416
|
disabledAgents = /* @__PURE__ */ new Set();
|
|
17400
17417
|
accountRefusedListeners = /* @__PURE__ */ new Set();
|
|
17418
|
+
signInProgressListeners = /* @__PURE__ */ new Set();
|
|
17401
17419
|
/**
|
|
17402
17420
|
* Agents whose sign-in the user cancelled this session (the wallet rejected
|
|
17403
17421
|
* the prompt), keyed by chain. Until the app ends the session they are read
|
|
@@ -17631,6 +17649,62 @@ var OwneySDK = class {
|
|
|
17631
17649
|
this.accountRefusedListeners.delete(listener);
|
|
17632
17650
|
};
|
|
17633
17651
|
}
|
|
17652
|
+
/**
|
|
17653
|
+
* Listens for the sign-ins a connect asks for (`SignInProgress`): which
|
|
17654
|
+
* agents will ask the wallet to sign in, and each one as it starts and ends,
|
|
17655
|
+
* then `"finished"` after the last one (or when the connect ends first).
|
|
17656
|
+
* Nothing is sent when no agent needs a sign-in. Returns the unsubscribe
|
|
17657
|
+
* function.
|
|
17658
|
+
*/
|
|
17659
|
+
onSignInProgress(listener) {
|
|
17660
|
+
this.signInProgressListeners.add(listener);
|
|
17661
|
+
return () => {
|
|
17662
|
+
this.signInProgressListeners.delete(listener);
|
|
17663
|
+
};
|
|
17664
|
+
}
|
|
17665
|
+
/**
|
|
17666
|
+
* The sign-ins this connect asks for: the agents whose `needsSignIn` says
|
|
17667
|
+
* yes now (one that throws counts as no). Each is announced at its first
|
|
17668
|
+
* step (its account check, or its activation when it has none) and counted
|
|
17669
|
+
* once.
|
|
17670
|
+
*/
|
|
17671
|
+
planSignIns(agents, state, chainId) {
|
|
17672
|
+
const planned = /* @__PURE__ */ new Set();
|
|
17673
|
+
for (const agent of agents) {
|
|
17674
|
+
try {
|
|
17675
|
+
if (agent.needsSignIn?.(state, chainId) === true) planned.add(agent.id);
|
|
17676
|
+
} catch {
|
|
17677
|
+
}
|
|
17678
|
+
}
|
|
17679
|
+
const total = planned.size;
|
|
17680
|
+
let done = 0;
|
|
17681
|
+
let finished = false;
|
|
17682
|
+
const send = (progress) => {
|
|
17683
|
+
if (total === 0 || finished) return;
|
|
17684
|
+
for (const listener of [...this.signInProgressListeners]) {
|
|
17685
|
+
try {
|
|
17686
|
+
listener(progress);
|
|
17687
|
+
} catch {
|
|
17688
|
+
}
|
|
17689
|
+
}
|
|
17690
|
+
};
|
|
17691
|
+
const finish = () => {
|
|
17692
|
+
send({ state: "finished", total, done });
|
|
17693
|
+
finished = true;
|
|
17694
|
+
};
|
|
17695
|
+
return {
|
|
17696
|
+
before: (agent) => {
|
|
17697
|
+
if (planned.has(agent.id)) send({ state: "waiting", total, done, agentId: agent.id });
|
|
17698
|
+
},
|
|
17699
|
+
after: (agent) => {
|
|
17700
|
+
if (!planned.delete(agent.id)) return;
|
|
17701
|
+
done += 1;
|
|
17702
|
+
send({ state: "signed", total, done, agentId: agent.id });
|
|
17703
|
+
if (done === total) finish();
|
|
17704
|
+
},
|
|
17705
|
+
finish
|
|
17706
|
+
};
|
|
17707
|
+
}
|
|
17634
17708
|
/** Wires the optional hooks the SDK offers an agent. */
|
|
17635
17709
|
attachAgentHooks(agent) {
|
|
17636
17710
|
try {
|
|
@@ -18295,6 +18369,14 @@ var OwneySDK = class {
|
|
|
18295
18369
|
* activation, with nothing activated.
|
|
18296
18370
|
*/
|
|
18297
18371
|
async activateAgentsInTurn(agents, state, chainId, asset, onAgentsSelected) {
|
|
18372
|
+
const signIns = this.planSignIns(agents, state, chainId);
|
|
18373
|
+
try {
|
|
18374
|
+
await this.activatePlannedAgents(agents, state, chainId, signIns, asset, onAgentsSelected);
|
|
18375
|
+
} finally {
|
|
18376
|
+
signIns.finish();
|
|
18377
|
+
}
|
|
18378
|
+
}
|
|
18379
|
+
async activatePlannedAgents(agents, state, chainId, signIns, asset, onAgentsSelected) {
|
|
18298
18380
|
let firstError = null;
|
|
18299
18381
|
let walletRejected = false;
|
|
18300
18382
|
const activatedAgentIds = [];
|
|
@@ -18320,8 +18402,10 @@ var OwneySDK = class {
|
|
|
18320
18402
|
if (!agent.checkAccount) continue;
|
|
18321
18403
|
this.assertActivationSession(state);
|
|
18322
18404
|
try {
|
|
18405
|
+
signIns.before(agent);
|
|
18323
18406
|
await agent.checkAccount(state, chainId);
|
|
18324
18407
|
this.assertActivationSession(state);
|
|
18408
|
+
signIns.after(agent);
|
|
18325
18409
|
} catch (error) {
|
|
18326
18410
|
recordFailure(agent, error);
|
|
18327
18411
|
break;
|
|
@@ -18332,8 +18416,10 @@ var OwneySDK = class {
|
|
|
18332
18416
|
for (const agent of agents) {
|
|
18333
18417
|
this.assertActivationSession(state);
|
|
18334
18418
|
try {
|
|
18419
|
+
signIns.before(agent);
|
|
18335
18420
|
await agent.activateAgent(state, chainId, asset);
|
|
18336
18421
|
this.assertActivationSession(state);
|
|
18422
|
+
signIns.after(agent);
|
|
18337
18423
|
await this.applyOrgPolicyTo(agent, state, chainId);
|
|
18338
18424
|
this.assertActivationSession(state);
|
|
18339
18425
|
activatedAgentIds.push(agent.id);
|
package/dist/index.d.cts
CHANGED
|
@@ -846,6 +846,14 @@ interface IAgent {
|
|
|
846
846
|
* checked.
|
|
847
847
|
*/
|
|
848
848
|
checkAccount?(state: ConnectionState, chainId: number): Promise<void>;
|
|
849
|
+
/**
|
|
850
|
+
* Would this agent ask the wallet to sign in for this wallet and chain right
|
|
851
|
+
* now? Read from what it has saved; it never prompts and never calls the
|
|
852
|
+
* network. Connect counts the sign-ins it will ask for from this
|
|
853
|
+
* (`OwneySDK.onSignInProgress`). Optional; without it the agent is counted
|
|
854
|
+
* as not needing one.
|
|
855
|
+
*/
|
|
856
|
+
needsSignIn?(state: ConnectionState, chainId: number): boolean;
|
|
849
857
|
/**
|
|
850
858
|
* A small, never-prompting read of the provider's earnings bookkeeping for a
|
|
851
859
|
* `provider.sample` ledger event (Zyfai). Null when unavailable; never throws.
|
|
@@ -928,6 +936,23 @@ type ActivateAgentOptions = {
|
|
|
928
936
|
*/
|
|
929
937
|
onAgentsSelected?: () => void;
|
|
930
938
|
};
|
|
939
|
+
/**
|
|
940
|
+
* One step of the sign-ins a connect asks for (`OwneySDK.onSignInProgress`).
|
|
941
|
+
* The plan is the agents whose `needsSignIn` said yes when the connect began:
|
|
942
|
+
* `total`. `"waiting"` comes right before the step that signs an agent in,
|
|
943
|
+
* `"signed"` when it returns, and `"finished"` once: right after the last
|
|
944
|
+
* planned sign-in, or when the connect ends before that (cancelled, failed, or
|
|
945
|
+
* the wallet changed).
|
|
946
|
+
*/
|
|
947
|
+
type SignInProgress = {
|
|
948
|
+
state: "waiting" | "signed" | "finished";
|
|
949
|
+
/** Sign-ins this connect asks for. */
|
|
950
|
+
total: number;
|
|
951
|
+
/** Sign-ins finished so far. */
|
|
952
|
+
done: number;
|
|
953
|
+
/** The agent this step is for; absent on `"finished"`. */
|
|
954
|
+
agentId?: AgentId;
|
|
955
|
+
};
|
|
931
956
|
type AvailableAgentsOptions = {
|
|
932
957
|
chainId?: number;
|
|
933
958
|
asset?: Asset;
|
|
@@ -1977,6 +2002,7 @@ declare class OwneySDK {
|
|
|
1977
2002
|
*/
|
|
1978
2003
|
private disabledAgents;
|
|
1979
2004
|
private readonly accountRefusedListeners;
|
|
2005
|
+
private readonly signInProgressListeners;
|
|
1980
2006
|
/**
|
|
1981
2007
|
* Agents whose sign-in the user cancelled this session (the wallet rejected
|
|
1982
2008
|
* the prompt), keyed by chain. Until the app ends the session they are read
|
|
@@ -2076,6 +2102,21 @@ declare class OwneySDK {
|
|
|
2076
2102
|
* each time an agent maps such a refusal. Returns the unsubscribe function.
|
|
2077
2103
|
*/
|
|
2078
2104
|
onAccountRefused(listener: (agentId: AgentId) => void): () => void;
|
|
2105
|
+
/**
|
|
2106
|
+
* Listens for the sign-ins a connect asks for (`SignInProgress`): which
|
|
2107
|
+
* agents will ask the wallet to sign in, and each one as it starts and ends,
|
|
2108
|
+
* then `"finished"` after the last one (or when the connect ends first).
|
|
2109
|
+
* Nothing is sent when no agent needs a sign-in. Returns the unsubscribe
|
|
2110
|
+
* function.
|
|
2111
|
+
*/
|
|
2112
|
+
onSignInProgress(listener: (progress: SignInProgress) => void): () => void;
|
|
2113
|
+
/**
|
|
2114
|
+
* The sign-ins this connect asks for: the agents whose `needsSignIn` says
|
|
2115
|
+
* yes now (one that throws counts as no). Each is announced at its first
|
|
2116
|
+
* step (its account check, or its activation when it has none) and counted
|
|
2117
|
+
* once.
|
|
2118
|
+
*/
|
|
2119
|
+
private planSignIns;
|
|
2079
2120
|
/** Wires the optional hooks the SDK offers an agent. */
|
|
2080
2121
|
private attachAgentHooks;
|
|
2081
2122
|
/**
|
|
@@ -2255,6 +2296,7 @@ declare class OwneySDK {
|
|
|
2255
2296
|
* activation, with nothing activated.
|
|
2256
2297
|
*/
|
|
2257
2298
|
private activateAgentsInTurn;
|
|
2299
|
+
private activatePlannedAgents;
|
|
2258
2300
|
/**
|
|
2259
2301
|
* Deposit into a specific agent, or distribute across all eligible agents.
|
|
2260
2302
|
* Validates that the asset is supported and amount meets minimums for the target agent(s).
|
|
@@ -3332,6 +3374,11 @@ declare class YieldseekerAgent implements IAgent {
|
|
|
3332
3374
|
status: YieldseekerWalletStatus;
|
|
3333
3375
|
}>;
|
|
3334
3376
|
disconnect(): Promise<void>;
|
|
3377
|
+
/**
|
|
3378
|
+
* Whether connecting now would ask the wallet to sign in: no reusable saved
|
|
3379
|
+
* sign-in for this wallet and chain. Never prompts; reads only what is saved.
|
|
3380
|
+
*/
|
|
3381
|
+
needsSignIn(state: ConnectionState, chainId: number): boolean;
|
|
3335
3382
|
/**
|
|
3336
3383
|
* The connect's account check (2026-11-13), run before any agent activates:
|
|
3337
3384
|
* sign in (a saved sign-in, else login-with-wallet, else POST /users for a
|
|
@@ -3995,4 +4042,4 @@ declare const YIELDSEEKER_WITHDRAW_SERVER_SUBMIT: 1;
|
|
|
3995
4042
|
* Older builds do not export this. */
|
|
3996
4043
|
declare const FUNDING_DEPOSIT_RECOVERY_REPORT: 1;
|
|
3997
4044
|
|
|
3998
|
-
export { type AccountAgentApy, type AccountApyOptions, type AccountDailyEarnings, type ActivateAgentOptions, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, type AgentFundingLedgerAccess, type AgentHistoryEntry, type AgentHistoryPosition, type AgentId, AgentNotFoundError, type AgentSupportedAsset, type AgentSupportedAssets, type AgentUserProfile, type AgentWithdrawResult, type AgentsApyOptions, type AllocationAgentApy, type AllocationApyOptions, type ApyByChainAndAsset, type ApyCoverage, type ApyHistoryPoint, type ApyIncentive, type Asset, type AssetDailyEarnings, type AssetReadMetadata, type AvailableAgent, type AvailableAgentsOptions, type AvailablePool, type ConnectionState, type DailyApyDays, type DailyEarningsOptions, type DailyEarningsPoint, type DepositAuthorizationReference, type DepositCallback, type DepositOptions, type DepositReplacementValidation, FUNDING_DEPOSIT_RECOVERY_REPORT, FUSION_SECRET_SERVER_PUBLISH, type FundingEvidence, type FundingOperationKind, type FundingOperationLeg, type FundingOperationRow, type FundingProgress, type FundingStage, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, type LedgerLegReport, type LookbackDays, NotConnectedError, type OrgPoolPolicy, type OrgPoolSelection, type OwneyAccountApy, type OwneyAgentApy, type OwneyAgentHistory, type OwneyAllocationApy, type OwneyBalances, type OwneyDepositResult, type OwneyEarnings, OwneyError, type OwneyErrorCode, type OwneyMultiDepositResult, type OwneyPosition, OwneySDK, type OwneySDKConfig, type OwneySIWXConfig, type OwneySupportedChainId, type OwneySupportedChains, type OwneySupportedTokens, type OwneyToken, type OwneyUserProfile, type OwneyWithdrawAllLeg, type OwneyWithdrawAllResult, type OwneyWithdrawResult, type PendingDeposit, type PoolCatalogProtocol, type PoolSelectionStrategy, type ProviderSnapshotSample, type RebalanceLog, type ReservationAgent, type ReservationReleaseReason, type RpcUrlsConfig, SDK_VERSION, SPONSORED_DEPOSIT_SERVER_BROADCAST, type SavedPoolSelection, type SwapChainTokens, type SwapDirection, type SwapOrderStatus, type SwapQuote, type SwapQuoteParams, type SwapRail, type SwapStage, type SwapTokenInfo, type SwapTokenSearchResult, type UnsignedUserOperationEvidence, type UserPoolSelection, type UserPoolSelectionRequest, type WithdrawOptions, type WithdrawSwapRecord, type WithdrawSwapStatus, type WithdrawalCompletion, type WithdrawalCompletionContext, type WithdrawalPayoutCandidate, type WithdrawalPayoutScan, type WithdrawalReservationConflict, type WithdrawalReservationMode, type WithdrawalReservationOptions, type WithdrawalSwapRecovery, YIELDSEEKER_WITHDRAW_SERVER_SUBMIT, YieldseekerAgent, type YieldseekerWalletStatus, ZYFAI_REGISTRATION_NOT_SENT_CODES, ZYFAI_SERVER_TASKS, ZYFAI_WITHDRAWAL_NOT_SENT_CODES, ZYFAI_WITHDRAW_DISPATCH_CHECKPOINT, type ZyfaiDepositPlacement, type ZyfaiRpcUrlsConfig, type ZyfaiWithdrawalLifecycle, clearWithdrawSwap, createOwneySIWX, listPendingDeposits, listOrders as listPendingSwaps, listWithdrawSwaps, saveWithdrawSwap, setOwneyDebug, subscribeWithdrawSwaps, switchWalletConnectChain, updateWithdrawSwap };
|
|
4045
|
+
export { type AccountAgentApy, type AccountApyOptions, type AccountDailyEarnings, type ActivateAgentOptions, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, type AgentFundingLedgerAccess, type AgentHistoryEntry, type AgentHistoryPosition, type AgentId, AgentNotFoundError, type AgentSupportedAsset, type AgentSupportedAssets, type AgentUserProfile, type AgentWithdrawResult, type AgentsApyOptions, type AllocationAgentApy, type AllocationApyOptions, type ApyByChainAndAsset, type ApyCoverage, type ApyHistoryPoint, type ApyIncentive, type Asset, type AssetDailyEarnings, type AssetReadMetadata, type AvailableAgent, type AvailableAgentsOptions, type AvailablePool, type ConnectionState, type DailyApyDays, type DailyEarningsOptions, type DailyEarningsPoint, type DepositAuthorizationReference, type DepositCallback, type DepositOptions, type DepositReplacementValidation, FUNDING_DEPOSIT_RECOVERY_REPORT, FUSION_SECRET_SERVER_PUBLISH, type FundingEvidence, type FundingOperationKind, type FundingOperationLeg, type FundingOperationRow, type FundingProgress, type FundingStage, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, type LedgerLegReport, type LookbackDays, NotConnectedError, type OrgPoolPolicy, type OrgPoolSelection, type OwneyAccountApy, type OwneyAgentApy, type OwneyAgentHistory, type OwneyAllocationApy, type OwneyBalances, type OwneyDepositResult, type OwneyEarnings, OwneyError, type OwneyErrorCode, type OwneyMultiDepositResult, type OwneyPosition, OwneySDK, type OwneySDKConfig, type OwneySIWXConfig, type OwneySupportedChainId, type OwneySupportedChains, type OwneySupportedTokens, type OwneyToken, type OwneyUserProfile, type OwneyWithdrawAllLeg, type OwneyWithdrawAllResult, type OwneyWithdrawResult, type PendingDeposit, type PoolCatalogProtocol, type PoolSelectionStrategy, type ProviderSnapshotSample, type RebalanceLog, type ReservationAgent, type ReservationReleaseReason, type RpcUrlsConfig, SDK_VERSION, SPONSORED_DEPOSIT_SERVER_BROADCAST, type SavedPoolSelection, type SignInProgress, type SwapChainTokens, type SwapDirection, type SwapOrderStatus, type SwapQuote, type SwapQuoteParams, type SwapRail, type SwapStage, type SwapTokenInfo, type SwapTokenSearchResult, type UnsignedUserOperationEvidence, type UserPoolSelection, type UserPoolSelectionRequest, type WithdrawOptions, type WithdrawSwapRecord, type WithdrawSwapStatus, type WithdrawalCompletion, type WithdrawalCompletionContext, type WithdrawalPayoutCandidate, type WithdrawalPayoutScan, type WithdrawalReservationConflict, type WithdrawalReservationMode, type WithdrawalReservationOptions, type WithdrawalSwapRecovery, YIELDSEEKER_WITHDRAW_SERVER_SUBMIT, YieldseekerAgent, type YieldseekerWalletStatus, ZYFAI_REGISTRATION_NOT_SENT_CODES, ZYFAI_SERVER_TASKS, ZYFAI_WITHDRAWAL_NOT_SENT_CODES, ZYFAI_WITHDRAW_DISPATCH_CHECKPOINT, type ZyfaiDepositPlacement, type ZyfaiRpcUrlsConfig, type ZyfaiWithdrawalLifecycle, clearWithdrawSwap, createOwneySIWX, listPendingDeposits, listOrders as listPendingSwaps, listWithdrawSwaps, saveWithdrawSwap, setOwneyDebug, subscribeWithdrawSwaps, switchWalletConnectChain, updateWithdrawSwap };
|
package/dist/index.d.ts
CHANGED
|
@@ -846,6 +846,14 @@ interface IAgent {
|
|
|
846
846
|
* checked.
|
|
847
847
|
*/
|
|
848
848
|
checkAccount?(state: ConnectionState, chainId: number): Promise<void>;
|
|
849
|
+
/**
|
|
850
|
+
* Would this agent ask the wallet to sign in for this wallet and chain right
|
|
851
|
+
* now? Read from what it has saved; it never prompts and never calls the
|
|
852
|
+
* network. Connect counts the sign-ins it will ask for from this
|
|
853
|
+
* (`OwneySDK.onSignInProgress`). Optional; without it the agent is counted
|
|
854
|
+
* as not needing one.
|
|
855
|
+
*/
|
|
856
|
+
needsSignIn?(state: ConnectionState, chainId: number): boolean;
|
|
849
857
|
/**
|
|
850
858
|
* A small, never-prompting read of the provider's earnings bookkeeping for a
|
|
851
859
|
* `provider.sample` ledger event (Zyfai). Null when unavailable; never throws.
|
|
@@ -928,6 +936,23 @@ type ActivateAgentOptions = {
|
|
|
928
936
|
*/
|
|
929
937
|
onAgentsSelected?: () => void;
|
|
930
938
|
};
|
|
939
|
+
/**
|
|
940
|
+
* One step of the sign-ins a connect asks for (`OwneySDK.onSignInProgress`).
|
|
941
|
+
* The plan is the agents whose `needsSignIn` said yes when the connect began:
|
|
942
|
+
* `total`. `"waiting"` comes right before the step that signs an agent in,
|
|
943
|
+
* `"signed"` when it returns, and `"finished"` once: right after the last
|
|
944
|
+
* planned sign-in, or when the connect ends before that (cancelled, failed, or
|
|
945
|
+
* the wallet changed).
|
|
946
|
+
*/
|
|
947
|
+
type SignInProgress = {
|
|
948
|
+
state: "waiting" | "signed" | "finished";
|
|
949
|
+
/** Sign-ins this connect asks for. */
|
|
950
|
+
total: number;
|
|
951
|
+
/** Sign-ins finished so far. */
|
|
952
|
+
done: number;
|
|
953
|
+
/** The agent this step is for; absent on `"finished"`. */
|
|
954
|
+
agentId?: AgentId;
|
|
955
|
+
};
|
|
931
956
|
type AvailableAgentsOptions = {
|
|
932
957
|
chainId?: number;
|
|
933
958
|
asset?: Asset;
|
|
@@ -1977,6 +2002,7 @@ declare class OwneySDK {
|
|
|
1977
2002
|
*/
|
|
1978
2003
|
private disabledAgents;
|
|
1979
2004
|
private readonly accountRefusedListeners;
|
|
2005
|
+
private readonly signInProgressListeners;
|
|
1980
2006
|
/**
|
|
1981
2007
|
* Agents whose sign-in the user cancelled this session (the wallet rejected
|
|
1982
2008
|
* the prompt), keyed by chain. Until the app ends the session they are read
|
|
@@ -2076,6 +2102,21 @@ declare class OwneySDK {
|
|
|
2076
2102
|
* each time an agent maps such a refusal. Returns the unsubscribe function.
|
|
2077
2103
|
*/
|
|
2078
2104
|
onAccountRefused(listener: (agentId: AgentId) => void): () => void;
|
|
2105
|
+
/**
|
|
2106
|
+
* Listens for the sign-ins a connect asks for (`SignInProgress`): which
|
|
2107
|
+
* agents will ask the wallet to sign in, and each one as it starts and ends,
|
|
2108
|
+
* then `"finished"` after the last one (or when the connect ends first).
|
|
2109
|
+
* Nothing is sent when no agent needs a sign-in. Returns the unsubscribe
|
|
2110
|
+
* function.
|
|
2111
|
+
*/
|
|
2112
|
+
onSignInProgress(listener: (progress: SignInProgress) => void): () => void;
|
|
2113
|
+
/**
|
|
2114
|
+
* The sign-ins this connect asks for: the agents whose `needsSignIn` says
|
|
2115
|
+
* yes now (one that throws counts as no). Each is announced at its first
|
|
2116
|
+
* step (its account check, or its activation when it has none) and counted
|
|
2117
|
+
* once.
|
|
2118
|
+
*/
|
|
2119
|
+
private planSignIns;
|
|
2079
2120
|
/** Wires the optional hooks the SDK offers an agent. */
|
|
2080
2121
|
private attachAgentHooks;
|
|
2081
2122
|
/**
|
|
@@ -2255,6 +2296,7 @@ declare class OwneySDK {
|
|
|
2255
2296
|
* activation, with nothing activated.
|
|
2256
2297
|
*/
|
|
2257
2298
|
private activateAgentsInTurn;
|
|
2299
|
+
private activatePlannedAgents;
|
|
2258
2300
|
/**
|
|
2259
2301
|
* Deposit into a specific agent, or distribute across all eligible agents.
|
|
2260
2302
|
* Validates that the asset is supported and amount meets minimums for the target agent(s).
|
|
@@ -3332,6 +3374,11 @@ declare class YieldseekerAgent implements IAgent {
|
|
|
3332
3374
|
status: YieldseekerWalletStatus;
|
|
3333
3375
|
}>;
|
|
3334
3376
|
disconnect(): Promise<void>;
|
|
3377
|
+
/**
|
|
3378
|
+
* Whether connecting now would ask the wallet to sign in: no reusable saved
|
|
3379
|
+
* sign-in for this wallet and chain. Never prompts; reads only what is saved.
|
|
3380
|
+
*/
|
|
3381
|
+
needsSignIn(state: ConnectionState, chainId: number): boolean;
|
|
3335
3382
|
/**
|
|
3336
3383
|
* The connect's account check (2026-11-13), run before any agent activates:
|
|
3337
3384
|
* sign in (a saved sign-in, else login-with-wallet, else POST /users for a
|
|
@@ -3995,4 +4042,4 @@ declare const YIELDSEEKER_WITHDRAW_SERVER_SUBMIT: 1;
|
|
|
3995
4042
|
* Older builds do not export this. */
|
|
3996
4043
|
declare const FUNDING_DEPOSIT_RECOVERY_REPORT: 1;
|
|
3997
4044
|
|
|
3998
|
-
export { type AccountAgentApy, type AccountApyOptions, type AccountDailyEarnings, type ActivateAgentOptions, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, type AgentFundingLedgerAccess, type AgentHistoryEntry, type AgentHistoryPosition, type AgentId, AgentNotFoundError, type AgentSupportedAsset, type AgentSupportedAssets, type AgentUserProfile, type AgentWithdrawResult, type AgentsApyOptions, type AllocationAgentApy, type AllocationApyOptions, type ApyByChainAndAsset, type ApyCoverage, type ApyHistoryPoint, type ApyIncentive, type Asset, type AssetDailyEarnings, type AssetReadMetadata, type AvailableAgent, type AvailableAgentsOptions, type AvailablePool, type ConnectionState, type DailyApyDays, type DailyEarningsOptions, type DailyEarningsPoint, type DepositAuthorizationReference, type DepositCallback, type DepositOptions, type DepositReplacementValidation, FUNDING_DEPOSIT_RECOVERY_REPORT, FUSION_SECRET_SERVER_PUBLISH, type FundingEvidence, type FundingOperationKind, type FundingOperationLeg, type FundingOperationRow, type FundingProgress, type FundingStage, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, type LedgerLegReport, type LookbackDays, NotConnectedError, type OrgPoolPolicy, type OrgPoolSelection, type OwneyAccountApy, type OwneyAgentApy, type OwneyAgentHistory, type OwneyAllocationApy, type OwneyBalances, type OwneyDepositResult, type OwneyEarnings, OwneyError, type OwneyErrorCode, type OwneyMultiDepositResult, type OwneyPosition, OwneySDK, type OwneySDKConfig, type OwneySIWXConfig, type OwneySupportedChainId, type OwneySupportedChains, type OwneySupportedTokens, type OwneyToken, type OwneyUserProfile, type OwneyWithdrawAllLeg, type OwneyWithdrawAllResult, type OwneyWithdrawResult, type PendingDeposit, type PoolCatalogProtocol, type PoolSelectionStrategy, type ProviderSnapshotSample, type RebalanceLog, type ReservationAgent, type ReservationReleaseReason, type RpcUrlsConfig, SDK_VERSION, SPONSORED_DEPOSIT_SERVER_BROADCAST, type SavedPoolSelection, type SwapChainTokens, type SwapDirection, type SwapOrderStatus, type SwapQuote, type SwapQuoteParams, type SwapRail, type SwapStage, type SwapTokenInfo, type SwapTokenSearchResult, type UnsignedUserOperationEvidence, type UserPoolSelection, type UserPoolSelectionRequest, type WithdrawOptions, type WithdrawSwapRecord, type WithdrawSwapStatus, type WithdrawalCompletion, type WithdrawalCompletionContext, type WithdrawalPayoutCandidate, type WithdrawalPayoutScan, type WithdrawalReservationConflict, type WithdrawalReservationMode, type WithdrawalReservationOptions, type WithdrawalSwapRecovery, YIELDSEEKER_WITHDRAW_SERVER_SUBMIT, YieldseekerAgent, type YieldseekerWalletStatus, ZYFAI_REGISTRATION_NOT_SENT_CODES, ZYFAI_SERVER_TASKS, ZYFAI_WITHDRAWAL_NOT_SENT_CODES, ZYFAI_WITHDRAW_DISPATCH_CHECKPOINT, type ZyfaiDepositPlacement, type ZyfaiRpcUrlsConfig, type ZyfaiWithdrawalLifecycle, clearWithdrawSwap, createOwneySIWX, listPendingDeposits, listOrders as listPendingSwaps, listWithdrawSwaps, saveWithdrawSwap, setOwneyDebug, subscribeWithdrawSwaps, switchWalletConnectChain, updateWithdrawSwap };
|
|
4045
|
+
export { type AccountAgentApy, type AccountApyOptions, type AccountDailyEarnings, type ActivateAgentOptions, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, type AgentFundingLedgerAccess, type AgentHistoryEntry, type AgentHistoryPosition, type AgentId, AgentNotFoundError, type AgentSupportedAsset, type AgentSupportedAssets, type AgentUserProfile, type AgentWithdrawResult, type AgentsApyOptions, type AllocationAgentApy, type AllocationApyOptions, type ApyByChainAndAsset, type ApyCoverage, type ApyHistoryPoint, type ApyIncentive, type Asset, type AssetDailyEarnings, type AssetReadMetadata, type AvailableAgent, type AvailableAgentsOptions, type AvailablePool, type ConnectionState, type DailyApyDays, type DailyEarningsOptions, type DailyEarningsPoint, type DepositAuthorizationReference, type DepositCallback, type DepositOptions, type DepositReplacementValidation, FUNDING_DEPOSIT_RECOVERY_REPORT, FUSION_SECRET_SERVER_PUBLISH, type FundingEvidence, type FundingOperationKind, type FundingOperationLeg, type FundingOperationRow, type FundingProgress, type FundingStage, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, type LedgerLegReport, type LookbackDays, NotConnectedError, type OrgPoolPolicy, type OrgPoolSelection, type OwneyAccountApy, type OwneyAgentApy, type OwneyAgentHistory, type OwneyAllocationApy, type OwneyBalances, type OwneyDepositResult, type OwneyEarnings, OwneyError, type OwneyErrorCode, type OwneyMultiDepositResult, type OwneyPosition, OwneySDK, type OwneySDKConfig, type OwneySIWXConfig, type OwneySupportedChainId, type OwneySupportedChains, type OwneySupportedTokens, type OwneyToken, type OwneyUserProfile, type OwneyWithdrawAllLeg, type OwneyWithdrawAllResult, type OwneyWithdrawResult, type PendingDeposit, type PoolCatalogProtocol, type PoolSelectionStrategy, type ProviderSnapshotSample, type RebalanceLog, type ReservationAgent, type ReservationReleaseReason, type RpcUrlsConfig, SDK_VERSION, SPONSORED_DEPOSIT_SERVER_BROADCAST, type SavedPoolSelection, type SignInProgress, type SwapChainTokens, type SwapDirection, type SwapOrderStatus, type SwapQuote, type SwapQuoteParams, type SwapRail, type SwapStage, type SwapTokenInfo, type SwapTokenSearchResult, type UnsignedUserOperationEvidence, type UserPoolSelection, type UserPoolSelectionRequest, type WithdrawOptions, type WithdrawSwapRecord, type WithdrawSwapStatus, type WithdrawalCompletion, type WithdrawalCompletionContext, type WithdrawalPayoutCandidate, type WithdrawalPayoutScan, type WithdrawalReservationConflict, type WithdrawalReservationMode, type WithdrawalReservationOptions, type WithdrawalSwapRecovery, YIELDSEEKER_WITHDRAW_SERVER_SUBMIT, YieldseekerAgent, type YieldseekerWalletStatus, ZYFAI_REGISTRATION_NOT_SENT_CODES, ZYFAI_SERVER_TASKS, ZYFAI_WITHDRAWAL_NOT_SENT_CODES, ZYFAI_WITHDRAW_DISPATCH_CHECKPOINT, type ZyfaiDepositPlacement, type ZyfaiRpcUrlsConfig, type ZyfaiWithdrawalLifecycle, clearWithdrawSwap, createOwneySIWX, listPendingDeposits, listOrders as listPendingSwaps, listWithdrawSwaps, saveWithdrawSwap, setOwneyDebug, subscribeWithdrawSwaps, switchWalletConnectChain, updateWithdrawSwap };
|
package/dist/index.js
CHANGED
|
@@ -1011,7 +1011,7 @@ var SnapshotHistory = class {
|
|
|
1011
1011
|
};
|
|
1012
1012
|
|
|
1013
1013
|
// src/lib/funding-ledger.ts
|
|
1014
|
-
var SDK_VERSION = "0.7.32-beta.
|
|
1014
|
+
var SDK_VERSION = "0.7.32-beta.11";
|
|
1015
1015
|
var SCOPE2 = "funding-ledger";
|
|
1016
1016
|
var REQUEST_TIMEOUT_MS2 = 5e3;
|
|
1017
1017
|
var RETRY_DELAYS_MS = [1e3, 4e3, 16e3];
|
|
@@ -4523,6 +4523,16 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
4523
4523
|
}
|
|
4524
4524
|
return this.connectedAddress;
|
|
4525
4525
|
}
|
|
4526
|
+
/**
|
|
4527
|
+
* Whether connecting now would ask the wallet to sign in: not connected for
|
|
4528
|
+
* this wallet and chain (the check `connectAuth` returns early on) and no
|
|
4529
|
+
* fresh saved session. Never prompts; reads only what is saved.
|
|
4530
|
+
*/
|
|
4531
|
+
needsSignIn(state, chainId) {
|
|
4532
|
+
const owner = state.walletAddress.toLowerCase();
|
|
4533
|
+
if (this.connectedAddress?.toLowerCase() === owner && this.connectedChainId === chainId) return false;
|
|
4534
|
+
return readSession(state.walletAddress, chainId) === null;
|
|
4535
|
+
}
|
|
4526
4536
|
/** Light connect: SIWE auth only. Re-auths if chain changed. */
|
|
4527
4537
|
async connectAuth(state, chainId) {
|
|
4528
4538
|
const validChainId = isValidChainId(chainId);
|
|
@@ -9650,6 +9660,13 @@ var YieldseekerAgent = class {
|
|
|
9650
9660
|
this.planHistoryKeys.clear();
|
|
9651
9661
|
this.lastLedgerRows.clear();
|
|
9652
9662
|
}
|
|
9663
|
+
/**
|
|
9664
|
+
* Whether connecting now would ask the wallet to sign in: no reusable saved
|
|
9665
|
+
* sign-in for this wallet and chain. Never prompts; reads only what is saved.
|
|
9666
|
+
*/
|
|
9667
|
+
needsSignIn(state, chainId) {
|
|
9668
|
+
return !this.auth.peekToken(state, chainId);
|
|
9669
|
+
}
|
|
9653
9670
|
/**
|
|
9654
9671
|
* The connect's account check (2026-11-13), run before any agent activates:
|
|
9655
9672
|
* sign in (a saved sign-in, else login-with-wallet, else POST /users for a
|
|
@@ -16743,6 +16760,7 @@ var OwneySDK = class {
|
|
|
16743
16760
|
*/
|
|
16744
16761
|
disabledAgents = /* @__PURE__ */ new Set();
|
|
16745
16762
|
accountRefusedListeners = /* @__PURE__ */ new Set();
|
|
16763
|
+
signInProgressListeners = /* @__PURE__ */ new Set();
|
|
16746
16764
|
/**
|
|
16747
16765
|
* Agents whose sign-in the user cancelled this session (the wallet rejected
|
|
16748
16766
|
* the prompt), keyed by chain. Until the app ends the session they are read
|
|
@@ -16976,6 +16994,62 @@ var OwneySDK = class {
|
|
|
16976
16994
|
this.accountRefusedListeners.delete(listener);
|
|
16977
16995
|
};
|
|
16978
16996
|
}
|
|
16997
|
+
/**
|
|
16998
|
+
* Listens for the sign-ins a connect asks for (`SignInProgress`): which
|
|
16999
|
+
* agents will ask the wallet to sign in, and each one as it starts and ends,
|
|
17000
|
+
* then `"finished"` after the last one (or when the connect ends first).
|
|
17001
|
+
* Nothing is sent when no agent needs a sign-in. Returns the unsubscribe
|
|
17002
|
+
* function.
|
|
17003
|
+
*/
|
|
17004
|
+
onSignInProgress(listener) {
|
|
17005
|
+
this.signInProgressListeners.add(listener);
|
|
17006
|
+
return () => {
|
|
17007
|
+
this.signInProgressListeners.delete(listener);
|
|
17008
|
+
};
|
|
17009
|
+
}
|
|
17010
|
+
/**
|
|
17011
|
+
* The sign-ins this connect asks for: the agents whose `needsSignIn` says
|
|
17012
|
+
* yes now (one that throws counts as no). Each is announced at its first
|
|
17013
|
+
* step (its account check, or its activation when it has none) and counted
|
|
17014
|
+
* once.
|
|
17015
|
+
*/
|
|
17016
|
+
planSignIns(agents, state, chainId) {
|
|
17017
|
+
const planned = /* @__PURE__ */ new Set();
|
|
17018
|
+
for (const agent of agents) {
|
|
17019
|
+
try {
|
|
17020
|
+
if (agent.needsSignIn?.(state, chainId) === true) planned.add(agent.id);
|
|
17021
|
+
} catch {
|
|
17022
|
+
}
|
|
17023
|
+
}
|
|
17024
|
+
const total = planned.size;
|
|
17025
|
+
let done = 0;
|
|
17026
|
+
let finished = false;
|
|
17027
|
+
const send = (progress) => {
|
|
17028
|
+
if (total === 0 || finished) return;
|
|
17029
|
+
for (const listener of [...this.signInProgressListeners]) {
|
|
17030
|
+
try {
|
|
17031
|
+
listener(progress);
|
|
17032
|
+
} catch {
|
|
17033
|
+
}
|
|
17034
|
+
}
|
|
17035
|
+
};
|
|
17036
|
+
const finish = () => {
|
|
17037
|
+
send({ state: "finished", total, done });
|
|
17038
|
+
finished = true;
|
|
17039
|
+
};
|
|
17040
|
+
return {
|
|
17041
|
+
before: (agent) => {
|
|
17042
|
+
if (planned.has(agent.id)) send({ state: "waiting", total, done, agentId: agent.id });
|
|
17043
|
+
},
|
|
17044
|
+
after: (agent) => {
|
|
17045
|
+
if (!planned.delete(agent.id)) return;
|
|
17046
|
+
done += 1;
|
|
17047
|
+
send({ state: "signed", total, done, agentId: agent.id });
|
|
17048
|
+
if (done === total) finish();
|
|
17049
|
+
},
|
|
17050
|
+
finish
|
|
17051
|
+
};
|
|
17052
|
+
}
|
|
16979
17053
|
/** Wires the optional hooks the SDK offers an agent. */
|
|
16980
17054
|
attachAgentHooks(agent) {
|
|
16981
17055
|
try {
|
|
@@ -17640,6 +17714,14 @@ var OwneySDK = class {
|
|
|
17640
17714
|
* activation, with nothing activated.
|
|
17641
17715
|
*/
|
|
17642
17716
|
async activateAgentsInTurn(agents, state, chainId, asset, onAgentsSelected) {
|
|
17717
|
+
const signIns = this.planSignIns(agents, state, chainId);
|
|
17718
|
+
try {
|
|
17719
|
+
await this.activatePlannedAgents(agents, state, chainId, signIns, asset, onAgentsSelected);
|
|
17720
|
+
} finally {
|
|
17721
|
+
signIns.finish();
|
|
17722
|
+
}
|
|
17723
|
+
}
|
|
17724
|
+
async activatePlannedAgents(agents, state, chainId, signIns, asset, onAgentsSelected) {
|
|
17643
17725
|
let firstError = null;
|
|
17644
17726
|
let walletRejected = false;
|
|
17645
17727
|
const activatedAgentIds = [];
|
|
@@ -17665,8 +17747,10 @@ var OwneySDK = class {
|
|
|
17665
17747
|
if (!agent.checkAccount) continue;
|
|
17666
17748
|
this.assertActivationSession(state);
|
|
17667
17749
|
try {
|
|
17750
|
+
signIns.before(agent);
|
|
17668
17751
|
await agent.checkAccount(state, chainId);
|
|
17669
17752
|
this.assertActivationSession(state);
|
|
17753
|
+
signIns.after(agent);
|
|
17670
17754
|
} catch (error) {
|
|
17671
17755
|
recordFailure(agent, error);
|
|
17672
17756
|
break;
|
|
@@ -17677,8 +17761,10 @@ var OwneySDK = class {
|
|
|
17677
17761
|
for (const agent of agents) {
|
|
17678
17762
|
this.assertActivationSession(state);
|
|
17679
17763
|
try {
|
|
17764
|
+
signIns.before(agent);
|
|
17680
17765
|
await agent.activateAgent(state, chainId, asset);
|
|
17681
17766
|
this.assertActivationSession(state);
|
|
17767
|
+
signIns.after(agent);
|
|
17682
17768
|
await this.applyOrgPolicyTo(agent, state, chainId);
|
|
17683
17769
|
this.assertActivationSession(state);
|
|
17684
17770
|
activatedAgentIds.push(agent.id);
|