@imtbl/sdk 0.45.4 → 0.45.6
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.d.ts +2 -2
- package/dist/blockchain_data.js +261 -1
- package/dist/browser/checkout/sdk.js +6 -6
- package/dist/browser/checkout/widgets.js +61 -61
- package/dist/checkout.d.ts +2 -2
- package/dist/checkout.js +530 -3
- package/dist/config.d.ts +2 -2
- package/dist/config.js +272 -0
- package/dist/index.browser.js +12 -12
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +571 -6
- package/dist/index.d.ts +2 -2
- package/dist/index.js +571 -6
- package/dist/orderbook.d.ts +2 -2
- package/dist/orderbook.js +260 -0
- package/dist/passport.d.ts +2 -2
- package/dist/passport.js +296 -3
- package/dist/x.d.ts +2 -2
- package/dist/x.js +262 -2
- package/package.json +1 -1
package/dist/checkout.d.ts
CHANGED
|
@@ -10117,9 +10117,9 @@ type ImmutableConfigurationWithRequireableFields<T> = ImmutableConfiguration & (
|
|
|
10117
10117
|
} ? Required<{
|
|
10118
10118
|
publishableKey: string;
|
|
10119
10119
|
}> : {});
|
|
10120
|
-
type ImmutableConfigurationWithOmitableFields<T> =
|
|
10120
|
+
type ImmutableConfigurationWithOmitableFields<T> = T extends {
|
|
10121
10121
|
apiKey: 'omit';
|
|
10122
|
-
} ? Omit<ImmutableConfigurationWithRequireableFields<T>, 'apiKey'> : ImmutableConfigurationWithRequireableFields<T
|
|
10122
|
+
} ? Omit<ImmutableConfigurationWithRequireableFields<T>, 'apiKey'> : ImmutableConfigurationWithRequireableFields<T>;
|
|
10123
10123
|
interface ModuleConfiguration<T> {
|
|
10124
10124
|
baseConfig: ImmutableConfigurationWithOmitableFields<T>;
|
|
10125
10125
|
overrides?: T;
|
package/dist/checkout.js
CHANGED
|
@@ -11,6 +11,271 @@ import { SwapRouter, PaymentsExtended } from '@uniswap/router-sdk';
|
|
|
11
11
|
import FormData$2 from 'form-data';
|
|
12
12
|
import { Seaport as Seaport$1 } from '@opensea/seaport-js';
|
|
13
13
|
|
|
14
|
+
const isNode$1 = () => typeof window === 'undefined';
|
|
15
|
+
const isBrowser$1 = () => !isNode$1();
|
|
16
|
+
|
|
17
|
+
var Detail$1;
|
|
18
|
+
(function (Detail) {
|
|
19
|
+
Detail["RUNTIME_ID"] = "rid";
|
|
20
|
+
Detail["PASSPORT_CLIENT_ID"] = "passportClientId";
|
|
21
|
+
Detail["ENVIRONMENT"] = "env";
|
|
22
|
+
Detail["PUBLISHABLE_API_KEY"] = "pak";
|
|
23
|
+
Detail["IDENTITY"] = "uid";
|
|
24
|
+
Detail["DOMAIN"] = "domain";
|
|
25
|
+
})(Detail$1 || (Detail$1 = {}));
|
|
26
|
+
var Store$1;
|
|
27
|
+
(function (Store) {
|
|
28
|
+
Store["EVENTS"] = "events";
|
|
29
|
+
Store["RUNTIME"] = "runtime";
|
|
30
|
+
})(Store$1 || (Store$1 = {}));
|
|
31
|
+
const POLLING_FREQUENCY$1 = 5000;
|
|
32
|
+
|
|
33
|
+
const IMTBL_API$1 = 'https://api.x.immutable.com';
|
|
34
|
+
async function post$1(path, data) {
|
|
35
|
+
const client = globalAxios.create({
|
|
36
|
+
baseURL: IMTBL_API$1,
|
|
37
|
+
});
|
|
38
|
+
const payload = JSON.stringify(data);
|
|
39
|
+
const body = {
|
|
40
|
+
payload: btoa(payload),
|
|
41
|
+
};
|
|
42
|
+
const response = await client.post(path, body);
|
|
43
|
+
return response.data;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Abstraction on localstorage
|
|
48
|
+
*/
|
|
49
|
+
const localStoragePrefix$1 = '__IMX-';
|
|
50
|
+
const hasLocalstorage$1 = () => isBrowser$1() && window.localStorage;
|
|
51
|
+
const parseItem$1 = (payload) => {
|
|
52
|
+
// Try to parse, if can't be parsed assume string
|
|
53
|
+
// and return string
|
|
54
|
+
if (payload === null)
|
|
55
|
+
return undefined;
|
|
56
|
+
try {
|
|
57
|
+
return JSON.parse(payload);
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
// Assumes it's a string.
|
|
61
|
+
return payload;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const serialiseItem$1 = (payload) => {
|
|
65
|
+
if (typeof payload === 'string') {
|
|
66
|
+
return payload;
|
|
67
|
+
}
|
|
68
|
+
return JSON.stringify(payload);
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* GenKey will take into account the namespace
|
|
72
|
+
* as well as if being run in the Link, it will tap into the link
|
|
73
|
+
* @param {string} key
|
|
74
|
+
* @returns key
|
|
75
|
+
*/
|
|
76
|
+
const genKey$1 = (key) => `${localStoragePrefix$1}${key}`;
|
|
77
|
+
function getItem$1(key) {
|
|
78
|
+
if (hasLocalstorage$1()) {
|
|
79
|
+
return parseItem$1(window.localStorage.getItem(genKey$1(key)));
|
|
80
|
+
}
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
const setItem$1 = (key, payload) => {
|
|
84
|
+
if (hasLocalstorage$1()) {
|
|
85
|
+
window.localStorage.setItem(genKey$1(key), serialiseItem$1(payload));
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
return false;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
// In memory storage for events and other data
|
|
92
|
+
let EVENT_STORE$1;
|
|
93
|
+
let RUNTIME_DETAILS$1;
|
|
94
|
+
// Initialise store and runtime
|
|
95
|
+
const initialise$1$1 = () => {
|
|
96
|
+
EVENT_STORE$1 = getItem$1(Store$1.EVENTS) || [];
|
|
97
|
+
RUNTIME_DETAILS$1 = getItem$1(Store$1.RUNTIME) || {};
|
|
98
|
+
};
|
|
99
|
+
initialise$1$1();
|
|
100
|
+
// Runtime Details
|
|
101
|
+
const storeDetail$1 = (key, value) => {
|
|
102
|
+
RUNTIME_DETAILS$1 = {
|
|
103
|
+
...RUNTIME_DETAILS$1,
|
|
104
|
+
[key]: value,
|
|
105
|
+
};
|
|
106
|
+
setItem$1(Store$1.RUNTIME, RUNTIME_DETAILS$1);
|
|
107
|
+
};
|
|
108
|
+
const getDetail$1 = (key) => {
|
|
109
|
+
// Handle the scenario where detail is a falsy value
|
|
110
|
+
if (RUNTIME_DETAILS$1[key] === undefined) {
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
113
|
+
return RUNTIME_DETAILS$1[key];
|
|
114
|
+
};
|
|
115
|
+
const getAllDetails$1 = () => RUNTIME_DETAILS$1;
|
|
116
|
+
// Events
|
|
117
|
+
const getEvents$1 = () => EVENT_STORE$1;
|
|
118
|
+
const addEvent$1 = (event) => {
|
|
119
|
+
EVENT_STORE$1.push(event);
|
|
120
|
+
setItem$1(Store$1.EVENTS, EVENT_STORE$1);
|
|
121
|
+
};
|
|
122
|
+
const removeSentEvents$1 = (numberOfEvents) => {
|
|
123
|
+
EVENT_STORE$1 = EVENT_STORE$1.slice(numberOfEvents);
|
|
124
|
+
setItem$1(Store$1.EVENTS, EVENT_STORE$1);
|
|
125
|
+
};
|
|
126
|
+
const flattenProperties$1 = (properties) => {
|
|
127
|
+
const propertyMap = [];
|
|
128
|
+
Object.entries(properties).forEach(([key, value]) => {
|
|
129
|
+
if (typeof key === 'string'
|
|
130
|
+
|| typeof value === 'string'
|
|
131
|
+
|| typeof value === 'number'
|
|
132
|
+
|| typeof value === 'boolean') {
|
|
133
|
+
propertyMap.push([key, value.toString()]);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
return propertyMap;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
let initialised$1 = false;
|
|
140
|
+
const isInitialised$1 = () => initialised$1;
|
|
141
|
+
const getReferrer$1 = () => {
|
|
142
|
+
if (isNode$1()) {
|
|
143
|
+
return '';
|
|
144
|
+
}
|
|
145
|
+
if (window.location.ancestorOrigins
|
|
146
|
+
&& window.location.ancestorOrigins.length > 0) {
|
|
147
|
+
return new URL(window.location.ancestorOrigins[0]).hostname;
|
|
148
|
+
}
|
|
149
|
+
return document.referrer ? new URL(window.document.referrer).hostname : '';
|
|
150
|
+
};
|
|
151
|
+
const runtimeHost$1 = () => {
|
|
152
|
+
if (isNode$1()) {
|
|
153
|
+
return '';
|
|
154
|
+
}
|
|
155
|
+
if (window.opener || window.parent !== window) {
|
|
156
|
+
return getReferrer$1();
|
|
157
|
+
}
|
|
158
|
+
return new URL(window.location.href).hostname;
|
|
159
|
+
};
|
|
160
|
+
const getRuntimeDetails$1 = () => {
|
|
161
|
+
if (isNode$1()) {
|
|
162
|
+
return { browser: 'nodejs' };
|
|
163
|
+
}
|
|
164
|
+
const domain = runtimeHost$1();
|
|
165
|
+
if (domain) {
|
|
166
|
+
storeDetail$1(Detail$1.DOMAIN, domain);
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
browser: window.navigator.userAgent,
|
|
170
|
+
domain,
|
|
171
|
+
tz: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
172
|
+
screen: `${window.screen.width}x${window.screen.height}`,
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
const initialise$2 = async () => {
|
|
176
|
+
const runtimeDetails = flattenProperties$1(getRuntimeDetails$1());
|
|
177
|
+
// Get any existing runtimeId and send it along with the initialise
|
|
178
|
+
const existingRuntimeId = getDetail$1(Detail$1.RUNTIME_ID);
|
|
179
|
+
const body = {
|
|
180
|
+
version: 1,
|
|
181
|
+
data: {
|
|
182
|
+
runtimeDetails,
|
|
183
|
+
runtimeId: existingRuntimeId,
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
const response = await post$1('/v1/sdk/initialise', body);
|
|
187
|
+
// Get runtimeId and store it
|
|
188
|
+
const { runtimeId } = response;
|
|
189
|
+
storeDetail$1(Detail$1.RUNTIME_ID, runtimeId);
|
|
190
|
+
initialised$1 = true;
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
function errorBoundary$1(fn) {
|
|
194
|
+
const wrappedFunction = ((...args) => {
|
|
195
|
+
try {
|
|
196
|
+
// Execute the original function
|
|
197
|
+
const result = fn(...args);
|
|
198
|
+
if (result instanceof Promise) {
|
|
199
|
+
// Silent fail for now, in future
|
|
200
|
+
// we can send errors to a logging service
|
|
201
|
+
return result.catch(() => undefined);
|
|
202
|
+
}
|
|
203
|
+
return result;
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
// As above, fail silently for now
|
|
207
|
+
return undefined;
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
return wrappedFunction;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function isTestEnvironment$1() {
|
|
214
|
+
if (typeof process === 'undefined') {
|
|
215
|
+
return false;
|
|
216
|
+
}
|
|
217
|
+
return process.env.JEST_WORKER_ID !== undefined;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// Store the event in the event store
|
|
221
|
+
const trackFn$1 = (moduleName, eventName, properties) => {
|
|
222
|
+
const event = {
|
|
223
|
+
event: `${moduleName}.${eventName}`,
|
|
224
|
+
time: new Date().toISOString(),
|
|
225
|
+
...(properties && { properties: flattenProperties$1(properties) }),
|
|
226
|
+
};
|
|
227
|
+
addEvent$1(event);
|
|
228
|
+
};
|
|
229
|
+
const track$1 = errorBoundary$1(trackFn$1);
|
|
230
|
+
// Sending events to the server
|
|
231
|
+
const flushFn$1 = async () => {
|
|
232
|
+
// Don't flush if not initialised
|
|
233
|
+
if (isInitialised$1() === false) {
|
|
234
|
+
await initialise$2();
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
const events = getEvents$1();
|
|
238
|
+
if (events.length === 0) {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
// Track events length here, incase
|
|
242
|
+
const numEvents = events.length;
|
|
243
|
+
// Get details and send it with the track request
|
|
244
|
+
const details = getAllDetails$1();
|
|
245
|
+
const metricsPayload = {
|
|
246
|
+
version: 1,
|
|
247
|
+
data: {
|
|
248
|
+
events,
|
|
249
|
+
details,
|
|
250
|
+
},
|
|
251
|
+
};
|
|
252
|
+
const response = await post$1('/v1/sdk/metrics', metricsPayload);
|
|
253
|
+
if (response instanceof Error) {
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
// Clear events if successfully posted
|
|
257
|
+
removeSentEvents$1(numEvents);
|
|
258
|
+
};
|
|
259
|
+
const flush$1 = errorBoundary$1(flushFn$1);
|
|
260
|
+
// Flush events every 5 seconds
|
|
261
|
+
const flushPoll$1 = async () => {
|
|
262
|
+
await flush$1();
|
|
263
|
+
setTimeout(flushPoll$1, POLLING_FREQUENCY$1);
|
|
264
|
+
};
|
|
265
|
+
// This will get initialised when module is imported.
|
|
266
|
+
if (!isTestEnvironment$1()) {
|
|
267
|
+
errorBoundary$1(flushPoll$1)();
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const setEnvironmentFn = (env) => {
|
|
271
|
+
storeDetail$1(Detail$1.ENVIRONMENT, env);
|
|
272
|
+
};
|
|
273
|
+
const setEnvironment = errorBoundary$1(setEnvironmentFn);
|
|
274
|
+
|
|
275
|
+
track$1('metrics', 'sdk_version', {
|
|
276
|
+
version: '0.45.6',
|
|
277
|
+
});
|
|
278
|
+
|
|
14
279
|
var Environment$1;
|
|
15
280
|
(function (Environment) {
|
|
16
281
|
Environment["PRODUCTION"] = "production";
|
|
@@ -23,6 +288,8 @@ class ImmutableConfiguration {
|
|
|
23
288
|
publishableKey;
|
|
24
289
|
constructor(options) {
|
|
25
290
|
this.environment = options.environment;
|
|
291
|
+
setEnvironment(options.environment);
|
|
292
|
+
track$1('config', 'created_imtbl_config');
|
|
26
293
|
}
|
|
27
294
|
}
|
|
28
295
|
|
|
@@ -16695,6 +16962,266 @@ class TokenBridge {
|
|
|
16695
16962
|
}
|
|
16696
16963
|
}
|
|
16697
16964
|
|
|
16965
|
+
const isNode = () => typeof window === 'undefined';
|
|
16966
|
+
const isBrowser = () => !isNode();
|
|
16967
|
+
|
|
16968
|
+
var Detail;
|
|
16969
|
+
(function (Detail) {
|
|
16970
|
+
Detail["RUNTIME_ID"] = "rid";
|
|
16971
|
+
Detail["PASSPORT_CLIENT_ID"] = "passportClientId";
|
|
16972
|
+
Detail["ENVIRONMENT"] = "env";
|
|
16973
|
+
Detail["PUBLISHABLE_API_KEY"] = "pak";
|
|
16974
|
+
Detail["IDENTITY"] = "uid";
|
|
16975
|
+
Detail["DOMAIN"] = "domain";
|
|
16976
|
+
})(Detail || (Detail = {}));
|
|
16977
|
+
var Store;
|
|
16978
|
+
(function (Store) {
|
|
16979
|
+
Store["EVENTS"] = "events";
|
|
16980
|
+
Store["RUNTIME"] = "runtime";
|
|
16981
|
+
})(Store || (Store = {}));
|
|
16982
|
+
const POLLING_FREQUENCY = 5000;
|
|
16983
|
+
|
|
16984
|
+
const IMTBL_API = 'https://api.x.immutable.com';
|
|
16985
|
+
async function post(path, data) {
|
|
16986
|
+
const client = axios$1.create({
|
|
16987
|
+
baseURL: IMTBL_API,
|
|
16988
|
+
});
|
|
16989
|
+
const payload = JSON.stringify(data);
|
|
16990
|
+
const body = {
|
|
16991
|
+
payload: btoa(payload),
|
|
16992
|
+
};
|
|
16993
|
+
const response = await client.post(path, body);
|
|
16994
|
+
return response.data;
|
|
16995
|
+
}
|
|
16996
|
+
|
|
16997
|
+
/**
|
|
16998
|
+
* Abstraction on localstorage
|
|
16999
|
+
*/
|
|
17000
|
+
const localStoragePrefix = '__IMX-';
|
|
17001
|
+
const hasLocalstorage = () => isBrowser() && window.localStorage;
|
|
17002
|
+
const parseItem = (payload) => {
|
|
17003
|
+
// Try to parse, if can't be parsed assume string
|
|
17004
|
+
// and return string
|
|
17005
|
+
if (payload === null)
|
|
17006
|
+
return undefined;
|
|
17007
|
+
try {
|
|
17008
|
+
return JSON.parse(payload);
|
|
17009
|
+
}
|
|
17010
|
+
catch (error) {
|
|
17011
|
+
// Assumes it's a string.
|
|
17012
|
+
return payload;
|
|
17013
|
+
}
|
|
17014
|
+
};
|
|
17015
|
+
const serialiseItem = (payload) => {
|
|
17016
|
+
if (typeof payload === 'string') {
|
|
17017
|
+
return payload;
|
|
17018
|
+
}
|
|
17019
|
+
return JSON.stringify(payload);
|
|
17020
|
+
};
|
|
17021
|
+
/**
|
|
17022
|
+
* GenKey will take into account the namespace
|
|
17023
|
+
* as well as if being run in the Link, it will tap into the link
|
|
17024
|
+
* @param {string} key
|
|
17025
|
+
* @returns key
|
|
17026
|
+
*/
|
|
17027
|
+
const genKey = (key) => `${localStoragePrefix}${key}`;
|
|
17028
|
+
function getItem(key) {
|
|
17029
|
+
if (hasLocalstorage()) {
|
|
17030
|
+
return parseItem(window.localStorage.getItem(genKey(key)));
|
|
17031
|
+
}
|
|
17032
|
+
return undefined;
|
|
17033
|
+
}
|
|
17034
|
+
const setItem = (key, payload) => {
|
|
17035
|
+
if (hasLocalstorage()) {
|
|
17036
|
+
window.localStorage.setItem(genKey(key), serialiseItem(payload));
|
|
17037
|
+
return true;
|
|
17038
|
+
}
|
|
17039
|
+
return false;
|
|
17040
|
+
};
|
|
17041
|
+
|
|
17042
|
+
// In memory storage for events and other data
|
|
17043
|
+
let EVENT_STORE;
|
|
17044
|
+
let RUNTIME_DETAILS;
|
|
17045
|
+
// Initialise store and runtime
|
|
17046
|
+
const initialise$1 = () => {
|
|
17047
|
+
EVENT_STORE = getItem(Store.EVENTS) || [];
|
|
17048
|
+
RUNTIME_DETAILS = getItem(Store.RUNTIME) || {};
|
|
17049
|
+
};
|
|
17050
|
+
initialise$1();
|
|
17051
|
+
// Runtime Details
|
|
17052
|
+
const storeDetail = (key, value) => {
|
|
17053
|
+
RUNTIME_DETAILS = {
|
|
17054
|
+
...RUNTIME_DETAILS,
|
|
17055
|
+
[key]: value,
|
|
17056
|
+
};
|
|
17057
|
+
setItem(Store.RUNTIME, RUNTIME_DETAILS);
|
|
17058
|
+
};
|
|
17059
|
+
const getDetail = (key) => {
|
|
17060
|
+
// Handle the scenario where detail is a falsy value
|
|
17061
|
+
if (RUNTIME_DETAILS[key] === undefined) {
|
|
17062
|
+
return undefined;
|
|
17063
|
+
}
|
|
17064
|
+
return RUNTIME_DETAILS[key];
|
|
17065
|
+
};
|
|
17066
|
+
const getAllDetails = () => RUNTIME_DETAILS;
|
|
17067
|
+
// Events
|
|
17068
|
+
const getEvents = () => EVENT_STORE;
|
|
17069
|
+
const addEvent = (event) => {
|
|
17070
|
+
EVENT_STORE.push(event);
|
|
17071
|
+
setItem(Store.EVENTS, EVENT_STORE);
|
|
17072
|
+
};
|
|
17073
|
+
const removeSentEvents = (numberOfEvents) => {
|
|
17074
|
+
EVENT_STORE = EVENT_STORE.slice(numberOfEvents);
|
|
17075
|
+
setItem(Store.EVENTS, EVENT_STORE);
|
|
17076
|
+
};
|
|
17077
|
+
const flattenProperties = (properties) => {
|
|
17078
|
+
const propertyMap = [];
|
|
17079
|
+
Object.entries(properties).forEach(([key, value]) => {
|
|
17080
|
+
if (typeof key === 'string'
|
|
17081
|
+
|| typeof value === 'string'
|
|
17082
|
+
|| typeof value === 'number'
|
|
17083
|
+
|| typeof value === 'boolean') {
|
|
17084
|
+
propertyMap.push([key, value.toString()]);
|
|
17085
|
+
}
|
|
17086
|
+
});
|
|
17087
|
+
return propertyMap;
|
|
17088
|
+
};
|
|
17089
|
+
|
|
17090
|
+
let initialised = false;
|
|
17091
|
+
const isInitialised = () => initialised;
|
|
17092
|
+
const getReferrer = () => {
|
|
17093
|
+
if (isNode()) {
|
|
17094
|
+
return '';
|
|
17095
|
+
}
|
|
17096
|
+
if (window.location.ancestorOrigins
|
|
17097
|
+
&& window.location.ancestorOrigins.length > 0) {
|
|
17098
|
+
return new URL(window.location.ancestorOrigins[0]).hostname;
|
|
17099
|
+
}
|
|
17100
|
+
return document.referrer ? new URL(window.document.referrer).hostname : '';
|
|
17101
|
+
};
|
|
17102
|
+
const runtimeHost = () => {
|
|
17103
|
+
if (isNode()) {
|
|
17104
|
+
return '';
|
|
17105
|
+
}
|
|
17106
|
+
if (window.opener || window.parent !== window) {
|
|
17107
|
+
return getReferrer();
|
|
17108
|
+
}
|
|
17109
|
+
return new URL(window.location.href).hostname;
|
|
17110
|
+
};
|
|
17111
|
+
const getRuntimeDetails = () => {
|
|
17112
|
+
if (isNode()) {
|
|
17113
|
+
return { browser: 'nodejs' };
|
|
17114
|
+
}
|
|
17115
|
+
const domain = runtimeHost();
|
|
17116
|
+
if (domain) {
|
|
17117
|
+
storeDetail(Detail.DOMAIN, domain);
|
|
17118
|
+
}
|
|
17119
|
+
return {
|
|
17120
|
+
browser: window.navigator.userAgent,
|
|
17121
|
+
domain,
|
|
17122
|
+
tz: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
17123
|
+
screen: `${window.screen.width}x${window.screen.height}`,
|
|
17124
|
+
};
|
|
17125
|
+
};
|
|
17126
|
+
const initialise = async () => {
|
|
17127
|
+
const runtimeDetails = flattenProperties(getRuntimeDetails());
|
|
17128
|
+
// Get any existing runtimeId and send it along with the initialise
|
|
17129
|
+
const existingRuntimeId = getDetail(Detail.RUNTIME_ID);
|
|
17130
|
+
const body = {
|
|
17131
|
+
version: 1,
|
|
17132
|
+
data: {
|
|
17133
|
+
runtimeDetails,
|
|
17134
|
+
runtimeId: existingRuntimeId,
|
|
17135
|
+
},
|
|
17136
|
+
};
|
|
17137
|
+
const response = await post('/v1/sdk/initialise', body);
|
|
17138
|
+
// Get runtimeId and store it
|
|
17139
|
+
const { runtimeId } = response;
|
|
17140
|
+
storeDetail(Detail.RUNTIME_ID, runtimeId);
|
|
17141
|
+
initialised = true;
|
|
17142
|
+
};
|
|
17143
|
+
|
|
17144
|
+
function errorBoundary(fn) {
|
|
17145
|
+
const wrappedFunction = ((...args) => {
|
|
17146
|
+
try {
|
|
17147
|
+
// Execute the original function
|
|
17148
|
+
const result = fn(...args);
|
|
17149
|
+
if (result instanceof Promise) {
|
|
17150
|
+
// Silent fail for now, in future
|
|
17151
|
+
// we can send errors to a logging service
|
|
17152
|
+
return result.catch(() => undefined);
|
|
17153
|
+
}
|
|
17154
|
+
return result;
|
|
17155
|
+
}
|
|
17156
|
+
catch (error) {
|
|
17157
|
+
// As above, fail silently for now
|
|
17158
|
+
return undefined;
|
|
17159
|
+
}
|
|
17160
|
+
});
|
|
17161
|
+
return wrappedFunction;
|
|
17162
|
+
}
|
|
17163
|
+
|
|
17164
|
+
function isTestEnvironment() {
|
|
17165
|
+
if (typeof process === 'undefined') {
|
|
17166
|
+
return false;
|
|
17167
|
+
}
|
|
17168
|
+
return process.env.JEST_WORKER_ID !== undefined;
|
|
17169
|
+
}
|
|
17170
|
+
|
|
17171
|
+
// Store the event in the event store
|
|
17172
|
+
const trackFn = (moduleName, eventName, properties) => {
|
|
17173
|
+
const event = {
|
|
17174
|
+
event: `${moduleName}.${eventName}`,
|
|
17175
|
+
time: new Date().toISOString(),
|
|
17176
|
+
...(properties && { properties: flattenProperties(properties) }),
|
|
17177
|
+
};
|
|
17178
|
+
addEvent(event);
|
|
17179
|
+
};
|
|
17180
|
+
const track = errorBoundary(trackFn);
|
|
17181
|
+
// Sending events to the server
|
|
17182
|
+
const flushFn = async () => {
|
|
17183
|
+
// Don't flush if not initialised
|
|
17184
|
+
if (isInitialised() === false) {
|
|
17185
|
+
await initialise();
|
|
17186
|
+
return;
|
|
17187
|
+
}
|
|
17188
|
+
const events = getEvents();
|
|
17189
|
+
if (events.length === 0) {
|
|
17190
|
+
return;
|
|
17191
|
+
}
|
|
17192
|
+
// Track events length here, incase
|
|
17193
|
+
const numEvents = events.length;
|
|
17194
|
+
// Get details and send it with the track request
|
|
17195
|
+
const details = getAllDetails();
|
|
17196
|
+
const metricsPayload = {
|
|
17197
|
+
version: 1,
|
|
17198
|
+
data: {
|
|
17199
|
+
events,
|
|
17200
|
+
details,
|
|
17201
|
+
},
|
|
17202
|
+
};
|
|
17203
|
+
const response = await post('/v1/sdk/metrics', metricsPayload);
|
|
17204
|
+
if (response instanceof Error) {
|
|
17205
|
+
return;
|
|
17206
|
+
}
|
|
17207
|
+
// Clear events if successfully posted
|
|
17208
|
+
removeSentEvents(numEvents);
|
|
17209
|
+
};
|
|
17210
|
+
const flush = errorBoundary(flushFn);
|
|
17211
|
+
// Flush events every 5 seconds
|
|
17212
|
+
const flushPoll = async () => {
|
|
17213
|
+
await flush();
|
|
17214
|
+
setTimeout(flushPoll, POLLING_FREQUENCY);
|
|
17215
|
+
};
|
|
17216
|
+
// This will get initialised when module is imported.
|
|
17217
|
+
if (!isTestEnvironment()) {
|
|
17218
|
+
errorBoundary(flushPoll)();
|
|
17219
|
+
}
|
|
17220
|
+
|
|
17221
|
+
track('metrics', 'sdk_version', {
|
|
17222
|
+
version: '0.45.6',
|
|
17223
|
+
});
|
|
17224
|
+
|
|
16698
17225
|
var Environment;
|
|
16699
17226
|
(function (Environment) {
|
|
16700
17227
|
Environment["PRODUCTION"] = "production";
|
|
@@ -26336,7 +26863,7 @@ class APIError extends Error {
|
|
|
26336
26863
|
|
|
26337
26864
|
/* eslint-disable implicit-arrow-linebreak */
|
|
26338
26865
|
const defaultHeaders = {
|
|
26339
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.45.
|
|
26866
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.45.6',
|
|
26340
26867
|
};
|
|
26341
26868
|
/**
|
|
26342
26869
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -27698,7 +28225,7 @@ const IMMUTABLE_ZKVEM_GAS_OVERRIDES = {
|
|
|
27698
28225
|
maxPriorityFeePerGas: BigNumber$1.from(10e9),
|
|
27699
28226
|
};
|
|
27700
28227
|
|
|
27701
|
-
const SDK_VERSION_MARKER = '0.45.
|
|
28228
|
+
const SDK_VERSION_MARKER = '0.45.6';
|
|
27702
28229
|
// This SDK version is replaced by the `yarn build` command ran on the root level
|
|
27703
28230
|
const globalPackageVersion = () => SDK_VERSION_MARKER;
|
|
27704
28231
|
|
|
@@ -27903,7 +28430,7 @@ async function getERC20TokenInfo(web3Provider, tokenAddress) {
|
|
|
27903
28430
|
}, { type: CheckoutErrorType.GET_ERC20_INFO_ERROR });
|
|
27904
28431
|
}
|
|
27905
28432
|
|
|
27906
|
-
const CACHE_DATA_TTL =
|
|
28433
|
+
const CACHE_DATA_TTL = 5; // seconds
|
|
27907
28434
|
/**
|
|
27908
28435
|
* Blockscout class provides a client abstraction for the Immutable 3rd party indexer.
|
|
27909
28436
|
*/
|
package/dist/config.d.ts
CHANGED
|
@@ -23,9 +23,9 @@ type ImmutableConfigurationWithRequireableFields<T> = ImmutableConfiguration & (
|
|
|
23
23
|
} ? Required<{
|
|
24
24
|
publishableKey: string;
|
|
25
25
|
}> : {});
|
|
26
|
-
type ImmutableConfigurationWithOmitableFields<T> =
|
|
26
|
+
type ImmutableConfigurationWithOmitableFields<T> = T extends {
|
|
27
27
|
apiKey: 'omit';
|
|
28
|
-
} ? Omit<ImmutableConfigurationWithRequireableFields<T>, 'apiKey'> : ImmutableConfigurationWithRequireableFields<T
|
|
28
|
+
} ? Omit<ImmutableConfigurationWithRequireableFields<T>, 'apiKey'> : ImmutableConfigurationWithRequireableFields<T>;
|
|
29
29
|
interface ModuleConfiguration<T> {
|
|
30
30
|
baseConfig: ImmutableConfigurationWithOmitableFields<T>;
|
|
31
31
|
overrides?: T;
|