Skip to content

Commit ab319a0

Browse files
authored
Merge pull request xch-dev#570 from dkackman/decimals-precision
rename all properties named decimals to precision
2 parents 55e716f + 5832fa2 commit ab319a0

27 files changed

+106
-101
lines changed

crates/sage-api/src/types/unit.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,29 @@ use serde::{Deserialize, Serialize};
55
#[cfg_attr(feature = "tauri", derive(specta::Type))]
66
pub struct Unit {
77
pub ticker: String,
8-
pub decimals: u8,
8+
pub precision: u8,
99
}
1010

1111
impl Unit {
1212
pub fn cat(ticker: String) -> Self {
1313
Self {
1414
ticker,
15-
decimals: 3,
15+
precision: 3,
1616
}
1717
}
1818
}
1919

2020
pub static XCH: Lazy<Unit> = Lazy::new(|| Unit {
2121
ticker: "XCH".to_string(),
22-
decimals: 12,
22+
precision: 12,
2323
});
2424

2525
pub static TXCH: Lazy<Unit> = Lazy::new(|| Unit {
2626
ticker: "TXCH".to_string(),
27-
decimals: 12,
27+
precision: 12,
2828
});
2929

3030
pub static MOJOS: Lazy<Unit> = Lazy::new(|| Unit {
3131
ticker: "Mojos".to_string(),
32-
decimals: 0,
32+
precision: 0,
3333
});

