@ercworldio/blockchain-shared 1.0.2-dev-PROJ-1265.1 → 1.0.2-dev-PROJ-1265.2
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/build/chains/networks_dev copy.json +793 -0
- package/build/chains/networks_prod-ab120.json +644 -0
- package/build/chains/networks_prod-dz-v1.json +727 -0
- package/build/chains/networks_prod-sh.json +645 -0
- package/build/chains/networks_prod-yb.json +645 -0
- package/build/chains/networks_stg-ab120-mainnet.json +681 -0
- package/build/chains/networks_stg-ab120.json +597 -0
- package/build/chains/networks_stg-bu-v1.json +635 -0
- package/build/chains/networks_stg-yb-v1.json +574 -0
- package/build/contracts/typechain-types/contracts/lib/Events.d.ts +394 -0
- package/build/contracts/typechain-types/contracts/lib/Events.d.ts.map +1 -0
- package/build/contracts/typechain-types/contracts/lib/Events.js +2 -0
- package/build/contracts/typechain-types/contracts/lib/MultisigLib.d.ts +21 -0
- package/build/contracts/typechain-types/contracts/lib/MultisigLib.d.ts.map +1 -0
- package/build/contracts/typechain-types/contracts/lib/MultisigLib.js +2 -0
- package/build/contracts/typechain-types/contracts/lib/index.d.ts +3 -0
- package/build/contracts/typechain-types/contracts/lib/index.d.ts.map +1 -0
- package/build/contracts/typechain-types/contracts/lib/index.js +2 -0
- package/build/contracts/typechain-types/contracts/mock/ReentrantReceiver.d.ts +54 -0
- package/build/contracts/typechain-types/contracts/mock/ReentrantReceiver.d.ts.map +1 -0
- package/build/contracts/typechain-types/contracts/mock/ReentrantReceiver.js +2 -0
- package/build/contracts/typechain-types/contracts/mock/SelfDestructForcer.d.ts +26 -0
- package/build/contracts/typechain-types/contracts/mock/SelfDestructForcer.d.ts.map +1 -0
- package/build/contracts/typechain-types/contracts/mock/SelfDestructForcer.js +2 -0
- package/build/contracts/typechain-types/contracts/test/DelegatecallProbe.d.ts +30 -0
- package/build/contracts/typechain-types/contracts/test/DelegatecallProbe.d.ts.map +1 -0
- package/build/contracts/typechain-types/contracts/test/DelegatecallProbe.js +2 -0
- package/build/contracts/typechain-types/contracts/test/index.d.ts +2 -0
- package/build/contracts/typechain-types/contracts/test/index.d.ts.map +1 -0
- package/build/contracts/typechain-types/contracts/test/index.js +2 -0
- package/build/contracts/typechain-types/factories/contracts/lib/Events__factory.d.ts +373 -0
- package/build/contracts/typechain-types/factories/contracts/lib/Events__factory.d.ts.map +1 -0
- package/build/contracts/typechain-types/factories/contracts/lib/Events__factory.js +474 -0
- package/build/contracts/typechain-types/factories/contracts/lib/MultisigLib__factory.d.ts +99 -0
- package/build/contracts/typechain-types/factories/contracts/lib/MultisigLib__factory.d.ts.map +1 -0
- package/build/contracts/typechain-types/factories/contracts/lib/MultisigLib__factory.js +140 -0
- package/build/contracts/typechain-types/factories/contracts/lib/index.d.ts +3 -0
- package/build/contracts/typechain-types/factories/contracts/lib/index.d.ts.map +1 -0
- package/build/contracts/typechain-types/factories/contracts/lib/index.js +10 -0
- package/build/contracts/typechain-types/factories/contracts/mock/ReentrantReceiver__factory.d.ts +112 -0
- package/build/contracts/typechain-types/factories/contracts/mock/ReentrantReceiver__factory.d.ts.map +1 -0
- package/build/contracts/typechain-types/factories/contracts/mock/ReentrantReceiver__factory.js +156 -0
- package/build/contracts/typechain-types/factories/contracts/mock/SelfDestructForcer__factory.d.ts +37 -0
- package/build/contracts/typechain-types/factories/contracts/mock/SelfDestructForcer__factory.d.ts.map +1 -0
- package/build/contracts/typechain-types/factories/contracts/mock/SelfDestructForcer__factory.js +57 -0
- package/build/contracts/typechain-types/factories/contracts/test/DelegatecallProbe__factory.d.ts +55 -0
- package/build/contracts/typechain-types/factories/contracts/test/DelegatecallProbe__factory.d.ts.map +1 -0
- package/build/contracts/typechain-types/factories/contracts/test/DelegatecallProbe__factory.js +81 -0
- package/build/contracts/typechain-types/factories/contracts/test/index.d.ts +2 -0
- package/build/contracts/typechain-types/factories/contracts/test/index.d.ts.map +1 -0
- package/build/contracts/typechain-types/factories/contracts/test/index.js +8 -0
- package/build/entities/AdminOperationThresholds.d.ts +11 -0
- package/build/entities/AdminOperationThresholds.d.ts.map +1 -0
- package/build/entities/AdminOperationThresholds.js +52 -0
- package/build/entities/AdminWithdrawal.d.ts +20 -0
- package/build/entities/AdminWithdrawal.d.ts.map +1 -0
- package/build/entities/AdminWithdrawal.js +88 -0
- package/build/entities/CryptoOperationType.d.ts +18 -0
- package/build/entities/CryptoOperationType.d.ts.map +1 -0
- package/build/entities/CryptoOperationType.js +50 -0
- package/build/entities/EscrowRoles.d.ts +12 -0
- package/build/entities/EscrowRoles.d.ts.map +1 -0
- package/build/entities/EscrowRoles.js +57 -0
- package/build/entities/GlobalTimelock.d.ts +13 -0
- package/build/entities/GlobalTimelock.d.ts.map +1 -0
- package/build/entities/GlobalTimelock.js +60 -0
- package/build/entities/GranularTimelock .d.ts +12 -0
- package/build/entities/GranularTimelock .d.ts.map +1 -0
- package/build/entities/GranularTimelock .js +56 -0
- package/build/entities/GranularTimelock.d.ts +11 -0
- package/build/entities/GranularTimelock.d.ts.map +1 -0
- package/build/entities/GranularTimelock.js +52 -0
- package/build/entities/OperationType.d.ts +18 -0
- package/build/entities/OperationType.d.ts.map +1 -0
- package/build/entities/OperationType.js +50 -0
- package/build/entities/RoleHash.d.ts +11 -0
- package/build/entities/RoleHash.d.ts.map +1 -0
- package/build/entities/RoleHash.js +52 -0
- package/build/entities/ScheduleTransactionJob.d.ts +23 -0
- package/build/entities/ScheduleTransactionJob.d.ts.map +1 -0
- package/build/entities/ScheduleTransactionJob.js +89 -0
- package/build/entities/ScheduleTransactionJobHistory.d.ts +17 -0
- package/build/entities/ScheduleTransactionJobHistory.d.ts.map +1 -0
- package/build/entities/ScheduleTransactionJobHistory.js +66 -0
- package/build/entities/Signatures.d.ts +16 -0
- package/build/entities/Signatures.d.ts.map +1 -0
- package/build/entities/Signatures.js +72 -0
- package/build/entities/TokenExecutionThresholds.d.ts +15 -0
- package/build/entities/TokenExecutionThresholds.d.ts.map +1 -0
- package/build/entities/TokenExecutionThresholds.js +68 -0
- package/build/entities/WithdrawalCommitment.d.ts +15 -0
- package/build/entities/WithdrawalCommitment.d.ts.map +1 -0
- package/build/entities/WithdrawalCommitment.js +64 -0
- package/build/entities/index.d.ts +22 -0
- package/build/entities/index.d.ts.map +1 -0
- package/build/entities/index.js +37 -0
- package/build/services/AccountingService.d.ts +2 -0
- package/build/services/AccountingService.d.ts.map +1 -1
- package/build/services/AccountingService.js +35 -6
- package/build/services/AccountingServiceStatic.d.ts +14 -0
- package/build/services/AccountingServiceStatic.d.ts.map +1 -0
- package/build/services/AccountingServiceStatic.js +38 -0
- package/build/services/ClaimJobServiceStatic.d.ts +9 -0
- package/build/services/ClaimJobServiceStatic.d.ts.map +1 -0
- package/build/services/ClaimJobServiceStatic.js +54 -0
- package/build/services/WithdrawalService.d.ts +10 -0
- package/build/services/WithdrawalService.d.ts.map +1 -0
- package/build/services/WithdrawalService.js +38 -0
- package/build/services/db/multisig/MultisigService.d.ts +31 -0
- package/build/services/db/multisig/MultisigService.d.ts.map +1 -0
- package/build/services/db/multisig/MultisigService.js +134 -0
- package/build/services/db/roles/ContractRoles.d.ts +54 -0
- package/build/services/db/roles/ContractRoles.d.ts.map +1 -0
- package/build/services/db/roles/ContractRoles.js +87 -0
- package/build/services/db/timelock/ScheduleTransactionJobHistoryService.d.ts +14 -0
- package/build/services/db/timelock/ScheduleTransactionJobHistoryService.d.ts.map +1 -0
- package/build/services/db/timelock/ScheduleTransactionJobHistoryService.js +63 -0
- package/build/services/db/timelock/ScheduleTransactionService.d.ts +46 -0
- package/build/services/db/timelock/ScheduleTransactionService.d.ts.map +1 -0
- package/build/services/db/timelock/ScheduleTransactionService.js +476 -0
- package/build/services/rpc/RPC.d.ts +20 -0
- package/build/services/rpc/RPC.d.ts.map +1 -0
- package/build/services/rpc/RPC.js +49 -0
- package/build/services/solana/escrow/services/TreasuryWithdrawalSignature.d.ts +58 -0
- package/build/services/solana/escrow/services/TreasuryWithdrawalSignature.d.ts.map +1 -0
- package/build/services/solana/escrow/services/TreasuryWithdrawalSignature.js +109 -0
- package/build/services/types/db/index.d.ts +3 -0
- package/build/services/types/db/index.d.ts.map +1 -0
- package/build/services/types/db/index.js +18 -0
- package/build/services/types/db/multisig_service.d.ts +154 -0
- package/build/services/types/db/multisig_service.d.ts.map +1 -0
- package/build/services/types/db/multisig_service.js +2 -0
- package/build/services/types/db/timelock.d.ts +84 -0
- package/build/services/types/db/timelock.d.ts.map +1 -0
- package/build/services/types/db/timelock.js +2 -0
- package/build/services/types/db/withdrawal_service.d.ts +16 -0
- package/build/services/types/db/withdrawal_service.d.ts.map +1 -0
- package/build/services/types/db/withdrawal_service.js +2 -0
- package/build/services/types/watchdog.d.ts +9 -0
- package/build/services/types/watchdog.d.ts.map +1 -0
- package/build/services/types/watchdog.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var _a;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
class ScheduleTransactionService {
|
|
14
|
+
}
|
|
15
|
+
_a = ScheduleTransactionService;
|
|
16
|
+
ScheduleTransactionService.get_and_lock_available_jobs = (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" }) {
|
|
17
|
+
const ttlSeconds = job_ttl_s;
|
|
18
|
+
const res = yield pool.query(`
|
|
19
|
+
WITH status_ids AS (
|
|
20
|
+
SELECT
|
|
21
|
+
MAX(CASE WHEN status = 'queued' THEN id END) AS queued_id,
|
|
22
|
+
MAX(CASE WHEN status = 'processing' THEN id END) AS processing_id
|
|
23
|
+
FROM multisig.schedule_job_statuses
|
|
24
|
+
),
|
|
25
|
+
candidates AS (
|
|
26
|
+
SELECT cj.id
|
|
27
|
+
FROM multisig.schedule_transaction_jobs cj, status_ids
|
|
28
|
+
WHERE cj.status_id = status_ids.queued_id
|
|
29
|
+
AND (cj.lock_expires_at IS NULL OR cj.lock_expires_at < now())
|
|
30
|
+
ORDER BY cj.blockchain, cj.chain_id ASC
|
|
31
|
+
LIMIT $1
|
|
32
|
+
FOR UPDATE SKIP LOCKED
|
|
33
|
+
)
|
|
34
|
+
UPDATE multisig.schedule_transaction_jobs cj
|
|
35
|
+
SET
|
|
36
|
+
status_id = si.processing_id,
|
|
37
|
+
locked_at = now(),
|
|
38
|
+
lock_expires_at = now() + ($2 || ' seconds')::interval,
|
|
39
|
+
metadata = jsonb_set(
|
|
40
|
+
jsonb_set(
|
|
41
|
+
coalesce(cj.metadata, '{}'::jsonb),
|
|
42
|
+
'{lock_owner}',
|
|
43
|
+
to_jsonb($3::text)
|
|
44
|
+
),
|
|
45
|
+
'{lock_reason}',
|
|
46
|
+
to_jsonb($4::text)
|
|
47
|
+
),
|
|
48
|
+
updated_at = now()
|
|
49
|
+
FROM candidates c, status_ids si
|
|
50
|
+
WHERE cj.id = c.id
|
|
51
|
+
RETURNING cj.*;
|
|
52
|
+
`, [limit, ttlSeconds, lock_metadata.lock_owner, lock_metadata.lock_reason]);
|
|
53
|
+
return res.rows;
|
|
54
|
+
});
|
|
55
|
+
/** Locks and returns available jobs with full withdrawal details via inline SQL (bypasses DB function). */
|
|
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" }) {
|
|
172
|
+
var _b;
|
|
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]);
|
|
174
|
+
return (_b = result.rows[0].fn_get_available_schedule_jobs_with_details) !== null && _b !== void 0 ? _b : [];
|
|
175
|
+
});
|
|
176
|
+
/**
|
|
177
|
+
* Requeues all jobs in the given status to "queued"
|
|
178
|
+
*/
|
|
179
|
+
ScheduleTransactionService.requeue_expired_jobs = (pool, data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
180
|
+
const res = yield pool.query(`
|
|
181
|
+
WITH status_ids AS (
|
|
182
|
+
SELECT
|
|
183
|
+
MAX(CASE WHEN status = $4::text THEN id END) AS current_status_id,
|
|
184
|
+
MAX(CASE WHEN status = 'queued' THEN id END) AS queued_id
|
|
185
|
+
FROM multisig.schedule_job_statuses
|
|
186
|
+
),
|
|
187
|
+
expired AS (
|
|
188
|
+
SELECT sj.id
|
|
189
|
+
FROM multisig.schedule_transaction_jobs sj, status_ids
|
|
190
|
+
WHERE sj.status_id = status_ids.current_status_id
|
|
191
|
+
AND (
|
|
192
|
+
sj.lock_expires_at IS NULL
|
|
193
|
+
OR sj.lock_expires_at < now()
|
|
194
|
+
)
|
|
195
|
+
AND sj.retry_count < $5
|
|
196
|
+
ORDER BY sj.lock_expires_at ASC
|
|
197
|
+
LIMIT $1
|
|
198
|
+
FOR UPDATE SKIP LOCKED
|
|
199
|
+
)
|
|
200
|
+
UPDATE multisig.schedule_transaction_jobs cj
|
|
201
|
+
SET
|
|
202
|
+
status_id = si.queued_id,
|
|
203
|
+
locked_at = NULL,
|
|
204
|
+
lock_expires_at = NULL,
|
|
205
|
+
metadata = jsonb_set(
|
|
206
|
+
jsonb_set(
|
|
207
|
+
coalesce(metadata, '{}'::jsonb),
|
|
208
|
+
'{requeued_by}',
|
|
209
|
+
to_jsonb($2::text),
|
|
210
|
+
true
|
|
211
|
+
),
|
|
212
|
+
'{requeue_reason}',
|
|
213
|
+
to_jsonb($3::text),
|
|
214
|
+
true
|
|
215
|
+
),
|
|
216
|
+
updated_at = now()
|
|
217
|
+
FROM expired e, status_ids si
|
|
218
|
+
WHERE cj.id = e.id
|
|
219
|
+
RETURNING cj.*;
|
|
220
|
+
`, [data.limit, data.lock_owner, data.lock_reason, data.watch_status, data.max_retries]);
|
|
221
|
+
return res.rows;
|
|
222
|
+
});
|
|
223
|
+
ScheduleTransactionService.batch_update_status = (pool, operation_type, request_ids, new_status) => __awaiter(void 0, void 0, void 0, function* () {
|
|
224
|
+
yield pool.query(`
|
|
225
|
+
UPDATE multisig.schedule_transaction_jobs
|
|
226
|
+
SET
|
|
227
|
+
status_id = (SELECT id FROM multisig.schedule_job_statuses WHERE status = $1),
|
|
228
|
+
updated_at = CURRENT_TIMESTAMP
|
|
229
|
+
WHERE operation_type = $2::int
|
|
230
|
+
AND request_id = ANY($3)
|
|
231
|
+
`, [new_status, operation_type, request_ids]);
|
|
232
|
+
});
|
|
233
|
+
ScheduleTransactionService.batch_update_failed_jobs = (pool, operation_type, request_ids, new_status, error_message, retryable) => __awaiter(void 0, void 0, void 0, function* () {
|
|
234
|
+
yield pool.query(`
|
|
235
|
+
UPDATE multisig.schedule_transaction_jobs
|
|
236
|
+
SET
|
|
237
|
+
status_id = (SELECT id FROM multisig.schedule_job_statuses WHERE status = $1),
|
|
238
|
+
updated_at = CURRENT_TIMESTAMP,
|
|
239
|
+
error_message = COALESCE($2, error_message),
|
|
240
|
+
last_error_at = CASE
|
|
241
|
+
WHEN $2 IS NOT NULL THEN CURRENT_TIMESTAMP
|
|
242
|
+
ELSE last_error_at
|
|
243
|
+
END,
|
|
244
|
+
retry_count = CASE
|
|
245
|
+
WHEN $3 = true THEN retry_count + 1
|
|
246
|
+
ELSE retry_count
|
|
247
|
+
END
|
|
248
|
+
WHERE operation_type = $5
|
|
249
|
+
AND request_id = ANY($4)
|
|
250
|
+
`, [
|
|
251
|
+
new_status,
|
|
252
|
+
error_message || null,
|
|
253
|
+
retryable === true,
|
|
254
|
+
request_ids,
|
|
255
|
+
operation_type,
|
|
256
|
+
]);
|
|
257
|
+
});
|
|
258
|
+
ScheduleTransactionService.batch_update_failed_jobs_custom_error = (pool, operation_type, jobs) => __awaiter(void 0, void 0, void 0, function* () {
|
|
259
|
+
const operationTypes = jobs.map(() => operation_type);
|
|
260
|
+
const requestIds = jobs.map(j => j.request_id);
|
|
261
|
+
const newStatuses = jobs.map(j => j.new_status);
|
|
262
|
+
const errorMessages = jobs.map(j => j.error_message);
|
|
263
|
+
const retryables = jobs.map(j => j.retryable);
|
|
264
|
+
yield pool.query(`
|
|
265
|
+
UPDATE multisig.schedule_transaction_jobs AS t
|
|
266
|
+
SET
|
|
267
|
+
status_id = sjs.id,
|
|
268
|
+
error_message = c.error_message,
|
|
269
|
+
last_error_at = CURRENT_TIMESTAMP,
|
|
270
|
+
retry_count = CASE WHEN c.retryable THEN t.retry_count + 1 ELSE t.retry_count END,
|
|
271
|
+
updated_at = CURRENT_TIMESTAMP
|
|
272
|
+
FROM (
|
|
273
|
+
SELECT
|
|
274
|
+
UNNEST($1::int[]) AS operation_type,
|
|
275
|
+
UNNEST($2::int[]) AS request_id,
|
|
276
|
+
UNNEST($3::text[]) AS status,
|
|
277
|
+
UNNEST($4::text[]) AS error_message,
|
|
278
|
+
UNNEST($5::boolean[]) AS retryable
|
|
279
|
+
) AS c
|
|
280
|
+
JOIN multisig.schedule_job_statuses sjs ON sjs.status = c.status
|
|
281
|
+
WHERE t.operation_type = c.operation_type
|
|
282
|
+
AND t.request_id = c.request_id
|
|
283
|
+
`, [operationTypes, requestIds, newStatuses, errorMessages, retryables]);
|
|
284
|
+
});
|
|
285
|
+
ScheduleTransactionService.batch_update_executed_jobs = (pool, data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
286
|
+
const requestIds = data.map(d => d.request_id);
|
|
287
|
+
const operationTypes = data.map(d => d.operation_type);
|
|
288
|
+
const txHashes = data.map(d => d.tx_hash);
|
|
289
|
+
const sentAts = data.map(d => d.sent_at);
|
|
290
|
+
yield pool.query(`
|
|
291
|
+
UPDATE multisig.schedule_transaction_jobs AS t
|
|
292
|
+
SET
|
|
293
|
+
tx_hash = c.tx_hash,
|
|
294
|
+
sent_at = c.sent_at,
|
|
295
|
+
status_id = (SELECT id FROM multisig.schedule_job_statuses WHERE status = 'confirming'),
|
|
296
|
+
updated_at = CURRENT_TIMESTAMP
|
|
297
|
+
FROM (
|
|
298
|
+
SELECT
|
|
299
|
+
UNNEST($1::int[]) AS operation_type,
|
|
300
|
+
UNNEST($2::int[]) AS request_id,
|
|
301
|
+
UNNEST($3::text[]) AS tx_hash,
|
|
302
|
+
UNNEST($4::timestamptz[]) AS sent_at
|
|
303
|
+
) AS c
|
|
304
|
+
WHERE t.request_id = c.request_id
|
|
305
|
+
AND t.operation_type = c.operation_type
|
|
306
|
+
`, [operationTypes, requestIds, txHashes, sentAts]);
|
|
307
|
+
});
|
|
308
|
+
ScheduleTransactionService.mark_complete = (pool, payloads) => __awaiter(void 0, void 0, void 0, function* () {
|
|
309
|
+
if (payloads.length === 0)
|
|
310
|
+
return;
|
|
311
|
+
const requestIds = payloads.map(d => d.requestId);
|
|
312
|
+
const operationTypes = payloads.map(d => d.operationType);
|
|
313
|
+
yield pool.query(`
|
|
314
|
+
UPDATE multisig.schedule_transaction_jobs AS t
|
|
315
|
+
SET
|
|
316
|
+
status_id = (SELECT id FROM multisig.schedule_job_statuses WHERE status = 'completed'),
|
|
317
|
+
updated_at = CURRENT_TIMESTAMP
|
|
318
|
+
FROM (
|
|
319
|
+
SELECT
|
|
320
|
+
UNNEST($1::int[]) AS request_id,
|
|
321
|
+
UNNEST($2::int[]) AS operation_type
|
|
322
|
+
) AS c
|
|
323
|
+
WHERE t.request_id = c.request_id
|
|
324
|
+
AND t.operation_type = c.operation_type
|
|
325
|
+
`, [requestIds, operationTypes]);
|
|
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
|
+
});
|
|
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;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { PublicKey, TransactionInstruction } from "@solana/web3.js";
|
|
2
|
+
/**
|
|
3
|
+
* Treasury withdrawal approval message + Ed25519 assembly.
|
|
4
|
+
*
|
|
5
|
+
* Mirrors the escrow program's `build_withdrawal_message` and its Ed25519SigVerify layout so the
|
|
6
|
+
* batch-withdraw transaction the funding worker sends carries signatures the program accepts.
|
|
7
|
+
*/
|
|
8
|
+
/** One treasury manager/executive approval over a request's message. */
|
|
9
|
+
export interface TreasurySignatureInput {
|
|
10
|
+
/** Base58 signer pubkey — a current treasury manager/executive on-chain. */
|
|
11
|
+
signer: string;
|
|
12
|
+
/** 64-byte Ed25519 signature (base64/hex/base58). */
|
|
13
|
+
signature: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Builds the UTF-8 approval message a treasury signer approves. MUST match the program's
|
|
17
|
+
* `build_withdrawal_message` byte for byte, or verification fails.
|
|
18
|
+
*
|
|
19
|
+
* Withdrawal Approval
|
|
20
|
+
* Version: 1
|
|
21
|
+
* Chain: <chainId>
|
|
22
|
+
* Request: <requestId>
|
|
23
|
+
* Recipient: <recipient base58>
|
|
24
|
+
* Token: <mint base58>
|
|
25
|
+
* Amount: <committed amount, raw base units>
|
|
26
|
+
*
|
|
27
|
+
* `Amount` is the committed (approved) amount — the net paid out is chosen later by the backend
|
|
28
|
+
* and bounded on-chain by TreasuryConfig.max_fee_delta. The title + Version line domain-separate
|
|
29
|
+
* the signature; bump Version in lockstep with the program on any format change.
|
|
30
|
+
*/
|
|
31
|
+
export declare function buildWithdrawalApprovalMessage(params: {
|
|
32
|
+
recipient: PublicKey;
|
|
33
|
+
tokenMint: PublicKey;
|
|
34
|
+
committedAmount: bigint;
|
|
35
|
+
chainId: bigint;
|
|
36
|
+
requestId: bigint;
|
|
37
|
+
}): Buffer;
|
|
38
|
+
/** Decode a 64-byte Ed25519 signature from base64, hex (0x-optional), or base58. */
|
|
39
|
+
export declare function decodeEd25519Signature(s: string): Uint8Array;
|
|
40
|
+
/** One fully-decoded signature entry: pubkey + signature over `message`. */
|
|
41
|
+
export interface Ed25519Entry {
|
|
42
|
+
publicKey: Uint8Array;
|
|
43
|
+
signature: Uint8Array;
|
|
44
|
+
message: Uint8Array;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Builds a single Ed25519SigVerify instruction carrying `entries` self-contained signatures
|
|
48
|
+
* (each entry's pubkey, signature and message live in this instruction's own data). This is the
|
|
49
|
+
* compact layout the program scans in `verify_treasury_threshold`; one instruction for the whole
|
|
50
|
+
* batch keeps the transaction far smaller than one instruction per signature.
|
|
51
|
+
*
|
|
52
|
+
* Identical messages are stored ONCE and shared by every signature over them, since the offsets
|
|
53
|
+
* table lets multiple entries point at the same message region. This matters: the N signers who
|
|
54
|
+
* approve one withdrawal all sign the same ~194-byte payload, so without sharing, a 2-of-N
|
|
55
|
+
* approval would spend an extra ~194 bytes and overflow Solana's 1232-byte transaction limit.
|
|
56
|
+
*/
|
|
57
|
+
export declare function buildTreasuryEd25519Instruction(entries: Ed25519Entry[]): TransactionInstruction;
|
|
58
|
+
//# sourceMappingURL=TreasuryWithdrawalSignature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreasuryWithdrawalSignature.d.ts","sourceRoot":"","sources":["../../../../../src/services/solana/escrow/services/TreasuryWithdrawalSignature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAGpF;;;;;GAKG;AAEH,wEAAwE;AACxE,MAAM,WAAW,sBAAsB;IACnC,4EAA4E;IAC5E,MAAM,EAAE,MAAM,CAAC;IACf,qDAAqD;IACrD,SAAS,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,8BAA8B,CAAC,MAAM,EAAE;IACnD,SAAS,EAAE,SAAS,CAAC;IACrB,SAAS,EAAE,SAAS,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACrB,GAAG,MAAM,CAUT;AAED,oFAAoF;AACpF,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,MAAM,GAAG,UAAU,CAU5D;AAED,4EAA4E;AAC5E,MAAM,WAAW,YAAY;IACzB,SAAS,EAAE,UAAU,CAAC;IACtB,SAAS,EAAE,UAAU,CAAC;IACtB,OAAO,EAAE,UAAU,CAAC;CACvB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,sBAAsB,CAoD/F"}
|