@imtbl/sdk 0.22.3 → 0.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11222,11 +11222,6 @@ type ERC721ItemRequirement = {
11222
11222
  id: string;
11223
11223
  spenderAddress: string;
11224
11224
  };
11225
- /**
11226
- * Represents the item requirements for a transaction.
11227
- * NativeItem, ERC20Item or ERC721Item {@link Checkout.smartCheckout}.
11228
- */
11229
- type ItemRequirement = NativeItem | ERC20Item | ERC721Item;
11230
11225
  /**
11231
11226
  * An enum representing the item types
11232
11227
  * @enum {string}
@@ -11239,41 +11234,6 @@ declare enum ItemType {
11239
11234
  ERC20 = "ERC20",
11240
11235
  ERC721 = "ERC721"
11241
11236
  }
11242
- /**
11243
- * Represents a native item.
11244
- * @property {ItemType} type - The type indicate this is a native item.
11245
- * @property {BigNumber} amount - The amount of the item.
11246
- */
11247
- type NativeItem = {
11248
- type: ItemType.NATIVE;
11249
- amount: BigNumber;
11250
- };
11251
- /**
11252
- * Represents an ERC20 item.
11253
- * @property {ItemType} type - The type to indicate this is an ERC20 item.
11254
- * @property {string} contractAddress - The contract address of the ERC20.
11255
- * @property {BigNumber} amount - The amount of the item.
11256
- * @property {string} spenderAddress - The contract address of the approver.
11257
- */
11258
- type ERC20Item = {
11259
- type: ItemType.ERC20;
11260
- contractAddress: string;
11261
- amount: BigNumber;
11262
- spenderAddress: string;
11263
- };
11264
- /**
11265
- * Represents an ERC721 item.
11266
- * @property {ItemType} type - The type to indicate this is an ERC721 item.
11267
- * @property {string} contractAddress - The contract address of the ERC721 collection.
11268
- * @property {string} id - The ID of this ERC721 in the collection.
11269
- * @property {string} spenderAddress - The contract address of the approver.
11270
- */
11271
- type ERC721Item = {
11272
- type: ItemType.ERC721;
11273
- contractAddress: string;
11274
- id: string;
11275
- spenderAddress: string;
11276
- };
11277
11237
  /**
11278
11238
  * An enum representing transaction or gas types
11279
11239
  * @enum {string}
@@ -11610,6 +11570,24 @@ type AvailableRoutingOptions = {
11610
11570
  swap?: boolean;
11611
11571
  bridge?: boolean;
11612
11572
  };
11573
+ type FundingRouteFeeEstimate = SwapRouteFeeEstimate | BridgeRouteFeeEstimate;
11574
+ type SwapRouteFeeEstimate = {
11575
+ type: FundingStepType.SWAP;
11576
+ estimatedAmount: BigNumber;
11577
+ token: TokenInfo;
11578
+ };
11579
+ type BridgeRouteFeeEstimate = {
11580
+ type: FundingStepType.BRIDGE;
11581
+ gasFee: {
11582
+ estimatedAmount: BigNumber;
11583
+ token?: TokenInfo;
11584
+ };
11585
+ bridgeFee: {
11586
+ estimatedAmount: BigNumber;
11587
+ token?: TokenInfo;
11588
+ };
11589
+ totalFees: BigNumber;
11590
+ };
11613
11591
  /**
11614
11592
  * Interface representing the parameters for {@link Checkout.buy}
11615
11593
  * @property {Web3Provider} provider - The provider to use for the buy.
@@ -12300,4 +12278,4 @@ declare class Checkout {
12300
12278
  getExchangeFeeEstimate(): Promise<OnRampProviderFees>;
12301
12279
  }
12302
12280
 
12303
- export { AllowedNetworkConfig, BuyOrder, BuyParams, BuyResult, BuyToken, CHECKOUT_API_BASE_URL, CancelParams, CancelResult, ChainId, ChainName, CheckConnectionParams, CheckConnectionResult, Checkout, CheckoutErrorType, CheckoutModuleConfiguration, CheckoutStatus, ConnectParams, ConnectResult, DexConfig, ERC20ItemRequirement, ERC721ItemRequirement, ErrorType, ExchangeType, FeePercentage, FeeToken, FiatRampParams, FulfillmentTransaction, GasAmount, GasEstimateBridgeToL2Result, GasEstimateParams, GasEstimateSwapResult, GasEstimateTokenConfig, GasEstimateType, GasToken, GasTokenType, GetAllBalancesParams, GetAllBalancesResult, GetBalanceParams, GetBalanceResult, GetNetworkAllowListParams, GetNetworkAllowListResult, GetNetworkParams, GetTokenAllowListParams, GetTokenAllowListResult, GetWalletAllowListParams, GetWalletAllowListResult, ItemRequirement, ItemType, NativeItemRequirement, NetworkFilter, NetworkFilterTypes, NetworkInfo, OrderFee, RemoteConfiguration, SellOrder, SellParams, SellResult, SellToken, SendTransactionParams, SendTransactionResult, SmartCheckoutParams, SwitchNetworkParams, SwitchNetworkResult, TokenFilter, TokenFilterTypes, TokenInfo, TransactionOrGasType, WalletFilter, WalletFilterTypes, WalletInfo, WalletProviderName };
12281
+ export { AllowedNetworkConfig, AvailableRoutingOptions, BalanceDelta, BuyOrder, BuyParams, BuyResult, BuyToken, CHECKOUT_API_BASE_URL, CancelParams, CancelResult, ChainId, ChainName, CheckConnectionParams, CheckConnectionResult, Checkout, CheckoutErrorType, CheckoutModuleConfiguration, CheckoutStatus, ConnectParams, ConnectResult, DexConfig, ERC20ItemRequirement, ERC721ItemRequirement, ErrorType, ExchangeType, FeePercentage, FeeToken, FiatRampParams, FulfillmentTransaction, FundingItem, FundingRoute, FundingRouteFeeEstimate, FundingStep, FundingStepType, GasAmount, GasEstimateBridgeToL2Result, GasEstimateParams, GasEstimateSwapResult, GasEstimateTokenConfig, GasEstimateType, GasToken, GasTokenType, GetAllBalancesParams, GetAllBalancesResult, GetBalanceParams, GetBalanceResult, GetNetworkAllowListParams, GetNetworkAllowListResult, GetNetworkParams, GetTokenAllowListParams, GetTokenAllowListResult, GetWalletAllowListParams, GetWalletAllowListResult, ItemBalance, ItemType, NativeItemRequirement, NetworkFilter, NetworkFilterTypes, NetworkInfo, OrderFee, RemoteConfiguration, RoutingOutcome, RoutingOutcomeType, SellOrder, SellParams, SellResult, SellToken, SendTransactionParams, SendTransactionResult, SmartCheckoutParams, SmartCheckoutResult, SmartCheckoutRouter, SwitchNetworkParams, SwitchNetworkResult, TokenFilter, TokenFilterTypes, TokenInfo, TransactionOrGasType, TransactionRequirement, WalletFilter, WalletFilterTypes, WalletInfo, WalletProviderName };
@@ -19815,7 +19815,7 @@ class APIError extends Error {
19815
19815
 
19816
19816
  /* eslint-disable implicit-arrow-linebreak */
