@argonprotocol/testing 1.4.3-dev.43df9563 → 1.4.3-dev.4544e954

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/lib/index.d.cts CHANGED
@@ -1,6 +1,29 @@
1
- import { KeyringPair, ArgonClient } from '@argonprotocol/mainchain';
1
+ import * as _argonprotocol_mainchain from '@argonprotocol/mainchain';
2
+ import { KeyringPair, ArgonClient, EthereumReceipt, EthereumBeaconHeaderDetailsResponse, EthereumBeaconBlockResponse, EvmContracts, IArgonQueryable } from '@argonprotocol/mainchain';
2
3
  import { Client } from 'pg';
3
- import Client$1 from 'bitcoin-core';
4
+ import * as viem from 'viem';
5
+ import { Hex, createWalletClient, defineChain, Address, ContractFunctionArgs } from 'viem';
6
+ import { privateKeyToAccount } from 'viem/accounts';
7
+ import * as _polkadot_types_codec from '@polkadot/types-codec';
8
+
9
+ interface ITeardownable {
10
+ teardown(): Promise<void>;
11
+ }
12
+ declare const SKIP_E2E: boolean;
13
+ declare function getProxy(): Promise<string>;
14
+ declare function projectRoot(): string;
15
+ declare function runTestScript(relativePath: string): Promise<string>;
16
+ declare function getDockerPortMapping(containerName: string, port: number): Promise<string | undefined>;
17
+ declare function teardown(): Promise<void>;
18
+ declare function cleanHostForDocker(host: string, replacer?: string): string;
19
+ declare function addTeardown(teardownable: ITeardownable): void;
20
+ declare function runOnTeardown(teardown: () => Promise<void>): void;
21
+ declare function closeOnTeardown<T extends {
22
+ close(): Promise<void>;
23
+ }>(closeable: T): T;
24
+ declare function disconnectOnTeardown<T extends {
25
+ disconnect(): Promise<void>;
26
+ }>(closeable: T): T;
4
27
 