crates/sage/src/sage.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ impl Sage {
288288
self.wallet = Some(wallet.clone());
289289
self.unit = Unit {
290290
ticker: self.network().ticker.clone(),
291-
decimals: self.network().precision,
291+
precision: self.network().precision,
292292
};
293293

294294
self.command_sender

src/bindings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ export type TransactionResponse = { summary: TransactionSummary; coin_spends: Co
543543
export type TransactionSummary = { fee: Amount; inputs: TransactionInput[] }
544544
export type TransferDids = { did_ids: string[]; address: string; fee: Amount; clawback?: number | null; auto_submit?: boolean }
545545
export type TransferNfts = { nft_ids: string[]; address: string; fee: Amount; clawback?: number | null; auto_submit?: boolean }
546-
export type Unit = { ticker: string; decimals: number }
546+
export type Unit = { ticker: string; precision: number }
547547
export type UpdateCat = { record: TokenRecord }
548548
export type UpdateCatResponse = Record<string, never>
549549
export type UpdateDid = { did_id: string; name: string | null; visible: boolean }

src/components/AdvancedTransactionSummary.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export function AdvancedTransactionSummary({
8686
<Trans>Fee</Trans>
8787
</Badge>
8888
<span>
89-
{toDecimal(summary.fee, walletState.sync.unit.decimals)}{' '}
89+
{toDecimal(summary.fee, walletState.sync.unit.precision)}{' '}
9090
{walletState.sync.unit.ticker}
9191
</span>
9292
</div>
@@ -136,9 +136,9 @@ export function calculateTransaction(
136136
spent.push({
137137
badge: 'Chia',
138138
label: `${formatNumber({
139-
value: fromMojos(input.amount, xch.decimals),
139+
value: fromMojos(input.amount, xch.precision),
140140
minimumFractionDigits: 0,
141-
maximumFractionDigits: xch.decimals,
141+
maximumFractionDigits: xch.precision,
142142
})} ${xch.ticker}`,
143143
coinId: input.coin_id,
144144
sort: 1,
@@ -152,9 +152,9 @@ export function calculateTransaction(
152152
created.push({
153153
badge: 'Chia',
154154
label: `${formatNumber({
155-
value: fromMojos(output.amount, xch.decimals),
155+
value: fromMojos(output.amount, xch.precision),
156156
minimumFractionDigits: 0,
157-
maximumFractionDigits: xch.decimals,
157+
maximumFractionDigits: xch.precision,
158158
})} ${xch.ticker}`,
159159
address: output.burning
160160
? t`Permanently Burned`

src/components/AssignNftDialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export function AssignNftDialog({
5353

5454
const schema = z.object({
5555
profile: z.string().min(1, t`Profile is required`),
56-
fee: amount(walletState.sync.unit.decimals).refine(
56+
fee: amount(walletState.sync.unit.precision).refine(
5757
(amount) => BigNumber(walletState.sync.balance).gte(amount || 0),
5858
t`Not enough funds to cover the fee`,
5959
),

src/components/ClawbackCoinsCard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ export function ClawbackCoinsCard({
192192
const [clawBackOpen, setClawBackOpen] = useState(false);
193193

194194
const clawBackFormSchema = z.object({
195-
clawBackFee: amount(walletState.sync.unit.decimals).refine(
195+
clawBackFee: amount(walletState.sync.unit.precision).refine(
196196
(amount) => BigNumber(walletState.sync.balance).gte(amount || 0),
197197
t`Not enough funds to cover the fee`,
198198
),
@@ -203,7 +203,7 @@ export function ClawbackCoinsCard({
203203
});
204204

205205
const onClawBackSubmit = (values: z.infer<typeof clawBackFormSchema>) => {
206-
const fee = toMojos(values.clawBackFee, walletState.sync.unit.decimals);
206+
const fee = toMojos(values.clawBackFee, walletState.sync.unit.precision);
207207

208208
// Get IDs from the selected coin records
209209
const coinIdsForRequest = selectedCoinRecords.map(

src/components/ConfirmationDialog.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -440,11 +440,11 @@ export default function ConfirmationDialog({
440440
{formatNumber({
441441
value: fromMojos(
442442
fee,
443-
walletState.sync.unit.decimals,
443+
walletState.sync.unit.precision,
444444
),
445445
minimumFractionDigits: 0,
446446
maximumFractionDigits:
447-
walletState.sync.unit.decimals,
447+
walletState.sync.unit.precision,
448448
})}{' '}
449449
{ticker}
450450
</span>
@@ -583,9 +583,9 @@ export default function ConfirmationDialog({
583583
) : (
584584
<>
585585
{formatNumber({
586-
value: fromMojos(fee, walletState.sync.unit.decimals),
586+
value: fromMojos(fee, walletState.sync.unit.precision),
587587
minimumFractionDigits: 0,
588-
maximumFractionDigits: walletState.sync.unit.decimals,
588+
maximumFractionDigits: walletState.sync.unit.precision,
589589
})}{' '}
590590
{ticker}
591591
</>

src/components/FeeOnlyDialog.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { amount } from '@/lib/formTypes';
22
import { useWalletState } from '@/state';
33
import { zodResolver } from '@hookform/resolvers/zod';
4+
import { t } from '@lingui/core/macro';
5+
import { Trans } from '@lingui/react/macro';
46
import BigNumber from 'bignumber.js';
57
import { PropsWithChildren } from 'react';
68
import { useForm } from 'react-hook-form';
79
import { z } from 'zod';
8-
import { Trans } from '@lingui/react/macro';
9-
import { t } from '@lingui/core/macro';
1010
import { Button } from './ui/button';
1111
import {
1212
Dialog,
@@ -45,7 +45,7 @@ export function FeeOnlyDialog({
4545
const walletState = useWalletState();
4646

4747
const schema = z.object({
48-
fee: amount(walletState.sync.unit.decimals).refine(
48+
fee: amount(walletState.sync.unit.precision).refine(
4949
(amount) => BigNumber(walletState.sync.balance).gte(amount || 0),
5050
t`Not enough funds to cover the fee`,
5151
),

src/components/MultiSelectActions.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export function MultiSelectActions({
135135
.transferNfts({
136136
nft_ids: selected,
137137
address,
138-
fee: toMojos(fee, walletState.sync.unit.decimals),
138+
fee: toMojos(fee, walletState.sync.unit.precision),
139139
})
140140
.then(setResponse)
141141
.catch((err: unknown) => {
@@ -152,7 +152,7 @@ export function MultiSelectActions({
152152
.assignNftsToDid({
153153
nft_ids: selected,
154154
did_id: profile,
155-
fee: toMojos(fee, walletState.sync.unit.decimals),
155+
fee: toMojos(fee, walletState.sync.unit.precision),
156156
})
157157
.then(setResponse)
158158
.catch((err: unknown) => {
@@ -168,7 +168,7 @@ export function MultiSelectActions({
168168
.transferNfts({
169169
nft_ids: selected,
170170
address: walletState.sync.burn_address,
171-
fee: toMojos(fee, walletState.sync.unit.decimals),
171+
fee: toMojos(fee, walletState.sync.unit.precision),
172172
})
173173
.then(setResponse)
174174
.catch((err: unknown) => {

src/components/NftCard.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ export function NftCard({ nft, updateNfts, selectionState }: NftCardProps) {
183183
.transferNfts({
184184
nft_ids: [nft.launcher_id],
185185
address,
186-
fee: toMojos(fee, walletState.sync.unit.decimals),
186+
fee: toMojos(fee, walletState.sync.unit.precision),
187187
})
188188
.then(setResponse)
189189
.catch((err) => {
@@ -200,7 +200,7 @@ export function NftCard({ nft, updateNfts, selectionState }: NftCardProps) {
200200
.assignNftsToDid({
201201
nft_ids: [nft.launcher_id],
202202
did_id: profile,
203-
fee: toMojos(fee, walletState.sync.unit.decimals),
203+
fee: toMojos(fee, walletState.sync.unit.precision),
204204
})
205205
.then(setResponse)
206206
.catch((err) => {
@@ -213,7 +213,7 @@ export function NftCard({ nft, updateNfts, selectionState }: NftCardProps) {
213213
const addUrlFormSchema = z.object({
214214
url: z.string().min(1, t`URL is required`),
215215
kind: z.string().min(1, t`Kind is required`),
216-
fee: amount(walletState.sync.unit.decimals).refine(
216+
fee: amount(walletState.sync.unit.precision).refine(
217217
(amount) => BigNumber(walletState.sync.balance).gte(amount || 0),
218218
t`Not enough funds to cover the fee`,
219219
),
@@ -236,7 +236,7 @@ export function NftCard({ nft, updateNfts, selectionState }: NftCardProps) {
236236
nft_id: nft.launcher_id,
237237
uri: values.url,
238238
kind: values.kind as NftUriKind,
239-
fee: toMojos(values.fee, walletState.sync.unit.decimals),
239+
fee: toMojos(values.fee, walletState.sync.unit.precision),
240240
})
241241
.then(setResponse)
242242
.catch((err) => {
@@ -252,7 +252,7 @@ export function NftCard({ nft, updateNfts, selectionState }: NftCardProps) {
252252
.transferNfts({
253253
nft_ids: [nft.launcher_id],
254254
address: walletState.sync.burn_address,
255-
fee: toMojos(fee, walletState.sync.unit.decimals),
255+
fee: toMojos(fee, walletState.sync.unit.precision),
256256
})
257257
.then(setResponse)
258258
.catch((err) => {

0 commit comments

Comments
 (0)