@ercworldio/blockchain-shared 1.0.3-dev.3-PROJ-1296.24 → 1.0.3-dev.3-PROJ-1296.25
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/errors/errors.d.ts +9 -0
- package/build/errors/errors.d.ts.map +1 -1
- package/build/errors/errors.js +17 -0
- package/build/services/db/timelock/ScheduleTransactionService.d.ts +5 -5
- package/build/services/db/timelock/ScheduleTransactionService.d.ts.map +1 -1
- package/build/services/db/timelock/ScheduleTransactionService.js +117 -119
- package/build/services/types/claim.d.ts +1 -1
- package/build/services/types/claim.d.ts.map +1 -1
- package/package.json +1 -1
package/build/errors/errors.d.ts
CHANGED
|
@@ -71,6 +71,9 @@ export declare const ErrorMessages: {
|
|
|
71
71
|
readonly FAILED_CANCEL_WITHDRAWAL: "Failed to cancel scheduled withdrawal";
|
|
72
72
|
readonly WITHDRAWAL_INSUFFICIENT_SIGNATURES: "Insufficient signatures for withdrawal scheduling";
|
|
73
73
|
readonly WITHDRAWAL_INVALID_SIGNATURES: "One or more signatures are invalid for withdrawal scheduling";
|
|
74
|
+
readonly UNDEFINED_DESTINATION_DETAILS: "Lightning withdrawal has no destination payment details";
|
|
75
|
+
readonly UNDEFINED_WITHDRAWAL_TOKEN: "Token address does not exist in withdraw request";
|
|
76
|
+
readonly MISSING_WITHDRAWAL_DETAILS: "Withdraw request details is missing";
|
|
74
77
|
};
|
|
75
78
|
export declare const ErrorCodes: {
|
|
76
79
|
readonly INTERNAL_SERVER: "error.internal_server_error";
|
|
@@ -138,6 +141,9 @@ export declare const ErrorCodes: {
|
|
|
138
141
|
readonly FAILED_CANCEL_WITHDRAWAL: "error.failed_cancel_withdrawal";
|
|
139
142
|
readonly WITHDRAWAL_INSUFFICIENT_SIGNATURES: "error.withdrawal_insufficient_signatures";
|
|
140
143
|
readonly WITHDRAWAL_INVALID_SIGNATURES: "error.withdrawal_invalid_signatures";
|
|
144
|
+
readonly UNDEFINED_DESTINATION_DETAILS: "error.undefined_destination_details";
|
|
145
|
+
readonly UNDEFINED_WITHDRAWAL_TOKEN: "error.undefined_withdrawawal_token";
|
|
146
|
+
readonly MISSING_WITHDRAWAL_DETAILS: "error.invalid_withdraw_request";
|
|
141
147
|
};
|
|
142
148
|
export type ErrorCode = typeof ErrorCodes[keyof typeof ErrorCodes];
|
|
143
149
|
export interface ErrorCodeEntry {
|
|
@@ -229,6 +235,9 @@ declare class BaseErrors {
|
|
|
229
235
|
FailedCancelWithdrawal(): "Failed to cancel scheduled withdrawal";
|
|
230
236
|
WithdrawalInvalidSignatures(): "One or more signatures are invalid for withdrawal scheduling";
|
|
231
237
|
WithdrawalInsufficientSignatures(): "Insufficient signatures for withdrawal scheduling";
|
|
238
|
+
MissingWithdrawDetails(): "Withdraw request details is missing";
|
|
239
|
+
UndefinedWithdrawalToken(): "Token address does not exist in withdraw request";
|
|
240
|
+
UndefinedDestinationDetails(): "Lightning withdrawal has no destination payment details";
|
|
232
241
|
/** Handler methods */
|
|
233
242
|
handle_error: (error: any, source_method: string) => ErrorHandlerResponse;
|
|
234
243
|
get_error_code_base: (message: string) => ErrorCodeEntry | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors/errors.ts"],"names":[],"mappings":"AACA;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAqFtB,2BAA2B;;;;IAK3B,sBAAsB
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors/errors.ts"],"names":[],"mappings":"AACA;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAqFtB,2BAA2B;;;;IAK3B,sBAAsB;;;;;;;;;;;;;;;;;;;CA0BhB,CAAC;AAEX,eAAO,MAAM,UAAU;;;;;;;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B,iBAAiB,CAAC,CAAC,CAAC,EAAE,GAAG;IACzB,gBAAgB;IAChB,sBAAsB;IACtB,eAAe,CAAC,CAAC,CAAC,EAAE,GAAG;IACvB,sBAAsB,CAAC,CAAC,CAAC,EAAE,GAAG;IAC9B,aAAa,CAAC,CAAC,CAAC,EAAE,GAAG;IACrB,eAAe,CAAC,CAAC,CAAC,EAAE,GAAG;IACvB,oBAAoB,CAAC,CAAC,CAAC,EAAE,GAAG;IAC5B,mBAAmB,CAAC,CAAC,CAAC,EAAE,GAAG;IAC3B,cAAc,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM;IAC/B,yBAAyB,CAAC,CAAC,CAAC,EAAE,GAAG;IACjC,gBAAgB,CAAC,CAAC,CAAC,EAAE,GAAG;IACxB,aAAa,CAAC,CAAC,CAAC,EAAE,GAAG;IACrB,yBAAyB;IACzB,WAAW;IACX,cAAc;IACd,iBAAiB;IACjB,oBAAoB;IACpB,kBAAkB;IAClB,mCAAmC;IACnC,4BAA4B;IAC5B,wBAAwB;IACxB,oBAAoB;IACpB,wBAAwB;IACxB,uBAAuB;IACvB,sBAAsB;IACtB,2BAA2B;IAC3B,gCAAgC;IAChC,sBAAsB;IACtB,wBAAwB;IACxB,2BAA2B;IAElC,sBAAsB;IACf,YAAY,GAAI,OAAO,GAAG,EAAE,eAAe,MAAM,KAAG,oBAAoB,CAuB9E;IAEM,mBAAmB,GAAI,SAAS,MAAM,KAAG,cAAc,GAAG,IAAI,CA6CpE;CACJ;AAED,eAAe,UAAU,CAAC"}
|
package/build/errors/errors.js
CHANGED
|
@@ -110,6 +110,9 @@ exports.ErrorMessages = {
|
|
|
110
110
|
FAILED_CANCEL_WITHDRAWAL: `Failed to cancel scheduled withdrawal`,
|
|
111
111
|
WITHDRAWAL_INSUFFICIENT_SIGNATURES: `Insufficient signatures for withdrawal scheduling`,
|
|
112
112
|
WITHDRAWAL_INVALID_SIGNATURES: `One or more signatures are invalid for withdrawal scheduling`,
|
|
113
|
+
UNDEFINED_DESTINATION_DETAILS: `Lightning withdrawal has no destination payment details`,
|
|
114
|
+
UNDEFINED_WITHDRAWAL_TOKEN: `Token address does not exist in withdraw request`,
|
|
115
|
+
MISSING_WITHDRAWAL_DETAILS: `Withdraw request details is missing`,
|
|
113
116
|
};
|
|
114
117
|
exports.ErrorCodes = {
|
|
115
118
|
INTERNAL_SERVER: 'error.internal_server_error',
|
|
@@ -184,6 +187,9 @@ exports.ErrorCodes = {
|
|
|
184
187
|
FAILED_CANCEL_WITHDRAWAL: `error.failed_cancel_withdrawal`,
|
|
185
188
|
WITHDRAWAL_INSUFFICIENT_SIGNATURES: `error.withdrawal_insufficient_signatures`,
|
|
186
189
|
WITHDRAWAL_INVALID_SIGNATURES: `error.withdrawal_invalid_signatures`,
|
|
190
|
+
UNDEFINED_DESTINATION_DETAILS: `error.undefined_destination_details`,
|
|
191
|
+
UNDEFINED_WITHDRAWAL_TOKEN: `error.undefined_withdrawawal_token`,
|
|
192
|
+
MISSING_WITHDRAWAL_DETAILS: `error.invalid_withdraw_request`,
|
|
187
193
|
};
|
|
188
194
|
class BaseErrors {
|
|
189
195
|
constructor() {
|
|
@@ -301,6 +307,12 @@ class BaseErrors {
|
|
|
301
307
|
return Object.assign(Object.assign({}, this.codes[500]), { error_code: exports.ErrorCodes.WITHDRAWAL_INSUFFICIENT_SIGNATURES });
|
|
302
308
|
if (message.includes(exports.ErrorMessages.WITHDRAWAL_INVALID_SIGNATURES))
|
|
303
309
|
return Object.assign(Object.assign({}, this.codes[500]), { error_code: exports.ErrorCodes.WITHDRAWAL_INVALID_SIGNATURES });
|
|
310
|
+
if (message.includes(exports.ErrorMessages.UNDEFINED_DESTINATION_DETAILS))
|
|
311
|
+
return Object.assign(Object.assign({}, this.codes[500]), { error_code: exports.ErrorCodes.UNDEFINED_DESTINATION_DETAILS });
|
|
312
|
+
if (message.includes(exports.ErrorMessages.UNDEFINED_WITHDRAWAL_TOKEN))
|
|
313
|
+
return Object.assign(Object.assign({}, this.codes[500]), { error_code: exports.ErrorCodes.UNDEFINED_WITHDRAWAL_TOKEN });
|
|
314
|
+
if (message.includes(exports.ErrorMessages.MISSING_WITHDRAWAL_DETAILS))
|
|
315
|
+
return Object.assign(Object.assign({}, this.codes[500]), { error_code: exports.ErrorCodes.MISSING_WITHDRAWAL_DETAILS });
|
|
304
316
|
return null;
|
|
305
317
|
};
|
|
306
318
|
}
|
|
@@ -383,5 +395,10 @@ class BaseErrors {
|
|
|
383
395
|
;
|
|
384
396
|
WithdrawalInsufficientSignatures() { return exports.ErrorMessages.WITHDRAWAL_INSUFFICIENT_SIGNATURES; }
|
|
385
397
|
;
|
|
398
|
+
MissingWithdrawDetails() { return exports.ErrorMessages.MISSING_WITHDRAWAL_DETAILS; }
|
|
399
|
+
;
|
|
400
|
+
UndefinedWithdrawalToken() { return exports.ErrorMessages.UNDEFINED_WITHDRAWAL_TOKEN; }
|
|
401
|
+
;
|
|
402
|
+
UndefinedDestinationDetails() { return exports.ErrorMessages.UNDEFINED_DESTINATION_DETAILS; }
|
|
386
403
|
}
|
|
387
404
|
exports.default = BaseErrors;
|
|
@@ -17,16 +17,16 @@ declare class ScheduleTransactionService {
|
|
|
17
17
|
* @param max_retries
|
|
18
18
|
* @returns
|
|
19
19
|
*/
|
|
20
|
-
requeue_expired_jobs: (pool: Pool, current_status: ScheduleJobStatus, limit: number, lock_owner: string, lock_reason: string, max_retries: number) => Promise<ScheduleTransactionJob[]>;
|
|
21
|
-
batch_update_status: (pool: Pool, operation_type: OperationType, request_ids: number[], new_status: ScheduleJobStatus) => Promise<void>;
|
|
22
|
-
batch_update_failed_jobs: (pool: Pool, request_ids: number[], new_status: ScheduleJobStatus, error_message?: string, retryable?: boolean) => Promise<void>;
|
|
23
|
-
batch_update_executed_jobs: (pool: Pool, data: {
|
|
20
|
+
static requeue_expired_jobs: (pool: Pool, current_status: ScheduleJobStatus, limit: number, lock_owner: string, lock_reason: string, max_retries: number) => Promise<ScheduleTransactionJob[]>;
|
|
21
|
+
static batch_update_status: (pool: Pool, operation_type: OperationType, request_ids: number[], new_status: ScheduleJobStatus) => Promise<void>;
|
|
22
|
+
static batch_update_failed_jobs: (pool: Pool, request_ids: number[], new_status: ScheduleJobStatus, error_message?: string, retryable?: boolean) => Promise<void>;
|
|
23
|
+
static batch_update_executed_jobs: (pool: Pool, data: {
|
|
24
24
|
operation_type: OperationType;
|
|
25
25
|
request_id: number;
|
|
26
26
|
tx_hash: string;
|
|
27
27
|
sent_at: Date;
|
|
28
28
|
}[]) => Promise<void>;
|
|
29
|
-
mark_complete: (pool: Pool, payloads: MarkCompleteScheduleJob[]) => Promise<void>;
|
|
29
|
+
static mark_complete: (pool: Pool, payloads: MarkCompleteScheduleJob[]) => Promise<void>;
|
|
30
30
|
}
|
|
31
31
|
export default ScheduleTransactionService;
|
|
32
32
|
//# 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,EAAE,uBAAuB,EAAE,iCAAiC,EAAE,MAAM,gBAAgB,CAAC;AAE5F,cAAM,0BAA0B;IAE5B,MAAM,CAAC,kBAAkB,GAAU,MAAM,IAAI,EAAE,QAAO,MAAW,EAAE,YAAW,MAAY,EAAE,gBAAe,oBAA0F,KAAG,OAAO,CAAC,sBAAsB,EAAE,CAAC,CAwCxO;IAGD,4FAA4F;IAC5F,MAAM,CAAC,+BAA+B,GAAU,MAAM,IAAI,EAAE,QAAO,MAAW,EAAE,YAAW,MAAY,EAAE,gBAAe,oBAA0F,KAAG,OAAO,CAAC,iCAAiC,EAAE,CAAC,CA4ChQ;IAGD;;;;;;;;;OASG;
|
|
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,EAAE,uBAAuB,EAAE,iCAAiC,EAAE,MAAM,gBAAgB,CAAC;AAE5F,cAAM,0BAA0B;IAE5B,MAAM,CAAC,kBAAkB,GAAU,MAAM,IAAI,EAAE,QAAO,MAAW,EAAE,YAAW,MAAY,EAAE,gBAAe,oBAA0F,KAAG,OAAO,CAAC,sBAAsB,EAAE,CAAC,CAwCxO;IAGD,4FAA4F;IAC5F,MAAM,CAAC,+BAA+B,GAAU,MAAM,IAAI,EAAE,QAAO,MAAW,EAAE,YAAW,MAAY,EAAE,gBAAe,oBAA0F,KAAG,OAAO,CAAC,iCAAiC,EAAE,CAAC,CA4ChQ;IAGD;;;;;;;;;OASG;IACH,MAAM,CAAC,oBAAoB,GACvB,MAAM,IAAI,EACV,gBAAgB,iBAAiB,EACjC,OAAO,MAAM,EACb,YAAY,MAAM,EAClB,aAAa,MAAM,EACnB,aAAa,MAAM,KACpB,OAAO,CAAC,sBAAsB,EAAE,CAAC,CAwClC;IAIF,MAAM,CAAC,mBAAmB,GAAU,MAAM,IAAI,EAAE,gBAAgB,aAAa,EAAE,aAAa,MAAM,EAAE,EAAE,YAAY,iBAAiB,KAAG,OAAO,CAAC,IAAI,CAAC,CAUjJ;IAGF,MAAM,CAAC,wBAAwB,GAC3B,MAAM,IAAI,EACV,aAAa,MAAM,EAAE,EACrB,YAAY,iBAAiB,EAC7B,gBAAgB,MAAM,EACtB,YAAY,OAAO,KACpB,OAAO,CAAC,IAAI,CAAC,CAwBd;IAGF,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,CAyBd;IAGF,MAAM,CAAC,aAAa,GAAU,MAAM,IAAI,EAAE,UAAU,uBAAuB,EAAE,mBAuB5E;CAGJ;AAED,eAAe,0BAA0B,CAAC"}
|
|
@@ -12,19 +12,95 @@ var _a;
|
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
const uuid_1 = require("uuid");
|
|
14
14
|
class ScheduleTransactionService {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
15
|
+
}
|
|
16
|
+
_a = ScheduleTransactionService;
|
|
17
|
+
ScheduleTransactionService.get_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" }) {
|
|
18
|
+
const ttlSeconds = job_ttl_s;
|
|
19
|
+
const batchGroupId = (0, uuid_1.v4)();
|
|
20
|
+
const res = yield pool.query(`
|
|
21
|
+
WITH candidates AS (
|
|
22
|
+
SELECT id
|
|
23
|
+
FROM multisig.schedule_transaction_jobs
|
|
24
|
+
WHERE status = 'queued'
|
|
25
|
+
AND (lock_expires_at IS NULL OR lock_expires_at < now())
|
|
26
|
+
ORDER BY blockchain, chain_id ASC
|
|
27
|
+
LIMIT $1
|
|
28
|
+
FOR UPDATE SKIP LOCKED
|
|
29
|
+
)
|
|
30
|
+
UPDATE multisig.schedule_transaction_jobs cj
|
|
31
|
+
SET
|
|
32
|
+
status = 'processing',
|
|
33
|
+
locked_at = now(),
|
|
34
|
+
lock_expires_at = now() + ($2 || ' seconds')::interval,
|
|
35
|
+
batch_group_id = $3,
|
|
36
|
+
metadata = jsonb_set(
|
|
37
|
+
jsonb_set(
|
|
38
|
+
coalesce(cj.metadata, '{}'::jsonb),
|
|
39
|
+
'{lock_owner}',
|
|
40
|
+
to_jsonb($4::text)
|
|
41
|
+
),
|
|
42
|
+
'{lock_reason}',
|
|
43
|
+
to_jsonb($5::text)
|
|
44
|
+
),
|
|
45
|
+
updated_at = now()
|
|
46
|
+
FROM candidates c
|
|
47
|
+
WHERE cj.id = c.id
|
|
48
|
+
RETURNING cj.*;
|
|
49
|
+
`, [limit, ttlSeconds, batchGroupId, lock_metadata.lock_owner, lock_metadata.lock_reason]);
|
|
50
|
+
return res.rows;
|
|
51
|
+
});
|
|
52
|
+
/** Same as get_available_jobs but joins withdrawal details from accounting for each job. */
|
|
53
|
+
ScheduleTransactionService.get_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" }) {
|
|
54
|
+
const ttlSeconds = job_ttl_s;
|
|
55
|
+
const batchGroupId = (0, uuid_1.v4)();
|
|
56
|
+
const res = yield pool.query(`
|
|
57
|
+
WITH candidates AS (
|
|
58
|
+
SELECT id
|
|
59
|
+
FROM multisig.schedule_transaction_jobs
|
|
60
|
+
WHERE status = 'queued'
|
|
61
|
+
AND (lock_expires_at IS NULL OR lock_expires_at < now())
|
|
62
|
+
ORDER BY blockchain, chain_id ASC
|
|
63
|
+
LIMIT $1
|
|
64
|
+
FOR UPDATE SKIP LOCKED
|
|
65
|
+
),
|
|
66
|
+
updated AS (
|
|
67
|
+
UPDATE multisig.schedule_transaction_jobs cj
|
|
68
|
+
SET
|
|
69
|
+
status = 'processing',
|
|
70
|
+
locked_at = now(),
|
|
71
|
+
lock_expires_at = now() + ($2 || ' seconds')::interval,
|
|
72
|
+
batch_group_id = $3,
|
|
73
|
+
metadata = jsonb_set(
|
|
74
|
+
jsonb_set(
|
|
75
|
+
coalesce(cj.metadata, '{}'::jsonb),
|
|
76
|
+
'{lock_owner}',
|
|
77
|
+
to_jsonb($4::text)
|
|
78
|
+
),
|
|
79
|
+
'{lock_reason}',
|
|
80
|
+
to_jsonb($5::text)
|
|
81
|
+
),
|
|
82
|
+
updated_at = now()
|
|
83
|
+
FROM candidates c
|
|
84
|
+
WHERE cj.id = c.id
|
|
85
|
+
RETURNING cj.*
|
|
86
|
+
)
|
|
87
|
+
SELECT u.*, accounting.fn_get_crypto_withdrawal_details(u.request_id) AS withdrawal_details
|
|
88
|
+
FROM updated u;
|
|
89
|
+
`, [limit, ttlSeconds, batchGroupId, lock_metadata.lock_owner, lock_metadata.lock_reason]);
|
|
90
|
+
return res.rows;
|
|
91
|
+
});
|
|
92
|
+
/**
|
|
93
|
+
* Requeues all jobs in the given status to "queued"
|
|
94
|
+
* @param pool
|
|
95
|
+
* @param current_status
|
|
96
|
+
* @param limit
|
|
97
|
+
* @param lock_owner
|
|
98
|
+
* @param lock_reason
|
|
99
|
+
* @param max_retries
|
|
100
|
+
* @returns
|
|
101
|
+
*/
|
|
102
|
+
ScheduleTransactionService.requeue_expired_jobs = (pool, current_status, limit, lock_owner, lock_reason, max_retries) => __awaiter(void 0, void 0, void 0, function* () {
|
|
103
|
+
const res = yield pool.query(`
|
|
28
104
|
WITH expired AS (
|
|
29
105
|
SELECT id
|
|
30
106
|
FROM multisig.schedule_transaction_jobs
|
|
@@ -59,19 +135,19 @@ class ScheduleTransactionService {
|
|
|
59
135
|
WHERE cj.id = e.id
|
|
60
136
|
RETURNING cj.*;
|
|
61
137
|
`, [limit, lock_owner, lock_reason, current_status, max_retries]);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
138
|
+
return res.rows;
|
|
139
|
+
});
|
|
140
|
+
ScheduleTransactionService.batch_update_status = (pool, operation_type, request_ids, new_status) => __awaiter(void 0, void 0, void 0, function* () {
|
|
141
|
+
const status = new_status;
|
|
142
|
+
yield pool.query(`
|
|
67
143
|
UPDATE multisig.schedule_transaction_jobs
|
|
68
144
|
SET status = $1, updated_at = CURRENT_TIMESTAMP
|
|
69
145
|
WHERE operation_type = $2::int AND request_id = ANY($2)
|
|
70
146
|
`, [status, operation_type, request_ids]);
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
147
|
+
return;
|
|
148
|
+
});
|
|
149
|
+
ScheduleTransactionService.batch_update_failed_jobs = (pool, request_ids, new_status, error_message, retryable) => __awaiter(void 0, void 0, void 0, function* () {
|
|
150
|
+
yield pool.query(`
|
|
75
151
|
UPDATE multisig.schedule_transaction_jobs
|
|
76
152
|
SET
|
|
77
153
|
status = $1,
|
|
@@ -87,18 +163,18 @@ class ScheduleTransactionService {
|
|
|
87
163
|
END
|
|
88
164
|
WHERE request_id = ANY($4)
|
|
89
165
|
`, [
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
166
|
+
new_status,
|
|
167
|
+
error_message || null,
|
|
168
|
+
retryable === true,
|
|
169
|
+
request_ids
|
|
170
|
+
]);
|
|
171
|
+
});
|
|
172
|
+
ScheduleTransactionService.batch_update_executed_jobs = (pool, data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
173
|
+
const requestIds = data.map(d => d.request_id);
|
|
174
|
+
const operationTypes = data.map(d => d.operation_type);
|
|
175
|
+
const txHashes = data.map(d => d.tx_hash);
|
|
176
|
+
const sentAts = data.map(d => d.sent_at);
|
|
177
|
+
yield pool.query(`
|
|
102
178
|
UPDATE multisig.schedule_transaction_jobs AS t
|
|
103
179
|
SET
|
|
104
180
|
tx_hash = c.tx_hash,
|
|
@@ -115,13 +191,13 @@ class ScheduleTransactionService {
|
|
|
115
191
|
WHERE t.request_id = c.request_id
|
|
116
192
|
AND t.operation_type = c.operation_type
|
|
117
193
|
`, [operationTypes, requestIds, txHashes, sentAts]);
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
194
|
+
});
|
|
195
|
+
ScheduleTransactionService.mark_complete = (pool, payloads) => __awaiter(void 0, void 0, void 0, function* () {
|
|
196
|
+
if (payloads.length === 0)
|
|
197
|
+
return;
|
|
198
|
+
const requestIds = payloads.map(d => d.requestId);
|
|
199
|
+
const operationTypes = payloads.map(d => d.operationType);
|
|
200
|
+
yield pool.query(`
|
|
125
201
|
UPDATE multisig.schedule_transaction_jobs AS t
|
|
126
202
|
SET
|
|
127
203
|
status = 'completed',
|
|
@@ -134,83 +210,5 @@ class ScheduleTransactionService {
|
|
|
134
210
|
WHERE t.request_id = c.request_id
|
|
135
211
|
AND t.operation_type = c.operation_type
|
|
136
212
|
`, [requestIds, operationTypes]);
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
_a = ScheduleTransactionService;
|
|
141
|
-
ScheduleTransactionService.get_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" }) {
|
|
142
|
-
const ttlSeconds = job_ttl_s;
|
|
143
|
-
const batchGroupId = (0, uuid_1.v4)();
|
|
144
|
-
const res = yield pool.query(`
|
|
145
|
-
WITH candidates AS (
|
|
146
|
-
SELECT id
|
|
147
|
-
FROM multisig.schedule_transaction_jobs
|
|
148
|
-
WHERE status = 'queued'
|
|
149
|
-
AND (lock_expires_at IS NULL OR lock_expires_at < now())
|
|
150
|
-
ORDER BY blockchain, chain_id ASC
|
|
151
|
-
LIMIT $1
|
|
152
|
-
FOR UPDATE SKIP LOCKED
|
|
153
|
-
)
|
|
154
|
-
UPDATE multisig.schedule_transaction_jobs cj
|
|
155
|
-
SET
|
|
156
|
-
status = 'processing',
|
|
157
|
-
locked_at = now(),
|
|
158
|
-
lock_expires_at = now() + ($2 || ' seconds')::interval,
|
|
159
|
-
batch_group_id = $3,
|
|
160
|
-
metadata = jsonb_set(
|
|
161
|
-
jsonb_set(
|
|
162
|
-
coalesce(cj.metadata, '{}'::jsonb),
|
|
163
|
-
'{lock_owner}',
|
|
164
|
-
to_jsonb($4::text)
|
|
165
|
-
),
|
|
166
|
-
'{lock_reason}',
|
|
167
|
-
to_jsonb($5::text)
|
|
168
|
-
),
|
|
169
|
-
updated_at = now()
|
|
170
|
-
FROM candidates c
|
|
171
|
-
WHERE cj.id = c.id
|
|
172
|
-
RETURNING cj.*;
|
|
173
|
-
`, [limit, ttlSeconds, batchGroupId, lock_metadata.lock_owner, lock_metadata.lock_reason]);
|
|
174
|
-
return res.rows;
|
|
175
|
-
});
|
|
176
|
-
/** Same as get_available_jobs but joins withdrawal details from accounting for each job. */
|
|
177
|
-
ScheduleTransactionService.get_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" }) {
|
|
178
|
-
const ttlSeconds = job_ttl_s;
|
|
179
|
-
const batchGroupId = (0, uuid_1.v4)();
|
|
180
|
-
const res = yield pool.query(`
|
|
181
|
-
WITH candidates AS (
|
|
182
|
-
SELECT id
|
|
183
|
-
FROM multisig.schedule_transaction_jobs
|
|
184
|
-
WHERE status = 'queued'
|
|
185
|
-
AND (lock_expires_at IS NULL OR lock_expires_at < now())
|
|
186
|
-
ORDER BY blockchain, chain_id ASC
|
|
187
|
-
LIMIT $1
|
|
188
|
-
FOR UPDATE SKIP LOCKED
|
|
189
|
-
),
|
|
190
|
-
updated AS (
|
|
191
|
-
UPDATE multisig.schedule_transaction_jobs cj
|
|
192
|
-
SET
|
|
193
|
-
status = 'processing',
|
|
194
|
-
locked_at = now(),
|
|
195
|
-
lock_expires_at = now() + ($2 || ' seconds')::interval,
|
|
196
|
-
batch_group_id = $3,
|
|
197
|
-
metadata = jsonb_set(
|
|
198
|
-
jsonb_set(
|
|
199
|
-
coalesce(cj.metadata, '{}'::jsonb),
|
|
200
|
-
'{lock_owner}',
|
|
201
|
-
to_jsonb($4::text)
|
|
202
|
-
),
|
|
203
|
-
'{lock_reason}',
|
|
204
|
-
to_jsonb($5::text)
|
|
205
|
-
),
|
|
206
|
-
updated_at = now()
|
|
207
|
-
FROM candidates c
|
|
208
|
-
WHERE cj.id = c.id
|
|
209
|
-
RETURNING cj.*
|
|
210
|
-
)
|
|
211
|
-
SELECT u.*, accounting.fn_get_crypto_withdrawal_details(u.request_id) AS withdrawal_details
|
|
212
|
-
FROM updated u;
|
|
213
|
-
`, [limit, ttlSeconds, batchGroupId, lock_metadata.lock_owner, lock_metadata.lock_reason]);
|
|
214
|
-
return res.rows;
|
|
215
213
|
});
|
|
216
214
|
exports.default = ScheduleTransactionService;
|
|
@@ -19,7 +19,7 @@ export interface WithdrawRequestDetails {
|
|
|
19
19
|
blockchain: BlockchainType;
|
|
20
20
|
receiver: string;
|
|
21
21
|
paymentType: PaymentType;
|
|
22
|
-
destinationBlockchain?: BLOCKCHAINS.EVM | BLOCKCHAINS.SOLANA;
|
|
22
|
+
destinationBlockchain?: BLOCKCHAINS.EVM | BLOCKCHAINS.SOLANA | BLOCKCHAINS.TRON;
|
|
23
23
|
destinationChainId?: number;
|
|
24
24
|
destinationToken?: string;
|
|
25
25
|
sigsExecutiveRequired?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claim.d.ts","sourceRoot":"","sources":["../../../src/services/types/claim.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,UAAU,CAAC;AAEhD,MAAM,WAAW,mBAAmB;IAChC,UAAU,EAAE,cAAc,CAAC;IAC3B,YAAY,EAAE,WAAW,CAAC;CAC7B;AACD,MAAM,MAAM,aAAa,GACnB,SAAS,GACT,YAAY,GACZ,UAAU,GACV,UAAU,GACV,UAAU,GACV,MAAM,GACN,aAAa,CAAC;AAEpB,MAAM,MAAM,SAAS,GACf,QAAQ,GACR,YAAY,GACZ,WAAW,GACX,YAAY,GACZ,aAAa,GACb,kBAAkB,GAClB,QAAQ,CAAC;AAEf,MAAM,WAAW,sBAAsB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,aAAa,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IAGd,UAAU,EAAE,cAAc,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,WAAW,CAAC;IAEzB,qBAAqB,CAAC,EAAE,WAAW,CAAC,GAAG,GAAG,WAAW,CAAC,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"claim.d.ts","sourceRoot":"","sources":["../../../src/services/types/claim.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,MAAM,WAAW,GAAG,QAAQ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