@coinlist-co/react 0.12.2-rc.7b430dd → 0.12.2-rc.9fb6364
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-MOE5S6CE.js → chunk-BNMF2HMW.js} +114 -4
- package/dist/chunk-BNMF2HMW.js.map +1 -0
- package/dist/{chunk-VH34YC3Q.js → chunk-KRA6EM2L.js} +2 -2
- package/dist/{chunk-DCW7NQXH.js → chunk-STAHYDLY.js} +52 -19
- package/dist/chunk-STAHYDLY.js.map +1 -0
- package/dist/client/index.cjs +322 -96
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +26 -10
- package/dist/client/index.d.ts +26 -10
- package/dist/client/index.js +225 -102
- package/dist/client/index.js.map +1 -1
- package/dist/server/index.cjs +437 -76
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +47 -38
- package/dist/server/index.d.ts +47 -38
- package/dist/server/index.js +316 -61
- package/dist/server/index.js.map +1 -1
- package/dist/time-B5YOQxuh.d.ts +50 -0
- package/dist/time-BY3apBpc.d.cts +50 -0
- package/dist/{token-registry-snapshot-BNBNuDu1.d.ts → token-registry-snapshot-C1NxdBmF.d.ts} +1 -1
- package/dist/{token-registry-snapshot-CqI6dXM_.d.cts → token-registry-snapshot-DyjrA32p.d.cts} +1 -1
- package/dist/{tokens-namespace-CIWBtgt2.d.cts → tokens-namespace-BJfFeowE.d.cts} +53 -1
- package/dist/{tokens-namespace-CIWBtgt2.d.ts → tokens-namespace-BJfFeowE.d.ts} +53 -1
- package/dist/universal/index.cjs +100 -3
- package/dist/universal/index.cjs.map +1 -1
- package/dist/universal/index.d.cts +23 -5
- package/dist/universal/index.d.ts +23 -5
- package/dist/universal/index.js +12 -2
- package/package.json +1 -1
- package/dist/chunk-DCW7NQXH.js.map +0 -1
- package/dist/chunk-MOE5S6CE.js.map +0 -1
- /package/dist/{chunk-VH34YC3Q.js.map → chunk-KRA6EM2L.js.map} +0 -0
package/dist/client/index.cjs
CHANGED
|
@@ -248,6 +248,30 @@ var VERIFY_IDENTITY_PATH = "/verify-identity";
|
|
|
248
248
|
var VERIFY_IDENTITY_ACCREDITATION_PATH = "/verify-identity/accreditation_full";
|
|
249
249
|
var WALLET_PATH = "/wallet";
|
|
250
250
|
|
|
251
|
+
// src/universal/api/internal-access-token-source.ts
|
|
252
|
+
var SentWith = {
|
|
253
|
+
userToken: (token) => ({
|
|
254
|
+
type: "user-token",
|
|
255
|
+
token
|
|
256
|
+
}),
|
|
257
|
+
noUserToken: { type: "no-user-token" }
|
|
258
|
+
};
|
|
259
|
+
var TokenTrigger = {
|
|
260
|
+
beforeRequest: { type: "before-request" },
|
|
261
|
+
after401: (rejected) => ({
|
|
262
|
+
type: "after-401",
|
|
263
|
+
rejected
|
|
264
|
+
})
|
|
265
|
+
};
|
|
266
|
+
function isRejectedToken(token, rejected) {
|
|
267
|
+
switch (rejected.type) {
|
|
268
|
+
case "user-token":
|
|
269
|
+
return rejected.token.value === token.value;
|
|
270
|
+
case "no-user-token":
|
|
271
|
+
return false;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
251
275
|
// src/universal/api/http-attributes.ts
|
|
252
276
|
var empty = {};
|
|
253
277
|
var concat = (left, right) => ({
|
|
@@ -275,6 +299,10 @@ var retryAttempt = (attempt) => ({
|
|
|
275
299
|
var renewAttempted = (value) => ({
|
|
276
300
|
renewAttempted: value
|
|
277
301
|
});
|
|
302
|
+
var notRetryable = () => ({ retryable: false });
|
|
303
|
+
var sentWith = (token) => ({
|
|
304
|
+
sentWith: token
|
|
305
|
+
});
|
|
278
306
|
var requestId = (id) => ({ requestId: id });
|
|
279
307
|
var getRequestId = (attrs) => attrs?.requestId ?? null;
|
|
280
308
|
var isProtected = (attrs) => attrs?.protected === true;
|
|
@@ -282,6 +310,8 @@ var needUserAgent = (attrs) => attrs?.userAgent === true;
|
|
|
282
310
|
var isIdempotent = (attrs) => attrs?.idempotencyKey === true;
|
|
283
311
|
var getRetryAttempt = (attrs) => attrs?.retryAttempt ?? 0;
|
|
284
312
|
var wasRenewAttempted = (attrs) => attrs?.renewAttempted === true;
|
|
313
|
+
var isRetryable = (attrs) => attrs?.retryable !== false;
|
|
314
|
+
var getSentWith = (attrs) => attrs?.sentWith === void 0 ? SentWith.noUserToken : SentWith.userToken(attrs.sentWith);
|
|
285
315
|
var getClientCredentials = (attrs) => attrs?.clientCredentials;
|
|
286
316
|
var Attributes = {
|
|
287
317
|
empty,
|
|
@@ -297,6 +327,10 @@ var Attributes = {
|
|
|
297
327
|
getRetryAttempt,
|
|
298
328
|
renewAttempted,
|
|
299
329
|
wasRenewAttempted,
|
|
330
|
+
notRetryable,
|
|
331
|
+
isRetryable,
|
|
332
|
+
sentWith,
|
|
333
|
+
getSentWith,
|
|
300
334
|
clientCredentials,
|
|
301
335
|
getClientCredentials,
|
|
302
336
|
requestId,
|
|
@@ -684,11 +718,18 @@ var HttpClient = class {
|
|
|
684
718
|
);
|
|
685
719
|
let response = await this.executeRequest(preparedRequest);
|
|
686
720
|
for (const middleware of this.middleware.afterRequest ?? []) {
|
|
721
|
+
let retried = false;
|
|
687
722
|
response = await middleware({
|
|
688
723
|
request: preparedRequest,
|
|
689
724
|
response,
|
|
690
|
-
retry: (nextRequest = preparedRequest) =>
|
|
725
|
+
retry: (nextRequest = preparedRequest) => {
|
|
726
|
+
retried = true;
|
|
727
|
+
return this.runRequestWithAfterMiddleware(nextRequest);
|
|
728
|
+
}
|
|
691
729
|
});
|
|
730
|
+
if (retried) {
|
|
731
|
+
return response;
|
|
732
|
+
}
|
|
692
733
|
}
|
|
693
734
|
return response;
|
|
694
735
|
}
|
|
@@ -821,23 +862,33 @@ function attachSessionMiddleware(fetchAccessToken) {
|
|
|
821
862
|
if (!Attributes.isProtected(request.attributes)) {
|
|
822
863
|
return request;
|
|
823
864
|
}
|
|
824
|
-
|
|
825
|
-
if (
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
865
|
+
const userToken = await fetchAccessToken(TokenTrigger.beforeRequest);
|
|
866
|
+
if (userToken !== null) {
|
|
867
|
+
return withBearer(
|
|
868
|
+
{
|
|
869
|
+
...request,
|
|
870
|
+
attributes: Attributes.concat(
|
|
871
|
+
request.attributes ?? Attributes.empty,
|
|
872
|
+
Attributes.sentWith(userToken)
|
|
873
|
+
)
|
|
874
|
+
},
|
|
875
|
+
userToken.value
|
|
876
|
+
);
|
|
830
877
|
}
|
|
831
|
-
|
|
832
|
-
|
|
878
|
+
const clientCreds = Attributes.getClientCredentials(request.attributes);
|
|
879
|
+
if (clientCreds) {
|
|
880
|
+
return withBearer(request, clientCreds.value);
|
|
881
|
+
}
|
|
882
|
+
return request;
|
|
883
|
+
};
|
|
884
|
+
}
|
|
885
|
+
function withBearer(request, token) {
|
|
886
|
+
return {
|
|
887
|
+
...request,
|
|
888
|
+
headers: {
|
|
889
|
+
...request.headers ?? {},
|
|
890
|
+
Authorization: `Bearer ${token}`
|
|
833
891
|
}
|
|
834
|
-
return {
|
|
835
|
-
...request,
|
|
836
|
-
headers: {
|
|
837
|
-
...request.headers ?? {},
|
|
838
|
-
Authorization: `Bearer ${accessToken.value}`
|
|
839
|
-
}
|
|
840
|
-
};
|
|
841
892
|
};
|
|
842
893
|
}
|
|
843
894
|
|
|
@@ -873,7 +924,7 @@ function getRetryDelayMs(attempt) {
|
|
|
873
924
|
function createRequestRetryMiddleware(options = {}) {
|
|
874
925
|
const delayFn = options.delayFn ?? defaultDelay;
|
|
875
926
|
return async ({ request, response, retry }) => {
|
|
876
|
-
if (!isRetryableStatus(response.status)) {
|
|
927
|
+
if (!isRetryableStatus(response.status) || !Attributes.isRetryable(request.attributes)) {
|
|
877
928
|
return response;
|
|
878
929
|
}
|
|
879
930
|
const currentAttempt = Attributes.getRetryAttempt(request.attributes);
|
|
@@ -906,7 +957,9 @@ function renewSessionMiddleware(fetchAccessToken) {
|
|
|
906
957
|
if (Attributes.wasRenewAttempted(request.attributes)) {
|
|
907
958
|
return response;
|
|
908
959
|
}
|
|
909
|
-
const newToken = await fetchAccessToken(
|
|
960
|
+
const newToken = await fetchAccessToken(
|
|
961
|
+
TokenTrigger.after401(Attributes.getSentWith(request.attributes))
|
|
962
|
+
);
|
|
910
963
|
if (newToken) {
|
|
911
964
|
const nextRequest = Request.concatAttributes(
|
|
912
965
|
request,
|
|
@@ -963,6 +1016,196 @@ var ApiClient = class {
|
|
|
963
1016
|
}
|
|
964
1017
|
};
|
|
965
1018
|
|
|
1019
|
+
// src/universal/core/auth/session-expired.ts
|
|
1020
|
+
function notifySessionExpired(onSessionExpired, log) {
|
|
1021
|
+
if (onSessionExpired === void 0) {
|
|
1022
|
+
return;
|
|
1023
|
+
}
|
|
1024
|
+
Promise.resolve().then(onSessionExpired).catch(
|
|
1025
|
+
(error) => log.failure(() => ({ msg: "onSessionExpired threw" }), error)
|
|
1026
|
+
);
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
// src/universal/types/time.ts
|
|
1030
|
+
var MAX_EPOCH_MILLIS = 864e13;
|
|
1031
|
+
var EpochMillis = {
|
|
1032
|
+
/**
|
|
1033
|
+
* @throws {@link ValidationError} unless `value` is an integer a `Date` can
|
|
1034
|
+
* represent: at most {@link MAX_EPOCH_MILLIS} either side of the epoch.
|
|
1035
|
+
*/
|
|
1036
|
+
of: (value) => {
|
|
1037
|
+
if (!Number.isInteger(value) || Math.abs(value) > MAX_EPOCH_MILLIS) {
|
|
1038
|
+
throw new ValidationError(
|
|
1039
|
+
`EpochMillis must be an integer within \xB1${MAX_EPOCH_MILLIS}, got ${value}`
|
|
1040
|
+
);
|
|
1041
|
+
}
|
|
1042
|
+
return value;
|
|
1043
|
+
},
|
|
1044
|
+
/** The wall clock. Code that needs the time takes a `TimeEff` instead. */
|
|
1045
|
+
now: () => EpochMillis.of(Date.now()),
|
|
1046
|
+
/** @throws {@link ValidationError} for an invalid `Date`. */
|
|
1047
|
+
fromDate: (date) => EpochMillis.of(date.getTime()),
|
|
1048
|
+
/** How long after `from` the instant `to` is; negative if it is before. */
|
|
1049
|
+
elapsed: (from, to) => Millis.of(to - from),
|
|
1050
|
+
plus: (at, duration) => EpochMillis.of(at + duration)
|
|
1051
|
+
};
|
|
1052
|
+
var Millis = {
|
|
1053
|
+
of: (value) => value
|
|
1054
|
+
};
|
|
1055
|
+
|
|
1056
|
+
// src/client/core/auth/client-access-token.ts
|
|
1057
|
+
var CONFIRM_DELAY = Millis.of(1e3);
|
|
1058
|
+
var Generation = {
|
|
1059
|
+
initial: 0,
|
|
1060
|
+
next: (generation) => generation + 1
|
|
1061
|
+
};
|
|
1062
|
+
var ClientAccessToken = class {
|
|
1063
|
+
constructor(env) {
|
|
1064
|
+
this.env = env;
|
|
1065
|
+
this.state = { type: "unknown" };
|
|
1066
|
+
this.hostCall = null;
|
|
1067
|
+
/**
|
|
1068
|
+
* Bumped by {@link clear}. A host call that started before a logout must not
|
|
1069
|
+
* log the user back in when it lands, so every write checks it first. A 401
|
|
1070
|
+
* that arrives after the logout never starts one: `'logged-out'` refuses it.
|
|
1071
|
+
*/
|
|
1072
|
+
this.generation = Generation.initial;
|
|
1073
|
+
this.log = internalLogger(env.logger, "AUTH").child({
|
|
1074
|
+
op: "getAccessToken"
|
|
1075
|
+
});
|
|
1076
|
+
}
|
|
1077
|
+
authState() {
|
|
1078
|
+
return this.state.type;
|
|
1079
|
+
}
|
|
1080
|
+
/**
|
|
1081
|
+
* Asks the host for the current token, whatever is cached.
|
|
1082
|
+
*
|
|
1083
|
+
* Never answers from a host call already in flight: one started before a
|
|
1084
|
+
* login (the mount's `init()`, racing the OAuth callback's) would hand back
|
|
1085
|
+
* the answer from before the session cookie existed. It waits for that call
|
|
1086
|
+
* to settle instead, so that call's verdict still lands, then asks afresh.
|
|
1087
|
+
* A logout while it waits still wins.
|
|
1088
|
+
*
|
|
1089
|
+
* @throws whatever the host's `getAccessToken` throws.
|
|
1090
|
+
*/
|
|
1091
|
+
async load() {
|
|
1092
|
+
const generation = this.generation;
|
|
1093
|
+
if (this.hostCall !== null) {
|
|
1094
|
+
await this.hostCall.catch(() => null);
|
|
1095
|
+
}
|
|
1096
|
+
await this.ask(SentWith.noUserToken, generation);
|
|
1097
|
+
return this.authState();
|
|
1098
|
+
}
|
|
1099
|
+
/**
|
|
1100
|
+
* The HTTP pipeline's token source: see {@link TokenTrigger}.
|
|
1101
|
+
*
|
|
1102
|
+
* @throws whatever the host's `getAccessToken` throws.
|
|
1103
|
+
*/
|
|
1104
|
+
async get(trigger) {
|
|
1105
|
+
const decision = decideToken(this.state, trigger);
|
|
1106
|
+
switch (decision.type) {
|
|
1107
|
+
case "serve":
|
|
1108
|
+
return decision.token;
|
|
1109
|
+
case "ask":
|
|
1110
|
+
return this.ask(decision.rejected, this.generation);
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
/** Forgets the token: `auth.logout()`. Never an expiry, so never notifies. */
|
|
1114
|
+
clear() {
|
|
1115
|
+
this.generation = Generation.next(this.generation);
|
|
1116
|
+
this.hostCall = null;
|
|
1117
|
+
this.state = { type: "logged-out" };
|
|
1118
|
+
}
|
|
1119
|
+
/**
|
|
1120
|
+
* A request that carried no user token was not refused for a token, so the
|
|
1121
|
+
* host's first answer stands. One that was is confirmed before it is
|
|
1122
|
+
* believed.
|
|
1123
|
+
*/
|
|
1124
|
+
async ask(rejected, generation) {
|
|
1125
|
+
if (generation !== this.generation) {
|
|
1126
|
+
return currentToken(this.state);
|
|
1127
|
+
}
|
|
1128
|
+
const first = await this.callHost();
|
|
1129
|
+
switch (rejected.type) {
|
|
1130
|
+
case "no-user-token":
|
|
1131
|
+
return this.commit(first, generation);
|
|
1132
|
+
case "user-token":
|
|
1133
|
+
return isFresh(first, rejected) ? this.commit(first, generation) : this.confirm(rejected, generation);
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
async confirm(rejected, generation) {
|
|
1137
|
+
this.log.warn(() => ({
|
|
1138
|
+
msg: "host returned no fresh token; asking again before signing out"
|
|
1139
|
+
}));
|
|
1140
|
+
await this.env.delay(CONFIRM_DELAY);
|
|
1141
|
+
const second = await this.callHost();
|
|
1142
|
+
return isFresh(second, rejected) ? this.commit(second, generation) : this.expire(generation);
|
|
1143
|
+
}
|
|
1144
|
+
/** The host's `getAccessToken`, joining a call already in flight. */
|
|
1145
|
+
callHost() {
|
|
1146
|
+
if (this.hostCall !== null) {
|
|
1147
|
+
this.log.debug(() => ({ msg: "joined a host call already in flight" }));
|
|
1148
|
+
return this.hostCall;
|
|
1149
|
+
}
|
|
1150
|
+
const call = (async () => this.env.getAccessToken())().finally(() => {
|
|
1151
|
+
if (this.hostCall === call) {
|
|
1152
|
+
this.hostCall = null;
|
|
1153
|
+
}
|
|
1154
|
+
});
|
|
1155
|
+
this.hostCall = call;
|
|
1156
|
+
return call;
|
|
1157
|
+
}
|
|
1158
|
+
commit(token, generation) {
|
|
1159
|
+
if (generation !== this.generation) {
|
|
1160
|
+
return currentToken(this.state);
|
|
1161
|
+
}
|
|
1162
|
+
this.state = token === null ? { type: "logged-out" } : { type: "logged-in", token };
|
|
1163
|
+
return token;
|
|
1164
|
+
}
|
|
1165
|
+
expire(generation) {
|
|
1166
|
+
if (generation !== this.generation) {
|
|
1167
|
+
return null;
|
|
1168
|
+
}
|
|
1169
|
+
const wasLoggedIn = this.state.type === "logged-in";
|
|
1170
|
+
this.state = { type: "logged-out" };
|
|
1171
|
+
if (wasLoggedIn) {
|
|
1172
|
+
this.log.info(() => ({ msg: "session expired" }));
|
|
1173
|
+
notifySessionExpired(this.env.onSessionExpired, this.log);
|
|
1174
|
+
}
|
|
1175
|
+
return null;
|
|
1176
|
+
}
|
|
1177
|
+
};
|
|
1178
|
+
function decideToken(state, trigger) {
|
|
1179
|
+
switch (trigger.type) {
|
|
1180
|
+
case "before-request":
|
|
1181
|
+
return state.type === "unknown" ? { type: "ask", rejected: SentWith.noUserToken } : { type: "serve", token: currentToken(state) };
|
|
1182
|
+
case "after-401":
|
|
1183
|
+
switch (state.type) {
|
|
1184
|
+
// A logout or an expiry verdict: only `load()` may log back in, so a
|
|
1185
|
+
// 401 to a request sent before it must not ask the host again.
|
|
1186
|
+
case "logged-out":
|
|
1187
|
+
return { type: "serve", token: null };
|
|
1188
|
+
// Another request may already have renewed since this one was sent.
|
|
1189
|
+
case "logged-in":
|
|
1190
|
+
return isRejectedToken(state.token, trigger.rejected) ? { type: "ask", rejected: trigger.rejected } : { type: "serve", token: state.token };
|
|
1191
|
+
case "unknown":
|
|
1192
|
+
return { type: "ask", rejected: trigger.rejected };
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
function currentToken(state) {
|
|
1197
|
+
switch (state.type) {
|
|
1198
|
+
case "logged-in":
|
|
1199
|
+
return state.token;
|
|
1200
|
+
case "unknown":
|
|
1201
|
+
case "logged-out":
|
|
1202
|
+
return null;
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
function isFresh(token, rejected) {
|
|
1206
|
+
return token !== null && !isRejectedToken(token, rejected);
|
|
1207
|
+
}
|
|
1208
|
+
|
|
966
1209
|
// src/universal/types/oauth.ts
|
|
967
1210
|
var AuthorizationCode = (value) => value;
|
|
968
1211
|
var CodeVerifier = (value) => value;
|
|
@@ -1939,7 +2182,11 @@ function formatAmount(amount, locale, options) {
|
|
|
1939
2182
|
const decimal = formatRawAmount(amount);
|
|
1940
2183
|
let [integerPart, fractionPart = ""] = decimal.split(".");
|
|
1941
2184
|
const maxFractionDigits = options?.maxFractionDigits;
|
|
1942
|
-
const minFractionDigits =
|
|
2185
|
+
const minFractionDigits = Math.min(
|
|
2186
|
+
options?.minFractionDigits ?? (maxFractionDigits !== void 0 ? maxFractionDigits : 2),
|
|
2187
|
+
maxFractionDigits ?? amount.decimals,
|
|
2188
|
+
amount.decimals
|
|
2189
|
+
);
|
|
1943
2190
|
if (maxFractionDigits !== void 0 && fractionPart.length > maxFractionDigits) {
|
|
1944
2191
|
({ integerPart, fractionPart } = roundFractionHalfUp(
|
|
1945
2192
|
integerPart,
|
|
@@ -1947,7 +2194,8 @@ function formatAmount(amount, locale, options) {
|
|
|
1947
2194
|
maxFractionDigits
|
|
1948
2195
|
));
|
|
1949
2196
|
}
|
|
1950
|
-
const
|
|
2197
|
+
const trimmed = fractionPart.replace(/0+$/, "");
|
|
2198
|
+
const fraction = trimmed.padEnd(minFractionDigits, "0");
|
|
1951
2199
|
const integerFormatted = BigInt(integerPart).toLocaleString(locale);
|
|
1952
2200
|
if (minFractionDigits === 0 && fraction === "") {
|
|
1953
2201
|
return FormattedAmountUi(integerFormatted);
|
|
@@ -2008,6 +2256,14 @@ function assetAmount(amount, symbol) {
|
|
|
2008
2256
|
return FormattedAmountAssetUi(`${amount} ${symbol}`);
|
|
2009
2257
|
}
|
|
2010
2258
|
var NA_AMOUNT_ASSET_UI = FormattedAmountAssetUi("-");
|
|
2259
|
+
var SHARE_MAX_FRACTION_DIGITS = AssetDecimals(6);
|
|
2260
|
+
var SHARE_MIN_FRACTION_DIGITS = AssetDecimals(2);
|
|
2261
|
+
function formatShareAmount(amount, locale) {
|
|
2262
|
+
return formatAmount(amount, locale, {
|
|
2263
|
+
maxFractionDigits: SHARE_MAX_FRACTION_DIGITS,
|
|
2264
|
+
minFractionDigits: SHARE_MIN_FRACTION_DIGITS
|
|
2265
|
+
});
|
|
2266
|
+
}
|
|
2011
2267
|
var USD_FRACTION_DIGITS = AssetDecimals(2);
|
|
2012
2268
|
function formattedUsdPrice(amount, locale) {
|
|
2013
2269
|
if (!amount) return NA_AMOUNT_ASSET_UI;
|
|
@@ -4951,37 +5207,46 @@ function transportFor(api, override, chain, logger) {
|
|
|
4951
5207
|
return typeof override === "string" ? (0, import_viem8.http)(override) : override;
|
|
4952
5208
|
}
|
|
4953
5209
|
|
|
5210
|
+
// src/universal/core/shared/effects.ts
|
|
5211
|
+
var systemTime = { time: { now: EpochMillis.now } };
|
|
5212
|
+
var systemDelay = {
|
|
5213
|
+
delay: (duration) => new Promise((resolve) => setTimeout(resolve, duration))
|
|
5214
|
+
};
|
|
5215
|
+
|
|
4954
5216
|
// src/client/core/coinlist-client.ts
|
|
4955
5217
|
var CoinListClientImpl = class {
|
|
4956
|
-
constructor(
|
|
4957
|
-
this.
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
5218
|
+
constructor(config) {
|
|
5219
|
+
this.config = config;
|
|
5220
|
+
const logger = config.logger ?? null;
|
|
5221
|
+
const accessToken = new ClientAccessToken({
|
|
5222
|
+
getAccessToken: () => config.getAccessToken(),
|
|
5223
|
+
onSessionExpired: config.onSessionExpired,
|
|
5224
|
+
logger,
|
|
5225
|
+
...systemDelay
|
|
5226
|
+
});
|
|
5227
|
+
this.accessToken = accessToken;
|
|
4961
5228
|
this.api = new ApiClient(
|
|
4962
5229
|
{
|
|
4963
|
-
baseUrl:
|
|
5230
|
+
baseUrl: config.baseUrl || PUBLIC_API_BASE_URL,
|
|
4964
5231
|
xApiVersion: API_VERSION
|
|
4965
5232
|
},
|
|
4966
|
-
|
|
5233
|
+
(trigger) => accessToken.get(trigger),
|
|
4967
5234
|
logger
|
|
4968
5235
|
);
|
|
4969
5236
|
const ctx = {
|
|
4970
5237
|
api: this.api,
|
|
4971
|
-
rpc: publicClients(this.api,
|
|
5238
|
+
rpc: publicClients(this.api, config.rpc, config.logger ?? null),
|
|
4972
5239
|
logger,
|
|
4973
5240
|
ensureUserAuthenticated: async () => this.ensureAuthenticated()
|
|
4974
5241
|
};
|
|
4975
|
-
this.auth = new ClientAuthNamespaceImpl(
|
|
4976
|
-
getState: () =>
|
|
4977
|
-
clearAccessToken: () =>
|
|
4978
|
-
this._accessToken = null;
|
|
4979
|
-
}
|
|
5242
|
+
this.auth = new ClientAuthNamespaceImpl(config, {
|
|
5243
|
+
getState: () => accessToken.authState(),
|
|
5244
|
+
clearAccessToken: () => accessToken.clear()
|
|
4980
5245
|
});
|
|
4981
5246
|
this.offers = new OffersNamespaceImpl(ctx);
|
|
4982
5247
|
this.requirements = new ClientRequirementsNamespaceImpl(
|
|
4983
5248
|
ctx,
|
|
4984
|
-
|
|
5249
|
+
config.coinlistBaseUrl
|
|
4985
5250
|
);
|
|
4986
5251
|
this.wallets = new WalletsNamespaceImpl(ctx);
|
|
4987
5252
|
this.erc20 = new Erc20NamespaceImpl(ctx);
|
|
@@ -4993,34 +5258,16 @@ var CoinListClientImpl = class {
|
|
|
4993
5258
|
);
|
|
4994
5259
|
this.ondo = new ClientOndoNamespaceImpl(ctx, this.erc20);
|
|
4995
5260
|
this.tokens = new TokensNamespaceImpl(
|
|
4996
|
-
|
|
5261
|
+
config.tokensBaseUrl ?? NABU_BASE_URL,
|
|
4997
5262
|
logger
|
|
4998
5263
|
);
|
|
4999
5264
|
this.support = new ClientSupportNamespaceImpl(logger);
|
|
5000
5265
|
}
|
|
5001
5266
|
async init() {
|
|
5002
|
-
|
|
5003
|
-
return this.getAuthState();
|
|
5004
|
-
}
|
|
5005
|
-
async fetchAccessToken(refresh) {
|
|
5006
|
-
if (!refresh && this._accessToken !== void 0) return this._accessToken;
|
|
5007
|
-
try {
|
|
5008
|
-
const accessToken = await this._config.getAccessToken();
|
|
5009
|
-
this._accessToken = accessToken;
|
|
5010
|
-
return accessToken;
|
|
5011
|
-
} catch (_) {
|
|
5012
|
-
this._accessToken = null;
|
|
5013
|
-
return null;
|
|
5014
|
-
}
|
|
5015
|
-
}
|
|
5016
|
-
getAuthState() {
|
|
5017
|
-
if (this._accessToken === void 0) {
|
|
5018
|
-
return "unknown";
|
|
5019
|
-
}
|
|
5020
|
-
return this._accessToken !== null ? "logged-in" : "logged-out";
|
|
5267
|
+
return this.accessToken.load();
|
|
5021
5268
|
}
|
|
5022
5269
|
ensureAuthenticated() {
|
|
5023
|
-
if (this.
|
|
5270
|
+
if (this.accessToken.authState() !== "logged-in") {
|
|
5024
5271
|
throw new NotAuthenticatedError();
|
|
5025
5272
|
}
|
|
5026
5273
|
}
|
|
@@ -6299,10 +6546,7 @@ function CheckoutConfirmationDialog({
|
|
|
6299
6546
|
}
|
|
6300
6547
|
)
|
|
6301
6548
|
] }),
|
|
6302
|
-
header
|
|
6303
|
-
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Divider, {}),
|
|
6304
|
-
header
|
|
6305
|
-
] }),
|
|
6549
|
+
header,
|
|
6306
6550
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Divider, {}),
|
|
6307
6551
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(CheckoutDetailList, { rows }),
|
|
6308
6552
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "clcosdk:flex clcosdk:flex-col clcosdk:gap-3", children: actions })
|
|
@@ -6319,6 +6563,7 @@ function AssetSummaryRow({
|
|
|
6319
6563
|
iconSize = 48,
|
|
6320
6564
|
value,
|
|
6321
6565
|
caption,
|
|
6566
|
+
wrapIdentity = false,
|
|
6322
6567
|
className
|
|
6323
6568
|
}) {
|
|
6324
6569
|
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(CoinListStyleScope, { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
@@ -6337,7 +6582,8 @@ function AssetSummaryRow({
|
|
|
6337
6582
|
{
|
|
6338
6583
|
className: cn(
|
|
6339
6584
|
typeClasses.h4,
|
|
6340
|
-
"clcosdk:
|
|
6585
|
+
"clcosdk:text-text-primary",
|
|
6586
|
+
wrapIdentity ? "clcosdk:break-words" : "clcosdk:truncate"
|
|
6341
6587
|
),
|
|
6342
6588
|
children: asset.name
|
|
6343
6589
|
}
|
|
@@ -6347,7 +6593,8 @@ function AssetSummaryRow({
|
|
|
6347
6593
|
{
|
|
6348
6594
|
className: cn(
|
|
6349
6595
|
typeClasses.subhead,
|
|
6350
|
-
"clcosdk:
|
|
6596
|
+
"clcosdk:text-text-secondary",
|
|
6597
|
+
wrapIdentity ? "clcosdk:break-words" : "clcosdk:truncate"
|
|
6351
6598
|
),
|
|
6352
6599
|
children: asset.symbol
|
|
6353
6600
|
}
|
|
@@ -6392,7 +6639,7 @@ function AssetSummaryRow({
|
|
|
6392
6639
|
// src/client/components/checkout/ondo/buy/confirmation/OndoBuyOrderConfirmed.tsx
|
|
6393
6640
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
6394
6641
|
var TITLE2 = "Order confirmed";
|
|
6395
|
-
var
|
|
6642
|
+
var SHARES_RECEIVED_LABEL = "Shares received";
|
|
6396
6643
|
var TOTAL_COST_LABEL = "Total cost";
|
|
6397
6644
|
var PRICE_PER_SHARE_LABEL = "Price per share";
|
|
6398
6645
|
var DELIVERED_TO_LABEL = "Delivered to";
|
|
@@ -6414,14 +6661,7 @@ function OndoBuyOrderConfirmed({
|
|
|
6414
6661
|
icon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SuccessGlyph, {}),
|
|
6415
6662
|
title: TITLE2,
|
|
6416
6663
|
subtitle: subtitle(state.outputAsset.symbol),
|
|
6417
|
-
header: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
6418
|
-
AssetSummaryRow,
|
|
6419
|
-
{
|
|
6420
|
-
asset: state.outputAsset,
|
|
6421
|
-
value: state.outputAmount,
|
|
6422
|
-
caption: SHARES_RECEIVED_CAPTION
|
|
6423
|
-
}
|
|
6424
|
-
),
|
|
6664
|
+
header: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(AssetSummaryRow, { asset: state.outputAsset, wrapIdentity: true }),
|
|
6425
6665
|
rows: detailRows(state),
|
|
6426
6666
|
actions: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [
|
|
6427
6667
|
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ClButton, { variant: "gradient", fullWidth: true, onClick: onClose, children: DONE_LABEL }),
|
|
@@ -6434,6 +6674,7 @@ function OndoBuyOrderConfirmed({
|
|
|
6434
6674
|
}
|
|
6435
6675
|
function detailRows(state) {
|
|
6436
6676
|
return [
|
|
6677
|
+
{ label: SHARES_RECEIVED_LABEL, value: state.outputAmount },
|
|
6437
6678
|
{ label: TOTAL_COST_LABEL, value: state.totalCost },
|
|
6438
6679
|
{ label: PRICE_PER_SHARE_LABEL, value: state.pricePerShare },
|
|
6439
6680
|
{ label: DELIVERED_TO_LABEL, value: state.recipientAddress }
|
|
@@ -8238,7 +8479,7 @@ function useOndoBuyReviewViewModel({
|
|
|
8238
8479
|
tokenMetadata: outputTokenMetadata
|
|
8239
8480
|
}),
|
|
8240
8481
|
outputAmount: assetAmount(
|
|
8241
|
-
|
|
8482
|
+
formatShareAmount(built.receiveOutputAmount, locale),
|
|
8242
8483
|
ondoSymbol
|
|
8243
8484
|
),
|
|
8244
8485
|
recipientAddress: shortenAddress(active.wallet.address),
|
|
@@ -9057,7 +9298,7 @@ function toOrderConfirmedUi({
|
|
|
9057
9298
|
tokenMetadata: outputTokenMetadata
|
|
9058
9299
|
}),
|
|
9059
9300
|
outputAmount: assetAmount(
|
|
9060
|
-
|
|
9301
|
+
formatShareAmount(order.transaction.receiveOutputAmount, locale),
|
|
9061
9302
|
ondoSymbol
|
|
9062
9303
|
),
|
|
9063
9304
|
totalCost: assetAmount(
|
|
@@ -9309,7 +9550,7 @@ function MaxButton2({
|
|
|
9309
9550
|
var import_lucide_react7 = require("lucide-react");
|
|
9310
9551
|
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
9311
9552
|
var TITLE7 = "Order confirmed";
|
|
9312
|
-
var
|
|
9553
|
+
var SHARES_SOLD_LABEL = "Shares sold";
|
|
9313
9554
|
var RECEIVED_LABEL = "Received";
|
|
9314
9555
|
var PRICE_PER_SHARE_LABEL3 = "Price per share";
|
|
9315
9556
|
var DELIVERED_TO_LABEL2 = "Delivered to";
|
|
@@ -9332,18 +9573,9 @@ function OndoSellOrderConfirmed({
|
|
|
9332
9573
|
title: TITLE7,
|
|
9333
9574
|
subtitle: subtitle2(state.soldAsset.symbol, state.proceedsSymbol),
|
|
9334
9575
|
header: (
|
|
9335
|
-
// The
|
|
9336
|
-
//
|
|
9337
|
-
|
|
9338
|
-
// for.
|
|
9339
|
-
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
9340
|
-
AssetSummaryRow,
|
|
9341
|
-
{
|
|
9342
|
-
asset: state.soldAsset,
|
|
9343
|
-
value: state.soldAmount,
|
|
9344
|
-
caption: SHARES_SOLD_CAPTION
|
|
9345
|
-
}
|
|
9346
|
-
)
|
|
9576
|
+
// The header names what was sold. The quantity is a detail row, so a
|
|
9577
|
+
// long fund name and a long share count each get the full width.
|
|
9578
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(AssetSummaryRow, { asset: state.soldAsset, wrapIdentity: true })
|
|
9347
9579
|
),
|
|
9348
9580
|
rows: detailRows3(state),
|
|
9349
9581
|
actions: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
|
|
@@ -9357,6 +9589,7 @@ function OndoSellOrderConfirmed({
|
|
|
9357
9589
|
}
|
|
9358
9590
|
function detailRows3(state) {
|
|
9359
9591
|
return [
|
|
9592
|
+
{ label: SHARES_SOLD_LABEL, value: state.soldAmount },
|
|
9360
9593
|
{ label: RECEIVED_LABEL, value: state.proceeds },
|
|
9361
9594
|
{ label: PRICE_PER_SHARE_LABEL3, value: state.pricePerShare },
|
|
9362
9595
|
{ label: DELIVERED_TO_LABEL2, value: state.recipientAddress }
|
|
@@ -10678,7 +10911,7 @@ function toOrderConfirmedUi2({
|
|
|
10678
10911
|
tokenMetadata: inputTokenMetadata
|
|
10679
10912
|
}),
|
|
10680
10913
|
soldAmount: assetAmount(
|
|
10681
|
-
|
|
10914
|
+
formatShareAmount(order.transaction.spendInputAmount, locale),
|
|
10682
10915
|
ondoSymbol
|
|
10683
10916
|
),
|
|
10684
10917
|
// The expected proceeds rather than the floor: this dialog reports a sale
|
|
@@ -10917,7 +11150,7 @@ var import_lucide_react9 = require("lucide-react");
|
|
|
10917
11150
|
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
10918
11151
|
var TITLE10 = "Order confirmed";
|
|
10919
11152
|
var TOTAL_COST_LABEL2 = "Total cost";
|
|
10920
|
-
var
|
|
11153
|
+
var SHARES_RECEIVED_LABEL2 = "Shares received";
|
|
10921
11154
|
var SHARES_RECEIVED_ESTIMATED_LABEL = "Shares received (estimated)";
|
|
10922
11155
|
var PRICE_PER_SHARE_LABEL5 = "Price per share";
|
|
10923
11156
|
var PRICE_PER_SHARE_ESTIMATED_LABEL = "Price per share (estimated)";
|
|
@@ -10940,13 +11173,7 @@ function SuperstateOrderConfirmed({
|
|
|
10940
11173
|
icon: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(SuccessGlyph3, {}),
|
|
10941
11174
|
title: TITLE10,
|
|
10942
11175
|
subtitle: subtitle3(state.asset.symbol),
|
|
10943
|
-
header: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
10944
|
-
AssetSummaryRow,
|
|
10945
|
-
{
|
|
10946
|
-
asset: state.asset,
|
|
10947
|
-
caption: `Issued by ${state.issuer}`
|
|
10948
|
-
}
|
|
10949
|
-
),
|
|
11176
|
+
header: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(AssetSummaryRow, { asset: state.asset, wrapIdentity: true }),
|
|
10950
11177
|
rows: detailRows4(state),
|
|
10951
11178
|
actions: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
|
|
10952
11179
|
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ClButton, { variant: "gradient", fullWidth: true, onClick: onClose, children: DONE_LABEL3 }),
|
|
@@ -10962,7 +11189,7 @@ function detailRows4(state) {
|
|
|
10962
11189
|
return [
|
|
10963
11190
|
{ label: TOTAL_COST_LABEL2, value: state.totalCost },
|
|
10964
11191
|
{
|
|
10965
|
-
label: confirmed ?
|
|
11192
|
+
label: confirmed ? SHARES_RECEIVED_LABEL2 : SHARES_RECEIVED_ESTIMATED_LABEL,
|
|
10966
11193
|
value: state.outputAmount
|
|
10967
11194
|
},
|
|
10968
11195
|
{
|
|
@@ -13034,7 +13261,6 @@ function toOrderConfirmedUi3({
|
|
|
13034
13261
|
networkName: getNetworkName(chain),
|
|
13035
13262
|
iconUrl: assetIconUrl
|
|
13036
13263
|
}),
|
|
13037
|
-
issuer: SUPERSTATE_ISSUER_NAME,
|
|
13038
13264
|
outputAmount: assetAmount(
|
|
13039
13265
|
formatAmount(order.outputAmount, locale),
|
|
13040
13266
|
order.outputAsset.symbol
|