@heyanon-arp/sdk 0.0.29 → 0.0.31

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.
@@ -5,3 +5,4 @@ export type { EscrowConfigStatus } from './config-status';
5
5
  export { buildCreateLockIxData, computeCreateLockDiscriminator, CREATE_LOCK_DISCRIMINATOR, CREATE_LOCK_NATIVE_DISCRIMINATOR, type CreateLockArgs, } from './create-lock';
6
6
  export { ESCROW_PDA_SEEDS, NO_ARG_LIFECYCLE_INSTRUCTIONS, type NoArgLifecycleInstruction, instructionDiscriminator, buildLifecycleIxData, buildResolveDisputeIxData, type ResolveDisputeArgs, } from './lifecycle-instructions';
7
7
  export { LOCK_ACCOUNT_SIZE, LOCK_ACCOUNT_DISCRIMINATOR, LOCK_STATE_NAMES, LOCK_TERMINAL_STATES, LockStates, LockTerminalStates, ESCROW_RELEASE_METHODS, EscrowReleaseMethods, NATIVE_SOL_MINT_BASE58, type LockStateName, type LockTerminalState, type EscrowReleaseMethodName, isEscrowReleaseMethod, type DecodedLockAccount, decodeLockAccount, computeLockAccountDiscriminator, } from './lock-account';
