@oobe-protocol-labs/synapse-sap-sdk 0.6.0 → 0.6.3
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 +107 -3
- package/dist/cjs/events/geyser.js +295 -0
- package/dist/cjs/events/geyser.js.map +1 -0
- package/dist/cjs/index.js +14 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/modules/escrow.js +23 -8
- package/dist/cjs/modules/escrow.js.map +1 -1
- package/dist/cjs/plugin/index.js +18 -2
- package/dist/cjs/plugin/index.js.map +1 -1
- package/dist/cjs/plugin/schemas.js +32 -0
- package/dist/cjs/plugin/schemas.js.map +1 -1
- package/dist/cjs/postgres/sync.js +72 -4
- package/dist/cjs/postgres/sync.js.map +1 -1
- package/dist/cjs/registries/index.js.map +1 -1
- package/dist/cjs/registries/x402.js +51 -8
- package/dist/cjs/registries/x402.js.map +1 -1
- package/dist/cjs/utils/index.js +10 -1
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/priority-fee.js +163 -0
- package/dist/cjs/utils/priority-fee.js.map +1 -0
- package/dist/esm/events/geyser.js +258 -0
- package/dist/esm/events/geyser.js.map +1 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/modules/escrow.js +23 -8
- package/dist/esm/modules/escrow.js.map +1 -1
- package/dist/esm/plugin/index.js +18 -2
- package/dist/esm/plugin/index.js.map +1 -1
- package/dist/esm/plugin/schemas.js +32 -0
- package/dist/esm/plugin/schemas.js.map +1 -1
- package/dist/esm/postgres/sync.js +72 -4
- package/dist/esm/postgres/sync.js.map +1 -1
- package/dist/esm/registries/index.js.map +1 -1
- package/dist/esm/registries/x402.js +51 -8
- package/dist/esm/registries/x402.js.map +1 -1
- package/dist/esm/utils/index.js +2 -0
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/priority-fee.js +158 -0
- package/dist/esm/utils/priority-fee.js.map +1 -0
- package/dist/types/events/geyser.d.ts +150 -0
- package/dist/types/events/geyser.d.ts.map +1 -0
- package/dist/types/index.d.ts +5 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modules/escrow.d.ts +7 -2
- package/dist/types/modules/escrow.d.ts.map +1 -1
- package/dist/types/plugin/index.d.ts.map +1 -1
- package/dist/types/plugin/schemas.d.ts +6 -0
- package/dist/types/plugin/schemas.d.ts.map +1 -1
- package/dist/types/postgres/sync.d.ts +26 -2
- package/dist/types/postgres/sync.d.ts.map +1 -1
- package/dist/types/registries/index.d.ts +1 -1
- package/dist/types/registries/index.d.ts.map +1 -1
- package/dist/types/registries/x402.d.ts +34 -2
- package/dist/types/registries/x402.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/utils/priority-fee.d.ts +185 -0
- package/dist/types/utils/priority-fee.d.ts.map +1 -0
- package/package.json +5 -1
- package/src/events/geyser.ts +384 -0
- package/src/events/yellowstone.d.ts +7 -0
- package/src/index.ts +19 -0
- package/src/modules/escrow.ts +33 -6
- package/src/plugin/index.ts +20 -0
- package/src/plugin/schemas.ts +32 -0
- package/src/postgres/sync.ts +90 -4
- package/src/registries/index.ts +1 -0
- package/src/registries/x402.ts +63 -6
- package/src/utils/index.ts +15 -0
- package/src/utils/priority-fee.ts +270 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module utils/priority-fee
|
|
4
|
+
* @description Compute budget and priority fee utilities for SAP transactions.
|
|
5
|
+
*
|
|
6
|
+
* Solana transactions that include a priority fee (via the Compute Budget program)
|
|
7
|
+
* land faster because validators prefer higher-fee transactions. This module
|
|
8
|
+
* provides a clean, composable API for building priority-fee instructions
|
|
9
|
+
* that can be prepended to any Anchor method builder via `.preInstructions()`.
|
|
10
|
+
*
|
|
11
|
+
* Typical use: x402 settlement transactions where the receiving agent's RPC
|
|
12
|
+
* has a short confirmation window (e.g., 30 seconds).
|
|
13
|
+
*
|
|
14
|
+
* @category Utils
|
|
15
|
+
* @since v0.6.2
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { buildPriorityFeeIxs, DEFAULT_SETTLE_PRIORITY } from "@synapse-sap/sdk";
|
|
20
|
+
*
|
|
21
|
+
* // Append to any Anchor method builder:
|
|
22
|
+
* await program.methods
|
|
23
|
+
* .settleCalls(calls, hash)
|
|
24
|
+
* .accounts({ ... })
|
|
25
|
+
* .preInstructions(buildPriorityFeeIxs({ priorityFeeMicroLamports: 5000 }))
|
|
26
|
+
* .rpc({ skipPreflight: true });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.FAST_BATCH_SETTLE_OPTIONS = exports.FAST_SETTLE_OPTIONS = exports.DEFAULT_BATCH_SETTLE_COMPUTE_UNITS = exports.DEFAULT_SETTLE_COMPUTE_UNITS = exports.DEFAULT_SETTLE_PRIORITY_FEE = void 0;
|
|
31
|
+
exports.buildPriorityFeeIxs = buildPriorityFeeIxs;
|
|
32
|
+
exports.buildRpcOptions = buildRpcOptions;
|
|
33
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
34
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
35
|
+
// Constants
|
|
36
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
37
|
+
/**
|
|
38
|
+
* Default priority fee for settlement transactions (in microlamports).
|
|
39
|
+
* 5000 µL ≈ 0.0005 SOL per 200k CU — fast enough for most agent RPCs.
|
|
40
|
+
*
|
|
41
|
+
* @since v0.6.2
|
|
42
|
+
*/
|
|
43
|
+
exports.DEFAULT_SETTLE_PRIORITY_FEE = 5_000;
|
|
44
|
+
/**
|
|
45
|
+
* Default compute unit limit for settlement transactions.
|
|
46
|
+
* `settle_calls` uses ~60k CU; 100k provides a safe margin.
|
|
47
|
+
*
|
|
48
|
+
* @since v0.6.2
|
|
49
|
+
*/
|
|
50
|
+
exports.DEFAULT_SETTLE_COMPUTE_UNITS = 100_000;
|
|
51
|
+
/**
|
|
52
|
+
* Default compute unit limit for batch settlement transactions.
|
|
53
|
+
* `settle_batch` with 10 entries uses ~200k CU; 300k provides margin.
|
|
54
|
+
*
|
|
55
|
+
* @since v0.6.2
|
|
56
|
+
*/
|
|
57
|
+
exports.DEFAULT_BATCH_SETTLE_COMPUTE_UNITS = 300_000;
|
|
58
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
59
|
+
// Presets
|
|
60
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
61
|
+
/**
|
|
62
|
+
* Recommended preset for fast x402 settlements.
|
|
63
|
+
* Priority fee 5000 µL, 100k CU, skip preflight, confirmed commitment.
|
|
64
|
+
*
|
|
65
|
+
* @since v0.6.2
|
|
66
|
+
*/
|
|
67
|
+
exports.FAST_SETTLE_OPTIONS = Object.freeze({
|
|
68
|
+
priorityFeeMicroLamports: exports.DEFAULT_SETTLE_PRIORITY_FEE,
|
|
69
|
+
computeUnits: exports.DEFAULT_SETTLE_COMPUTE_UNITS,
|
|
70
|
+
skipPreflight: true,
|
|
71
|
+
commitment: "confirmed",
|
|
72
|
+
});
|
|
73
|
+
/**
|
|
74
|
+
* Recommended preset for fast batch settlements.
|
|
75
|
+
* Priority fee 5000 µL, 300k CU, skip preflight, confirmed commitment.
|
|
76
|
+
*
|
|
77
|
+
* @since v0.6.2
|
|
78
|
+
*/
|
|
79
|
+
exports.FAST_BATCH_SETTLE_OPTIONS = Object.freeze({
|
|
80
|
+
priorityFeeMicroLamports: exports.DEFAULT_SETTLE_PRIORITY_FEE,
|
|
81
|
+
computeUnits: exports.DEFAULT_BATCH_SETTLE_COMPUTE_UNITS,
|
|
82
|
+
skipPreflight: true,
|
|
83
|
+
commitment: "confirmed",
|
|
84
|
+
});
|
|
85
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
86
|
+
// Builder
|
|
87
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
88
|
+
/**
|
|
89
|
+
* @name buildPriorityFeeIxs
|
|
90
|
+
* @description Build compute budget instructions for priority fee transactions.
|
|
91
|
+
*
|
|
92
|
+
* Returns an array of 0–2 `TransactionInstruction`s:
|
|
93
|
+
* - `SetComputeUnitPrice` (if `priorityFeeMicroLamports > 0`)
|
|
94
|
+
* - `SetComputeUnitLimit` (if `computeUnits` provided)
|
|
95
|
+
*
|
|
96
|
+
* The returned array is designed to be passed directly to
|
|
97
|
+
* Anchor's `.preInstructions()` builder method.
|
|
98
|
+
*
|
|
99
|
+
* @param config - Priority fee configuration.
|
|
100
|
+
* @returns Array of compute budget instructions (may be empty).
|
|
101
|
+
*
|
|
102
|
+
* @category Utils
|
|
103
|
+
* @since v0.6.2
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```ts
|
|
107
|
+
* const ixs = buildPriorityFeeIxs({
|
|
108
|
+
* priorityFeeMicroLamports: 5000,
|
|
109
|
+
* computeUnits: 100_000,
|
|
110
|
+
* });
|
|
111
|
+
*
|
|
112
|
+
* await program.methods
|
|
113
|
+
* .settleCalls(calls, hash)
|
|
114
|
+
* .accounts({ ... })
|
|
115
|
+
* .preInstructions(ixs)
|
|
116
|
+
* .rpc({ skipPreflight: true });
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
function buildPriorityFeeIxs(config) {
|
|
120
|
+
if (!config)
|
|
121
|
+
return [];
|
|
122
|
+
const ixs = [];
|
|
123
|
+
const fee = config.priorityFeeMicroLamports ?? 0;
|
|
124
|
+
if (fee > 0) {
|
|
125
|
+
ixs.push(web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
|
|
126
|
+
microLamports: fee,
|
|
127
|
+
}));
|
|
128
|
+
}
|
|
129
|
+
const cu = config.computeUnits;
|
|
130
|
+
if (cu !== undefined && cu > 0) {
|
|
131
|
+
ixs.push(web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({
|
|
132
|
+
units: cu,
|
|
133
|
+
}));
|
|
134
|
+
}
|
|
135
|
+
return ixs;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* @name buildRpcOptions
|
|
139
|
+
* @description Build Anchor `.rpc()` options from {@link SettleOptions}.
|
|
140
|
+
*
|
|
141
|
+
* @param opts - Settle options.
|
|
142
|
+
* @returns Options object suitable for Anchor `.rpc(opts)`.
|
|
143
|
+
*
|
|
144
|
+
* @category Utils
|
|
145
|
+
* @since v0.6.2
|
|
146
|
+
* @internal
|
|
147
|
+
*/
|
|
148
|
+
function buildRpcOptions(opts) {
|
|
149
|
+
if (!opts)
|
|
150
|
+
return undefined;
|
|
151
|
+
const rpcOpts = {};
|
|
152
|
+
if (opts.skipPreflight !== undefined) {
|
|
153
|
+
rpcOpts.skipPreflight = opts.skipPreflight;
|
|
154
|
+
}
|
|
155
|
+
if (opts.commitment !== undefined) {
|
|
156
|
+
rpcOpts.commitment = opts.commitment;
|
|
157
|
+
}
|
|
158
|
+
if (opts.maxRetries !== undefined) {
|
|
159
|
+
rpcOpts.maxRetries = opts.maxRetries;
|
|
160
|
+
}
|
|
161
|
+
return Object.keys(rpcOpts).length > 0 ? rpcOpts : undefined;
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=priority-fee.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"priority-fee.js","sourceRoot":"","sources":["../../../src/utils/priority-fee.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;;;AA0LH,kDA0BC;AAaD,0CAkBC;AAjPD,6CAGyB;AAEzB,sEAAsE;AACtE,aAAa;AACb,sEAAsE;AAEtE;;;;;GAKG;AACU,QAAA,2BAA2B,GAAG,KAAK,CAAC;AAEjD;;;;;GAKG;AACU,QAAA,4BAA4B,GAAG,OAAO,CAAC;AAEpD;;;;;GAKG;AACU,QAAA,kCAAkC,GAAG,OAAO,CAAC;AAwF1D,sEAAsE;AACtE,WAAW;AACX,s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5C,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;QACrC,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;IAC7C,CAAC;IACD,IAAI,IAAI,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QAClC,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;IACvC,CAAC;IACD,IAAI,IAAI,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QAClC,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;IACvC,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module events/geyser
|
|
3
|
+
* @description Yellowstone gRPC (Geyser) event stream for SAP v2.
|
|
4
|
+
*
|
|
5
|
+
* Drop-in alternative to the WebSocket `connection.onLogs()` pipeline.
|
|
6
|
+
* Uses Triton / Helius / any Yellowstone-compatible gRPC endpoint to
|
|
7
|
+
* receive program transaction updates with sub-second latency and
|
|
8
|
+
* automatic reconnection.
|
|
9
|
+
*
|
|
10
|
+
* @category Events
|
|
11
|
+
* @since v0.6.3
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { GeyserEventStream } from "@oobe-protocol-labs/synapse-sap-sdk";
|
|
16
|
+
* import { EventParser } from "@oobe-protocol-labs/synapse-sap-sdk";
|
|
17
|
+
*
|
|
18
|
+
* const stream = new GeyserEventStream({
|
|
19
|
+
* endpoint: "https://grpc.triton.one",
|
|
20
|
+
* token: process.env.GEYSER_TOKEN!,
|
|
21
|
+
* programId: "SAPpUhsWLJG1FfkGRcXagEDMrMsWGjbky7AyhGpFETZ",
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* const parser = new EventParser(program);
|
|
25
|
+
*
|
|
26
|
+
* stream.on("logs", (logs, signature, slot) => {
|
|
27
|
+
* const events = parser.parseLogs(logs);
|
|
28
|
+
* for (const event of events) {
|
|
29
|
+
* console.log(event.name, event.data);
|
|
30
|
+
* }
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* stream.on("error", (err) => console.error("gRPC error:", err));
|
|
34
|
+
*
|
|
35
|
+
* await stream.connect();
|
|
36
|
+
* // ... later
|
|
37
|
+
* await stream.disconnect();
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
import { EventEmitter } from "events";
|
|
41
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
42
|
+
// Constants
|
|
43
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
44
|
+
const SAP_PROGRAM_ID = "SAPpUhsWLJG1FfkGRcXagEDMrMsWGjbky7AyhGpFETZ";
|
|
45
|
+
const COMMITMENT_MAP = {
|
|
46
|
+
processed: 0,
|
|
47
|
+
confirmed: 1,
|
|
48
|
+
finalized: 2,
|
|
49
|
+
};
|
|
50
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
51
|
+
// GeyserEventStream
|
|
52
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
53
|
+
/**
|
|
54
|
+
* Yellowstone gRPC event stream for SAP v2 programs.
|
|
55
|
+
*
|
|
56
|
+
* Wraps `@triton-one/yellowstone-grpc` and emits parsed log lines
|
|
57
|
+
* compatible with the existing {@link EventParser}.
|
|
58
|
+
*
|
|
59
|
+
* @name GeyserEventStream
|
|
60
|
+
* @category Events
|
|
61
|
+
* @since v0.6.3
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* const stream = new GeyserEventStream({
|
|
66
|
+
* endpoint: "https://grpc.triton.one",
|
|
67
|
+
* token: process.env.GEYSER_TOKEN!,
|
|
68
|
+
* });
|
|
69
|
+
*
|
|
70
|
+
* stream.on("logs", (logs, sig, slot) => {
|
|
71
|
+
* const events = parser.parseLogs(logs);
|
|
72
|
+
* events.forEach(e => db.insertEvent(e));
|
|
73
|
+
* });
|
|
74
|
+
*
|
|
75
|
+
* await stream.connect();
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export class GeyserEventStream extends EventEmitter {
|
|
79
|
+
config;
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
81
|
+
client = null;
|
|
82
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
83
|
+
stream = null;
|
|
84
|
+
reconnectAttempts = 0;
|
|
85
|
+
_connected = false;
|
|
86
|
+
_stopped = false;
|
|
87
|
+
constructor(config) {
|
|
88
|
+
super();
|
|
89
|
+
this.config = {
|
|
90
|
+
endpoint: config.endpoint,
|
|
91
|
+
token: config.token,
|
|
92
|
+
programId: config.programId ?? SAP_PROGRAM_ID,
|
|
93
|
+
commitment: config.commitment ?? "confirmed",
|
|
94
|
+
autoReconnect: config.autoReconnect ?? true,
|
|
95
|
+
reconnectDelayMs: config.reconnectDelayMs ?? 3_000,
|
|
96
|
+
maxReconnectAttempts: config.maxReconnectAttempts ?? 0,
|
|
97
|
+
includeFailedTxs: config.includeFailedTxs ?? false,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/** Whether the gRPC stream is currently connected. */
|
|
101
|
+
get connected() {
|
|
102
|
+
return this._connected;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Connect to the Yellowstone gRPC endpoint and start streaming.
|
|
106
|
+
*
|
|
107
|
+
* @throws If `@triton-one/yellowstone-grpc` is not installed.
|
|
108
|
+
*/
|
|
109
|
+
async connect() {
|
|
110
|
+
this._stopped = false;
|
|
111
|
+
this.reconnectAttempts = 0;
|
|
112
|
+
// Dynamic import — yellowstone is an optional peer dependency
|
|
113
|
+
let YellowstoneClient;
|
|
114
|
+
try {
|
|
115
|
+
const mod = await import("@triton-one/yellowstone-grpc");
|
|
116
|
+
YellowstoneClient = mod.default ?? mod.Client;
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
throw new Error("Missing dependency: @triton-one/yellowstone-grpc\n" +
|
|
120
|
+
"Install it with: npm i @triton-one/yellowstone-grpc");
|
|
121
|
+
}
|
|
122
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
123
|
+
this.client = new YellowstoneClient(this.config.endpoint, this.config.token, undefined);
|
|
124
|
+
await this.subscribe();
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Disconnect from the gRPC stream and stop reconnection.
|
|
128
|
+
*/
|
|
129
|
+
async disconnect() {
|
|
130
|
+
this._stopped = true;
|
|
131
|
+
this._connected = false;
|
|
132
|
+
if (this.stream) {
|
|
133
|
+
try {
|
|
134
|
+
this.stream.cancel?.();
|
|
135
|
+
this.stream = null;
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
// ignore cancel errors
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
this.emit("disconnected", "manual");
|
|
142
|
+
}
|
|
143
|
+
// ─── Internal ──────────────────────────────────────
|
|
144
|
+
async subscribe() {
|
|
145
|
+
if (!this.client || this._stopped)
|
|
146
|
+
return;
|
|
147
|
+
try {
|
|
148
|
+
this.stream = await this.client.subscribe();
|
|
149
|
+
}
|
|
150
|
+
catch (err) {
|
|
151
|
+
this.emit("error", err instanceof Error ? err : new Error(String(err)));
|
|
152
|
+
await this.maybeReconnect();
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
// Build the subscription request
|
|
156
|
+
const request = {
|
|
157
|
+
accounts: {},
|
|
158
|
+
slots: {},
|
|
159
|
+
transactions: {
|
|
160
|
+
sap: {
|
|
161
|
+
vote: false,
|
|
162
|
+
failed: this.config.includeFailedTxs,
|
|
163
|
+
signature: undefined,
|
|
164
|
+
accountInclude: [this.config.programId],
|
|
165
|
+
accountExclude: [],
|
|
166
|
+
accountRequired: [],
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
transactionsStatus: {},
|
|
170
|
+
blocks: {},
|
|
171
|
+
blocksMeta: {},
|
|
172
|
+
entry: {},
|
|
173
|
+
commitment: COMMITMENT_MAP[this.config.commitment] ?? 1,
|
|
174
|
+
accountsDataSlice: [],
|
|
175
|
+
ping: { id: 1 },
|
|
176
|
+
};
|
|
177
|
+
// Send subscription
|
|
178
|
+
try {
|
|
179
|
+
await new Promise((resolve, reject) => {
|
|
180
|
+
this.stream.write(request, (err) => {
|
|
181
|
+
if (err)
|
|
182
|
+
reject(err);
|
|
183
|
+
else
|
|
184
|
+
resolve();
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
catch (err) {
|
|
189
|
+
this.emit("error", err instanceof Error ? err : new Error(String(err)));
|
|
190
|
+
await this.maybeReconnect();
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
this._connected = true;
|
|
194
|
+
this.reconnectAttempts = 0;
|
|
195
|
+
this.emit("connected");
|
|
196
|
+
// Listen for data
|
|
197
|
+
this.stream.on("data", (data) => {
|
|
198
|
+
try {
|
|
199
|
+
this.handleMessage(data);
|
|
200
|
+
}
|
|
201
|
+
catch (err) {
|
|
202
|
+
this.emit("error", err instanceof Error ? err : new Error(String(err)));
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
this.stream.on("error", (err) => {
|
|
206
|
+
this.emit("error", err);
|
|
207
|
+
});
|
|
208
|
+
this.stream.on("end", () => {
|
|
209
|
+
this._connected = false;
|
|
210
|
+
this.emit("disconnected", "stream-end");
|
|
211
|
+
this.maybeReconnect();
|
|
212
|
+
});
|
|
213
|
+
this.stream.on("close", () => {
|
|
214
|
+
this._connected = false;
|
|
215
|
+
this.emit("disconnected", "stream-close");
|
|
216
|
+
this.maybeReconnect();
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
handleMessage(data) {
|
|
220
|
+
// Respond to pings to keep the stream alive
|
|
221
|
+
if (data.ping) {
|
|
222
|
+
this.stream?.write({ ping: { id: data.ping.id } }, () => { });
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
// Extract transaction data
|
|
226
|
+
const tx = data.transaction;
|
|
227
|
+
if (!tx?.transaction?.transaction)
|
|
228
|
+
return;
|
|
229
|
+
const meta = tx.transaction.meta;
|
|
230
|
+
if (!meta)
|
|
231
|
+
return;
|
|
232
|
+
// Extract log messages from the transaction meta
|
|
233
|
+
const logs = meta.logMessages ?? [];
|
|
234
|
+
if (logs.length === 0)
|
|
235
|
+
return;
|
|
236
|
+
const signature = tx.transaction.signature
|
|
237
|
+
? Buffer.from(tx.transaction.signature).toString("base64")
|
|
238
|
+
: "unknown";
|
|
239
|
+
const slot = Number(tx.slot ?? 0);
|
|
240
|
+
this.emit("logs", logs, signature, slot);
|
|
241
|
+
}
|
|
242
|
+
async maybeReconnect() {
|
|
243
|
+
if (this._stopped || !this.config.autoReconnect)
|
|
244
|
+
return;
|
|
245
|
+
const max = this.config.maxReconnectAttempts;
|
|
246
|
+
if (max > 0 && this.reconnectAttempts >= max) {
|
|
247
|
+
this.emit("error", new Error(`Max reconnect attempts (${max}) exceeded`));
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
this.reconnectAttempts++;
|
|
251
|
+
this.emit("reconnecting", this.reconnectAttempts);
|
|
252
|
+
await new Promise((r) => setTimeout(r, this.config.reconnectDelayMs));
|
|
253
|
+
if (!this._stopped) {
|
|
254
|
+
await this.subscribe();
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
//# sourceMappingURL=geyser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geyser.js","sourceRoot":"","sources":["../../../src/events/geyser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AA+EtC,sEAAsE;AACtE,aAAa;AACb,sEAA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,EAAE,CAAC;YAC7C,IAAI,CAAC,IAAI,CACP,OAAO,EACP,IAAI,KAAK,CAAC,2BAA2B,GAAG,YAAY,CAAC,CACtD,CAAC;YACF,OAAO;QACT,CAAC;QAED,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAElD,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC;QAEtE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnB,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;QACzB,CAAC;IACH,CAAC;CACF"}
|
package/dist/esm/index.js
CHANGED
|
@@ -63,10 +63,14 @@ export { validateEndpoint, validateEndpointDescriptor, validateHealthCheck, vali
|
|
|
63
63
|
export { getRpcUrl, getFallbackRpcUrl, createDualConnection, findATA, classifyAnchorError, extractAnchorErrorCode, } from "./utils";
|
|
64
64
|
// v0.6.0 — Zod runtime schemas
|
|
65
65
|
export { createEnvSchema, createEndpointDescriptorSchema, createHealthCheckSchema, createToolManifestEntrySchema, createAgentManifestSchema, createPreparePaymentSchema, createRegisterAgentSchema, createCallArgsSchema, validateOrThrow, } from "./utils";
|
|
66
|
+
// v0.6.2 — Priority fee & settle options
|
|
67
|
+
export { buildPriorityFeeIxs, buildRpcOptions, FAST_SETTLE_OPTIONS, FAST_BATCH_SETTLE_OPTIONS, DEFAULT_SETTLE_PRIORITY_FEE, DEFAULT_SETTLE_COMPUTE_UNITS, DEFAULT_BATCH_SETTLE_COMPUTE_UNITS, } from "./utils";
|
|
66
68
|
// ── Errors ───────────────────────────────────────────
|
|
67
69
|
export { SapError, SapValidationError, SapRpcError, SapAccountNotFoundError, SapTimeoutError, SapPermissionError, } from "./errors";
|
|
68
70
|
// ── Events ───────────────────────────────────────────
|
|
69
71
|
export { EventParser, SAP_EVENT_NAMES } from "./events";
|
|
72
|
+
// ── Geyser (Yellowstone gRPC) ────────────────────────
|
|
73
|
+
export { GeyserEventStream } from "./events/geyser";
|
|
70
74
|
// ── Modules (for advanced usage / tree-shaking) ──────
|
|
71
75
|
export { AgentModule, FeedbackModule, IndexingModule, ToolsModule, VaultModule, EscrowModule, AttestationModule, LedgerModule, BaseModule, } from "./modules/index";
|
|
72
76
|
// ── Plugin (SynapseAgentKit integration) ─────────────
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,wDAAwD;AACxD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AA0DjE,OAAO,EACL,SAAS,EACT,UAAU,EACV,cAAc,EACd,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,UAAU,EACV,eAAe,GAChB,MAAM,SAAS,CAAC;AAEjB,wDAAwD;AACxD,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,KAAK,EACL,MAAM,EACN,aAAa,EACb,sBAAsB,EACtB,oBAAoB,EACpB,kBAAkB,EAClB,UAAU,GACX,MAAM,aAAa,CAAC;AAGrB,wDAAwD;AACxD,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGzE,wDAAwD;AACxD,OAAO,EACL,oBAAoB,EACpB,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACrB,mBAAmB,EACnB,uBAAuB,EACvB,WAAW,EACX,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,UAAU,EACV,YAAY,EACZ,iBAAiB,EACjB,Y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AA4D;AAC5D,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAevE,0DAA0D;AAC1D,OAAO,EACL,mCAAmC,EACnC,uCAAuC,EACvC,4BAA4B,EAC5B,gCAAgC,EAChC,sBAAsB,EACtB,2BAA2B,EAC3B,wBAAwB,EACxB,uBAAuB,EACvB,0BAA0B,EAC1B,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,UAAU,CAAC;AAWlB,yDAAyD;AACzD,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,YAAY,GACb,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,wDAAwD;AACxD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AA0DjE,OAAO,EACL,SAAS,EACT,UAAU,EACV,cAAc,EACd,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,UAAU,EACV,eAAe,GAChB,MAAM,SAAS,CAAC;AAEjB,wDAAwD;AACxD,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,KAAK,EACL,MAAM,EACN,aAAa,EACb,sBAAsB,EACtB,oBAAoB,EACpB,kBAAkB,EAClB,UAAU,GACX,MAAM,aAAa,CAAC;AAGrB,wDAAwD;AACxD,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGzE,wDAAwD;AACxD,OAAO,EACL,oBAAoB,EACpB,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACrB,mBAAmB,EACnB,uBAAuB,EACvB,WAAW,EACX,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,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EACX,cAAc,EACd,cAAc,EACd,WAAW,EACX,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,UAAU,GACX,MAAM,iBAAiB,CAAC;AAGzB,wDAAwD;AACxD,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAY5D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,4DAA4D;AAC5D,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAevE,0DAA0D;AAC1D,OAAO,EACL,mCAAmC,EACnC,uCAAuC,EACvC,4BAA4B,EAC5B,gCAAgC,EAChC,sBAAsB,EACtB,2BAA2B,EAC3B,wBAAwB,EACxB,uBAAuB,EACvB,0BAA0B,EAC1B,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,UAAU,CAAC;AAWlB,yDAAyD;AACzD,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,YAAY,GACb,MAAM,oBAAoB,CAAC"}
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
import { SystemProgram, } from "@solana/web3.js";
|
|
14
14
|
import { BaseModule } from "./base";
|
|
15
15
|
import { deriveAgent, deriveAgentStats, deriveEscrow, } from "../pda";
|
|
16
|
+
import { buildPriorityFeeIxs, buildRpcOptions, } from "../utils/priority-fee";
|
|
16
17
|
/**
|
|
17
18
|
* @name EscrowModule
|
|
18
19
|
* @description Manages x402-compatible escrow accounts for agent micropayments.
|
|
@@ -114,14 +115,18 @@ export class EscrowModule extends BaseModule {
|
|
|
114
115
|
* @param callsToSettle - Number of calls to settle payment for.
|
|
115
116
|
* @param serviceHash - A 32-byte SHA-256 hash identifying the service rendered.
|
|
116
117
|
* @param splAccounts - Remaining accounts for SPL token transfers. Defaults to `[]`.
|
|
118
|
+
* @param opts - Optional {@link SettleOptions} for priority fees and RPC tuning.
|
|
117
119
|
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
118
120
|
* @since v0.1.0
|
|
121
|
+
* @updated v0.6.2 — Added optional `opts` parameter for priority fees.
|
|
119
122
|
*/
|
|
120
|
-
async settle(depositorWallet, callsToSettle, serviceHash, splAccounts = []) {
|
|
123
|
+
async settle(depositorWallet, callsToSettle, serviceHash, splAccounts = [], opts) {
|
|
121
124
|
const [agentPda] = deriveAgent(this.walletPubkey);
|
|
122
125
|
const [escrowPda] = deriveEscrow(agentPda, depositorWallet);
|
|
123
126
|
const [statsPda] = deriveAgentStats(agentPda);
|
|
124
|
-
|
|
127
|
+
const preIxs = buildPriorityFeeIxs(opts);
|
|
128
|
+
const rpcOpts = buildRpcOptions(opts);
|
|
129
|
+
let builder = this.methods
|
|
125
130
|
.settleCalls(this.bn(callsToSettle), serviceHash)
|
|
126
131
|
.accounts({
|
|
127
132
|
wallet: this.walletPubkey,
|
|
@@ -130,8 +135,11 @@ export class EscrowModule extends BaseModule {
|
|
|
130
135
|
escrow: escrowPda,
|
|
131
136
|
systemProgram: SystemProgram.programId,
|
|
132
137
|
})
|
|
133
|
-
.remainingAccounts(splAccounts)
|
|
134
|
-
|
|
138
|
+
.remainingAccounts(splAccounts);
|
|
139
|
+
if (preIxs.length > 0) {
|
|
140
|
+
builder = builder.preInstructions(preIxs);
|
|
141
|
+
}
|
|
142
|
+
return builder.rpc(rpcOpts);
|
|
135
143
|
}
|
|
136
144
|
/**
|
|
137
145
|
* @name withdraw
|
|
@@ -180,14 +188,18 @@ export class EscrowModule extends BaseModule {
|
|
|
180
188
|
* @param depositorWallet - The wallet of the client who funded the escrow.
|
|
181
189
|
* @param settlements - Array of settlement entries (up to 10).
|
|
182
190
|
* @param splAccounts - Remaining accounts for SPL token transfers. Defaults to `[]`.
|
|
191
|
+
* @param opts - Optional {@link SettleOptions} for priority fees and RPC tuning.
|
|
183
192
|
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
184
193
|
* @since v0.1.0
|
|
194
|
+
* @updated v0.6.2 — Added optional `opts` parameter for priority fees.
|
|
185
195
|
*/
|
|
186
|
-
async settleBatch(depositorWallet, settlements, splAccounts = []) {
|
|
196
|
+
async settleBatch(depositorWallet, settlements, splAccounts = [], opts) {
|
|
187
197
|
const [agentPda] = deriveAgent(this.walletPubkey);
|
|
188
198
|
const [escrowPda] = deriveEscrow(agentPda, depositorWallet);
|
|
189
199
|
const [statsPda] = deriveAgentStats(agentPda);
|
|
190
|
-
|
|
200
|
+
const preIxs = buildPriorityFeeIxs(opts);
|
|
201
|
+
const rpcOpts = buildRpcOptions(opts);
|
|
202
|
+
let builder = this.methods
|
|
191
203
|
.settleBatch(settlements)
|
|
192
204
|
.accounts({
|
|
193
205
|
wallet: this.walletPubkey,
|
|
@@ -196,8 +208,11 @@ export class EscrowModule extends BaseModule {
|
|
|
196
208
|
escrow: escrowPda,
|
|
197
209
|
systemProgram: SystemProgram.programId,
|
|
198
210
|
})
|
|
199
|
-
.remainingAccounts(splAccounts)
|
|
200
|
-
|
|
211
|
+
.remainingAccounts(splAccounts);
|
|
212
|
+
if (preIxs.length > 0) {
|
|
213
|
+
builder = builder.preInstructions(preIxs);
|
|
214
|
+
}
|
|
215
|
+
return builder.rpc(rpcOpts);
|
|
201
216
|
}
|
|
202
217
|
// ── Fetchers ─────────────────────────────────────────
|
|
203
218
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"escrow.js","sourceRoot":"","sources":["../../../src/modules/escrow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,aAAa,GAId,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,YAAY,GACb,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"escrow.js","sourceRoot":"","sources":["../../../src/modules/escrow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,aAAa,GAId,MAAM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AAG,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QACrD,OAAO,IAAI,CAAC,oBAAoB,CAAoB,eAAe,EAAE,GAAG,CAAC,CAAC;IAC5E,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,UAAU,CAAC,SAAoB;QACnC,OAAO,IAAI,CAAC,YAAY,CAAoB,eAAe,EAAE,SAAS,CAAC,CAAC;IAC1E,CAAC;CACF"}
|
package/dist/esm/plugin/index.js
CHANGED
|
@@ -560,7 +560,15 @@ async function executeEscrow(client, name, input) {
|
|
|
560
560
|
return { txSignature: tx };
|
|
561
561
|
}
|
|
562
562
|
case "settleEscrow": {
|
|
563
|
-
|
|
563
|
+
// Build settle options from optional priority fee fields
|
|
564
|
+
const settleOpts = (input.priorityFeeMicroLamports || input.computeUnits || input.skipPreflight)
|
|
565
|
+
? {
|
|
566
|
+
priorityFeeMicroLamports: input.priorityFeeMicroLamports ?? undefined,
|
|
567
|
+
computeUnits: input.computeUnits ?? undefined,
|
|
568
|
+
skipPreflight: input.skipPreflight ?? undefined,
|
|
569
|
+
}
|
|
570
|
+
: undefined;
|
|
571
|
+
const tx = await client.escrow.settle(new PublicKey(input.depositorWallet), new BN(input.callsToSettle), input.serviceHash, [], settleOpts);
|
|
564
572
|
return { txSignature: tx };
|
|
565
573
|
}
|
|
566
574
|
case "withdrawEscrow": {
|
|
@@ -574,7 +582,15 @@ async function executeEscrow(client, name, input) {
|
|
|
574
582
|
callsToSettle: new BN(s.callsToSettle),
|
|
575
583
|
serviceHash: s.serviceHash,
|
|
576
584
|
}));
|
|
577
|
-
|
|
585
|
+
// Build settle options from optional priority fee fields
|
|
586
|
+
const batchOpts = (input.priorityFeeMicroLamports || input.computeUnits || input.skipPreflight)
|
|
587
|
+
? {
|
|
588
|
+
priorityFeeMicroLamports: input.priorityFeeMicroLamports ?? undefined,
|
|
589
|
+
computeUnits: input.computeUnits ?? undefined,
|
|
590
|
+
skipPreflight: input.skipPreflight ?? undefined,
|
|
591
|
+
}
|
|
592
|
+
: undefined;
|
|
593
|
+
const tx = await client.escrow.settleBatch(new PublicKey(input.depositorWallet), settlements, [], batchOpts);
|
|
578
594
|
return { txSignature: tx };
|
|
579
595
|
}
|
|
580
596
|
case "fetchEscrow": {
|