@oobe-protocol-labs/synapse-sap-sdk 0.10.1 → 0.12.5

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.
Files changed (84) hide show
  1. package/dist/cjs/constants/payments.js +51 -1
  2. package/dist/cjs/constants/payments.js.map +1 -1
  3. package/dist/cjs/core/client.js +46 -0
  4. package/dist/cjs/core/client.js.map +1 -1
  5. package/dist/cjs/idl/synapse_agent_sap.json +156 -4
  6. package/dist/cjs/index.js +3 -2
  7. package/dist/cjs/index.js.map +1 -1
  8. package/dist/cjs/modules/escrow-v2.js +46 -0
  9. package/dist/cjs/modules/escrow-v2.js.map +1 -1
  10. package/dist/cjs/modules/escrow.js +13 -3
  11. package/dist/cjs/modules/escrow.js.map +1 -1
  12. package/dist/cjs/modules/receipt.js +4 -0
  13. package/dist/cjs/modules/receipt.js.map +1 -1
  14. package/dist/cjs/modules/staking.js +30 -0
  15. package/dist/cjs/modules/staking.js.map +1 -1
  16. package/dist/cjs/registries/fairscale.js +639 -0
  17. package/dist/cjs/registries/fairscale.js.map +1 -0
  18. package/dist/cjs/registries/index.js +6 -1
  19. package/dist/cjs/registries/index.js.map +1 -1
  20. package/dist/cjs/registries/x402.js +10 -4
  21. package/dist/cjs/registries/x402.js.map +1 -1
  22. package/dist/cjs/utils/index.js +2 -1
  23. package/dist/cjs/utils/index.js.map +1 -1
  24. package/dist/cjs/utils/priority-fee.js +52 -0
  25. package/dist/cjs/utils/priority-fee.js.map +1 -1
  26. package/dist/esm/constants/payments.js +49 -0
  27. package/dist/esm/constants/payments.js.map +1 -1
  28. package/dist/esm/core/client.js +46 -0
  29. package/dist/esm/core/client.js.map +1 -1
  30. package/dist/esm/idl/synapse_agent_sap.json +156 -4
  31. package/dist/esm/index.js +1 -1
  32. package/dist/esm/index.js.map +1 -1
  33. package/dist/esm/modules/escrow-v2.js +47 -1
  34. package/dist/esm/modules/escrow-v2.js.map +1 -1
  35. package/dist/esm/modules/escrow.js +14 -4
  36. package/dist/esm/modules/escrow.js.map +1 -1
  37. package/dist/esm/modules/receipt.js +5 -1
  38. package/dist/esm/modules/receipt.js.map +1 -1
  39. package/dist/esm/modules/staking.js +30 -0
  40. package/dist/esm/modules/staking.js.map +1 -1
  41. package/dist/esm/registries/fairscale.js +633 -0
  42. package/dist/esm/registries/fairscale.js.map +1 -0
  43. package/dist/esm/registries/index.js +1 -0
  44. package/dist/esm/registries/index.js.map +1 -1
  45. package/dist/esm/registries/x402.js +11 -5
  46. package/dist/esm/registries/x402.js.map +1 -1
  47. package/dist/esm/utils/index.js +1 -1
  48. package/dist/esm/utils/index.js.map +1 -1
  49. package/dist/esm/utils/priority-fee.js +51 -0
  50. package/dist/esm/utils/priority-fee.js.map +1 -1
  51. package/dist/types/constants/payments.d.ts +43 -0
  52. package/dist/types/constants/payments.d.ts.map +1 -1
  53. package/dist/types/core/client.d.ts +39 -0
  54. package/dist/types/core/client.d.ts.map +1 -1
  55. package/dist/types/index.d.ts +1 -1
  56. package/dist/types/index.d.ts.map +1 -1
  57. package/dist/types/modules/escrow-v2.d.ts.map +1 -1
  58. package/dist/types/modules/escrow.d.ts.map +1 -1
  59. package/dist/types/modules/receipt.d.ts.map +1 -1
  60. package/dist/types/modules/staking.d.ts +19 -0
  61. package/dist/types/modules/staking.d.ts.map +1 -1
  62. package/dist/types/registries/fairscale.d.ts +680 -0
  63. package/dist/types/registries/fairscale.d.ts.map +1 -0
  64. package/dist/types/registries/index.d.ts +2 -0
  65. package/dist/types/registries/index.d.ts.map +1 -1
  66. package/dist/types/registries/x402.d.ts.map +1 -1
  67. package/dist/types/utils/index.d.ts +1 -1
  68. package/dist/types/utils/index.d.ts.map +1 -1
  69. package/dist/types/utils/priority-fee.d.ts +20 -0
  70. package/dist/types/utils/priority-fee.d.ts.map +1 -1
  71. package/package.json +6 -1
  72. package/src/constants/payments.ts +53 -0
  73. package/src/core/client.ts +51 -0
  74. package/src/idl/synapse_agent_sap.json +156 -4
  75. package/src/index.ts +1 -0
  76. package/src/modules/escrow-v2.ts +49 -1
  77. package/src/modules/escrow.ts +14 -3
  78. package/src/modules/receipt.ts +5 -0
  79. package/src/modules/staking.ts +35 -0
  80. package/src/registries/fairscale.ts +1278 -0
  81. package/src/registries/index.ts +46 -0
  82. package/src/registries/x402.ts +11 -4
  83. package/src/utils/index.ts +1 -0
  84. package/src/utils/priority-fee.ts +55 -0
