@coinlist-co/react 0.12.2-rc.3de3751 → 0.12.2-rc.4cc3d7e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-RLOYYAMO.js → chunk-4FGI6MAK.js} +108 -110
- package/dist/chunk-4FGI6MAK.js.map +1 -0
- package/dist/{chunk-HMLWCXAP.js → chunk-ANPPXFXD.js} +186 -432
- package/dist/chunk-ANPPXFXD.js.map +1 -0
- package/dist/{chunk-L7SVKXXW.js → chunk-AY4ADMCH.js} +328 -21
- package/dist/chunk-AY4ADMCH.js.map +1 -0
- package/dist/{chunk-MJ6YXZWH.js → chunk-IWQ6A52U.js} +4 -2
- package/dist/chunk-IWQ6A52U.js.map +1 -0
- package/dist/client/index.d.ts +298 -123
- package/dist/client/index.js +1876 -1032
- package/dist/client/index.js.map +1 -1
- package/dist/client-credentials-B2l_rZTE.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-DkU7jivQ.d.ts → time-BgR3LVER.d.ts} +91 -43
- package/dist/{token-registry-snapshot-D0OWXMe4.d.ts → token-registry-snapshot-CE21sVyi.d.ts} +1 -1
- package/dist/universal/index.d.ts +56 -44
- package/dist/universal/index.js +6 -4
- package/package.json +1 -1
- package/dist/chunk-HMLWCXAP.js.map +0 -1
- package/dist/chunk-L7SVKXXW.js.map +0 -1
- package/dist/chunk-MJ6YXZWH.js.map +0 -1
- package/dist/chunk-RLOYYAMO.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 {
|
|
@@ -633,10 +446,13 @@ function requiredDate(value, field) {
|
|
|
633
446
|
return date;
|
|
634
447
|
}
|
|
635
448
|
function dateOrNull(value, field) {
|
|
636
|
-
return value
|
|
449
|
+
return mapNullish(value, (date) => requiredDate(date, field));
|
|
637
450
|
}
|
|
638
451
|
function decimalOrNull(value) {
|
|
639
|
-
return value
|
|
452
|
+
return mapNullish(value, DecimalString);
|
|
453
|
+
}
|
|
454
|
+
function mapNullish(value, parse) {
|
|
455
|
+
return value === null || value === void 0 ? null : parse(value);
|
|
640
456
|
}
|
|
641
457
|
function requiredArray(value, field) {
|
|
642
458
|
if (!Array.isArray(value)) {
|
|
@@ -792,6 +608,95 @@ function assertSpendScaleAgrees({
|
|
|
792
608
|
);
|
|
793
609
|
}
|
|
794
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
|
+
|
|
795
700
|
// src/universal/api/frontline/providers/centrifuge/centrifuge.ts
|
|
796
701
|
async function getCentrifugeVaultStatus(api, params) {
|
|
797
702
|
const dto = await api.send({
|
|
@@ -848,7 +753,7 @@ function walletFields(params) {
|
|
|
848
753
|
};
|
|
849
754
|
}
|
|
850
755
|
|
|
851
|
-
// src/universal/core/providers/
|
|
756
|
+
// src/universal/core/providers/centrifuge/blockchain/abi.ts
|
|
852
757
|
var CENTRIFUGE_PROXY_ABI = [
|
|
853
758
|
{
|
|
854
759
|
type: "function",
|
|
@@ -1111,7 +1016,7 @@ var noopInternalLogger = {
|
|
|
1111
1016
|
wrap: (_op, _params, run) => run()
|
|
1112
1017
|
};
|
|
1113
1018
|
|
|
1114
|
-
// src/universal/core/providers/
|
|
1019
|
+
// src/universal/core/providers/centrifuge/centrifuge-namespace.ts
|
|
1115
1020
|
var CentrifugeNamespaceImpl = class {
|
|
1116
1021
|
constructor(ctx) {
|
|
1117
1022
|
this.ctx = ctx;
|
|
@@ -1448,6 +1353,17 @@ var OfferVaultContract = {
|
|
|
1448
1353
|
*/
|
|
1449
1354
|
listFromDto: (dtos) => dtos.filter((dto) => isChain(dto.chain)).map(OfferVaultContract.fromDto)
|
|
1450
1355
|
};
|
|
1356
|
+
var OfferFundingContract = {
|
|
1357
|
+
fromDto: (dto) => ({
|
|
1358
|
+
chain: Chain(dto.chain),
|
|
1359
|
+
address: EvmContractAddress(dto.address)
|
|
1360
|
+
}),
|
|
1361
|
+
/**
|
|
1362
|
+
* Drops every contract on a chain this SDK does not name, as
|
|
1363
|
+
* {@link OfferVaultContract.listFromDto} does.
|
|
1364
|
+
*/
|
|
1365
|
+
listFromDto: (dtos) => dtos.filter((dto) => isChain(dto.chain)).map(OfferFundingContract.fromDto)
|
|
1366
|
+
};
|
|
1451
1367
|
var OfferDetail = {
|
|
1452
1368
|
fromDto: (dto) => {
|
|
1453
1369
|
const fundingAssets = requiredArray(
|
|
@@ -1489,7 +1405,15 @@ var OfferDetail = {
|
|
|
1489
1405
|
...base2,
|
|
1490
1406
|
...OfferEditorial.fromDto(dto, "OfferDetail"),
|
|
1491
1407
|
type: dto.type,
|
|
1492
|
-
logoUrl: requiredString(dto.logo_url, "OfferDetail.logo_url")
|
|
1408
|
+
logoUrl: requiredString(dto.logo_url, "OfferDetail.logo_url"),
|
|
1409
|
+
// `[]` is fine and a missing key is not, as for `swap_contracts`:
|
|
1410
|
+
// this is the spender a participation's approval names.
|
|
1411
|
+
fundingContracts: OfferFundingContract.listFromDto(
|
|
1412
|
+
requiredArray(
|
|
1413
|
+
dto.funding_contracts,
|
|
1414
|
+
"OfferDetail.funding_contracts"
|
|
1415
|
+
)
|
|
1416
|
+
)
|
|
1493
1417
|
};
|
|
1494
1418
|
case "superstate::swap":
|
|
1495
1419
|
return {
|
|
@@ -1660,7 +1584,7 @@ async function createParticipation(api, params) {
|
|
|
1660
1584
|
return Participation.fromDto(dto);
|
|
1661
1585
|
}
|
|
1662
1586
|
|
|
1663
|
-
// src/universal/core/providers/
|
|
1587
|
+
// src/universal/core/providers/coin-list/token-sale-namespace.ts
|
|
1664
1588
|
var CoinListTokenSaleNamespaceImpl = class {
|
|
1665
1589
|
constructor(ctx) {
|
|
1666
1590
|
this.ctx = ctx;
|
|
@@ -1919,7 +1843,7 @@ function sizeParam(params) {
|
|
|
1919
1843
|
return { notional_value: notionalValue };
|
|
1920
1844
|
}
|
|
1921
1845
|
|
|
1922
|
-
// src/universal/core/providers/
|
|
1846
|
+
// src/universal/core/providers/ondo/ondo-namespace.ts
|
|
1923
1847
|
var OndoNamespaceImpl = class {
|
|
1924
1848
|
constructor(ctx) {
|
|
1925
1849
|
this.ctx = ctx;
|
|
@@ -2010,7 +1934,7 @@ var AllowWalletResponse = {
|
|
|
2010
1934
|
}
|
|
2011
1935
|
};
|
|
2012
1936
|
|
|
2013
|
-
// src/universal/core/providers/
|
|
1937
|
+
// src/universal/core/providers/superstate/blockchain/quote.ts
|
|
2014
1938
|
var SwapQuote = {
|
|
2015
1939
|
/**
|
|
2016
1940
|
* Assembles a {@link SwapQuote} from a raw contract {@link SwapPreview}. The
|
|
@@ -2045,7 +1969,7 @@ async function allowWallet(api, params) {
|
|
|
2045
1969
|
return AllowWalletResponse.fromDto(dto);
|
|
2046
1970
|
}
|
|
2047
1971
|
|
|
2048
|
-
// src/universal/core/providers/
|
|
1972
|
+
// src/universal/core/providers/superstate/blockchain/abi.ts
|
|
2049
1973
|
var SUPERSTATE_SWAP_ABI = [
|
|
2050
1974
|
{
|
|
2051
1975
|
type: "function",
|
|
@@ -3066,7 +2990,7 @@ async function getSwapOutputToken(clients, params) {
|
|
|
3066
2990
|
};
|
|
3067
2991
|
}
|
|
3068
2992
|
|
|
3069
|
-
// src/universal/core/providers/
|
|
2993
|
+
// src/universal/core/providers/superstate/superstate-namespace.ts
|
|
3070
2994
|
var SuperstateSwapNamespaceImpl = class {
|
|
3071
2995
|
constructor(ctx) {
|
|
3072
2996
|
this.ctx = ctx;
|
|
@@ -3438,6 +3362,61 @@ var WalletsNamespaceImpl = class {
|
|
|
3438
3362
|
}
|
|
3439
3363
|
};
|
|
3440
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
|
+
|
|
3441
3420
|
// src/universal/api/rpc/erc20.ts
|
|
3442
3421
|
async function getTokenAllowance(clients, params) {
|
|
3443
3422
|
const allowance = await clients(params.chain).readContract({
|
|
@@ -3565,187 +3544,6 @@ var resolveLogoUrl = (url, baseUrl) => TokenLogoUrl(
|
|
|
3565
3544
|
|
|
3566
3545
|
// src/universal/api/nabu/tokens.ts
|
|
3567
3546
|
import { getAddress } from "viem";
|
|
3568
|
-
|
|
3569
|
-
// src/universal/api/frontline/config.ts
|
|
3570
|
-
var PUBLIC_API_BASE_URL = "https://api.coinlist.co";
|
|
3571
|
-
var HEADER_API_VERSION = "X-API-Version";
|
|
3572
|
-
var HEADER_USER_AGENT = "User-Agent";
|
|
3573
|
-
var HEADER_IDEMPOTENCY_KEY = "Idempotency-Key";
|
|
3574
|
-
var API_VERSION = "2025-10-17";
|
|
3575
|
-
var COINLIST_BASE_URL = "https://coinlist.co";
|
|
3576
|
-
var OAUTH_PAGE_PATH = "/oauth/authorize";
|
|
3577
|
-
var SUPPORT_NEW_TICKET_URL = "https://support.coinlist.co/support/tickets/new";
|
|
3578
|
-
var VERIFY_IDENTITY_PATH = "/verify-identity";
|
|
3579
|
-
var VERIFY_IDENTITY_ACCREDITATION_PATH = "/verify-identity/accreditation_full";
|
|
3580
|
-
var WALLET_PATH = "/wallet";
|
|
3581
|
-
|
|
3582
|
-
// src/universal/api/http-client.ts
|
|
3583
|
-
var HttpClient = class {
|
|
3584
|
-
constructor(config, middleware = {}, logger = null, options = {}) {
|
|
3585
|
-
this.config = config;
|
|
3586
|
-
this.middleware = middleware;
|
|
3587
|
-
this.log = internalLogger(logger, "HTTP");
|
|
3588
|
-
this.makeRequestId = options.makeRequestId ?? defaultMakeRequestId;
|
|
3589
|
-
}
|
|
3590
|
-
async send(request) {
|
|
3591
|
-
return this.runRequestWithAfterMiddleware(request);
|
|
3592
|
-
}
|
|
3593
|
-
/**
|
|
3594
|
-
* Runs beforeRequest, executeRequest, then the full afterRequest middleware
|
|
3595
|
-
* chain. Used by send() and by the retry() callback so that when a
|
|
3596
|
-
* middleware calls retry(), the retried response also goes through all
|
|
3597
|
-
* afterRequest middleware (e.g. session renewal, retry). Middleware
|
|
3598
|
-
* must use request.attributes.retryAttempt (or similar) to avoid infinite
|
|
3599
|
-
* recursion when they trigger retries.
|
|
3600
|
-
*/
|
|
3601
|
-
async runRequestWithAfterMiddleware(request) {
|
|
3602
|
-
const preparedRequest = await this.runBeforeRequestMiddleware(
|
|
3603
|
-
this.withClientDefaults(request)
|
|
3604
|
-
);
|
|
3605
|
-
let response = await this.executeRequest(preparedRequest);
|
|
3606
|
-
for (const middleware of this.middleware.afterRequest ?? []) {
|
|
3607
|
-
let retried = false;
|
|
3608
|
-
response = await middleware({
|
|
3609
|
-
request: preparedRequest,
|
|
3610
|
-
response,
|
|
3611
|
-
retry: (nextRequest = preparedRequest) => {
|
|
3612
|
-
retried = true;
|
|
3613
|
-
return this.runRequestWithAfterMiddleware(nextRequest);
|
|
3614
|
-
}
|
|
3615
|
-
});
|
|
3616
|
-
if (retried) {
|
|
3617
|
-
return response;
|
|
3618
|
-
}
|
|
3619
|
-
}
|
|
3620
|
-
return response;
|
|
3621
|
-
}
|
|
3622
|
-
withClientDefaults(request) {
|
|
3623
|
-
const url = this.resolveUrl(request.url);
|
|
3624
|
-
const headers = {
|
|
3625
|
-
...request.headers ?? {},
|
|
3626
|
-
...this.config.xApiVersion !== void 0 ? { [HEADER_API_VERSION]: this.config.xApiVersion } : {}
|
|
3627
|
-
};
|
|
3628
|
-
return {
|
|
3629
|
-
...request,
|
|
3630
|
-
url,
|
|
3631
|
-
headers,
|
|
3632
|
-
// Only when absent: a retry or a post-renewal re-send arrives with the
|
|
3633
|
-
// first attempt's id already on it, and keeping it is the whole point.
|
|
3634
|
-
attributes: Attributes.getRequestId(request.attributes) === null ? Attributes.concat(
|
|
3635
|
-
request.attributes ?? Attributes.empty,
|
|
3636
|
-
Attributes.requestId(this.makeRequestId())
|
|
3637
|
-
) : request.attributes
|
|
3638
|
-
};
|
|
3639
|
-
}
|
|
3640
|
-
/**
|
|
3641
|
-
* Resolves a request URL against the client's baseUrl.
|
|
3642
|
-
*
|
|
3643
|
-
* @internal Public only for testing. Do not use in application code; use
|
|
3644
|
-
* {@link HttpClient.send} with a path and the client will resolve the URL.
|
|
3645
|
-
*/
|
|
3646
|
-
resolveUrl(url) {
|
|
3647
|
-
if (url.startsWith("http://") || url.startsWith("https://")) {
|
|
3648
|
-
return url;
|
|
3649
|
-
}
|
|
3650
|
-
const base2 = this.config.baseUrl.replace(/\/$/, "");
|
|
3651
|
-
const path = url.startsWith("/") ? url : `/${url}`;
|
|
3652
|
-
return base2 + path;
|
|
3653
|
-
}
|
|
3654
|
-
async runBeforeRequestMiddleware(initialRequest) {
|
|
3655
|
-
let request = initialRequest;
|
|
3656
|
-
for (const middleware of this.middleware.beforeRequest ?? []) {
|
|
3657
|
-
request = await middleware(request);
|
|
3658
|
-
}
|
|
3659
|
-
return request;
|
|
3660
|
-
}
|
|
3661
|
-
/**
|
|
3662
|
-
* One physical attempt, logged as one line.
|
|
3663
|
-
*
|
|
3664
|
-
* A non-2xx is a `warn` rather than an `error` because the wire does not
|
|
3665
|
-
* know whether it is a failure: the retry middleware may turn a 503 into a
|
|
3666
|
-
* success, and the token registry reads a 404 as "not listed". The namespace
|
|
3667
|
-
* above decides, and logs the `error` when it does.
|
|
3668
|
-
*/
|
|
3669
|
-
async executeRequest(request) {
|
|
3670
|
-
const requestId2 = Attributes.getRequestId(request.attributes);
|
|
3671
|
-
const log = requestId2 === null ? this.log : this.log.child({ requestId: requestId2 });
|
|
3672
|
-
const attempt = Attributes.getRetryAttempt(request.attributes) + 1;
|
|
3673
|
-
const startedAt = Date.now();
|
|
3674
|
-
log.debug(() => ({
|
|
3675
|
-
msg: "request sent",
|
|
3676
|
-
fields: describeRequestUnredacted(request)
|
|
3677
|
-
}));
|
|
3678
|
-
try {
|
|
3679
|
-
const response = await makeRequest(request);
|
|
3680
|
-
const elapsed = Date.now() - startedAt;
|
|
3681
|
-
const outcome = () => ({
|
|
3682
|
-
msg: "request completed",
|
|
3683
|
-
fields: {
|
|
3684
|
-
...identifyRequest(request),
|
|
3685
|
-
"http.response.status_code": response.status,
|
|
3686
|
-
duration_ms: elapsed,
|
|
3687
|
-
attempt
|
|
3688
|
-
}
|
|
3689
|
-
});
|
|
3690
|
-
if (response.status >= 200 && response.status < 300) {
|
|
3691
|
-
log.info(outcome);
|
|
3692
|
-
} else {
|
|
3693
|
-
log.warn(outcome);
|
|
3694
|
-
}
|
|
3695
|
-
log.debug(() => ({
|
|
3696
|
-
msg: "response received",
|
|
3697
|
-
fields: { body: response.body }
|
|
3698
|
-
}));
|
|
3699
|
-
return requestId2 === null ? response : { ...response, requestId: requestId2 };
|
|
3700
|
-
} catch (error) {
|
|
3701
|
-
const elapsed = Date.now() - startedAt;
|
|
3702
|
-
log.warning(
|
|
3703
|
-
() => ({
|
|
3704
|
-
msg: "request threw",
|
|
3705
|
-
fields: {
|
|
3706
|
-
...identifyRequest(request),
|
|
3707
|
-
duration_ms: elapsed,
|
|
3708
|
-
attempt
|
|
3709
|
-
}
|
|
3710
|
-
}),
|
|
3711
|
-
error
|
|
3712
|
-
);
|
|
3713
|
-
throw error;
|
|
3714
|
-
}
|
|
3715
|
-
}
|
|
3716
|
-
};
|
|
3717
|
-
function identifyRequest(request) {
|
|
3718
|
-
const { host, path } = splitUrl(request.url);
|
|
3719
|
-
return {
|
|
3720
|
-
"http.request.method": request.method,
|
|
3721
|
-
"server.address": host,
|
|
3722
|
-
"url.path": path
|
|
3723
|
-
};
|
|
3724
|
-
}
|
|
3725
|
-
function splitUrl(url) {
|
|
3726
|
-
try {
|
|
3727
|
-
const parsed = new URL(url);
|
|
3728
|
-
return { host: parsed.host, path: parsed.pathname };
|
|
3729
|
-
} catch (_) {
|
|
3730
|
-
return { host: null, path: url };
|
|
3731
|
-
}
|
|
3732
|
-
}
|
|
3733
|
-
function defaultMakeRequestId() {
|
|
3734
|
-
return Math.random().toString(36).slice(2, 10).padEnd(8, "0");
|
|
3735
|
-
}
|
|
3736
|
-
function describeRequestUnredacted(request) {
|
|
3737
|
-
return {
|
|
3738
|
-
"http.request.method": request.method,
|
|
3739
|
-
"url.full": buildUrlWithQueryParams(request.url, request.queryParams),
|
|
3740
|
-
headers: request.headers,
|
|
3741
|
-
...request.method === "POST" ? { body: request.body } : {}
|
|
3742
|
-
};
|
|
3743
|
-
}
|
|
3744
|
-
|
|
3745
|
-
// src/universal/api/nabu/tokens.ts
|
|
3746
|
-
function createNabuApiClient(baseUrl, logger = null) {
|
|
3747
|
-
return new HttpClient({ baseUrl }, {}, logger);
|
|
3748
|
-
}
|
|
3749
3547
|
async function fetchTokenMetadata(client, token) {
|
|
3750
3548
|
const address = checksummed(token.address);
|
|
3751
3549
|
let response;
|
|
@@ -3833,84 +3631,39 @@ function checksummed(address) {
|
|
|
3833
3631
|
}
|
|
3834
3632
|
}
|
|
3835
3633
|
|
|
3836
|
-
// src/universal/core/tokens/tokens-namespace.ts
|
|
3634
|
+
// src/universal/core/shared/blockchain/tokens/tokens-namespace.ts
|
|
3837
3635
|
var TokensNamespaceImpl = class {
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
* and the auth check would both be dead weight here.
|
|
3842
|
-
*/
|
|
3843
|
-
constructor(baseUrl, logger = null) {
|
|
3844
|
-
this.api = createNabuApiClient(baseUrl, logger);
|
|
3845
|
-
this.log = internalLogger(logger, "TOKENS");
|
|
3636
|
+
constructor(ctx) {
|
|
3637
|
+
this.ctx = ctx;
|
|
3638
|
+
this.log = internalLogger(ctx.logger, "TOKENS");
|
|
3846
3639
|
}
|
|
3847
3640
|
get(token) {
|
|
3848
3641
|
return this.log.wrap(
|
|
3849
3642
|
"get",
|
|
3850
3643
|
token,
|
|
3851
|
-
() => fetchTokenMetadata(this.
|
|
3644
|
+
() => fetchTokenMetadata(this.ctx.nabu, token)
|
|
3852
3645
|
);
|
|
3853
3646
|
}
|
|
3854
3647
|
list(chain) {
|
|
3855
3648
|
return this.log.wrap(
|
|
3856
3649
|
"list",
|
|
3857
3650
|
chain,
|
|
3858
|
-
() => chain === void 0 ? fetchAllTokensMetadata(this.
|
|
3651
|
+
() => chain === void 0 ? fetchAllTokensMetadata(this.ctx.nabu) : fetchTokensMetadata(this.ctx.nabu, chain)
|
|
3859
3652
|
);
|
|
3860
3653
|
}
|
|
3861
3654
|
};
|
|
3862
3655
|
|
|
3863
|
-
// src/universal/api/frontline/offers.ts
|
|
3864
|
-
async function fetchOffers(api, clientCreds) {
|
|
3865
|
-
return fetchAllPages((params) => fetchOffersPage(api, params, clientCreds));
|
|
3866
|
-
}
|
|
3867
|
-
async function fetchOffersPage(api, params, clientCreds) {
|
|
3868
|
-
const queryParams = PaginationParams.toQueryParams(params);
|
|
3869
|
-
const pageDto = await api.send({
|
|
3870
|
-
method: "GET",
|
|
3871
|
-
url: "/v1/offers",
|
|
3872
|
-
queryParams,
|
|
3873
|
-
attributes: Attributes.concat(
|
|
3874
|
-
Attributes.protected(),
|
|
3875
|
-
Attributes.clientCredentials(clientCreds)
|
|
3876
|
-
)
|
|
3877
|
-
});
|
|
3878
|
-
return PaginatedResponse.fromDtoPage(pageDto, Offer.listFromDto);
|
|
3879
|
-
}
|
|
3880
|
-
async function fetchOfferDetails(api, id, clientCreds) {
|
|
3881
|
-
const dto = await api.send({
|
|
3882
|
-
method: "GET",
|
|
3883
|
-
url: `/v1/offers/${id}`,
|
|
3884
|
-
attributes: Attributes.concat(
|
|
3885
|
-
Attributes.protected(),
|
|
3886
|
-
Attributes.clientCredentials(clientCreds)
|
|
3887
|
-
)
|
|
3888
|
-
});
|
|
3889
|
-
return OfferDetail.fromDto(dto);
|
|
3890
|
-
}
|
|
3891
|
-
|
|
3892
3656
|
export {
|
|
3893
3657
|
sha256,
|
|
3894
3658
|
arrayBufferToBase64Url,
|
|
3895
3659
|
generateSecureRandomBase64Url,
|
|
3896
3660
|
getUUIDv4,
|
|
3897
|
-
PUBLIC_API_BASE_URL,
|
|
3898
|
-
HEADER_USER_AGENT,
|
|
3899
|
-
HEADER_IDEMPOTENCY_KEY,
|
|
3900
|
-
API_VERSION,
|
|
3901
|
-
COINLIST_BASE_URL,
|
|
3902
|
-
OAUTH_PAGE_PATH,
|
|
3903
|
-
SUPPORT_NEW_TICKET_URL,
|
|
3904
|
-
VERIFY_IDENTITY_PATH,
|
|
3905
|
-
VERIFY_IDENTITY_ACCREDITATION_PATH,
|
|
3906
|
-
WALLET_PATH,
|
|
3907
3661
|
SentWith,
|
|
3908
3662
|
TokenTrigger,
|
|
3909
3663
|
isRejectedToken,
|
|
3910
3664
|
Attributes,
|
|
3911
3665
|
HttpError,
|
|
3912
3666
|
apiErrorCode,
|
|
3913
|
-
Request,
|
|
3914
3667
|
NotImplementedError,
|
|
3915
3668
|
NotAuthenticatedError,
|
|
3916
3669
|
ValidationError,
|
|
@@ -3919,7 +3672,6 @@ export {
|
|
|
3919
3672
|
classifyLogCause,
|
|
3920
3673
|
describeErrorUnredacted,
|
|
3921
3674
|
internalLogger,
|
|
3922
|
-
HttpClient,
|
|
3923
3675
|
EpochMillis,
|
|
3924
3676
|
Millis,
|
|
3925
3677
|
Seconds,
|
|
@@ -4002,6 +3754,7 @@ export {
|
|
|
4002
3754
|
OfferOptionSlug,
|
|
4003
3755
|
OfferSwapContract,
|
|
4004
3756
|
OfferVaultContract,
|
|
3757
|
+
OfferFundingContract,
|
|
4005
3758
|
OfferDetail,
|
|
4006
3759
|
OfferOption,
|
|
4007
3760
|
FaqItem,
|
|
@@ -4045,10 +3798,11 @@ export {
|
|
|
4045
3798
|
fetchOffers,
|
|
4046
3799
|
fetchOffersPage,
|
|
4047
3800
|
fetchOfferDetails,
|
|
3801
|
+
OffersNamespaceImpl,
|
|
4048
3802
|
Erc20NamespaceImpl,
|
|
4049
3803
|
TokenLogoUrl,
|
|
4050
3804
|
TokenLogo,
|
|
4051
3805
|
TokenMetadata,
|
|
4052
3806
|
TokensNamespaceImpl
|
|
4053
3807
|
};
|
|
4054
|
-
//# sourceMappingURL=chunk-
|
|
3808
|
+
//# sourceMappingURL=chunk-ANPPXFXD.js.map
|