@imtbl/sdk 0.28.10-alpha.1 → 0.29.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/README.md +147 -0
- package/dist/blockchain_data.d.ts +14 -5
- package/dist/blockchain_data.js +1 -1
- package/dist/browser/checkout.js +2 -0
- package/dist/checkout_sdk.d.ts +238 -920
- package/dist/checkout_sdk.js +2396 -2907
- package/dist/checkout_widgets.d.ts +25614 -0
- package/dist/checkout_widgets.js +450 -0
- package/dist/config.d.ts +18 -6
- package/dist/config.js +21 -20
- package/dist/immutablex_client.d.ts +14 -5
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +21 -12
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +3061 -3045
- package/dist/index.d.ts +15444 -1169
- package/dist/index.js +3061 -3046
- package/dist/orderbook.d.ts +14 -5
- package/dist/passport.d.ts +14 -5
- package/dist/passport.js +145 -97
- package/dist/provider.d.ts +14 -5
- package/package.json +6 -17
- package/dist/browser/checkout/sdk.js +0 -35
- package/dist/browser/checkout/widgets.js +0 -890
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
|
|
4
|
+
function $parcel$export(e, n, v, s) {
|
|
5
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
6
|
+
}
|
|
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.29.0";
|
|
29
|
+
const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
|
|
30
|
+
const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
|
|
31
|
+
|
|
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
|
+
}
|
|
55
|
+
function $430e3eda76fa4d5f$export$46b1ae20f762ad4c(version) {
|
|
56
|
+
const defaultPackageVersion = ($d663162fd5a0853f$export$1169f5475725171b)();
|
|
57
|
+
if (version === undefined || version.major === undefined) return defaultPackageVersion;
|
|
58
|
+
if (!Number.isInteger(version.major) || version.major < 0) return defaultPackageVersion;
|
|
59
|
+
if (version.minor !== undefined && version.minor < 0) return defaultPackageVersion;
|
|
60
|
+
if (version.patch !== undefined && version.patch < 0) return defaultPackageVersion;
|
|
61
|
+
if (version.major === 0 && version.minor === undefined) return defaultPackageVersion;
|
|
62
|
+
if (version.major === 0 && version.minor === 0 && version.patch === undefined) return defaultPackageVersion;
|
|
63
|
+
if (version.major === 0 && version.minor === undefined && version.patch === undefined) return defaultPackageVersion;
|
|
64
|
+
if (version.major === 0 && version.minor === 0 && version.patch === 0) return defaultPackageVersion;
|
|
65
|
+
let validatedVersion = version.major.toString();
|
|
66
|
+
if (version.minor === undefined) return validatedVersion;
|
|
67
|
+
if (Number.isInteger(version.minor)) validatedVersion += `.${version.minor.toString()}`;
|
|
68
|
+
if (version.patch === undefined) return validatedVersion;
|
|
69
|
+
if (Number.isInteger(version.patch)) validatedVersion += `.${version.patch.toString()}`;
|
|
70
|
+
if (version.prerelease === undefined || version.prerelease !== "alpha") return validatedVersion;
|
|
71
|
+
if (version.prerelease === "alpha") validatedVersion += `-${version.prerelease}`;
|
|
72
|
+
if (version.build === undefined) return validatedVersion;
|
|
73
|
+
if (Number.isInteger(version.build) && version.build >= 0) validatedVersion += `.${version.build.toString()}`;
|
|
74
|
+
return validatedVersion;
|
|
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
|
+
}
|
|
99
|
+
function $430e3eda76fa4d5f$export$af210a0808087845(config) {
|
|
100
|
+
if (window === undefined) {
|
|
101
|
+
// eslint-disable-next-line no-console
|
|
102
|
+
console.error("missing window object: please run Checkout client side");
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (document === undefined) {
|
|
106
|
+
// eslint-disable-next-line no-console
|
|
107
|
+
console.error("missing document object: please run Checkout client side");
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
$430e3eda76fa4d5f$var$loadScript(config || {});
|
|
111
|
+
$430e3eda76fa4d5f$var$saveConfig(config || {});
|
|
112
|
+
}
|
|
113
|
+
function $430e3eda76fa4d5f$export$bf1548ba7e61c17f(config) {
|
|
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) {
|
|
120
|
+
// eslint-disable-next-line no-console
|
|
121
|
+
console.error("missing document object: please run Checkout client side");
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
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
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
var $207ed853f11d19d5$exports = {};
|
|
153
|
+
|
|
154
|
+
$parcel$export($207ed853f11d19d5$exports, "IMTBLWidgetEvents", () => $207ed853f11d19d5$export$5a0ace85cae72d45);
|
|
155
|
+
var $207ed853f11d19d5$export$5a0ace85cae72d45;
|
|
156
|
+
(function(IMTBLWidgetEvents) {
|
|
157
|
+
IMTBLWidgetEvents["IMTBL_CONNECT_WIDGET_EVENT"] = "imtbl-connect-widget";
|
|
158
|
+
IMTBLWidgetEvents["IMTBL_WALLET_WIDGET_EVENT"] = "imtbl-wallet-widget";
|
|
159
|
+
IMTBLWidgetEvents["IMTBL_SWAP_WIDGET_EVENT"] = "imtbl-swap-widget";
|
|
160
|
+
IMTBLWidgetEvents["IMTBL_BRIDGE_WIDGET_EVENT"] = "imtbl-bridge-widget";
|
|
161
|
+
IMTBLWidgetEvents["IMTBL_ONRAMP_WIDGET_EVENT"] = "imtbl-onramp-widget";
|
|
162
|
+
IMTBLWidgetEvents["IMTBL_SALE_WIDGET_EVENT"] = "imtbl-sale-widget";
|
|
163
|
+
})($207ed853f11d19d5$export$5a0ace85cae72d45 || ($207ed853f11d19d5$export$5a0ace85cae72d45 = {}));
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
var $a85ecdbd885c58ad$exports = {};
|
|
167
|
+
|
|
168
|
+
$parcel$export($a85ecdbd885c58ad$exports, "ConnectEventType", () => $a85ecdbd885c58ad$export$e72e7f9969a47dd3);
|
|
169
|
+
var $a85ecdbd885c58ad$export$e72e7f9969a47dd3;
|
|
170
|
+
(function(ConnectEventType) {
|
|
171
|
+
ConnectEventType["CLOSE_WIDGET"] = "close-widget";
|
|
172
|
+
ConnectEventType["SUCCESS"] = "success";
|
|
173
|
+
ConnectEventType["FAILURE"] = "failure";
|
|
174
|
+
})($a85ecdbd885c58ad$export$e72e7f9969a47dd3 || ($a85ecdbd885c58ad$export$e72e7f9969a47dd3 = {}));
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
var $77b6aac5c353d4a9$exports = {};
|
|
178
|
+
|
|
179
|
+
$parcel$export($77b6aac5c353d4a9$exports, "WalletEventType", () => $77b6aac5c353d4a9$export$d9be06b70b28c742);
|
|
180
|
+
var $77b6aac5c353d4a9$export$d9be06b70b28c742;
|
|
181
|
+
(function(WalletEventType) {
|
|
182
|
+
WalletEventType["CLOSE_WIDGET"] = "close-widget";
|
|
183
|
+
WalletEventType["NETWORK_SWITCH"] = "network-switch";
|
|
184
|
+
WalletEventType["DISCONNECT_WALLET"] = "disconnect-wallet";
|
|
185
|
+
})($77b6aac5c353d4a9$export$d9be06b70b28c742 || ($77b6aac5c353d4a9$export$d9be06b70b28c742 = {}));
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
var $53d219e7f6bf0cd6$exports = {};
|
|
189
|
+
|
|
190
|
+
$parcel$export($53d219e7f6bf0cd6$exports, "SwapEventType", () => $53d219e7f6bf0cd6$export$140a49745ab55563);
|
|
191
|
+
/**
|
|
192
|
+
* Enum representing possible Swap Widget event types.
|
|
193
|
+
*/ var $53d219e7f6bf0cd6$export$140a49745ab55563;
|
|
194
|
+
(function(SwapEventType) {
|
|
195
|
+
SwapEventType["CLOSE_WIDGET"] = "close-widget";
|
|
196
|
+
SwapEventType["SUCCESS"] = "success";
|
|
197
|
+
SwapEventType["FAILURE"] = "failure";
|
|
198
|
+
SwapEventType["REJECTED"] = "rejected";
|
|
199
|
+
})($53d219e7f6bf0cd6$export$140a49745ab55563 || ($53d219e7f6bf0cd6$export$140a49745ab55563 = {}));
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
var $9b3189b6b155842e$exports = {};
|
|
203
|
+
|
|
204
|
+
$parcel$export($9b3189b6b155842e$exports, "SaleEventType", () => $9b3189b6b155842e$export$881881ffb3bd733e);
|
|
205
|
+
/**
|
|
206
|
+
* Enum representing possible Sale Widget event types.
|
|
207
|
+
*/ var $9b3189b6b155842e$export$881881ffb3bd733e;
|
|
208
|
+
(function(SaleEventType) {
|
|
209
|
+
SaleEventType["CLOSE_WIDGET"] = "close-widget";
|
|
210
|
+
SaleEventType["SUCCESS"] = "success";
|
|
211
|
+
SaleEventType["FAILURE"] = "failure";
|
|
212
|
+
SaleEventType["REJECTED"] = "rejected";
|
|
213
|
+
SaleEventType["TRANSACTION_SUCCESS"] = "transaction-success";
|
|
214
|
+
})($9b3189b6b155842e$export$881881ffb3bd733e || ($9b3189b6b155842e$export$881881ffb3bd733e = {}));
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
var $15cc9e120aa6f3bf$exports = {};
|
|
218
|
+
|
|
219
|
+
$parcel$export($15cc9e120aa6f3bf$exports, "BridgeEventType", () => $15cc9e120aa6f3bf$export$d1bfa21f7c76447a);
|
|
220
|
+
/**
|
|
221
|
+
* Enum of possible Bridge Widget event types.
|
|
222
|
+
*/ var $15cc9e120aa6f3bf$export$d1bfa21f7c76447a;
|
|
223
|
+
(function(BridgeEventType) {
|
|
224
|
+
BridgeEventType["CLOSE_WIDGET"] = "close-widget";
|
|
225
|
+
BridgeEventType["SUCCESS"] = "success";
|
|
226
|
+
BridgeEventType["FAILURE"] = "failure";
|
|
227
|
+
})($15cc9e120aa6f3bf$export$d1bfa21f7c76447a || ($15cc9e120aa6f3bf$export$d1bfa21f7c76447a = {}));
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
var $ad06b030b1a3ba34$exports = {};
|
|
231
|
+
|
|
232
|
+
$parcel$export($ad06b030b1a3ba34$exports, "OrchestrationEventType", () => $ad06b030b1a3ba34$export$b80d2daf830437b9);
|
|
233
|
+
/**
|
|
234
|
+
* Enum representing different types of orchestration events.
|
|
235
|
+
*/ var $ad06b030b1a3ba34$export$b80d2daf830437b9;
|
|
236
|
+
(function(OrchestrationEventType) {
|
|
237
|
+
OrchestrationEventType["REQUEST_CONNECT"] = "request-connect";
|
|
238
|
+
OrchestrationEventType["REQUEST_WALLET"] = "request-wallet";
|
|
239
|
+
OrchestrationEventType["REQUEST_SWAP"] = "request-swap";
|
|
240
|
+
OrchestrationEventType["REQUEST_BRIDGE"] = "request-bridge";
|
|
241
|
+
OrchestrationEventType["REQUEST_ONRAMP"] = "request-onramp";
|
|
242
|
+
})($ad06b030b1a3ba34$export$b80d2daf830437b9 || ($ad06b030b1a3ba34$export$b80d2daf830437b9 = {}));
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
var $d882ddc5600b1284$exports = {};
|
|
246
|
+
|
|
247
|
+
$parcel$export($d882ddc5600b1284$exports, "OnRampEventType", () => $d882ddc5600b1284$export$66ec39c0924078d8);
|
|
248
|
+
/**
|
|
249
|
+
* Enum of possible OnRamp Widget event types.
|
|
250
|
+
*/ var $d882ddc5600b1284$export$66ec39c0924078d8;
|
|
251
|
+
(function(OnRampEventType) {
|
|
252
|
+
OnRampEventType["CLOSE_WIDGET"] = "close-widget";
|
|
253
|
+
OnRampEventType["SUCCESS"] = "success";
|
|
254
|
+
OnRampEventType["FAILURE"] = "failure";
|
|
255
|
+
})($d882ddc5600b1284$export$66ec39c0924078d8 || ($d882ddc5600b1284$export$66ec39c0924078d8 = {}));
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
var $1f969328e5988c99$exports = {};
|
|
259
|
+
|
|
260
|
+
$parcel$export($1f969328e5988c99$exports, "BridgeReact", () => $1f969328e5988c99$export$30f61ebf204c69f6);
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
function $77ec335383336bdd$export$931068bc678f0d73(tagName, provider) {
|
|
264
|
+
if (!provider) {
|
|
265
|
+
// eslint-disable-next-line no-console
|
|
266
|
+
console.error("no provider parsed");
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
if (window === undefined) {
|
|
270
|
+
// eslint-disable-next-line no-console
|
|
271
|
+
console.error("missing window object: please run Checkout client side");
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
let attempts = 0;
|
|
275
|
+
const maxAttempts = 10;
|
|
276
|
+
let timer;
|
|
277
|
+
const attemptToSetProvider = ()=>{
|
|
278
|
+
try {
|
|
279
|
+
const elements = document.getElementsByTagName(tagName);
|
|
280
|
+
const widget = elements[0];
|
|
281
|
+
widget.setProvider(provider);
|
|
282
|
+
window.clearInterval(timer);
|
|
283
|
+
} catch (err) {
|
|
284
|
+
attempts++;
|
|
285
|
+
if (attempts >= maxAttempts) {
|
|
286
|
+
window.clearInterval(timer);
|
|
287
|
+
// eslint-disable-next-line no-console
|
|
288
|
+
console.error("failed to set the provider");
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
timer = window.setInterval(attemptToSetProvider, 10);
|
|
293
|
+
attemptToSetProvider();
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
function $b222a8f062090058$export$fae4199086a966a3(tagName, passport) {
|
|
299
|
+
if (!passport) {
|
|
300
|
+
// eslint-disable-next-line no-console
|
|
301
|
+
console.error("no passport provided");
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
if (window === undefined) {
|
|
305
|
+
// eslint-disable-next-line no-console
|
|
306
|
+
console.error("missing window object: please run Checkout client side");
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
let attempts = 0;
|
|
310
|
+
const maxAttempts = 10;
|
|
311
|
+
let timer;
|
|
312
|
+
const attemptToAddPassport = ()=>{
|
|
313
|
+
try {
|
|
314
|
+
const elements = document.getElementsByTagName(tagName);
|
|
315
|
+
const widget = elements[0];
|
|
316
|
+
widget.addPassportOption(passport);
|
|
317
|
+
window.clearInterval(timer);
|
|
318
|
+
} catch (err) {
|
|
319
|
+
attempts++;
|
|
320
|
+
if (attempts >= maxAttempts) {
|
|
321
|
+
window.clearInterval(timer);
|
|
322
|
+
// eslint-disable-next-line no-console
|
|
323
|
+
console.error("failed to set the provider", err);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
timer = window.setInterval(attemptToAddPassport, 10);
|
|
328
|
+
attemptToAddPassport();
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
function $1f969328e5988c99$export$30f61ebf204c69f6(props) {
|
|
333
|
+
const { walletProvider: walletProvider, fromContractAddress: fromContractAddress, amount: amount, provider: provider, passport: passport } = props;
|
|
334
|
+
(useEffect)(()=>{
|
|
335
|
+
if (provider) ($77ec335383336bdd$export$931068bc678f0d73)(($045213b18e9f1f94$export$75be0f6af9650f2c).BRIDGE, provider);
|
|
336
|
+
if (passport) ($b222a8f062090058$export$fae4199086a966a3)(($045213b18e9f1f94$export$75be0f6af9650f2c).BRIDGE, passport);
|
|
337
|
+
}, [
|
|
338
|
+
provider,
|
|
339
|
+
passport
|
|
340
|
+
]);
|
|
341
|
+
const config = window.ImtblCheckoutWidgetConfig;
|
|
342
|
+
return /*#__PURE__*/ (jsx)("imtbl-bridge", {
|
|
343
|
+
widgetConfig: config,
|
|
344
|
+
walletProvider: walletProvider,
|
|
345
|
+
fromContractAddress: fromContractAddress ?? "",
|
|
346
|
+
amount: amount ?? ""
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
var $f2083cd30e2f5c56$exports = {};
|
|
352
|
+
|
|
353
|
+
$parcel$export($f2083cd30e2f5c56$exports, "ConnectReact", () => $f2083cd30e2f5c56$export$49d62957f420a1e2);
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
function $f2083cd30e2f5c56$export$49d62957f420a1e2({ passport: passport }) {
|
|
359
|
+
const config = window.ImtblCheckoutWidgetConfig;
|
|
360
|
+
(useEffect)(()=>{
|
|
361
|
+
if (passport) ($b222a8f062090058$export$fae4199086a966a3)(($045213b18e9f1f94$export$75be0f6af9650f2c).CONNECT, passport);
|
|
362
|
+
}, [
|
|
363
|
+
passport
|
|
364
|
+
]);
|
|
365
|
+
return /*#__PURE__*/ (jsx)("imtbl-connect", {
|
|
366
|
+
widgetConfig: config
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
var $a4fbb8e3a6aeff58$exports = {};
|
|
372
|
+
|
|
373
|
+
$parcel$export($a4fbb8e3a6aeff58$exports, "SwapReact", () => $a4fbb8e3a6aeff58$export$971e031379577f4);
|
|
374
|
+
/* eslint-disable max-len */
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
function $a4fbb8e3a6aeff58$export$971e031379577f4(props) {
|
|
380
|
+
const { walletProvider: walletProvider, fromContractAddress: fromContractAddress, amount: amount, toContractAddress: toContractAddress, provider: provider, passport: passport } = props;
|
|
381
|
+
(useEffect)(()=>{
|
|
382
|
+
if (provider) ($77ec335383336bdd$export$931068bc678f0d73)(($045213b18e9f1f94$export$75be0f6af9650f2c).SWAP, provider);
|
|
383
|
+
if (passport) ($b222a8f062090058$export$fae4199086a966a3)(($045213b18e9f1f94$export$75be0f6af9650f2c).SWAP, passport);
|
|
384
|
+
}, [
|
|
385
|
+
provider,
|
|
386
|
+
passport
|
|
387
|
+
]);
|
|
388
|
+
const config = window.ImtblCheckoutWidgetConfig;
|
|
389
|
+
return /*#__PURE__*/ (jsx)("imtbl-swap", {
|
|
390
|
+
widgetConfig: config,
|
|
391
|
+
walletProvider: walletProvider,
|
|
392
|
+
fromContractAddress: fromContractAddress ?? "",
|
|
393
|
+
toContractAddress: toContractAddress ?? "",
|
|
394
|
+
amount: amount ?? ""
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
var $89d55ace0f8f1c07$exports = {};
|
|
400
|
+
|
|
401
|
+
$parcel$export($89d55ace0f8f1c07$exports, "WalletReact", () => $89d55ace0f8f1c07$export$ceaac94f34dba154);
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
function $89d55ace0f8f1c07$export$ceaac94f34dba154(props) {
|
|
408
|
+
const { walletProvider: walletProvider, provider: provider, passport: passport } = props;
|
|
409
|
+
(useEffect)(()=>{
|
|
410
|
+
if (provider) ($77ec335383336bdd$export$931068bc678f0d73)(($045213b18e9f1f94$export$75be0f6af9650f2c).WALLET, provider);
|
|
411
|
+
if (passport) ($b222a8f062090058$export$fae4199086a966a3)(($045213b18e9f1f94$export$75be0f6af9650f2c).WALLET, passport);
|
|
412
|
+
}, [
|
|
413
|
+
provider,
|
|
414
|
+
passport
|
|
415
|
+
]);
|
|
416
|
+
const config = window.ImtblCheckoutWidgetConfig;
|
|
417
|
+
return /*#__PURE__*/ (jsx)("imtbl-wallet", {
|
|
418
|
+
widgetConfig: config,
|
|
419
|
+
walletProvider: walletProvider
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
var $f94f63f2c041a04c$exports = {};
|
|
425
|
+
|
|
426
|
+
$parcel$export($f94f63f2c041a04c$exports, "OnRampReact", () => $f94f63f2c041a04c$export$9e363c61ea99bbb4);
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
function $f94f63f2c041a04c$export$9e363c61ea99bbb4(props) {
|
|
433
|
+
const { walletProvider: walletProvider, amount: amount, provider: provider, passport: passport, contractAddress: contractAddress } = props;
|
|
434
|
+
(useEffect)(()=>{
|
|
435
|
+
if (provider) ($77ec335383336bdd$export$931068bc678f0d73)(($045213b18e9f1f94$export$75be0f6af9650f2c).ONRAMP, provider);
|
|
436
|
+
if (passport) ($b222a8f062090058$export$fae4199086a966a3)(($045213b18e9f1f94$export$75be0f6af9650f2c).ONRAMP, passport);
|
|
437
|
+
}, [
|
|
438
|
+
provider,
|
|
439
|
+
passport
|
|
440
|
+
]);
|
|
441
|
+
const config = window.ImtblCheckoutWidgetConfig;
|
|
442
|
+
return /*#__PURE__*/ (jsx)("imtbl-onramp", {
|
|
443
|
+
widgetConfig: config,
|
|
444
|
+
walletProvider: walletProvider,
|
|
445
|
+
amount: amount ?? "",
|
|
446
|
+
contractAddress: contractAddress ?? ""
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
export { $15cc9e120aa6f3bf$export$d1bfa21f7c76447a as BridgeEventType, $1f969328e5988c99$export$30f61ebf204c69f6 as BridgeReact, $045213b18e9f1f94$export$75be0f6af9650f2c as CheckoutWidgetTagNames, $430e3eda76fa4d5f$export$af210a0808087845 as CheckoutWidgets, $a85ecdbd885c58ad$export$e72e7f9969a47dd3 as ConnectEventType, $f2083cd30e2f5c56$export$49d62957f420a1e2 as ConnectReact, $207ed853f11d19d5$export$5a0ace85cae72d45 as IMTBLWidgetEvents, $d882ddc5600b1284$export$66ec39c0924078d8 as OnRampEventType, $f94f63f2c041a04c$export$9e363c61ea99bbb4 as OnRampReact, $ad06b030b1a3ba34$export$b80d2daf830437b9 as OrchestrationEventType, $9b3189b6b155842e$export$881881ffb3bd733e as SaleEventType, $53d219e7f6bf0cd6$export$140a49745ab55563 as SwapEventType, $a4fbb8e3a6aeff58$export$971e031379577f4 as SwapReact, $430e3eda76fa4d5f$export$bf1548ba7e61c17f as UpdateConfig, $77b6aac5c353d4a9$export$d9be06b70b28c742 as WalletEventType, $89d55ace0f8f1c07$export$ceaac94f34dba154 as WalletReact, $045213b18e9f1f94$export$c88931fdc51854eb as WidgetTheme };
|
package/dist/config.d.ts
CHANGED
|
@@ -6,17 +6,29 @@ declare class ImmutableConfiguration {
|
|
|
6
6
|
readonly environment: Environment;
|
|
7
7
|
readonly rateLimitingKey?: string;
|
|
8
8
|
readonly apiKey?: string;
|
|
9
|
-
readonly
|
|
9
|
+
readonly publishableKey?: string;
|
|
10
10
|
constructor(options: {
|
|
11
11
|
environment: Environment;
|
|
12
|
-
rateLimitingKey?: string;
|
|
13
|
-
apiKey?: string;
|
|
14
|
-
clientAppId?: string;
|
|
15
12
|
});
|
|
16
13
|
}
|
|
14
|
+
declare const addApiKeyToAxiosHeader: (apiKey: string) => void;
|
|
15
|
+
declare const addPublishableKeyToAxiosHeader: (publishableKey: string) => void;
|
|
16
|
+
declare const addRateLimitingKeyToAxiosHeader: (rateLimitingKey: string) => void;
|
|
17
|
+
type ImmutableConfigurationWithRequireableFields<T> = ImmutableConfiguration & (T extends {
|
|
18
|
+
apiKey: 'required';
|
|
19
|
+
} ? Required<{
|
|
20
|
+
apiKey: string;
|
|
21
|
+
}> : {}) & (T extends {
|
|
22
|
+
publishableKey: 'required';
|
|
23
|
+
} ? Required<{
|
|
24
|
+
publishableKey: string;
|
|
25
|
+
}> : {});
|
|
26
|
+
type ImmutableConfigurationWithOmitableFields<T> = (T extends {
|
|
27
|
+
apiKey: 'omit';
|
|
28
|
+
} ? Omit<ImmutableConfigurationWithRequireableFields<T>, 'apiKey'> : ImmutableConfigurationWithRequireableFields<T>);
|
|
17
29
|
interface ModuleConfiguration<T> {
|
|
18
|
-
baseConfig:
|
|
30
|
+
baseConfig: ImmutableConfigurationWithOmitableFields<T>;
|
|
19
31
|
overrides?: T;
|
|
20
32
|
}
|
|
21
33
|
|
|
22
|
-
export { Environment, ImmutableConfiguration, ModuleConfiguration };
|
|
34
|
+
export { Environment, ImmutableConfiguration, ModuleConfiguration, addApiKeyToAxiosHeader, addPublishableKeyToAxiosHeader, addRateLimitingKeyToAxiosHeader };
|
package/dist/config.js
CHANGED
|
@@ -9,28 +9,29 @@ class ImmutableConfiguration {
|
|
|
9
9
|
environment;
|
|
10
10
|
rateLimitingKey;
|
|
11
11
|
apiKey;
|
|
12
|
-
|
|
12
|
+
publishableKey;
|
|
13
13
|
constructor(options) {
|
|
14
14
|
this.environment = options.environment;
|
|
15
|
-
if (options.rateLimitingKey) {
|
|
16
|
-
this.rateLimitingKey = options.rateLimitingKey;
|
|
17
|
-
axios.defaults.headers.common['x-api-key'] = this.rateLimitingKey;
|
|
18
|
-
}
|
|
19
|
-
if (options.apiKey) {
|
|
20
|
-
if (!options.apiKey.startsWith('sk_imapik-')) {
|
|
21
|
-
throw new Error('Invalid API key');
|
|
22
|
-
}
|
|
23
|
-
this.apiKey = options.apiKey;
|
|
24
|
-
axios.defaults.headers.common['x-immutable-api-key'] = this.apiKey;
|
|
25
|
-
}
|
|
26
|
-
if (options.clientAppId) {
|
|
27
|
-
if (!options.clientAppId.startsWith('cai_imapik-')) {
|
|
28
|
-
throw new Error('Invalid Client App Id');
|
|
29
|
-
}
|
|
30
|
-
this.clientAppId = options.clientAppId;
|
|
31
|
-
axios.defaults.headers.common['x-immutable-client-app-id'] = this.clientAppId;
|
|
32
|
-
}
|
|
33
15
|
}
|
|
34
16
|
}
|
|
17
|
+
const API_KEY_PREFIX = 'sk_imapik-';
|
|
18
|
+
const PUBLISHABLE_KEY_PREFIX = 'pk_imapik-';
|
|
19
|
+
const PUBLISHABLE_KEY_LENGTH = 30;
|
|
20
|
+
const addApiKeyToAxiosHeader = (apiKey) => {
|
|
21
|
+
if (!apiKey.startsWith(API_KEY_PREFIX)) {
|
|
22
|
+
throw new Error('Invalid API key. Create your api key in Immutable developer hub. https://hub.immutable.com');
|
|
23
|
+
}
|
|
24
|
+
axios.defaults.headers.common['x-immutable-api-key'] = apiKey;
|
|
25
|
+
};
|
|
26
|
+
const addPublishableKeyToAxiosHeader = (publishableKey) => {
|
|
27
|
+
if (!publishableKey.startsWith(PUBLISHABLE_KEY_PREFIX) || publishableKey.length !== PUBLISHABLE_KEY_LENGTH) {
|
|
28
|
+
throw new Error('Invalid Publishable key. Create your Publishable key in Immutable developer hub.'
|
|
29
|
+
+ ' https://hub.immutable.com');
|
|
30
|
+
}
|
|
31
|
+
axios.defaults.headers.common['x-immutable-publishable-key'] = publishableKey;
|
|
32
|
+
};
|
|
33
|
+
const addRateLimitingKeyToAxiosHeader = (rateLimitingKey) => {
|
|
34
|
+
axios.defaults.headers.common['x-api-key'] = rateLimitingKey;
|
|
35
|
+
};
|
|
35
36
|
|
|
36
|
-
export { Environment, ImmutableConfiguration };
|
|
37
|
+
export { Environment, ImmutableConfiguration, addApiKeyToAxiosHeader, addPublishableKeyToAxiosHeader, addRateLimitingKeyToAxiosHeader };
|
|
@@ -9742,16 +9742,25 @@ declare class ImmutableConfiguration {
|
|
|
9742
9742
|
readonly environment: Environment;
|
|
9743
9743
|
readonly rateLimitingKey?: string;
|
|
9744
9744
|
readonly apiKey?: string;
|
|
9745
|
-
readonly
|
|
9745
|
+
readonly publishableKey?: string;
|
|
9746
9746
|
constructor(options: {
|
|
9747
9747
|
environment: Environment;
|
|
9748
|
-
rateLimitingKey?: string;
|
|
9749
|
-
apiKey?: string;
|
|
9750
|
-
clientAppId?: string;
|
|
9751
9748
|
});
|
|
9752
9749
|
}
|
|
9750
|
+
type ImmutableConfigurationWithRequireableFields<T> = ImmutableConfiguration & (T extends {
|
|
9751
|
+
apiKey: 'required';
|
|
9752
|
+
} ? Required<{
|
|
9753
|
+
apiKey: string;
|
|
9754
|
+
}> : {}) & (T extends {
|
|
9755
|
+
publishableKey: 'required';
|
|
9756
|
+
} ? Required<{
|
|
9757
|
+
publishableKey: string;
|
|
9758
|
+
}> : {});
|
|
9759
|
+
type ImmutableConfigurationWithOmitableFields<T> = (T extends {
|
|
9760
|
+
apiKey: 'omit';
|
|
9761
|
+
} ? Omit<ImmutableConfigurationWithRequireableFields<T>, 'apiKey'> : ImmutableConfigurationWithRequireableFields<T>);
|
|
9753
9762
|
interface ModuleConfiguration<T> {
|
|
9754
|
-
baseConfig:
|
|
9763
|
+
baseConfig: ImmutableConfigurationWithOmitableFields<T>;
|
|
9755
9764
|
overrides?: T;
|
|
9756
9765
|
}
|
|
9757
9766
|
|
|
@@ -17,7 +17,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
17
17
|
chainID,
|
|
18
18
|
coreContractAddress,
|
|
19
19
|
registrationContractAddress,
|
|
20
|
-
sdkVersion: 'ts-immutable-sdk-0.
|
|
20
|
+
sdkVersion: 'ts-immutable-sdk-0.29.0',
|
|
21
21
|
});
|
|
22
22
|
/**
|
|
23
23
|
* Sets `sdkVersion` at the time of build
|