19817
19817
  const defaultHeaders = {
19818
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.22.3',
19818
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.23.1',
19819
19819
  };
19820
19820
  /**
19821
19821
  * createAPIConfiguration to create a custom Configuration
@@ -24126,4 +24126,4 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
24126
24126
  }
24127
24127
  }
24128
24128
 
24129
- export { $d85ad1457a3f1a83$export$161d4a74df65fc08 as CHECKOUT_API_BASE_URL, $0472f23319457bfb$export$c06e1e7429de6283 as ChainId, $0472f23319457bfb$export$b874c6b1dfe85e02 as ChainName, $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 as Checkout, $a8bc256d81a5e2c1$export$e3dc0620abde7f5a as CheckoutErrorType, $4b58188d47aafe8d$export$de7bcda3c490bf18 as CheckoutStatus, $e055e79256bbc1dd$export$80f4da0d409a629d as ExchangeType, $de275b98d2b651c3$export$788b1fd17f3dad84 as GasEstimateType, $4b58188d47aafe8d$export$537fa3efd10ed435 as GasTokenType, $4b58188d47aafe8d$export$1fc8f52ad1810e52 as ItemType, $a47e48dd2c04791b$export$1f05a55fe0680cc7 as NetworkFilterTypes, $08d5ddc39acd6833$export$fd9b17d87f4121d2 as TokenFilterTypes, $4b58188d47aafe8d$export$65c64e46348ee3c1 as TransactionOrGasType, $4f91c5f280efe242$export$a75605c67ea83a5a as WalletFilterTypes, $e768639828688ca3$export$2d7a51a18d87e21d as WalletProviderName };
24129
+ export { $d85ad1457a3f1a83$export$161d4a74df65fc08 as CHECKOUT_API_BASE_URL, $0472f23319457bfb$export$c06e1e7429de6283 as ChainId, $0472f23319457bfb$export$b874c6b1dfe85e02 as ChainName, $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 as Checkout, $a8bc256d81a5e2c1$export$e3dc0620abde7f5a as CheckoutErrorType, $4b58188d47aafe8d$export$de7bcda3c490bf18 as CheckoutStatus, $e055e79256bbc1dd$export$80f4da0d409a629d as ExchangeType, $4b58188d47aafe8d$export$6fbaa98ee06d03e8 as FundingStepType, $de275b98d2b651c3$export$788b1fd17f3dad84 as GasEstimateType, $4b58188d47aafe8d$export$537fa3efd10ed435 as GasTokenType, $4b58188d47aafe8d$export$1fc8f52ad1810e52 as ItemType, $a47e48dd2c04791b$export$1f05a55fe0680cc7 as NetworkFilterTypes, $4b58188d47aafe8d$export$d0616bd3e995b8be as RoutingOutcomeType, $08d5ddc39acd6833$export$fd9b17d87f4121d2 as TokenFilterTypes, $4b58188d47aafe8d$export$65c64e46348ee3c1 as TransactionOrGasType, $4f91c5f280efe242$export$a75605c67ea83a5a as WalletFilterTypes, $e768639828688ca3$export$2d7a51a18d87e21d as WalletProviderName };
@@ -25393,7 +25393,7 @@ declare function CheckoutWidgets(config?: CheckoutWidgetsConfig): void;
25393
25393
  /**
25394
25394
  * Updates the configuration for the checkout widgets by setting the global variable
25395
25395
  * `window.ImtblCheckoutWidgetConfig` to the JSON string representation of the given
25396
- * `config` object.
25396
+ * `config` object and update all the Checkout web components configuration.
25397
25397
  * @param {CheckoutWidgetsConfig} config - The new configuration object for the checkout widgets.
25398
25398
  * @returns None
25399
25399
  */
