@imtbl/sdk 0.1.6 → 0.1.7-alpha.2

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.
@@ -0,0 +1,986 @@
1
+ /// <reference types="node" />
2
+ declare type Bytes = ArrayLike<number>;
3
+ declare type BytesLike = Bytes | string;
4
+ interface Hexable {
5
+ toHexString(): string;
6
+ }
7
+
8
+ declare type BigNumberish = BigNumber | Bytes | bigint | string | number;
9
+ declare class BigNumber implements Hexable {
10
+ readonly _hex: string;
11
+ readonly _isBigNumber: boolean;
12
+ constructor(constructorGuard: any, hex: string);
13
+ fromTwos(value: number): BigNumber;
14
+ toTwos(value: number): BigNumber;
15
+ abs(): BigNumber;
16
+ add(other: BigNumberish): BigNumber;
17
+ sub(other: BigNumberish): BigNumber;
18
+ div(other: BigNumberish): BigNumber;
19
+ mul(other: BigNumberish): BigNumber;
20
+ mod(other: BigNumberish): BigNumber;
21
+ pow(other: BigNumberish): BigNumber;
22
+ and(other: BigNumberish): BigNumber;
23
+ or(other: BigNumberish): BigNumber;
24
+ xor(other: BigNumberish): BigNumber;
25
+ mask(value: number): BigNumber;
26
+ shl(value: number): BigNumber;
27
+ shr(value: number): BigNumber;
28
+ eq(other: BigNumberish): boolean;
29
+ lt(other: BigNumberish): boolean;
30
+ lte(other: BigNumberish): boolean;
31
+ gt(other: BigNumberish): boolean;
32
+ gte(other: BigNumberish): boolean;
33
+ isNegative(): boolean;
34
+ isZero(): boolean;
35
+ toNumber(): number;
36
+ toBigInt(): bigint;
37
+ toString(): string;
38
+ toHexString(): string;
39
+ toJSON(key?: string): any;
40
+ static from(value: any): BigNumber;
41
+ static isBigNumber(value: any): value is BigNumber;
42
+ }
43
+
44
+ declare type Network = {
45
+ name: string;
46
+ chainId: number;
47
+ ensAddress?: string;
48
+ _defaultProvider?: (providers: any, options?: any) => any;
49
+ };
50
+ declare type Networkish = Network | string | number;
51
+
52
+ declare type Deferrable<T> = {
53
+ [K in keyof T]: T[K] | Promise<T[K]>;
54
+ };
55
+ declare class Description<T = any> {
56
+ constructor(info: {
57
+ [K in keyof T]: T[K];
58
+ });
59
+ }
60
+
61
+ declare type AccessList = Array<{
62
+ address: string;
63
+ storageKeys: Array<string>;
64
+ }>;
65
+ declare type AccessListish = AccessList | Array<[string, Array<string>]> | Record<string, Array<string>>;
66
+ interface Transaction$1 {
67
+ hash?: string;
68
+ to?: string;
69
+ from?: string;
70
+ nonce: number;
71
+ gasLimit: BigNumber;
72
+ gasPrice?: BigNumber;
73
+ data: string;
74
+ value: BigNumber;
75
+ chainId: number;
76
+ r?: string;
77
+ s?: string;
78
+ v?: number;
79
+ type?: number | null;
80
+ accessList?: AccessList;
81
+ maxPriorityFeePerGas?: BigNumber;
82
+ maxFeePerGas?: BigNumber;
83
+ }
84
+
85
+ declare type ConnectionInfo = {
86
+ url: string;
87
+ headers?: {
88
+ [key: string]: string | number;
89
+ };
90
+ user?: string;
91
+ password?: string;
92
+ allowInsecureAuthentication?: boolean;
93
+ allowGzip?: boolean;
94
+ throttleLimit?: number;
95
+ throttleSlotInterval?: number;
96
+ throttleCallback?: (attempt: number, url: string) => Promise<boolean>;
97
+ skipFetchSetup?: boolean;
98
+ fetchOptions?: Record<string, string>;
99
+ errorPassThrough?: boolean;
100
+ timeout?: number;
101
+ };
102
+ interface OnceBlockable {
103
+ once(eventName: "block", handler: () => void): void;
104
+ }
105
+
106
+ declare type TransactionRequest = {
107
+ to?: string;
108
+ from?: string;
109
+ nonce?: BigNumberish;
110
+ gasLimit?: BigNumberish;
111
+ gasPrice?: BigNumberish;
112
+ data?: BytesLike;
113
+ value?: BigNumberish;
114
+ chainId?: number;
115
+ type?: number;
116
+ accessList?: AccessListish;
117
+ maxPriorityFeePerGas?: BigNumberish;
118
+ maxFeePerGas?: BigNumberish;
119
+ customData?: Record<string, any>;
120
+ ccipReadEnabled?: boolean;
121
+ };
122
+ interface TransactionResponse extends Transaction$1 {
123
+ hash: string;
124
+ blockNumber?: number;
125
+ blockHash?: string;
126
+ timestamp?: number;
127
+ confirmations: number;
128
+ from: string;
129
+ raw?: string;
130
+ wait: (confirmations?: number) => Promise<TransactionReceipt>;
131
+ }
132
+ declare type BlockTag = string | number;
133
+ interface _Block {
134
+ hash: string;
135
+ parentHash: string;
136
+ number: number;
137
+ timestamp: number;
138
+ nonce: string;
139
+ difficulty: number;
140
+ _difficulty: BigNumber;
141
+ gasLimit: BigNumber;
142
+ gasUsed: BigNumber;
143
+ miner: string;
144
+ extraData: string;
145
+ baseFeePerGas?: null | BigNumber;
146
+ }
147
+ interface Block extends _Block {
148
+ transactions: Array<string>;
149
+ }
150
+ interface BlockWithTransactions extends _Block {
151
+ transactions: Array<TransactionResponse>;
152
+ }
153
+ interface Log {
154
+ blockNumber: number;
155
+ blockHash: string;
156
+ transactionIndex: number;
157
+ removed: boolean;
158
+ address: string;
159
+ data: string;
160
+ topics: Array<string>;
161
+ transactionHash: string;
162
+ logIndex: number;
163
+ }
164
+ interface TransactionReceipt {
165
+ to: string;
166
+ from: string;
167
+ contractAddress: string;
168
+ transactionIndex: number;
169
+ root?: string;
170
+ gasUsed: BigNumber;
171
+ logsBloom: string;
172
+ blockHash: string;
173
+ transactionHash: string;
174
+ logs: Array<Log>;
175
+ blockNumber: number;
176
+ confirmations: number;
177
+ cumulativeGasUsed: BigNumber;
178
+ effectiveGasPrice: BigNumber;
179
+ byzantium: boolean;
180
+ type: number;
181
+ status?: number;
182
+ }
183
+ interface FeeData {
184
+ lastBaseFeePerGas: null | BigNumber;
185
+ maxFeePerGas: null | BigNumber;
186
+ maxPriorityFeePerGas: null | BigNumber;
187
+ gasPrice: null | BigNumber;
188
+ }
189
+ interface EventFilter {
190
+ address?: string;
191
+ topics?: Array<string | Array<string> | null>;
192
+ }
193
+ interface Filter extends EventFilter {
194
+ fromBlock?: BlockTag;
195
+ toBlock?: BlockTag;
196
+ }
197
+ interface FilterByBlockHash extends EventFilter {
198
+ blockHash?: string;
199
+ }
200
+ declare abstract class ForkEvent extends Description {
201
+ readonly expiry: number;
202
+ readonly _isForkEvent?: boolean;
203
+ static isForkEvent(value: any): value is ForkEvent;
204
+ }
205
+ declare type EventType = string | Array<string | Array<string>> | EventFilter | ForkEvent;
206
+ declare type Listener = (...args: Array<any>) => void;
207
+ declare abstract class Provider implements OnceBlockable {
208
+ abstract getNetwork(): Promise<Network>;
209
+ abstract getBlockNumber(): Promise<number>;
210
+ abstract getGasPrice(): Promise<BigNumber>;
211
+ getFeeData(): Promise<FeeData>;
212
+ abstract getBalance(addressOrName: string | Promise<string>, blockTag?: BlockTag | Promise<BlockTag>): Promise<BigNumber>;
213
+ abstract getTransactionCount(addressOrName: string | Promise<string>, blockTag?: BlockTag | Promise<BlockTag>): Promise<number>;
214
+ abstract getCode(addressOrName: string | Promise<string>, blockTag?: BlockTag | Promise<BlockTag>): Promise<string>;
215
+ abstract getStorageAt(addressOrName: string | Promise<string>, position: BigNumberish | Promise<BigNumberish>, blockTag?: BlockTag | Promise<BlockTag>): Promise<string>;
216
+ abstract sendTransaction(signedTransaction: string | Promise<string>): Promise<TransactionResponse>;
217
+ abstract call(transaction: Deferrable<TransactionRequest>, blockTag?: BlockTag | Promise<BlockTag>): Promise<string>;
218
+ abstract estimateGas(transaction: Deferrable<TransactionRequest>): Promise<BigNumber>;
219
+ abstract getBlock(blockHashOrBlockTag: BlockTag | string | Promise<BlockTag | string>): Promise<Block>;
220
+ abstract getBlockWithTransactions(blockHashOrBlockTag: BlockTag | string | Promise<BlockTag | string>): Promise<BlockWithTransactions>;
221
+ abstract getTransaction(transactionHash: string): Promise<TransactionResponse>;
222
+ abstract getTransactionReceipt(transactionHash: string): Promise<TransactionReceipt>;
223
+ abstract getLogs(filter: Filter): Promise<Array<Log>>;
224
+ abstract resolveName(name: string | Promise<string>): Promise<null | string>;
225
+ abstract lookupAddress(address: string | Promise<string>): Promise<null | string>;
226
+ abstract on(eventName: EventType, listener: Listener): Provider;
227
+ abstract once(eventName: EventType, listener: Listener): Provider;
228
+ abstract emit(eventName: EventType, ...args: Array<any>): boolean;
229
+ abstract listenerCount(eventName?: EventType): number;
230
+ abstract listeners(eventName?: EventType): Array<Listener>;
231
+ abstract off(eventName: EventType, listener?: Listener): Provider;
232
+ abstract removeAllListeners(eventName?: EventType): Provider;
233
+ addListener(eventName: EventType, listener: Listener): Provider;
234
+ removeListener(eventName: EventType, listener: Listener): Provider;
235
+ abstract waitForTransaction(transactionHash: string, confirmations?: number, timeout?: number): Promise<TransactionReceipt>;
236
+ readonly _isProvider: boolean;
237
+ constructor();
238
+ static isProvider(value: any): value is Provider;
239
+ }
240
+
241
+ declare type FormatFunc = (value: any) => any;
242
+ declare type FormatFuncs = {
243
+ [key: string]: FormatFunc;
244
+ };
245
+ declare type Formats = {
246
+ transaction: FormatFuncs;
247
+ transactionRequest: FormatFuncs;
248
+ receipt: FormatFuncs;
249
+ receiptLog: FormatFuncs;
250
+ block: FormatFuncs;
251
+ blockWithTransactions: FormatFuncs;
252
+ filter: FormatFuncs;
253
+ filterLog: FormatFuncs;
254
+ };
255
+ declare class Formatter {
256
+ readonly formats: Formats;
257
+ constructor();
258
+ getDefaultFormats(): Formats;
259
+ accessList(accessList: Array<any>): AccessList;
260
+ number(number: any): number;
261
+ type(number: any): number;
262
+ bigNumber(value: any): BigNumber;
263
+ boolean(value: any): boolean;
264
+ hex(value: any, strict?: boolean): string;
265
+ data(value: any, strict?: boolean): string;
266
+ address(value: any): string;
267
+ callAddress(value: any): string;
268
+ contractAddress(value: any): string;
269
+ blockTag(blockTag: any): string;
270
+ hash(value: any, strict?: boolean): string;
271
+ difficulty(value: any): number;
272
+ uint256(value: any): string;
273
+ _block(value: any, format: any): Block;
274
+ block(value: any): Block;
275
+ blockWithTransactions(value: any): Block;
276
+ transactionRequest(value: any): any;
277
+ transactionResponse(transaction: any): TransactionResponse;
278
+ transaction(value: any): any;
279
+ receiptLog(value: any): any;
280
+ receipt(value: any): TransactionReceipt;
281
+ topics(value: any): any;
282
+ filter(value: any): any;
283
+ filterLog(value: any): any;
284
+ static check(format: {
285
+ [name: string]: FormatFunc;
286
+ }, object: any): any;
287
+ static allowNull(format: FormatFunc, nullValue?: any): FormatFunc;
288
+ static allowFalsish(format: FormatFunc, replaceValue: any): FormatFunc;
289
+ static arrayOf(format: FormatFunc): FormatFunc;
290
+ }
291
+
292
+ declare class Event {
293
+ readonly listener: Listener;
294
+ readonly once: boolean;
295
+ readonly tag: string;
296
+ _lastBlockNumber: number;
297
+ _inflight: boolean;
298
+ constructor(tag: string, listener: Listener, once: boolean);
299
+ get event(): EventType;
300
+ get type(): string;
301
+ get hash(): string;
302
+ get filter(): Filter;
303
+ pollable(): boolean;
304
+ }
305
+ interface EnsResolver {
306
+ readonly name: string;
307
+ readonly address: string;
308
+ getAddress(coinType?: 60): Promise<null | string>;
309
+ getContentHash(): Promise<null | string>;
310
+ getText(key: string): Promise<null | string>;
311
+ }
312
+ interface EnsProvider {
313
+ resolveName(name: string): Promise<null | string>;
314
+ lookupAddress(address: string): Promise<null | string>;
315
+ getResolver(name: string): Promise<null | EnsResolver>;
316
+ }
317
+ interface Avatar {
318
+ url: string;
319
+ linkage: Array<{
320
+ type: string;
321
+ content: string;
322
+ }>;
323
+ }
324
+ declare class Resolver implements EnsResolver {
325
+ readonly provider: BaseProvider;
326
+ readonly name: string;
327
+ readonly address: string;
328
+ readonly _resolvedAddress: null | string;
329
+ _supportsEip2544: null | Promise<boolean>;
330
+ constructor(provider: BaseProvider, address: string, name: string, resolvedAddress?: string);
331
+ supportsWildcard(): Promise<boolean>;
332
+ _fetch(selector: string, parameters?: string): Promise<null | string>;
333
+ _fetchBytes(selector: string, parameters?: string): Promise<null | string>;
334
+ _getAddress(coinType: number, hexBytes: string): string;
335
+ getAddress(coinType?: number): Promise<string>;
336
+ getAvatar(): Promise<null | Avatar>;
337
+ getContentHash(): Promise<string>;
338
+ getText(key: string): Promise<string>;
339
+ }
340
+ declare class BaseProvider extends Provider implements EnsProvider {
341
+ _networkPromise: Promise<Network>;
342
+ _network: Network;
343
+ _events: Array<Event>;
344
+ formatter: Formatter;
345
+ _emitted: {
346
+ [eventName: string]: number | "pending";
347
+ };
348
+ _pollingInterval: number;
349
+ _poller: NodeJS.Timer;
350
+ _bootstrapPoll: NodeJS.Timer;
351
+ _lastBlockNumber: number;
352
+ _maxFilterBlockRange: number;
353
+ _fastBlockNumber: number;
354
+ _fastBlockNumberPromise: Promise<number>;
355
+ _fastQueryDate: number;
356
+ _maxInternalBlockNumber: number;
357
+ _internalBlockNumber: Promise<{
358
+ blockNumber: number;
359
+ reqTime: number;
360
+ respTime: number;
361
+ }>;
362
+ readonly anyNetwork: boolean;
363
+ disableCcipRead: boolean;
364
+ /**
365
+ * ready
366
+ *
367
+ * A Promise<Network> that resolves only once the provider is ready.
368
+ *
369
+ * Sub-classes that call the super with a network without a chainId
370
+ * MUST set this. Standard named networks have a known chainId.
371
+ *
372
+ */
373
+ constructor(network: Networkish | Promise<Network>);
374
+ _ready(): Promise<Network>;
375
+ get ready(): Promise<Network>;
376
+ static getFormatter(): Formatter;
377
+ static getNetwork(network: Networkish): Network;
378
+ ccipReadFetch(tx: Transaction$1, calldata: string, urls: Array<string>): Promise<null | string>;
379
+ _getInternalBlockNumber(maxAge: number): Promise<number>;
380
+ poll(): Promise<void>;
381
+ resetEventsBlock(blockNumber: number): void;
382
+ get network(): Network;
383
+ detectNetwork(): Promise<Network>;
384
+ getNetwork(): Promise<Network>;
385
+ get blockNumber(): number;
386
+ get polling(): boolean;
387
+ set polling(value: boolean);
388
+ get pollingInterval(): number;
389
+ set pollingInterval(value: number);
390
+ _getFastBlockNumber(): Promise<number>;
391
+ _setFastBlockNumber(blockNumber: number): void;
392
+ waitForTransaction(transactionHash: string, confirmations?: number, timeout?: number): Promise<TransactionReceipt>;
393
+ _waitForTransaction(transactionHash: string, confirmations: number, timeout: number, replaceable: {
394
+ data: string;
395
+ from: string;
396
+ nonce: number;
397
+ to: string;
398
+ value: BigNumber;
399
+ startBlock: number;
400
+ }): Promise<TransactionReceipt>;
401
+ getBlockNumber(): Promise<number>;
402
+ getGasPrice(): Promise<BigNumber>;
403
+ getBalance(addressOrName: string | Promise<string>, blockTag?: BlockTag | Promise<BlockTag>): Promise<BigNumber>;
404
+ getTransactionCount(addressOrName: string | Promise<string>, blockTag?: BlockTag | Promise<BlockTag>): Promise<number>;
405
+ getCode(addressOrName: string | Promise<string>, blockTag?: BlockTag | Promise<BlockTag>): Promise<string>;
406
+ getStorageAt(addressOrName: string | Promise<string>, position: BigNumberish | Promise<BigNumberish>, blockTag?: BlockTag | Promise<BlockTag>): Promise<string>;
407
+ _wrapTransaction(tx: Transaction$1, hash?: string, startBlock?: number): TransactionResponse;
408
+ sendTransaction(signedTransaction: string | Promise<string>): Promise<TransactionResponse>;
409
+ _getTransactionRequest(transaction: Deferrable<TransactionRequest>): Promise<Transaction$1>;
410
+ _getFilter(filter: Filter | FilterByBlockHash | Promise<Filter | FilterByBlockHash>): Promise<Filter | FilterByBlockHash>;
411
+ _call(transaction: TransactionRequest, blockTag: BlockTag, attempt: number): Promise<string>;
412
+ call(transaction: Deferrable<TransactionRequest>, blockTag?: BlockTag | Promise<BlockTag>): Promise<string>;
413
+ estimateGas(transaction: Deferrable<TransactionRequest>): Promise<BigNumber>;
414
+ _getAddress(addressOrName: string | Promise<string>): Promise<string>;
415
+ _getBlock(blockHashOrBlockTag: BlockTag | string | Promise<BlockTag | string>, includeTransactions?: boolean): Promise<Block | BlockWithTransactions>;
416
+ getBlock(blockHashOrBlockTag: BlockTag | string | Promise<BlockTag | string>): Promise<Block>;
417
+ getBlockWithTransactions(blockHashOrBlockTag: BlockTag | string | Promise<BlockTag | string>): Promise<BlockWithTransactions>;
418
+ getTransaction(transactionHash: string | Promise<string>): Promise<TransactionResponse>;
419
+ getTransactionReceipt(transactionHash: string | Promise<string>): Promise<TransactionReceipt>;
420
+ getLogs(filter: Filter | FilterByBlockHash | Promise<Filter | FilterByBlockHash>): Promise<Array<Log>>;
421
+ getEtherPrice(): Promise<number>;
422
+ _getBlockTag(blockTag: BlockTag | Promise<BlockTag>): Promise<BlockTag>;
423
+ getResolver(name: string): Promise<null | Resolver>;
424
+ _getResolver(name: string, operation?: string): Promise<string>;
425
+ resolveName(name: string | Promise<string>): Promise<null | string>;
426
+ lookupAddress(address: string | Promise<string>): Promise<null | string>;
427
+ getAvatar(nameOrAddress: string): Promise<null | string>;
428
+ perform(method: string, params: any): Promise<any>;
429
+ _startEvent(event: Event): void;
430
+ _stopEvent(event: Event): void;
431
+ _addEventListener(eventName: EventType, listener: Listener, once: boolean): this;
432
+ on(eventName: EventType, listener: Listener): this;
433
+ once(eventName: EventType, listener: Listener): this;
434
+ emit(eventName: EventType, ...args: Array<any>): boolean;
435
+ listenerCount(eventName?: EventType): number;
436
+ listeners(eventName?: EventType): Array<Listener>;
437
+ off(eventName: EventType, listener?: Listener): this;
438
+ removeAllListeners(eventName?: EventType): this;
439
+ }
440
+
441
+ interface TypedDataDomain {
442
+ name?: string;
443
+ version?: string;
444
+ chainId?: BigNumberish;
445
+ verifyingContract?: string;
446
+ salt?: BytesLike;
447
+ }
448
+ interface TypedDataField {
449
+ name: string;
450
+ type: string;
451
+ }
452
+ interface TypedDataSigner {
453
+ _signTypedData(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, value: Record<string, any>): Promise<string>;
454
+ }
455
+ declare abstract class Signer {
456
+ readonly provider?: Provider;
457
+ abstract getAddress(): Promise<string>;
458
+ abstract signMessage(message: Bytes | string): Promise<string>;
459
+ abstract signTransaction(transaction: Deferrable<TransactionRequest>): Promise<string>;
460
+ abstract connect(provider: Provider): Signer;
461
+ readonly _isSigner: boolean;
462
+ constructor();
463
+ getBalance(blockTag?: BlockTag): Promise<BigNumber>;
464
+ getTransactionCount(blockTag?: BlockTag): Promise<number>;
465
+ estimateGas(transaction: Deferrable<TransactionRequest>): Promise<BigNumber>;
466
+ call(transaction: Deferrable<TransactionRequest>, blockTag?: BlockTag): Promise<string>;
467
+ sendTransaction(transaction: Deferrable<TransactionRequest>): Promise<TransactionResponse>;
468
+ getChainId(): Promise<number>;
469
+ getGasPrice(): Promise<BigNumber>;
470
+ getFeeData(): Promise<FeeData>;
471
+ resolveName(name: string): Promise<string>;
472
+ checkTransaction(transaction: Deferrable<TransactionRequest>): Deferrable<TransactionRequest>;
473
+ populateTransaction(transaction: Deferrable<TransactionRequest>): Promise<TransactionRequest>;
474
+ _checkProvider(operation?: string): void;
475
+ static isSigner(value: any): value is Signer;
476
+ }
477
+
478
+ declare class JsonRpcSigner extends Signer implements TypedDataSigner {
479
+ readonly provider: JsonRpcProvider;
480
+ _index: number;
481
+ _address: string;
482
+ constructor(constructorGuard: any, provider: JsonRpcProvider, addressOrIndex?: string | number);
483
+ connect(provider: Provider): JsonRpcSigner;
484
+ connectUnchecked(): JsonRpcSigner;
485
+ getAddress(): Promise<string>;
486
+ sendUncheckedTransaction(transaction: Deferrable<TransactionRequest>): Promise<string>;
487
+ signTransaction(transaction: Deferrable<TransactionRequest>): Promise<string>;
488
+ sendTransaction(transaction: Deferrable<TransactionRequest>): Promise<TransactionResponse>;
489
+ signMessage(message: Bytes | string): Promise<string>;
490
+ _legacySignMessage(message: Bytes | string): Promise<string>;
491
+ _signTypedData(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, value: Record<string, any>): Promise<string>;
492
+ unlock(password: string): Promise<boolean>;
493
+ }
494
+ declare class UncheckedJsonRpcSigner extends JsonRpcSigner {
495
+ sendTransaction(transaction: Deferrable<TransactionRequest>): Promise<TransactionResponse>;
496
+ }
497
+ declare class JsonRpcProvider extends BaseProvider {
498
+ readonly connection: ConnectionInfo;
499
+ _pendingFilter: Promise<number>;
500
+ _nextId: number;
501
+ _eventLoopCache: Record<string, Promise<any>>;
502
+ get _cache(): Record<string, Promise<any>>;
503
+ constructor(url?: ConnectionInfo | string, network?: Networkish);
504
+ static defaultUrl(): string;
505
+ detectNetwork(): Promise<Network>;
506
+ _uncachedDetectNetwork(): Promise<Network>;
507
+ getSigner(addressOrIndex?: string | number): JsonRpcSigner;
508
+ getUncheckedSigner(addressOrIndex?: string | number): UncheckedJsonRpcSigner;
509
+ listAccounts(): Promise<Array<string>>;
510
+ send(method: string, params: Array<any>): Promise<any>;
511
+ prepareRequest(method: string, params: any): [string, Array<any>];
512
+ perform(method: string, params: any): Promise<any>;
513
+ _startEvent(event: Event): void;
514
+ _startPending(): void;
515
+ _stopEvent(event: Event): void;
516
+ static hexlifyTransaction(transaction: TransactionRequest, allowExtra?: {
517
+ [key: string]: boolean;
518
+ }): {
519
+ [key: string]: string | AccessList;
520
+ };
521
+ }
522
+
523
+ declare type ExternalProvider = {
524
+ isMetaMask?: boolean;
525
+ isStatus?: boolean;
526
+ host?: string;
527
+ path?: string;
528
+ sendAsync?: (request: {
529
+ method: string;
530
+ params?: Array<any>;
531
+ }, callback: (error: any, response: any) => void) => void;
532
+ send?: (request: {
533
+ method: string;
534
+ params?: Array<any>;
535
+ }, callback: (error: any, response: any) => void) => void;
536
+ request?: (request: {
537
+ method: string;
538
+ params?: Array<any>;
539
+ }) => Promise<any>;
540
+ };
541
+ declare type JsonRpcFetchFunc = (method: string, params?: Array<any>) => Promise<any>;
542
+ declare class Web3Provider extends JsonRpcProvider {
543
+ readonly provider: ExternalProvider;
544
+ readonly jsonRpcFetchFunc: JsonRpcFetchFunc;
545
+ constructor(provider: ExternalProvider | JsonRpcFetchFunc, network?: Networkish);
546
+ send(method: string, params: Array<any>): Promise<any>;
547
+ }
548
+
549
+ declare enum Environment {
550
+ PRODUCTION = "production",
551
+ SANDBOX = "sandbox"
552
+ }
553
+ declare class ImmutableConfiguration {
554
+ readonly environment: Environment;
555
+ readonly apiKey?: string;
556
+ constructor(options: {
557
+ environment: Environment;
558
+ apiKey?: string;
559
+ });
560
+ }
561
+ interface ModuleConfiguration<T> {
562
+ baseConfig: ImmutableConfiguration;
563
+ overrides?: T;
564
+ }
565
+
566
+ /**
567
+ * Interface representing token information.
568
+ * @property {string} name - The token name.
569
+ * @property {string} symbol - The token symbol.
570
+ * @property {number} decimals - The token decimals.
571
+ * @property {string} [address] - The token contract address.
572
+ * @property {string} [icon] - The token icon URL/data:image.
573
+ */
574
+ interface TokenInfo {
575
+ name: string;
576
+ symbol: string;
577
+ decimals: number;
578
+ address?: string;
579
+ icon?: string;
580
+ }
581
+ /**
582
+ * Interface representing the parameters for {@link Checkout.getTokenAllowList}.
583
+ * @property {TokenFilterTypes} type - The type of token to retrieve.
584
+ * @property {ChainId} chainId - The ID of the blockchain network.
585
+ * @property {TokenFilter[]} [exclude] - The tokens to exclude from the list.
586
+ */
587
+ interface GetTokenAllowListParams {
588
+ type: TokenFilterTypes;
589
+ chainId?: ChainId;
590
+ exclude?: TokenFilter[];
591
+ }
592
+ /**
593
+ * Interface representing the result of {@link Checkout.getTokenAllowList}.
594
+ * @property {TokenInfo[]} tokens - The list of tokens allowed for the specified params.
595
+ */
596
+ interface GetTokenAllowListResult {
597
+ tokens: TokenInfo[];
598
+ }
599
+ /**
600
+ * Enum representing the types of token filters available.
601
+ */
602
+ declare enum TokenFilterTypes {
603
+ SWAP = "swap",
604
+ BRIDGE = "bridge",
605
+ ALL = "all"
606
+ }
607
+ /**
608
+ * Interface representing a token filter that can be used to exclude certain tokens.
609
+ * @property {string} address - The token contract address.
610
+ */
611
+ interface TokenFilter {
612
+ address: string;
613
+ }
614
+ /**
615
+ * Enum representing the supported chains with their corresponding IDs.
616
+ */
617
+ declare enum ChainId {
618
+ ETHEREUM = 1,
619
+ SEPOLIA = 11155111,
620
+ IMTBL_ZKEVM_DEVNET = 13373,
621
+ IMTBL_ZKEVM_TESTNET = 13372,
622
+ POLYGON_ZKEVM_TESTNET = 1442,
623
+ POLYGON_ZKEVM = 137
624
+ }
625
+ /**
626
+ * Interface representing the information of a network.
627
+ * @property {string} name - The name of the network.
628
+ * @property {number} chainId - The ID of the network.
629
+ * @property {TokenInfo} nativeCurrency - The info of the network's native currency.
630
+ * @property {boolean} isSupported - Flag indicating if the network is supported by the application.
631
+ */
632
+ interface NetworkInfo {
633
+ name: string;
634
+ chainId: number;
635
+ nativeCurrency: TokenInfo;
636
+ isSupported: boolean;
637
+ }
638
+ /**
639
+ * Type representing the details of a network.
640
+ * @property {string} chainIdHex - The hexadecimal ID of the network.
641
+ * @property {string} chainName - The name of the network.
642
+ * @property {string[]} rpcUrls - The RPS URLs of the network's node.
643
+ * @property {TokenInfo} nativeCurrency - The info of the network's native currency.
644
+ * @property {string[]} [blockExplorerUrls] - The URLs of the network's block explorer.
645
+ */
646
+ type NetworkDetails = {
647
+ chainIdHex: string;
648
+ chainName: string;
649
+ rpcUrls: string[];
650
+ nativeCurrency: TokenInfo;
651
+ blockExplorerUrls?: string[];
652
+ };
653
+ /**
654
+ * Type representing the mapping between ChainId and NetworkDetails
655
+ */
656
+ type NetworkMap = Map<ChainId, NetworkDetails>;
657
+ /**
658
+ * Interface representing the parameters for {@link Checkout.switchNetwork}.
659
+ * @property {Web3Provider} provider - The provider to connect to the network.
660
+ * @property {ChainId} chainId - The ID of the network to switch to.
661
+ */
662
+ interface SwitchNetworkParams {
663
+ provider: Web3Provider;
664
+ chainId: ChainId;
665
+ }
666
+ /**
667
+ * Interface representing the result of {@link Checkout.switchNetwork}.
668
+ * @property {NetworkInfo} network - The information of the network that was switched to.
669
+ */
670
+ interface SwitchNetworkResult {
671
+ network: NetworkInfo;
672
+ provider: Web3Provider;
673
+ }
674
+ /**
675
+ * * Interface representing the parameters for {@link Checkout.getNetworkInfo}.
676
+ * @property {Web3Provider} provider - The provider to connect to the network.
677
+ */
678
+ interface GetNetworkParams {
679
+ provider: Web3Provider;
680
+ }
681
+ /**
682
+ * Enum representing the types of filters that can be applied to get the allow list of networks.
683
+ */
684
+ declare enum NetworkFilterTypes {
685
+ ALL = "all"
686
+ }
687
+ /**
688
+ * Interface representing a filter for filtering a specific network.
689
+ * @property {ChainId} chainId - The ID of the network to allow or disallow.
690
+ */
691
+ interface NetworkFilter {
692
+ chainId: ChainId;
693
+ }
694
+ /**
695
+ * * Interface representing the parameters for {@link Checkout.getNetworkAllowList}.
696
+ * @property {NetworkFilterTypes} type - The type of allow list filter to apply.
697
+ * @property {NetworkFilter[]} [exclude] - The list of networks to exclude from the allow list.
698
+ */
699
+ interface GetNetworkAllowListParams {
700
+ type: NetworkFilterTypes;
701
+ exclude?: NetworkFilter[];
702
+ }
703
+ /**
704
+ * Interface representing the result of {@link Checkout.getNetworkAllowList}.
705
+ * @property {NetworkInfo[]} networks - The list of allowed networks.
706
+ */
707
+ interface GetNetworkAllowListResult {
708
+ networks: NetworkInfo[];
709
+ }
710
+ /**
711
+ * Interface representing the parameters for {@link Checkout.getBalance}.
712
+ * @property {@link Web3Provider} provider - The provider to connect to the network.
713
+ * @property {string} walletAddress - The wallet address.
714
+ * @property {string | undefined} contractAddress - The contract address of the token.
715
+ */
716
+ interface GetBalanceParams {
717
+ provider: Web3Provider;
718
+ walletAddress: string;
719
+ contractAddress?: string;
720
+ }
721
+ /**
722
+ * Interface representing the result of {@link Checkout.getBalance}.
723
+ * @property {BigNumber} balance - The balance of the wallet for the token.
724
+ * @property {string} formattedBalance - The formatted balance of the wallet for the token.
725
+ * @property {TokenInfo} token - The token information.
726
+ */
727
+ interface GetBalanceResult {
728
+ balance: BigNumber;
729
+ formattedBalance: string;
730
+ token: TokenInfo;
731
+ }
732
+ /**
733
+ * Interface representing the parameters for {@link Checkout.getAllBalances}.
734
+ * @property {Web3Provider} provider - The provider to connect to the network.
735
+ * @property {string} walletAddress - The wallet address.
736
+ * @property {ChainId} chainId - The ID of the network.
737
+ */
738
+ interface GetAllBalancesParams {
739
+ provider: Web3Provider;
740
+ walletAddress: string;
741
+ chainId: ChainId;
742
+ }
743
+ /**
744
+ * Interface representing the result of {@link Checkout.getAllBalances}.
745
+ * @property {GetBalanceResult[]} balances - The array of balances of the wallet for every token.
746
+ */
747
+ interface GetAllBalancesResult {
748
+ balances: GetBalanceResult[];
749
+ }
750
+ interface CheckoutOverrides {
751
+ }
752
+ interface CheckoutModuleConfiguration extends ModuleConfiguration<CheckoutOverrides> {
753
+ }
754
+ /**
755
+ * Enum representing the list of default supported providers.
756
+ */
757
+ declare enum ConnectionProviders {
758
+ METAMASK = "metamask"
759
+ }
760
+ /**
761
+ * Interface representing the parameters for {@link Checkout.connect}.
762
+ * @property {ConnectionProviders} providerPreference - The preferred provider to connect to the network.
763
+ */
764
+ type ConnectParams = {
765
+ providerPreference: ConnectionProviders;
766
+ };
767
+ /**
768
+ * Interface representing the result of {@link Checkout.connect}.
769
+ * @property {Web3Provider} provider - The provider used to connect to the network.
770
+ * @property {NetworkInfo} network - Information about the connected network.
771
+ */
772
+ interface ConnectResult {
773
+ provider: Web3Provider;
774
+ network: NetworkInfo;
775
+ }
776
+ /**
777
+ * Interface representing the parameters for {@link Checkout.checkIsWalletConnected}.
778
+ * @property {ConnectionProviders} providerPreference - The preferred provider to use to check the connection status to th Web3 network.
779
+ */
780
+ interface CheckConnectionParams {
781
+ providerPreference: ConnectionProviders;
782
+ }
783
+ /**
784
+ * Interface representing the result of {@link Checkout.checkIsWalletConnected}.
785
+ * @property {boolean} isConnected - A boolean indicating the connection status of th Web3 provider.
786
+ * @property {string} walletAddress - The wallet address used to check the connection.
787
+ */
788
+ interface CheckConnectionResult {
789
+ isConnected: boolean;
790
+ walletAddress: string;
791
+ }
792
+ /**
793
+ * Interface representing the parameters for {@link Checkout.sendTransaction}.
794
+ * @property {Web3Provider} provider - The provider to connect to the network.
795
+ * @property {Transaction} transaction - The transaction to send.
796
+ */
797
+ interface SendTransactionParams {
798
+ provider: Web3Provider;
799
+ transaction: Transaction;
800
+ }
801
+ /**
802
+ * Interface representing the result of {@link Checkout.sendTransaction}.
803
+ * @property {TransactionResponse} transactionResponse - The response of the transaction.
804
+ */
805
+ interface SendTransactionResult {
806
+ transactionResponse: TransactionResponse;
807
+ }
808
+ /**
809
+ * Interface representing a blockchain transaction.
810
+ * @property {string} nonce - The transaction nonce.
811
+ * @property {string} gasPrice - The gas price of the transaction.
812
+ * @property {string} gas - The gas limit for the transaction.
813
+ * @property {string} to - The address of the recipient.
814
+ * @property {string} from - The address of the sender.
815
+ * @property {string} value - The value to transfer in wei.
816
+ * @property {string} data - The data to include in the transaction.
817
+ * @property {number} chainId - The ID of the chain the transaction is for.
818
+ */
819
+ interface Transaction {
820
+ nonce: string;
821
+ gasPrice: string;
822
+ gas: string;
823
+ to: string;
824
+ from: string;
825
+ value: string;
826
+ data: string;
827
+ chainId: number;
828
+ }
829
+ /**
830
+ * Interface representing a wallet filter to be used in {@link GetWalletAllowListParams}.
831
+ * @property {ConnectionProviders} connectionProvider - The connection provider to filter wallets by.
832
+ */
833
+ interface WalletFilter {
834
+ connectionProvider: ConnectionProviders;
835
+ }
836
+ /**
837
+ * Interface representing the parameters for {@link Checkout.getWalletAllowList}.
838
+ * @property {WalletFilterTypes} type - The type of wallets to filter by.
839
+ * @property {WalletFilter[]} [exclude] - An optional list of wallet filters to exclude from the allowed wallets list.
840
+ */
841
+ interface GetWalletAllowListParams {
842
+ type: WalletFilterTypes;
843
+ exclude?: WalletFilter[];
844
+ }
845
+ /**
846
+ * Interface representing information about a wallet used in {@link GetWalletAllowListResult}.
847
+ * @property {ConnectionProviders} connectionProvider - The connection provider for the wallet.
848
+ * @property {string} name - The name of the wallet.
849
+ * @property {string} description - A description of the wallet.
850
+ * @property {string} icon - The URL/data:image of an icon for the wallet.
851
+ */
852
+ interface WalletInfo {
853
+ connectionProvider: ConnectionProviders;
854
+ name: string;
855
+ description: string;
856
+ icon: string;
857
+ }
858
+ /**
859
+ * Interface representing the result of {@link Checkout.getWalletAllowList}.
860
+ * @property {WalletInfo[]} wallets - A list of {@link WalletInfo} objects representing the allowed wallets.
861
+ */
862
+ interface GetWalletAllowListResult {
863
+ wallets: WalletInfo[];
864
+ }
865
+ /**
866
+ * Enum representing the platform filters used in {@link GetWalletAllowListParams}.
867
+ */
868
+ declare enum WalletFilterTypes {
869
+ ALL = "all",
870
+ DESKTOP = "desktop",
871
+ MOBILE = "mobile"
872
+ }
873
+ /**
874
+ * The different types of errors that can be returned by the checkout process.
875
+ */
876
+ declare enum CheckoutErrorType {
877
+ PROVIDER_PREFERENCE_ERROR = "PROVIDER_PREFERENCE_ERROR",
878
+ CONNECT_PROVIDER_ERROR = "CONNECT_PROVIDER_ERROR",
879
+ GET_BALANCE_ERROR = "GET_BALANCE_ERROR",
880
+ GET_ERC20_BALANCE_ERROR = "GET_ERC20_BALANCE_ERROR",
881
+ GET_NETWORK_INFO_ERROR = "GET_NETWORK_INFO_ERROR",
882
+ METAMASK_PROVIDER_ERROR = "METAMASK_PROVIDER_ERROR",
883
+ CHAIN_NOT_SUPPORTED_ERROR = "CHAIN_NOT_SUPPORTED_ERROR",
884
+ PROVIDER_REQUEST_MISSING_ERROR = "PROVIDER_REQUEST_MISSING_ERROR",
885
+ PROVIDER_REQUEST_FAILED_ERROR = "PROVIDER_REQUEST_FAILED_ERROR",
886
+ USER_REJECTED_REQUEST_ERROR = "USER_REJECTED_REQUEST_ERROR",
887
+ TRANSACTION_ERROR = "TRANSACTION_ERROR"
888
+ }
889
+ /**
890
+ * The type signature for an error.
891
+ * Contains a type that corresponds to a {@link CheckoutErrorType}, an optional message string and optional data object.
892
+ */
893
+ type ErrorType = {
894
+ type: CheckoutErrorType;
895
+ message?: string;
896
+ data?: {
897
+ [key: string]: string;
898
+ };
899
+ };
900
+ declare class CheckoutConfiguration {
901
+ readonly environment: Environment;
902
+ readonly networkMap: NetworkMap;
903
+ constructor(config: CheckoutModuleConfiguration);
904
+ }
905
+ declare class Checkout {
906
+ readonly config: CheckoutConfiguration;
907
+ constructor(config?: CheckoutModuleConfiguration);
908
+ /**
909
+ * Check if a wallet is connected to the current application
910
+ * without requesting permission from the wallet and hence triggering a connect popup.
911
+ * @param {CheckConnectionParams} params - The necessary data required to verify a wallet connection status.
912
+ * @returns Wallet connection status details.
913
+ * @throws {@link ErrorType}
914
+ */
915
+ checkIsWalletConnected(params: CheckConnectionParams): Promise<CheckConnectionResult>;
916
+ /**
917
+ * Establish a connection with a wallet provider such as MetaMask and returns the provider object and the current network details.
918
+ * @param {ConnectParams} params - The necessary data required to establish a connection with a wallet provider.
919
+ * @returns Wallet provider and current network information.
920
+ * @throws {@link ErrorType}
921
+ */
922
+ connect(params: ConnectParams): Promise<ConnectResult>;
923
+ /**
924
+ * Switch the currently connected wallet to a new network.
925
+ * @param {SwitchNetworkParams} params - The necessary data required to switch network.
926
+ * @returns The new network information.
927
+ * @throws {@link ErrorType}
928
+ */
929
+ switchNetwork(params: SwitchNetworkParams): Promise<SwitchNetworkResult>;
930
+ /**
931
+ * Fetch the balance of the native token of the current connected network or,
932
+ * if a contract address is provided, it will return the balance of that ERC20 token. For example,
933
+ * if the wallet is connected to the Ethereum Mainnet then the function gets the wallet ETH L1 balance.
934
+ * @param {GetBalanceParams} params - The necessary data required to fetch the wallet balance.
935
+ * @returns Native token balance for the given wallet.
936
+ * @throws {@link ErrorType}
937
+ */
938
+ getBalance(params: GetBalanceParams): Promise<GetBalanceResult>;
939
+ /**
940
+ * Fetch all available balances (ERC20 & Native) of the current connected network of the given wallet.
941
+ * It will loop through the list of allowed tokens and check for balance on each one.
942
+ * @param {GetAllBalancesParams} params - The necessary data required to fetch all the wallet balances.
943
+ * @returns List of tokens balance for the given wallet.
944
+ * @throws {@link ErrorType}
945
+ */
946
+ getAllBalances(params: GetAllBalancesParams): Promise<GetAllBalancesResult>;
947
+ /**
948
+ * Fetch the list of available networks that a wallet can add or/and switch to.
949
+ * @param {GetNetworkAllowListParams} params - The necessary data required to fetch the list of available networks.
950
+ * @returns List of networks.
951
+ * @throws {@link ErrorType}
952
+ */
953
+ getNetworkAllowList(params: GetNetworkAllowListParams): Promise<GetNetworkAllowListResult>;
954
+ /**
955
+ * Get the list of tokens which are allowed to be used with the product.
956
+ * @param {GetTokenAllowListParams} params - The necessary data required to fetch the list of allowed tokens.
957
+ * @returns List of allowed tokens.
958
+ * @throws {@link ErrorType}
959
+ */
960
+ getTokenAllowList(params: GetTokenAllowListParams): Promise<GetTokenAllowListResult>;
961
+ /**
962
+ * Fetch the list of wallets which are available to connect with.
963
+ * @param {GetWalletAllowListParams} params - The necessary data required to fetch the list of allowed wallets.
964
+ * @returns List of allowed wallets.
965
+ * @throws {@link ErrorType}
966
+ */
967
+ getWalletAllowList(params: GetWalletAllowListParams): Promise<GetWalletAllowListResult>;
968
+ /**
969
+ * Send a generic transaction to the provider.
970
+ * @param {SendTransactionParams} params - The necessary data required to send a transaction.
971
+ * @returns Transaction response.
972
+ * @throws {@link ErrorType}
973
+ * @remarks
974
+ * Further documenation can be found at [MetaMask | Sending Transactions](https://docs.metamask.io/guide/sending-transactions.html).
975
+ */
976
+ sendTransaction(params: SendTransactionParams): Promise<SendTransactionResult>;
977
+ /**
978
+ * Get network information about the currently selected network.
979
+ * @param {GetNetworkParams} params - The necessary data required to get the current network information.
980
+ * @returns Network details.
981
+ * @throws {@link ErrorType}
982
+ */
983
+ getNetworkInfo(params: GetNetworkParams): Promise<NetworkInfo>;
984
+ }
985
+
986
+ export { ChainId, CheckConnectionParams, CheckConnectionResult, Checkout, CheckoutErrorType, CheckoutModuleConfiguration, ConnectParams, ConnectResult, ConnectionProviders, ErrorType, GetAllBalancesParams, GetAllBalancesResult, GetBalanceParams, GetBalanceResult, GetNetworkAllowListParams, GetNetworkAllowListResult, GetNetworkParams, GetTokenAllowListParams, GetTokenAllowListResult, GetWalletAllowListParams, GetWalletAllowListResult, NetworkFilter, NetworkFilterTypes, NetworkInfo, SendTransactionParams, SendTransactionResult, SwitchNetworkParams, SwitchNetworkResult, TokenFilter, TokenFilterTypes, TokenInfo, Transaction, WalletFilter, WalletFilterTypes, WalletInfo };