@@ -95,3 +95,49 @@ export type {
95
95
  RegisterBothResult,
96
96
  TripleCheckResult,
97
97
  } from "./metaplex-bridge";
98
+
99
+ export {
100
+ FairScaleRegistry,
101
+ HumanScoreNamespace,
102
+ FairScaleError,
103
+ FAIRSCALE,
104
+ } from "./fairscale";
105
+ export type {
106
+ FairScaleConfig,
107
+ FairScaleTier,
108
+ FairScalePreset,
109
+ FairScaleTask,
110
+ FairScalePillars,
111
+ FairScaleBadge,
112
+ FairScaleAction,
113
+ FairScaleSignals,
114
+ FairScaleRecommendationTier,
115
+ FairScaleDirectorySort,
116
+ FairScaleDescriptionAlignment,
117
+ FairScaleRedFlag,
118
+ FairScaleVerifications,
119
+ FairScaleMeta,
120
+ AgentScoreResult,
121
+ TrustGateResult,
122
+ BatchScoreResult,
123
+ ScoreOptions,
124
+ TrustGateOptions,
125
+ ScoreAiOptions,
126
+ DirectoryOptions,
127
+ DirectoryEntry,
128
+ DirectoryResult,
129
+ LeaderboardResult,
130
+ ScoreHistoryResult,
131
+ CreditOptions,
132
+ CreditResult,
133
+ CreditConfidence,
134
+ CreditUnderwriting,
135
+ CreditLendingTerms,
136
+ CreditRiskFlag,
137
+ CreditPillars,
138
+ CreditAttestation,
139
+ HumanScoreResult,
140
+ HumanScoreFeatures,
141
+ AggregatedReputation,
142
+ AggregateOptions,
143
+ } from "./fairscale";
@@ -88,6 +88,7 @@ import type {
88
88
  } from "../types";
89
89
  import {
90
90
  buildPriorityFeeIxs,
91
+ computeBatchSettleCu,
91
92
  buildRpcOptions,
92
93
  } from "../utils/priority-fee";
93
94
  import type { SettleOptions } from "../utils/priority-fee";
@@ -856,13 +857,19 @@ export class X402Registry {
856
857
  totalCalls,
857
858
  );
858
859
 
