@oobe-protocol-labs/synapse-sap-sdk 0.9.3 → 0.10.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/index.js +9 -1
- package/dist/cjs/constants/index.js.map +1 -1
- package/dist/cjs/constants/payments.js +87 -0
- package/dist/cjs/constants/payments.js.map +1 -0
- package/dist/cjs/constants/seeds.js +9 -1
- package/dist/cjs/constants/seeds.js.map +1 -1
- package/dist/cjs/idl/synapse_agent_sap.json +270 -2
- package/dist/cjs/index.js +13 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/modules/escrow-v2.js +10 -0
- package/dist/cjs/modules/escrow-v2.js.map +1 -1
- package/dist/cjs/modules/escrow.js +29 -4
- package/dist/cjs/modules/escrow.js.map +1 -1
- package/dist/cjs/pda/index.js +31 -1
- package/dist/cjs/pda/index.js.map +1 -1
- package/dist/cjs/plugin/index.js +3 -1
- package/dist/cjs/plugin/index.js.map +1 -1
- package/dist/cjs/utils/hash.js +52 -1
- package/dist/cjs/utils/hash.js.map +1 -1
- package/dist/cjs/utils/index.js +2 -1
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/esm/constants/index.js +2 -0
- package/dist/esm/constants/index.js.map +1 -1
- package/dist/esm/constants/payments.js +82 -0
- package/dist/esm/constants/payments.js.map +1 -0
- package/dist/esm/constants/seeds.js +9 -1
- package/dist/esm/constants/seeds.js.map +1 -1
- package/dist/esm/idl/synapse_agent_sap.json +270 -2
- package/dist/esm/index.js +4 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/modules/escrow-v2.js +11 -1
- package/dist/esm/modules/escrow-v2.js.map +1 -1
- package/dist/esm/modules/escrow.js +30 -5
- package/dist/esm/modules/escrow.js.map +1 -1
- package/dist/esm/pda/index.js +29 -0
- package/dist/esm/pda/index.js.map +1 -1
- package/dist/esm/plugin/index.js +3 -1
- package/dist/esm/plugin/index.js.map +1 -1
- package/dist/esm/utils/hash.js +50 -0
- package/dist/esm/utils/hash.js.map +1 -1
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/types/constants/index.d.ts +1 -0
- package/dist/types/constants/index.d.ts.map +1 -1
- package/dist/types/constants/payments.d.ts +78 -0
- package/dist/types/constants/payments.d.ts.map +1 -0
- package/dist/types/constants/seeds.d.ts +9 -1
- package/dist/types/constants/seeds.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modules/escrow-v2.d.ts.map +1 -1
- package/dist/types/modules/escrow.d.ts +9 -1
- package/dist/types/modules/escrow.d.ts.map +1 -1
- package/dist/types/pda/index.d.ts +21 -0
- package/dist/types/pda/index.d.ts.map +1 -1
- package/dist/types/plugin/index.d.ts.map +1 -1
- package/dist/types/utils/hash.d.ts +27 -0
- package/dist/types/utils/hash.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types/utils/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/constants/index.ts +11 -1
- package/src/constants/payments.ts +92 -0
- package/src/constants/seeds.ts +9 -1
- package/src/idl/synapse_agent_sap.json +270 -2
- package/src/index.ts +12 -1
- package/src/modules/escrow-v2.ts +15 -0
- package/src/modules/escrow.ts +36 -3
- package/src/pda/index.ts +39 -0
- package/src/plugin/index.ts +2 -0
- package/src/utils/hash.ts +56 -0
- package/src/utils/index.ts +1 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"address": "SAPpUhsWLJG1FfkGRcXagEDMrMsWGjbky7AyhGpFETZ",
|
|
3
3
|
"metadata": {
|
|
4
4
|
"name": "synapse_agent_sap",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.2.0",
|
|
6
6
|
"spec": "0.1.0",
|
|
7
7
|
"description": "Created with Anchor"
|
|
8
8
|
},
|
|
@@ -2693,6 +2693,37 @@
|
|
|
2693
2693
|
"Agent to prepay for — anyone can create escrow"
|
|
2694
2694
|
]
|
|
2695
2695
|
},
|
|
2696
|
+
{
|
|
2697
|
+
"name": "agent_stake",
|
|
2698
|
+
"docs": [
|
|
2699
|
+
"v0.10 hardening: agent MUST hold at least `AgentStake::MIN_STAKE`",
|
|
2700
|
+
"in collateral before any new escrow can be opened. This guarantees",
|
|
2701
|
+
"every accepted client has a slashable bond to claim against in case",
|
|
2702
|
+
"of dispute."
|
|
2703
|
+
],
|
|
2704
|
+
"pda": {
|
|
2705
|
+
"seeds": [
|
|
2706
|
+
{
|
|
2707
|
+
"kind": "const",
|
|
2708
|
+
"value": [
|
|
2709
|
+
115,
|
|
2710
|
+
97,
|
|
2711
|
+
112,
|
|
2712
|
+
95,
|
|
2713
|
+
115,
|
|
2714
|
+
116,
|
|
2715
|
+
97,
|
|
2716
|
+
107,
|
|
2717
|
+
101
|
|
2718
|
+
]
|
|
2719
|
+
},
|
|
2720
|
+
{
|
|
2721
|
+
"kind": "account",
|
|
2722
|
+
"path": "agent"
|
|
2723
|
+
}
|
|
2724
|
+
]
|
|
2725
|
+
}
|
|
2726
|
+
},
|
|
2696
2727
|
{
|
|
2697
2728
|
"name": "escrow",
|
|
2698
2729
|
"writable": true,
|
|
@@ -2792,6 +2823,35 @@
|
|
|
2792
2823
|
{
|
|
2793
2824
|
"name": "agent"
|
|
2794
2825
|
},
|
|
2826
|
+
{
|
|
2827
|
+
"name": "agent_stake",
|
|
2828
|
+
"docs": [
|
|
2829
|
+
"v0.10 hardening: agent MUST have an active stake ≥ MIN_STAKE",
|
|
2830
|
+
"before any new escrow can be opened."
|
|
2831
|
+
],
|
|
2832
|
+
"pda": {
|
|
2833
|
+
"seeds": [
|
|
2834
|
+
{
|
|
2835
|
+
"kind": "const",
|
|
2836
|
+
"value": [
|
|
2837
|
+
115,
|
|
2838
|
+
97,
|
|
2839
|
+
112,
|
|
2840
|
+
95,
|
|
2841
|
+
115,
|
|
2842
|
+
116,
|
|
2843
|
+
97,
|
|
2844
|
+
107,
|
|
2845
|
+
101
|
|
2846
|
+
]
|
|
2847
|
+
},
|
|
2848
|
+
{
|
|
2849
|
+
"kind": "account",
|
|
2850
|
+
"path": "agent"
|
|
2851
|
+
}
|
|
2852
|
+
]
|
|
2853
|
+
}
|
|
2854
|
+
},
|
|
2795
2855
|
{
|
|
2796
2856
|
"name": "escrow",
|
|
2797
2857
|
"writable": true,
|
|
@@ -6956,7 +7016,9 @@
|
|
|
6956
7016
|
{
|
|
6957
7017
|
"name": "settle_batch",
|
|
6958
7018
|
"docs": [
|
|
6959
|
-
"Batch settle up to 10 settlements in one TX. Volume curve spans batch."
|
|
7019
|
+
"Batch settle up to 10 settlements in one TX. Volume curve spans batch.",
|
|
7020
|
+
"v0.10: requires `batch_root = sha256(s_0 || s_1 || ... || s_{N-1})`",
|
|
7021
|
+
"to seed the anti-replay receipt PDA."
|
|
6960
7022
|
],
|
|
6961
7023
|
"discriminator": [
|
|
6962
7024
|
22,
|
|
@@ -7056,6 +7118,44 @@
|
|
|
7056
7118
|
}
|
|
7057
7119
|
]
|
|
7058
7120
|
}
|
|
7121
|
+
},
|
|
7122
|
+
{
|
|
7123
|
+
"name": "settlement_receipt",
|
|
7124
|
+
"docs": [
|
|
7125
|
+
"v0.10 anti-replay: PDA bound to the batch_root (sha256 of all",
|
|
7126
|
+
"service_hashes in order). Replaying the same batch fails the",
|
|
7127
|
+
"`init` constraint."
|
|
7128
|
+
],
|
|
7129
|
+
"writable": true,
|
|
7130
|
+
"pda": {
|
|
7131
|
+
"seeds": [
|
|
7132
|
+
{
|
|
7133
|
+
"kind": "const",
|
|
7134
|
+
"value": [
|
|
7135
|
+
115,
|
|
7136
|
+
97,
|
|
7137
|
+
112,
|
|
7138
|
+
95,
|
|
7139
|
+
114,
|
|
7140
|
+
101,
|
|
7141
|
+
99,
|
|
7142
|
+
118
|
|
7143
|
+
]
|
|
7144
|
+
},
|
|
7145
|
+
{
|
|
7146
|
+
"kind": "account",
|
|
7147
|
+
"path": "escrow"
|
|
7148
|
+
},
|
|
7149
|
+
{
|
|
7150
|
+
"kind": "arg",
|
|
7151
|
+
"path": "batch_root"
|
|
7152
|
+
}
|
|
7153
|
+
]
|
|
7154
|
+
}
|
|
7155
|
+
},
|
|
7156
|
+
{
|
|
7157
|
+
"name": "system_program",
|
|
7158
|
+
"address": "11111111111111111111111111111111"
|
|
7059
7159
|
}
|
|
7060
7160
|
],
|
|
7061
7161
|
"args": [
|
|
@@ -7068,6 +7168,15 @@
|
|
|
7068
7168
|
}
|
|
7069
7169
|
}
|
|
7070
7170
|
}
|
|
7171
|
+
},
|
|
7172
|
+
{
|
|
7173
|
+
"name": "batch_root",
|
|
7174
|
+
"type": {
|
|
7175
|
+
"array": [
|
|
7176
|
+
"u8",
|
|
7177
|
+
32
|
|
7178
|
+
]
|
|
7179
|
+
}
|
|
7071
7180
|
}
|
|
7072
7181
|
]
|
|
7073
7182
|
},
|
|
@@ -7180,6 +7289,45 @@
|
|
|
7180
7289
|
}
|
|
7181
7290
|
]
|
|
7182
7291
|
}
|
|
7292
|
+
},
|
|
7293
|
+
{
|
|
7294
|
+
"name": "settlement_receipt",
|
|
7295
|
+
"docs": [
|
|
7296
|
+
"v0.10 anti-replay: an `init` of this PDA fails if the same",
|
|
7297
|
+
"`service_hash` was already used to settle this escrow.",
|
|
7298
|
+
"Receipt PDAs are intentionally NOT closeable to preserve the",
|
|
7299
|
+
"uniqueness invariant for the lifetime of the escrow."
|
|
7300
|
+
],
|
|
7301
|
+
"writable": true,
|
|
7302
|
+
"pda": {
|
|
7303
|
+
"seeds": [
|
|
7304
|
+
{
|
|
7305
|
+
"kind": "const",
|
|
7306
|
+
"value": [
|
|
7307
|
+
115,
|
|
7308
|
+
97,
|
|
7309
|
+
112,
|
|
7310
|
+
95,
|
|
7311
|
+
114,
|
|
7312
|
+
101,
|
|
7313
|
+
99,
|
|
7314
|
+
118
|
|
7315
|
+
]
|
|
7316
|
+
},
|
|
7317
|
+
{
|
|
7318
|
+
"kind": "account",
|
|
7319
|
+
"path": "escrow"
|
|
7320
|
+
},
|
|
7321
|
+
{
|
|
7322
|
+
"kind": "arg",
|
|
7323
|
+
"path": "service_hash"
|
|
7324
|
+
}
|
|
7325
|
+
]
|
|
7326
|
+
}
|
|
7327
|
+
},
|
|
7328
|
+
{
|
|
7329
|
+
"name": "system_program",
|
|
7330
|
+
"address": "11111111111111111111111111111111"
|
|
7183
7331
|
}
|
|
7184
7332
|
],
|
|
7185
7333
|
"args": [
|
|
@@ -7312,6 +7460,41 @@
|
|
|
7312
7460
|
]
|
|
7313
7461
|
}
|
|
7314
7462
|
},
|
|
7463
|
+
{
|
|
7464
|
+
"name": "settlement_receipt",
|
|
7465
|
+
"docs": [
|
|
7466
|
+
"v0.10 anti-replay: PDA bound to (escrow, service_hash).",
|
|
7467
|
+
"In CoSigned mode this gates the immediate transfer; in",
|
|
7468
|
+
"DisputeWindow mode this gates the pending-amount bump so the",
|
|
7469
|
+
"same `service_hash` cannot be re-applied to inflate pending."
|
|
7470
|
+
],
|
|
7471
|
+
"writable": true,
|
|
7472
|
+
"pda": {
|
|
7473
|
+
"seeds": [
|
|
7474
|
+
{
|
|
7475
|
+
"kind": "const",
|
|
7476
|
+
"value": [
|
|
7477
|
+
115,
|
|
7478
|
+
97,
|
|
7479
|
+
112,
|
|
7480
|
+
95,
|
|
7481
|
+
114,
|
|
7482
|
+
101,
|
|
7483
|
+
99,
|
|
7484
|
+
118
|
|
7485
|
+
]
|
|
7486
|
+
},
|
|
7487
|
+
{
|
|
7488
|
+
"kind": "account",
|
|
7489
|
+
"path": "escrow"
|
|
7490
|
+
},
|
|
7491
|
+
{
|
|
7492
|
+
"kind": "arg",
|
|
7493
|
+
"path": "service_hash"
|
|
7494
|
+
}
|
|
7495
|
+
]
|
|
7496
|
+
}
|
|
7497
|
+
},
|
|
7315
7498
|
{
|
|
7316
7499
|
"name": "system_program",
|
|
7317
7500
|
"address": "11111111111111111111111111111111"
|
|
@@ -8486,6 +8669,19 @@
|
|
|
8486
8669
|
179
|
|
8487
8670
|
]
|
|
8488
8671
|
},
|
|
8672
|
+
{
|
|
8673
|
+
"name": "SettlementReceipt",
|
|
8674
|
+
"discriminator": [
|
|
8675
|
+
52,
|
|
8676
|
+
249,
|
|
8677
|
+
252,
|
|
8678
|
+
121,
|
|
8679
|
+
4,
|
|
8680
|
+
232,
|
|
8681
|
+
187,
|
|
8682
|
+
4
|
|
8683
|
+
]
|
|
8684
|
+
},
|
|
8489
8685
|
{
|
|
8490
8686
|
"name": "Subscription",
|
|
8491
8687
|
"discriminator": [
|
|
@@ -9980,6 +10176,41 @@
|
|
|
9980
10176
|
"code": 6136,
|
|
9981
10177
|
"name": "InvalidReceiptProof",
|
|
9982
10178
|
"msg": "bad receipt proof"
|
|
10179
|
+
},
|
|
10180
|
+
{
|
|
10181
|
+
"code": 6137,
|
|
10182
|
+
"name": "SettlementReplay",
|
|
10183
|
+
"msg": "settlement replay"
|
|
10184
|
+
},
|
|
10185
|
+
{
|
|
10186
|
+
"code": 6138,
|
|
10187
|
+
"name": "PaymentTokenNotAllowed",
|
|
10188
|
+
"msg": "token not allowed"
|
|
10189
|
+
},
|
|
10190
|
+
{
|
|
10191
|
+
"code": 6139,
|
|
10192
|
+
"name": "AgentStakeRequired",
|
|
10193
|
+
"msg": "agent stake required"
|
|
10194
|
+
},
|
|
10195
|
+
{
|
|
10196
|
+
"code": 6140,
|
|
10197
|
+
"name": "DelegateExpiryInvalid",
|
|
10198
|
+
"msg": "delegate expiry invalid"
|
|
10199
|
+
},
|
|
10200
|
+
{
|
|
10201
|
+
"code": 6141,
|
|
10202
|
+
"name": "EscrowNotClosed",
|
|
10203
|
+
"msg": "escrow not closed"
|
|
10204
|
+
},
|
|
10205
|
+
{
|
|
10206
|
+
"code": 6142,
|
|
10207
|
+
"name": "VolumeCurveNotDescending",
|
|
10208
|
+
"msg": "curve not descending"
|
|
10209
|
+
},
|
|
10210
|
+
{
|
|
10211
|
+
"code": 6143,
|
|
10212
|
+
"name": "DuplicateServiceHash",
|
|
10213
|
+
"msg": "dup service hash"
|
|
9983
10214
|
}
|
|
9984
10215
|
],
|
|
9985
10216
|
"types": [
|
|
@@ -13125,6 +13356,43 @@
|
|
|
13125
13356
|
]
|
|
13126
13357
|
}
|
|
13127
13358
|
},
|
|
13359
|
+
{
|
|
13360
|
+
"name": "SettlementReceipt",
|
|
13361
|
+
"type": {
|
|
13362
|
+
"kind": "struct",
|
|
13363
|
+
"fields": [
|
|
13364
|
+
{
|
|
13365
|
+
"name": "bump",
|
|
13366
|
+
"type": "u8"
|
|
13367
|
+
},
|
|
13368
|
+
{
|
|
13369
|
+
"name": "escrow",
|
|
13370
|
+
"type": "pubkey"
|
|
13371
|
+
},
|
|
13372
|
+
{
|
|
13373
|
+
"name": "service_hash",
|
|
13374
|
+
"type": {
|
|
13375
|
+
"array": [
|
|
13376
|
+
"u8",
|
|
13377
|
+
32
|
|
13378
|
+
]
|
|
13379
|
+
}
|
|
13380
|
+
},
|
|
13381
|
+
{
|
|
13382
|
+
"name": "calls_settled",
|
|
13383
|
+
"type": "u64"
|
|
13384
|
+
},
|
|
13385
|
+
{
|
|
13386
|
+
"name": "amount",
|
|
13387
|
+
"type": "u64"
|
|
13388
|
+
},
|
|
13389
|
+
{
|
|
13390
|
+
"name": "settled_at",
|
|
13391
|
+
"type": "i64"
|
|
13392
|
+
}
|
|
13393
|
+
]
|
|
13394
|
+
}
|
|
13395
|
+
},
|
|
13128
13396
|
{
|
|
13129
13397
|
"name": "SettlementSecurity",
|
|
13130
13398
|
"docs": [
|
package/dist/esm/index.js
CHANGED
|
@@ -51,10 +51,12 @@ export { SAP_PROGRAM_ADDRESS, SAP_PROGRAM_ID, MAINNET_SAP_PROGRAM_ID, DEVNET_SAP
|
|
|
51
51
|
// ── IDL ──────────────────────────────────────────────
|
|
52
52
|
export { SAP_IDL, IDL_PROGRAM_ADDRESS, IDL_METADATA } from "./idl/index";
|
|
53
53
|
// ── PDA Derivation ───────────────────────────────────
|
|
54
|
-
export { deriveGlobalRegistry, deriveAgent, deriveAgentStats, deriveFeedback, deriveCapabilityIndex, deriveProtocolIndex, deriveToolCategoryIndex, deriveVault, deriveSession, deriveEpochPage, deriveVaultDelegate, deriveCheckpoint, deriveTool, deriveEscrow, deriveEscrowV2, derivePendingSettlement, deriveDispute, deriveStake, deriveSubscription, deriveShard, deriveIndexPage, deriveAttestation, deriveLedger, deriveLedgerPage, deriveReceiptBatch, } from "./pda";
|
|
54
|
+
export { deriveGlobalRegistry, deriveAgent, deriveAgentStats, deriveFeedback, deriveCapabilityIndex, deriveProtocolIndex, deriveToolCategoryIndex, deriveVault, deriveSession, deriveEpochPage, deriveVaultDelegate, deriveCheckpoint, deriveTool, deriveEscrow, deriveEscrowV2, derivePendingSettlement, deriveDispute, deriveStake, deriveSubscription, deriveShard, deriveIndexPage, deriveAttestation, deriveLedger, deriveLedgerPage, deriveReceiptBatch, deriveSettlementReceipt, } from "./pda";
|
|
55
55
|
// ── Utilities ────────────────────────────────────────
|
|
56
|
-
export { sha256, hashToArray, assert } from "./utils";
|
|
56
|
+
export { sha256, hashToArray, assert, computeBatchRoot } from "./utils";
|
|
57
57
|
export { serializeAccount, serializeValue } from "./utils";
|
|
58
|
+
// v0.10 — payment + stake constants
|
|
59
|
+
export { USDC_MINT_MAINNET, USDC_MINT_DEVNET, MIN_AGENT_STAKE_LAMPORTS, MAX_DELEGATE_DURATION_SECS, isAcceptedUsdcMint, isAcceptedPaymentToken, } from "./constants";
|
|
58
60
|
// v0.6.0 — Network normalizer
|
|
59
61
|
export { normalizeNetworkId, isNetworkEquivalent, getNetworkGenesisHash, getNetworkClusterName, isKnownNetwork, } from "./utils";
|
|
60
62
|
// v0.6.0 — Endpoint validation
|
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;AA2EjE,OAAO,EACL,SAAS,EACT,UAAU,EACV,cAAc,EACd,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,UAAU,EACV,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,WAAW,EACX,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,cAAc,EACd,uBAAuB,EACvB,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,
|
|
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;AA2EjE,OAAO,EACL,SAAS,EACT,UAAU,EACV,cAAc,EACd,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,UAAU,EACV,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D,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,EACZ,cAAc,GACf,MAAM,oBAAoB,CAAC"}
|
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
import { SystemProgram, } from "@solana/web3.js";
|
|
12
12
|
import { BN } from "@coral-xyz/anchor";
|
|
13
13
|
import { BaseModule } from "./base";
|
|
14
|
-
import { deriveAgent, deriveAgentStats, deriveEscrowV2, derivePendingSettlement as derivePendingPda, deriveDispute as deriveDisputePda, } from "../pda";
|
|
14
|
+
import { deriveAgent, deriveAgentStats, deriveEscrowV2, derivePendingSettlement as derivePendingPda, deriveDispute as deriveDisputePda, deriveStake, deriveSettlementReceipt, } from "../pda";
|
|
15
15
|
import { buildPriorityFeeIxs, buildRpcOptions, } from "../utils/priority-fee";
|
|
16
|
+
import { isAcceptedPaymentToken } from "../constants/payments";
|
|
16
17
|
/**
|
|
17
18
|
* @name EscrowV2Module
|
|
18
19
|
* @description Manages V2 escrow accounts with settlement security modes,
|
|
@@ -40,13 +41,20 @@ export class EscrowV2Module extends BaseModule {
|
|
|
40
41
|
}
|
|
41
42
|
// ── Instructions ─────────────────────────────────────
|
|
42
43
|
async create(agentWallet, args, splAccounts = []) {
|
|
44
|
+
// v0.10.0: payment-token allowlist (SOL or USDC only).
|
|
45
|
+
if (!isAcceptedPaymentToken(args.tokenMint ?? null)) {
|
|
46
|
+
throw new Error("createEscrowV2: tokenMint must be null (SOL) or USDC (mainnet/devnet). " +
|
|
47
|
+
"On-chain will reject with PaymentTokenNotAllowed.");
|
|
48
|
+
}
|
|
43
49
|
const [agentPda] = deriveAgent(agentWallet);
|
|
44
50
|
const [escrowPda] = this.deriveEscrow(agentPda, undefined, args.escrowNonce);
|
|
51
|
+
const [stakePda] = deriveStake(agentPda);
|
|
45
52
|
return this.methods
|
|
46
53
|
.createEscrowV2(this.bn(args.escrowNonce), this.bn(args.pricePerCall), this.bn(args.maxCalls), this.bn(args.initialDeposit), args.expiresAt, args.volumeCurve, args.tokenMint, args.tokenDecimals, args.settlementSecurity, this.bn(args.disputeWindowSlots), args.coSigner, args.arbiter)
|
|
47
54
|
.accounts({
|
|
48
55
|
depositor: this.walletPubkey,
|
|
49
56
|
agent: agentPda,
|
|
57
|
+
agentStake: stakePda,
|
|
50
58
|
escrow: escrowPda,
|
|
51
59
|
systemProgram: SystemProgram.programId,
|
|
52
60
|
})
|
|
@@ -70,6 +78,7 @@ export class EscrowV2Module extends BaseModule {
|
|
|
70
78
|
const [agentPda] = deriveAgent(this.walletPubkey);
|
|
71
79
|
const [escrowPda] = this.deriveEscrow(agentPda, depositorWallet, nonce);
|
|
72
80
|
const [statsPda] = deriveAgentStats(agentPda);
|
|
81
|
+
const [receiptPda] = deriveSettlementReceipt(escrowPda, serviceHash);
|
|
73
82
|
const preIxs = buildPriorityFeeIxs(opts);
|
|
74
83
|
const rpcOpts = buildRpcOptions(opts);
|
|
75
84
|
let builder = this.methods
|
|
@@ -79,6 +88,7 @@ export class EscrowV2Module extends BaseModule {
|
|
|
79
88
|
agent: agentPda,
|
|
80
89
|
agentStats: statsPda,
|
|
81
90
|
escrow: escrowPda,
|
|
91
|
+
settlementReceipt: receiptPda,
|
|
82
92
|
systemProgram: SystemProgram.programId,
|
|
83
93
|
})
|
|
84
94
|
.remainingAccounts(splAccounts);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"escrow-v2.js","sourceRoot":"","sources":["../../../src/modules/escrow-v2.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,aAAa,GAId,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,uBAAuB,IAAI,gBAAgB,EAC3C,aAAa,IAAI,gBAAgB,
|
|
1
|
+
{"version":3,"file":"escrow-v2.js","sourceRoot":"","sources":["../../../src/modules/escrow-v2.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,aAAa,GAId,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,uBAAuB,IAAI,gBAAgB,EAC3C,aAAa,IAAI,gBAAgB,EACjC,WAAW,EACX,uBAAuB,GACxB,MAAM,QAAQ,CAAC;AAOhB,OAAO,EACL,mBAAmB,EACnB,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE/D;;;;;;;;GAQG;AACH,MAAM,OAAO,cAAe,SAAQ,UAAU;IAC5C,wDAAwD;IAExD,oEAAoE;IAC5D,KAAK,CAAC,CAAuB;QACnC,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC;IAED,wDAAwD;IAExD,YAAY,CACV,QAAmB,EACnB,SAAqB,EACrB,QAA8B,CAAC;QAE/B,OAAO,cAAc,CAAC,QAAQ,EA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CAAC;QAC5D,OAAO,IAAI,CAAC,YAAY,CAAsB,iBAAiB,EAAE,GAAG,CAAC,CAAC;IACxE,CAAC;IAED,KAAK,CAAC,aAAa,CACjB,QAAmB,EACnB,SAAqB,EACrB,QAA8B,CAAC;QAE/B,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;QAC5D,OAAO,IAAI,CAAC,oBAAoB,CAAsB,iBAAiB,EAAE,GAAG,CAAC,CAAC;IAChF,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,SAAoB;QACnC,OAAO,IAAI,CAAC,YAAY,CAAsB,iBAAiB,EAAE,SAAS,CAAC,CAAC;IAC9E,CAAC;IAED,KAAK,CAAC,sBAAsB,CAC1B,UAAqB;QAErB,OAAO,IAAI,CAAC,YAAY,CAAwB,mBAAmB,EAAE,UAAU,CAAC,CAAC;IACnF,CAAC;IAED,KAAK,CAAC,8BAA8B,CAClC,UAAqB;QAErB,OAAO,IAAI,CAAC,oBAAoB,CAAwB,mBAAmB,EAAE,UAAU,CAAC,CAAC;IAC3F,CAAC;IAED,KAAK,CAAC,YAAY,CAChB,UAAqB;QAErB,OAAO,IAAI,CAAC,YAAY,CAAoB,eAAe,EAAE,UAAU,CAAC,CAAC;IAC3E,CAAC;IAED,KAAK,CAAC,oBAAoB,CACxB,UAAqB;QAErB,OAAO,IAAI,CAAC,oBAAoB,CAAoB,eAAe,EAAE,UAAU,CAAC,CAAC;IACnF,CAAC;CACF"}
|
|
@@ -12,8 +12,10 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { SystemProgram, } from "@solana/web3.js";
|
|
14
14
|
import { BaseModule } from "./base";
|
|
15
|
-
import { deriveAgent, deriveAgentStats, deriveEscrow, } from "../pda";
|
|
15
|
+
import { deriveAgent, deriveAgentStats, deriveEscrow, deriveStake, deriveSettlementReceipt, } from "../pda";
|
|
16
16
|
import { buildPriorityFeeIxs, buildRpcOptions, } from "../utils/priority-fee";
|
|
17
|
+
import { computeBatchRoot, hashToArray } from "../utils/hash";
|
|
18
|
+
import { isAcceptedPaymentToken } from "../constants/payments";
|
|
17
19
|
/**
|
|
18
20
|
* @name EscrowModule
|
|
19
21
|
* @description Manages x402-compatible escrow accounts for agent micropayments.
|
|
@@ -74,15 +76,20 @@ export class EscrowModule extends BaseModule {
|
|
|
74
76
|
* @since v0.1.0
|
|
75
77
|
*/
|
|
76
78
|
async create(agentWallet, args, splAccounts = []) {
|
|
79
|
+
// v0.10.0 client-side guard — surface the on-chain rejection earlier.
|
|
80
|
+
if (!isAcceptedPaymentToken(args.tokenMint ?? null)) {
|
|
81
|
+
throw new Error("createEscrow: tokenMint must be null (SOL) or USDC (mainnet/devnet). " +
|
|
82
|
+
"On-chain will reject with PaymentTokenNotAllowed.");
|
|
83
|
+
}
|
|
77
84
|
const [agentPda] = deriveAgent(agentWallet);
|
|
78
85
|
const [escrowPda] = this.deriveEscrow(agentPda);
|
|
79
|
-
const [
|
|
86
|
+
const [stakePda] = deriveStake(agentPda);
|
|
80
87
|
return this.methods
|
|
81
88
|
.createEscrow(args.pricePerCall, args.maxCalls, args.initialDeposit, args.expiresAt, args.volumeCurve, args.tokenMint, args.tokenDecimals)
|
|
82
89
|
.accounts({
|
|
83
90
|
depositor: this.walletPubkey,
|
|
84
91
|
agent: agentPda,
|
|
85
|
-
|
|
92
|
+
agentStake: stakePda,
|
|
86
93
|
escrow: escrowPda,
|
|
87
94
|
systemProgram: SystemProgram.programId,
|
|
88
95
|
})
|
|
@@ -128,6 +135,7 @@ export class EscrowModule extends BaseModule {
|
|
|
128
135
|
const [agentPda] = deriveAgent(this.walletPubkey);
|
|
129
136
|
const [escrowPda] = deriveEscrow(agentPda, depositorWallet);
|
|
130
137
|
const [statsPda] = deriveAgentStats(agentPda);
|
|
138
|
+
const [receiptPda] = deriveSettlementReceipt(escrowPda, serviceHash);
|
|
131
139
|
const preIxs = buildPriorityFeeIxs(opts);
|
|
132
140
|
const rpcOpts = buildRpcOptions(opts);
|
|
133
141
|
let builder = this.methods
|
|
@@ -137,6 +145,7 @@ export class EscrowModule extends BaseModule {
|
|
|
137
145
|
agent: agentPda,
|
|
138
146
|
agentStats: statsPda,
|
|
139
147
|
escrow: escrowPda,
|
|
148
|
+
settlementReceipt: receiptPda,
|
|
140
149
|
systemProgram: SystemProgram.programId,
|
|
141
150
|
})
|
|
142
151
|
.remainingAccounts(splAccounts);
|
|
@@ -189,27 +198,43 @@ export class EscrowModule extends BaseModule {
|
|
|
189
198
|
* @name settleBatch
|
|
190
199
|
* @description Batch settlement — process up to 10 settlements in a single
|
|
191
200
|
* transaction. Must be called by the agent owner wallet.
|
|
201
|
+
*
|
|
192
202
|
* @param depositorWallet - The wallet of the client who funded the escrow.
|
|
193
203
|
* @param settlements - Array of settlement entries (up to 10).
|
|
204
|
+
* @param batchRoot - Optional pre-computed batch root
|
|
205
|
+
* (`sha256(s_0 || s_1 || ... || s_{N-1})`). When omitted the SDK
|
|
206
|
+
* computes it from `settlements[*].serviceHash`. **Required on-chain
|
|
207
|
+
* since v0.10.0** to seed the anti-replay receipt PDA.
|
|
194
208
|
* @param splAccounts - Remaining accounts for SPL token transfers. Defaults to `[]`.
|
|
195
209
|
* @param opts - Optional {@link SettleOptions} for priority fees and RPC tuning.
|
|
196
210
|
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
211
|
+
*
|
|
197
212
|
* @since v0.1.0
|
|
198
213
|
* @updated v0.6.2 — Added optional `opts` parameter for priority fees.
|
|
214
|
+
* @updated v0.10.0 — Added `batchRoot` argument and required
|
|
215
|
+
* `settlementReceipt` PDA on-chain (anti-replay).
|
|
199
216
|
*/
|
|
200
|
-
async settleBatch(depositorWallet, settlements, splAccounts = [], opts) {
|
|
217
|
+
async settleBatch(depositorWallet, settlements, batchRoot, splAccounts = [], opts) {
|
|
201
218
|
const [agentPda] = deriveAgent(this.walletPubkey);
|
|
202
219
|
const [escrowPda] = deriveEscrow(agentPda, depositorWallet);
|
|
203
220
|
const [statsPda] = deriveAgentStats(agentPda);
|
|
221
|
+
const rootBytes = batchRoot && batchRoot !== null
|
|
222
|
+
? batchRoot instanceof Uint8Array
|
|
223
|
+
? batchRoot
|
|
224
|
+
: Uint8Array.from(batchRoot)
|
|
225
|
+
: computeBatchRoot(settlements.map((s) => s.serviceHash));
|
|
226
|
+
const rootArr = hashToArray(rootBytes);
|
|
227
|
+
const [receiptPda] = deriveSettlementReceipt(escrowPda, rootBytes);
|
|
204
228
|
const preIxs = buildPriorityFeeIxs(opts);
|
|
205
229
|
const rpcOpts = buildRpcOptions(opts);
|
|
206
230
|
let builder = this.methods
|
|
207
|
-
.settleBatch(settlements)
|
|
231
|
+
.settleBatch(settlements, rootArr)
|
|
208
232
|
.accounts({
|
|
209
233
|
wallet: this.walletPubkey,
|
|
210
234
|
agent: agentPda,
|
|
211
235
|
agentStats: statsPda,
|
|
212
236
|
escrow: escrowPda,
|
|
237
|
+
settlementReceipt: receiptPda,
|
|
213
238
|
systemProgram: SystemProgram.programId,
|
|
214
239
|
})
|
|
215
240
|
.remainingAccounts(splAccounts);
|
|
@@ -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,
|
|
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,EACZ,WAAW,E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Index),
|
|
608
608
|
], programId);
|
|
609
|
+
/**
|
|
610
|
+
* Derive the **SettlementReceipt** PDA (v0.10.0 anti-replay).
|
|
611
|
+
*
|
|
612
|
+
* Seeds: `["sap_recv", escrow_pda, service_hash_or_batch_root]`
|
|
613
|
+
*
|
|
614
|
+
* Created via `init` on every `settle_calls`, `settle_batch`, and
|
|
615
|
+
* `settle_calls_v2`. The PDA's existence after the first call blocks
|
|
616
|
+
* any future replay of the same `service_hash` (or `batch_root`)
|
|
617
|
+
* against the same escrow.
|
|
618
|
+
*
|
|
619
|
+
* @name deriveSettlementReceipt
|
|
620
|
+
* @description Compute the receipt PDA that gates settlement replay.
|
|
621
|
+
* @param escrowPda - Parent escrow PDA (V1 `EscrowAccount` or V2 `EscrowAccountV2`).
|
|
622
|
+
* @param receiptKey - 32-byte `service_hash` (single settle / V2 settle)
|
|
623
|
+
* or `batch_root = sha256(s_0 || ... || s_{N-1})` (settle_batch).
|
|
624
|
+
* @param programId - Override program ID.
|
|
625
|
+
* @returns {PdaResult} `[pda, bump]` tuple.
|
|
626
|
+
* @category PDA
|
|
627
|
+
* @since v0.10.0
|
|
628
|
+
*/
|
|
629
|
+
export const deriveSettlementReceipt = (escrowPda, receiptKey, programId = SAP_PROGRAM_ID) => {
|
|
630
|
+
const buf = Buffer.isBuffer(receiptKey)
|
|
631
|
+
? receiptKey
|
|
632
|
+
: Buffer.from(receiptKey);
|
|
633
|
+
if (buf.length !== 32) {
|
|
634
|
+
throw new Error(`deriveSettlementReceipt: receiptKey must be 32 bytes, got ${buf.length}`);
|
|
635
|
+
}
|
|
636
|
+
return findPda([toSeedBuf(SEEDS.SETTLEMENT_RECEIPT), escrowPda.toBuffer(), buf], programId);
|
|
637
|
+
};
|
|
609
638
|
//# sourceMappingURL=index.js.map
|