@imtbl/sdk 0.28.8 → 0.28.10-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 +924 -233
- package/dist/checkout_sdk.js +2893 -2400
- 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 +2931 -2895
- package/dist/index.d.ts +1160 -15417
- package/dist/index.js +2932 -2895
- 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 -25605
- package/dist/checkout_widgets.js +0 -450
package/dist/checkout_sdk.d.ts
CHANGED
|
@@ -41,6 +41,14 @@ declare class BigNumber implements Hexable {
|
|
|
41
41
|
static isBigNumber(value: any): value is BigNumber;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
declare type Network = {
|
|
45
|
+
name: string;
|
|
46
|
+
chainId: number;
|
|
47
|
+
ensAddress?: string;
|
|
48
|
+
_defaultProvider?: (providers: any, options?: any) => any;
|
|
49
|
+
};
|
|
50
|
+
declare type Networkish = Network | string | number;
|
|
51
|
+
|
|
44
52
|
declare type Deferrable<T> = {
|
|
45
53
|
[K in keyof T]: T[K] | Promise<T[K]>;
|
|
46
54
|
};
|
|
@@ -50,14 +58,6 @@ declare class Description<T = any> {
|
|
|
50
58
|
});
|
|
51
59
|
}
|
|
52
60
|
|
|
53
|
-
declare type Network = {
|
|
54
|
-
name: string;
|
|
55
|
-
chainId: number;
|
|
56
|
-
ensAddress?: string;
|
|
57
|
-
_defaultProvider?: (providers: any, options?: any) => any;
|
|
58
|
-
};
|
|
59
|
-
declare type Networkish = Network | string | number;
|
|
60
|
-
|
|
61
61
|
declare type AccessList = Array<{
|
|
62
62
|
address: string;
|
|
63
63
|
storageKeys: Array<string>;
|
|
@@ -238,43 +238,6 @@ declare abstract class Provider$1 implements OnceBlockable {
|
|
|
238
238
|
static isProvider(value: any): value is Provider$1;
|
|
239
239
|
}
|
|
240
240
|
|
|
241
|
-
interface TypedDataDomain {
|
|
242
|
-
name?: string;
|
|
243
|
-
version?: string;
|
|
244
|
-
chainId?: BigNumberish;
|
|
245
|
-
verifyingContract?: string;
|
|
246
|
-
salt?: BytesLike;
|
|
247
|
-
}
|
|
248
|
-
interface TypedDataField {
|
|
249
|
-
name: string;
|
|
250
|
-
type: string;
|
|
251
|
-
}
|
|
252
|
-
interface TypedDataSigner {
|
|
253
|
-
_signTypedData(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, value: Record<string, any>): Promise<string>;
|
|
254
|
-
}
|
|
255
|
-
declare abstract class Signer {
|
|
256
|
-
readonly provider?: Provider$1;
|
|
257
|
-
abstract getAddress(): Promise<string>;
|
|
258
|
-
abstract signMessage(message: Bytes | string): Promise<string>;
|
|
259
|
-
abstract signTransaction(transaction: Deferrable<TransactionRequest>): Promise<string>;
|
|
260
|
-
abstract connect(provider: Provider$1): Signer;
|
|
261
|
-
readonly _isSigner: boolean;
|
|
262
|
-
constructor();
|
|
263
|
-
getBalance(blockTag?: BlockTag): Promise<BigNumber>;
|
|
264
|
-
getTransactionCount(blockTag?: BlockTag): Promise<number>;
|
|
265
|
-
estimateGas(transaction: Deferrable<TransactionRequest>): Promise<BigNumber>;
|
|
266
|
-
call(transaction: Deferrable<TransactionRequest>, blockTag?: BlockTag): Promise<string>;
|
|
267
|
-
sendTransaction(transaction: Deferrable<TransactionRequest>): Promise<TransactionResponse>;
|
|
268
|
-
getChainId(): Promise<number>;
|
|
269
|
-
getGasPrice(): Promise<BigNumber>;
|
|
270
|
-
getFeeData(): Promise<FeeData$1>;
|
|
271
|
-
resolveName(name: string): Promise<string>;
|
|
272
|
-
checkTransaction(transaction: Deferrable<TransactionRequest>): Deferrable<TransactionRequest>;
|
|
273
|
-
populateTransaction(transaction: Deferrable<TransactionRequest>): Promise<TransactionRequest>;
|
|
274
|
-
_checkProvider(operation?: string): void;
|
|
275
|
-
static isSigner(value: any): value is Signer;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
241
|
declare type FormatFunc = (value: any) => any;
|
|
279
242
|
declare type FormatFuncs = {
|
|
280
243
|
[key: string]: FormatFunc;
|
|
@@ -475,6 +438,43 @@ declare class BaseProvider extends Provider$1 implements EnsProvider {
|
|
|
475
438
|
removeAllListeners(eventName?: EventType): this;
|
|
476
439
|
}
|
|
477
440
|
|
|
441
|
+
interface TypedDataDomain {
|
|
442
|
+
name?: string;
|
|
443
|
+
version?: string;
|
|
444
|
+
chainId?: BigNumberish;
|
|
445
|
+
verifyingContract?: string;
|
|
446
|
+
salt?: BytesLike;
|
|
447
|
+
}
|
|
448
|
+
interface TypedDataField {
|
|
449
|
+
name: string;
|
|
450
|
+
type: string;
|
|
451
|
+
}
|
|
452
|
+
interface TypedDataSigner {
|
|
453
|
+
_signTypedData(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, value: Record<string, any>): Promise<string>;
|
|
454
|
+
}
|
|
455
|
+
declare abstract class Signer {
|
|
456
|
+
readonly provider?: Provider$1;
|
|
457
|
+
abstract getAddress(): Promise<string>;
|
|
458
|
+
abstract signMessage(message: Bytes | string): Promise<string>;
|
|
459
|
+
abstract signTransaction(transaction: Deferrable<TransactionRequest>): Promise<string>;
|
|
460
|
+
abstract connect(provider: Provider$1): Signer;
|
|
461
|
+
readonly _isSigner: boolean;
|
|
462
|
+
constructor();
|
|
463
|
+
getBalance(blockTag?: BlockTag): Promise<BigNumber>;
|
|
464
|
+
getTransactionCount(blockTag?: BlockTag): Promise<number>;
|
|
465
|
+
estimateGas(transaction: Deferrable<TransactionRequest>): Promise<BigNumber>;
|
|
466
|
+
call(transaction: Deferrable<TransactionRequest>, blockTag?: BlockTag): Promise<string>;
|
|
467
|
+
sendTransaction(transaction: Deferrable<TransactionRequest>): Promise<TransactionResponse>;
|
|
468
|
+
getChainId(): Promise<number>;
|
|
469
|
+
getGasPrice(): Promise<BigNumber>;
|
|
470
|
+
getFeeData(): Promise<FeeData$1>;
|
|
471
|
+
resolveName(name: string): Promise<string>;
|
|
472
|
+
checkTransaction(transaction: Deferrable<TransactionRequest>): Deferrable<TransactionRequest>;
|
|
473
|
+
populateTransaction(transaction: Deferrable<TransactionRequest>): Promise<TransactionRequest>;
|
|
474
|
+
_checkProvider(operation?: string): void;
|
|
475
|
+
static isSigner(value: any): value is Signer;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
478
|
declare class JsonRpcSigner extends Signer implements TypedDataSigner {
|
|
479
479
|
readonly provider: JsonRpcProvider;
|
|
480
480
|
_index: number;
|
|
@@ -546,95 +546,6 @@ declare class Web3Provider extends JsonRpcProvider {
|
|
|
546
546
|
send(method: string, params: Array<any>): Promise<any>;
|
|
547
547
|
}
|
|
548
548
|
|
|
549
|
-
declare enum Environment {
|
|
550
|
-
PRODUCTION = "production",
|
|
551
|
-
SANDBOX = "sandbox"
|
|
552
|
-
}
|
|
553
|
-
declare class ImmutableConfiguration {
|
|
554
|
-
readonly environment: Environment;
|
|
555
|
-
readonly rateLimitingKey?: string;
|
|
556
|
-
readonly apiKey?: string;
|
|
557
|
-
readonly clientAppId?: string;
|
|
558
|
-
constructor(options: {
|
|
559
|
-
environment: Environment;
|
|
560
|
-
rateLimitingKey?: string;
|
|
561
|
-
apiKey?: string;
|
|
562
|
-
clientAppId?: string;
|
|
563
|
-
});
|
|
564
|
-
}
|
|
565
|
-
interface ModuleConfiguration<T> {
|
|
566
|
-
baseConfig: ImmutableConfiguration;
|
|
567
|
-
overrides?: T;
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
type ExchangeContracts = {
|
|
571
|
-
multicall: string;
|
|
572
|
-
coreFactory: string;
|
|
573
|
-
quoterV2: string;
|
|
574
|
-
peripheryRouter: string;
|
|
575
|
-
secondaryFee: string;
|
|
576
|
-
};
|
|
577
|
-
/**
|
|
578
|
-
* Type representing an ERC20 token
|
|
579
|
-
* @property {string} type - The token type, used to discriminate between {@link ERC20} and {@link Native}
|
|
580
|
-
* @property {number} chainId - The chain ID
|
|
581
|
-
* @property {string} address - The token address
|
|
582
|
-
* @property {number} decimals - The token decimals
|
|
583
|
-
* @property {string | undefined} symbol - The token symbol or undefined if it is not available
|
|
584
|
-
* @property {string | undefined} name - The token name or undefined if it is not available
|
|
585
|
-
*/
|
|
586
|
-
type ERC20 = {
|
|
587
|
-
type: 'erc20';
|
|
588
|
-
chainId: number;
|
|
589
|
-
address: string;
|
|
590
|
-
decimals: number;
|
|
591
|
-
symbol?: string;
|
|
592
|
-
name?: string;
|
|
593
|
-
};
|
|
594
|
-
/**
|
|
595
|
-
* Type representing a native token
|
|
596
|
-
* @property {string} type - The token type, used to discriminate between {@link ERC20} and {@link Native}
|
|
597
|
-
* @property {number} chainId - The chain ID
|
|
598
|
-
* @property {number} decimals - The token decimals
|
|
599
|
-
* @property {string | undefined} symbol - The token symbol or undefined if it is not available
|
|
600
|
-
* @property {string | undefined} name - The token name or undefined if it is not available
|
|
601
|
-
*/
|
|
602
|
-
type Native = {
|
|
603
|
-
type: 'native';
|
|
604
|
-
chainId: number;
|
|
605
|
-
decimals: number;
|
|
606
|
-
symbol?: string;
|
|
607
|
-
name?: string;
|
|
608
|
-
};
|
|
609
|
-
/**
|
|
610
|
-
* Type representing a token, either an {@link ERC20} or {@link Native}
|
|
611
|
-
*/
|
|
612
|
-
type Coin = ERC20 | Native;
|
|
613
|
-
/**
|
|
614
|
-
* Type representing the overrides for the {@link Exchange} module
|
|
615
|
-
* @property {string} rpcURL - The RPC URL for the chain
|
|
616
|
-
* @property {ExchangeContracts} exchangeContracts - The DEX contract addresses
|
|
617
|
-
* @property {ERC20[]} commonRoutingTokens - The tokens used to find available pools for a swap
|
|
618
|
-
* @property {Coin} nativeToken - The native token of the chain
|
|
619
|
-
* @property {ERC20} wrappedNativeToken - The wrapped native token of the chain
|
|
620
|
-
*/
|
|
621
|
-
type ExchangeOverrides = {
|
|
622
|
-
rpcURL: string;
|
|
623
|
-
exchangeContracts: ExchangeContracts;
|
|
624
|
-
commonRoutingTokens: ERC20[];
|
|
625
|
-
nativeToken: Coin;
|
|
626
|
-
wrappedNativeToken: ERC20;
|
|
627
|
-
};
|
|
628
|
-
|
|
629
|
-
/**
|
|
630
|
-
* @typedef {string} Address - Represents an Ethereum address.
|
|
631
|
-
*/
|
|
632
|
-
type Address = string;
|
|
633
|
-
/**
|
|
634
|
-
* @typedef {Address | 'NATIVE'} FungibleToken - Represents a fungible token, either an ERC20 token address or the native token.
|
|
635
|
-
*/
|
|
636
|
-
type FungibleToken = Address | 'NATIVE';
|
|
637
|
-
|
|
638
549
|
// TypeScript Version: 3.0
|
|
639
550
|
|
|
640
551
|
type AxiosRequestHeaders = Record<string, string | number | boolean>;
|
|
@@ -10184,6 +10095,27 @@ interface IMXProvider {
|
|
|
10184
10095
|
completeWithdrawal(starkPublicKey: string, token: AnyToken): Promise<TransactionResponse>;
|
|
10185
10096
|
}
|
|
10186
10097
|
|
|
10098
|
+
declare enum Environment {
|
|
10099
|
+
PRODUCTION = "production",
|
|
10100
|
+
SANDBOX = "sandbox"
|
|
10101
|
+
}
|
|
10102
|
+
declare class ImmutableConfiguration {
|
|
10103
|
+
readonly environment: Environment;
|
|
10104
|
+
readonly rateLimitingKey?: string;
|
|
10105
|
+
readonly apiKey?: string;
|
|
10106
|
+
readonly clientAppId?: string;
|
|
10107
|
+
constructor(options: {
|
|
10108
|
+
environment: Environment;
|
|
10109
|
+
rateLimitingKey?: string;
|
|
10110
|
+
apiKey?: string;
|
|
10111
|
+
clientAppId?: string;
|
|
10112
|
+
});
|
|
10113
|
+
}
|
|
10114
|
+
interface ModuleConfiguration<T> {
|
|
10115
|
+
baseConfig: ImmutableConfiguration;
|
|
10116
|
+
overrides?: T;
|
|
10117
|
+
}
|
|
10118
|
+
|
|
10187
10119
|
interface ImxOverrides {
|
|
10188
10120
|
immutableXConfig: ImmutableXConfiguration;
|
|
10189
10121
|
}
|
|
@@ -10724,6 +10656,7 @@ declare enum ChainName {
|
|
|
10724
10656
|
IMTBL_ZKEVM_DEVNET = "Immutable zkEVM Dev",
|
|
10725
10657
|
IMTBL_ZKEVM_MAINNET = "Immutable zkEVM"
|
|
10726
10658
|
}
|
|
10659
|
+
|
|
10727
10660
|
/**
|
|
10728
10661
|
* Represents information about a token.
|
|
10729
10662
|
* @interface TokenInfo
|
|
@@ -10740,6 +10673,7 @@ interface TokenInfo {
|
|
|
10740
10673
|
address?: string;
|
|
10741
10674
|
icon?: string;
|
|
10742
10675
|
}
|
|
10676
|
+
|
|
10743
10677
|
/**
|
|
10744
10678
|
* Interface representing the parameters for {@link Checkout.getBalance}.
|
|
10745
10679
|
* @property {Web3Provider} provider - The provider used to get the balance.
|
|
@@ -10780,6 +10714,7 @@ interface GetAllBalancesParams {
|
|
|
10780
10714
|
interface GetAllBalancesResult {
|
|
10781
10715
|
balances: GetBalanceResult[];
|
|
10782
10716
|
}
|
|
10717
|
+
|
|
10783
10718
|
interface OrderFee {
|
|
10784
10719
|
amount: FeeToken | FeePercentage;
|
|
10785
10720
|
recipient: string;
|
|
@@ -10790,6 +10725,7 @@ interface FeeToken {
|
|
|
10790
10725
|
interface FeePercentage {
|
|
10791
10726
|
percentageDecimal: number;
|
|
10792
10727
|
}
|
|
10728
|
+
|
|
10793
10729
|
type BuyResult = BuyResultSuccess | BuyResultFailed | BuyResultInsufficientFunds;
|
|
10794
10730
|
/**
|
|
10795
10731
|
* Represents the result of {@link Checkout.buy}
|
|
@@ -11327,6 +11263,7 @@ type AvailableRoutingOptions = {
|
|
|
11327
11263
|
swap?: boolean;
|
|
11328
11264
|
bridge?: boolean;
|
|
11329
11265
|
};
|
|
11266
|
+
|
|
11330
11267
|
/**
|
|
11331
11268
|
* Interface representing the parameters for {@link Checkout.buy}
|
|
11332
11269
|
* @property {Web3Provider} provider - The provider to use for the buy.
|
|
@@ -11337,6 +11274,7 @@ interface BuyParams {
|
|
|
11337
11274
|
provider: Web3Provider;
|
|
11338
11275
|
orders: Array<BuyOrder>;
|
|
11339
11276
|
}
|
|
11277
|
+
|
|
11340
11278
|
/**
|
|
11341
11279
|
* Interface representing the parameters for {@link Checkout.cancel}
|
|
11342
11280
|
* @property {Web3Provider} provider - The provider to use for the cancel.
|
|
@@ -11347,38 +11285,106 @@ interface CancelParams {
|
|
|
11347
11285
|
provider: Web3Provider;
|
|
11348
11286
|
orderIds: string[];
|
|
11349
11287
|
}
|
|
11350
|
-
|
|
11351
|
-
|
|
11352
|
-
|
|
11353
|
-
|
|
11354
|
-
|
|
11355
|
-
|
|
11356
|
-
|
|
11288
|
+
|
|
11289
|
+
type ExchangeContracts = {
|
|
11290
|
+
multicall: string;
|
|
11291
|
+
coreFactory: string;
|
|
11292
|
+
quoterV2: string;
|
|
11293
|
+
peripheryRouter: string;
|
|
11294
|
+
secondaryFee: string;
|
|
11295
|
+
};
|
|
11357
11296
|
/**
|
|
11358
|
-
*
|
|
11359
|
-
*
|
|
11360
|
-
* @property {
|
|
11361
|
-
* @property {
|
|
11362
|
-
* @property {
|
|
11363
|
-
* @property {
|
|
11297
|
+
* Type representing an ERC20 token
|
|
11298
|
+
* @property {string} type - The token type, used to discriminate between {@link ERC20} and {@link Native}
|
|
11299
|
+
* @property {number} chainId - The chain ID
|
|
11300
|
+
* @property {string} address - The token address
|
|
11301
|
+
* @property {number} decimals - The token decimals
|
|
11302
|
+
* @property {string | undefined} symbol - The token symbol or undefined if it is not available
|
|
11303
|
+
* @property {string | undefined} name - The token name or undefined if it is not available
|
|
11364
11304
|
*/
|
|
11365
|
-
type
|
|
11366
|
-
|
|
11367
|
-
|
|
11368
|
-
|
|
11369
|
-
|
|
11370
|
-
|
|
11371
|
-
|
|
11305
|
+
type ERC20 = {
|
|
11306
|
+
type: 'erc20';
|
|
11307
|
+
chainId: number;
|
|
11308
|
+
address: string;
|
|
11309
|
+
decimals: number;
|
|
11310
|
+
symbol?: string;
|
|
11311
|
+
name?: string;
|
|
11372
11312
|
};
|
|
11373
11313
|
/**
|
|
11374
|
-
*
|
|
11375
|
-
* @property {string
|
|
11376
|
-
* @property {
|
|
11377
|
-
* @property {
|
|
11378
|
-
|
|
11379
|
-
|
|
11380
|
-
|
|
11381
|
-
|
|
11314
|
+
* Type representing a native token
|
|
11315
|
+
* @property {string} type - The token type, used to discriminate between {@link ERC20} and {@link Native}
|
|
11316
|
+
* @property {number} chainId - The chain ID
|
|
11317
|
+
* @property {number} decimals - The token decimals
|
|
11318
|
+
* @property {string | undefined} symbol - The token symbol or undefined if it is not available
|
|
11319
|
+
* @property {string | undefined} name - The token name or undefined if it is not available
|
|
11320
|
+
*/
|
|
11321
|
+
type Native = {
|
|
11322
|
+
type: 'native';
|
|
11323
|
+
chainId: number;
|
|
11324
|
+
decimals: number;
|
|
11325
|
+
symbol?: string;
|
|
11326
|
+
name?: string;
|
|
11327
|
+
};
|
|
11328
|
+
/**
|
|
11329
|
+
* Type representing a token, either an {@link ERC20} or {@link Native}
|
|
11330
|
+
*/
|
|
11331
|
+
type Coin = ERC20 | Native;
|
|
11332
|
+
/**
|
|
11333
|
+
* Type representing the overrides for the {@link Exchange} module
|
|
11334
|
+
* @property {string} rpcURL - The RPC URL for the chain
|
|
11335
|
+
* @property {ExchangeContracts} exchangeContracts - The DEX contract addresses
|
|
11336
|
+
* @property {ERC20[]} commonRoutingTokens - The tokens used to find available pools for a swap
|
|
11337
|
+
* @property {Coin} nativeToken - The native token of the chain
|
|
11338
|
+
* @property {ERC20} wrappedNativeToken - The wrapped native token of the chain
|
|
11339
|
+
*/
|
|
11340
|
+
type ExchangeOverrides = {
|
|
11341
|
+
rpcURL: string;
|
|
11342
|
+
exchangeContracts: ExchangeContracts;
|
|
11343
|
+
commonRoutingTokens: ERC20[];
|
|
11344
|
+
nativeToken: Coin;
|
|
11345
|
+
wrappedNativeToken: ERC20;
|
|
11346
|
+
};
|
|
11347
|
+
|
|
11348
|
+
interface CheckoutOverrides {
|
|
11349
|
+
}
|
|
11350
|
+
/**
|
|
11351
|
+
* A type representing checkout SDK configurations.
|
|
11352
|
+
* @property {boolean} isOnRampEnabled - To enable on-ramp feature in Checkout sdk.
|
|
11353
|
+
* @property {boolean} isSwapEnabled - To enable swap feature in Checkout sdk.
|
|
11354
|
+
* @property {boolean} isBridgeEnabled - To enable bridge feature in Checkout sdk.
|
|
11355
|
+
* @property {Passport} passport - To enable passport wallet with Checkout sdk.
|
|
11356
|
+
*/
|
|
11357
|
+
interface CheckoutModuleConfiguration extends ModuleConfiguration<CheckoutOverrides> {
|
|
11358
|
+
isOnRampEnabled?: boolean;
|
|
11359
|
+
isSwapEnabled?: boolean;
|
|
11360
|
+
isBridgeEnabled?: boolean;
|
|
11361
|
+
passport?: Passport;
|
|
11362
|
+
}
|
|
11363
|
+
/**
|
|
11364
|
+
* A type representing various remotely defined configurations which are
|
|
11365
|
+
* accessible via the Checkout config and configured based on the Environment.
|
|
11366
|
+
* @property {DexConfig} dex - The config used for the DEX.
|
|
11367
|
+
* @property {OnRampConfig} onramp - The config used for the OnRamp
|
|
11368
|
+
* @property {AllowedNetworkConfig[]} allowedNetworks - An array representing the allowed networks.
|
|
11369
|
+
* @property {GasEstimateTokenConfig | undefined} gasEstimateTokens - The config for the tokens used to estimate gas.
|
|
11370
|
+
*/
|
|
11371
|
+
type RemoteConfiguration = {
|
|
11372
|
+
dex: DexConfig;
|
|
11373
|
+
onramp: OnRampConfig;
|
|
11374
|
+
bridge: BridgeConfig;
|
|
11375
|
+
allowedNetworks: AllowedNetworkConfig[];
|
|
11376
|
+
gasEstimateTokens?: GasEstimateTokenConfig;
|
|
11377
|
+
imxAddressMapping?: ImxAddressConfig;
|
|
11378
|
+
};
|
|
11379
|
+
/**
|
|
11380
|
+
* A type representing the fee structure for an OnRamp provider
|
|
11381
|
+
* @property {string | undefined} minPercentage - minimum percentage fee shown if a fee range is provided
|
|
11382
|
+
* @property {string | undefined} maxPercentage - maximum percentage fee shown if a fee range is provided
|
|
11383
|
+
* @property {string | undefined} feePercentage - specific fee percentage shown if there is no range provided
|
|
11384
|
+
*/
|
|
11385
|
+
type OnRampProviderFees = {
|
|
11386
|
+
minPercentage?: string;
|
|
11387
|
+
maxPercentage?: string;
|
|
11382
11388
|
feePercentage?: string;
|
|
11383
11389
|
};
|
|
11384
11390
|
/**
|
|
@@ -11470,6 +11476,7 @@ type ChainTokensConfig = {
|
|
|
11470
11476
|
allowed?: TokenInfo[];
|
|
11471
11477
|
blockscout?: boolean;
|
|
11472
11478
|
};
|
|
11479
|
+
|
|
11473
11480
|
/**
|
|
11474
11481
|
* Interface representing the params of {@link Checkout.connect}.
|
|
11475
11482
|
* @property {Web3Provider} provider - The provider used to connect to the network.
|
|
@@ -11500,6 +11507,16 @@ interface CheckConnectionResult {
|
|
|
11500
11507
|
isConnected: boolean;
|
|
11501
11508
|
walletAddress: string;
|
|
11502
11509
|
}
|
|
11510
|
+
|
|
11511
|
+
/**
|
|
11512
|
+
* @typedef {string} Address - Represents an Ethereum address.
|
|
11513
|
+
*/
|
|
11514
|
+
type Address = string;
|
|
11515
|
+
/**
|
|
11516
|
+
* @typedef {Address | 'NATIVE'} FungibleToken - Represents a fungible token, either an ERC20 token address or the native token.
|
|
11517
|
+
*/
|
|
11518
|
+
type FungibleToken = Address | 'NATIVE';
|
|
11519
|
+
|
|
11503
11520
|
/**
|
|
11504
11521
|
* An enum representing the type of gas estimate.
|
|
11505
11522
|
* @enum {string}
|
|
@@ -11563,6 +11580,7 @@ interface TokenAmountEstimate {
|
|
|
11563
11580
|
estimatedAmount?: BigNumber;
|
|
11564
11581
|
token?: TokenInfo;
|
|
11565
11582
|
}
|
|
11583
|
+
|
|
11566
11584
|
/**
|
|
11567
11585
|
* Represents information about a network.
|
|
11568
11586
|
* @interface NetworkInfo
|
|
@@ -11577,6 +11595,7 @@ interface NetworkInfo {
|
|
|
11577
11595
|
nativeCurrency: TokenInfo;
|
|
11578
11596
|
isSupported: boolean;
|
|
11579
11597
|
}
|
|
11598
|
+
|
|
11580
11599
|
/**
|
|
11581
11600
|
* Interface representing the parameters for {@link Checkout.switchNetwork}.
|
|
11582
11601
|
* @property {Web3Provider} provider - The provider to connect to the network.
|
|
@@ -11632,6 +11651,7 @@ declare enum NetworkFilterTypes {
|
|
|
11632
11651
|
interface NetworkFilter {
|
|
11633
11652
|
chainId: ChainId;
|
|
11634
11653
|
}
|
|
11654
|
+
|
|
11635
11655
|
/**
|
|
11636
11656
|
* Interface representing the parameters for {@link Checkout.sell}
|
|
11637
11657
|
* @property {Web3Provider} provider - The provider to use for the sell.
|
|
@@ -11642,6 +11662,7 @@ interface SellParams {
|
|
|
11642
11662
|
provider: Web3Provider;
|
|
11643
11663
|
orders: Array<SellOrder>;
|
|
11644
11664
|
}
|
|
11665
|
+
|
|
11645
11666
|
/**
|
|
11646
11667
|
* Interface representing the parameters for {@link Checkout.getTokenAllowList}.
|
|
11647
11668
|
* @property {TokenFilterTypes} type - The type of token to retrieve.
|
|
@@ -11676,6 +11697,7 @@ declare enum TokenFilterTypes {
|
|
|
11676
11697
|
interface TokenFilter {
|
|
11677
11698
|
address: string;
|
|
11678
11699
|
}
|
|
11700
|
+
|
|
11679
11701
|
/**
|
|
11680
11702
|
* Interface representing the parameters for {@link Checkout.sendTransaction}.
|
|
11681
11703
|
* @property {Web3Provider} provider - The provider to connect to the network.
|
|
@@ -11692,6 +11714,7 @@ interface SendTransactionParams {
|
|
|
11692
11714
|
interface SendTransactionResult {
|
|
11693
11715
|
transactionResponse: TransactionResponse;
|
|
11694
11716
|
}
|
|
11717
|
+
|
|
11695
11718
|
/**
|
|
11696
11719
|
* Enum representing the names of different wallet providers.
|
|
11697
11720
|
*/
|
|
@@ -11702,29 +11725,27 @@ declare enum WalletProviderName {
|
|
|
11702
11725
|
/**
|
|
11703
11726
|
* Interface for the parameters required to create a wallet provider {@link Checkout.createProvider}.
|
|
11704
11727
|
* @interface CreateProviderParams
|
|
11705
|
-
* @property {WalletProviderName}
|
|
11706
|
-
* @property {Passport | undefined} passport - The Passport instance required to create a provider for passport users.
|
|
11707
|
-
* If walletProvider is 'passport', then the passport instance must be passed in.
|
|
11728
|
+
* @property {WalletProviderName} walletProviderName - The wallet provider name to create a provider for.
|
|
11708
11729
|
*/
|
|
11709
11730
|
interface CreateProviderParams {
|
|
11710
|
-
|
|
11711
|
-
passport?: Passport;
|
|
11731
|
+
walletProviderName: WalletProviderName;
|
|
11712
11732
|
}
|
|
11713
11733
|
/**
|
|
11714
11734
|
* Represents the result of creating a Web3 provider {@link Checkout.createProvider}.
|
|
11715
11735
|
* @property {Web3Provider} provider - The created Web3 provider.
|
|
11716
|
-
* @property {WalletProviderName}
|
|
11736
|
+
* @property {WalletProviderName} walletProviderName - The wallet provider name of the provider that was created.
|
|
11717
11737
|
*/
|
|
11718
11738
|
type CreateProviderResult = {
|
|
11719
11739
|
provider: Web3Provider;
|
|
11720
11740
|
walletProviderName: WalletProviderName;
|
|
11721
11741
|
};
|
|
11742
|
+
|
|
11722
11743
|
/**
|
|
11723
11744
|
* Interface representing a wallet filter to be used in {@link GetWalletAllowListParams}.
|
|
11724
|
-
* @property {WalletProviderName}
|
|
11745
|
+
* @property {WalletProviderName} walletProviderName - The wallet provider name to filter wallets by.
|
|
11725
11746
|
*/
|
|
11726
11747
|
interface WalletFilter {
|
|
11727
|
-
|
|
11748
|
+
walletProviderName: WalletProviderName;
|
|
11728
11749
|
}
|
|
11729
11750
|
/**
|
|
11730
11751
|
* Interface representing the parameters for {@link Checkout.getWalletAllowList}.
|
|
@@ -11737,14 +11758,12 @@ interface GetWalletAllowListParams {
|
|
|
11737
11758
|
}
|
|
11738
11759
|
/**
|
|
11739
11760
|
* Interface representing information about a wallet used in {@link GetWalletAllowListResult}.
|
|
11740
|
-
* @property {WalletProviderName}
|
|
11741
|
-
* @property {string} name - The name of the wallet.
|
|
11761
|
+
* @property {WalletProviderName} walletProviderName - The wallet provider name for the wallet.
|
|
11742
11762
|
* @property {string | undefined} description - A description of the wallet.
|
|
11743
11763
|
* @property {string | undefined} icon - The URL/data:image of an icon for the wallet.
|
|
11744
11764
|
*/
|
|
11745
11765
|
interface WalletInfo {
|
|
11746
|
-
|
|
11747
|
-
name: string;
|
|
11766
|
+
walletProviderName: WalletProviderName;
|
|
11748
11767
|
description?: string;
|
|
11749
11768
|
icon?: string;
|
|
11750
11769
|
}
|
|
@@ -11761,6 +11780,7 @@ interface GetWalletAllowListResult {
|
|
|
11761
11780
|
declare enum WalletFilterTypes {
|
|
11762
11781
|
ALL = "all"
|
|
11763
11782
|
}
|
|
11783
|
+
|
|
11764
11784
|
/**
|
|
11765
11785
|
* Base URL for the checkout API based on the environment.
|
|
11766
11786
|
* @property {string} DEVELOPMENT - The base URL for the development environment.
|
|
@@ -11780,6 +11800,7 @@ type NetworkDetails = {
|
|
|
11780
11800
|
blockExplorerUrls?: string[];
|
|
11781
11801
|
};
|
|
11782
11802
|
type NetworkMap = Map<ChainId, NetworkDetails>;
|
|
11803
|
+
|
|
11783
11804
|
/**
|
|
11784
11805
|
* An enum representing the type of exchange.
|
|
11785
11806
|
* @enum {string}
|
|
@@ -11801,71 +11822,27 @@ interface FiatRampParams {
|
|
|
11801
11822
|
web3Provider: Web3Provider;
|
|
11802
11823
|
tokenAmount?: string;
|
|
11803
11824
|
tokenAddress?: string;
|
|
11804
|
-
passport?:
|
|
11805
|
-
}
|
|
11806
|
-
/**
|
|
11807
|
-
* Enum representing different types of errors that can occur during the checkout process.
|
|
11808
|
-
*/
|
|
11809
|
-
declare enum CheckoutErrorType {
|
|
11810
|
-
WEB3_PROVIDER_ERROR = "WEB3_PROVIDER_ERROR",
|
|
11811
|
-
PROVIDER_ERROR = "PROVIDER_ERROR",
|
|
11812
|
-
DEFAULT_PROVIDER_ERROR = "DEFAULT_PROVIDER_ERROR",
|
|
11813
|
-
CONNECT_PROVIDER_ERROR = "CONNECT_PROVIDER_ERROR",
|
|
11814
|
-
GET_BALANCE_ERROR = "GET_BALANCE_ERROR",
|
|
11815
|
-
GET_INDEXER_BALANCE_ERROR = "GET_INDEXER_BALANCE_ERROR",
|
|
11816
|
-
GET_ERC20_BALANCE_ERROR = "GET_ERC20_BALANCE_ERROR",
|
|
11817
|
-
GET_ERC721_BALANCE_ERROR = "GET_ERC721_BALANCE_ERROR",
|
|
11818
|
-
GET_NETWORK_INFO_ERROR = "GET_NETWORK_INFO_ERROR",
|
|
11819
|
-
METAMASK_PROVIDER_ERROR = "METAMASK_PROVIDER_ERROR",
|
|
11820
|
-
CHAIN_NOT_SUPPORTED_ERROR = "CHAIN_NOT_SUPPORTED_ERROR",
|
|
11821
|
-
PROVIDER_REQUEST_MISSING_ERROR = "PROVIDER_REQUEST_MISSING_ERROR",
|
|
11822
|
-
PROVIDER_REQUEST_FAILED_ERROR = "PROVIDER_REQUEST_FAILED_ERROR",
|
|
11823
|
-
USER_REJECTED_REQUEST_ERROR = "USER_REJECTED_REQUEST_ERROR",
|
|
11824
|
-
TRANSACTION_FAILED = "TRANSACTION_FAILED",
|
|
11825
|
-
INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS",
|
|
11826
|
-
UNPREDICTABLE_GAS_LIMIT = "UNPREDICTABLE_GAS_LIMIT",
|
|
11827
|
-
INVALID_GAS_ESTIMATE_TYPE = "INVALID_GAS_ESTIMATE_TYPE",
|
|
11828
|
-
UNSUPPORTED_TOKEN_TYPE_ERROR = "UNSUPPORTED_TOKEN_TYPE_ERROR",
|
|
11829
|
-
UNSUPPORTED_BALANCE_REQUIREMENT_ERROR = "UNSUPPORTED_BALANCE_REQUIREMENT_ERROR",
|
|
11830
|
-
GET_ORDER_LISTING_ERROR = "GET_ORDER_LISTING_ERROR",
|
|
11831
|
-
CANCEL_ORDER_LISTING_ERROR = "CANCEL_ORDER_LISTING_ERROR",
|
|
11832
|
-
PREPARE_ORDER_LISTING_ERROR = "PREPARE_ORDER_LISTING_ERROR",
|
|
11833
|
-
CREATE_ORDER_LISTING_ERROR = "CREATE_ORDER_LISTING_ERROR",
|
|
11834
|
-
FULFILL_ORDER_LISTING_ERROR = "FULFILL_ORDER_LISTING_ERROR",
|
|
11835
|
-
SWITCH_NETWORK_UNSUPPORTED = "SWITCH_NETWORK_UNSUPPORTED",
|
|
11836
|
-
GET_ERC20_ALLOWANCE_ERROR = "GET_ERC20_ALLOWANCE_ERROR",
|
|
11837
|
-
GET_ERC721_ALLOWANCE_ERROR = "GET_ERC721_ALLOWANCE_ERROR",
|
|
11838
|
-
EXECUTE_APPROVAL_TRANSACTION_ERROR = "EXECUTE_APPROVAL_TRANSACTION_ERROR",
|
|
11839
|
-
EXECUTE_FULFILLMENT_TRANSACTION_ERROR = "EXECUTE_FULFILLMENT_TRANSACTION_ERROR",
|
|
11840
|
-
SIGN_MESSAGE_ERROR = "SIGN_MESSAGE_ERROR",
|
|
11841
|
-
BRIDGE_GAS_ESTIMATE_ERROR = "BRIDGE_GAS_ESTIMATE_ERROR",
|
|
11842
|
-
ORDER_FEE_ERROR = "ORDER_FEE_ERROR",
|
|
11843
|
-
ITEM_REQUIREMENTS_ERROR = "ITEM_REQUIREMENTS_ERROR",
|
|
11844
|
-
API_ERROR = "API_ERROR",
|
|
11845
|
-
ORDER_EXPIRED_ERROR = "ORDER_EXPIRED_ERROR"
|
|
11825
|
+
passport?: any;
|
|
11846
11826
|
}
|
|
11847
|
-
|
|
11848
|
-
* Represents an error object with a specific type, optional message, and optional data.
|
|
11849
|
-
* @property {CheckoutErrorType} type - The type of the error.
|
|
11850
|
-
* @property {string | undefined} [message] - The error message.
|
|
11851
|
-
* @property {Object.<string, string> | undefined} [data] - Additional data associated with the error.
|
|
11852
|
-
*/
|
|
11853
|
-
type ErrorType = {
|
|
11854
|
-
type: CheckoutErrorType;
|
|
11855
|
-
message?: string;
|
|
11856
|
-
data?: {
|
|
11857
|
-
[key: string]: string;
|
|
11858
|
-
};
|
|
11859
|
-
};
|
|
11827
|
+
|
|
11860
11828
|
type RemoteConfigParams = {
|
|
11861
11829
|
isDevelopment: boolean;
|
|
11862
11830
|
isProduction: boolean;
|
|
11863
11831
|
};
|
|
11864
11832
|
declare class RemoteConfigFetcher {
|
|
11833
|
+
private isDevelopment;
|
|
11834
|
+
private isProduction;
|
|
11835
|
+
private configCache;
|
|
11836
|
+
private tokensCache;
|
|
11865
11837
|
constructor(params: RemoteConfigParams);
|
|
11838
|
+
private static makeHttpRequest;
|
|
11839
|
+
private getEndpoint;
|
|
11840
|
+
private loadConfig;
|
|
11841
|
+
private loadConfigTokens;
|
|
11866
11842
|
getConfig(key?: keyof RemoteConfiguration): Promise<RemoteConfiguration | RemoteConfiguration[keyof RemoteConfiguration] | undefined>;
|
|
11867
11843
|
getTokensConfig(chainId: ChainId): Promise<ChainTokensConfig>;
|
|
11868
11844
|
}
|
|
11845
|
+
|
|
11869
11846
|
declare class CheckoutConfiguration {
|
|
11870
11847
|
readonly isDevelopment: boolean;
|
|
11871
11848
|
readonly isProduction: boolean;
|
|
@@ -11877,9 +11854,7 @@ declare class CheckoutConfiguration {
|
|
|
11877
11854
|
readonly networkMap: NetworkMap;
|
|
11878
11855
|
constructor(config: CheckoutModuleConfiguration);
|
|
11879
11856
|
}
|
|
11880
|
-
|
|
11881
|
-
checkDexAvailability: () => Promise<boolean>;
|
|
11882
|
-
};
|
|
11857
|
+
|
|
11883
11858
|
interface FiatRampWidgetParams {
|
|
11884
11859
|
exchangeType: ExchangeType;
|
|
11885
11860
|
isPassport: boolean;
|
|
@@ -11897,16 +11872,613 @@ declare class FiatRampService {
|
|
|
11897
11872
|
constructor(config: CheckoutConfiguration);
|
|
11898
11873
|
feeEstimate(): Promise<OnRampProviderFees>;
|
|
11899
11874
|
createWidgetUrl(params: FiatRampWidgetParams): Promise<string>;
|
|
11875
|
+
private getTransakWidgetUrl;
|
|
11876
|
+
}
|
|
11877
|
+
|
|
11878
|
+
type AvailabilityService = {
|
|
11879
|
+
checkDexAvailability: () => Promise<boolean>;
|
|
11880
|
+
};
|
|
11881
|
+
|
|
11882
|
+
/**
|
|
11883
|
+
* Enum representing the themes for the widgets.
|
|
11884
|
+
*/
|
|
11885
|
+
declare enum WidgetTheme {
|
|
11886
|
+
LIGHT = "light",
|
|
11887
|
+
DARK = "dark"
|
|
11888
|
+
}
|
|
11889
|
+
|
|
11890
|
+
/**
|
|
11891
|
+
* Represents the local configuration options for the Checkout Widgets.
|
|
11892
|
+
* @property {WidgetTheme | undefined} theme - The theme of the Checkout Widget (default: "DARK")
|
|
11893
|
+
*/
|
|
11894
|
+
type WidgetConfiguration = {
|
|
11895
|
+
theme?: WidgetTheme;
|
|
11896
|
+
};
|
|
11897
|
+
|
|
11898
|
+
/**
|
|
11899
|
+
* Enum representing the events emitted by the widgets.
|
|
11900
|
+
*/
|
|
11901
|
+
declare enum IMTBLWidgetEvents {
|
|
11902
|
+
IMTBL_WIDGETS_PROVIDER = "imtbl-widgets-provider",
|
|
11903
|
+
IMTBL_CONNECT_WIDGET_EVENT = "imtbl-connect-widget",
|
|
11904
|
+
IMTBL_WALLET_WIDGET_EVENT = "imtbl-wallet-widget",
|
|
11905
|
+
IMTBL_SWAP_WIDGET_EVENT = "imtbl-swap-widget",
|
|
11906
|
+
IMTBL_BRIDGE_WIDGET_EVENT = "imtbl-bridge-widget",
|
|
11907
|
+
IMTBL_ONRAMP_WIDGET_EVENT = "imtbl-onramp-widget",
|
|
11908
|
+
IMTBL_SALE_WIDGET_EVENT = "imtbl-sale-widget"
|
|
11909
|
+
}
|
|
11910
|
+
/**
|
|
11911
|
+
* Enum for events raised for about provider objects
|
|
11912
|
+
*/
|
|
11913
|
+
declare enum ProviderEventType {
|
|
11914
|
+
PROVIDER_UPDATED = "PROVIDER_UPDATED"
|
|
11915
|
+
}
|
|
11916
|
+
/**
|
|
11917
|
+
* Payload type for the PROVIDER_UPDATED event
|
|
11918
|
+
*/
|
|
11919
|
+
type ProviderUpdated = {
|
|
11920
|
+
provider: Web3Provider;
|
|
11921
|
+
};
|
|
11922
|
+
|
|
11923
|
+
/**
|
|
11924
|
+
* Enum representing possible Connect Widget event types.
|
|
11925
|
+
*/
|
|
11926
|
+
declare enum ConnectEventType {
|
|
11927
|
+
CLOSE_WIDGET = "close-widget",
|
|
11928
|
+
SUCCESS = "success",
|
|
11929
|
+
FAILURE = "failure"
|
|
11930
|
+
}
|
|
11931
|
+
/**
|
|
11932
|
+
* Represents a successful connection.
|
|
11933
|
+
* @property {Web3Provider} provider - The connected provider.
|
|
11934
|
+
* @property {WalletProviderName | undefined} walletProviderName - The wallet provider name of the connected provider.
|
|
11935
|
+
*/
|
|
11936
|
+
type ConnectionSuccess = {
|
|
11937
|
+
provider: Web3Provider;
|
|
11938
|
+
walletProviderName: WalletProviderName | undefined;
|
|
11939
|
+
};
|
|
11940
|
+
/**
|
|
11941
|
+
* Represents a connection failure with a reason.
|
|
11942
|
+
* @property {string} reason - The reason for the failed connection.
|
|
11943
|
+
*/
|
|
11944
|
+
type ConnectionFailed = {
|
|
11945
|
+
reason: string;
|
|
11946
|
+
};
|
|
11947
|
+
|
|
11948
|
+
/**
|
|
11949
|
+
* Enum representing possible Wallet Widget event types.
|
|
11950
|
+
*/
|
|
11951
|
+
declare enum WalletEventType {
|
|
11952
|
+
CLOSE_WIDGET = "close-widget",
|
|
11953
|
+
NETWORK_SWITCH = "network-switch",
|
|
11954
|
+
DISCONNECT_WALLET = "disconnect-wallet"
|
|
11955
|
+
}
|
|
11956
|
+
/**
|
|
11957
|
+
* Represents an event that is triggered when the user switches the network in their wallet.
|
|
11958
|
+
* @property {string} network - The name of the network that the user switched to.
|
|
11959
|
+
* @property {number} chainId - The chain ID of the network that the user switched to.
|
|
11960
|
+
* @property {Web3Provider} provider - The Web3 provider object for the switched network.
|
|
11961
|
+
*/
|
|
11962
|
+
type WalletNetworkSwitch = {
|
|
11963
|
+
network: string;
|
|
11964
|
+
chainId: number;
|
|
11965
|
+
provider: Web3Provider;
|
|
11966
|
+
};
|
|
11967
|
+
/**
|
|
11968
|
+
* Represents an event that is triggered when a wallet is disconnected.
|
|
11969
|
+
*/
|
|
11970
|
+
type WalletDisconnect = {};
|
|
11971
|
+
|
|
11972
|
+
/**
|
|
11973
|
+
* Enum representing possible Swap Widget event types.
|
|
11974
|
+
*/
|
|
11975
|
+
declare enum SwapEventType {
|
|
11976
|
+
CLOSE_WIDGET = "close-widget",
|
|
11977
|
+
SUCCESS = "success",
|
|
11978
|
+
FAILURE = "failure",
|
|
11979
|
+
REJECTED = "rejected"
|
|
11980
|
+
}
|
|
11981
|
+
/**
|
|
11982
|
+
* Represents a successful swap transaction.
|
|
11983
|
+
* @property {string} transactionHash - The hash of the successful transaction.
|
|
11984
|
+
*/
|
|
11985
|
+
type SwapSuccess = {
|
|
11986
|
+
transactionHash: string;
|
|
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 SwapFailed = {
|
|
11994
|
+
reason: string;
|
|
11995
|
+
timestamp: number;
|
|
11996
|
+
};
|
|
11997
|
+
/**
|
|
11998
|
+
* Type representing a Swap Widget with type REJECTED.
|
|
11999
|
+
* @property {string} reason - The reason why the swap failed.
|
|
12000
|
+
* @property {number} timestamp - The timestamp of the failed swap.
|
|
12001
|
+
*/
|
|
12002
|
+
type SwapRejected = {
|
|
12003
|
+
reason: string;
|
|
12004
|
+
timestamp: number;
|
|
12005
|
+
};
|
|
12006
|
+
|
|
12007
|
+
/**
|
|
12008
|
+
* Enum representing possible Sale Widget event types.
|
|
12009
|
+
*/
|
|
12010
|
+
declare enum SaleEventType {
|
|
12011
|
+
CLOSE_WIDGET = "close-widget",
|
|
12012
|
+
SUCCESS = "success",
|
|
12013
|
+
FAILURE = "failure",
|
|
12014
|
+
REJECTED = "rejected",
|
|
12015
|
+
TRANSACTION_SUCCESS = "transaction-success"
|
|
12016
|
+
}
|
|
12017
|
+
/**
|
|
12018
|
+
* Represents a successful Sale transaction.
|
|
12019
|
+
* @property {Array} transactions - The executed transactions
|
|
12020
|
+
*/
|
|
12021
|
+
type SaleSuccess = {
|
|
12022
|
+
transactions: {
|
|
12023
|
+
method: string;
|
|
12024
|
+
hash: string | undefined;
|
|
12025
|
+
}[];
|
|
12026
|
+
[key: string]: unknown;
|
|
12027
|
+
};
|
|
12028
|
+
/**
|
|
12029
|
+
* Type representing a Sale Widget with type FAILURE.
|
|
12030
|
+
* @property {string} reason - The reason why the swap failed.
|
|
12031
|
+
* @property {number} timestamp - The timestamp of the failed swap.
|
|
12032
|
+
* @property {Array} transactions - The executed transactions
|
|
12033
|
+
*/
|
|
12034
|
+
type SaleFailed = {
|
|
12035
|
+
reason: string;
|
|
12036
|
+
timestamp: number;
|
|
12037
|
+
transactions: {
|
|
12038
|
+
method: string;
|
|
12039
|
+
hash: string | undefined;
|
|
12040
|
+
}[];
|
|
12041
|
+
};
|
|
12042
|
+
/**
|
|
12043
|
+
* Type representing a Sale Widget with type TRANSACTION_SUCCESS.
|
|
12044
|
+
* @property {Object} transactions - The executed transactions
|
|
12045
|
+
*/
|
|
12046
|
+
type SaleTransactionSuccess = {
|
|
12047
|
+
transactions: {
|
|
12048
|
+
method: string;
|
|
12049
|
+
hash: string | undefined;
|
|
12050
|
+
}[];
|
|
12051
|
+
};
|
|
12052
|
+
|
|
12053
|
+
/**
|
|
12054
|
+
* Enum of possible Bridge Widget event types.
|
|
12055
|
+
*/
|
|
12056
|
+
declare enum BridgeEventType {
|
|
12057
|
+
CLOSE_WIDGET = "close-widget",
|
|
12058
|
+
SUCCESS = "success",
|
|
12059
|
+
FAILURE = "failure"
|
|
12060
|
+
}
|
|
12061
|
+
/**
|
|
12062
|
+
* Represents a successful bridge transaction.
|
|
12063
|
+
* @property {string} transactionHash - The hash of the successful transaction.
|
|
12064
|
+
*/
|
|
12065
|
+
type BridgeSuccess = {
|
|
12066
|
+
transactionHash: string;
|
|
12067
|
+
};
|
|
12068
|
+
/**
|
|
12069
|
+
* Represents a failed bridge transaction.
|
|
12070
|
+
* @property {string} reason - The reason for the failed transaction.
|
|
12071
|
+
* @property {number} timestamp - The timestamp of the failed transaction.
|
|
12072
|
+
*/
|
|
12073
|
+
type BridgeFailed = {
|
|
12074
|
+
reason: string;
|
|
12075
|
+
timestamp: number;
|
|
12076
|
+
};
|
|
12077
|
+
|
|
12078
|
+
/**
|
|
12079
|
+
* Enum representing different types of orchestration events.
|
|
12080
|
+
*/
|
|
12081
|
+
declare enum OrchestrationEventType {
|
|
12082
|
+
REQUEST_CONNECT = "request-connect",
|
|
12083
|
+
REQUEST_WALLET = "request-wallet",
|
|
12084
|
+
REQUEST_SWAP = "request-swap",
|
|
12085
|
+
REQUEST_BRIDGE = "request-bridge",
|
|
12086
|
+
REQUEST_ONRAMP = "request-onramp"
|
|
12087
|
+
}
|
|
12088
|
+
/**
|
|
12089
|
+
* Represents the connect event object when the connect widget is requested.
|
|
12090
|
+
* @property {string} walletProviderName - The wallet provider name.
|
|
12091
|
+
*/
|
|
12092
|
+
type RequestConnectEvent = {
|
|
12093
|
+
walletProviderName: string;
|
|
12094
|
+
};
|
|
12095
|
+
/**
|
|
12096
|
+
* Represents the wallet event object when the wallet widget is requested.
|
|
12097
|
+
* @property {string} walletProviderName - The wallet provider name.
|
|
12098
|
+
*/
|
|
12099
|
+
type RequestWalletEvent = {
|
|
12100
|
+
walletProviderName: string;
|
|
12101
|
+
};
|
|
12102
|
+
/**
|
|
12103
|
+
* Represents the swap event object when the swap widget is requested.
|
|
12104
|
+
* @property {string} fromTokenAddress - The address of the token to swap from.
|
|
12105
|
+
* @property {string} toTokenAddress - The address of the token to swap to.
|
|
12106
|
+
* @property {string} amount - The amount of from tokens to swap.
|
|
12107
|
+
*/
|
|
12108
|
+
type RequestSwapEvent = {
|
|
12109
|
+
fromTokenAddress: string;
|
|
12110
|
+
toTokenAddress: string;
|
|
12111
|
+
amount: string;
|
|
12112
|
+
};
|
|
12113
|
+
/**
|
|
12114
|
+
* Represents the bridge event object when the bridge widget is requested.
|
|
12115
|
+
* @property {string} tokenAddress - The address of the token to bridge.
|
|
12116
|
+
* @property {string} amount - The amount of tokens to bridge.
|
|
12117
|
+
*/
|
|
12118
|
+
type RequestBridgeEvent = {
|
|
12119
|
+
tokenAddress: string;
|
|
12120
|
+
amount: string;
|
|
12121
|
+
};
|
|
12122
|
+
/**
|
|
12123
|
+
* Represents the onramp event object when the onramp widget is requested.
|
|
12124
|
+
* @property {string} tokenAddress - The address of the token to be used for onramp.
|
|
12125
|
+
* @property {string} amount - The amount of tokens to onramp.
|
|
12126
|
+
*/
|
|
12127
|
+
type RequestOnrampEvent = {
|
|
12128
|
+
tokenAddress: string;
|
|
12129
|
+
amount: string;
|
|
12130
|
+
};
|
|
12131
|
+
type OrchestrationEventData = RequestConnectEvent | RequestWalletEvent | RequestSwapEvent | RequestBridgeEvent | RequestOnrampEvent;
|
|
12132
|
+
|
|
12133
|
+
/**
|
|
12134
|
+
* Enum of possible OnRamp Widget event types.
|
|
12135
|
+
*/
|
|
12136
|
+
declare enum OnRampEventType {
|
|
12137
|
+
CLOSE_WIDGET = "close-widget",
|
|
12138
|
+
SUCCESS = "success",
|
|
12139
|
+
FAILURE = "failure"
|
|
12140
|
+
}
|
|
12141
|
+
/**
|
|
12142
|
+
* Represents a successful on-ramp transaction.
|
|
12143
|
+
* @property {string} transactionHash - The transaction hash of the successful transaction.
|
|
12144
|
+
*/
|
|
12145
|
+
type OnRampSuccess = {
|
|
12146
|
+
transactionHash: string;
|
|
12147
|
+
};
|
|
12148
|
+
/**
|
|
12149
|
+
* Type representing a On-ramp Widget with type FAILURE.
|
|
12150
|
+
* @property {string} reason - The reason why the on-ramp failed.
|
|
12151
|
+
* @property {number} timestamp - The timestamp of the failed transaction.
|
|
12152
|
+
*/
|
|
12153
|
+
type OnRampFailed = {
|
|
12154
|
+
reason: string;
|
|
12155
|
+
timestamp: number;
|
|
12156
|
+
};
|
|
12157
|
+
|
|
12158
|
+
declare enum ConnectTargetLayer {
|
|
12159
|
+
LAYER1 = "LAYER1",
|
|
12160
|
+
LAYER2 = "LAYER2"
|
|
12161
|
+
}
|
|
12162
|
+
type ConnectWidgetParams = {};
|
|
12163
|
+
|
|
12164
|
+
/**
|
|
12165
|
+
* Bridge Widget parameters
|
|
12166
|
+
* @property {string | undefined} fromContractAddress - The contract address of the token to bridge from, used to populate the bridge form token field
|
|
12167
|
+
* @property {string | undefined} amount - The formatted amount to bridge, used to populate the bridge form amount field
|
|
12168
|
+
* @property {WalletProviderName | undefined} walletProviderName - The wallet provider name to use for the bridge widget
|
|
12169
|
+
*/
|
|
12170
|
+
type BridgeWidgetParams = {
|
|
12171
|
+
fromContractAddress?: string;
|
|
12172
|
+
amount?: string;
|
|
12173
|
+
walletProviderName?: WalletProviderName;
|
|
12174
|
+
};
|
|
12175
|
+
|
|
12176
|
+
/**
|
|
12177
|
+
* Wallet Widget parameters
|
|
12178
|
+
* @property {WalletProviderName | undefined} walletProviderName - The wallet provider name to use for the wallet widget
|
|
12179
|
+
* @property {Web3Provider | undefined} web3Provider - The ethers Web3Provider
|
|
12180
|
+
*/
|
|
12181
|
+
type WalletWidgetParams = {
|
|
12182
|
+
walletProviderName?: WalletProviderName;
|
|
12183
|
+
};
|
|
12184
|
+
|
|
12185
|
+
/**
|
|
12186
|
+
* Swap Widget parameters
|
|
12187
|
+
* @property {string | undefined} amount - The formatted amount to swap, used to populate the swap from amount field
|
|
12188
|
+
* @property {string | undefined} fromContractAddress - The contract address of the token to swap from
|
|
12189
|
+
* @property {string | undefined} toContractAddress - The contract address of the token to swap to
|
|
12190
|
+
* @property {WalletProviderName | undefined} walletProviderName - The wallet provider name to use for the swap widget
|
|
12191
|
+
*/
|
|
12192
|
+
interface SwapWidgetParams {
|
|
12193
|
+
amount?: string;
|
|
12194
|
+
fromContractAddress?: string;
|
|
12195
|
+
toContractAddress?: string;
|
|
12196
|
+
walletProviderName?: WalletProviderName;
|
|
12197
|
+
}
|
|
12198
|
+
|
|
12199
|
+
/**
|
|
12200
|
+
* OnRamp Widget parameters
|
|
12201
|
+
* @property {string | undefined} contractAddress - The contract address of the token to onramp
|
|
12202
|
+
* @property {string | undefined} amount - The formatted amount to onramp, used to populate the onramp form amount field
|
|
12203
|
+
* @property {WalletProviderName | undefined} walletProviderName - The wallet provider name to use for the onramp widget
|
|
12204
|
+
*/
|
|
12205
|
+
type OnRampWidgetParams = {
|
|
12206
|
+
contractAddress?: string;
|
|
12207
|
+
amount?: string;
|
|
12208
|
+
walletProviderName?: WalletProviderName;
|
|
12209
|
+
};
|
|
12210
|
+
|
|
12211
|
+
/**
|
|
12212
|
+
* Sale Widget parameters
|
|
12213
|
+
* @property {string} amount - The total price to pay for the items in the sale
|
|
12214
|
+
* @property {SaleItem[]} items - The list of products to be purchased
|
|
12215
|
+
* @property {WalletProviderName | undefined} walletProviderName - The wallet provider name to default to if no web3Provider is passed
|
|
12216
|
+
*/
|
|
12217
|
+
type SaleWidgetParams = {
|
|
12218
|
+
amount?: string;
|
|
12219
|
+
environmentId?: string;
|
|
12220
|
+
fromContractAddress?: string;
|
|
12221
|
+
items?: SaleItem[];
|
|
12222
|
+
walletProviderName?: WalletProviderName;
|
|
12223
|
+
};
|
|
12224
|
+
type SaleItem = {
|
|
12225
|
+
productId: string;
|
|
12226
|
+
qty: number;
|
|
12227
|
+
name: string;
|
|
12228
|
+
image: string;
|
|
12229
|
+
description: string;
|
|
12230
|
+
};
|
|
12231
|
+
|
|
12232
|
+
type ConnectWidgetConfiguration = {} & WidgetConfiguration;
|
|
12233
|
+
|
|
12234
|
+
type BridgeWidgetConfiguration = {} & WidgetConfiguration;
|
|
12235
|
+
|
|
12236
|
+
type WalletWidgetConfiguration = {} & WidgetConfiguration;
|
|
12237
|
+
|
|
12238
|
+
type SwapWidgetConfiguration = {} & WidgetConfiguration;
|
|
12239
|
+
|
|
12240
|
+
type OnrampWidgetConfiguration = {} & WidgetConfiguration;
|
|
12241
|
+
|
|
12242
|
+
type SaleWidgetConfiguration = {} & WidgetConfiguration;
|
|
12243
|
+
|
|
12244
|
+
/**
|
|
12245
|
+
* Enum representing the list of widget types.
|
|
12246
|
+
*/
|
|
12247
|
+
declare enum WidgetType {
|
|
12248
|
+
CONNECT = "connect",
|
|
12249
|
+
WALLET = "wallet",
|
|
12250
|
+
SWAP = "swap",
|
|
12251
|
+
BRIDGE = "bridge",
|
|
12252
|
+
ONRAMP = "onramp",
|
|
12253
|
+
SALE = "sale"
|
|
12254
|
+
}
|
|
12255
|
+
/**
|
|
12256
|
+
* Widget properties definition for each widget. Used for creating and updating widgets
|
|
12257
|
+
*/
|
|
12258
|
+
type WidgetProperties<T extends WidgetType> = {
|
|
12259
|
+
config?: WidgetConfigurations[T];
|
|
12260
|
+
provider?: Web3Provider;
|
|
12261
|
+
};
|
|
12262
|
+
type WidgetConfigurations = {
|
|
12263
|
+
[WidgetType.CONNECT]: ConnectWidgetConfiguration;
|
|
12264
|
+
[WidgetType.WALLET]: WalletWidgetConfiguration;
|
|
12265
|
+
[WidgetType.SWAP]: SwapWidgetConfiguration;
|
|
12266
|
+
[WidgetType.BRIDGE]: BridgeWidgetConfiguration;
|
|
12267
|
+
[WidgetType.ONRAMP]: OnrampWidgetConfiguration;
|
|
12268
|
+
[WidgetType.SALE]: SaleWidgetConfiguration;
|
|
12269
|
+
};
|
|
12270
|
+
type WidgetParameters = {
|
|
12271
|
+
[WidgetType.CONNECT]: ConnectWidgetParams;
|
|
12272
|
+
[WidgetType.WALLET]: WalletWidgetParams;
|
|
12273
|
+
[WidgetType.SWAP]: SwapWidgetParams;
|
|
12274
|
+
[WidgetType.BRIDGE]: BridgeWidgetParams;
|
|
12275
|
+
[WidgetType.ONRAMP]: OnRampWidgetParams;
|
|
12276
|
+
[WidgetType.SALE]: SaleWidgetParams;
|
|
12277
|
+
};
|
|
12278
|
+
/**
|
|
12279
|
+
* Represents all the possible event types that are emitted by the widgets.
|
|
12280
|
+
*/
|
|
12281
|
+
type WidgetEventTypes = {
|
|
12282
|
+
[WidgetType.CONNECT]: ConnectEventType | OrchestrationEventType;
|
|
12283
|
+
[WidgetType.WALLET]: WalletEventType | OrchestrationEventType;
|
|
12284
|
+
[WidgetType.SWAP]: SwapEventType | OrchestrationEventType;
|
|
12285
|
+
[WidgetType.BRIDGE]: BridgeEventType | OrchestrationEventType;
|
|
12286
|
+
[WidgetType.ONRAMP]: OnRampEventType | OrchestrationEventType;
|
|
12287
|
+
[WidgetType.SALE]: SaleEventType | OrchestrationEventType;
|
|
12288
|
+
};
|
|
12289
|
+
type OrchestrationMapping = {
|
|
12290
|
+
[OrchestrationEventType.REQUEST_CONNECT]: RequestConnectEvent;
|
|
12291
|
+
[OrchestrationEventType.REQUEST_WALLET]: RequestWalletEvent;
|
|
12292
|
+
[OrchestrationEventType.REQUEST_SWAP]: RequestSwapEvent;
|
|
12293
|
+
[OrchestrationEventType.REQUEST_BRIDGE]: RequestBridgeEvent;
|
|
12294
|
+
[OrchestrationEventType.REQUEST_ONRAMP]: RequestOnrampEvent;
|
|
12295
|
+
};
|
|
12296
|
+
type ProviderEventMapping = {
|
|
12297
|
+
[ProviderEventType.PROVIDER_UPDATED]: ProviderUpdated;
|
|
12298
|
+
};
|
|
12299
|
+
/**
|
|
12300
|
+
* Mapping of widget type, to each of it's events and then each event's payload
|
|
12301
|
+
* Update this whenever a new event is created and used by a widget
|
|
12302
|
+
* Each widget also has all of the orchestration events
|
|
12303
|
+
*/
|
|
12304
|
+
type WidgetEventData = {
|
|
12305
|
+
[WidgetType.CONNECT]: {
|
|
12306
|
+
[ConnectEventType.SUCCESS]: ConnectionSuccess;
|
|
12307
|
+
[ConnectEventType.FAILURE]: ConnectionFailed;
|
|
12308
|
+
[ConnectEventType.CLOSE_WIDGET]: {};
|
|
12309
|
+
} & OrchestrationMapping & ProviderEventMapping;
|
|
12310
|
+
[WidgetType.WALLET]: {
|
|
12311
|
+
[WalletEventType.NETWORK_SWITCH]: WalletNetworkSwitch;
|
|
12312
|
+
[WalletEventType.DISCONNECT_WALLET]: WalletDisconnect;
|
|
12313
|
+
[WalletEventType.CLOSE_WIDGET]: {};
|
|
12314
|
+
} & OrchestrationMapping & ProviderEventMapping;
|
|
12315
|
+
[WidgetType.SWAP]: {
|
|
12316
|
+
[SwapEventType.SUCCESS]: SwapSuccess;
|
|
12317
|
+
[SwapEventType.FAILURE]: SwapFailed;
|
|
12318
|
+
[SwapEventType.REJECTED]: SwapRejected;
|
|
12319
|
+
[SwapEventType.CLOSE_WIDGET]: {};
|
|
12320
|
+
} & OrchestrationMapping & ProviderEventMapping;
|
|
12321
|
+
[WidgetType.BRIDGE]: {
|
|
12322
|
+
[BridgeEventType.SUCCESS]: BridgeSuccess;
|
|
12323
|
+
[BridgeEventType.FAILURE]: BridgeFailed;
|
|
12324
|
+
[BridgeEventType.CLOSE_WIDGET]: {};
|
|
12325
|
+
} & OrchestrationMapping & ProviderEventMapping;
|
|
12326
|
+
[WidgetType.ONRAMP]: {
|
|
12327
|
+
[OnRampEventType.SUCCESS]: OnRampSuccess;
|
|
12328
|
+
[OnRampEventType.FAILURE]: OnRampFailed;
|
|
12329
|
+
[OnRampEventType.CLOSE_WIDGET]: {};
|
|
12330
|
+
} & OrchestrationMapping & ProviderEventMapping;
|
|
12331
|
+
[WidgetType.SALE]: {
|
|
12332
|
+
[SaleEventType.SUCCESS]: SaleSuccess;
|
|
12333
|
+
[SaleEventType.FAILURE]: SaleFailed;
|
|
12334
|
+
[SaleEventType.REJECTED]: any;
|
|
12335
|
+
[SaleEventType.CLOSE_WIDGET]: {};
|
|
12336
|
+
[SaleEventType.TRANSACTION_SUCCESS]: SaleTransactionSuccess;
|
|
12337
|
+
} & OrchestrationMapping & ProviderEventMapping;
|
|
12338
|
+
};
|
|
12339
|
+
/**
|
|
12340
|
+
* Represents an event emitted by a widget. The event type should match the event data
|
|
12341
|
+
*/
|
|
12342
|
+
/**
|
|
12343
|
+
* Represents an event emitted by a widget.
|
|
12344
|
+
* @template T - The widget type
|
|
12345
|
+
* @template KEventName - The widget event name.
|
|
12346
|
+
* @property {KEventName} type - The type of the event.
|
|
12347
|
+
* @property {WidgetEventData[T][KEventName]} data - The data associated with the widget event.
|
|
12348
|
+
*/
|
|
12349
|
+
type WidgetEvent<T extends WidgetType, KEventName extends keyof WidgetEventData[T]> = {
|
|
12350
|
+
type: KEventName;
|
|
12351
|
+
data: WidgetEventData[T][KEventName];
|
|
12352
|
+
};
|
|
12353
|
+
/**
|
|
12354
|
+
* Represents an event emitted by a widget.
|
|
12355
|
+
* @template KEventName - The orchestration event name.
|
|
12356
|
+
* @property {KEventName} type - The type of the event.
|
|
12357
|
+
* @property {OrchestrationMapping[KEventName]} data - The data associated with the event.
|
|
12358
|
+
*/
|
|
12359
|
+
type OrchestrationEvent<KEventName extends keyof OrchestrationMapping> = {
|
|
12360
|
+
type: KEventName;
|
|
12361
|
+
data: OrchestrationMapping[KEventName];
|
|
12362
|
+
};
|
|
12363
|
+
/**
|
|
12364
|
+
* Represents an event emitted by a widget.
|
|
12365
|
+
* @template KEventName - The provider event name.
|
|
12366
|
+
* @property {KEventName} type - The type of the event.
|
|
12367
|
+
* @property {ProviderEventMapping[KEventName]} data - The data associated with the event.
|
|
12368
|
+
*/
|
|
12369
|
+
type ProviderEvent<KEventName extends keyof ProviderEventMapping> = {
|
|
12370
|
+
type: KEventName;
|
|
12371
|
+
data: ProviderEventMapping[KEventName];
|
|
12372
|
+
};
|
|
12373
|
+
interface IWidgetsFactory {
|
|
12374
|
+
/**
|
|
12375
|
+
* Create a new widget instance.
|
|
12376
|
+
* @param type widget type to instantiate.
|
|
12377
|
+
* @param props widget configurations and provider.
|
|
12378
|
+
*/
|
|
12379
|
+
create<T extends WidgetType>(type: T, props?: WidgetProperties<T>): Widget<T>;
|
|
12380
|
+
/**
|
|
12381
|
+
* Update the widgets provider instance.
|
|
12382
|
+
* @param provider provider instantiate.
|
|
12383
|
+
*/
|
|
12384
|
+
updateProvider(provider: Web3Provider): void;
|
|
11900
12385
|
}
|
|
12386
|
+
/**
|
|
12387
|
+
* Widget interface. Every widget implements this interface.
|
|
12388
|
+
*/
|
|
12389
|
+
interface Widget<T extends WidgetType> {
|
|
12390
|
+
/**
|
|
12391
|
+
* Mount a widget to a DOM ref element.
|
|
12392
|
+
* @param id ID of the DOM element where the widget will be mounted.
|
|
12393
|
+
* @param params widget parameters.
|
|
12394
|
+
*/
|
|
12395
|
+
mount(id: string, params?: WidgetParameters[T]): void;
|
|
12396
|
+
/**
|
|
12397
|
+
* Unmount a widget and reset parameters
|
|
12398
|
+
*/
|
|
12399
|
+
unmount(): void;
|
|
12400
|
+
/**
|
|
12401
|
+
* Update the widget properties
|
|
12402
|
+
* @param props Widget specific properties including configuration
|
|
12403
|
+
*/
|
|
12404
|
+
update(props: WidgetProperties<T>): void;
|
|
12405
|
+
/**
|
|
12406
|
+
* Add a listener for a widget event.
|
|
12407
|
+
* @param event Widget specific event name.
|
|
12408
|
+
* @param callback function to execute when the event is received.
|
|
12409
|
+
*/
|
|
12410
|
+
addListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName, callback: (data: WidgetEventData[T][KEventName]) => void): void;
|
|
12411
|
+
/**
|
|
12412
|
+
* Removes an event listener for a widget event.
|
|
12413
|
+
* @param type Widget specific event name.
|
|
12414
|
+
*/
|
|
12415
|
+
removeListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName): void;
|
|
12416
|
+
}
|
|
12417
|
+
/**
|
|
12418
|
+
* Represents the version of the Checkout Widgets to use defaults to (0.1.9-alpha)
|
|
12419
|
+
* @property {number} major - The major version of the widgets, must specify a major version even if it is 0.
|
|
12420
|
+
* @property {number | undefined} minor - The minor version of the widgets, leaving this blank will use the latest minor based on major
|
|
12421
|
+
* @property {number | undefined} patch - The patch version of the widgets, leaving this blank will use the latest minor based on minor
|
|
12422
|
+
* @property {'alpha' | undefined} prerelease - The prerelease version of the widgets, can only be 'alpha'. Do not use in production.
|
|
12423
|
+
* @property {number | undefined} build - The build version of the widgets. Do not use in production.
|
|
12424
|
+
*
|
|
12425
|
+
* @example
|
|
12426
|
+
* { major: 0 } - use default version 0.1.9-alpha
|
|
12427
|
+
* { major: 1 } - use version 1.x.x, pickup all new minor and patch versions released
|
|
12428
|
+
* { major: 1, minor: 1 } - use version 1.1.x, pickup all new patch versions released
|
|
12429
|
+
* { major: 1, minor: 2, patch: 3 } - use version 1.2.3 specifically
|
|
12430
|
+
*/
|
|
12431
|
+
type SemanticVersion = {
|
|
12432
|
+
major: number;
|
|
12433
|
+
minor?: number;
|
|
12434
|
+
patch?: number;
|
|
12435
|
+
prerelease?: 'alpha';
|
|
12436
|
+
build?: number;
|
|
12437
|
+
};
|
|
12438
|
+
/**
|
|
12439
|
+
* Represents the global configuration options for the Checkout Widgets.
|
|
12440
|
+
* @property {WidgetTheme | undefined} theme - The theme of the Checkout Widget (default: "DARK")
|
|
12441
|
+
* @property {Environment | undefined} environment - The environment configuration (default: "SANDBOX")
|
|
12442
|
+
* @property {SemanticVersion | undefined} version - The version of the checkout widgets js file to use (default: "0.1.x")
|
|
12443
|
+
* @property {boolean | undefined} isOnRampEnabled - Enable on-ramp top-up method (default: "true")
|
|
12444
|
+
* @property {boolean | undefined} isSwapEnabled - Enable swap top-up method (default: "true")
|
|
12445
|
+
* @property {boolean | undefined} isBridgeEnabled - Enable bridge top-up method (default: "true")
|
|
12446
|
+
*/
|
|
12447
|
+
type CheckoutWidgetsConfig = {
|
|
12448
|
+
theme?: WidgetTheme;
|
|
12449
|
+
environment?: Environment;
|
|
12450
|
+
version?: SemanticVersion;
|
|
12451
|
+
isOnRampEnabled?: boolean;
|
|
12452
|
+
isSwapEnabled?: boolean;
|
|
12453
|
+
isBridgeEnabled?: boolean;
|
|
12454
|
+
};
|
|
12455
|
+
|
|
12456
|
+
/**
|
|
12457
|
+
* Represents the configuration options for instantiating the Checkout Widgets factory.
|
|
12458
|
+
* @property {WidgetConfiguration} config - global configuration options for the widgets.
|
|
12459
|
+
* @property {SemanticVersion | undefined} version - version of the Checkout widgets bundle (default latest version will be used).
|
|
12460
|
+
*/
|
|
12461
|
+
type WidgetsInit = {
|
|
12462
|
+
config: WidgetConfiguration;
|
|
12463
|
+
version?: SemanticVersion;
|
|
12464
|
+
};
|
|
12465
|
+
|
|
11901
12466
|
declare class Checkout {
|
|
12467
|
+
private readOnlyProviders;
|
|
11902
12468
|
readonly config: CheckoutConfiguration;
|
|
11903
12469
|
readonly fiatRampService: FiatRampService;
|
|
11904
12470
|
readonly availability: AvailabilityService;
|
|
12471
|
+
readonly passport?: Passport;
|
|
11905
12472
|
/**
|
|
11906
12473
|
* Constructs a new instance of the CheckoutModule class.
|
|
11907
12474
|
* @param {CheckoutModuleConfiguration} [config=SANDBOX_CONFIGURATION] - The configuration object for the CheckoutModule.
|
|
11908
12475
|
*/
|
|
11909
12476
|
constructor(config?: CheckoutModuleConfiguration);
|
|
12477
|
+
/**
|
|
12478
|
+
* Loads the widgets bundle and initiate the widgets factory.
|
|
12479
|
+
* @param {WidgetsInit} init - The initialisation parameters for loading the widgets bundle and applying configuration
|
|
12480
|
+
*/
|
|
12481
|
+
widgets(init: WidgetsInit): Promise<ImmutableCheckoutWidgets.WidgetsFactory>;
|
|
11910
12482
|
/**
|
|
11911
12483
|
* Creates a provider using the given parameters.
|
|
11912
12484
|
* @param {CreateProviderParams} params - The parameters for creating the provider.
|
|
@@ -12026,4 +12598,123 @@ declare class Checkout {
|
|
|
12026
12598
|
isSwapAvailable(): Promise<boolean>;
|
|
12027
12599
|
}
|
|
12028
12600
|
|
|
12029
|
-
|
|
12601
|
+
/**
|
|
12602
|
+
* Declares global interfaces and namespaces for the application.
|
|
12603
|
+
* @global
|
|
12604
|
+
* @namespace ImmutableCheckoutWidgets
|
|
12605
|
+
* */
|
|
12606
|
+
declare global {
|
|
12607
|
+
namespace ImmutableCheckoutWidgets {
|
|
12608
|
+
class WidgetsFactory implements IWidgetsFactory {
|
|
12609
|
+
constructor(sdk: Checkout, config: CheckoutWidgetsConfig);
|
|
12610
|
+
create<T extends WidgetType>(type: T, props?: WidgetProperties<T>): Widget<T>;
|
|
12611
|
+
updateProvider(provider: Web3Provider): void;
|
|
12612
|
+
}
|
|
12613
|
+
class Connect<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 Bridge<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
|
+
class Wallet<T extends WidgetType> implements Widget<T> {
|
|
12630
|
+
constructor(sdk: Checkout, props: WidgetProperties<T>);
|
|
12631
|
+
mount(id: string, params?: WidgetParameters[T]): void;
|
|
12632
|
+
unmount(): void;
|
|
12633
|
+
update(props: WidgetProperties<T>): void;
|
|
12634
|
+
addListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName, callback: (data: WidgetEventData[T][KEventName]) => void): void;
|
|
12635
|
+
removeListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName): void;
|
|
12636
|
+
}
|
|
12637
|
+
class Swap<T extends WidgetType> implements Widget<T> {
|
|
12638
|
+
constructor(sdk: Checkout, props: WidgetProperties<T>);
|
|
12639
|
+
mount(id: string, params?: WidgetParameters[T]): void;
|
|
12640
|
+
unmount(): void;
|
|
12641
|
+
update(props: WidgetProperties<T>): void;
|
|
12642
|
+
addListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName, callback: (data: WidgetEventData[T][KEventName]) => void): void;
|
|
12643
|
+
removeListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName): void;
|
|
12644
|
+
}
|
|
12645
|
+
class OnRamp<T extends WidgetType> implements Widget<T> {
|
|
12646
|
+
constructor(sdk: Checkout, props: WidgetProperties<T>);
|
|
12647
|
+
mount(id: string, params?: WidgetParameters[T]): void;
|
|
12648
|
+
unmount(): void;
|
|
12649
|
+
update(props: WidgetProperties<T>): void;
|
|
12650
|
+
addListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName, callback: (data: WidgetEventData[T][KEventName]) => void): void;
|
|
12651
|
+
removeListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName): void;
|
|
12652
|
+
}
|
|
12653
|
+
class Sale<T extends WidgetType> implements Widget<T> {
|
|
12654
|
+
constructor(sdk: Checkout, props: WidgetProperties<T>);
|
|
12655
|
+
mount(id: string, params?: WidgetParameters[T]): void;
|
|
12656
|
+
unmount(): void;
|
|
12657
|
+
update(props: WidgetProperties<T>): void;
|
|
12658
|
+
addListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName, callback: (data: WidgetEventData[T][KEventName]) => void): void;
|
|
12659
|
+
removeListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName): void;
|
|
12660
|
+
}
|
|
12661
|
+
}
|
|
12662
|
+
}
|
|
12663
|
+
|
|
12664
|
+
/**
|
|
12665
|
+
* Enum representing different types of errors that can occur during the checkout process.
|
|
12666
|
+
*/
|
|
12667
|
+
declare enum CheckoutErrorType {
|
|
12668
|
+
WEB3_PROVIDER_ERROR = "WEB3_PROVIDER_ERROR",
|
|
12669
|
+
PROVIDER_ERROR = "PROVIDER_ERROR",
|
|
12670
|
+
DEFAULT_PROVIDER_ERROR = "DEFAULT_PROVIDER_ERROR",
|
|
12671
|
+
CONNECT_PROVIDER_ERROR = "CONNECT_PROVIDER_ERROR",
|
|
12672
|
+
GET_BALANCE_ERROR = "GET_BALANCE_ERROR",
|
|
12673
|
+
GET_INDEXER_BALANCE_ERROR = "GET_INDEXER_BALANCE_ERROR",
|
|
12674
|
+
GET_ERC20_BALANCE_ERROR = "GET_ERC20_BALANCE_ERROR",
|
|
12675
|
+
GET_ERC721_BALANCE_ERROR = "GET_ERC721_BALANCE_ERROR",
|
|
12676
|
+
GET_NETWORK_INFO_ERROR = "GET_NETWORK_INFO_ERROR",
|
|
12677
|
+
METAMASK_PROVIDER_ERROR = "METAMASK_PROVIDER_ERROR",
|
|
12678
|
+
CHAIN_NOT_SUPPORTED_ERROR = "CHAIN_NOT_SUPPORTED_ERROR",
|
|
12679
|
+
PROVIDER_REQUEST_MISSING_ERROR = "PROVIDER_REQUEST_MISSING_ERROR",
|
|
12680
|
+
PROVIDER_REQUEST_FAILED_ERROR = "PROVIDER_REQUEST_FAILED_ERROR",
|
|
12681
|
+
USER_REJECTED_REQUEST_ERROR = "USER_REJECTED_REQUEST_ERROR",
|
|
12682
|
+
TRANSACTION_FAILED = "TRANSACTION_FAILED",
|
|
12683
|
+
INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS",
|
|
12684
|
+
UNPREDICTABLE_GAS_LIMIT = "UNPREDICTABLE_GAS_LIMIT",
|
|
12685
|
+
INVALID_GAS_ESTIMATE_TYPE = "INVALID_GAS_ESTIMATE_TYPE",
|
|
12686
|
+
UNSUPPORTED_TOKEN_TYPE_ERROR = "UNSUPPORTED_TOKEN_TYPE_ERROR",
|
|
12687
|
+
UNSUPPORTED_BALANCE_REQUIREMENT_ERROR = "UNSUPPORTED_BALANCE_REQUIREMENT_ERROR",
|
|
12688
|
+
GET_ORDER_LISTING_ERROR = "GET_ORDER_LISTING_ERROR",
|
|
12689
|
+
CANCEL_ORDER_LISTING_ERROR = "CANCEL_ORDER_LISTING_ERROR",
|
|
12690
|
+
PREPARE_ORDER_LISTING_ERROR = "PREPARE_ORDER_LISTING_ERROR",
|
|
12691
|
+
CREATE_ORDER_LISTING_ERROR = "CREATE_ORDER_LISTING_ERROR",
|
|
12692
|
+
FULFILL_ORDER_LISTING_ERROR = "FULFILL_ORDER_LISTING_ERROR",
|
|
12693
|
+
SWITCH_NETWORK_UNSUPPORTED = "SWITCH_NETWORK_UNSUPPORTED",
|
|
12694
|
+
GET_ERC20_ALLOWANCE_ERROR = "GET_ERC20_ALLOWANCE_ERROR",
|
|
12695
|
+
GET_ERC721_ALLOWANCE_ERROR = "GET_ERC721_ALLOWANCE_ERROR",
|
|
12696
|
+
EXECUTE_APPROVAL_TRANSACTION_ERROR = "EXECUTE_APPROVAL_TRANSACTION_ERROR",
|
|
12697
|
+
EXECUTE_FULFILLMENT_TRANSACTION_ERROR = "EXECUTE_FULFILLMENT_TRANSACTION_ERROR",
|
|
12698
|
+
SIGN_MESSAGE_ERROR = "SIGN_MESSAGE_ERROR",
|
|
12699
|
+
BRIDGE_GAS_ESTIMATE_ERROR = "BRIDGE_GAS_ESTIMATE_ERROR",
|
|
12700
|
+
ORDER_FEE_ERROR = "ORDER_FEE_ERROR",
|
|
12701
|
+
ITEM_REQUIREMENTS_ERROR = "ITEM_REQUIREMENTS_ERROR",
|
|
12702
|
+
API_ERROR = "API_ERROR",
|
|
12703
|
+
ORDER_EXPIRED_ERROR = "ORDER_EXPIRED_ERROR",
|
|
12704
|
+
WIDGETS_SCRIPT_LOAD_ERROR = "WIDGETS_SCRIPT_LOAD_ERROR"
|
|
12705
|
+
}
|
|
12706
|
+
/**
|
|
12707
|
+
* Represents an error object with a specific type, optional message, and optional data.
|
|
12708
|
+
* @property {CheckoutErrorType} type - The type of the error.
|
|
12709
|
+
* @property {string | undefined} [message] - The error message.
|
|
12710
|
+
* @property {Object.<string, string> | undefined} [data] - Additional data associated with the error.
|
|
12711
|
+
*/
|
|
12712
|
+
type ErrorType = {
|
|
12713
|
+
type: CheckoutErrorType;
|
|
12714
|
+
message?: string;
|
|
12715
|
+
data?: {
|
|
12716
|
+
[key: string]: string;
|
|
12717
|
+
};
|
|
12718
|
+
};
|
|
12719
|
+
|
|
12720
|
+
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, Fee, 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, SaleTransactionSuccess, 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, WalletDisconnect, WalletEventType, WalletFilter, WalletFilterTypes, WalletInfo, WalletNetworkSwitch, WalletProviderName, WalletWidgetConfiguration, WalletWidgetParams, Widget, WidgetConfiguration, WidgetConfigurations, WidgetEvent, WidgetEventData, WidgetEventTypes, WidgetParameters, WidgetProperties, WidgetTheme, WidgetType };
|