veilioexchange 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -1
- package/dist/cjs/solana/auction.d.ts +180 -0
- package/dist/cjs/solana/auction.d.ts.map +1 -0
- package/dist/cjs/solana/auction.js +457 -0
- package/dist/cjs/solana/auction.js.map +1 -0
- package/dist/cjs/solana/client.d.ts +75 -0
- package/dist/cjs/solana/client.d.ts.map +1 -0
- package/dist/cjs/solana/client.js +281 -0
- package/dist/cjs/solana/client.js.map +1 -0
- package/dist/cjs/solana/escrow.d.ts +140 -0
- package/dist/cjs/solana/escrow.d.ts.map +1 -0
- package/dist/cjs/solana/escrow.js +354 -0
- package/dist/cjs/solana/escrow.js.map +1 -0
- package/dist/cjs/solana/index.d.ts +9 -0
- package/dist/cjs/solana/index.d.ts.map +1 -0
- package/dist/cjs/solana/index.js +32 -0
- package/dist/cjs/solana/index.js.map +1 -0
- package/dist/cjs/solana/registry.d.ts +100 -0
- package/dist/cjs/solana/registry.d.ts.map +1 -0
- package/dist/cjs/solana/registry.js +278 -0
- package/dist/cjs/solana/registry.js.map +1 -0
- package/dist/esm/solana/auction.d.ts +180 -0
- package/dist/esm/solana/auction.d.ts.map +1 -0
- package/dist/esm/solana/auction.js +438 -0
- package/dist/esm/solana/auction.js.map +1 -0
- package/dist/esm/solana/client.d.ts +75 -0
- package/dist/esm/solana/client.d.ts.map +1 -0
- package/dist/esm/solana/client.js +274 -0
- package/dist/esm/solana/client.js.map +1 -0
- package/dist/esm/solana/escrow.d.ts +140 -0
- package/dist/esm/solana/escrow.d.ts.map +1 -0
- package/dist/esm/solana/escrow.js +339 -0
- package/dist/esm/solana/escrow.js.map +1 -0
- package/dist/esm/solana/index.d.ts +9 -0
- package/dist/esm/solana/index.d.ts.map +1 -0
- package/dist/esm/solana/index.js +9 -0
- package/dist/esm/solana/index.js.map +1 -0
- package/dist/esm/solana/registry.d.ts +100 -0
- package/dist/esm/solana/registry.d.ts.map +1 -0
- package/dist/esm/solana/registry.js +264 -0
- package/dist/esm/solana/registry.js.map +1 -0
- package/package.json +30 -4
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { randomBytes } from 'node:crypto';
|
|
2
|
+
import { LAMPORTS_PER_SOL, PublicKey, Transaction, TransactionInstruction, } from '@solana/web3.js';
|
|
3
|
+
import { VeilioSdkError } from '../errors.js';
|
|
4
|
+
import { DEFAULT_SOLANA_AUCTION_PROGRAM_ID, computeSealedBidCommitment, createAcceptDatasetInstruction, createClaimRefundInstruction, createCommitBidInstruction, createRevealBidInstruction, decodeAuctionStateAccount, findAuctionPda, } from './auction.js';
|
|
5
|
+
import { DEFAULT_SOLANA_SERVICE_ESCROW_PROGRAM_ID, createCancelOrRefundInstruction, createDepositServiceOrderInstruction, createDisputeOrderInstruction, createReleaseFundsInstruction, createSubmitDeliveryInstruction, decodeEscrowOrderAccount, findEscrowOrderPda, } from './escrow.js';
|
|
6
|
+
import { encodeBase58, getAnchorDiscriminator } from './registry.js';
|
|
7
|
+
/** Wraps a Keypair (e.g. an agent's devnet key) as a SolanaSigner. */
|
|
8
|
+
export function keypairSigner(keypair) {
|
|
9
|
+
return {
|
|
10
|
+
publicKey: keypair.publicKey,
|
|
11
|
+
async signTransaction(transaction) {
|
|
12
|
+
transaction.partialSign(keypair);
|
|
13
|
+
return transaction;
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Encodes an order ID into the 32-byte seed the escrow program expects.
|
|
19
|
+
* Accepts a 64-char hex string as-is; otherwise UTF-8 bytes right-padded with zeros
|
|
20
|
+
* (same encoding the EVM escrow uses), up to 32 bytes.
|
|
21
|
+
*/
|
|
22
|
+
export function toSolanaOrderId(orderId) {
|
|
23
|
+
const hex = orderId.startsWith('0x') ? orderId.slice(2) : orderId;
|
|
24
|
+
if (/^[0-9a-fA-F]{64}$/.test(hex))
|
|
25
|
+
return hex.toLowerCase();
|
|
26
|
+
const bytes = Buffer.from(orderId, 'utf8');
|
|
27
|
+
if (bytes.length === 0 || bytes.length > 32) {
|
|
28
|
+
throw new VeilioSdkError({ code: 'INVALID_INPUT', message: 'orderId must be 1 to 32 bytes of UTF-8, or 32 bytes of hex.' });
|
|
29
|
+
}
|
|
30
|
+
return Buffer.concat([bytes, Buffer.alloc(32 - bytes.length)]).toString('hex');
|
|
31
|
+
}
|
|
32
|
+
/** Converts a decimal SOL string to lamports without floating-point rounding. */
|
|
33
|
+
export function solToLamports(sol) {
|
|
34
|
+
const trimmed = sol.trim();
|
|
35
|
+
if (!/^\d+(\.\d{1,9})?$/.test(trimmed)) {
|
|
36
|
+
throw new VeilioSdkError({ code: 'INVALID_INPUT', message: `Invalid SOL amount: "${sol}" (max 9 decimals).` });
|
|
37
|
+
}
|
|
38
|
+
const [whole, fraction = ''] = trimmed.split('.');
|
|
39
|
+
return BigInt(whole) * BigInt(LAMPORTS_PER_SOL) + BigInt(fraction.padEnd(9, '0'));
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Validates a base58 address. A lowercased address often still decodes to 32 bytes, so it would
|
|
43
|
+
* silently point at the wrong account; real addresses with no uppercase letter are vanishingly rare.
|
|
44
|
+
*/
|
|
45
|
+
export function assertSolanaAddress(label, value) {
|
|
46
|
+
let valid = true;
|
|
47
|
+
try {
|
|
48
|
+
new PublicKey(value);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
valid = false;
|
|
52
|
+
}
|
|
53
|
+
if (!valid || value === value.toLowerCase()) {
|
|
54
|
+
throw new VeilioSdkError({
|
|
55
|
+
code: 'INVALID_INPUT',
|
|
56
|
+
message: `${label} is not a valid Solana address. Base58 is case-sensitive: never lowercase it.`,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function toTransactionInstruction(ix) {
|
|
61
|
+
return new TransactionInstruction({
|
|
62
|
+
programId: new PublicKey(ix.programId),
|
|
63
|
+
keys: ix.accounts.map((meta) => ({
|
|
64
|
+
pubkey: new PublicKey(meta.pubkey),
|
|
65
|
+
isSigner: meta.isSigner,
|
|
66
|
+
isWritable: meta.isWritable,
|
|
67
|
+
})),
|
|
68
|
+
data: Buffer.from(ix.data),
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* High-level client for VEILIO on Solana Devnet: sealed-bid auctions and service escrow.
|
|
73
|
+
* Node.js 18+ (uses node:crypto and Buffer).
|
|
74
|
+
*/
|
|
75
|
+
export function createVeilioSolanaClient(options) {
|
|
76
|
+
const { connection } = options;
|
|
77
|
+
const commitment = options.commitment ?? 'confirmed';
|
|
78
|
+
const auctionProgramId = options.auctionProgramId ?? DEFAULT_SOLANA_AUCTION_PROGRAM_ID;
|
|
79
|
+
const escrowProgramId = options.escrowProgramId ?? DEFAULT_SOLANA_SERVICE_ESCROW_PROGRAM_ID;
|
|
80
|
+
function requireSigner() {
|
|
81
|
+
if (!options.signer) {
|
|
82
|
+
throw new VeilioSdkError({ code: 'WALLET_REQUIRED', message: 'A Solana signer is required to send transactions.' });
|
|
83
|
+
}
|
|
84
|
+
return options.signer;
|
|
85
|
+
}
|
|
86
|
+
async function send(ix) {
|
|
87
|
+
const signer = requireSigner();
|
|
88
|
+
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash(commitment);
|
|
89
|
+
const tx = new Transaction({ feePayer: signer.publicKey, blockhash, lastValidBlockHeight }).add(toTransactionInstruction(ix));
|
|
90
|
+
const signed = await signer.signTransaction(tx);
|
|
91
|
+
const signature = await connection.sendRawTransaction(signed.serialize());
|
|
92
|
+
const result = await connection.confirmTransaction({ signature, blockhash, lastValidBlockHeight }, commitment);
|
|
93
|
+
if (result.value.err) {
|
|
94
|
+
throw new VeilioSdkError({
|
|
95
|
+
code: 'TRANSACTION_REVERTED',
|
|
96
|
+
message: `Solana transaction failed: ${JSON.stringify(result.value.err)}`,
|
|
97
|
+
context: { signature },
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
return signature;
|
|
101
|
+
}
|
|
102
|
+
// ---------------------------------------------------------------- Auctions
|
|
103
|
+
async function getAuction(auctionId) {
|
|
104
|
+
const { pda } = findAuctionPda(BigInt(auctionId), auctionProgramId);
|
|
105
|
+
const account = await connection.getAccountInfo(new PublicKey(pda), commitment);
|
|
106
|
+
return account ? decodeAuctionStateAccount(account.data) : null;
|
|
107
|
+
}
|
|
108
|
+
async function listAuctions() {
|
|
109
|
+
const discriminator = encodeBase58(getAnchorDiscriminator('account', 'AuctionStateAccount'));
|
|
110
|
+
const accounts = await connection.getProgramAccounts(new PublicKey(auctionProgramId), {
|
|
111
|
+
commitment,
|
|
112
|
+
filters: [{ memcmp: { offset: 0, bytes: discriminator } }],
|
|
113
|
+
});
|
|
114
|
+
const auctions = [];
|
|
115
|
+
for (const { pubkey, account } of accounts) {
|
|
116
|
+
try {
|
|
117
|
+
auctions.push({ ...decodeAuctionStateAccount(account.data), address: pubkey.toBase58() });
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
// Skip accounts from an older layout instead of failing the whole listing.
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return auctions.sort((a, b) => Number(b.auctionId - a.auctionId));
|
|
124
|
+
}
|
|
125
|
+
function prepareBid(auctionId, maxBidSol) {
|
|
126
|
+
const bidder = requireSigner().publicKey.toBase58();
|
|
127
|
+
const id = BigInt(auctionId);
|
|
128
|
+
const maxBidLamports = solToLamports(maxBidSol);
|
|
129
|
+
if (id < 0n || maxBidLamports <= 0n) {
|
|
130
|
+
throw new VeilioSdkError({ code: 'INVALID_INPUT', message: 'auctionId must be >= 0 and maxBid must be positive.' });
|
|
131
|
+
}
|
|
132
|
+
const salt = randomBytes(32);
|
|
133
|
+
const { pda: auctionPda } = findAuctionPda(id, auctionProgramId);
|
|
134
|
+
const commitmentHash = computeSealedBidCommitment({ auctionPubkey: auctionPda, bidderPubkey: bidder, maxBidLamports, salt });
|
|
135
|
+
return {
|
|
136
|
+
auctionId: id.toString(),
|
|
137
|
+
bidder,
|
|
138
|
+
maxBidLamports: maxBidLamports.toString(),
|
|
139
|
+
salt: salt.toString('hex'),
|
|
140
|
+
commitment: commitmentHash.toString('hex'),
|
|
141
|
+
programId: auctionProgramId,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
/** Commits the sealed bid. Deposit must cover the max bid; over-deposit to hide your ceiling. */
|
|
145
|
+
async function commitBid(prepared, depositSol) {
|
|
146
|
+
const depositLamports = solToLamports(depositSol);
|
|
147
|
+
if (depositLamports < BigInt(prepared.maxBidLamports)) {
|
|
148
|
+
throw new VeilioSdkError({ code: 'INVALID_INPUT', message: 'Deposit must cover the maximum bid.' });
|
|
149
|
+
}
|
|
150
|
+
return send(createCommitBidInstruction({
|
|
151
|
+
programId: prepared.programId,
|
|
152
|
+
auctionId: BigInt(prepared.auctionId),
|
|
153
|
+
bidder: prepared.bidder,
|
|
154
|
+
commitment: Buffer.from(prepared.commitment, 'hex'),
|
|
155
|
+
depositLamports,
|
|
156
|
+
}));
|
|
157
|
+
}
|
|
158
|
+
async function revealBid(prepared) {
|
|
159
|
+
return send(createRevealBidInstruction({
|
|
160
|
+
programId: prepared.programId,
|
|
161
|
+
auctionId: BigInt(prepared.auctionId),
|
|
162
|
+
bidder: prepared.bidder,
|
|
163
|
+
maxBidLamports: BigInt(prepared.maxBidLamports),
|
|
164
|
+
salt: Buffer.from(prepared.salt, 'hex'),
|
|
165
|
+
}));
|
|
166
|
+
}
|
|
167
|
+
/** Winner accepts the asset during inspection, releasing payment to the seller. */
|
|
168
|
+
async function acceptDataset(auctionId, seller) {
|
|
169
|
+
return send(createAcceptDatasetInstruction({
|
|
170
|
+
programId: auctionProgramId,
|
|
171
|
+
auctionId: BigInt(auctionId),
|
|
172
|
+
seller,
|
|
173
|
+
winner: requireSigner().publicKey.toBase58(),
|
|
174
|
+
}));
|
|
175
|
+
}
|
|
176
|
+
/** Losing bidders reclaim their deposit after settlement. */
|
|
177
|
+
async function claimRefund(auctionId) {
|
|
178
|
+
return send(createClaimRefundInstruction({
|
|
179
|
+
programId: auctionProgramId,
|
|
180
|
+
auctionId: BigInt(auctionId),
|
|
181
|
+
bidder: requireSigner().publicKey.toBase58(),
|
|
182
|
+
}));
|
|
183
|
+
}
|
|
184
|
+
// ---------------------------------------------------------- Service escrow
|
|
185
|
+
async function getEscrowOrder(orderId) {
|
|
186
|
+
const { pda } = findEscrowOrderPda(toSolanaOrderId(orderId), escrowProgramId);
|
|
187
|
+
const account = await connection.getAccountInfo(new PublicKey(pda), commitment);
|
|
188
|
+
return account ? decodeEscrowOrderAccount(account.data) : null;
|
|
189
|
+
}
|
|
190
|
+
async function deposit(input) {
|
|
191
|
+
if (input.reviewer === escrowProgramId || input.reviewer === auctionProgramId) {
|
|
192
|
+
throw new VeilioSdkError({
|
|
193
|
+
code: 'INVALID_INPUT',
|
|
194
|
+
message: 'reviewer must be a wallet that can sign; a program ID can never resolve a dispute.',
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
for (const [label, value] of [['seller', input.seller], ['reviewer', input.reviewer], ['feeRecipient', input.feeRecipient]]) {
|
|
198
|
+
assertSolanaAddress(label, value);
|
|
199
|
+
}
|
|
200
|
+
if (input.deadline <= Math.floor(Date.now() / 1000)) {
|
|
201
|
+
throw new VeilioSdkError({ code: 'INVALID_INPUT', message: 'Deadline must be in the future.' });
|
|
202
|
+
}
|
|
203
|
+
return send(createDepositServiceOrderInstruction({
|
|
204
|
+
programId: escrowProgramId,
|
|
205
|
+
buyer: requireSigner().publicKey.toBase58(),
|
|
206
|
+
seller: input.seller,
|
|
207
|
+
reviewer: input.reviewer,
|
|
208
|
+
feeRecipient: input.feeRecipient,
|
|
209
|
+
orderId: toSolanaOrderId(input.orderId),
|
|
210
|
+
amountLamports: solToLamports(input.amountSol),
|
|
211
|
+
deadline: input.deadline,
|
|
212
|
+
}));
|
|
213
|
+
}
|
|
214
|
+
async function submitDelivery(orderId, deliverableReference) {
|
|
215
|
+
return send(createSubmitDeliveryInstruction({
|
|
216
|
+
programId: escrowProgramId,
|
|
217
|
+
seller: requireSigner().publicKey.toBase58(),
|
|
218
|
+
orderId: toSolanaOrderId(orderId),
|
|
219
|
+
deliverableReference,
|
|
220
|
+
}));
|
|
221
|
+
}
|
|
222
|
+
/** Buyer releases escrow to the seller (5% fee to feeRecipient). Accounts are read from the order. */
|
|
223
|
+
async function releaseFunds(orderId) {
|
|
224
|
+
const order = await getEscrowOrder(orderId);
|
|
225
|
+
if (!order)
|
|
226
|
+
throw new VeilioSdkError({ code: 'NOT_FOUND', message: `Escrow order ${orderId} not found on Solana.` });
|
|
227
|
+
return send(createReleaseFundsInstruction({
|
|
228
|
+
programId: escrowProgramId,
|
|
229
|
+
buyer: requireSigner().publicKey.toBase58(),
|
|
230
|
+
seller: order.seller,
|
|
231
|
+
feeRecipient: order.feeRecipient,
|
|
232
|
+
orderId: toSolanaOrderId(orderId),
|
|
233
|
+
}));
|
|
234
|
+
}
|
|
235
|
+
/** Seller cancellation, or buyer refund after the deadline. Fee-free. */
|
|
236
|
+
async function refund(orderId, reason) {
|
|
237
|
+
const order = await getEscrowOrder(orderId);
|
|
238
|
+
if (!order)
|
|
239
|
+
throw new VeilioSdkError({ code: 'NOT_FOUND', message: `Escrow order ${orderId} not found on Solana.` });
|
|
240
|
+
return send(createCancelOrRefundInstruction({
|
|
241
|
+
programId: escrowProgramId,
|
|
242
|
+
caller: requireSigner().publicKey.toBase58(),
|
|
243
|
+
buyer: order.buyer,
|
|
244
|
+
orderId: toSolanaOrderId(orderId),
|
|
245
|
+
reason,
|
|
246
|
+
}));
|
|
247
|
+
}
|
|
248
|
+
async function dispute(orderId, reason) {
|
|
249
|
+
return send(createDisputeOrderInstruction({
|
|
250
|
+
programId: escrowProgramId,
|
|
251
|
+
caller: requireSigner().publicKey.toBase58(),
|
|
252
|
+
orderId: toSolanaOrderId(orderId),
|
|
253
|
+
reason,
|
|
254
|
+
}));
|
|
255
|
+
}
|
|
256
|
+
return {
|
|
257
|
+
auctionProgramId,
|
|
258
|
+
escrowProgramId,
|
|
259
|
+
getAuction,
|
|
260
|
+
listAuctions,
|
|
261
|
+
prepareBid,
|
|
262
|
+
commitBid,
|
|
263
|
+
revealBid,
|
|
264
|
+
acceptDataset,
|
|
265
|
+
claimRefund,
|
|
266
|
+
getEscrowOrder,
|
|
267
|
+
deposit,
|
|
268
|
+
submitDelivery,
|
|
269
|
+
releaseFunds,
|
|
270
|
+
refund,
|
|
271
|
+
dispute,
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/solana/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAGL,gBAAgB,EAChB,SAAS,EACT,WAAW,EACX,sBAAsB,GAEvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EACL,iCAAiC,EACjC,0BAA0B,EAC1B,8BAA8B,EAC9B,4BAA4B,EAC5B,0BAA0B,EAC1B,0BAA0B,EAC1B,yBAAyB,EACzB,cAAc,GAEf,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,wCAAwC,EACxC,+BAA+B,EAC/B,oCAAoC,EACpC,6BAA6B,EAC7B,6BAA6B,EAC7B,+BAA+B,EAC/B,wBAAwB,EACxB,kBAAkB,GAEnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAkC,MAAM,eAAe,CAAC;AAQrG,sEAAsE;AACtE,MAAM,UAAU,aAAa,CAAC,OAAgB;IAC5C,OAAO;QACL,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,KAAK,CAAC,eAAe,CAAwB,WAAc;YACzD,WAAW,CAAC,WAAW,CAAC,OAAO,C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;QACnD,MAAM,KAAK,GAAG,MAAM,cAAc,CAAC,OAAO,CAAC,CAAC;QAC5C,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,cAAc,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,gBAAgB,OAAO,uBAAuB,EAAE,CAAC,CAAC;QACrH,OAAO,IAAI,CACT,+BAA+B,CAAC;YAC9B,SAAS,EAAE,eAAe;YAC1B,MAAM,EAAE,aAAa,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE;YAC5C,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC;YACjC,MAAM;SACP,CAAC,CACH,CAAC;IACJ,CAAC;IAED,KAAK,UAAU,OAAO,CAAC,OAAe,EAAE,MAAc;QACpD,OAAO,IAAI,CACT,6BAA6B,CAAC;YAC5B,SAAS,EAAE,eAAe;YAC1B,MAAM,EAAE,aAAa,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE;YAC5C,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC;YACjC,MAAM;SACP,CAAC,CACH,CAAC;IACJ,CAAC;IAED,OAAO;QACL,gBAAgB;QAChB,eAAe;QACf,UAAU;QACV,YAAY;QACZ,UAAU;QACV,SAAS;QACT,SAAS;QACT,aAAa;QACb,WAAW;QACX,cAAc;QACd,OAAO;QACP,cAAc;QACd,YAAY;QACZ,MAAM;QACN,OAAO;KACR,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VEILIO Solana Services Escrow Client & Program Interface
|
|
3
|
+
*
|
|
4
|
+
* Implements client-side PDA derivation, Anchor instruction serialization,
|
|
5
|
+
* account deserialization, fee calculations, and transaction verification
|
|
6
|
+
* for the dedicated Solana Devnet VeilServiceEscrow program.
|
|
7
|
+
*/
|
|
8
|
+
import { type SolanaCompiledInstruction } from './registry.js';
|
|
9
|
+
export declare const ESCROW_SEED: Buffer<ArrayBuffer>;
|
|
10
|
+
export declare const VAULT_SEED: Buffer<ArrayBuffer>;
|
|
11
|
+
export declare const MAX_DELIVERABLE_REF_LEN = 200;
|
|
12
|
+
export declare const MAX_FEE_BPS = 500;
|
|
13
|
+
export declare const DEFAULT_SOLANA_SERVICE_ESCROW_PROGRAM_ID = "5Vj4y8BT74PDe5VwLuDp9agTR5ak4vtZdwxnBfRW3R8s";
|
|
14
|
+
export type SolanaServiceEscrowStatus = 'None' | 'Funded' | 'Delivered' | 'Released' | 'Refunded' | 'Disputed';
|
|
15
|
+
export declare const SOLANA_SERVICE_ESCROW_STATUS_MAP: Record<number, SolanaServiceEscrowStatus>;
|
|
16
|
+
export interface DecodedSolanaEscrowOrder {
|
|
17
|
+
buyer: string;
|
|
18
|
+
seller: string;
|
|
19
|
+
reviewer: string;
|
|
20
|
+
feeRecipient: string;
|
|
21
|
+
orderIdHex: string;
|
|
22
|
+
orderIdBytes: Uint8Array;
|
|
23
|
+
amountLamports: bigint;
|
|
24
|
+
amountSol: string;
|
|
25
|
+
feeBasisPoints: number;
|
|
26
|
+
deadline: number;
|
|
27
|
+
status: SolanaServiceEscrowStatus;
|
|
28
|
+
createdAt: number;
|
|
29
|
+
settledAt: number;
|
|
30
|
+
deliverableReference: string;
|
|
31
|
+
bump: number;
|
|
32
|
+
vaultBump: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Derives the EscrowOrder account PDA: [b"service_escrow", order_id]
|
|
36
|
+
*/
|
|
37
|
+
export declare function findEscrowOrderPda(orderId: string | Uint8Array, programId?: string): {
|
|
38
|
+
pda: string;
|
|
39
|
+
bump: number;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Derives the Vault account PDA holding SOL lamports: [b"service_vault", order_id]
|
|
43
|
+
*/
|
|
44
|
+
export declare function findVaultPda(orderId: string | Uint8Array, programId?: string): {
|
|
45
|
+
pda: string;
|
|
46
|
+
bump: number;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Encodes the deposit instruction:
|
|
50
|
+
* accounts: [escrow_order (mut, pda), vault (mut, pda), buyer (signer, mut), system_program]
|
|
51
|
+
*/
|
|
52
|
+
export declare function createDepositServiceOrderInstruction(params: {
|
|
53
|
+
programId?: string;
|
|
54
|
+
buyer: string;
|
|
55
|
+
seller: string;
|
|
56
|
+
reviewer: string;
|
|
57
|
+
feeRecipient: string;
|
|
58
|
+
orderId: string | Uint8Array;
|
|
59
|
+
amountLamports: bigint | number;
|
|
60
|
+
deadline: number;
|
|
61
|
+
}): SolanaCompiledInstruction;
|
|
62
|
+
/**
|
|
63
|
+
* Encodes the submit_delivery instruction:
|
|
64
|
+
* accounts: [escrow_order (mut), seller (signer)]
|
|
65
|
+
*/
|
|
66
|
+
export declare function createSubmitDeliveryInstruction(params: {
|
|
67
|
+
programId?: string;
|
|
68
|
+
seller: string;
|
|
69
|
+
orderId: string | Uint8Array;
|
|
70
|
+
deliverableReference: string;
|
|
71
|
+
}): SolanaCompiledInstruction;
|
|
72
|
+
/**
|
|
73
|
+
* Encodes the release_funds instruction:
|
|
74
|
+
* accounts: [escrow_order (mut), vault (mut), buyer (signer), seller (mut), fee_recipient (mut)]
|
|
75
|
+
*/
|
|
76
|
+
export declare function createReleaseFundsInstruction(params: {
|
|
77
|
+
programId?: string;
|
|
78
|
+
buyer: string;
|
|
79
|
+
seller: string;
|
|
80
|
+
feeRecipient: string;
|
|
81
|
+
orderId: string | Uint8Array;
|
|
82
|
+
}): SolanaCompiledInstruction;
|
|
83
|
+
/**
|
|
84
|
+
* Encodes the cancel_or_refund instruction:
|
|
85
|
+
* accounts: [escrow_order (mut), vault (mut), caller (signer), buyer (mut), system_program]
|
|
86
|
+
*/
|
|
87
|
+
export declare function createCancelOrRefundInstruction(params: {
|
|
88
|
+
programId?: string;
|
|
89
|
+
caller: string;
|
|
90
|
+
buyer: string;
|
|
91
|
+
orderId: string | Uint8Array;
|
|
92
|
+
reason: string;
|
|
93
|
+
}): SolanaCompiledInstruction;
|
|
94
|
+
/**
|
|
95
|
+
* Encodes the dispute instruction:
|
|
96
|
+
* accounts: [escrow_order (mut), caller (signer)]
|
|
97
|
+
*/
|
|
98
|
+
export declare function createDisputeOrderInstruction(params: {
|
|
99
|
+
programId?: string;
|
|
100
|
+
caller: string;
|
|
101
|
+
orderId: string | Uint8Array;
|
|
102
|
+
reason: string;
|
|
103
|
+
}): SolanaCompiledInstruction;
|
|
104
|
+
/**
|
|
105
|
+
* Encodes the resolve_dispute instruction:
|
|
106
|
+
* accounts: [escrow_order (mut), vault (mut), reviewer (signer), buyer (mut), seller (mut), fee_recipient (mut)]
|
|
107
|
+
*/
|
|
108
|
+
export declare function createResolveDisputeInstruction(params: {
|
|
109
|
+
programId?: string;
|
|
110
|
+
reviewer: string;
|
|
111
|
+
buyer: string;
|
|
112
|
+
seller: string;
|
|
113
|
+
feeRecipient: string;
|
|
114
|
+
orderId: string | Uint8Array;
|
|
115
|
+
splitToBuyerPercent: number;
|
|
116
|
+
}): SolanaCompiledInstruction;
|
|
117
|
+
/**
|
|
118
|
+
* Decodes serialized EscrowOrder account buffer.
|
|
119
|
+
*/
|
|
120
|
+
export declare function decodeEscrowOrderAccount(buffer: Uint8Array | Buffer): DecodedSolanaEscrowOrder;
|
|
121
|
+
/**
|
|
122
|
+
* Calculates exact platform fee and payouts for Solana lamports.
|
|
123
|
+
* Strict parity with EVM: 500 bps (5%) platform fee deducted from seller gross award.
|
|
124
|
+
* Buyer refunds are 100% fee-free.
|
|
125
|
+
*/
|
|
126
|
+
export declare function calculateSolanaServicePayouts(totalLamports: bigint | number, splitToBuyerPercent?: number, feeBps?: number): {
|
|
127
|
+
buyerRefundLamports: bigint;
|
|
128
|
+
sellerGrossLamports: bigint;
|
|
129
|
+
platformFeeLamports: bigint;
|
|
130
|
+
sellerNetPayoutLamports: bigint;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Lossless conversion of lamports to a high-precision SOL string without floating-point errors.
|
|
134
|
+
*/
|
|
135
|
+
export declare function formatLamportsToSol(lamports: bigint | number): string;
|
|
136
|
+
/**
|
|
137
|
+
* Lossless conversion of SOL string to lamports bigint without floating-point inaccuracies.
|
|
138
|
+
*/
|
|
139
|
+
export declare function parseSolToLamports(sol: string): bigint;
|
|
140
|
+
//# sourceMappingURL=escrow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"escrow.d.ts","sourceRoot":"","sources":["../../../src/solana/escrow.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAOL,KAAK,yBAAyB,EAC/B,MAAM,eAAe,CAAC;AAGvB,eAAO,MAAM,WAAW,qBAAgC,CAAC;AACzD,eAAO,MAAM,UAAU,qBAA+B,CAAC;AACvD,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAC3C,eAAO,MAAM,WAAW,MAAM,CAAC;AAG/B,eAAO,MAAM,wCAAwC,iDACL,CAAC;AAEjD,MAAM,MAAM,yBAAyB,GACjC,MAAM,GACN,QAAQ,GACR,WAAW,GACX,UAAU,GACV,UAAU,GACV,UAAU,CAAC;AAEf,eAAO,MAAM,gCAAgC,EAAE,MAAM,CAAC,MAAM,EAAE,yBAAyB,CAOtF,CAAC;AAEF,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,UAAU,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,yBAAyB,CAAC;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,IAAI,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