@ercworldio/blockchain-shared 1.0.5-dev.8-PLAT304.4 → 1.0.5-dev.8-fix
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/chains/networks_dev.json +2 -3
- package/build/chains/networks_prod-ab120.json +644 -0
- package/build/chains/networks_prod-bu.json +0 -14
- package/build/chains/networks_prod-dz-v1.json +1 -1
- package/build/chains/networks_prod-dz.json +47 -26
- package/build/chains/networks_stg-ab120-mainnet.json +681 -0
- package/build/chains/networks_stg-ab120.json +597 -0
- package/build/chains/networks_stg-bu.json +25 -30
- package/build/chains/networks_stg-dz.json +20 -30
- package/build/chains/networks_stg-yb-v1.json +574 -0
- package/build/contracts/artifacts/Escrow.json +87 -10
- package/build/index.d.ts +1 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +4 -6
- package/build/services/AccountingService.d.ts +2 -0
- package/build/services/AccountingService.d.ts.map +1 -1
- package/build/services/AccountingService.js +35 -6
- package/build/services/AlchemyService.d.ts.map +1 -1
- package/build/services/AlchemyService.js +2 -3
- package/build/services/ClaimJobService.d.ts.map +1 -1
- package/build/services/ClaimJobService.js +12 -5
- package/build/services/Redis.js +2 -2
- package/build/services/RedisPubSub.js +1 -1
- package/build/services/WithdrawalManager.js +1 -1
- package/build/services/db/multisig/MultisigService.d.ts +1 -44
- package/build/services/db/multisig/MultisigService.d.ts.map +1 -1
- package/build/services/db/multisig/MultisigService.js +0 -133
- package/build/services/solana/escrow/idl/escrow.json +1448 -4661
- package/build/services/solana/escrow/services/EscrowAdminUtility.d.ts.map +1 -1
- package/build/services/solana/escrow/services/EscrowAdminUtility.js +0 -1
- package/build/services/solana/escrow/services/TreasuryWithdrawalSignature.d.ts +1 -8
- package/build/services/solana/escrow/services/TreasuryWithdrawalSignature.d.ts.map +1 -1
- package/build/services/solana/escrow/services/TreasuryWithdrawalSignature.js +2 -9
- package/build/services/solana/escrow/types/escrow.d.ts +1442 -4655
- package/build/services/solana/escrow/types/escrow.d.ts.map +1 -1
- package/build/services/types/db/multisig_service.d.ts +0 -144
- package/build/services/types/db/multisig_service.d.ts.map +1 -1
- package/build/utils/solana.d.ts.map +1 -1
- package/build/utils/solana.js +5 -3
- package/package.json +1 -1
package/build/index.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ export { default as AsyncRateLimiter } from "./utils/AsyncRateLimiter";
|
|
|
2
2
|
export { default as AsyncTTLCache } from "./utils/AsyncTTLCache";
|
|
3
3
|
export { default as AzureEventHubHandler } from './services/AzureEventHubHandler';
|
|
4
4
|
export { default as AccountingService } from './services/AccountingService';
|
|
5
|
-
export { default as AccountingServiceStatic } from "./services/AccountingServiceStatic";
|
|
6
5
|
export { default as AlchemyService } from './services/AlchemyService';
|
|
7
6
|
export { default as AlchemyWebhookAddressManager } from './services/AlchemyWebhookAddressManager';
|
|
8
7
|
export { default as AlchemyWebhooks } from './services/AlchemyWebhooks';
|
|
@@ -29,6 +28,7 @@ export { default as RedisQueue } from './services/RedisQueue';
|
|
|
29
28
|
export { default as RedisListQueue } from './services/RedisListQueue';
|
|
30
29
|
export { default as RedisPubSub } from './services/RedisPubSub';
|
|
31
30
|
export { default as RpcLimiter } from "./utils/RpcLimiter";
|
|
31
|
+
export { default as RPCManager } from "./services/rpc/RPC";
|
|
32
32
|
export { default as TimerManager } from './services/TimerManager';
|
|
33
33
|
export { default as TronSigner } from './services/tron/services/TronSigner';
|
|
34
34
|
export { default as TronTransaction } from './services/tron/services/Transactions';
|
|
@@ -37,7 +37,6 @@ export { default as TronHotWallet } from "./services/tron/services/TronHotWallet
|
|
|
37
37
|
export { default as TronCustodialWallet } from "./services/tron/services/TronCustodialWallet";
|
|
38
38
|
export { default as TronFundingWallet } from "./services/tron/services/TronFundingWallet";
|
|
39
39
|
export { default as ScheduleTransactionService } from "./services/db/timelock/ScheduleTransactionService";
|
|
40
|
-
export { default as RPCManager } from "./services/rpc/RPC";
|
|
41
40
|
export { default as ScheduleTransactionJobHistoryService } from "./services/db/timelock/ScheduleTransactionJobHistoryService";
|
|
42
41
|
export { default as Provider } from './chains/Provider';
|
|
43
42
|
export { default as ProviderManager } from './services/ProviderManager';
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAClF,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EAAE,OAAO,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAClF,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,4BAA4B,EAAE,MAAM,yCAAyC,CAAC;AAClG,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AACxF,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAClE,O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var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
40
40
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41
41
|
};
|
|
42
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
-
exports.WithdrawalManager = exports.WalletManagerHelper = exports.WalletManager = exports.WalletIndexService = exports.SweepHistoryService = exports.SweepJobService = exports.StorageService = exports.ProviderManager = exports.Provider = exports.ScheduleTransactionJobHistoryService = exports.
|
|
44
|
-
exports.AppErrors = exports.EscrowIdl = exports.CoverageInfo = exports.EscrowEvents = exports.Erc20Events = exports.AccessControlEvents = exports.ERC20Abi = exports.ErrorAbi = exports.EscrowAbi = exports.ERC20MockAbi = exports.BaseErrors = exports.VoltageErrors = exports.AlchemyErrors = exports.WalletErrors = exports.DatabaseErrors = exports.BalanceErrors = exports.AdminErrors = exports.TransactionsErrors = exports.EscrowInteraction = exports.QnWebhookAddressManager = exports.SetupNotifications = exports.QnNotificationsApi = exports.QuicknodeWebhookSignature = exports.Worker =
|
|
43
|
+
exports.WithdrawalService = exports.WithdrawalManager = exports.WalletManagerHelper = exports.WalletManager = exports.WalletIndexService = exports.SweepHistoryService = exports.SweepJobService = exports.StorageService = exports.ProviderManager = exports.Provider = exports.ScheduleTransactionJobHistoryService = exports.ScheduleTransactionService = exports.TronFundingWallet = exports.TronCustodialWallet = exports.TronHotWallet = exports.TronHelper = exports.TronTransaction = exports.TronSigner = exports.TimerManager = exports.RPCManager = exports.RpcLimiter = exports.RedisPubSub = exports.RedisListQueue = exports.RedisQueue = exports.Redis = exports.MultisigService = exports.MemoryMonitor = exports.Logger = exports.KeyVaultHandler = exports.InvoiceQueue = exports.EscrowService = exports.EventsService = exports.EventsHandler = exports.ElasticSearch = exports.DepositAddressArchiveService = exports.DepositAddressService = exports.ClaimJobServiceStatic = exports.ClaimJobService = exports.ClaimHistoryService = exports.ContractRoles = exports.ChainManager = exports.BalanceService = exports.AlchemyWebhookSignature = exports.AlchemyWebhooks = exports.AlchemyWebhookAddressManager = exports.AlchemyService = exports.AccountingService = exports.AzureEventHubHandler = exports.AsyncTTLCache = exports.AsyncRateLimiter = void 0;
|
|
44
|
+
exports.AppErrors = exports.EscrowIdl = exports.CoverageInfo = exports.EscrowEvents = exports.Erc20Events = exports.AccessControlEvents = exports.ERC20Abi = exports.ErrorAbi = exports.EscrowAbi = exports.ERC20MockAbi = exports.BaseErrors = exports.VoltageErrors = exports.AlchemyErrors = exports.WalletErrors = exports.DatabaseErrors = exports.BalanceErrors = exports.AdminErrors = exports.TransactionsErrors = exports.EscrowInteraction = exports.QnWebhookAddressManager = exports.SetupNotifications = exports.QnNotificationsApi = exports.QuicknodeWebhookSignature = exports.Worker = void 0;
|
|
45
45
|
// Services
|
|
46
46
|
var AsyncRateLimiter_1 = require("./utils/AsyncRateLimiter");
|
|
47
47
|
Object.defineProperty(exports, "AsyncRateLimiter", { enumerable: true, get: function () { return __importDefault(AsyncRateLimiter_1).default; } });
|
|
@@ -51,8 +51,6 @@ var AzureEventHubHandler_1 = require("./services/AzureEventHubHandler");
|
|
|
51
51
|
Object.defineProperty(exports, "AzureEventHubHandler", { enumerable: true, get: function () { return __importDefault(AzureEventHubHandler_1).default; } });
|
|
52
52
|
var AccountingService_1 = require("./services/AccountingService");
|
|
53
53
|
Object.defineProperty(exports, "AccountingService", { enumerable: true, get: function () { return __importDefault(AccountingService_1).default; } });
|
|
54
|
-
var AccountingServiceStatic_1 = require("./services/AccountingServiceStatic");
|
|
55
|
-
Object.defineProperty(exports, "AccountingServiceStatic", { enumerable: true, get: function () { return __importDefault(AccountingServiceStatic_1).default; } });
|
|
56
54
|
var AlchemyService_1 = require("./services/AlchemyService");
|
|
57
55
|
Object.defineProperty(exports, "AlchemyService", { enumerable: true, get: function () { return __importDefault(AlchemyService_1).default; } });
|
|
58
56
|
var AlchemyWebhookAddressManager_1 = require("./services/AlchemyWebhookAddressManager");
|
|
@@ -104,6 +102,8 @@ var RedisPubSub_1 = require("./services/RedisPubSub");
|
|
|
104
102
|
Object.defineProperty(exports, "RedisPubSub", { enumerable: true, get: function () { return __importDefault(RedisPubSub_1).default; } });
|
|
105
103
|
var RpcLimiter_1 = require("./utils/RpcLimiter");
|
|
106
104
|
Object.defineProperty(exports, "RpcLimiter", { enumerable: true, get: function () { return __importDefault(RpcLimiter_1).default; } });
|
|
105
|
+
var RPC_1 = require("./services/rpc/RPC");
|
|
106
|
+
Object.defineProperty(exports, "RPCManager", { enumerable: true, get: function () { return __importDefault(RPC_1).default; } });
|
|
107
107
|
var TimerManager_1 = require("./services/TimerManager");
|
|
108
108
|
Object.defineProperty(exports, "TimerManager", { enumerable: true, get: function () { return __importDefault(TimerManager_1).default; } });
|
|
109
109
|
var TronSigner_1 = require("./services/tron/services/TronSigner");
|
|
@@ -120,8 +120,6 @@ var TronFundingWallet_1 = require("./services/tron/services/TronFundingWallet");
|
|
|
120
120
|
Object.defineProperty(exports, "TronFundingWallet", { enumerable: true, get: function () { return __importDefault(TronFundingWallet_1).default; } });
|
|
121
121
|
var ScheduleTransactionService_1 = require("./services/db/timelock/ScheduleTransactionService");
|
|
122
122
|
Object.defineProperty(exports, "ScheduleTransactionService", { enumerable: true, get: function () { return __importDefault(ScheduleTransactionService_1).default; } });
|
|
123
|
-
var RPC_1 = require("./services/rpc/RPC");
|
|
124
|
-
Object.defineProperty(exports, "RPCManager", { enumerable: true, get: function () { return __importDefault(RPC_1).default; } });
|
|
125
123
|
var ScheduleTransactionJobHistoryService_1 = require("./services/db/timelock/ScheduleTransactionJobHistoryService");
|
|
126
124
|
Object.defineProperty(exports, "ScheduleTransactionJobHistoryService", { enumerable: true, get: function () { return __importDefault(ScheduleTransactionJobHistoryService_1).default; } });
|
|
127
125
|
var Provider_1 = require("./chains/Provider");
|
|
@@ -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,C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AAe,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;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AlchemyService.d.ts","sourceRoot":"","sources":["../../src/services/AlchemyService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EACH,yBAAyB,EAEzB,yBAAyB,EACzB,oBAAoB,EAEpB,oBAAoB,EACpB,6BAA6B,EAC7B,8BAA8B,EAI9B,8BAA8B,EAC9B,uBAAuB,EACvB,0BAA0B,EAC1B,WAAW,EACd,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAc/C,UAAU,kBAAkB;IACxB,OAAO,EAAE,WAAW,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;CAC3B;AAOD,MAAM,WAAW,mBAAmB;IAChC,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,cAAM,cAAc;IAChB,OAAc,QAAQ,EAAE,cAAc,CAAC;IACvC,OAAO,CAAC,MAAM,CAAU;IACxB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,aAAa,CAAuC;IAE5D,OAAO;IAOP,OAAO,CAAC,YAAY,CAGlB;WAGY,WAAW,CAAC,MAAM,EAAE,OAAO;IAOlC,gBAAgB,GAAU,KAAK,yBAAyB,KAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CASvF;IAEM,6BAA6B,G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B,KAAG,OAAO,CAAC,8BAA8B,CAAC,CAO7J;IAEM,wBAAwB,CAAC,GAAG,EAAE,yBAAyB,GAAG,IAAI;IAI9D,iCAAiC,GAAU,cAAc,yBAAyB,EAAE,YAAY,cAAc,EAAE,kBAAkB,MAAM,EAAE,EAAE,qBAAqB,MAAM,EAAE;;;;OAiD/K;IAIM,wBAAwB,GAAU,cAAc,yBAAyB,EAAE,kBAAkB,MAAM,EAAE,EAAE,qBAAqB,MAAM,EAAE,sBAmC1I;IAGM,aAAa,GAAU,KAAK,yBAAyB,EAAE,SAAS,OAAO,EAAE,cAAc,WAAW,EAAE,mCAqB1G;IAEY,mBAAmB,CAAC,YAAY,EAAE,yBAAyB;;;;;;;;;IAsBjE,cAAc,GAAU,cAAc,yBAAyB,EAAE,SAAS,oBAAoB,KAAG,OAAO,CAAC,WAAW,CAAC,CAc3H;IAEM,iBAAiB,GAAU,cAAc,yBAAyB,EAAE,SAAS,uBAAuB,KAAG,OAAO,CAAC,OAAO,CAAC,CAK7H;IAEM,oBAAoB,GAAU,cAAc,yBAAyB,EAAE,SAAS,yBAAyB,KAAG,OAAO,CAAC,OAAO,CAAC,CAIlI;IACM,qBAAqB,GAAU,cAAc,yBAAyB,EAAE,SAAS,0BAA0B,KAAG,OAAO,CAAC,WAAW,CAAC,CAKxI;IACM,cAAc,GAAU,cAAc,yBAAyB,EAAE,SAAS,oBAAoB,KAAG,OAAO,CAAC,OAAO,CAAC,CAKvH;IACD,OAAO,CAAC,IAAI,CA+CX;CACJ;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -56,7 +56,6 @@ class AlchemyService {
|
|
|
56
56
|
this.logger.info(`${all_webhooks.length} webhooks available in subscription: ${subscription}`);
|
|
57
57
|
const address_activity_webhooks = all_webhooks.filter(w => w.webhook_type === "ADDRESS_ACTIVITY" && w.webhook_url.includes(`address-activity`) && w.webhook_url.includes(subscription));
|
|
58
58
|
this.logger.info(`Found ${address_activity_webhooks.length} ADDRESS_ACTIVITY webhooks`);
|
|
59
|
-
this.logger.info(`ADDRESS_ACTIVITY webhooks`, { address_activity_webhooks });
|
|
60
59
|
const webhook_ids = address_activity_webhooks.map((webhook) => webhook.id);
|
|
61
60
|
const promises = yield Promise.allSettled(webhook_ids.map((id) => __awaiter(this, void 0, void 0, function* () {
|
|
62
61
|
try {
|
|
@@ -67,8 +66,8 @@ class AlchemyService {
|
|
|
67
66
|
};
|
|
68
67
|
const is_added_removed = yield this.add_remove_addresses(subscription, payload);
|
|
69
68
|
if (!is_added_removed)
|
|
70
|
-
this.logger.info(`Failed to add/remove addresses.`, { data: { webhook_ids, add: payload.addresses_to_add, remove: payload.addresses_to_remove } });
|
|
71
|
-
this.logger.info(`Added/removed:`, { added: payload.addresses_to_add, remove: payload.addresses_to_remove });
|
|
69
|
+
this.logger.info(`Failed to add/remove addresses.`, { data: { webhook_ids, add: payload.addresses_to_add.length, remove: payload.addresses_to_remove.length } });
|
|
70
|
+
this.logger.info(`Added/removed:`, { added: payload.addresses_to_add.length, remove: payload.addresses_to_remove.length });
|
|
72
71
|
return {
|
|
73
72
|
status: is_added_removed,
|
|
74
73
|
webhook_id: id
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClaimJobService.d.ts","sourceRoot":"","sources":["../../src/services/ClaimJobService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGjD,OAAO,EAAE,SAAS,EAA0B,MAAM,eAAe,CAAC;AAElE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAKlK,cAAM,gBAAgB;IAClB,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,MAAM,CAA4B;IAC1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BAAgB,GAAU,YAAY,QAAQ,GAAG,KAAK,EAAE,UAAU,OAAO,qBAI/E;IAEM,oBAAoB,GAAU,YAAY,QAAQ,GAAG,KAAK,GAAG,MAAM,EAAE,UAAU,OAAO,EAAE,cAAU,KAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAW/H;IAEM,iBAAiB,GAAU,aAAa,MAAM,EAAE,KAAG,OAAO,CAAC,IAAI,CAAC,CAQrE;IAEK,gBAAgB,GAAU,YAAY,MAAM,6CAGlD;IAED,OAAO,CAAC,YAAY,CAenB;CAEJ;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -108,7 +108,8 @@ class ClaimJobsService {
|
|
|
108
108
|
'operationType', cs.operation_type,
|
|
109
109
|
'v', cs.v,
|
|
110
110
|
'r', cs.r,
|
|
111
|
-
's', cs.s
|
|
111
|
+
's', cs.s,
|
|
112
|
+
'signature', cs.signature
|
|
112
113
|
)), '[]'::json)
|
|
113
114
|
FROM multisig.crypto_signatures cs
|
|
114
115
|
LEFT JOIN multisig.crypto_escrow_roles cer
|
|
@@ -118,9 +119,10 @@ class ClaimJobsService {
|
|
|
118
119
|
AND LOWER(cer.contract_address) = LOWER(cs.contract_address)
|
|
119
120
|
LEFT JOIN multisig.crypto_role cr ON cr.id = cer.role_id
|
|
120
121
|
WHERE cs.reference_id = u.request_id
|
|
121
|
-
AND
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
AND (
|
|
123
|
+
(cs.v IS NOT NULL AND cs.r IS NOT NULL AND cs.s IS NOT NULL)
|
|
124
|
+
OR cs.signature IS NOT NULL
|
|
125
|
+
)
|
|
124
126
|
) AS multisig_signatures
|
|
125
127
|
FROM updated u;
|
|
126
128
|
`, [limit, job_ttl_s, (0, uuid_1.v4)(), lock_metadata.lock_owner, lock_metadata.lock_reason, max_retry_count]);
|
|
@@ -185,7 +187,8 @@ class ClaimJobsService {
|
|
|
185
187
|
'operationType', cs.operation_type,
|
|
186
188
|
'v', cs.v,
|
|
187
189
|
'r', cs.r,
|
|
188
|
-
's', cs.s
|
|
190
|
+
's', cs.s,
|
|
191
|
+
'signature', cs.signature
|
|
189
192
|
)), '[]'::json)
|
|
190
193
|
FROM multisig.crypto_signatures cs
|
|
191
194
|
LEFT JOIN multisig.crypto_escrow_roles cer
|
|
@@ -195,6 +198,10 @@ class ClaimJobsService {
|
|
|
195
198
|
AND LOWER(cer.contract_address) = LOWER(cs.contract_address)
|
|
196
199
|
LEFT JOIN multisig.crypto_role cr ON cr.id = cer.role_id
|
|
197
200
|
WHERE cs.reference_id = u.request_id
|
|
201
|
+
AND (
|
|
202
|
+
(cs.v IS NOT NULL AND cs.r IS NOT NULL AND cs.s IS NOT NULL)
|
|
203
|
+
OR cs.signature IS NOT NULL
|
|
204
|
+
)
|
|
198
205
|
) AS multisig_signatures
|
|
199
206
|
FROM updated u
|
|
200
207
|
LEFT JOIN multisig.crypto_withdrawal_commitment cwc ON cwc.request_id = u.request_id;
|
package/build/services/Redis.js
CHANGED
|
@@ -277,7 +277,7 @@ class Redis {
|
|
|
277
277
|
try {
|
|
278
278
|
const pref = `${this.prefix}-`;
|
|
279
279
|
const normalizedKey = expiredKey.startsWith(pref) ? expiredKey.slice(pref.length) : expiredKey;
|
|
280
|
-
this.logger.info(`Redis: key expired: ${normalizedKey}`);
|
|
280
|
+
// this.logger.info(`Redis: key expired: ${normalizedKey}`);
|
|
281
281
|
let value = null;
|
|
282
282
|
try {
|
|
283
283
|
value = yield this.get_object(expiredKey);
|
|
@@ -381,7 +381,7 @@ class Redis {
|
|
|
381
381
|
get_object(_key_1) {
|
|
382
382
|
return __awaiter(this, arguments, void 0, function* (_key, use_prefix = true) {
|
|
383
383
|
const key = this.get_key(_key, use_prefix);
|
|
384
|
-
this.logger.info(`Redis: Getting object with key: ${key}`);
|
|
384
|
+
// this.logger.info(`Redis: Getting object with key: ${key}`);
|
|
385
385
|
const raw = yield this._get(key);
|
|
386
386
|
return raw ? JSON.parse(raw) : null;
|
|
387
387
|
});
|
|
@@ -110,7 +110,7 @@ class RedisPubSub {
|
|
|
110
110
|
this.logger.info(`RedisPubSub: pSubscribe: Subscribed to pattern: ${pattern}`);
|
|
111
111
|
yield this.subscriber.pSubscribe(pattern, (eventKey) => __awaiter(this, void 0, void 0, function* () {
|
|
112
112
|
try {
|
|
113
|
-
this.logger.info(`RedisPubSub: pSubscribe: Received subscriber event: ${event.eventName}. eventkey: ${eventKey}`)
|
|
113
|
+
// this.logger.info(`RedisPubSub: pSubscribe: Received subscriber event: ${event.eventName}. eventkey: ${eventKey}`)
|
|
114
114
|
// Get the value before it expires (if possible) or use the key
|
|
115
115
|
const pref = `${this.prefix}-`;
|
|
116
116
|
if (eventKey.startsWith(pref))
|
|
@@ -151,7 +151,7 @@ class WithdrawalManager extends TransactionsErrors_1.default {
|
|
|
151
151
|
else if (blockchain === "evm") {
|
|
152
152
|
// Build evm batch withdraw payload
|
|
153
153
|
const payloads = queue.map(j => ({
|
|
154
|
-
amount_in_tokens:
|
|
154
|
+
amount_in_tokens: j.amount,
|
|
155
155
|
requestId: j.request_id,
|
|
156
156
|
token: j.token,
|
|
157
157
|
receiver: j.receiver
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Pool } from "pg";
|
|
2
|
-
import { GetAdminOperationThreshold, UpsertAdminOperationThreshold, GetGlobalTimelock, UpsertGlobalTimelock, GetGranularTimelock, UpsertGranularTimelock, GetTokenExecutionThreshold, UpsertTokenExecutionThreshold, FnWithdrawalScheduledPayload, FnWithdrawalScheduledResult, FnWithdrawalExecutedResult, FnWithdrawalExecutedPayload, FnWithdrawalCancelledPayload, FnWithdrawalCancelledResult, FnGetWithdrawalCommitmentsResult, FnGetWithdrawalCommitmentsPayload
|
|
2
|
+
import { GetAdminOperationThreshold, UpsertAdminOperationThreshold, GetGlobalTimelock, UpsertGlobalTimelock, GetGranularTimelock, UpsertGranularTimelock, GetTokenExecutionThreshold, UpsertTokenExecutionThreshold, FnWithdrawalScheduledPayload, FnWithdrawalScheduledResult, FnWithdrawalExecutedResult, FnWithdrawalExecutedPayload, FnWithdrawalCancelledPayload, FnWithdrawalCancelledResult, FnGetWithdrawalCommitmentsResult, FnGetWithdrawalCommitmentsPayload } from "../../types";
|
|
3
3
|
import { OperationType } from "../../../contracts/types/escrow";
|
|
4
4
|
/**
|
|
5
5
|
* Adapter class for interfacing the DB functions
|
|
@@ -26,49 +26,6 @@ declare class MultisigService {
|
|
|
26
26
|
static fn_withdrawal_scheduled(pool: Pool, data: FnWithdrawalScheduledPayload): Promise<FnWithdrawalScheduledResult>;
|
|
27
27
|
static fn_withdrawal_executed(pool: Pool, data: FnWithdrawalExecutedPayload): Promise<FnWithdrawalExecutedResult>;
|
|
28
28
|
static fn_withdrawal_cancelled(pool: Pool, data: FnWithdrawalCancelledPayload): Promise<FnWithdrawalCancelledResult>;
|
|
29
|
-
/** Creates a config-change request; returns it with resolved status + required signature counts. */
|
|
30
|
-
static fn_create_config_change_request(pool: Pool, blockchain: string, chainId: string, escrow_address: string, operation_type: number, config_target: ConfigChangeTarget, config_nonce: number, payload: Record<string, unknown>, target_key?: string | null): Promise<CreateConfigChangeResult>;
|
|
31
|
-
/** Upserts a collected approver signature onto a pre-seeded placeholder; auto-promotes to approved when the quota is met. */
|
|
32
|
-
static fn_upsert_config_change_signature(pool: Pool, blockchain: string, chainId: string, contract_address: string, operation_type: number, reference_id: number, signer_address: string, v?: number | null, r?: string | null, s?: string | null, signature?: string | null, commitment_hash?: string | null, type_data_hash?: string | null): Promise<UpsertConfigChangeSignatureResult>;
|
|
33
|
-
/** Lists config-change requests (all filters optional), each with its embedded signatures array. */
|
|
34
|
-
static fn_get_config_change_requests(pool: Pool, blockchain?: string | null, chainId?: string | null, status?: ConfigChangeStatus | null, config_target?: ConfigChangeTarget | null): Promise<ConfigChangeRequestRow[]>;
|
|
35
|
-
/** Cancels a pending/approved request. */
|
|
36
|
-
static fn_cancel_config_change_request(pool: Pool, request_id: number): Promise<CancelConfigChangeResult>;
|
|
37
|
-
/** Records the broadcast tx hash on an approved request (status stays approved until the event applies it). */
|
|
38
|
-
static fn_set_config_change_tx_hash(pool: Pool, request_id: number, tx_hash: string): Promise<SetConfigChangeTxHashResult>;
|
|
39
|
-
/**
|
|
40
|
-
* Worker-side: flips an approved config-change request to applied when the confirming on-chain
|
|
41
|
-
* event lands. Matches primarily by the tx hash the client stored via /submit; falls back to the
|
|
42
|
-
* single approved request for the {blockchain, chainId, escrowAddress, operationType} group
|
|
43
|
-
* (backfilling tx_hash) when /submit was never called. `operationType` is the governing group
|
|
44
|
-
* op type (MANAGE_MULTISIG=4 / CONFIG_TIMELOCK=5), not the configured operation's op type.
|
|
45
|
-
*/
|
|
46
|
-
static fn_config_change_applied(pool: Pool, blockchain: string, chainId: string, escrowAddress: string, operationType: number, tx_hash: string): Promise<ConfigChangeAppliedResult>;
|
|
47
|
-
/**
|
|
48
|
-
* Creates an admin-withdrawal request; snapshots the op=3 threshold and pre-seeds signature
|
|
49
|
-
* placeholders. Returns the request `pending`, or `approved` when no signatures are required.
|
|
50
|
-
* `amount`/`amountDecimals` are numeric strings (raw base-unit + human-readable). `adminUserId`
|
|
51
|
-
* is the requesting admin's user id from the JWT.
|
|
52
|
-
*/
|
|
53
|
-
static fn_create_admin_withdrawal_request(pool: Pool, blockchain: string, chainId: string, escrow_address: string, amount: string, amount_decimals: string, token_address: string, receiver_address: string, admin_user_id: number): Promise<CreateAdminWithdrawalResult>;
|
|
54
|
-
/**
|
|
55
|
-
* Upserts a collected approver signature onto a pre-seeded placeholder — v/r/s (EVM) or the base58
|
|
56
|
-
* `signature` (Solana). Auto-promotes to `approved` once the ADMIN_TREASURY manager+executive quota
|
|
57
|
-
* is met. Op type 3 is implied (no p_operation_type arg).
|
|
58
|
-
*/
|
|
59
|
-
static fn_upsert_admin_withdrawal_signature(pool: Pool, blockchain: string, chainId: string, escrow_address: string, request_id: number, signer_address: string, v?: number | null, r?: string | null, s?: string | null, signature?: string | null, type_data_hash?: string | null): Promise<UpsertAdminWithdrawalSignatureResult>;
|
|
60
|
-
/** Lists admin-withdrawal requests (all filters optional), each with its embedded signatures array. */
|
|
61
|
-
static fn_get_admin_withdrawal_requests(pool: Pool, blockchain?: string | null, chainId?: string | null, status?: AdminWithdrawalStatus | null): Promise<AdminWithdrawalRequestRow[]>;
|
|
62
|
-
/** Cancels a pending/approved request — only while it has not been broadcast (tx_hash IS NULL). */
|
|
63
|
-
static fn_cancel_admin_withdrawal_request(pool: Pool, request_id: number): Promise<CancelAdminWithdrawalResult>;
|
|
64
|
-
/** Records the broadcast tx hash on an approved request (status stays approved until the event completes it). */
|
|
65
|
-
static fn_set_admin_withdrawal_tx_hash(pool: Pool, request_id: number, tx_hash: string): Promise<SetAdminWithdrawalTxHashResult>;
|
|
66
|
-
/**
|
|
67
|
-
* Worker-side: flips an approved admin-withdrawal request to `completed` when the confirming on-chain
|
|
68
|
-
* event lands. Matches by `request_id` identity (the AdminWithdraw / AdminPullWithdrawEvent carries it),
|
|
69
|
-
* backfilling tx_hash/block/timestamp. Idempotent.
|
|
70
|
-
*/
|
|
71
|
-
static fn_admin_withdrawal_completed(pool: Pool, blockchain: string, chainId: string, escrow_address: string, request_id: number, tx_hash: string, block_number: number, timestamp: number): Promise<AdminWithdrawalCompletedResult>;
|
|
72
29
|
}
|
|
73
30
|
export default MultisigService;
|
|
74
31
|
//# sourceMappingURL=MultisigService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultisigService.d.ts","sourceRoot":"","sources":["../../../../src/services/db/multisig/MultisigService.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAE1B,OAAO,EACH,0BAA0B,EAC1B,6BAA6B,EAC7B,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,0BAA0B,EAC1B,6BAA6B,EAC7B,4BAA4B,EAC5B,2BAA2B,EAC3B,0BAA0B,EAC1B,2BAA2B,EAC3B,4BAA4B,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AE,IAAI,EAAE,IAAI,EAAE,2BAA2B,GAAG,OAAO,CAAC,0BAA0B,CAAC;WAW1G,uBAAuB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,4BAA4B,GAAG,OAAO,CAAC,2BAA2B,CAAC;CAW7H;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -130,138 +130,5 @@ class MultisigService {
|
|
|
130
130
|
return result.rows[0].fn_withdrawal_cancelled;
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
|
-
///////////////////////////////////////////
|
|
134
|
-
/// Admin config-change requests (PLAN3/PLAN4)
|
|
135
|
-
///////////////////////////////////////////
|
|
136
|
-
/** Creates a config-change request; returns it with resolved status + required signature counts. */
|
|
137
|
-
static fn_create_config_change_request(pool_1, blockchain_1, chainId_1, escrow_address_1, operation_type_1, config_target_1, config_nonce_1, payload_1) {
|
|
138
|
-
return __awaiter(this, arguments, void 0, function* (pool, blockchain, chainId, escrow_address, operation_type, config_target, config_nonce, payload, target_key = null) {
|
|
139
|
-
const result = yield pool.query(`SELECT multisig.fn_create_config_change_request($1::varchar,$2::varchar,$3::varchar,$4::integer,$5::varchar,$6::bigint,$7::jsonb,$8::varchar)`, [blockchain, chainId, escrow_address, operation_type, config_target, config_nonce, JSON.stringify(payload), target_key]);
|
|
140
|
-
if (!result)
|
|
141
|
-
throw new Error(`DB FN error: multisig.fn_create_config_change_request()`);
|
|
142
|
-
return result.rows[0].fn_create_config_change_request;
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
/** Upserts a collected approver signature onto a pre-seeded placeholder; auto-promotes to approved when the quota is met. */
|
|
146
|
-
static fn_upsert_config_change_signature(pool_1, blockchain_1, chainId_1, contract_address_1, operation_type_1, reference_id_1, signer_address_1) {
|
|
147
|
-
return __awaiter(this, arguments, void 0, function* (pool, blockchain, chainId, contract_address, operation_type, reference_id, signer_address, v = null, r = null, s = null, signature = null, commitment_hash = null, type_data_hash = null) {
|
|
148
|
-
const result = yield pool.query(`SELECT multisig.fn_upsert_config_change_signature($1::varchar,$2::varchar,$3::varchar,$4::integer,$5::bigint,$6::varchar,$7::integer,$8::varchar,$9::varchar,$10::varchar,$11::varchar,$12::varchar)`, [blockchain, chainId, contract_address, operation_type, reference_id, signer_address, v, r, s, signature, commitment_hash, type_data_hash]);
|
|
149
|
-
if (!result)
|
|
150
|
-
throw new Error(`DB FN error: multisig.fn_upsert_config_change_signature()`);
|
|
151
|
-
return result.rows[0].fn_upsert_config_change_signature;
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
/** Lists config-change requests (all filters optional), each with its embedded signatures array. */
|
|
155
|
-
static fn_get_config_change_requests(pool_1) {
|
|
156
|
-
return __awaiter(this, arguments, void 0, function* (pool, blockchain = null, chainId = null, status = null, config_target = null) {
|
|
157
|
-
const result = yield pool.query(`SELECT multisig.fn_get_config_change_requests($1::varchar,$2::varchar,$3::varchar,$4::varchar)`, [blockchain, chainId, status, config_target]);
|
|
158
|
-
if (!result)
|
|
159
|
-
throw new Error(`DB FN error: multisig.fn_get_config_change_requests()`);
|
|
160
|
-
return result.rows[0].fn_get_config_change_requests;
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
/** Cancels a pending/approved request. */
|
|
164
|
-
static fn_cancel_config_change_request(pool, request_id) {
|
|
165
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
166
|
-
const result = yield pool.query(`SELECT multisig.fn_cancel_config_change_request($1::bigint)`, [request_id]);
|
|
167
|
-
if (!result)
|
|
168
|
-
throw new Error(`DB FN error: multisig.fn_cancel_config_change_request()`);
|
|
169
|
-
return result.rows[0].fn_cancel_config_change_request;
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
/** Records the broadcast tx hash on an approved request (status stays approved until the event applies it). */
|
|
173
|
-
static fn_set_config_change_tx_hash(pool, request_id, tx_hash) {
|
|
174
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
175
|
-
const result = yield pool.query(`SELECT multisig.fn_set_config_change_tx_hash($1::bigint,$2::varchar)`, [request_id, tx_hash]);
|
|
176
|
-
if (!result)
|
|
177
|
-
throw new Error(`DB FN error: multisig.fn_set_config_change_tx_hash()`);
|
|
178
|
-
return result.rows[0].fn_set_config_change_tx_hash;
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Worker-side: flips an approved config-change request to applied when the confirming on-chain
|
|
183
|
-
* event lands. Matches primarily by the tx hash the client stored via /submit; falls back to the
|
|
184
|
-
* single approved request for the {blockchain, chainId, escrowAddress, operationType} group
|
|
185
|
-
* (backfilling tx_hash) when /submit was never called. `operationType` is the governing group
|
|
186
|
-
* op type (MANAGE_MULTISIG=4 / CONFIG_TIMELOCK=5), not the configured operation's op type.
|
|
187
|
-
*/
|
|
188
|
-
static fn_config_change_applied(pool, blockchain, chainId, escrowAddress, operationType, tx_hash) {
|
|
189
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
190
|
-
const result = yield pool.query(`SELECT multisig.fn_config_change_applied($1::varchar,$2::varchar,$3::varchar,$4::integer,$5::varchar)`, [blockchain, chainId, escrowAddress, operationType, tx_hash]);
|
|
191
|
-
if (!result)
|
|
192
|
-
throw new Error(`DB FN error: multisig.fn_config_change_applied()`);
|
|
193
|
-
return result.rows[0].fn_config_change_applied;
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
///////////////////////////////////////////
|
|
197
|
-
/// Admin-withdrawal requests (PLAN5)
|
|
198
|
-
///////////////////////////////////////////
|
|
199
|
-
/**
|
|
200
|
-
* Creates an admin-withdrawal request; snapshots the op=3 threshold and pre-seeds signature
|
|
201
|
-
* placeholders. Returns the request `pending`, or `approved` when no signatures are required.
|
|
202
|
-
* `amount`/`amountDecimals` are numeric strings (raw base-unit + human-readable). `adminUserId`
|
|
203
|
-
* is the requesting admin's user id from the JWT.
|
|
204
|
-
*/
|
|
205
|
-
static fn_create_admin_withdrawal_request(pool, blockchain, chainId, escrow_address, amount, amount_decimals, token_address, receiver_address, admin_user_id) {
|
|
206
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
207
|
-
const result = yield pool.query(`SELECT multisig.fn_create_admin_withdrawal_request($1::varchar,$2::varchar,$3::varchar,$4::numeric,$5::numeric,$6::varchar,$7::varchar,$8::varchar)`, [blockchain, chainId, escrow_address, amount, amount_decimals, token_address, receiver_address, admin_user_id.toString()]);
|
|
208
|
-
if (!result)
|
|
209
|
-
throw new Error(`DB FN error: multisig.fn_create_admin_withdrawal_request()`);
|
|
210
|
-
return result.rows[0].fn_create_admin_withdrawal_request;
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Upserts a collected approver signature onto a pre-seeded placeholder — v/r/s (EVM) or the base58
|
|
215
|
-
* `signature` (Solana). Auto-promotes to `approved` once the ADMIN_TREASURY manager+executive quota
|
|
216
|
-
* is met. Op type 3 is implied (no p_operation_type arg).
|
|
217
|
-
*/
|
|
218
|
-
static fn_upsert_admin_withdrawal_signature(pool_1, blockchain_1, chainId_1, escrow_address_1, request_id_1, signer_address_1) {
|
|
219
|
-
return __awaiter(this, arguments, void 0, function* (pool, blockchain, chainId, escrow_address, request_id, signer_address, v = null, r = null, s = null, signature = null, type_data_hash = null) {
|
|
220
|
-
const result = yield pool.query(`SELECT multisig.fn_upsert_admin_withdrawal_signature($1::varchar,$2::varchar,$3::varchar,$4::bigint,$5::varchar,$6::integer,$7::varchar,$8::varchar,$9::varchar,$10::varchar)`, [blockchain, chainId, escrow_address, request_id, signer_address, v, r, s, signature, type_data_hash]);
|
|
221
|
-
if (!result)
|
|
222
|
-
throw new Error(`DB FN error: multisig.fn_upsert_admin_withdrawal_signature()`);
|
|
223
|
-
return result.rows[0].fn_upsert_admin_withdrawal_signature;
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
/** Lists admin-withdrawal requests (all filters optional), each with its embedded signatures array. */
|
|
227
|
-
static fn_get_admin_withdrawal_requests(pool_1) {
|
|
228
|
-
return __awaiter(this, arguments, void 0, function* (pool, blockchain = null, chainId = null, status = null) {
|
|
229
|
-
const result = yield pool.query(`SELECT multisig.fn_get_admin_withdrawal_requests($1::varchar,$2::varchar,$3::varchar)`, [blockchain, chainId, status]);
|
|
230
|
-
if (!result)
|
|
231
|
-
throw new Error(`DB FN error: multisig.fn_get_admin_withdrawal_requests()`);
|
|
232
|
-
return result.rows[0].fn_get_admin_withdrawal_requests;
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
/** Cancels a pending/approved request — only while it has not been broadcast (tx_hash IS NULL). */
|
|
236
|
-
static fn_cancel_admin_withdrawal_request(pool, request_id) {
|
|
237
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
238
|
-
const result = yield pool.query(`SELECT multisig.fn_cancel_admin_withdrawal_request($1::bigint)`, [request_id]);
|
|
239
|
-
if (!result)
|
|
240
|
-
throw new Error(`DB FN error: multisig.fn_cancel_admin_withdrawal_request()`);
|
|
241
|
-
return result.rows[0].fn_cancel_admin_withdrawal_request;
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
/** Records the broadcast tx hash on an approved request (status stays approved until the event completes it). */
|
|
245
|
-
static fn_set_admin_withdrawal_tx_hash(pool, request_id, tx_hash) {
|
|
246
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
247
|
-
const result = yield pool.query(`SELECT multisig.fn_set_admin_withdrawal_tx_hash($1::bigint,$2::varchar)`, [request_id, tx_hash]);
|
|
248
|
-
if (!result)
|
|
249
|
-
throw new Error(`DB FN error: multisig.fn_set_admin_withdrawal_tx_hash()`);
|
|
250
|
-
return result.rows[0].fn_set_admin_withdrawal_tx_hash;
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* Worker-side: flips an approved admin-withdrawal request to `completed` when the confirming on-chain
|
|
255
|
-
* event lands. Matches by `request_id` identity (the AdminWithdraw / AdminPullWithdrawEvent carries it),
|
|
256
|
-
* backfilling tx_hash/block/timestamp. Idempotent.
|
|
257
|
-
*/
|
|
258
|
-
static fn_admin_withdrawal_completed(pool, blockchain, chainId, escrow_address, request_id, tx_hash, block_number, timestamp) {
|
|
259
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
260
|
-
const result = yield pool.query(`SELECT multisig.fn_admin_withdrawal_completed($1::varchar,$2::varchar,$3::varchar,$4::bigint,$5::varchar,$6::bigint,$7::bigint)`, [blockchain, chainId, escrow_address, request_id, tx_hash, block_number, timestamp]);
|
|
261
|
-
if (!result)
|
|
262
|
-
throw new Error(`DB FN error: multisig.fn_admin_withdrawal_completed()`);
|
|
263
|
-
return result.rows[0].fn_admin_withdrawal_completed;
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
133
|
}
|
|
267
134
|
exports.default = MultisigService;
|