@owney/sdk 0.7.17-beta.0 → 0.7.17-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/index.cjs CHANGED
@@ -3631,9 +3631,12 @@ var OwneySDK = class {
3631
3631
  { asset, agentErrors: agentErrors2 }
3632
3632
  );
3633
3633
  }
3634
+ const amountsKnown = Object.values(results2).every(
3635
+ (result) => typeof result.amount === "string" && /^\d+$/.test(result.amount)
3636
+ );
3634
3637
  return {
3635
3638
  agentResult: results2,
3636
- totalWithdrawn: sumWithdrawnAmount(results2).toString()
3639
+ totalWithdrawn: amountsKnown ? sumWithdrawnAmount(results2).toString() : null
3637
3640
  };
3638
3641
  }
3639
3642
  const requested = BigInt(amount);
@@ -3753,6 +3756,7 @@ var OwneySDK = class {
3753
3756
  );
3754
3757
  let successCount = 0;
3755
3758
  const agentErrors = {};
3759
+ const agentRetryAt = {};
3756
3760
  const agentFailures = [];
3757
3761
  for (let i = 0; i < balanceResults.length; i++) {
3758
3762
  const settledResult = balanceResults[i];
@@ -3766,6 +3770,8 @@ var OwneySDK = class {
3766
3770
  }
3767
3771
  const reason = settledResult.reason;
3768
3772
  agentFailures.push(reason);
3773
+ const retryDelay = rateLimitDelay(reason);
3774
+ if (retryDelay !== void 0) agentRetryAt[agentId2] = Date.now() + retryDelay;
3769
3775
  agentErrors[agentId2] = reason instanceof Error ? reason.message : String(reason);
3770
3776
  }
3771
3777
  if (successCount === 0) {
@@ -3778,7 +3784,8 @@ var OwneySDK = class {
3778
3784
  return {
3779
3785
  totalBalance: String(totalBalance),
3780
3786
  totalBalanceAsset: "usdc",
3781
- agentBalances: results
3787
+ agentBalances: results,
3788
+ ...Object.keys(agentErrors).length > 0 ? { agentErrors, agentRetryAt } : {}
3782
3789
  };
3783
3790
  }
3784
3791
  /**
package/dist/index.d.cts CHANGED
@@ -186,11 +186,16 @@ interface OwneyMultiDepositResult {
186
186
  interface AgentWithdrawResult {
187
187
  txHash?: string;
188
188
  type: "full" | "partial";
189
+ /** Smallest-unit amount, or a provider sentinel such as "all" for a full request. */
189
190
  amount: string;
190
191
  }
191
192
  interface OwneyWithdrawResult {
192
193
  agentResult: Record<AgentId, AgentWithdrawResult>;
193
- totalWithdrawn: string;
194
+ /**
195
+ * Sum of reported smallest-unit amounts; null when a full withdrawal's
196
+ * amount is not yet known. An accepted request is not proof of settlement.
197
+ */
198
+ totalWithdrawn: string | null;
194
199
  }
195
200
  interface OwneyToken {
196
201
  chain: OwneySupportedChains;
@@ -254,6 +259,10 @@ interface OwneyBalances {
254
259
  /** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
255
260
  totalBalanceAsset: string;
256
261
  agentBalances: Record<AgentId, AgentBalance>;
262
+ /** Omitted agents failed to load; they must not be interpreted as zero. */
263
+ agentErrors?: Record<AgentId, string>;
264
+ /** Absolute provider cooldown deadlines (Unix milliseconds). */
265
+ agentRetryAt?: Record<AgentId, number>;
257
266
  }
258
267
  interface AgentEarnings {
259
268
  smartWallet: `0x${string}`;
package/dist/index.d.ts CHANGED
@@ -186,11 +186,16 @@ interface OwneyMultiDepositResult {
186
186
  interface AgentWithdrawResult {
187
187
  txHash?: string;
188
188
  type: "full" | "partial";
189
+ /** Smallest-unit amount, or a provider sentinel such as "all" for a full request. */
189
190
  amount: string;
190
191
  }
191
192
  interface OwneyWithdrawResult {
192
193
  agentResult: Record<AgentId, AgentWithdrawResult>;
193
- totalWithdrawn: string;
194
+ /**
195
+ * Sum of reported smallest-unit amounts; null when a full withdrawal's
196
+ * amount is not yet known. An accepted request is not proof of settlement.
197
+ */
198
+ totalWithdrawn: string | null;
194
199
  }
195
200
  interface OwneyToken {
196
201
  chain: OwneySupportedChains;
@@ -254,6 +259,10 @@ interface OwneyBalances {
254
259
  /** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
255
260
  totalBalanceAsset: string;
256
261
  agentBalances: Record<AgentId, AgentBalance>;
262
+ /** Omitted agents failed to load; they must not be interpreted as zero. */
263
+ agentErrors?: Record<AgentId, string>;
264
+ /** Absolute provider cooldown deadlines (Unix milliseconds). */
265
+ agentRetryAt?: Record<AgentId, number>;
257
266
  }
258
267
  interface AgentEarnings {
259
268
  smartWallet: `0x${string}`;
package/dist/index.js CHANGED
@@ -3602,9 +3602,12 @@ var OwneySDK = class {
3602
3602
  { asset, agentErrors: agentErrors2 }
3603
3603
  );
3604
3604
  }
3605
+ const amountsKnown = Object.values(results2).every(
3606
+ (result) => typeof result.amount === "string" && /^\d+$/.test(result.amount)
3607
+ );
3605
3608
  return {
3606
3609
  agentResult: results2,
3607
- totalWithdrawn: sumWithdrawnAmount(results2).toString()
3610
+ totalWithdrawn: amountsKnown ? sumWithdrawnAmount(results2).toString() : null
3608
3611
  };
3609
3612
  }
3610
3613
  const requested = BigInt(amount);
@@ -3724,6 +3727,7 @@ var OwneySDK = class {
3724
3727
  );
3725
3728
  let successCount = 0;
3726
3729
  const agentErrors = {};
3730
+ const agentRetryAt = {};
3727
3731
  const agentFailures = [];
3728
3732
  for (let i = 0; i < balanceResults.length; i++) {
3729
3733
  const settledResult = balanceResults[i];
@@ -3737,6 +3741,8 @@ var OwneySDK = class {
3737
3741
  }
3738
3742
  const reason = settledResult.reason;
3739
3743
  agentFailures.push(reason);
3744
+ const retryDelay = rateLimitDelay(reason);
3745
+ if (retryDelay !== void 0) agentRetryAt[agentId2] = Date.now() + retryDelay;
3740
3746
  agentErrors[agentId2] = reason instanceof Error ? reason.message : String(reason);
3741
3747
  }
3742
3748
  if (successCount === 0) {
@@ -3749,7 +3755,8 @@ var OwneySDK = class {
3749
3755
  return {
3750
3756
  totalBalance: String(totalBalance),
3751
3757
  totalBalanceAsset: "usdc",
3752
- agentBalances: results
3758
+ agentBalances: results,
3759
+ ...Object.keys(agentErrors).length > 0 ? { agentErrors, agentRetryAt } : {}
3753
3760
  };
3754
3761
  }
3755
3762
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owney/sdk",
3
- "version": "0.7.17-beta.0",
3
+ "version": "0.7.17-beta.1",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",