@imtbl/sdk 0.28.4 → 0.28.5-alpha.1
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/dist/blockchain_data.js +1 -1
- package/dist/browser/checkout/sdk.js +35 -0
- package/dist/browser/checkout/widgets.js +890 -0
- package/dist/checkout_sdk.d.ts +892 -213
- package/dist/checkout_sdk.js +2884 -2388
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +12 -21
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +2923 -2883
- package/dist/index.d.ts +1150 -15405
- package/dist/index.js +2924 -2883
- package/dist/passport.js +2 -2
- package/package.json +17 -6
- package/dist/browser/checkout.js +0 -2
- package/dist/checkout_widgets.d.ts +0 -25583
- package/dist/checkout_widgets.js +0 -449
package/dist/checkout_sdk.d.ts
CHANGED
|
@@ -43,6 +43,14 @@ declare class BigNumber implements Hexable {
|
|
|
43
43
|
static isBigNumber(value: any): value is BigNumber;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
declare type Network = {
|
|
47
|
+
name: string;
|
|
48
|
+
chainId: number;
|
|
49
|
+
ensAddress?: string;
|
|
50
|
+
_defaultProvider?: (providers: any, options?: any) => any;
|
|
51
|
+
};
|
|
52
|
+
declare type Networkish = Network | string | number;
|
|
53
|
+
|
|
46
54
|
declare type Deferrable<T> = {
|
|
47
55
|
[K in keyof T]: T[K] | Promise<T[K]>;
|
|
48
56
|
};
|
|
@@ -52,14 +60,6 @@ declare class Description<T = any> {
|
|
|
52
60
|
});
|
|
53
61
|
}
|
|
54
62
|
|
|
55
|
-
declare type Network = {
|
|
56
|
-
name: string;
|
|
57
|
-
chainId: number;
|
|
58
|
-
ensAddress?: string;
|
|
59
|
-
_defaultProvider?: (providers: any, options?: any) => any;
|
|
60
|
-
};
|
|
61
|
-
declare type Networkish = Network | string | number;
|
|
62
|
-
|
|
63
63
|
declare type AccessList = Array<{
|
|
64
64
|
address: string;
|
|
65
65
|
storageKeys: Array<string>;
|
|
@@ -240,43 +240,6 @@ declare abstract class Provider$1 implements OnceBlockable {
|
|
|
240
240
|
static isProvider(value: any): value is Provider$1;
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
-
interface TypedDataDomain {
|
|
244
|
-
name?: string;
|
|
245
|
-
version?: string;
|
|
246
|
-
chainId?: BigNumberish;
|
|
247
|
-
verifyingContract?: string;
|
|
248
|
-
salt?: BytesLike;
|
|
249
|
-
}
|
|
250
|
-
interface TypedDataField {
|
|
251
|
-
name: string;
|
|
252
|
-
type: string;
|
|
253
|
-
}
|
|
254
|
-
interface TypedDataSigner {
|
|
255
|
-
_signTypedData(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, value: Record<string, any>): Promise<string>;
|
|
256
|
-
}
|
|
257
|
-
declare abstract class Signer {
|
|
258
|
-
readonly provider?: Provider$1;
|
|
259
|
-
abstract getAddress(): Promise<string>;
|
|
260
|
-
abstract signMessage(message: Bytes | string): Promise<string>;
|
|
261
|
-
abstract signTransaction(transaction: Deferrable<TransactionRequest>): Promise<string>;
|
|
262
|
-
abstract connect(provider: Provider$1): Signer;
|
|
263
|
-
readonly _isSigner: boolean;
|
|
264
|
-
constructor();
|
|
265
|
-
getBalance(blockTag?: BlockTag): Promise<BigNumber>;
|
|
266
|
-
getTransactionCount(blockTag?: BlockTag): Promise<number>;
|
|
267
|
-
estimateGas(transaction: Deferrable<TransactionRequest>): Promise<BigNumber>;
|
|
268
|
-
call(transaction: Deferrable<TransactionRequest>, blockTag?: BlockTag): Promise<string>;
|
|
269
|
-
sendTransaction(transaction: Deferrable<TransactionRequest>): Promise<TransactionResponse>;
|
|
270
|
-
getChainId(): Promise<number>;
|
|
271
|
-
getGasPrice(): Promise<BigNumber>;
|
|
272
|
-
getFeeData(): Promise<FeeData$1>;
|
|
273
|
-
resolveName(name: string): Promise<string>;
|
|
274
|
-
checkTransaction(transaction: Deferrable<TransactionRequest>): Deferrable<TransactionRequest>;
|
|
275
|
-
populateTransaction(transaction: Deferrable<TransactionRequest>): Promise<TransactionRequest>;
|
|
276
|
-
_checkProvider(operation?: string): void;
|
|
277
|
-
static isSigner(value: any): value is Signer;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
243
|
declare type FormatFunc = (value: any) => any;
|
|
281
244
|
declare type FormatFuncs = {
|
|
282
245
|
[key: string]: FormatFunc;
|
|
@@ -477,6 +440,43 @@ declare class BaseProvider extends Provider$1 implements EnsProvider {
|
|
|
477
440
|
removeAllListeners(eventName?: EventType): this;
|
|
478
441
|
}
|
|
479
442
|
|
|
443
|
+
interface TypedDataDomain {
|
|
444
|
+
name?: string;
|
|
445
|
+
version?: string;
|
|
446
|
+
chainId?: BigNumberish;
|
|
447
|
+
verifyingContract?: string;
|
|
448
|
+
salt?: BytesLike;
|
|
449
|
+
}
|
|
450
|
+
interface TypedDataField {
|
|
451
|
+
name: string;
|
|
452
|
+
type: string;
|
|
453
|
+
}
|
|
454
|
+
interface TypedDataSigner {
|
|
455
|
+
_signTypedData(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, value: Record<string, any>): Promise<string>;
|
|
456
|
+
}
|
|
457
|
+
declare abstract class Signer {
|
|
458
|
+
readonly provider?: Provider$1;
|
|
459
|
+
abstract getAddress(): Promise<string>;
|
|
460
|
+
abstract signMessage(message: Bytes | string): Promise<string>;
|
|
461
|
+
abstract signTransaction(transaction: Deferrable<TransactionRequest>): Promise<string>;
|
|
462
|
+
abstract connect(provider: Provider$1): Signer;
|
|
463
|
+
readonly _isSigner: boolean;
|
|
464
|
+
constructor();
|
|
465
|
+
getBalance(blockTag?: BlockTag): Promise<BigNumber>;
|
|
466
|
+
getTransactionCount(blockTag?: BlockTag): Promise<number>;
|
|
467
|
+
estimateGas(transaction: Deferrable<TransactionRequest>): Promise<BigNumber>;
|
|
468
|
+
call(transaction: Deferrable<TransactionRequest>, blockTag?: BlockTag): Promise<string>;
|
|
469
|
+
sendTransaction(transaction: Deferrable<TransactionRequest>): Promise<TransactionResponse>;
|
|
470
|
+
getChainId(): Promise<number>;
|
|
471
|
+
getGasPrice(): Promise<BigNumber>;
|
|
472
|
+
getFeeData(): Promise<FeeData$1>;
|
|
473
|
+
resolveName(name: string): Promise<string>;
|
|
474
|
+
checkTransaction(transaction: Deferrable<TransactionRequest>): Deferrable<TransactionRequest>;
|
|
475
|
+
populateTransaction(transaction: Deferrable<TransactionRequest>): Promise<TransactionRequest>;
|
|
476
|
+
_checkProvider(operation?: string): void;
|
|
477
|
+
static isSigner(value: any): value is Signer;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
480
|
declare class JsonRpcSigner extends Signer implements TypedDataSigner {
|
|
481
481
|
readonly provider: JsonRpcProvider;
|
|
482
482
|
_index: number;
|
|
@@ -548,88 +548,6 @@ declare class Web3Provider extends JsonRpcProvider {
|
|
|
548
548
|
send(method: string, params: Array<any>): Promise<any>;
|
|
549
549
|
}
|
|
550
550
|
|
|
551
|
-
declare enum Environment {
|
|
552
|
-
PRODUCTION = "production",
|
|
553
|
-
SANDBOX = "sandbox"
|
|
554
|
-
}
|
|
555
|
-
declare class ImmutableConfiguration {
|
|
556
|
-
readonly environment: Environment;
|
|
557
|
-
readonly rateLimitingKey?: string;
|
|
558
|
-
readonly apiKey?: string;
|
|
559
|
-
readonly clientAppId?: string;
|
|
560
|
-
constructor(options: {
|
|
561
|
-
environment: Environment;
|
|
562
|
-
rateLimitingKey?: string;
|
|
563
|
-
apiKey?: string;
|
|
564
|
-
clientAppId?: string;
|
|
565
|
-
});
|
|
566
|
-
}
|
|
567
|
-
interface ModuleConfiguration<T> {
|
|
568
|
-
baseConfig: ImmutableConfiguration;
|
|
569
|
-
overrides?: T;
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
/**
|
|
573
|
-
* Type representing an ERC20 token
|
|
574
|
-
* @property {string} type - The token type, used to discriminate between {@link ERC20} and {@link Native}
|
|
575
|
-
* @property {number} chainId - The chain ID
|
|
576
|
-
* @property {string} address - The token address
|
|
577
|
-
* @property {number} decimals - The token decimals
|
|
578
|
-
* @property {string | undefined} symbol - The token symbol or undefined if it is not available
|
|
579
|
-
* @property {string | undefined} name - The token name or undefined if it is not available
|
|
580
|
-
*/
|
|
581
|
-
type ERC20 = {
|
|
582
|
-
type: 'erc20';
|
|
583
|
-
chainId: number;
|
|
584
|
-
address: string;
|
|
585
|
-
decimals: number;
|
|
586
|
-
symbol?: string;
|
|
587
|
-
name?: string;
|
|
588
|
-
};
|
|
589
|
-
/**
|
|
590
|
-
* Type representing a native token
|
|
591
|
-
* @property {string} type - The token type, used to discriminate between {@link ERC20} and {@link Native}
|
|
592
|
-
* @property {number} chainId - The chain ID
|
|
593
|
-
* @property {number} decimals - The token decimals
|
|
594
|
-
* @property {string | undefined} symbol - The token symbol or undefined if it is not available
|
|
595
|
-
* @property {string | undefined} name - The token name or undefined if it is not available
|
|
596
|
-
*/
|
|
597
|
-
type Native = {
|
|
598
|
-
type: 'native';
|
|
599
|
-
chainId: number;
|
|
600
|
-
decimals: number;
|
|
601
|
-
symbol?: string;
|
|
602
|
-
name?: string;
|
|
603
|
-
};
|
|
604
|
-
/**
|
|
605
|
-
* Type representing a token, either an {@link ERC20} or {@link Native}
|
|
606
|
-
*/
|
|
607
|
-
type Coin = ERC20 | Native;
|
|
608
|
-
/**
|
|
609
|
-
* Type representing the overrides for the {@link Exchange} module
|
|
610
|
-
* @property {string} rpcURL - The RPC URL for the chain
|
|
611
|
-
* @property {ExchangeContracts} exchangeContracts - The DEX contract addresses
|
|
612
|
-
* @property {ERC20[]} commonRoutingTokens - The tokens used to find available pools for a swap
|
|
613
|
-
* @property {Coin} nativeToken - The native token of the chain
|
|
614
|
-
* @property {ERC20} wrappedNativeToken - The wrapped native token of the chain
|
|
615
|
-
*/
|
|
616
|
-
type ExchangeOverrides = {
|
|
617
|
-
rpcURL: string;
|
|
618
|
-
exchangeContracts: ExchangeContracts;
|
|
619
|
-
commonRoutingTokens: ERC20[];
|
|
620
|
-
nativeToken: Coin;
|
|
621
|
-
wrappedNativeToken: ERC20;
|
|
622
|
-
};
|
|
623
|
-
|
|
624
|
-
/**
|
|
625
|
-
* @typedef {string} Address - Represents an Ethereum address.
|
|
626
|
-
*/
|
|
627
|
-
type Address = string;
|
|
628
|
-
/**
|
|
629
|
-
* @typedef {Address | 'NATIVE'} FungibleToken - Represents a fungible token, either an ERC20 token address or the native token.
|
|
630
|
-
*/
|
|
631
|
-
type FungibleToken = Address | 'NATIVE';
|
|
632
|
-
|
|
633
551
|
// TypeScript Version: 3.0
|
|
634
552
|
|
|
635
553
|
type AxiosRequestHeaders = Record<string, string | number | boolean>;
|
|
@@ -10173,6 +10091,27 @@ interface IMXProvider {
|
|
|
10173
10091
|
completeWithdrawal(starkPublicKey: string, token: AnyToken): Promise<TransactionResponse>;
|
|
10174
10092
|
}
|
|
10175
10093
|
|
|
10094
|
+
declare enum Environment {
|
|
10095
|
+
PRODUCTION = "production",
|
|
10096
|
+
SANDBOX = "sandbox"
|
|
10097
|
+
}
|
|
10098
|
+
declare class ImmutableConfiguration {
|
|
10099
|
+
readonly environment: Environment;
|
|
10100
|
+
readonly rateLimitingKey?: string;
|
|
10101
|
+
readonly apiKey?: string;
|
|
10102
|
+
readonly clientAppId?: string;
|
|
10103
|
+
constructor(options: {
|
|
10104
|
+
environment: Environment;
|
|
10105
|
+
rateLimitingKey?: string;
|
|
10106
|
+
apiKey?: string;
|
|
10107
|
+
clientAppId?: string;
|
|
10108
|
+
});
|
|
10109
|
+
}
|
|
10110
|
+
interface ModuleConfiguration<T> {
|
|
10111
|
+
baseConfig: ImmutableConfiguration;
|
|
10112
|
+
overrides?: T;
|
|
10113
|
+
}
|
|
10114
|
+
|
|
10176
10115
|
interface ImxOverrides {
|
|
10177
10116
|
immutableXConfig: ImmutableXConfiguration;
|
|
10178
10117
|
}
|
|
@@ -10713,6 +10652,7 @@ declare enum ChainName {
|
|
|
10713
10652
|
IMTBL_ZKEVM_DEVNET = "Immutable zkEVM Dev",
|
|
10714
10653
|
IMTBL_ZKEVM_MAINNET = "Immutable zkEVM"
|
|
10715
10654
|
}
|
|
10655
|
+
|
|
10716
10656
|
/**
|
|
10717
10657
|
* Represents information about a token.
|
|
10718
10658
|
* @interface TokenInfo
|
|
@@ -10729,6 +10669,7 @@ interface TokenInfo {
|
|
|
10729
10669
|
address?: string;
|
|
10730
10670
|
icon?: string;
|
|
10731
10671
|
}
|
|
10672
|
+
|
|
10732
10673
|
/**
|
|
10733
10674
|
* Interface representing the parameters for {@link Checkout.getBalance}.
|
|
10734
10675
|
* @property {Web3Provider} provider - The provider used to get the balance.
|
|
@@ -10769,6 +10710,7 @@ interface GetAllBalancesParams {
|
|
|
10769
10710
|
interface GetAllBalancesResult {
|
|
10770
10711
|
balances: GetBalanceResult[];
|
|
10771
10712
|
}
|
|
10713
|
+
|
|
10772
10714
|
interface OrderFee {
|
|
10773
10715
|
amount: FeeToken | FeePercentage;
|
|
10774
10716
|
recipient: string;
|
|
@@ -10779,6 +10721,7 @@ interface FeeToken {
|
|
|
10779
10721
|
interface FeePercentage {
|
|
10780
10722
|
percentageDecimal: number;
|
|
10781
10723
|
}
|
|
10724
|
+
|
|
10782
10725
|
type BuyResult = BuyResultSuccess | BuyResultFailed | BuyResultInsufficientFunds;
|
|
10783
10726
|
/**
|
|
10784
10727
|
* Represents the result of {@link Checkout.buy}
|
|
@@ -11316,6 +11259,7 @@ type AvailableRoutingOptions = {
|
|
|
11316
11259
|
swap?: boolean;
|
|
11317
11260
|
bridge?: boolean;
|
|
11318
11261
|
};
|
|
11262
|
+
|
|
11319
11263
|
/**
|
|
11320
11264
|
* Interface representing the parameters for {@link Checkout.buy}
|
|
11321
11265
|
* @property {Web3Provider} provider - The provider to use for the buy.
|
|
@@ -11326,6 +11270,7 @@ interface BuyParams {
|
|
|
11326
11270
|
provider: Web3Provider;
|
|
11327
11271
|
orders: Array<BuyOrder>;
|
|
11328
11272
|
}
|
|
11273
|
+
|
|
11329
11274
|
/**
|
|
11330
11275
|
* Interface representing the parameters for {@link Checkout.cancel}
|
|
11331
11276
|
* @property {Web3Provider} provider - The provider to use for the cancel.
|
|
@@ -11336,12 +11281,73 @@ interface CancelParams {
|
|
|
11336
11281
|
provider: Web3Provider;
|
|
11337
11282
|
orderIds: string[];
|
|
11338
11283
|
}
|
|
11284
|
+
|
|
11285
|
+
/**
|
|
11286
|
+
* Type representing an ERC20 token
|
|
11287
|
+
* @property {string} type - The token type, used to discriminate between {@link ERC20} and {@link Native}
|
|
11288
|
+
* @property {number} chainId - The chain ID
|
|
11289
|
+
* @property {string} address - The token address
|
|
11290
|
+
* @property {number} decimals - The token decimals
|
|
11291
|
+
* @property {string | undefined} symbol - The token symbol or undefined if it is not available
|
|
11292
|
+
* @property {string | undefined} name - The token name or undefined if it is not available
|
|
11293
|
+
*/
|
|
11294
|
+
type ERC20 = {
|
|
11295
|
+
type: 'erc20';
|
|
11296
|
+
chainId: number;
|
|
11297
|
+
address: string;
|
|
11298
|
+
decimals: number;
|
|
11299
|
+
symbol?: string;
|
|
11300
|
+
name?: string;
|
|
11301
|
+
};
|
|
11302
|
+
/**
|
|
11303
|
+
* Type representing a native token
|
|
11304
|
+
* @property {string} type - The token type, used to discriminate between {@link ERC20} and {@link Native}
|
|
11305
|
+
* @property {number} chainId - The chain ID
|
|
11306
|
+
* @property {number} decimals - The token decimals
|
|
11307
|
+
* @property {string | undefined} symbol - The token symbol or undefined if it is not available
|
|
11308
|
+
* @property {string | undefined} name - The token name or undefined if it is not available
|
|
11309
|
+
*/
|
|
11310
|
+
type Native = {
|
|
11311
|
+
type: 'native';
|
|
11312
|
+
chainId: number;
|
|
11313
|
+
decimals: number;
|
|
11314
|
+
symbol?: string;
|
|
11315
|
+
name?: string;
|
|
11316
|
+
};
|
|
11317
|
+
/**
|
|
11318
|
+
* Type representing a token, either an {@link ERC20} or {@link Native}
|
|
11319
|
+
*/
|
|
11320
|
+
type Coin = ERC20 | Native;
|
|
11321
|
+
/**
|
|
11322
|
+
* Type representing the overrides for the {@link Exchange} module
|
|
11323
|
+
* @property {string} rpcURL - The RPC URL for the chain
|
|
11324
|
+
* @property {ExchangeContracts} exchangeContracts - The DEX contract addresses
|
|
11325
|
+
* @property {ERC20[]} commonRoutingTokens - The tokens used to find available pools for a swap
|
|
11326
|
+
* @property {Coin} nativeToken - The native token of the chain
|
|
11327
|
+
* @property {ERC20} wrappedNativeToken - The wrapped native token of the chain
|
|
11328
|
+
*/
|
|
11329
|
+
type ExchangeOverrides = {
|
|
11330
|
+
rpcURL: string;
|
|
11331
|
+
exchangeContracts: ExchangeContracts;
|
|
11332
|
+
commonRoutingTokens: ERC20[];
|
|
11333
|
+
nativeToken: Coin;
|
|
11334
|
+
wrappedNativeToken: ERC20;
|
|
11335
|
+
};
|
|
11336
|
+
|
|
11339
11337
|
interface CheckoutOverrides {
|
|
11340
11338
|
}
|
|
11339
|
+
/**
|
|
11340
|
+
* A type representing checkout SDK configurations.
|
|
11341
|
+
* @property {boolean} isOnRampEnabled - To enable on-ramp feature in Checkout sdk.
|
|
11342
|
+
* @property {boolean} isSwapEnabled - To enable swap feature in Checkout sdk.
|
|
11343
|
+
* @property {boolean} isBridgeEnabled - To enable bridge feature in Checkout sdk.
|
|
11344
|
+
* @property {Passport} passport - To enable passport wallet with Checkout sdk.
|
|
11345
|
+
*/
|
|
11341
11346
|
interface CheckoutModuleConfiguration extends ModuleConfiguration<CheckoutOverrides> {
|
|
11342
11347
|
isOnRampEnabled?: boolean;
|
|
11343
11348
|
isSwapEnabled?: boolean;
|
|
11344
11349
|
isBridgeEnabled?: boolean;
|
|
11350
|
+
passport?: Passport;
|
|
11345
11351
|
}
|
|
11346
11352
|
/**
|
|
11347
11353
|
* A type representing various remotely defined configurations which are
|
|
@@ -11459,8 +11465,24 @@ type ChainTokensConfig = {
|
|
|
11459
11465
|
allowed?: TokenInfo[];
|
|
11460
11466
|
blockscout?: boolean;
|
|
11461
11467
|
};
|
|
11468
|
+
|
|
11462
11469
|
/**
|
|
11463
|
-
*
|
|
11470
|
+
* Represents information about a network.
|
|
11471
|
+
* @interface NetworkInfo
|
|
11472
|
+
* @property {string} name - The name of the network.
|
|
11473
|
+
* @property {number} chainId - The chain ID of the network.
|
|
11474
|
+
* @property {TokenInfo} nativeCurrency - Information about the native currency of the network.
|
|
11475
|
+
* @property {boolean} isSupported - Indicates whether the network is supported.
|
|
11476
|
+
*/
|
|
11477
|
+
interface NetworkInfo {
|
|
11478
|
+
name: string;
|
|
11479
|
+
chainId: number;
|
|
11480
|
+
nativeCurrency: TokenInfo;
|
|
11481
|
+
isSupported: boolean;
|
|
11482
|
+
}
|
|
11483
|
+
|
|
11484
|
+
/**
|
|
11485
|
+
* Interface representing the params of {@link Checkout.connect}.
|
|
11464
11486
|
* @property {Web3Provider} provider - The provider used to connect to the network.
|
|
11465
11487
|
*/
|
|
11466
11488
|
interface ConnectParams {
|
|
@@ -11469,9 +11491,11 @@ interface ConnectParams {
|
|
|
11469
11491
|
/**
|
|
11470
11492
|
* Interface representing the result of {@link Checkout.connect}.
|
|
11471
11493
|
* @property {Web3Provider} provider - The provider used to connect to the network.
|
|
11494
|
+
* @property {NetworkInfo} network - Information about the connected network.
|
|
11472
11495
|
*/
|
|
11473
11496
|
interface ConnectResult {
|
|
11474
11497
|
provider: Web3Provider;
|
|
11498
|
+
network: NetworkInfo;
|
|
11475
11499
|
}
|
|
11476
11500
|
/**
|
|
11477
11501
|
* Interface representing the params of {@link Checkout.checkIsWalletConnected}.
|
|
@@ -11489,6 +11513,16 @@ interface CheckConnectionResult {
|
|
|
11489
11513
|
isConnected: boolean;
|
|
11490
11514
|
walletAddress: string;
|
|
11491
11515
|
}
|
|
11516
|
+
|
|
11517
|
+
/**
|
|
11518
|
+
* @typedef {string} Address - Represents an Ethereum address.
|
|
11519
|
+
*/
|
|
11520
|
+
type Address = string;
|
|
11521
|
+
/**
|
|
11522
|
+
* @typedef {Address | 'NATIVE'} FungibleToken - Represents a fungible token, either an ERC20 token address or the native token.
|
|
11523
|
+
*/
|
|
11524
|
+
type FungibleToken = Address | 'NATIVE';
|
|
11525
|
+
|
|
11492
11526
|
/**
|
|
11493
11527
|
* An enum representing the type of gas estimate.
|
|
11494
11528
|
* @enum {string}
|
|
@@ -11552,20 +11586,7 @@ interface TokenAmountEstimate {
|
|
|
11552
11586
|
estimatedAmount?: BigNumber;
|
|
11553
11587
|
token?: TokenInfo;
|
|
11554
11588
|
}
|
|
11555
|
-
|
|
11556
|
-
* Represents information about a network.
|
|
11557
|
-
* @interface NetworkInfo
|
|
11558
|
-
* @property {string} name - The name of the network.
|
|
11559
|
-
* @property {number} chainId - The chain ID of the network.
|
|
11560
|
-
* @property {TokenInfo} nativeCurrency - Information about the native currency of the network.
|
|
11561
|
-
* @property {boolean} isSupported - Indicates whether the network is supported.
|
|
11562
|
-
*/
|
|
11563
|
-
interface NetworkInfo {
|
|
11564
|
-
name: string;
|
|
11565
|
-
chainId: number;
|
|
11566
|
-
nativeCurrency: TokenInfo;
|
|
11567
|
-
isSupported: boolean;
|
|
11568
|
-
}
|
|
11589
|
+
|
|
11569
11590
|
/**
|
|
11570
11591
|
* Interface representing the parameters for {@link Checkout.switchNetwork}.
|
|
11571
11592
|
* @property {Web3Provider} provider - The provider to connect to the network.
|
|
@@ -11621,6 +11642,7 @@ declare enum NetworkFilterTypes {
|
|
|
11621
11642
|
interface NetworkFilter {
|
|
11622
11643
|
chainId: ChainId;
|
|
11623
11644
|
}
|
|
11645
|
+
|
|
11624
11646
|
/**
|
|
11625
11647
|
* Interface representing the parameters for {@link Checkout.sell}
|
|
11626
11648
|
* @property {Web3Provider} provider - The provider to use for the sell.
|
|
@@ -11631,6 +11653,7 @@ interface SellParams {
|
|
|
11631
11653
|
provider: Web3Provider;
|
|
11632
11654
|
orders: Array<SellOrder>;
|
|
11633
11655
|
}
|
|
11656
|
+
|
|
11634
11657
|
/**
|
|
11635
11658
|
* Interface representing the parameters for {@link Checkout.getTokenAllowList}.
|
|
11636
11659
|
* @property {TokenFilterTypes} type - The type of token to retrieve.
|
|
@@ -11665,6 +11688,7 @@ declare enum TokenFilterTypes {
|
|
|
11665
11688
|
interface TokenFilter {
|
|
11666
11689
|
address: string;
|
|
11667
11690
|
}
|
|
11691
|
+
|
|
11668
11692
|
/**
|
|
11669
11693
|
* Interface representing the parameters for {@link Checkout.sendTransaction}.
|
|
11670
11694
|
* @property {Web3Provider} provider - The provider to connect to the network.
|
|
@@ -11681,6 +11705,7 @@ interface SendTransactionParams {
|
|
|
11681
11705
|
interface SendTransactionResult {
|
|
11682
11706
|
transactionResponse: TransactionResponse;
|
|
11683
11707
|
}
|
|
11708
|
+
|
|
11684
11709
|
/**
|
|
11685
11710
|
* Enum representing the names of different wallet providers.
|
|
11686
11711
|
*/
|
|
@@ -11691,29 +11716,27 @@ declare enum WalletProviderName {
|
|
|
11691
11716
|
/**
|
|
11692
11717
|
* Interface for the parameters required to create a wallet provider {@link Checkout.createProvider}.
|
|
11693
11718
|
* @interface CreateProviderParams
|
|
11694
|
-
* @property {WalletProviderName}
|
|
11695
|
-
* @property {Passport | undefined} passport - The Passport instance required to create a provider for passport users.
|
|
11696
|
-
* If walletProvider is 'passport', then the passport instance must be passed in.
|
|
11719
|
+
* @property {WalletProviderName} walletProviderName - The wallet provider name to create a provider for.
|
|
11697
11720
|
*/
|
|
11698
11721
|
interface CreateProviderParams {
|
|
11699
|
-
|
|
11700
|
-
passport?: Passport;
|
|
11722
|
+
walletProviderName: WalletProviderName;
|
|
11701
11723
|
}
|
|
11702
11724
|
/**
|
|
11703
11725
|
* Represents the result of creating a Web3 provider {@link Checkout.createProvider}.
|
|
11704
11726
|
* @property {Web3Provider} provider - The created Web3 provider.
|
|
11705
|
-
* @property {WalletProviderName}
|
|
11727
|
+
* @property {WalletProviderName} walletProviderName - The wallet provider name of the provider that was created.
|
|
11706
11728
|
*/
|
|
11707
11729
|
type CreateProviderResult = {
|
|
11708
11730
|
provider: Web3Provider;
|
|
11709
11731
|
walletProviderName: WalletProviderName;
|
|
11710
11732
|
};
|
|
11733
|
+
|
|
11711
11734
|
/**
|
|
11712
11735
|
* Interface representing a wallet filter to be used in {@link GetWalletAllowListParams}.
|
|
11713
|
-
* @property {WalletProviderName}
|
|
11736
|
+
* @property {WalletProviderName} walletProviderName - The wallet provider name to filter wallets by.
|
|
11714
11737
|
*/
|
|
11715
11738
|
interface WalletFilter {
|
|
11716
|
-
|
|
11739
|
+
walletProviderName: WalletProviderName;
|
|
11717
11740
|
}
|
|
11718
11741
|
/**
|
|
11719
11742
|
* Interface representing the parameters for {@link Checkout.getWalletAllowList}.
|
|
@@ -11726,14 +11749,12 @@ interface GetWalletAllowListParams {
|
|
|
11726
11749
|
}
|
|
11727
11750
|
/**
|
|
11728
11751
|
* Interface representing information about a wallet used in {@link GetWalletAllowListResult}.
|
|
11729
|
-
* @property {WalletProviderName}
|
|
11730
|
-
* @property {string} name - The name of the wallet.
|
|
11752
|
+
* @property {WalletProviderName} walletProviderName - The wallet provider name for the wallet.
|
|
11731
11753
|
* @property {string | undefined} description - A description of the wallet.
|
|
11732
11754
|
* @property {string | undefined} icon - The URL/data:image of an icon for the wallet.
|
|
11733
11755
|
*/
|
|
11734
11756
|
interface WalletInfo {
|
|
11735
|
-
|
|
11736
|
-
name: string;
|
|
11757
|
+
walletProviderName: WalletProviderName;
|
|
11737
11758
|
description?: string;
|
|
11738
11759
|
icon?: string;
|
|
11739
11760
|
}
|
|
@@ -11750,6 +11771,7 @@ interface GetWalletAllowListResult {
|
|
|
11750
11771
|
declare enum WalletFilterTypes {
|
|
11751
11772
|
ALL = "all"
|
|
11752
11773
|
}
|
|
11774
|
+
|
|
11753
11775
|
/**
|
|
11754
11776
|
* Base URL for the checkout API based on the environment.
|
|
11755
11777
|
* @property {string} DEVELOPMENT - The base URL for the development environment.
|
|
@@ -11769,6 +11791,7 @@ type NetworkDetails = {
|
|
|
11769
11791
|
blockExplorerUrls?: string[];
|
|
11770
11792
|
};
|
|
11771
11793
|
type NetworkMap = Map<ChainId, NetworkDetails>;
|
|
11794
|
+
|
|
11772
11795
|
/**
|
|
11773
11796
|
* An enum representing the type of exchange.
|
|
11774
11797
|
* @enum {string}
|
|
@@ -11790,71 +11813,27 @@ interface FiatRampParams {
|
|
|
11790
11813
|
web3Provider: Web3Provider;
|
|
11791
11814
|
tokenAmount?: string;
|
|
11792
11815
|
tokenAddress?: string;
|
|
11793
|
-
passport?:
|
|
11816
|
+
passport?: any;
|
|
11794
11817
|
}
|
|
11795
|
-
|
|
11796
|
-
* Enum representing different types of errors that can occur during the checkout process.
|
|
11797
|
-
*/
|
|
11798
|
-
declare enum CheckoutErrorType {
|
|
11799
|
-
WEB3_PROVIDER_ERROR = "WEB3_PROVIDER_ERROR",
|
|
11800
|
-
PROVIDER_ERROR = "PROVIDER_ERROR",
|
|
11801
|
-
DEFAULT_PROVIDER_ERROR = "DEFAULT_PROVIDER_ERROR",
|
|
11802
|
-
CONNECT_PROVIDER_ERROR = "CONNECT_PROVIDER_ERROR",
|
|
11803
|
-
GET_BALANCE_ERROR = "GET_BALANCE_ERROR",
|
|
11804
|
-
GET_INDEXER_BALANCE_ERROR = "GET_INDEXER_BALANCE_ERROR",
|
|
11805
|
-
GET_ERC20_BALANCE_ERROR = "GET_ERC20_BALANCE_ERROR",
|
|
11806
|
-
GET_ERC721_BALANCE_ERROR = "GET_ERC721_BALANCE_ERROR",
|
|
11807
|
-
GET_NETWORK_INFO_ERROR = "GET_NETWORK_INFO_ERROR",
|
|
11808
|
-
METAMASK_PROVIDER_ERROR = "METAMASK_PROVIDER_ERROR",
|
|
11809
|
-
CHAIN_NOT_SUPPORTED_ERROR = "CHAIN_NOT_SUPPORTED_ERROR",
|
|
11810
|
-
PROVIDER_REQUEST_MISSING_ERROR = "PROVIDER_REQUEST_MISSING_ERROR",
|
|
11811
|
-
PROVIDER_REQUEST_FAILED_ERROR = "PROVIDER_REQUEST_FAILED_ERROR",
|
|
11812
|
-
USER_REJECTED_REQUEST_ERROR = "USER_REJECTED_REQUEST_ERROR",
|
|
11813
|
-
TRANSACTION_FAILED = "TRANSACTION_FAILED",
|
|
11814
|
-
INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS",
|
|
11815
|
-
UNPREDICTABLE_GAS_LIMIT = "UNPREDICTABLE_GAS_LIMIT",
|
|
11816
|
-
INVALID_GAS_ESTIMATE_TYPE = "INVALID_GAS_ESTIMATE_TYPE",
|
|
11817
|
-
UNSUPPORTED_TOKEN_TYPE_ERROR = "UNSUPPORTED_TOKEN_TYPE_ERROR",
|
|
11818
|
-
UNSUPPORTED_BALANCE_REQUIREMENT_ERROR = "UNSUPPORTED_BALANCE_REQUIREMENT_ERROR",
|
|
11819
|
-
GET_ORDER_LISTING_ERROR = "GET_ORDER_LISTING_ERROR",
|
|
11820
|
-
CANCEL_ORDER_LISTING_ERROR = "CANCEL_ORDER_LISTING_ERROR",
|
|
11821
|
-
PREPARE_ORDER_LISTING_ERROR = "PREPARE_ORDER_LISTING_ERROR",
|
|
11822
|
-
CREATE_ORDER_LISTING_ERROR = "CREATE_ORDER_LISTING_ERROR",
|
|
11823
|
-
FULFILL_ORDER_LISTING_ERROR = "FULFILL_ORDER_LISTING_ERROR",
|
|
11824
|
-
SWITCH_NETWORK_UNSUPPORTED = "SWITCH_NETWORK_UNSUPPORTED",
|
|
11825
|
-
GET_ERC20_ALLOWANCE_ERROR = "GET_ERC20_ALLOWANCE_ERROR",
|
|
11826
|
-
GET_ERC721_ALLOWANCE_ERROR = "GET_ERC721_ALLOWANCE_ERROR",
|
|
11827
|
-
EXECUTE_APPROVAL_TRANSACTION_ERROR = "EXECUTE_APPROVAL_TRANSACTION_ERROR",
|
|
11828
|
-
EXECUTE_FULFILLMENT_TRANSACTION_ERROR = "EXECUTE_FULFILLMENT_TRANSACTION_ERROR",
|
|
11829
|
-
SIGN_MESSAGE_ERROR = "SIGN_MESSAGE_ERROR",
|
|
11830
|
-
BRIDGE_GAS_ESTIMATE_ERROR = "BRIDGE_GAS_ESTIMATE_ERROR",
|
|
11831
|
-
ORDER_FEE_ERROR = "ORDER_FEE_ERROR",
|
|
11832
|
-
ITEM_REQUIREMENTS_ERROR = "ITEM_REQUIREMENTS_ERROR",
|
|
11833
|
-
API_ERROR = "API_ERROR",
|
|
11834
|
-
ORDER_EXPIRED_ERROR = "ORDER_EXPIRED_ERROR"
|
|
11835
|
-
}
|
|
11836
|
-
/**
|
|
11837
|
-
* Represents an error object with a specific type, optional message, and optional data.
|
|
11838
|
-
* @property {CheckoutErrorType} type - The type of the error.
|
|
11839
|
-
* @property {string | undefined} [message] - The error message.
|
|
11840
|
-
* @property {Object.<string, string> | undefined} [data] - Additional data associated with the error.
|
|
11841
|
-
*/
|
|
11842
|
-
type ErrorType = {
|
|
11843
|
-
type: CheckoutErrorType;
|
|
11844
|
-
message?: string;
|
|
11845
|
-
data?: {
|
|
11846
|
-
[key: string]: string;
|
|
11847
|
-
};
|
|
11848
|
-
};
|
|
11818
|
+
|
|
11849
11819
|
type RemoteConfigParams = {
|
|
11850
11820
|
isDevelopment: boolean;
|
|
11851
11821
|
isProduction: boolean;
|
|
11852
11822
|
};
|
|
11853
11823
|
declare class RemoteConfigFetcher {
|
|
11824
|
+
private isDevelopment;
|
|
11825
|
+
private isProduction;
|
|
11826
|
+
private configCache;
|
|
11827
|
+
private tokensCache;
|
|
11854
11828
|
constructor(params: RemoteConfigParams);
|
|
11829
|
+
private static makeHttpRequest;
|
|
11830
|
+
private getEndpoint;
|
|
11831
|
+
private loadConfig;
|
|
11832
|
+
private loadConfigTokens;
|
|
11855
11833
|
getConfig(key?: keyof RemoteConfiguration): Promise<RemoteConfiguration | RemoteConfiguration[keyof RemoteConfiguration] | undefined>;
|
|
11856
11834
|
getTokensConfig(chainId: ChainId): Promise<ChainTokensConfig>;
|
|
11857
11835
|
}
|
|
11836
|
+
|
|
11858
11837
|
declare class CheckoutConfiguration {
|
|
11859
11838
|
readonly isDevelopment: boolean;
|
|
11860
11839
|
readonly isProduction: boolean;
|
|
@@ -11866,9 +11845,7 @@ declare class CheckoutConfiguration {
|
|
|
11866
11845
|
readonly networkMap: NetworkMap;
|
|
11867
11846
|
constructor(config: CheckoutModuleConfiguration);
|
|
11868
11847
|
}
|
|
11869
|
-
|
|
11870
|
-
checkDexAvailability: () => Promise<boolean>;
|
|
11871
|
-
};
|
|
11848
|
+
|
|
11872
11849
|
interface FiatRampWidgetParams {
|
|
11873
11850
|
exchangeType: ExchangeType;
|
|
11874
11851
|
isPassport: boolean;
|
|
@@ -11886,16 +11863,600 @@ declare class FiatRampService {
|
|
|
11886
11863
|
constructor(config: CheckoutConfiguration);
|
|
11887
11864
|
feeEstimate(): Promise<OnRampProviderFees>;
|
|
11888
11865
|
createWidgetUrl(params: FiatRampWidgetParams): Promise<string>;
|
|
11866
|
+
private getTransakWidgetUrl;
|
|
11867
|
+
}
|
|
11868
|
+
|
|
11869
|
+
type AvailabilityService = {
|
|
11870
|
+
checkDexAvailability: () => Promise<boolean>;
|
|
11871
|
+
};
|
|
11872
|
+
|
|
11873
|
+
/**
|
|
11874
|
+
* Enum representing the themes for the widgets.
|
|
11875
|
+
*/
|
|
11876
|
+
declare enum WidgetTheme {
|
|
11877
|
+
LIGHT = "light",
|
|
11878
|
+
DARK = "dark"
|
|
11879
|
+
}
|
|
11880
|
+
|
|
11881
|
+
/**
|
|
11882
|
+
* Represents the local configuration options for the Checkout Widgets.
|
|
11883
|
+
* @property {WidgetTheme | undefined} theme - The theme of the Checkout Widget (default: "DARK")
|
|
11884
|
+
*/
|
|
11885
|
+
type WidgetConfiguration = {
|
|
11886
|
+
theme?: WidgetTheme;
|
|
11887
|
+
};
|
|
11888
|
+
|
|
11889
|
+
/**
|
|
11890
|
+
* Enum representing the events emitted by the widgets.
|
|
11891
|
+
*/
|
|
11892
|
+
declare enum IMTBLWidgetEvents {
|
|
11893
|
+
IMTBL_WIDGETS_PROVIDER = "imtbl-widgets-provider",
|
|
11894
|
+
IMTBL_CONNECT_WIDGET_EVENT = "imtbl-connect-widget",
|
|
11895
|
+
IMTBL_WALLET_WIDGET_EVENT = "imtbl-wallet-widget",
|
|
11896
|
+
IMTBL_SWAP_WIDGET_EVENT = "imtbl-swap-widget",
|
|
11897
|
+
IMTBL_BRIDGE_WIDGET_EVENT = "imtbl-bridge-widget",
|
|
11898
|
+
IMTBL_ONRAMP_WIDGET_EVENT = "imtbl-onramp-widget",
|
|
11899
|
+
IMTBL_SALE_WIDGET_EVENT = "imtbl-sale-widget"
|
|
11900
|
+
}
|
|
11901
|
+
/**
|
|
11902
|
+
* Enum for events raised for about provider objects
|
|
11903
|
+
*/
|
|
11904
|
+
declare enum ProviderEventType {
|
|
11905
|
+
PROVIDER_UPDATED = "PROVIDER_UPDATED"
|
|
11906
|
+
}
|
|
11907
|
+
/**
|
|
11908
|
+
* Payload type for the PROVIDER_UPDATED event
|
|
11909
|
+
*/
|
|
11910
|
+
type ProviderUpdated = {
|
|
11911
|
+
provider: Web3Provider;
|
|
11912
|
+
};
|
|
11913
|
+
|
|
11914
|
+
/**
|
|
11915
|
+
* Enum representing possible Connect Widget event types.
|
|
11916
|
+
*/
|
|
11917
|
+
declare enum ConnectEventType {
|
|
11918
|
+
CLOSE_WIDGET = "close-widget",
|
|
11919
|
+
SUCCESS = "success",
|
|
11920
|
+
FAILURE = "failure"
|
|
11921
|
+
}
|
|
11922
|
+
/**
|
|
11923
|
+
* Represents a successful connection.
|
|
11924
|
+
* @property {Web3Provider} provider - The connected provider.
|
|
11925
|
+
* @property {WalletProviderName | undefined} walletProviderName - The wallet provider name of the connected provider.
|
|
11926
|
+
*/
|
|
11927
|
+
type ConnectionSuccess = {
|
|
11928
|
+
provider: Web3Provider;
|
|
11929
|
+
walletProviderName: WalletProviderName | undefined;
|
|
11930
|
+
};
|
|
11931
|
+
/**
|
|
11932
|
+
* Represents a connection failure with a reason.
|
|
11933
|
+
* @property {string} reason - The reason for the failed connection.
|
|
11934
|
+
*/
|
|
11935
|
+
type ConnectionFailed = {
|
|
11936
|
+
reason: string;
|
|
11937
|
+
};
|
|
11938
|
+
|
|
11939
|
+
/**
|
|
11940
|
+
* Enum representing possible Wallet Widget event types.
|
|
11941
|
+
*/
|
|
11942
|
+
declare enum WalletEventType {
|
|
11943
|
+
CLOSE_WIDGET = "close-widget",
|
|
11944
|
+
NETWORK_SWITCH = "network-switch",
|
|
11945
|
+
DISCONNECT_WALLET = "disconnect-wallet"
|
|
11889
11946
|
}
|
|
11947
|
+
/**
|
|
11948
|
+
* Represents an event that is triggered when the user switches the network in their wallet.
|
|
11949
|
+
* @property {string} network - The name of the network that the user switched to.
|
|
11950
|
+
* @property {number} chainId - The chain ID of the network that the user switched to.
|
|
11951
|
+
* @property {Web3Provider} provider - The Web3 provider object for the switched network.
|
|
11952
|
+
*/
|
|
11953
|
+
type WalletNetworkSwitchEvent = {
|
|
11954
|
+
network: string;
|
|
11955
|
+
chainId: number;
|
|
11956
|
+
provider: Web3Provider;
|
|
11957
|
+
};
|
|
11958
|
+
/**
|
|
11959
|
+
* Represents an event that is triggered when a wallet is disconnected.
|
|
11960
|
+
*/
|
|
11961
|
+
type WalletDisconnectWalletEvent = {};
|
|
11962
|
+
|
|
11963
|
+
/**
|
|
11964
|
+
* Enum representing possible Swap Widget event types.
|
|
11965
|
+
*/
|
|
11966
|
+
declare enum SwapEventType {
|
|
11967
|
+
CLOSE_WIDGET = "close-widget",
|
|
11968
|
+
SUCCESS = "success",
|
|
11969
|
+
FAILURE = "failure",
|
|
11970
|
+
REJECTED = "rejected"
|
|
11971
|
+
}
|
|
11972
|
+
/**
|
|
11973
|
+
* Represents a successful swap transaction.
|
|
11974
|
+
* @property {string} transactionHash - The hash of the successful transaction.
|
|
11975
|
+
*/
|
|
11976
|
+
type SwapSuccess = {
|
|
11977
|
+
transactionHash: string;
|
|
11978
|
+
};
|
|
11979
|
+
/**
|
|
11980
|
+
* Type representing a Swap Widget with type FAILURE.
|
|
11981
|
+
* @property {string} reason - The reason why the swap failed.
|
|
11982
|
+
* @property {number} timestamp - The timestamp of the failed swap.
|
|
11983
|
+
*/
|
|
11984
|
+
type SwapFailed = {
|
|
11985
|
+
reason: string;
|
|
11986
|
+
timestamp: number;
|
|
11987
|
+
};
|
|
11988
|
+
/**
|
|
11989
|
+
* Type representing a Swap Widget with type FAILURE.
|
|
11990
|
+
* @property {string} reason - The reason why the swap failed.
|
|
11991
|
+
* @property {number} timestamp - The timestamp of the failed swap.
|
|
11992
|
+
*/
|
|
11993
|
+
type SwapRejected = {
|
|
11994
|
+
reason: string;
|
|
11995
|
+
timestamp: number;
|
|
11996
|
+
};
|
|
11997
|
+
|
|
11998
|
+
/**
|
|
11999
|
+
* Enum representing possible Sale Widget event types.
|
|
12000
|
+
*/
|
|
12001
|
+
declare enum SaleEventType {
|
|
12002
|
+
CLOSE_WIDGET = "close-widget",
|
|
12003
|
+
SUCCESS = "success",
|
|
12004
|
+
FAILURE = "failure",
|
|
12005
|
+
REJECTED = "rejected"
|
|
12006
|
+
}
|
|
12007
|
+
/**
|
|
12008
|
+
* Represents a successful Sale transaction.
|
|
12009
|
+
* @property {string} transactionHash - The hash of the successful transaction.
|
|
12010
|
+
*/
|
|
12011
|
+
type SaleSuccess = {
|
|
12012
|
+
transactions: {
|
|
12013
|
+
method: string;
|
|
12014
|
+
hash: string | undefined;
|
|
12015
|
+
}[];
|
|
12016
|
+
[key: string]: unknown;
|
|
12017
|
+
};
|
|
12018
|
+
/**
|
|
12019
|
+
* Type representing a Sale Widget with type FAILURE.
|
|
12020
|
+
* @property {string} reason - The reason why the swap failed.
|
|
12021
|
+
* @property {number} timestamp - The timestamp of the failed swap.
|
|
12022
|
+
*/
|
|
12023
|
+
type SaleFailed = {
|
|
12024
|
+
reason: string;
|
|
12025
|
+
timestamp: number;
|
|
12026
|
+
};
|
|
12027
|
+
|
|
12028
|
+
/**
|
|
12029
|
+
* Enum of possible Bridge Widget event types.
|
|
12030
|
+
*/
|
|
12031
|
+
declare enum BridgeEventType {
|
|
12032
|
+
CLOSE_WIDGET = "close-widget",
|
|
12033
|
+
SUCCESS = "success",
|
|
12034
|
+
FAILURE = "failure"
|
|
12035
|
+
}
|
|
12036
|
+
/**
|
|
12037
|
+
* Represents a successful bridge transaction.
|
|
12038
|
+
* @property {string} transactionHash - The hash of the successful transaction.
|
|
12039
|
+
*/
|
|
12040
|
+
type BridgeSuccess = {
|
|
12041
|
+
transactionHash: string;
|
|
12042
|
+
};
|
|
12043
|
+
/**
|
|
12044
|
+
* Represents a failed bridge transaction.
|
|
12045
|
+
* @property {string} reason - The reason for the failed transaction.
|
|
12046
|
+
* @property {number} timestamp - The timestamp of the failed transaction.
|
|
12047
|
+
*/
|
|
12048
|
+
type BridgeFailed = {
|
|
12049
|
+
reason: string;
|
|
12050
|
+
timestamp: number;
|
|
12051
|
+
};
|
|
12052
|
+
|
|
12053
|
+
/**
|
|
12054
|
+
* Enum representing different types of orchestration events.
|
|
12055
|
+
*/
|
|
12056
|
+
declare enum OrchestrationEventType {
|
|
12057
|
+
REQUEST_CONNECT = "request-connect",
|
|
12058
|
+
REQUEST_WALLET = "request-wallet",
|
|
12059
|
+
REQUEST_SWAP = "request-swap",
|
|
12060
|
+
REQUEST_BRIDGE = "request-bridge",
|
|
12061
|
+
REQUEST_ONRAMP = "request-onramp"
|
|
12062
|
+
}
|
|
12063
|
+
/**
|
|
12064
|
+
* Represents the connect event object when the connect widget is requested.
|
|
12065
|
+
* @property {string} walletProviderName - The wallet provider name.
|
|
12066
|
+
*/
|
|
12067
|
+
type RequestConnectEvent = {
|
|
12068
|
+
walletProviderName: string;
|
|
12069
|
+
};
|
|
12070
|
+
/**
|
|
12071
|
+
* Represents the wallet event object when the wallet widget is requested.
|
|
12072
|
+
* @property {string} walletProviderName - The wallet provider name.
|
|
12073
|
+
*/
|
|
12074
|
+
type RequestWalletEvent = {
|
|
12075
|
+
walletProviderName: string;
|
|
12076
|
+
};
|
|
12077
|
+
/**
|
|
12078
|
+
* Represents the swap event object when the swap widget is requested.
|
|
12079
|
+
* @property {string} fromTokenAddress - The address of the token to swap from.
|
|
12080
|
+
* @property {string} toTokenAddress - The address of the token to swap to.
|
|
12081
|
+
* @property {string} amount - The amount of from tokens to swap.
|
|
12082
|
+
*/
|
|
12083
|
+
type RequestSwapEvent = {
|
|
12084
|
+
fromTokenAddress: string;
|
|
12085
|
+
toTokenAddress: string;
|
|
12086
|
+
amount: string;
|
|
12087
|
+
};
|
|
12088
|
+
/**
|
|
12089
|
+
* Represents the bridge event object when the bridge widget is requested.
|
|
12090
|
+
* @property {string} tokenAddress - The address of the token to bridge.
|
|
12091
|
+
* @property {string} amount - The amount of tokens to bridge.
|
|
12092
|
+
*/
|
|
12093
|
+
type RequestBridgeEvent = {
|
|
12094
|
+
tokenAddress: string;
|
|
12095
|
+
amount: string;
|
|
12096
|
+
};
|
|
12097
|
+
/**
|
|
12098
|
+
* Represents the onramp event object when the onramp widget is requested.
|
|
12099
|
+
* @property {string} tokenAddress - The address of the token to be used for onramp.
|
|
12100
|
+
* @property {string} amount - The amount of tokens to onramp.
|
|
12101
|
+
*/
|
|
12102
|
+
type RequestOnrampEvent = {
|
|
12103
|
+
tokenAddress: string;
|
|
12104
|
+
amount: string;
|
|
12105
|
+
};
|
|
12106
|
+
type OrchestrationEventData = RequestConnectEvent | RequestWalletEvent | RequestSwapEvent | RequestBridgeEvent | RequestOnrampEvent;
|
|
12107
|
+
|
|
12108
|
+
/**
|
|
12109
|
+
* Enum of possible OnRamp Widget event types.
|
|
12110
|
+
*/
|
|
12111
|
+
declare enum OnRampEventType {
|
|
12112
|
+
CLOSE_WIDGET = "close-widget",
|
|
12113
|
+
SUCCESS = "success",
|
|
12114
|
+
FAILURE = "failure"
|
|
12115
|
+
}
|
|
12116
|
+
/**
|
|
12117
|
+
* Represents a successful on-ramp transaction.
|
|
12118
|
+
* @property {string} transactionHash - The transaction hash of the successful transaction.
|
|
12119
|
+
*/
|
|
12120
|
+
type OnRampSuccess = {
|
|
12121
|
+
transactionHash: string;
|
|
12122
|
+
};
|
|
12123
|
+
/**
|
|
12124
|
+
* Type representing a On-ramp Widget with type FAILURE.
|
|
12125
|
+
* @property {string} reason - The reason why the on-ramp failed.
|
|
12126
|
+
* @property {number} timestamp - The timestamp of the failed transaction.
|
|
12127
|
+
*/
|
|
12128
|
+
type OnRampFailed = {
|
|
12129
|
+
reason: string;
|
|
12130
|
+
timestamp: number;
|
|
12131
|
+
};
|
|
12132
|
+
|
|
12133
|
+
declare enum ConnectTargetLayer {
|
|
12134
|
+
LAYER1 = "LAYER1",
|
|
12135
|
+
LAYER2 = "LAYER2"
|
|
12136
|
+
}
|
|
12137
|
+
type ConnectWidgetParams = {
|
|
12138
|
+
web3Provider?: Web3Provider;
|
|
12139
|
+
};
|
|
12140
|
+
|
|
12141
|
+
/**
|
|
12142
|
+
* Bridge Widget parameters
|
|
12143
|
+
* @property {string | undefined} fromContractAddress - The contract address of the token to bridge from, used to populate the bridge form token field
|
|
12144
|
+
* @property {string | undefined} amount - The formatted amount to bridge, used to populate the bridge form amount field
|
|
12145
|
+
* @property {WalletProviderName | undefined} walletProviderName - The wallet provider name to use for the bridge widget
|
|
12146
|
+
* @property {Web3Provider | undefined} web3Provider - The ethers Web3Provider
|
|
12147
|
+
*/
|
|
12148
|
+
type BridgeWidgetParams = {
|
|
12149
|
+
fromContractAddress?: string;
|
|
12150
|
+
amount?: string;
|
|
12151
|
+
walletProviderName?: WalletProviderName;
|
|
12152
|
+
web3Provider?: Web3Provider;
|
|
12153
|
+
};
|
|
12154
|
+
|
|
12155
|
+
/**
|
|
12156
|
+
* Wallet Widget parameters
|
|
12157
|
+
* @property {WalletProviderName | undefined} walletProviderName - The wallet provider name to use for the wallet widget
|
|
12158
|
+
* @property {Web3Provider | undefined} web3Provider - The ethers Web3Provider
|
|
12159
|
+
*/
|
|
12160
|
+
type WalletWidgetParams = {
|
|
12161
|
+
walletProviderName?: WalletProviderName;
|
|
12162
|
+
web3Provider?: Web3Provider;
|
|
12163
|
+
};
|
|
12164
|
+
|
|
12165
|
+
/**
|
|
12166
|
+
* Swap Widget parameters
|
|
12167
|
+
* @property {string | undefined} amount - The formatted amount to swap, used to populate the swap from amount field
|
|
12168
|
+
* @property {string | undefined} fromContractAddress - The contract address of the token to swap from
|
|
12169
|
+
* @property {string | undefined} toContractAddress - The contract address of the token to swap to
|
|
12170
|
+
* @property {WalletProviderName | undefined} walletProviderName - The wallet provider name to use for the swap widget
|
|
12171
|
+
* @property {Web3Provider | undefined} web3Provider - The ethers Web3Provider
|
|
12172
|
+
*/
|
|
12173
|
+
interface SwapWidgetParams {
|
|
12174
|
+
amount?: string;
|
|
12175
|
+
fromContractAddress?: string;
|
|
12176
|
+
toContractAddress?: string;
|
|
12177
|
+
walletProviderName?: WalletProviderName;
|
|
12178
|
+
web3Provider?: Web3Provider;
|
|
12179
|
+
}
|
|
12180
|
+
|
|
12181
|
+
/**
|
|
12182
|
+
* OnRamp Widget parameters
|
|
12183
|
+
* @property {string | undefined} contractAddress - The contract address of the token to onramp
|
|
12184
|
+
* @property {string | undefined} amount - The formatted amount to onramp, used to populate the onramp form amount field
|
|
12185
|
+
* @property {WalletProviderName | undefined} walletProviderName - The wallet provider name to use for the onramp widget
|
|
12186
|
+
* @property {Web3Provider | undefined} web3Provider - The ethers Web3Provider
|
|
12187
|
+
*/
|
|
12188
|
+
type OnRampWidgetParams = {
|
|
12189
|
+
contractAddress?: string;
|
|
12190
|
+
amount?: string;
|
|
12191
|
+
walletProviderName?: WalletProviderName;
|
|
12192
|
+
web3Provider?: Web3Provider;
|
|
12193
|
+
};
|
|
12194
|
+
|
|
12195
|
+
/**
|
|
12196
|
+
* Sale Widget parameters
|
|
12197
|
+
* @property {string} amount - The total price to pay for the items in the sale
|
|
12198
|
+
* @property {SaleItem[]} items - The list of products to be purchased
|
|
12199
|
+
* @property {WalletProviderName | undefined} walletProviderName - The wallet provider name to default to if no web3Provider is passed
|
|
12200
|
+
* @property {Web3Provider | undefined} web3Provider - The ethers Web3Provider
|
|
12201
|
+
*/
|
|
12202
|
+
type SaleWidgetParams = {
|
|
12203
|
+
amount?: string;
|
|
12204
|
+
environmentId?: string;
|
|
12205
|
+
fromContractAddress?: string;
|
|
12206
|
+
items?: SaleItem[];
|
|
12207
|
+
walletProviderName?: WalletProviderName;
|
|
12208
|
+
web3Provider?: Web3Provider;
|
|
12209
|
+
};
|
|
12210
|
+
type SaleItem = {
|
|
12211
|
+
productId: string;
|
|
12212
|
+
qty: number;
|
|
12213
|
+
name: string;
|
|
12214
|
+
image: string;
|
|
12215
|
+
description: string;
|
|
12216
|
+
};
|
|
12217
|
+
|
|
12218
|
+
type ConnectWidgetConfiguration = {} & WidgetConfiguration;
|
|
12219
|
+
|
|
12220
|
+
type BridgeWidgetConfiguration = {} & WidgetConfiguration;
|
|
12221
|
+
|
|
12222
|
+
type WalletWidgetConfiguration = {} & WidgetConfiguration;
|
|
12223
|
+
|
|
12224
|
+
type SwapWidgetConfiguration = {} & WidgetConfiguration;
|
|
12225
|
+
|
|
12226
|
+
type OnrampWidgetConfiguration = {} & WidgetConfiguration;
|
|
12227
|
+
|
|
12228
|
+
type SaleWidgetConfiguration = {} & WidgetConfiguration;
|
|
12229
|
+
|
|
12230
|
+
/**
|
|
12231
|
+
* Enum representing the list of widget types.
|
|
12232
|
+
*/
|
|
12233
|
+
declare enum WidgetType {
|
|
12234
|
+
CONNECT = "connect",
|
|
12235
|
+
WALLET = "wallet",
|
|
12236
|
+
SWAP = "swap",
|
|
12237
|
+
BRIDGE = "bridge",
|
|
12238
|
+
ONRAMP = "onramp",
|
|
12239
|
+
SALE = "sale"
|
|
12240
|
+
}
|
|
12241
|
+
/**
|
|
12242
|
+
* Widget properties definition for each widget. Used for creating and updating widgets
|
|
12243
|
+
*/
|
|
12244
|
+
type WidgetProperties<T extends WidgetType> = {
|
|
12245
|
+
config?: WidgetConfigurations[T];
|
|
12246
|
+
provider?: Web3Provider;
|
|
12247
|
+
};
|
|
12248
|
+
type WidgetConfigurations = {
|
|
12249
|
+
[WidgetType.CONNECT]: ConnectWidgetConfiguration;
|
|
12250
|
+
[WidgetType.WALLET]: WalletWidgetConfiguration;
|
|
12251
|
+
[WidgetType.SWAP]: SwapWidgetConfiguration;
|
|
12252
|
+
[WidgetType.BRIDGE]: BridgeWidgetConfiguration;
|
|
12253
|
+
[WidgetType.ONRAMP]: OnrampWidgetConfiguration;
|
|
12254
|
+
[WidgetType.SALE]: SaleWidgetConfiguration;
|
|
12255
|
+
};
|
|
12256
|
+
type WidgetParameters = {
|
|
12257
|
+
[WidgetType.CONNECT]: ConnectWidgetParams;
|
|
12258
|
+
[WidgetType.WALLET]: WalletWidgetParams;
|
|
12259
|
+
[WidgetType.SWAP]: SwapWidgetParams;
|
|
12260
|
+
[WidgetType.BRIDGE]: BridgeWidgetParams;
|
|
12261
|
+
[WidgetType.ONRAMP]: OnRampWidgetParams;
|
|
12262
|
+
[WidgetType.SALE]: SaleWidgetParams;
|
|
12263
|
+
};
|
|
12264
|
+
/**
|
|
12265
|
+
* Represents all the possible event types that are emitted by the widgets.
|
|
12266
|
+
*/
|
|
12267
|
+
type WidgetEventTypes = {
|
|
12268
|
+
[WidgetType.CONNECT]: ConnectEventType | OrchestrationEventType;
|
|
12269
|
+
[WidgetType.WALLET]: WalletEventType | OrchestrationEventType;
|
|
12270
|
+
[WidgetType.SWAP]: SwapEventType | OrchestrationEventType;
|
|
12271
|
+
[WidgetType.BRIDGE]: BridgeEventType | OrchestrationEventType;
|
|
12272
|
+
[WidgetType.ONRAMP]: OnRampEventType | OrchestrationEventType;
|
|
12273
|
+
[WidgetType.SALE]: SaleEventType | OrchestrationEventType;
|
|
12274
|
+
};
|
|
12275
|
+
type OrchestrationMapping = {
|
|
12276
|
+
[OrchestrationEventType.REQUEST_CONNECT]: RequestConnectEvent;
|
|
12277
|
+
[OrchestrationEventType.REQUEST_WALLET]: RequestWalletEvent;
|
|
12278
|
+
[OrchestrationEventType.REQUEST_SWAP]: RequestSwapEvent;
|
|
12279
|
+
[OrchestrationEventType.REQUEST_BRIDGE]: RequestBridgeEvent;
|
|
12280
|
+
[OrchestrationEventType.REQUEST_ONRAMP]: RequestOnrampEvent;
|
|
12281
|
+
};
|
|
12282
|
+
type ProviderEventMapping = {
|
|
12283
|
+
[ProviderEventType.PROVIDER_UPDATED]: ProviderUpdated;
|
|
12284
|
+
};
|
|
12285
|
+
/**
|
|
12286
|
+
* Mapping of widget type, to each of it's events and then each event's payload
|
|
12287
|
+
* Update this whenever a new event is created and used by a widget
|
|
12288
|
+
* Each widget also has all of the orchestration events
|
|
12289
|
+
*/
|
|
12290
|
+
type WidgetEventData = {
|
|
12291
|
+
[WidgetType.CONNECT]: {
|
|
12292
|
+
[ConnectEventType.SUCCESS]: ConnectionSuccess;
|
|
12293
|
+
[ConnectEventType.FAILURE]: ConnectionFailed;
|
|
12294
|
+
[ConnectEventType.CLOSE_WIDGET]: {};
|
|
12295
|
+
} & OrchestrationMapping & ProviderEventMapping;
|
|
12296
|
+
[WidgetType.WALLET]: {
|
|
12297
|
+
[WalletEventType.NETWORK_SWITCH]: WalletNetworkSwitchEvent;
|
|
12298
|
+
[WalletEventType.DISCONNECT_WALLET]: WalletDisconnectWalletEvent;
|
|
12299
|
+
[WalletEventType.CLOSE_WIDGET]: {};
|
|
12300
|
+
} & OrchestrationMapping & ProviderEventMapping;
|
|
12301
|
+
[WidgetType.SWAP]: {
|
|
12302
|
+
[SwapEventType.SUCCESS]: SwapSuccess;
|
|
12303
|
+
[SwapEventType.FAILURE]: SwapFailed;
|
|
12304
|
+
[SwapEventType.REJECTED]: SwapRejected;
|
|
12305
|
+
[SwapEventType.CLOSE_WIDGET]: {};
|
|
12306
|
+
} & OrchestrationMapping & ProviderEventMapping;
|
|
12307
|
+
[WidgetType.BRIDGE]: {
|
|
12308
|
+
[BridgeEventType.SUCCESS]: BridgeSuccess;
|
|
12309
|
+
[BridgeEventType.FAILURE]: BridgeFailed;
|
|
12310
|
+
[BridgeEventType.CLOSE_WIDGET]: {};
|
|
12311
|
+
} & OrchestrationMapping & ProviderEventMapping;
|
|
12312
|
+
[WidgetType.ONRAMP]: {
|
|
12313
|
+
[OnRampEventType.SUCCESS]: OnRampSuccess;
|
|
12314
|
+
[OnRampEventType.FAILURE]: OnRampFailed;
|
|
12315
|
+
[OnRampEventType.CLOSE_WIDGET]: {};
|
|
12316
|
+
} & OrchestrationMapping & ProviderEventMapping;
|
|
12317
|
+
[WidgetType.SALE]: {
|
|
12318
|
+
[SaleEventType.SUCCESS]: SaleSuccess;
|
|
12319
|
+
[SaleEventType.FAILURE]: SaleFailed;
|
|
12320
|
+
[SaleEventType.REJECTED]: any;
|
|
12321
|
+
[SaleEventType.CLOSE_WIDGET]: {};
|
|
12322
|
+
} & OrchestrationMapping & ProviderEventMapping;
|
|
12323
|
+
};
|
|
12324
|
+
/**
|
|
12325
|
+
* Represents an event emitted by a widget. The event type should match the event data
|
|
12326
|
+
*/
|
|
12327
|
+
/**
|
|
12328
|
+
* Represents an event emitted by a widget.
|
|
12329
|
+
* @template T - The widget type
|
|
12330
|
+
* @template KEventName - The widget event name.
|
|
12331
|
+
* @property {KEventName} type - The type of the event.
|
|
12332
|
+
* @property {WidgetEventData[T][KEventName]} data - The data associated with the widget event.
|
|
12333
|
+
*/
|
|
12334
|
+
type WidgetEvent<T extends WidgetType, KEventName extends keyof WidgetEventData[T]> = {
|
|
12335
|
+
type: KEventName;
|
|
12336
|
+
data: WidgetEventData[T][KEventName];
|
|
12337
|
+
};
|
|
12338
|
+
/**
|
|
12339
|
+
* Represents an event emitted by a widget.
|
|
12340
|
+
* @template KEventName - The orchestration event name.
|
|
12341
|
+
* @property {KEventName} type - The type of the event.
|
|
12342
|
+
* @property {OrchestrationMapping[KEventName]} data - The data associated with the event.
|
|
12343
|
+
*/
|
|
12344
|
+
type OrchestrationEvent<KEventName extends keyof OrchestrationMapping> = {
|
|
12345
|
+
type: KEventName;
|
|
12346
|
+
data: OrchestrationMapping[KEventName];
|
|
12347
|
+
};
|
|
12348
|
+
/**
|
|
12349
|
+
* Represents an event emitted by a widget.
|
|
12350
|
+
* @template KEventName - The provider event name.
|
|
12351
|
+
* @property {KEventName} type - The type of the event.
|
|
12352
|
+
* @property {ProviderEventMapping[KEventName]} data - The data associated with the event.
|
|
12353
|
+
*/
|
|
12354
|
+
type ProviderEvent<KEventName extends keyof ProviderEventMapping> = {
|
|
12355
|
+
type: KEventName;
|
|
12356
|
+
data: ProviderEventMapping[KEventName];
|
|
12357
|
+
};
|
|
12358
|
+
interface IWidgetsFactory {
|
|
12359
|
+
/**
|
|
12360
|
+
* Create a new widget instance.
|
|
12361
|
+
* @param type widget type to instantiate.
|
|
12362
|
+
*/
|
|
12363
|
+
create<T extends WidgetType>(type: T, config: WidgetConfigurations[T], provider?: Web3Provider): Widget<T>;
|
|
12364
|
+
}
|
|
12365
|
+
/**
|
|
12366
|
+
* Widget interface. Every widget implements this interface.
|
|
12367
|
+
*/
|
|
12368
|
+
interface Widget<T extends WidgetType> {
|
|
12369
|
+
/**
|
|
12370
|
+
* Mount a widget to a DOM ref element.
|
|
12371
|
+
* @param id ID of the DOM element where the widget will be mounted.
|
|
12372
|
+
*/
|
|
12373
|
+
mount(id: string, params: WidgetParameters[T]): void;
|
|
12374
|
+
/**
|
|
12375
|
+
* Unmount a widget and reset parameters
|
|
12376
|
+
*/
|
|
12377
|
+
unmount(): void;
|
|
12378
|
+
/**
|
|
12379
|
+
* Update the widget parameters
|
|
12380
|
+
* @param params Widget specific parameters including configuration
|
|
12381
|
+
*/
|
|
12382
|
+
update(params: WidgetProperties<T>): void;
|
|
12383
|
+
/**
|
|
12384
|
+
* Add a listener for a widget event.
|
|
12385
|
+
* @param event Widget specific event name.
|
|
12386
|
+
* @param callback function to execute when the event is received.
|
|
12387
|
+
*/
|
|
12388
|
+
addListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName, callback: (data: WidgetEventData[T][KEventName]) => void): void;
|
|
12389
|
+
/**
|
|
12390
|
+
* Removes an event listener for a widget event.
|
|
12391
|
+
* @param type Widget specific event name.
|
|
12392
|
+
*/
|
|
12393
|
+
removeListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName): void;
|
|
12394
|
+
}
|
|
12395
|
+
/**
|
|
12396
|
+
* Represents the version of the Checkout Widgets to use defaults to (0.1.9-alpha)
|
|
12397
|
+
* @property {number} major - The major version of the widgets, must specify a major version even if it is 0.
|
|
12398
|
+
* @property {number | undefined} minor - The minor version of the widgets, leaving this blank will use the latest minor based on major
|
|
12399
|
+
* @property {number | undefined} patch - The patch version of the widgets, leaving this blank will use the latest minor based on minor
|
|
12400
|
+
* @property {'alpha' | undefined} prerelease - The prerelease version of the widgets, can only be 'alpha'. Do not use in production.
|
|
12401
|
+
* @property {number | undefined} build - The build version of the widgets. Do not use in production.
|
|
12402
|
+
*
|
|
12403
|
+
* @example
|
|
12404
|
+
* { major: 0 } - use default version 0.1.9-alpha
|
|
12405
|
+
* { major: 1 } - use version 1.x.x, pickup all new minor and patch versions released
|
|
12406
|
+
* { major: 1, minor: 1 } - use version 1.1.x, pickup all new patch versions released
|
|
12407
|
+
* { major: 1, minor: 2, patch: 3 } - use version 1.2.3 specifically
|
|
12408
|
+
*/
|
|
12409
|
+
type SemanticVersion = {
|
|
12410
|
+
major: number;
|
|
12411
|
+
minor?: number;
|
|
12412
|
+
patch?: number;
|
|
12413
|
+
prerelease?: 'alpha';
|
|
12414
|
+
build?: number;
|
|
12415
|
+
};
|
|
12416
|
+
/**
|
|
12417
|
+
* Represents the global configuration options for the Checkout Widgets.
|
|
12418
|
+
* @property {WidgetTheme | undefined} theme - The theme of the Checkout Widget (default: "DARK")
|
|
12419
|
+
* @property {Environment | undefined} environment - The environment configuration (default: "SANDBOX")
|
|
12420
|
+
* @property {SemanticVersion | undefined} version - The version of the checkout widgets js file to use (default: "0.1.x")
|
|
12421
|
+
* @property {boolean | undefined} isOnRampEnabled - Enable on-ramp top-up method (default: "true")
|
|
12422
|
+
* @property {boolean | undefined} isSwapEnabled - Enable swap top-up method (default: "true")
|
|
12423
|
+
* @property {boolean | undefined} isBridgeEnabled - Enable bridge top-up method (default: "true")
|
|
12424
|
+
*/
|
|
12425
|
+
type CheckoutWidgetsConfig = {
|
|
12426
|
+
theme?: WidgetTheme;
|
|
12427
|
+
environment?: Environment;
|
|
12428
|
+
version?: SemanticVersion;
|
|
12429
|
+
isOnRampEnabled?: boolean;
|
|
12430
|
+
isSwapEnabled?: boolean;
|
|
12431
|
+
isBridgeEnabled?: boolean;
|
|
12432
|
+
};
|
|
12433
|
+
|
|
12434
|
+
/**
|
|
12435
|
+
* Represents the configuration options for instantiating the Checkout Widgets factory.
|
|
12436
|
+
* @property {WidgetConfiguration} config - global configuration options for the widgets.
|
|
12437
|
+
* @property {SemanticVersion | undefined} version - version of the Checkout widgets bundle (default latest version will be used).
|
|
12438
|
+
*/
|
|
12439
|
+
type WidgetsInit = {
|
|
12440
|
+
config: WidgetConfiguration;
|
|
12441
|
+
version?: SemanticVersion;
|
|
12442
|
+
};
|
|
12443
|
+
|
|
11890
12444
|
declare class Checkout {
|
|
12445
|
+
private readOnlyProviders;
|
|
11891
12446
|
readonly config: CheckoutConfiguration;
|
|
11892
12447
|
readonly fiatRampService: FiatRampService;
|
|
11893
12448
|
readonly availability: AvailabilityService;
|
|
12449
|
+
readonly passport?: Passport;
|
|
11894
12450
|
/**
|
|
11895
12451
|
* Constructs a new instance of the CheckoutModule class.
|
|
11896
12452
|
* @param {CheckoutModuleConfiguration} [config=SANDBOX_CONFIGURATION] - The configuration object for the CheckoutModule.
|
|
11897
12453
|
*/
|
|
11898
12454
|
constructor(config?: CheckoutModuleConfiguration);
|
|
12455
|
+
/**
|
|
12456
|
+
* Loads the widgets bundle and initiate the widgets factory.
|
|
12457
|
+
* @param {WidgetsInit} init - The initialisation parameters for loading the widgets bundle and applying configuration
|
|
12458
|
+
*/
|
|
12459
|
+
widgets(init: WidgetsInit): Promise<ImmutableCheckoutWidgets.WidgetsFactory>;
|
|
11899
12460
|
/**
|
|
11900
12461
|
* Creates a provider using the given parameters.
|
|
11901
12462
|
* @param {CreateProviderParams} params - The parameters for creating the provider.
|
|
@@ -12015,4 +12576,122 @@ declare class Checkout {
|
|
|
12015
12576
|
isSwapAvailable(): Promise<boolean>;
|
|
12016
12577
|
}
|
|
12017
12578
|
|
|
12018
|
-
|
|
12579
|
+
/**
|
|
12580
|
+
* Declares global interfaces and namespaces for the application.
|
|
12581
|
+
* @global
|
|
12582
|
+
* @namespace ImmutableCheckoutWidgets
|
|
12583
|
+
* */
|
|
12584
|
+
declare global {
|
|
12585
|
+
namespace ImmutableCheckoutWidgets {
|
|
12586
|
+
class WidgetsFactory implements IWidgetsFactory {
|
|
12587
|
+
constructor(sdk: Checkout, config: CheckoutWidgetsConfig);
|
|
12588
|
+
create<T extends WidgetType>(type: T, config: WidgetConfigurations[T], provider?: Web3Provider): Widget<T>;
|
|
12589
|
+
}
|
|
12590
|
+
class Connect<T extends WidgetType> implements Widget<T> {
|
|
12591
|
+
constructor(sdk: Checkout, props: WidgetProperties<T>);
|
|
12592
|
+
mount(id: string, params: WidgetParameters[T]): void;
|
|
12593
|
+
unmount(): void;
|
|
12594
|
+
update(props: WidgetProperties<T>): void;
|
|
12595
|
+
addListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName, callback: (data: WidgetEventData[T][KEventName]) => void): void;
|
|
12596
|
+
removeListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName): void;
|
|
12597
|
+
}
|
|
12598
|
+
class Bridge<T extends WidgetType> implements Widget<T> {
|
|
12599
|
+
constructor(sdk: Checkout, props: WidgetProperties<T>);
|
|
12600
|
+
mount(id: string, params: WidgetParameters[T]): void;
|
|
12601
|
+
unmount(): void;
|
|
12602
|
+
update(props: WidgetProperties<T>): void;
|
|
12603
|
+
addListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName, callback: (data: WidgetEventData[T][KEventName]) => void): void;
|
|
12604
|
+
removeListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName): void;
|
|
12605
|
+
}
|
|
12606
|
+
class Wallet<T extends WidgetType> implements Widget<T> {
|
|
12607
|
+
constructor(sdk: Checkout, props: WidgetProperties<T>);
|
|
12608
|
+
mount(id: string, params: WidgetParameters[T]): void;
|
|
12609
|
+
unmount(): void;
|
|
12610
|
+
update(props: WidgetProperties<T>): void;
|
|
12611
|
+
addListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName, callback: (data: WidgetEventData[T][KEventName]) => void): void;
|
|
12612
|
+
removeListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName): void;
|
|
12613
|
+
}
|
|
12614
|
+
class Swap<T extends WidgetType> implements Widget<T> {
|
|
12615
|
+
constructor(sdk: Checkout, props: WidgetProperties<T>);
|
|
12616
|
+
mount(id: string, params: WidgetParameters[T]): void;
|
|
12617
|
+
unmount(): void;
|
|
12618
|
+
update(props: WidgetProperties<T>): void;
|
|
12619
|
+
addListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName, callback: (data: WidgetEventData[T][KEventName]) => void): void;
|
|
12620
|
+
removeListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName): void;
|
|
12621
|
+
}
|
|
12622
|
+
class OnRamp<T extends WidgetType> implements Widget<T> {
|
|
12623
|
+
constructor(sdk: Checkout, props: WidgetProperties<T>);
|
|
12624
|
+
mount(id: string, params: WidgetParameters[T]): void;
|
|
12625
|
+
unmount(): void;
|
|
12626
|
+
update(props: WidgetProperties<T>): void;
|
|
12627
|
+
addListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName, callback: (data: WidgetEventData[T][KEventName]) => void): void;
|
|
12628
|
+
removeListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName): void;
|
|
12629
|
+
}
|
|
12630
|
+
class Sale<T extends WidgetType> implements Widget<T> {
|
|
12631
|
+
constructor(sdk: Checkout, props: WidgetProperties<T>);
|
|
12632
|
+
mount(id: string, params: WidgetParameters[T]): void;
|
|
12633
|
+
unmount(): void;
|
|
12634
|
+
update(props: WidgetProperties<T>): void;
|
|
12635
|
+
addListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName, callback: (data: WidgetEventData[T][KEventName]) => void): void;
|
|
12636
|
+
removeListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName): void;
|
|
12637
|
+
}
|
|
12638
|
+
}
|
|
12639
|
+
}
|
|
12640
|
+
|
|
12641
|
+
/**
|
|
12642
|
+
* Enum representing different types of errors that can occur during the checkout process.
|
|
12643
|
+
*/
|
|
12644
|
+
declare enum CheckoutErrorType {
|
|
12645
|
+
WEB3_PROVIDER_ERROR = "WEB3_PROVIDER_ERROR",
|
|
12646
|
+
PROVIDER_ERROR = "PROVIDER_ERROR",
|
|
12647
|
+
DEFAULT_PROVIDER_ERROR = "DEFAULT_PROVIDER_ERROR",
|
|
12648
|
+
CONNECT_PROVIDER_ERROR = "CONNECT_PROVIDER_ERROR",
|
|
12649
|
+
GET_BALANCE_ERROR = "GET_BALANCE_ERROR",
|
|
12650
|
+
GET_INDEXER_BALANCE_ERROR = "GET_INDEXER_BALANCE_ERROR",
|
|
12651
|
+
GET_ERC20_BALANCE_ERROR = "GET_ERC20_BALANCE_ERROR",
|
|
12652
|
+
GET_ERC721_BALANCE_ERROR = "GET_ERC721_BALANCE_ERROR",
|
|
12653
|
+
GET_NETWORK_INFO_ERROR = "GET_NETWORK_INFO_ERROR",
|
|
12654
|
+
METAMASK_PROVIDER_ERROR = "METAMASK_PROVIDER_ERROR",
|
|
12655
|
+
CHAIN_NOT_SUPPORTED_ERROR = "CHAIN_NOT_SUPPORTED_ERROR",
|
|
12656
|
+
PROVIDER_REQUEST_MISSING_ERROR = "PROVIDER_REQUEST_MISSING_ERROR",
|
|
12657
|
+
PROVIDER_REQUEST_FAILED_ERROR = "PROVIDER_REQUEST_FAILED_ERROR",
|
|
12658
|
+
USER_REJECTED_REQUEST_ERROR = "USER_REJECTED_REQUEST_ERROR",
|
|
12659
|
+
TRANSACTION_FAILED = "TRANSACTION_FAILED",
|
|
12660
|
+
INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS",
|
|
12661
|
+
UNPREDICTABLE_GAS_LIMIT = "UNPREDICTABLE_GAS_LIMIT",
|
|
12662
|
+
INVALID_GAS_ESTIMATE_TYPE = "INVALID_GAS_ESTIMATE_TYPE",
|
|
12663
|
+
UNSUPPORTED_TOKEN_TYPE_ERROR = "UNSUPPORTED_TOKEN_TYPE_ERROR",
|
|
12664
|
+
UNSUPPORTED_BALANCE_REQUIREMENT_ERROR = "UNSUPPORTED_BALANCE_REQUIREMENT_ERROR",
|
|
12665
|
+
GET_ORDER_LISTING_ERROR = "GET_ORDER_LISTING_ERROR",
|
|
12666
|
+
CANCEL_ORDER_LISTING_ERROR = "CANCEL_ORDER_LISTING_ERROR",
|
|
12667
|
+
PREPARE_ORDER_LISTING_ERROR = "PREPARE_ORDER_LISTING_ERROR",
|
|
12668
|
+
CREATE_ORDER_LISTING_ERROR = "CREATE_ORDER_LISTING_ERROR",
|
|
12669
|
+
FULFILL_ORDER_LISTING_ERROR = "FULFILL_ORDER_LISTING_ERROR",
|
|
12670
|
+
SWITCH_NETWORK_UNSUPPORTED = "SWITCH_NETWORK_UNSUPPORTED",
|
|
12671
|
+
GET_ERC20_ALLOWANCE_ERROR = "GET_ERC20_ALLOWANCE_ERROR",
|
|
12672
|
+
GET_ERC721_ALLOWANCE_ERROR = "GET_ERC721_ALLOWANCE_ERROR",
|
|
12673
|
+
EXECUTE_APPROVAL_TRANSACTION_ERROR = "EXECUTE_APPROVAL_TRANSACTION_ERROR",
|
|
12674
|
+
EXECUTE_FULFILLMENT_TRANSACTION_ERROR = "EXECUTE_FULFILLMENT_TRANSACTION_ERROR",
|
|
12675
|
+
SIGN_MESSAGE_ERROR = "SIGN_MESSAGE_ERROR",
|
|
12676
|
+
BRIDGE_GAS_ESTIMATE_ERROR = "BRIDGE_GAS_ESTIMATE_ERROR",
|
|
12677
|
+
ORDER_FEE_ERROR = "ORDER_FEE_ERROR",
|
|
12678
|
+
ITEM_REQUIREMENTS_ERROR = "ITEM_REQUIREMENTS_ERROR",
|
|
12679
|
+
API_ERROR = "API_ERROR",
|
|
12680
|
+
ORDER_EXPIRED_ERROR = "ORDER_EXPIRED_ERROR",
|
|
12681
|
+
WIDGETS_SCRIPT_LOAD_ERROR = "WIDGETS_SCRIPT_LOAD_ERROR"
|
|
12682
|
+
}
|
|
12683
|
+
/**
|
|
12684
|
+
* Represents an error object with a specific type, optional message, and optional data.
|
|
12685
|
+
* @property {CheckoutErrorType} type - The type of the error.
|
|
12686
|
+
* @property {string | undefined} [message] - The error message.
|
|
12687
|
+
* @property {Object.<string, string> | undefined} [data] - Additional data associated with the error.
|
|
12688
|
+
*/
|
|
12689
|
+
type ErrorType = {
|
|
12690
|
+
type: CheckoutErrorType;
|
|
12691
|
+
message?: string;
|
|
12692
|
+
data?: {
|
|
12693
|
+
[key: string]: string;
|
|
12694
|
+
};
|
|
12695
|
+
};
|
|
12696
|
+
|
|
12697
|
+
export { AllowedNetworkConfig, AvailableRoutingOptions, BalanceDelta, BridgeEventType, BridgeFailed, BridgeFundingStep, BridgeSuccess, BridgeWidgetConfiguration, BridgeWidgetParams, BuyOrder, BuyParams, BuyResult, BuyResultFailed, BuyResultInsufficientFunds, BuyResultSuccess, BuyToken, CHECKOUT_API_BASE_URL, CancelParams, CancelResult, CancelResultFailed, CancelResultSuccess, ChainId, ChainName, CheckConnectionParams, CheckConnectionResult, Checkout, CheckoutConfiguration, CheckoutErrorType, CheckoutModuleConfiguration, CheckoutStatus, CheckoutWidgetsConfig, ConnectEventType, ConnectParams, ConnectResult, ConnectTargetLayer, ConnectWidgetConfiguration, ConnectWidgetParams, ConnectionFailed, ConnectionSuccess, DexConfig, ERC20ItemRequirement, ERC721Balance, ERC721ItemRequirement, ErrorType, ExchangeType, FeePercentage, FeeToken, FiatRampParams, FulfillmentTransaction, FundingItem, FundingRoute, FundingStep, FundingStepType, GasAmount, GasEstimateBridgeToL2Result, GasEstimateParams, GasEstimateSwapResult, GasEstimateTokenConfig, GasEstimateType, GasToken, GasTokenType, GetAllBalancesParams, GetAllBalancesResult, GetBalanceParams, GetBalanceResult, GetNetworkAllowListParams, GetNetworkAllowListResult, GetNetworkParams, GetTokenAllowListParams, GetTokenAllowListResult, GetWalletAllowListParams, GetWalletAllowListResult, IMTBLWidgetEvents, IWidgetsFactory, ItemBalance, ItemType, NativeItemRequirement, NetworkFilter, NetworkFilterTypes, NetworkInfo, NoRouteOptions, NoRoutesFound, OnRampEventType, OnRampFailed, OnRampFundingStep, OnRampProviderFees, OnRampSuccess, OnRampWidgetParams, OnrampWidgetConfiguration, OrchestrationEvent, OrchestrationEventData, OrchestrationEventType, OrderFee, ProviderEvent, ProviderEventType, ProviderUpdated, RemoteConfiguration, RequestBridgeEvent, RequestConnectEvent, RequestOnrampEvent, RequestSwapEvent, RequestWalletEvent, RoutesFound, RoutingOutcome, RoutingOutcomeType, SaleEventType, SaleFailed, SaleItem, SaleSuccess, SaleWidgetConfiguration, SaleWidgetParams, SellOrder, SellParams, SellResult, SellResultFailed, SellResultInsufficientFunds, SellResultSuccess, SellToken, SemanticVersion, SendTransactionParams, SendTransactionResult, SmartCheckoutInsufficient, SmartCheckoutParams, SmartCheckoutResult, SmartCheckoutRouter, SmartCheckoutSufficient, SwapEventType, SwapFailed, SwapFundingStep, SwapRejected, SwapSuccess, SwapWidgetConfiguration, SwapWidgetParams, SwitchNetworkParams, SwitchNetworkResult, TokenAmountEstimate, TokenBalance, TokenFilter, TokenFilterTypes, TokenInfo, TransactionOrGasType, TransactionRequirement, WalletDisconnectWalletEvent, WalletEventType, WalletFilter, WalletFilterTypes, WalletInfo, WalletNetworkSwitchEvent, WalletProviderName, WalletWidgetConfiguration, WalletWidgetParams, Widget, WidgetConfiguration, WidgetConfigurations, WidgetEvent, WidgetEventData, WidgetEventTypes, WidgetParameters, WidgetProperties, WidgetTheme, WidgetType };
|