@ercworldio/blockchain-shared 1.0.2-dev-PROJ-1265.1 → 1.0.2-dev-PROJ-1265.1.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 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,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.WithdrawalCommitment = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
let WithdrawalCommitment = class WithdrawalCommitment {
|
|
15
|
+
};
|
|
16
|
+
exports.WithdrawalCommitment = WithdrawalCommitment;
|
|
17
|
+
__decorate([
|
|
18
|
+
(0, typeorm_1.Column)(),
|
|
19
|
+
__metadata("design:type", String)
|
|
20
|
+
], WithdrawalCommitment.prototype, "blockchain", void 0);
|
|
21
|
+
__decorate([
|
|
22
|
+
(0, typeorm_1.Column)(),
|
|
23
|
+
__metadata("design:type", Number)
|
|
24
|
+
], WithdrawalCommitment.prototype, "chain_id", void 0);
|
|
25
|
+
__decorate([
|
|
26
|
+
(0, typeorm_1.Column)({ type: "varchar" }),
|
|
27
|
+
__metadata("design:type", String)
|
|
28
|
+
], WithdrawalCommitment.prototype, "escrow_contract", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, typeorm_1.Column)({ type: "varchar", nullable: false }),
|
|
31
|
+
__metadata("design:type", String)
|
|
32
|
+
], WithdrawalCommitment.prototype, "commitment_hash", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, typeorm_1.Column)({ type: "bigint" }),
|
|
35
|
+
__metadata("design:type", Number)
|
|
36
|
+
], WithdrawalCommitment.prototype, "request_id", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, typeorm_1.Column)({ type: "enum" }),
|
|
39
|
+
__metadata("design:type", String)
|
|
40
|
+
], WithdrawalCommitment.prototype, "status", void 0);
|
|
41
|
+
__decorate([
|
|
42
|
+
(0, typeorm_1.Column)({ type: "varchar", nullable: true }),
|
|
43
|
+
__metadata("design:type", Object)
|
|
44
|
+
], WithdrawalCommitment.prototype, "tx_hash", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
47
|
+
__metadata("design:type", Object)
|
|
48
|
+
], WithdrawalCommitment.prototype, "finalized_at", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, typeorm_1.Column)({ type: 'timestamptz' }),
|
|
51
|
+
__metadata("design:type", Date)
|
|
52
|
+
], WithdrawalCommitment.prototype, "execute_at", void 0);
|
|
53
|
+
__decorate([
|
|
54
|
+
(0, typeorm_1.Column)({ type: 'timestamptz', default: () => 'CURRENT_TIMESTAMP' }),
|
|
55
|
+
__metadata("design:type", Date)
|
|
56
|
+
], WithdrawalCommitment.prototype, "created_at", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, typeorm_1.Column)({ type: 'timestamptz', default: () => 'CURRENT_TIMESTAMP' }),
|
|
59
|
+
__metadata("design:type", Date)
|
|
60
|
+
], WithdrawalCommitment.prototype, "updated_at", void 0);
|
|
61
|
+
exports.WithdrawalCommitment = WithdrawalCommitment = __decorate([
|
|
62
|
+
(0, typeorm_1.Entity)({ name: "crypto_withdrawal_commitment", schema: "multisig" }),
|
|
63
|
+
(0, typeorm_1.Unique)(['blockchain', 'chain_id', 'escrow_contract', 'commitment_hash', 'request_id'])
|
|
64
|
+
], WithdrawalCommitment);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export * from "./AdminOperationThresholds";
|
|
2
|
+
export * from "./Checkpoint";
|
|
3
|
+
export * from "./ClaimHistory";
|
|
4
|
+
export * from "./ClaimJob";
|
|
5
|
+
export * from "./CryptoConfirmationLocks";
|
|
6
|
+
export * from "./CryptoOperationType";
|
|
7
|
+
export * from "./DepositAddress";
|
|
8
|
+
export * from "./DepositAddressArchive";
|
|
9
|
+
export * from "./DepositWalletBalance";
|
|
10
|
+
export * from "./EscrowRoles";
|
|
11
|
+
export * from "./GlobalTimelock";
|
|
12
|
+
export * from "./GranularTimelock";
|
|
13
|
+
export * from "./RoleHash";
|
|
14
|
+
export * from "./ScheduleTransactionJob";
|
|
15
|
+
export * from "./ScheduleTransactionJobHistory";
|
|
16
|
+
export * from "./Signatures";
|
|
17
|
+
export * from "./SweepHistory";
|
|
18
|
+
export * from "./SweepJob";
|
|
19
|
+
export * from "./TokenExecutionThresholds";
|
|
20
|
+
export * from "./WalletIndex";
|
|
21
|
+
export * from "./WithdrawalCommitment";
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/entities/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,0BAA0B,CAAC;AACzC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,eAAe,CAAC;AAC9B,cAAc,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./AdminOperationThresholds"), exports);
|
|
18
|
+
__exportStar(require("./Checkpoint"), exports);
|
|
19
|
+
__exportStar(require("./ClaimHistory"), exports);
|
|
20
|
+
__exportStar(require("./ClaimJob"), exports);
|
|
21
|
+
__exportStar(require("./CryptoConfirmationLocks"), exports);
|
|
22
|
+
__exportStar(require("./CryptoOperationType"), exports);
|
|
23
|
+
__exportStar(require("./DepositAddress"), exports);
|
|
24
|
+
__exportStar(require("./DepositAddressArchive"), exports);
|
|
25
|
+
__exportStar(require("./DepositWalletBalance"), exports);
|
|
26
|
+
__exportStar(require("./EscrowRoles"), exports);
|
|
27
|
+
__exportStar(require("./GlobalTimelock"), exports);
|
|
28
|
+
__exportStar(require("./GranularTimelock"), exports);
|
|
29
|
+
__exportStar(require("./RoleHash"), exports);
|
|
30
|
+
__exportStar(require("./ScheduleTransactionJob"), exports);
|
|
31
|
+
__exportStar(require("./ScheduleTransactionJobHistory"), exports);
|
|
32
|
+
__exportStar(require("./Signatures"), exports);
|
|
33
|
+
__exportStar(require("./SweepHistory"), exports);
|
|
34
|
+
__exportStar(require("./SweepJob"), exports);
|
|
35
|
+
__exportStar(require("./TokenExecutionThresholds"), exports);
|
|
36
|
+
__exportStar(require("./WalletIndex"), exports);
|
|
37
|
+
__exportStar(require("./WithdrawalCommitment"), exports);
|
|
@@ -18,12 +18,14 @@ export interface FetchPriceData {
|
|
|
18
18
|
declare class AccountingService extends BaseErrors {
|
|
19
19
|
private dbPool;
|
|
20
20
|
private config;
|
|
21
|
+
private logger;
|
|
21
22
|
constructor(dbPool: IDatabasePool, config: IConfig);
|
|
22
23
|
deposit_address_exists_by_user: (user_id: number, address: string, blockchain: BlockchainType) => Promise<boolean>;
|
|
23
24
|
get_crypto_withdrawal_request: (request_id: number) => Promise<WithdrawRequestDetails | null>;
|
|
24
25
|
get_crypto_rate: (chain_id: ChainId) => Promise<number>;
|
|
25
26
|
private fetch_crypto_rate_task;
|
|
26
27
|
convert_amount_to_currency: (amount_in_source: number, source_currency: string, destination_currency: string) => Promise<number>;
|
|
28
|
+
private validate_currency_code;
|
|
27
29
|
private convert_currency_pair_task;
|
|
28
30
|
find_withdrawal_by_hash: (tx_hash: string, request_id: number) => Promise<any>;
|
|
29
31
|
find_withdrawals_batch: (lookups: WithdrawalLookup[]) => Promise<any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountingService.d.ts","sourceRoot":"","sources":["../../src/services/AccountingService.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"AccountingService.d.ts","sourceRoot":"","sources":["../../src/services/AccountingService.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAO9D,MAAM,MAAM,mBAAmB,GAAG,CAAC,IAAI,EAAE,cAAc,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAC5E,MAAM,MAAM,kBAAkB,GAAG,CAAC,IAAI,EAAE,qBAAqB,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAElF,MAAM,WAAW,qBAAqB;IAClC,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,oBAAoB,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,cAAc;IAC3B,QAAQ,EAAE,OAAO,CAAA;CACpB;AAED,cAAM,iBAAkB,SAAQ,UAAU;IACtC,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,MAAM,CAAU;IACxB,OAAO,CAAC,MAAM,CAAS;gBACX,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO;IAO3C,8BAA8B,GAAU,SAAS,MAAM,EAAE,SAAS,MAAM,EAAE,YAAY,cAAc,sBAe1G;IAEM,6BAA6B,GAAU,YAAY,MAAM,4CAc/D;IAEM,eAAe,GAAU,UAAU,OAAO,qBAQhD;IAGD,OAAO,CAAC,sBAAsB,CAoB7B;IAGM,0BAA0B,GAAU,kBAAkB,MAAM,EAAE,iBAAiB,MAAM,EAAE,sBAAsB,MAAM,qBAiBzH;IAED,OAAO,CAAC,sBAAsB,CAQ7B;IAED,OAAO,CAAC,0BAA0B,CAuBjC;IAEM,uBAAuB,GAAU,SAAS,MAAM,EAAE,YAAY,MAAM,kBAe1E;IAEM,sBAAsB,GACzB,SAAS,gBAAgB,EAAE,kBA8B7B;IAEK,4BAA4B,GAAU,QAAO,MAAY,kBAmB/D;IAqDM,qCAAqC,GAAU,QAAO,MAAY,EAAE,kBAAiB,MAAU,kBA4DrG;CACJ;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -16,6 +16,9 @@ const errors_1 = __importDefault(require("../errors/errors"));
|
|
|
16
16
|
const Wallets_1 = require("../utils/Wallets");
|
|
17
17
|
const ChainManager_1 = __importDefault(require("./ChainManager"));
|
|
18
18
|
const AsyncTTLCache_1 = __importDefault(require("../utils/AsyncTTLCache"));
|
|
19
|
+
const Logger_1 = require("../utils/Logger");
|
|
20
|
+
// Currency tickers are short alphanumeric codes (EUR, USD, USDT, ...); anything else is rejected before it reaches the DB.
|
|
21
|
+
const CURRENCY_CODE_PATTERN = /^[A-Z0-9]{2,10}$/;
|
|
19
22
|
class AccountingService extends errors_1.default {
|
|
20
23
|
constructor(dbPool, config) {
|
|
21
24
|
super();
|
|
@@ -63,20 +66,45 @@ class AccountingService extends errors_1.default {
|
|
|
63
66
|
return Number(result[0].fn_get_crypto_rate);
|
|
64
67
|
});
|
|
65
68
|
this.convert_amount_to_currency = (amount_in_source, source_currency, destination_currency) => __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
const source = this.validate_currency_code(source_currency, "source_currency");
|
|
70
|
+
const destination = this.validate_currency_code(destination_currency, "destination_currency");
|
|
71
|
+
if (typeof amount_in_source !== "number" || !Number.isFinite(amount_in_source)) {
|
|
72
|
+
this.logger.warn(`Rejected currency conversion: invalid amount`, { data: { amount_in_source: String(amount_in_source).slice(0, 200), source, destination } });
|
|
73
|
+
throw new Error(`Invalid amount for currency conversion`);
|
|
74
|
+
}
|
|
66
75
|
// const unit_rate = await PriceCache.getInstance().get_rate(source_currency, destination_currency, this.convert_currency_pair_task);
|
|
67
|
-
const key = `${
|
|
68
|
-
const unit_rate = yield AsyncTTLCache_1.default.getInstance().get_value(key, { amount_in_source, source_currency, destination_currency }, this.convert_currency_pair_task);
|
|
76
|
+
const key = `${source}/${destination}`;
|
|
77
|
+
const unit_rate = yield AsyncTTLCache_1.default.getInstance().get_value(key, { amount_in_source, source_currency: source, destination_currency: destination }, this.convert_currency_pair_task);
|
|
69
78
|
return unit_rate * amount_in_source;
|
|
70
79
|
});
|
|
80
|
+
this.validate_currency_code = (value, field) => {
|
|
81
|
+
const code = typeof value === "string" ? value.trim().toUpperCase() : "";
|
|
82
|
+
if (!CURRENCY_CODE_PATTERN.test(code)) {
|
|
83
|
+
// Warn goes to Elastic: an unexpected value here is either a client bug or an injection attempt.
|
|
84
|
+
this.logger.warn(`Rejected currency conversion: invalid ${field}`, { data: { field, value: String(value).slice(0, 200) } });
|
|
85
|
+
throw new Error(`Invalid ${field}`);
|
|
86
|
+
}
|
|
87
|
+
return code;
|
|
88
|
+
};
|
|
71
89
|
this.convert_currency_pair_task = (data) => __awaiter(this, void 0, void 0, function* () {
|
|
72
90
|
if (!this.dbPool.customerAppDataSource)
|
|
73
91
|
throw new Error(this.NotInitializedDatabase());
|
|
74
92
|
const { amount_in_source, source_currency, destination_currency } = data;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
93
|
+
this.logger.info(`Fetching currency conversion from DB`, { data: { amount_in_source, source_currency, destination_currency } });
|
|
94
|
+
let result;
|
|
95
|
+
try {
|
|
96
|
+
result = yield this.dbPool.customerAppDataSource.query(`
|
|
97
|
+
SELECT accounting.fn_convert_amount_to_currency($1::numeric, $2::text, $3::text)
|
|
98
|
+
`, [amount_in_source, source_currency, destination_currency]);
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
this.logger.error(`Currency conversion query failed`, { data: { error, amount_in_source, source_currency, destination_currency } });
|
|
102
|
+
throw error;
|
|
103
|
+
}
|
|
104
|
+
if (!result.length || result[0].fn_convert_amount_to_currency === null) {
|
|
105
|
+
this.logger.warn(`No conversion rate returned`, { data: { source_currency, destination_currency } });
|
|
79
106
|
throw new Error(`Failed to get crypto rate for pair ${source_currency}/${destination_currency}`);
|
|
107
|
+
}
|
|
80
108
|
return Number(result[0].fn_convert_amount_to_currency);
|
|
81
109
|
});
|
|
82
110
|
this.find_withdrawal_by_hash = (tx_hash, request_id) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -234,6 +262,7 @@ class AccountingService extends errors_1.default {
|
|
|
234
262
|
});
|
|
235
263
|
this.dbPool = dbPool;
|
|
236
264
|
this.config = config;
|
|
265
|
+
this.logger = (0, Logger_1.createLogger)(`AccountingService`, this.config.pipelineConfig.azureAppName);
|
|
237
266
|
}
|
|
238
267
|
}
|
|
239
268
|
exports.default = AccountingService;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ChainId } from "../interfaces";
|
|
2
|
+
import { Pool } from 'pg';
|
|
3
|
+
import { IConfig } from "../interfaces/config";
|
|
4
|
+
interface FetchPriceData {
|
|
5
|
+
chain_id: ChainId;
|
|
6
|
+
config: IConfig;
|
|
7
|
+
pool: Pool;
|
|
8
|
+
}
|
|
9
|
+
declare class AccountingServiceStatic {
|
|
10
|
+
static get_crypto_rate: (chain_id: ChainId, config: IConfig, pool: Pool) => Promise<number>;
|
|
11
|
+
static fetch_crypto_rate_task: (data: FetchPriceData) => Promise<number>;
|
|
12
|
+
}
|
|
13
|
+
export default AccountingServiceStatic;
|
|
14
|
+
//# sourceMappingURL=AccountingServiceStatic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccountingServiceStatic.d.ts","sourceRoot":"","sources":["../../src/services/AccountingServiceStatic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAC,IAAI,EAAC,MAAM,IAAI,CAAC;AAExB,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C,UAAU,cAAc;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,IAAI,CAAC;CACd;AAED,cAAM,uBAAuB;IACtB,MAAM,CAAC,eAAe,GAAU,UAAU,OAAO,EAAE,QAAQ,OAAO,EAAE,MAAM,IAAI,qBAQhF;IAGD,MAAM,CAAC,sBAAsB,GAAU,MAAM,cAAc,qBAkB1D;CAEJ;AAED,eAAe,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
var _a;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
const AsyncTTLCache_1 = __importDefault(require("../utils/AsyncTTLCache"));
|
|
17
|
+
const ChainManager_1 = __importDefault(require("./ChainManager"));
|
|
18
|
+
class AccountingServiceStatic {
|
|
19
|
+
}
|
|
20
|
+
_a = AccountingServiceStatic;
|
|
21
|
+
AccountingServiceStatic.get_crypto_rate = (chain_id, config, pool) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
+
// const price = await PriceCache.getInstance().get_price(chain_id, this.fetch_crypto_rate_task);
|
|
23
|
+
const price = yield AsyncTTLCache_1.default.getInstance().get_value(chain_id, { chain_id, config, pool }, _a.fetch_crypto_rate_task);
|
|
24
|
+
return price;
|
|
25
|
+
});
|
|
26
|
+
AccountingServiceStatic.fetch_crypto_rate_task = (data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
|
+
// if (!this.dbPool.customerAppDataSource) throw new Error(this.NotInitializedDatabase());
|
|
28
|
+
const { chain_id, config, pool } = data;
|
|
29
|
+
const ticker = ChainManager_1.default.getInstance(config).get_ticker_for_chain(chain_id);
|
|
30
|
+
const result = yield pool.query(`
|
|
31
|
+
SELECT accounting.fn_get_crypto_rate($1::text)
|
|
32
|
+
`, [ticker]);
|
|
33
|
+
if (!result.rows || !result.rowCount) {
|
|
34
|
+
throw new Error("DB returned no rows for fn_get_crypto_rate");
|
|
35
|
+
}
|
|
36
|
+
return Number(result.rows[0].fn_get_crypto_rate);
|
|
37
|
+
});
|
|
38
|
+
exports.default = AccountingServiceStatic;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Pool } from "pg";
|
|
2
|
+
import { ClaimJobs } from "../entities";
|
|
3
|
+
import { RequeueJobConfiguration } from "./types/watchdog";
|
|
4
|
+
import { JobStatus } from "./types";
|
|
5
|
+
declare class ClaimJobServiceStatic {
|
|
6
|
+
static requeue_expired_jobs: (pool: Pool, data: RequeueJobConfiguration<JobStatus>) => Promise<ClaimJobs[]>;
|
|
7
|
+
}
|
|
8
|
+
export default ClaimJobServiceStatic;
|
|
9
|
+
//# sourceMappingURL=ClaimJobServiceStatic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClaimJobServiceStatic.d.ts","sourceRoot":"","sources":["../../src/services/ClaimJobServiceStatic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,cAAM,qBAAqB;IACzB,MAAM,CAAC,oBAAoB,GACzB,MAAM,IAAI,EACV,MAAM,uBAAuB,CAAC,SAAS,CAAC,KACvC,OAAO,CAAC,SAAS,EAAE,CAAC,CAwCrB;CACH;AAED,eAAe,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
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 ClaimJobServiceStatic {
|
|
14
|
+
}
|
|
15
|
+
_a = ClaimJobServiceStatic;
|
|
16
|
+
ClaimJobServiceStatic.requeue_expired_jobs = (pool, data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
const result = yield pool.query(`
|
|
18
|
+
WITH expired AS (
|
|
19
|
+
SELECT id
|
|
20
|
+
FROM accounting.claim_jobs
|
|
21
|
+
WHERE job_status = $4
|
|
22
|
+
AND (
|
|
23
|
+
lock_expires_at IS NULL
|
|
24
|
+
OR lock_expires_at < now()
|
|
25
|
+
)
|
|
26
|
+
AND retry_count < $5
|
|
27
|
+
ORDER BY lock_expires_at ASC
|
|
28
|
+
LIMIT $1
|
|
29
|
+
FOR UPDATE SKIP LOCKED
|
|
30
|
+
)
|
|
31
|
+
UPDATE accounting.claim_jobs cj
|
|
32
|
+
SET
|
|
33
|
+
job_status = 'queued',
|
|
34
|
+
locked_at = NULL,
|
|
35
|
+
lock_expires_at = NULL,
|
|
36
|
+
metadata = jsonb_set(
|
|
37
|
+
jsonb_set(
|
|
38
|
+
coalesce(metadata, '{}'::jsonb),
|
|
39
|
+
'{requeued_by}',
|
|
40
|
+
to_jsonb($2::text),
|
|
41
|
+
true
|
|
42
|
+
),
|
|
43
|
+
'{requeue_reason}',
|
|
44
|
+
to_jsonb($3::text),
|
|
45
|
+
true
|
|
46
|
+
),
|
|
47
|
+
updated_at = now()
|
|
48
|
+
FROM expired e
|
|
49
|
+
WHERE cj.id = e.id
|
|
50
|
+
RETURNING cj.*;
|
|
51
|
+
`, [data.limit, data.lock_owner, data.lock_reason, data.watch_status, data.max_retries]);
|
|
52
|
+
return result.rows;
|
|
53
|
+
});
|
|
54
|
+
exports.default = ClaimJobServiceStatic;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Pool } from "pg";
|
|
2
|
+
import { WithdrawRequestDetails } from "./types";
|
|
3
|
+
import { WithdrawalCommitment } from "../entities";
|
|
4
|
+
declare class WithdrawalService {
|
|
5
|
+
static get_crypto_withdrawal_request: (pool: Pool, request_id: number) => Promise<WithdrawRequestDetails | null>;
|
|
6
|
+
static get_withdrawal_commitments: (pool: Pool, blockchain: string, chainId: string, escrowAddress: string) => Promise<WithdrawalCommitment[]>;
|
|
7
|
+
static get_withdrawal_commitment: (pool: Pool, request_id: number) => Promise<WithdrawalCommitment>;
|
|
8
|
+
}
|
|
9
|
+
export default WithdrawalService;
|
|
10
|
+
//# sourceMappingURL=WithdrawalService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WithdrawalService.d.ts","sourceRoot":"","sources":["../../src/services/WithdrawalService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAoB,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAErE,cAAM,iBAAiB;IACnB,MAAM,CAAC,6BAA6B,GAAU,MAAM,IAAI,EAAE,YAAY,MAAM,4CAQ3E;IAED,MAAM,CAAC,0BAA0B,GAAU,MAAM,IAAI,EAAE,YAAY,MAAM,EAAE,SAAS,MAAM,EAAE,eAAe,MAAM,qCAUhH;IAED,MAAM,CAAC,yBAAyB,GAAU,MAAM,IAAI,EAAE,YAAY,MAAM,mCAYvE;CACJ;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
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 WithdrawalService {
|
|
14
|
+
}
|
|
15
|
+
_a = WithdrawalService;
|
|
16
|
+
WithdrawalService.get_crypto_withdrawal_request = (pool, request_id) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
const result = yield pool.query(`
|
|
18
|
+
SELECT accounting.fn_get_crypto_withdrawal_details($1::bigint);
|
|
19
|
+
`, [request_id]);
|
|
20
|
+
return result.rows[0].fn_get_crypto_withdrawal_details;
|
|
21
|
+
});
|
|
22
|
+
WithdrawalService.get_withdrawal_commitments = (pool, blockchain, chainId, escrowAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
+
const status = "scheduled";
|
|
24
|
+
const result = yield pool.query(`
|
|
25
|
+
SELECT multisig.fn_get_withdrawal_commitments($1::text,$2::text,$3::text,$4::text);
|
|
26
|
+
`, [blockchain, chainId, escrowAddress, status]);
|
|
27
|
+
return result.rows[0].fn_get_withdrawal_commitments;
|
|
28
|
+
});
|
|
29
|
+
WithdrawalService.get_withdrawal_commitment = (pool, request_id) => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
+
const result = yield pool.query(`
|
|
31
|
+
SELECT cwc.*, ccs.status
|
|
32
|
+
FROM multisig.crypto_withdrawal_commitment cwc
|
|
33
|
+
JOIN multisig.crypto_commitment_statuses ccs ON ccs.id = cwc.status_id
|
|
34
|
+
WHERE cwc.request_id = $1::bigint
|
|
35
|
+
`, [request_id]);
|
|
36
|
+
return result.rows[0];
|
|
37
|
+
});
|
|
38
|
+
exports.default = WithdrawalService;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Pool } from "pg";
|
|
2
|
+
import { GetAdminOperationThreshold, UpsertAdminOperationThreshold, GetGlobalTimelock, UpsertGlobalTimelock, GetGranularTimelock, UpsertGranularTimelock, GetTokenExecutionThreshold, UpsertTokenExecutionThreshold, FnWithdrawalScheduledPayload, FnWithdrawalScheduledResult, FnWithdrawalExecutedResult, FnWithdrawalExecutedPayload, FnWithdrawalCancelledPayload, FnWithdrawalCancelledResult, FnGetWithdrawalCommitmentsResult, FnGetWithdrawalCommitmentsPayload } from "../../types";
|
|
3
|
+
import { OperationType } from "../../../contracts/types/escrow";
|
|
4
|
+
/**
|
|
5
|
+
* Adapter class for interfacing the DB functions
|
|
6
|
+
* related to escrow multisig threshold execution settings
|
|
7
|
+
*/
|
|
8
|
+
declare class MultisigService {
|
|
9
|
+
/** Returns all admin operation signature thresholds for the given escrow. */
|
|
10
|
+
static fn_get_admin_operation_thresholds(pool: Pool, blockchain: string, chainId: string, escrow_address: string): Promise<GetAdminOperationThreshold[]>;
|
|
11
|
+
/** Inserts or updates the manager/executive signature thresholds for the given escrow. */
|
|
12
|
+
static fn_upsert_admin_operation_threshold(pool: Pool, blockchain: string, chainId: string, escrow_address: string, operation_type: OperationType, sigs_manager: number, sigs_executive: number): Promise<UpsertAdminOperationThreshold>;
|
|
13
|
+
/** Returns all global timelock configs for the given escrow. */
|
|
14
|
+
static fn_get_global_timelock(pool: Pool, blockchain: string, chainId: string, escrow_address: string): Promise<GetGlobalTimelock[]>;
|
|
15
|
+
/** Inserts or updates the global timelock durations for a token/escrow pair. */
|
|
16
|
+
static fn_upsert_global_timelock(pool: Pool, blockchain: string, chainId: string, escrow_address: string, token_address: string, threshold_amount: number, duration_below_seconds: number, duration_above_seconds: number): Promise<UpsertGlobalTimelock>;
|
|
17
|
+
/** Returns all granular timelock configs for the given escrow. */
|
|
18
|
+
static fn_get_granular_timelock(pool: Pool, blockchain: string, chainId: string, escrow_address: string): Promise<GetGranularTimelock[]>;
|
|
19
|
+
/** Inserts or updates the timelock duration for a specific receiver address. */
|
|
20
|
+
static fn_upsert_granular_timelock(pool: Pool, blockchain: string, chainId: string, escrow_address: string, receiver_address: string, duration_seconds: number): Promise<UpsertGranularTimelock>;
|
|
21
|
+
/** Returns all per-token execution signature thresholds for the given escrow. */
|
|
22
|
+
static fn_get_token_execution_thresholds(pool: Pool, blockchain: string, chainId: string, escrow_address: string): Promise<GetTokenExecutionThreshold[]>;
|
|
23
|
+
/** Inserts or updates the above/below signature thresholds for a token/escrow pair. */
|
|
24
|
+
static fn_upsert_token_execution_threshold(pool: Pool, blockchain: string, chainId: string, escrow_address: string, token_address: string, threshold_amount: number, sigs_executive_below: number, sigs_executive_above: number, sigs_manager_below: number, sigs_manager_above: number): Promise<UpsertTokenExecutionThreshold>;
|
|
25
|
+
static fn_get_withdrawal_commitments(pool: Pool, data: FnGetWithdrawalCommitmentsPayload): Promise<FnGetWithdrawalCommitmentsResult[]>;
|
|
26
|
+
static fn_withdrawal_scheduled(pool: Pool, data: FnWithdrawalScheduledPayload): Promise<FnWithdrawalScheduledResult>;
|
|
27
|
+
static fn_withdrawal_executed(pool: Pool, data: FnWithdrawalExecutedPayload): Promise<FnWithdrawalExecutedResult>;
|
|
28
|
+
static fn_withdrawal_cancelled(pool: Pool, data: FnWithdrawalCancelledPayload): Promise<FnWithdrawalCancelledResult>;
|
|
29
|
+
}
|
|
30
|
+
export default MultisigService;
|
|
31
|
+
//# sourceMappingURL=MultisigService.d.ts.map
|
|
@@ -0,0 +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,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,cAAc,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,6BAA6B,CAAC;IAc9O,gEAAgE;WACnD,sBAAsB,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAS1I,gFAAgF;WACnE,yBAAyB,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAS/P,kEAAkE;WACrD,wBAAwB,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC;IAS9I,gFAAgF;WACnE,2BAA2B,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC;IActM,iFAAiF;WACpE,iCAAiC,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,0BAA0B,EAAE,CAAC;IAS9J,uFAAuF;WAC1E,mCAAmC,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,gBAAgB,EAAE,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"}
|
|
@@ -0,0 +1,134 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
/**
|
|
13
|
+
* Adapter class for interfacing the DB functions
|
|
14
|
+
* related to escrow multisig threshold execution settings
|
|
15
|
+
*/
|
|
16
|
+
class MultisigService {
|
|
17
|
+
///////////////////////////////////////////
|
|
18
|
+
/// Admin Operation Execution Thresholds
|
|
19
|
+
///////////////////////////////////////////
|
|
20
|
+
/** Returns all admin operation signature thresholds for the given escrow. */
|
|
21
|
+
static fn_get_admin_operation_thresholds(pool, blockchain, chainId, escrow_address) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const result = yield pool.query(`SELECT multisig.fn_get_admin_operation_thresholds($1::text,$2::text,$3::text)`, [blockchain, chainId, escrow_address]);
|
|
24
|
+
if (!result)
|
|
25
|
+
throw new Error(`DB FN error: multisig.fn_get_admin_operation_thresholds()`);
|
|
26
|
+
return result.rows[0].fn_get_admin_operation_thresholds;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/** Inserts or updates the manager/executive signature thresholds for the given escrow. */
|
|
30
|
+
static fn_upsert_admin_operation_threshold(pool, blockchain, chainId, escrow_address, operation_type, sigs_manager, sigs_executive) {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
const result = yield pool.query(`SELECT multisig.fn_upsert_admin_operation_threshold($1::text,$2::text,$3::text,$4::integer,$5::integer,$6::integer)`, [blockchain, chainId, escrow_address, operation_type, sigs_manager, sigs_executive]);
|
|
33
|
+
if (!result)
|
|
34
|
+
throw new Error(`DB FN error: multisig.fn_upsert_admin_operation_threshold()`);
|
|
35
|
+
return result.rows[0].fn_upsert_admin_operation_threshold;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
///////////////////////////////////////////
|
|
39
|
+
/// Timelock Durations
|
|
40
|
+
///////////////////////////////////////////
|
|
41
|
+
/** Returns all global timelock configs for the given escrow. */
|
|
42
|
+
static fn_get_global_timelock(pool, blockchain, chainId, escrow_address) {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
const result = yield pool.query(`SELECT multisig.fn_get_global_timelock($1::text,$2::text,$3::text)`, [blockchain, chainId, escrow_address]);
|
|
45
|
+
if (!result)
|
|
46
|
+
throw new Error(`DB FN error: multisig.fn_get_global_timelock()`);
|
|
47
|
+
return result.rows[0].fn_get_global_timelock;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/** Inserts or updates the global timelock durations for a token/escrow pair. */
|
|
51
|
+
static fn_upsert_global_timelock(pool, blockchain, chainId, escrow_address, token_address, threshold_amount, duration_below_seconds, duration_above_seconds) {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
const result = yield pool.query(`SELECT multisig.fn_upsert_global_timelock($1::text,$2::text,$3::text,$4::text,$5::numeric,$6::bigint,$7::bigint)`, [blockchain, chainId, escrow_address, token_address, threshold_amount, duration_below_seconds, duration_above_seconds]);
|
|
54
|
+
if (!result)
|
|
55
|
+
throw new Error(`DB FN error: multisig.fn_upsert_global_timelock()`);
|
|
56
|
+
return result.rows[0].fn_upsert_global_timelock;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/** Returns all granular timelock configs for the given escrow. */
|
|
60
|
+
static fn_get_granular_timelock(pool, blockchain, chainId, escrow_address) {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
const result = yield pool.query(`SELECT multisig.fn_get_granular_timelock($1::text,$2::text,$3::text)`, [blockchain, chainId, escrow_address]);
|
|
63
|
+
if (!result)
|
|
64
|
+
throw new Error(`DB FN error: multisig.fn_get_granular_timelock()`);
|
|
65
|
+
return result.rows[0].fn_get_granular_timelock;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/** Inserts or updates the timelock duration for a specific receiver address. */
|
|
69
|
+
static fn_upsert_granular_timelock(pool, blockchain, chainId, escrow_address, receiver_address, duration_seconds) {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
const result = yield pool.query(`SELECT multisig.fn_upsert_granular_timelock($1::text,$2::text,$3::text,$4::text,$5::bigint)`, [blockchain, chainId, escrow_address, receiver_address, duration_seconds]);
|
|
72
|
+
if (!result)
|
|
73
|
+
throw new Error(`DB FN error: multisig.fn_upsert_granular_timelock()`);
|
|
74
|
+
return result.rows[0].fn_upsert_granular_timelock;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
///////////////////////////////////////////
|
|
78
|
+
/// Token Execution Thresholds
|
|
79
|
+
///////////////////////////////////////////
|
|
80
|
+
/** Returns all per-token execution signature thresholds for the given escrow. */
|
|
81
|
+
static fn_get_token_execution_thresholds(pool, blockchain, chainId, escrow_address) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
const result = yield pool.query(`SELECT multisig.fn_get_token_execution_thresholds($1::text,$2::text,$3::text)`, [blockchain, chainId, escrow_address]);
|
|
84
|
+
if (!result)
|
|
85
|
+
throw new Error(`DB FN error: multisig.fn_get_token_execution_thresholds()`);
|
|
86
|
+
return result.rows[0].fn_get_token_execution_thresholds;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/** Inserts or updates the above/below signature thresholds for a token/escrow pair. */
|
|
90
|
+
static fn_upsert_token_execution_threshold(pool, blockchain, chainId, escrow_address, token_address, threshold_amount, sigs_executive_below, sigs_executive_above, sigs_manager_below, sigs_manager_above) {
|
|
91
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
const result = yield pool.query(`SELECT multisig.fn_upsert_token_execution_threshold($1::text,$2::text,$3::text,$4::text,$5::numeric,$6::bigint,$7::bigint,$8::bigint,$9::bigint)`, [blockchain, chainId, escrow_address, token_address, threshold_amount, sigs_executive_below, sigs_executive_above, sigs_manager_below, sigs_manager_above]);
|
|
93
|
+
if (!result)
|
|
94
|
+
throw new Error(`DB FN error: multisig.fn_upsert_token_execution_threshold()`);
|
|
95
|
+
return result.rows[0].fn_upsert_token_execution_threshold;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
///////////////////////////////////////////
|
|
99
|
+
/// Withdrawal Commitment
|
|
100
|
+
///////////////////////////////////////////
|
|
101
|
+
static fn_get_withdrawal_commitments(pool, data) {
|
|
102
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
const result = yield pool.query(`SELECT multisig.fn_get_withdrawal_commitments($1::text,$2::text,$3::text,$4::text)`, [data.p_blockchain, data.p_chain_id, data.p_escrow_contract, data.p_status]);
|
|
104
|
+
if (!result)
|
|
105
|
+
throw new Error(`DB FN error: multisig.fn_get_withdrawal_commitments()`);
|
|
106
|
+
return result.rows[0].fn_get_withdrawal_commitments;
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
static fn_withdrawal_scheduled(pool, data) {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
const result = yield pool.query(`SELECT multisig.fn_withdrawal_scheduled($1::text,$2::text,$3::text,$4::text,$5::bigint,$6::bigint,$7::numeric,$8::text,$9::text,$10::boolean,$11::text,$12::text,$13::text,$14::bigint,$15::bigint,$16::numeric)`, [data.p_blockchain, data.p_chain_id, data.p_escrow_contract, data.p_commitment_hash, data.p_request_id, data.p_execute_at, data.p_amount, data.p_token_address, data.p_receiver_address, data.p_confirmed, data.p_caller, data.p_sender, data.p_tx_hash, data.p_timestamp, data.p_block_number, data.p_gas_used]);
|
|
112
|
+
if (!result)
|
|
113
|
+
throw new Error(`DB FN error: multisig.fn_withdrawal_scheduled()`);
|
|
114
|
+
return result.rows[0].fn_withdrawal_scheduled;
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
static fn_withdrawal_executed(pool, data) {
|
|
118
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
119
|
+
const result = yield pool.query(`SELECT multisig.fn_withdrawal_executed($1::text,$2::text,$3::text,$4::text,$5::bigint,$6::boolean,$7::text,$8::text,$9::text,$10::bigint,$11::bigint,$12::numeric)`, [data.p_blockchain, data.p_chain_id, data.p_escrow_contract, data.p_commitment_hash, data.p_request_id, data.p_confirmed, data.p_caller, data.p_sender, data.p_tx_hash, data.p_timestamp, data.p_block_number, data.p_gas_used]);
|
|
120
|
+
if (!result)
|
|
121
|
+
throw new Error(`DB FN error: multisig.fn_withdrawal_executed()`);
|
|
122
|
+
return result.rows[0].fn_withdrawal_executed;
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
static fn_withdrawal_cancelled(pool, data) {
|
|
126
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
+
const result = yield pool.query(`SELECT multisig.fn_withdrawal_cancelled($1::text,$2::text,$3::text,$4::text,$5::bigint,$6::boolean,$7::text,$8::text,$9::text,$10::bigint,$11::bigint,$12::numeric)`, [data.p_blockchain, data.p_chain_id, data.p_escrow_contract, data.p_commitment_hash, data.p_request_id, data.p_confirmed, data.p_caller, data.p_sender, data.p_tx_hash, data.p_timestamp, data.p_block_number, data.p_gas_used]);
|
|
128
|
+
if (!result)
|
|
129
|
+
throw new Error(`DB FN error: multisig.fn_withdrawal_cancelled()`);
|
|
130
|
+
return result.rows[0].fn_withdrawal_cancelled;
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
exports.default = MultisigService;
|