@coinlist-co/react 0.12.2-rc.eea3be6 → 0.12.2
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 +79 -43
- package/dist/{chunk-335G7ZM5.js → chunk-2FZAXGVH.js} +162 -431
- package/dist/chunk-2FZAXGVH.js.map +1 -0
- package/dist/{chunk-WBB6P6ZI.js → chunk-EAPBF7T2.js} +11 -42
- package/dist/chunk-EAPBF7T2.js.map +1 -0
- package/dist/{chunk-MJ6YXZWH.js → chunk-IWQ6A52U.js} +4 -2
- package/dist/chunk-IWQ6A52U.js.map +1 -0
- package/dist/{chunk-IUAGXUJY.js → chunk-OQ2ANYUF.js} +328 -21
- package/dist/chunk-OQ2ANYUF.js.map +1 -0
- package/dist/client/index.d.ts +251 -164
- package/dist/client/index.js +930 -570
- package/dist/client/index.js.map +1 -1
- package/dist/client-credentials-BwcmPcn-.d.ts +13 -0
- package/dist/server/index.d.ts +58 -106
- package/dist/server/index.js +208 -170
- package/dist/server/index.js.map +1 -1
- package/dist/{time-qZW4aYYp.d.ts → time-ChSGmKZe.d.ts} +82 -51
- package/dist/{token-registry-snapshot-CMrhSBun.d.ts → token-registry-snapshot-DMubXr2c.d.ts} +1 -1
- package/dist/universal/index.d.ts +45 -44
- package/dist/universal/index.js +4 -4
- package/package.json +1 -1
- package/dist/chunk-335G7ZM5.js.map +0 -1
- package/dist/chunk-IUAGXUJY.js.map +0 -1
- package/dist/chunk-MJ6YXZWH.js.map +0 -1
- package/dist/chunk-WBB6P6ZI.js.map +0 -1
|
@@ -1,93 +1,4 @@
|
|
|
1
|
-
// src/universal/
|
|
2
|
-
var SentWith = {
|
|
3
|
-
userToken: (token) => ({
|
|
4
|
-
type: "user-token",
|
|
5
|
-
token
|
|
6
|
-
}),
|
|
7
|
-
noUserToken: { type: "no-user-token" }
|
|
8
|
-
};
|
|
9
|
-
var TokenTrigger = {
|
|
10
|
-
beforeRequest: { type: "before-request" },
|
|
11
|
-
after401: (rejected) => ({
|
|
12
|
-
type: "after-401",
|
|
13
|
-
rejected
|
|
14
|
-
})
|
|
15
|
-
};
|
|
16
|
-
function isRejectedToken(token, rejected) {
|
|
17
|
-
switch (rejected.type) {
|
|
18
|
-
case "user-token":
|
|
19
|
-
return rejected.token.value === token.value;
|
|
20
|
-
case "no-user-token":
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// src/universal/api/http-attributes.ts
|
|
26
|
-
var empty = {};
|
|
27
|
-
var concat = (left, right) => ({
|
|
28
|
-
...left,
|
|
29
|
-
...right
|
|
30
|
-
});
|
|
31
|
-
var concatAll = (...items) => {
|
|
32
|
-
let result = empty;
|
|
33
|
-
for (const item of items) {
|
|
34
|
-
result = concat(result, item);
|
|
35
|
-
}
|
|
36
|
-
return result;
|
|
37
|
-
};
|
|
38
|
-
var protectedRequest = () => ({ protected: true });
|
|
39
|
-
var userAgent = () => ({ userAgent: true });
|
|
40
|
-
var idempotencyKey = () => ({
|
|
41
|
-
idempotencyKey: true
|
|
42
|
-
});
|
|
43
|
-
var clientCredentials = (credentials) => ({
|
|
44
|
-
clientCredentials: credentials
|
|
45
|
-
});
|
|
46
|
-
var retryAttempt = (attempt) => ({
|
|
47
|
-
retryAttempt: attempt
|
|
48
|
-
});
|
|
49
|
-
var renewAttempted = (value) => ({
|
|
50
|
-
renewAttempted: value
|
|
51
|
-
});
|
|
52
|
-
var notRetryable = () => ({ retryable: false });
|
|
53
|
-
var sentWith = (token) => ({
|
|
54
|
-
sentWith: token
|
|
55
|
-
});
|
|
56
|
-
var requestId = (id) => ({ requestId: id });
|
|
57
|
-
var getRequestId = (attrs) => attrs?.requestId ?? null;
|
|
58
|
-
var isProtected = (attrs) => attrs?.protected === true;
|
|
59
|
-
var needUserAgent = (attrs) => attrs?.userAgent === true;
|
|
60
|
-
var isIdempotent = (attrs) => attrs?.idempotencyKey === true;
|
|
61
|
-
var getRetryAttempt = (attrs) => attrs?.retryAttempt ?? 0;
|
|
62
|
-
var wasRenewAttempted = (attrs) => attrs?.renewAttempted === true;
|
|
63
|
-
var isRetryable = (attrs) => attrs?.retryable !== false;
|
|
64
|
-
var getSentWith = (attrs) => attrs?.sentWith === void 0 ? SentWith.noUserToken : SentWith.userToken(attrs.sentWith);
|
|
65
|
-
var getClientCredentials = (attrs) => attrs?.clientCredentials;
|
|
66
|
-
var Attributes = {
|
|
67
|
-
empty,
|
|
68
|
-
concat,
|
|
69
|
-
concatAll,
|
|
70
|
-
protected: protectedRequest,
|
|
71
|
-
isProtected,
|
|
72
|
-
userAgent,
|
|
73
|
-
needUserAgent,
|
|
74
|
-
idempotencyKey,
|
|
75
|
-
isIdempotent,
|
|
76
|
-
retryAttempt,
|
|
77
|
-
getRetryAttempt,
|
|
78
|
-
renewAttempted,
|
|
79
|
-
wasRenewAttempted,
|
|
80
|
-
notRetryable,
|
|
81
|
-
isRetryable,
|
|
82
|
-
sentWith,
|
|
83
|
-
getSentWith,
|
|
84
|
-
clientCredentials,
|
|
85
|
-
getClientCredentials,
|
|
86
|
-
requestId,
|
|
87
|
-
getRequestId
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
// src/universal/api/http.ts
|
|
1
|
+
// src/universal/types/http.ts
|
|
91
2
|
var HttpError = class extends Error {
|
|
92
3
|
constructor(response) {
|
|
93
4
|
super(`Request failed with ${response.status} status`);
|
|
@@ -112,104 +23,6 @@ function apiErrorCode(error) {
|
|
|
112
23
|
const code = body.code;
|
|
113
24
|
return typeof code === "string" ? code : null;
|
|
114
25
|
}
|
|
115
|
-
async function makeRequest(request) {
|
|
116
|
-
const headers = {
|
|
117
|
-
Accept: "application/json",
|
|
118
|
-
...request.method === "POST" && request.body !== void 0 ? { "Content-Type": "application/json" } : {},
|
|
119
|
-
...request.headers ?? {}
|
|
120
|
-
};
|
|
121
|
-
const init = {
|
|
122
|
-
method: request.method,
|
|
123
|
-
headers,
|
|
124
|
-
...request.redirect !== void 0 ? { redirect: request.redirect } : {}
|
|
125
|
-
};
|
|
126
|
-
if (request.method === "POST" && request.body !== void 0) {
|
|
127
|
-
init.body = JSON.stringify(request.body);
|
|
128
|
-
}
|
|
129
|
-
const response = await fetch(
|
|
130
|
-
buildUrlWithQueryParams(request.url, request.queryParams),
|
|
131
|
-
init
|
|
132
|
-
);
|
|
133
|
-
const responseHeaders = headersToRecord(response.headers);
|
|
134
|
-
if (response.status === 204 || response.status === 205) {
|
|
135
|
-
return {
|
|
136
|
-
status: response.status,
|
|
137
|
-
body: null,
|
|
138
|
-
headers: responseHeaders
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
if (response.status >= 300 && response.status < 400) {
|
|
142
|
-
await response.text();
|
|
143
|
-
return {
|
|
144
|
-
status: response.status,
|
|
145
|
-
body: null,
|
|
146
|
-
headers: responseHeaders
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
const text = await response.text();
|
|
150
|
-
let body;
|
|
151
|
-
try {
|
|
152
|
-
body = text ? JSON.parse(text) : null;
|
|
153
|
-
} catch (_) {
|
|
154
|
-
throw new HttpError({
|
|
155
|
-
status: response.status,
|
|
156
|
-
headers: responseHeaders,
|
|
157
|
-
body: text
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
return {
|
|
161
|
-
status: response.status,
|
|
162
|
-
body,
|
|
163
|
-
headers: responseHeaders
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
function buildUrlWithQueryParams(url, queryParams) {
|
|
167
|
-
if (!queryParams) {
|
|
168
|
-
return url;
|
|
169
|
-
}
|
|
170
|
-
const searchParams = new URLSearchParams();
|
|
171
|
-
for (const [key, value] of Object.entries(queryParams)) {
|
|
172
|
-
if (value === void 0 || value === null) {
|
|
173
|
-
continue;
|
|
174
|
-
}
|
|
175
|
-
if (Array.isArray(value)) {
|
|
176
|
-
for (const item of value) {
|
|
177
|
-
if (item === void 0 || item === null) {
|
|
178
|
-
continue;
|
|
179
|
-
}
|
|
180
|
-
searchParams.append(key, String(item));
|
|
181
|
-
}
|
|
182
|
-
continue;
|
|
183
|
-
}
|
|
184
|
-
searchParams.append(key, String(value));
|
|
185
|
-
}
|
|
186
|
-
const queryString = searchParams.toString();
|
|
187
|
-
if (!queryString) {
|
|
188
|
-
return url;
|
|
189
|
-
}
|
|
190
|
-
return url.includes("?") ? `${url}&${queryString}` : `${url}?${queryString}`;
|
|
191
|
-
}
|
|
192
|
-
function headersToRecord(headers) {
|
|
193
|
-
const record = {};
|
|
194
|
-
headers.forEach((value, key) => {
|
|
195
|
-
record[key.toLowerCase()] = value;
|
|
196
|
-
});
|
|
197
|
-
return record;
|
|
198
|
-
}
|
|
199
|
-
function concatAttributes(request, attrs) {
|
|
200
|
-
const nextAttributes = Attributes.concat(
|
|
201
|
-
request.attributes ?? Attributes.empty,
|
|
202
|
-
attrs
|
|
203
|
-
);
|
|
204
|
-
const nextRequest = {
|
|
205
|
-
...request,
|
|
206
|
-
attributes: nextAttributes
|
|
207
|
-
};
|
|
208
|
-
return nextRequest;
|
|
209
|
-
}
|
|
210
|
-
var Request = {
|
|
211
|
-
concatAttributes
|
|
212
|
-
};
|
|
213
26
|
|
|
214
27
|
// src/universal/types/errors.ts
|
|
215
28
|
var NotImplementedError = class extends Error {
|
|
@@ -795,6 +608,95 @@ function assertSpendScaleAgrees({
|
|
|
795
608
|
);
|
|
796
609
|
}
|
|
797
610
|
|
|
611
|
+
// src/universal/types/access-token-source.ts
|
|
612
|
+
var SentWith = {
|
|
613
|
+
userToken: (token) => ({
|
|
614
|
+
type: "user-token",
|
|
615
|
+
token
|
|
616
|
+
}),
|
|
617
|
+
noUserToken: { type: "no-user-token" }
|
|
618
|
+
};
|
|
619
|
+
var TokenTrigger = {
|
|
620
|
+
beforeRequest: { type: "before-request" },
|
|
621
|
+
after401: (rejected) => ({
|
|
622
|
+
type: "after-401",
|
|
623
|
+
rejected
|
|
624
|
+
})
|
|
625
|
+
};
|
|
626
|
+
function isRejectedToken(token, rejected) {
|
|
627
|
+
switch (rejected.type) {
|
|
628
|
+
case "user-token":
|
|
629
|
+
return rejected.token.value === token.value;
|
|
630
|
+
case "no-user-token":
|
|
631
|
+
return false;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
// src/universal/api/http-attributes.ts
|
|
636
|
+
var empty = {};
|
|
637
|
+
var concat = (left, right) => ({
|
|
638
|
+
...left,
|
|
639
|
+
...right
|
|
640
|
+
});
|
|
641
|
+
var concatAll = (...items) => {
|
|
642
|
+
let result = empty;
|
|
643
|
+
for (const item of items) {
|
|
644
|
+
result = concat(result, item);
|
|
645
|
+
}
|
|
646
|
+
return result;
|
|
647
|
+
};
|
|
648
|
+
var protectedRequest = () => ({ protected: true });
|
|
649
|
+
var userAgent = () => ({ userAgent: true });
|
|
650
|
+
var idempotencyKey = () => ({
|
|
651
|
+
idempotencyKey: true
|
|
652
|
+
});
|
|
653
|
+
var clientCredentials = (credentials) => ({
|
|
654
|
+
clientCredentials: credentials
|
|
655
|
+
});
|
|
656
|
+
var retryAttempt = (attempt) => ({
|
|
657
|
+
retryAttempt: attempt
|
|
658
|
+
});
|
|
659
|
+
var renewAttempted = (value) => ({
|
|
660
|
+
renewAttempted: value
|
|
661
|
+
});
|
|
662
|
+
var notRetryable = () => ({ retryable: false });
|
|
663
|
+
var sentWith = (token) => ({
|
|
664
|
+
sentWith: token
|
|
665
|
+
});
|
|
666
|
+
var requestId = (id) => ({ requestId: id });
|
|
667
|
+
var getRequestId = (attrs) => attrs?.requestId ?? null;
|
|
668
|
+
var isProtected = (attrs) => attrs?.protected === true;
|
|
669
|
+
var needUserAgent = (attrs) => attrs?.userAgent === true;
|
|
670
|
+
var isIdempotent = (attrs) => attrs?.idempotencyKey === true;
|
|
671
|
+
var getRetryAttempt = (attrs) => attrs?.retryAttempt ?? 0;
|
|
672
|
+
var wasRenewAttempted = (attrs) => attrs?.renewAttempted === true;
|
|
673
|
+
var isRetryable = (attrs) => attrs?.retryable !== false;
|
|
674
|
+
var getSentWith = (attrs) => attrs?.sentWith === void 0 ? SentWith.noUserToken : SentWith.userToken(attrs.sentWith);
|
|
675
|
+
var getClientCredentials = (attrs) => attrs?.clientCredentials;
|
|
676
|
+
var Attributes = {
|
|
677
|
+
empty,
|
|
678
|
+
concat,
|
|
679
|
+
concatAll,
|
|
680
|
+
protected: protectedRequest,
|
|
681
|
+
isProtected,
|
|
682
|
+
userAgent,
|
|
683
|
+
needUserAgent,
|
|
684
|
+
idempotencyKey,
|
|
685
|
+
isIdempotent,
|
|
686
|
+
retryAttempt,
|
|
687
|
+
getRetryAttempt,
|
|
688
|
+
renewAttempted,
|
|
689
|
+
wasRenewAttempted,
|
|
690
|
+
notRetryable,
|
|
691
|
+
isRetryable,
|
|
692
|
+
sentWith,
|
|
693
|
+
getSentWith,
|
|
694
|
+
clientCredentials,
|
|
695
|
+
getClientCredentials,
|
|
696
|
+
requestId,
|
|
697
|
+
getRequestId
|
|
698
|
+
};
|
|
699
|
+
|
|
798
700
|
// src/universal/api/frontline/providers/centrifuge/centrifuge.ts
|
|
799
701
|
async function getCentrifugeVaultStatus(api, params) {
|
|
800
702
|
const dto = await api.send({
|
|
@@ -851,7 +753,7 @@ function walletFields(params) {
|
|
|
851
753
|
};
|
|
852
754
|
}
|
|
853
755
|
|
|
854
|
-
// src/universal/core/providers/
|
|
756
|
+
// src/universal/core/providers/centrifuge/blockchain/abi.ts
|
|
855
757
|
var CENTRIFUGE_PROXY_ABI = [
|
|
856
758
|
{
|
|
857
759
|
type: "function",
|
|
@@ -1114,7 +1016,7 @@ var noopInternalLogger = {
|
|
|
1114
1016
|
wrap: (_op, _params, run) => run()
|
|
1115
1017
|
};
|
|
1116
1018
|
|
|
1117
|
-
// src/universal/core/providers/
|
|
1019
|
+
// src/universal/core/providers/centrifuge/centrifuge-namespace.ts
|
|
1118
1020
|
var CentrifugeNamespaceImpl = class {
|
|
1119
1021
|
constructor(ctx) {
|
|
1120
1022
|
this.ctx = ctx;
|
|
@@ -1409,7 +1311,7 @@ var Isin = (value) => value;
|
|
|
1409
1311
|
var AsyncOfferDetail = {
|
|
1410
1312
|
/**
|
|
1411
1313
|
* Narrows an offer fetched generically, e.g. on an offer page, to one with
|
|
1412
|
-
*
|
|
1314
|
+
* a second leg to show.
|
|
1413
1315
|
*
|
|
1414
1316
|
* An exhaustive `switch` rather than a list of async types, so a new offer
|
|
1415
1317
|
* type is a compile error here until someone decides whether it settles
|
|
@@ -1418,10 +1320,10 @@ var AsyncOfferDetail = {
|
|
|
1418
1320
|
is: (offer) => {
|
|
1419
1321
|
switch (offer.type) {
|
|
1420
1322
|
case "centrifuge::vault":
|
|
1323
|
+
case "coinlist::token_sale":
|
|
1421
1324
|
return true;
|
|
1422
1325
|
case "ondo::swap":
|
|
1423
1326
|
case "superstate::swap":
|
|
1424
|
-
case "coinlist::token_sale":
|
|
1425
1327
|
return false;
|
|
1426
1328
|
default: {
|
|
1427
1329
|
const exhaustive = offer;
|
|
@@ -1682,7 +1584,7 @@ async function createParticipation(api, params) {
|
|
|
1682
1584
|
return Participation.fromDto(dto);
|
|
1683
1585
|
}
|
|
1684
1586
|
|
|
1685
|
-
// src/universal/core/providers/
|
|
1587
|
+
// src/universal/core/providers/coin-list/token-sale-namespace.ts
|
|
1686
1588
|
var CoinListTokenSaleNamespaceImpl = class {
|
|
1687
1589
|
constructor(ctx) {
|
|
1688
1590
|
this.ctx = ctx;
|
|
@@ -1941,7 +1843,7 @@ function sizeParam(params) {
|
|
|
1941
1843
|
return { notional_value: notionalValue };
|
|
1942
1844
|
}
|
|
1943
1845
|
|
|
1944
|
-
// src/universal/core/providers/
|
|
1846
|
+
// src/universal/core/providers/ondo/ondo-namespace.ts
|
|
1945
1847
|
var OndoNamespaceImpl = class {
|
|
1946
1848
|
constructor(ctx) {
|
|
1947
1849
|
this.ctx = ctx;
|
|
@@ -2032,7 +1934,7 @@ var AllowWalletResponse = {
|
|
|
2032
1934
|
}
|
|
2033
1935
|
};
|
|
2034
1936
|
|
|
2035
|
-
// src/universal/core/providers/
|
|
1937
|
+
// src/universal/core/providers/superstate/blockchain/quote.ts
|
|
2036
1938
|
var SwapQuote = {
|
|
2037
1939
|
/**
|
|
2038
1940
|
* Assembles a {@link SwapQuote} from a raw contract {@link SwapPreview}. The
|
|
@@ -2067,7 +1969,7 @@ async function allowWallet(api, params) {
|
|
|
2067
1969
|
return AllowWalletResponse.fromDto(dto);
|
|
2068
1970
|
}
|
|
2069
1971
|
|
|
2070
|
-
// src/universal/core/providers/
|
|
1972
|
+
// src/universal/core/providers/superstate/blockchain/abi.ts
|
|
2071
1973
|
var SUPERSTATE_SWAP_ABI = [
|
|
2072
1974
|
{
|
|
2073
1975
|
type: "function",
|
|
@@ -3088,7 +2990,7 @@ async function getSwapOutputToken(clients, params) {
|
|
|
3088
2990
|
};
|
|
3089
2991
|
}
|
|
3090
2992
|
|
|
3091
|
-
// src/universal/core/providers/
|
|
2993
|
+
// src/universal/core/providers/superstate/superstate-namespace.ts
|
|
3092
2994
|
var SuperstateSwapNamespaceImpl = class {
|
|
3093
2995
|
constructor(ctx) {
|
|
3094
2996
|
this.ctx = ctx;
|
|
@@ -3460,6 +3362,61 @@ var WalletsNamespaceImpl = class {
|
|
|
3460
3362
|
}
|
|
3461
3363
|
};
|
|
3462
3364
|
|
|
3365
|
+
// src/universal/api/frontline/offers.ts
|
|
3366
|
+
async function fetchOffers(api, clientCreds) {
|
|
3367
|
+
return fetchAllPages((params) => fetchOffersPage(api, params, clientCreds));
|
|
3368
|
+
}
|
|
3369
|
+
async function fetchOffersPage(api, params, clientCreds) {
|
|
3370
|
+
const queryParams = PaginationParams.toQueryParams(params);
|
|
3371
|
+
const pageDto = await api.send({
|
|
3372
|
+
method: "GET",
|
|
3373
|
+
url: "/v1/offers",
|
|
3374
|
+
queryParams,
|
|
3375
|
+
attributes: Attributes.concat(
|
|
3376
|
+
Attributes.protected(),
|
|
3377
|
+
Attributes.clientCredentials(clientCreds)
|
|
3378
|
+
)
|
|
3379
|
+
});
|
|
3380
|
+
return PaginatedResponse.fromDtoPage(pageDto, Offer.listFromDto);
|
|
3381
|
+
}
|
|
3382
|
+
async function fetchOfferDetails(api, id, clientCreds) {
|
|
3383
|
+
const dto = await api.send({
|
|
3384
|
+
method: "GET",
|
|
3385
|
+
url: `/v1/offers/${id}`,
|
|
3386
|
+
attributes: Attributes.concat(
|
|
3387
|
+
Attributes.protected(),
|
|
3388
|
+
Attributes.clientCredentials(clientCreds)
|
|
3389
|
+
)
|
|
3390
|
+
});
|
|
3391
|
+
return OfferDetail.fromDto(dto);
|
|
3392
|
+
}
|
|
3393
|
+
|
|
3394
|
+
// src/universal/core/offers/offers-namespace.ts
|
|
3395
|
+
var OffersNamespaceImpl = class {
|
|
3396
|
+
constructor(ctx) {
|
|
3397
|
+
this.ctx = ctx;
|
|
3398
|
+
this.log = internalLogger(ctx.logger, "OFFERS");
|
|
3399
|
+
}
|
|
3400
|
+
async list() {
|
|
3401
|
+
return this.log.wrap("list", void 0, async () => {
|
|
3402
|
+
await this.ctx.ensureUserAuthenticated();
|
|
3403
|
+
return fetchOffers(this.ctx.api, void 0);
|
|
3404
|
+
});
|
|
3405
|
+
}
|
|
3406
|
+
async listPage(params) {
|
|
3407
|
+
return this.log.wrap("listPage", params, async () => {
|
|
3408
|
+
await this.ctx.ensureUserAuthenticated();
|
|
3409
|
+
return fetchOffersPage(this.ctx.api, params, void 0);
|
|
3410
|
+
});
|
|
3411
|
+
}
|
|
3412
|
+
async get(id) {
|
|
3413
|
+
return this.log.wrap("get", id, async () => {
|
|
3414
|
+
await this.ctx.ensureUserAuthenticated();
|
|
3415
|
+
return fetchOfferDetails(this.ctx.api, id, void 0);
|
|
3416
|
+
});
|
|
3417
|
+
}
|
|
3418
|
+
};
|
|
3419
|
+
|
|
3463
3420
|
// src/universal/api/rpc/erc20.ts
|
|
3464
3421
|
async function getTokenAllowance(clients, params) {
|
|
3465
3422
|
const allowance = await clients(params.chain).readContract({
|
|
@@ -3587,187 +3544,6 @@ var resolveLogoUrl = (url, baseUrl) => TokenLogoUrl(
|
|
|
3587
3544
|
|
|
3588
3545
|
// src/universal/api/nabu/tokens.ts
|
|
3589
3546
|
import { getAddress } from "viem";
|
|
3590
|
-
|
|
3591
|
-
// src/universal/api/frontline/config.ts
|
|
3592
|
-
var PUBLIC_API_BASE_URL = "https://api.coinlist.co";
|
|
3593
|
-
var HEADER_API_VERSION = "X-API-Version";
|
|
3594
|
-
var HEADER_USER_AGENT = "User-Agent";
|
|
3595
|
-
var HEADER_IDEMPOTENCY_KEY = "Idempotency-Key";
|
|
3596
|
-
var API_VERSION = "2025-10-17";
|
|
3597
|
-
var COINLIST_BASE_URL = "https://coinlist.co";
|
|
3598
|
-
var OAUTH_PAGE_PATH = "/oauth/authorize";
|
|
3599
|
-
var SUPPORT_NEW_TICKET_URL = "https://support.coinlist.co/support/tickets/new";
|
|
3600
|
-
var VERIFY_IDENTITY_PATH = "/verify-identity";
|
|
3601
|
-
var VERIFY_IDENTITY_ACCREDITATION_PATH = "/verify-identity/accreditation_full";
|
|
3602
|
-
var WALLET_PATH = "/wallet";
|
|
3603
|
-
|
|
3604
|
-
// src/universal/api/http-client.ts
|
|
3605
|
-
var HttpClient = class {
|
|
3606
|
-
constructor(config, middleware = {}, logger = null, options = {}) {
|
|
3607
|
-
this.config = config;
|
|
3608
|
-
this.middleware = middleware;
|
|
3609
|
-
this.log = internalLogger(logger, "HTTP");
|
|
3610
|
-
this.makeRequestId = options.makeRequestId ?? defaultMakeRequestId;
|
|
3611
|
-
}
|
|
3612
|
-
async send(request) {
|
|
3613
|
-
return this.runRequestWithAfterMiddleware(request);
|
|
3614
|
-
}
|
|
3615
|
-
/**
|
|
3616
|
-
* Runs beforeRequest, executeRequest, then the full afterRequest middleware
|
|
3617
|
-
* chain. Used by send() and by the retry() callback so that when a
|
|
3618
|
-
* middleware calls retry(), the retried response also goes through all
|
|
3619
|
-
* afterRequest middleware (e.g. session renewal, retry). Middleware
|
|
3620
|
-
* must use request.attributes.retryAttempt (or similar) to avoid infinite
|
|
3621
|
-
* recursion when they trigger retries.
|
|
3622
|
-
*/
|
|
3623
|
-
async runRequestWithAfterMiddleware(request) {
|
|
3624
|
-
const preparedRequest = await this.runBeforeRequestMiddleware(
|
|
3625
|
-
this.withClientDefaults(request)
|
|
3626
|
-
);
|
|
3627
|
-
let response = await this.executeRequest(preparedRequest);
|
|
3628
|
-
for (const middleware of this.middleware.afterRequest ?? []) {
|
|
3629
|
-
let retried = false;
|
|
3630
|
-
response = await middleware({
|
|
3631
|
-
request: preparedRequest,
|
|
3632
|
-
response,
|
|
3633
|
-
retry: (nextRequest = preparedRequest) => {
|
|
3634
|
-
retried = true;
|
|
3635
|
-
return this.runRequestWithAfterMiddleware(nextRequest);
|
|
3636
|
-
}
|
|
3637
|
-
});
|
|
3638
|
-
if (retried) {
|
|
3639
|
-
return response;
|
|
3640
|
-
}
|
|
3641
|
-
}
|
|
3642
|
-
return response;
|
|
3643
|
-
}
|
|
3644
|
-
withClientDefaults(request) {
|
|
3645
|
-
const url = this.resolveUrl(request.url);
|
|
3646
|
-
const headers = {
|
|
3647
|
-
...request.headers ?? {},
|
|
3648
|
-
...this.config.xApiVersion !== void 0 ? { [HEADER_API_VERSION]: this.config.xApiVersion } : {}
|
|
3649
|
-
};
|
|
3650
|
-
return {
|
|
3651
|
-
...request,
|
|
3652
|
-
url,
|
|
3653
|
-
headers,
|
|
3654
|
-
// Only when absent: a retry or a post-renewal re-send arrives with the
|
|
3655
|
-
// first attempt's id already on it, and keeping it is the whole point.
|
|
3656
|
-
attributes: Attributes.getRequestId(request.attributes) === null ? Attributes.concat(
|
|
3657
|
-
request.attributes ?? Attributes.empty,
|
|
3658
|
-
Attributes.requestId(this.makeRequestId())
|
|
3659
|
-
) : request.attributes
|
|
3660
|
-
};
|
|
3661
|
-
}
|
|
3662
|
-
/**
|
|
3663
|
-
* Resolves a request URL against the client's baseUrl.
|
|
3664
|
-
*
|
|
3665
|
-
* @internal Public only for testing. Do not use in application code; use
|
|
3666
|
-
* {@link HttpClient.send} with a path and the client will resolve the URL.
|
|
3667
|
-
*/
|
|
3668
|
-
resolveUrl(url) {
|
|
3669
|
-
if (url.startsWith("http://") || url.startsWith("https://")) {
|
|
3670
|
-
return url;
|
|
3671
|
-
}
|
|
3672
|
-
const base2 = this.config.baseUrl.replace(/\/$/, "");
|
|
3673
|
-
const path = url.startsWith("/") ? url : `/${url}`;
|
|
3674
|
-
return base2 + path;
|
|
3675
|
-
}
|
|
3676
|
-
async runBeforeRequestMiddleware(initialRequest) {
|
|
3677
|
-
let request = initialRequest;
|
|
3678
|
-
for (const middleware of this.middleware.beforeRequest ?? []) {
|
|
3679
|
-
request = await middleware(request);
|
|
3680
|
-
}
|
|
3681
|
-
return request;
|
|
3682
|
-
}
|
|
3683
|
-
/**
|
|
3684
|
-
* One physical attempt, logged as one line.
|
|
3685
|
-
*
|
|
3686
|
-
* A non-2xx is a `warn` rather than an `error` because the wire does not
|
|
3687
|
-
* know whether it is a failure: the retry middleware may turn a 503 into a
|
|
3688
|
-
* success, and the token registry reads a 404 as "not listed". The namespace
|
|
3689
|
-
* above decides, and logs the `error` when it does.
|
|
3690
|
-
*/
|
|
3691
|
-
async executeRequest(request) {
|
|
3692
|
-
const requestId2 = Attributes.getRequestId(request.attributes);
|
|
3693
|
-
const log = requestId2 === null ? this.log : this.log.child({ requestId: requestId2 });
|
|
3694
|
-
const attempt = Attributes.getRetryAttempt(request.attributes) + 1;
|
|
3695
|
-
const startedAt = Date.now();
|
|
3696
|
-
log.debug(() => ({
|
|
3697
|
-
msg: "request sent",
|
|
3698
|
-
fields: describeRequestUnredacted(request)
|
|
3699
|
-
}));
|
|
3700
|
-
try {
|
|
3701
|
-
const response = await makeRequest(request);
|
|
3702
|
-
const elapsed = Date.now() - startedAt;
|
|
3703
|
-
const outcome = () => ({
|
|
3704
|
-
msg: "request completed",
|
|
3705
|
-
fields: {
|
|
3706
|
-
...identifyRequest(request),
|
|
3707
|
-
"http.response.status_code": response.status,
|
|
3708
|
-
duration_ms: elapsed,
|
|
3709
|
-
attempt
|
|
3710
|
-
}
|
|
3711
|
-
});
|
|
3712
|
-
if (response.status >= 200 && response.status < 300) {
|
|
3713
|
-
log.info(outcome);
|
|
3714
|
-
} else {
|
|
3715
|
-
log.warn(outcome);
|
|
3716
|
-
}
|
|
3717
|
-
log.debug(() => ({
|
|
3718
|
-
msg: "response received",
|
|
3719
|
-
fields: { body: response.body }
|
|
3720
|
-
}));
|
|
3721
|
-
return requestId2 === null ? response : { ...response, requestId: requestId2 };
|
|
3722
|
-
} catch (error) {
|
|
3723
|
-
const elapsed = Date.now() - startedAt;
|
|
3724
|
-
log.warning(
|
|
3725
|
-
() => ({
|
|
3726
|
-
msg: "request threw",
|
|
3727
|
-
fields: {
|
|
3728
|
-
...identifyRequest(request),
|
|
3729
|
-
duration_ms: elapsed,
|
|
3730
|
-
attempt
|
|
3731
|
-
}
|
|
3732
|
-
}),
|
|
3733
|
-
error
|
|
3734
|
-
);
|
|
3735
|
-
throw error;
|
|
3736
|
-
}
|
|
3737
|
-
}
|
|
3738
|
-
};
|
|
3739
|
-
function identifyRequest(request) {
|
|
3740
|
-
const { host, path } = splitUrl(request.url);
|
|
3741
|
-
return {
|
|
3742
|
-
"http.request.method": request.method,
|
|
3743
|
-
"server.address": host,
|
|
3744
|
-
"url.path": path
|
|
3745
|
-
};
|
|
3746
|
-
}
|
|
3747
|
-
function splitUrl(url) {
|
|
3748
|
-
try {
|
|
3749
|
-
const parsed = new URL(url);
|
|
3750
|
-
return { host: parsed.host, path: parsed.pathname };
|
|
3751
|
-
} catch (_) {
|
|
3752
|
-
return { host: null, path: url };
|
|
3753
|
-
}
|
|
3754
|
-
}
|
|
3755
|
-
function defaultMakeRequestId() {
|
|
3756
|
-
return Math.random().toString(36).slice(2, 10).padEnd(8, "0");
|
|
3757
|
-
}
|
|
3758
|
-
function describeRequestUnredacted(request) {
|
|
3759
|
-
return {
|
|
3760
|
-
"http.request.method": request.method,
|
|
3761
|
-
"url.full": buildUrlWithQueryParams(request.url, request.queryParams),
|
|
3762
|
-
headers: request.headers,
|
|
3763
|
-
...request.method === "POST" ? { body: request.body } : {}
|
|
3764
|
-
};
|
|
3765
|
-
}
|
|
3766
|
-
|
|
3767
|
-
// src/universal/api/nabu/tokens.ts
|
|
3768
|
-
function createNabuApiClient(baseUrl, logger = null) {
|
|
3769
|
-
return new HttpClient({ baseUrl }, {}, logger);
|
|
3770
|
-
}
|
|
3771
3547
|
async function fetchTokenMetadata(client, token) {
|
|
3772
3548
|
const address = checksummed(token.address);
|
|
3773
3549
|
let response;
|
|
@@ -3855,84 +3631,39 @@ function checksummed(address) {
|
|
|
3855
3631
|
}
|
|
3856
3632
|
}
|
|
3857
3633
|
|
|
3858
|
-
// src/universal/core/tokens/tokens-namespace.ts
|
|
3634
|
+
// src/universal/core/shared/blockchain/tokens/tokens-namespace.ts
|
|
3859
3635
|
var TokensNamespaceImpl = class {
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
* and the auth check would both be dead weight here.
|
|
3864
|
-
*/
|
|
3865
|
-
constructor(baseUrl, logger = null) {
|
|
3866
|
-
this.api = createNabuApiClient(baseUrl, logger);
|
|
3867
|
-
this.log = internalLogger(logger, "TOKENS");
|
|
3636
|
+
constructor(ctx) {
|
|
3637
|
+
this.ctx = ctx;
|
|
3638
|
+
this.log = internalLogger(ctx.logger, "TOKENS");
|
|
3868
3639
|
}
|
|
3869
3640
|
get(token) {
|
|
3870
3641
|
return this.log.wrap(
|
|
3871
3642
|
"get",
|
|
3872
3643
|
token,
|
|
3873
|
-
() => fetchTokenMetadata(this.
|
|
3644
|
+
() => fetchTokenMetadata(this.ctx.nabu, token)
|
|
3874
3645
|
);
|
|
3875
3646
|
}
|
|
3876
3647
|
list(chain) {
|
|
3877
3648
|
return this.log.wrap(
|
|
3878
3649
|
"list",
|
|
3879
3650
|
chain,
|
|
3880
|
-
() => chain === void 0 ? fetchAllTokensMetadata(this.
|
|
3651
|
+
() => chain === void 0 ? fetchAllTokensMetadata(this.ctx.nabu) : fetchTokensMetadata(this.ctx.nabu, chain)
|
|
3881
3652
|
);
|
|
3882
3653
|
}
|
|
3883
3654
|
};
|
|
3884
3655
|
|
|
3885
|
-
// src/universal/api/frontline/offers.ts
|
|
3886
|
-
async function fetchOffers(api, clientCreds) {
|
|
3887
|
-
return fetchAllPages((params) => fetchOffersPage(api, params, clientCreds));
|
|
3888
|
-
}
|
|
3889
|
-
async function fetchOffersPage(api, params, clientCreds) {
|
|
3890
|
-
const queryParams = PaginationParams.toQueryParams(params);
|
|
3891
|
-
const pageDto = await api.send({
|
|
3892
|
-
method: "GET",
|
|
3893
|
-
url: "/v1/offers",
|
|
3894
|
-
queryParams,
|
|
3895
|
-
attributes: Attributes.concat(
|
|
3896
|
-
Attributes.protected(),
|
|
3897
|
-
Attributes.clientCredentials(clientCreds)
|
|
3898
|
-
)
|
|
3899
|
-
});
|
|
3900
|
-
return PaginatedResponse.fromDtoPage(pageDto, Offer.listFromDto);
|
|
3901
|
-
}
|
|
3902
|
-
async function fetchOfferDetails(api, id, clientCreds) {
|
|
3903
|
-
const dto = await api.send({
|
|
3904
|
-
method: "GET",
|
|
3905
|
-
url: `/v1/offers/${id}`,
|
|
3906
|
-
attributes: Attributes.concat(
|
|
3907
|
-
Attributes.protected(),
|
|
3908
|
-
Attributes.clientCredentials(clientCreds)
|
|
3909
|
-
)
|
|
3910
|
-
});
|
|
3911
|
-
return OfferDetail.fromDto(dto);
|
|
3912
|
-
}
|
|
3913
|
-
|
|
3914
3656
|
export {
|
|
3915
3657
|
sha256,
|
|
3916
3658
|
arrayBufferToBase64Url,
|
|
3917
3659
|
generateSecureRandomBase64Url,
|
|
3918
3660
|
getUUIDv4,
|
|
3919
|
-
PUBLIC_API_BASE_URL,
|
|
3920
|
-
HEADER_USER_AGENT,
|
|
3921
|
-
HEADER_IDEMPOTENCY_KEY,
|
|
3922
|
-
API_VERSION,
|
|
3923
|
-
COINLIST_BASE_URL,
|
|
3924
|
-
OAUTH_PAGE_PATH,
|
|
3925
|
-
SUPPORT_NEW_TICKET_URL,
|
|
3926
|
-
VERIFY_IDENTITY_PATH,
|
|
3927
|
-
VERIFY_IDENTITY_ACCREDITATION_PATH,
|
|
3928
|
-
WALLET_PATH,
|
|
3929
3661
|
SentWith,
|
|
3930
3662
|
TokenTrigger,
|
|
3931
3663
|
isRejectedToken,
|
|
3932
3664
|
Attributes,
|
|
3933
3665
|
HttpError,
|
|
3934
3666
|
apiErrorCode,
|
|
3935
|
-
Request,
|
|
3936
3667
|
NotImplementedError,
|
|
3937
3668
|
NotAuthenticatedError,
|
|
3938
3669
|
ValidationError,
|
|
@@ -3941,7 +3672,6 @@ export {
|
|
|
3941
3672
|
classifyLogCause,
|
|
3942
3673
|
describeErrorUnredacted,
|
|
3943
3674
|
internalLogger,
|
|
3944
|
-
HttpClient,
|
|
3945
3675
|
EpochMillis,
|
|
3946
3676
|
Millis,
|
|
3947
3677
|
Seconds,
|
|
@@ -4068,10 +3798,11 @@ export {
|
|
|
4068
3798
|
fetchOffers,
|
|
4069
3799
|
fetchOffersPage,
|
|
4070
3800
|
fetchOfferDetails,
|
|
3801
|
+
OffersNamespaceImpl,
|
|
4071
3802
|
Erc20NamespaceImpl,
|
|
4072
3803
|
TokenLogoUrl,
|
|
4073
3804
|
TokenLogo,
|
|
4074
3805
|
TokenMetadata,
|
|
4075
3806
|
TokensNamespaceImpl
|
|
4076
3807
|
};
|
|
4077
|
-
//# sourceMappingURL=chunk-
|
|
3808
|
+
//# sourceMappingURL=chunk-2FZAXGVH.js.map
|