@coinlist-co/react 0.10.0 → 0.11.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 +32 -0
- package/dist/{chunk-GSSAB4K5.js → chunk-B2HCVPCQ.js} +225 -247
- package/dist/chunk-B2HCVPCQ.js.map +1 -0
- package/dist/chunk-KDGNDAHA.js +146 -0
- package/dist/chunk-KDGNDAHA.js.map +1 -0
- package/dist/chunk-UIIXXLA7.js +1863 -0
- package/dist/chunk-UIIXXLA7.js.map +1 -0
- package/dist/client/index.cjs +10559 -3442
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +4219 -862
- package/dist/client/index.d.ts +4219 -862
- package/dist/client/index.js +8729 -2370
- package/dist/client/index.js.map +1 -1
- package/dist/collections-BhDkYmzV.d.cts +65 -0
- package/dist/collections-CZhHoQHr.d.ts +65 -0
- package/dist/config-B5mwS_2l.d.cts +1926 -0
- package/dist/config-B5mwS_2l.d.ts +1926 -0
- package/dist/server/index.cjs +981 -464
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +190 -163
- package/dist/server/index.d.ts +190 -163
- package/dist/server/index.js +151 -156
- package/dist/server/index.js.map +1 -1
- package/dist/shared/index.cjs +1810 -907
- package/dist/shared/index.cjs.map +1 -1
- package/dist/shared/index.d.cts +243 -132
- package/dist/shared/index.d.ts +243 -132
- package/dist/shared/index.js +102 -114
- package/dist/shared/index.js.map +1 -1
- package/package.json +10 -7
- package/dist/chunk-7BJ2HAG7.js +0 -442
- package/dist/chunk-7BJ2HAG7.js.map +0 -1
- package/dist/chunk-AAER5LOL.js +0 -22
- package/dist/chunk-AAER5LOL.js.map +0 -1
- package/dist/chunk-GSSAB4K5.js.map +0 -1
- package/dist/chunk-TUZKKFNW.js +0 -836
- package/dist/chunk-TUZKKFNW.js.map +0 -1
- package/dist/collections-CJ24dOda.d.cts +0 -28
- package/dist/collections-ZYLKp8JB.d.ts +0 -28
- package/dist/requirement-CDi5NJI8.d.cts +0 -1036
- package/dist/requirement-CDi5NJI8.d.ts +0 -1036
|
@@ -0,0 +1,1863 @@
|
|
|
1
|
+
// src/shared/api/http-attributes.ts
|
|
2
|
+
var empty = {};
|
|
3
|
+
var concat = (left, right) => ({
|
|
4
|
+
...left,
|
|
5
|
+
...right
|
|
6
|
+
});
|
|
7
|
+
var concatAll = (...items) => {
|
|
8
|
+
let result = empty;
|
|
9
|
+
for (const item of items) {
|
|
10
|
+
result = concat(result, item);
|
|
11
|
+
}
|
|
12
|
+
return result;
|
|
13
|
+
};
|
|
14
|
+
var protectedRequest = () => ({ protected: true });
|
|
15
|
+
var userAgent = () => ({ userAgent: true });
|
|
16
|
+
var idempotencyKey = () => ({
|
|
17
|
+
idempotencyKey: true
|
|
18
|
+
});
|
|
19
|
+
var clientCredentials = (credentials) => ({
|
|
20
|
+
clientCredentials: credentials
|
|
21
|
+
});
|
|
22
|
+
var retryAttempt = (attempt) => ({
|
|
23
|
+
retryAttempt: attempt
|
|
24
|
+
});
|
|
25
|
+
var renewAttempted = (value) => ({
|
|
26
|
+
renewAttempted: value
|
|
27
|
+
});
|
|
28
|
+
var isProtected = (attrs) => attrs?.protected === true;
|
|
29
|
+
var needUserAgent = (attrs) => attrs?.userAgent === true;
|
|
30
|
+
var isIdempotent = (attrs) => attrs?.idempotencyKey === true;
|
|
31
|
+
var getRetryAttempt = (attrs) => attrs?.retryAttempt ?? 0;
|
|
32
|
+
var wasRenewAttempted = (attrs) => attrs?.renewAttempted === true;
|
|
33
|
+
var getClientCredentials = (attrs) => attrs?.clientCredentials;
|
|
34
|
+
var Attributes = {
|
|
35
|
+
empty,
|
|
36
|
+
concat,
|
|
37
|
+
concatAll,
|
|
38
|
+
protected: protectedRequest,
|
|
39
|
+
isProtected,
|
|
40
|
+
userAgent,
|
|
41
|
+
needUserAgent,
|
|
42
|
+
idempotencyKey,
|
|
43
|
+
isIdempotent,
|
|
44
|
+
retryAttempt,
|
|
45
|
+
getRetryAttempt,
|
|
46
|
+
renewAttempted,
|
|
47
|
+
wasRenewAttempted,
|
|
48
|
+
clientCredentials,
|
|
49
|
+
getClientCredentials
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// src/shared/api/http.ts
|
|
53
|
+
var HttpError = class extends Error {
|
|
54
|
+
constructor(response) {
|
|
55
|
+
super(`Request failed with ${response.status} status`);
|
|
56
|
+
this.name = "HttpError";
|
|
57
|
+
this.response = response;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
function apiErrorCode(error) {
|
|
61
|
+
if (!(error instanceof HttpError)) return null;
|
|
62
|
+
const body = error.response.body;
|
|
63
|
+
if (typeof body !== "object" || body === null) return null;
|
|
64
|
+
const code = body.code;
|
|
65
|
+
return typeof code === "string" ? code : null;
|
|
66
|
+
}
|
|
67
|
+
async function makeRequest(request) {
|
|
68
|
+
const headers = {
|
|
69
|
+
Accept: "application/json",
|
|
70
|
+
...request.method === "POST" && request.body !== void 0 ? { "Content-Type": "application/json" } : {},
|
|
71
|
+
...request.headers ?? {}
|
|
72
|
+
};
|
|
73
|
+
const init = {
|
|
74
|
+
method: request.method,
|
|
75
|
+
headers,
|
|
76
|
+
...request.redirect !== void 0 ? { redirect: request.redirect } : {}
|
|
77
|
+
};
|
|
78
|
+
if (request.method === "POST" && request.body !== void 0) {
|
|
79
|
+
init.body = JSON.stringify(request.body);
|
|
80
|
+
}
|
|
81
|
+
const response = await fetch(
|
|
82
|
+
buildUrlWithQueryParams(request.url, request.queryParams),
|
|
83
|
+
init
|
|
84
|
+
);
|
|
85
|
+
const responseHeaders = headersToRecord(response.headers);
|
|
86
|
+
if (response.status === 204 || response.status === 205) {
|
|
87
|
+
return {
|
|
88
|
+
status: response.status,
|
|
89
|
+
body: null,
|
|
90
|
+
headers: responseHeaders
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
if (response.status >= 300 && response.status < 400) {
|
|
94
|
+
await response.text();
|
|
95
|
+
return {
|
|
96
|
+
status: response.status,
|
|
97
|
+
body: null,
|
|
98
|
+
headers: responseHeaders
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
const text = await response.text();
|
|
102
|
+
let body;
|
|
103
|
+
try {
|
|
104
|
+
body = text ? JSON.parse(text) : null;
|
|
105
|
+
} catch (_) {
|
|
106
|
+
throw new HttpError({
|
|
107
|
+
status: response.status,
|
|
108
|
+
headers: responseHeaders,
|
|
109
|
+
body: text
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
status: response.status,
|
|
114
|
+
body,
|
|
115
|
+
headers: responseHeaders
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function buildUrlWithQueryParams(url, queryParams) {
|
|
119
|
+
if (!queryParams) {
|
|
120
|
+
return url;
|
|
121
|
+
}
|
|
122
|
+
const searchParams = new URLSearchParams();
|
|
123
|
+
for (const [key, value] of Object.entries(queryParams)) {
|
|
124
|
+
if (value === void 0 || value === null) {
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
if (Array.isArray(value)) {
|
|
128
|
+
for (const item of value) {
|
|
129
|
+
if (item === void 0 || item === null) {
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
searchParams.append(key, String(item));
|
|
133
|
+
}
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
searchParams.append(key, String(value));
|
|
137
|
+
}
|
|
138
|
+
const queryString = searchParams.toString();
|
|
139
|
+
if (!queryString) {
|
|
140
|
+
return url;
|
|
141
|
+
}
|
|
142
|
+
return url.includes("?") ? `${url}&${queryString}` : `${url}?${queryString}`;
|
|
143
|
+
}
|
|
144
|
+
function headersToRecord(headers) {
|
|
145
|
+
const record = {};
|
|
146
|
+
headers.forEach((value, key) => {
|
|
147
|
+
record[key.toLowerCase()] = value;
|
|
148
|
+
});
|
|
149
|
+
return record;
|
|
150
|
+
}
|
|
151
|
+
function concatAttributes(request, attrs) {
|
|
152
|
+
const nextAttributes = Attributes.concat(
|
|
153
|
+
request.attributes ?? Attributes.empty,
|
|
154
|
+
attrs
|
|
155
|
+
);
|
|
156
|
+
const nextRequest = {
|
|
157
|
+
...request,
|
|
158
|
+
attributes: nextAttributes
|
|
159
|
+
};
|
|
160
|
+
return nextRequest;
|
|
161
|
+
}
|
|
162
|
+
var Request = {
|
|
163
|
+
concatAttributes
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
// src/shared/api/pagination.ts
|
|
167
|
+
async function fetchAllPages(fetchPage, baseParams) {
|
|
168
|
+
const items = [];
|
|
169
|
+
let cursor = null;
|
|
170
|
+
do {
|
|
171
|
+
const params = {
|
|
172
|
+
...baseParams ?? {},
|
|
173
|
+
after: cursor ?? void 0
|
|
174
|
+
};
|
|
175
|
+
const page = await fetchPage(params);
|
|
176
|
+
items.push(...page.data);
|
|
177
|
+
cursor = page.startingAfter;
|
|
178
|
+
} while (cursor);
|
|
179
|
+
return items;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// src/shared/types/errors.ts
|
|
183
|
+
var NotImplementedError = class extends Error {
|
|
184
|
+
constructor(message = "Not implemented yet") {
|
|
185
|
+
super(message);
|
|
186
|
+
this.name = "NotImplementedError";
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
var NotAuthenticatedError = class extends Error {
|
|
190
|
+
constructor(message = "The user is not authenticated. Go through the OAuth flow first!") {
|
|
191
|
+
super(message);
|
|
192
|
+
this.name = "NotAuthenticatedError";
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
var ValidationError = class extends Error {
|
|
196
|
+
constructor(message) {
|
|
197
|
+
super(message);
|
|
198
|
+
this.name = "ValidationError";
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
// src/shared/types/blockchain/core.ts
|
|
203
|
+
var ETHEREUM_CHAINS = {
|
|
204
|
+
ethereum_mainnet: true,
|
|
205
|
+
ethereum_sepolia: true
|
|
206
|
+
};
|
|
207
|
+
var EthereumChain = (value) => {
|
|
208
|
+
if (!Object.keys(ETHEREUM_CHAINS).includes(value)) {
|
|
209
|
+
throw new ValidationError(`Unsupported Ethereum chain: "${value}"`);
|
|
210
|
+
}
|
|
211
|
+
return value;
|
|
212
|
+
};
|
|
213
|
+
var SOLANA_CHAINS = {
|
|
214
|
+
solana_mainnet: true,
|
|
215
|
+
solana_devnet: true
|
|
216
|
+
};
|
|
217
|
+
var SolanaChain = (value) => {
|
|
218
|
+
if (!Object.keys(SOLANA_CHAINS).includes(value)) {
|
|
219
|
+
throw new ValidationError(`Unsupported Solana chain: "${value}"`);
|
|
220
|
+
}
|
|
221
|
+
return value;
|
|
222
|
+
};
|
|
223
|
+
var Chain = (value) => {
|
|
224
|
+
if (!Object.keys(ETHEREUM_CHAINS).includes(value) && !Object.keys(SOLANA_CHAINS).includes(value)) {
|
|
225
|
+
throw new ValidationError(`Unsupported chain: "${value}"`);
|
|
226
|
+
}
|
|
227
|
+
return value;
|
|
228
|
+
};
|
|
229
|
+
var EvmWalletAddress = (value) => value;
|
|
230
|
+
var EvmContractAddress = (value) => value;
|
|
231
|
+
var HexEncodedTransactionData = (value) => value;
|
|
232
|
+
var MAX_ASSET_DECIMALS = 77;
|
|
233
|
+
var AssetDecimals = (value) => {
|
|
234
|
+
if (!Number.isInteger(value)) {
|
|
235
|
+
throw new ValidationError(`Asset decimals must be an integer: ${value}`);
|
|
236
|
+
}
|
|
237
|
+
if (value < 0 || value > MAX_ASSET_DECIMALS) {
|
|
238
|
+
throw new ValidationError(
|
|
239
|
+
`Asset decimals out of range [0, ${MAX_ASSET_DECIMALS}]: ${value}`
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
return value;
|
|
243
|
+
};
|
|
244
|
+
var STABLE_DECIMALS = AssetDecimals(6);
|
|
245
|
+
var DecimalString = (value) => value;
|
|
246
|
+
var MAX_UINT_256 = 2n ** 256n - 1n;
|
|
247
|
+
var assertUint256 = (value) => {
|
|
248
|
+
if (value < 0n || value > MAX_UINT_256) {
|
|
249
|
+
throw new Error(`Value out of uint256 bounds: ${value}`);
|
|
250
|
+
}
|
|
251
|
+
return value;
|
|
252
|
+
};
|
|
253
|
+
var BlockchainAmount = Object.assign(
|
|
254
|
+
(value) => value,
|
|
255
|
+
{
|
|
256
|
+
add: (a, b) => combineAmounts(a, b, (x, y) => x + y),
|
|
257
|
+
sub: (a, b) => combineAmounts(a, b, (x, y) => x - y)
|
|
258
|
+
}
|
|
259
|
+
);
|
|
260
|
+
function combineAmounts(a, b, op) {
|
|
261
|
+
if (a.decimals !== b.decimals) {
|
|
262
|
+
throw new Error(
|
|
263
|
+
`Cannot combine BlockchainAmounts with different decimals: ${a.decimals} vs ${b.decimals}`
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
const raw = op(a.raw, b.raw);
|
|
267
|
+
if (raw < 0n || raw > MAX_UINT_256) {
|
|
268
|
+
throw new Error(`BlockchainAmount out of uint256 bounds: ${raw}`);
|
|
269
|
+
}
|
|
270
|
+
return BlockchainAmount({ raw, decimals: a.decimals });
|
|
271
|
+
}
|
|
272
|
+
var AssetSymbol = (value) => value;
|
|
273
|
+
var StablecoinSymbol = (value) => value;
|
|
274
|
+
var KnownAssetSymbol = StablecoinSymbol;
|
|
275
|
+
var Bps = (value) => value;
|
|
276
|
+
|
|
277
|
+
// src/shared/types/blockchain/ui.ts
|
|
278
|
+
var FormattedAmountUi = (value) => value;
|
|
279
|
+
var FormattedPercentUi = (value) => value;
|
|
280
|
+
var TxExplorerUrl = (value) => value;
|
|
281
|
+
var ShortenedWalletAddress = (value) => value;
|
|
282
|
+
var FormattedAmountAssetUi = (value) => value;
|
|
283
|
+
var AssetIconUrl = (value) => value;
|
|
284
|
+
|
|
285
|
+
// src/shared/core/blockchain/chain.ts
|
|
286
|
+
var CHAIN_IDS = {
|
|
287
|
+
ethereum_mainnet: 1,
|
|
288
|
+
ethereum_sepolia: 11155111
|
|
289
|
+
};
|
|
290
|
+
function getChainId(chain) {
|
|
291
|
+
return CHAIN_IDS[chain];
|
|
292
|
+
}
|
|
293
|
+
function chainFromId(chainId) {
|
|
294
|
+
const chains = Object.keys(CHAIN_IDS);
|
|
295
|
+
const chain = chains.find((c) => String(CHAIN_IDS[c]) === chainId);
|
|
296
|
+
if (!chain) {
|
|
297
|
+
throw new ValidationError(`Unsupported EIP-155 chain id: "${chainId}"`);
|
|
298
|
+
}
|
|
299
|
+
return chain;
|
|
300
|
+
}
|
|
301
|
+
function getNetworkName(chain) {
|
|
302
|
+
switch (chain) {
|
|
303
|
+
case "ethereum_mainnet":
|
|
304
|
+
return "Ethereum";
|
|
305
|
+
case "ethereum_sepolia":
|
|
306
|
+
return "Ethereum Sepolia";
|
|
307
|
+
default: {
|
|
308
|
+
const _exhaustive = chain;
|
|
309
|
+
return _exhaustive;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
function txExplorerUrl(chain, txHash) {
|
|
314
|
+
return TxExplorerUrl(`${explorerBaseUrl(chain)}/tx/${txHash}`);
|
|
315
|
+
}
|
|
316
|
+
function explorerBaseUrl(chain) {
|
|
317
|
+
switch (chain) {
|
|
318
|
+
case "ethereum_mainnet":
|
|
319
|
+
return "https://etherscan.io";
|
|
320
|
+
case "ethereum_sepolia":
|
|
321
|
+
return "https://sepolia.etherscan.io";
|
|
322
|
+
default: {
|
|
323
|
+
const _exhaustive = chain;
|
|
324
|
+
return _exhaustive;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// src/shared/types/providers/superstate/swap.ts
|
|
330
|
+
var SwapAuthorization = {
|
|
331
|
+
fromDto: (dto) => ({
|
|
332
|
+
authorized: dto.authorized
|
|
333
|
+
})
|
|
334
|
+
};
|
|
335
|
+
var SwapPreview = {
|
|
336
|
+
fromDto: (dto) => ({
|
|
337
|
+
inputAmount: assertUint256(BigInt(dto.pay_input_amount)),
|
|
338
|
+
fee: assertUint256(BigInt(dto.fee)),
|
|
339
|
+
outputAmount: assertUint256(BigInt(dto.receive_output_amount))
|
|
340
|
+
})
|
|
341
|
+
};
|
|
342
|
+
var SwapStatus = {
|
|
343
|
+
fromDto: (dto) => ({
|
|
344
|
+
stopped: assertUint256(BigInt(dto.stopped)),
|
|
345
|
+
swapLevel: assertUint256(BigInt(dto.swap_level))
|
|
346
|
+
})
|
|
347
|
+
};
|
|
348
|
+
var TokenAllowance = {
|
|
349
|
+
fromDto: (dto) => ({
|
|
350
|
+
allowance: assertUint256(BigInt(dto.allowance))
|
|
351
|
+
})
|
|
352
|
+
};
|
|
353
|
+
var TokenBalance = {
|
|
354
|
+
fromDto: (dto) => ({
|
|
355
|
+
balance: assertUint256(BigInt(dto.balance))
|
|
356
|
+
})
|
|
357
|
+
};
|
|
358
|
+
var AllowWalletResponse = {
|
|
359
|
+
fromDto: (dto) => {
|
|
360
|
+
switch (dto.action) {
|
|
361
|
+
case "broadcast_transaction":
|
|
362
|
+
return {
|
|
363
|
+
action: "broadcast_transaction",
|
|
364
|
+
to: EvmContractAddress(dto.to),
|
|
365
|
+
data: HexEncodedTransactionData(dto.data)
|
|
366
|
+
};
|
|
367
|
+
case "none":
|
|
368
|
+
return {
|
|
369
|
+
action: "none",
|
|
370
|
+
alreadyAllowed: dto.already_allowed
|
|
371
|
+
};
|
|
372
|
+
default: {
|
|
373
|
+
const _exhaustive = dto;
|
|
374
|
+
return _exhaustive;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
// src/shared/api/frontline/providers/superstate/swap.ts
|
|
381
|
+
async function getSwapAuthorization(api, params) {
|
|
382
|
+
const dto = await api.send({
|
|
383
|
+
method: "GET",
|
|
384
|
+
url: "/v1/wallet/authorized",
|
|
385
|
+
queryParams: {
|
|
386
|
+
chain: params.chain,
|
|
387
|
+
contract_address: params.contractAddress,
|
|
388
|
+
wallet_address: params.walletAddress
|
|
389
|
+
},
|
|
390
|
+
attributes: Attributes.protected()
|
|
391
|
+
});
|
|
392
|
+
return SwapAuthorization.fromDto(dto);
|
|
393
|
+
}
|
|
394
|
+
async function getSwapOutputToken(api, params) {
|
|
395
|
+
const dto = await api.send({
|
|
396
|
+
method: "GET",
|
|
397
|
+
url: "/v1/swap/output-token",
|
|
398
|
+
queryParams: {
|
|
399
|
+
chain: params.chain,
|
|
400
|
+
contract_address: params.contractAddress
|
|
401
|
+
},
|
|
402
|
+
attributes: Attributes.protected()
|
|
403
|
+
});
|
|
404
|
+
return toErc20Asset(dto);
|
|
405
|
+
}
|
|
406
|
+
async function getSwapPreview(api, params) {
|
|
407
|
+
const dto = await api.send({
|
|
408
|
+
method: "GET",
|
|
409
|
+
url: "/v1/swap/preview",
|
|
410
|
+
queryParams: {
|
|
411
|
+
chain: params.chain,
|
|
412
|
+
contract_address: params.contractAddress,
|
|
413
|
+
input_token: params.inputToken,
|
|
414
|
+
amount: params.amount.toString()
|
|
415
|
+
},
|
|
416
|
+
attributes: Attributes.protected()
|
|
417
|
+
});
|
|
418
|
+
return SwapPreview.fromDto(dto);
|
|
419
|
+
}
|
|
420
|
+
async function getSwapStatus(api, params) {
|
|
421
|
+
const dto = await api.send({
|
|
422
|
+
method: "GET",
|
|
423
|
+
url: "/v1/swap/status",
|
|
424
|
+
queryParams: {
|
|
425
|
+
chain: params.chain,
|
|
426
|
+
contract_address: params.contractAddress
|
|
427
|
+
},
|
|
428
|
+
attributes: Attributes.protected()
|
|
429
|
+
});
|
|
430
|
+
return SwapStatus.fromDto(dto);
|
|
431
|
+
}
|
|
432
|
+
async function getTokenAllowance(api, params) {
|
|
433
|
+
const dto = await api.send({
|
|
434
|
+
method: "GET",
|
|
435
|
+
url: "/v1/token/allowance",
|
|
436
|
+
queryParams: {
|
|
437
|
+
chain: params.chain,
|
|
438
|
+
token_address: params.tokenAddress,
|
|
439
|
+
owner: params.owner,
|
|
440
|
+
spender: params.spender
|
|
441
|
+
},
|
|
442
|
+
attributes: Attributes.protected()
|
|
443
|
+
});
|
|
444
|
+
return TokenAllowance.fromDto(dto);
|
|
445
|
+
}
|
|
446
|
+
async function getTokenBalance(api, params) {
|
|
447
|
+
const dto = await api.send({
|
|
448
|
+
method: "GET",
|
|
449
|
+
url: "/v1/token/balance",
|
|
450
|
+
queryParams: {
|
|
451
|
+
chain: params.chain,
|
|
452
|
+
token_address: params.tokenAddress,
|
|
453
|
+
owner: params.owner
|
|
454
|
+
},
|
|
455
|
+
attributes: Attributes.protected()
|
|
456
|
+
});
|
|
457
|
+
return TokenBalance.fromDto(dto);
|
|
458
|
+
}
|
|
459
|
+
async function allowWallet(api, params) {
|
|
460
|
+
const dto = await api.send({
|
|
461
|
+
method: "POST",
|
|
462
|
+
url: `/v1/offers/${encodeURIComponent(params.offerId)}/allow-wallet`,
|
|
463
|
+
body: {
|
|
464
|
+
wallet_address: params.walletAddress,
|
|
465
|
+
chain: params.chain,
|
|
466
|
+
signature: params.signature
|
|
467
|
+
},
|
|
468
|
+
attributes: Attributes.protected()
|
|
469
|
+
});
|
|
470
|
+
return AllowWalletResponse.fromDto(dto);
|
|
471
|
+
}
|
|
472
|
+
function toErc20Asset(dto) {
|
|
473
|
+
return {
|
|
474
|
+
name: dto.name,
|
|
475
|
+
symbol: AssetSymbol(dto.symbol),
|
|
476
|
+
decimals: AssetDecimals(dto.decimals)
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
// src/shared/core/blockchain/erc20/erc20-namespace.ts
|
|
481
|
+
var Erc20NamespaceImpl = class {
|
|
482
|
+
constructor(ctx) {
|
|
483
|
+
this.ctx = ctx;
|
|
484
|
+
}
|
|
485
|
+
async getAllowance(params) {
|
|
486
|
+
await this.ctx.ensureUserAuthenticated();
|
|
487
|
+
return getTokenAllowance(this.ctx.api, params);
|
|
488
|
+
}
|
|
489
|
+
async getBalance(params) {
|
|
490
|
+
await this.ctx.ensureUserAuthenticated();
|
|
491
|
+
return getTokenBalance(this.ctx.api, params);
|
|
492
|
+
}
|
|
493
|
+
};
|
|
494
|
+
|
|
495
|
+
// src/shared/core/blockchain/formatters.ts
|
|
496
|
+
import { formatUnits } from "viem";
|
|
497
|
+
function shortenAddress(address) {
|
|
498
|
+
const short = address.length > 10 ? `${address.slice(0, 6)}\u2026${address.slice(-4)}` : address;
|
|
499
|
+
return ShortenedWalletAddress(short);
|
|
500
|
+
}
|
|
501
|
+
function formatAmount(amount, locale, options) {
|
|
502
|
+
const decimal = formatRawAmount(amount);
|
|
503
|
+
let [integerPart, fractionPart = ""] = decimal.split(".");
|
|
504
|
+
const maxFractionDigits = options?.maxFractionDigits;
|
|
505
|
+
const minFractionDigits = maxFractionDigits !== void 0 ? Math.min(maxFractionDigits, amount.decimals) : Math.min(2, amount.decimals);
|
|
506
|
+
if (maxFractionDigits !== void 0 && fractionPart.length > maxFractionDigits) {
|
|
507
|
+
({ integerPart, fractionPart } = roundFractionHalfUp(
|
|
508
|
+
integerPart,
|
|
509
|
+
fractionPart,
|
|
510
|
+
maxFractionDigits
|
|
511
|
+
));
|
|
512
|
+
}
|
|
513
|
+
const fraction = minFractionDigits === 0 ? "" : fractionPart.padEnd(minFractionDigits, "0");
|
|
514
|
+
const integerFormatted = BigInt(integerPart).toLocaleString(locale);
|
|
515
|
+
if (minFractionDigits === 0 && fraction === "") {
|
|
516
|
+
return FormattedAmountUi(integerFormatted);
|
|
517
|
+
}
|
|
518
|
+
const decimalSeparator = new Intl.NumberFormat(locale).formatToParts(1.1).find((p) => p.type === "decimal")?.value ?? ".";
|
|
519
|
+
return FormattedAmountUi(`${integerFormatted}${decimalSeparator}${fraction}`);
|
|
520
|
+
}
|
|
521
|
+
function roundFractionHalfUp(integerPart, fractionPart, maxFractionDigits) {
|
|
522
|
+
if (fractionPart.length <= maxFractionDigits) {
|
|
523
|
+
return { integerPart, fractionPart };
|
|
524
|
+
}
|
|
525
|
+
if (maxFractionDigits === 0) {
|
|
526
|
+
const roundUp = fractionPart[0] >= "5";
|
|
527
|
+
const integer = BigInt(integerPart) + (roundUp ? 1n : 0n);
|
|
528
|
+
return { integerPart: integer.toString(), fractionPart: "" };
|
|
529
|
+
}
|
|
530
|
+
const trimmed = fractionPart.slice(0, maxFractionDigits);
|
|
531
|
+
if (fractionPart[maxFractionDigits] < "5") {
|
|
532
|
+
return { integerPart, fractionPart: trimmed };
|
|
533
|
+
}
|
|
534
|
+
const digits = trimmed.split("").map((digit) => Number.parseInt(digit, 10));
|
|
535
|
+
let carry = 1;
|
|
536
|
+
for (let i = digits.length - 1; i >= 0 && carry > 0; i -= 1) {
|
|
537
|
+
const sum = digits[i] + carry;
|
|
538
|
+
if (sum === 10) {
|
|
539
|
+
digits[i] = 0;
|
|
540
|
+
carry = 1;
|
|
541
|
+
} else {
|
|
542
|
+
digits[i] = sum;
|
|
543
|
+
carry = 0;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
return {
|
|
547
|
+
integerPart: carry > 0 ? (BigInt(integerPart) + 1n).toString() : integerPart,
|
|
548
|
+
fractionPart: digits.join("")
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
function formatRawAmount(amount) {
|
|
552
|
+
return formatUnits(amount.raw, amount.decimals);
|
|
553
|
+
}
|
|
554
|
+
function formatCompactAmount(amount, locale) {
|
|
555
|
+
const value = Number(formatRawAmount(amount));
|
|
556
|
+
const formatted = new Intl.NumberFormat(locale, {
|
|
557
|
+
notation: "compact",
|
|
558
|
+
maximumFractionDigits: 2
|
|
559
|
+
}).format(value);
|
|
560
|
+
return FormattedAmountUi(formatted);
|
|
561
|
+
}
|
|
562
|
+
function formatBpsAsPercent(bps, locale) {
|
|
563
|
+
const whole = bps / 100n;
|
|
564
|
+
const fraction = bps % 100n;
|
|
565
|
+
const wholeFormatted = whole.toLocaleString(locale);
|
|
566
|
+
const decimalSeparator = new Intl.NumberFormat(locale).formatToParts(1.1).find((p) => p.type === "decimal")?.value ?? ".";
|
|
567
|
+
if (fraction === 0n) {
|
|
568
|
+
return FormattedPercentUi(`${wholeFormatted}%`);
|
|
569
|
+
}
|
|
570
|
+
const fractionFormatted = fraction.toString().padStart(2, "0").replace(/0+$/, "");
|
|
571
|
+
return FormattedPercentUi(
|
|
572
|
+
`${wholeFormatted}${decimalSeparator}${fractionFormatted}%`
|
|
573
|
+
);
|
|
574
|
+
}
|
|
575
|
+
function usdAmount(amount) {
|
|
576
|
+
return FormattedAmountAssetUi(`$${amount}`);
|
|
577
|
+
}
|
|
578
|
+
function assetAmount(amount, symbol) {
|
|
579
|
+
return FormattedAmountAssetUi(`${amount} ${symbol}`);
|
|
580
|
+
}
|
|
581
|
+
var NA_AMOUNT_ASSET_UI = FormattedAmountAssetUi("-");
|
|
582
|
+
var USD_FRACTION_DIGITS = AssetDecimals(2);
|
|
583
|
+
function formattedUsdPrice(amount, locale) {
|
|
584
|
+
if (!amount) return NA_AMOUNT_ASSET_UI;
|
|
585
|
+
return usdAmount(
|
|
586
|
+
formatAmount(amount, locale, { maxFractionDigits: USD_FRACTION_DIGITS })
|
|
587
|
+
);
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
// src/shared/core/blockchain/math.ts
|
|
591
|
+
import { parseUnits } from "viem";
|
|
592
|
+
function blockchainAmountFromRawOrThrow({
|
|
593
|
+
label,
|
|
594
|
+
raw,
|
|
595
|
+
decimals
|
|
596
|
+
}) {
|
|
597
|
+
const trimmed = raw.trim();
|
|
598
|
+
if (trimmed === "") {
|
|
599
|
+
throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
|
|
600
|
+
}
|
|
601
|
+
let value;
|
|
602
|
+
try {
|
|
603
|
+
value = BigInt(trimmed);
|
|
604
|
+
} catch {
|
|
605
|
+
throw new ValidationError(`${label}: not a uint256 integer ("${raw}")`);
|
|
606
|
+
}
|
|
607
|
+
try {
|
|
608
|
+
return BlockchainAmount({ raw: assertUint256(value), decimals });
|
|
609
|
+
} catch {
|
|
610
|
+
throw new ValidationError(`${label}: out of uint256 bounds (${value})`);
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
function parseBlockchainAmount(amount, decimals) {
|
|
614
|
+
const trimmed = amount.trim();
|
|
615
|
+
if (trimmed === "") return { valid: false, reason: { type: "empty" } };
|
|
616
|
+
if (trimmed.startsWith("-")) {
|
|
617
|
+
return { valid: false, reason: { type: "negative" } };
|
|
618
|
+
}
|
|
619
|
+
if (/[eE]/.test(trimmed)) {
|
|
620
|
+
return { valid: false, reason: { type: "invalid-format" } };
|
|
621
|
+
}
|
|
622
|
+
if (!/^\d+(\.\d+)?$/.test(trimmed)) {
|
|
623
|
+
return { valid: false, reason: { type: "invalid-format" } };
|
|
624
|
+
}
|
|
625
|
+
const [, fraction = ""] = trimmed.split(".");
|
|
626
|
+
if (fraction.length > decimals) {
|
|
627
|
+
return {
|
|
628
|
+
valid: false,
|
|
629
|
+
reason: { type: "too-many-decimals", maxDecimals: decimals }
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
try {
|
|
633
|
+
const raw = parseUnits(trimmed, decimals);
|
|
634
|
+
if (raw > MAX_UINT_256) {
|
|
635
|
+
return { valid: false, reason: { type: "overflow" } };
|
|
636
|
+
}
|
|
637
|
+
return {
|
|
638
|
+
valid: true,
|
|
639
|
+
amount: BlockchainAmount({ raw, decimals })
|
|
640
|
+
};
|
|
641
|
+
} catch {
|
|
642
|
+
return { valid: false, reason: { type: "invalid-format" } };
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
// src/shared/types/pagination.ts
|
|
647
|
+
var Cursor = (value) => value;
|
|
648
|
+
var PaginatedResponse = {
|
|
649
|
+
fromDto: (dto, itemMapper) => ({
|
|
650
|
+
data: dto.data.map(itemMapper),
|
|
651
|
+
startingAfter: dto.starting_after ? Cursor(dto.starting_after) : null,
|
|
652
|
+
startingBefore: dto.starting_before ? Cursor(dto.starting_before) : null
|
|
653
|
+
})
|
|
654
|
+
};
|
|
655
|
+
var PaginationParams = {
|
|
656
|
+
toQueryParams: (params) => {
|
|
657
|
+
const queryParams = {};
|
|
658
|
+
if (params.after) {
|
|
659
|
+
queryParams.starting_after = params.after;
|
|
660
|
+
}
|
|
661
|
+
if (params.before) {
|
|
662
|
+
queryParams.starting_before = params.before;
|
|
663
|
+
}
|
|
664
|
+
if (params.limit) {
|
|
665
|
+
queryParams.limit = params.limit;
|
|
666
|
+
}
|
|
667
|
+
return queryParams;
|
|
668
|
+
}
|
|
669
|
+
};
|
|
670
|
+
|
|
671
|
+
// src/shared/types/asset.ts
|
|
672
|
+
var AssetId = (value) => value;
|
|
673
|
+
var AssetCode = (value) => value;
|
|
674
|
+
var Asset = {
|
|
675
|
+
fromDto: (dto) => ({
|
|
676
|
+
id: AssetId(dto.id),
|
|
677
|
+
code: AssetCode(dto.code),
|
|
678
|
+
name: dto.name,
|
|
679
|
+
fractionalDigits: dto.fractional_digits
|
|
680
|
+
})
|
|
681
|
+
};
|
|
682
|
+
|
|
683
|
+
// src/shared/types/offer.ts
|
|
684
|
+
var OfferId = (value) => value;
|
|
685
|
+
var OfferSlug = (value) => value;
|
|
686
|
+
var Offer = {
|
|
687
|
+
fromDto: (dto) => ({
|
|
688
|
+
id: OfferId(dto.id),
|
|
689
|
+
slug: OfferSlug(dto.slug),
|
|
690
|
+
type: dto.type,
|
|
691
|
+
tagline: dto.tagline,
|
|
692
|
+
bannerUrl: dto.banner_url,
|
|
693
|
+
logoUrl: dto.logo_url,
|
|
694
|
+
startsAt: new Date(dto.starts_at),
|
|
695
|
+
endsAt: dto.ends_at ? new Date(dto.ends_at) : null
|
|
696
|
+
})
|
|
697
|
+
};
|
|
698
|
+
|
|
699
|
+
// src/shared/core/utils/crypto.ts
|
|
700
|
+
async function sha256(data) {
|
|
701
|
+
const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
|
|
702
|
+
const buffer = bytes.buffer.slice(
|
|
703
|
+
bytes.byteOffset,
|
|
704
|
+
bytes.byteOffset + bytes.byteLength
|
|
705
|
+
);
|
|
706
|
+
return crypto.subtle.digest("SHA-256", buffer);
|
|
707
|
+
}
|
|
708
|
+
function arrayBufferToBase64Url(buffer, padding = true) {
|
|
709
|
+
const bytes = new Uint8Array(buffer);
|
|
710
|
+
let binary = "";
|
|
711
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
712
|
+
binary += String.fromCharCode(bytes[i]);
|
|
713
|
+
}
|
|
714
|
+
let base64 = btoa(binary);
|
|
715
|
+
base64 = base64.replace(/\+/g, "-").replace(/\//g, "_");
|
|
716
|
+
if (!padding) {
|
|
717
|
+
base64 = base64.replace(/=+$/, "");
|
|
718
|
+
}
|
|
719
|
+
return base64;
|
|
720
|
+
}
|
|
721
|
+
function generateSecureRandomBase64Url(byteLength) {
|
|
722
|
+
const bytes = new Uint8Array(byteLength);
|
|
723
|
+
crypto.getRandomValues(bytes);
|
|
724
|
+
const buffer = bytes.buffer;
|
|
725
|
+
return arrayBufferToBase64Url(buffer, false);
|
|
726
|
+
}
|
|
727
|
+
function getUUIDv4() {
|
|
728
|
+
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
729
|
+
return crypto.randomUUID();
|
|
730
|
+
}
|
|
731
|
+
if (typeof crypto !== "undefined" && typeof crypto.getRandomValues === "function") {
|
|
732
|
+
const bytes = new Uint8Array(16);
|
|
733
|
+
crypto.getRandomValues(bytes);
|
|
734
|
+
bytes[6] = bytes[6] & 15 | 64;
|
|
735
|
+
bytes[8] = bytes[8] & 63 | 128;
|
|
736
|
+
const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0"));
|
|
737
|
+
return `${hex.slice(0, 4).join("")}-${hex.slice(4, 6).join("")}-${hex.slice(6, 8).join("")}-${hex.slice(8, 10).join("")}-${hex.slice(10, 16).join("")}`;
|
|
738
|
+
}
|
|
739
|
+
return `${Date.now()}-${Math.random().toString(36).slice(2, 12)}`;
|
|
740
|
+
}
|
|
741
|
+
function notBlankStringOrNull(value) {
|
|
742
|
+
if (value?.trim()) {
|
|
743
|
+
return value;
|
|
744
|
+
} else {
|
|
745
|
+
return null;
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
// src/shared/types/offer-detail.ts
|
|
750
|
+
var OfferOptionId = (value) => value;
|
|
751
|
+
var OfferOptionSlug = (value) => value;
|
|
752
|
+
var OfferDetail = {
|
|
753
|
+
fromDto: (dto) => {
|
|
754
|
+
if (!Array.isArray(dto.funding_assets)) {
|
|
755
|
+
throw new Error(`funding_assets must be an array`);
|
|
756
|
+
}
|
|
757
|
+
if (!Array.isArray(dto.options)) {
|
|
758
|
+
throw new Error(`options must be an array`);
|
|
759
|
+
}
|
|
760
|
+
if (!Array.isArray(dto.terms)) {
|
|
761
|
+
throw new Error(`terms must be an array`);
|
|
762
|
+
}
|
|
763
|
+
if (!Array.isArray(dto.links)) {
|
|
764
|
+
throw new Error(`links must be an array`);
|
|
765
|
+
}
|
|
766
|
+
if (!Array.isArray(dto.faqs)) {
|
|
767
|
+
throw new Error(`faqs must be an array`);
|
|
768
|
+
}
|
|
769
|
+
if (!Array.isArray(dto.milestones)) {
|
|
770
|
+
throw new Error(`milestones must be an array`);
|
|
771
|
+
}
|
|
772
|
+
if (!Array.isArray(dto.tokens)) {
|
|
773
|
+
throw new Error(`tokens must be an array`);
|
|
774
|
+
}
|
|
775
|
+
return {
|
|
776
|
+
id: OfferId(dto.id),
|
|
777
|
+
slug: OfferSlug(dto.slug),
|
|
778
|
+
type: dto.type,
|
|
779
|
+
name: dto.name,
|
|
780
|
+
asset: Asset.fromDto(dto.asset),
|
|
781
|
+
fundingAssets: dto.funding_assets.map(Asset.fromDto),
|
|
782
|
+
tokens: dto.tokens.map(OfferToken.fromDto),
|
|
783
|
+
about: notBlankStringOrNull(dto.about),
|
|
784
|
+
tagline: dto.tagline,
|
|
785
|
+
bannerUrl: dto.banner_url,
|
|
786
|
+
logoUrl: dto.logo_url,
|
|
787
|
+
category: dto.category,
|
|
788
|
+
startsAt: new Date(dto.starts_at),
|
|
789
|
+
endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
|
|
790
|
+
faqs: dto.faqs.map(FaqItem.fromDto),
|
|
791
|
+
links: dto.links.map(Link.fromDto),
|
|
792
|
+
milestones: dto.milestones.map(Milestone.fromDto),
|
|
793
|
+
options: dto.options.map(OfferOption.fromDto),
|
|
794
|
+
terms: dto.terms.map(TermItem.fromDto)
|
|
795
|
+
};
|
|
796
|
+
}
|
|
797
|
+
};
|
|
798
|
+
var OfferOption = {
|
|
799
|
+
fromDto: (dto) => ({
|
|
800
|
+
id: OfferOptionId(dto.id),
|
|
801
|
+
slug: OfferOptionSlug(dto.slug),
|
|
802
|
+
bidIncrement: dto.bid_increment,
|
|
803
|
+
floorPriceUsd: dto.floor_price_usd,
|
|
804
|
+
minimumPurchaseUsd: dto.minimum_purchase_usd,
|
|
805
|
+
priceUsd: dto.price_usd,
|
|
806
|
+
saleAgreementUrl: notBlankStringOrNull(dto.sale_agreement_url),
|
|
807
|
+
totalTokenSupply: dto.total_token_supply
|
|
808
|
+
})
|
|
809
|
+
};
|
|
810
|
+
var FaqItem = {
|
|
811
|
+
fromDto: (dto) => ({
|
|
812
|
+
question: notBlankStringOrNull(dto.question),
|
|
813
|
+
answer: notBlankStringOrNull(dto.answer)
|
|
814
|
+
})
|
|
815
|
+
};
|
|
816
|
+
var Link = {
|
|
817
|
+
fromDto: (dto) => ({
|
|
818
|
+
label: notBlankStringOrNull(dto.label),
|
|
819
|
+
url: notBlankStringOrNull(dto.url)
|
|
820
|
+
})
|
|
821
|
+
};
|
|
822
|
+
var TermItem = {
|
|
823
|
+
fromDto: (dto) => ({
|
|
824
|
+
key: notBlankStringOrNull(dto.key),
|
|
825
|
+
value: notBlankStringOrNull(dto.value)
|
|
826
|
+
})
|
|
827
|
+
};
|
|
828
|
+
var Milestone = {
|
|
829
|
+
fromDto: (dto) => ({
|
|
830
|
+
name: notBlankStringOrNull(dto.name),
|
|
831
|
+
schedule: notBlankStringOrNull(dto.schedule),
|
|
832
|
+
status: dto.status
|
|
833
|
+
})
|
|
834
|
+
};
|
|
835
|
+
var OfferToken = {
|
|
836
|
+
fromDto: (dto) => ({
|
|
837
|
+
role: dto.role,
|
|
838
|
+
chain: Chain(dto.chain),
|
|
839
|
+
address: EvmContractAddress(dto.address)
|
|
840
|
+
})
|
|
841
|
+
};
|
|
842
|
+
|
|
843
|
+
// src/shared/types/providers/coin-list/token-sale.ts
|
|
844
|
+
var ParticipationId = (value) => value;
|
|
845
|
+
var Blockchain = (value) => value;
|
|
846
|
+
var WalletAddress = (value) => value;
|
|
847
|
+
var ParticipationsPaginationParams = {
|
|
848
|
+
toQueryParams: (params) => {
|
|
849
|
+
const queryParams = PaginationParams.toQueryParams(params);
|
|
850
|
+
if (params.offerId) {
|
|
851
|
+
queryParams["filters[0][field]"] = "offer_id";
|
|
852
|
+
queryParams["filters[0][op]"] = "==";
|
|
853
|
+
queryParams["filters[0][value]"] = params.offerId;
|
|
854
|
+
}
|
|
855
|
+
return queryParams;
|
|
856
|
+
}
|
|
857
|
+
};
|
|
858
|
+
var Participation = {
|
|
859
|
+
/** Maps API DTO shape into the SDK participation domain model. */
|
|
860
|
+
fromDto: (dto) => {
|
|
861
|
+
const walletAddress = notBlankStringOrNull(dto.wallet_address);
|
|
862
|
+
return {
|
|
863
|
+
id: ParticipationId(dto.id),
|
|
864
|
+
offerId: OfferId(dto.offer_id),
|
|
865
|
+
offerOptionId: OfferOptionId(dto.offer_option_id),
|
|
866
|
+
status: dto.status,
|
|
867
|
+
amount: dto.amount,
|
|
868
|
+
displayAmount: dto.amount_string,
|
|
869
|
+
asset: Asset.fromDto(dto.asset),
|
|
870
|
+
chain: Blockchain(dto.chain),
|
|
871
|
+
insertedAt: dto.inserted_at ? new Date(dto.inserted_at) : null,
|
|
872
|
+
updatedAt: dto.updated_at ? new Date(dto.updated_at) : null,
|
|
873
|
+
walletAddress: walletAddress ? WalletAddress(walletAddress) : null
|
|
874
|
+
};
|
|
875
|
+
}
|
|
876
|
+
};
|
|
877
|
+
var CreateParticipationParams = {
|
|
878
|
+
/** Maps participation creation params into API DTO payload. */
|
|
879
|
+
toDto: (params) => ({
|
|
880
|
+
offer_id: params.offerId,
|
|
881
|
+
offer_option_id: params.offerOptionId,
|
|
882
|
+
chain: params.chain,
|
|
883
|
+
wallet_address: params.walletAddress,
|
|
884
|
+
amount: params.amount,
|
|
885
|
+
asset_id: params.assetId,
|
|
886
|
+
approval_transaction_hash: params.approvalTransactionHash
|
|
887
|
+
})
|
|
888
|
+
};
|
|
889
|
+
|
|
890
|
+
// src/shared/api/frontline/providers/coin-list/token-sale.ts
|
|
891
|
+
async function fetchParticipations(api, offerId) {
|
|
892
|
+
return fetchAllPages(
|
|
893
|
+
(params) => fetchParticipationsPage(api, params),
|
|
894
|
+
{ offerId }
|
|
895
|
+
);
|
|
896
|
+
}
|
|
897
|
+
async function fetchParticipationsPage(api, params) {
|
|
898
|
+
const pageDto = await api.send({
|
|
899
|
+
method: "GET",
|
|
900
|
+
url: "/v1/participations",
|
|
901
|
+
queryParams: ParticipationsPaginationParams.toQueryParams(params),
|
|
902
|
+
attributes: Attributes.protected()
|
|
903
|
+
});
|
|
904
|
+
return PaginatedResponse.fromDto(pageDto, Participation.fromDto);
|
|
905
|
+
}
|
|
906
|
+
async function fetchParticipation(api, id) {
|
|
907
|
+
const dto = await api.send({
|
|
908
|
+
method: "GET",
|
|
909
|
+
url: `/v1/participations/${id}`,
|
|
910
|
+
attributes: Attributes.protected()
|
|
911
|
+
});
|
|
912
|
+
return Participation.fromDto(dto);
|
|
913
|
+
}
|
|
914
|
+
async function createParticipation(api, params) {
|
|
915
|
+
const dto = await api.send({
|
|
916
|
+
method: "POST",
|
|
917
|
+
url: "/v1/participations",
|
|
918
|
+
body: CreateParticipationParams.toDto(params),
|
|
919
|
+
attributes: Attributes.protected()
|
|
920
|
+
});
|
|
921
|
+
return Participation.fromDto(dto);
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
// src/shared/core/checkout/coin-list/token-sale-namespace.ts
|
|
925
|
+
var CoinListTokenSaleNamespaceImpl = class {
|
|
926
|
+
constructor(ctx) {
|
|
927
|
+
this.ctx = ctx;
|
|
928
|
+
}
|
|
929
|
+
async list(offerId) {
|
|
930
|
+
await this.ctx.ensureUserAuthenticated();
|
|
931
|
+
return fetchParticipations(this.ctx.api, offerId);
|
|
932
|
+
}
|
|
933
|
+
async listPage(params) {
|
|
934
|
+
await this.ctx.ensureUserAuthenticated();
|
|
935
|
+
return fetchParticipationsPage(this.ctx.api, params);
|
|
936
|
+
}
|
|
937
|
+
async get(id) {
|
|
938
|
+
await this.ctx.ensureUserAuthenticated();
|
|
939
|
+
return fetchParticipation(this.ctx.api, id);
|
|
940
|
+
}
|
|
941
|
+
async createParticipation(params) {
|
|
942
|
+
await this.ctx.ensureUserAuthenticated();
|
|
943
|
+
return createParticipation(this.ctx.api, params);
|
|
944
|
+
}
|
|
945
|
+
};
|
|
946
|
+
|
|
947
|
+
// src/shared/types/trading.ts
|
|
948
|
+
var Ticker = (value) => value;
|
|
949
|
+
|
|
950
|
+
// src/shared/types/providers/ondo/ondo.ts
|
|
951
|
+
var OndoTradingStatus = {
|
|
952
|
+
fromDto: (dto) => {
|
|
953
|
+
if (!dto.tradable) return { type: "not-tradable", side: dto.side };
|
|
954
|
+
return {
|
|
955
|
+
type: "tradable",
|
|
956
|
+
side: dto.side,
|
|
957
|
+
grossMaxTokens: decimalOrNull(dto.gross_max_tokens),
|
|
958
|
+
grossMaxNotionalValue: decimalOrNull(dto.gross_max_notional_value),
|
|
959
|
+
grossMaxActiveNotionalValue: decimalOrNull(
|
|
960
|
+
dto.gross_max_active_notional_value
|
|
961
|
+
)
|
|
962
|
+
};
|
|
963
|
+
}
|
|
964
|
+
};
|
|
965
|
+
var decimalOrNull = (value) => value === null ? null : DecimalString(value);
|
|
966
|
+
var OndoQuote = {
|
|
967
|
+
fromDto: (dto) => {
|
|
968
|
+
const assetDecimals = AssetDecimals(dto.asset_decimals);
|
|
969
|
+
return {
|
|
970
|
+
chain: chainFromId(dto.chain_id),
|
|
971
|
+
ticker: Ticker(dto.ticker),
|
|
972
|
+
assetAddress: EvmContractAddress(dto.asset_address),
|
|
973
|
+
asset: {
|
|
974
|
+
name: dto.ticker,
|
|
975
|
+
symbol: AssetSymbol(dto.symbol),
|
|
976
|
+
decimals: assetDecimals
|
|
977
|
+
},
|
|
978
|
+
side: dto.side,
|
|
979
|
+
tokenBaseUnits: blockchainAmountFromRawOrThrow({
|
|
980
|
+
label: "tokenBaseUnits",
|
|
981
|
+
raw: dto.token_base_units,
|
|
982
|
+
decimals: assetDecimals
|
|
983
|
+
}),
|
|
984
|
+
price: DecimalString(dto.price)
|
|
985
|
+
};
|
|
986
|
+
}
|
|
987
|
+
};
|
|
988
|
+
var OndoSwapTransaction = {
|
|
989
|
+
fromDto: (dto) => {
|
|
990
|
+
const inputDecimals = AssetDecimals(dto.pay_input_decimals);
|
|
991
|
+
const outputDecimals = AssetDecimals(dto.receive_output_decimals);
|
|
992
|
+
return {
|
|
993
|
+
tx: {
|
|
994
|
+
to: EvmContractAddress(dto.to),
|
|
995
|
+
data: HexEncodedTransactionData(dto.data)
|
|
996
|
+
},
|
|
997
|
+
expiresAt: parseExpiresAt(dto.expires_at),
|
|
998
|
+
payInputAmount: blockchainAmountFromRawOrThrow({
|
|
999
|
+
label: "pay_input_amount",
|
|
1000
|
+
raw: dto.pay_input_amount,
|
|
1001
|
+
decimals: inputDecimals
|
|
1002
|
+
}),
|
|
1003
|
+
fee: blockchainAmountFromRawOrThrow({
|
|
1004
|
+
label: "fee",
|
|
1005
|
+
raw: dto.fee,
|
|
1006
|
+
decimals: inputDecimals
|
|
1007
|
+
}),
|
|
1008
|
+
notionalValue: blockchainAmountFromRawOrThrow({
|
|
1009
|
+
label: "notional_value",
|
|
1010
|
+
raw: dto.notional_value,
|
|
1011
|
+
decimals: inputDecimals
|
|
1012
|
+
}),
|
|
1013
|
+
receiveOutputAmount: parseReceiveOutputAmount(
|
|
1014
|
+
dto.receive_output_amount,
|
|
1015
|
+
outputDecimals
|
|
1016
|
+
)
|
|
1017
|
+
};
|
|
1018
|
+
}
|
|
1019
|
+
};
|
|
1020
|
+
function parseReceiveOutputAmount(raw, decimals) {
|
|
1021
|
+
const amount = blockchainAmountFromRawOrThrow({
|
|
1022
|
+
label: "receive_output_amount",
|
|
1023
|
+
raw,
|
|
1024
|
+
decimals
|
|
1025
|
+
});
|
|
1026
|
+
if (amount.raw <= 0n) {
|
|
1027
|
+
throw new ValidationError(
|
|
1028
|
+
`receive_output_amount: must be greater than zero ("${raw}")`
|
|
1029
|
+
);
|
|
1030
|
+
}
|
|
1031
|
+
return amount;
|
|
1032
|
+
}
|
|
1033
|
+
function parseExpiresAt(value) {
|
|
1034
|
+
const date = new Date(value);
|
|
1035
|
+
if (Number.isNaN(date.getTime())) {
|
|
1036
|
+
throw new ValidationError(`expires_at: not a date ("${value}")`);
|
|
1037
|
+
}
|
|
1038
|
+
return date;
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
// src/shared/api/frontline/providers/ondo/ondo.ts
|
|
1042
|
+
async function getOndoTradingStatus(api, params) {
|
|
1043
|
+
const dto = await api.send({
|
|
1044
|
+
method: "GET",
|
|
1045
|
+
url: "/v1/ondo/swap/trading-status",
|
|
1046
|
+
queryParams: { symbol: params.symbol, side: params.side },
|
|
1047
|
+
attributes: Attributes.protected()
|
|
1048
|
+
});
|
|
1049
|
+
return OndoTradingStatus.fromDto(dto);
|
|
1050
|
+
}
|
|
1051
|
+
async function getOndoQuote(api, params) {
|
|
1052
|
+
const dto = await api.send({
|
|
1053
|
+
method: "GET",
|
|
1054
|
+
url: "/v1/ondo/swap/quote",
|
|
1055
|
+
queryParams: {
|
|
1056
|
+
symbol: params.symbol,
|
|
1057
|
+
side: params.side,
|
|
1058
|
+
duration: params.duration,
|
|
1059
|
+
...sizeParam(params)
|
|
1060
|
+
},
|
|
1061
|
+
attributes: Attributes.protected()
|
|
1062
|
+
});
|
|
1063
|
+
return OndoQuote.fromDto(dto);
|
|
1064
|
+
}
|
|
1065
|
+
async function buildOndoSwapTransaction(api, params) {
|
|
1066
|
+
const dto = await api.send({
|
|
1067
|
+
method: "POST",
|
|
1068
|
+
url: "/v1/ondo/swap/transaction",
|
|
1069
|
+
body: {
|
|
1070
|
+
symbol: params.symbol,
|
|
1071
|
+
chain: params.chain,
|
|
1072
|
+
wallet_address: params.walletAddress,
|
|
1073
|
+
amount: params.amount.raw.toString()
|
|
1074
|
+
},
|
|
1075
|
+
attributes: Attributes.protected()
|
|
1076
|
+
});
|
|
1077
|
+
assertFundingScaleAgrees(dto, params);
|
|
1078
|
+
return OndoSwapTransaction.fromDto(dto);
|
|
1079
|
+
}
|
|
1080
|
+
function assertFundingScaleAgrees(dto, params) {
|
|
1081
|
+
if (dto.pay_input_decimals !== params.amount.decimals) {
|
|
1082
|
+
throw new ValidationError(
|
|
1083
|
+
`pay_input_decimals: the swap was priced in ${dto.pay_input_decimals} decimals but the order was sized in ${params.amount.decimals}`
|
|
1084
|
+
);
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
function sizeParam(params) {
|
|
1088
|
+
const tokenAmount = "tokenAmount" in params ? params.tokenAmount : void 0;
|
|
1089
|
+
const notionalValue = "notionalValue" in params ? params.notionalValue : void 0;
|
|
1090
|
+
if (tokenAmount !== void 0) {
|
|
1091
|
+
if (notionalValue !== void 0) {
|
|
1092
|
+
throw new ValidationError(
|
|
1093
|
+
"An Ondo quote takes tokenAmount or notionalValue, not both"
|
|
1094
|
+
);
|
|
1095
|
+
}
|
|
1096
|
+
return { token_amount: formatRawAmount(tokenAmount) };
|
|
1097
|
+
}
|
|
1098
|
+
if (notionalValue === void 0) {
|
|
1099
|
+
throw new ValidationError(
|
|
1100
|
+
"An Ondo quote must be sized by tokenAmount or notionalValue"
|
|
1101
|
+
);
|
|
1102
|
+
}
|
|
1103
|
+
return { notional_value: notionalValue };
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
// src/shared/core/checkout/ondo/ondo-namespace.ts
|
|
1107
|
+
var OndoNamespaceImpl = class {
|
|
1108
|
+
constructor(ctx) {
|
|
1109
|
+
this.ctx = ctx;
|
|
1110
|
+
}
|
|
1111
|
+
async getTradingStatus(params) {
|
|
1112
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1113
|
+
return getOndoTradingStatus(this.ctx.api, params);
|
|
1114
|
+
}
|
|
1115
|
+
async getQuote(params) {
|
|
1116
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1117
|
+
return getOndoQuote(this.ctx.api, params);
|
|
1118
|
+
}
|
|
1119
|
+
async buildSwapTransaction(params) {
|
|
1120
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1121
|
+
return buildOndoSwapTransaction(this.ctx.api, params);
|
|
1122
|
+
}
|
|
1123
|
+
};
|
|
1124
|
+
|
|
1125
|
+
// src/shared/core/checkout/superstate/swap-namespace.ts
|
|
1126
|
+
var SuperstateSwapNamespaceImpl = class {
|
|
1127
|
+
constructor(ctx) {
|
|
1128
|
+
this.ctx = ctx;
|
|
1129
|
+
}
|
|
1130
|
+
async getAuthorization(params) {
|
|
1131
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1132
|
+
return getSwapAuthorization(this.ctx.api, params);
|
|
1133
|
+
}
|
|
1134
|
+
async getPreview(params) {
|
|
1135
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1136
|
+
return getSwapPreview(this.ctx.api, params);
|
|
1137
|
+
}
|
|
1138
|
+
async getStatus(params) {
|
|
1139
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1140
|
+
return getSwapStatus(this.ctx.api, params);
|
|
1141
|
+
}
|
|
1142
|
+
async getOutputToken(params) {
|
|
1143
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1144
|
+
return getSwapOutputToken(this.ctx.api, params);
|
|
1145
|
+
}
|
|
1146
|
+
async allowWallet(params) {
|
|
1147
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1148
|
+
return allowWallet(this.ctx.api, params);
|
|
1149
|
+
}
|
|
1150
|
+
};
|
|
1151
|
+
|
|
1152
|
+
// src/shared/types/document-submission.ts
|
|
1153
|
+
var DocumentSubmission = {
|
|
1154
|
+
fromDto: (dto) => ({
|
|
1155
|
+
status: dto.status,
|
|
1156
|
+
formType: dto.form_type
|
|
1157
|
+
})
|
|
1158
|
+
};
|
|
1159
|
+
|
|
1160
|
+
// src/shared/types/kyc.ts
|
|
1161
|
+
var KycToken = {
|
|
1162
|
+
fromDto: (dto) => ({
|
|
1163
|
+
token: dto.token
|
|
1164
|
+
})
|
|
1165
|
+
};
|
|
1166
|
+
|
|
1167
|
+
// src/shared/types/pii.ts
|
|
1168
|
+
var Iso2CountryCode = (value) => value;
|
|
1169
|
+
var PiiJurisdiction = {
|
|
1170
|
+
fromDto: (dto) => ({
|
|
1171
|
+
iso2: Iso2CountryCode(dto.iso_2),
|
|
1172
|
+
name: dto.name
|
|
1173
|
+
})
|
|
1174
|
+
};
|
|
1175
|
+
var PiiAddress = {
|
|
1176
|
+
fromDto: (dto) => ({
|
|
1177
|
+
street: dto.street,
|
|
1178
|
+
city: dto.city,
|
|
1179
|
+
state: dto.state,
|
|
1180
|
+
postalCode: dto.postal_code,
|
|
1181
|
+
country: dto.country
|
|
1182
|
+
})
|
|
1183
|
+
};
|
|
1184
|
+
var Pii = {
|
|
1185
|
+
fromDto: (dto) => ({
|
|
1186
|
+
kind: dto.kind,
|
|
1187
|
+
fullLegalName: dto.full_legal_name,
|
|
1188
|
+
dateOfBirth: dto.date_of_birth,
|
|
1189
|
+
jurisdiction: dto.jurisdiction ? PiiJurisdiction.fromDto(dto.jurisdiction) : null,
|
|
1190
|
+
taxId: dto.tax_id,
|
|
1191
|
+
permanentAddress: PiiAddress.fromDto(dto.permanent_address)
|
|
1192
|
+
})
|
|
1193
|
+
};
|
|
1194
|
+
|
|
1195
|
+
// src/shared/types/requirement.ts
|
|
1196
|
+
var RequirementId = (value) => value;
|
|
1197
|
+
var Requirement = {
|
|
1198
|
+
fromDto: (dto) => ({
|
|
1199
|
+
id: RequirementId(dto.id),
|
|
1200
|
+
type: dto.type,
|
|
1201
|
+
details: dto.details
|
|
1202
|
+
})
|
|
1203
|
+
};
|
|
1204
|
+
var RequirementStatusInfo = {
|
|
1205
|
+
fromStatusesDto: (dto) => Object.entries(dto.statuses).map(
|
|
1206
|
+
([id, value]) => typeof value === "string" ? { id: RequirementId(id), status: value, action: null } : {
|
|
1207
|
+
id: RequirementId(id),
|
|
1208
|
+
status: value.status,
|
|
1209
|
+
action: value.action ?? null,
|
|
1210
|
+
kycLevel: value.kyc_level,
|
|
1211
|
+
kycReset: value.kyc_reset
|
|
1212
|
+
}
|
|
1213
|
+
)
|
|
1214
|
+
};
|
|
1215
|
+
|
|
1216
|
+
// src/shared/api/frontline/documents.ts
|
|
1217
|
+
async function submitDocument(api, documentType, fields) {
|
|
1218
|
+
const dto = await api.send({
|
|
1219
|
+
method: "POST",
|
|
1220
|
+
url: `/v1/documents/${documentType}/submission`,
|
|
1221
|
+
body: fields,
|
|
1222
|
+
attributes: Attributes.protected()
|
|
1223
|
+
});
|
|
1224
|
+
return DocumentSubmission.fromDto(dto);
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
// src/shared/api/frontline/kyc.ts
|
|
1228
|
+
async function createKycToken(api, levelName, reset) {
|
|
1229
|
+
const dto = await api.send({
|
|
1230
|
+
method: "POST",
|
|
1231
|
+
url: "/v1/kyc-token",
|
|
1232
|
+
body: {
|
|
1233
|
+
...levelName === void 0 ? {} : { level_name: levelName },
|
|
1234
|
+
...reset === void 0 ? {} : { reset }
|
|
1235
|
+
},
|
|
1236
|
+
attributes: Attributes.protected()
|
|
1237
|
+
});
|
|
1238
|
+
return KycToken.fromDto(dto);
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
// src/shared/api/frontline/pii.ts
|
|
1242
|
+
async function fetchPii(api) {
|
|
1243
|
+
const dto = await api.send({
|
|
1244
|
+
method: "GET",
|
|
1245
|
+
url: "/v1/pii",
|
|
1246
|
+
attributes: Attributes.protected()
|
|
1247
|
+
});
|
|
1248
|
+
return Pii.fromDto(dto);
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
// src/shared/api/frontline/requirements.ts
|
|
1252
|
+
async function fetchOfferRequirements(api, offerId, clientCreds) {
|
|
1253
|
+
const response = await api.send({
|
|
1254
|
+
method: "GET",
|
|
1255
|
+
url: `/v1/offers/${offerId}/requirements`,
|
|
1256
|
+
attributes: Attributes.concat(
|
|
1257
|
+
Attributes.protected(),
|
|
1258
|
+
Attributes.clientCredentials(clientCreds)
|
|
1259
|
+
)
|
|
1260
|
+
});
|
|
1261
|
+
return Object.fromEntries(
|
|
1262
|
+
Object.entries(response.options).map(([optionId, list]) => [
|
|
1263
|
+
optionId,
|
|
1264
|
+
list.data.map(Requirement.fromDto)
|
|
1265
|
+
])
|
|
1266
|
+
);
|
|
1267
|
+
}
|
|
1268
|
+
async function fetchRequirementStatuses(api, offerId) {
|
|
1269
|
+
const response = await api.send({
|
|
1270
|
+
method: "GET",
|
|
1271
|
+
url: `/v1/offers/${offerId}/requirements/statuses`,
|
|
1272
|
+
attributes: Attributes.protected()
|
|
1273
|
+
});
|
|
1274
|
+
return RequirementStatusInfo.fromStatusesDto(response);
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
// src/shared/core/requirements/requirements-namespace.ts
|
|
1278
|
+
var RequirementsNamespaceImpl = class {
|
|
1279
|
+
constructor(ctx) {
|
|
1280
|
+
this.ctx = ctx;
|
|
1281
|
+
}
|
|
1282
|
+
async forOffer(offerId) {
|
|
1283
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1284
|
+
return fetchOfferRequirements(
|
|
1285
|
+
this.ctx.api,
|
|
1286
|
+
offerId,
|
|
1287
|
+
void 0
|
|
1288
|
+
);
|
|
1289
|
+
}
|
|
1290
|
+
async statuses(offerId) {
|
|
1291
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1292
|
+
return fetchRequirementStatuses(this.ctx.api, offerId);
|
|
1293
|
+
}
|
|
1294
|
+
async createKycToken(params) {
|
|
1295
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1296
|
+
return createKycToken(
|
|
1297
|
+
this.ctx.api,
|
|
1298
|
+
params?.levelName,
|
|
1299
|
+
params?.reset
|
|
1300
|
+
);
|
|
1301
|
+
}
|
|
1302
|
+
async getPii() {
|
|
1303
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1304
|
+
return fetchPii(this.ctx.api);
|
|
1305
|
+
}
|
|
1306
|
+
async submitDocument(params) {
|
|
1307
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1308
|
+
return submitDocument(
|
|
1309
|
+
this.ctx.api,
|
|
1310
|
+
params.documentType,
|
|
1311
|
+
params.fields
|
|
1312
|
+
);
|
|
1313
|
+
}
|
|
1314
|
+
};
|
|
1315
|
+
|
|
1316
|
+
// src/shared/types/token-metadata.ts
|
|
1317
|
+
var TokenLogoUrl = (value) => value;
|
|
1318
|
+
var TokenLogo = {
|
|
1319
|
+
/** `baseUrl` is the registry origin; registry URLs are root-relative. */
|
|
1320
|
+
fromDto: (dto, baseUrl) => dto.kind === "VECTOR" ? { kind: "VECTOR", url: resolveLogoUrl(dto.url, baseUrl) } : {
|
|
1321
|
+
kind: "RASTER",
|
|
1322
|
+
original: logoImageFromDto(dto.original, baseUrl),
|
|
1323
|
+
variants: dto.variants.map((v) => logoImageFromDto(v, baseUrl))
|
|
1324
|
+
}
|
|
1325
|
+
};
|
|
1326
|
+
var TokenMetadata = {
|
|
1327
|
+
/** `baseUrl` is the registry origin; registry logo URLs are root-relative. */
|
|
1328
|
+
fromDto: (dto, baseUrl) => {
|
|
1329
|
+
assertSupportedSchemaVersion(dto.schema_version);
|
|
1330
|
+
return {
|
|
1331
|
+
identifier: {
|
|
1332
|
+
chain: EthereumChain(dto.chain),
|
|
1333
|
+
address: EvmContractAddress(dto.address)
|
|
1334
|
+
},
|
|
1335
|
+
name: dto.name,
|
|
1336
|
+
symbol: AssetSymbol(dto.symbol),
|
|
1337
|
+
decimals: AssetDecimals(dto.decimals),
|
|
1338
|
+
logo: TokenLogo.fromDto(dto.logo, baseUrl),
|
|
1339
|
+
logoDark: dto.logo_dark === void 0 ? null : TokenLogo.fromDto(dto.logo_dark, baseUrl)
|
|
1340
|
+
};
|
|
1341
|
+
},
|
|
1342
|
+
/**
|
|
1343
|
+
* Maps a chain snapshot to the tokens it lists, skipping the chain's native
|
|
1344
|
+
* coin (`kind: 'COIN'`, no contract address).
|
|
1345
|
+
*/
|
|
1346
|
+
fromChainAssetsDto: (dto, baseUrl) => {
|
|
1347
|
+
assertSupportedSchemaVersion(dto.schema_version);
|
|
1348
|
+
const chain = EthereumChain(dto.chain);
|
|
1349
|
+
return dto.assets.filter((asset) => asset.kind === "TOKEN" && asset.address !== void 0).map((asset) => ({
|
|
1350
|
+
identifier: {
|
|
1351
|
+
chain,
|
|
1352
|
+
// The filter above cannot narrow `address` for the type checker.
|
|
1353
|
+
address: EvmContractAddress(asset.address)
|
|
1354
|
+
},
|
|
1355
|
+
name: asset.name,
|
|
1356
|
+
symbol: AssetSymbol(asset.symbol),
|
|
1357
|
+
decimals: AssetDecimals(asset.decimals),
|
|
1358
|
+
logo: TokenLogo.fromDto(asset.logo, baseUrl),
|
|
1359
|
+
logoDark: asset.logo_dark === void 0 ? null : TokenLogo.fromDto(asset.logo_dark, baseUrl)
|
|
1360
|
+
}));
|
|
1361
|
+
}
|
|
1362
|
+
};
|
|
1363
|
+
function assertSupportedSchemaVersion(version) {
|
|
1364
|
+
if (version !== 1) {
|
|
1365
|
+
throw new ValidationError(
|
|
1366
|
+
`Unsupported token registry schema_version: ${version}`
|
|
1367
|
+
);
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
var logoImageFromDto = (dto, baseUrl) => ({
|
|
1371
|
+
url: resolveLogoUrl(dto.url, baseUrl),
|
|
1372
|
+
width: dto.width,
|
|
1373
|
+
height: dto.height
|
|
1374
|
+
});
|
|
1375
|
+
var resolveLogoUrl = (url, baseUrl) => TokenLogoUrl(
|
|
1376
|
+
url.startsWith("http") ? url : `${baseUrl.replace(/\/$/, "")}${url}`
|
|
1377
|
+
);
|
|
1378
|
+
|
|
1379
|
+
// src/shared/api/nabu/tokens.ts
|
|
1380
|
+
import { getAddress } from "viem";
|
|
1381
|
+
|
|
1382
|
+
// src/shared/api/frontline/config.ts
|
|
1383
|
+
var PUBLIC_API_BASE_URL = "https://api.coinlist.co";
|
|
1384
|
+
var HEADER_API_VERSION = "X-API-Version";
|
|
1385
|
+
var HEADER_USER_AGENT = "User-Agent";
|
|
1386
|
+
var HEADER_IDEMPOTENCY_KEY = "Idempotency-Key";
|
|
1387
|
+
var API_VERSION = "2025-10-17";
|
|
1388
|
+
var COINLIST_BASE_URL = "https://coinlist.co";
|
|
1389
|
+
var OAUTH_PAGE_PATH = "/oauth/authorize";
|
|
1390
|
+
var SUPPORT_NEW_TICKET_URL = "https://support.coinlist.co/support/tickets/new";
|
|
1391
|
+
var VERIFY_IDENTITY_PATH = "/verify-identity";
|
|
1392
|
+
var VERIFY_IDENTITY_VERIFIED_PATH = "/verify-identity/identity_verified";
|
|
1393
|
+
var VERIFY_IDENTITY_PROOF_OF_ADDRESS_PATH = "/verify-identity/proof_of_address";
|
|
1394
|
+
var VERIFY_IDENTITY_SOURCE_OF_FUNDS_PATH = "/verify-identity/source_of_funds";
|
|
1395
|
+
var VERIFY_IDENTITY_ACCREDITATION_PATH = "/verify-identity/accreditation_full";
|
|
1396
|
+
var WALLET_PATH = "/wallet";
|
|
1397
|
+
|
|
1398
|
+
// src/shared/api/http-client.ts
|
|
1399
|
+
var HttpClient = class {
|
|
1400
|
+
constructor(config, middleware = {}) {
|
|
1401
|
+
this.config = config;
|
|
1402
|
+
this.middleware = middleware;
|
|
1403
|
+
}
|
|
1404
|
+
async send(request) {
|
|
1405
|
+
return this.runRequestWithAfterMiddleware(request);
|
|
1406
|
+
}
|
|
1407
|
+
/**
|
|
1408
|
+
* Runs beforeRequest, executeRequest, then the full afterRequest middleware
|
|
1409
|
+
* chain. Used by send() and by the retry() callback so that when a
|
|
1410
|
+
* middleware calls retry(), the retried response also goes through all
|
|
1411
|
+
* afterRequest middleware (e.g. session renewal, retry). Middleware
|
|
1412
|
+
* must use request.attributes.retryAttempt (or similar) to avoid infinite
|
|
1413
|
+
* recursion when they trigger retries.
|
|
1414
|
+
*/
|
|
1415
|
+
async runRequestWithAfterMiddleware(request) {
|
|
1416
|
+
const preparedRequest = await this.runBeforeRequestMiddleware(
|
|
1417
|
+
this.withClientDefaults(request)
|
|
1418
|
+
);
|
|
1419
|
+
let response = await this.executeRequest(preparedRequest);
|
|
1420
|
+
for (const middleware of this.middleware.afterRequest ?? []) {
|
|
1421
|
+
response = await middleware({
|
|
1422
|
+
request: preparedRequest,
|
|
1423
|
+
response,
|
|
1424
|
+
retry: (nextRequest = preparedRequest) => this.runRequestWithAfterMiddleware(nextRequest)
|
|
1425
|
+
});
|
|
1426
|
+
}
|
|
1427
|
+
return response;
|
|
1428
|
+
}
|
|
1429
|
+
withClientDefaults(request) {
|
|
1430
|
+
const url = this.resolveUrl(request.url);
|
|
1431
|
+
const headers = {
|
|
1432
|
+
...request.headers ?? {},
|
|
1433
|
+
...this.config.xApiVersion !== void 0 ? { [HEADER_API_VERSION]: this.config.xApiVersion } : {}
|
|
1434
|
+
};
|
|
1435
|
+
return {
|
|
1436
|
+
...request,
|
|
1437
|
+
url,
|
|
1438
|
+
headers
|
|
1439
|
+
};
|
|
1440
|
+
}
|
|
1441
|
+
/**
|
|
1442
|
+
* Resolves a request URL against the client's baseUrl.
|
|
1443
|
+
*
|
|
1444
|
+
* @internal Public only for testing. Do not use in application code; use
|
|
1445
|
+
* {@link HttpClient.send} with a path and the client will resolve the URL.
|
|
1446
|
+
*/
|
|
1447
|
+
resolveUrl(url) {
|
|
1448
|
+
if (url.startsWith("http://") || url.startsWith("https://")) {
|
|
1449
|
+
return url;
|
|
1450
|
+
}
|
|
1451
|
+
const base = this.config.baseUrl.replace(/\/$/, "");
|
|
1452
|
+
const path = url.startsWith("/") ? url : `/${url}`;
|
|
1453
|
+
return base + path;
|
|
1454
|
+
}
|
|
1455
|
+
async runBeforeRequestMiddleware(initialRequest) {
|
|
1456
|
+
let request = initialRequest;
|
|
1457
|
+
for (const middleware of this.middleware.beforeRequest ?? []) {
|
|
1458
|
+
request = await middleware(request);
|
|
1459
|
+
}
|
|
1460
|
+
return request;
|
|
1461
|
+
}
|
|
1462
|
+
executeRequest(request) {
|
|
1463
|
+
return makeRequest(request);
|
|
1464
|
+
}
|
|
1465
|
+
};
|
|
1466
|
+
|
|
1467
|
+
// src/shared/api/nabu/tokens.ts
|
|
1468
|
+
function createNabuApiClient(baseUrl) {
|
|
1469
|
+
return new HttpClient({ baseUrl });
|
|
1470
|
+
}
|
|
1471
|
+
async function fetchTokenMetadata(client, token) {
|
|
1472
|
+
const address = checksummed(token.address);
|
|
1473
|
+
let response;
|
|
1474
|
+
try {
|
|
1475
|
+
response = await client.send({
|
|
1476
|
+
method: "GET",
|
|
1477
|
+
url: `/${token.chain}/token/${address}`
|
|
1478
|
+
});
|
|
1479
|
+
} catch (error) {
|
|
1480
|
+
if (isRegistryHtmlFallback(error)) {
|
|
1481
|
+
return null;
|
|
1482
|
+
}
|
|
1483
|
+
throw error;
|
|
1484
|
+
}
|
|
1485
|
+
if (response.status === 404) {
|
|
1486
|
+
return null;
|
|
1487
|
+
}
|
|
1488
|
+
assertOk(response);
|
|
1489
|
+
if (response.body === null) {
|
|
1490
|
+
throw new ValidationError(
|
|
1491
|
+
`Token registry returned an empty body for token "${address}" on "${token.chain}"`
|
|
1492
|
+
);
|
|
1493
|
+
}
|
|
1494
|
+
return TokenMetadata.fromDto(response.body, client.config.baseUrl);
|
|
1495
|
+
}
|
|
1496
|
+
async function fetchTokensMetadata(client, chain) {
|
|
1497
|
+
let response;
|
|
1498
|
+
try {
|
|
1499
|
+
response = await client.send({
|
|
1500
|
+
method: "GET",
|
|
1501
|
+
url: `/${chain}/assets.json`
|
|
1502
|
+
});
|
|
1503
|
+
} catch (error) {
|
|
1504
|
+
if (isRegistryHtmlFallback(error)) {
|
|
1505
|
+
throw new ValidationError(
|
|
1506
|
+
`Token registry returned non-JSON for the "${chain}" snapshot`
|
|
1507
|
+
);
|
|
1508
|
+
}
|
|
1509
|
+
throw error;
|
|
1510
|
+
}
|
|
1511
|
+
assertOk(response);
|
|
1512
|
+
if (response.body === null) {
|
|
1513
|
+
throw new ValidationError(
|
|
1514
|
+
`Token registry returned an empty "${chain}" snapshot`
|
|
1515
|
+
);
|
|
1516
|
+
}
|
|
1517
|
+
return TokenMetadata.fromChainAssetsDto(response.body, client.config.baseUrl);
|
|
1518
|
+
}
|
|
1519
|
+
function isRegistryHtmlFallback(error) {
|
|
1520
|
+
return error instanceof HttpError && error.response.status >= 200 && error.response.status < 300;
|
|
1521
|
+
}
|
|
1522
|
+
function assertOk(response) {
|
|
1523
|
+
if (response.status < 200 || response.status >= 300) {
|
|
1524
|
+
throw new HttpError(response);
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
function checksummed(address) {
|
|
1528
|
+
try {
|
|
1529
|
+
return getAddress(address);
|
|
1530
|
+
} catch (_) {
|
|
1531
|
+
throw new ValidationError(`Invalid EVM contract address: "${address}"`);
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
// src/shared/core/tokens/tokens-namespace.ts
|
|
1536
|
+
var TokensNamespaceImpl = class {
|
|
1537
|
+
/**
|
|
1538
|
+
* Takes the registry origin rather than a `SharedNamespaceContext`: the
|
|
1539
|
+
* registry is unauthenticated and on its own host, so the frontline sender
|
|
1540
|
+
* and the auth check would both be dead weight here.
|
|
1541
|
+
*/
|
|
1542
|
+
constructor(baseUrl) {
|
|
1543
|
+
this.api = createNabuApiClient(baseUrl);
|
|
1544
|
+
}
|
|
1545
|
+
get(token) {
|
|
1546
|
+
return fetchTokenMetadata(this.api, token);
|
|
1547
|
+
}
|
|
1548
|
+
list(chain) {
|
|
1549
|
+
return fetchTokensMetadata(this.api, chain);
|
|
1550
|
+
}
|
|
1551
|
+
};
|
|
1552
|
+
|
|
1553
|
+
// src/shared/types/offer-option-address.ts
|
|
1554
|
+
var OfferOptionAddressId = (value) => value;
|
|
1555
|
+
var OfferOptionAddress = {
|
|
1556
|
+
/** Maps the API DTO into the SDK offer-option-address domain model. */
|
|
1557
|
+
fromDto: (dto) => ({
|
|
1558
|
+
id: OfferOptionAddressId(dto.id),
|
|
1559
|
+
offerOptionId: OfferOptionId(dto.offer_option_id),
|
|
1560
|
+
address: EvmWalletAddress(dto.address),
|
|
1561
|
+
protocol: dto.protocol,
|
|
1562
|
+
createdAt: new Date(dto.created_at)
|
|
1563
|
+
})
|
|
1564
|
+
};
|
|
1565
|
+
var ConnectExternalWalletParams = {
|
|
1566
|
+
/** Maps connect-wallet params into the API DTO payload. */
|
|
1567
|
+
toDto: (params) => ({
|
|
1568
|
+
offer_option_id: params.offerOptionId,
|
|
1569
|
+
wallet_address: params.walletAddress,
|
|
1570
|
+
chain: params.chain,
|
|
1571
|
+
signature: params.signature
|
|
1572
|
+
})
|
|
1573
|
+
};
|
|
1574
|
+
|
|
1575
|
+
// src/shared/types/wallet-ownership-challenge.ts
|
|
1576
|
+
var WalletOwnershipChallenge = {
|
|
1577
|
+
/** Maps the API DTO into the SDK wallet-ownership-challenge domain model. */
|
|
1578
|
+
fromDto: (dto) => ({
|
|
1579
|
+
message: dto.message,
|
|
1580
|
+
expiresAt: new Date(dto.expires_at)
|
|
1581
|
+
})
|
|
1582
|
+
};
|
|
1583
|
+
var CreateWalletOwnershipChallengeParams = {
|
|
1584
|
+
/**
|
|
1585
|
+
* Maps challenge-request params into the API DTO payload. The discriminated
|
|
1586
|
+
* union guarantees SIWE fields are present exactly when `challengeType` is
|
|
1587
|
+
* `siwe`, so the mapping narrows on the discriminant.
|
|
1588
|
+
*/
|
|
1589
|
+
toDto: (params) => {
|
|
1590
|
+
switch (params.challengeType) {
|
|
1591
|
+
case "plain":
|
|
1592
|
+
return {
|
|
1593
|
+
wallet_address: params.walletAddress,
|
|
1594
|
+
chain: params.chain,
|
|
1595
|
+
challenge_type: "plain"
|
|
1596
|
+
};
|
|
1597
|
+
case "siwe":
|
|
1598
|
+
return {
|
|
1599
|
+
wallet_address: params.walletAddress,
|
|
1600
|
+
chain: params.chain,
|
|
1601
|
+
challenge_type: "siwe",
|
|
1602
|
+
domain: params.domain,
|
|
1603
|
+
uri: params.uri,
|
|
1604
|
+
statement: params.statement
|
|
1605
|
+
};
|
|
1606
|
+
default: {
|
|
1607
|
+
const _exhaustive = params;
|
|
1608
|
+
return _exhaustive;
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
};
|
|
1613
|
+
|
|
1614
|
+
// src/shared/api/frontline/wallet-connect.ts
|
|
1615
|
+
async function createWalletOwnershipChallenge(api, params) {
|
|
1616
|
+
const dto = await api.send({
|
|
1617
|
+
method: "POST",
|
|
1618
|
+
url: "/v1/wallet-ownership",
|
|
1619
|
+
body: CreateWalletOwnershipChallengeParams.toDto(params),
|
|
1620
|
+
attributes: Attributes.protected()
|
|
1621
|
+
});
|
|
1622
|
+
return WalletOwnershipChallenge.fromDto(dto);
|
|
1623
|
+
}
|
|
1624
|
+
async function connectExternalWallet(api, params) {
|
|
1625
|
+
const dto = await api.send({
|
|
1626
|
+
method: "POST",
|
|
1627
|
+
url: `/v1/offers/${params.offerId}/addresses`,
|
|
1628
|
+
body: ConnectExternalWalletParams.toDto(params),
|
|
1629
|
+
attributes: Attributes.protected()
|
|
1630
|
+
});
|
|
1631
|
+
return OfferOptionAddress.fromDto(dto);
|
|
1632
|
+
}
|
|
1633
|
+
async function listOptionAddresses(api, offerId, offerOptionId) {
|
|
1634
|
+
const { data } = await api.send({
|
|
1635
|
+
method: "GET",
|
|
1636
|
+
url: `/v1/offers/${offerId}/addresses`,
|
|
1637
|
+
queryParams: { offer_option_id: offerOptionId },
|
|
1638
|
+
attributes: Attributes.protected()
|
|
1639
|
+
});
|
|
1640
|
+
return data.map(OfferOptionAddress.fromDto);
|
|
1641
|
+
}
|
|
1642
|
+
async function removeOptionAddress(api, offerId, addressId) {
|
|
1643
|
+
const dto = await api.send({
|
|
1644
|
+
method: "DELETE",
|
|
1645
|
+
url: `/v1/offers/${offerId}/addresses/${addressId}`,
|
|
1646
|
+
attributes: Attributes.protected()
|
|
1647
|
+
});
|
|
1648
|
+
return OfferOptionAddress.fromDto(dto);
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
// src/shared/core/wallets/wallets-namespace.ts
|
|
1652
|
+
var WalletsNamespaceImpl = class {
|
|
1653
|
+
constructor(ctx) {
|
|
1654
|
+
this.ctx = ctx;
|
|
1655
|
+
}
|
|
1656
|
+
async createOwnershipChallenge(params) {
|
|
1657
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1658
|
+
return createWalletOwnershipChallenge(
|
|
1659
|
+
this.ctx.api,
|
|
1660
|
+
params
|
|
1661
|
+
);
|
|
1662
|
+
}
|
|
1663
|
+
async connectExternal(params) {
|
|
1664
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1665
|
+
return connectExternalWallet(this.ctx.api, params);
|
|
1666
|
+
}
|
|
1667
|
+
async list(params) {
|
|
1668
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1669
|
+
return listOptionAddresses(
|
|
1670
|
+
this.ctx.api,
|
|
1671
|
+
params.offerId,
|
|
1672
|
+
params.offerOptionId
|
|
1673
|
+
);
|
|
1674
|
+
}
|
|
1675
|
+
async remove(params) {
|
|
1676
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1677
|
+
return removeOptionAddress(
|
|
1678
|
+
this.ctx.api,
|
|
1679
|
+
params.offerId,
|
|
1680
|
+
params.addressId
|
|
1681
|
+
);
|
|
1682
|
+
}
|
|
1683
|
+
};
|
|
1684
|
+
|
|
1685
|
+
// src/shared/types/oauth-session.ts
|
|
1686
|
+
var ClientCredentialsOAuth = (value) => value;
|
|
1687
|
+
var OAuthRefreshToken = (value) => value;
|
|
1688
|
+
var OAuthSession = {
|
|
1689
|
+
fromDto: (dto) => {
|
|
1690
|
+
const expiresAt = new Date(Date.now() + dto.expires_in * 1e3);
|
|
1691
|
+
return {
|
|
1692
|
+
accessToken: {
|
|
1693
|
+
value: dto.access_token,
|
|
1694
|
+
expiresAt
|
|
1695
|
+
},
|
|
1696
|
+
...dto.refresh_token != null && dto.refresh_token !== "" ? { refreshToken: OAuthRefreshToken(dto.refresh_token) } : void 0
|
|
1697
|
+
};
|
|
1698
|
+
}
|
|
1699
|
+
};
|
|
1700
|
+
|
|
1701
|
+
// src/shared/api/frontline/offers.ts
|
|
1702
|
+
async function fetchOffers(api, clientCreds) {
|
|
1703
|
+
return fetchAllPages((params) => fetchOffersPage(api, params, clientCreds));
|
|
1704
|
+
}
|
|
1705
|
+
async function fetchOffersPage(api, params, clientCreds) {
|
|
1706
|
+
const queryParams = PaginationParams.toQueryParams(params);
|
|
1707
|
+
const pageDto = await api.send({
|
|
1708
|
+
method: "GET",
|
|
1709
|
+
url: "/v1/offers",
|
|
1710
|
+
queryParams,
|
|
1711
|
+
attributes: Attributes.concat(
|
|
1712
|
+
Attributes.protected(),
|
|
1713
|
+
Attributes.clientCredentials(clientCreds)
|
|
1714
|
+
)
|
|
1715
|
+
});
|
|
1716
|
+
return PaginatedResponse.fromDto(pageDto, Offer.fromDto);
|
|
1717
|
+
}
|
|
1718
|
+
async function fetchOfferDetails(api, id, clientCreds) {
|
|
1719
|
+
const dto = await api.send({
|
|
1720
|
+
method: "GET",
|
|
1721
|
+
url: `/v1/offers/${id}`,
|
|
1722
|
+
attributes: Attributes.concat(
|
|
1723
|
+
Attributes.protected(),
|
|
1724
|
+
Attributes.clientCredentials(clientCreds)
|
|
1725
|
+
)
|
|
1726
|
+
});
|
|
1727
|
+
return OfferDetail.fromDto(dto);
|
|
1728
|
+
}
|
|
1729
|
+
|
|
1730
|
+
export {
|
|
1731
|
+
sha256,
|
|
1732
|
+
arrayBufferToBase64Url,
|
|
1733
|
+
generateSecureRandomBase64Url,
|
|
1734
|
+
getUUIDv4,
|
|
1735
|
+
PUBLIC_API_BASE_URL,
|
|
1736
|
+
HEADER_USER_AGENT,
|
|
1737
|
+
HEADER_IDEMPOTENCY_KEY,
|
|
1738
|
+
API_VERSION,
|
|
1739
|
+
COINLIST_BASE_URL,
|
|
1740
|
+
OAUTH_PAGE_PATH,
|
|
1741
|
+
SUPPORT_NEW_TICKET_URL,
|
|
1742
|
+
VERIFY_IDENTITY_PATH,
|
|
1743
|
+
VERIFY_IDENTITY_VERIFIED_PATH,
|
|
1744
|
+
VERIFY_IDENTITY_PROOF_OF_ADDRESS_PATH,
|
|
1745
|
+
VERIFY_IDENTITY_SOURCE_OF_FUNDS_PATH,
|
|
1746
|
+
VERIFY_IDENTITY_ACCREDITATION_PATH,
|
|
1747
|
+
WALLET_PATH,
|
|
1748
|
+
Attributes,
|
|
1749
|
+
HttpError,
|
|
1750
|
+
apiErrorCode,
|
|
1751
|
+
Request,
|
|
1752
|
+
HttpClient,
|
|
1753
|
+
fetchAllPages,
|
|
1754
|
+
NotImplementedError,
|
|
1755
|
+
NotAuthenticatedError,
|
|
1756
|
+
ValidationError,
|
|
1757
|
+
ETHEREUM_CHAINS,
|
|
1758
|
+
EthereumChain,
|
|
1759
|
+
SOLANA_CHAINS,
|
|
1760
|
+
SolanaChain,
|
|
1761
|
+
Chain,
|
|
1762
|
+
EvmWalletAddress,
|
|
1763
|
+
EvmContractAddress,
|
|
1764
|
+
HexEncodedTransactionData,
|
|
1765
|
+
MAX_ASSET_DECIMALS,
|
|
1766
|
+
AssetDecimals,
|
|
1767
|
+
STABLE_DECIMALS,
|
|
1768
|
+
DecimalString,
|
|
1769
|
+
MAX_UINT_256,
|
|
1770
|
+
assertUint256,
|
|
1771
|
+
BlockchainAmount,
|
|
1772
|
+
AssetSymbol,
|
|
1773
|
+
StablecoinSymbol,
|
|
1774
|
+
KnownAssetSymbol,
|
|
1775
|
+
Bps,
|
|
1776
|
+
FormattedAmountUi,
|
|
1777
|
+
FormattedPercentUi,
|
|
1778
|
+
TxExplorerUrl,
|
|
1779
|
+
ShortenedWalletAddress,
|
|
1780
|
+
FormattedAmountAssetUi,
|
|
1781
|
+
AssetIconUrl,
|
|
1782
|
+
getChainId,
|
|
1783
|
+
chainFromId,
|
|
1784
|
+
getNetworkName,
|
|
1785
|
+
txExplorerUrl,
|
|
1786
|
+
SwapAuthorization,
|
|
1787
|
+
SwapPreview,
|
|
1788
|
+
SwapStatus,
|
|
1789
|
+
TokenAllowance,
|
|
1790
|
+
TokenBalance,
|
|
1791
|
+
AllowWalletResponse,
|
|
1792
|
+
Erc20NamespaceImpl,
|
|
1793
|
+
shortenAddress,
|
|
1794
|
+
formatAmount,
|
|
1795
|
+
formatRawAmount,
|
|
1796
|
+
formatCompactAmount,
|
|
1797
|
+
formatBpsAsPercent,
|
|
1798
|
+
usdAmount,
|
|
1799
|
+
assetAmount,
|
|
1800
|
+
NA_AMOUNT_ASSET_UI,
|
|
1801
|
+
formattedUsdPrice,
|
|
1802
|
+
blockchainAmountFromRawOrThrow,
|
|
1803
|
+
parseBlockchainAmount,
|
|
1804
|
+
Cursor,
|
|
1805
|
+
PaginatedResponse,
|
|
1806
|
+
PaginationParams,
|
|
1807
|
+
AssetId,
|
|
1808
|
+
AssetCode,
|
|
1809
|
+
Asset,
|
|
1810
|
+
OfferId,
|
|
1811
|
+
OfferSlug,
|
|
1812
|
+
Offer,
|
|
1813
|
+
OfferOptionId,
|
|
1814
|
+
OfferOptionSlug,
|
|
1815
|
+
OfferDetail,
|
|
1816
|
+
OfferOption,
|
|
1817
|
+
FaqItem,
|
|
1818
|
+
Link,
|
|
1819
|
+
TermItem,
|
|
1820
|
+
Milestone,
|
|
1821
|
+
OfferToken,
|
|
1822
|
+
ParticipationId,
|
|
1823
|
+
Blockchain,
|
|
1824
|
+
WalletAddress,
|
|
1825
|
+
ParticipationsPaginationParams,
|
|
1826
|
+
Participation,
|
|
1827
|
+
CreateParticipationParams,
|
|
1828
|
+
CoinListTokenSaleNamespaceImpl,
|
|
1829
|
+
Ticker,
|
|
1830
|
+
OndoTradingStatus,
|
|
1831
|
+
OndoQuote,
|
|
1832
|
+
OndoSwapTransaction,
|
|
1833
|
+
OndoNamespaceImpl,
|
|
1834
|
+
SuperstateSwapNamespaceImpl,
|
|
1835
|
+
fetchOffers,
|
|
1836
|
+
fetchOffersPage,
|
|
1837
|
+
fetchOfferDetails,
|
|
1838
|
+
DocumentSubmission,
|
|
1839
|
+
KycToken,
|
|
1840
|
+
Iso2CountryCode,
|
|
1841
|
+
PiiJurisdiction,
|
|
1842
|
+
PiiAddress,
|
|
1843
|
+
Pii,
|
|
1844
|
+
RequirementId,
|
|
1845
|
+
Requirement,
|
|
1846
|
+
RequirementStatusInfo,
|
|
1847
|
+
fetchOfferRequirements,
|
|
1848
|
+
RequirementsNamespaceImpl,
|
|
1849
|
+
TokenLogoUrl,
|
|
1850
|
+
TokenLogo,
|
|
1851
|
+
TokenMetadata,
|
|
1852
|
+
TokensNamespaceImpl,
|
|
1853
|
+
OfferOptionAddressId,
|
|
1854
|
+
OfferOptionAddress,
|
|
1855
|
+
ConnectExternalWalletParams,
|
|
1856
|
+
WalletOwnershipChallenge,
|
|
1857
|
+
CreateWalletOwnershipChallengeParams,
|
|
1858
|
+
WalletsNamespaceImpl,
|
|
1859
|
+
ClientCredentialsOAuth,
|
|
1860
|
+
OAuthRefreshToken,
|
|
1861
|
+
OAuthSession
|
|
1862
|
+
};
|
|
1863
|
+
//# sourceMappingURL=chunk-UIIXXLA7.js.map
|