@coinlist-co/react 0.11.0 → 0.11.1-rc.209af8d
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-UIIXXLA7.js → chunk-3Z4PLLV7.js} +540 -154
- package/dist/chunk-3Z4PLLV7.js.map +1 -0
- package/dist/{chunk-B2HCVPCQ.js → chunk-T4ANQVQA.js} +26 -11
- package/dist/chunk-T4ANQVQA.js.map +1 -0
- package/dist/chunk-YPFS2SAD.js +279 -0
- package/dist/chunk-YPFS2SAD.js.map +1 -0
- package/dist/client/index.cjs +1364 -475
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +217 -212
- package/dist/client/index.d.ts +217 -212
- package/dist/client/index.js +464 -108
- package/dist/client/index.js.map +1 -1
- package/dist/collections-B0nu_6q5.d.ts +116 -0
- package/dist/collections-DdLA4_GN.d.cts +116 -0
- package/dist/{config-B5mwS_2l.d.cts → config-D0r6GyPL.d.cts} +743 -31
- package/dist/{config-B5mwS_2l.d.ts → config-D0r6GyPL.d.ts} +743 -31
- package/dist/server/index.cjs +822 -222
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +81 -4
- package/dist/server/index.d.ts +81 -4
- package/dist/server/index.js +120 -51
- package/dist/server/index.js.map +1 -1
- package/dist/shared/index.cjs +543 -137
- package/dist/shared/index.cjs.map +1 -1
- package/dist/shared/index.d.cts +18 -5
- package/dist/shared/index.d.ts +18 -5
- package/dist/shared/index.js +8 -2
- package/package.json +3 -2
- package/dist/chunk-B2HCVPCQ.js.map +0 -1
- package/dist/chunk-KDGNDAHA.js +0 -146
- package/dist/chunk-KDGNDAHA.js.map +0 -1
- package/dist/chunk-UIIXXLA7.js.map +0 -1
- package/dist/collections-BhDkYmzV.d.cts +0 -65
- package/dist/collections-CZhHoQHr.d.ts +0 -65
package/dist/shared/index.cjs
CHANGED
|
@@ -60,6 +60,7 @@ __export(shared_exports, {
|
|
|
60
60
|
FormattedPercentUi: () => FormattedPercentUi,
|
|
61
61
|
HexEncodedTransactionData: () => HexEncodedTransactionData,
|
|
62
62
|
HttpError: () => HttpError,
|
|
63
|
+
InvariantError: () => InvariantError,
|
|
63
64
|
Iso2CountryCode: () => Iso2CountryCode,
|
|
64
65
|
KnownAssetSymbol: () => KnownAssetSymbol,
|
|
65
66
|
KycToken: () => KycToken,
|
|
@@ -99,6 +100,7 @@ __export(shared_exports, {
|
|
|
99
100
|
Pii: () => Pii,
|
|
100
101
|
PiiAddress: () => PiiAddress,
|
|
101
102
|
PiiJurisdiction: () => PiiJurisdiction,
|
|
103
|
+
RedactedWalletError: () => RedactedWalletError,
|
|
102
104
|
RedirectUri: () => RedirectUri,
|
|
103
105
|
Requirement: () => Requirement,
|
|
104
106
|
RequirementId: () => RequirementId,
|
|
@@ -164,6 +166,7 @@ __export(shared_exports, {
|
|
|
164
166
|
isStopped: () => isStopped,
|
|
165
167
|
ondoSwapContractAddress: () => ondoSwapContractAddress,
|
|
166
168
|
parseBlockchainAmount: () => parseBlockchainAmount,
|
|
169
|
+
parseUint256: () => parseUint256,
|
|
167
170
|
shortenAddress: () => shortenAddress,
|
|
168
171
|
superstateSwapContractAddress: () => superstateSwapContractAddress,
|
|
169
172
|
txExplorerUrl: () => txExplorerUrl,
|
|
@@ -198,6 +201,8 @@ var retryAttempt = (attempt) => ({
|
|
|
198
201
|
var renewAttempted = (value) => ({
|
|
199
202
|
renewAttempted: value
|
|
200
203
|
});
|
|
204
|
+
var requestId = (id) => ({ requestId: id });
|
|
205
|
+
var getRequestId = (attrs) => attrs?.requestId ?? null;
|
|
201
206
|
var isProtected = (attrs) => attrs?.protected === true;
|
|
202
207
|
var needUserAgent = (attrs) => attrs?.userAgent === true;
|
|
203
208
|
var isIdempotent = (attrs) => attrs?.idempotencyKey === true;
|
|
@@ -219,7 +224,9 @@ var Attributes = {
|
|
|
219
224
|
renewAttempted,
|
|
220
225
|
wasRenewAttempted,
|
|
221
226
|
clientCredentials,
|
|
222
|
-
getClientCredentials
|
|
227
|
+
getClientCredentials,
|
|
228
|
+
requestId,
|
|
229
|
+
getRequestId
|
|
223
230
|
};
|
|
224
231
|
|
|
225
232
|
// src/shared/api/http.ts
|
|
@@ -229,6 +236,16 @@ var HttpError = class extends Error {
|
|
|
229
236
|
this.name = "HttpError";
|
|
230
237
|
this.response = response;
|
|
231
238
|
}
|
|
239
|
+
/**
|
|
240
|
+
* Correlates this failure with the `[HTTP]` log lines for the same request,
|
|
241
|
+
* which carry the method, the URL, the duration and every retry. `null` when
|
|
242
|
+
* the response did not come from an {@link HttpClient}.
|
|
243
|
+
*
|
|
244
|
+
* Worth quoting in a bug report: it is what makes a log excerpt readable.
|
|
245
|
+
*/
|
|
246
|
+
get requestId() {
|
|
247
|
+
return this.response.requestId ?? null;
|
|
248
|
+
}
|
|
232
249
|
};
|
|
233
250
|
function apiErrorCode(error) {
|
|
234
251
|
if (!(error instanceof HttpError)) return null;
|
|
@@ -419,6 +436,12 @@ var ValidationError = class extends Error {
|
|
|
419
436
|
this.name = "ValidationError";
|
|
420
437
|
}
|
|
421
438
|
};
|
|
439
|
+
var InvariantError = class extends Error {
|
|
440
|
+
constructor(message) {
|
|
441
|
+
super(message);
|
|
442
|
+
this.name = "InvariantError";
|
|
443
|
+
}
|
|
444
|
+
};
|
|
422
445
|
|
|
423
446
|
// src/shared/types/blockchain/core.ts
|
|
424
447
|
var ETHEREUM_CHAINS = {
|
|
@@ -466,11 +489,14 @@ var STABLE_DECIMALS = AssetDecimals(6);
|
|
|
466
489
|
var DecimalString = (value) => value;
|
|
467
490
|
var MAX_UINT_256 = 2n ** 256n - 1n;
|
|
468
491
|
var assertUint256 = (value) => {
|
|
469
|
-
if (value
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
492
|
+
if (isUint256(value)) return value;
|
|
493
|
+
throw new InvariantError(`Value out of uint256 bounds: ${value}`);
|
|
494
|
+
};
|
|
495
|
+
var parseUint256 = (value, label) => {
|
|
496
|
+
if (isUint256(value)) return value;
|
|
497
|
+
throw new ValidationError(`${label}: out of uint256 bounds (${value})`);
|
|
473
498
|
};
|
|
499
|
+
var isUint256 = (value) => value >= 0n && value <= MAX_UINT_256;
|
|
474
500
|
var BlockchainAmount = Object.assign(
|
|
475
501
|
(value) => value,
|
|
476
502
|
{
|
|
@@ -480,13 +506,13 @@ var BlockchainAmount = Object.assign(
|
|
|
480
506
|
);
|
|
481
507
|
function combineAmounts(a, b, op) {
|
|
482
508
|
if (a.decimals !== b.decimals) {
|
|
483
|
-
throw new
|
|
509
|
+
throw new InvariantError(
|
|
484
510
|
`Cannot combine BlockchainAmounts with different decimals: ${a.decimals} vs ${b.decimals}`
|
|
485
511
|
);
|
|
486
512
|
}
|
|
487
513
|
const raw = op(a.raw, b.raw);
|
|
488
514
|
if (raw < 0n || raw > MAX_UINT_256) {
|
|
489
|
-
throw new
|
|
515
|
+
throw new InvariantError(`BlockchainAmount out of uint256 bounds: ${raw}`);
|
|
490
516
|
}
|
|
491
517
|
return BlockchainAmount({ raw, decimals: a.decimals });
|
|
492
518
|
}
|
|
@@ -661,25 +687,31 @@ var SwapAuthorization = {
|
|
|
661
687
|
};
|
|
662
688
|
var SwapPreview = {
|
|
663
689
|
fromDto: (dto) => ({
|
|
664
|
-
inputAmount:
|
|
665
|
-
|
|
666
|
-
|
|
690
|
+
inputAmount: parseUint256(
|
|
691
|
+
BigInt(dto.pay_input_amount),
|
|
692
|
+
"SwapPreview.pay_input_amount"
|
|
693
|
+
),
|
|
694
|
+
fee: parseUint256(BigInt(dto.fee), "SwapPreview.fee"),
|
|
695
|
+
outputAmount: parseUint256(
|
|
696
|
+
BigInt(dto.receive_output_amount),
|
|
697
|
+
"SwapPreview.receive_output_amount"
|
|
698
|
+
)
|
|
667
699
|
})
|
|
668
700
|
};
|
|
669
701
|
var SwapStatus = {
|
|
670
702
|
fromDto: (dto) => ({
|
|
671
|
-
stopped:
|
|
672
|
-
swapLevel:
|
|
703
|
+
stopped: parseUint256(BigInt(dto.stopped), "SwapStatus.stopped"),
|
|
704
|
+
swapLevel: parseUint256(BigInt(dto.swap_level), "SwapStatus.swap_level")
|
|
673
705
|
})
|
|
674
706
|
};
|
|
675
707
|
var TokenAllowance = {
|
|
676
708
|
fromDto: (dto) => ({
|
|
677
|
-
allowance:
|
|
709
|
+
allowance: parseUint256(BigInt(dto.allowance), "TokenAllowance.allowance")
|
|
678
710
|
})
|
|
679
711
|
};
|
|
680
712
|
var TokenBalance = {
|
|
681
713
|
fromDto: (dto) => ({
|
|
682
|
-
balance:
|
|
714
|
+
balance: parseUint256(BigInt(dto.balance), "TokenBalance.balance")
|
|
683
715
|
})
|
|
684
716
|
};
|
|
685
717
|
var AllowWalletResponse = {
|
|
@@ -804,18 +836,169 @@ function toErc20Asset(dto) {
|
|
|
804
836
|
};
|
|
805
837
|
}
|
|
806
838
|
|
|
839
|
+
// src/shared/core/observability/log-cause.ts
|
|
840
|
+
function classifyLogCause(error) {
|
|
841
|
+
if (error instanceof HttpError) {
|
|
842
|
+
return httpCause(error);
|
|
843
|
+
}
|
|
844
|
+
if (error instanceof ValidationError) {
|
|
845
|
+
return { type: "validation", message: error.message };
|
|
846
|
+
}
|
|
847
|
+
if (error instanceof InvariantError) {
|
|
848
|
+
return { type: "invariant", message: error.message };
|
|
849
|
+
}
|
|
850
|
+
if (error instanceof NotAuthenticatedError) {
|
|
851
|
+
return { type: "not-authenticated" };
|
|
852
|
+
}
|
|
853
|
+
if (error instanceof NotImplementedError) {
|
|
854
|
+
return { type: "not-implemented" };
|
|
855
|
+
}
|
|
856
|
+
return { type: "generic-error", name: errorName(error) };
|
|
857
|
+
}
|
|
858
|
+
function describeErrorUnredacted(error) {
|
|
859
|
+
if (error instanceof HttpError) {
|
|
860
|
+
return describeHttpErrorRedacted(error);
|
|
861
|
+
}
|
|
862
|
+
if (error instanceof Error) {
|
|
863
|
+
return `${error.name}: ${error.message}`;
|
|
864
|
+
}
|
|
865
|
+
return `thrown non-error: ${stringifyUnredacted(error)}`;
|
|
866
|
+
}
|
|
867
|
+
function stringifyUnredacted(value) {
|
|
868
|
+
if (value === void 0) return "";
|
|
869
|
+
try {
|
|
870
|
+
return JSON.stringify(
|
|
871
|
+
value,
|
|
872
|
+
(_key, item) => typeof item === "bigint" ? `${item}` : item
|
|
873
|
+
) ?? String(value);
|
|
874
|
+
} catch (_) {
|
|
875
|
+
return "<unserializable>";
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
function describeHttpErrorRedacted(error) {
|
|
879
|
+
const code = apiErrorCode(error);
|
|
880
|
+
const status = error.response.status;
|
|
881
|
+
return code === null ? `HttpError ${status}` : `HttpError ${status} (${code})`;
|
|
882
|
+
}
|
|
883
|
+
function errorName(error) {
|
|
884
|
+
return error instanceof Error ? error.name : `non-error ${typeof error}`;
|
|
885
|
+
}
|
|
886
|
+
function httpCause(error) {
|
|
887
|
+
return {
|
|
888
|
+
type: "http",
|
|
889
|
+
requestId: error.requestId,
|
|
890
|
+
status: error.response.status,
|
|
891
|
+
code: apiErrorCode(error),
|
|
892
|
+
eventId: apiErrorEventId(error)
|
|
893
|
+
};
|
|
894
|
+
}
|
|
895
|
+
function apiErrorEventId(error) {
|
|
896
|
+
const body = error.response.body;
|
|
897
|
+
if (typeof body !== "object" || body === null) return null;
|
|
898
|
+
const eventId = body.event_id;
|
|
899
|
+
return typeof eventId === "string" ? eventId : null;
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
// src/shared/core/observability/internal-logger.ts
|
|
903
|
+
function internalLogger(logger, scope) {
|
|
904
|
+
return logger ? scopedLogger(logger, scope, {}) : noopInternalLogger;
|
|
905
|
+
}
|
|
906
|
+
var LEVEL_RANK = {
|
|
907
|
+
none: 0,
|
|
908
|
+
error: 1,
|
|
909
|
+
warn: 2,
|
|
910
|
+
info: 3,
|
|
911
|
+
debug: 4
|
|
912
|
+
};
|
|
913
|
+
function scopedLogger(logger, scope, bindings) {
|
|
914
|
+
const admits = (level) => LEVEL_RANK[logger.level()] >= LEVEL_RANK[level];
|
|
915
|
+
const safe = (event) => ({
|
|
916
|
+
msg: event.msg,
|
|
917
|
+
scope,
|
|
918
|
+
bindings,
|
|
919
|
+
fields: event.fields ?? {},
|
|
920
|
+
...event.cause === void 0 ? {} : { cause: event.cause }
|
|
921
|
+
});
|
|
922
|
+
const unredacted = (event) => ({
|
|
923
|
+
msg: event.msg,
|
|
924
|
+
scope,
|
|
925
|
+
bindings,
|
|
926
|
+
fields: event.fields ?? {}
|
|
927
|
+
});
|
|
928
|
+
const self = {
|
|
929
|
+
child: (binding) => scopedLogger(logger, scope, { ...bindings, ...binding }),
|
|
930
|
+
debug: (event) => {
|
|
931
|
+
if (admits("debug")) logger.debug(() => unredacted(event()));
|
|
932
|
+
},
|
|
933
|
+
info: (event) => {
|
|
934
|
+
if (admits("info")) logger.info(() => safe(event()));
|
|
935
|
+
},
|
|
936
|
+
warn: (event) => {
|
|
937
|
+
if (admits("warn")) logger.warn(() => safe(event()));
|
|
938
|
+
},
|
|
939
|
+
error: (event) => {
|
|
940
|
+
if (admits("error")) logger.error(() => safe(event()));
|
|
941
|
+
},
|
|
942
|
+
failure: (event, error) => {
|
|
943
|
+
if (admits("debug"))
|
|
944
|
+
logger.debug(() => unredacted(verbatim(event(), error)));
|
|
945
|
+
if (admits("error")) logger.error(() => safe(classified(event(), error)));
|
|
946
|
+
},
|
|
947
|
+
warning: (event, error) => {
|
|
948
|
+
if (admits("debug"))
|
|
949
|
+
logger.debug(() => unredacted(verbatim(event(), error)));
|
|
950
|
+
if (admits("warn")) logger.warn(() => safe(classified(event(), error)));
|
|
951
|
+
},
|
|
952
|
+
wrap: async (op, params, run) => {
|
|
953
|
+
const opLog = self.child({ op });
|
|
954
|
+
opLog.debug(() => ({ msg: "call", fields: { params } }));
|
|
955
|
+
try {
|
|
956
|
+
return await run();
|
|
957
|
+
} catch (error) {
|
|
958
|
+
opLog.failure(() => ({ msg: "call failed" }), error);
|
|
959
|
+
throw error;
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
};
|
|
963
|
+
return self;
|
|
964
|
+
}
|
|
965
|
+
function verbatim(event, error) {
|
|
966
|
+
return {
|
|
967
|
+
msg: event.msg,
|
|
968
|
+
fields: { ...event.fields, error: describeErrorUnredacted(error) }
|
|
969
|
+
};
|
|
970
|
+
}
|
|
971
|
+
function classified(event, error) {
|
|
972
|
+
return { ...event, cause: event.cause ?? classifyLogCause(error) };
|
|
973
|
+
}
|
|
974
|
+
var noopInternalLogger = {
|
|
975
|
+
child: () => noopInternalLogger,
|
|
976
|
+
debug: () => void 0,
|
|
977
|
+
info: () => void 0,
|
|
978
|
+
warn: () => void 0,
|
|
979
|
+
error: () => void 0,
|
|
980
|
+
failure: () => void 0,
|
|
981
|
+
warning: () => void 0,
|
|
982
|
+
wrap: (_op, _params, run) => run()
|
|
983
|
+
};
|
|
984
|
+
|
|
807
985
|
// src/shared/core/blockchain/erc20/erc20-namespace.ts
|
|
808
986
|
var Erc20NamespaceImpl = class {
|
|
809
987
|
constructor(ctx) {
|
|
810
988
|
this.ctx = ctx;
|
|
989
|
+
this.log = internalLogger(ctx.logger, "ERC20");
|
|
811
990
|
}
|
|
812
991
|
async getAllowance(params) {
|
|
813
|
-
|
|
814
|
-
|
|
992
|
+
return this.log.wrap("getAllowance", params, async () => {
|
|
993
|
+
await this.ctx.ensureUserAuthenticated();
|
|
994
|
+
return getTokenAllowance(this.ctx.api, params);
|
|
995
|
+
});
|
|
815
996
|
}
|
|
816
997
|
async getBalance(params) {
|
|
817
|
-
|
|
818
|
-
|
|
998
|
+
return this.log.wrap("getBalance", params, async () => {
|
|
999
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1000
|
+
return getTokenBalance(this.ctx.api, params);
|
|
1001
|
+
});
|
|
819
1002
|
}
|
|
820
1003
|
};
|
|
821
1004
|
|
|
@@ -1007,7 +1190,7 @@ var TOKEN_REGISTRY = {
|
|
|
1007
1190
|
case "USDT":
|
|
1008
1191
|
return USDT;
|
|
1009
1192
|
default:
|
|
1010
|
-
throw new
|
|
1193
|
+
throw new InvariantError(`Unknown asset symbol: ${symbol}`);
|
|
1011
1194
|
}
|
|
1012
1195
|
},
|
|
1013
1196
|
contractAddress: (symbol, chain) => {
|
|
@@ -1017,7 +1200,7 @@ var TOKEN_REGISTRY = {
|
|
|
1017
1200
|
case "USDT":
|
|
1018
1201
|
return USDT_ADDRESSES[chain];
|
|
1019
1202
|
default:
|
|
1020
|
-
throw new
|
|
1203
|
+
throw new InvariantError(`Unknown asset symbol: ${symbol}`);
|
|
1021
1204
|
}
|
|
1022
1205
|
}
|
|
1023
1206
|
};
|
|
@@ -1063,15 +1246,30 @@ var Asset = {
|
|
|
1063
1246
|
var OfferId = (value) => value;
|
|
1064
1247
|
var OfferSlug = (value) => value;
|
|
1065
1248
|
var Offer = {
|
|
1249
|
+
fromDto: (dto) => {
|
|
1250
|
+
if (!Array.isArray(dto.tokens)) {
|
|
1251
|
+
throw new ValidationError(
|
|
1252
|
+
`Offer.tokens: expected an array, got ${typeof dto.tokens}`
|
|
1253
|
+
);
|
|
1254
|
+
}
|
|
1255
|
+
return {
|
|
1256
|
+
id: OfferId(dto.id),
|
|
1257
|
+
slug: OfferSlug(dto.slug),
|
|
1258
|
+
type: dto.type,
|
|
1259
|
+
tagline: dto.tagline,
|
|
1260
|
+
bannerUrl: dto.banner_url,
|
|
1261
|
+
logoUrl: dto.logo_url,
|
|
1262
|
+
startsAt: new Date(dto.starts_at),
|
|
1263
|
+
endsAt: dto.ends_at ? new Date(dto.ends_at) : null,
|
|
1264
|
+
tokens: dto.tokens.map(OfferToken.fromDto)
|
|
1265
|
+
};
|
|
1266
|
+
}
|
|
1267
|
+
};
|
|
1268
|
+
var OfferToken = {
|
|
1066
1269
|
fromDto: (dto) => ({
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
tagline: dto.tagline,
|
|
1071
|
-
bannerUrl: dto.banner_url,
|
|
1072
|
-
logoUrl: dto.logo_url,
|
|
1073
|
-
startsAt: new Date(dto.starts_at),
|
|
1074
|
-
endsAt: dto.ends_at ? new Date(dto.ends_at) : null
|
|
1270
|
+
role: dto.role,
|
|
1271
|
+
chain: Chain(dto.chain),
|
|
1272
|
+
address: EvmContractAddress(dto.address)
|
|
1075
1273
|
})
|
|
1076
1274
|
};
|
|
1077
1275
|
|
|
@@ -1081,25 +1279,39 @@ var OfferOptionSlug = (value) => value;
|
|
|
1081
1279
|
var OfferDetail = {
|
|
1082
1280
|
fromDto: (dto) => {
|
|
1083
1281
|
if (!Array.isArray(dto.funding_assets)) {
|
|
1084
|
-
throw new
|
|
1282
|
+
throw new ValidationError(
|
|
1283
|
+
`OfferDetail.funding_assets: expected an array, got ${typeof dto.funding_assets}`
|
|
1284
|
+
);
|
|
1085
1285
|
}
|
|
1086
1286
|
if (!Array.isArray(dto.options)) {
|
|
1087
|
-
throw new
|
|
1287
|
+
throw new ValidationError(
|
|
1288
|
+
`OfferDetail.options: expected an array, got ${typeof dto.options}`
|
|
1289
|
+
);
|
|
1088
1290
|
}
|
|
1089
1291
|
if (!Array.isArray(dto.terms)) {
|
|
1090
|
-
throw new
|
|
1292
|
+
throw new ValidationError(
|
|
1293
|
+
`OfferDetail.terms: expected an array, got ${typeof dto.terms}`
|
|
1294
|
+
);
|
|
1091
1295
|
}
|
|
1092
1296
|
if (!Array.isArray(dto.links)) {
|
|
1093
|
-
throw new
|
|
1297
|
+
throw new ValidationError(
|
|
1298
|
+
`OfferDetail.links: expected an array, got ${typeof dto.links}`
|
|
1299
|
+
);
|
|
1094
1300
|
}
|
|
1095
1301
|
if (!Array.isArray(dto.faqs)) {
|
|
1096
|
-
throw new
|
|
1302
|
+
throw new ValidationError(
|
|
1303
|
+
`OfferDetail.faqs: expected an array, got ${typeof dto.faqs}`
|
|
1304
|
+
);
|
|
1097
1305
|
}
|
|
1098
1306
|
if (!Array.isArray(dto.milestones)) {
|
|
1099
|
-
throw new
|
|
1307
|
+
throw new ValidationError(
|
|
1308
|
+
`OfferDetail.milestones: expected an array, got ${typeof dto.milestones}`
|
|
1309
|
+
);
|
|
1100
1310
|
}
|
|
1101
1311
|
if (!Array.isArray(dto.tokens)) {
|
|
1102
|
-
throw new
|
|
1312
|
+
throw new ValidationError(
|
|
1313
|
+
`OfferDetail.tokens: expected an array, got ${typeof dto.tokens}`
|
|
1314
|
+
);
|
|
1103
1315
|
}
|
|
1104
1316
|
return {
|
|
1105
1317
|
id: OfferId(dto.id),
|
|
@@ -1161,13 +1373,6 @@ var Milestone = {
|
|
|
1161
1373
|
status: dto.status
|
|
1162
1374
|
})
|
|
1163
1375
|
};
|
|
1164
|
-
var OfferToken = {
|
|
1165
|
-
fromDto: (dto) => ({
|
|
1166
|
-
role: dto.role,
|
|
1167
|
-
chain: Chain(dto.chain),
|
|
1168
|
-
address: EvmContractAddress(dto.address)
|
|
1169
|
-
})
|
|
1170
|
-
};
|
|
1171
1376
|
|
|
1172
1377
|
// src/shared/types/providers/coin-list/token-sale.ts
|
|
1173
1378
|
var ParticipationId = (value) => value;
|
|
@@ -1254,29 +1459,38 @@ async function createParticipation(api, params) {
|
|
|
1254
1459
|
var CoinListTokenSaleNamespaceImpl = class {
|
|
1255
1460
|
constructor(ctx) {
|
|
1256
1461
|
this.ctx = ctx;
|
|
1462
|
+
this.log = internalLogger(ctx.logger, "TOKEN_SALE");
|
|
1257
1463
|
}
|
|
1258
1464
|
async list(offerId) {
|
|
1259
|
-
|
|
1260
|
-
|
|
1465
|
+
return this.log.wrap("list", offerId, async () => {
|
|
1466
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1467
|
+
return fetchParticipations(this.ctx.api, offerId);
|
|
1468
|
+
});
|
|
1261
1469
|
}
|
|
1262
1470
|
async listPage(params) {
|
|
1263
|
-
|
|
1264
|
-
|
|
1471
|
+
return this.log.wrap("listPage", params, async () => {
|
|
1472
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1473
|
+
return fetchParticipationsPage(this.ctx.api, params);
|
|
1474
|
+
});
|
|
1265
1475
|
}
|
|
1266
1476
|
async get(id) {
|
|
1267
|
-
|
|
1268
|
-
|
|
1477
|
+
return this.log.wrap("get", id, async () => {
|
|
1478
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1479
|
+
return fetchParticipation(this.ctx.api, id);
|
|
1480
|
+
});
|
|
1269
1481
|
}
|
|
1270
1482
|
async createParticipation(params) {
|
|
1271
|
-
|
|
1272
|
-
|
|
1483
|
+
return this.log.wrap("createParticipation", params, async () => {
|
|
1484
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1485
|
+
return createParticipation(this.ctx.api, params);
|
|
1486
|
+
});
|
|
1273
1487
|
}
|
|
1274
1488
|
};
|
|
1275
1489
|
|
|
1276
1490
|
// src/shared/core/checkout/ondo/constants.ts
|
|
1277
1491
|
var ONDO_SWAP_CONTRACT_ADDRESSES = {
|
|
1278
1492
|
ethereum_sepolia: EvmContractAddress(
|
|
1279
|
-
"
|
|
1493
|
+
"0x7014019ed51Edab984a71D30F2707D2dB2316A7A"
|
|
1280
1494
|
)
|
|
1281
1495
|
};
|
|
1282
1496
|
function ondoSwapContractAddress(chain) {
|
|
@@ -1475,18 +1689,25 @@ function sizeParam(params) {
|
|
|
1475
1689
|
var OndoNamespaceImpl = class {
|
|
1476
1690
|
constructor(ctx) {
|
|
1477
1691
|
this.ctx = ctx;
|
|
1692
|
+
this.log = internalLogger(ctx.logger, "ONDO");
|
|
1478
1693
|
}
|
|
1479
1694
|
async getTradingStatus(params) {
|
|
1480
|
-
|
|
1481
|
-
|
|
1695
|
+
return this.log.wrap("getTradingStatus", params, async () => {
|
|
1696
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1697
|
+
return getOndoTradingStatus(this.ctx.api, params);
|
|
1698
|
+
});
|
|
1482
1699
|
}
|
|
1483
1700
|
async getQuote(params) {
|
|
1484
|
-
|
|
1485
|
-
|
|
1701
|
+
return this.log.wrap("getQuote", params, async () => {
|
|
1702
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1703
|
+
return getOndoQuote(this.ctx.api, params);
|
|
1704
|
+
});
|
|
1486
1705
|
}
|
|
1487
1706
|
async buildSwapTransaction(params) {
|
|
1488
|
-
|
|
1489
|
-
|
|
1707
|
+
return this.log.wrap("buildSwapTransaction", params, async () => {
|
|
1708
|
+
await this.ctx.ensureUserAuthenticated();
|
|
1709
|
+
return buildOndoSwapTransaction(this.ctx.api, params);
|
|
1710
|
+
});
|
|
1490
1711
|
}
|
|
1491
1712
|
};
|
|
1492
1713
|
|
|
@@ -1800,26 +2021,37 @@ function formattedPricePerShare(quote, locale) {
|
|
|
1800
2021
|
var SuperstateSwapNamespaceImpl = class {
|
|
1801
2022
|
constructor(ctx) {
|
|
1802
2023
|
this.ctx = ctx;
|
|
2024
|
+
this.log = internalLogger(ctx.logger, "SUPERSTATE");
|
|
1803
2025
|
}
|
|
1804
2026
|
async getAuthorization(params) {
|
|
1805
|
-
|
|
1806
|
-
|
|
2027
|
+
return this.log.wrap("getAuthorization", params, async () => {
|
|
2028
|
+
await this.ctx.ensureUserAuthenticated();
|
|
2029
|
+
return getSwapAuthorization(this.ctx.api, params);
|
|
2030
|
+
});
|
|
1807
2031
|
}
|
|
1808
2032
|
async getPreview(params) {
|
|
1809
|
-
|
|
1810
|
-
|
|
2033
|
+
return this.log.wrap("getPreview", params, async () => {
|
|
2034
|
+
await this.ctx.ensureUserAuthenticated();
|
|
2035
|
+
return getSwapPreview(this.ctx.api, params);
|
|
2036
|
+
});
|
|
1811
2037
|
}
|
|
1812
2038
|
async getStatus(params) {
|
|
1813
|
-
|
|
1814
|
-
|
|
2039
|
+
return this.log.wrap("getStatus", params, async () => {
|
|
2040
|
+
await this.ctx.ensureUserAuthenticated();
|
|
2041
|
+
return getSwapStatus(this.ctx.api, params);
|
|
2042
|
+
});
|
|
1815
2043
|
}
|
|
1816
2044
|
async getOutputToken(params) {
|
|
1817
|
-
|
|
1818
|
-
|
|
2045
|
+
return this.log.wrap("getOutputToken", params, async () => {
|
|
2046
|
+
await this.ctx.ensureUserAuthenticated();
|
|
2047
|
+
return getSwapOutputToken(this.ctx.api, params);
|
|
2048
|
+
});
|
|
1819
2049
|
}
|
|
1820
2050
|
async allowWallet(params) {
|
|
1821
|
-
|
|
1822
|
-
|
|
2051
|
+
return this.log.wrap("allowWallet", params, async () => {
|
|
2052
|
+
await this.ctx.ensureUserAuthenticated();
|
|
2053
|
+
return allowWallet(this.ctx.api, params);
|
|
2054
|
+
});
|
|
1823
2055
|
}
|
|
1824
2056
|
};
|
|
1825
2057
|
|
|
@@ -1856,18 +2088,25 @@ async function fetchOfferDetails(api, id, clientCreds) {
|
|
|
1856
2088
|
var OffersNamespaceImpl = class {
|
|
1857
2089
|
constructor(ctx) {
|
|
1858
2090
|
this.ctx = ctx;
|
|
2091
|
+
this.log = internalLogger(ctx.logger, "OFFERS");
|
|
1859
2092
|
}
|
|
1860
2093
|
async list() {
|
|
1861
|
-
|
|
1862
|
-
|
|
2094
|
+
return this.log.wrap("list", void 0, async () => {
|
|
2095
|
+
await this.ctx.ensureUserAuthenticated();
|
|
2096
|
+
return fetchOffers(this.ctx.api, void 0);
|
|
2097
|
+
});
|
|
1863
2098
|
}
|
|
1864
2099
|
async listPage(params) {
|
|
1865
|
-
|
|
1866
|
-
|
|
2100
|
+
return this.log.wrap("listPage", params, async () => {
|
|
2101
|
+
await this.ctx.ensureUserAuthenticated();
|
|
2102
|
+
return fetchOffersPage(this.ctx.api, params, void 0);
|
|
2103
|
+
});
|
|
1867
2104
|
}
|
|
1868
2105
|
async get(id) {
|
|
1869
|
-
|
|
1870
|
-
|
|
2106
|
+
return this.log.wrap("get", id, async () => {
|
|
2107
|
+
await this.ctx.ensureUserAuthenticated();
|
|
2108
|
+
return fetchOfferDetails(this.ctx.api, id, void 0);
|
|
2109
|
+
});
|
|
1871
2110
|
}
|
|
1872
2111
|
};
|
|
1873
2112
|
|
|
@@ -2000,38 +2239,49 @@ async function fetchRequirementStatuses(api, offerId) {
|
|
|
2000
2239
|
var RequirementsNamespaceImpl = class {
|
|
2001
2240
|
constructor(ctx) {
|
|
2002
2241
|
this.ctx = ctx;
|
|
2242
|
+
this.log = internalLogger(ctx.logger, "REQUIREMENTS");
|
|
2003
2243
|
}
|
|
2004
2244
|
async forOffer(offerId) {
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2245
|
+
return this.log.wrap("forOffer", offerId, async () => {
|
|
2246
|
+
await this.ctx.ensureUserAuthenticated();
|
|
2247
|
+
return fetchOfferRequirements(
|
|
2248
|
+
this.ctx.api,
|
|
2249
|
+
offerId,
|
|
2250
|
+
void 0
|
|
2251
|
+
);
|
|
2252
|
+
});
|
|
2011
2253
|
}
|
|
2012
2254
|
async statuses(offerId) {
|
|
2013
|
-
|
|
2014
|
-
|
|
2255
|
+
return this.log.wrap("statuses", offerId, async () => {
|
|
2256
|
+
await this.ctx.ensureUserAuthenticated();
|
|
2257
|
+
return fetchRequirementStatuses(this.ctx.api, offerId);
|
|
2258
|
+
});
|
|
2015
2259
|
}
|
|
2016
2260
|
async createKycToken(params) {
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2261
|
+
return this.log.wrap("createKycToken", params, async () => {
|
|
2262
|
+
await this.ctx.ensureUserAuthenticated();
|
|
2263
|
+
return createKycToken(
|
|
2264
|
+
this.ctx.api,
|
|
2265
|
+
params?.levelName,
|
|
2266
|
+
params?.reset
|
|
2267
|
+
);
|
|
2268
|
+
});
|
|
2023
2269
|
}
|
|
2024
2270
|
async getPii() {
|
|
2025
|
-
|
|
2026
|
-
|
|
2271
|
+
return this.log.wrap("getPii", void 0, async () => {
|
|
2272
|
+
await this.ctx.ensureUserAuthenticated();
|
|
2273
|
+
return fetchPii(this.ctx.api);
|
|
2274
|
+
});
|
|
2027
2275
|
}
|
|
2028
2276
|
async submitDocument(params) {
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2277
|
+
return this.log.wrap("submitDocument", params, async () => {
|
|
2278
|
+
await this.ctx.ensureUserAuthenticated();
|
|
2279
|
+
return submitDocument(
|
|
2280
|
+
this.ctx.api,
|
|
2281
|
+
params.documentType,
|
|
2282
|
+
params.fields
|
|
2283
|
+
);
|
|
2284
|
+
});
|
|
2035
2285
|
}
|
|
2036
2286
|
};
|
|
2037
2287
|
|
|
@@ -2043,9 +2293,11 @@ var HEADER_API_VERSION = "X-API-Version";
|
|
|
2043
2293
|
|
|
2044
2294
|
// src/shared/api/http-client.ts
|
|
2045
2295
|
var HttpClient = class {
|
|
2046
|
-
constructor(config, middleware = {}) {
|
|
2296
|
+
constructor(config, middleware = {}, logger = null, options = {}) {
|
|
2047
2297
|
this.config = config;
|
|
2048
2298
|
this.middleware = middleware;
|
|
2299
|
+
this.log = internalLogger(logger, "HTTP");
|
|
2300
|
+
this.makeRequestId = options.makeRequestId ?? defaultMakeRequestId;
|
|
2049
2301
|
}
|
|
2050
2302
|
async send(request) {
|
|
2051
2303
|
return this.runRequestWithAfterMiddleware(request);
|
|
@@ -2081,7 +2333,13 @@ var HttpClient = class {
|
|
|
2081
2333
|
return {
|
|
2082
2334
|
...request,
|
|
2083
2335
|
url,
|
|
2084
|
-
headers
|
|
2336
|
+
headers,
|
|
2337
|
+
// Only when absent: a retry or a post-renewal re-send arrives with the
|
|
2338
|
+
// first attempt's id already on it, and keeping it is the whole point.
|
|
2339
|
+
attributes: Attributes.getRequestId(request.attributes) === null ? Attributes.concat(
|
|
2340
|
+
request.attributes ?? Attributes.empty,
|
|
2341
|
+
Attributes.requestId(this.makeRequestId())
|
|
2342
|
+
) : request.attributes
|
|
2085
2343
|
};
|
|
2086
2344
|
}
|
|
2087
2345
|
/**
|
|
@@ -2105,10 +2363,89 @@ var HttpClient = class {
|
|
|
2105
2363
|
}
|
|
2106
2364
|
return request;
|
|
2107
2365
|
}
|
|
2108
|
-
|
|
2109
|
-
|
|
2366
|
+
/**
|
|
2367
|
+
* One physical attempt, logged as one line.
|
|
2368
|
+
*
|
|
2369
|
+
* A non-2xx is a `warn` rather than an `error` because the wire does not
|
|
2370
|
+
* know whether it is a failure: the retry middleware may turn a 503 into a
|
|
2371
|
+
* success, and the token registry reads a 404 as "not listed". The namespace
|
|
2372
|
+
* above decides, and logs the `error` when it does.
|
|
2373
|
+
*/
|
|
2374
|
+
async executeRequest(request) {
|
|
2375
|
+
const requestId2 = Attributes.getRequestId(request.attributes);
|
|
2376
|
+
const log = requestId2 === null ? this.log : this.log.child({ requestId: requestId2 });
|
|
2377
|
+
const attempt = Attributes.getRetryAttempt(request.attributes) + 1;
|
|
2378
|
+
const startedAt = Date.now();
|
|
2379
|
+
log.debug(() => ({
|
|
2380
|
+
msg: "request sent",
|
|
2381
|
+
fields: describeRequestUnredacted(request)
|
|
2382
|
+
}));
|
|
2383
|
+
try {
|
|
2384
|
+
const response = await makeRequest(request);
|
|
2385
|
+
const elapsed = Date.now() - startedAt;
|
|
2386
|
+
const outcome = () => ({
|
|
2387
|
+
msg: "request completed",
|
|
2388
|
+
fields: {
|
|
2389
|
+
...identifyRequest(request),
|
|
2390
|
+
"http.response.status_code": response.status,
|
|
2391
|
+
duration_ms: elapsed,
|
|
2392
|
+
attempt
|
|
2393
|
+
}
|
|
2394
|
+
});
|
|
2395
|
+
if (response.status >= 200 && response.status < 300) {
|
|
2396
|
+
log.info(outcome);
|
|
2397
|
+
} else {
|
|
2398
|
+
log.warn(outcome);
|
|
2399
|
+
}
|
|
2400
|
+
log.debug(() => ({
|
|
2401
|
+
msg: "response received",
|
|
2402
|
+
fields: { body: response.body }
|
|
2403
|
+
}));
|
|
2404
|
+
return requestId2 === null ? response : { ...response, requestId: requestId2 };
|
|
2405
|
+
} catch (error) {
|
|
2406
|
+
const elapsed = Date.now() - startedAt;
|
|
2407
|
+
log.warning(
|
|
2408
|
+
() => ({
|
|
2409
|
+
msg: "request threw",
|
|
2410
|
+
fields: {
|
|
2411
|
+
...identifyRequest(request),
|
|
2412
|
+
duration_ms: elapsed,
|
|
2413
|
+
attempt
|
|
2414
|
+
}
|
|
2415
|
+
}),
|
|
2416
|
+
error
|
|
2417
|
+
);
|
|
2418
|
+
throw error;
|
|
2419
|
+
}
|
|
2110
2420
|
}
|
|
2111
2421
|
};
|
|
2422
|
+
function identifyRequest(request) {
|
|
2423
|
+
const { host, path } = splitUrl(request.url);
|
|
2424
|
+
return {
|
|
2425
|
+
"http.request.method": request.method,
|
|
2426
|
+
"server.address": host,
|
|
2427
|
+
"url.path": path
|
|
2428
|
+
};
|
|
2429
|
+
}
|
|
2430
|
+
function splitUrl(url) {
|
|
2431
|
+
try {
|
|
2432
|
+
const parsed = new URL(url);
|
|
2433
|
+
return { host: parsed.host, path: parsed.pathname };
|
|
2434
|
+
} catch (_) {
|
|
2435
|
+
return { host: null, path: url };
|
|
2436
|
+
}
|
|
2437
|
+
}
|
|
2438
|
+
function defaultMakeRequestId() {
|
|
2439
|
+
return Math.random().toString(36).slice(2, 10).padEnd(8, "0");
|
|
2440
|
+
}
|
|
2441
|
+
function describeRequestUnredacted(request) {
|
|
2442
|
+
return {
|
|
2443
|
+
"http.request.method": request.method,
|
|
2444
|
+
"url.full": buildUrlWithQueryParams(request.url, request.queryParams),
|
|
2445
|
+
headers: request.headers,
|
|
2446
|
+
...request.method === "POST" ? { body: request.body } : {}
|
|
2447
|
+
};
|
|
2448
|
+
}
|
|
2112
2449
|
|
|
2113
2450
|
// src/shared/types/token-metadata.ts
|
|
2114
2451
|
var TokenLogoUrl = (value) => value;
|
|
@@ -2136,27 +2473,47 @@ var TokenMetadata = {
|
|
|
2136
2473
|
logoDark: dto.logo_dark === void 0 ? null : TokenLogo.fromDto(dto.logo_dark, baseUrl)
|
|
2137
2474
|
};
|
|
2138
2475
|
},
|
|
2476
|
+
/**
|
|
2477
|
+
* Maps the complete registry snapshot to every token it lists across the
|
|
2478
|
+
* chains this SDK models, skipping native coins and chains outside
|
|
2479
|
+
* {@link EthereumChain} (e.g. Solana) rather than failing on them — the
|
|
2480
|
+
* registry may serve chains ahead of the SDK's type surface.
|
|
2481
|
+
*/
|
|
2482
|
+
fromRegistryDto: (dto, baseUrl) => {
|
|
2483
|
+
assertSupportedSchemaVersion(dto.schema_version);
|
|
2484
|
+
return dto.chains.flatMap((chainDto) => {
|
|
2485
|
+
let chain;
|
|
2486
|
+
try {
|
|
2487
|
+
chain = EthereumChain(chainDto.chain);
|
|
2488
|
+
} catch {
|
|
2489
|
+
return [];
|
|
2490
|
+
}
|
|
2491
|
+
return tokensOfChain(chain, chainDto.assets, baseUrl);
|
|
2492
|
+
});
|
|
2493
|
+
},
|
|
2139
2494
|
/**
|
|
2140
2495
|
* Maps a chain snapshot to the tokens it lists, skipping the chain's native
|
|
2141
2496
|
* coin (`kind: 'COIN'`, no contract address).
|
|
2142
2497
|
*/
|
|
2143
2498
|
fromChainAssetsDto: (dto, baseUrl) => {
|
|
2144
2499
|
assertSupportedSchemaVersion(dto.schema_version);
|
|
2145
|
-
|
|
2146
|
-
return dto.assets.filter((asset) => asset.kind === "TOKEN" && asset.address !== void 0).map((asset) => ({
|
|
2147
|
-
identifier: {
|
|
2148
|
-
chain,
|
|
2149
|
-
// The filter above cannot narrow `address` for the type checker.
|
|
2150
|
-
address: EvmContractAddress(asset.address)
|
|
2151
|
-
},
|
|
2152
|
-
name: asset.name,
|
|
2153
|
-
symbol: AssetSymbol(asset.symbol),
|
|
2154
|
-
decimals: AssetDecimals(asset.decimals),
|
|
2155
|
-
logo: TokenLogo.fromDto(asset.logo, baseUrl),
|
|
2156
|
-
logoDark: asset.logo_dark === void 0 ? null : TokenLogo.fromDto(asset.logo_dark, baseUrl)
|
|
2157
|
-
}));
|
|
2500
|
+
return tokensOfChain(EthereumChain(dto.chain), dto.assets, baseUrl);
|
|
2158
2501
|
}
|
|
2159
2502
|
};
|
|
2503
|
+
function tokensOfChain(chain, assets, baseUrl) {
|
|
2504
|
+
return assets.filter((asset) => asset.kind === "TOKEN" && asset.address !== void 0).map((asset) => ({
|
|
2505
|
+
identifier: {
|
|
2506
|
+
chain,
|
|
2507
|
+
// The filter above cannot narrow `address` for the type checker.
|
|
2508
|
+
address: EvmContractAddress(asset.address)
|
|
2509
|
+
},
|
|
2510
|
+
name: asset.name,
|
|
2511
|
+
symbol: AssetSymbol(asset.symbol),
|
|
2512
|
+
decimals: AssetDecimals(asset.decimals),
|
|
2513
|
+
logo: TokenLogo.fromDto(asset.logo, baseUrl),
|
|
2514
|
+
logoDark: asset.logo_dark === void 0 ? null : TokenLogo.fromDto(asset.logo_dark, baseUrl)
|
|
2515
|
+
}));
|
|
2516
|
+
}
|
|
2160
2517
|
function assertSupportedSchemaVersion(version) {
|
|
2161
2518
|
if (version !== 1) {
|
|
2162
2519
|
throw new ValidationError(
|
|
@@ -2174,8 +2531,8 @@ var resolveLogoUrl = (url, baseUrl) => TokenLogoUrl(
|
|
|
2174
2531
|
);
|
|
2175
2532
|
|
|
2176
2533
|
// src/shared/api/nabu/tokens.ts
|
|
2177
|
-
function createNabuApiClient(baseUrl) {
|
|
2178
|
-
return new HttpClient({ baseUrl });
|
|
2534
|
+
function createNabuApiClient(baseUrl, logger = null) {
|
|
2535
|
+
return new HttpClient({ baseUrl }, {}, logger);
|
|
2179
2536
|
}
|
|
2180
2537
|
async function fetchTokenMetadata(client, token) {
|
|
2181
2538
|
const address = checksummed(token.address);
|
|
@@ -2225,6 +2582,29 @@ async function fetchTokensMetadata(client, chain) {
|
|
|
2225
2582
|
}
|
|
2226
2583
|
return TokenMetadata.fromChainAssetsDto(response.body, client.config.baseUrl);
|
|
2227
2584
|
}
|
|
2585
|
+
async function fetchAllTokensMetadata(client) {
|
|
2586
|
+
let response;
|
|
2587
|
+
try {
|
|
2588
|
+
response = await client.send({
|
|
2589
|
+
method: "GET",
|
|
2590
|
+
url: `/assets.json`
|
|
2591
|
+
});
|
|
2592
|
+
} catch (error) {
|
|
2593
|
+
if (isRegistryHtmlFallback(error)) {
|
|
2594
|
+
throw new ValidationError(
|
|
2595
|
+
"Token registry returned non-JSON for the complete snapshot"
|
|
2596
|
+
);
|
|
2597
|
+
}
|
|
2598
|
+
throw error;
|
|
2599
|
+
}
|
|
2600
|
+
assertOk(response);
|
|
2601
|
+
if (response.body === null) {
|
|
2602
|
+
throw new ValidationError(
|
|
2603
|
+
"Token registry returned an empty complete snapshot"
|
|
2604
|
+
);
|
|
2605
|
+
}
|
|
2606
|
+
return TokenMetadata.fromRegistryDto(response.body, client.config.baseUrl);
|
|
2607
|
+
}
|
|
2228
2608
|
function isRegistryHtmlFallback(error) {
|
|
2229
2609
|
return error instanceof HttpError && error.response.status >= 200 && error.response.status < 300;
|
|
2230
2610
|
}
|
|
@@ -2248,14 +2628,23 @@ var TokensNamespaceImpl = class {
|
|
|
2248
2628
|
* registry is unauthenticated and on its own host, so the frontline sender
|
|
2249
2629
|
* and the auth check would both be dead weight here.
|
|
2250
2630
|
*/
|
|
2251
|
-
constructor(baseUrl) {
|
|
2252
|
-
this.api = createNabuApiClient(baseUrl);
|
|
2631
|
+
constructor(baseUrl, logger = null) {
|
|
2632
|
+
this.api = createNabuApiClient(baseUrl, logger);
|
|
2633
|
+
this.log = internalLogger(logger, "TOKENS");
|
|
2253
2634
|
}
|
|
2254
2635
|
get(token) {
|
|
2255
|
-
return
|
|
2636
|
+
return this.log.wrap(
|
|
2637
|
+
"get",
|
|
2638
|
+
token,
|
|
2639
|
+
() => fetchTokenMetadata(this.api, token)
|
|
2640
|
+
);
|
|
2256
2641
|
}
|
|
2257
2642
|
list(chain) {
|
|
2258
|
-
return
|
|
2643
|
+
return this.log.wrap(
|
|
2644
|
+
"list",
|
|
2645
|
+
chain,
|
|
2646
|
+
() => chain === void 0 ? fetchAllTokensMetadata(this.api) : fetchTokensMetadata(this.api, chain)
|
|
2647
|
+
);
|
|
2259
2648
|
}
|
|
2260
2649
|
};
|
|
2261
2650
|
|
|
@@ -2361,36 +2750,50 @@ async function removeOptionAddress(api, offerId, addressId) {
|
|
|
2361
2750
|
var WalletsNamespaceImpl = class {
|
|
2362
2751
|
constructor(ctx) {
|
|
2363
2752
|
this.ctx = ctx;
|
|
2753
|
+
this.log = internalLogger(ctx.logger, "WALLETS");
|
|
2364
2754
|
}
|
|
2365
2755
|
async createOwnershipChallenge(params) {
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2756
|
+
return this.log.wrap("createOwnershipChallenge", params, async () => {
|
|
2757
|
+
await this.ctx.ensureUserAuthenticated();
|
|
2758
|
+
return createWalletOwnershipChallenge(
|
|
2759
|
+
this.ctx.api,
|
|
2760
|
+
params
|
|
2761
|
+
);
|
|
2762
|
+
});
|
|
2371
2763
|
}
|
|
2372
2764
|
async connectExternal(params) {
|
|
2373
|
-
|
|
2374
|
-
|
|
2765
|
+
return this.log.wrap("connectExternal", params, async () => {
|
|
2766
|
+
await this.ctx.ensureUserAuthenticated();
|
|
2767
|
+
return connectExternalWallet(this.ctx.api, params);
|
|
2768
|
+
});
|
|
2375
2769
|
}
|
|
2376
2770
|
async list(params) {
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2771
|
+
return this.log.wrap("list", params, async () => {
|
|
2772
|
+
await this.ctx.ensureUserAuthenticated();
|
|
2773
|
+
return listOptionAddresses(
|
|
2774
|
+
this.ctx.api,
|
|
2775
|
+
params.offerId,
|
|
2776
|
+
params.offerOptionId
|
|
2777
|
+
);
|
|
2778
|
+
});
|
|
2383
2779
|
}
|
|
2384
2780
|
async remove(params) {
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2781
|
+
return this.log.wrap("remove", params, async () => {
|
|
2782
|
+
await this.ctx.ensureUserAuthenticated();
|
|
2783
|
+
return removeOptionAddress(
|
|
2784
|
+
this.ctx.api,
|
|
2785
|
+
params.offerId,
|
|
2786
|
+
params.addressId
|
|
2787
|
+
);
|
|
2788
|
+
});
|
|
2391
2789
|
}
|
|
2392
2790
|
};
|
|
2393
2791
|
|
|
2792
|
+
// src/shared/types/blockchain/wallet-error.ts
|
|
2793
|
+
var RedactedWalletError = {
|
|
2794
|
+
fromWalletError: (error) => error.type === "unknown" ? { type: "unknown" } : error
|
|
2795
|
+
};
|
|
2796
|
+
|
|
2394
2797
|
// src/shared/types/oauth-session.ts
|
|
2395
2798
|
var ClientCredentialsOAuth = (value) => value;
|
|
2396
2799
|
var OAuthRefreshToken = (value) => value;
|
|
@@ -2458,6 +2861,7 @@ var User = {
|
|
|
2458
2861
|
FormattedPercentUi,
|
|
2459
2862
|
HexEncodedTransactionData,
|
|
2460
2863
|
HttpError,
|
|
2864
|
+
InvariantError,
|
|
2461
2865
|
Iso2CountryCode,
|
|
2462
2866
|
KnownAssetSymbol,
|
|
2463
2867
|
KycToken,
|
|
@@ -2497,6 +2901,7 @@ var User = {
|
|
|
2497
2901
|
Pii,
|
|
2498
2902
|
PiiAddress,
|
|
2499
2903
|
PiiJurisdiction,
|
|
2904
|
+
RedactedWalletError,
|
|
2500
2905
|
RedirectUri,
|
|
2501
2906
|
Requirement,
|
|
2502
2907
|
RequirementId,
|
|
@@ -2562,6 +2967,7 @@ var User = {
|
|
|
2562
2967
|
isStopped,
|
|
2563
2968
|
ondoSwapContractAddress,
|
|
2564
2969
|
parseBlockchainAmount,
|
|
2970
|
+
parseUint256,
|
|
2565
2971
|
shortenAddress,
|
|
2566
2972
|
superstateSwapContractAddress,
|
|
2567
2973
|
txExplorerUrl,
|