@ercworldio/blockchain-shared 1.0.5-dev.8-PLAT300.7 → 1.0.5-dev.8-fix
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.json +11 -2
- package/build/chains/networks_prod-ab120.json +644 -0
- package/build/chains/networks_prod-bu.json +0 -14
- package/build/chains/networks_prod-dz-v1.json +1 -1
- package/build/chains/networks_prod-dz.json +47 -26
- 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.json +25 -30
- package/build/chains/networks_stg-dz.json +20 -21
- package/build/chains/networks_stg-yb-v1.json +574 -0
- package/build/contracts/Escrow.d.ts +2 -0
- package/build/contracts/Escrow.d.ts.map +1 -1
- package/build/contracts/Escrow.js +63 -0
- package/build/contracts/artifacts/Escrow.json +87 -10
- package/build/contracts/contract-events/EscrowEvents.d.ts +14 -14
- package/build/contracts/contract-events/EscrowEvents.d.ts.map +1 -1
- package/build/contracts/contract-events/EscrowEvents.js +5 -5
- package/build/contracts/typechain-types/contracts/escrow/Escrow.d.ts +31 -17
- package/build/contracts/typechain-types/contracts/escrow/Escrow.d.ts.map +1 -1
- package/build/contracts/typechain-types/factories/contracts/escrow/EscrowAccessControl__factory.d.ts +1 -1
- package/build/contracts/typechain-types/factories/contracts/escrow/EscrowAccessControl__factory.js +1 -1
- package/build/contracts/typechain-types/factories/contracts/escrow/EscrowSignature__factory.d.ts +1 -1
- package/build/contracts/typechain-types/factories/contracts/escrow/EscrowSignature__factory.js +1 -1
- package/build/contracts/typechain-types/factories/contracts/escrow/Escrow__factory.d.ts +67 -9
- package/build/contracts/typechain-types/factories/contracts/escrow/Escrow__factory.d.ts.map +1 -1
- package/build/contracts/typechain-types/factories/contracts/escrow/Escrow__factory.js +88 -11
- package/build/contracts/typechain-types/factories/contracts/lib/MultisigLib__factory.d.ts +1 -1
- package/build/contracts/typechain-types/factories/contracts/lib/MultisigLib__factory.js +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +3 -3
- 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/AlchemyService.d.ts.map +1 -1
- package/build/services/AlchemyService.js +2 -3
- package/build/services/AzureEventHubHandler.d.ts.map +1 -1
- package/build/services/AzureEventHubHandler.js +4 -1
- package/build/services/ClaimJobService.d.ts.map +1 -1
- package/build/services/ClaimJobService.js +12 -5
- package/build/services/Redis.js +2 -2
- package/build/services/RedisPubSub.js +1 -1
- package/build/services/WithdrawalManager.js +1 -1
- package/build/services/db/multisig/MultisigService.d.ts +1 -19
- package/build/services/db/multisig/MultisigService.d.ts.map +1 -1
- package/build/services/db/multisig/MultisigService.js +0 -63
- package/build/services/db/timelock/ScheduleTransactionService.d.ts +16 -2
- package/build/services/db/timelock/ScheduleTransactionService.d.ts.map +1 -1
- package/build/services/db/timelock/ScheduleTransactionService.js +265 -1
- package/build/services/solana/escrow/idl/escrow.json +1459 -4161
- package/build/services/solana/escrow/services/EscrowAdminUtility.d.ts.map +1 -1
- package/build/services/solana/escrow/services/EscrowAdminUtility.js +0 -1
- package/build/services/solana/escrow/services/TreasuryWithdrawalSignature.d.ts +1 -8
- package/build/services/solana/escrow/services/TreasuryWithdrawalSignature.d.ts.map +1 -1
- package/build/services/solana/escrow/services/TreasuryWithdrawalSignature.js +2 -9
- package/build/services/solana/escrow/types/escrow.d.ts +1457 -4159
- package/build/services/solana/escrow/types/escrow.d.ts.map +1 -1
- package/build/services/types/azure_event_hub_handler.d.ts +3 -1
- package/build/services/types/azure_event_hub_handler.d.ts.map +1 -1
- package/build/services/types/azure_event_hub_handler.js +3 -0
- package/build/services/types/claim.d.ts +1 -0
- package/build/services/types/claim.d.ts.map +1 -1
- package/build/services/types/db/multisig_service.d.ts +0 -74
- package/build/services/types/db/multisig_service.d.ts.map +1 -1
- package/build/services/types/db/timelock.d.ts +56 -0
- package/build/services/types/db/timelock.d.ts.map +1 -1
- package/build/utils/solana.d.ts.map +1 -1
- package/build/utils/solana.js +5 -3
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClaimJobService.d.ts","sourceRoot":"","sources":["../../src/services/ClaimJobService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGjD,OAAO,EAAE,SAAS,EAA0B,MAAM,eAAe,CAAC;AAElE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAKlK,cAAM,gBAAgB;IAClB,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,KAAK,CAAS;gBAGV,MAAM,EAAE,aAAa;IAMjC,OAAO,CAAC,QAAQ,CAIf;IAED,OAAO,CAAC,gBAAgB,CAIvB;IAED,OAAO,CAAC,QAAQ,CAsBf;IAEM,yCAAyC,GAAU,QAAO,MAAW,EAAE,YAAW,MAAY,EAAE,kBAAiB,MAAU,EAAE,gBAAe,oBAAoF,KAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAOvQ;IAEM,8BAA8B,GAAU,QAAO,MAAW,EAAE,YAAW,MAAY,EAAE,kBAAiB,MAAU,EAAE,gBAAe,oBAAoF,KAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"ClaimJobService.d.ts","sourceRoot":"","sources":["../../src/services/ClaimJobService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC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KAAG,OAAO,CAAC,SAAS,CAAC,CA2BpF;IAEM,uBAAuB,GAAU,YAAY,MAAM,EAAE,YAAY,SAAS,6CAGhF;IAEM,mBAAmB,GAAU,aAAa,MAAM,EAAE,EAAE,YAAY,SAAS,KAAG,OAAO,CAAC,IAAI,CAAC,CAW9F;IAEK,wBAAwB,GAC3B,aAAa,MAAM,EAAE,EACrB,YAAY,SAAS,EACrB,gBAAgB,MAAM,EACtB,YAAY,OAAO,KACpB,OAAO,CAAC,IAAI,CAAC,CAwBd;IAIK,aAAa,GAAU,UAAU,mBAAmB,EAAE,+BA+C5D;IAEM,0BAA0B,GAC7B,MAAM;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,IAAI,CAAA;KAAE,EAAE,KAC/D,OAAO,CAAC,IAAI,CAAC,CAwBd;IAGK,mCAAmC,GACtC,MAAM,SAAS,EAAE,EACjB,WAAW,OAAO,KACnB,OAAO,CAAC,IAAI,CAAC,CAsBf;IAIM,gBAAgB,GAAU,YAAY,QAAQ,GAAG,KAAK,EAAE,UAAU,OAAO,qBAI/E;IAEM,oBAAoB,GAAU,YAAY,QAAQ,GAAG,KAAK,GAAG,MAAM,EAAE,UAAU,OAAO,EAAE,cAAU,KAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAW/H;IAEM,iBAAiB,GAAU,aAAa,MAAM,EAAE,KAAG,OAAO,CAAC,IAAI,CAAC,CAQrE;IAEK,gBAAgB,GAAU,YAAY,MAAM,6CAGlD;IAED,OAAO,CAAC,YAAY,CAenB;CAEJ;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -108,7 +108,8 @@ class ClaimJobsService {
|
|
|
108
108
|
'operationType', cs.operation_type,
|
|
109
109
|
'v', cs.v,
|
|
110
110
|
'r', cs.r,
|
|
111
|
-
's', cs.s
|
|
111
|
+
's', cs.s,
|
|
112
|
+
'signature', cs.signature
|
|
112
113
|
)), '[]'::json)
|
|
113
114
|
FROM multisig.crypto_signatures cs
|
|
114
115
|
LEFT JOIN multisig.crypto_escrow_roles cer
|
|
@@ -118,9 +119,10 @@ class ClaimJobsService {
|
|
|
118
119
|
AND LOWER(cer.contract_address) = LOWER(cs.contract_address)
|
|
119
120
|
LEFT JOIN multisig.crypto_role cr ON cr.id = cer.role_id
|
|
120
121
|
WHERE cs.reference_id = u.request_id
|
|
121
|
-
AND
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
AND (
|
|
123
|
+
(cs.v IS NOT NULL AND cs.r IS NOT NULL AND cs.s IS NOT NULL)
|
|
124
|
+
OR cs.signature IS NOT NULL
|
|
125
|
+
)
|
|
124
126
|
) AS multisig_signatures
|
|
125
127
|
FROM updated u;
|
|
126
128
|
`, [limit, job_ttl_s, (0, uuid_1.v4)(), lock_metadata.lock_owner, lock_metadata.lock_reason, max_retry_count]);
|
|
@@ -185,7 +187,8 @@ class ClaimJobsService {
|
|
|
185
187
|
'operationType', cs.operation_type,
|
|
186
188
|
'v', cs.v,
|
|
187
189
|
'r', cs.r,
|
|
188
|
-
's', cs.s
|
|
190
|
+
's', cs.s,
|
|
191
|
+
'signature', cs.signature
|
|
189
192
|
)), '[]'::json)
|
|
190
193
|
FROM multisig.crypto_signatures cs
|
|
191
194
|
LEFT JOIN multisig.crypto_escrow_roles cer
|
|
@@ -195,6 +198,10 @@ class ClaimJobsService {
|
|
|
195
198
|
AND LOWER(cer.contract_address) = LOWER(cs.contract_address)
|
|
196
199
|
LEFT JOIN multisig.crypto_role cr ON cr.id = cer.role_id
|
|
197
200
|
WHERE cs.reference_id = u.request_id
|
|
201
|
+
AND (
|
|
202
|
+
(cs.v IS NOT NULL AND cs.r IS NOT NULL AND cs.s IS NOT NULL)
|
|
203
|
+
OR cs.signature IS NOT NULL
|
|
204
|
+
)
|
|
198
205
|
) AS multisig_signatures
|
|
199
206
|
FROM updated u
|
|
200
207
|
LEFT JOIN multisig.crypto_withdrawal_commitment cwc ON cwc.request_id = u.request_id;
|
package/build/services/Redis.js
CHANGED
|
@@ -277,7 +277,7 @@ class Redis {
|
|
|
277
277
|
try {
|
|
278
278
|
const pref = `${this.prefix}-`;
|
|
279
279
|
const normalizedKey = expiredKey.startsWith(pref) ? expiredKey.slice(pref.length) : expiredKey;
|
|
280
|
-
this.logger.info(`Redis: key expired: ${normalizedKey}`);
|
|
280
|
+
// this.logger.info(`Redis: key expired: ${normalizedKey}`);
|
|
281
281
|
let value = null;
|
|
282
282
|
try {
|
|
283
283
|
value = yield this.get_object(expiredKey);
|
|
@@ -381,7 +381,7 @@ class Redis {
|
|
|
381
381
|
get_object(_key_1) {
|
|
382
382
|
return __awaiter(this, arguments, void 0, function* (_key, use_prefix = true) {
|
|
383
383
|
const key = this.get_key(_key, use_prefix);
|
|
384
|
-
this.logger.info(`Redis: Getting object with key: ${key}`);
|
|
384
|
+
// this.logger.info(`Redis: Getting object with key: ${key}`);
|
|
385
385
|
const raw = yield this._get(key);
|
|
386
386
|
return raw ? JSON.parse(raw) : null;
|
|
387
387
|
});
|
|
@@ -110,7 +110,7 @@ class RedisPubSub {
|
|
|
110
110
|
this.logger.info(`RedisPubSub: pSubscribe: Subscribed to pattern: ${pattern}`);
|
|
111
111
|
yield this.subscriber.pSubscribe(pattern, (eventKey) => __awaiter(this, void 0, void 0, function* () {
|
|
112
112
|
try {
|
|
113
|
-
this.logger.info(`RedisPubSub: pSubscribe: Received subscriber event: ${event.eventName}. eventkey: ${eventKey}`)
|
|
113
|
+
// this.logger.info(`RedisPubSub: pSubscribe: Received subscriber event: ${event.eventName}. eventkey: ${eventKey}`)
|
|
114
114
|
// Get the value before it expires (if possible) or use the key
|
|
115
115
|
const pref = `${this.prefix}-`;
|
|
116
116
|
if (eventKey.startsWith(pref))
|
|
@@ -151,7 +151,7 @@ class WithdrawalManager extends TransactionsErrors_1.default {
|
|
|
151
151
|
else if (blockchain === "evm") {
|
|
152
152
|
// Build evm batch withdraw payload
|
|
153
153
|
const payloads = queue.map(j => ({
|
|
154
|
-
amount_in_tokens:
|
|
154
|
+
amount_in_tokens: j.amount,
|
|
155
155
|
requestId: j.request_id,
|
|
156
156
|
token: j.token,
|
|
157
157
|
receiver: j.receiver
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Pool } from "pg";
|
|
2
|
-
import { GetAdminOperationThreshold, UpsertAdminOperationThreshold, GetGlobalTimelock, UpsertGlobalTimelock, GetGranularTimelock, UpsertGranularTimelock, GetTokenExecutionThreshold, UpsertTokenExecutionThreshold, FnWithdrawalScheduledPayload, FnWithdrawalScheduledResult, FnWithdrawalExecutedResult, FnWithdrawalExecutedPayload, FnWithdrawalCancelledPayload, FnWithdrawalCancelledResult, FnGetWithdrawalCommitmentsResult, FnGetWithdrawalCommitmentsPayload
|
|
2
|
+
import { GetAdminOperationThreshold, UpsertAdminOperationThreshold, GetGlobalTimelock, UpsertGlobalTimelock, GetGranularTimelock, UpsertGranularTimelock, GetTokenExecutionThreshold, UpsertTokenExecutionThreshold, FnWithdrawalScheduledPayload, FnWithdrawalScheduledResult, FnWithdrawalExecutedResult, FnWithdrawalExecutedPayload, FnWithdrawalCancelledPayload, FnWithdrawalCancelledResult, FnGetWithdrawalCommitmentsResult, FnGetWithdrawalCommitmentsPayload } from "../../types";
|
|
3
3
|
import { OperationType } from "../../../contracts/types/escrow";
|
|
4
4
|
/**
|
|
5
5
|
* Adapter class for interfacing the DB functions
|
|
@@ -26,24 +26,6 @@ declare class MultisigService {
|
|
|
26
26
|
static fn_withdrawal_scheduled(pool: Pool, data: FnWithdrawalScheduledPayload): Promise<FnWithdrawalScheduledResult>;
|
|
27
27
|
static fn_withdrawal_executed(pool: Pool, data: FnWithdrawalExecutedPayload): Promise<FnWithdrawalExecutedResult>;
|
|
28
28
|
static fn_withdrawal_cancelled(pool: Pool, data: FnWithdrawalCancelledPayload): Promise<FnWithdrawalCancelledResult>;
|
|
29
|
-
/** Creates a config-change request; returns it with resolved status + required signature counts. */
|
|
30
|
-
static fn_create_config_change_request(pool: Pool, blockchain: string, chainId: string, escrow_address: string, operation_type: number, config_target: ConfigChangeTarget, config_nonce: number, payload: Record<string, unknown>, target_key?: string | null): Promise<CreateConfigChangeResult>;
|
|
31
|
-
/** Upserts a collected approver signature onto a pre-seeded placeholder; auto-promotes to approved when the quota is met. */
|
|
32
|
-
static fn_upsert_config_change_signature(pool: Pool, blockchain: string, chainId: string, contract_address: string, operation_type: number, reference_id: number, signer_address: string, v?: number | null, r?: string | null, s?: string | null, signature?: string | null, commitment_hash?: string | null, type_data_hash?: string | null): Promise<UpsertConfigChangeSignatureResult>;
|
|
33
|
-
/** Lists config-change requests (all filters optional), each with its embedded signatures array. */
|
|
34
|
-
static fn_get_config_change_requests(pool: Pool, blockchain?: string | null, chainId?: string | null, status?: ConfigChangeStatus | null, config_target?: ConfigChangeTarget | null): Promise<ConfigChangeRequestRow[]>;
|
|
35
|
-
/** Cancels a pending/approved request. */
|
|
36
|
-
static fn_cancel_config_change_request(pool: Pool, request_id: number): Promise<CancelConfigChangeResult>;
|
|
37
|
-
/** Records the broadcast tx hash on an approved request (status stays approved until the event applies it). */
|
|
38
|
-
static fn_set_config_change_tx_hash(pool: Pool, request_id: number, tx_hash: string): Promise<SetConfigChangeTxHashResult>;
|
|
39
|
-
/**
|
|
40
|
-
* Worker-side: flips an approved config-change request to applied when the confirming on-chain
|
|
41
|
-
* event lands. Matches primarily by the tx hash the client stored via /submit; falls back to the
|
|
42
|
-
* single approved request for the {blockchain, chainId, escrowAddress, operationType} group
|
|
43
|
-
* (backfilling tx_hash) when /submit was never called. `operationType` is the governing group
|
|
44
|
-
* op type (MANAGE_MULTISIG=4 / CONFIG_TIMELOCK=5), not the configured operation's op type.
|
|
45
|
-
*/
|
|
46
|
-
static fn_config_change_applied(pool: Pool, blockchain: string, chainId: string, escrowAddress: string, operationType: number, tx_hash: string): Promise<ConfigChangeAppliedResult>;
|
|
47
29
|
}
|
|
48
30
|
export default MultisigService;
|
|
49
31
|
//# sourceMappingURL=MultisigService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultisigService.d.ts","sourceRoot":"","sources":["../../../../src/services/db/multisig/MultisigService.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAE1B,OAAO,EACH,0BAA0B,EAC1B,6BAA6B,EAC7B,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,0BAA0B,EAC1B,6BAA6B,EAC7B,4BAA4B,EAC5B,2BAA2B,EAC3B,0BAA0B,EAC1B,2BAA2B,EAC3B,4BAA4B,EAC5B,2BAA2B,EAC3B,gCAAgC,EAChC,iCAAiC,
|
|
1
|
+
{"version":3,"file":"MultisigService.d.ts","sourceRoot":"","sources":["../../../../src/services/db/multisig/MultisigService.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAE1B,OAAO,EACH,0BAA0B,EAC1B,6BAA6B,EAC7B,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,0BAA0B,EAC1B,6BAA6B,EAC7B,4BAA4B,EAC5B,2BAA2B,EAC3B,0BAA0B,EAC1B,2BAA2B,EAC3B,4BAA4B,EAC5B,2BAA2B,EAC3B,gCAAgC,EAChC,iCAAiC,EACpC,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAGhE;;;GAGG;AACH,cAAM,eAAe;IAMjB,6EAA6E;WAChE,iCAAiC,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,0BAA0B,EAAE,CAAC;IAS9J,0FAA0F;WAC7E,mCAAmC,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,cA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E,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,6BAA6B,CAAC;WAezT,6BAA6B,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,iCAAiC,GAAG,OAAO,CAAC,gCAAgC,EAAE,CAAC;WAW/H,uBAAuB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,4BAA4B,GAAG,OAAO,CAAC,2BAA2B,CAAC;WAS7G,sBAAsB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,2BAA2B,GAAG,OAAO,CAAC,0BAA0B,CAAC;WAW1G,uBAAuB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,4BAA4B,GAAG,OAAO,CAAC,2BAA2B,CAAC;CAW7H;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -130,68 +130,5 @@ class MultisigService {
|
|
|
130
130
|
return result.rows[0].fn_withdrawal_cancelled;
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
|
-
///////////////////////////////////////////
|
|
134
|
-
/// Admin config-change requests (PLAN3/PLAN4)
|
|
135
|
-
///////////////////////////////////////////
|
|
136
|
-
/** Creates a config-change request; returns it with resolved status + required signature counts. */
|
|
137
|
-
static fn_create_config_change_request(pool_1, blockchain_1, chainId_1, escrow_address_1, operation_type_1, config_target_1, config_nonce_1, payload_1) {
|
|
138
|
-
return __awaiter(this, arguments, void 0, function* (pool, blockchain, chainId, escrow_address, operation_type, config_target, config_nonce, payload, target_key = null) {
|
|
139
|
-
const result = yield pool.query(`SELECT multisig.fn_create_config_change_request($1::varchar,$2::varchar,$3::varchar,$4::integer,$5::varchar,$6::bigint,$7::jsonb,$8::varchar)`, [blockchain, chainId, escrow_address, operation_type, config_target, config_nonce, JSON.stringify(payload), target_key]);
|
|
140
|
-
if (!result)
|
|
141
|
-
throw new Error(`DB FN error: multisig.fn_create_config_change_request()`);
|
|
142
|
-
return result.rows[0].fn_create_config_change_request;
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
/** Upserts a collected approver signature onto a pre-seeded placeholder; auto-promotes to approved when the quota is met. */
|
|
146
|
-
static fn_upsert_config_change_signature(pool_1, blockchain_1, chainId_1, contract_address_1, operation_type_1, reference_id_1, signer_address_1) {
|
|
147
|
-
return __awaiter(this, arguments, void 0, function* (pool, blockchain, chainId, contract_address, operation_type, reference_id, signer_address, v = null, r = null, s = null, signature = null, commitment_hash = null, type_data_hash = null) {
|
|
148
|
-
const result = yield pool.query(`SELECT multisig.fn_upsert_config_change_signature($1::varchar,$2::varchar,$3::varchar,$4::integer,$5::bigint,$6::varchar,$7::integer,$8::varchar,$9::varchar,$10::varchar,$11::varchar,$12::varchar)`, [blockchain, chainId, contract_address, operation_type, reference_id, signer_address, v, r, s, signature, commitment_hash, type_data_hash]);
|
|
149
|
-
if (!result)
|
|
150
|
-
throw new Error(`DB FN error: multisig.fn_upsert_config_change_signature()`);
|
|
151
|
-
return result.rows[0].fn_upsert_config_change_signature;
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
/** Lists config-change requests (all filters optional), each with its embedded signatures array. */
|
|
155
|
-
static fn_get_config_change_requests(pool_1) {
|
|
156
|
-
return __awaiter(this, arguments, void 0, function* (pool, blockchain = null, chainId = null, status = null, config_target = null) {
|
|
157
|
-
const result = yield pool.query(`SELECT multisig.fn_get_config_change_requests($1::varchar,$2::varchar,$3::varchar,$4::varchar)`, [blockchain, chainId, status, config_target]);
|
|
158
|
-
if (!result)
|
|
159
|
-
throw new Error(`DB FN error: multisig.fn_get_config_change_requests()`);
|
|
160
|
-
return result.rows[0].fn_get_config_change_requests;
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
/** Cancels a pending/approved request. */
|
|
164
|
-
static fn_cancel_config_change_request(pool, request_id) {
|
|
165
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
166
|
-
const result = yield pool.query(`SELECT multisig.fn_cancel_config_change_request($1::bigint)`, [request_id]);
|
|
167
|
-
if (!result)
|
|
168
|
-
throw new Error(`DB FN error: multisig.fn_cancel_config_change_request()`);
|
|
169
|
-
return result.rows[0].fn_cancel_config_change_request;
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
/** Records the broadcast tx hash on an approved request (status stays approved until the event applies it). */
|
|
173
|
-
static fn_set_config_change_tx_hash(pool, request_id, tx_hash) {
|
|
174
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
175
|
-
const result = yield pool.query(`SELECT multisig.fn_set_config_change_tx_hash($1::bigint,$2::varchar)`, [request_id, tx_hash]);
|
|
176
|
-
if (!result)
|
|
177
|
-
throw new Error(`DB FN error: multisig.fn_set_config_change_tx_hash()`);
|
|
178
|
-
return result.rows[0].fn_set_config_change_tx_hash;
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Worker-side: flips an approved config-change request to applied when the confirming on-chain
|
|
183
|
-
* event lands. Matches primarily by the tx hash the client stored via /submit; falls back to the
|
|
184
|
-
* single approved request for the {blockchain, chainId, escrowAddress, operationType} group
|
|
185
|
-
* (backfilling tx_hash) when /submit was never called. `operationType` is the governing group
|
|
186
|
-
* op type (MANAGE_MULTISIG=4 / CONFIG_TIMELOCK=5), not the configured operation's op type.
|
|
187
|
-
*/
|
|
188
|
-
static fn_config_change_applied(pool, blockchain, chainId, escrowAddress, operationType, tx_hash) {
|
|
189
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
190
|
-
const result = yield pool.query(`SELECT multisig.fn_config_change_applied($1::varchar,$2::varchar,$3::varchar,$4::integer,$5::varchar)`, [blockchain, chainId, escrowAddress, operationType, tx_hash]);
|
|
191
|
-
if (!result)
|
|
192
|
-
throw new Error(`DB FN error: multisig.fn_config_change_applied()`);
|
|
193
|
-
return result.rows[0].fn_config_change_applied;
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
133
|
}
|
|
197
134
|
exports.default = MultisigService;
|
|
@@ -2,12 +2,15 @@ import { ScheduleJobStatus, ScheduleTransactionJob } from "../../../entities/Sch
|
|
|
2
2
|
import { ClaimJobLockMetadata } from "../../types";
|
|
3
3
|
import { Pool } from "pg";
|
|
4
4
|
import { OperationType } from "../../../contracts/types/escrow";
|
|
5
|
-
import { MarkCompleteScheduleJob, ScheduleTransactionJobWithDetails } from "../../types/db";
|
|
5
|
+
import { MarkCompleteScheduleJob, ScheduleTransactionJobWithDetails, ScheduleJobFilters, ScheduleJobListItem, ScheduleJobHistoryFilters, ScheduleJobHistoryItem } from "../../types/db";
|
|
6
|
+
import { Paginated } from "../../types/claim_job_service";
|
|
6
7
|
import { RequeueJobConfiguration } from "../../types/watchdog";
|
|
7
8
|
declare class ScheduleTransactionService {
|
|
8
9
|
static get_and_lock_available_jobs: (pool: Pool, limit?: number, job_ttl_s?: number, lock_metadata?: ClaimJobLockMetadata) => Promise<ScheduleTransactionJob[]>;
|
|
9
|
-
/** Locks and returns available jobs with full withdrawal details via DB function. */
|
|
10
|
+
/** Locks and returns available jobs with full withdrawal details via inline SQL (bypasses DB function). */
|
|
10
11
|
static get_and_lock_available_jobs_with_details: (pool: Pool, limit?: number, job_ttl_s?: number, lock_metadata?: ClaimJobLockMetadata) => Promise<ScheduleTransactionJobWithDetails[]>;
|
|
12
|
+
/** Locks and returns available jobs with full withdrawal details via DB function. */
|
|
13
|
+
static get_and_lock_available_jobs_with_details_depr: (pool: Pool, limit?: number, job_ttl_s?: number, lock_metadata?: ClaimJobLockMetadata) => Promise<ScheduleTransactionJobWithDetails[]>;
|
|
11
14
|
/**
|
|
12
15
|
* Requeues all jobs in the given status to "queued"
|
|
13
16
|
*/
|
|
@@ -27,6 +30,17 @@ declare class ScheduleTransactionService {
|
|
|
27
30
|
sent_at: Date;
|
|
28
31
|
}[]) => Promise<void>;
|
|
29
32
|
static mark_complete: (pool: Pool, payloads: MarkCompleteScheduleJob[]) => Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Paginated list of current schedule-transaction jobs, newest first, with the
|
|
35
|
+
* status resolved to text and (for withdrawal operation types) the receiver/token/
|
|
36
|
+
* amount joined in. All filters are optional and combine with AND.
|
|
37
|
+
*/
|
|
38
|
+
static list_jobs_paginated: (pool: Pool, page: number, page_size?: number, filters?: ScheduleJobFilters) => Promise<Paginated<ScheduleJobListItem[]>>;
|
|
39
|
+
/**
|
|
40
|
+
* Paginated schedule-transaction job history (append-only status transitions),
|
|
41
|
+
* newest first. All filters are optional and combine with AND.
|
|
42
|
+
*/
|
|
43
|
+
static list_history_paginated: (pool: Pool, page: number, page_size?: number, filters?: ScheduleJobHistoryFilters) => Promise<Paginated<ScheduleJobHistoryItem[]>>;
|
|
30
44
|
}
|
|
31
45
|
export default ScheduleTransactionService;
|
|
32
46
|
//# sourceMappingURL=ScheduleTransactionService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScheduleTransactionService.d.ts","sourceRoot":"","sources":["../../../../src/services/db/timelock/ScheduleTransactionService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AACrG,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,
|
|
1
|
+
{"version":3,"file":"ScheduleTransactionService.d.ts","sourceRoot":"","sources":["../../../../src/services/db/timelock/ScheduleTransactionService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AACrG,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OA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MAAM,IAAI,EACV,gBAAgB,aAAa,EAC7B,MAAM;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,iBAAiB,CAAC;QAAC,aAAa,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,OAAO,CAAA;KAAE,EAAE,KACzG,OAAO,CAAC,IAAI,CAAC,CA8Bf;IAGD,MAAM,CAAC,0BAA0B,GAC7B,MAAM,IAAI,EACV,MAAM;QAAE,cAAc,EAAE,aAAa,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,IAAI,CAAA;KAAE,EAAE,KAC9F,OAAO,CAAC,IAAI,CAAC,CAwBd;IAGF,MAAM,CAAC,aAAa,GAAU,MAAM,IAAI,EAAE,UAAU,uBAAuB,EAAE,KAAG,OAAO,CAAC,IAAI,CAAC,CAmB5F;IAKD;;;;OAIG;IACH,MAAM,CAAC,mBAAmB,GACtB,MAAM,IAAI,EACV,MAAM,MAAM,EACZ,YAAW,MAAW,EACtB,UAAS,kBAAuB,KACjC,OAAO,CAAC,SAAS,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAgE1C;IAGF;;;OAGG;IACH,MAAM,CAAC,sBAAsB,GACzB,MAAM,IAAI,EACV,MAAM,MAAM,EACZ,YAAW,MAAW,EACtB,UAAS,yBAA8B,KACxC,OAAO,CAAC,SAAS,CAAC,sBAAsB,EAAE,CAAC,CAAC,CAqD7C;CAEL;AAED,eAAe,0BAA0B,CAAC"}
|
|
@@ -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;
|