@ercworldio/blockchain-shared 1.0.5-dev.7.PROJ-1464.0 → 1.0.5-dev.8
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 +10 -0
- package/build/chains/networks_prod-bu.json +0 -14
- package/build/chains/networks_prod-dz.json +22 -1
- package/build/errors/TransactionsErrors.d.ts +0 -1
- package/build/errors/TransactionsErrors.d.ts.map +1 -1
- package/build/errors/TransactionsErrors.js +0 -4
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +4 -2
- 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/db/timelock/ScheduleTransactionService.d.ts +16 -2
- package/build/services/db/timelock/ScheduleTransactionService.d.ts.map +1 -1
- package/build/services/db/timelock/ScheduleTransactionService.js +265 -1
- 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/SolanaEscrowAdmin.d.ts +41 -1
- package/build/services/solana/escrow/SolanaEscrowAdmin.d.ts.map +1 -1
- package/build/services/solana/escrow/SolanaEscrowAdmin.js +35 -3
- package/build/services/solana/escrow/idl/escrow.json +4267 -988
- package/build/services/solana/escrow/services/EscrowAdminUtility.d.ts +116 -3
- package/build/services/solana/escrow/services/EscrowAdminUtility.d.ts.map +1 -1
- package/build/services/solana/escrow/services/EscrowAdminUtility.js +543 -55
- 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/solana/escrow/types/escrow.d.ts +4262 -983
- package/build/services/solana/escrow/types/escrow.d.ts.map +1 -1
- package/build/services/solana/escrow/types/types.d.ts +17 -0
- package/build/services/solana/escrow/types/types.d.ts.map +1 -1
- package/build/services/types/claim.d.ts +1 -0
- package/build/services/types/claim.d.ts.map +1 -1
- package/build/services/types/db/timelock.d.ts +56 -0
- package/build/services/types/db/timelock.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
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const constants_1 = require("../../constants");
|
|
4
|
+
const Provider_1 = require("../../chains/Provider");
|
|
5
|
+
// export var default_archival_connection_provider: RpcProviderType = RpcProviderType.ALCHEMY;
|
|
6
|
+
// export var default_evm_rpc_provider: RpcProviderType = RpcProviderType.ALCHEMY;
|
|
7
|
+
class RPC {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.initialized = false;
|
|
10
|
+
this.currentProvider = new Map();
|
|
11
|
+
// const config = Config.getInstance();
|
|
12
|
+
// const evmProvider = config.config.defaultEvmRpcProviderType ? config.config.defaultEvmRpcProviderType : RpcProviderType.ALCHEMY;
|
|
13
|
+
// const solanaProvider = config.config.defaultSolRpcProviderType ? config.config.defaultSolRpcProviderType : RpcProviderType.ALCHEMY;
|
|
14
|
+
// const tronProvider = config.config.defaultTronRpcProviderType ? config.config.defaultTronRpcProviderType : RpcProviderType.ALCHEMY;
|
|
15
|
+
// this.updateDefault(BLOCKCHAINS.EVM, evmProvider);
|
|
16
|
+
// this.updateDefault(BLOCKCHAINS.SOLANA, solanaProvider);
|
|
17
|
+
// this.updateDefault(BLOCKCHAINS.TRON, tronProvider);
|
|
18
|
+
}
|
|
19
|
+
static getInstance() {
|
|
20
|
+
if (!this.instance) {
|
|
21
|
+
this.instance = new RPC();
|
|
22
|
+
}
|
|
23
|
+
return this.instance;
|
|
24
|
+
}
|
|
25
|
+
initialize(config) {
|
|
26
|
+
var _a, _b, _c;
|
|
27
|
+
if (this.initialized)
|
|
28
|
+
throw new Error(`RPC provider manager is already initialized. Use 'updateDefault' instead.`);
|
|
29
|
+
const evmProvider = ((_a = config === null || config === void 0 ? void 0 : config.config) === null || _a === void 0 ? void 0 : _a.defaultEvmRpcProviderType) ? config.config.defaultEvmRpcProviderType : Provider_1.RpcProviderType.ALCHEMY;
|
|
30
|
+
const solanaProvider = ((_b = config === null || config === void 0 ? void 0 : config.config) === null || _b === void 0 ? void 0 : _b.defaultSolRpcProviderType) ? config.config.defaultSolRpcProviderType : Provider_1.RpcProviderType.ALCHEMY;
|
|
31
|
+
const tronProvider = ((_c = config === null || config === void 0 ? void 0 : config.config) === null || _c === void 0 ? void 0 : _c.defaultTronRpcProviderType) ? config.config.defaultTronRpcProviderType : Provider_1.RpcProviderType.ALCHEMY;
|
|
32
|
+
this.updateDefault(constants_1.BLOCKCHAINS.EVM, evmProvider);
|
|
33
|
+
this.updateDefault(constants_1.BLOCKCHAINS.SOLANA, solanaProvider);
|
|
34
|
+
this.updateDefault(constants_1.BLOCKCHAINS.TRON, tronProvider);
|
|
35
|
+
this.initialized = true;
|
|
36
|
+
}
|
|
37
|
+
updateDefault(blockchainType, targetProvider) {
|
|
38
|
+
this.currentProvider.set(blockchainType, targetProvider);
|
|
39
|
+
}
|
|
40
|
+
getCurrentDefault(blockchainType) {
|
|
41
|
+
if (!this.initialized)
|
|
42
|
+
throw new Error(`RPC provider manager is not initialized`);
|
|
43
|
+
const current = this.currentProvider.get(blockchainType);
|
|
44
|
+
if (!current)
|
|
45
|
+
throw new Error(`RPC provider manager is not initialized`);
|
|
46
|
+
return current;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.default = RPC;
|
|
@@ -2,9 +2,16 @@ import { Connection, Keypair, PublicKey } from "@solana/web3.js";
|
|
|
2
2
|
import * as anchor from "@coral-xyz/anchor";
|
|
3
3
|
import { Escrow } from "./types/escrow";
|
|
4
4
|
import { BatchReceiver, SignAllTransactionsInterface, SignTransactionInterface } from "./types/types";
|
|
5
|
+
import { ChainId } from "../../../interfaces";
|
|
5
6
|
interface AdditionalConstructorParams {
|
|
6
7
|
signer_keypair?: Keypair;
|
|
7
8
|
localnet: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Address Lookup Table holding the batch path's static accounts. Supply it to send v0
|
|
11
|
+
* transactions, which is required for batches carrying more than two treasury signatures.
|
|
12
|
+
* Create it once with `create_lookup_table` and persist the returned address.
|
|
13
|
+
*/
|
|
14
|
+
lookup_table_address?: string;
|
|
8
15
|
}
|
|
9
16
|
declare class SolanaEscrowAdmin {
|
|
10
17
|
provider: anchor.AnchorProvider;
|
|
@@ -81,7 +88,40 @@ declare class SolanaEscrowAdmin {
|
|
|
81
88
|
* @returns string - transaction signature
|
|
82
89
|
*/
|
|
83
90
|
set_pause_state: (target_state: boolean) => Promise<string>;
|
|
84
|
-
withdraw_batch: (token_address: string, receivers: BatchReceiver[]) => Promise<string>;
|
|
91
|
+
withdraw_batch: (chain_id: ChainId, token_address: string, receivers: BatchReceiver[]) => Promise<string>;
|
|
92
|
+
/**
|
|
93
|
+
* Executes previously-scheduled (timelocked) withdrawals whose delay has elapsed. Amounts and
|
|
94
|
+
* recipients are read from each on-chain commitment, so only request ids + recipients are passed.
|
|
95
|
+
*/
|
|
96
|
+
batch_execute_withdrawal: (chain_id: ChainId, token_address: string, receivers: Array<{
|
|
97
|
+
request_id: number;
|
|
98
|
+
receiver_pubkey: PublicKey | string;
|
|
99
|
+
}>) => Promise<string>;
|
|
100
|
+
/** Simulate a batch withdraw (schedule/immediate) to detect requests that would revert. */
|
|
101
|
+
simulate_withdraw_batch: (chain_id: ChainId, token_address: string, receivers: BatchReceiver[]) => Promise<{
|
|
102
|
+
ok: boolean;
|
|
103
|
+
error: string | null;
|
|
104
|
+
}>;
|
|
105
|
+
/** Simulate a batch execute to detect requests that would revert (timelock, already executed). */
|
|
106
|
+
simulate_batch_execute_withdrawal: (chain_id: ChainId, token_address: string, receivers: Array<{
|
|
107
|
+
request_id: number;
|
|
108
|
+
receiver_pubkey: PublicKey | string;
|
|
109
|
+
}>) => Promise<{
|
|
110
|
+
ok: boolean;
|
|
111
|
+
error: string | null;
|
|
112
|
+
}>;
|
|
113
|
+
/**
|
|
114
|
+
* Idempotently ensures the batch path's Address Lookup Table exists and covers `mints`.
|
|
115
|
+
* Safe to call on every startup: it discovers an existing table on-chain, extends it when
|
|
116
|
+
* addresses are missing, and only creates one when none exists. Returns the address, or null
|
|
117
|
+
* when provisioning failed (callers then run on legacy transactions).
|
|
118
|
+
*
|
|
119
|
+
* `withdraw_batch` calls this automatically for signature-carrying batches, so wiring it into
|
|
120
|
+
* startup is about observability and warming, not correctness.
|
|
121
|
+
*/
|
|
122
|
+
ensure_lookup_table: (mints: string[]) => Promise<string>;
|
|
123
|
+
/** @deprecated prefer `ensure_lookup_table` — this throws instead of degrading gracefully. */
|
|
124
|
+
create_lookup_table: (mints: string[]) => Promise<string>;
|
|
85
125
|
/**
|
|
86
126
|
*
|
|
87
127
|
* @param token_address Address of the token to withdraw
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SolanaEscrowAdmin.d.ts","sourceRoot":"","sources":["../../../../src/services/solana/escrow/SolanaEscrowAdmin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAqC,MAAM,iBAAiB,CAAC;AAEpG,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAE,aAAa,EAAE,4BAA4B,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"SolanaEscrowAdmin.d.ts","sourceRoot":"","sources":["../../../../src/services/solana/escrow/SolanaEscrowAdmin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAqC,MAAM,iBAAiB,CAAC;AAEpG,OAAO,KAAK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,SAAS,GAAU,gBAAgB,MAAM,qBAE/C;IAGD;;;;OAIG;IACI,YAAY,GAAU,gBAAgB,MAAM,qBAElD;IAED;;;;OAIG;IACI,eAAe,GAAU,cAAc,OAAO,qBAEpD;IAIM,cAAc,GAAU,UAAU,OAAO,EAAE,eAAe,MAAM,EAAE,WAAW,aAAa,EAAE,qBAElG;IAED;;;OAGG;IACI,wBAAwB,GAC3B,UAAU,OAAO,EACjB,eAAe,MAAM,EACrB,WAAW,KAAK,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,SAAS,GAAG,MAAM,CAAA;KAAE,CAAC,qBAGhF;IAED,2FAA2F;IACpF,uBAAuB,GAAU,UAAU,OAAO,EAAE,eAAe,MAAM,EAAE,WAAW,aAAa,EAAE;;;OAE3G;IAED,kGAAkG;IAC3F,iCAAiC,GACpC,UAAU,OAAO,EACjB,eAAe,MAAM,EACrB,WAAW,KAAK,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,SAAS,GAAG,MAAM,CAAA;KAAE,CAAC;;;OAGhF;IAED;;;;;;;;OAQG;IACI,mBAAmB,GAAU,OAAO,MAAM,EAAE,qBAGlD;IAED,8FAA8F;IACvF,mBAAmB,GAAU,OAAO,MAAM,EAAE,qBAElD;IAGD;;;;;;OAMG;IACI,QAAQ,GAAU,eAAe,MAAM,EAAE,oBAAoB,MAAM,EAAE,kBAAkB,MAAM,iCAEnG;IAED;;;;;OAKG;IACI,OAAO,GAAU,eAAe,MAAM,EAAE,oBAAoB,MAAM,qBAExE;CAKJ;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -162,8 +162,40 @@ class SolanaEscrowAdmin {
|
|
|
162
162
|
this.set_pause_state = (target_state) => __awaiter(this, void 0, void 0, function* () {
|
|
163
163
|
return this.adminUtility.set_pause_state(target_state, this.signer);
|
|
164
164
|
});
|
|
165
|
-
this.withdraw_batch = (token_address, receivers) => __awaiter(this, void 0, void 0, function* () {
|
|
166
|
-
return this.adminUtility.withdraw_batch(token_address, receivers, this.signer);
|
|
165
|
+
this.withdraw_batch = (chain_id, token_address, receivers) => __awaiter(this, void 0, void 0, function* () {
|
|
166
|
+
return this.adminUtility.withdraw_batch(chain_id, token_address, receivers, this.signer);
|
|
167
|
+
});
|
|
168
|
+
/**
|
|
169
|
+
* Executes previously-scheduled (timelocked) withdrawals whose delay has elapsed. Amounts and
|
|
170
|
+
* recipients are read from each on-chain commitment, so only request ids + recipients are passed.
|
|
171
|
+
*/
|
|
172
|
+
this.batch_execute_withdrawal = (chain_id, token_address, receivers) => __awaiter(this, void 0, void 0, function* () {
|
|
173
|
+
return this.adminUtility.batch_execute_withdrawal(chain_id, token_address, receivers, this.signer);
|
|
174
|
+
});
|
|
175
|
+
/** Simulate a batch withdraw (schedule/immediate) to detect requests that would revert. */
|
|
176
|
+
this.simulate_withdraw_batch = (chain_id, token_address, receivers) => __awaiter(this, void 0, void 0, function* () {
|
|
177
|
+
return this.adminUtility.simulate_withdraw_batch(chain_id, token_address, receivers);
|
|
178
|
+
});
|
|
179
|
+
/** Simulate a batch execute to detect requests that would revert (timelock, already executed). */
|
|
180
|
+
this.simulate_batch_execute_withdrawal = (chain_id, token_address, receivers) => __awaiter(this, void 0, void 0, function* () {
|
|
181
|
+
return this.adminUtility.simulate_batch_execute_withdrawal(chain_id, token_address, receivers);
|
|
182
|
+
});
|
|
183
|
+
/**
|
|
184
|
+
* Idempotently ensures the batch path's Address Lookup Table exists and covers `mints`.
|
|
185
|
+
* Safe to call on every startup: it discovers an existing table on-chain, extends it when
|
|
186
|
+
* addresses are missing, and only creates one when none exists. Returns the address, or null
|
|
187
|
+
* when provisioning failed (callers then run on legacy transactions).
|
|
188
|
+
*
|
|
189
|
+
* `withdraw_batch` calls this automatically for signature-carrying batches, so wiring it into
|
|
190
|
+
* startup is about observability and warming, not correctness.
|
|
191
|
+
*/
|
|
192
|
+
this.ensure_lookup_table = (mints) => __awaiter(this, void 0, void 0, function* () {
|
|
193
|
+
const table = yield this.adminUtility.ensure_lookup_table(mints, this.signer);
|
|
194
|
+
return table.toBase58();
|
|
195
|
+
});
|
|
196
|
+
/** @deprecated prefer `ensure_lookup_table` — this throws instead of degrading gracefully. */
|
|
197
|
+
this.create_lookup_table = (mints) => __awaiter(this, void 0, void 0, function* () {
|
|
198
|
+
return this.adminUtility.create_lookup_table(mints, this.signer);
|
|
167
199
|
});
|
|
168
200
|
/**
|
|
169
201
|
*
|
|
@@ -205,7 +237,7 @@ class SolanaEscrowAdmin {
|
|
|
205
237
|
const program = new anchor.Program(target_idl, provider);
|
|
206
238
|
this.program = program;
|
|
207
239
|
this.provider = provider;
|
|
208
|
-
this.adminUtility = EscrowAdminUtility_1.default.createWithCustomProgramId(provider, new web3_js_1.PublicKey(escrowAddress), this.get_idl());
|
|
240
|
+
this.adminUtility = EscrowAdminUtility_1.default.createWithCustomProgramId(provider, new web3_js_1.PublicKey(escrowAddress), this.get_idl(), additionalParams === null || additionalParams === void 0 ? void 0 : additionalParams.lookup_table_address);
|
|
209
241
|
if (additionalParams === null || additionalParams === void 0 ? void 0 : additionalParams.signer_keypair)
|
|
210
242
|
this.signer = additionalParams.signer_keypair;
|
|
211
243
|
}
|