@ercworldio/blockchain-shared 1.0.5-dev.7.PROJ-1464.0 → 1.0.5-dev.8-PLAT134.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.
Files changed (45) hide show
  1. package/build/chains/networks_dev.json +10 -0
  2. package/build/chains/networks_prod-bu.json +0 -14
  3. package/build/chains/networks_prod-dz.json +22 -1
  4. package/build/errors/TransactionsErrors.d.ts +0 -1
  5. package/build/errors/TransactionsErrors.d.ts.map +1 -1
  6. package/build/errors/TransactionsErrors.js +0 -4
  7. package/build/index.d.ts +1 -0
  8. package/build/index.d.ts.map +1 -1
  9. package/build/index.js +4 -2
  10. package/build/services/ClaimJobService.d.ts.map +1 -1
  11. package/build/services/ClaimJobService.js +12 -5
  12. package/build/services/Redis.js +2 -2
  13. package/build/services/RedisPubSub.js +1 -1
  14. package/build/services/db/multisig/MultisigService.d.ts +13 -1
  15. package/build/services/db/multisig/MultisigService.d.ts.map +1 -1
  16. package/build/services/db/multisig/MultisigService.js +57 -0
  17. package/build/services/db/timelock/ScheduleTransactionService.d.ts +16 -2
  18. package/build/services/db/timelock/ScheduleTransactionService.d.ts.map +1 -1
  19. package/build/services/db/timelock/ScheduleTransactionService.js +265 -1
  20. package/build/services/rpc/RPC.d.ts +20 -0
  21. package/build/services/rpc/RPC.d.ts.map +1 -0
  22. package/build/services/rpc/RPC.js +49 -0
  23. package/build/services/solana/escrow/SolanaEscrowAdmin.d.ts +41 -1
  24. package/build/services/solana/escrow/SolanaEscrowAdmin.d.ts.map +1 -1
  25. package/build/services/solana/escrow/SolanaEscrowAdmin.js +35 -3
  26. package/build/services/solana/escrow/idl/escrow.json +4267 -988
  27. package/build/services/solana/escrow/services/EscrowAdminUtility.d.ts +116 -3
  28. package/build/services/solana/escrow/services/EscrowAdminUtility.d.ts.map +1 -1
  29. package/build/services/solana/escrow/services/EscrowAdminUtility.js +543 -55
  30. package/build/services/solana/escrow/services/TreasuryWithdrawalSignature.d.ts +58 -0
  31. package/build/services/solana/escrow/services/TreasuryWithdrawalSignature.d.ts.map +1 -0
  32. package/build/services/solana/escrow/services/TreasuryWithdrawalSignature.js +109 -0
  33. package/build/services/solana/escrow/types/escrow.d.ts +4262 -983
  34. package/build/services/solana/escrow/types/escrow.d.ts.map +1 -1
  35. package/build/services/solana/escrow/types/types.d.ts +17 -0
  36. package/build/services/solana/escrow/types/types.d.ts.map +1 -1
  37. package/build/services/types/claim.d.ts +1 -0
  38. package/build/services/types/claim.d.ts.map +1 -1
  39. package/build/services/types/db/multisig_service.d.ts +74 -0
  40. package/build/services/types/db/multisig_service.d.ts.map +1 -1
  41. package/build/services/types/db/timelock.d.ts +56 -0
  42. package/build/services/types/db/timelock.d.ts.map +1 -1
  43. package/build/utils/solana.d.ts.map +1 -1
  44. package/build/utils/solana.js +5 -3
  45. package/package.json +1 -1