@@ -4,11 +4,54 @@ import { useEffect } from 'react';
4
4
  function $parcel$export(e, n, v, s) {
5
5
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
6
6
  }
7
- const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.22.3";
7
+ var $045213b18e9f1f94$exports = {};
8
+
9
+ $parcel$export($045213b18e9f1f94$exports, "WidgetTheme", () => $045213b18e9f1f94$export$c88931fdc51854eb);
10
+ $parcel$export($045213b18e9f1f94$exports, "CheckoutWidgetTagNames", () => $045213b18e9f1f94$export$75be0f6af9650f2c);
11
+ /**
12
+ * Enum representing the themes for the Checkout widgets.
13
+ */ var $045213b18e9f1f94$export$c88931fdc51854eb;
14
+ (function(WidgetTheme) {
15
+ WidgetTheme["LIGHT"] = "light";
16
+ WidgetTheme["DARK"] = "dark";
17
+ })($045213b18e9f1f94$export$c88931fdc51854eb || ($045213b18e9f1f94$export$c88931fdc51854eb = {}));
18
+ var $045213b18e9f1f94$export$75be0f6af9650f2c;
19
+ (function(CheckoutWidgetTagNames) {
20
+ CheckoutWidgetTagNames["CONNECT"] = "imtbl-connect";
21
+ CheckoutWidgetTagNames["WALLET"] = "imtbl-wallet";
22
+ CheckoutWidgetTagNames["SWAP"] = "imtbl-swap";
23
+ CheckoutWidgetTagNames["BRIDGE"] = "imtbl-bridge";
24
+ CheckoutWidgetTagNames["ONRAMP"] = "imtbl-onramp";
25
+ })($045213b18e9f1f94$export$75be0f6af9650f2c || ($045213b18e9f1f94$export$75be0f6af9650f2c = {}));
26
+
27
+
28
+ const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.23.1";
8
29
  const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
