@dynamic-labs/sdk-react-core 4.84.1 → 4.86.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/package.cjs +3 -3
- package/package.js +3 -3
- package/package.json +14 -14
- package/src/index.d.ts +1 -1
- package/src/lib/components/SendBalancePageLayout/components/TokensBalanceDropdown/TokensBalanceDropdown.cjs +5 -1
- package/src/lib/components/SendBalancePageLayout/components/TokensBalanceDropdown/TokensBalanceDropdown.js +5 -1
- package/src/lib/context/OnrampContext/utils/getOnrampProviders.cjs +2 -6
- package/src/lib/context/OnrampContext/utils/getOnrampProviders.js +4 -8
- package/src/lib/data/api/onramp/onramp.cjs +26 -1
- package/src/lib/data/api/onramp/onramp.d.ts +11 -1
- package/src/lib/data/api/onramp/onramp.js +26 -1
- package/src/lib/utils/functions/onrampProviders/index.cjs +1 -0
- package/src/lib/utils/functions/onrampProviders/index.js +1 -0
- package/src/lib/utils/hooks/index.d.ts +1 -1
- package/src/lib/utils/hooks/useAleoShieldedBalances/useAleoShieldedBalances.cjs +81 -10
- package/src/lib/utils/hooks/useAleoShieldedBalances/useAleoShieldedBalances.d.ts +18 -2
- package/src/lib/utils/hooks/useAleoShieldedBalances/useAleoShieldedBalances.js +82 -11
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +4 -4
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +4 -4
- package/src/lib/utils/hooks/usePrivateTokenBalances/index.d.ts +1 -1
- package/src/lib/utils/hooks/usePrivateTokenBalances/usePrivateTokenBalances.cjs +10 -2
- package/src/lib/utils/hooks/usePrivateTokenBalances/usePrivateTokenBalances.d.ts +17 -2
- package/src/lib/utils/hooks/usePrivateTokenBalances/usePrivateTokenBalances.js +10 -2
- package/src/lib/utils/hooks/useSyncDynamicWaas/instrumentWalletCreation.cjs +60 -0
- package/src/lib/utils/hooks/useSyncDynamicWaas/instrumentWalletCreation.d.ts +29 -0
- package/src/lib/utils/hooks/useSyncDynamicWaas/instrumentWalletCreation.js +55 -0
- package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.cjs +14 -24
- package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.js +14 -24
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +17 -1
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +17 -1
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/optimisticShield.cjs +28 -12
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/optimisticShield.d.ts +8 -3
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/optimisticShield.js +28 -12
|
@@ -19,28 +19,44 @@ const matches = (entry, token) => {
|
|
|
19
19
|
* `balance` and `marketValue` scale by the same ratio so the fiat
|
|
20
20
|
* column doesn't disagree with the optimistic raw balance.
|
|
21
21
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
22
|
+
* Rows that are zeroed by the deduction are dropped from the returned
|
|
23
|
+
* array so they disappear immediately from the unshielded list instead
|
|
24
|
+
* of lingering as a `<$0.01` ghost (the per-row fiat formatter renders
|
|
25
|
+
* any non-positive-but-non-undefined `marketValue` as `<$0.01`, which
|
|
26
|
+
* looks broken when the optimistic deduction has already taken the row
|
|
27
|
+
* to exactly 0). Rows untouched by the optimistic shield pass through
|
|
28
|
+
* by reference (no copy) so downstream memos / identity comparisons
|
|
29
|
+
* don't churn on every render.
|
|
25
30
|
*/
|
|
26
31
|
const applyOptimisticUnshieldedDeductions = (balances, optimisticShields) => {
|
|
32
|
+
var _a, _b;
|
|
27
33
|
if (optimisticShields.length === 0)
|
|
28
34
|
return balances;
|
|
29
|
-
|
|
30
|
-
|
|
35
|
+
const result = [];
|
|
36
|
+
for (const token of balances) {
|
|
31
37
|
const adjustments = optimisticShields.filter((o) => matches(o, token));
|
|
32
|
-
if (adjustments.length === 0)
|
|
33
|
-
|
|
38
|
+
if (adjustments.length === 0) {
|
|
39
|
+
result.push(token);
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
34
42
|
const currentRaw = BigInt(Math.round((_a = token.rawBalance) !== null && _a !== void 0 ? _a : 0));
|
|
35
43
|
const totalAdjustment = adjustments.reduce((sum, o) => sum + o.amount, BigInt(0));
|
|
36
44
|
const newRaw = currentRaw > totalAdjustment ? currentRaw - totalAdjustment : BigInt(0);
|
|
45
|
+
// Zero-out drop: the optimistic deduction took this row to (or
|
|
46
|
+
// below) zero, so there is nothing useful to display. Filter it
|
|
47
|
+
// out rather than emit a synthetic 0-balance row — otherwise the
|
|
48
|
+
// `<$0.01` formatter renders it as a misleading dust value until
|
|
49
|
+
// the server catches up and reconciliation drops the entry.
|
|
50
|
+
if (newRaw <= BigInt(0))
|
|
51
|
+
continue;
|
|
37
52
|
// Ratio-scale display-units balance + fiat so they stay consistent
|
|
38
|
-
// with the optimistic raw value. `currentRaw === 0n`
|
|
39
|
-
//
|
|
40
|
-
//
|
|
53
|
+
// with the optimistic raw value. `currentRaw === 0n` is
|
|
54
|
+
// unreachable here (already handled by the zero-out drop above
|
|
55
|
+
// via `newRaw <= 0`), but the guard remains as defence-in-depth.
|
|
41
56
|
const ratio = currentRaw > BigInt(0) ? Number(newRaw) / Number(currentRaw) : 0;
|
|
42
|
-
|
|
43
|
-
}
|
|
57
|
+
result.push(Object.assign(Object.assign({}, token), { balance: ((_b = token.balance) !== null && _b !== void 0 ? _b : 0) * ratio, marketValue: token.marketValue !== undefined ? token.marketValue * ratio : undefined, rawBalance: Number(newRaw), rawBalanceString: newRaw.toString() }));
|
|
58
|
+
}
|
|
59
|
+
return result;
|
|
44
60
|
};
|
|
45
61
|
/**
|
|
46
62
|
* Apply optimistic shield additions to the shielded balance list. For
|
|
@@ -30,9 +30,14 @@ export declare const OPTIMISTIC_SHIELD_STALE_MS = 180000;
|
|
|
30
30
|
* `balance` and `marketValue` scale by the same ratio so the fiat
|
|
31
31
|
* column doesn't disagree with the optimistic raw balance.
|
|
32
32
|
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
33
|
+
* Rows that are zeroed by the deduction are dropped from the returned
|
|
34
|
+
* array so they disappear immediately from the unshielded list instead
|
|
35
|
+
* of lingering as a `<$0.01` ghost (the per-row fiat formatter renders
|
|
36
|
+
* any non-positive-but-non-undefined `marketValue` as `<$0.01`, which
|
|
37
|
+
* looks broken when the optimistic deduction has already taken the row
|
|
38
|
+
* to exactly 0). Rows untouched by the optimistic shield pass through
|
|
39
|
+
* by reference (no copy) so downstream memos / identity comparisons
|
|
40
|
+
* don't churn on every render.
|
|
36
41
|
*/
|
|
37
42
|
export declare const applyOptimisticUnshieldedDeductions: (balances: TokenBalance[], optimisticShields: ReadonlyArray<OptimisticShieldEntry>) => TokenBalance[];
|
|
38
43
|
/**
|
|
@@ -15,28 +15,44 @@ const matches = (entry, token) => {
|
|
|
15
15
|
* `balance` and `marketValue` scale by the same ratio so the fiat
|
|
16
16
|
* column doesn't disagree with the optimistic raw balance.
|
|
17
17
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
18
|
+
* Rows that are zeroed by the deduction are dropped from the returned
|
|
19
|
+
* array so they disappear immediately from the unshielded list instead
|
|
20
|
+
* of lingering as a `<$0.01` ghost (the per-row fiat formatter renders
|
|
21
|
+
* any non-positive-but-non-undefined `marketValue` as `<$0.01`, which
|
|
22
|
+
* looks broken when the optimistic deduction has already taken the row
|
|
23
|
+
* to exactly 0). Rows untouched by the optimistic shield pass through
|
|
24
|
+
* by reference (no copy) so downstream memos / identity comparisons
|
|
25
|
+
* don't churn on every render.
|
|
21
26
|
*/
|
|
22
27
|
const applyOptimisticUnshieldedDeductions = (balances, optimisticShields) => {
|
|
28
|
+
var _a, _b;
|
|
23
29
|
if (optimisticShields.length === 0)
|
|
24
30
|
return balances;
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
const result = [];
|
|
32
|
+
for (const token of balances) {
|
|
27
33
|
const adjustments = optimisticShields.filter((o) => matches(o, token));
|
|
28
|
-
if (adjustments.length === 0)
|
|
29
|
-
|
|
34
|
+
if (adjustments.length === 0) {
|
|
35
|
+
result.push(token);
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
30
38
|
const currentRaw = BigInt(Math.round((_a = token.rawBalance) !== null && _a !== void 0 ? _a : 0));
|
|
31
39
|
const totalAdjustment = adjustments.reduce((sum, o) => sum + o.amount, BigInt(0));
|
|
32
40
|
const newRaw = currentRaw > totalAdjustment ? currentRaw - totalAdjustment : BigInt(0);
|
|
41
|
+
// Zero-out drop: the optimistic deduction took this row to (or
|
|
42
|
+
// below) zero, so there is nothing useful to display. Filter it
|
|
43
|
+
// out rather than emit a synthetic 0-balance row — otherwise the
|
|
44
|
+
// `<$0.01` formatter renders it as a misleading dust value until
|
|
45
|
+
// the server catches up and reconciliation drops the entry.
|
|
46
|
+
if (newRaw <= BigInt(0))
|
|
47
|
+
continue;
|
|
33
48
|
// Ratio-scale display-units balance + fiat so they stay consistent
|
|
34
|
-
// with the optimistic raw value. `currentRaw === 0n`
|
|
35
|
-
//
|
|
36
|
-
//
|
|
49
|
+
// with the optimistic raw value. `currentRaw === 0n` is
|
|
50
|
+
// unreachable here (already handled by the zero-out drop above
|
|
51
|
+
// via `newRaw <= 0`), but the guard remains as defence-in-depth.
|
|
37
52
|
const ratio = currentRaw > BigInt(0) ? Number(newRaw) / Number(currentRaw) : 0;
|
|
38
|
-
|
|
39
|
-
}
|
|
53
|
+
result.push(Object.assign(Object.assign({}, token), { balance: ((_b = token.balance) !== null && _b !== void 0 ? _b : 0) * ratio, marketValue: token.marketValue !== undefined ? token.marketValue * ratio : undefined, rawBalance: Number(newRaw), rawBalanceString: newRaw.toString() }));
|
|
54
|
+
}
|
|
55
|
+
return result;
|
|
40
56
|
};
|
|
41
57
|
/**
|
|
42
58
|
* Apply optimistic shield additions to the shielded balance list. For
|