@oobe-protocol-labs/synapse-sap-sdk 0.7.0 → 0.9.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/cjs/constants/seeds.js +2 -0
- package/dist/cjs/constants/seeds.js.map +1 -1
- package/dist/cjs/core/client.js +44 -0
- package/dist/cjs/core/client.js.map +1 -1
- package/dist/cjs/idl/synapse_agent_sap.json +1050 -629
- package/dist/cjs/index.js +8 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/modules/escrow-v2.js +17 -38
- package/dist/cjs/modules/escrow-v2.js.map +1 -1
- package/dist/cjs/modules/index.js +3 -1
- package/dist/cjs/modules/index.js.map +1 -1
- package/dist/cjs/modules/receipt.js +144 -0
- package/dist/cjs/modules/receipt.js.map +1 -0
- package/dist/cjs/pda/index.js +24 -1
- package/dist/cjs/pda/index.js.map +1 -1
- package/dist/cjs/registries/index.js +3 -1
- package/dist/cjs/registries/index.js.map +1 -1
- package/dist/cjs/registries/metaplex-bridge.js +446 -0
- package/dist/cjs/registries/metaplex-bridge.js.map +1 -0
- package/dist/cjs/types/enums.js +47 -2
- package/dist/cjs/types/enums.js.map +1 -1
- package/dist/cjs/types/index.js +3 -1
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/esm/constants/seeds.js +2 -0
- package/dist/esm/constants/seeds.js.map +1 -1
- package/dist/esm/core/client.js +44 -0
- package/dist/esm/core/client.js.map +1 -1
- package/dist/esm/idl/synapse_agent_sap.json +1050 -629
- package/dist/esm/index.js +4 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/modules/escrow-v2.js +18 -39
- package/dist/esm/modules/escrow-v2.js.map +1 -1
- package/dist/esm/modules/index.js +1 -0
- package/dist/esm/modules/index.js.map +1 -1
- package/dist/esm/modules/receipt.js +140 -0
- package/dist/esm/modules/receipt.js.map +1 -0
- package/dist/esm/pda/index.js +22 -0
- package/dist/esm/pda/index.js.map +1 -1
- package/dist/esm/registries/index.js +1 -0
- package/dist/esm/registries/index.js.map +1 -1
- package/dist/esm/registries/metaplex-bridge.js +409 -0
- package/dist/esm/registries/metaplex-bridge.js.map +1 -0
- package/dist/esm/types/enums.js +46 -1
- package/dist/esm/types/enums.js.map +1 -1
- package/dist/esm/types/index.js +1 -1
- package/dist/esm/types/index.js.map +1 -1
- package/dist/types/constants/seeds.d.ts +2 -0
- package/dist/types/constants/seeds.d.ts.map +1 -1
- package/dist/types/core/client.d.ts +38 -0
- package/dist/types/core/client.d.ts.map +1 -1
- package/dist/types/index.d.ts +6 -6
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modules/escrow-v2.d.ts +13 -6
- package/dist/types/modules/escrow-v2.d.ts.map +1 -1
- package/dist/types/modules/index.d.ts +1 -0
- package/dist/types/modules/index.d.ts.map +1 -1
- package/dist/types/modules/receipt.d.ts +77 -0
- package/dist/types/modules/receipt.d.ts.map +1 -0
- package/dist/types/pda/index.d.ts +15 -0
- package/dist/types/pda/index.d.ts.map +1 -1
- package/dist/types/registries/index.d.ts +2 -0
- package/dist/types/registries/index.d.ts.map +1 -1
- package/dist/types/registries/metaplex-bridge.d.ts +228 -0
- package/dist/types/registries/metaplex-bridge.d.ts.map +1 -0
- package/dist/types/types/accounts.d.ts +46 -2
- package/dist/types/types/accounts.d.ts.map +1 -1
- package/dist/types/types/enums.d.ts +52 -1
- package/dist/types/types/enums.d.ts.map +1 -1
- package/dist/types/types/index.d.ts +3 -3
- package/dist/types/types/index.d.ts.map +1 -1
- package/package.json +26 -6
- package/src/constants/seeds.ts +2 -0
- package/src/core/client.ts +46 -0
- package/src/idl/synapse_agent_sap.json +1050 -629
- package/src/index.ts +14 -0
- package/src/modules/escrow-v2.ts +21 -42
- package/src/modules/index.ts +1 -0
- package/src/modules/receipt.ts +207 -0
- package/src/pda/index.ts +32 -0
- package/src/registries/index.ts +10 -0
- package/src/registries/metaplex-bridge.ts +645 -0
- package/src/types/accounts.ts +51 -2
- package/src/types/enums.ts +55 -1
- package/src/types/index.ts +5 -0
package/src/index.ts
CHANGED
|
@@ -62,6 +62,8 @@ export type {
|
|
|
62
62
|
SettlementSecurityKind,
|
|
63
63
|
DisputeOutcomeKind,
|
|
64
64
|
BillingIntervalKind,
|
|
65
|
+
DisputeTypeValue,
|
|
66
|
+
ResolutionLayerKind,
|
|
65
67
|
// Helper structs
|
|
66
68
|
Capability,
|
|
67
69
|
VolumeCurveBreakpoint,
|
|
@@ -90,6 +92,7 @@ export type {
|
|
|
90
92
|
EscrowAccountV2Data,
|
|
91
93
|
PendingSettlementData,
|
|
92
94
|
DisputeRecordData,
|
|
95
|
+
ReceiptBatchData,
|
|
93
96
|
AgentStakeData,
|
|
94
97
|
SubscriptionData,
|
|
95
98
|
CounterShardData,
|
|
@@ -129,6 +132,8 @@ export {
|
|
|
129
132
|
SettlementSecurity,
|
|
130
133
|
DisputeOutcome,
|
|
131
134
|
BillingInterval,
|
|
135
|
+
DisputeType,
|
|
136
|
+
ResolutionLayer,
|
|
132
137
|
} from "./types";
|
|
133
138
|
|
|
134
139
|
// ── Constants ────────────────────────────────────────
|
|
@@ -178,6 +183,7 @@ export {
|
|
|
178
183
|
deriveAttestation,
|
|
179
184
|
deriveLedger,
|
|
180
185
|
deriveLedgerPage,
|
|
186
|
+
deriveReceiptBatch,
|
|
181
187
|
} from "./pda";
|
|
182
188
|
|
|
183
189
|
// ── Utilities ────────────────────────────────────────
|
|
@@ -297,6 +303,7 @@ export {
|
|
|
297
303
|
VaultModule,
|
|
298
304
|
EscrowModule,
|
|
299
305
|
EscrowV2Module,
|
|
306
|
+
ReceiptModule,
|
|
300
307
|
StakingModule,
|
|
301
308
|
SubscriptionModule,
|
|
302
309
|
AttestationModule,
|
|
@@ -366,6 +373,7 @@ export {
|
|
|
366
373
|
X402Registry,
|
|
367
374
|
SessionManager,
|
|
368
375
|
AgentBuilder,
|
|
376
|
+
MetaplexBridge,
|
|
369
377
|
} from "./registries/index";
|
|
370
378
|
export type {
|
|
371
379
|
DiscoveredAgent,
|
|
@@ -391,4 +399,10 @@ export type {
|
|
|
391
399
|
ToolInput,
|
|
392
400
|
RegisterResult,
|
|
393
401
|
RegisterWithToolsResult,
|
|
402
|
+
UnifiedProfile,
|
|
403
|
+
MplAgentSnapshot,
|
|
404
|
+
Eip8004Registration,
|
|
405
|
+
Eip8004Service,
|
|
406
|
+
AttachAgentIdentityOpts,
|
|
407
|
+
UpdateAgentIdentityUriOpts,
|
|
394
408
|
} from "./registries/index";
|
package/src/modules/escrow-v2.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module escrow-v2
|
|
3
3
|
* @description V2 escrow settlement layer — supports settlement security
|
|
4
|
-
* modes (
|
|
5
|
-
* pending settlements, and
|
|
4
|
+
* modes (CoSigned, DisputeWindow), receipt-based dispute resolution,
|
|
5
|
+
* pending settlements, and automatic resolution via merkle proofs.
|
|
6
6
|
*
|
|
7
7
|
* @category Modules
|
|
8
8
|
* @since v0.7.0
|
|
@@ -20,7 +20,6 @@ import { BaseModule } from "./base";
|
|
|
20
20
|
import {
|
|
21
21
|
deriveAgent,
|
|
22
22
|
deriveAgentStats,
|
|
23
|
-
deriveEscrow,
|
|
24
23
|
deriveEscrowV2,
|
|
25
24
|
derivePendingSettlement as derivePendingPda,
|
|
26
25
|
deriveDispute as deriveDisputePda,
|
|
@@ -173,6 +172,7 @@ export class EscrowV2Module extends BaseModule {
|
|
|
173
172
|
callsToSettle: BN | number | bigint,
|
|
174
173
|
amount: BN | number | bigint,
|
|
175
174
|
serviceHash: number[],
|
|
175
|
+
receiptMerkleRoot: number[] = new Array(32).fill(0),
|
|
176
176
|
): Promise<TransactionSignature> {
|
|
177
177
|
const [agentPda] = deriveAgent(agentWallet);
|
|
178
178
|
const [escrowPda] = this.deriveEscrow(agentPda, depositorWallet, nonce);
|
|
@@ -184,6 +184,7 @@ export class EscrowV2Module extends BaseModule {
|
|
|
184
184
|
this.bn(callsToSettle),
|
|
185
185
|
this.bn(amount),
|
|
186
186
|
serviceHash,
|
|
187
|
+
receiptMerkleRoot,
|
|
187
188
|
)
|
|
188
189
|
.accounts({
|
|
189
190
|
wallet: this.walletPubkey,
|
|
@@ -223,6 +224,7 @@ export class EscrowV2Module extends BaseModule {
|
|
|
223
224
|
nonce: BN | number | bigint,
|
|
224
225
|
settlementIndex: BN | number | bigint,
|
|
225
226
|
evidenceHash: number[],
|
|
227
|
+
disputeType: number = 0,
|
|
226
228
|
): Promise<TransactionSignature> {
|
|
227
229
|
const [agentPda] = deriveAgent(agentWallet);
|
|
228
230
|
const [escrowPda] = this.deriveEscrow(agentPda, undefined, nonce);
|
|
@@ -230,7 +232,7 @@ export class EscrowV2Module extends BaseModule {
|
|
|
230
232
|
const [disputePda] = this.deriveDispute(pendingPda);
|
|
231
233
|
|
|
232
234
|
return this.methods
|
|
233
|
-
.fileDispute(evidenceHash)
|
|
235
|
+
.fileDispute(evidenceHash, disputeType)
|
|
234
236
|
.accounts({
|
|
235
237
|
depositor: this.walletPubkey,
|
|
236
238
|
escrow: escrowPda,
|
|
@@ -241,31 +243,18 @@ export class EscrowV2Module extends BaseModule {
|
|
|
241
243
|
.rpc();
|
|
242
244
|
}
|
|
243
245
|
|
|
246
|
+
/**
|
|
247
|
+
* @deprecated Since v0.7.0 — Arbiter-based resolution removed.
|
|
248
|
+
* Use {@link ReceiptModule.submitReceiptProof} + {@link ReceiptModule.autoResolveDispute} instead.
|
|
249
|
+
*/
|
|
244
250
|
async resolveDispute(
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
251
|
+
_depositorWallet: PublicKey,
|
|
252
|
+
_agentWallet: PublicKey,
|
|
253
|
+
_nonce: BN | number | bigint,
|
|
254
|
+
_settlementIndex: BN | number | bigint,
|
|
255
|
+
_outcome: number,
|
|
250
256
|
): Promise<TransactionSignature> {
|
|
251
|
-
|
|
252
|
-
const [escrowPda] = this.deriveEscrow(agentPda, depositorWallet, nonce);
|
|
253
|
-
const [pendingPda] = this.derivePendingSettlement(escrowPda, settlementIndex);
|
|
254
|
-
const [disputePda] = this.deriveDispute(pendingPda);
|
|
255
|
-
const [statsPda] = deriveAgentStats(agentPda);
|
|
256
|
-
|
|
257
|
-
return this.methods
|
|
258
|
-
.resolveDispute(outcome)
|
|
259
|
-
.accounts({
|
|
260
|
-
arbiter: this.walletPubkey,
|
|
261
|
-
depositor: depositorWallet,
|
|
262
|
-
agentWallet,
|
|
263
|
-
escrow: escrowPda,
|
|
264
|
-
pendingSettlement: pendingPda,
|
|
265
|
-
dispute: disputePda,
|
|
266
|
-
agentStats: statsPda,
|
|
267
|
-
})
|
|
268
|
-
.rpc();
|
|
257
|
+
throw new Error("resolveDispute removed in v0.7.0 — use ReceiptModule.autoResolveDispute");
|
|
269
258
|
}
|
|
270
259
|
|
|
271
260
|
async closeDispute(
|
|
@@ -327,23 +316,13 @@ export class EscrowV2Module extends BaseModule {
|
|
|
327
316
|
.rpc();
|
|
328
317
|
}
|
|
329
318
|
|
|
319
|
+
/**
|
|
320
|
+
* @deprecated Since v0.7.0 — Migration instruction removed from program.
|
|
321
|
+
*/
|
|
330
322
|
async migrateFromV1(
|
|
331
|
-
|
|
323
|
+
_agentWallet: PublicKey,
|
|
332
324
|
): Promise<TransactionSignature> {
|
|
333
|
-
|
|
334
|
-
const [escrowV1Pda] = deriveEscrow(agentPda, this.walletPubkey);
|
|
335
|
-
const [escrowV2Pda] = this.deriveEscrow(agentPda, undefined, 0);
|
|
336
|
-
|
|
337
|
-
return this.methods
|
|
338
|
-
.migrateEscrowV1ToV2()
|
|
339
|
-
.accounts({
|
|
340
|
-
depositor: this.walletPubkey,
|
|
341
|
-
agent: agentPda,
|
|
342
|
-
escrowV1: escrowV1Pda,
|
|
343
|
-
escrowV2: escrowV2Pda,
|
|
344
|
-
systemProgram: SystemProgram.programId,
|
|
345
|
-
})
|
|
346
|
-
.rpc();
|
|
325
|
+
throw new Error("migrateFromV1 removed in v0.7.0 — migration instruction was deleted");
|
|
347
326
|
}
|
|
348
327
|
|
|
349
328
|
// ── Fetchers ─────────────────────────────────────────
|
package/src/modules/index.ts
CHANGED
|
@@ -19,6 +19,7 @@ export { ToolsModule } from "./tools";
|
|
|
19
19
|
export { VaultModule } from "./vault";
|
|
20
20
|
export { EscrowModule } from "./escrow";
|
|
21
21
|
export { EscrowV2Module } from "./escrow-v2";
|
|
22
|
+
export { ReceiptModule } from "./receipt";
|
|
22
23
|
export { StakingModule } from "./staking";
|
|
23
24
|
export { SubscriptionModule } from "./subscription";
|
|
24
25
|
export { AttestationModule } from "./attestation";
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module receipt
|
|
3
|
+
* @description Receipt-based trustless dispute resolution (v0.7).
|
|
4
|
+
*
|
|
5
|
+
* Agents inscribe merkle roots of call receipt batches on-chain.
|
|
6
|
+
* During disputes, agents submit merkle inclusion proofs to prove delivery.
|
|
7
|
+
* After the proof deadline, anyone can trigger automatic proportional resolution.
|
|
8
|
+
*
|
|
9
|
+
* @category Modules
|
|
10
|
+
* @since v0.7.0
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
SystemProgram,
|
|
16
|
+
type PublicKey,
|
|
17
|
+
type TransactionSignature,
|
|
18
|
+
} from "@solana/web3.js";
|
|
19
|
+
import { BN } from "@coral-xyz/anchor";
|
|
20
|
+
import { BaseModule } from "./base";
|
|
21
|
+
import {
|
|
22
|
+
deriveAgent,
|
|
23
|
+
deriveAgentStats,
|
|
24
|
+
deriveEscrowV2,
|
|
25
|
+
derivePendingSettlement as derivePendingPda,
|
|
26
|
+
deriveDispute as deriveDisputePda,
|
|
27
|
+
deriveReceiptBatch as deriveReceiptPda,
|
|
28
|
+
} from "../pda";
|
|
29
|
+
import type { ReceiptBatchData } from "../types";
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @name ReceiptModule
|
|
33
|
+
* @description Manages receipt batch inscriptions, merkle proof submissions,
|
|
34
|
+
* and automatic dispute resolution for the v0.7 trustless settlement layer.
|
|
35
|
+
*
|
|
36
|
+
* @category Modules
|
|
37
|
+
* @since v0.7.0
|
|
38
|
+
* @extends BaseModule
|
|
39
|
+
*/
|
|
40
|
+
export class ReceiptModule extends BaseModule {
|
|
41
|
+
// ── Helpers ──────────────────────────────────────────
|
|
42
|
+
|
|
43
|
+
private toNum(v: BN | number | bigint): number {
|
|
44
|
+
return BN.isBN(v) ? v.toNumber() : Number(v);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// ── PDA helpers ──────────────────────────────────────
|
|
48
|
+
|
|
49
|
+
deriveReceiptBatch(
|
|
50
|
+
escrowV2Pda: PublicKey,
|
|
51
|
+
batchIndex: number,
|
|
52
|
+
): readonly [PublicKey, number] {
|
|
53
|
+
return deriveReceiptPda(escrowV2Pda, batchIndex);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// ── Instructions ─────────────────────────────────────
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Inscribe a receipt batch merkle root on-chain.
|
|
60
|
+
*
|
|
61
|
+
* Called by the **agent** to commit a cryptographic proof of calls delivered.
|
|
62
|
+
* The `merkleRoot` is the root of a merkle tree whose leaves are individual
|
|
63
|
+
* call receipt hashes.
|
|
64
|
+
*
|
|
65
|
+
* @param depositorWallet - The depositor's wallet (needed for escrow PDA derivation).
|
|
66
|
+
* @param nonce - Escrow nonce.
|
|
67
|
+
* @param batchIndex - Zero-based batch index (must equal escrow.receipt_batch_count).
|
|
68
|
+
* @param merkleRoot - 32-byte merkle root of the receipt batch.
|
|
69
|
+
* @param callCount - Number of calls in the batch.
|
|
70
|
+
* @param periodStart - Unix timestamp for the start of the covered period.
|
|
71
|
+
* @param periodEnd - Unix timestamp for the end of the covered period.
|
|
72
|
+
*/
|
|
73
|
+
async inscribeReceiptBatch(
|
|
74
|
+
depositorWallet: PublicKey,
|
|
75
|
+
nonce: BN | number | bigint,
|
|
76
|
+
batchIndex: number,
|
|
77
|
+
merkleRoot: number[],
|
|
78
|
+
callCount: BN | number | bigint,
|
|
79
|
+
periodStart: BN | number | bigint,
|
|
80
|
+
periodEnd: BN | number | bigint,
|
|
81
|
+
): Promise<TransactionSignature> {
|
|
82
|
+
const [agentPda] = deriveAgent(this.walletPubkey);
|
|
83
|
+
const [escrowPda] = deriveEscrowV2(agentPda, depositorWallet, this.toNum(nonce));
|
|
84
|
+
const [receiptPda] = this.deriveReceiptBatch(escrowPda, batchIndex);
|
|
85
|
+
|
|
86
|
+
return this.methods
|
|
87
|
+
.inscribeReceiptBatch(
|
|
88
|
+
batchIndex,
|
|
89
|
+
merkleRoot,
|
|
90
|
+
this.bn(callCount),
|
|
91
|
+
this.bn(periodStart),
|
|
92
|
+
this.bn(periodEnd),
|
|
93
|
+
)
|
|
94
|
+
.accounts({
|
|
95
|
+
wallet: this.walletPubkey,
|
|
96
|
+
agent: agentPda,
|
|
97
|
+
escrow: escrowPda,
|
|
98
|
+
receiptBatch: receiptPda,
|
|
99
|
+
systemProgram: SystemProgram.programId,
|
|
100
|
+
})
|
|
101
|
+
.rpc();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Submit a merkle inclusion proof during a dispute.
|
|
106
|
+
*
|
|
107
|
+
* Called by the **agent** to prove delivery of specific calls.
|
|
108
|
+
* Each proof verifies that a set of receipt hashes are included
|
|
109
|
+
* in the previously inscribed merkle root.
|
|
110
|
+
*
|
|
111
|
+
* @param depositorWallet - The depositor's wallet.
|
|
112
|
+
* @param nonce - Escrow nonce.
|
|
113
|
+
* @param settlementIndex - Index of the disputed pending settlement.
|
|
114
|
+
* @param batchIndex - Receipt batch index containing the proof.
|
|
115
|
+
* @param provenCount - Number of calls proven in this proof submission.
|
|
116
|
+
* @param proof - Array of 32-byte merkle proof hashes.
|
|
117
|
+
* @param leaf - The 32-byte leaf hash being proven.
|
|
118
|
+
*/
|
|
119
|
+
async submitReceiptProof(
|
|
120
|
+
depositorWallet: PublicKey,
|
|
121
|
+
nonce: BN | number | bigint,
|
|
122
|
+
settlementIndex: BN | number | bigint,
|
|
123
|
+
batchIndex: number,
|
|
124
|
+
provenCount: BN | number | bigint,
|
|
125
|
+
proof: number[][],
|
|
126
|
+
leaf: number[],
|
|
127
|
+
): Promise<TransactionSignature> {
|
|
128
|
+
const [agentPda] = deriveAgent(this.walletPubkey);
|
|
129
|
+
const [escrowPda] = deriveEscrowV2(agentPda, depositorWallet, this.toNum(nonce));
|
|
130
|
+
const [pendingPda] = derivePendingPda(escrowPda, this.toNum(settlementIndex));
|
|
131
|
+
const [disputePda] = deriveDisputePda(pendingPda);
|
|
132
|
+
const [receiptPda] = this.deriveReceiptBatch(escrowPda, batchIndex);
|
|
133
|
+
|
|
134
|
+
return this.methods
|
|
135
|
+
.submitReceiptProof(
|
|
136
|
+
batchIndex,
|
|
137
|
+
this.bn(provenCount),
|
|
138
|
+
proof,
|
|
139
|
+
leaf,
|
|
140
|
+
)
|
|
141
|
+
.accounts({
|
|
142
|
+
wallet: this.walletPubkey,
|
|
143
|
+
agent: agentPda,
|
|
144
|
+
escrow: escrowPda,
|
|
145
|
+
pendingSettlement: pendingPda,
|
|
146
|
+
dispute: disputePda,
|
|
147
|
+
receiptBatch: receiptPda,
|
|
148
|
+
})
|
|
149
|
+
.rpc();
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Trigger automatic dispute resolution after the proof deadline.
|
|
154
|
+
*
|
|
155
|
+
* Permissionless crank — anyone can call this once the deadline has passed.
|
|
156
|
+
* Resolution is proportional: if the agent proved N of M claimed calls,
|
|
157
|
+
* N/M of the settlement amount goes to the agent, the rest is refunded.
|
|
158
|
+
*
|
|
159
|
+
* @param agentWallet - The agent's wallet.
|
|
160
|
+
* @param depositorWallet - The depositor's wallet.
|
|
161
|
+
* @param nonce - Escrow nonce.
|
|
162
|
+
* @param settlementIndex - Index of the disputed pending settlement.
|
|
163
|
+
*/
|
|
164
|
+
async autoResolveDispute(
|
|
165
|
+
agentWallet: PublicKey,
|
|
166
|
+
depositorWallet: PublicKey,
|
|
167
|
+
nonce: BN | number | bigint,
|
|
168
|
+
settlementIndex: BN | number | bigint,
|
|
169
|
+
): Promise<TransactionSignature> {
|
|
170
|
+
const [agentPda] = deriveAgent(agentWallet);
|
|
171
|
+
const [escrowPda] = deriveEscrowV2(agentPda, depositorWallet, this.toNum(nonce));
|
|
172
|
+
const [pendingPda] = derivePendingPda(escrowPda, this.toNum(settlementIndex));
|
|
173
|
+
const [disputePda] = deriveDisputePda(pendingPda);
|
|
174
|
+
const [statsPda] = deriveAgentStats(agentPda);
|
|
175
|
+
|
|
176
|
+
return this.methods
|
|
177
|
+
.autoResolveDispute()
|
|
178
|
+
.accounts({
|
|
179
|
+
payer: this.walletPubkey,
|
|
180
|
+
depositor: depositorWallet,
|
|
181
|
+
agentWallet,
|
|
182
|
+
escrow: escrowPda,
|
|
183
|
+
pendingSettlement: pendingPda,
|
|
184
|
+
dispute: disputePda,
|
|
185
|
+
agentStats: statsPda,
|
|
186
|
+
})
|
|
187
|
+
.rpc();
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// ── Fetchers ─────────────────────────────────────────
|
|
191
|
+
|
|
192
|
+
async fetchReceiptBatch(
|
|
193
|
+
escrowV2Pda: PublicKey,
|
|
194
|
+
batchIndex: number,
|
|
195
|
+
): Promise<ReceiptBatchData> {
|
|
196
|
+
const [pda] = this.deriveReceiptBatch(escrowV2Pda, batchIndex);
|
|
197
|
+
return this.fetchAccount<ReceiptBatchData>("receiptBatch", pda);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
async fetchReceiptBatchNullable(
|
|
201
|
+
escrowV2Pda: PublicKey,
|
|
202
|
+
batchIndex: number,
|
|
203
|
+
): Promise<ReceiptBatchData | null> {
|
|
204
|
+
const [pda] = this.deriveReceiptBatch(escrowV2Pda, batchIndex);
|
|
205
|
+
return this.fetchAccountNullable<ReceiptBatchData>("receiptBatch", pda);
|
|
206
|
+
}
|
|
207
|
+
}
|
package/src/pda/index.ts
CHANGED
|
@@ -846,3 +846,35 @@ export const deriveIndexPage = (
|
|
|
846
846
|
],
|
|
847
847
|
programId,
|
|
848
848
|
);
|
|
849
|
+
|
|
850
|
+
// ═════════════════════════════════════════════
|
|
851
|
+
// Receipt Batch (v0.7)
|
|
852
|
+
// ═════════════════════════════════════════════
|
|
853
|
+
|
|
854
|
+
/**
|
|
855
|
+
* Derive the **ReceiptBatch** PDA.
|
|
856
|
+
*
|
|
857
|
+
* Seeds: `["sap_receipt", escrow_v2_pda, batch_index_u32_le]`
|
|
858
|
+
*
|
|
859
|
+
* @name deriveReceiptBatch
|
|
860
|
+
* @description Computes the receipt batch PDA storing a merkle root of call receipts.
|
|
861
|
+
* @param escrowV2Pda - The parent V2 escrow PDA.
|
|
862
|
+
* @param batchIndex - Zero-based batch index (u32).
|
|
863
|
+
* @param programId - Override program ID.
|
|
864
|
+
* @returns {PdaResult} `[pda, bump]` tuple.
|
|
865
|
+
* @category PDA
|
|
866
|
+
* @since v0.7.0
|
|
867
|
+
*/
|
|
868
|
+
export const deriveReceiptBatch = (
|
|
869
|
+
escrowV2Pda: PublicKey,
|
|
870
|
+
batchIndex: number,
|
|
871
|
+
programId = SAP_PROGRAM_ID,
|
|
872
|
+
): PdaResult =>
|
|
873
|
+
findPda(
|
|
874
|
+
[
|
|
875
|
+
toSeedBuf(SEEDS.RECEIPT),
|
|
876
|
+
escrowV2Pda.toBuffer(),
|
|
877
|
+
u32le(batchIndex),
|
|
878
|
+
],
|
|
879
|
+
programId,
|
|
880
|
+
);
|
package/src/registries/index.ts
CHANGED
|
@@ -76,3 +76,13 @@ export type {
|
|
|
76
76
|
RegisterResult,
|
|
77
77
|
RegisterWithToolsResult,
|
|
78
78
|
} from "./builder";
|
|
79
|
+
|
|
80
|
+
export { MetaplexBridge } from "./metaplex-bridge";
|
|
81
|
+
export type {
|
|
82
|
+
UnifiedProfile,
|
|
83
|
+
MplAgentSnapshot,
|
|
84
|
+
Eip8004Registration,
|
|
85
|
+
Eip8004Service,
|
|
86
|
+
AttachAgentIdentityOpts,
|
|
87
|
+
UpdateAgentIdentityUriOpts,
|
|
88
|
+
} from "./metaplex-bridge";
|