@ercworldio/blockchain-shared 1.0.3-dev.3-PROJ-1296.27 → 1.0.3-dev.3-PROJ-1296.29
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/services/db/timelock/ScheduleTransactionService.d.ts +1 -1
- package/build/services/db/timelock/ScheduleTransactionService.d.ts.map +1 -1
- package/build/services/db/timelock/ScheduleTransactionService.js +7 -51
- package/build/services/types/db/timelock.d.ts +20 -3
- package/build/services/types/db/timelock.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ import { OperationType } from "../../../contracts/types/escrow";
|
|
|
5
5
|
import { MarkCompleteScheduleJob, ScheduleTransactionJobWithDetails } from "../../types/db";
|
|
6
6
|
declare class ScheduleTransactionService {
|
|
7
7
|
static get_and_lock_available_jobs: (pool: Pool, limit?: number, job_ttl_s?: number, lock_metadata?: ClaimJobLockMetadata) => Promise<ScheduleTransactionJob[]>;
|
|
8
|
-
/**
|
|
8
|
+
/** Locks and returns available jobs with full withdrawal details via DB function. */
|
|
9
9
|
static get_and_lock_available_jobs_with_details: (pool: Pool, limit?: number, job_ttl_s?: number, lock_metadata?: ClaimJobLockMetadata) => Promise<ScheduleTransactionJobWithDetails[]>;
|
|
10
10
|
/**
|
|
11
11
|
* Requeues all jobs in the given status to "queued"
|
|
@@ -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,2BAA2B,GAAU,MAAM,IAAI,EAAE,QAAO,MAAW,EAAE,YAAW,MAAY,EAAE,gBAAe,oBAA0F,KAAG,OAAO,CAAC,sBAAsB,EAAE,CAAC,
|
|
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,2BAA2B,GAAU,MAAM,IAAI,EAAE,QAAO,MAAW,EAAE,YAAW,MAAY,EAAE,gBAAe,oBAA0F,KAAG,OAAO,CAAC,sBAAsB,EAAE,CAAC,CA4CjP;IAGD,qFAAqF;IACrF,MAAM,CAAC,wCAAwC,GAC3C,MAAM,IAAI,EACV,QAAO,MAAW,EAClB,YAAW,MAAY,EACvB,gBAAe,oBAA0F,KAC1G,OAAO,CAAC,iCAAiC,EAAE,CAAC,CAQ9C;IAGD;;OAEG;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,CA8ClC;IAGF,MAAM,CAAC,mBAAmB,GAAU,MAAM,IAAI,EAAE,gBAAgB,aAAa,EAAE,aAAa,MAAM,EAAE,EAAE,YAAY,iBAAiB,KAAG,OAAO,CAAC,IAAI,CAAC,CASjJ;IAGF,MAAM,CAAC,wBAAwB,GAC3B,MAAM,IAAI,EACV,gBAAgB,aAAa,EAC7B,aAAa,MAAM,EAAE,EACrB,YAAY,iBAAiB,EAC7B,gBAAgB,MAAM,EACtB,YAAY,OAAO,KACpB,OAAO,CAAC,IAAI,CAAC,CAwBd;IAGF,MAAM,CAAC,qCAAqC,GACxC,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;CAEJ;AAED,eAAe,0BAA0B,CAAC"}
|
|
@@ -10,13 +10,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
var _a;
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
const uuid_1 = require("uuid");
|
|
14
13
|
class ScheduleTransactionService {
|
|
15
14
|
}
|
|
16
15
|
_a = ScheduleTransactionService;
|
|
17
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" }) {
|
|
18
17
|
const ttlSeconds = job_ttl_s;
|
|
19
|
-
const batchGroupId = (0, uuid_1.v4)();
|
|
20
18
|
const res = yield pool.query(`
|
|
21
19
|
WITH status_ids AS (
|
|
22
20
|
SELECT
|
|
@@ -38,69 +36,27 @@ ScheduleTransactionService.get_and_lock_available_jobs = (pool_1, ...args_1) =>
|
|
|
38
36
|
status_id = si.processing_id,
|
|
39
37
|
locked_at = now(),
|
|
40
38
|
lock_expires_at = now() + ($2 || ' seconds')::interval,
|
|
41
|
-
batch_group_id = $3,
|
|
42
39
|
metadata = jsonb_set(
|
|
43
40
|
jsonb_set(
|
|
44
41
|
coalesce(cj.metadata, '{}'::jsonb),
|
|
45
42
|
'{lock_owner}',
|
|
46
|
-
to_jsonb($
|
|
43
|
+
to_jsonb($3::text)
|
|
47
44
|
),
|
|
48
45
|
'{lock_reason}',
|
|
49
|
-
to_jsonb($
|
|
46
|
+
to_jsonb($4::text)
|
|
50
47
|
),
|
|
51
48
|
updated_at = now()
|
|
52
49
|
FROM candidates c, status_ids si
|
|
53
50
|
WHERE cj.id = c.id
|
|
54
51
|
RETURNING cj.*;
|
|
55
|
-
`, [limit, ttlSeconds,
|
|
52
|
+
`, [limit, ttlSeconds, lock_metadata.lock_owner, lock_metadata.lock_reason]);
|
|
56
53
|
return res.rows;
|
|
57
54
|
});
|
|
58
|
-
/**
|
|
55
|
+
/** Locks and returns available jobs with full withdrawal details via DB function. */
|
|
59
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" }) {
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
WITH status_ids AS (
|
|
64
|
-
SELECT
|
|
65
|
-
MAX(CASE WHEN status = 'queued' THEN id END) AS queued_id,
|
|
66
|
-
MAX(CASE WHEN status = 'processing' THEN id END) AS processing_id
|
|
67
|
-
FROM multisig.schedule_job_statuses
|
|
68
|
-
),
|
|
69
|
-
candidates AS (
|
|
70
|
-
SELECT cj.id
|
|
71
|
-
FROM multisig.schedule_transaction_jobs cj, status_ids
|
|
72
|
-
WHERE cj.status_id = status_ids.queued_id
|
|
73
|
-
AND (cj.lock_expires_at IS NULL OR cj.lock_expires_at < now())
|
|
74
|
-
ORDER BY cj.blockchain, cj.chain_id ASC
|
|
75
|
-
LIMIT $1
|
|
76
|
-
FOR UPDATE SKIP LOCKED
|
|
77
|
-
),
|
|
78
|
-
updated AS (
|
|
79
|
-
UPDATE multisig.schedule_transaction_jobs cj
|
|
80
|
-
SET
|
|
81
|
-
status_id = si.processing_id,
|
|
82
|
-
locked_at = now(),
|
|
83
|
-
lock_expires_at = now() + ($2 || ' seconds')::interval,
|
|
84
|
-
batch_group_id = $3,
|
|
85
|
-
metadata = jsonb_set(
|
|
86
|
-
jsonb_set(
|
|
87
|
-
coalesce(cj.metadata, '{}'::jsonb),
|
|
88
|
-
'{lock_owner}',
|
|
89
|
-
to_jsonb($4::text)
|
|
90
|
-
),
|
|
91
|
-
'{lock_reason}',
|
|
92
|
-
to_jsonb($5::text)
|
|
93
|
-
),
|
|
94
|
-
updated_at = now()
|
|
95
|
-
FROM candidates c, status_ids si
|
|
96
|
-
WHERE cj.id = c.id
|
|
97
|
-
RETURNING cj.*
|
|
98
|
-
)
|
|
99
|
-
SELECT u.*, sjs.status, accounting.fn_get_crypto_withdrawal_details(u.request_id) AS withdrawal_details
|
|
100
|
-
FROM updated u
|
|
101
|
-
JOIN multisig.schedule_job_statuses sjs ON sjs.id = u.status_id
|
|
102
|
-
`, [limit, ttlSeconds, batchGroupId, lock_metadata.lock_owner, lock_metadata.lock_reason]);
|
|
103
|
-
return res.rows;
|
|
57
|
+
var _b;
|
|
58
|
+
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
|
+
return (_b = result.rows[0].fn_get_available_schedule_jobs_with_details) !== null && _b !== void 0 ? _b : [];
|
|
104
60
|
});
|
|
105
61
|
/**
|
|
106
62
|
* Requeues all jobs in the given status to "queued"
|
|
@@ -1,11 +1,28 @@
|
|
|
1
1
|
import { OperationType } from "../../../contracts/types/escrow";
|
|
2
|
-
import { ScheduleTransactionJob } from "../../../entities/ScheduleTransactionJob";
|
|
3
2
|
import { WithdrawRequestDetails } from "../claim";
|
|
4
3
|
export interface MarkCompleteScheduleJob {
|
|
5
4
|
requestId: number;
|
|
6
5
|
operationType: OperationType;
|
|
7
6
|
}
|
|
8
|
-
export interface ScheduleTransactionJobWithDetails
|
|
9
|
-
|
|
7
|
+
export interface ScheduleTransactionJobWithDetails {
|
|
8
|
+
id: number;
|
|
9
|
+
requestId: number;
|
|
10
|
+
operationType: OperationType;
|
|
11
|
+
status: string;
|
|
12
|
+
blockchain: string;
|
|
13
|
+
chainId: string;
|
|
14
|
+
batchGroupId: string;
|
|
15
|
+
lockExpiresAt: string | null;
|
|
16
|
+
lockedAt: string | null;
|
|
17
|
+
txHash: string | null;
|
|
18
|
+
sentAt: string | null;
|
|
19
|
+
confirmedAt: string | null;
|
|
20
|
+
retryCount: number;
|
|
21
|
+
errorMessage: string | null;
|
|
22
|
+
lastErrorAt: string | null;
|
|
23
|
+
metadata: Record<string, unknown> | null;
|
|
24
|
+
createdAt: string;
|
|
25
|
+
updatedAt: string;
|
|
26
|
+
withdrawalDetails: WithdrawRequestDetails | null;
|
|
10
27
|
}
|
|
11
28
|
//# sourceMappingURL=timelock.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timelock.d.ts","sourceRoot":"","sources":["../../../../src/services/types/db/timelock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"timelock.d.ts","sourceRoot":"","sources":["../../../../src/services/types/db/timelock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAElD,MAAM,WAAW,uBAAuB;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,aAAa,CAAC;CAChC;AAED,MAAM,WAAW,iCAAiC;IAC9C,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,aAAa,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,sBAAsB,GAAG,IAAI,CAAC;CACpD"}
|
package/package.json
CHANGED