8
+ export * from './instructions';
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Escrow instruction assembly — the web3.js half of the escrow layer.
3
+ * The rest of the SDK is web3.js-free (pure-bytes instruction DATA
4
+ * builders + PDA seed strings); this module derives the PDAs and wraps
5
+ * the data in `TransactionInstruction`s with the exact account lists
6
+ * from the pinned IDL.
7
+ *
8
+ * `@solana/web3.js` is a PEER dependency — only consumers that build
9
+ * on-chain transactions (the CLI, the server's dispute signer) pull it
10
+ * in; the crypto/encoding surface of the SDK stays web3.js-free.
11
+ *
12
+ * All builders are PURE (no RPC). Callers that need on-chain context
13
+ * (the Lock's payer/payee/mint/fee_recipient for the claim paths) use
14
+ * `fetchLockAccount` first and feed the decoded fields in.
15
+ *
16
+ * Account orders are BYTE-LAW — they mirror the pinned IDL exactly;
17
+ * reordering = on-chain ConstraintSeeds reject. This is the single
18
+ * source of truth shared by every consumer; do not duplicate it.
19
+ */
20
+ import { type Connection, PublicKey, TransactionInstruction } from '@solana/web3.js';
21
+ import { type ResolveDisputeArgs } from './lifecycle-instructions';
22
+ import { type DecodedLockAccount } from './lock-account';
23
+ export declare const SPL_TOKEN_PROGRAM_ID: PublicKey;
24
+ export declare const ASSOCIATED_TOKEN_PROGRAM_ID: PublicKey;
25
+ /** The contract's native-SOL sentinel as a PublicKey ([0u8;32]). */
26
+ export declare const NATIVE_SOL_MINT: PublicKey;
27
+ export declare function deriveLockPda(programId: PublicKey, lockId: Uint8Array): PublicKey;
28
+ export declare function deriveEscrowPda(programId: PublicKey, lockId: Uint8Array): PublicKey;
29
+ export declare function deriveConfigPda(programId: PublicKey): PublicKey;
30
+ export declare function deriveStakeVaultPda(programId: PublicKey): PublicKey;
31
+ /** Native locks use the all-zero sentinel as the collateral seed. */
32
+ export declare function deriveCollateralConfigPda(programId: PublicKey, mint: PublicKey): PublicKey;
33
+ export declare function deriveDisputeResolutionPda(programId: PublicKey, lockId: Uint8Array): PublicKey;
34
+ export declare function deriveOperatorAuthPda(programId: PublicKey, operator: PublicKey): PublicKey;
35
+ export declare function deriveEventAuthorityPda(programId: PublicKey): PublicKey;
36
+ /** Associated token account for (owner, mint) under the legacy SPL Token program. */
37
+ export declare function deriveAta(owner: PublicKey, mint: PublicKey): PublicKey;
38
+ interface Ctx {
39
+ programId: PublicKey;
40
+ lockId: Uint8Array;
41
+ }
42
+ export interface CreateLockIxInput extends Ctx {
43
+ payer: PublicKey;
44
+ payee: PublicKey;
45
+ amount: bigint;
46
+ conditionHash: Uint8Array;
47
+ /** null → native SOL (`create_lock_native`). */
48
+ mint: PublicKey | null;
49
+ }
50
+ export declare function buildCreateLockIx(input: CreateLockIxInput): TransactionInstruction;
51
+ export interface AcceptLockIxInput extends Ctx {
52
+ payee: PublicKey;
53
+ }
54
+ export declare function buildAcceptLockIx(input: AcceptLockIxInput): TransactionInstruction;
55
+ export interface SubmitWorkIxInput extends Ctx {
56
+ payee: PublicKey;
57
+ }
58
+ export declare function buildSubmitWorkIx(input: SubmitWorkIxInput): TransactionInstruction;
59
+ export interface ClaimWorkPaymentIxInput extends Ctx {
60
+ /** The tx sender: payer (buyer approval) or payee (post-review self-claim). */
61
+ authority: PublicKey;
62
+ payer: PublicKey;
63
+ payee: PublicKey;
64
+ /** null → native. */
65
+ mint: PublicKey | null;
66
+ feeRecipient: PublicKey;
67
+ }
68
+ export declare function buildClaimWorkPaymentIx(input: ClaimWorkPaymentIxInput): TransactionInstruction;
69
+ export interface CancelLockIxInput extends Ctx {
70
+ payer: PublicKey;
71
+ mint: PublicKey | null;
72
+ }
73
+ export declare function buildCancelLockIx(input: CancelLockIxInput): TransactionInstruction;
74
+ export interface ClaimExpiredWorkIxInput extends Ctx {
75
+ payer: PublicKey;
76
+ mint: PublicKey | null;
77
+ }
78
+ export declare function buildClaimExpiredWorkIx(input: ClaimExpiredWorkIxInput): TransactionInstruction;
79
+ export interface OpenDisputeIxInput extends Ctx {
80
+ payer: PublicKey;
81
+ }
82
+ export declare function buildOpenDisputeIx(input: OpenDisputeIxInput): TransactionInstruction;
83
+ export interface ResolveDisputeIxInput extends Ctx {
84
+ operator: PublicKey;
85
+ payer: PublicKey;
86
+ /** The ruled winner (payer or payee — must agree with args.isPayerWinner). */
87
+ winner: PublicKey;
88
+ feeRecipient: PublicKey;
89
+ treasury: PublicKey;
90
+ mint: PublicKey | null;
91
+ args: ResolveDisputeArgs;
92
+ }
93
+ export declare function buildResolveDisputeIx(input: ResolveDisputeIxInput): TransactionInstruction;
94
+ export interface CloseDisputeIxInput extends Ctx {
95
+ /** Either party — after the dispute window lapses unresolved. */
96
+ authority: PublicKey;
97
+ payer: PublicKey;
98
+ payee: PublicKey;
99
+ mint: PublicKey | null;
100
+ }
101
+ export declare function buildCloseDisputeIx(input: CloseDisputeIxInput): TransactionInstruction;
102
+ /**
103
+ * Fetch + decode the Lock account for a delegation. Returns `null`
104
+ * when the lock PDA doesn't exist (never created, or wrong cluster /
105
+ * program id — the caller distinguishes via its own context).
106
+ */
107
+ export declare function fetchLockAccount(conn: Connection, programId: PublicKey, delegationId: string): Promise<{
108
+ lockId: Uint8Array;
109
+ lockPda: PublicKey;
110
+ lock: DecodedLockAccount;
111
+ } | null>;
112
+ export {};
package/dist/index.js CHANGED
@@ -7,6 +7,7 @@ var base = require('@scure/base');
7
7
  var ed = require('@noble/ed25519');
8
8
  var hmac = require('@noble/hashes/hmac');
9
9
  var scrypt = require('@noble/hashes/scrypt');
10
+ var web3_js = require('@solana/web3.js');
10
11
 
11
12
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
12
13
 
@@ -941,6 +942,270 @@ function readU64LE(buf, off) {
941
942
  }
942
943
  return v;
943
944
  }
945
+ var SPL_TOKEN_PROGRAM_ID = new web3_js.PublicKey(SPL_TOKEN_PROGRAM_ID_BASE58);
946
+ var ASSOCIATED_TOKEN_PROGRAM_ID = new web3_js.PublicKey(ASSOCIATED_TOKEN_PROGRAM_ID_BASE58);
947
+ var NATIVE_SOL_MINT = new web3_js.PublicKey(NATIVE_SOL_MINT_BASE58);
948
+ function deriveLockPda(programId, lockId) {
949
+ return web3_js.PublicKey.findProgramAddressSync([Buffer.from(ESCROW_PDA_SEEDS.LOCK), Buffer.from(lockId)], programId)[0];
950
+ }
951
+ function deriveEscrowPda(programId, lockId) {
952
+ return web3_js.PublicKey.findProgramAddressSync([Buffer.from(ESCROW_PDA_SEEDS.ESCROW), Buffer.from(lockId)], programId)[0];
953
+ }
954
+ function deriveConfigPda(programId) {
955
+ return web3_js.PublicKey.findProgramAddressSync([Buffer.from(ESCROW_PDA_SEEDS.CONFIG)], programId)[0];
956
+ }
957
+ function deriveStakeVaultPda(programId) {
958
+ return web3_js.PublicKey.findProgramAddressSync([Buffer.from(ESCROW_PDA_SEEDS.STAKE_VAULT)], programId)[0];
959
+ }
960
+ function deriveCollateralConfigPda(programId, mint) {
961
+ return web3_js.PublicKey.findProgramAddressSync([Buffer.from(ESCROW_PDA_SEEDS.COLLATERAL), mint.toBuffer()], programId)[0];
962
+ }
963
+ function deriveDisputeResolutionPda(programId, lockId) {
964
+ return web3_js.PublicKey.findProgramAddressSync([Buffer.from(ESCROW_PDA_SEEDS.DISPUTE_RESOLUTION), Buffer.from(lockId)], programId)[0];
965
+ }
966
+ function deriveOperatorAuthPda(programId, operator) {
967
+ return web3_js.PublicKey.findProgramAddressSync([Buffer.from(ESCROW_PDA_SEEDS.OPERATOR_AUTH), operator.toBuffer()], programId)[0];
968
+ }
969
+ function deriveEventAuthorityPda(programId) {
970
+ return web3_js.PublicKey.findProgramAddressSync([Buffer.from(ESCROW_PDA_SEEDS.EVENT_AUTHORITY)], programId)[0];
971
+ }
972
+ function deriveAta(owner, mint) {
973
+ return web3_js.PublicKey.findProgramAddressSync([owner.toBuffer(), SPL_TOKEN_PROGRAM_ID.toBuffer(), mint.toBuffer()], ASSOCIATED_TOKEN_PROGRAM_ID)[0];
974
+ }
975
+ function eventCpiTail(programId) {
976
+ return [
977
+ { pubkey: deriveEventAuthorityPda(programId), isSigner: false, isWritable: false },
978
+ { pubkey: programId, isSigner: false, isWritable: false }
979
+ ];
980
+ }
981
+ function meta(pubkey, opts = {}) {
982
+ return { pubkey, isSigner: opts.signer === true, isWritable: opts.writable === true };
983
+ }
984
+ function noArgIx(programId, name, keys) {
985
+ return new web3_js.TransactionInstruction({ programId, keys, data: Buffer.from(buildLifecycleIxData(name)) });
986
+ }
987
+ function buildCreateLockIx(input) {
988
+ const { programId, lockId } = input;
989
+ const native = input.mint === null;
990
+ const data = Buffer.from(buildCreateLockIxData({ lockId, amount: input.amount, conditionHash: input.conditionHash }, { native }));
991
+ const head = [
992
+ meta(input.payer, { signer: true, writable: true }),
993
+ meta(input.payee),
994
+ meta(deriveConfigPda(programId)),
995
+ meta(deriveLockPda(programId, lockId), { writable: true }),
996
+ meta(deriveCollateralConfigPda(programId, input.mint ?? NATIVE_SOL_MINT))
997
+ ];
998
+ const keys = native ? [...head, meta(deriveEscrowPda(programId, lockId), { writable: true }), meta(web3_js.SystemProgram.programId), ...eventCpiTail(programId)] : [
999
+ ...head,
1000
+ meta(input.mint),
1001
+ meta(deriveAta(input.payer, input.mint), { writable: true }),
1002
+ meta(deriveEscrowPda(programId, lockId), { writable: true }),
1003
+ meta(web3_js.SystemProgram.programId),
1004
+ meta(SPL_TOKEN_PROGRAM_ID),
1005
+ ...eventCpiTail(programId)
1006
+ ];
1007
+ return new web3_js.TransactionInstruction({ programId, keys, data });
1008
+ }
1009
+ function buildAcceptLockIx(input) {
1010
+ const { programId, lockId } = input;
1011
+ return noArgIx(programId, "accept_lock", [
1012
+ meta(input.payee, { signer: true, writable: true }),
1013
+ meta(deriveConfigPda(programId)),
1014
+ meta(deriveStakeVaultPda(programId), { writable: true }),
1015
+ meta(deriveLockPda(programId, lockId), { writable: true }),
1016
+ meta(web3_js.SystemProgram.programId),
1017
+ ...eventCpiTail(programId)
1018
+ ]);
1019
+ }
1020
+ function buildSubmitWorkIx(input) {
1021
+ const { programId, lockId } = input;
1022
+ return noArgIx(programId, "submit_work", [
1023
+ meta(input.payee, { signer: true }),
1024
+ meta(deriveConfigPda(programId)),
1025
+ meta(deriveLockPda(programId, lockId), { writable: true }),
1026
+ ...eventCpiTail(programId)
1027
+ ]);
1028
+ }
1029
+ function buildClaimWorkPaymentIx(input) {
1030
+ const { programId, lockId } = input;
1031
+ if (input.mint === null) {
1032
+ return noArgIx(programId, "claim_work_payment_native", [
1033
+ meta(input.authority, { signer: true, writable: true }),
1034
+ meta(deriveStakeVaultPda(programId), { writable: true }),
1035
+ meta(deriveLockPda(programId, lockId), { writable: true }),
1036
+ meta(deriveEscrowPda(programId, lockId), { writable: true }),
1037
+ meta(input.payer, { writable: true }),
1038
+ meta(input.payee, { writable: true }),
1039
+ meta(input.feeRecipient, { writable: true }),
1040
+ meta(web3_js.SystemProgram.programId),
1041
+ ...eventCpiTail(programId)
1042
+ ]);
1043
+ }
1044
+ return noArgIx(programId, "claim_work_payment", [
1045
+ meta(input.authority, { signer: true, writable: true }),
1046
+ meta(deriveConfigPda(programId)),
1047
+ meta(deriveStakeVaultPda(programId), { writable: true }),
1048
+ meta(deriveLockPda(programId, lockId), { writable: true }),
1049
+ meta(input.mint),
1050
+ meta(deriveEscrowPda(programId, lockId), { writable: true }),
1051
+ meta(input.payer, { writable: true }),
1052
+ meta(input.payee, { writable: true }),
1053
+ meta(deriveAta(input.payee, input.mint), { writable: true }),
1054
+ meta(input.feeRecipient),
1055
+ meta(deriveAta(input.feeRecipient, input.mint), { writable: true }),
1056
+ meta(web3_js.SystemProgram.programId),
1057
+ meta(SPL_TOKEN_PROGRAM_ID),
1058
+ meta(ASSOCIATED_TOKEN_PROGRAM_ID),
1059
+ ...eventCpiTail(programId)
1060
+ ]);
1061
+ }
1062
+ function buildCancelLockIx(input) {
1063
+ const { programId, lockId } = input;
1064
+ if (input.mint === null) {
1065
+ return noArgIx(programId, "cancel_lock_native", [
1066
+ meta(input.payer, { signer: true, writable: true }),
1067
+ meta(deriveLockPda(programId, lockId), { writable: true }),
1068
+ meta(deriveEscrowPda(programId, lockId), { writable: true }),
1069
+ meta(web3_js.SystemProgram.programId),
1070
+ ...eventCpiTail(programId)
1071
+ ]);
1072
+ }
1073
+ return noArgIx(programId, "cancel_lock", [
1074
+ meta(input.payer, { signer: true, writable: true }),
1075
+ meta(deriveConfigPda(programId)),
1076
+ meta(deriveLockPda(programId, lockId), { writable: true }),
1077
+ meta(input.mint),
1078
+ meta(deriveEscrowPda(programId, lockId), { writable: true }),
1079
+ meta(deriveAta(input.payer, input.mint), { writable: true }),
1080
+ meta(web3_js.SystemProgram.programId),
1081
+ meta(SPL_TOKEN_PROGRAM_ID),
1082
+ meta(ASSOCIATED_TOKEN_PROGRAM_ID),
1083
+ ...eventCpiTail(programId)
1084
+ ]);
1085
+ }
1086
+ function buildClaimExpiredWorkIx(input) {
1087
+ const { programId, lockId } = input;
1088
+ if (input.mint === null) {
1089
+ return noArgIx(programId, "claim_expired_work_native", [
1090
+ meta(input.payer, { signer: true, writable: true }),
1091
+ meta(deriveStakeVaultPda(programId), { writable: true }),
1092
+ meta(deriveLockPda(programId, lockId), { writable: true }),
1093
+ meta(deriveEscrowPda(programId, lockId), { writable: true }),
1094
+ meta(web3_js.SystemProgram.programId),
1095
+ ...eventCpiTail(programId)
1096
+ ]);
1097
+ }
1098
+ return noArgIx(programId, "claim_expired_work", [
1099
+ meta(input.payer, { signer: true, writable: true }),
1100
+ meta(deriveConfigPda(programId)),
1101
+ meta(deriveStakeVaultPda(programId), { writable: true }),
1102
+ meta(deriveLockPda(programId, lockId), { writable: true }),
1103
+ meta(input.mint),
1104
+ meta(deriveEscrowPda(programId, lockId), { writable: true }),
1105
+ meta(deriveAta(input.payer, input.mint), { writable: true }),
1106
+ meta(web3_js.SystemProgram.programId),
1107
+ meta(SPL_TOKEN_PROGRAM_ID),
1108
+ meta(ASSOCIATED_TOKEN_PROGRAM_ID),
1109
+ ...eventCpiTail(programId)
1110
+ ]);
1111
+ }
1112
+ function buildOpenDisputeIx(input) {
1113
+ const { programId, lockId } = input;
1114
+ return noArgIx(programId, "open_dispute", [
1115
+ meta(input.payer, { signer: true, writable: true }),
1116
+ meta(deriveConfigPda(programId)),
1117
+ meta(deriveStakeVaultPda(programId), { writable: true }),
1118
+ meta(deriveLockPda(programId, lockId), { writable: true }),
1119
+ meta(web3_js.SystemProgram.programId),
1120
+ ...eventCpiTail(programId)
1121
+ ]);
1122
+ }
1123
+ function buildResolveDisputeIx(input) {
1124
+ const { programId, lockId } = input;
1125
+ const native = input.mint === null;
1126
+ const data = Buffer.from(buildResolveDisputeIxData(input.args, { native }));
1127
+ if (native) {
1128
+ return new web3_js.TransactionInstruction({
1129
+ programId,
1130
+ data,
1131
+ keys: [
1132
+ meta(input.operator, { signer: true, writable: true }),
1133
+ meta(deriveOperatorAuthPda(programId, input.operator)),
1134
+ meta(deriveStakeVaultPda(programId), { writable: true }),
1135
+ meta(deriveLockPda(programId, lockId), { writable: true }),
1136
+ meta(deriveDisputeResolutionPda(programId, lockId), { writable: true }),
1137
+ meta(deriveEscrowPda(programId, lockId), { writable: true }),
1138
+ meta(input.payer, { writable: true }),
1139
+ meta(input.winner, { writable: true }),
1140
+ meta(input.feeRecipient, { writable: true }),
1141
+ meta(input.treasury, { writable: true }),
1142
+ meta(web3_js.SystemProgram.programId),
1143
+ ...eventCpiTail(programId)
1144
+ ]
1145
+ });
1146
+ }
1147
+ return new web3_js.TransactionInstruction({
1148
+ programId,
1149
+ data,
1150
+ keys: [
1151
+ meta(input.operator, { signer: true, writable: true }),
1152
+ meta(deriveOperatorAuthPda(programId, input.operator)),
1153
+ meta(deriveConfigPda(programId)),
1154
+ meta(deriveStakeVaultPda(programId), { writable: true }),
1155
+ meta(deriveLockPda(programId, lockId), { writable: true }),
1156
+ meta(deriveDisputeResolutionPda(programId, lockId), { writable: true }),
1157
+ meta(input.mint),
1158
+ meta(deriveEscrowPda(programId, lockId), { writable: true }),
1159
+ meta(input.payer, { writable: true }),
1160
+ meta(input.winner, { writable: true }),
1161
+ meta(deriveAta(input.winner, input.mint), { writable: true }),
1162
+ meta(input.feeRecipient),
1163
+ meta(deriveAta(input.feeRecipient, input.mint), { writable: true }),
1164
+ meta(input.treasury, { writable: true }),
1165
+ meta(web3_js.SystemProgram.programId),
1166
+ meta(SPL_TOKEN_PROGRAM_ID),
1167
+ meta(ASSOCIATED_TOKEN_PROGRAM_ID),
1168
+ ...eventCpiTail(programId)
1169
+ ]
1170
+ });
1171
+ }
1172
+ function buildCloseDisputeIx(input) {
1173
+ const { programId, lockId } = input;
1174
+ if (input.mint === null) {
1175
+ return noArgIx(programId, "close_dispute_native", [
1176
+ meta(input.authority, { signer: true, writable: true }),
1177
+ meta(deriveStakeVaultPda(programId), { writable: true }),
1178
+ meta(deriveLockPda(programId, lockId), { writable: true }),
1179
+ meta(deriveEscrowPda(programId, lockId), { writable: true }),
1180
+ meta(input.payer, { writable: true }),
1181
+ meta(input.payee, { writable: true }),
1182
+ meta(web3_js.SystemProgram.programId),
1183
+ ...eventCpiTail(programId)
1184
+ ]);
1185
+ }
1186
+ return noArgIx(programId, "close_dispute", [
1187
+ meta(input.authority, { signer: true, writable: true }),
1188
+ meta(deriveConfigPda(programId)),
1189
+ meta(deriveStakeVaultPda(programId), { writable: true }),
1190
+ meta(deriveLockPda(programId, lockId), { writable: true }),
1191
+ meta(input.mint),
1192
+ meta(deriveEscrowPda(programId, lockId), { writable: true }),
1193
+ meta(input.payer, { writable: true }),
1194
+ meta(deriveAta(input.payer, input.mint), { writable: true }),
1195
+ meta(input.payee, { writable: true }),
1196
+ meta(web3_js.SystemProgram.programId),
1197
+ meta(SPL_TOKEN_PROGRAM_ID),
1198
+ meta(ASSOCIATED_TOKEN_PROGRAM_ID),
1199
+ ...eventCpiTail(programId)
1200
+ ]);
1201
+ }
1202
+ async function fetchLockAccount(conn, programId, delegationId) {
1203
+ const lockId = deriveLockId(delegationId);
1204
+ const lockPda = deriveLockPda(programId, lockId);
1205
+ const info = await conn.getAccountInfo(lockPda);
1206
+ if (!info) return null;
1207
+ return { lockId, lockPda, lock: decodeLockAccount(Uint8Array.from(info.data)) };
1208
+ }
944
1209
 
945
1210
  // src/errors/post-commit.ts
946
1211
  var POST_COMMIT_ERROR_CODES = [
@@ -1005,6 +1270,7 @@ exports.ASSET_DECIMALS_MIN = ASSET_DECIMALS_MIN;
1005
1270
  exports.ASSET_SYMBOL_MAX_LEN = ASSET_SYMBOL_MAX_LEN;
1006
1271
  exports.ASSET_SYMBOL_MIN_LEN = ASSET_SYMBOL_MIN_LEN;
1007
1272
  exports.ASSET_WHITELIST = ASSET_WHITELIST;
1273
+ exports.ASSOCIATED_TOKEN_PROGRAM_ID = ASSOCIATED_TOKEN_PROGRAM_ID;
1008
1274
  exports.ASSOCIATED_TOKEN_PROGRAM_ID_BASE58 = ASSOCIATED_TOKEN_PROGRAM_ID_BASE58;
1009
1275
  exports.BODY_TYPES = BODY_TYPES;
1010
1276
  exports.BodyTypes = BodyTypes;
@@ -1049,6 +1315,7 @@ exports.LockTerminalStates = LockTerminalStates;
1049
1315
  exports.MAINNET_MINTS = MAINNET_MINTS;
1050
1316
  exports.MAX_CLOCK_SKEW_SECONDS = MAX_CLOCK_SKEW_SECONDS;
1051
1317
  exports.MAX_ENVELOPE_TTL_SECONDS = MAX_ENVELOPE_TTL_SECONDS;
1318
+ exports.NATIVE_SOL_MINT = NATIVE_SOL_MINT;
1052
1319
  exports.NATIVE_SOL_MINT_BASE58 = NATIVE_SOL_MINT_BASE58;
1053
1320
  exports.NO_ARG_LIFECYCLE_INSTRUCTIONS = NO_ARG_LIFECYCLE_INSTRUCTIONS;
1054
1321
  exports.OWNER_SIGNING_METHODS = OWNER_SIGNING_METHODS;
@@ -1067,6 +1334,7 @@ exports.SCRYPT_PARAMS = SCRYPT_PARAMS;
1067
1334
  exports.SHA256_HEX_RE = SHA256_HEX_RE;
1068
1335
  exports.SLIP44_SOLANA = SLIP44_SOLANA;
1069
1336
  exports.SOLANA_CLUSTER_IDS = SOLANA_CLUSTER_IDS;
1337
+ exports.SPL_TOKEN_PROGRAM_ID = SPL_TOKEN_PROGRAM_ID;
1070
1338
  exports.SPL_TOKEN_PROGRAM_ID_BASE58 = SPL_TOKEN_PROGRAM_ID_BASE58;
1071
1339
  exports.SYSTEM_PROGRAM_ID_BASE58 = SYSTEM_PROGRAM_ID_BASE58;
1072
1340
  exports.TOKEN_2022_PROGRAM_ID_BASE58 = TOKEN_2022_PROGRAM_ID_BASE58;
@@ -1076,9 +1344,18 @@ exports.WORK_LOG_STATES = WORK_LOG_STATES;
1076
1344
  exports.WorkLogStates = WorkLogStates;
1077
1345
  exports.base58btcDecode = base58btcDecode;
1078
1346
  exports.base58btcEncode = base58btcEncode;
1347
+ exports.buildAcceptLockIx = buildAcceptLockIx;
1348
+ exports.buildCancelLockIx = buildCancelLockIx;
1349
+ exports.buildClaimExpiredWorkIx = buildClaimExpiredWorkIx;
1350
+ exports.buildClaimWorkPaymentIx = buildClaimWorkPaymentIx;
1351
+ exports.buildCloseDisputeIx = buildCloseDisputeIx;
1352
+ exports.buildCreateLockIx = buildCreateLockIx;
1079
1353
  exports.buildCreateLockIxData = buildCreateLockIxData;
1080
1354
  exports.buildLifecycleIxData = buildLifecycleIxData;
1355
+ exports.buildOpenDisputeIx = buildOpenDisputeIx;
1356
+ exports.buildResolveDisputeIx = buildResolveDisputeIx;
1081
1357
  exports.buildResolveDisputeIxData = buildResolveDisputeIxData;
1358
+ exports.buildSubmitWorkIx = buildSubmitWorkIx;
1082
1359
  exports.bytes16ToDelegationId = bytes16ToDelegationId;
1083
1360
  exports.canonicalBytes = canonicalBytes;
1084
1361
  exports.canonicalJson = canonicalJson;
@@ -1087,12 +1364,22 @@ exports.computeCreateLockDiscriminator = computeCreateLockDiscriminator;
1087
1364
  exports.computeLockAccountDiscriminator = computeLockAccountDiscriminator;
1088
1365
  exports.decodeLockAccount = decodeLockAccount;
1089
1366
  exports.delegationIdToBytes16 = delegationIdToBytes16;
1367
+ exports.deriveAta = deriveAta;
1368
+ exports.deriveCollateralConfigPda = deriveCollateralConfigPda;
1369
+ exports.deriveConfigPda = deriveConfigPda;
1090
1370
  exports.deriveDelegationConditionHash = deriveDelegationConditionHash;
1371
+ exports.deriveDisputeResolutionPda = deriveDisputeResolutionPda;
1372
+ exports.deriveEscrowPda = deriveEscrowPda;
1373
+ exports.deriveEventAuthorityPda = deriveEventAuthorityPda;
1091
1374
  exports.deriveLockId = deriveLockId;
1375
+ exports.deriveLockPda = deriveLockPda;
1376
+ exports.deriveOperatorAuthPda = deriveOperatorAuthPda;
1092
1377
  exports.deriveScryptKey = deriveScryptKey;
1378
+ exports.deriveStakeVaultPda = deriveStakeVaultPda;
1093
1379
  exports.detectTokenProgramFromOwner = detectTokenProgramFromOwner;
1094
1380
  exports.detectTokenProgramFromOwnerBytes = detectTokenProgramFromOwnerBytes;
1095
1381
  exports.expiresAt = expiresAt;
1382
+ exports.fetchLockAccount = fetchLockAccount;
1096
1383
  exports.findAssetByAssetId = findAssetByAssetId;
1097
1384
  exports.findFirstChainDivergence = findFirstChainDivergence;
1098
1385
  exports.formatDid = formatDid;
package/dist/index.mjs CHANGED
@@ -5,6 +5,7 @@ import { base58, base64, base64urlnopad } from '@scure/base';
5
5
  import * as ed from '@noble/ed25519';
6
6
  import { hmac } from '@noble/hashes/hmac';
7
7
  import { scrypt } from '@noble/hashes/scrypt';
8
+ import { PublicKey, SystemProgram, TransactionInstruction } from '@solana/web3.js';
8
9
 
9
10
  // src/canonical/canonicalize.ts
10
11
  function canonicalJson(value) {
@@ -916,6 +917,270 @@ function readU64LE(buf, off) {
916
917
  }
917
918
  return v;
918
919
  }
920
+ var SPL_TOKEN_PROGRAM_ID = new PublicKey(SPL_TOKEN_PROGRAM_ID_BASE58);
921
+ var ASSOCIATED_TOKEN_PROGRAM_ID = new PublicKey(ASSOCIATED_TOKEN_PROGRAM_ID_BASE58);
922
+ var NATIVE_SOL_MINT = new PublicKey(NATIVE_SOL_MINT_BASE58);
923
+ function deriveLockPda(programId, lockId) {
924
+ return PublicKey.findProgramAddressSync([Buffer.from(ESCROW_PDA_SEEDS.LOCK), Buffer.from(lockId)], programId)[0];
925
+ }
926
+ function deriveEscrowPda(programId, lockId) {
927
+ return PublicKey.findProgramAddressSync([Buffer.from(ESCROW_PDA_SEEDS.ESCROW), Buffer.from(lockId)], programId)[0];
928
+ }
929
+ function deriveConfigPda(programId) {
930
+ return PublicKey.findProgramAddressSync([Buffer.from(ESCROW_PDA_SEEDS.CONFIG)], programId)[0];
931
+ }
932
+ function deriveStakeVaultPda(programId) {
933
+ return PublicKey.findProgramAddressSync([Buffer.from(ESCROW_PDA_SEEDS.STAKE_VAULT)], programId)[0];
934
+ }
935
+ function deriveCollateralConfigPda(programId, mint) {
936
+ return PublicKey.findProgramAddressSync([Buffer.from(ESCROW_PDA_SEEDS.COLLATERAL), mint.toBuffer()], programId)[0];
937
+ }
938
+ function deriveDisputeResolutionPda(programId, lockId) {
939
+ return PublicKey.findProgramAddressSync([Buffer.from(ESCROW_PDA_SEEDS.DISPUTE_RESOLUTION), Buffer.from(lockId)], programId)[0];
940
+ }
941
+ function deriveOperatorAuthPda(programId, operator) {
942
+ return PublicKey.findProgramAddressSync([Buffer.from(ESCROW_PDA_SEEDS.OPERATOR_AUTH), operator.toBuffer()], programId)[0];
943
+ }
944
+ function deriveEventAuthorityPda(programId) {
945
+ return PublicKey.findProgramAddressSync([Buffer.from(ESCROW_PDA_SEEDS.EVENT_AUTHORITY)], programId)[0];
946
+ }
947
+ function deriveAta(owner, mint) {
948
+ return PublicKey.findProgramAddressSync([owner.toBuffer(), SPL_TOKEN_PROGRAM_ID.toBuffer(), mint.toBuffer()], ASSOCIATED_TOKEN_PROGRAM_ID)[0];
949
+ }
950
+ function eventCpiTail(programId) {
951
+ return [
952
+ { pubkey: deriveEventAuthorityPda(programId), isSigner: false, isWritable: false },
953
+ { pubkey: programId, isSigner: false, isWritable: false }
954
+ ];
955
+ }
956
+ function meta(pubkey, opts = {}) {
957
+ return { pubkey, isSigner: opts.signer === true, isWritable: opts.writable === true };
958
+ }
959
+ function noArgIx(programId, name, keys) {
960
+ return new TransactionInstruction({ programId, keys, data: Buffer.from(buildLifecycleIxData(name)) });
961
+ }
962
+ function buildCreateLockIx(input) {
963
+ const { programId, lockId } = input;
964
+ const native = input.mint === null;
965
+ const data = Buffer.from(buildCreateLockIxData({ lockId, amount: input.amount, conditionHash: input.conditionHash }, { native }));
966
+ const head = [
967
+ meta(input.payer, { signer: true, writable: true }),
968
+ meta(input.payee),
969
+ meta(deriveConfigPda(programId)),
970
+ meta(deriveLockPda(programId, lockId), { writable: true }),
971
+ meta(deriveCollateralConfigPda(programId, input.mint ?? NATIVE_SOL_MINT))
972
+ ];
973
+ const keys = native ? [...head, meta(deriveEscrowPda(programId, lockId), { writable: true }), meta(SystemProgram.programId), ...eventCpiTail(programId)] : [
974
+ ...head,
975
+ meta(input.mint),
976
+ meta(deriveAta(input.payer, input.mint), { writable: true }),
977
+ meta(deriveEscrowPda(programId, lockId), { writable: true }),
978
+ meta(SystemProgram.programId),
979
+ meta(SPL_TOKEN_PROGRAM_ID),
980
+ ...eventCpiTail(programId)
981
+ ];
982
+ return new TransactionInstruction({ programId, keys, data });
983
+ }
984
+ function buildAcceptLockIx(input) {
985
+ const { programId, lockId } = input;
986
+ return noArgIx(programId, "accept_lock", [
987
+ meta(input.payee, { signer: true, writable: true }),
988
+ meta(deriveConfigPda(programId)),
989
+ meta(deriveStakeVaultPda(programId), { writable: true }),
990
+ meta(deriveLockPda(programId, lockId), { writable: true }),
991
+ meta(SystemProgram.programId),
992
+ ...eventCpiTail(programId)
993
+ ]);
994
+ }
995
+ function buildSubmitWorkIx(input) {
996
+ const { programId, lockId } = input;
997
+ return noArgIx(programId, "submit_work", [
998
+ meta(input.payee, { signer: true }),
999
+ meta(deriveConfigPda(programId)),
1000
+ meta(deriveLockPda(programId, lockId), { writable: true }),
1001
+ ...eventCpiTail(programId)
1002
+ ]);
1003
+ }
1004
+ function buildClaimWorkPaymentIx(input) {
1005
+ const { programId, lockId } = input;
1006
+ if (input.mint === null) {
1007
+ return noArgIx(programId, "claim_work_payment_native", [
1008
+ meta(input.authority, { signer: true, writable: true }),
1009
+ meta(deriveStakeVaultPda(programId), { writable: true }),
1010
+ meta(deriveLockPda(programId, lockId), { writable: true }),
1011
+ meta(deriveEscrowPda(programId, lockId), { writable: true }),
1012
+ meta(input.payer, { writable: true }),
1013
+ meta(input.payee, { writable: true }),
1014
+ meta(input.feeRecipient, { writable: true }),
1015
+ meta(SystemProgram.programId),
1016
+ ...eventCpiTail(programId)
1017
+ ]);
1018
+ }
1019
+ return noArgIx(programId, "claim_work_payment", [
1020
+ meta(input.authority, { signer: true, writable: true }),
1021
+ meta(deriveConfigPda(programId)),
1022
+ meta(deriveStakeVaultPda(programId), { writable: true }),
1023
+ meta(deriveLockPda(programId, lockId), { writable: true }),
1024
+ meta(input.mint),
1025
+ meta(deriveEscrowPda(programId, lockId), { writable: true }),
1026
+ meta(input.payer, { writable: true }),
1027
+ meta(input.payee, { writable: true }),
1028
+ meta(deriveAta(input.payee, input.mint), { writable: true }),
1029
+ meta(input.feeRecipient),
1030
+ meta(deriveAta(input.feeRecipient, input.mint), { writable: true }),
1031
+ meta(SystemProgram.programId),
1032
+ meta(SPL_TOKEN_PROGRAM_ID),
1033
+ meta(ASSOCIATED_TOKEN_PROGRAM_ID),
1034
+ ...eventCpiTail(programId)
1035
+ ]);
1036
+ }
1037
+ function buildCancelLockIx(input) {
1038
+ const { programId, lockId } = input;
1039
+ if (input.mint === null) {
1040
+ return noArgIx(programId, "cancel_lock_native", [
1041
+ meta(input.payer, { signer: true, writable: true }),
1042
+ meta(deriveLockPda(programId, lockId), { writable: true }),
1043
+ meta(deriveEscrowPda(programId, lockId), { writable: true }),
1044
+ meta(SystemProgram.programId),
1045
+ ...eventCpiTail(programId)
1046
+ ]);
1047
+ }
1048
+ return noArgIx(programId, "cancel_lock", [
1049
+ meta(input.payer, { signer: true, writable: true }),
1050
+ meta(deriveConfigPda(programId)),
1051
+ meta(deriveLockPda(programId, lockId), { writable: true }),
1052
+ meta(input.mint),
1053
+ meta(deriveEscrowPda(programId, lockId), { writable: true }),
1054
+ meta(deriveAta(input.payer, input.mint), { writable: true }),
1055
+ meta(SystemProgram.programId),
1056
+ meta(SPL_TOKEN_PROGRAM_ID),
1057
+ meta(ASSOCIATED_TOKEN_PROGRAM_ID),
1058
+ ...eventCpiTail(programId)
1059
+ ]);
1060
+ }
1061
+ function buildClaimExpiredWorkIx(input) {
1062
+ const { programId, lockId } = input;
1063
+ if (input.mint === null) {
1064
+ return noArgIx(programId, "claim_expired_work_native", [
1065
+ meta(input.payer, { signer: true, writable: true }),
1066
+ meta(deriveStakeVaultPda(programId), { writable: true }),
1067
+ meta(deriveLockPda(programId, lockId), { writable: true }),
1068
+ meta(deriveEscrowPda(programId, lockId), { writable: true }),
1069
+ meta(SystemProgram.programId),
1070
+ ...eventCpiTail(programId)
1071
+ ]);
1072
+ }
1073
+ return noArgIx(programId, "claim_expired_work", [
1074
+ meta(input.payer, { signer: true, writable: true }),
1075
+ meta(deriveConfigPda(programId)),
1076
+ meta(deriveStakeVaultPda(programId), { writable: true }),
1077
+ meta(deriveLockPda(programId, lockId), { writable: true }),
1078
+ meta(input.mint),
1079
+ meta(deriveEscrowPda(programId, lockId), { writable: true }),
1080
+ meta(deriveAta(input.payer, input.mint), { writable: true }),
1081
+ meta(SystemProgram.programId),
1082
+ meta(SPL_TOKEN_PROGRAM_ID),
1083
+ meta(ASSOCIATED_TOKEN_PROGRAM_ID),
1084
+ ...eventCpiTail(programId)
1085
+ ]);
1086
+ }
1087
+ function buildOpenDisputeIx(input) {
1088
+ const { programId, lockId } = input;
1089
+ return noArgIx(programId, "open_dispute", [
1090
+ meta(input.payer, { signer: true, writable: true }),
1091
+ meta(deriveConfigPda(programId)),
1092
+ meta(deriveStakeVaultPda(programId), { writable: true }),
1093
+ meta(deriveLockPda(programId, lockId), { writable: true }),
1094
+ meta(SystemProgram.programId),
1095
+ ...eventCpiTail(programId)
1096
+ ]);
1097
+ }
1098
+ function buildResolveDisputeIx(input) {
1099
+ const { programId, lockId } = input;
1100
+ const native = input.mint === null;
1101
+ const data = Buffer.from(buildResolveDisputeIxData(input.args, { native }));
1102
+ if (native) {
1103
+ return new TransactionInstruction({
1104
+ programId,
1105
+ data,
1106
+ keys: [
1107
+ meta(input.operator, { signer: true, writable: true }),
1108
+ meta(deriveOperatorAuthPda(programId, input.operator)),
1109
+ meta(deriveStakeVaultPda(programId), { writable: true }),
1110
+ meta(deriveLockPda(programId, lockId), { writable: true }),
1111
+ meta(deriveDisputeResolutionPda(programId, lockId), { writable: true }),
1112
+ meta(deriveEscrowPda(programId, lockId), { writable: true }),
1113
+ meta(input.payer, { writable: true }),
1114
+ meta(input.winner, { writable: true }),
1115
+ meta(input.feeRecipient, { writable: true }),
1116
+ meta(input.treasury, { writable: true }),
1117
+ meta(SystemProgram.programId),
1118
+ ...eventCpiTail(programId)
1119
+ ]
1120
+ });
1121
+ }
1122
+ return new TransactionInstruction({
1123
+ programId,
1124
+ data,
1125
+ keys: [
1126
+ meta(input.operator, { signer: true, writable: true }),
1127
+ meta(deriveOperatorAuthPda(programId, input.operator)),
1128
+ meta(deriveConfigPda(programId)),
1129
+ meta(deriveStakeVaultPda(programId), { writable: true }),
1130
+ meta(deriveLockPda(programId, lockId), { writable: true }),
1131
+ meta(deriveDisputeResolutionPda(programId, lockId), { writable: true }),
1132
+ meta(input.mint),
1133
+ meta(deriveEscrowPda(programId, lockId), { writable: true }),
1134
+ meta(input.payer, { writable: true }),
1135
+ meta(input.winner, { writable: true }),
1136
+ meta(deriveAta(input.winner, input.mint), { writable: true }),
1137
+ meta(input.feeRecipient),
1138
+ meta(deriveAta(input.feeRecipient, input.mint), { writable: true }),
1139
+ meta(input.treasury, { writable: true }),
1140
+ meta(SystemProgram.programId),
1141
+ meta(SPL_TOKEN_PROGRAM_ID),
1142
+ meta(ASSOCIATED_TOKEN_PROGRAM_ID),
1143
+ ...eventCpiTail(programId)
1144
+ ]
1145
+ });
1146
+ }
1147
+ function buildCloseDisputeIx(input) {
1148
+ const { programId, lockId } = input;
1149
+ if (input.mint === null) {
1150
+ return noArgIx(programId, "close_dispute_native", [
1151
+ meta(input.authority, { signer: true, writable: true }),
1152
+ meta(deriveStakeVaultPda(programId), { writable: true }),
1153
+ meta(deriveLockPda(programId, lockId), { writable: true }),
1154
+ meta(deriveEscrowPda(programId, lockId), { writable: true }),
1155
+ meta(input.payer, { writable: true }),
1156
+ meta(input.payee, { writable: true }),
1157
+ meta(SystemProgram.programId),
1158
+ ...eventCpiTail(programId)
1159
+ ]);
1160
+ }
1161
+ return noArgIx(programId, "close_dispute", [
1162
+ meta(input.authority, { signer: true, writable: true }),
1163
+ meta(deriveConfigPda(programId)),
1164
+ meta(deriveStakeVaultPda(programId), { writable: true }),
1165
+ meta(deriveLockPda(programId, lockId), { writable: true }),
1166
+ meta(input.mint),
1167
+ meta(deriveEscrowPda(programId, lockId), { writable: true }),
1168
+ meta(input.payer, { writable: true }),
1169
+ meta(deriveAta(input.payer, input.mint), { writable: true }),
1170
+ meta(input.payee, { writable: true }),
1171
+ meta(SystemProgram.programId),
1172
+ meta(SPL_TOKEN_PROGRAM_ID),
1173
+ meta(ASSOCIATED_TOKEN_PROGRAM_ID),
1174
+ ...eventCpiTail(programId)
1175
+ ]);
1176
+ }
1177
+ async function fetchLockAccount(conn, programId, delegationId) {
1178
+ const lockId = deriveLockId(delegationId);
1179
+ const lockPda = deriveLockPda(programId, lockId);
1180
+ const info = await conn.getAccountInfo(lockPda);
1181
+ if (!info) return null;
1182
+ return { lockId, lockPda, lock: decodeLockAccount(Uint8Array.from(info.data)) };
1183
+ }
919
1184
 
920
1185
  // src/errors/post-commit.ts
921
1186
  var POST_COMMIT_ERROR_CODES = [
@@ -973,4 +1238,4 @@ var CliAuthTokenErrorCodes = {
973
1238
  REQUIRED: "AUTH_TOKEN_REQUIRED"
974
1239
  };
975
1240
 
976
- export { AGENT_NAME_REGEX, AGENT_TAG_REGEX, ASSET_DECIMALS_MAX, ASSET_DECIMALS_MIN, ASSET_SYMBOL_MAX_LEN, ASSET_SYMBOL_MIN_LEN, ASSET_WHITELIST, ASSOCIATED_TOKEN_PROGRAM_ID_BASE58, BODY_TYPES, BodyTypes, CAIP19_REGEX, CLI_AUTH_TOKEN_ERROR_CODES, CLI_LOGIN_SESSION_STATES, CLI_LOGIN_SESSION_STORED_STATES, CREATE_LOCK_DISCRIMINATOR, CREATE_LOCK_NATIVE_DISCRIMINATOR, CURRENT_PROTOCOL_VERSION, CliAuthTokenErrorCodes, CliLoginSessionStates, DECIMAL_AMOUNT_REGEX, DECLINE_REASONS, DELEGATION_ACTIONS, DELEGATION_ACTIVE_STATES, DELEGATION_OFFER_REJECTION_CODES, DELEGATION_STATES, DEVNET_MINTS, DID_ARP_REGEX, DISCOVERY_SORTS, DelegationActions, DelegationOfferRejectionCodes, DelegationStates, DiscoverySorts, ED25519_SIG_PREFIX, ESCROW_PDA_SEEDS, ESCROW_PROGRAM_ID_BASE58, ESCROW_RELEASE_METHODS, EscrowReleaseMethods, HANDSHAKE_DECISIONS, HandshakeDecisions, INBOX_BLOCK_SCOPES, InboxBlockScopes, LIVE_RELATIONSHIP_STATE_NAMES, LOCK_ACCOUNT_DISCRIMINATOR, LOCK_ACCOUNT_SIZE, LOCK_STATE_NAMES, LOCK_TERMINAL_STATES, LockStates, LockTerminalStates, MAINNET_MINTS, MAX_CLOCK_SKEW_SECONDS, MAX_ENVELOPE_TTL_SECONDS, NATIVE_SOL_MINT_BASE58, NO_ARG_LIFECYCLE_INSTRUCTIONS, OWNER_SIGNING_METHODS, POST_COMMIT_ERROR_CODES, POST_COMMIT_ERROR_CODE_PREFIXES, PROTOCOL_VERSIONS, Purpose, READ_MODEL_STATUSES, RECEIPT_VERDICTS, RELATIONSHIP_STATE_NAMES, RESERVED_NAMES, ReadModelStatuses, ReceiptVerdicts, RelationshipStates, SCRYPT_PARAMS, SHA256_HEX_RE, SLIP44_SOLANA, SOLANA_CLUSTER_IDS, SPL_TOKEN_PROGRAM_ID_BASE58, SYSTEM_PROGRAM_ID_BASE58, TOKEN_2022_PROGRAM_ID_BASE58, WELL_KNOWN_ASSETS, WELL_KNOWN_ASSET_KEYS, WORK_LOG_STATES, WorkLogStates, base58btcDecode, base58btcEncode, buildCreateLockIxData, buildLifecycleIxData, buildResolveDisputeIxData, bytes16ToDelegationId, canonicalBytes, canonicalJson, canonicalSha256Hex, computeCreateLockDiscriminator, computeLockAccountDiscriminator, decodeLockAccount, delegationIdToBytes16, deriveDelegationConditionHash, deriveLockId, deriveScryptKey, detectTokenProgramFromOwner, detectTokenProgramFromOwnerBytes, expiresAt, findAssetByAssetId, findFirstChainDivergence, formatDid, generateKeyPair, getPublicKey2 as getPublicKey, instructionDiscriminator, isAssetIdentifier, isBodyType, isCliLoginSessionWireState, isDecimalAmountString, isDeclineReason, isDelegationAction, isDelegationState, isDiscoverySort, isEscrowReleaseMethod, isHandshakeDecision, isInboxBlockScope, isPostCommitErrorCode, isReadModelStatus, isReceiptVerdict, isRelationshipState, isReservedName, isSha256Hex, isValidAgentName, isValidDid, isWhitelistedAssetId, isWorkLogState, listWhitelistedAssets, normalizeName, parseCaip19SolanaAssetId, parseDid, pollUntil, resolveAsset, rfc3339, scryptPasswordProofSign, scryptPasswordProofVerify, senderNonce, serverEventHash, sign2 as sign, signChallenge, signEnvelope, signKeyLinkAttestation, signedMessageHash, uuidV4, verify2 as verify, verifyChallenge, verifyEnvelope, verifyKeyLinkAttestation };
1241
+ export { AGENT_NAME_REGEX, AGENT_TAG_REGEX, ASSET_DECIMALS_MAX, ASSET_DECIMALS_MIN, ASSET_SYMBOL_MAX_LEN, ASSET_SYMBOL_MIN_LEN, ASSET_WHITELIST, ASSOCIATED_TOKEN_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID_BASE58, BODY_TYPES, BodyTypes, CAIP19_REGEX, CLI_AUTH_TOKEN_ERROR_CODES, CLI_LOGIN_SESSION_STATES, CLI_LOGIN_SESSION_STORED_STATES, CREATE_LOCK_DISCRIMINATOR, CREATE_LOCK_NATIVE_DISCRIMINATOR, CURRENT_PROTOCOL_VERSION, CliAuthTokenErrorCodes, CliLoginSessionStates, DECIMAL_AMOUNT_REGEX, DECLINE_REASONS, DELEGATION_ACTIONS, DELEGATION_ACTIVE_STATES, DELEGATION_OFFER_REJECTION_CODES, DELEGATION_STATES, DEVNET_MINTS, DID_ARP_REGEX, DISCOVERY_SORTS, DelegationActions, DelegationOfferRejectionCodes, DelegationStates, DiscoverySorts, ED25519_SIG_PREFIX, ESCROW_PDA_SEEDS, ESCROW_PROGRAM_ID_BASE58, ESCROW_RELEASE_METHODS, EscrowReleaseMethods, HANDSHAKE_DECISIONS, HandshakeDecisions, INBOX_BLOCK_SCOPES, InboxBlockScopes, LIVE_RELATIONSHIP_STATE_NAMES, LOCK_ACCOUNT_DISCRIMINATOR, LOCK_ACCOUNT_SIZE, LOCK_STATE_NAMES, LOCK_TERMINAL_STATES, LockStates, LockTerminalStates, MAINNET_MINTS, MAX_CLOCK_SKEW_SECONDS, MAX_ENVELOPE_TTL_SECONDS, NATIVE_SOL_MINT, NATIVE_SOL_MINT_BASE58, NO_ARG_LIFECYCLE_INSTRUCTIONS, OWNER_SIGNING_METHODS, POST_COMMIT_ERROR_CODES, POST_COMMIT_ERROR_CODE_PREFIXES, PROTOCOL_VERSIONS, Purpose, READ_MODEL_STATUSES, RECEIPT_VERDICTS, RELATIONSHIP_STATE_NAMES, RESERVED_NAMES, ReadModelStatuses, ReceiptVerdicts, RelationshipStates, SCRYPT_PARAMS, SHA256_HEX_RE, SLIP44_SOLANA, SOLANA_CLUSTER_IDS, SPL_TOKEN_PROGRAM_ID, SPL_TOKEN_PROGRAM_ID_BASE58, SYSTEM_PROGRAM_ID_BASE58, TOKEN_2022_PROGRAM_ID_BASE58, WELL_KNOWN_ASSETS, WELL_KNOWN_ASSET_KEYS, WORK_LOG_STATES, WorkLogStates, base58btcDecode, base58btcEncode, buildAcceptLockIx, buildCancelLockIx, buildClaimExpiredWorkIx, buildClaimWorkPaymentIx, buildCloseDisputeIx, buildCreateLockIx, buildCreateLockIxData, buildLifecycleIxData, buildOpenDisputeIx, buildResolveDisputeIx, buildResolveDisputeIxData, buildSubmitWorkIx, bytes16ToDelegationId, canonicalBytes, canonicalJson, canonicalSha256Hex, computeCreateLockDiscriminator, computeLockAccountDiscriminator, decodeLockAccount, delegationIdToBytes16, deriveAta, deriveCollateralConfigPda, deriveConfigPda, deriveDelegationConditionHash, deriveDisputeResolutionPda, deriveEscrowPda, deriveEventAuthorityPda, deriveLockId, deriveLockPda, deriveOperatorAuthPda, deriveScryptKey, deriveStakeVaultPda, detectTokenProgramFromOwner, detectTokenProgramFromOwnerBytes, expiresAt, fetchLockAccount, findAssetByAssetId, findFirstChainDivergence, formatDid, generateKeyPair, getPublicKey2 as getPublicKey, instructionDiscriminator, isAssetIdentifier, isBodyType, isCliLoginSessionWireState, isDecimalAmountString, isDeclineReason, isDelegationAction, isDelegationState, isDiscoverySort, isEscrowReleaseMethod, isHandshakeDecision, isInboxBlockScope, isPostCommitErrorCode, isReadModelStatus, isReceiptVerdict, isRelationshipState, isReservedName, isSha256Hex, isValidAgentName, isValidDid, isWhitelistedAssetId, isWorkLogState, listWhitelistedAssets, normalizeName, parseCaip19SolanaAssetId, parseDid, pollUntil, resolveAsset, rfc3339, scryptPasswordProofSign, scryptPasswordProofVerify, senderNonce, serverEventHash, sign2 as sign, signChallenge, signEnvelope, signKeyLinkAttestation, signedMessageHash, uuidV4, verify2 as verify, verifyChallenge, verifyEnvelope, verifyKeyLinkAttestation };
@@ -16,7 +16,7 @@ export type { InboxBlockScope, InboxBlock, BlockInboxBody } from './inbox';
16
16
  export { INBOX_BLOCK_SCOPES, InboxBlockScopes, isInboxBlockScope } from './inbox';
17
17
  export type { CliSessionCreated, CliTokenIssued, CliWhoami, MyAgentSummary, CliLoginSessionStoredState, CliLoginSessionWireState, } from './cli-auth';
18
18
  export { CLI_LOGIN_SESSION_STORED_STATES, CLI_LOGIN_SESSION_STATES, CliLoginSessionStates, isCliLoginSessionWireState } from './cli-auth';
19
- export type { AssetIdentifierWire, DelegationPublic, ReceiptPublic, RelationshipPublic, WorkLogPublic, EventPublic, IngestResult, SenderSequenceResponse, InboxUnblockResult, ListRelationshipsQuery, ListInboxQuery, ListEventsQuery, ListDelegationsQuery, ListWorkLogsQuery, ListReceiptsQuery, } from './read-model';
19
+ export type { AssetIdentifierWire, DelegationPublic, DisputeResolutionPublic, ReceiptPublic, RelationshipPublic, WorkLogPublic, EventPublic, IngestResult, SenderSequenceResponse, InboxUnblockResult, ListRelationshipsQuery, ListInboxQuery, ListEventsQuery, ListDelegationsQuery, ListWorkLogsQuery, ListReceiptsQuery, } from './read-model';
20
20
  export type { AcceptPrefs, AcceptCurrency, AgentRegisteredResponse, AgentPublic, UpdateAgentBody, RegisterAgentRequest, ChallengeResponse, ReputationScores, ReputationCounters, AgentReputation, } from './agent';
21
21
  export { AGENT_TAG_REGEX, AGENT_NAME_REGEX, RESERVED_NAMES, isReservedName, isValidAgentName, normalizeName } from './agent';
22
22
  export type { OwnerSigningMethod, KeyLinkPayload, ScryptPasswordAttestation } from './identity';
@@ -217,3 +217,34 @@ export interface ListReceiptsQuery {
217
217
  after?: string;
218
218
  limit?: number;
219
219
  }
220
+ /**
221
+ * Public projection of an autonomous dispute resolution — the arbiter's
222
+ * verdict for a disputed delegation. Returned by signed
223
+ * `GET /v1/escrow/disputes/:delegationId` (parties only); the server's
224
+ * DisputeReadService maps the `dispute_resolutions` row to this shape and the
225
+ * CLI consumes it. `winnerRole`/`winnerDid` are derived (payer = buyer/offerer,
226
+ * payee = worker/recipient); `verdictSource` is `llm` | `objective_fallback`;
227
+ * `solanaSignature` is the on-chain `resolve_dispute` tx. `status` /
228
+ * `verdictSource` are carried as strings here — they are the server-side
229
+ * worker-queue enums, not shared on-chain wire vocab.
230
+ */
231
+ export interface DisputeResolutionPublic {
232
+ delegationId: string;
233
+ lockId: string;
234
+ status: string;
235
+ disputeId: string | null;
236
+ isPayerWinner: boolean | null;
237
+ winnerRole: 'payer' | 'payee' | null;
238
+ winnerDid: string | null;
239
+ verdictSource: string | null;
240
+ reasoning: string | null;
241
+ policyId: string | null;
242
+ snapshotHash: string | null;
243
+ reasonHashHex: string | null;
244
+ solanaSignature: string | null;
245
+ attempts: number;
246
+ lastError: string | null;
247
+ deadlineAt: string | null;
248
+ createdAt: string | null;
249
+ updatedAt: string | null;
250
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heyanon-arp/sdk",
3
- "version": "0.0.29",
3
+ "version": "0.0.31",
4
4
  "description": "TypeScript SDK for the Agent Relationship Protocol — canonical JSON, Ed25519 envelope sign/verify, did:arp identity, scrypt key attestation, chain-audit helpers.",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -40,7 +40,16 @@
40
40
  "@scure/base": "^1.1.9",
41
41
  "canonicalize": "^2.0.0"
42
42
  },
43
+ "peerDependencies": {
44
+ "@solana/web3.js": "^1.98.0"
45
+ },
46
+ "peerDependenciesMeta": {
47
+ "@solana/web3.js": {
48
+ "optional": true
49
+ }
50
+ },
43
51
  "devDependencies": {
52
+ "@solana/web3.js": "^1.98.4",
44
53
  "@types/node": "^22.10.7",
45
54
  "tslib": "^2.6.2",
46
55
  "tsup": "^8.3.5",