@imtbl/sdk 0.1.8-alpha.2 → 0.1.9-alpha

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.
@@ -41,14 +41,6 @@ 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
-
52
44
  declare type Deferrable<T> = {
53
45
  [K in keyof T]: T[K] | Promise<T[K]>;
54
46
  };
@@ -58,6 +50,14 @@ declare class Description<T = any> {
58
50
  });
59
51
  }
60
52
 
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,6 +238,43 @@ declare abstract class Provider implements OnceBlockable {
238
238
  static isProvider(value: any): value is Provider;
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;
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): 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>;
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
+
241
278
  declare type FormatFunc = (value: any) => any;
242
279
  declare type FormatFuncs = {
243
280
  [key: string]: FormatFunc;
@@ -438,43 +475,6 @@ declare class BaseProvider extends Provider implements EnsProvider {
438
475
  removeAllListeners(eventName?: EventType): this;
439
476
  }
440
477
 
441
- interface TypedDataDomain {
442
- name?: string;
443
- version?: string;
444
- chainId?: BigNumberish;
445
- verifyingContract?: string;
446
- salt?: BytesLike;
447
- }
448
- interface TypedDataField {
449
- name: string;
450
- type: string;
451
- }
452
- interface TypedDataSigner {
453
- _signTypedData(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, value: Record<string, any>): Promise<string>;
454
- }
455
- declare abstract class Signer {
456
- readonly provider?: Provider;
457
- abstract getAddress(): Promise<string>;
458
- abstract signMessage(message: Bytes | string): Promise<string>;
459
- abstract signTransaction(transaction: Deferrable<TransactionRequest>): Promise<string>;
460
- abstract connect(provider: Provider): Signer;
461
- readonly _isSigner: boolean;
462
- constructor();
463
- getBalance(blockTag?: BlockTag): Promise<BigNumber>;
464
- getTransactionCount(blockTag?: BlockTag): Promise<number>;
465
- estimateGas(transaction: Deferrable<TransactionRequest>): Promise<BigNumber>;
466
- call(transaction: Deferrable<TransactionRequest>, blockTag?: BlockTag): Promise<string>;
467
- sendTransaction(transaction: Deferrable<TransactionRequest>): Promise<TransactionResponse>;
468
- getChainId(): Promise<number>;
469
- getGasPrice(): Promise<BigNumber>;
470
- getFeeData(): Promise<FeeData>;
471
- resolveName(name: string): Promise<string>;
472
- checkTransaction(transaction: Deferrable<TransactionRequest>): Deferrable<TransactionRequest>;
473
- populateTransaction(transaction: Deferrable<TransactionRequest>): Promise<TransactionRequest>;
474
- _checkProvider(operation?: string): void;
475
- static isSigner(value: any): value is Signer;
476
- }
477
-
478
478
  declare class JsonRpcSigner extends Signer implements TypedDataSigner {
479
479
  readonly provider: JsonRpcProvider;
480
480
  _index: number;
@@ -563,16 +563,23 @@ interface ModuleConfiguration<T> {
563
563
  overrides?: T;
564
564
  }
565
565
 
566
+ /**
567
+ * @typedef {string} Address - Represents an Ethereum address.
568
+ */
569
+ type Address = string;
570
+ /**
571
+ * @typedef {Address | 'NATIVE'} FungibleToken - Represents a fungible token, either an ERC20 token address or the native token.
572
+ */
573
+ type FungibleToken = Address | 'NATIVE';
574
+
566
575
  /**
567
576
  * Enum representing the supported chains with their corresponding IDs.
568
577
  */
569
578
  declare enum ChainId {
570
579
  ETHEREUM = 1,
571
- SEPOLIA = 11155111,
572
- IMTBL_ZKEVM_DEVNET = 13373,
573
580
  IMTBL_ZKEVM_TESTNET = 13372,
574
- POLYGON_ZKEVM_TESTNET = 1442,
575
- POLYGON_ZKEVM = 137
581
+ SEPOLIA = 11155111,
582
+ IMTBL_ZKEVM_DEVNET = 13383
576
583
  }
577
584
  /**
578
585
  * Interface representing token information.
@@ -591,7 +598,6 @@ interface TokenInfo {
591
598
  }
592
599
  /**
593
600
  * Interface representing the parameters for {@link Checkout.getBalance}.
594
- * @property {@link Web3Provider} provider - The provider to connect to the network.
595
601
  * @property {string} walletAddress - The wallet address.
596
602
  * @property {string | undefined} contractAddress - The contract address of the token.
597
603
  */
@@ -613,7 +619,6 @@ interface GetBalanceResult {
613
619
  }
614
620
  /**
615
621
  * Interface representing the parameters for {@link Checkout.getAllBalances}.
616
- * @property {Web3Provider} provider - The provider to connect to the network.
617
622
  * @property {string} walletAddress - The wallet address.
618
623
  * @property {ChainId} chainId - The ID of the network.
619
624
  */
@@ -652,13 +657,9 @@ interface NetworkInfo {
652
657
  declare enum ConnectionProviders {
653
658
  METAMASK = "metamask"
654
659
  }
655
- /**
656
- * Interface representing the parameters for {@link Checkout.connect}.
657
- * @property {ConnectionProviders} providerPreference - The preferred provider to connect to the network.
658
- */
659
- type ConnectParams = {
660
- providerPreference: ConnectionProviders;
661
- };
660
+ interface ConnectParams {
661
+ provider: Web3Provider;
662
+ }
662
663
  /**
663
664
  * Interface representing the result of {@link Checkout.connect}.
664
665
  * @property {Web3Provider} provider - The provider used to connect to the network.
@@ -668,12 +669,8 @@ interface ConnectResult {
668
669
  provider: Web3Provider;
669
670
  network: NetworkInfo;
670
671
  }
671
- /**
672
- * Interface representing the parameters for {@link Checkout.checkIsWalletConnected}.
673
- * @property {ConnectionProviders} providerPreference - The preferred provider to use to check the connection status to th Web3 network.
674
- */
675
672
  interface CheckConnectionParams {
676
- providerPreference: ConnectionProviders;
673
+ provider: Web3Provider;
677
674
  }
678
675
  /**
679
676
  * Interface representing the result of {@link Checkout.checkIsWalletConnected}.
@@ -684,6 +681,71 @@ interface CheckConnectionResult {
684
681
  isConnected: boolean;
685
682
  walletAddress: string;
686
683
  }
684
+ /**
685
+ * * Enum representing the actions that gas can be estimated for when calling {@link Checkout.gasEstimate}.
686
+ * */
687
+ declare enum GasEstimateType {
688
+ BRIDGE_TO_L2 = "BRIDGE_TO_L2",
689
+ SWAP = "SWAP"
690
+ }
691
+ /**
692
+ * * Type representing the params that can be used with {@link Checkout.gasEstimate}.
693
+ * */
694
+ type GasEstimateParams = GasEstimateBridgeToL2Params | GasEstimateSwapParams;
695
+ /**
696
+ * * Interface representing the parameters to estimate gas for a bridge to L2 for {@link Checkout.gasEstimate}.
697
+ @property {gasEstimateType} - The type of action to estimate gas for.
698
+ @property {boolean} isSpendingCapApprovalRequired - Is spending cap approval required.
699
+ @property {tokenAddress} - The address of the token to bridge.
700
+ * */
701
+ interface GasEstimateBridgeToL2Params {
702
+ gasEstimateType: GasEstimateType.BRIDGE_TO_L2;
703
+ isSpendingCapApprovalRequired: boolean;
704
+ tokenAddress?: FungibleToken;
705
+ }
706
+ /**
707
+ * * Interface representing the parameters to estimate gas for a swap for {@link Checkout.gasEstimate}.
708
+ @property {gasEstimateType} - The type of action to estimate gas for.
709
+ * */
710
+ interface GasEstimateSwapParams {
711
+ gasEstimateType: GasEstimateType.SWAP;
712
+ }
713
+ /**
714
+ * * Interface representing the result for {@link Checkout.gasEstimate}.
715
+ @property {gasEstimateType} - The type of action this gas estimate is for.
716
+ @property {gasFee} - The gas fee estimate.
717
+ * */
718
+ interface GasEstimateSwapResult {
719
+ gasEstimateType: GasEstimateType.SWAP;
720
+ gasFee: TokenAmountEstimate;
721
+ }
722
+ /**
723
+ * * Interface representing the result for {@link Checkout.gasEstimate}.
724
+ @property {gasEstimateType} - The type of action this gas estimate is for.
725
+ @property {gasFee} - The gas fee estimate.
726
+ @property {bridgeFee} - The bridge fee estimate.
727
+ @property {bridgeable} - Indicates whether the token can be bridged or not.
728
+ * */
729
+ interface GasEstimateBridgeToL2Result {
730
+ gasEstimateType: GasEstimateType.BRIDGE_TO_L2;
731
+ gasFee: TokenAmountEstimate;
732
+ bridgeFee: TokenAmountEstimate;
733
+ bridgeable: boolean;
734
+ }
735
+ /**
736
+ * * Interface representing the type used in the result for {@link Checkout.gasEstimate}.
737
+ @property {BigNumber} estimatedAmount - estimated amount.
738
+ @property {TokenInfo} token - token for the estimate.
739
+ * */
740
+ interface TokenAmountEstimate {
741
+ estimatedAmount?: BigNumber;
742
+ token?: TokenInfo;
743
+ }
744
+ /**
745
+ * Object mapping the list of supported networks with the corresponding RPC urls.
746
+ */
747
+ type RpcUrlMap = Map<ChainId, string>;
748
+ declare const RPC_URL_MAP: RpcUrlMap;
687
749
  /**
688
750
  * Type representing the details of a network.
689
751
  * @property {string} chainIdHex - The hexadecimal ID of the network.
@@ -805,12 +867,28 @@ interface SendTransactionParams {
805
867
  interface SendTransactionResult {
806
868
  transactionResponse: TransactionResponse;
807
869
  }
870
+ /**
871
+ * Enum representing the avaiable wallet providers to use when creating a provider
872
+ */
873
+ declare enum WalletProviderName {
874
+ METAMASK = "metamask"
875
+ }
876
+ interface CreateProviderParams {
877
+ walletProvider: WalletProviderName;
878
+ }
879
+ /**
880
+ * Interface representing the result of {@link Checkout.createProvider}.
881
+ * @property {Web3Provider} provider - The provider used to connect to the network.
882
+ */
883
+ type CreateProviderResult = {
884
+ provider: Web3Provider;
885
+ };
808
886
  /**
809
887
  * Interface representing a wallet filter to be used in {@link GetWalletAllowListParams}.
810
888
  * @property {ConnectionProviders} connectionProvider - The connection provider to filter wallets by.
811
889
  */
812
890
  interface WalletFilter {
813
- connectionProvider: ConnectionProviders;
891
+ providerName: WalletProviderName;
814
892
  }
815
893
  /**
816
894
  * Interface representing the parameters for {@link Checkout.getWalletAllowList}.
@@ -829,7 +907,7 @@ interface GetWalletAllowListParams {
829
907
  * @property {string} icon - The URL/data:image of an icon for the wallet.
830
908
  */
831
909
  interface WalletInfo {
832
- connectionProvider: ConnectionProviders;
910
+ providerName: WalletProviderName;
833
911
  name: string;
834
912
  description: string;
835
913
  icon: string;
@@ -853,7 +931,9 @@ declare enum WalletFilterTypes {
853
931
  * The different types of errors that can be returned by the checkout process.
854
932
  */
855
933
  declare enum CheckoutErrorType {
856
- PROVIDER_PREFERENCE_ERROR = "PROVIDER_PREFERENCE_ERROR",
934
+ WEB3_PROVIDER_ERROR = "WEB3_PROVIDER_ERROR",
935
+ PROVIDER_ERROR = "PROVIDER_ERROR",
936
+ DEFAULT_PROVIDER_ERROR = "DEFAULT_PROVIDER_ERROR",
857
937
  CONNECT_PROVIDER_ERROR = "CONNECT_PROVIDER_ERROR",
858
938
  GET_BALANCE_ERROR = "GET_BALANCE_ERROR",
859
939
  GET_ERC20_BALANCE_ERROR = "GET_ERC20_BALANCE_ERROR",
@@ -865,7 +945,8 @@ declare enum CheckoutErrorType {
865
945
  USER_REJECTED_REQUEST_ERROR = "USER_REJECTED_REQUEST_ERROR",
866
946
  TRANSACTION_FAILED = "TRANSACTION_FAILED",
867
947
  INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS",
868
- UNPREDICTABLE_GAS_LIMIT = "UNPREDICTABLE_GAS_LIMIT"
948
+ UNPREDICTABLE_GAS_LIMIT = "UNPREDICTABLE_GAS_LIMIT",
949
+ INVALID_GAS_ESTIMATE_TYPE = "INVALID_GAS_ESTIMATE_TYPE"
869
950
  }
870
951
  /**
871
952
  * The type signature for an error.
@@ -886,6 +967,13 @@ declare class CheckoutConfiguration {
886
967
  declare class Checkout {
887
968
  readonly config: CheckoutConfiguration;
888
969
  constructor(config?: CheckoutModuleConfiguration);
970
+ /**
971
+ * Create a provider object which can be used within the Checkout class methods.
972
+ * @param {CreateProviderParams} params The data required to create a provider
973
+ * @returns A new provider object
974
+ * @throws {@link ErrorType}
975
+ */
976
+ createProvider(params: CreateProviderParams): Promise<CreateProviderResult>;
889
977
  /**
890
978
  * Check if a wallet is connected to the current application
891
979
  * without requesting permission from the wallet and hence triggering a connect popup.
@@ -962,6 +1050,13 @@ declare class Checkout {
962
1050
  * @throws {@link ErrorType}
963
1051
  */
964
1052
  getNetworkInfo(params: GetNetworkParams): Promise<NetworkInfo>;
1053
+ static isWeb3Provider(web3Provider: Web3Provider): boolean;
1054
+ /**
1055
+ * Estimates the gas to perform an action.
1056
+ * @param {GasEstimateParams} params - The params required to calculate a gas estimate
1057
+ * @returns The gas estimate for the given action.
1058
+ */
1059
+ gasEstimate(params: GasEstimateParams): Promise<GasEstimateSwapResult | GasEstimateBridgeToL2Result>;
965
1060
  }
966
1061
 
967
- export { ChainId, CheckConnectionParams, CheckConnectionResult, Checkout, CheckoutErrorType, CheckoutModuleConfiguration, ConnectParams, ConnectResult, ConnectionProviders, ErrorType, GetAllBalancesParams, GetAllBalancesResult, GetBalanceParams, GetBalanceResult, GetNetworkAllowListParams, GetNetworkAllowListResult, GetNetworkParams, GetTokenAllowListParams, GetTokenAllowListResult, GetWalletAllowListParams, GetWalletAllowListResult, NetworkFilter, NetworkFilterTypes, NetworkInfo, SendTransactionParams, SendTransactionResult, SwitchNetworkParams, SwitchNetworkResult, TokenFilter, TokenFilterTypes, TokenInfo, WalletFilter, WalletFilterTypes, WalletInfo };
1062
+ export { ChainId, CheckConnectionParams, CheckConnectionResult, Checkout, CheckoutErrorType, CheckoutModuleConfiguration, ConnectParams, ConnectResult, ConnectionProviders, ErrorType, GasEstimateBridgeToL2Result, GasEstimateParams, GasEstimateSwapResult, GasEstimateType, GetAllBalancesParams, GetAllBalancesResult, GetBalanceParams, GetBalanceResult, GetNetworkAllowListParams, GetNetworkAllowListResult, GetNetworkParams, GetTokenAllowListParams, GetTokenAllowListResult, GetWalletAllowListParams, GetWalletAllowListResult, NetworkFilter, NetworkFilterTypes, NetworkInfo, RPC_URL_MAP, SendTransactionParams, SendTransactionResult, SwitchNetworkParams, SwitchNetworkResult, TokenFilter, TokenFilterTypes, TokenInfo, WalletFilter, WalletFilterTypes, WalletInfo, WalletProviderName };