@ercworldio/blockchain-shared 1.0.3-dev.3-PROJ-1296.23 → 1.0.3-dev.3-PROJ-1296.24
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/entities/ScheduleTransactionJob.d.ts.map +1 -1
- package/build/entities/ScheduleTransactionJob.js +1 -1
- package/build/services/db/timelock/ScheduleTransactionService.d.ts +3 -1
- package/build/services/db/timelock/ScheduleTransactionService.d.ts.map +1 -1
- package/build/services/db/timelock/ScheduleTransactionService.js +40 -0
- package/build/services/types/db/timelock.d.ts +5 -0
- package/build/services/types/db/timelock.d.ts.map +1 -1
- package/build/services/types/index.d.ts +1 -1
- package/build/services/types/index.d.ts.map +1 -1
- package/build/services/types/index.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScheduleTransactionJob.d.ts","sourceRoot":"","sources":["../../src/entities/ScheduleTransactionJob.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,YAAY,GAAG,YAAY,GAAG,WAAW,GAAG,kBAAkB,GAAG,kBAAkB,CAAC;AAG/H,
|
|
1
|
+
{"version":3,"file":"ScheduleTransactionJob.d.ts","sourceRoot":"","sources":["../../src/entities/ScheduleTransactionJob.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,YAAY,GAAG,YAAY,GAAG,WAAW,GAAG,kBAAkB,GAAG,kBAAkB,CAAC;AAG/H,qBAEa,sBAAsB;IAE/B,EAAE,EAAG,MAAM,CAAC;IAGZ,UAAU,EAAG,MAAM,CAAC;IAGpB,cAAc,EAAG,aAAa,CAAC;IAG/B,MAAM,EAAG,iBAAiB,CAAC;IAG3B,UAAU,EAAG,cAAc,CAAC;IAG5B,QAAQ,EAAG,MAAM,CAAC;IAIlB,eAAe,EAAG,IAAI,GAAG,IAAI,CAAC;IAG9B,SAAS,EAAG,IAAI,GAAG,IAAI,CAAC;IAGxB,OAAO,EAAG,MAAM,GAAG,IAAI,CAAC;IAGxB,OAAO,EAAG,IAAI,GAAG,IAAI,CAAC;IAGtB,YAAY,EAAG,IAAI,GAAG,IAAI,CAAC;IAG3B,WAAW,EAAG,MAAM,CAAC;IAGrB,aAAa,EAAG,MAAM,GAAG,IAAI,CAAC;IAG9B,aAAa,EAAG,IAAI,GAAG,IAAI,CAAC;IAG5B,QAAQ,EAAG,GAAG,CAAC;IAIf,UAAU,EAAG,IAAI,CAAC;IAGlB,UAAU,EAAG,IAAI,CAAC;CACrB"}
|
|
@@ -85,5 +85,5 @@ __decorate([
|
|
|
85
85
|
], ScheduleTransactionJob.prototype, "updated_at", void 0);
|
|
86
86
|
exports.ScheduleTransactionJob = ScheduleTransactionJob = __decorate([
|
|
87
87
|
(0, typeorm_1.Entity)({ name: "schedule_transaction_jobs", schema: "multisig" }),
|
|
88
|
-
(0, typeorm_1.Unique)(["request_id"])
|
|
88
|
+
(0, typeorm_1.Unique)(["request_id", 'operation_type'])
|
|
89
89
|
], ScheduleTransactionJob);
|
|
@@ -2,9 +2,11 @@ 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 } from "../../types/db";
|
|
5
|
+
import { MarkCompleteScheduleJob, ScheduleTransactionJobWithDetails } from "../../types/db";
|
|
6
6
|
declare class ScheduleTransactionService {
|
|
7
7
|
static get_available_jobs: (pool: Pool, limit?: number, job_ttl_s?: number, lock_metadata?: ClaimJobLockMetadata) => Promise<ScheduleTransactionJob[]>;
|
|
8
|
+
/** Same as get_available_jobs but joins withdrawal details from accounting for each job. */
|
|
9
|
+
static get_available_jobs_with_details: (pool: Pool, limit?: number, job_ttl_s?: number, lock_metadata?: ClaimJobLockMetadata) => Promise<ScheduleTransactionJobWithDetails[]>;
|
|
8
10
|
/**
|
|
9
11
|
* Requeues all jobs in the given status to "queued"
|
|
10
12
|
* @param pool
|
|
@@ -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,MAAM,gBAAgB,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,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;IACI,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;IAIK,mBAAmB,GAAU,MAAM,IAAI,EAAE,gBAAgB,aAAa,EAAE,aAAa,MAAM,EAAE,EAAE,YAAY,iBAAiB,KAAG,OAAO,CAAC,IAAI,CAAC,CAUjJ;IAGK,wBAAwB,GAC3B,MAAM,IAAI,EACV,aAAa,MAAM,EAAE,EACrB,YAAY,iBAAiB,EAC7B,gBAAgB,MAAM,EACtB,YAAY,OAAO,KACpB,OAAO,CAAC,IAAI,CAAC,CAwBd;IAGK,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;IAGK,aAAa,GAAU,MAAM,IAAI,EAAE,UAAU,uBAAuB,EAAE,mBAuB5E;CAGJ;AAED,eAAe,0BAA0B,CAAC"}
|
|
@@ -173,4 +173,44 @@ ScheduleTransactionService.get_available_jobs = (pool_1, ...args_1) => __awaiter
|
|
|
173
173
|
`, [limit, ttlSeconds, batchGroupId, lock_metadata.lock_owner, lock_metadata.lock_reason]);
|
|
174
174
|
return res.rows;
|
|
175
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
|
+
});
|
|
176
216
|
exports.default = ScheduleTransactionService;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { OperationType } from "../../../contracts/types/escrow";
|
|
2
|
+
import { ScheduleTransactionJob } from "../../../entities/ScheduleTransactionJob";
|
|
3
|
+
import { WithdrawRequestDetails } from "../claim";
|
|
2
4
|
export interface MarkCompleteScheduleJob {
|
|
3
5
|
requestId: number;
|
|
4
6
|
operationType: OperationType;
|
|
5
7
|
}
|
|
8
|
+
export interface ScheduleTransactionJobWithDetails extends ScheduleTransactionJob {
|
|
9
|
+
withdrawal_details: WithdrawRequestDetails | null;
|
|
10
|
+
}
|
|
6
11
|
//# 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;
|
|
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,0CAA0C,CAAC;AAClF,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,iCAAkC,SAAQ,sBAAsB;IAC7E,kBAAkB,EAAE,sBAAsB,GAAG,IAAI,CAAC;CACrD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC;AAC1B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,SAAS,CAAC;AACxB,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC;AAC1B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,SAAS,CAAC;AACxB,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC"}
|
|
@@ -30,4 +30,4 @@ __exportStar(require("./balance_service"), exports);
|
|
|
30
30
|
__exportStar(require("./chain_manager"), exports);
|
|
31
31
|
__exportStar(require("./quicknode"), exports);
|
|
32
32
|
__exportStar(require("./bo_withdrawal"), exports);
|
|
33
|
-
__exportStar(require("./db/
|
|
33
|
+
__exportStar(require("./db/index"), exports);
|
package/package.json
CHANGED