@@ -52,8 +52,123 @@ ScheduleTransactionService.get_and_lock_available_jobs = (pool_1, ...args_1) =>
52
52
  `, [limit, ttlSeconds, lock_metadata.lock_owner, lock_metadata.lock_reason]);
53
53
  return res.rows;
54
54
  });
55
- /** Locks and returns available jobs with full withdrawal details via DB function. */
55
+ /** Locks and returns available jobs with full withdrawal details via inline SQL (bypasses DB function). */
56
56
  ScheduleTransactionService.get_and_lock_available_jobs_with_details = (pool_1, ...args_1) => __awaiter(void 0, [pool_1, ...args_1], void 0, function* (pool, limit = 10, job_ttl_s = 120, lock_metadata = { lock_owner: "schedule-tx-worker", lock_reason: "process_queued" }) {
57
+ var _b, _c;
58
+ const result = yield pool.query(`
59
+ WITH status_ids AS (
60
+ SELECT
61
+ MAX(CASE WHEN status = 'queued' THEN id END) AS queued_id,
62
+ MAX(CASE WHEN status = 'processing' THEN id END) AS processing_id
63
+ FROM multisig.schedule_job_statuses
64
+ ),
65
+ candidates AS (
66
+ SELECT id
67
+ FROM multisig.schedule_transaction_jobs, status_ids
68
+ WHERE status_id = status_ids.queued_id
69
+ AND (lock_expires_at IS NULL OR lock_expires_at < NOW())
70
+ ORDER BY blockchain, chain_id ASC
71
+ LIMIT $1
72
+ FOR UPDATE SKIP LOCKED
73
+ ),
74
+ updated AS (
75
+ UPDATE multisig.schedule_transaction_jobs j
76
+ SET status_id = si.processing_id,
77
+ locked_at = NOW(),
78
+ lock_expires_at = NOW() + ($2 || ' seconds')::INTERVAL,
79
+ batch_group_id = gen_random_uuid(),
80
+ metadata = jsonb_set(
81
+ jsonb_set(
82
+ COALESCE(j.metadata, '{}'::jsonb),
83
+ '{lock_owner}', to_jsonb($3::text)
84
+ ),
85
+ '{lock_reason}', to_jsonb($4::text)
86
+ ),
87
+ updated_at = NOW()
88
+ FROM candidates c, status_ids si
89
+ WHERE j.id = c.id
90
+ RETURNING j.*
91
+ )
92
+ SELECT COALESCE(json_agg(json_build_object(
93
+ 'id', u.id,
94
+ 'requestId', u.request_id,
95
+ 'operationType', u.operation_type,
96
+ 'status', sjs.status,
97
+ 'blockchain', u.blockchain,
98
+ 'chainId', u.chain_id,
99
+ 'batchGroupId', u.batch_group_id,
100
+ 'lockExpiresAt', u.lock_expires_at,
101
+ 'lockedAt', u.locked_at,
102
+ 'txHash', u.tx_hash,
103
+ 'sentAt', u.sent_at,
104
+ 'confirmedAt', u.confirmed_at,
105
+ 'retryCount', u.retry_count,
106
+ 'errorMessage', u.error_message,
107
+ 'lastErrorAt', u.last_error_at,
108
+ 'metadata', u.metadata,
109
+ 'createdAt', u.created_at,
110
+ 'updatedAt', u.updated_at,
111
+ 'withdrawalDetails', json_build_object(
112
+ 'id', cw.id,
113
+ 'userId', cw.user_id,
114
+ 'status', LOWER(cws.status),
115
+ 'blockchain', LOWER(cwbt.blockchain),
116
+ 'receiver', cw.receiver_address,
117
+ 'receiverAddress', cw.receiver_address,
118
+ 'paymentType', LOWER(cwpt.type),
119
+ 'chainId', cw.chain_id,
120
+ 'token', cw.token_address,
121
+ 'amount', cw.amount,
122
+ 'amountInUsd', cw.amount * cr.rate,
123
+ 'destinationChainId', cw.destination_chain_id,
124
+ 'destinationToken', cw.destination_token_address,
125
+ 'destinationBlockchain', cw.destination_blockchain,
126
+ 'sigsExecutiveRequired', cw.sigs_executive_required,
127
+ 'sigsManagerRequired', cw.sigs_manager_required,
128
+ 'timeLockSeconds', cw.timelock_seconds,
129
+ 'multisigSignatures', (
130
+ SELECT COALESCE(json_agg(json_build_object(
131
+ 'name', COALESCE(role.role_alias, ''),
132
+ 'signerAddress', cs.signer_address,
133
+ 'contractAddress', cs.contract_address,
134
+ 'createdAt', cs.created_at,
135
+ 'updatedAt', cs.updated_at,
136
+ 'operationType', cs.operation_type,
137
+ 'v', cs.v,
138
+ 'r', cs.r,
139
+ 's', cs.s,
140
+ 'signature', cs.signature
141
+ )), '[]'::json)
142
+ FROM multisig.crypto_signatures cs
143
+ LEFT JOIN multisig.crypto_escrow_roles cer
144
+ ON LOWER(cer.wallet_address) = LOWER(cs.signer_address)
145
+ AND LOWER(cer.blockchain) = LOWER(cs.blockchain)
146
+ AND cer.chain_id = cs.chain_id
147
+ AND LOWER(cer.contract_address) = LOWER(cs.contract_address)
148
+ LEFT JOIN multisig.crypto_role role ON role.id = cer.role_id
149
+ WHERE cs.reference_id = cw.id
150
+ AND cs.operation_type = 1
151
+ AND (
152
+ (cs.v IS NOT NULL AND cs.r IS NOT NULL AND cs.s IS NOT NULL)
153
+ OR cs.signature IS NOT NULL
154
+ )
155
+ )
156
+ )
157
+ )), '[]'::json) AS result
158
+ FROM updated u
159
+ JOIN multisig.schedule_job_statuses sjs ON sjs.id = u.status_id
160
+ JOIN accounting.crypto_withdrawals cw ON cw.id = u.request_id
161
+ LEFT JOIN accounting.crypto_withdrawal_status cws ON cws.id = cw.status_id
162
+ LEFT JOIN accounting.crypto_withdrawal_blockchain_types cwbt ON cwbt.id = cw.blockchain_id
163
+ LEFT JOIN accounting.crypto_withdrawal_payment_types cwpt ON cwpt.id = cw.payment_type_id
164
+ LEFT JOIN usersmanagement.user_currency_mappings ucm ON ucm.currency_specific_user_id = cw.currency_specific_user_id
165
+ LEFT JOIN public.currencies cur ON cur.currencyid = ucm.currency_id
166
+ LEFT JOIN accounting.currencyrates cr ON cr.symbol = UPPER(cur.currency_code || 'USD')
167
+ `, [limit, job_ttl_s, lock_metadata.lock_owner, lock_metadata.lock_reason]);
168
+ return (_c = (_b = result.rows[0]) === null || _b === void 0 ? void 0 : _b.result) !== null && _c !== void 0 ? _c : [];
169
+ });
170
+ /** Locks and returns available jobs with full withdrawal details via DB function. */
171
+ ScheduleTransactionService.get_and_lock_available_jobs_with_details_depr = (pool_1, ...args_1) => __awaiter(void 0, [pool_1, ...args_1], void 0, function* (pool, limit = 10, job_ttl_s = 120, lock_metadata = { lock_owner: "schedule-tx-worker", lock_reason: "process_queued" }) {
57
172
  var _b;
58
173
  const result = yield pool.query(`SELECT multisig.fn_get_available_schedule_jobs_with_details($1::int, $2::int, $3::text, $4::text)`, [limit, job_ttl_s, lock_metadata.lock_owner, lock_metadata.lock_reason]);
59
174
  return (_b = result.rows[0].fn_get_available_schedule_jobs_with_details) !== null && _b !== void 0 ? _b : [];
@@ -209,4 +324,153 @@ ScheduleTransactionService.mark_complete = (pool, payloads) => __awaiter(void 0,
209
324
  AND t.operation_type = c.operation_type
210
325
  `, [requestIds, operationTypes]);