9
30
  const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
10
31
 
11
32
 
33
+ function $430e3eda76fa4d5f$var$getWidgetConfig(element) {
34
+ const config = element.getAttribute("widgetconfig");
35
+ if (!config) return null;
36
+ try {
37
+ return JSON.parse(config);
38
+ } catch (err) {
39
+ // eslint-disable-next-line no-console
40
+ console.warn(`Unable to decode widgetconfig for ${element}: `, err);
41
+ }
42
+ return null;
43
+ }
44
+ function $430e3eda76fa4d5f$var$setWidgetConfig(element, config) {
45
+ element.setAttribute("widgetconfig", JSON.stringify(config));
46
+ }
47
+ function $430e3eda76fa4d5f$var$saveConfig(config) {
48
+ if (window === undefined) {
49
+ // eslint-disable-next-line no-console
50
+ console.error("missing window object: please run Checkout client side");
51
+ return;
52
+ }
53
+ window.ImtblCheckoutWidgetConfig = JSON.stringify(config);
54
+ }
12
55
  function $430e3eda76fa4d5f$export$46b1ae20f762ad4c(version) {
13
56
  const defaultPackageVersion = ($d663162fd5a0853f$export$1169f5475725171b)();
14
57
  if (version === undefined || version.major === undefined) return defaultPackageVersion;
@@ -30,6 +73,29 @@ function $430e3eda76fa4d5f$export$46b1ae20f762ad4c(version) {
30
73
  if (Number.isInteger(version.build) && version.build >= 0) validatedVersion += `.${version.build.toString()}`;
31
74
  return validatedVersion;
32
75
  }
76
+ function $430e3eda76fa4d5f$var$loadScript(config) {
77
+ if (document === undefined) {
78
+ // eslint-disable-next-line no-console
79
+ console.error("missing document object: please run Checkout client side");
80
+ return;
81
+ }
82
+ const validVersion = $430e3eda76fa4d5f$export$46b1ae20f762ad4c(config?.version);
83
+ // Prevent the script to be loaded more than once
84
+ // by checking the presence of the script and its version.
85
+ const initScript = document.querySelector('[data-product="checkout"]');
86
+ if (initScript) {
87
+ // eslint-disable-next-line no-console
88
+ console.warn("checkout script has already been loaded, it can only be loaded once.");
89
+ return;
90
+ }
91
+ const tag = document.createElement("script");
92
+ let cdnUrl = `https://cdn.jsdelivr.net/npm/@imtbl/sdk@${validVersion}/dist/browser/checkout.js`;
93
+ if (($d663162fd5a0853f$export$83bf90b30cdfd29f)()) cdnUrl = "http://localhost:3000/lib/js/imtbl-checkout.js";
94
+ tag.setAttribute("data-product", "checkout");
95
+ tag.setAttribute("data-version", validVersion);
96
+ tag.setAttribute("src", cdnUrl);
97
+ document.head.appendChild(tag);
98
+ }
33
99
  function $430e3eda76fa4d5f$export$af210a0808087845(config) {
34
100
  if (window === undefined) {
35
101
  // eslint-disable-next-line no-console
@@ -41,21 +107,45 @@ function $430e3eda76fa4d5f$export$af210a0808087845(config) {
41
107
  console.error("missing document object: please run Checkout client side");
42
108
  return;
43
109
  }
44
- const checkoutWidgetJS = document.createElement("script");
45
- const validVersion = $430e3eda76fa4d5f$export$46b1ae20f762ad4c(config?.version);
46
- let cdnUrl = `https://cdn.jsdelivr.net/npm/@imtbl/sdk@${validVersion}/dist/browser/checkout.js`;
47
- if (($d663162fd5a0853f$export$83bf90b30cdfd29f)()) cdnUrl = "http://localhost:3000/lib/js/imtbl-checkout.js";
48
- checkoutWidgetJS.setAttribute("src", cdnUrl);
49
- document.head.appendChild(checkoutWidgetJS);
50
- window.ImtblCheckoutWidgetConfig = JSON.stringify(config);
110
+ $430e3eda76fa4d5f$var$loadScript(config || {});
111
+ $430e3eda76fa4d5f$var$saveConfig(config || {});
51
112
  }
52
113
  function $430e3eda76fa4d5f$export$bf1548ba7e61c17f(config) {
53
114
  if (window === undefined) {
115
+ // eslint-disable-next-line no-console
116
+ console.error("missing window object: please run Checkout client side");
117
+ return;
118
+ }
119
+ if (document === undefined) {
54
120
  // eslint-disable-next-line no-console
55
121
  console.error("missing document object: please run Checkout client side");
56
122
  return;
57
123
  }
58
- window.ImtblCheckoutWidgetConfig = JSON.stringify(config);
124
+ let globalConfig = {};
125
+ try {
126
+ globalConfig = JSON.parse(window.ImtblCheckoutWidgetConfig);
127
+ } catch (err) {
128
+ // eslint-disable-next-line no-console
129
+ console.warn("Unable to decode window.ImtblCheckoutWidgetConfig: ", err);
130
+ }
131
+ Object.values(($045213b18e9f1f94$export$75be0f6af9650f2c)).forEach((elem)=>{
132
+ const widgets = document.getElementsByTagName(elem);
133
+ if (!widgets) return;
134
+ // Loop through all the widgets to ensure that the script
135
+ // get the correct local configs for the DOM elements and
136
+ // simply update the global configurations.
137
+ for (const e of widgets){
138
+ const widgetConf = $430e3eda76fa4d5f$var$getWidgetConfig(e) || {};
139
+ $430e3eda76fa4d5f$var$setWidgetConfig(e, {
140
+ ...widgetConf,
141
+ ...config
142
+ });
143
+ }
144
+ });
145
+ $430e3eda76fa4d5f$var$saveConfig({
146
+ ...globalConfig,
147
+ ...config
148
+ });
59
149
  }
60
150
 
61
151
 
@@ -162,27 +252,6 @@ $parcel$export($d882ddc5600b1284$exports, "OnRampEventType", () => $d882ddc5600b
162
252
  OnRampEventType["SUCCESS"] = "success";
163
253
  OnRampEventType["FAILURE"] = "failure";
164
254
  })($d882ddc5600b1284$export$66ec39c0924078d8 || ($d882ddc5600b1284$export$66ec39c0924078d8 = {}));
165
- /* eslint-disable @typescript-eslint/naming-convention */
166
-
167
- var $045213b18e9f1f94$exports = {};
168
-
169
- $parcel$export($045213b18e9f1f94$exports, "WidgetTheme", () => $045213b18e9f1f94$export$c88931fdc51854eb);
170
- $parcel$export($045213b18e9f1f94$exports, "CheckoutWidgetTagNames", () => $045213b18e9f1f94$export$75be0f6af9650f2c);
171
- /**
172
- * Enum representing the themes for the Checkout widgets.
173
- */ var $045213b18e9f1f94$export$c88931fdc51854eb;
174
- (function(WidgetTheme) {
175
- WidgetTheme["LIGHT"] = "light";
176
- WidgetTheme["DARK"] = "dark";
177
- })($045213b18e9f1f94$export$c88931fdc51854eb || ($045213b18e9f1f94$export$c88931fdc51854eb = {}));
178
- var $045213b18e9f1f94$export$75be0f6af9650f2c;
179
- (function(CheckoutWidgetTagNames) {
180
- CheckoutWidgetTagNames["CONNECT"] = "imtbl-connect";
181
- CheckoutWidgetTagNames["WALLET"] = "imtbl-wallet";
182
- CheckoutWidgetTagNames["SWAP"] = "imtbl-swap";
183
- CheckoutWidgetTagNames["BRIDGE"] = "imtbl-bridge";
184
- CheckoutWidgetTagNames["ONRAMP"] = "imtbl-onramp";
185
- })($045213b18e9f1f94$export$75be0f6af9650f2c || ($045213b18e9f1f94$export$75be0f6af9650f2c = {}));
186
255
 
187
256
 
188
257
  var $1f969328e5988c99$exports = {};
@@ -16,7 +16,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
16
16
  chainID,
17
17
  coreContractAddress,
18
18
  registrationContractAddress,
19
- sdkVersion: 'ts-immutable-sdk-0.22.3',
19
+ sdkVersion: 'ts-immutable-sdk-0.23.1',
20
20
  });
21
21
  /**
22
22
  * Sets `sdkVersion` at the time of build