@imtbl/sdk 0.28.5 → 0.28.6-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 +883 -219
- package/dist/checkout_sdk.js +2903 -2423
- 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 +2958 -2984
- package/dist/index.d.ts +1143 -15432
- package/dist/index.js +2960 -2985
- package/dist/passport.d.ts +1 -7
- package/dist/passport.js +19 -48
- package/dist/provider.d.ts +0 -7
- package/dist/provider.js +2 -22
- package/package.json +19 -8
- package/dist/browser/checkout.js +0 -2
- package/dist/checkout_widgets.d.ts +0 -25605
- package/dist/checkout_widgets.js +0 -450
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>;
|
|
@@ -10101,12 +10019,6 @@ interface IMXProvider {
|
|
|
10101
10019
|
* @return {Promise<RegisterUserResponse>} Returns a promise that resolves with the user registration response
|
|
10102
10020
|
*/
|
|
10103
10021
|
registerOffchain(): Promise<RegisterUserResponse>;
|
|
10104
|
-
/**
|
|
10105
|
-
* Checks if a User is registered off-chain
|
|
10106
|
-
*
|
|
10107
|
-
* @return {Promise<boolean>} Returns a promise that resolves with true if the User is registered with IMX, false otherwise
|
|
10108
|
-
*/
|
|
10109
|
-
isRegisteredOffchain(): Promise<boolean>;
|
|
10110
10022
|
/**
|
|
10111
10023
|
* Checks if a User is registered on-chain
|
|
10112
10024
|
*
|
|
@@ -10179,6 +10091,27 @@ interface IMXProvider {
|
|
|
10179
10091
|
completeWithdrawal(starkPublicKey: string, token: AnyToken): Promise<TransactionResponse>;
|
|
10180
10092
|
}
|
|
10181
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
|
+
|
|
10182
10115
|
interface ImxOverrides {
|
|
10183
10116
|
immutableXConfig: ImmutableXConfiguration;
|
|
10184
10117
|
}
|
|
@@ -10538,7 +10471,7 @@ type UserProfile = {
|
|
|
10538
10471
|
};
|
|
10539
10472
|
declare enum Networks {
|
|
10540
10473
|
PRODUCTION = "mainnet",
|
|
10541
|
-
SANDBOX = "
|
|
10474
|
+
SANDBOX = "goerli"
|
|
10542
10475
|
}
|
|
10543
10476
|
interface OidcConfiguration {
|
|
10544
10477
|
clientId: string;
|
|
@@ -10719,6 +10652,7 @@ declare enum ChainName {
|
|
|
10719
10652
|
IMTBL_ZKEVM_DEVNET = "Immutable zkEVM Dev",
|
|
10720
10653
|
IMTBL_ZKEVM_MAINNET = "Immutable zkEVM"
|
|
10721
10654
|
}
|
|
10655
|
+
|
|
10722
10656
|
/**
|
|
10723
10657
|
* Represents information about a token.
|
|
10724
10658
|
* @interface TokenInfo
|
|
@@ -10735,6 +10669,7 @@ interface TokenInfo {
|
|
|
10735
10669
|
address?: string;
|
|
10736
10670
|
icon?: string;
|
|
10737
10671
|
}
|
|
10672
|
+
|
|
10738
10673
|
/**
|
|
10739
10674
|
* Interface representing the parameters for {@link Checkout.getBalance}.
|
|
10740
10675
|
* @property {Web3Provider} provider - The provider used to get the balance.
|
|
@@ -10775,6 +10710,7 @@ interface GetAllBalancesParams {
|
|
|
10775
10710
|
interface GetAllBalancesResult {
|
|
10776
10711
|
balances: GetBalanceResult[];
|
|
10777
10712
|
}
|
|
10713
|
+
|
|
10778
10714
|
interface OrderFee {
|
|
10779
10715
|
amount: FeeToken | FeePercentage;
|
|
10780
10716
|
recipient: string;
|
|
@@ -10785,6 +10721,7 @@ interface FeeToken {
|
|
|
10785
10721
|
interface FeePercentage {
|
|
10786
10722
|
percentageDecimal: number;
|
|
10787
10723
|
}
|
|
10724
|
+
|
|
10788
10725
|
type BuyResult = BuyResultSuccess | BuyResultFailed | BuyResultInsufficientFunds;
|
|
10789
10726
|
/**
|
|
10790
10727
|
* Represents the result of {@link Checkout.buy}
|
|
@@ -11322,6 +11259,7 @@ type AvailableRoutingOptions = {
|
|
|
11322
11259
|
swap?: boolean;
|
|
11323
11260
|
bridge?: boolean;
|
|
11324
11261
|
};
|
|
11262
|
+
|
|
11325
11263
|
/**
|
|
11326
11264
|
* Interface representing the parameters for {@link Checkout.buy}
|
|
11327
11265
|
* @property {Web3Provider} provider - The provider to use for the buy.
|
|
@@ -11332,6 +11270,7 @@ interface BuyParams {
|
|
|
11332
11270
|
provider: Web3Provider;
|
|
11333
11271
|
orders: Array<BuyOrder>;
|
|
11334
11272
|
}
|
|
11273
|
+
|
|
11335
11274
|
/**
|
|
11336
11275
|
* Interface representing the parameters for {@link Checkout.cancel}
|
|
11337
11276
|
* @property {Web3Provider} provider - The provider to use for the cancel.
|
|
@@ -11342,12 +11281,73 @@ interface CancelParams {
|
|
|
11342
11281
|
provider: Web3Provider;
|
|
11343
11282
|
orderIds: string[];
|
|
11344
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
|
+
|
|
11345
11337
|
interface CheckoutOverrides {
|
|
11346
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
|
+
*/
|
|
11347
11346
|
interface CheckoutModuleConfiguration extends ModuleConfiguration<CheckoutOverrides> {
|
|
11348
11347
|
isOnRampEnabled?: boolean;
|
|
11349
11348
|
isSwapEnabled?: boolean;
|
|
11350
11349
|
isBridgeEnabled?: boolean;
|
|
11350
|
+
passport?: Passport;
|
|
11351
11351
|
}
|
|
11352
11352
|
/**
|
|
11353
11353
|
* A type representing various remotely defined configurations which are
|
|
@@ -11465,6 +11465,22 @@ type ChainTokensConfig = {
|
|
|
11465
11465
|
allowed?: TokenInfo[];
|
|
11466
11466
|
blockscout?: boolean;
|
|
11467
11467
|
};
|
|
11468
|
+
|
|
11469
|
+
/**
|
|
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
|
+
|
|
11468
11484
|
/**
|
|
11469
11485
|
* Interface representing the params of {@link Checkout.connect}.
|
|
11470
11486
|
* @property {Web3Provider} provider - The provider used to connect to the network.
|
|
@@ -11475,9 +11491,11 @@ interface ConnectParams {
|
|
|
11475
11491
|
/**
|
|
11476
11492
|
* Interface representing the result of {@link Checkout.connect}.
|
|
11477
11493
|
* @property {Web3Provider} provider - The provider used to connect to the network.
|
|
11494
|
+
* @property {NetworkInfo} network - Information about the connected network.
|
|
11478
11495
|
*/
|
|
11479
11496
|
interface ConnectResult {
|
|
11480
11497
|
provider: Web3Provider;
|
|
11498
|
+
network: NetworkInfo;
|
|
11481
11499
|
}
|
|
11482
11500
|
/**
|
|
11483
11501
|
* Interface representing the params of {@link Checkout.checkIsWalletConnected}.
|
|
@@ -11495,6 +11513,16 @@ interface CheckConnectionResult {
|
|
|
11495
11513
|
isConnected: boolean;
|
|
11496
11514
|
walletAddress: string;
|
|
11497
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
|
+
|
|
11498
11526
|
/**
|
|
11499
11527
|
* An enum representing the type of gas estimate.
|
|
11500
11528
|
* @enum {string}
|
|
@@ -11558,20 +11586,7 @@ interface TokenAmountEstimate {
|
|
|
11558
11586
|
estimatedAmount?: BigNumber;
|
|
11559
11587
|
token?: TokenInfo;
|
|
11560
11588
|
}
|
|
11561
|
-
|
|
11562
|
-
* Represents information about a network.
|
|
11563
|
-
* @interface NetworkInfo
|
|
11564
|
-
* @property {string} name - The name of the network.
|
|
11565
|
-
* @property {number} chainId - The chain ID of the network.
|
|
11566
|
-
* @property {TokenInfo} nativeCurrency - Information about the native currency of the network.
|
|
11567
|
-
* @property {boolean} isSupported - Indicates whether the network is supported.
|
|
11568
|
-
*/
|
|
11569
|
-
interface NetworkInfo {
|
|
11570
|
-
name: string;
|
|
11571
|
-
chainId: number;
|
|
11572
|
-
nativeCurrency: TokenInfo;
|
|
11573
|
-
isSupported: boolean;
|
|
11574
|
-
}
|
|
11589
|
+
|
|
11575
11590
|
/**
|
|
11576
11591
|
* Interface representing the parameters for {@link Checkout.switchNetwork}.
|
|
11577
11592
|
* @property {Web3Provider} provider - The provider to connect to the network.
|
|
@@ -11627,6 +11642,7 @@ declare enum NetworkFilterTypes {
|
|
|
11627
11642
|
interface NetworkFilter {
|
|
11628
11643
|
chainId: ChainId;
|
|
11629
11644
|
}
|
|
11645
|
+
|
|
11630
11646
|
/**
|
|
11631
11647
|
* Interface representing the parameters for {@link Checkout.sell}
|
|
11632
11648
|
* @property {Web3Provider} provider - The provider to use for the sell.
|
|
@@ -11637,6 +11653,7 @@ interface SellParams {
|
|
|
11637
11653
|
provider: Web3Provider;
|
|
11638
11654
|
orders: Array<SellOrder>;
|
|
11639
11655
|
}
|
|
11656
|
+
|
|
11640
11657
|
/**
|
|
11641
11658
|
* Interface representing the parameters for {@link Checkout.getTokenAllowList}.
|
|
11642
11659
|
* @property {TokenFilterTypes} type - The type of token to retrieve.
|
|
@@ -11671,6 +11688,7 @@ declare enum TokenFilterTypes {
|
|
|
11671
11688
|
interface TokenFilter {
|
|
11672
11689
|
address: string;
|
|
11673
11690
|
}
|
|
11691
|
+
|
|
11674
11692
|
/**
|
|
11675
11693
|
* Interface representing the parameters for {@link Checkout.sendTransaction}.
|
|
11676
11694
|
* @property {Web3Provider} provider - The provider to connect to the network.
|
|
@@ -11687,6 +11705,7 @@ interface SendTransactionParams {
|
|
|
11687
11705
|
interface SendTransactionResult {
|
|
11688
11706
|
transactionResponse: TransactionResponse;
|
|
11689
11707
|
}
|
|
11708
|
+
|
|
11690
11709
|
/**
|
|
11691
11710
|
* Enum representing the names of different wallet providers.
|
|
11692
11711
|
*/
|
|
@@ -11697,29 +11716,27 @@ declare enum WalletProviderName {
|
|
|
11697
11716
|
/**
|
|
11698
11717
|
* Interface for the parameters required to create a wallet provider {@link Checkout.createProvider}.
|
|
11699
11718
|
* @interface CreateProviderParams
|
|
11700
|
-
* @property {WalletProviderName}
|
|
11701
|
-
* @property {Passport | undefined} passport - The Passport instance required to create a provider for passport users.
|
|
11702
|
-
* 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.
|
|
11703
11720
|
*/
|
|
11704
11721
|
interface CreateProviderParams {
|
|
11705
|
-
|
|
11706
|
-
passport?: Passport;
|
|
11722
|
+
walletProviderName: WalletProviderName;
|
|
11707
11723
|
}
|
|
11708
11724
|
/**
|
|
11709
11725
|
* Represents the result of creating a Web3 provider {@link Checkout.createProvider}.
|
|
11710
11726
|
* @property {Web3Provider} provider - The created Web3 provider.
|
|
11711
|
-
* @property {WalletProviderName}
|
|
11727
|
+
* @property {WalletProviderName} walletProviderName - The wallet provider name of the provider that was created.
|
|
11712
11728
|
*/
|
|
11713
11729
|
type CreateProviderResult = {
|
|
11714
11730
|
provider: Web3Provider;
|
|
11715
11731
|
walletProviderName: WalletProviderName;
|
|
11716
11732
|
};
|
|
11733
|
+
|
|
11717
11734
|
/**
|
|
11718
11735
|
* Interface representing a wallet filter to be used in {@link GetWalletAllowListParams}.
|
|
11719
|
-
* @property {WalletProviderName}
|
|
11736
|
+
* @property {WalletProviderName} walletProviderName - The wallet provider name to filter wallets by.
|
|
11720
11737
|
*/
|
|
11721
11738
|
interface WalletFilter {
|
|
11722
|
-
|
|
11739
|
+
walletProviderName: WalletProviderName;
|
|
11723
11740
|
}
|
|
11724
11741
|
/**
|
|
11725
11742
|
* Interface representing the parameters for {@link Checkout.getWalletAllowList}.
|
|
@@ -11732,14 +11749,12 @@ interface GetWalletAllowListParams {
|
|
|
11732
11749
|
}
|
|
11733
11750
|
/**
|
|
11734
11751
|
* Interface representing information about a wallet used in {@link GetWalletAllowListResult}.
|
|
11735
|
-
* @property {WalletProviderName}
|
|
11736
|
-
* @property {string} name - The name of the wallet.
|
|
11752
|
+
* @property {WalletProviderName} walletProviderName - The wallet provider name for the wallet.
|
|
11737
11753
|
* @property {string | undefined} description - A description of the wallet.
|
|
11738
11754
|
* @property {string | undefined} icon - The URL/data:image of an icon for the wallet.
|
|
11739
11755
|
*/
|
|
11740
11756
|
interface WalletInfo {
|
|
11741
|
-
|
|
11742
|
-
name: string;
|
|
11757
|
+
walletProviderName: WalletProviderName;
|
|
11743
11758
|
description?: string;
|
|
11744
11759
|
icon?: string;
|
|
11745
11760
|
}
|
|
@@ -11756,6 +11771,7 @@ interface GetWalletAllowListResult {
|
|
|
11756
11771
|
declare enum WalletFilterTypes {
|
|
11757
11772
|
ALL = "all"
|
|
11758
11773
|
}
|
|
11774
|
+
|
|
11759
11775
|
/**
|
|
11760
11776
|
* Base URL for the checkout API based on the environment.
|
|
11761
11777
|
* @property {string} DEVELOPMENT - The base URL for the development environment.
|
|
@@ -11775,6 +11791,7 @@ type NetworkDetails = {
|
|
|
11775
11791
|
blockExplorerUrls?: string[];
|
|
11776
11792
|
};
|
|
11777
11793
|
type NetworkMap = Map<ChainId, NetworkDetails>;
|
|
11794
|
+
|
|
11778
11795
|
/**
|
|
11779
11796
|
* An enum representing the type of exchange.
|
|
11780
11797
|
* @enum {string}
|
|
@@ -11796,71 +11813,27 @@ interface FiatRampParams {
|
|
|
11796
11813
|
web3Provider: Web3Provider;
|
|
11797
11814
|
tokenAmount?: string;
|
|
11798
11815
|
tokenAddress?: string;
|
|
11799
|
-
passport?:
|
|
11816
|
+
passport?: any;
|
|
11800
11817
|
}
|
|
11801
|
-
|
|
11802
|
-
* Enum representing different types of errors that can occur during the checkout process.
|
|
11803
|
-
*/
|
|
11804
|
-
declare enum CheckoutErrorType {
|
|
11805
|
-
WEB3_PROVIDER_ERROR = "WEB3_PROVIDER_ERROR",
|
|
11806
|
-
PROVIDER_ERROR = "PROVIDER_ERROR",
|
|
11807
|
-
DEFAULT_PROVIDER_ERROR = "DEFAULT_PROVIDER_ERROR",
|
|
11808
|
-
CONNECT_PROVIDER_ERROR = "CONNECT_PROVIDER_ERROR",
|
|
11809
|
-
GET_BALANCE_ERROR = "GET_BALANCE_ERROR",
|
|
11810
|
-
GET_INDEXER_BALANCE_ERROR = "GET_INDEXER_BALANCE_ERROR",
|
|
11811
|
-
GET_ERC20_BALANCE_ERROR = "GET_ERC20_BALANCE_ERROR",
|
|
11812
|
-
GET_ERC721_BALANCE_ERROR = "GET_ERC721_BALANCE_ERROR",
|
|
11813
|
-
GET_NETWORK_INFO_ERROR = "GET_NETWORK_INFO_ERROR",
|
|
11814
|
-
METAMASK_PROVIDER_ERROR = "METAMASK_PROVIDER_ERROR",
|
|
11815
|
-
CHAIN_NOT_SUPPORTED_ERROR = "CHAIN_NOT_SUPPORTED_ERROR",
|
|
11816
|
-
PROVIDER_REQUEST_MISSING_ERROR = "PROVIDER_REQUEST_MISSING_ERROR",
|
|
11817
|
-
PROVIDER_REQUEST_FAILED_ERROR = "PROVIDER_REQUEST_FAILED_ERROR",
|
|
11818
|
-
USER_REJECTED_REQUEST_ERROR = "USER_REJECTED_REQUEST_ERROR",
|
|
11819
|
-
TRANSACTION_FAILED = "TRANSACTION_FAILED",
|
|
11820
|
-
INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS",
|
|
11821
|
-
UNPREDICTABLE_GAS_LIMIT = "UNPREDICTABLE_GAS_LIMIT",
|
|
11822
|
-
INVALID_GAS_ESTIMATE_TYPE = "INVALID_GAS_ESTIMATE_TYPE",
|
|
11823
|
-
UNSUPPORTED_TOKEN_TYPE_ERROR = "UNSUPPORTED_TOKEN_TYPE_ERROR",
|
|
11824
|
-
UNSUPPORTED_BALANCE_REQUIREMENT_ERROR = "UNSUPPORTED_BALANCE_REQUIREMENT_ERROR",
|
|
11825
|
-
GET_ORDER_LISTING_ERROR = "GET_ORDER_LISTING_ERROR",
|
|
11826
|
-
CANCEL_ORDER_LISTING_ERROR = "CANCEL_ORDER_LISTING_ERROR",
|
|
11827
|
-
PREPARE_ORDER_LISTING_ERROR = "PREPARE_ORDER_LISTING_ERROR",
|
|
11828
|
-
CREATE_ORDER_LISTING_ERROR = "CREATE_ORDER_LISTING_ERROR",
|
|
11829
|
-
FULFILL_ORDER_LISTING_ERROR = "FULFILL_ORDER_LISTING_ERROR",
|
|
11830
|
-
SWITCH_NETWORK_UNSUPPORTED = "SWITCH_NETWORK_UNSUPPORTED",
|
|
11831
|
-
GET_ERC20_ALLOWANCE_ERROR = "GET_ERC20_ALLOWANCE_ERROR",
|
|
11832
|
-
GET_ERC721_ALLOWANCE_ERROR = "GET_ERC721_ALLOWANCE_ERROR",
|
|
11833
|
-
EXECUTE_APPROVAL_TRANSACTION_ERROR = "EXECUTE_APPROVAL_TRANSACTION_ERROR",
|
|
11834
|
-
EXECUTE_FULFILLMENT_TRANSACTION_ERROR = "EXECUTE_FULFILLMENT_TRANSACTION_ERROR",
|
|
11835
|
-
SIGN_MESSAGE_ERROR = "SIGN_MESSAGE_ERROR",
|
|
11836
|
-
BRIDGE_GAS_ESTIMATE_ERROR = "BRIDGE_GAS_ESTIMATE_ERROR",
|
|
11837
|
-
ORDER_FEE_ERROR = "ORDER_FEE_ERROR",
|
|
11838
|
-
ITEM_REQUIREMENTS_ERROR = "ITEM_REQUIREMENTS_ERROR",
|
|
11839
|
-
API_ERROR = "API_ERROR",
|
|
11840
|
-
ORDER_EXPIRED_ERROR = "ORDER_EXPIRED_ERROR"
|
|
11841
|
-
}
|
|
11842
|
-
/**
|
|
11843
|
-
* Represents an error object with a specific type, optional message, and optional data.
|
|
11844
|
-
* @property {CheckoutErrorType} type - The type of the error.
|
|
11845
|
-
* @property {string | undefined} [message] - The error message.
|
|
11846
|
-
* @property {Object.<string, string> | undefined} [data] - Additional data associated with the error.
|
|
11847
|
-
*/
|
|
11848
|
-
type ErrorType = {
|
|
11849
|
-
type: CheckoutErrorType;
|
|
11850
|
-
message?: string;
|
|
11851
|
-
data?: {
|
|
11852
|
-
[key: string]: string;
|
|
11853
|
-
};
|
|
11854
|
-
};
|
|
11818
|
+
|
|
11855
11819
|
type RemoteConfigParams = {
|
|
11856
11820
|
isDevelopment: boolean;
|
|
11857
11821
|
isProduction: boolean;
|
|
11858
11822
|
};
|
|
11859
11823
|
declare class RemoteConfigFetcher {
|
|
11824
|
+
private isDevelopment;
|
|
11825
|
+
private isProduction;
|
|
11826
|
+
private configCache;
|
|
11827
|
+
private tokensCache;
|
|
11860
11828
|
constructor(params: RemoteConfigParams);
|
|
11829
|
+
private static makeHttpRequest;
|
|
11830
|
+
private getEndpoint;
|
|
11831
|
+
private loadConfig;
|
|
11832
|
+
private loadConfigTokens;
|
|
11861
11833
|
getConfig(key?: keyof RemoteConfiguration): Promise<RemoteConfiguration | RemoteConfiguration[keyof RemoteConfiguration] | undefined>;
|
|
11862
11834
|
getTokensConfig(chainId: ChainId): Promise<ChainTokensConfig>;
|
|
11863
11835
|
}
|
|
11836
|
+
|
|
11864
11837
|
declare class CheckoutConfiguration {
|
|
11865
11838
|
readonly isDevelopment: boolean;
|
|
11866
11839
|
readonly isProduction: boolean;
|
|
@@ -11872,9 +11845,7 @@ declare class CheckoutConfiguration {
|
|
|
11872
11845
|
readonly networkMap: NetworkMap;
|
|
11873
11846
|
constructor(config: CheckoutModuleConfiguration);
|
|
11874
11847
|
}
|
|
11875
|
-
|
|
11876
|
-
checkDexAvailability: () => Promise<boolean>;
|
|
11877
|
-
};
|
|
11848
|
+
|
|
11878
11849
|
interface FiatRampWidgetParams {
|
|
11879
11850
|
exchangeType: ExchangeType;
|
|
11880
11851
|
isPassport: boolean;
|
|
@@ -11892,16 +11863,590 @@ declare class FiatRampService {
|
|
|
11892
11863
|
constructor(config: CheckoutConfiguration);
|
|
11893
11864
|
feeEstimate(): Promise<OnRampProviderFees>;
|
|
11894
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"
|
|
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"
|
|
11895
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
|
+
|
|
12139
|
+
/**
|
|
12140
|
+
* Bridge Widget parameters
|
|
12141
|
+
* @property {string | undefined} fromContractAddress - The contract address of the token to bridge from, used to populate the bridge form token field
|
|
12142
|
+
* @property {string | undefined} amount - The formatted amount to bridge, used to populate the bridge form amount field
|
|
12143
|
+
* @property {WalletProviderName | undefined} walletProviderName - The wallet provider name to use for the bridge widget
|
|
12144
|
+
*/
|
|
12145
|
+
type BridgeWidgetParams = {
|
|
12146
|
+
fromContractAddress?: string;
|
|
12147
|
+
amount?: string;
|
|
12148
|
+
walletProviderName?: WalletProviderName;
|
|
12149
|
+
};
|
|
12150
|
+
|
|
12151
|
+
/**
|
|
12152
|
+
* Wallet Widget parameters
|
|
12153
|
+
* @property {WalletProviderName | undefined} walletProviderName - The wallet provider name to use for the wallet widget
|
|
12154
|
+
* @property {Web3Provider | undefined} web3Provider - The ethers Web3Provider
|
|
12155
|
+
*/
|
|
12156
|
+
type WalletWidgetParams = {
|
|
12157
|
+
walletProviderName?: WalletProviderName;
|
|
12158
|
+
};
|
|
12159
|
+
|
|
12160
|
+
/**
|
|
12161
|
+
* Swap Widget parameters
|
|
12162
|
+
* @property {string | undefined} amount - The formatted amount to swap, used to populate the swap from amount field
|
|
12163
|
+
* @property {string | undefined} fromContractAddress - The contract address of the token to swap from
|
|
12164
|
+
* @property {string | undefined} toContractAddress - The contract address of the token to swap to
|
|
12165
|
+
* @property {WalletProviderName | undefined} walletProviderName - The wallet provider name to use for the swap widget
|
|
12166
|
+
*/
|
|
12167
|
+
interface SwapWidgetParams {
|
|
12168
|
+
amount?: string;
|
|
12169
|
+
fromContractAddress?: string;
|
|
12170
|
+
toContractAddress?: string;
|
|
12171
|
+
walletProviderName?: WalletProviderName;
|
|
12172
|
+
}
|
|
12173
|
+
|
|
12174
|
+
/**
|
|
12175
|
+
* OnRamp Widget parameters
|
|
12176
|
+
* @property {string | undefined} contractAddress - The contract address of the token to onramp
|
|
12177
|
+
* @property {string | undefined} amount - The formatted amount to onramp, used to populate the onramp form amount field
|
|
12178
|
+
* @property {WalletProviderName | undefined} walletProviderName - The wallet provider name to use for the onramp widget
|
|
12179
|
+
*/
|
|
12180
|
+
type OnRampWidgetParams = {
|
|
12181
|
+
contractAddress?: string;
|
|
12182
|
+
amount?: string;
|
|
12183
|
+
walletProviderName?: WalletProviderName;
|
|
12184
|
+
};
|
|
12185
|
+
|
|
12186
|
+
/**
|
|
12187
|
+
* Sale Widget parameters
|
|
12188
|
+
* @property {string} amount - The total price to pay for the items in the sale
|
|
12189
|
+
* @property {SaleItem[]} items - The list of products to be purchased
|
|
12190
|
+
* @property {WalletProviderName | undefined} walletProviderName - The wallet provider name to default to if no web3Provider is passed
|
|
12191
|
+
*/
|
|
12192
|
+
type SaleWidgetParams = {
|
|
12193
|
+
amount?: string;
|
|
12194
|
+
environmentId?: string;
|
|
12195
|
+
fromContractAddress?: string;
|
|
12196
|
+
items?: SaleItem[];
|
|
12197
|
+
walletProviderName?: WalletProviderName;
|
|
12198
|
+
};
|
|
12199
|
+
type SaleItem = {
|
|
12200
|
+
productId: string;
|
|
12201
|
+
qty: number;
|
|
12202
|
+
name: string;
|
|
12203
|
+
image: string;
|
|
12204
|
+
description: string;
|
|
12205
|
+
};
|
|
12206
|
+
|
|
12207
|
+
type ConnectWidgetConfiguration = {} & WidgetConfiguration;
|
|
12208
|
+
|
|
12209
|
+
type BridgeWidgetConfiguration = {} & WidgetConfiguration;
|
|
12210
|
+
|
|
12211
|
+
type WalletWidgetConfiguration = {} & WidgetConfiguration;
|
|
12212
|
+
|
|
12213
|
+
type SwapWidgetConfiguration = {} & WidgetConfiguration;
|
|
12214
|
+
|
|
12215
|
+
type OnrampWidgetConfiguration = {} & WidgetConfiguration;
|
|
12216
|
+
|
|
12217
|
+
type SaleWidgetConfiguration = {} & WidgetConfiguration;
|
|
12218
|
+
|
|
12219
|
+
/**
|
|
12220
|
+
* Enum representing the list of widget types.
|
|
12221
|
+
*/
|
|
12222
|
+
declare enum WidgetType {
|
|
12223
|
+
CONNECT = "connect",
|
|
12224
|
+
WALLET = "wallet",
|
|
12225
|
+
SWAP = "swap",
|
|
12226
|
+
BRIDGE = "bridge",
|
|
12227
|
+
ONRAMP = "onramp",
|
|
12228
|
+
SALE = "sale"
|
|
12229
|
+
}
|
|
12230
|
+
/**
|
|
12231
|
+
* Widget properties definition for each widget. Used for creating and updating widgets
|
|
12232
|
+
*/
|
|
12233
|
+
type WidgetProperties<T extends WidgetType> = {
|
|
12234
|
+
config?: WidgetConfigurations[T];
|
|
12235
|
+
provider?: Web3Provider;
|
|
12236
|
+
};
|
|
12237
|
+
type WidgetConfigurations = {
|
|
12238
|
+
[WidgetType.CONNECT]: ConnectWidgetConfiguration;
|
|
12239
|
+
[WidgetType.WALLET]: WalletWidgetConfiguration;
|
|
12240
|
+
[WidgetType.SWAP]: SwapWidgetConfiguration;
|
|
12241
|
+
[WidgetType.BRIDGE]: BridgeWidgetConfiguration;
|
|
12242
|
+
[WidgetType.ONRAMP]: OnrampWidgetConfiguration;
|
|
12243
|
+
[WidgetType.SALE]: SaleWidgetConfiguration;
|
|
12244
|
+
};
|
|
12245
|
+
type WidgetParameters = {
|
|
12246
|
+
[WidgetType.CONNECT]: ConnectWidgetParams;
|
|
12247
|
+
[WidgetType.WALLET]: WalletWidgetParams;
|
|
12248
|
+
[WidgetType.SWAP]: SwapWidgetParams;
|
|
12249
|
+
[WidgetType.BRIDGE]: BridgeWidgetParams;
|
|
12250
|
+
[WidgetType.ONRAMP]: OnRampWidgetParams;
|
|
12251
|
+
[WidgetType.SALE]: SaleWidgetParams;
|
|
12252
|
+
};
|
|
12253
|
+
/**
|
|
12254
|
+
* Represents all the possible event types that are emitted by the widgets.
|
|
12255
|
+
*/
|
|
12256
|
+
type WidgetEventTypes = {
|
|
12257
|
+
[WidgetType.CONNECT]: ConnectEventType | OrchestrationEventType;
|
|
12258
|
+
[WidgetType.WALLET]: WalletEventType | OrchestrationEventType;
|
|
12259
|
+
[WidgetType.SWAP]: SwapEventType | OrchestrationEventType;
|
|
12260
|
+
[WidgetType.BRIDGE]: BridgeEventType | OrchestrationEventType;
|
|
12261
|
+
[WidgetType.ONRAMP]: OnRampEventType | OrchestrationEventType;
|
|
12262
|
+
[WidgetType.SALE]: SaleEventType | OrchestrationEventType;
|
|
12263
|
+
};
|
|
12264
|
+
type OrchestrationMapping = {
|
|
12265
|
+
[OrchestrationEventType.REQUEST_CONNECT]: RequestConnectEvent;
|
|
12266
|
+
[OrchestrationEventType.REQUEST_WALLET]: RequestWalletEvent;
|
|
12267
|
+
[OrchestrationEventType.REQUEST_SWAP]: RequestSwapEvent;
|
|
12268
|
+
[OrchestrationEventType.REQUEST_BRIDGE]: RequestBridgeEvent;
|
|
12269
|
+
[OrchestrationEventType.REQUEST_ONRAMP]: RequestOnrampEvent;
|
|
12270
|
+
};
|
|
12271
|
+
type ProviderEventMapping = {
|
|
12272
|
+
[ProviderEventType.PROVIDER_UPDATED]: ProviderUpdated;
|
|
12273
|
+
};
|
|
12274
|
+
/**
|
|
12275
|
+
* Mapping of widget type, to each of it's events and then each event's payload
|
|
12276
|
+
* Update this whenever a new event is created and used by a widget
|
|
12277
|
+
* Each widget also has all of the orchestration events
|
|
12278
|
+
*/
|
|
12279
|
+
type WidgetEventData = {
|
|
12280
|
+
[WidgetType.CONNECT]: {
|
|
12281
|
+
[ConnectEventType.SUCCESS]: ConnectionSuccess;
|
|
12282
|
+
[ConnectEventType.FAILURE]: ConnectionFailed;
|
|
12283
|
+
[ConnectEventType.CLOSE_WIDGET]: {};
|
|
12284
|
+
} & OrchestrationMapping & ProviderEventMapping;
|
|
12285
|
+
[WidgetType.WALLET]: {
|
|
12286
|
+
[WalletEventType.NETWORK_SWITCH]: WalletNetworkSwitchEvent;
|
|
12287
|
+
[WalletEventType.DISCONNECT_WALLET]: WalletDisconnectWalletEvent;
|
|
12288
|
+
[WalletEventType.CLOSE_WIDGET]: {};
|
|
12289
|
+
} & OrchestrationMapping & ProviderEventMapping;
|
|
12290
|
+
[WidgetType.SWAP]: {
|
|
12291
|
+
[SwapEventType.SUCCESS]: SwapSuccess;
|
|
12292
|
+
[SwapEventType.FAILURE]: SwapFailed;
|
|
12293
|
+
[SwapEventType.REJECTED]: SwapRejected;
|
|
12294
|
+
[SwapEventType.CLOSE_WIDGET]: {};
|
|
12295
|
+
} & OrchestrationMapping & ProviderEventMapping;
|
|
12296
|
+
[WidgetType.BRIDGE]: {
|
|
12297
|
+
[BridgeEventType.SUCCESS]: BridgeSuccess;
|
|
12298
|
+
[BridgeEventType.FAILURE]: BridgeFailed;
|
|
12299
|
+
[BridgeEventType.CLOSE_WIDGET]: {};
|
|
12300
|
+
} & OrchestrationMapping & ProviderEventMapping;
|
|
12301
|
+
[WidgetType.ONRAMP]: {
|
|
12302
|
+
[OnRampEventType.SUCCESS]: OnRampSuccess;
|
|
12303
|
+
[OnRampEventType.FAILURE]: OnRampFailed;
|
|
12304
|
+
[OnRampEventType.CLOSE_WIDGET]: {};
|
|
12305
|
+
} & OrchestrationMapping & ProviderEventMapping;
|
|
12306
|
+
[WidgetType.SALE]: {
|
|
12307
|
+
[SaleEventType.SUCCESS]: SaleSuccess;
|
|
12308
|
+
[SaleEventType.FAILURE]: SaleFailed;
|
|
12309
|
+
[SaleEventType.REJECTED]: any;
|
|
12310
|
+
[SaleEventType.CLOSE_WIDGET]: {};
|
|
12311
|
+
} & OrchestrationMapping & ProviderEventMapping;
|
|
12312
|
+
};
|
|
12313
|
+
/**
|
|
12314
|
+
* Represents an event emitted by a widget. The event type should match the event data
|
|
12315
|
+
*/
|
|
12316
|
+
/**
|
|
12317
|
+
* Represents an event emitted by a widget.
|
|
12318
|
+
* @template T - The widget type
|
|
12319
|
+
* @template KEventName - The widget event name.
|
|
12320
|
+
* @property {KEventName} type - The type of the event.
|
|
12321
|
+
* @property {WidgetEventData[T][KEventName]} data - The data associated with the widget event.
|
|
12322
|
+
*/
|
|
12323
|
+
type WidgetEvent<T extends WidgetType, KEventName extends keyof WidgetEventData[T]> = {
|
|
12324
|
+
type: KEventName;
|
|
12325
|
+
data: WidgetEventData[T][KEventName];
|
|
12326
|
+
};
|
|
12327
|
+
/**
|
|
12328
|
+
* Represents an event emitted by a widget.
|
|
12329
|
+
* @template KEventName - The orchestration event name.
|
|
12330
|
+
* @property {KEventName} type - The type of the event.
|
|
12331
|
+
* @property {OrchestrationMapping[KEventName]} data - The data associated with the event.
|
|
12332
|
+
*/
|
|
12333
|
+
type OrchestrationEvent<KEventName extends keyof OrchestrationMapping> = {
|
|
12334
|
+
type: KEventName;
|
|
12335
|
+
data: OrchestrationMapping[KEventName];
|
|
12336
|
+
};
|
|
12337
|
+
/**
|
|
12338
|
+
* Represents an event emitted by a widget.
|
|
12339
|
+
* @template KEventName - The provider event name.
|
|
12340
|
+
* @property {KEventName} type - The type of the event.
|
|
12341
|
+
* @property {ProviderEventMapping[KEventName]} data - The data associated with the event.
|
|
12342
|
+
*/
|
|
12343
|
+
type ProviderEvent<KEventName extends keyof ProviderEventMapping> = {
|
|
12344
|
+
type: KEventName;
|
|
12345
|
+
data: ProviderEventMapping[KEventName];
|
|
12346
|
+
};
|
|
12347
|
+
interface IWidgetsFactory {
|
|
12348
|
+
/**
|
|
12349
|
+
* Create a new widget instance.
|
|
12350
|
+
* @param type widget type to instantiate.
|
|
12351
|
+
*/
|
|
12352
|
+
create<T extends WidgetType>(type: T, config?: WidgetConfigurations[T], provider?: Web3Provider): Widget<T>;
|
|
12353
|
+
updateProvider(provider: Web3Provider): void;
|
|
12354
|
+
}
|
|
12355
|
+
/**
|
|
12356
|
+
* Widget interface. Every widget implements this interface.
|
|
12357
|
+
*/
|
|
12358
|
+
interface Widget<T extends WidgetType> {
|
|
12359
|
+
/**
|
|
12360
|
+
* Mount a widget to a DOM ref element.
|
|
12361
|
+
* @param id ID of the DOM element where the widget will be mounted.
|
|
12362
|
+
*/
|
|
12363
|
+
mount(id: string, params?: WidgetParameters[T]): void;
|
|
12364
|
+
/**
|
|
12365
|
+
* Unmount a widget and reset parameters
|
|
12366
|
+
*/
|
|
12367
|
+
unmount(): void;
|
|
12368
|
+
/**
|
|
12369
|
+
* Update the widget properties
|
|
12370
|
+
* @param props Widget specific properties including configuration
|
|
12371
|
+
*/
|
|
12372
|
+
update(props: WidgetProperties<T>): void;
|
|
12373
|
+
/**
|
|
12374
|
+
* Add a listener for a widget event.
|
|
12375
|
+
* @param event Widget specific event name.
|
|
12376
|
+
* @param callback function to execute when the event is received.
|
|
12377
|
+
*/
|
|
12378
|
+
addListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName, callback: (data: WidgetEventData[T][KEventName]) => void): void;
|
|
12379
|
+
/**
|
|
12380
|
+
* Removes an event listener for a widget event.
|
|
12381
|
+
* @param type Widget specific event name.
|
|
12382
|
+
*/
|
|
12383
|
+
removeListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName): void;
|
|
12384
|
+
}
|
|
12385
|
+
/**
|
|
12386
|
+
* Represents the version of the Checkout Widgets to use defaults to (0.1.9-alpha)
|
|
12387
|
+
* @property {number} major - The major version of the widgets, must specify a major version even if it is 0.
|
|
12388
|
+
* @property {number | undefined} minor - The minor version of the widgets, leaving this blank will use the latest minor based on major
|
|
12389
|
+
* @property {number | undefined} patch - The patch version of the widgets, leaving this blank will use the latest minor based on minor
|
|
12390
|
+
* @property {'alpha' | undefined} prerelease - The prerelease version of the widgets, can only be 'alpha'. Do not use in production.
|
|
12391
|
+
* @property {number | undefined} build - The build version of the widgets. Do not use in production.
|
|
12392
|
+
*
|
|
12393
|
+
* @example
|
|
12394
|
+
* { major: 0 } - use default version 0.1.9-alpha
|
|
12395
|
+
* { major: 1 } - use version 1.x.x, pickup all new minor and patch versions released
|
|
12396
|
+
* { major: 1, minor: 1 } - use version 1.1.x, pickup all new patch versions released
|
|
12397
|
+
* { major: 1, minor: 2, patch: 3 } - use version 1.2.3 specifically
|
|
12398
|
+
*/
|
|
12399
|
+
type SemanticVersion = {
|
|
12400
|
+
major: number;
|
|
12401
|
+
minor?: number;
|
|
12402
|
+
patch?: number;
|
|
12403
|
+
prerelease?: 'alpha';
|
|
12404
|
+
build?: number;
|
|
12405
|
+
};
|
|
12406
|
+
/**
|
|
12407
|
+
* Represents the global configuration options for the Checkout Widgets.
|
|
12408
|
+
* @property {WidgetTheme | undefined} theme - The theme of the Checkout Widget (default: "DARK")
|
|
12409
|
+
* @property {Environment | undefined} environment - The environment configuration (default: "SANDBOX")
|
|
12410
|
+
* @property {SemanticVersion | undefined} version - The version of the checkout widgets js file to use (default: "0.1.x")
|
|
12411
|
+
* @property {boolean | undefined} isOnRampEnabled - Enable on-ramp top-up method (default: "true")
|
|
12412
|
+
* @property {boolean | undefined} isSwapEnabled - Enable swap top-up method (default: "true")
|
|
12413
|
+
* @property {boolean | undefined} isBridgeEnabled - Enable bridge top-up method (default: "true")
|
|
12414
|
+
*/
|
|
12415
|
+
type CheckoutWidgetsConfig = {
|
|
12416
|
+
theme?: WidgetTheme;
|
|
12417
|
+
environment?: Environment;
|
|
12418
|
+
version?: SemanticVersion;
|
|
12419
|
+
isOnRampEnabled?: boolean;
|
|
12420
|
+
isSwapEnabled?: boolean;
|
|
12421
|
+
isBridgeEnabled?: boolean;
|
|
12422
|
+
};
|
|
12423
|
+
|
|
12424
|
+
/**
|
|
12425
|
+
* Represents the configuration options for instantiating the Checkout Widgets factory.
|
|
12426
|
+
* @property {WidgetConfiguration} config - global configuration options for the widgets.
|
|
12427
|
+
* @property {SemanticVersion | undefined} version - version of the Checkout widgets bundle (default latest version will be used).
|
|
12428
|
+
*/
|
|
12429
|
+
type WidgetsInit = {
|
|
12430
|
+
config: WidgetConfiguration;
|
|
12431
|
+
version?: SemanticVersion;
|
|
12432
|
+
};
|
|
12433
|
+
|
|
11896
12434
|
declare class Checkout {
|
|
12435
|
+
private readOnlyProviders;
|
|
11897
12436
|
readonly config: CheckoutConfiguration;
|
|
11898
12437
|
readonly fiatRampService: FiatRampService;
|
|
11899
12438
|
readonly availability: AvailabilityService;
|
|
12439
|
+
readonly passport?: Passport;
|
|
11900
12440
|
/**
|
|
11901
12441
|
* Constructs a new instance of the CheckoutModule class.
|
|
11902
12442
|
* @param {CheckoutModuleConfiguration} [config=SANDBOX_CONFIGURATION] - The configuration object for the CheckoutModule.
|
|
11903
12443
|
*/
|
|
11904
12444
|
constructor(config?: CheckoutModuleConfiguration);
|
|
12445
|
+
/**
|
|
12446
|
+
* Loads the widgets bundle and initiate the widgets factory.
|
|
12447
|
+
* @param {WidgetsInit} init - The initialisation parameters for loading the widgets bundle and applying configuration
|
|
12448
|
+
*/
|
|
12449
|
+
widgets(init: WidgetsInit): Promise<ImmutableCheckoutWidgets.WidgetsFactory>;
|
|
11905
12450
|
/**
|
|
11906
12451
|
* Creates a provider using the given parameters.
|
|
11907
12452
|
* @param {CreateProviderParams} params - The parameters for creating the provider.
|
|
@@ -12021,4 +12566,123 @@ declare class Checkout {
|
|
|
12021
12566
|
isSwapAvailable(): Promise<boolean>;
|
|
12022
12567
|
}
|
|
12023
12568
|
|
|
12024
|
-
|
|
12569
|
+
/**
|
|
12570
|
+
* Declares global interfaces and namespaces for the application.
|
|
12571
|
+
* @global
|
|
12572
|
+
* @namespace ImmutableCheckoutWidgets
|
|
12573
|
+
* */
|
|
12574
|
+
declare global {
|
|
12575
|
+
namespace ImmutableCheckoutWidgets {
|
|
12576
|
+
class WidgetsFactory implements IWidgetsFactory {
|
|
12577
|
+
constructor(sdk: Checkout, config: CheckoutWidgetsConfig);
|
|
12578
|
+
create<T extends WidgetType>(type: T, config?: WidgetConfigurations[T], provider?: Web3Provider): Widget<T>;
|
|
12579
|
+
updateProvider(provider: Web3Provider): void;
|
|
12580
|
+
}
|
|
12581
|
+
class Connect<T extends WidgetType> implements Widget<T> {
|
|
12582
|
+
constructor(sdk: Checkout, props: WidgetProperties<T>);
|
|
12583
|
+
mount(id: string, params?: WidgetParameters[T]): void;
|
|
12584
|
+
unmount(): void;
|
|
12585
|
+
update(props: WidgetProperties<T>): void;
|
|
12586
|
+
addListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName, callback: (data: WidgetEventData[T][KEventName]) => void): void;
|
|
12587
|
+
removeListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName): void;
|
|
12588
|
+
}
|
|
12589
|
+
class Bridge<T extends WidgetType> implements Widget<T> {
|
|
12590
|
+
constructor(sdk: Checkout, props: WidgetProperties<T>);
|
|
12591
|
+
mount(id: string, params?: WidgetParameters[T]): void;
|
|
12592
|
+
unmount(): void;
|
|
12593
|
+
update(props: WidgetProperties<T>): void;
|
|
12594
|
+
addListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName, callback: (data: WidgetEventData[T][KEventName]) => void): void;
|
|
12595
|
+
removeListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName): void;
|
|
12596
|
+
}
|
|
12597
|
+
class Wallet<T extends WidgetType> implements Widget<T> {
|
|
12598
|
+
constructor(sdk: Checkout, props: WidgetProperties<T>);
|
|
12599
|
+
mount(id: string, params?: WidgetParameters[T]): void;
|
|
12600
|
+
unmount(): void;
|
|
12601
|
+
update(props: WidgetProperties<T>): void;
|
|
12602
|
+
addListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName, callback: (data: WidgetEventData[T][KEventName]) => void): void;
|
|
12603
|
+
removeListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName): void;
|
|
12604
|
+
}
|
|
12605
|
+
class Swap<T extends WidgetType> implements Widget<T> {
|
|
12606
|
+
constructor(sdk: Checkout, props: WidgetProperties<T>);
|
|
12607
|
+
mount(id: string, params?: WidgetParameters[T]): void;
|
|
12608
|
+
unmount(): void;
|
|
12609
|
+
update(props: WidgetProperties<T>): void;
|
|
12610
|
+
addListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName, callback: (data: WidgetEventData[T][KEventName]) => void): void;
|
|
12611
|
+
removeListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName): void;
|
|
12612
|
+
}
|
|
12613
|
+
class OnRamp<T extends WidgetType> implements Widget<T> {
|
|
12614
|
+
constructor(sdk: Checkout, props: WidgetProperties<T>);
|
|
12615
|
+
mount(id: string, params?: WidgetParameters[T]): void;
|
|
12616
|
+
unmount(): void;
|
|
12617
|
+
update(props: WidgetProperties<T>): void;
|
|
12618
|
+
addListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName, callback: (data: WidgetEventData[T][KEventName]) => void): void;
|
|
12619
|
+
removeListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName): void;
|
|
12620
|
+
}
|
|
12621
|
+
class Sale<T extends WidgetType> implements Widget<T> {
|
|
12622
|
+
constructor(sdk: Checkout, props: WidgetProperties<T>);
|
|
12623
|
+
mount(id: string, params?: WidgetParameters[T]): void;
|
|
12624
|
+
unmount(): void;
|
|
12625
|
+
update(props: WidgetProperties<T>): void;
|
|
12626
|
+
addListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName, callback: (data: WidgetEventData[T][KEventName]) => void): void;
|
|
12627
|
+
removeListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName): void;
|
|
12628
|
+
}
|
|
12629
|
+
}
|
|
12630
|
+
}
|
|
12631
|
+
|
|
12632
|
+
/**
|
|
12633
|
+
* Enum representing different types of errors that can occur during the checkout process.
|
|
12634
|
+
*/
|
|
12635
|
+
declare enum CheckoutErrorType {
|
|
12636
|
+
WEB3_PROVIDER_ERROR = "WEB3_PROVIDER_ERROR",
|
|
12637
|
+
PROVIDER_ERROR = "PROVIDER_ERROR",
|
|
12638
|
+
DEFAULT_PROVIDER_ERROR = "DEFAULT_PROVIDER_ERROR",
|
|
12639
|
+
CONNECT_PROVIDER_ERROR = "CONNECT_PROVIDER_ERROR",
|
|
12640
|
+
GET_BALANCE_ERROR = "GET_BALANCE_ERROR",
|
|
12641
|
+
GET_INDEXER_BALANCE_ERROR = "GET_INDEXER_BALANCE_ERROR",
|
|
12642
|
+
GET_ERC20_BALANCE_ERROR = "GET_ERC20_BALANCE_ERROR",
|
|
12643
|
+
GET_ERC721_BALANCE_ERROR = "GET_ERC721_BALANCE_ERROR",
|
|
12644
|
+
GET_NETWORK_INFO_ERROR = "GET_NETWORK_INFO_ERROR",
|
|
12645
|
+
METAMASK_PROVIDER_ERROR = "METAMASK_PROVIDER_ERROR",
|
|
12646
|
+
CHAIN_NOT_SUPPORTED_ERROR = "CHAIN_NOT_SUPPORTED_ERROR",
|
|
12647
|
+
PROVIDER_REQUEST_MISSING_ERROR = "PROVIDER_REQUEST_MISSING_ERROR",
|
|
12648
|
+
PROVIDER_REQUEST_FAILED_ERROR = "PROVIDER_REQUEST_FAILED_ERROR",
|
|
12649
|
+
USER_REJECTED_REQUEST_ERROR = "USER_REJECTED_REQUEST_ERROR",
|
|
12650
|
+
TRANSACTION_FAILED = "TRANSACTION_FAILED",
|
|
12651
|
+
INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS",
|
|
12652
|
+
UNPREDICTABLE_GAS_LIMIT = "UNPREDICTABLE_GAS_LIMIT",
|
|
12653
|
+
INVALID_GAS_ESTIMATE_TYPE = "INVALID_GAS_ESTIMATE_TYPE",
|
|
12654
|
+
UNSUPPORTED_TOKEN_TYPE_ERROR = "UNSUPPORTED_TOKEN_TYPE_ERROR",
|
|
12655
|
+
UNSUPPORTED_BALANCE_REQUIREMENT_ERROR = "UNSUPPORTED_BALANCE_REQUIREMENT_ERROR",
|
|
12656
|
+
GET_ORDER_LISTING_ERROR = "GET_ORDER_LISTING_ERROR",
|
|
12657
|
+
CANCEL_ORDER_LISTING_ERROR = "CANCEL_ORDER_LISTING_ERROR",
|
|
12658
|
+
PREPARE_ORDER_LISTING_ERROR = "PREPARE_ORDER_LISTING_ERROR",
|
|
12659
|
+
CREATE_ORDER_LISTING_ERROR = "CREATE_ORDER_LISTING_ERROR",
|
|
12660
|
+
FULFILL_ORDER_LISTING_ERROR = "FULFILL_ORDER_LISTING_ERROR",
|
|
12661
|
+
SWITCH_NETWORK_UNSUPPORTED = "SWITCH_NETWORK_UNSUPPORTED",
|
|
12662
|
+
GET_ERC20_ALLOWANCE_ERROR = "GET_ERC20_ALLOWANCE_ERROR",
|
|
12663
|
+
GET_ERC721_ALLOWANCE_ERROR = "GET_ERC721_ALLOWANCE_ERROR",
|
|
12664
|
+
EXECUTE_APPROVAL_TRANSACTION_ERROR = "EXECUTE_APPROVAL_TRANSACTION_ERROR",
|
|
12665
|
+
EXECUTE_FULFILLMENT_TRANSACTION_ERROR = "EXECUTE_FULFILLMENT_TRANSACTION_ERROR",
|
|
12666
|
+
SIGN_MESSAGE_ERROR = "SIGN_MESSAGE_ERROR",
|
|
12667
|
+
BRIDGE_GAS_ESTIMATE_ERROR = "BRIDGE_GAS_ESTIMATE_ERROR",
|
|
12668
|
+
ORDER_FEE_ERROR = "ORDER_FEE_ERROR",
|
|
12669
|
+
ITEM_REQUIREMENTS_ERROR = "ITEM_REQUIREMENTS_ERROR",
|
|
12670
|
+
API_ERROR = "API_ERROR",
|
|
12671
|
+
ORDER_EXPIRED_ERROR = "ORDER_EXPIRED_ERROR",
|
|
12672
|
+
WIDGETS_SCRIPT_LOAD_ERROR = "WIDGETS_SCRIPT_LOAD_ERROR"
|
|
12673
|
+
}
|
|
12674
|
+
/**
|
|
12675
|
+
* Represents an error object with a specific type, optional message, and optional data.
|
|
12676
|
+
* @property {CheckoutErrorType} type - The type of the error.
|
|
12677
|
+
* @property {string | undefined} [message] - The error message.
|
|
12678
|
+
* @property {Object.<string, string> | undefined} [data] - Additional data associated with the error.
|
|
12679
|
+
*/
|
|
12680
|
+
type ErrorType = {
|
|
12681
|
+
type: CheckoutErrorType;
|
|
12682
|
+
message?: string;
|
|
12683
|
+
data?: {
|
|
12684
|
+
[key: string]: string;
|
|
12685
|
+
};
|
|
12686
|
+
};
|
|
12687
|
+
|
|
12688
|
+
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 };
|