211
326
  });
327
+ // ── BO read views ────────────────────────────────────────────────────────
328
+ /**
329
+ * Paginated list of current schedule-transaction jobs, newest first, with the
330
+ * status resolved to text and (for withdrawal operation types) the receiver/token/
331
+ * amount joined in. All filters are optional and combine with AND.
332
+ */
333
+ ScheduleTransactionService.list_jobs_paginated = (pool_1, page_1, ...args_1) => __awaiter(void 0, [pool_1, page_1, ...args_1], void 0, function* (pool, page, page_size = 20, filters = {}) {
334
+ var _b, _c;
335
+ if (page < 1)
336
+ page = 1;
337
+ const clauses = [];
338
+ const params = [];
339
+ let i = 1;
340
+ if (filters.status) {
341
+ clauses.push(`sjs.status = $${i++}`);
342
+ params.push(filters.status);
343
+ }
344
+ if (filters.blockchain) {
345
+ clauses.push(`j.blockchain = $${i++}`);
346
+ params.push(filters.blockchain);
347
+ }
348
+ if (filters.chainId) {
349
+ clauses.push(`j.chain_id = $${i++}`);
350
+ params.push(filters.chainId);
351
+ }
352
+ if (filters.operationType !== undefined) {
353
+ clauses.push(`j.operation_type = $${i++}`);
354
+ params.push(filters.operationType);
355
+ }
356
+ if (filters.requestId !== undefined) {
357
+ clauses.push(`j.request_id = $${i++}`);
358
+ params.push(filters.requestId);
359
+ }
360
+ if (filters.txHash) {
361
+ clauses.push(`j.tx_hash = $${i++}`);
362
+ params.push(filters.txHash);
363
+ }
364
+ const where = clauses.length ? `WHERE ${clauses.join(" AND ")}` : "";
365
+ const countRes = yield pool.query(`SELECT COUNT(*)::bigint AS count
366
+ FROM multisig.schedule_transaction_jobs j
367
+ JOIN multisig.schedule_job_statuses sjs ON sjs.id = j.status_id
368
+ ${where}`, params);
369
+ const total_count = Number((_c = (_b = countRes.rows[0]) === null || _b === void 0 ? void 0 : _b.count) !== null && _c !== void 0 ? _c : 0);
370
+ const limitParam = i++;
371
+ const offsetParam = i++;
372
+ const rowsRes = yield pool.query(`SELECT
373
+ j.id,
374
+ j.request_id AS "requestId",
375
+ j.operation_type AS "operationType",
376
+ sjs.status AS status,
377
+ j.blockchain,
378
+ j.chain_id AS "chainId",
379
+ j.tx_hash AS "txHash",
380
+ j.locked_at AS "lockedAt",
381
+ j.lock_expires_at AS "lockExpiresAt",
382
+ j.sent_at AS "sentAt",
383
+ j.confirmed_at AS "confirmedAt",
384
+ j.retry_count AS "retryCount",
385
+ j.error_message AS "errorMessage",
386
+ j.last_error_at AS "lastErrorAt",
387
+ j.metadata,
388
+ j.created_at AS "createdAt",
389
+ j.updated_at AS "updatedAt",
390
+ cw.receiver_address AS "receiverAddress",
391
+ cw.token_address AS "tokenAddress",
392
+ cw.amount AS "amount"
393
+ FROM multisig.schedule_transaction_jobs j
394
+ JOIN multisig.schedule_job_statuses sjs ON sjs.id = j.status_id
395
+ LEFT JOIN accounting.crypto_withdrawals cw
396
+ ON cw.id = j.request_id AND j.operation_type IN (1, 3)
397
+ ${where}
398
+ ORDER BY j.created_at DESC
399
+ LIMIT $${limitParam} OFFSET $${offsetParam}`, [...params, page_size, (page - 1) * page_size]);
400
+ return {
401
+ total_count,
402
+ pages_count: Math.ceil(total_count / page_size),
403
+ current_page: page,
404
+ has_next: total_count > page * page_size,
405
+ items: rowsRes.rows
406
+ };
407
+ });
408
+ /**
409
+ * Paginated schedule-transaction job history (append-only status transitions),
410
+ * newest first. All filters are optional and combine with AND.
411
+ */
412
+ ScheduleTransactionService.list_history_paginated = (pool_1, page_1, ...args_1) => __awaiter(void 0, [pool_1, page_1, ...args_1], void 0, function* (pool, page, page_size = 20, filters = {}) {
413
+ var _b, _c;
414
+ if (page < 1)
415
+ page = 1;
416
+ const clauses = [];
417
+ const params = [];
418
+ let i = 1;
419
+ if (filters.jobId !== undefined) {
420
+ clauses.push(`h.job_id = $${i++}`);
421
+ params.push(filters.jobId);
422
+ }
423
+ if (filters.requestId !== undefined) {
424
+ clauses.push(`h.request_id = $${i++}`);
425
+ params.push(filters.requestId);
426
+ }
427
+ if (filters.operationType !== undefined) {
428
+ clauses.push(`h.operation_type = $${i++}`);
429
+ params.push(filters.operationType);
430
+ }
431
+ if (filters.status) {
432
+ clauses.push(`sjs.status = $${i++}`);
433
+ params.push(filters.status);
434
+ }
435
+ if (filters.blockchain) {
436
+ clauses.push(`h.blockchain = $${i++}`);
437
+ params.push(filters.blockchain);
438
+ }
439
+ if (filters.chainId) {
440
+ clauses.push(`h.chain_id = $${i++}`);
441
+ params.push(filters.chainId);
442
+ }
443
+ const where = clauses.length ? `WHERE ${clauses.join(" AND ")}` : "";
444
+ const countRes = yield pool.query(`SELECT COUNT(*)::bigint AS count
445
+ FROM multisig.schedule_transaction_jobs_history h
446
+ JOIN multisig.schedule_job_statuses sjs ON sjs.id = h.status_id
447
+ ${where}`, params);
448
+ const total_count = Number((_c = (_b = countRes.rows[0]) === null || _b === void 0 ? void 0 : _b.count) !== null && _c !== void 0 ? _c : 0);
449
+ const limitParam = i++;
450
+ const offsetParam = i++;
451
+ const rowsRes = yield pool.query(`SELECT
452
+ h.id,
453
+ h.job_id AS "jobId",
454
+ h.request_id AS "requestId",
455
+ h.operation_type AS "operationType",
456
+ sjs.status AS status,
457
+ h.blockchain,
458
+ h.chain_id AS "chainId",
459
+ h.tx_hash AS "txHash",
460
+ h.retry_count AS "retryCount",
461
+ h.error_message AS "errorMessage",
462
+ h.created_at AS "createdAt"
463
+ FROM multisig.schedule_transaction_jobs_history h
464
+ JOIN multisig.schedule_job_statuses sjs ON sjs.id = h.status_id
465
+ ${where}
466
+ ORDER BY h.created_at DESC
467
+ LIMIT $${limitParam} OFFSET $${offsetParam}`, [...params, page_size, (page - 1) * page_size]);
468
+ return {
469
+ total_count,
470
+ pages_count: Math.ceil(total_count / page_size),
471
+ current_page: page,
472
+ has_next: total_count > page * page_size,
473
+ items: rowsRes.rows
474
+ };
475
+ });
212
476
  exports.default = ScheduleTransactionService;
