@imtbl/sdk 0.29.0 → 0.30.0
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 +154 -15
- package/dist/browser/checkout/sdk.js +35 -0
- package/dist/browser/checkout/widgets.js +890 -0
- package/dist/checkout_sdk.d.ts +1308 -380
- package/dist/checkout_sdk.js +3040 -2408
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +11 -20
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +3152 -2910
- package/dist/index.d.ts +1540 -15560
- package/dist/index.js +3153 -2910
- package/dist/passport.js +203 -17
- package/package.json +14 -6
- package/dist/browser/checkout.js +0 -2
- package/dist/checkout_widgets.d.ts +0 -25614
- 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,104 +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 publishableKey?: string;
|
|
558
|
-
constructor(options: {
|
|
559
|
-
environment: Environment;
|
|
560
|
-
});
|
|
561
|
-
}
|
|
562
|
-
type ImmutableConfigurationWithRequireableFields<T> = ImmutableConfiguration & (T extends {
|
|
563
|
-
apiKey: 'required';
|
|
564
|
-
} ? Required<{
|
|
565
|
-
apiKey: string;
|
|
566
|
-
}> : {}) & (T extends {
|
|
567
|
-
publishableKey: 'required';
|
|
568
|
-
} ? Required<{
|
|
569
|
-
publishableKey: string;
|
|
570
|
-
}> : {});
|
|
571
|
-
type ImmutableConfigurationWithOmitableFields<T> = (T extends {
|
|
572
|
-
apiKey: 'omit';
|
|
573
|
-
} ? Omit<ImmutableConfigurationWithRequireableFields<T>, 'apiKey'> : ImmutableConfigurationWithRequireableFields<T>);
|
|
574
|
-
interface ModuleConfiguration<T> {
|
|
575
|
-
baseConfig: ImmutableConfigurationWithOmitableFields<T>;
|
|
576
|
-
overrides?: T;
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
type ExchangeContracts = {
|
|
580
|
-
multicall: string;
|
|
581
|
-
coreFactory: string;
|
|
582
|
-
quoterV2: string;
|
|
583
|
-
peripheryRouter: string;
|
|
584
|
-
secondaryFee: string;
|
|
585
|
-
};
|
|
586
|
-
/**
|
|
587
|
-
* Type representing an ERC20 token
|
|
588
|
-
* @property {string} type - The token type, used to discriminate between {@link ERC20} and {@link Native}
|
|
589
|
-
* @property {number} chainId - The chain ID
|
|
590
|
-
* @property {string} address - The token address
|
|
591
|
-
* @property {number} decimals - The token decimals
|
|
592
|
-
* @property {string | undefined} symbol - The token symbol or undefined if it is not available
|
|
593
|
-
* @property {string | undefined} name - The token name or undefined if it is not available
|
|
594
|
-
*/
|
|
595
|
-
type ERC20 = {
|
|
596
|
-
type: 'erc20';
|
|
597
|
-
chainId: number;
|
|
598
|
-
address: string;
|
|
599
|
-
decimals: number;
|
|
600
|
-
symbol?: string;
|
|
601
|
-
name?: string;
|
|
602
|
-
};
|
|
603
|
-
/**
|
|
604
|
-
* Type representing a native token
|
|
605
|
-
* @property {string} type - The token type, used to discriminate between {@link ERC20} and {@link Native}
|
|
606
|
-
* @property {number} chainId - The chain ID
|
|
607
|
-
* @property {number} decimals - The token decimals
|
|
608
|
-
* @property {string | undefined} symbol - The token symbol or undefined if it is not available
|
|
609
|
-
* @property {string | undefined} name - The token name or undefined if it is not available
|
|
610
|
-
*/
|
|
611
|
-
type Native = {
|
|
612
|
-
type: 'native';
|
|
613
|
-
chainId: number;
|
|
614
|
-
decimals: number;
|
|
615
|
-
symbol?: string;
|
|
616
|
-
name?: string;
|
|
617
|
-
};
|
|
618
|
-
/**
|
|
619
|
-
* Type representing a token, either an {@link ERC20} or {@link Native}
|
|
620
|
-
*/
|
|
621
|
-
type Coin = ERC20 | Native;
|
|
622
|
-
/**
|
|
623
|
-
* Type representing the overrides for the {@link Exchange} module
|
|
624
|
-
* @property {string} rpcURL - The RPC URL for the chain
|
|
625
|
-
* @property {ExchangeContracts} exchangeContracts - The DEX contract addresses
|
|
626
|
-
* @property {ERC20[]} commonRoutingTokens - The tokens used to find available pools for a swap
|
|
627
|
-
* @property {Coin} nativeToken - The native token of the chain
|
|
628
|
-
* @property {ERC20} wrappedNativeToken - The wrapped native token of the chain
|
|
629
|
-
*/
|
|
630
|
-
type ExchangeOverrides = {
|
|
631
|
-
rpcURL: string;
|
|
632
|
-
exchangeContracts: ExchangeContracts;
|
|
633
|
-
commonRoutingTokens: ERC20[];
|
|
634
|
-
nativeToken: Coin;
|
|
635
|
-
wrappedNativeToken: ERC20;
|
|
636
|
-
};
|
|
637
|
-
|
|
638
|
-
/**
|
|
639
|
-
* @typedef {string} Address - Represents an Ethereum address.
|
|
640
|
-
*/
|
|
641
|
-
type Address = string;
|
|
642
|
-
/**
|
|
643
|
-
* @typedef {Address | 'NATIVE'} FungibleToken - Represents a fungible token, either an ERC20 token address or the native token.
|
|
644
|
-
*/
|
|
645
|
-
type FungibleToken = Address | 'NATIVE';
|
|
646
|
-
|
|
647
549
|
// TypeScript Version: 3.0
|
|
648
550
|
|
|
649
551
|
type AxiosRequestHeaders = Record<string, string | number | boolean>;
|
|
@@ -10193,6 +10095,36 @@ interface IMXProvider {
|
|
|
10193
10095
|
completeWithdrawal(starkPublicKey: string, token: AnyToken): Promise<TransactionResponse>;
|
|
10194
10096
|
}
|
|
10195
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 publishableKey?: string;
|
|
10107
|
+
constructor(options: {
|
|
10108
|
+
environment: Environment;
|
|
10109
|
+
});
|
|
10110
|
+
}
|
|
10111
|
+
type ImmutableConfigurationWithRequireableFields<T> = ImmutableConfiguration & (T extends {
|
|
10112
|
+
apiKey: 'required';
|
|
10113
|
+
} ? Required<{
|
|
10114
|
+
apiKey: string;
|
|
10115
|
+
}> : {}) & (T extends {
|
|
10116
|
+
publishableKey: 'required';
|
|
10117
|
+
} ? Required<{
|
|
10118
|
+
publishableKey: string;
|
|
10119
|
+
}> : {});
|
|
10120
|
+
type ImmutableConfigurationWithOmitableFields<T> = (T extends {
|
|
10121
|
+
apiKey: 'omit';
|
|
10122
|
+
} ? Omit<ImmutableConfigurationWithRequireableFields<T>, 'apiKey'> : ImmutableConfigurationWithRequireableFields<T>);
|
|
10123
|
+
interface ModuleConfiguration<T> {
|
|
10124
|
+
baseConfig: ImmutableConfigurationWithOmitableFields<T>;
|
|
10125
|
+
overrides?: T;
|
|
10126
|
+
}
|
|
10127
|
+
|
|
10196
10128
|
interface ImxOverrides {
|
|
10197
10129
|
immutableXConfig: ImmutableXConfiguration;
|
|
10198
10130
|
}
|
|
@@ -10733,6 +10665,7 @@ declare enum ChainName {
|
|
|
10733
10665
|
IMTBL_ZKEVM_DEVNET = "Immutable zkEVM Dev",
|
|
10734
10666
|
IMTBL_ZKEVM_MAINNET = "Immutable zkEVM"
|
|
10735
10667
|
}
|
|
10668
|
+
|
|
10736
10669
|
/**
|
|
10737
10670
|
* Represents information about a token.
|
|
10738
10671
|
* @interface TokenInfo
|
|
@@ -10749,6 +10682,7 @@ interface TokenInfo {
|
|
|
10749
10682
|
address?: string;
|
|
10750
10683
|
icon?: string;
|
|
10751
10684
|
}
|
|
10685
|
+
|
|
10752
10686
|
/**
|
|
10753
10687
|
* Interface representing the parameters for {@link Checkout.getBalance}.
|
|
10754
10688
|
* @property {Web3Provider} provider - The provider used to get the balance.
|
|
@@ -10789,6 +10723,7 @@ interface GetAllBalancesParams {
|
|
|
10789
10723
|
interface GetAllBalancesResult {
|
|
10790
10724
|
balances: GetBalanceResult[];
|
|
10791
10725
|
}
|
|
10726
|
+
|
|
10792
10727
|
interface OrderFee {
|
|
10793
10728
|
amount: FeeToken | FeePercentage;
|
|
10794
10729
|
recipient: string;
|
|
@@ -10799,88 +10734,111 @@ interface FeeToken {
|
|
|
10799
10734
|
interface FeePercentage {
|
|
10800
10735
|
percentageDecimal: number;
|
|
10801
10736
|
}
|
|
10737
|
+
|
|
10802
10738
|
type BuyResult = BuyResultSuccess | BuyResultFailed | BuyResultInsufficientFunds;
|
|
10803
10739
|
/**
|
|
10804
10740
|
* Represents the result of {@link Checkout.buy}
|
|
10805
|
-
* @property {CheckoutStatus.SUCCESS} status
|
|
10806
|
-
* @property {SmartCheckoutSufficient} smartCheckoutResult
|
|
10741
|
+
* @property {CheckoutStatus.SUCCESS} status
|
|
10742
|
+
* @property {SmartCheckoutSufficient} smartCheckoutResult
|
|
10807
10743
|
*/
|
|
10808
10744
|
type BuyResultSuccess = {
|
|
10745
|
+
/** The status to indicate success */
|
|
10809
10746
|
status: CheckoutStatus.SUCCESS;
|
|
10747
|
+
/** The sufficient result of smart checkout */
|
|
10810
10748
|
smartCheckoutResult: SmartCheckoutSufficient;
|
|
10811
10749
|
};
|
|
10812
10750
|
/**
|
|
10813
10751
|
* Represents the result of {@link Checkout.buy}
|
|
10814
|
-
* @property {CheckoutStatus.FAILED} status
|
|
10815
|
-
* @property {string} transactionHash
|
|
10816
|
-
* @property {string} reason
|
|
10817
|
-
* @property {SmartCheckoutSufficient} smartCheckoutResult
|
|
10752
|
+
* @property {CheckoutStatus.FAILED} status
|
|
10753
|
+
* @property {string} transactionHash
|
|
10754
|
+
* @property {string} reason
|
|
10755
|
+
* @property {SmartCheckoutSufficient} smartCheckoutResult
|
|
10818
10756
|
*/
|
|
10819
10757
|
type BuyResultFailed = {
|
|
10758
|
+
/** The status to indicate failure */
|
|
10820
10759
|
status: CheckoutStatus.FAILED;
|
|
10760
|
+
/** The transaction hash of the failed transaction */
|
|
10821
10761
|
transactionHash: string;
|
|
10762
|
+
/** The reason for the failure */
|
|
10822
10763
|
reason: string;
|
|
10764
|
+
/** The sufficient result of smart checkout */
|
|
10823
10765
|
smartCheckoutResult: SmartCheckoutSufficient;
|
|
10824
10766
|
};
|
|
10825
10767
|
/**
|
|
10826
10768
|
* Represents the result of {@link Checkout.buy}
|
|
10827
|
-
* @property {CheckoutStatus.INSUFFICIENT_FUNDS} status
|
|
10828
|
-
* @property {SmartCheckoutInsufficient} smartCheckoutResult
|
|
10769
|
+
* @property {CheckoutStatus.INSUFFICIENT_FUNDS} status
|
|
10770
|
+
* @property {SmartCheckoutInsufficient} smartCheckoutResult
|
|
10829
10771
|
*/
|
|
10830
10772
|
type BuyResultInsufficientFunds = {
|
|
10773
|
+
/** The status to indicate insufficient funds */
|
|
10831
10774
|
status: CheckoutStatus.INSUFFICIENT_FUNDS;
|
|
10775
|
+
/** The insufficient result of smart checkout */
|
|
10832
10776
|
smartCheckoutResult: SmartCheckoutInsufficient;
|
|
10833
10777
|
};
|
|
10834
10778
|
type SellResult = SellResultSuccess | SellResultFailed | SellResultInsufficientFunds;
|
|
10835
10779
|
/**
|
|
10836
10780
|
* Represents the result of {@link Checkout.sell}
|
|
10837
|
-
* @property {CheckoutStatus.SUCCESS} status
|
|
10838
|
-
* @property {
|
|
10781
|
+
* @property {CheckoutStatus.SUCCESS} status
|
|
10782
|
+
* @property {string[]} orderIds
|
|
10783
|
+
* @property {SmartCheckoutSufficient} smartCheckoutResult
|
|
10839
10784
|
*/
|
|
10840
10785
|
type SellResultSuccess = {
|
|
10786
|
+
/** The status to indicate success */
|
|
10841
10787
|
status: CheckoutStatus.SUCCESS;
|
|
10788
|
+
/** The orders' ids */
|
|
10842
10789
|
orderIds: string[];
|
|
10790
|
+
/** The sufficient result of smart checkout */
|
|
10843
10791
|
smartCheckoutResult: SmartCheckoutSufficient;
|
|
10844
10792
|
};
|
|
10845
10793
|
/**
|
|
10846
10794
|
* Represents the result of {@link Checkout.sell}
|
|
10847
|
-
* @property {CheckoutStatus.FAILED} status
|
|
10848
|
-
* @property {string} transactionHash
|
|
10849
|
-
* @property {string} reason
|
|
10850
|
-
* @property {SmartCheckoutSufficient} smartCheckoutResult
|
|
10795
|
+
* @property {CheckoutStatus.FAILED} status
|
|
10796
|
+
* @property {string} transactionHash
|
|
10797
|
+
* @property {string} reason
|
|
10798
|
+
* @property {SmartCheckoutSufficient} smartCheckoutResult
|
|
10851
10799
|
*/
|
|
10852
10800
|
type SellResultFailed = {
|
|
10801
|
+
/** The status to indicate failure */
|
|
10853
10802
|
status: CheckoutStatus.FAILED;
|
|
10803
|
+
/** The transaction hash of the failed transaction */
|
|
10854
10804
|
transactionHash: string;
|
|
10805
|
+
/** The reason for the failure */
|
|
10855
10806
|
reason: string;
|
|
10807
|
+
/** The sufficient result of smart checkout */
|
|
10856
10808
|
smartCheckoutResult: SmartCheckoutSufficient;
|
|
10857
10809
|
};
|
|
10858
10810
|
/**
|
|
10859
10811
|
* Represents the result of {@link Checkout.sell}
|
|
10860
|
-
* @property {CheckoutStatus.INSUFFICIENT_FUNDS} status
|
|
10861
|
-
* @property {SmartCheckoutInsufficient} smartCheckoutResult
|
|
10812
|
+
* @property {CheckoutStatus.INSUFFICIENT_FUNDS} status
|
|
10813
|
+
* @property {SmartCheckoutInsufficient} smartCheckoutResult
|
|
10862
10814
|
*/
|
|
10863
10815
|
type SellResultInsufficientFunds = {
|
|
10816
|
+
/** The status to indicate insufficient funds */
|
|
10864
10817
|
status: CheckoutStatus.INSUFFICIENT_FUNDS;
|
|
10818
|
+
/** The insufficient result of smart checkout */
|
|
10865
10819
|
smartCheckoutResult: SmartCheckoutInsufficient;
|
|
10866
10820
|
};
|
|
10867
10821
|
type CancelResult = CancelResultSuccess | CancelResultFailed;
|
|
10868
10822
|
/**
|
|
10869
10823
|
* Represents the result of {@link Checkout.cancel}
|
|
10870
|
-
* @property {CheckoutStatus.SUCCESS} status
|
|
10824
|
+
* @property {CheckoutStatus.SUCCESS} status
|
|
10871
10825
|
*/
|
|
10872
10826
|
type CancelResultSuccess = {
|
|
10827
|
+
/** The status to indicate success */
|
|
10873
10828
|
status: CheckoutStatus.SUCCESS;
|
|
10874
10829
|
};
|
|
10875
10830
|
/**
|
|
10876
10831
|
* Represents the result of {@link Checkout.cancel}
|
|
10877
|
-
* @property {CheckoutStatus.FAILED} status
|
|
10878
|
-
* @property {string} transactionHash
|
|
10879
|
-
* @property {string} reason
|
|
10832
|
+
* @property {CheckoutStatus.FAILED} status
|
|
10833
|
+
* @property {string} transactionHash
|
|
10834
|
+
* @property {string} reason
|
|
10880
10835
|
*/
|
|
10881
10836
|
type CancelResultFailed = {
|
|
10837
|
+
/** The status to indicate failure */
|
|
10882
10838
|
status: CheckoutStatus.FAILED;
|
|
10839
|
+
/** The transaction hash of the failed transaction */
|
|
10883
10840
|
transactionHash: string;
|
|
10841
|
+
/** The reason for the failure */
|
|
10884
10842
|
reason: string;
|
|
10885
10843
|
};
|
|
10886
10844
|
/**
|
|
@@ -10897,22 +10855,27 @@ declare enum CheckoutStatus {
|
|
|
10897
10855
|
}
|
|
10898
10856
|
/**
|
|
10899
10857
|
* The type representing the order to buy
|
|
10900
|
-
* @property {string} orderId
|
|
10901
|
-
* @property {Array<OrderFee>} takerFees
|
|
10858
|
+
* @property {string} orderId
|
|
10859
|
+
* @property {Array<OrderFee>} takerFees
|
|
10902
10860
|
*/
|
|
10903
10861
|
type BuyOrder = {
|
|
10862
|
+
/** the id of the order to buy */
|
|
10904
10863
|
id: string;
|
|
10864
|
+
/** array of order fees to apply to the order */
|
|
10905
10865
|
takerFees?: OrderFee[];
|
|
10906
10866
|
};
|
|
10907
10867
|
/**
|
|
10908
10868
|
* The type representing the sell order to create a listing from
|
|
10909
|
-
* @property {SellToken} sellToken
|
|
10910
|
-
* @property {BuyToken} buyToken
|
|
10911
|
-
* @property {OrderFee[]} makerFees
|
|
10869
|
+
* @property {SellToken} sellToken
|
|
10870
|
+
* @property {BuyToken} buyToken
|
|
10871
|
+
* @property {OrderFee[]} makerFees
|
|
10912
10872
|
*/
|
|
10913
10873
|
type SellOrder = {
|
|
10874
|
+
/** the token to be listed for sale */
|
|
10914
10875
|
sellToken: SellToken;
|
|
10876
|
+
/** the token info of the price of the item */
|
|
10915
10877
|
buyToken: BuyToken;
|
|
10878
|
+
/** option array of makerFees to be applied to the listing */
|
|
10916
10879
|
makerFees?: OrderFee[];
|
|
10917
10880
|
};
|
|
10918
10881
|
/**
|
|
@@ -10922,77 +10885,97 @@ type SellOrder = {
|
|
|
10922
10885
|
type BuyToken = NativeBuyToken | ERC20BuyToken;
|
|
10923
10886
|
/**
|
|
10924
10887
|
* Represents a native buy token
|
|
10925
|
-
* @property {ItemType} type
|
|
10926
|
-
* @property {string} amount
|
|
10888
|
+
* @property {ItemType} type
|
|
10889
|
+
* @property {string} amount
|
|
10927
10890
|
*/
|
|
10928
10891
|
type NativeBuyToken = {
|
|
10892
|
+
/** The type indicate this is a native token. */
|
|
10929
10893
|
type: ItemType.NATIVE;
|
|
10894
|
+
/** The amount of native token. */
|
|
10930
10895
|
amount: string;
|
|
10931
10896
|
};
|
|
10932
10897
|
/**
|
|
10933
10898
|
* Represents a ERC20 buy token
|
|
10934
|
-
* @property {ItemType} type
|
|
10935
|
-
* @property {string} amount
|
|
10936
|
-
* @property {string} contractAddress
|
|
10899
|
+
* @property {ItemType} type
|
|
10900
|
+
* @property {string} amount
|
|
10901
|
+
* @property {string} contractAddress
|
|
10937
10902
|
*/
|
|
10938
10903
|
type ERC20BuyToken = {
|
|
10904
|
+
/** The type indicate this is a ERC20 token. */
|
|
10939
10905
|
type: ItemType.ERC20;
|
|
10906
|
+
/** The amount of native token. */
|
|
10940
10907
|
amount: string;
|
|
10908
|
+
/** The contract address of the ERC20. */
|
|
10941
10909
|
contractAddress: string;
|
|
10942
10910
|
};
|
|
10943
10911
|
/**
|
|
10944
10912
|
* The SellToken type
|
|
10945
|
-
* @property {string} id
|
|
10946
|
-
* @property {string} collectionAddress
|
|
10913
|
+
* @property {string} id
|
|
10914
|
+
* @property {string} collectionAddress
|
|
10947
10915
|
*/
|
|
10948
10916
|
type SellToken = {
|
|
10917
|
+
/** The ERC721 token id */
|
|
10949
10918
|
id: string;
|
|
10919
|
+
/** The ERC721 collection address */
|
|
10950
10920
|
collectionAddress: string;
|
|
10951
10921
|
};
|
|
10952
10922
|
/**
|
|
10953
10923
|
* Interface representing the parameters for {@link Checkout.smartCheckout}
|
|
10954
|
-
* @property {Web3Provider} provider
|
|
10955
|
-
* @property {ItemRequirement[]} itemRequirements
|
|
10956
|
-
* @property {FulfillmentTransaction | GasAmount} transactionOrGasAmount
|
|
10924
|
+
* @property {Web3Provider} provider
|
|
10925
|
+
* @property {ItemRequirement[]} itemRequirements
|
|
10926
|
+
* @property {FulfillmentTransaction | GasAmount} transactionOrGasAmount
|
|
10957
10927
|
*/
|
|
10958
10928
|
interface SmartCheckoutParams {
|
|
10929
|
+
/** The provider to use for smart checkout. */
|
|
10959
10930
|
provider: Web3Provider;
|
|
10931
|
+
/** The item requirements for the transaction. */
|
|
10960
10932
|
itemRequirements: (NativeItemRequirement | ERC20ItemRequirement | ERC721ItemRequirement)[];
|
|
10933
|
+
/** The transaction or gas amount. */
|
|
10961
10934
|
transactionOrGasAmount: FulfillmentTransaction | GasAmount;
|
|
10962
10935
|
}
|
|
10963
10936
|
/**
|
|
10964
10937
|
* Represents a native item requirement for a transaction.
|
|
10965
|
-
* @property {ItemType.NATIVE} type
|
|
10966
|
-
* @property {string} amount
|
|
10938
|
+
* @property {ItemType.NATIVE} type
|
|
10939
|
+
* @property {string} amount
|
|
10967
10940
|
*/
|
|
10968
10941
|
type NativeItemRequirement = {
|
|
10942
|
+
/** The type to indicate this is a native item requirement. */
|
|
10969
10943
|
type: ItemType.NATIVE;
|
|
10944
|
+
/** The amount of the item. */
|
|
10970
10945
|
amount: string;
|
|
10971
10946
|
};
|
|
10972
10947
|
/**
|
|
10973
10948
|
* Represents an ERC20 item requirement for a transaction.
|
|
10974
|
-
* @property {ItemType.ERC20} type
|
|
10975
|
-
* @property {string} amount
|
|
10976
|
-
* @property {string} contractAddress
|
|
10977
|
-
* @property {string} spenderAddress
|
|
10949
|
+
* @property {ItemType.ERC20} type
|
|
10950
|
+
* @property {string} amount
|
|
10951
|
+
* @property {string} contractAddress
|
|
10952
|
+
* @property {string} spenderAddress
|
|
10978
10953
|
*/
|
|
10979
10954
|
type ERC20ItemRequirement = {
|
|
10955
|
+
/** The type to indicate this is a ERC20 item requirement. */
|
|
10980
10956
|
type: ItemType.ERC20;
|
|
10957
|
+
/** The amount of the item. */
|
|
10981
10958
|
contractAddress: string;
|
|
10959
|
+
/** The contract address of the ERC20. */
|
|
10982
10960
|
amount: string;
|
|
10961
|
+
/** The contract address of the approver. */
|
|
10983
10962
|
spenderAddress: string;
|
|
10984
10963
|
};
|
|
10985
10964
|
/**
|
|
10986
10965
|
* Represents an ERC721 item requirement for a transaction.
|
|
10987
|
-
* @property {ItemType.ERC721} type
|
|
10988
|
-
* @property {string} contractAddress
|
|
10989
|
-
* @property {string} id
|
|
10990
|
-
* @property {string} spenderAddress
|
|
10966
|
+
* @property {ItemType.ERC721} type
|
|
10967
|
+
* @property {string} contractAddress
|
|
10968
|
+
* @property {string} id
|
|
10969
|
+
* @property {string} spenderAddress
|
|
10991
10970
|
*/
|
|
10992
10971
|
type ERC721ItemRequirement = {
|
|
10972
|
+
/** The type to indicate this is a ERC721 item requirement. */
|
|
10993
10973
|
type: ItemType.ERC721;
|
|
10974
|
+
/** The contract address of the ERC721 collection. */
|
|
10994
10975
|
contractAddress: string;
|
|
10976
|
+
/** The ID of this ERC721 in the collection. */
|
|
10995
10977
|
id: string;
|
|
10978
|
+
/** The contract address of the approver. */
|
|
10996
10979
|
spenderAddress: string;
|
|
10997
10980
|
};
|
|
10998
10981
|
/**
|
|
@@ -11019,20 +11002,24 @@ declare enum TransactionOrGasType {
|
|
|
11019
11002
|
}
|
|
11020
11003
|
/**
|
|
11021
11004
|
* The fulfillment transaction which contains the transaction to send.
|
|
11022
|
-
* @property {TransactionOrGasType} type
|
|
11023
|
-
* @property {TransactionRequest} transaction
|
|
11005
|
+
* @property {TransactionOrGasType} type
|
|
11006
|
+
* @property {TransactionRequest} transaction
|
|
11024
11007
|
*/
|
|
11025
11008
|
type FulfillmentTransaction = {
|
|
11009
|
+
/** The type to indicate this is a fulfillment transaction. */
|
|
11026
11010
|
type: TransactionOrGasType.TRANSACTION;
|
|
11011
|
+
/** The transaction to send. */
|
|
11027
11012
|
transaction: TransactionRequest;
|
|
11028
11013
|
};
|
|
11029
11014
|
/**
|
|
11030
11015
|
* The gas amount which contains the gas token and the gas limit.
|
|
11031
|
-
* @property {TransactionOrGasType} type
|
|
11032
|
-
* @property {GasToken} gasToken
|
|
11016
|
+
* @property {TransactionOrGasType} type
|
|
11017
|
+
* @property {GasToken} gasToken
|
|
11033
11018
|
*/
|
|
11034
11019
|
type GasAmount = {
|
|
11020
|
+
/** The type to indicate this is a gas amount. */
|
|
11035
11021
|
type: TransactionOrGasType.GAS;
|
|
11022
|
+
/** The gas token. */
|
|
11036
11023
|
gasToken: GasToken;
|
|
11037
11024
|
};
|
|
11038
11025
|
/**
|
|
@@ -11051,22 +11038,27 @@ declare enum GasTokenType {
|
|
|
11051
11038
|
}
|
|
11052
11039
|
/**
|
|
11053
11040
|
* Represents a native gas token.
|
|
11054
|
-
* @property {GasTokenType} type
|
|
11055
|
-
* @property {BigNumber} limit
|
|
11041
|
+
* @property {GasTokenType} type
|
|
11042
|
+
* @property {BigNumber} limit
|
|
11056
11043
|
*/
|
|
11057
11044
|
type NativeGas = {
|
|
11045
|
+
/** The type to indicate this is a native gas token. */
|
|
11058
11046
|
type: GasTokenType.NATIVE;
|
|
11047
|
+
/** The gas limit. */
|
|
11059
11048
|
limit: BigNumber;
|
|
11060
11049
|
};
|
|
11061
11050
|
/**
|
|
11062
11051
|
* Represents an ERC20 gas token.
|
|
11063
|
-
* @property {GasTokenType} type
|
|
11064
|
-
* @property {string} contractAddress
|
|
11065
|
-
* @property {BigNumber} limit
|
|
11052
|
+
* @property {GasTokenType} type
|
|
11053
|
+
* @property {string} contractAddress
|
|
11054
|
+
* @property {BigNumber} limit
|
|
11066
11055
|
*/
|
|
11067
11056
|
type ERC20Gas = {
|
|
11057
|
+
/** The type to indicate this is an ERC20 gas token. */
|
|
11068
11058
|
type: GasTokenType.ERC20;
|
|
11059
|
+
/** The contract address of the ERC20. */
|
|
11069
11060
|
contractAddress: string;
|
|
11061
|
+
/** The gas limit. */
|
|
11070
11062
|
limit: BigNumber;
|
|
11071
11063
|
};
|
|
11072
11064
|
/**
|
|
@@ -11075,34 +11067,38 @@ type ERC20Gas = {
|
|
|
11075
11067
|
type SmartCheckoutResult = SmartCheckoutSufficient | SmartCheckoutInsufficient;
|
|
11076
11068
|
/**
|
|
11077
11069
|
* Represents the result of {@link Checkout.smartCheckout} when smart checkout is sufficient.
|
|
11078
|
-
* @property {boolean} sufficient
|
|
11079
|
-
* @property {TransactionRequirement[]} transactionRequirements
|
|
11080
|
-
* determined were required for the transaction.
|
|
11070
|
+
* @property {boolean} sufficient
|
|
11071
|
+
* @property {TransactionRequirement[]} transactionRequirements
|
|
11081
11072
|
*/
|
|
11082
11073
|
type SmartCheckoutSufficient = {
|
|
11074
|
+
/** Indicates that smart checkout determined the user had sufficient funds. */
|
|
11083
11075
|
sufficient: true;
|
|
11076
|
+
/** The transaction requirements smart checkout determined were required for the transaction. */
|
|
11084
11077
|
transactionRequirements: TransactionRequirement[];
|
|
11085
11078
|
};
|
|
11086
11079
|
/**
|
|
11087
11080
|
* Represents the result of {@link Checkout.smartCheckout} when smart checkout is insufficient.
|
|
11088
|
-
* @property {boolean} sufficient
|
|
11089
|
-
* @property {TransactionRequirement[]} transactionRequirements
|
|
11090
|
-
*
|
|
11091
|
-
* @property {SmartCheckoutRouter} router - The type containing the funding routes the user can take to fulfill the transaction requirements
|
|
11081
|
+
* @property {boolean} sufficient
|
|
11082
|
+
* @property {TransactionRequirement[]} transactionRequirements
|
|
11083
|
+
* @property {SmartCheckoutRouter} router
|
|
11092
11084
|
*/
|
|
11093
11085
|
type SmartCheckoutInsufficient = {
|
|
11086
|
+
/** Indicates that smart checkout determined the user has insufficient funds */
|
|
11094
11087
|
sufficient: false;
|
|
11088
|
+
/** The transaction requirements smart checkout determined were required for the transaction. */
|
|
11095
11089
|
transactionRequirements: TransactionRequirement[];
|
|
11090
|
+
/** The type containing the funding routes the user can take to fulfill the transaction requirements */
|
|
11096
11091
|
router: SmartCheckoutRouter;
|
|
11097
11092
|
};
|
|
11098
11093
|
/**
|
|
11099
11094
|
* Represents the routing outcome for a transaction.
|
|
11100
|
-
* @property {AvailableRoutingOptions} availableRoutingOptions
|
|
11101
|
-
* @property {RoutingOutcome} routingOutcome
|
|
11102
|
-
* includes the funding routes if routes were found
|
|
11095
|
+
* @property {AvailableRoutingOptions} availableRoutingOptions
|
|
11096
|
+
* @property {RoutingOutcome} routingOutcome
|
|
11103
11097
|
*/
|
|
11104
11098
|
type SmartCheckoutRouter = {
|
|
11099
|
+
/** The routing options available to the user */
|
|
11105
11100
|
availableRoutingOptions: AvailableRoutingOptions;
|
|
11101
|
+
/** The routing outcome for the transaction which includes the funding routes if routes were found */
|
|
11106
11102
|
routingOutcome: RoutingOutcome;
|
|
11107
11103
|
};
|
|
11108
11104
|
/**
|
|
@@ -11120,109 +11116,137 @@ declare enum RoutingOutcomeType {
|
|
|
11120
11116
|
type RoutingOutcome = RoutesFound | NoRoutesFound | NoRouteOptions;
|
|
11121
11117
|
/**
|
|
11122
11118
|
* Represents a routing outcome where funding routes were found.
|
|
11123
|
-
* @property {RoutingOutcomeType.ROUTES_FOUND} type
|
|
11124
|
-
* @property {AvailableRoutingOptions} fundingRoutes
|
|
11119
|
+
* @property {RoutingOutcomeType.ROUTES_FOUND} type
|
|
11120
|
+
* @property {AvailableRoutingOptions} fundingRoutes
|
|
11125
11121
|
*/
|
|
11126
11122
|
type RoutesFound = {
|
|
11123
|
+
/** Indicates that funding routes were found for the transaction. */
|
|
11127
11124
|
type: RoutingOutcomeType.ROUTES_FOUND;
|
|
11125
|
+
/** The funding routes found for the transaction. */
|
|
11128
11126
|
fundingRoutes: FundingRoute[];
|
|
11129
11127
|
};
|
|
11130
11128
|
/**
|
|
11131
11129
|
* Represents a routing outcome where no funding routes were found.
|
|
11132
|
-
* @property {RoutingOutcomeType.NO_ROUTES_FOUND} type
|
|
11133
|
-
* @property {string} message
|
|
11130
|
+
* @property {RoutingOutcomeType.NO_ROUTES_FOUND} type
|
|
11131
|
+
* @property {string} message
|
|
11134
11132
|
*/
|
|
11135
11133
|
type NoRoutesFound = {
|
|
11134
|
+
/** Indicates that no funding routes were found for the transaction. */
|
|
11136
11135
|
type: RoutingOutcomeType.NO_ROUTES_FOUND;
|
|
11136
|
+
/** The message indicating why no funding routes were found. */
|
|
11137
11137
|
message: string;
|
|
11138
11138
|
};
|
|
11139
11139
|
/**
|
|
11140
11140
|
* Represents a routing outcome where no routing options were available for the transaction.
|
|
11141
|
-
* @property {RoutingOutcomeType.NO_ROUTE_OPTIONS} type
|
|
11142
|
-
* @property {string} message
|
|
11141
|
+
* @property {RoutingOutcomeType.NO_ROUTE_OPTIONS} type
|
|
11142
|
+
* @property {string} message
|
|
11143
11143
|
*/
|
|
11144
11144
|
type NoRouteOptions = {
|
|
11145
|
+
/** Indicates that no routing options were available for the transaction. */
|
|
11145
11146
|
type: RoutingOutcomeType.NO_ROUTE_OPTIONS;
|
|
11147
|
+
/** The message indicating why no routing options were available. */
|
|
11146
11148
|
message: string;
|
|
11147
11149
|
};
|
|
11148
11150
|
/**
|
|
11149
11151
|
* Represents a funding route
|
|
11150
|
-
* @property {number} priority
|
|
11151
|
-
* @property {FundingStep[]} steps
|
|
11152
|
+
* @property {number} priority
|
|
11153
|
+
* @property {FundingStep[]} steps
|
|
11152
11154
|
*/
|
|
11153
11155
|
type FundingRoute = {
|
|
11156
|
+
/** The priority of the route */
|
|
11154
11157
|
priority: number;
|
|
11158
|
+
/** The steps associated with this funding route */
|
|
11155
11159
|
steps: FundingStep[];
|
|
11156
11160
|
};
|
|
11157
11161
|
/**
|
|
11158
11162
|
* Represents a fee
|
|
11159
|
-
* @property {BigNumber} amount
|
|
11160
|
-
* @property {string} formatted
|
|
11161
|
-
* @property {TokenInfo | undefined} token
|
|
11163
|
+
* @property {BigNumber} amount
|
|
11164
|
+
* @property {string} formatted
|
|
11165
|
+
* @property {TokenInfo | undefined} token
|
|
11162
11166
|
*/
|
|
11163
11167
|
type Fee = {
|
|
11168
|
+
/** The amount of the fee */
|
|
11164
11169
|
amount: BigNumber;
|
|
11170
|
+
/** The formatted amount of the fee */
|
|
11165
11171
|
formattedAmount: string;
|
|
11172
|
+
/** The token info for the fee */
|
|
11166
11173
|
token?: TokenInfo;
|
|
11167
11174
|
};
|
|
11168
11175
|
type FundingStep = BridgeFundingStep | SwapFundingStep | OnRampFundingStep;
|
|
11169
11176
|
/**
|
|
11170
11177
|
* Represents a bridge funding route
|
|
11171
|
-
* @property {FundingStepType.BRIDGE} type
|
|
11172
|
-
* @property {number} chainId
|
|
11173
|
-
* @property {FundingItem} fundingItem
|
|
11174
|
-
* @property {BridgeFees} fees
|
|
11178
|
+
* @property {FundingStepType.BRIDGE} type
|
|
11179
|
+
* @property {number} chainId
|
|
11180
|
+
* @property {FundingItem} fundingItem
|
|
11181
|
+
* @property {BridgeFees} fees
|
|
11175
11182
|
*/
|
|
11176
11183
|
type BridgeFundingStep = {
|
|
11184
|
+
/** Indicates that this is a bridge funding step */
|
|
11177
11185
|
type: FundingStepType.BRIDGE;
|
|
11186
|
+
/** The chain id the bridge should be executed on */
|
|
11178
11187
|
chainId: number;
|
|
11188
|
+
/** The funding item for the bridge */
|
|
11179
11189
|
fundingItem: FundingItem;
|
|
11190
|
+
/** The fees for the bridge */
|
|
11180
11191
|
fees: BridgeFees;
|
|
11181
11192
|
};
|
|
11182
11193
|
/**
|
|
11183
11194
|
* Represents the fees for a bridge funding step
|
|
11184
|
-
* @property {Fee} approvalGasFees
|
|
11185
|
-
* @property {Fee} bridgeGasFees
|
|
11186
|
-
* @property {Fee[]} bridgeFees
|
|
11195
|
+
* @property {Fee} approvalGasFees
|
|
11196
|
+
* @property {Fee} bridgeGasFees
|
|
11197
|
+
* @property {Fee[]} bridgeFees
|
|
11187
11198
|
*/
|
|
11188
11199
|
type BridgeFees = {
|
|
11200
|
+
/** The approval gas fees for the bridge */
|
|
11189
11201
|
approvalGasFees: Fee;
|
|
11202
|
+
/** The bridge gas fees for the bridge */
|
|
11190
11203
|
bridgeGasFees: Fee;
|
|
11204
|
+
/** Additional bridge fees for the bridge */
|
|
11191
11205
|
bridgeFees: Fee[];
|
|
11192
11206
|
};
|
|
11193
11207
|
/**
|
|
11194
11208
|
* Represents a swap funding route
|
|
11195
|
-
* @property {FundingStepType.SWAP} type
|
|
11196
|
-
* @property {number} chainId
|
|
11197
|
-
* @property {FundingItem} fundingItem
|
|
11198
|
-
* @property {SwapFees} fees
|
|
11209
|
+
* @property {FundingStepType.SWAP} type
|
|
11210
|
+
* @property {number} chainId
|
|
11211
|
+
* @property {FundingItem} fundingItem
|
|
11212
|
+
* @property {SwapFees} fees
|
|
11199
11213
|
*/
|
|
11200
11214
|
type SwapFundingStep = {
|
|
11215
|
+
/** Indicates that this is a swap funding step */
|
|
11201
11216
|
type: FundingStepType.SWAP;
|
|
11217
|
+
/** The chain id the swap should be executed on */
|
|
11202
11218
|
chainId: number;
|
|
11219
|
+
/** The funding item for the swap */
|
|
11203
11220
|
fundingItem: FundingItem;
|
|
11221
|
+
/** The fees for the swap */
|
|
11204
11222
|
fees: SwapFees;
|
|
11205
11223
|
};
|
|
11206
11224
|
/**
|
|
11207
11225
|
* Represents the fees for a swap funding step
|
|
11208
|
-
* @property {Fee} approvalGasFees
|
|
11209
|
-
* @property {Fee} swapGasFees
|
|
11210
|
-
* @property {Fee[]} swapFees
|
|
11226
|
+
* @property {Fee} approvalGasFees
|
|
11227
|
+
* @property {Fee} swapGasFees
|
|
11228
|
+
* @property {Fee[]} swapFees
|
|
11211
11229
|
*/
|
|
11212
11230
|
type SwapFees = {
|
|
11231
|
+
/** The approval gas fees for the swap */
|
|
11213
11232
|
approvalGasFees: Fee;
|
|
11233
|
+
/** The swap gas fees for the swap */
|
|
11214
11234
|
swapGasFees: Fee;
|
|
11235
|
+
/** Additional swap fees for the swap */
|
|
11215
11236
|
swapFees: Fee[];
|
|
11216
11237
|
};
|
|
11217
11238
|
/**
|
|
11218
11239
|
* Represents an onramp funding route
|
|
11219
|
-
* @property {FundingStepType.ONRAMP} type
|
|
11220
|
-
* @property {number} chainId
|
|
11221
|
-
* @property {FundingItem} fundingItem
|
|
11240
|
+
* @property {FundingStepType.ONRAMP} type
|
|
11241
|
+
* @property {number} chainId
|
|
11242
|
+
* @property {FundingItem} fundingItem
|
|
11222
11243
|
*/
|
|
11223
11244
|
type OnRampFundingStep = {
|
|
11245
|
+
/** Indicates that this is an onramp funding step */
|
|
11224
11246
|
type: FundingStepType.ONRAMP;
|
|
11247
|
+
/** The chain id the onramp should provide funds to */
|
|
11225
11248
|
chainId: number;
|
|
11249
|
+
/** The item to be onramped */
|
|
11226
11250
|
fundingItem: FundingItem;
|
|
11227
11251
|
};
|
|
11228
11252
|
/**
|
|
@@ -11239,76 +11263,98 @@ declare enum FundingStepType {
|
|
|
11239
11263
|
}
|
|
11240
11264
|
/**
|
|
11241
11265
|
* Represents a funding item
|
|
11242
|
-
* @property {ItemType.NATIVE | ItemType.ERC20} type
|
|
11243
|
-
* @property {FundsRequired} fundsRequired
|
|
11244
|
-
* @property {UserBalance} userBalance
|
|
11245
|
-
* @property {TokenInfo} token
|
|
11266
|
+
* @property {ItemType.NATIVE | ItemType.ERC20} type
|
|
11267
|
+
* @property {FundsRequired} fundsRequired
|
|
11268
|
+
* @property {UserBalance} userBalance
|
|
11269
|
+
* @property {TokenInfo} token
|
|
11246
11270
|
*/
|
|
11247
11271
|
type FundingItem = {
|
|
11272
|
+
/** The type of the funding item */
|
|
11248
11273
|
type: ItemType.NATIVE | ItemType.ERC20;
|
|
11274
|
+
/** The amount of funds required of this funding item */
|
|
11249
11275
|
fundsRequired: FundsRequired;
|
|
11276
|
+
/** The current user balance of this funding item */
|
|
11250
11277
|
userBalance: UserBalance;
|
|
11278
|
+
/** The token info for the funding item */
|
|
11251
11279
|
token: TokenInfo;
|
|
11252
11280
|
};
|
|
11253
11281
|
/**
|
|
11254
11282
|
* Represents the funds required of a funding item
|
|
11255
|
-
* @property {BigNumber} amount
|
|
11256
|
-
* @property {string} formattedAmount
|
|
11283
|
+
* @property {BigNumber} amount
|
|
11284
|
+
* @property {string} formattedAmount
|
|
11257
11285
|
*/
|
|
11258
11286
|
type FundsRequired = {
|
|
11287
|
+
/** The amount of funds required */
|
|
11259
11288
|
amount: BigNumber;
|
|
11289
|
+
/** The formatted amount of funds required */
|
|
11260
11290
|
formattedAmount: string;
|
|
11261
11291
|
};
|
|
11262
11292
|
/**
|
|
11263
11293
|
* Represents the user balance of a funding item
|
|
11264
|
-
* @property {BigNumber} balance
|
|
11265
|
-
* @property {string} formattedBalance
|
|
11294
|
+
* @property {BigNumber} balance
|
|
11295
|
+
* @property {string} formattedBalance
|
|
11266
11296
|
*/
|
|
11267
11297
|
type UserBalance = {
|
|
11298
|
+
/** The balance of the funding item */
|
|
11268
11299
|
balance: BigNumber;
|
|
11300
|
+
/** The formatted balance of the funding item */
|
|
11269
11301
|
formattedBalance: string;
|
|
11270
11302
|
};
|
|
11271
11303
|
/**
|
|
11272
11304
|
* Represents the transaction requirement for a transaction.
|
|
11273
|
-
* @property {ItemType} type
|
|
11274
|
-
* @property {boolean} sufficient
|
|
11275
|
-
* @property {ItemBalance} required
|
|
11276
|
-
* @property {ItemBalance} current
|
|
11277
|
-
* @property {BalanceDelta} delta
|
|
11305
|
+
* @property {ItemType} type
|
|
11306
|
+
* @property {boolean} sufficient
|
|
11307
|
+
* @property {ItemBalance} required
|
|
11308
|
+
* @property {ItemBalance} current
|
|
11309
|
+
* @property {BalanceDelta} delta
|
|
11278
11310
|
*/
|
|
11279
11311
|
type TransactionRequirement = {
|
|
11312
|
+
/** The type of the transaction requirement. */
|
|
11280
11313
|
type: ItemType;
|
|
11314
|
+
/** If the user address has sufficient funds to cover the transaction. */
|
|
11281
11315
|
sufficient: boolean;
|
|
11316
|
+
/** The required item balance. */
|
|
11282
11317
|
required: ItemBalance;
|
|
11318
|
+
/** The current item balance. */
|
|
11283
11319
|
current: ItemBalance;
|
|
11320
|
+
/** The delta between the required and current balances. */
|
|
11284
11321
|
delta: BalanceDelta;
|
|
11285
11322
|
};
|
|
11286
11323
|
/**
|
|
11287
11324
|
* Represents the balance for either a native or ERC20 token.
|
|
11288
|
-
* @property {ItemType.NATIVE | ItemType.ERC20} type
|
|
11289
|
-
* @property {BigNumber} balance
|
|
11290
|
-
* @property {string}
|
|
11291
|
-
* @property {TokenInfo} token
|
|
11325
|
+
* @property {ItemType.NATIVE | ItemType.ERC20} type
|
|
11326
|
+
* @property {BigNumber} balance
|
|
11327
|
+
* @property {string} formattedBalanc
|
|
11328
|
+
* @property {TokenInfo} token
|
|
11292
11329
|
*/
|
|
11293
11330
|
type TokenBalance = {
|
|
11331
|
+
/** Type to indicate this is a native or ERC20 token. */
|
|
11294
11332
|
type: ItemType.NATIVE | ItemType.ERC20;
|
|
11333
|
+
/** The balance of the item. */
|
|
11295
11334
|
balance: BigNumber;
|
|
11335
|
+
/** The formatted balance of the item. */
|
|
11296
11336
|
formattedBalance: string;
|
|
11337
|
+
/** The token info of the item. */
|
|
11297
11338
|
token: TokenInfo;
|
|
11298
11339
|
};
|
|
11299
11340
|
/**
|
|
11300
11341
|
* Represents the balance for an ERC721.
|
|
11301
|
-
* @property {ItemType.ERC721} type
|
|
11302
|
-
* @property {BigNumber} balance
|
|
11303
|
-
* @property {string} formattedBalance
|
|
11304
|
-
* @property {string} contractAddress
|
|
11305
|
-
* @property {string} id
|
|
11342
|
+
* @property {ItemType.ERC721} type
|
|
11343
|
+
* @property {BigNumber} balance
|
|
11344
|
+
* @property {string} formattedBalance
|
|
11345
|
+
* @property {string} contractAddress
|
|
11346
|
+
* @property {string} id
|
|
11306
11347
|
*/
|
|
11307
11348
|
type ERC721Balance = {
|
|
11349
|
+
/** Type to indicate this is an ERC721 token. */
|
|
11308
11350
|
type: ItemType.ERC721;
|
|
11351
|
+
/** The balance of the item. */
|
|
11309
11352
|
balance: BigNumber;
|
|
11353
|
+
/** The formatted balance of the item. */
|
|
11310
11354
|
formattedBalance: string;
|
|
11355
|
+
/** The contract address of the ERC721 collection. */
|
|
11311
11356
|
contractAddress: string;
|
|
11357
|
+
/** The ID of the ERC721 in the collection */
|
|
11312
11358
|
id: string;
|
|
11313
11359
|
};
|
|
11314
11360
|
/**
|
|
@@ -11317,25 +11363,31 @@ type ERC721Balance = {
|
|
|
11317
11363
|
type ItemBalance = ERC721Balance | TokenBalance;
|
|
11318
11364
|
/**
|
|
11319
11365
|
* Represents the delta between two balances.
|
|
11320
|
-
* @property {BigNumber} balance
|
|
11321
|
-
* @property {string} formattedBalance
|
|
11366
|
+
* @property {BigNumber} balance
|
|
11367
|
+
* @property {string} formattedBalance
|
|
11322
11368
|
*/
|
|
11323
11369
|
type BalanceDelta = {
|
|
11370
|
+
/** The delta of the balance. */
|
|
11324
11371
|
balance: BigNumber;
|
|
11372
|
+
/** The formatted balance of the delta. */
|
|
11325
11373
|
formattedBalance: string;
|
|
11326
11374
|
};
|
|
11327
11375
|
/**
|
|
11328
11376
|
* A type representing the Smart Checkout routing options available for a user
|
|
11329
11377
|
* if they are configured and enabled (not geo-blocked etc.)
|
|
11330
|
-
* @property {boolean | undefined} onRamp
|
|
11331
|
-
* @property {boolean | undefined} swap
|
|
11332
|
-
* @property {boolean | undefined} bridge
|
|
11378
|
+
* @property {boolean | undefined} onRamp
|
|
11379
|
+
* @property {boolean | undefined} swap
|
|
11380
|
+
* @property {boolean | undefined} bridge
|
|
11333
11381
|
*/
|
|
11334
11382
|
type AvailableRoutingOptions = {
|
|
11383
|
+
/** If the user can use onramp */
|
|
11335
11384
|
onRamp?: boolean;
|
|
11385
|
+
/** If the user can use swap */
|
|
11336
11386
|
swap?: boolean;
|
|
11387
|
+
/** If the user can use bridge */
|
|
11337
11388
|
bridge?: boolean;
|
|
11338
11389
|
};
|
|
11390
|
+
|
|
11339
11391
|
/**
|
|
11340
11392
|
* Interface representing the parameters for {@link Checkout.buy}
|
|
11341
11393
|
* @property {Web3Provider} provider - The provider to use for the buy.
|
|
@@ -11346,6 +11398,7 @@ interface BuyParams {
|
|
|
11346
11398
|
provider: Web3Provider;
|
|
11347
11399
|
orders: Array<BuyOrder>;
|
|
11348
11400
|
}
|
|
11401
|
+
|
|
11349
11402
|
/**
|
|
11350
11403
|
* Interface representing the parameters for {@link Checkout.cancel}
|
|
11351
11404
|
* @property {Web3Provider} provider - The provider to use for the cancel.
|
|
@@ -11356,79 +11409,166 @@ interface CancelParams {
|
|
|
11356
11409
|
provider: Web3Provider;
|
|
11357
11410
|
orderIds: string[];
|
|
11358
11411
|
}
|
|
11359
|
-
|
|
11360
|
-
|
|
11361
|
-
|
|
11362
|
-
|
|
11363
|
-
|
|
11364
|
-
|
|
11365
|
-
|
|
11366
|
-
/**
|
|
11367
|
-
* A type representing various remotely defined configurations which are
|
|
11368
|
-
* accessible via the Checkout config and configured based on the Environment.
|
|
11369
|
-
* @property {DexConfig} dex - The config used for the DEX.
|
|
11370
|
-
* @property {OnRampConfig} onramp - The config used for the OnRamp
|
|
11371
|
-
* @property {AllowedNetworkConfig[]} allowedNetworks - An array representing the allowed networks.
|
|
11372
|
-
* @property {GasEstimateTokenConfig | undefined} gasEstimateTokens - The config for the tokens used to estimate gas.
|
|
11373
|
-
*/
|
|
11374
|
-
type RemoteConfiguration = {
|
|
11375
|
-
dex: DexConfig;
|
|
11376
|
-
onramp: OnRampConfig;
|
|
11377
|
-
bridge: BridgeConfig;
|
|
11378
|
-
allowedNetworks: AllowedNetworkConfig[];
|
|
11379
|
-
gasEstimateTokens?: GasEstimateTokenConfig;
|
|
11380
|
-
imxAddressMapping?: ImxAddressConfig;
|
|
11412
|
+
|
|
11413
|
+
type ExchangeContracts = {
|
|
11414
|
+
multicall: string;
|
|
11415
|
+
coreFactory: string;
|
|
11416
|
+
quoterV2: string;
|
|
11417
|
+
peripheryRouter: string;
|
|
11418
|
+
secondaryFee: string;
|
|
11381
11419
|
};
|
|
11382
11420
|
/**
|
|
11383
|
-
*
|
|
11384
|
-
* @property {string
|
|
11385
|
-
* @property {
|
|
11386
|
-
* @property {string
|
|
11387
|
-
|
|
11388
|
-
|
|
11389
|
-
|
|
11390
|
-
|
|
11391
|
-
|
|
11421
|
+
* Type representing an ERC20 token
|
|
11422
|
+
* @property {string} type - The token type, used to discriminate between {@link ERC20} and {@link Native}
|
|
11423
|
+
* @property {number} chainId - The chain ID
|
|
11424
|
+
* @property {string} address - The token address
|
|
11425
|
+
* @property {number} decimals - The token decimals
|
|
11426
|
+
* @property {string | undefined} symbol - The token symbol or undefined if it is not available
|
|
11427
|
+
* @property {string | undefined} name - The token name or undefined if it is not available
|
|
11428
|
+
*/
|
|
11429
|
+
type ERC20 = {
|
|
11430
|
+
type: 'erc20';
|
|
11431
|
+
chainId: number;
|
|
11432
|
+
address: string;
|
|
11433
|
+
decimals: number;
|
|
11434
|
+
symbol?: string;
|
|
11435
|
+
name?: string;
|
|
11436
|
+
};
|
|
11437
|
+
/**
|
|
11438
|
+
* Type representing a native token
|
|
11439
|
+
* @property {string} type - The token type, used to discriminate between {@link ERC20} and {@link Native}
|
|
11440
|
+
* @property {number} chainId - The chain ID
|
|
11441
|
+
* @property {number} decimals - The token decimals
|
|
11442
|
+
* @property {string | undefined} symbol - The token symbol or undefined if it is not available
|
|
11443
|
+
* @property {string | undefined} name - The token name or undefined if it is not available
|
|
11444
|
+
*/
|
|
11445
|
+
type Native = {
|
|
11446
|
+
type: 'native';
|
|
11447
|
+
chainId: number;
|
|
11448
|
+
decimals: number;
|
|
11449
|
+
symbol?: string;
|
|
11450
|
+
name?: string;
|
|
11451
|
+
};
|
|
11452
|
+
/**
|
|
11453
|
+
* Type representing a token, either an {@link ERC20} or {@link Native}
|
|
11454
|
+
*/
|
|
11455
|
+
type Coin = ERC20 | Native;
|
|
11456
|
+
/**
|
|
11457
|
+
* Type representing the overrides for the {@link Exchange} module
|
|
11458
|
+
* @property {string} rpcURL - The RPC URL for the chain
|
|
11459
|
+
* @property {ExchangeContracts} exchangeContracts - The DEX contract addresses
|
|
11460
|
+
* @property {ERC20[]} commonRoutingTokens - The tokens used to find available pools for a swap
|
|
11461
|
+
* @property {Coin} nativeToken - The native token of the chain
|
|
11462
|
+
* @property {ERC20} wrappedNativeToken - The wrapped native token of the chain
|
|
11463
|
+
*/
|
|
11464
|
+
type ExchangeOverrides = {
|
|
11465
|
+
rpcURL: string;
|
|
11466
|
+
exchangeContracts: ExchangeContracts;
|
|
11467
|
+
commonRoutingTokens: ERC20[];
|
|
11468
|
+
nativeToken: Coin;
|
|
11469
|
+
wrappedNativeToken: ERC20;
|
|
11470
|
+
};
|
|
11471
|
+
|
|
11472
|
+
interface CheckoutOverrides {
|
|
11473
|
+
}
|
|
11474
|
+
/**
|
|
11475
|
+
* A type representing checkout SDK configurations.
|
|
11476
|
+
* @property {boolean} isOnRampEnabled - To enable on-ramp feature in Checkout sdk.
|
|
11477
|
+
* @property {boolean} isSwapEnabled - To enable swap feature in Checkout sdk.
|
|
11478
|
+
* @property {boolean} isBridgeEnabled - To enable bridge feature in Checkout sdk.
|
|
11479
|
+
* @property {Passport} passport - To enable passport wallet with Checkout sdk.
|
|
11480
|
+
*/
|
|
11481
|
+
interface CheckoutModuleConfiguration extends ModuleConfiguration<CheckoutOverrides> {
|
|
11482
|
+
isOnRampEnabled?: boolean;
|
|
11483
|
+
isSwapEnabled?: boolean;
|
|
11484
|
+
isBridgeEnabled?: boolean;
|
|
11485
|
+
passport?: Passport;
|
|
11486
|
+
}
|
|
11487
|
+
/**
|
|
11488
|
+
* A type representing various remotely defined configurations which are
|
|
11489
|
+
* accessible via the Checkout config and configured based on the Environment.
|
|
11490
|
+
* @property {DexConfig} dex
|
|
11491
|
+
* @property {OnRampConfig} onramp
|
|
11492
|
+
* @property {BridgeConfig} bridge
|
|
11493
|
+
* @property {AllowedNetworkConfig[]} allowedNetworks
|
|
11494
|
+
* @property {GasEstimateTokenConfig | undefined} gasEstimateTokens
|
|
11495
|
+
* @property {ImxAddressConfig | undefined} imxAddressMapping
|
|
11496
|
+
*/
|
|
11497
|
+
type RemoteConfiguration = {
|
|
11498
|
+
/** The config used for the DEX. */
|
|
11499
|
+
dex: DexConfig;
|
|
11500
|
+
/** The config used for the OnRamp */
|
|
11501
|
+
onramp: OnRampConfig;
|
|
11502
|
+
/** The config used for the Bridge. */
|
|
11503
|
+
bridge: BridgeConfig;
|
|
11504
|
+
/** An array representing the allowed networks. */
|
|
11505
|
+
allowedNetworks: AllowedNetworkConfig[];
|
|
11506
|
+
/** The config for the tokens used to estimate gas. */
|
|
11507
|
+
gasEstimateTokens?: GasEstimateTokenConfig;
|
|
11508
|
+
/** The IMX address mappings across available networks. */
|
|
11509
|
+
imxAddressMapping?: ImxAddressConfig;
|
|
11510
|
+
};
|
|
11511
|
+
/**
|
|
11512
|
+
* A type representing the fee structure for an OnRamp provider
|
|
11513
|
+
* @property {string | undefined} minPercentage
|
|
11514
|
+
* @property {string | undefined} maxPercentage
|
|
11515
|
+
* @property {string | undefined} feePercentage
|
|
11516
|
+
*/
|
|
11517
|
+
type OnRampProviderFees = {
|
|
11518
|
+
/** The minimum percentage fee shown if a fee range is provided */
|
|
11519
|
+
minPercentage?: string;
|
|
11520
|
+
/** The maximum percentage fee shown if a fee range is provided */
|
|
11521
|
+
maxPercentage?: string;
|
|
11522
|
+
/** The specific fee percentage shown if there is no range provided */
|
|
11523
|
+
feePercentage?: string;
|
|
11392
11524
|
};
|
|
11393
11525
|
/**
|
|
11394
11526
|
* A type representing the configuration for the OnRamp for a specific provider.
|
|
11395
|
-
* @property {string} publishableApiKey
|
|
11396
|
-
* @property {TokenInfo[]} tokens
|
|
11397
|
-
* @property {OnRampProviderFees} fees
|
|
11527
|
+
* @property {string} publishableApiKey
|
|
11528
|
+
* @property {TokenInfo[]} tokens
|
|
11529
|
+
* @property {OnRampProviderFees} fees
|
|
11398
11530
|
*/
|
|
11399
11531
|
type OnRampProviderConfig = {
|
|
11532
|
+
/** The on ramp provider publishable api-key */
|
|
11400
11533
|
publishableApiKey: string;
|
|
11534
|
+
/** The allowed tokens for the OnRamp provider */
|
|
11401
11535
|
tokens: TokenInfo[];
|
|
11536
|
+
/** The on ramp provider transaction fees */
|
|
11402
11537
|
fees: OnRampProviderFees;
|
|
11403
11538
|
};
|
|
11404
11539
|
/**
|
|
11405
11540
|
* A type representing the configuration for the OnRamp.
|
|
11406
|
-
* @property {OnRampProviderConfig} transak
|
|
11541
|
+
* @property {OnRampProviderConfig} transak
|
|
11407
11542
|
*/
|
|
11408
11543
|
type OnRampConfig = {
|
|
11544
|
+
/** OnRamp config for Transak provider */
|
|
11409
11545
|
[key: string]: OnRampProviderConfig;
|
|
11410
11546
|
};
|
|
11411
11547
|
/**
|
|
11412
11548
|
* A type representing the configuration for the DEX.
|
|
11413
|
-
* @property {ExchangeOverrides | undefined} overrides
|
|
11414
|
-
* @property {TokenInfo[] | undefined} tokens
|
|
11549
|
+
* @property {ExchangeOverrides | undefined} overrides
|
|
11550
|
+
* @property {TokenInfo[] | undefined} tokens
|
|
11415
11551
|
*/
|
|
11416
11552
|
type DexConfig = {
|
|
11553
|
+
/** The DEX overrides. */
|
|
11417
11554
|
overrides?: ExchangeOverrides;
|
|
11555
|
+
/** An array of tokens compatible with the DEX. */
|
|
11418
11556
|
tokens?: TokenInfo[];
|
|
11419
11557
|
};
|
|
11420
11558
|
/**
|
|
11421
11559
|
* A type representing the configuration for the Bridge.
|
|
11422
|
-
* @property {TokenInfo[] | undefined} tokens
|
|
11560
|
+
* @property {TokenInfo[] | undefined} tokens
|
|
11423
11561
|
*/
|
|
11424
11562
|
type BridgeConfig = {
|
|
11563
|
+
/** An array of tokens compatible with the Bridge. */
|
|
11425
11564
|
tokens?: TokenInfo[];
|
|
11426
11565
|
};
|
|
11427
11566
|
/**
|
|
11428
11567
|
* A type representing an allowed network.
|
|
11429
|
-
* @property {number} chainId
|
|
11568
|
+
* @property {number} chainId
|
|
11430
11569
|
*/
|
|
11431
11570
|
type AllowedNetworkConfig = {
|
|
11571
|
+
/** The network chain id. */
|
|
11432
11572
|
chainId: number;
|
|
11433
11573
|
};
|
|
11434
11574
|
/**
|
|
@@ -11443,42 +11583,50 @@ type ImxAddressConfig = {
|
|
|
11443
11583
|
* @type {{ [key: string]: { bridgeToL2Addresses?: GasEstimateBridgeToL2TokenConfig, swapAddresses?: GasEstimateSwapTokenConfig } }}
|
|
11444
11584
|
* - A map of addresses for estimating gas keyed by the network chain id.
|
|
11445
11585
|
* @property {GasEstimateBridgeToL2TokenConfig | undefined} bridgeToL2Addresses
|
|
11446
|
-
*
|
|
11447
|
-
* @property {GasEstimateSwapTokenConfig | undefined} swapAddresses - The type representing the addresses for a swap gas estimate
|
|
11586
|
+
* @property {GasEstimateSwapTokenConfig | undefined} swapAddresses
|
|
11448
11587
|
*/
|
|
11449
11588
|
type GasEstimateTokenConfig = {
|
|
11450
11589
|
[key: string]: {
|
|
11590
|
+
/** The type representing the addresses for a bridge to layer 2 gas estimate. */
|
|
11451
11591
|
bridgeToL2Addresses?: GasEstimateBridgeToL2TokenConfig;
|
|
11592
|
+
/** The type representing the addresses for a swap gas estimate */
|
|
11452
11593
|
swapAddresses?: GasEstimateSwapTokenConfig;
|
|
11453
11594
|
};
|
|
11454
11595
|
};
|
|
11455
11596
|
/**
|
|
11456
11597
|
* A type representing the config for a bridge to layer 2 gas estimate.
|
|
11457
|
-
* @property {string | 'NATIVE'} gasTokenAddress
|
|
11458
|
-
* @property {string} fromAddress
|
|
11598
|
+
* @property {string | 'NATIVE'} gasTokenAddress
|
|
11599
|
+
* @property {string} fromAddress
|
|
11459
11600
|
*/
|
|
11460
11601
|
type GasEstimateBridgeToL2TokenConfig = {
|
|
11602
|
+
/** The address of the gas token. */
|
|
11461
11603
|
gasTokenAddress: string | 'NATIVE';
|
|
11604
|
+
/** The address of the token being bridged. */
|
|
11462
11605
|
fromAddress: string;
|
|
11463
11606
|
};
|
|
11464
11607
|
/**
|
|
11465
11608
|
* A type representing the config for a swap gas estimate.
|
|
11466
|
-
* @property {string} inAddress
|
|
11467
|
-
* @property {string} outAddress
|
|
11609
|
+
* @property {string} inAddress
|
|
11610
|
+
* @property {string} outAddress
|
|
11468
11611
|
*/
|
|
11469
11612
|
type GasEstimateSwapTokenConfig = {
|
|
11613
|
+
/** The in token address. */
|
|
11470
11614
|
inAddress: string;
|
|
11615
|
+
/** The out token address. */
|
|
11471
11616
|
outAddress: string;
|
|
11472
11617
|
};
|
|
11473
11618
|
/**
|
|
11474
11619
|
* A type representing all the feature flags available.
|
|
11475
|
-
* @property {TokenInfo[] | undefined} allowed -
|
|
11476
|
-
* @property {boolean | undefined} blockscout -
|
|
11620
|
+
* @property {TokenInfo[] | undefined} allowed -
|
|
11621
|
+
* @property {boolean | undefined} blockscout -
|
|
11477
11622
|
*/
|
|
11478
11623
|
type ChainTokensConfig = {
|
|
11624
|
+
/** List of allowed tokens for a given chain. */
|
|
11479
11625
|
allowed?: TokenInfo[];
|
|
11626
|
+
/** Feature flag to enable/disable blockscout integration. */
|
|
11480
11627
|
blockscout?: boolean;
|
|
11481
11628
|
};
|
|
11629
|
+
|
|
11482
11630
|
/**
|
|
11483
11631
|
* Interface representing the params of {@link Checkout.connect}.
|
|
11484
11632
|
* @property {Web3Provider} provider - The provider used to connect to the network.
|
|
@@ -11509,6 +11657,16 @@ interface CheckConnectionResult {
|
|
|
11509
11657
|
isConnected: boolean;
|
|
11510
11658
|
walletAddress: string;
|
|
11511
11659
|
}
|
|
11660
|
+
|
|
11661
|
+
/**
|
|
11662
|
+
* @typedef {string} Address - Represents an Ethereum address.
|
|
11663
|
+
*/
|
|
11664
|
+
type Address = string;
|
|
11665
|
+
/**
|
|
11666
|
+
* @typedef {Address | 'NATIVE'} FungibleToken - Represents a fungible token, either an ERC20 token address or the native token.
|
|
11667
|
+
*/
|
|
11668
|
+
type FungibleToken = Address | 'NATIVE';
|
|
11669
|
+
|
|
11512
11670
|
/**
|
|
11513
11671
|
* An enum representing the type of gas estimate.
|
|
11514
11672
|
* @enum {string}
|
|
@@ -11572,6 +11730,7 @@ interface TokenAmountEstimate {
|
|
|
11572
11730
|
estimatedAmount?: BigNumber;
|
|
11573
11731
|
token?: TokenInfo;
|
|
11574
11732
|
}
|
|
11733
|
+
|
|
11575
11734
|
/**
|
|
11576
11735
|
* Represents information about a network.
|
|
11577
11736
|
* @interface NetworkInfo
|
|
@@ -11586,6 +11745,7 @@ interface NetworkInfo {
|
|
|
11586
11745
|
nativeCurrency: TokenInfo;
|
|
11587
11746
|
isSupported: boolean;
|
|
11588
11747
|
}
|
|
11748
|
+
|
|
11589
11749
|
/**
|
|
11590
11750
|
* Interface representing the parameters for {@link Checkout.switchNetwork}.
|
|
11591
11751
|
* @property {Web3Provider} provider - The provider to connect to the network.
|
|
@@ -11641,6 +11801,7 @@ declare enum NetworkFilterTypes {
|
|
|
11641
11801
|
interface NetworkFilter {
|
|
11642
11802
|
chainId: ChainId;
|
|
11643
11803
|
}
|
|
11804
|
+
|
|
11644
11805
|
/**
|
|
11645
11806
|
* Interface representing the parameters for {@link Checkout.sell}
|
|
11646
11807
|
* @property {Web3Provider} provider - The provider to use for the sell.
|
|
@@ -11651,6 +11812,7 @@ interface SellParams {
|
|
|
11651
11812
|
provider: Web3Provider;
|
|
11652
11813
|
orders: Array<SellOrder>;
|
|
11653
11814
|
}
|
|
11815
|
+
|
|
11654
11816
|
/**
|
|
11655
11817
|
* Interface representing the parameters for {@link Checkout.getTokenAllowList}.
|
|
11656
11818
|
* @property {TokenFilterTypes} type - The type of token to retrieve.
|
|
@@ -11685,6 +11847,7 @@ declare enum TokenFilterTypes {
|
|
|
11685
11847
|
interface TokenFilter {
|
|
11686
11848
|
address: string;
|
|
11687
11849
|
}
|
|
11850
|
+
|
|
11688
11851
|
/**
|
|
11689
11852
|
* Interface representing the parameters for {@link Checkout.sendTransaction}.
|
|
11690
11853
|
* @property {Web3Provider} provider - The provider to connect to the network.
|
|
@@ -11701,6 +11864,7 @@ interface SendTransactionParams {
|
|
|
11701
11864
|
interface SendTransactionResult {
|
|
11702
11865
|
transactionResponse: TransactionResponse;
|
|
11703
11866
|
}
|
|
11867
|
+
|
|
11704
11868
|
/**
|
|
11705
11869
|
* Enum representing the names of different wallet providers.
|
|
11706
11870
|
*/
|
|
@@ -11711,29 +11875,27 @@ declare enum WalletProviderName {
|
|
|
11711
11875
|
/**
|
|
11712
11876
|
* Interface for the parameters required to create a wallet provider {@link Checkout.createProvider}.
|
|
11713
11877
|
* @interface CreateProviderParams
|
|
11714
|
-
* @property {WalletProviderName}
|
|
11715
|
-
* @property {Passport | undefined} passport - The Passport instance required to create a provider for passport users.
|
|
11716
|
-
* If walletProvider is 'passport', then the passport instance must be passed in.
|
|
11878
|
+
* @property {WalletProviderName} walletProviderName - The wallet provider name to create a provider for.
|
|
11717
11879
|
*/
|
|
11718
11880
|
interface CreateProviderParams {
|
|
11719
|
-
|
|
11720
|
-
passport?: Passport;
|
|
11881
|
+
walletProviderName: WalletProviderName;
|
|
11721
11882
|
}
|
|
11722
11883
|
/**
|
|
11723
11884
|
* Represents the result of creating a Web3 provider {@link Checkout.createProvider}.
|
|
11724
11885
|
* @property {Web3Provider} provider - The created Web3 provider.
|
|
11725
|
-
* @property {WalletProviderName}
|
|
11886
|
+
* @property {WalletProviderName} walletProviderName - The wallet provider name of the provider that was created.
|
|
11726
11887
|
*/
|
|
11727
11888
|
type CreateProviderResult = {
|
|
11728
11889
|
provider: Web3Provider;
|
|
11729
11890
|
walletProviderName: WalletProviderName;
|
|
11730
11891
|
};
|
|
11892
|
+
|
|
11731
11893
|
/**
|
|
11732
11894
|
* Interface representing a wallet filter to be used in {@link GetWalletAllowListParams}.
|
|
11733
|
-
* @property {WalletProviderName}
|
|
11895
|
+
* @property {WalletProviderName} walletProviderName - The wallet provider name to filter wallets by.
|
|
11734
11896
|
*/
|
|
11735
11897
|
interface WalletFilter {
|
|
11736
|
-
|
|
11898
|
+
walletProviderName: WalletProviderName;
|
|
11737
11899
|
}
|
|
11738
11900
|
/**
|
|
11739
11901
|
* Interface representing the parameters for {@link Checkout.getWalletAllowList}.
|
|
@@ -11746,14 +11908,12 @@ interface GetWalletAllowListParams {
|
|
|
11746
11908
|
}
|
|
11747
11909
|
/**
|
|
11748
11910
|
* Interface representing information about a wallet used in {@link GetWalletAllowListResult}.
|
|
11749
|
-
* @property {WalletProviderName}
|
|
11750
|
-
* @property {string} name - The name of the wallet.
|
|
11911
|
+
* @property {WalletProviderName} walletProviderName - The wallet provider name for the wallet.
|
|
11751
11912
|
* @property {string | undefined} description - A description of the wallet.
|
|
11752
11913
|
* @property {string | undefined} icon - The URL/data:image of an icon for the wallet.
|
|
11753
11914
|
*/
|
|
11754
11915
|
interface WalletInfo {
|
|
11755
|
-
|
|
11756
|
-
name: string;
|
|
11916
|
+
walletProviderName: WalletProviderName;
|
|
11757
11917
|
description?: string;
|
|
11758
11918
|
icon?: string;
|
|
11759
11919
|
}
|
|
@@ -11770,6 +11930,7 @@ interface GetWalletAllowListResult {
|
|
|
11770
11930
|
declare enum WalletFilterTypes {
|
|
11771
11931
|
ALL = "all"
|
|
11772
11932
|
}
|
|
11933
|
+
|
|
11773
11934
|
/**
|
|
11774
11935
|
* Base URL for the checkout API based on the environment.
|
|
11775
11936
|
* @property {string} DEVELOPMENT - The base URL for the development environment.
|
|
@@ -11789,6 +11950,7 @@ type NetworkDetails = {
|
|
|
11789
11950
|
blockExplorerUrls?: string[];
|
|
11790
11951
|
};
|
|
11791
11952
|
type NetworkMap = Map<ChainId, NetworkDetails>;
|
|
11953
|
+
|
|
11792
11954
|
/**
|
|
11793
11955
|
* An enum representing the type of exchange.
|
|
11794
11956
|
* @enum {string}
|
|
@@ -11810,71 +11972,27 @@ interface FiatRampParams {
|
|
|
11810
11972
|
web3Provider: Web3Provider;
|
|
11811
11973
|
tokenAmount?: string;
|
|
11812
11974
|
tokenAddress?: string;
|
|
11813
|
-
passport?:
|
|
11814
|
-
}
|
|
11815
|
-
/**
|
|
11816
|
-
* Enum representing different types of errors that can occur during the checkout process.
|
|
11817
|
-
*/
|
|
11818
|
-
declare enum CheckoutErrorType {
|
|
11819
|
-
WEB3_PROVIDER_ERROR = "WEB3_PROVIDER_ERROR",
|
|
11820
|
-
PROVIDER_ERROR = "PROVIDER_ERROR",
|
|
11821
|
-
DEFAULT_PROVIDER_ERROR = "DEFAULT_PROVIDER_ERROR",
|
|
11822
|
-
CONNECT_PROVIDER_ERROR = "CONNECT_PROVIDER_ERROR",
|
|
11823
|
-
GET_BALANCE_ERROR = "GET_BALANCE_ERROR",
|
|
11824
|
-
GET_INDEXER_BALANCE_ERROR = "GET_INDEXER_BALANCE_ERROR",
|
|
11825
|
-
GET_ERC20_BALANCE_ERROR = "GET_ERC20_BALANCE_ERROR",
|
|
11826
|
-
GET_ERC721_BALANCE_ERROR = "GET_ERC721_BALANCE_ERROR",
|
|
11827
|
-
GET_NETWORK_INFO_ERROR = "GET_NETWORK_INFO_ERROR",
|
|
11828
|
-
METAMASK_PROVIDER_ERROR = "METAMASK_PROVIDER_ERROR",
|
|
11829
|
-
CHAIN_NOT_SUPPORTED_ERROR = "CHAIN_NOT_SUPPORTED_ERROR",
|
|
11830
|
-
PROVIDER_REQUEST_MISSING_ERROR = "PROVIDER_REQUEST_MISSING_ERROR",
|
|
11831
|
-
PROVIDER_REQUEST_FAILED_ERROR = "PROVIDER_REQUEST_FAILED_ERROR",
|
|
11832
|
-
USER_REJECTED_REQUEST_ERROR = "USER_REJECTED_REQUEST_ERROR",
|
|
11833
|
-
TRANSACTION_FAILED = "TRANSACTION_FAILED",
|
|
11834
|
-
INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS",
|
|
11835
|
-
UNPREDICTABLE_GAS_LIMIT = "UNPREDICTABLE_GAS_LIMIT",
|
|
11836
|
-
INVALID_GAS_ESTIMATE_TYPE = "INVALID_GAS_ESTIMATE_TYPE",
|
|
11837
|
-
UNSUPPORTED_TOKEN_TYPE_ERROR = "UNSUPPORTED_TOKEN_TYPE_ERROR",
|
|
11838
|
-
UNSUPPORTED_BALANCE_REQUIREMENT_ERROR = "UNSUPPORTED_BALANCE_REQUIREMENT_ERROR",
|
|
11839
|
-
GET_ORDER_LISTING_ERROR = "GET_ORDER_LISTING_ERROR",
|
|
11840
|
-
CANCEL_ORDER_LISTING_ERROR = "CANCEL_ORDER_LISTING_ERROR",
|
|
11841
|
-
PREPARE_ORDER_LISTING_ERROR = "PREPARE_ORDER_LISTING_ERROR",
|
|
11842
|
-
CREATE_ORDER_LISTING_ERROR = "CREATE_ORDER_LISTING_ERROR",
|
|
11843
|
-
FULFILL_ORDER_LISTING_ERROR = "FULFILL_ORDER_LISTING_ERROR",
|
|
11844
|
-
SWITCH_NETWORK_UNSUPPORTED = "SWITCH_NETWORK_UNSUPPORTED",
|
|
11845
|
-
GET_ERC20_ALLOWANCE_ERROR = "GET_ERC20_ALLOWANCE_ERROR",
|
|
11846
|
-
GET_ERC721_ALLOWANCE_ERROR = "GET_ERC721_ALLOWANCE_ERROR",
|
|
11847
|
-
EXECUTE_APPROVAL_TRANSACTION_ERROR = "EXECUTE_APPROVAL_TRANSACTION_ERROR",
|
|
11848
|
-
EXECUTE_FULFILLMENT_TRANSACTION_ERROR = "EXECUTE_FULFILLMENT_TRANSACTION_ERROR",
|
|
11849
|
-
SIGN_MESSAGE_ERROR = "SIGN_MESSAGE_ERROR",
|
|
11850
|
-
BRIDGE_GAS_ESTIMATE_ERROR = "BRIDGE_GAS_ESTIMATE_ERROR",
|
|
11851
|
-
ORDER_FEE_ERROR = "ORDER_FEE_ERROR",
|
|
11852
|
-
ITEM_REQUIREMENTS_ERROR = "ITEM_REQUIREMENTS_ERROR",
|
|
11853
|
-
API_ERROR = "API_ERROR",
|
|
11854
|
-
ORDER_EXPIRED_ERROR = "ORDER_EXPIRED_ERROR"
|
|
11975
|
+
passport?: any;
|
|
11855
11976
|
}
|
|
11856
|
-
|
|
11857
|
-
* Represents an error object with a specific type, optional message, and optional data.
|
|
11858
|
-
* @property {CheckoutErrorType} type - The type of the error.
|
|
11859
|
-
* @property {string | undefined} [message] - The error message.
|
|
11860
|
-
* @property {Object.<string, string> | undefined} [data] - Additional data associated with the error.
|
|
11861
|
-
*/
|
|
11862
|
-
type ErrorType = {
|
|
11863
|
-
type: CheckoutErrorType;
|
|
11864
|
-
message?: string;
|
|
11865
|
-
data?: {
|
|
11866
|
-
[key: string]: string;
|
|
11867
|
-
};
|
|
11868
|
-
};
|
|
11977
|
+
|
|
11869
11978
|
type RemoteConfigParams = {
|
|
11870
11979
|
isDevelopment: boolean;
|
|
11871
11980
|
isProduction: boolean;
|
|
11872
11981
|
};
|
|
11873
11982
|
declare class RemoteConfigFetcher {
|
|
11983
|
+
private isDevelopment;
|
|
11984
|
+
private isProduction;
|
|
11985
|
+
private configCache;
|
|
11986
|
+
private tokensCache;
|
|
11874
11987
|
constructor(params: RemoteConfigParams);
|
|
11988
|
+
private static makeHttpRequest;
|
|
11989
|
+
private getEndpoint;
|
|
11990
|
+
private loadConfig;
|
|
11991
|
+
private loadConfigTokens;
|
|
11875
11992
|
getConfig(key?: keyof RemoteConfiguration): Promise<RemoteConfiguration | RemoteConfiguration[keyof RemoteConfiguration] | undefined>;
|
|
11876
11993
|
getTokensConfig(chainId: ChainId): Promise<ChainTokensConfig>;
|
|
11877
11994
|
}
|
|
11995
|
+
|
|
11878
11996
|
declare class CheckoutConfiguration {
|
|
11879
11997
|
readonly isDevelopment: boolean;
|
|
11880
11998
|
readonly isProduction: boolean;
|
|
@@ -11886,9 +12004,7 @@ declare class CheckoutConfiguration {
|
|
|
11886
12004
|
readonly networkMap: NetworkMap;
|
|
11887
12005
|
constructor(config: CheckoutModuleConfiguration);
|
|
11888
12006
|
}
|
|
11889
|
-
|
|
11890
|
-
checkDexAvailability: () => Promise<boolean>;
|
|
11891
|
-
};
|
|
12007
|
+
|
|
11892
12008
|
interface FiatRampWidgetParams {
|
|
11893
12009
|
exchangeType: ExchangeType;
|
|
11894
12010
|
isPassport: boolean;
|
|
@@ -11906,16 +12022,706 @@ declare class FiatRampService {
|
|
|
11906
12022
|
constructor(config: CheckoutConfiguration);
|
|
11907
12023
|
feeEstimate(): Promise<OnRampProviderFees>;
|
|
11908
12024
|
createWidgetUrl(params: FiatRampWidgetParams): Promise<string>;
|
|
12025
|
+
private getTransakWidgetUrl;
|
|
12026
|
+
}
|
|
12027
|
+
|
|
12028
|
+
type AvailabilityService = {
|
|
12029
|
+
checkDexAvailability: () => Promise<boolean>;
|
|
12030
|
+
};
|
|
12031
|
+
|
|
12032
|
+
/**
|
|
12033
|
+
* Enum representing the themes for the widgets.
|
|
12034
|
+
*/
|
|
12035
|
+
declare enum WidgetTheme {
|
|
12036
|
+
LIGHT = "light",
|
|
12037
|
+
DARK = "dark"
|
|
11909
12038
|
}
|
|
12039
|
+
|
|
12040
|
+
/**
|
|
12041
|
+
* Widget Configuration represents the shared configuration options for the Checkout Widgets.
|
|
12042
|
+
* @property {WidgetTheme | undefined} theme
|
|
12043
|
+
*/
|
|
12044
|
+
type WidgetConfiguration = {
|
|
12045
|
+
/** The theme of the Checkout Widget (default: "DARK") */
|
|
12046
|
+
theme?: WidgetTheme;
|
|
12047
|
+
};
|
|
12048
|
+
|
|
12049
|
+
/**
|
|
12050
|
+
* Enum representing the events emitted by the widgets.
|
|
12051
|
+
*/
|
|
12052
|
+
declare enum IMTBLWidgetEvents {
|
|
12053
|
+
IMTBL_WIDGETS_PROVIDER = "imtbl-widgets-provider",
|
|
12054
|
+
IMTBL_CONNECT_WIDGET_EVENT = "imtbl-connect-widget",
|
|
12055
|
+
IMTBL_WALLET_WIDGET_EVENT = "imtbl-wallet-widget",
|
|
12056
|
+
IMTBL_SWAP_WIDGET_EVENT = "imtbl-swap-widget",
|
|
12057
|
+
IMTBL_BRIDGE_WIDGET_EVENT = "imtbl-bridge-widget",
|
|
12058
|
+
IMTBL_ONRAMP_WIDGET_EVENT = "imtbl-onramp-widget",
|
|
12059
|
+
IMTBL_SALE_WIDGET_EVENT = "imtbl-sale-widget"
|
|
12060
|
+
}
|
|
12061
|
+
/**
|
|
12062
|
+
* Enum for events raised for about provider objects
|
|
12063
|
+
*/
|
|
12064
|
+
declare enum ProviderEventType {
|
|
12065
|
+
PROVIDER_UPDATED = "PROVIDER_UPDATED"
|
|
12066
|
+
}
|
|
12067
|
+
/**
|
|
12068
|
+
* Payload type for the PROVIDER_UPDATED event
|
|
12069
|
+
*/
|
|
12070
|
+
type ProviderUpdated = {
|
|
12071
|
+
provider: Web3Provider;
|
|
12072
|
+
};
|
|
12073
|
+
|
|
12074
|
+
/**
|
|
12075
|
+
* Enum representing possible Connect Widget event types.
|
|
12076
|
+
*/
|
|
12077
|
+
declare enum ConnectEventType {
|
|
12078
|
+
CLOSE_WIDGET = "close-widget",
|
|
12079
|
+
SUCCESS = "success",
|
|
12080
|
+
FAILURE = "failure"
|
|
12081
|
+
}
|
|
12082
|
+
/**
|
|
12083
|
+
* Represents a successful connection.
|
|
12084
|
+
* @property {Web3Provider} provider
|
|
12085
|
+
* @property {WalletProviderName | undefined} walletProviderName
|
|
12086
|
+
*/
|
|
12087
|
+
type ConnectionSuccess = {
|
|
12088
|
+
/** The connected provider. */
|
|
12089
|
+
provider: Web3Provider;
|
|
12090
|
+
/** The wallet provider name of the connected provider. */
|
|
12091
|
+
walletProviderName: WalletProviderName | undefined;
|
|
12092
|
+
};
|
|
12093
|
+
/**
|
|
12094
|
+
* Represents a connection failure with a reason.
|
|
12095
|
+
* @property {string} reason
|
|
12096
|
+
*/
|
|
12097
|
+
type ConnectionFailed = {
|
|
12098
|
+
/** The reason for the failed connection. */
|
|
12099
|
+
reason: string;
|
|
12100
|
+
};
|
|
12101
|
+
|
|
12102
|
+
/**
|
|
12103
|
+
* Enum representing possible Wallet Widget event types.
|
|
12104
|
+
*/
|
|
12105
|
+
declare enum WalletEventType {
|
|
12106
|
+
CLOSE_WIDGET = "close-widget",
|
|
12107
|
+
NETWORK_SWITCH = "network-switch",
|
|
12108
|
+
DISCONNECT_WALLET = "disconnect-wallet"
|
|
12109
|
+
}
|
|
12110
|
+
/**
|
|
12111
|
+
* Represents an event that is triggered when the user switches the network in their wallet.
|
|
12112
|
+
* @property {string} network
|
|
12113
|
+
* @property {number} chainId
|
|
12114
|
+
* @property {Web3Provider} provider
|
|
12115
|
+
*/
|
|
12116
|
+
type WalletNetworkSwitch = {
|
|
12117
|
+
/** The name of the network that the user switched to. */
|
|
12118
|
+
network: string;
|
|
12119
|
+
/** The chain ID of the network that the user switched to. */
|
|
12120
|
+
chainId: number;
|
|
12121
|
+
/** The Web3 provider object for the switched network. */
|
|
12122
|
+
provider: Web3Provider;
|
|
12123
|
+
};
|
|
12124
|
+
/**
|
|
12125
|
+
* Represents an event that is triggered when a wallet is disconnected.
|
|
12126
|
+
*/
|
|
12127
|
+
type WalletDisconnect = {};
|
|
12128
|
+
|
|
12129
|
+
/**
|
|
12130
|
+
* Enum representing possible Swap Widget event types.
|
|
12131
|
+
*/
|
|
12132
|
+
declare enum SwapEventType {
|
|
12133
|
+
CLOSE_WIDGET = "close-widget",
|
|
12134
|
+
SUCCESS = "success",
|
|
12135
|
+
FAILURE = "failure",
|
|
12136
|
+
REJECTED = "rejected"
|
|
12137
|
+
}
|
|
12138
|
+
/**
|
|
12139
|
+
* Represents a successful swap transaction.
|
|
12140
|
+
* @property {string} transactionHash
|
|
12141
|
+
*/
|
|
12142
|
+
type SwapSuccess = {
|
|
12143
|
+
/** The hash of the successful transaction. */
|
|
12144
|
+
transactionHash: string;
|
|
12145
|
+
};
|
|
12146
|
+
/**
|
|
12147
|
+
* Type representing a Swap Widget with type FAILURE.
|
|
12148
|
+
* @property {string} reason
|
|
12149
|
+
* @property {number} timestamp
|
|
12150
|
+
*/
|
|
12151
|
+
type SwapFailed = {
|
|
12152
|
+
/** The reason why the swap failed. */
|
|
12153
|
+
reason: string;
|
|
12154
|
+
/** The timestamp of the failed swap. */
|
|
12155
|
+
timestamp: number;
|
|
12156
|
+
};
|
|
12157
|
+
/**
|
|
12158
|
+
* Type representing a Swap Widget with type REJECTED.
|
|
12159
|
+
* @property {string} reason -
|
|
12160
|
+
* @property {number} timestamp -
|
|
12161
|
+
*/
|
|
12162
|
+
type SwapRejected = {
|
|
12163
|
+
/** The reason why the swap failed. */
|
|
12164
|
+
reason: string;
|
|
12165
|
+
/** The timestamp of the failed swap. */
|
|
12166
|
+
timestamp: number;
|
|
12167
|
+
};
|
|
12168
|
+
|
|
12169
|
+
/**
|
|
12170
|
+
* Enum representing possible Sale Widget event types.
|
|
12171
|
+
*/
|
|
12172
|
+
declare enum SaleEventType {
|
|
12173
|
+
CLOSE_WIDGET = "close-widget",
|
|
12174
|
+
SUCCESS = "success",
|
|
12175
|
+
FAILURE = "failure",
|
|
12176
|
+
REJECTED = "rejected",
|
|
12177
|
+
TRANSACTION_SUCCESS = "transaction-success"
|
|
12178
|
+
}
|
|
12179
|
+
/**
|
|
12180
|
+
* Represents a successful Sale transaction.
|
|
12181
|
+
* @property {Array} transactions -
|
|
12182
|
+
*/
|
|
12183
|
+
type SaleSuccess = {
|
|
12184
|
+
/** The executed transactions */
|
|
12185
|
+
transactions: {
|
|
12186
|
+
method: string;
|
|
12187
|
+
hash: string | undefined;
|
|
12188
|
+
}[];
|
|
12189
|
+
[key: string]: unknown;
|
|
12190
|
+
};
|
|
12191
|
+
/**
|
|
12192
|
+
* Type representing a Sale Widget with type FAILURE.
|
|
12193
|
+
* @property {string} reason
|
|
12194
|
+
* @property {number} timestamp
|
|
12195
|
+
* @property {Array} transactions
|
|
12196
|
+
*/
|
|
12197
|
+
type SaleFailed = {
|
|
12198
|
+
/** The reason why the swap failed. */
|
|
12199
|
+
reason: string;
|
|
12200
|
+
/** The timestamp of the failed swap. */
|
|
12201
|
+
timestamp: number;
|
|
12202
|
+
/** The executed transactions */
|
|
12203
|
+
transactions: {
|
|
12204
|
+
method: string;
|
|
12205
|
+
hash: string | undefined;
|
|
12206
|
+
}[];
|
|
12207
|
+
};
|
|
12208
|
+
/**
|
|
12209
|
+
* Type representing a Sale Widget with type TRANSACTION_SUCCESS.
|
|
12210
|
+
* @property {Object} transactions
|
|
12211
|
+
*/
|
|
12212
|
+
type SaleTransactionSuccess = {
|
|
12213
|
+
/** The executed transactions */
|
|
12214
|
+
transactions: {
|
|
12215
|
+
method: string;
|
|
12216
|
+
hash: string | undefined;
|
|
12217
|
+
}[];
|
|
12218
|
+
};
|
|
12219
|
+
|
|
12220
|
+
/**
|
|
12221
|
+
* Enum of possible Bridge Widget event types.
|
|
12222
|
+
*/
|
|
12223
|
+
declare enum BridgeEventType {
|
|
12224
|
+
CLOSE_WIDGET = "close-widget",
|
|
12225
|
+
SUCCESS = "success",
|
|
12226
|
+
FAILURE = "failure"
|
|
12227
|
+
}
|
|
12228
|
+
/**
|
|
12229
|
+
* Represents a successful bridge transaction.
|
|
12230
|
+
* @property {string} transactionHash
|
|
12231
|
+
*/
|
|
12232
|
+
type BridgeSuccess = {
|
|
12233
|
+
/** The hash of the successful transaction. */
|
|
12234
|
+
transactionHash: string;
|
|
12235
|
+
};
|
|
12236
|
+
/**
|
|
12237
|
+
* Represents a failed bridge transaction.
|
|
12238
|
+
* @property {string} reason
|
|
12239
|
+
* @property {number} timestamp
|
|
12240
|
+
*/
|
|
12241
|
+
type BridgeFailed = {
|
|
12242
|
+
/** The reason for the failed transaction. */
|
|
12243
|
+
reason: string;
|
|
12244
|
+
/** The timestamp of the failed transaction. */
|
|
12245
|
+
timestamp: number;
|
|
12246
|
+
};
|
|
12247
|
+
|
|
12248
|
+
/**
|
|
12249
|
+
* Enum representing different types of orchestration events.
|
|
12250
|
+
*/
|
|
12251
|
+
declare enum OrchestrationEventType {
|
|
12252
|
+
REQUEST_CONNECT = "request-connect",
|
|
12253
|
+
REQUEST_WALLET = "request-wallet",
|
|
12254
|
+
REQUEST_SWAP = "request-swap",
|
|
12255
|
+
REQUEST_BRIDGE = "request-bridge",
|
|
12256
|
+
REQUEST_ONRAMP = "request-onramp"
|
|
12257
|
+
}
|
|
12258
|
+
/**
|
|
12259
|
+
* Represents the connect event object when the connect widget is requested.
|
|
12260
|
+
* @property {string} walletProviderName
|
|
12261
|
+
*/
|
|
12262
|
+
type RequestConnectEvent = {
|
|
12263
|
+
/** The wallet provider name. */
|
|
12264
|
+
walletProviderName: string;
|
|
12265
|
+
};
|
|
12266
|
+
/**
|
|
12267
|
+
* Represents the wallet event object when the wallet widget is requested.
|
|
12268
|
+
* @property {string} walletProviderName
|
|
12269
|
+
*/
|
|
12270
|
+
type RequestWalletEvent = {
|
|
12271
|
+
/** The wallet provider name. */
|
|
12272
|
+
walletProviderName: string;
|
|
12273
|
+
};
|
|
12274
|
+
/**
|
|
12275
|
+
* Represents the swap event object when the swap widget is requested.
|
|
12276
|
+
* @property {string} fromTokenAddress
|
|
12277
|
+
* @property {string} toTokenAddress
|
|
12278
|
+
* @property {string} amount
|
|
12279
|
+
*/
|
|
12280
|
+
type RequestSwapEvent = {
|
|
12281
|
+
/** The address of the token to swap from. */
|
|
12282
|
+
fromTokenAddress: string;
|
|
12283
|
+
/** The address of the token to swap to. */
|
|
12284
|
+
toTokenAddress: string;
|
|
12285
|
+
/** The amount of from tokens to swap. */
|
|
12286
|
+
amount: string;
|
|
12287
|
+
};
|
|
12288
|
+
/**
|
|
12289
|
+
* Represents the bridge event object when the bridge widget is requested.
|
|
12290
|
+
* @property {string} tokenAddress
|
|
12291
|
+
* @property {string} amount
|
|
12292
|
+
*/
|
|
12293
|
+
type RequestBridgeEvent = {
|
|
12294
|
+
/** The address of the token to bridge. */
|
|
12295
|
+
tokenAddress: string;
|
|
12296
|
+
/** The amount of tokens to bridge. */
|
|
12297
|
+
amount: string;
|
|
12298
|
+
};
|
|
12299
|
+
/**
|
|
12300
|
+
* Represents the onramp event object when the onramp widget is requested.
|
|
12301
|
+
* @property {string} tokenAddress
|
|
12302
|
+
* @property {string} amount
|
|
12303
|
+
*/
|
|
12304
|
+
type RequestOnrampEvent = {
|
|
12305
|
+
/** The address of the token to be used for onramp. */
|
|
12306
|
+
tokenAddress: string;
|
|
12307
|
+
/** The amount of tokens to onramp. */
|
|
12308
|
+
amount: string;
|
|
12309
|
+
};
|
|
12310
|
+
type OrchestrationEventData = RequestConnectEvent | RequestWalletEvent | RequestSwapEvent | RequestBridgeEvent | RequestOnrampEvent;
|
|
12311
|
+
|
|
12312
|
+
/**
|
|
12313
|
+
* Enum of possible OnRamp Widget event types.
|
|
12314
|
+
*/
|
|
12315
|
+
declare enum OnRampEventType {
|
|
12316
|
+
CLOSE_WIDGET = "close-widget",
|
|
12317
|
+
SUCCESS = "success",
|
|
12318
|
+
FAILURE = "failure"
|
|
12319
|
+
}
|
|
12320
|
+
/**
|
|
12321
|
+
* Represents a successful on-ramp transaction.
|
|
12322
|
+
* @property {string} transactionHash
|
|
12323
|
+
*/
|
|
12324
|
+
type OnRampSuccess = {
|
|
12325
|
+
/** The transaction hash of the successful transaction. */
|
|
12326
|
+
transactionHash: string;
|
|
12327
|
+
};
|
|
12328
|
+
/**
|
|
12329
|
+
* Type representing a On-ramp Widget with type FAILURE.
|
|
12330
|
+
* @property {string} reason
|
|
12331
|
+
* @property {number} timestamp
|
|
12332
|
+
*/
|
|
12333
|
+
type OnRampFailed = {
|
|
12334
|
+
/** The reason why the on-ramp failed. */
|
|
12335
|
+
reason: string;
|
|
12336
|
+
/** The timestamp of the failed transaction. */
|
|
12337
|
+
timestamp: number;
|
|
12338
|
+
};
|
|
12339
|
+
|
|
12340
|
+
declare enum ConnectTargetLayer {
|
|
12341
|
+
LAYER1 = "LAYER1",
|
|
12342
|
+
LAYER2 = "LAYER2"
|
|
12343
|
+
}
|
|
12344
|
+
type ConnectWidgetParams = {};
|
|
12345
|
+
|
|
12346
|
+
/**
|
|
12347
|
+
* Bridge Widget parameters
|
|
12348
|
+
* @property {string | undefined} fromContractAddress
|
|
12349
|
+
* @property {string | undefined} amount
|
|
12350
|
+
* @property {WalletProviderName | undefined} walletProviderName
|
|
12351
|
+
*/
|
|
12352
|
+
type BridgeWidgetParams = {
|
|
12353
|
+
/** The contract address of the token to bridge from, used to populate the bridge form token field */
|
|
12354
|
+
fromContractAddress?: string;
|
|
12355
|
+
/** The formatted amount to bridge, used to populate the bridge form amount field */
|
|
12356
|
+
amount?: string;
|
|
12357
|
+
/** The wallet provider name to use for the bridge widget */
|
|
12358
|
+
walletProviderName?: WalletProviderName;
|
|
12359
|
+
};
|
|
12360
|
+
|
|
12361
|
+
/**
|
|
12362
|
+
* Wallet Widget parameters
|
|
12363
|
+
* @property {WalletProviderName | undefined} walletProviderName
|
|
12364
|
+
*/
|
|
12365
|
+
type WalletWidgetParams = {
|
|
12366
|
+
/** The wallet provider name to use for the wallet widget */
|
|
12367
|
+
walletProviderName?: WalletProviderName;
|
|
12368
|
+
};
|
|
12369
|
+
|
|
12370
|
+
/**
|
|
12371
|
+
* Swap Widget parameters
|
|
12372
|
+
* @property {string | undefined} amount
|
|
12373
|
+
* @property {string | undefined} fromContractAddress
|
|
12374
|
+
* @property {string | undefined} toContractAddress
|
|
12375
|
+
* @property {WalletProviderName | undefined} walletProviderName
|
|
12376
|
+
*/
|
|
12377
|
+
type SwapWidgetParams = {
|
|
12378
|
+
/** The formatted amount to swap, used to populate the swap from amount field */
|
|
12379
|
+
amount?: string;
|
|
12380
|
+
/** The contract address of the token to swap from */
|
|
12381
|
+
fromContractAddress?: string;
|
|
12382
|
+
/** The contract address of the token to swap to */
|
|
12383
|
+
toContractAddress?: string;
|
|
12384
|
+
/** The wallet provider name to use for the swap widget */
|
|
12385
|
+
walletProviderName?: WalletProviderName;
|
|
12386
|
+
};
|
|
12387
|
+
|
|
12388
|
+
/**
|
|
12389
|
+
* OnRamp Widget parameters
|
|
12390
|
+
* @property {string | undefined} contractAddress
|
|
12391
|
+
* @property {string | undefined} amount
|
|
12392
|
+
* @property {WalletProviderName | undefined} walletProviderName
|
|
12393
|
+
*/
|
|
12394
|
+
type OnRampWidgetParams = {
|
|
12395
|
+
/** The contract address of the token to onramp */
|
|
12396
|
+
contractAddress?: string;
|
|
12397
|
+
/** The formatted amount to onramp, used to populate the onramp form amount field */
|
|
12398
|
+
amount?: string;
|
|
12399
|
+
/** The wallet provider name to use for the onramp widget */
|
|
12400
|
+
walletProviderName?: WalletProviderName;
|
|
12401
|
+
};
|
|
12402
|
+
|
|
12403
|
+
/**
|
|
12404
|
+
* Sale Widget parameters
|
|
12405
|
+
* @property {string} amount
|
|
12406
|
+
* @property {string} environmentId
|
|
12407
|
+
* @property {string} fromContractAddress
|
|
12408
|
+
* @property {SaleItem[]} items
|
|
12409
|
+
* @property {WalletProviderName | undefined} walletProviderName
|
|
12410
|
+
*/
|
|
12411
|
+
type SaleWidgetParams = {
|
|
12412
|
+
/** The total price to pay for the items in the sale */
|
|
12413
|
+
amount?: string;
|
|
12414
|
+
environmentId?: string;
|
|
12415
|
+
fromContractAddress?: string;
|
|
12416
|
+
/** The list of products to be purchased */
|
|
12417
|
+
items?: SaleItem[];
|
|
12418
|
+
/** The wallet provider name to default to if no web3Provider is passed */
|
|
12419
|
+
walletProviderName?: WalletProviderName;
|
|
12420
|
+
};
|
|
12421
|
+
/**
|
|
12422
|
+
* A product to be purchased
|
|
12423
|
+
* @property {string} productId
|
|
12424
|
+
* @property {number} qty
|
|
12425
|
+
* @property {string} name
|
|
12426
|
+
* @property {string} image
|
|
12427
|
+
* @property {string} description
|
|
12428
|
+
*/
|
|
12429
|
+
type SaleItem = {
|
|
12430
|
+
/** The id of the product */
|
|
12431
|
+
productId: string;
|
|
12432
|
+
/** The quantity to be purchased */
|
|
12433
|
+
qty: number;
|
|
12434
|
+
/** The name of the item */
|
|
12435
|
+
name: string;
|
|
12436
|
+
/** The image url of the item */
|
|
12437
|
+
image: string;
|
|
12438
|
+
/** The description of the item */
|
|
12439
|
+
description: string;
|
|
12440
|
+
};
|
|
12441
|
+
|
|
12442
|
+
/**
|
|
12443
|
+
* Connect Widget Configuration represents the configuration options for the Connect Widget.
|
|
12444
|
+
*/
|
|
12445
|
+
type ConnectWidgetConfiguration = {} & WidgetConfiguration;
|
|
12446
|
+
|
|
12447
|
+
/**
|
|
12448
|
+
* Bridge Widget Configuration represents the configuration options for the Bridge Widget.
|
|
12449
|
+
*/
|
|
12450
|
+
type BridgeWidgetConfiguration = {} & WidgetConfiguration;
|
|
12451
|
+
|
|
12452
|
+
/**
|
|
12453
|
+
* Wallet Widget Configuration represents the configuration options for the Wallet Widget.
|
|
12454
|
+
*/
|
|
12455
|
+
type WalletWidgetConfiguration = {} & WidgetConfiguration;
|
|
12456
|
+
|
|
12457
|
+
/**
|
|
12458
|
+
* Swap Widget Configuration represents the configuration options for the Swap Widget.
|
|
12459
|
+
*/
|
|
12460
|
+
type SwapWidgetConfiguration = {} & WidgetConfiguration;
|
|
12461
|
+
|
|
12462
|
+
/**
|
|
12463
|
+
* Onramp Widget Configuration represents the configuration options for the Onramp Widget.
|
|
12464
|
+
*/
|
|
12465
|
+
type OnrampWidgetConfiguration = {} & WidgetConfiguration;
|
|
12466
|
+
|
|
12467
|
+
/**
|
|
12468
|
+
* Sale Widget Configuration represents the configuration options for the Sale Widget.
|
|
12469
|
+
*/
|
|
12470
|
+
type SaleWidgetConfiguration = {} & WidgetConfiguration;
|
|
12471
|
+
|
|
12472
|
+
/**
|
|
12473
|
+
* Enum representing the list of widget types.
|
|
12474
|
+
*/
|
|
12475
|
+
declare enum WidgetType {
|
|
12476
|
+
CONNECT = "connect",
|
|
12477
|
+
WALLET = "wallet",
|
|
12478
|
+
SWAP = "swap",
|
|
12479
|
+
BRIDGE = "bridge",
|
|
12480
|
+
ONRAMP = "onramp",
|
|
12481
|
+
SALE = "sale"
|
|
12482
|
+
}
|
|
12483
|
+
/**
|
|
12484
|
+
* Widget properties definition for each widget. Used for creating and updating widgets
|
|
12485
|
+
*/
|
|
12486
|
+
type WidgetProperties<T extends WidgetType> = {
|
|
12487
|
+
config?: WidgetConfigurations[T];
|
|
12488
|
+
provider?: Web3Provider;
|
|
12489
|
+
};
|
|
12490
|
+
type WidgetConfigurations = {
|
|
12491
|
+
[WidgetType.CONNECT]: ConnectWidgetConfiguration;
|
|
12492
|
+
[WidgetType.WALLET]: WalletWidgetConfiguration;
|
|
12493
|
+
[WidgetType.SWAP]: SwapWidgetConfiguration;
|
|
12494
|
+
[WidgetType.BRIDGE]: BridgeWidgetConfiguration;
|
|
12495
|
+
[WidgetType.ONRAMP]: OnrampWidgetConfiguration;
|
|
12496
|
+
[WidgetType.SALE]: SaleWidgetConfiguration;
|
|
12497
|
+
};
|
|
12498
|
+
type WidgetParameters = {
|
|
12499
|
+
[WidgetType.CONNECT]: ConnectWidgetParams;
|
|
12500
|
+
[WidgetType.WALLET]: WalletWidgetParams;
|
|
12501
|
+
[WidgetType.SWAP]: SwapWidgetParams;
|
|
12502
|
+
[WidgetType.BRIDGE]: BridgeWidgetParams;
|
|
12503
|
+
[WidgetType.ONRAMP]: OnRampWidgetParams;
|
|
12504
|
+
[WidgetType.SALE]: SaleWidgetParams;
|
|
12505
|
+
};
|
|
12506
|
+
/**
|
|
12507
|
+
* Represents all the possible event types that are emitted by the widgets.
|
|
12508
|
+
*/
|
|
12509
|
+
type WidgetEventTypes = {
|
|
12510
|
+
[WidgetType.CONNECT]: ConnectEventType | OrchestrationEventType;
|
|
12511
|
+
[WidgetType.WALLET]: WalletEventType | OrchestrationEventType;
|
|
12512
|
+
[WidgetType.SWAP]: SwapEventType | OrchestrationEventType;
|
|
12513
|
+
[WidgetType.BRIDGE]: BridgeEventType | OrchestrationEventType;
|
|
12514
|
+
[WidgetType.ONRAMP]: OnRampEventType | OrchestrationEventType;
|
|
12515
|
+
[WidgetType.SALE]: SaleEventType | OrchestrationEventType;
|
|
12516
|
+
};
|
|
12517
|
+
type OrchestrationMapping = {
|
|
12518
|
+
[OrchestrationEventType.REQUEST_CONNECT]: RequestConnectEvent;
|
|
12519
|
+
[OrchestrationEventType.REQUEST_WALLET]: RequestWalletEvent;
|
|
12520
|
+
[OrchestrationEventType.REQUEST_SWAP]: RequestSwapEvent;
|
|
12521
|
+
[OrchestrationEventType.REQUEST_BRIDGE]: RequestBridgeEvent;
|
|
12522
|
+
[OrchestrationEventType.REQUEST_ONRAMP]: RequestOnrampEvent;
|
|
12523
|
+
};
|
|
12524
|
+
type ProviderEventMapping = {
|
|
12525
|
+
[ProviderEventType.PROVIDER_UPDATED]: ProviderUpdated;
|
|
12526
|
+
};
|
|
12527
|
+
/**
|
|
12528
|
+
* Mapping of widget type, to each of it's events and then each event's payload
|
|
12529
|
+
* Update this whenever a new event is created and used by a widget
|
|
12530
|
+
* Each widget also has all of the orchestration events
|
|
12531
|
+
*/
|
|
12532
|
+
type WidgetEventData = {
|
|
12533
|
+
[WidgetType.CONNECT]: {
|
|
12534
|
+
[ConnectEventType.SUCCESS]: ConnectionSuccess;
|
|
12535
|
+
[ConnectEventType.FAILURE]: ConnectionFailed;
|
|
12536
|
+
[ConnectEventType.CLOSE_WIDGET]: {};
|
|
12537
|
+
} & OrchestrationMapping & ProviderEventMapping;
|
|
12538
|
+
[WidgetType.WALLET]: {
|
|
12539
|
+
[WalletEventType.NETWORK_SWITCH]: WalletNetworkSwitch;
|
|
12540
|
+
[WalletEventType.DISCONNECT_WALLET]: WalletDisconnect;
|
|
12541
|
+
[WalletEventType.CLOSE_WIDGET]: {};
|
|
12542
|
+
} & OrchestrationMapping & ProviderEventMapping;
|
|
12543
|
+
[WidgetType.SWAP]: {
|
|
12544
|
+
[SwapEventType.SUCCESS]: SwapSuccess;
|
|
12545
|
+
[SwapEventType.FAILURE]: SwapFailed;
|
|
12546
|
+
[SwapEventType.REJECTED]: SwapRejected;
|
|
12547
|
+
[SwapEventType.CLOSE_WIDGET]: {};
|
|
12548
|
+
} & OrchestrationMapping & ProviderEventMapping;
|
|
12549
|
+
[WidgetType.BRIDGE]: {
|
|
12550
|
+
[BridgeEventType.SUCCESS]: BridgeSuccess;
|
|
12551
|
+
[BridgeEventType.FAILURE]: BridgeFailed;
|
|
12552
|
+
[BridgeEventType.CLOSE_WIDGET]: {};
|
|
12553
|
+
} & OrchestrationMapping & ProviderEventMapping;
|
|
12554
|
+
[WidgetType.ONRAMP]: {
|
|
12555
|
+
[OnRampEventType.SUCCESS]: OnRampSuccess;
|
|
12556
|
+
[OnRampEventType.FAILURE]: OnRampFailed;
|
|
12557
|
+
[OnRampEventType.CLOSE_WIDGET]: {};
|
|
12558
|
+
} & OrchestrationMapping & ProviderEventMapping;
|
|
12559
|
+
[WidgetType.SALE]: {
|
|
12560
|
+
[SaleEventType.SUCCESS]: SaleSuccess;
|
|
12561
|
+
[SaleEventType.FAILURE]: SaleFailed;
|
|
12562
|
+
[SaleEventType.REJECTED]: any;
|
|
12563
|
+
[SaleEventType.CLOSE_WIDGET]: {};
|
|
12564
|
+
[SaleEventType.TRANSACTION_SUCCESS]: SaleTransactionSuccess;
|
|
12565
|
+
} & OrchestrationMapping & ProviderEventMapping;
|
|
12566
|
+
};
|
|
12567
|
+
/**
|
|
12568
|
+
* Represents an event emitted by a widget. The event type should match the event data
|
|
12569
|
+
*/
|
|
12570
|
+
/**
|
|
12571
|
+
* Represents an event emitted by a widget.
|
|
12572
|
+
* @template T - The widget type
|
|
12573
|
+
* @template KEventName - The widget event name.
|
|
12574
|
+
* @property {KEventName} type - The type of the event.
|
|
12575
|
+
* @property {WidgetEventData[T][KEventName]} data - The data associated with the widget event.
|
|
12576
|
+
*/
|
|
12577
|
+
type WidgetEvent<T extends WidgetType, KEventName extends keyof WidgetEventData[T]> = {
|
|
12578
|
+
type: KEventName;
|
|
12579
|
+
data: WidgetEventData[T][KEventName];
|
|
12580
|
+
};
|
|
12581
|
+
/**
|
|
12582
|
+
* Represents an event emitted by a widget.
|
|
12583
|
+
* @template KEventName - The orchestration event name.
|
|
12584
|
+
* @property {KEventName} type
|
|
12585
|
+
* @property {OrchestrationMapping[KEventName]} data
|
|
12586
|
+
*/
|
|
12587
|
+
type OrchestrationEvent<KEventName extends keyof OrchestrationMapping> = {
|
|
12588
|
+
/** The type of the event. */
|
|
12589
|
+
type: KEventName;
|
|
12590
|
+
/** The data associated with the event. */
|
|
12591
|
+
data: OrchestrationMapping[KEventName];
|
|
12592
|
+
};
|
|
12593
|
+
/**
|
|
12594
|
+
* Represents an event emitted by a widget.
|
|
12595
|
+
* @template KEventName - The provider event name.
|
|
12596
|
+
* @property {KEventName} type
|
|
12597
|
+
* @property {ProviderEventMapping[KEventName]} data
|
|
12598
|
+
*/
|
|
12599
|
+
type ProviderEvent<KEventName extends keyof ProviderEventMapping> = {
|
|
12600
|
+
/** The type of the event. */
|
|
12601
|
+
type: KEventName;
|
|
12602
|
+
/** The data associated with the event. */
|
|
12603
|
+
data: ProviderEventMapping[KEventName];
|
|
12604
|
+
};
|
|
12605
|
+
interface IWidgetsFactory {
|
|
12606
|
+
/**
|
|
12607
|
+
* Create a new widget instance.
|
|
12608
|
+
* @param type widget type to instantiate.
|
|
12609
|
+
* @param props widget configurations and provider.
|
|
12610
|
+
*/
|
|
12611
|
+
create<T extends WidgetType>(type: T, props?: WidgetProperties<T>): Widget<T>;
|
|
12612
|
+
/**
|
|
12613
|
+
* Update the widgets provider instance.
|
|
12614
|
+
* @param provider the provider instance to update all widgets.
|
|
12615
|
+
*/
|
|
12616
|
+
updateProvider(provider: Web3Provider): void;
|
|
12617
|
+
}
|
|
12618
|
+
/**
|
|
12619
|
+
* Widget interface. Every widget implements this interface.
|
|
12620
|
+
*/
|
|
12621
|
+
interface Widget<T extends WidgetType> {
|
|
12622
|
+
/**
|
|
12623
|
+
* Mount a widget to a DOM ref element.
|
|
12624
|
+
* @param id ID of the DOM element where the widget will be mounted.
|
|
12625
|
+
* @param params widget parameters.
|
|
12626
|
+
*/
|
|
12627
|
+
mount(id: string, params?: WidgetParameters[T]): void;
|
|
12628
|
+
/**
|
|
12629
|
+
* Unmount a widget and reset parameters
|
|
12630
|
+
*/
|
|
12631
|
+
unmount(): void;
|
|
12632
|
+
/**
|
|
12633
|
+
* Update the widget properties
|
|
12634
|
+
* @param props Widget specific properties including configuration
|
|
12635
|
+
*/
|
|
12636
|
+
update(props: WidgetProperties<T>): void;
|
|
12637
|
+
/**
|
|
12638
|
+
* Add a listener for a widget event.
|
|
12639
|
+
* @param event Widget specific event name.
|
|
12640
|
+
* @param callback function to execute when the event is received.
|
|
12641
|
+
*/
|
|
12642
|
+
addListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName, callback: (data: WidgetEventData[T][KEventName]) => void): void;
|
|
12643
|
+
/**
|
|
12644
|
+
* Removes an event listener for a widget event.
|
|
12645
|
+
* @param type Widget specific event name.
|
|
12646
|
+
*/
|
|
12647
|
+
removeListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName): void;
|
|
12648
|
+
}
|
|
12649
|
+
/**
|
|
12650
|
+
* Represents the version of the Checkout Widgets to use defaults to (0.1.9-alpha)
|
|
12651
|
+
* @property {number} major
|
|
12652
|
+
* @property {number | undefined} minor
|
|
12653
|
+
* @property {number | undefined} patch
|
|
12654
|
+
* @property {'alpha' | undefined} prerelease
|
|
12655
|
+
* @property {number | undefined} build
|
|
12656
|
+
*
|
|
12657
|
+
* @example
|
|
12658
|
+
* { major: 0 } - use default version 0.1.9-alpha
|
|
12659
|
+
* { major: 1 } - use version 1.x.x, pickup all new minor and patch versions released
|
|
12660
|
+
* { major: 1, minor: 1 } - use version 1.1.x, pickup all new patch versions released
|
|
12661
|
+
* { major: 1, minor: 2, patch: 3 } - use version 1.2.3 specifically
|
|
12662
|
+
*/
|
|
12663
|
+
type SemanticVersion = {
|
|
12664
|
+
/** The major version of the widgets, must specify a major version even if it is 0. */
|
|
12665
|
+
major: number;
|
|
12666
|
+
/** The minor version of the widgets, leaving this blank will use the latest minor based on major */
|
|
12667
|
+
minor?: number;
|
|
12668
|
+
/** The patch version of the widgets, leaving this blank will use the latest minor based on minor */
|
|
12669
|
+
patch?: number;
|
|
12670
|
+
/** The prerelease version of the widgets, can only be 'alpha'. Do not use in production. */
|
|
12671
|
+
prerelease?: 'alpha';
|
|
12672
|
+
/** The build version of the widgets. Do not use in production. */
|
|
12673
|
+
build?: number;
|
|
12674
|
+
};
|
|
12675
|
+
/**
|
|
12676
|
+
* Represents the global configuration options for the Checkout Widgets.
|
|
12677
|
+
* @property {WidgetTheme | undefined} theme
|
|
12678
|
+
* @property {Environment | undefined} environment
|
|
12679
|
+
* @property {SemanticVersion | undefined} version
|
|
12680
|
+
* @property {boolean | undefined} isOnRampEnabled
|
|
12681
|
+
* @property {boolean | undefined} isSwapEnabled
|
|
12682
|
+
* @property {boolean | undefined} isBridgeEnabled
|
|
12683
|
+
*/
|
|
12684
|
+
type CheckoutWidgetsConfig = {
|
|
12685
|
+
/** The theme of the Checkout Widget (default: "DARK") */
|
|
12686
|
+
theme?: WidgetTheme;
|
|
12687
|
+
/** The environment configuration (default: "SANDBOX") */
|
|
12688
|
+
environment?: Environment;
|
|
12689
|
+
/** The version of the checkout widgets js file to use (default: "0.1.x") */
|
|
12690
|
+
version?: SemanticVersion;
|
|
12691
|
+
/** Enable on-ramp top-up method (default: "true") */
|
|
12692
|
+
isOnRampEnabled?: boolean;
|
|
12693
|
+
/** Enable swap top-up method (default: "true") */
|
|
12694
|
+
isSwapEnabled?: boolean;
|
|
12695
|
+
/** Enable bridge top-up method (default: "true") */
|
|
12696
|
+
isBridgeEnabled?: boolean;
|
|
12697
|
+
};
|
|
12698
|
+
|
|
12699
|
+
/**
|
|
12700
|
+
* Represents the configuration options for instantiating the Checkout Widgets factory.
|
|
12701
|
+
* @property {WidgetConfiguration} config - global configuration options for the widgets.
|
|
12702
|
+
* @property {SemanticVersion | undefined} version - version of the Checkout widgets bundle (default latest version will be used).
|
|
12703
|
+
*/
|
|
12704
|
+
type WidgetsInit = {
|
|
12705
|
+
config: WidgetConfiguration;
|
|
12706
|
+
version?: SemanticVersion;
|
|
12707
|
+
};
|
|
12708
|
+
|
|
11910
12709
|
declare class Checkout {
|
|
12710
|
+
private readOnlyProviders;
|
|
11911
12711
|
readonly config: CheckoutConfiguration;
|
|
11912
12712
|
readonly fiatRampService: FiatRampService;
|
|
11913
12713
|
readonly availability: AvailabilityService;
|
|
12714
|
+
readonly passport?: Passport;
|
|
11914
12715
|
/**
|
|
11915
12716
|
* Constructs a new instance of the CheckoutModule class.
|
|
11916
12717
|
* @param {CheckoutModuleConfiguration} [config=SANDBOX_CONFIGURATION] - The configuration object for the CheckoutModule.
|
|
11917
12718
|
*/
|
|
11918
12719
|
constructor(config?: CheckoutModuleConfiguration);
|
|
12720
|
+
/**
|
|
12721
|
+
* Loads the widgets bundle and initiate the widgets factory.
|
|
12722
|
+
* @param {WidgetsInit} init - The initialisation parameters for loading the widgets bundle and applying configuration
|
|
12723
|
+
*/
|
|
12724
|
+
widgets(init: WidgetsInit): Promise<ImmutableCheckoutWidgets.WidgetsFactory>;
|
|
11919
12725
|
/**
|
|
11920
12726
|
* Creates a provider using the given parameters.
|
|
11921
12727
|
* @param {CreateProviderParams} params - The parameters for creating the provider.
|
|
@@ -12035,4 +12841,126 @@ declare class Checkout {
|
|
|
12035
12841
|
isSwapAvailable(): Promise<boolean>;
|
|
12036
12842
|
}
|
|
12037
12843
|
|
|
12038
|
-
|
|
12844
|
+
/**
|
|
12845
|
+
* Declares global interfaces and namespaces for the application.
|
|
12846
|
+
* @global
|
|
12847
|
+
* @namespace ImmutableCheckoutWidgets
|
|
12848
|
+
* */
|
|
12849
|
+
declare global {
|
|
12850
|
+
namespace ImmutableCheckoutWidgets {
|
|
12851
|
+
class WidgetsFactory implements IWidgetsFactory {
|
|
12852
|
+
constructor(sdk: Checkout, config: CheckoutWidgetsConfig);
|
|
12853
|
+
create<T extends WidgetType>(type: T, props?: WidgetProperties<T>): Widget<T>;
|
|
12854
|
+
updateProvider(provider: Web3Provider): void;
|
|
12855
|
+
}
|
|
12856
|
+
class Connect<T extends WidgetType> implements Widget<T> {
|
|
12857
|
+
constructor(sdk: Checkout, props: WidgetProperties<T>);
|
|
12858
|
+
mount(id: string, params?: WidgetParameters[T]): void;
|
|
12859
|
+
unmount(): void;
|
|
12860
|
+
update(props: WidgetProperties<T>): void;
|
|
12861
|
+
addListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName, callback: (data: WidgetEventData[T][KEventName]) => void): void;
|
|
12862
|
+
removeListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName): void;
|
|
12863
|
+
}
|
|
12864
|
+
class Bridge<T extends WidgetType> implements Widget<T> {
|
|
12865
|
+
constructor(sdk: Checkout, props: WidgetProperties<T>);
|
|
12866
|
+
mount(id: string, params?: WidgetParameters[T]): void;
|
|
12867
|
+
unmount(): void;
|
|
12868
|
+
update(props: WidgetProperties<T>): void;
|
|
12869
|
+
addListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName, callback: (data: WidgetEventData[T][KEventName]) => void): void;
|
|
12870
|
+
removeListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName): void;
|
|
12871
|
+
}
|
|
12872
|
+
class Wallet<T extends WidgetType> implements Widget<T> {
|
|
12873
|
+
constructor(sdk: Checkout, props: WidgetProperties<T>);
|
|
12874
|
+
mount(id: string, params?: WidgetParameters[T]): void;
|
|
12875
|
+
unmount(): void;
|
|
12876
|
+
update(props: WidgetProperties<T>): void;
|
|
12877
|
+
addListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName, callback: (data: WidgetEventData[T][KEventName]) => void): void;
|
|
12878
|
+
removeListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName): void;
|
|
12879
|
+
}
|
|
12880
|
+
class Swap<T extends WidgetType> implements Widget<T> {
|
|
12881
|
+
constructor(sdk: Checkout, props: WidgetProperties<T>);
|
|
12882
|
+
mount(id: string, params?: WidgetParameters[T]): void;
|
|
12883
|
+
unmount(): void;
|
|
12884
|
+
update(props: WidgetProperties<T>): void;
|
|
12885
|
+
addListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName, callback: (data: WidgetEventData[T][KEventName]) => void): void;
|
|
12886
|
+
removeListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName): void;
|
|
12887
|
+
}
|
|
12888
|
+
class OnRamp<T extends WidgetType> implements Widget<T> {
|
|
12889
|
+
constructor(sdk: Checkout, props: WidgetProperties<T>);
|
|
12890
|
+
mount(id: string, params?: WidgetParameters[T]): void;
|
|
12891
|
+
unmount(): void;
|
|
12892
|
+
update(props: WidgetProperties<T>): void;
|
|
12893
|
+
addListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName, callback: (data: WidgetEventData[T][KEventName]) => void): void;
|
|
12894
|
+
removeListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName): void;
|
|
12895
|
+
}
|
|
12896
|
+
class Sale<T extends WidgetType> implements Widget<T> {
|
|
12897
|
+
constructor(sdk: Checkout, props: WidgetProperties<T>);
|
|
12898
|
+
mount(id: string, params?: WidgetParameters[T]): void;
|
|
12899
|
+
unmount(): void;
|
|
12900
|
+
update(props: WidgetProperties<T>): void;
|
|
12901
|
+
addListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName, callback: (data: WidgetEventData[T][KEventName]) => void): void;
|
|
12902
|
+
removeListener<KEventName extends keyof WidgetEventData[T]>(type: KEventName): void;
|
|
12903
|
+
}
|
|
12904
|
+
}
|
|
12905
|
+
}
|
|
12906
|
+
|
|
12907
|
+
/**
|
|
12908
|
+
* Enum representing different types of errors that can occur during the checkout process.
|
|
12909
|
+
*/
|
|
12910
|
+
declare enum CheckoutErrorType {
|
|
12911
|
+
WEB3_PROVIDER_ERROR = "WEB3_PROVIDER_ERROR",
|
|
12912
|
+
PROVIDER_ERROR = "PROVIDER_ERROR",
|
|
12913
|
+
DEFAULT_PROVIDER_ERROR = "DEFAULT_PROVIDER_ERROR",
|
|
12914
|
+
CONNECT_PROVIDER_ERROR = "CONNECT_PROVIDER_ERROR",
|
|
12915
|
+
GET_BALANCE_ERROR = "GET_BALANCE_ERROR",
|
|
12916
|
+
GET_INDEXER_BALANCE_ERROR = "GET_INDEXER_BALANCE_ERROR",
|
|
12917
|
+
GET_ERC20_BALANCE_ERROR = "GET_ERC20_BALANCE_ERROR",
|
|
12918
|
+
GET_ERC721_BALANCE_ERROR = "GET_ERC721_BALANCE_ERROR",
|
|
12919
|
+
GET_NETWORK_INFO_ERROR = "GET_NETWORK_INFO_ERROR",
|
|
12920
|
+
METAMASK_PROVIDER_ERROR = "METAMASK_PROVIDER_ERROR",
|
|
12921
|
+
CHAIN_NOT_SUPPORTED_ERROR = "CHAIN_NOT_SUPPORTED_ERROR",
|
|
12922
|
+
PROVIDER_REQUEST_MISSING_ERROR = "PROVIDER_REQUEST_MISSING_ERROR",
|
|
12923
|
+
PROVIDER_REQUEST_FAILED_ERROR = "PROVIDER_REQUEST_FAILED_ERROR",
|
|
12924
|
+
USER_REJECTED_REQUEST_ERROR = "USER_REJECTED_REQUEST_ERROR",
|
|
12925
|
+
TRANSACTION_FAILED = "TRANSACTION_FAILED",
|
|
12926
|
+
INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS",
|
|
12927
|
+
UNPREDICTABLE_GAS_LIMIT = "UNPREDICTABLE_GAS_LIMIT",
|
|
12928
|
+
INVALID_GAS_ESTIMATE_TYPE = "INVALID_GAS_ESTIMATE_TYPE",
|
|
12929
|
+
UNSUPPORTED_TOKEN_TYPE_ERROR = "UNSUPPORTED_TOKEN_TYPE_ERROR",
|
|
12930
|
+
UNSUPPORTED_BALANCE_REQUIREMENT_ERROR = "UNSUPPORTED_BALANCE_REQUIREMENT_ERROR",
|
|
12931
|
+
GET_ORDER_LISTING_ERROR = "GET_ORDER_LISTING_ERROR",
|
|
12932
|
+
CANCEL_ORDER_LISTING_ERROR = "CANCEL_ORDER_LISTING_ERROR",
|
|
12933
|
+
PREPARE_ORDER_LISTING_ERROR = "PREPARE_ORDER_LISTING_ERROR",
|
|
12934
|
+
CREATE_ORDER_LISTING_ERROR = "CREATE_ORDER_LISTING_ERROR",
|
|
12935
|
+
FULFILL_ORDER_LISTING_ERROR = "FULFILL_ORDER_LISTING_ERROR",
|
|
12936
|
+
SWITCH_NETWORK_UNSUPPORTED = "SWITCH_NETWORK_UNSUPPORTED",
|
|
12937
|
+
GET_ERC20_ALLOWANCE_ERROR = "GET_ERC20_ALLOWANCE_ERROR",
|
|
12938
|
+
GET_ERC721_ALLOWANCE_ERROR = "GET_ERC721_ALLOWANCE_ERROR",
|
|
12939
|
+
EXECUTE_APPROVAL_TRANSACTION_ERROR = "EXECUTE_APPROVAL_TRANSACTION_ERROR",
|
|
12940
|
+
EXECUTE_FULFILLMENT_TRANSACTION_ERROR = "EXECUTE_FULFILLMENT_TRANSACTION_ERROR",
|
|
12941
|
+
SIGN_MESSAGE_ERROR = "SIGN_MESSAGE_ERROR",
|
|
12942
|
+
BRIDGE_GAS_ESTIMATE_ERROR = "BRIDGE_GAS_ESTIMATE_ERROR",
|
|
12943
|
+
ORDER_FEE_ERROR = "ORDER_FEE_ERROR",
|
|
12944
|
+
ITEM_REQUIREMENTS_ERROR = "ITEM_REQUIREMENTS_ERROR",
|
|
12945
|
+
API_ERROR = "API_ERROR",
|
|
12946
|
+
ORDER_EXPIRED_ERROR = "ORDER_EXPIRED_ERROR",
|
|
12947
|
+
WIDGETS_SCRIPT_LOAD_ERROR = "WIDGETS_SCRIPT_LOAD_ERROR"
|
|
12948
|
+
}
|
|
12949
|
+
/**
|
|
12950
|
+
* Represents an error object with a specific type, optional message, and optional data.
|
|
12951
|
+
* @property {CheckoutErrorType} type
|
|
12952
|
+
* @property {string | undefined} [message]
|
|
12953
|
+
* @property {Object.<string, string> | undefined} [data]
|
|
12954
|
+
*/
|
|
12955
|
+
type ErrorType = {
|
|
12956
|
+
/** The type of the error. */
|
|
12957
|
+
type: CheckoutErrorType;
|
|
12958
|
+
/** The error message. */
|
|
12959
|
+
message?: string;
|
|
12960
|
+
/** Additional data associated with the error. */
|
|
12961
|
+
data?: {
|
|
12962
|
+
[key: string]: string;
|
|
12963
|
+
};
|
|
12964
|
+
};
|
|
12965
|
+
|
|
12966
|
+
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 };
|