From ee9291314089494704b3b307a6733a831af8fad9 Mon Sep 17 00:00:00 2001 From: danield9tqh Date: Mon, 21 Oct 2024 14:49:53 -0400 Subject: [PATCH] Remove CurrencyUtils.encode --- ironfish-cli/src/commands/wallet/burn.ts | 6 +++--- ironfish-cli/src/commands/wallet/chainport/send.ts | 4 ++-- ironfish-cli/src/commands/wallet/mint.ts | 6 +++--- ironfish-cli/src/commands/wallet/notes/combine.ts | 10 +++++----- ironfish-cli/src/commands/wallet/send.ts | 6 +++--- ironfish-cli/src/utils/fees.ts | 4 ++-- ironfish-cli/src/utils/spendPostTime.ts | 5 ++--- ironfish/src/mining/poolShares.ts | 4 ++-- ironfish/src/rpc/routes/chain/estimateFeeRate.ts | 3 +-- ironfish/src/rpc/routes/chain/estimateFeeRates.ts | 7 +++---- ironfish/src/rpc/routes/chain/getAsset.test.ts | 3 +-- ironfish/src/rpc/routes/chain/getAsset.ts | 3 +-- ironfish/src/rpc/routes/chain/getTransactionStream.ts | 8 ++++---- ironfish/src/rpc/routes/wallet/burnAsset.test.ts | 3 +-- ironfish/src/rpc/routes/wallet/burnAsset.ts | 2 +- .../rpc/routes/wallet/getAccountNotesStream.test.ts | 4 ++-- .../src/rpc/routes/wallet/getAccountNotesStream.ts | 4 ++-- ironfish/src/rpc/routes/wallet/getAsset.ts | 3 +-- ironfish/src/rpc/routes/wallet/getAssets.ts | 3 +-- ironfish/src/rpc/routes/wallet/getBalances.ts | 9 ++++----- ironfish/src/rpc/routes/wallet/mintAsset.test.ts | 3 +-- ironfish/src/rpc/routes/wallet/serializers.ts | 4 ++-- ironfish/src/utils/currency.test.ts | 8 -------- ironfish/src/utils/currency.ts | 7 ------- ironfish/src/utils/yup.test.ts | 5 ++--- 25 files changed, 49 insertions(+), 75 deletions(-) diff --git a/ironfish-cli/src/commands/wallet/burn.ts b/ironfish-cli/src/commands/wallet/burn.ts index 1ee14c9777..556981263e 100644 --- a/ironfish-cli/src/commands/wallet/burn.ts +++ b/ironfish-cli/src/commands/wallet/burn.ts @@ -179,11 +179,11 @@ This will destroy tokens and decrease supply for a given asset.` burns: [ { assetId, - value: CurrencyUtils.encode(amount), + value: amount.toString(), }, ], - fee: flags.fee ? CurrencyUtils.encode(flags.fee) : null, - feeRate: flags.feeRate ? CurrencyUtils.encode(flags.feeRate) : null, + fee: flags.fee ? flags.fee.toString() : null, + feeRate: flags.feeRate ? flags.feeRate.toString() : null, expiration: flags.expiration, confirmations: flags.confirmations, } diff --git a/ironfish-cli/src/commands/wallet/chainport/send.ts b/ironfish-cli/src/commands/wallet/chainport/send.ts index 93595ba3e9..d041ff78da 100644 --- a/ironfish-cli/src/commands/wallet/chainport/send.ts +++ b/ironfish-cli/src/commands/wallet/chainport/send.ts @@ -347,8 +347,8 @@ export class BridgeCommand extends IronfishCommand { memo: txn.gas_fee_output.memo, }, ], - fee: flags.fee ? CurrencyUtils.encode(flags.fee) : null, - feeRate: flags.feeRate ? CurrencyUtils.encode(flags.feeRate) : null, + fee: flags.fee ? flags.fee.toString() : null, + feeRate: flags.feeRate ? flags.feeRate.toString() : null, expiration, } diff --git a/ironfish-cli/src/commands/wallet/mint.ts b/ironfish-cli/src/commands/wallet/mint.ts index d2b5d8a294..a87f1bf5c6 100644 --- a/ironfish-cli/src/commands/wallet/mint.ts +++ b/ironfish-cli/src/commands/wallet/mint.ts @@ -244,7 +244,7 @@ This will create tokens and increase supply for a given asset.` ...(assetData != null ? { assetId } : {}), name: name, metadata: metadata, - value: CurrencyUtils.encode(amount), + value: amount.toString(), transferOwnershipTo: flags.transferOwnershipTo, } @@ -252,8 +252,8 @@ This will create tokens and increase supply for a given asset.` account, outputs: [], mints: [mint], - fee: flags.fee ? CurrencyUtils.encode(flags.fee) : null, - feeRate: flags.feeRate ? CurrencyUtils.encode(flags.feeRate) : null, + fee: flags.fee ? flags.fee.toString() : null, + feeRate: flags.feeRate ? flags.feeRate.toString() : null, expiration: expiration, confirmations: flags.confirmations, } diff --git a/ironfish-cli/src/commands/wallet/notes/combine.ts b/ironfish-cli/src/commands/wallet/notes/combine.ts index e11fb33e32..d8380495af 100644 --- a/ironfish-cli/src/commands/wallet/notes/combine.ts +++ b/ironfish-cli/src/commands/wallet/notes/combine.ts @@ -297,12 +297,12 @@ export class CombineNotesCommand extends IronfishCommand { { publicAddress: to, assetId, - amount: CurrencyUtils.encode(totalAmount), + amount: totalAmount.toString(), memo, }, ], - fee: flags.fee ? CurrencyUtils.encode(flags.fee) : null, - feeRate: flags.feeRate ? CurrencyUtils.encode(flags.feeRate) : null, + fee: flags.fee ? flags.fee.toString() : null, + feeRate: flags.feeRate ? flags.feeRate.toString() : null, notes: notes.map((note) => note.noteHash), expiration, } @@ -326,8 +326,8 @@ export class CombineNotesCommand extends IronfishCommand { if (assetId === Asset.nativeId().toString('hex')) { amount = totalAmount - raw.fee } - params.outputs[0].amount = CurrencyUtils.encode(amount) - params.fee = CurrencyUtils.encode(raw.fee) + params.outputs[0].amount = amount.toString() + params.fee = raw.fee.toString() const createTransactionResponse = await client.wallet.createTransaction(params) const createTransactionBytes = Buffer.from( diff --git a/ironfish-cli/src/commands/wallet/send.ts b/ironfish-cli/src/commands/wallet/send.ts index 50d3875b89..5f6dc8f0e9 100644 --- a/ironfish-cli/src/commands/wallet/send.ts +++ b/ironfish-cli/src/commands/wallet/send.ts @@ -210,13 +210,13 @@ export class Send extends IronfishCommand { outputs: [ { publicAddress: to, - amount: CurrencyUtils.encode(amount), + amount: amount.toString(), memo, assetId, }, ], - fee: flags.fee ? CurrencyUtils.encode(flags.fee) : null, - feeRate: flags.feeRate ? CurrencyUtils.encode(flags.feeRate) : null, + fee: flags.fee ? flags.fee.toString() : null, + feeRate: flags.feeRate ? flags.feeRate.toString() : null, expiration: expiration, confirmations: flags.confirmations, notes: flags.note, diff --git a/ironfish-cli/src/utils/fees.ts b/ironfish-cli/src/utils/fees.ts index fce9b08088..7533c4c702 100644 --- a/ironfish-cli/src/utils/fees.ts +++ b/ironfish-cli/src/utils/fees.ts @@ -85,7 +85,7 @@ export async function selectFee(options: { const custom = await options.client.wallet.createTransaction({ ...options.transaction, - fee: CurrencyUtils.encode(fee), + fee: fee.toString(), }) const bytes = Buffer.from(custom.content.transaction, 'hex') @@ -103,7 +103,7 @@ async function getTxWithFee( ): Promise { const promise = client.wallet.createTransaction({ ...params, - feeRate: CurrencyUtils.encode(feeRate), + feeRate: feeRate.toString(), }) const response = await promise.catch((e) => { diff --git a/ironfish-cli/src/utils/spendPostTime.ts b/ironfish-cli/src/utils/spendPostTime.ts index 70913b995b..3e84aa11e1 100644 --- a/ironfish-cli/src/utils/spendPostTime.ts +++ b/ironfish-cli/src/utils/spendPostTime.ts @@ -5,7 +5,6 @@ import { Asset } from '@ironfish/rust-nodejs' import { BenchUtils, CreateTransactionRequest, - CurrencyUtils, EstimateFeeRatesResponse, IronfishSdk, RawTransaction, @@ -79,7 +78,7 @@ export async function benchmarkSpendPostTime( outputs: [ { publicAddress: publicKey, - amount: CurrencyUtils.encode(BigInt(notes[0].value)), + amount: BigInt(notes[0].value).toString(), memo: '', }, ], @@ -95,7 +94,7 @@ export async function benchmarkSpendPostTime( outputs: [ { publicAddress: publicKey, - amount: CurrencyUtils.encode(BigInt(notes[0].value) + BigInt(notes[1].value)), + amount: (BigInt(notes[0].value) + BigInt(notes[1].value)).toString(), memo: '', }, ], diff --git a/ironfish/src/mining/poolShares.ts b/ironfish/src/mining/poolShares.ts index 56a5860260..4b9beb54d9 100644 --- a/ironfish/src/mining/poolShares.ts +++ b/ironfish/src/mining/poolShares.ts @@ -6,7 +6,7 @@ import { Assert } from '../assert' import { Config } from '../fileStores/config' import { Logger } from '../logger' import { RpcClient } from '../rpc/clients/client' -import { CurrencyUtils, ErrorUtils } from '../utils' +import { ErrorUtils } from '../utils' import { PoolDatabase } from './poolDatabase' import { DatabaseBlock, DatabasePayoutTransaction } from './poolDatabase/database' import { WebhookNotifier } from './webhooks' @@ -236,7 +236,7 @@ export class MiningPoolShares { const amount = amountPerShare * BigInt(payout.shareCount) outputs.push({ publicAddress: payout.publicAddress, - amount: CurrencyUtils.encode(amount), + amount: amount.toString(), memo: `${this.poolName} payout ${payoutPeriod.id}`, assetId, }) diff --git a/ironfish/src/rpc/routes/chain/estimateFeeRate.ts b/ironfish/src/rpc/routes/chain/estimateFeeRate.ts index df684cd60c..6b189aa562 100644 --- a/ironfish/src/rpc/routes/chain/estimateFeeRate.ts +++ b/ironfish/src/rpc/routes/chain/estimateFeeRate.ts @@ -5,7 +5,6 @@ import * as yup from 'yup' import { Assert } from '../../../assert' import { PRIORITY_LEVELS, PriorityLevel } from '../../../memPool/feeEstimator' import { FullNode } from '../../../node' -import { CurrencyUtils } from '../../../utils' import { ApiNamespace } from '../namespaces' import { routes } from '../router' @@ -35,6 +34,6 @@ routes.register( const priority = request.data?.priority ?? 'average' const rate = node.memPool.feeEstimator.estimateFeeRate(priority) - request.end({ rate: CurrencyUtils.encode(rate) }) + request.end({ rate: rate.toString() }) }, ) diff --git a/ironfish/src/rpc/routes/chain/estimateFeeRates.ts b/ironfish/src/rpc/routes/chain/estimateFeeRates.ts index 4a7c2bc13c..728be14cad 100644 --- a/ironfish/src/rpc/routes/chain/estimateFeeRates.ts +++ b/ironfish/src/rpc/routes/chain/estimateFeeRates.ts @@ -4,7 +4,6 @@ import * as yup from 'yup' import { Assert } from '../../../assert' import { FullNode } from '../../../node' -import { CurrencyUtils } from '../../../utils' import { ApiNamespace } from '../namespaces' import { routes } from '../router' @@ -36,9 +35,9 @@ routes.register( const rates = node.memPool.feeEstimator.estimateFeeRates() request.end({ - slow: CurrencyUtils.encode(rates.slow), - average: CurrencyUtils.encode(rates.average), - fast: CurrencyUtils.encode(rates.fast), + slow: rates.slow.toString(), + average: rates.average.toString(), + fast: rates.fast.toString(), }) }, ) diff --git a/ironfish/src/rpc/routes/chain/getAsset.test.ts b/ironfish/src/rpc/routes/chain/getAsset.test.ts index dee5959c5a..c9359391b2 100644 --- a/ironfish/src/rpc/routes/chain/getAsset.test.ts +++ b/ironfish/src/rpc/routes/chain/getAsset.test.ts @@ -6,7 +6,6 @@ import '../../../testUtilities/matchers' import { Asset } from '@ironfish/rust-nodejs' import { Assert } from '../../../assert' import { createRouteTest } from '../../../testUtilities/routeTest' -import { CurrencyUtils } from '../../../utils' describe('Route chain.getAsset', () => { const routeTest = createRouteTest() @@ -24,7 +23,7 @@ describe('Route chain.getAsset', () => { expect(response.content.nonce).toBe(asset.nonce) expect(response.content.creator).toBe(asset.creator.toString('hex')) expect(response.content.owner).toBe(asset.owner.toString('hex')) - expect(response.content.supply).toBe(CurrencyUtils.encode(asset.supply)) + expect(response.content.supply).toBe(asset.supply.toString()) expect(response.content.createdTransactionHash).toBe( asset.createdTransactionHash.toString('hex'), ) diff --git a/ironfish/src/rpc/routes/chain/getAsset.ts b/ironfish/src/rpc/routes/chain/getAsset.ts index 4eb937fbfe..96915b87b6 100644 --- a/ironfish/src/rpc/routes/chain/getAsset.ts +++ b/ironfish/src/rpc/routes/chain/getAsset.ts @@ -6,7 +6,6 @@ import * as yup from 'yup' import { Assert } from '../../../assert' import { AssetValue } from '../../../blockchain/database/assetValue' import { FullNode } from '../../../node' -import { CurrencyUtils } from '../../../utils' import { AssetStatus } from '../../../wallet' import { RpcNotFoundError, RpcValidationError } from '../../adapters' import { ApiNamespace } from '../namespaces' @@ -81,7 +80,7 @@ routes.register( nonce: asset.nonce, creator: asset.creator.toString('hex'), owner: asset.owner.toString('hex'), - supply: CurrencyUtils.encode(asset.supply), + supply: asset.supply.toString(), status: await getAssetStatus(node, asset), verification: node.assetsVerifier.verify(asset.id), }) diff --git a/ironfish/src/rpc/routes/chain/getTransactionStream.ts b/ironfish/src/rpc/routes/chain/getTransactionStream.ts index 2a5adbfd24..5ca0973f6b 100644 --- a/ironfish/src/rpc/routes/chain/getTransactionStream.ts +++ b/ironfish/src/rpc/routes/chain/getTransactionStream.ts @@ -7,7 +7,7 @@ import { ChainProcessor } from '../../../chainProcessor' import { FullNode } from '../../../node' import { Block } from '../../../primitives/block' import { BlockHeader } from '../../../primitives/blockheader' -import { BufferUtils, CurrencyUtils } from '../../../utils' +import { BufferUtils } from '../../../utils' import { PromiseUtils } from '../../../utils/promise' import { isValidIncomingViewKey, isValidOutgoingViewKey } from '../../../wallet/validator' import { RpcValidationError } from '../../adapters/errors' @@ -158,7 +158,7 @@ routes.register { @@ -84,7 +83,7 @@ describe('Route wallet/burnAsset', () => { account: account.name, assetId: assetId.toString('hex'), fee: '1', - value: CurrencyUtils.encode(value), + value: value.toString(), }) const walletTransaction = await account.getTransaction(burnTransaction.hash()) diff --git a/ironfish/src/rpc/routes/wallet/burnAsset.ts b/ironfish/src/rpc/routes/wallet/burnAsset.ts index 69fd388246..41f0c12b02 100644 --- a/ironfish/src/rpc/routes/wallet/burnAsset.ts +++ b/ironfish/src/rpc/routes/wallet/burnAsset.ts @@ -123,7 +123,7 @@ routes.register( hash: transaction.hash().toString('hex'), name: asset.name.toString('hex'), assetName: asset.name.toString('hex'), - value: CurrencyUtils.encode(burn.value), + value: burn.value.toString(), }) }, ) diff --git a/ironfish/src/rpc/routes/wallet/getAccountNotesStream.test.ts b/ironfish/src/rpc/routes/wallet/getAccountNotesStream.test.ts index 5a480bc087..25ff76751e 100644 --- a/ironfish/src/rpc/routes/wallet/getAccountNotesStream.test.ts +++ b/ironfish/src/rpc/routes/wallet/getAccountNotesStream.test.ts @@ -5,7 +5,7 @@ import { BufferMap } from 'buffer-map' import { Assert } from '../../../assert' import { useAccountFixture, useBlockWithTx } from '../../../testUtilities' import { createRouteTest } from '../../../testUtilities/routeTest' -import { AsyncUtils, BufferUtils, CurrencyUtils } from '../../../utils' +import { AsyncUtils, BufferUtils } from '../../../utils' import { DecryptedNoteValue } from '../../../wallet/walletdb/decryptedNoteValue' describe('Route wallet/getAccountNotesStream', () => { @@ -44,7 +44,7 @@ describe('Route wallet/getAccountNotesStream', () => { Assert.isNotUndefined(expectedNote) - expect(note.value).toEqual(CurrencyUtils.encode(expectedNote.note.value())) + expect(note.value).toEqual(expectedNote.note.value().toString()) expect(note.assetId).toEqual(expectedNote.note.assetId().toString('hex')) expect(note.memo).toEqual(BufferUtils.toHuman(expectedNote.note.memo())) expect(note.sender).toEqual(expectedNote.note.sender()) diff --git a/ironfish/src/rpc/routes/wallet/getAccountNotesStream.ts b/ironfish/src/rpc/routes/wallet/getAccountNotesStream.ts index a078bfa2f1..7da311e59c 100644 --- a/ironfish/src/rpc/routes/wallet/getAccountNotesStream.ts +++ b/ironfish/src/rpc/routes/wallet/getAccountNotesStream.ts @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import * as yup from 'yup' -import { BufferUtils, CurrencyUtils } from '../../../utils' +import { BufferUtils } from '../../../utils' import { ApiNamespace } from '../namespaces' import { routes } from '../router' import { AssertHasRpcContext } from '../rpcContext' @@ -46,7 +46,7 @@ routes.register( status: await node.wallet.getAssetStatus(account, asset, { confirmations: request.data.confirmations, }), - supply: asset.supply ? CurrencyUtils.encode(asset.supply) : undefined, + supply: asset.supply ? asset.supply.toString() : undefined, verification: node.assetsVerifier.verify(asset.id), }) }, diff --git a/ironfish/src/rpc/routes/wallet/getAssets.ts b/ironfish/src/rpc/routes/wallet/getAssets.ts index dc221813c9..eb0829ebc9 100644 --- a/ironfish/src/rpc/routes/wallet/getAssets.ts +++ b/ironfish/src/rpc/routes/wallet/getAssets.ts @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import * as yup from 'yup' -import { CurrencyUtils } from '../../../utils' import { RpcAsset, RpcAssetSchema } from '../chain' import { ApiNamespace } from '../namespaces' import { routes } from '../router' @@ -50,7 +49,7 @@ routes.register( status: await node.wallet.getAssetStatus(account, asset, { confirmations: request.data.confirmations, }), - supply: asset.supply !== null ? CurrencyUtils.encode(asset.supply) : undefined, + supply: asset.supply !== null ? asset.supply.toString() : undefined, createdTransactionHash: asset.createdTransactionHash.toString('hex'), verification: node.assetsVerifier.verify(asset.id), }) diff --git a/ironfish/src/rpc/routes/wallet/getBalances.ts b/ironfish/src/rpc/routes/wallet/getBalances.ts index 6f8bd43f7b..3f34c14cab 100644 --- a/ironfish/src/rpc/routes/wallet/getBalances.ts +++ b/ironfish/src/rpc/routes/wallet/getBalances.ts @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import * as yup from 'yup' import { AssetVerification } from '../../../assets' -import { CurrencyUtils } from '../../../utils' import { ApiNamespace } from '../namespaces' import { routes } from '../router' import { AssertHasRpcContext } from '../rpcContext' @@ -113,13 +112,13 @@ routes.register( assetOwner: asset?.owner.toString('hex') ?? '', assetVerification: { status: context.assetsVerifier.verify(balance.assetId).status }, blockHash: balance.blockHash?.toString('hex') ?? null, - confirmed: CurrencyUtils.encode(balance.confirmed), + confirmed: balance.confirmed.toString(), sequence: balance.sequence, - unconfirmed: CurrencyUtils.encode(balance.unconfirmed), + unconfirmed: balance.unconfirmed.toString(), unconfirmedCount: balance.unconfirmedCount, - pending: CurrencyUtils.encode(balance.pending), + pending: balance.pending.toString(), pendingCount: balance.pendingCount, - available: CurrencyUtils.encode(balance.available), + available: balance.available.toString(), availableNoteCount: balance.availableNoteCount, }) } diff --git a/ironfish/src/rpc/routes/wallet/mintAsset.test.ts b/ironfish/src/rpc/routes/wallet/mintAsset.test.ts index 4fe62e8841..9fe2480aea 100644 --- a/ironfish/src/rpc/routes/wallet/mintAsset.test.ts +++ b/ironfish/src/rpc/routes/wallet/mintAsset.test.ts @@ -5,7 +5,6 @@ import { Asset } from '@ironfish/rust-nodejs' import { Assert } from '../../../assert' import { useAccountFixture, useMinerBlockFixture, useTxFixture } from '../../../testUtilities' import { createRouteTest } from '../../../testUtilities/routeTest' -import { CurrencyUtils } from '../../../utils' import { serializeRpcWalletTransaction } from './serializers' describe('Route wallet/mintAsset', () => { @@ -112,7 +111,7 @@ describe('Route wallet/mintAsset', () => { fee: '1', metadata: asset.metadata().toString('utf8'), name: asset.name().toString('utf8'), - value: CurrencyUtils.encode(mintData.value), + value: mintData.value.toString(), transferOwnershipTo: newOwner, }) diff --git a/ironfish/src/rpc/routes/wallet/serializers.ts b/ironfish/src/rpc/routes/wallet/serializers.ts index bb2c27b627..4461a5cfa5 100644 --- a/ironfish/src/rpc/routes/wallet/serializers.ts +++ b/ironfish/src/rpc/routes/wallet/serializers.ts @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import { Config } from '../../../fileStores' -import { BufferUtils, CurrencyUtils } from '../../../utils' +import { BufferUtils } from '../../../utils' import { Account, Wallet } from '../../../wallet' import { isMultisigHardwareSignerImport, @@ -135,7 +135,7 @@ export function serializeRpcWalletNote( asset?: AssetValue, ): RpcWalletNote { return { - value: CurrencyUtils.encode(note.note.value()), + value: note.note.value().toString(), assetId: note.note.assetId().toString('hex'), assetName: asset?.name.toString('hex') || '', memo: BufferUtils.toHuman(note.note.memo()), diff --git a/ironfish/src/utils/currency.test.ts b/ironfish/src/utils/currency.test.ts index fae23808fa..22c40cdf17 100644 --- a/ironfish/src/utils/currency.test.ts +++ b/ironfish/src/utils/currency.test.ts @@ -5,14 +5,6 @@ import { Asset } from '@ironfish/rust-nodejs' import { CurrencyUtils } from './currency' describe('CurrencyUtils', () => { - it('encode', () => { - expect(CurrencyUtils.encode(0n)).toEqual('0') - expect(CurrencyUtils.encode(1n)).toEqual('1') - expect(CurrencyUtils.encode(100n)).toEqual('100') - expect(CurrencyUtils.encode(10000n)).toEqual('10000') - expect(CurrencyUtils.encode(100000000n)).toEqual('100000000') - }) - it('decode', () => { expect(CurrencyUtils.decode('0')).toEqual(0n) expect(CurrencyUtils.decode('1')).toEqual(1n) diff --git a/ironfish/src/utils/currency.ts b/ironfish/src/utils/currency.ts index bd35d3a2d6..bcf086cb5f 100644 --- a/ironfish/src/utils/currency.ts +++ b/ironfish/src/utils/currency.ts @@ -33,13 +33,6 @@ export class CurrencyUtils { return BigIntUtils.tryParse(amount) } - /** - * Serialize ore into a string - */ - static encode(amount: bigint): string { - return amount.toString() - } - /** * Parses a value in a major denomination as the minor denomination where possible: * - $IRON is always going to have 8 decimal places. diff --git a/ironfish/src/utils/yup.test.ts b/ironfish/src/utils/yup.test.ts index bed04336a5..854b27553b 100644 --- a/ironfish/src/utils/yup.test.ts +++ b/ironfish/src/utils/yup.test.ts @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import * as yup from 'yup' -import { CurrencyUtils } from './currency' import { YupUtils } from './yup' describe('YupUtils', () => { @@ -34,8 +33,8 @@ describe('YupUtils', () => { }) it('currency', () => { - expect(YupUtils.currency().isValidSync(CurrencyUtils.encode(6n))).toBe(true) - expect(YupUtils.currency({ min: 0n }).isValidSync(CurrencyUtils.encode(-1n))).toBe(false) + expect(YupUtils.currency().isValidSync(6n.toString())).toBe(true) + expect(YupUtils.currency({ min: 0n }).isValidSync((-1n).toString())).toBe(false) expect(YupUtils.currency({ min: 0n }).isValidSync('0.1')).toBe(false) expect(YupUtils.currency().isValidSync('hello world')).toBe(false) expect(YupUtils.currency().isValidSync(0.00046)).toBe(false)