5
28
  declare class TestNotary implements ITeardownable {
6
29
  #private;
@@ -36,7 +59,7 @@ declare class TestMainchain implements ITeardownable {
36
59
  bitcoinPort?: number;
37
60
  get address(): string;
38
61
  constructor(binPath?: string);
39
- getBitcoinClient(): Client$1;
62
+ getBitcoinClient(): BitcoinRpcClient;
40
63
  /**
41
64
  * Launch and return the localhost url. NOTE: this url will not work cross-docker. You need to use the containerAddress property
42
65
  * @param options
@@ -54,6 +77,48 @@ declare class TestMainchain implements ITeardownable {
54
77
  teardown(): Promise<void>;
55
78
  private startBitcoin;
56
79
  }
80
+ declare class BitcoinRpcClient {
81
+ #private;
82
+ constructor(rpcUrl: string, username: string, password: string);
83
+ command<TMethod extends BitcoinRpcMethod>(method: TMethod, ...params: Parameters<BitcoinRpcMethods[TMethod]>): Promise<ReturnType<BitcoinRpcMethods[TMethod]>>;
84
+ command<TResult = unknown>(method: string, ...params: unknown[]): Promise<TResult>;
85
+ }
86
+ type BitcoinRpcMethod = keyof BitcoinRpcMethods;
87
+ type BitcoinRpcMethods = {
88
+ createwallet(walletName: string): unknown;
89
+ loadwallet(walletName: string): unknown;
90
+ getnewaddress(): string;
91
+ generatetoaddress(blockCount: number, address: string): unknown;
92
+ getbalances(): unknown;
93
+ walletcreatefundedpsbt(inputs: unknown[], outputs: Record<string, number>, locktime: number, options: BitcoinWalletCreateFundedPsbtOptions): BitcoinFundedPsbtResult;
94
+ walletprocesspsbt(psbt: string): BitcoinProcessedPsbtResult;
95
+ decodepsbt(psbt: string): BitcoinDecodedPsbtResult;
96
+ finalizepsbt(psbt: string): BitcoinFinalizedPsbtResult;
97
+ sendrawtransaction(transactionHex: string): string;
98
+ getrawtransaction(txid: string, verbose: true): BitcoinRawTransactionResult;
99
+ gettransaction(txid: string): unknown;
100
+ };
101
+ type BitcoinWalletCreateFundedPsbtOptions = {
102
+ lockUnspents?: boolean;
103
+ feeRate?: number;
104
+ };
105
+ type BitcoinFundedPsbtResult = {
106
+ psbt: string;
107
+ };
108
+ type BitcoinProcessedPsbtResult = {
109
+ psbt: string;
110
+ complete: boolean;
111
+ };
112
+ type BitcoinDecodedPsbtResult = {
113
+ inputs?: unknown[];
114
+ };
115
+ type BitcoinFinalizedPsbtResult = {
116
+ hex: string;
117
+ txid?: string;
118
+ };
119
+ type BitcoinRawTransactionResult = {
120
+ txid: string;
121
+ };
57
122
 
58
123
  declare class TestBitcoinCli {
59
124
  /**
@@ -78,6 +143,51 @@ declare class TestOracle implements ITeardownable {
78
143
  teardown(): Promise<void>;
79
144
  }
80
145
 
146
+ interface EthereumEndpoints {
147
+ executionRpcUrl: string;
148
+ beaconApiUrl: string;
149
+ chainId: string;
150
+ }
151
+ interface EthereumMintingGatewayFixture {
152
+ argonTokenAddress: Hex;
153
+ argonotTokenAddress: Hex;
154
+ gatewayAddress: Hex;
155
+ }
156
+ interface EthereumPrefundedAccount {
157
+ balance: string;
158
+ }
159
+ type EthereumConsensusClient = 'lighthouse' | 'lodestar';
160
+ type EthereumBeaconPreset = 'mainnet' | 'minimal';
161
+ declare class TestEthereum implements ITeardownable {
162
+ #private;
163
+ readonly enclaveName: string;
164
+ readonly kurtosisBin: string;
165
+ readonly packageRef: string;
166
+ executionRpcUrl?: string;
167
+ beaconApiUrl?: string;
168
+ chainId?: string;
169
+ constructor(enclaveName?: string, kurtosisBin?: string, packageRef?: string);
170
+ static isInstalled(kurtosisBin?: string): boolean;
171
+ launch(options?: {
172
+ consensusClient?: EthereumConsensusClient;
173
+ preset?: EthereumBeaconPreset;
174
+ secondsPerSlot?: number;
175
+ waitForFinalization?: boolean;
176
+ prefundedAccounts?: Record<string, EthereumPrefundedAccount>;
177
+ }): Promise<EthereumEndpoints>;
178
+ callExecution<TResult>(method: string, params?: unknown[]): Promise<TResult>;
179
+ getBeacon<TResult>(path: string): Promise<TResult>;
180
+ deployMintingGatewayFixture(options: {
181
+ deployerPrivateKey: Hex;
182
+ adminSafe?: Hex;
183
+ guardianSafe?: Hex;
184
+ initialMicrogonsPerArgonot?: bigint;
185
+ seedArgonRecipient?: Hex;
186
+ seedArgonAmountBaseUnits?: bigint;
187
+ }): Promise<EthereumMintingGatewayFixture>;
188
+ teardown(): Promise<void>;
189
+ }
190
+
81
191
  declare function startNetwork(testName: string, options?: {
82
192
  shouldLog: boolean;
83
193
  dockerEnv?: Record<string, string>;
@@ -86,30 +196,234 @@ declare function startNetwork(testName: string, options?: {
86
196
  notaryUrl: string;
87
197
  }>;
88
198
 
89
- interface ITeardownable {
90
- teardown(): Promise<void>;
199
+ declare function signGatewayPermit(args: {
200
+ account: ReturnType<typeof privateKeyToAccount>;
201
+ chainId: number;
202
+ tokenAddress: Hex;
203
+ gatewayAddress: Hex;
204
+ owner: Hex;
205
+ value: bigint;
206
+ nonce: bigint;
207
+ deadline: bigint;
208
+ }): Promise<{
209
+ v: number;
210
+ r: `0x${string}`;
211
+ s: `0x${string}`;
212
+ }>;
213
+ declare function waitForFinalizedBeaconExecutionAtOrAbove(ethereum: TestEthereum, minimumExecutionBlockNumber: bigint, options?: {
214
+ minimumFinalizedSlot?: bigint;
215
+ }): Promise<{
216
+ header: EthereumBeaconHeaderDetailsResponse;
217
+ block: EthereumBeaconBlockResponse;
218
+ }>;
219
+ declare function mineLaterExecutionAnchorReceipt(walletClient: Pick<ReturnType<typeof createWalletClient>, 'sendTransaction'>, chain: ReturnType<typeof defineChain>, ethereum: TestEthereum, account: ReturnType<typeof privateKeyToAccount>, minimumBlockNumber: bigint): Promise<viem.TransactionReceipt>;
220
+ declare function waitForExecutionReceipt(ethereum: TestEthereum, transactionHash: Hex): Promise<EthereumReceipt>;
221
+ declare function syncEthereumVerifierUntilAnchorCovers(mainchainClient: ArgonClient, relayer: KeyringPair, beaconApiUrl: string, minimumExecutionBlockNumber: bigint): Promise<void>;
222
+ declare function toArgonKeccakSignature(signature: Hex): Hex;
223
+ declare function toEvmRecoverableSignature(signature: Hex): Hex;
224
+
225
+ type ApplyGatewayUpdatesArgs = ContractFunctionArgs<typeof EvmContracts.mintingGatewayAbi, 'nonpayable', 'applyGatewayUpdates'>;
226
+ type MintingGatewayCouncilSnapshot = ApplyGatewayUpdatesArgs[0];
227
+ type MintingGatewayGatewayUpdate = ApplyGatewayUpdatesArgs[1][number];
228
+ type EthereumGatewayUpdateBatch = {
229
+ destinationChain: 'Ethereum';
230
+ chainId: bigint;
231
+ gatewayAddress: Address;
232
+ currentCouncilHash: Hex;
233
+ currentCouncil: MintingGatewayCouncilSnapshot;
234
+ argonApprovalsNonce: bigint;
235
+ argonApprovalsHash: Hex;
236
+ paused: boolean;
237
+ pendingClearOutQueueNonces: bigint[];
238
+ firstQueueNonce?: bigint;
239
+ lastQueueNonce?: bigint;
240
+ updates: MintingGatewayGatewayUpdate[];
241
+ };
242
+ declare function getReadyEthereumGatewayUpdates(client: IArgonQueryable, gatewayClient: {
243
+ readContract: (...args: any[]) => Promise<unknown>;
244
+ }, options?: {
245
+ destinationChain?: 'Ethereum';
246
+ maxQueueEntries?: number;
247
+ }): Promise<EthereumGatewayUpdateBatch>;
248
+
249
+ type DeployerAccount = ReturnType<typeof privateKeyToAccount>;
250
+ type EthereumChain = ReturnType<typeof defineChain>;
251
+ type EthereumPublicClient = {
252
+ getBalance: (args: {
253
+ address: Hex;
254
+ }) => Promise<bigint>;
255
+ getBlock: (...args: any[]) => Promise<any>;
256
+ getBlockNumber: () => Promise<bigint>;
257
+ readContract: (...args: any[]) => Promise<unknown>;
258
+ waitForTransactionReceipt: (args: {
259
+ hash: Hex;
260
+ }) => Promise<{
261
+ status: string;
262
+ blockNumber: bigint;
263
+ }>;
264
+ };
265
+ type EthereumWalletClient = {
266
+ sendTransaction: (...args: any[]) => Promise<Hex>;
267
+ writeContract: (...args: any[]) => Promise<Hex>;
268
+ };
269
+ type GatewayDeployment = Awaited<ReturnType<TestEthereum['deployMintingGatewayFixture']>>;
270
+ type RuntimeSetupMode = {
271
+ kind: 'inbound-only';
272
+ } | {
273
+ kind: 'outbound';
274
+ activationPricing: {
275
+ activationGasCost: bigint | number;
276
+ signatureGasCost: bigint | number;
277
+ estimatedWeiPerGas: bigint | number;
278
+ estimatedMicrogonsPerEth: bigint | number;
279
+ };
280
+ minimumMintingAuthorityValue?: bigint;
281
+ };
282
+ declare class EthereumProofE2eHarness {
283
+ readonly ethereum: TestEthereum;
284
+ readonly endpoints: Awaited<ReturnType<TestEthereum['launch']>>;
285
+ readonly mainchain: TestMainchain;
286
+ readonly sudoSigner: KeyringPair;
287
+ readonly deployer: DeployerAccount;
288
+ readonly chain: EthereumChain;
289
+ readonly publicClient: EthereumPublicClient;
290
+ readonly walletClient: EthereumWalletClient;
291
+ readonly mainchainClient: ArgonClient;
292
+ readonly proofRelayer: KeyringPair;
293
+ private constructor();
294
+ static launch(args: {
295
+ testAccount: {
296
+ address: Hex;
297
+ balance: string;
298
+ privateKey: Hex;
299
+ };
300
+ proofRelayerUri: string;
301
+ }): Promise<EthereumProofE2eHarness>;
302
+ submit(tx: unknown, signer: KeyringPair): Promise<_argonprotocol_mainchain.TxResult>;
303
+ sudoSubmit(tx: unknown): Promise<_argonprotocol_mainchain.TxResult>;
304
+ syncVerifierThrough(minimumExecutionBlockNumber: bigint): Promise<void>;
305
+ proveGatewayActivity(gatewayAddress: Hex, throughExecutionBlockNumber: bigint): Promise<{
306
+ payload: _argonprotocol_mainchain.EthereumGatewayActivityProofPayload;
307
+ result: _argonprotocol_mainchain.TxResult;
308
+ }>;
309
+ configureEthereumRuntime(gateway: TestMintingGateway, mode: RuntimeSetupMode): Promise<{
310
+ result: _argonprotocol_mainchain.TxResult;
311
+ }>;
312
+ fundBurnAccount(amount: bigint): Promise<_argonprotocol_mainchain.TxResult>;
313
+ fundProofRelayer(amount?: bigint): Promise<_argonprotocol_mainchain.TxResult>;
314
+ forceSetBalance(address: string, amount: bigint): Promise<_argonprotocol_mainchain.TxResult>;
315
+ forceSetOwnership(address: string, amount: bigint): Promise<_argonprotocol_mainchain.TxResult>;
316
+ waitForExecutionFinalizedAfter(minimumExecutionBlockNumber: bigint): Promise<viem.TransactionReceipt>;
91
317
  }
92
- declare const SKIP_E2E: boolean;
93
- declare function getProxy(): Promise<string>;
318
+ declare class TestMintingGateway {
319
+ readonly harness: EthereumProofE2eHarness;
320
+ readonly deployment: GatewayDeployment;
321
+ private constructor();
322
+ static deploy(harness: EthereumProofE2eHarness, options: Parameters<TestEthereum['deployMintingGatewayFixture']>[0]): Promise<TestMintingGateway>;
323
+ get gatewayAddress(): `0x${string}`;
324
+ get argonTokenAddress(): `0x${string}`;
325
+ get argonotTokenAddress(): `0x${string}`;
326
+ startTransferToArgon(args: {
327
+ account: DeployerAccount;
328
+ amountRuntimeUnits: bigint;
329
+ recipientArgonAddress: Hex;
330
+ }): Promise<viem.TransactionReceipt>;
331
+ forceUpdateActiveCouncil(replacementCouncil: {
332
+ signers: Hex[];
333
+ weights: bigint[];
334
+ }, nextMicrogonsPerArgonot: bigint): Promise<{
335
+ status: string;
336
+ blockNumber: bigint;
337
+ }>;
338
+ relayReadyApprovals(batch: Awaited<ReturnType<typeof getReadyEthereumGatewayUpdates>>, operatorAddress: string): Promise<{
339
+ status: string;
340
+ blockNumber: bigint;
341
+ }>;
342
+ argonApprovalsNonce(): Promise<bigint>;
343
+ globalIssuanceCouncil(): Promise<[Hex[], bigint[], Hex]>;
344
+ authorityCollateral(signingKey: Hex): Promise<[bigint, bigint]>;
345
+ finalizeTransferOut(args: {
346
+ transferRequest: {
347
+ argonAccountId: Hex;
348
+ argonTransferNonce: bigint;
349
+ chainId: bigint;
350
+ microgonsPerArgonot: bigint;
351
+ recipient: Hex;
352
+ validUntilBlock: bigint;
353
+ token: Hex;
354
+ amount: bigint;
355
+ mintingAuthorityTip: bigint;
356
+ };
357
+ collateralizationSignature: Hex;
358
+ micronotCollateral: bigint;
359
+ }): Promise<{
360
+ status: string;
361
+ blockNumber: bigint;
362
+ }>;
363
+ isFinalizedTransferOut(transferRequest: Parameters<typeof EvmContracts.hashMintingGatewayTransferOutOfArgonRequest>[0]): Promise<boolean>;
364
+ argonBalance(address: Hex): Promise<bigint>;
365
+ fundExecutionAccount(address: Hex, value: bigint): Promise<{
366
+ status: string;
367
+ blockNumber: bigint;
368
+ }>;
369
+ }
370
+ declare class TestMintingAuthorityActor {
371
+ readonly harness: EthereumProofE2eHarness;
372
+ readonly operator: KeyringPair;
373
+ readonly councilSigner: DeployerAccount;
374
+ readonly authoritySigner: DeployerAccount;
375
+ private gateway?;
376
+ constructor(harness: EthereumProofE2eHarness, args: {
377
+ operatorUri: string;
378
+ councilPrivateKey: Hex;
379
+ authorityPrivateKey: Hex;
380
+ });
381
+ attachGateway(gateway: TestMintingGateway): void;
382
+ prepareOperator(args: {
383
+ freeBalance: bigint;
384
+ ownershipBalance: bigint;
385
+ committedArgonots: bigint;
386
+ bitcoinXpub: string;
387
+ }): Promise<void>;
388
+ registerCouncilSigner(): Promise<_argonprotocol_mainchain.TxResult>;
389
+ forceSingleMemberCouncil(): Promise<{
390
+ activeCouncilHash: `0x${string}`;
391
+ activeCouncil: _argonprotocol_mainchain.PalletCrosschainTransferGlobalIssuanceCouncil;
392
+ currentCouncil: {
393
+ signers: `0x${string}`[];
394
+ weights: bigint[];
395
+ };
396
+ }>;
397
+ registerMintingAuthority(micronotCollateral: bigint): Promise<_argonprotocol_mainchain.TxResult>;
398
+ approveActivationQueueEntry(queueNonce?: bigint): Promise<{
399
+ approvalQueueEntry: _polkadot_types_codec.Option<_argonprotocol_mainchain.PalletCrosschainTransferCouncilApprovalQueueEntry>;
400
+ councilApprovalSignature: `0x${string}`;
401
+ batch: EthereumGatewayUpdateBatch;
402
+ }>;
403
+ collateralizeFirstPendingTransferOut(): Promise<{
404
+ pendingRequest: _argonprotocol_mainchain.PalletCrosschainTransferTransferOutPendingCollateralizationRequest;
405
+ transferId: `0x${string}`;
406
+ transferRequest: {
407
+ argonAccountId: `0x${string}`;
408
+ argonTransferNonce: bigint;
409
+ chainId: bigint;
410
+ microgonsPerArgonot: bigint;
411
+ recipient: `0x${string}`;
412
+ validUntilBlock: bigint;
413
+ token: `0x${string}`;
414
+ amount: bigint;
415
+ mintingAuthorityTip: bigint;
416
+ };
417
+ micronotCollateral: bigint;
418
+ collateralizationSignature: `0x${string}`;
419
+ result: _argonprotocol_mainchain.TxResult;
420
+ }>;
421
+ private registrationMessage;
422
+ private requireGateway;
423
+ }
424
+
94
425
  declare function stringifyExt(obj: any): any;
95
- declare function projectRoot(): string;
96
- /**
97
- * Run a script from the project "scripts" folder
98
- * @param relativePath
99
- */
100
- declare function runTestScript(relativePath: string): Promise<string>;
101
- declare function getDockerPortMapping(containerName: string, port: number): Promise<string | undefined>;
102
- declare function teardown(): Promise<void>;
103
- declare function cleanHostForDocker(host: string, replacer?: string): string;
104
- declare function addTeardown(teardownable: ITeardownable): void;
105
- declare function runOnTeardown(teardown: () => Promise<void>): void;
106
- declare function closeOnTeardown<T extends {
107
- close(): Promise<void>;
108
- }>(closeable: T): T;
109
- declare function disconnectOnTeardown<T extends {
110
- disconnect(): Promise<void>;
111
- }>(closeable: T): T;
112
426
  declare function sudo(): KeyringPair;
113
427
  declare function activateNotary(sudo: KeyringPair, client: ArgonClient, notary: TestNotary): Promise<void>;
114
428
 
115
- export { type ITeardownable, SKIP_E2E, TestBitcoinCli, TestMainchain, TestNotary, TestOracle, activateNotary, addTeardown, cleanHostForDocker, closeOnTeardown, disconnectOnTeardown, getDockerPortMapping, getProxy, projectRoot, runOnTeardown, runTestScript, startNetwork, stringifyExt, sudo, teardown };
429
+ export { type EthereumGatewayUpdateBatch, EthereumProofE2eHarness, type ITeardownable, SKIP_E2E, TestBitcoinCli, TestEthereum, TestMainchain, TestMintingAuthorityActor, TestMintingGateway, TestNotary, TestOracle, activateNotary, addTeardown, cleanHostForDocker, closeOnTeardown, disconnectOnTeardown, getDockerPortMapping, getProxy, getReadyEthereumGatewayUpdates, mineLaterExecutionAnchorReceipt, projectRoot, runOnTeardown, runTestScript, signGatewayPermit, startNetwork, stringifyExt, sudo, syncEthereumVerifierUntilAnchorCovers, teardown, toArgonKeccakSignature, toEvmRecoverableSignature, waitForExecutionReceipt, waitForFinalizedBeaconExecutionAtOrAbove };