@@ -0,0 +1,20 @@
1
+ import { BlockchainType } from "../../interfaces";
2
+ import { RpcProviderType } from "../../chains/Provider";
3
+ declare class RPC {
4
+ static instance: RPC;
5
+ private currentProvider;
6
+ initialized: boolean;
7
+ private constructor();
8
+ static getInstance(): RPC;
9
+ initialize(config: Partial<{
10
+ config: Partial<{
11
+ defaultEvmRpcProviderType: RpcProviderType;
12
+ defaultSolRpcProviderType: RpcProviderType;
13
+ defaultTronRpcProviderType: RpcProviderType;
14
+ }>;
15
+ }>): void;
16
+ updateDefault(blockchainType: BlockchainType, targetProvider: RpcProviderType): void;
17
+ getCurrentDefault(blockchainType: BlockchainType): RpcProviderType;
18
+ }
19
+ export default RPC;
20
+ //# sourceMappingURL=RPC.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RPC.d.ts","sourceRoot":"","sources":["../../../src/services/rpc/RPC.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAKxD,cAAM,GAAG;IACL,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC;IACrB,OAAO,CAAC,eAAe,CAAuC;IACvD,WAAW,EAAE,OAAO,CAAS;IAEpC,OAAO;IAaP,MAAM,CAAC,WAAW;IAQlB,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,OAAO,CAAC;YAAC,yBAAyB,EAAE,eAAe,CAAC;YAAC,yBAAyB,EAAE,eAAe,CAAC;YAAC,0BAA0B,EAAE,eAAe,CAAA;SAAC,CAAC,CAAA;KAAC,CAAC;IAcpL,aAAa,CAAC,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe;IAI7E,iBAAiB,CAAC,cAAc,EAAE,cAAc;CAQnD;AAED,eAAe,GAAG,CAAC"}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const constants_1 = require("../../constants");
4
+ const Provider_1 = require("../../chains/Provider");
5
+ // export var default_archival_connection_provider: RpcProviderType = RpcProviderType.ALCHEMY;
6
+ // export var default_evm_rpc_provider: RpcProviderType = RpcProviderType.ALCHEMY;
7
+ class RPC {
8
+ constructor() {
9
+ this.initialized = false;
10
+ this.currentProvider = new Map();
11
+ // const config = Config.getInstance();
12
+ // const evmProvider = config.config.defaultEvmRpcProviderType ? config.config.defaultEvmRpcProviderType : RpcProviderType.ALCHEMY;
13
+ // const solanaProvider = config.config.defaultSolRpcProviderType ? config.config.defaultSolRpcProviderType : RpcProviderType.ALCHEMY;
14
+ // const tronProvider = config.config.defaultTronRpcProviderType ? config.config.defaultTronRpcProviderType : RpcProviderType.ALCHEMY;
15
+ // this.updateDefault(BLOCKCHAINS.EVM, evmProvider);
16
+ // this.updateDefault(BLOCKCHAINS.SOLANA, solanaProvider);
17
+ // this.updateDefault(BLOCKCHAINS.TRON, tronProvider);
18
+ }
19
+ static getInstance() {
20
+ if (!this.instance) {
21
+ this.instance = new RPC();
22
+ }
23
+ return this.instance;
24
+ }
25
+ initialize(config) {
26
+ var _a, _b, _c;
27
+ if (this.initialized)
28
+ throw new Error(`RPC provider manager is already initialized. Use 'updateDefault' instead.`);
29
+ const evmProvider = ((_a = config === null || config === void 0 ? void 0 : config.config) === null || _a === void 0 ? void 0 : _a.defaultEvmRpcProviderType) ? config.config.defaultEvmRpcProviderType : Provider_1.RpcProviderType.ALCHEMY;
30
+ const solanaProvider = ((_b = config === null || config === void 0 ? void 0 : config.config) === null || _b === void 0 ? void 0 : _b.defaultSolRpcProviderType) ? config.config.defaultSolRpcProviderType : Provider_1.RpcProviderType.ALCHEMY;
31
+ const tronProvider = ((_c = config === null || config === void 0 ? void 0 : config.config) === null || _c === void 0 ? void 0 : _c.defaultTronRpcProviderType) ? config.config.defaultTronRpcProviderType : Provider_1.RpcProviderType.ALCHEMY;
32
+ this.updateDefault(constants_1.BLOCKCHAINS.EVM, evmProvider);
33
+ this.updateDefault(constants_1.BLOCKCHAINS.SOLANA, solanaProvider);
34
+ this.updateDefault(constants_1.BLOCKCHAINS.TRON, tronProvider);
35
+ this.initialized = true;
36
+ }
37
+ updateDefault(blockchainType, targetProvider) {
38
+ this.currentProvider.set(blockchainType, targetProvider);
39
+ }
40
+ getCurrentDefault(blockchainType) {
41
+ if (!this.initialized)
42
+ throw new Error(`RPC provider manager is not initialized`);
43
+ const current = this.currentProvider.get(blockchainType);
44
+ if (!current)
45
+ throw new Error(`RPC provider manager is not initialized`);
46
+ return current;
47
+ }
48
+ }
49
+ exports.default = RPC;
@@ -2,9 +2,16 @@ import { Connection, Keypair, PublicKey } from "@solana/web3.js";
2
2
  import * as anchor from "@coral-xyz/anchor";