859
- // Build priority fee instructions (empty array if no opts)
860
- const preIxs = buildPriorityFeeIxs(opts);
861
- const rpcOpts = buildRpcOptions(opts);
860
+ // Auto-size CU to the batch length when the caller didn't pin one.
861
+ // Default Solana cap (200k) is tight past ~8 entries; a CU limit
862
+ // costs nothing extra (only caps the maximum charge).
863
+ const effectiveOpts: SettleOptions = {
864
+ ...opts,
865
+ computeUnits: opts?.computeUnits ?? computeBatchSettleCu(settlements.length),
866
+ };
867
+ const preIxs = buildPriorityFeeIxs(effectiveOpts);
868
+ const rpcOpts = buildRpcOptions(effectiveOpts);
862
869
 
863
870
  let builder = this.methods
864
871
  .settleBatch(settlements)
865
- .accounts({
872
+ .accountsPartial({
866
873
  wallet: this.wallet,
867
874
  agent: agentPda,
868
875
  agentStats: statsPda,
@@ -66,6 +66,7 @@ export {
66
66
  DEFAULT_SETTLE_PRIORITY_FEE,
67
67
  DEFAULT_SETTLE_COMPUTE_UNITS,
68
68
  DEFAULT_BATCH_SETTLE_COMPUTE_UNITS,
69
+ computeBatchSettleCu,
69
70
  } from "./priority-fee";
70
71
  export type {
71
72
  PriorityFeeConfig,
@@ -59,6 +59,61 @@ export const DEFAULT_SETTLE_COMPUTE_UNITS = 100_000;
59
59
  */
60
60
  export const DEFAULT_BATCH_SETTLE_COMPUTE_UNITS = 300_000;
61
61
 
62
+ /**
63
+ * Per-settlement CU cost observed for `settle_batch` (sha256 of the
64
+ * service hash, dedup scan, volume-curve math, account writes).
65
+ *
66
+ * @since v0.11.0
67
+ * @internal
68
+ */
69
+ const BATCH_SETTLE_CU_PER_ENTRY = 25_000;
70
+
71
+ /**
72
+ * Fixed CU overhead for a `settle_batch` transaction independent of
73
+ * the entry count (signature verify, account loads, transfer, event).
74
+ *
75
+ * @since v0.11.0
76
+ * @internal
77
+ */
78
+ const BATCH_SETTLE_CU_BASE = 60_000;
79
+
80
+ /**
81
+ * Hard ceiling — Solana caps a single instruction at 1.4M CU. We
82
+ * stay below that so a transaction with extra preInstructions
83
+ * (priority-fee, ATA creation) still fits.
84
+ *
85
+ * @since v0.11.0
86
+ * @internal
87
+ */
88
+ const BATCH_SETTLE_CU_MAX = 1_200_000;
89
+
90
+ /**
91
+ * @name computeBatchSettleCu
92
+ * @description Compute the CU limit needed by `settle_batch` for a
93
+ * given entry count. Returned value is safe to pass to
94
+ * `ComputeBudgetProgram.setComputeUnitLimit`.
95
+ *
96
+ * Formula: `60_000 + n * 25_000`, clamped to 1.2M.
97
+ *
98
+ * @param entryCount - Number of settlements in the batch (1..N).
99
+ * @returns CU limit suitable for `setComputeUnitLimit`.
100
+ *
101
+ * @example
102
+ * ```ts
103
+ * const cu = computeBatchSettleCu(20); // 560_000
104
+ * ```
105
+ *
106
+ * @category Utils
107
+ * @since v0.11.0
108
+ */
109
+ export function computeBatchSettleCu(entryCount: number): number {
110
+ if (!Number.isFinite(entryCount) || entryCount <= 0) {
111
+ return DEFAULT_BATCH_SETTLE_COMPUTE_UNITS;
112
+ }
113
+ const raw = BATCH_SETTLE_CU_BASE + Math.ceil(entryCount) * BATCH_SETTLE_CU_PER_ENTRY;
114
+ return Math.min(raw, BATCH_SETTLE_CU_MAX);
115
+ }
116
+
62
117
  // ═══════════════════════════════════════════════════════════════════
63
118
  // Types
64
119
  // ═══════════════════════════════════════════════════════════════════