@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
|
@@ -3,10 +3,47 @@ import { Program } from "@coral-xyz/anchor";
|
|
|
3
3
|
import { Commitment, Keypair, PublicKey, TransactionSignature } from "@solana/web3.js";
|
|
4
4
|
import { Escrow } from "../types/escrow";
|
|
5
5
|
import { BatchReceiver } from "../types/types";
|
|
6
|
+
import { ChainId } from "../../../../interfaces";
|
|
6
7
|
export declare class EscrowAdminUtility {
|
|
7
8
|
program: Program<Escrow>;
|
|
8
9
|
provider: anchor.AnchorProvider;
|
|
9
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Optional Address Lookup Table. When set, transactions are sent as v0 and the batch path's
|
|
12
|
+
* ~11 static accounts collapse from 32 bytes each to a 1-byte index — roughly 300 bytes back,
|
|
13
|
+
* which is what makes >2 treasury signatures fit under the 1232-byte limit.
|
|
14
|
+
*/
|
|
15
|
+
private lookupTableAddress?;
|
|
16
|
+
private lookupTableCache?;
|
|
17
|
+
constructor(program: Program<Escrow>, provider: anchor.AnchorProvider, lookupTableAddress?: string);
|
|
18
|
+
/** Accounts that are identical on every batch withdrawal — the ALT payload. */
|
|
19
|
+
lookup_table_addresses(mints: string[]): PublicKey[];
|
|
20
|
+
/**
|
|
21
|
+
* Idempotently guarantees a lookup table covering `mints` exists and is usable.
|
|
22
|
+
*
|
|
23
|
+
* Deliberately keeps no external state: tables are discovered on-chain by their authority
|
|
24
|
+
* (the funding wallet), so there is nothing to persist, migrate, or keep in sync across
|
|
25
|
+
* environments and worker instances. Extends a table that is missing addresses, creates one
|
|
26
|
+
* when none exists, and returns the usable address.
|
|
27
|
+
*
|
|
28
|
+
* Returns null if provisioning fails — the lookup table is an optimisation, so callers fall
|
|
29
|
+
* back to legacy transactions rather than failing a withdrawal that would otherwise succeed.
|
|
30
|
+
*/
|
|
31
|
+
ensure_lookup_table(mints: string[], signer?: Keypair): Promise<PublicKey>;
|
|
32
|
+
/** Back-compat wrapper for explicit one-time provisioning; prefer `ensure_lookup_table`. */
|
|
33
|
+
create_lookup_table(mints: string[], signer?: Keypair): Promise<string>;
|
|
34
|
+
private fetchLookupTable;
|
|
35
|
+
/**
|
|
36
|
+
* Finds a live table already owned by this authority. `getProgramAccounts` is filtered
|
|
37
|
+
* server-side on the authority pubkey, which sits at a fixed offset in the table header:
|
|
38
|
+
* u32 typeIndex + u64 deactivationSlot + u64 lastExtendedSlot + u8 startIndex + u8 option tag.
|
|
39
|
+
*/
|
|
40
|
+
private discoverLookupTable;
|
|
41
|
+
private missingAddresses;
|
|
42
|
+
private createLookupTable;
|
|
43
|
+
private extendLookupTable;
|
|
44
|
+
private waitForLookupTableActivation;
|
|
45
|
+
/** Resolves (and caches) the configured lookup table; [] when none is set or it's missing. */
|
|
46
|
+
private resolveLookupTables;
|
|
10
47
|
/**
|
|
11
48
|
* Check if the escrow program is paused or running
|
|
12
49
|
* @returns true/false. True: program is paused. False: Program is running
|
|
@@ -84,15 +121,89 @@ export declare class EscrowAdminUtility {
|
|
|
84
121
|
/**
|
|
85
122
|
* Accepts an array of receivers and amounts and performs a batch withdrawal to the specified receivers
|
|
86
123
|
* for the specified token (SOL or SPL)
|
|
124
|
+
* @param chain_id Network's chain id
|
|
87
125
|
* @param token_address Address of the token to withdraw
|
|
88
126
|
* @param recipients Array of receivers and their amounts
|
|
89
127
|
* @param signer optional signer keypair
|
|
90
128
|
* @returns string - signature
|
|
91
129
|
*/
|
|
92
|
-
withdraw_batch(token_address: string, recipients: BatchReceiver[], signer?: Keypair): Promise<string>;
|
|
130
|
+
withdraw_batch(chain_id: ChainId, token_address: string, recipients: BatchReceiver[], signer?: Keypair): Promise<string>;
|
|
131
|
+
/**
|
|
132
|
+
* Executes previously-scheduled (timelocked) withdrawals whose delay has elapsed. The amounts
|
|
133
|
+
* and recipient are read from each commitment on-chain, so only the request ids + their
|
|
134
|
+
* commitment/recipient accounts are supplied. Pays out and closes each commitment.
|
|
135
|
+
*
|
|
136
|
+
* Sent as a v0 transaction over the escrow lookup table: a batch's per-request accounts
|
|
137
|
+
* (commitment + recipient [+ ATA]) plus the static config accounts overflow a legacy
|
|
138
|
+
* transaction beyond a handful of requests, so we reuse the same ALT as the withdraw path.
|
|
139
|
+
*/
|
|
140
|
+
batch_execute_withdrawal(chain_id: ChainId, token_address: string, receivers: Array<{
|
|
141
|
+
request_id: number;
|
|
142
|
+
receiver_pubkey: PublicKey | string;
|
|
143
|
+
}>, signer?: Keypair): Promise<string>;
|
|
144
|
+
/** Builds the SOL batch-execute instruction. Shared by the send and simulate paths. */
|
|
145
|
+
private build_batch_execute_sol_ixs;
|
|
146
|
+
/** Builds the SPL batch-execute instruction. Shared by the send and simulate paths. */
|
|
147
|
+
private build_batch_execute_spl_ixs;
|
|
148
|
+
private batch_execute_withdrawal_sol;
|
|
149
|
+
private batch_execute_withdrawal_spl;
|
|
150
|
+
/**
|
|
151
|
+
* Simulates a batch execute without sending, returning `{ ok, error }`. The funding worker
|
|
152
|
+
* uses it to quarantine requests that would revert (timelock not elapsed, commitment already
|
|
153
|
+
* executed, …) before committing the real batch — the program reverts the whole transaction
|
|
154
|
+
* without naming the offending request, so callers simulate one request at a time.
|
|
155
|
+
*/
|
|
156
|
+
simulate_batch_execute_withdrawal(chain_id: ChainId, token_address: string, receivers: Array<{
|
|
157
|
+
request_id: number;
|
|
158
|
+
receiver_pubkey: PublicKey | string;
|
|
159
|
+
}>): Promise<{
|
|
160
|
+
ok: boolean;
|
|
161
|
+
error: string | null;
|
|
162
|
+
}>;
|
|
163
|
+
/**
|
|
164
|
+
* Builds an (unsigned) transaction from `ixs` and simulates it. Returns `{ ok:false, error }`
|
|
165
|
+
* with the revert reason from the program logs when it would fail. `sigVerify:false` skips the
|
|
166
|
+
* missing fee-payer signature; the Ed25519 program instruction still executes, so invalid or
|
|
167
|
+
* insufficient treasury signatures are caught here too.
|
|
168
|
+
*/
|
|
169
|
+
private simulateInstructions;
|
|
170
|
+
/** Per-request PDAs the folded batch path expects: receiver timelock override + commitment. */
|
|
171
|
+
private request_pdas;
|
|
172
|
+
/** Matches the program's IDS_PER_PAGE — the replay-bitmap page a request id maps to. */
|
|
173
|
+
private static readonly IDS_PER_PAGE;
|
|
174
|
+
/**
|
|
175
|
+
* The distinct replay-bitmap page accounts a batch touches. The program appends these AFTER
|
|
176
|
+
* the per-request accounts and locates each request's page by key, so a page shared by several
|
|
177
|
+
* requests is passed once. Metas are writable (the program may create/flip bits) and non-signer.
|
|
178
|
+
*/
|
|
179
|
+
private bitmap_page_accounts;
|
|
180
|
+
/**
|
|
181
|
+
* Builds the Ed25519SigVerify instruction the program scans to enforce treasury multisig.
|
|
182
|
+
* Each request contributes its signers' approvals over that request's message (which binds
|
|
183
|
+
* the committed amount + token + chain + request id). Returns null when no request carries
|
|
184
|
+
* signatures, so plain batches send just the withdraw instruction.
|
|
185
|
+
*/
|
|
186
|
+
private buildBatchTreasuryEd25519;
|
|
187
|
+
/**
|
|
188
|
+
* Builds the instruction list for an SPL batch withdraw: an optional treasury Ed25519 proof
|
|
189
|
+
* followed by the batch instruction. Shared by the send and simulate paths so they never drift.
|
|
190
|
+
*/
|
|
191
|
+
private build_batch_withdraw_spl_ixs;
|
|
93
192
|
/** @dev this might fail if the recipient does not have an ATA - take care of it in funding worker task */
|
|
94
193
|
private batch_withdraw_spl;
|
|
194
|
+
/** Builds the instruction list for a SOL batch withdraw (optional treasury proof + batch ix). */
|
|
195
|
+
private build_batch_withdraw_sol_ixs;
|
|
95
196
|
private batch_withdraw_sol;
|
|
197
|
+
/**
|
|
198
|
+
* Simulates a batch withdraw without sending, returning `{ ok, error }`. Used by the funding
|
|
199
|
+
* worker to quarantine individual requests that would revert (bad/insufficient signatures,
|
|
200
|
+
* already scheduled, …) before committing the real batch — the program reverts the whole
|
|
201
|
+
* transaction without naming the offending request, so callers simulate one request at a time.
|
|
202
|
+
*/
|
|
203
|
+
simulate_withdraw_batch(chain_id: ChainId, token_address: string, recipients: BatchReceiver[]): Promise<{
|
|
204
|
+
ok: boolean;
|
|
205
|
+
error: string | null;
|
|
206
|
+
}>;
|
|
96
207
|
private withdraw_sol;
|
|
97
208
|
private withdraw_spl;
|
|
98
209
|
private deposit_sol;
|
|
@@ -100,6 +211,8 @@ export declare class EscrowAdminUtility {
|
|
|
100
211
|
getVaultBalance(): Promise<number>;
|
|
101
212
|
getVaultTokenBalance(mint: PublicKey): Promise<number>;
|
|
102
213
|
private sendTransaction;
|
|
214
|
+
private sendVersionedTransaction;
|
|
215
|
+
private sendLegacyTransaction;
|
|
103
216
|
confirmTransaction(signature: string, commitment?: Commitment): Promise<void>;
|
|
104
217
|
waitForConfirmation(signature: TransactionSignature, commitment?: 'confirmed' | 'finalized', timeoutMs?: number): Promise<void>;
|
|
105
218
|
/**
|
|
@@ -116,7 +229,7 @@ export declare class EscrowAdminUtility {
|
|
|
116
229
|
* @param idl IDL file - Escrow program idl
|
|
117
230
|
* @returns
|
|
118
231
|
*/
|
|
119
|
-
static createWithCustomProgramId(provider: anchor.AnchorProvider, programId: PublicKey, idl: anchor.Idl): EscrowAdminUtility;
|
|
232
|
+
static createWithCustomProgramId(provider: anchor.AnchorProvider, programId: PublicKey, idl: anchor.Idl, lookupTableAddress?: string): EscrowAdminUtility;
|
|
120
233
|
}
|
|
121
234
|
export default EscrowAdminUtility;
|
|
122
235
|
//# sourceMappingURL=EscrowAdminUtility.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EscrowAdminUtility.d.ts","sourceRoot":"","sources":["../../../../../src/services/solana/escrow/services/EscrowAdminUtility.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,OAAO,EA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