3
3
  import { Escrow } from "./types/escrow";
4
4
  import { BatchReceiver, SignAllTransactionsInterface, SignTransactionInterface } from "./types/types";
5
+ import { ChainId } from "../../../interfaces";
5
6
  interface AdditionalConstructorParams {
6
7
  signer_keypair?: Keypair;
7
8
  localnet: boolean;
9
+ /**
10
+ * Address Lookup Table holding the batch path's static accounts. Supply it to send v0
11
+ * transactions, which is required for batches carrying more than two treasury signatures.
12
+ * Create it once with `create_lookup_table` and persist the returned address.
13
+ */
14
+ lookup_table_address?: string;
8
15
  }
9
16
  declare class SolanaEscrowAdmin {
10
17
  provider: anchor.AnchorProvider;
@@ -81,7 +88,40 @@ declare class SolanaEscrowAdmin {
81
88
  * @returns string - transaction signature
82
89
  */
83
90
  set_pause_state: (target_state: boolean) => Promise<string>;
84
- withdraw_batch: (token_address: string, receivers: BatchReceiver[]) => Promise<string>;
91
+ withdraw_batch: (chain_id: ChainId, token_address: string, receivers: BatchReceiver[]) => Promise<string>;
92
+ /**
93
+ * Executes previously-scheduled (timelocked) withdrawals whose delay has elapsed. Amounts and
94
+ * recipients are read from each on-chain commitment, so only request ids + recipients are passed.
95
+ */
96
+ batch_execute_withdrawal: (chain_id: ChainId, token_address: string, receivers: Array<{
97
+ request_id: number;
98
+ receiver_pubkey: PublicKey | string;
99
+ }>) => Promise<string>;
100
+ /** Simulate a batch withdraw (schedule/immediate) to detect requests that would revert. */
101
+ simulate_withdraw_batch: (chain_id: ChainId, token_address: string, receivers: BatchReceiver[]) => Promise<{
102
+ ok: boolean;
103
+ error: string | null;
104
+ }>;
105
+ /** Simulate a batch execute to detect requests that would revert (timelock, already executed). */
106
+ simulate_batch_execute_withdrawal: (chain_id: ChainId, token_address: string, receivers: Array<{
107
+ request_id: number;
108
+ receiver_pubkey: PublicKey | string;
109
+ }>) => Promise<{
110
+ ok: boolean;
111
+ error: string | null;
112
+ }>;
113
+ /**
114
+ * Idempotently ensures the batch path's Address Lookup Table exists and covers `mints`.
115
+ * Safe to call on every startup: it discovers an existing table on-chain, extends it when
116
+ * addresses are missing, and only creates one when none exists. Returns the address, or null
117
+ * when provisioning failed (callers then run on legacy transactions).
118
+ *
119
+ * `withdraw_batch` calls this automatically for signature-carrying batches, so wiring it into
120
+ * startup is about observability and warming, not correctness.
121
+ */
122
+ ensure_lookup_table: (mints: string[]) => Promise<string>;
123
+ /** @deprecated prefer `ensure_lookup_table` — this throws instead of degrading gracefully. */
124
+ create_lookup_table: (mints: string[]) => Promise<string>;
85
125
  /**
86
126
  *
87
127
  * @param token_address Address of the token to withdraw
@@ -1 +1 @@
1
- {"version":3,"file":"SolanaEscrowAdmin.d.ts","sourceRoot":"","sources":["../../../../src/services/solana/escrow/SolanaEscrowAdmin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAqC,MAAM,iBAAiB,CAAC;AAEpG,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAE,aAAa,EAAE,4BAA4B,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAkBtG,UAAU,2BAA2B;IACjC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,EAAE,OAAO,CAAC;CACrB;AAED,cAAM,iBAAiB;IACZ,QAAQ,EAAE,MAAM,CAAC,cAAc,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACvC,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,MAAM,CAAC,CAAU;IAClB,UAAU,EAAE,UAAU,CAAC;gBAG1B,aAAa,EAAE,MAAM,EACrB,eAAe,EAAE,SAAS,EAC1B,eAAe,EAAE,wBAAwB,EACzC,mBAAmB,EAAE,4BAA4B,EACjD,OAAO,EAAE,MAAM,EACf,gBAAgB,CAAC,EAAE,2BAA2B,EAC9C,UAAU,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU;IAkCvC;;;OAGG;IACH,OAAO,CAAC,OAAO,CAGb;IAEF;;;OAGG;IACI,kBAAkB,wBAGvB;IAKF;;;OAGG;IACI,SAAS,yBAEf;IAED;;;;OAIG;IACI,QAAQ,GAA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CAAC;QAAC,eAAe,EAAE,SAAS,GAAG,MAAM,CAAA;KAAE,CAAC,qBAGhF;IAED,2FAA2F;IACpF,uBAAuB,GAAU,UAAU,OAAO,EAAE,eAAe,MAAM,EAAE,WAAW,aAAa,EAAE;;;OAE3G;IAED,kGAAkG;IAC3F,iCAAiC,GACpC,UAAU,OAAO,EACjB,eAAe,MAAM,EACrB,WAAW,KAAK,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,SAAS,GAAG,MAAM,CAAA;KAAE,CAAC;;;OAGhF;IAED;;;;;;;;OAQG;IACI,mBAAmB,GAAU,OAAO,MAAM,EAAE,qBAGlD;IAED,8FAA8F;IACvF,mBAAmB,GAAU,OAAO,MAAM,EAAE,qBAElD;IAGD;;;;;;OAMG;IACI,QAAQ,GAAU,eAAe,MAAM,EAAE,oBAAoB,MAAM,EAAE,kBAAkB,MAAM,iCAEnG;IAED;;;;;OAKG;IACI,OAAO,GAAU,eAAe,MAAM,EAAE,oBAAoB,MAAM,qBAExE;CAKJ;AAED,eAAe,iBAAiB,CAAC"}
@@ -162,8 +162,40 @@ class SolanaEscrowAdmin {
162
162
  this.set_pause_state = (target_state) => __awaiter(this, void 0, void 0, function* () {
163
163
  return this.adminUtility.set_pause_state(target_state, this.signer);
164
164
  });
165
- this.withdraw_batch = (token_address, receivers) => __awaiter(this, void 0, void 0, function* () {
166
- return this.adminUtility.withdraw_batch(token_address, receivers, this.signer);
165
+ this.withdraw_batch = (chain_id, token_address, receivers) => __awaiter(this, void 0, void 0, function* () {
166
+ return this.adminUtility.withdraw_batch(chain_id, token_address, receivers, this.signer);
167
+ });
168
+ /**
169
+ * Executes previously-scheduled (timelocked) withdrawals whose delay has elapsed. Amounts and
170
+ * recipients are read from each on-chain commitment, so only request ids + recipients are passed.
171
+ */
172
+ this.batch_execute_withdrawal = (chain_id, token_address, receivers) => __awaiter(this, void 0, void 0, function* () {
173
+ return this.adminUtility.batch_execute_withdrawal(chain_id, token_address, receivers, this.signer);
174
+ });
175
+ /** Simulate a batch withdraw (schedule/immediate) to detect requests that would revert. */
176
+ this.simulate_withdraw_batch = (chain_id, token_address, receivers) => __awaiter(this, void 0, void 0, function* () {
177
+ return this.adminUtility.simulate_withdraw_batch(chain_id, token_address, receivers);
178
+ });
179
+ /** Simulate a batch execute to detect requests that would revert (timelock, already executed). */
180
+ this.simulate_batch_execute_withdrawal = (chain_id, token_address, receivers) => __awaiter(this, void 0, void 0, function* () {
181
+ return this.adminUtility.simulate_batch_execute_withdrawal(chain_id, token_address, receivers);
182
+ });
183
+ /**
184
+ * Idempotently ensures the batch path's Address Lookup Table exists and covers `mints`.
185
+ * Safe to call on every startup: it discovers an existing table on-chain, extends it when
186
+ * addresses are missing, and only creates one when none exists. Returns the address, or null
187
+ * when provisioning failed (callers then run on legacy transactions).
188
+ *
189
+ * `withdraw_batch` calls this automatically for signature-carrying batches, so wiring it into
190
+ * startup is about observability and warming, not correctness.
191
+ */
192
+ this.ensure_lookup_table = (mints) => __awaiter(this, void 0, void 0, function* () {
193
+ const table = yield this.adminUtility.ensure_lookup_table(mints, this.signer);
194
+ return table.toBase58();
195
+ });
196
+ /** @deprecated prefer `ensure_lookup_table` — this throws instead of degrading gracefully. */
197
+ this.create_lookup_table = (mints) => __awaiter(this, void 0, void 0, function* () {
198
+ return this.adminUtility.create_lookup_table(mints, this.signer);
167
199
  });
168
200
  /**
169
201
  *
@@ -205,7 +237,7 @@ class SolanaEscrowAdmin {
205
237
  const program = new anchor.Program(target_idl, provider);
206
238
  this.program = program;
207
239
  this.provider = provider;
208
- this.adminUtility = EscrowAdminUtility_1.default.createWithCustomProgramId(provider, new web3_js_1.PublicKey(escrowAddress), this.get_idl());
240
+ this.adminUtility = EscrowAdminUtility_1.default.createWithCustomProgramId(provider, new web3_js_1.PublicKey(escrowAddress), this.get_idl(), additionalParams === null || additionalParams === void 0 ? void 0 : additionalParams.lookup_table_address);
209
241
  if (additionalParams === null || additionalParams === void 0 ? void 0 : additionalParams.signer_keypair)
210
242
  this.signer = additionalParams.signer_keypair;
211
243
  }