From 84e4811d1466804123f9f26e31662616996e2df8 Mon Sep 17 00:00:00 2001 From: Rahul Patni Date: Thu, 7 Sep 2023 09:09:01 -0700 Subject: [PATCH 01/26] new burn asset response with asset object --- ironfish/src/rpc/routes/wallet/burnAsset.ts | 48 +++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/ironfish/src/rpc/routes/wallet/burnAsset.ts b/ironfish/src/rpc/routes/wallet/burnAsset.ts index e798b4e998..bdba8070d0 100644 --- a/ironfish/src/rpc/routes/wallet/burnAsset.ts +++ b/ironfish/src/rpc/routes/wallet/burnAsset.ts @@ -17,9 +17,44 @@ export interface BurnAssetRequest { confirmations?: number } +export interface RpcAsset { + id: string + metadata: string + name: string + nonce: number + creator: string + owner: string + createdTransactionHash: string + supply?: string // Populated for assets the account owns + blockHash?: string // Populated once the asset has been added to the main chain + sequence?: number // Populated once the asset has been added to the main chain +} + +export const RpcAssetSchema: yup.ObjectSchema = yup + .object({ + id: yup.string().required(), + metadata: yup.string().required(), + name: yup.string().required(), + nonce: yup.number().required(), + creator: yup.string().required(), + owner: yup.string().required(), + createdTransactionHash: yup.string().required(), + supply: yup.string().optional(), + blockHash: yup.string().optional(), + sequence: yup.number().optional(), + }) + .defined() + export interface BurnAssetResponse { + asset: RpcAsset + /** + * @deprecated Please use `asset.id` instead + */ assetId: string hash: string + /** + * @deprecated Please use `asset.name` instead + */ name: string value: string } @@ -38,6 +73,7 @@ export const BurnAssetRequestSchema: yup.ObjectSchema = yup export const BurnAssetResponseSchema: yup.ObjectSchema = yup .object({ + asset: RpcAssetSchema.required(), assetId: yup.string().required(), hash: yup.string().required(), name: yup.string().required(), @@ -71,6 +107,18 @@ routes.register( const burn = transaction.burns[0] request.end({ + asset: { + id: asset.id.toString('hex'), + metadata: asset.metadata.toString('hex'), + name: asset.name.toString('hex'), + nonce: asset.nonce, + creator: asset.creator.toString('hex'), + owner: asset.owner.toString('hex'), + createdTransactionHash: asset.createdTransactionHash.toString('hex'), + supply: asset.supply?.toString(), + blockHash: asset.blockHash?.toString('hex'), + sequence: asset.sequence || undefined, + }, assetId: burn.assetId.toString('hex'), hash: transaction.hash().toString('hex'), name: asset.name.toString('hex'), From 6ba92da63ab8e56ddb552f63d22131e6f11b7789 Mon Sep 17 00:00:00 2001 From: Rahul Patni Date: Thu, 7 Sep 2023 09:34:38 -0700 Subject: [PATCH 02/26] updating tests --- ironfish/src/rpc/routes/wallet/burnAsset.test.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ironfish/src/rpc/routes/wallet/burnAsset.test.ts b/ironfish/src/rpc/routes/wallet/burnAsset.test.ts index 725725166b..aa284253fe 100644 --- a/ironfish/src/rpc/routes/wallet/burnAsset.test.ts +++ b/ironfish/src/rpc/routes/wallet/burnAsset.test.ts @@ -74,6 +74,10 @@ describe('Route wallet/burnAsset', () => { }) jest.spyOn(wallet, 'burn').mockResolvedValueOnce(burnTransaction) + const accountAsset = await account.getAsset(assetId) + + expect(accountAsset).toBeDefined() + const response = await routeTest.client.wallet.burnAsset({ account: account.name, assetId: assetId.toString('hex'), @@ -82,6 +86,18 @@ describe('Route wallet/burnAsset', () => { }) expect(response.content).toEqual({ + asset: { + id: asset.id().toString('hex'), + metadata: asset.metadata().toString('hex'), + name: asset.name().toString('hex'), + creator: asset.creator().toString('hex'), + nonce: accountAsset?.nonce ?? null, + owner: accountAsset?.owner?.toString('hex') ?? null, + sequence: accountAsset?.sequence ?? null, + supply: accountAsset?.supply?.toString() ?? null, + blockHash: accountAsset?.blockHash?.toString('hex') ?? null, + createdTransactionHash: accountAsset?.createdTransactionHash?.toString('hex') ?? null, + }, assetId: asset.id().toString('hex'), name: asset.name().toString('hex'), hash: burnTransaction.hash().toString('hex'), From dfdf84098de86f4a24a2ad871f2c311e247b5cde Mon Sep 17 00:00:00 2001 From: Rahul Patni Date: Fri, 8 Sep 2023 15:43:58 -0700 Subject: [PATCH 03/26] moving asset to a types file to be reused in mint and burn --- ironfish/src/rpc/routes/wallet/burnAsset.ts | 42 +----------------- ironfish/src/rpc/routes/wallet/mintAsset.ts | 10 +++++ ironfish/src/rpc/types.ts | 48 +++++++++++++++++++++ 3 files changed, 60 insertions(+), 40 deletions(-) create mode 100644 ironfish/src/rpc/types.ts diff --git a/ironfish/src/rpc/routes/wallet/burnAsset.ts b/ironfish/src/rpc/routes/wallet/burnAsset.ts index bdba8070d0..caffcd5fa3 100644 --- a/ironfish/src/rpc/routes/wallet/burnAsset.ts +++ b/ironfish/src/rpc/routes/wallet/burnAsset.ts @@ -4,6 +4,7 @@ import * as yup from 'yup' import { Assert } from '../../../assert' import { CurrencyUtils, YupUtils } from '../../../utils' +import { constructRpcAsset, RpcAsset, RpcAssetSchema } from '../../types' import { ApiNamespace, routes } from '../router' import { getAccount } from './utils' @@ -17,34 +18,6 @@ export interface BurnAssetRequest { confirmations?: number } -export interface RpcAsset { - id: string - metadata: string - name: string - nonce: number - creator: string - owner: string - createdTransactionHash: string - supply?: string // Populated for assets the account owns - blockHash?: string // Populated once the asset has been added to the main chain - sequence?: number // Populated once the asset has been added to the main chain -} - -export const RpcAssetSchema: yup.ObjectSchema = yup - .object({ - id: yup.string().required(), - metadata: yup.string().required(), - name: yup.string().required(), - nonce: yup.number().required(), - creator: yup.string().required(), - owner: yup.string().required(), - createdTransactionHash: yup.string().required(), - supply: yup.string().optional(), - blockHash: yup.string().optional(), - sequence: yup.number().optional(), - }) - .defined() - export interface BurnAssetResponse { asset: RpcAsset /** @@ -107,18 +80,7 @@ routes.register( const burn = transaction.burns[0] request.end({ - asset: { - id: asset.id.toString('hex'), - metadata: asset.metadata.toString('hex'), - name: asset.name.toString('hex'), - nonce: asset.nonce, - creator: asset.creator.toString('hex'), - owner: asset.owner.toString('hex'), - createdTransactionHash: asset.createdTransactionHash.toString('hex'), - supply: asset.supply?.toString(), - blockHash: asset.blockHash?.toString('hex'), - sequence: asset.sequence || undefined, - }, + asset: constructRpcAsset(asset), assetId: burn.assetId.toString('hex'), hash: transaction.hash().toString('hex'), name: asset.name.toString('hex'), diff --git a/ironfish/src/rpc/routes/wallet/mintAsset.ts b/ironfish/src/rpc/routes/wallet/mintAsset.ts index cd8b476bd7..83e773b8ff 100644 --- a/ironfish/src/rpc/routes/wallet/mintAsset.ts +++ b/ironfish/src/rpc/routes/wallet/mintAsset.ts @@ -6,6 +6,7 @@ import * as yup from 'yup' import { Assert } from '../../../assert' import { CurrencyUtils, YupUtils } from '../../../utils' import { MintAssetOptions } from '../../../wallet/interfaces/mintAssetOptions' +import { constructRpcAsset, RpcAsset, RpcAssetSchema } from '../../types' import { ApiNamespace, routes } from '../router' import { getAccount } from './utils' @@ -22,8 +23,15 @@ export interface MintAssetRequest { } export interface MintAssetResponse { + asset: RpcAsset + /** + * @deprecated Please use `asset.id` instead + */ assetId: string hash: string + /** + * @deprecated Please use `asset.name` instead + */ name: string value: string } @@ -44,6 +52,7 @@ export const MintAssetRequestSchema: yup.ObjectSchema = yup export const MintAssetResponseSchema: yup.ObjectSchema = yup .object({ + asset: RpcAssetSchema.defined(), assetId: yup.string().required(), hash: yup.string().required(), name: yup.string().required(), @@ -94,6 +103,7 @@ routes.register( const mint = transaction.mints[0] request.end({ + asset: constructRpcAsset(mint.asset), assetId: mint.asset.id().toString('hex'), hash: transaction.hash().toString('hex'), name: mint.asset.name().toString('hex'), diff --git a/ironfish/src/rpc/types.ts b/ironfish/src/rpc/types.ts new file mode 100644 index 0000000000..f81df1fd77 --- /dev/null +++ b/ironfish/src/rpc/types.ts @@ -0,0 +1,48 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * 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 { Asset } from '../../../ironfish-rust-nodejs' +import { AssetValue as BlochcainAssetValue } from '../blockchain/database/assetValue' +import { AssetValue as WalletAssetValue } from '../wallet/walletdb/assetValue' + +export interface RpcAsset { + id: string + metadata: string + name: string + nonce: number + creator: string + // chain?: { + // owner?: string + // supply?: string // Populated for assets the account owns + // blockHash: string + // blockSequence: number + // createdAtTransactionHash?: string // Populated once the asset has been added to the main chain + // createdAtblockHash?: string // Populated once the asset has been added to the main chain + // createdAtSequence?: number // Populated once the asset has been added to the main chain + // } +} + +export const RpcAssetSchema: yup.ObjectSchema = yup + .object({ + id: yup.string().required(), + metadata: yup.string().required(), + name: yup.string().required(), + nonce: yup.number().required(), + creator: yup.string().required(), + owner: yup.string().optional(), + }) + .defined() + +export const constructRpcAsset = ( + asset: Asset | WalletAssetValue | BlochcainAssetValue, +): RpcAsset => { + return { + id: asset.id.toString('hex'), + metadata: asset.metadata.toString('hex'), + name: asset.name.toString('hex'), + nonce: typeof asset.nonce === 'number' ? asset.nonce : asset.nonce(), + creator: asset.creator.toString('hex'), + } +} From a9fd8f85925ccf89e8cdad183b58207c3ae2a2d3 Mon Sep 17 00:00:00 2001 From: Rahul Patni Date: Fri, 8 Sep 2023 15:44:33 -0700 Subject: [PATCH 04/26] updating test --- ironfish/src/rpc/routes/wallet/burnAsset.test.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ironfish/src/rpc/routes/wallet/burnAsset.test.ts b/ironfish/src/rpc/routes/wallet/burnAsset.test.ts index aa284253fe..17ee5968f5 100644 --- a/ironfish/src/rpc/routes/wallet/burnAsset.test.ts +++ b/ironfish/src/rpc/routes/wallet/burnAsset.test.ts @@ -92,11 +92,6 @@ describe('Route wallet/burnAsset', () => { name: asset.name().toString('hex'), creator: asset.creator().toString('hex'), nonce: accountAsset?.nonce ?? null, - owner: accountAsset?.owner?.toString('hex') ?? null, - sequence: accountAsset?.sequence ?? null, - supply: accountAsset?.supply?.toString() ?? null, - blockHash: accountAsset?.blockHash?.toString('hex') ?? null, - createdTransactionHash: accountAsset?.createdTransactionHash?.toString('hex') ?? null, }, assetId: asset.id().toString('hex'), name: asset.name().toString('hex'), From d659113951b92e29258f8e50d192dcae15495566 Mon Sep 17 00:00:00 2001 From: Rahul Patni Date: Tue, 12 Sep 2023 08:34:37 -0700 Subject: [PATCH 05/26] adding two different construct rpc methods --- ironfish/src/rpc/routes/wallet/getBalances.ts | 10 ++++++++++ ironfish/src/rpc/routes/wallet/mintAsset.test.ts | 7 +++++++ ironfish/src/rpc/routes/wallet/mintAsset.ts | 4 ++-- ironfish/src/rpc/routes/wallet/types.ts | 9 +++++++++ ironfish/src/rpc/routes/wallet/utils.ts | 2 ++ ironfish/src/rpc/types.ts | 14 ++++++++++++-- 6 files changed, 42 insertions(+), 4 deletions(-) diff --git a/ironfish/src/rpc/routes/wallet/getBalances.ts b/ironfish/src/rpc/routes/wallet/getBalances.ts index 562b955ce1..52efd4f90d 100644 --- a/ironfish/src/rpc/routes/wallet/getBalances.ts +++ b/ironfish/src/rpc/routes/wallet/getBalances.ts @@ -4,6 +4,7 @@ import * as yup from 'yup' import { AssetVerification } from '../../../assets' import { CurrencyUtils } from '../../../utils' +import { constructRpcAsset, RpcAsset, RpcAssetSchema } from '../../types' import { ApiNamespace, routes } from '../router' import { getAccount } from './utils' @@ -15,8 +16,15 @@ export interface GetBalancesRequest { export interface GetBalancesResponse { account: string balances: { + asset?: RpcAsset assetId: string + /** + * @deprecated Please use `asset.name` instead + */ assetName: string + /** + * @deprecated Please use `asset.creator` instead + */ assetCreator: string assetOwner: string assetVerification: AssetVerification @@ -47,6 +55,7 @@ export const GetBalancesResponseSchema: yup.ObjectSchema = yup .object() .shape({ + asset: RpcAssetSchema.defined(), assetId: yup.string().defined(), assetName: yup.string().defined(), assetCreator: yup.string().defined(), @@ -86,6 +95,7 @@ routes.register( const asset = await account.getAsset(balance.assetId) balances.push({ + asset: asset ? constructRpcAsset(asset) : undefined, assetId: balance.assetId.toString('hex'), assetName: asset?.name.toString('hex') ?? '', assetCreator: asset?.creator.toString('hex') ?? '', diff --git a/ironfish/src/rpc/routes/wallet/mintAsset.test.ts b/ironfish/src/rpc/routes/wallet/mintAsset.test.ts index cf394c8816..2a4f7ad34a 100644 --- a/ironfish/src/rpc/routes/wallet/mintAsset.test.ts +++ b/ironfish/src/rpc/routes/wallet/mintAsset.test.ts @@ -89,6 +89,13 @@ describe('Route wallet/mintAsset', () => { }) expect(response.content).toEqual({ + asset: { + id: asset.id().toString('hex'), + metadata: asset.metadata().toString('hex'), + name: asset.name().toString('hex'), + creator: asset.creator().toString('hex'), + nonce: asset.nonce() ?? null, + }, assetId: asset.id().toString('hex'), hash: mintTransaction.hash().toString('hex'), name: asset.name().toString('hex'), diff --git a/ironfish/src/rpc/routes/wallet/mintAsset.ts b/ironfish/src/rpc/routes/wallet/mintAsset.ts index 83e773b8ff..0324a953b8 100644 --- a/ironfish/src/rpc/routes/wallet/mintAsset.ts +++ b/ironfish/src/rpc/routes/wallet/mintAsset.ts @@ -6,7 +6,7 @@ import * as yup from 'yup' import { Assert } from '../../../assert' import { CurrencyUtils, YupUtils } from '../../../utils' import { MintAssetOptions } from '../../../wallet/interfaces/mintAssetOptions' -import { constructRpcAsset, RpcAsset, RpcAssetSchema } from '../../types' +import { constructRpcAssetFromAsset, RpcAsset, RpcAssetSchema } from '../../types' import { ApiNamespace, routes } from '../router' import { getAccount } from './utils' @@ -103,7 +103,7 @@ routes.register( const mint = transaction.mints[0] request.end({ - asset: constructRpcAsset(mint.asset), + asset: constructRpcAssetFromAsset(mint.asset), assetId: mint.asset.id().toString('hex'), hash: transaction.hash().toString('hex'), name: mint.asset.name().toString('hex'), diff --git a/ironfish/src/rpc/routes/wallet/types.ts b/ironfish/src/rpc/routes/wallet/types.ts index a6d1a9d960..6868de1956 100644 --- a/ironfish/src/rpc/routes/wallet/types.ts +++ b/ironfish/src/rpc/routes/wallet/types.ts @@ -4,6 +4,7 @@ import * as yup from 'yup' import { AccountImport } from '../../../wallet/walletdb/accountValue' +import { RpcAsset, RpcAssetSchema } from '../../types' export type RpcAccountTransaction = { hash: string @@ -21,6 +22,9 @@ export type RpcAccountTransaction = { export type RcpAccountAssetBalanceDelta = { assetId: string + /** + * @deprecated Please use `asset.name` instead + */ assetName: string delta: string } @@ -28,6 +32,10 @@ export type RcpAccountAssetBalanceDelta = { export type RpcWalletNote = { value: string assetId: string + asset?: RpcAsset + /** + * @deprecated Please use `asset.name` instead + */ assetName: string memo: string sender: string @@ -51,6 +59,7 @@ export const RpcWalletNoteSchema: yup.ObjectSchema = yup .object({ value: yup.string().defined(), assetId: yup.string().defined(), + asset: RpcAssetSchema.optional(), assetName: yup.string().defined(), memo: yup.string().defined(), sender: yup.string().defined(), diff --git a/ironfish/src/rpc/routes/wallet/utils.ts b/ironfish/src/rpc/routes/wallet/utils.ts index 232d0cf2b9..7a23f47fc6 100644 --- a/ironfish/src/rpc/routes/wallet/utils.ts +++ b/ironfish/src/rpc/routes/wallet/utils.ts @@ -10,6 +10,7 @@ import { DecryptedNoteValue } from '../../../wallet/walletdb/decryptedNoteValue' import { TransactionValue } from '../../../wallet/walletdb/transactionValue' import { WorkerPool } from '../../../workerPool' import { ValidationError } from '../../adapters' +import { constructRpcAsset } from '../../types' import { RcpAccountAssetBalanceDelta, RpcAccountImport, @@ -173,6 +174,7 @@ export function serializeRpcWalletNote( return { value: CurrencyUtils.encode(note.note.value()), assetId: note.note.assetId().toString('hex'), + asset: asset ? constructRpcAsset(asset) : undefined, assetName: asset?.name.toString('hex') || '', memo: note.note.memo(), owner: note.note.owner(), diff --git a/ironfish/src/rpc/types.ts b/ironfish/src/rpc/types.ts index f81df1fd77..97e726dd69 100644 --- a/ironfish/src/rpc/types.ts +++ b/ironfish/src/rpc/types.ts @@ -36,13 +36,23 @@ export const RpcAssetSchema: yup.ObjectSchema = yup .defined() export const constructRpcAsset = ( - asset: Asset | WalletAssetValue | BlochcainAssetValue, + asset: WalletAssetValue | BlochcainAssetValue | Readonly, ): RpcAsset => { return { id: asset.id.toString('hex'), metadata: asset.metadata.toString('hex'), name: asset.name.toString('hex'), - nonce: typeof asset.nonce === 'number' ? asset.nonce : asset.nonce(), + nonce: asset.nonce, creator: asset.creator.toString('hex'), } } + +export const constructRpcAssetFromAsset = (asset: Asset): RpcAsset => { + return { + id: asset.id().toString('hex'), + metadata: asset.metadata().toString('hex'), + name: asset.name().toString('hex'), + nonce: asset.nonce(), + creator: asset.creator().toString('hex'), + } +} From de1119960aaff4d963925807139f624dd19b1f3b Mon Sep 17 00:00:00 2001 From: Rahul Patni Date: Tue, 12 Sep 2023 11:14:09 -0700 Subject: [PATCH 06/26] updating RcpAccountAssetBalanceDeltaSchema --- .../routes/wallet/getAccountTransaction.ts | 21 +++++++------------ ironfish/src/rpc/routes/wallet/types.ts | 9 ++++++++ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/ironfish/src/rpc/routes/wallet/getAccountTransaction.ts b/ironfish/src/rpc/routes/wallet/getAccountTransaction.ts index 3f36339c15..b43270b880 100644 --- a/ironfish/src/rpc/routes/wallet/getAccountTransaction.ts +++ b/ironfish/src/rpc/routes/wallet/getAccountTransaction.ts @@ -5,7 +5,12 @@ import * as yup from 'yup' import { TransactionStatus, TransactionType } from '../../../wallet' import { RpcSpend, RpcSpendSchema } from '../chain' import { ApiNamespace, routes } from '../router' -import { RpcWalletNote, RpcWalletNoteSchema } from './types' +import { + RcpAccountAssetBalanceDelta, + RcpAccountAssetBalanceDeltaSchema, + RpcWalletNote, + RpcWalletNoteSchema, +} from './types' import { getAccount, getAccountDecryptedNotes, @@ -35,7 +40,7 @@ export type GetAccountTransactionResponse = { burnsCount: number timestamp: number submittedSequence: number - assetBalanceDeltas: Array<{ assetId: string; assetName: string; delta: string }> + assetBalanceDeltas: RcpAccountAssetBalanceDelta[] notes: RpcWalletNote[] spends: RpcSpend[] } | null @@ -69,17 +74,7 @@ export const GetAccountTransactionResponseSchema: yup.ObjectSchema = + yup + .object({ + assetId: yup.string().defined(), + assetName: yup.string().defined(), + delta: yup.string().defined(), + }) + .defined() + export type RpcWalletNote = { value: string assetId: string From de6602e409b6cb89994d8652bdd28a7f5a236179 Mon Sep 17 00:00:00 2001 From: Rahul Patni Date: Tue, 12 Sep 2023 11:28:17 -0700 Subject: [PATCH 07/26] updating get account transactions --- .../routes/wallet/getAccountTransactions.ts | 21 +++++++------------ ironfish/src/rpc/routes/wallet/types.ts | 2 +- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/ironfish/src/rpc/routes/wallet/getAccountTransactions.ts b/ironfish/src/rpc/routes/wallet/getAccountTransactions.ts index b66049c778..ad2865d1e5 100644 --- a/ironfish/src/rpc/routes/wallet/getAccountTransactions.ts +++ b/ironfish/src/rpc/routes/wallet/getAccountTransactions.ts @@ -9,7 +9,12 @@ import { TransactionValue } from '../../../wallet/walletdb/transactionValue' import { RpcRequest } from '../../request' import { RpcSpend, RpcSpendSchema } from '../chain' import { ApiNamespace, routes } from '../router' -import { RpcWalletNote, RpcWalletNoteSchema } from './types' +import { + RcpAccountAssetBalanceDelta, + RcpAccountAssetBalanceDeltaSchema, + RpcWalletNote, + RpcWalletNoteSchema, +} from './types' import { getAccount, getAccountDecryptedNotes, @@ -43,7 +48,7 @@ export type GetAccountTransactionsResponse = { expiration: number timestamp: number submittedSequence: number - assetBalanceDeltas: Array<{ assetId: string; assetName: string; delta: string }> + assetBalanceDeltas: RcpAccountAssetBalanceDelta[] notes?: RpcWalletNote[] spends?: RpcSpend[] } @@ -79,17 +84,7 @@ export const GetAccountTransactionsResponseSchema: yup.ObjectSchema Date: Tue, 12 Sep 2023 11:43:10 -0700 Subject: [PATCH 08/26] deprecating asset variables in balance endpoints --- ironfish/src/rpc/routes/wallet/getBalance.ts | 9 +++++++++ ironfish/src/rpc/routes/wallet/getBalances.ts | 6 ++++++ ironfish/src/rpc/types.ts | 9 --------- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/ironfish/src/rpc/routes/wallet/getBalance.ts b/ironfish/src/rpc/routes/wallet/getBalance.ts index e3da2687e7..4353187c87 100644 --- a/ironfish/src/rpc/routes/wallet/getBalance.ts +++ b/ironfish/src/rpc/routes/wallet/getBalance.ts @@ -4,6 +4,7 @@ import { Asset } from '@ironfish/rust-nodejs' import * as yup from 'yup' import { AssetVerification } from '../../../assets' +import { constructRpcAsset, RpcAsset, RpcAssetSchema } from '../../types' import { ApiNamespace, routes } from '../router' import { getAccount } from './utils' @@ -18,6 +19,10 @@ export type GetBalanceRequest = export type GetBalanceResponse = { account: string assetId: string + asset?: RpcAsset + /** + * @deprecated Please use getAsset endpoint to get this information + * */ assetVerification: AssetVerification confirmed: string unconfirmed: string @@ -42,6 +47,7 @@ export const GetBalanceResponseSchema: yup.ObjectSchema = yu .object({ account: yup.string().defined(), assetId: yup.string().defined(), + asset: RpcAssetSchema.optional(), assetVerification: yup .object({ status: yup.string().oneOf(['verified', 'unverified', 'unknown']).defined() }) .defined(), @@ -74,9 +80,12 @@ routes.register( confirmations, }) + const asset = await account.getAsset(assetId) + request.end({ account: account.name, assetId: assetId.toString('hex'), + asset: asset ? constructRpcAsset(asset) : undefined, assetVerification: node.assetsVerifier.verify(assetId), confirmed: balance.confirmed.toString(), unconfirmed: balance.unconfirmed.toString(), diff --git a/ironfish/src/rpc/routes/wallet/getBalances.ts b/ironfish/src/rpc/routes/wallet/getBalances.ts index 52efd4f90d..5b77e5660f 100644 --- a/ironfish/src/rpc/routes/wallet/getBalances.ts +++ b/ironfish/src/rpc/routes/wallet/getBalances.ts @@ -26,7 +26,13 @@ export interface GetBalancesResponse { * @deprecated Please use `asset.creator` instead */ assetCreator: string + /** + * @deprecated Please use getAsset endpoint to get this information + * */ assetOwner: string + /** + * @deprecated Please use getAsset endpoint to get this information + * */ assetVerification: AssetVerification confirmed: string unconfirmed: string diff --git a/ironfish/src/rpc/types.ts b/ironfish/src/rpc/types.ts index 97e726dd69..2af1bd7d15 100644 --- a/ironfish/src/rpc/types.ts +++ b/ironfish/src/rpc/types.ts @@ -13,15 +13,6 @@ export interface RpcAsset { name: string nonce: number creator: string - // chain?: { - // owner?: string - // supply?: string // Populated for assets the account owns - // blockHash: string - // blockSequence: number - // createdAtTransactionHash?: string // Populated once the asset has been added to the main chain - // createdAtblockHash?: string // Populated once the asset has been added to the main chain - // createdAtSequence?: number // Populated once the asset has been added to the main chain - // } } export const RpcAssetSchema: yup.ObjectSchema = yup From 067e4599ba3132869b278e318616f9b170e084ac Mon Sep 17 00:00:00 2001 From: Rahul Patni Date: Tue, 12 Sep 2023 13:53:37 -0700 Subject: [PATCH 09/26] removing asset object when id doesn't guarantee asset object is found --- ironfish/src/rpc/routes/wallet/getBalance.ts | 4 +--- ironfish/src/rpc/routes/wallet/getBalances.ts | 7 +++---- ironfish/src/rpc/types.ts | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/ironfish/src/rpc/routes/wallet/getBalance.ts b/ironfish/src/rpc/routes/wallet/getBalance.ts index 4353187c87..f62c797d01 100644 --- a/ironfish/src/rpc/routes/wallet/getBalance.ts +++ b/ironfish/src/rpc/routes/wallet/getBalance.ts @@ -4,7 +4,7 @@ import { Asset } from '@ironfish/rust-nodejs' import * as yup from 'yup' import { AssetVerification } from '../../../assets' -import { constructRpcAsset, RpcAsset, RpcAssetSchema } from '../../types' +import { RpcAssetSchema } from '../../types' import { ApiNamespace, routes } from '../router' import { getAccount } from './utils' @@ -19,7 +19,6 @@ export type GetBalanceRequest = export type GetBalanceResponse = { account: string assetId: string - asset?: RpcAsset /** * @deprecated Please use getAsset endpoint to get this information * */ @@ -85,7 +84,6 @@ routes.register( request.end({ account: account.name, assetId: assetId.toString('hex'), - asset: asset ? constructRpcAsset(asset) : undefined, assetVerification: node.assetsVerifier.verify(assetId), confirmed: balance.confirmed.toString(), unconfirmed: balance.unconfirmed.toString(), diff --git a/ironfish/src/rpc/routes/wallet/getBalances.ts b/ironfish/src/rpc/routes/wallet/getBalances.ts index 5b77e5660f..22757b114d 100644 --- a/ironfish/src/rpc/routes/wallet/getBalances.ts +++ b/ironfish/src/rpc/routes/wallet/getBalances.ts @@ -4,7 +4,7 @@ import * as yup from 'yup' import { AssetVerification } from '../../../assets' import { CurrencyUtils } from '../../../utils' -import { constructRpcAsset, RpcAsset, RpcAssetSchema } from '../../types' +import { constructRpcAsset, RpcAssetSchema } from '../../types' import { ApiNamespace, routes } from '../router' import { getAccount } from './utils' @@ -16,14 +16,13 @@ export interface GetBalancesRequest { export interface GetBalancesResponse { account: string balances: { - asset?: RpcAsset assetId: string /** - * @deprecated Please use `asset.name` instead + * @deprecated Please use getAsset endpoint to get this information */ assetName: string /** - * @deprecated Please use `asset.creator` instead + * @deprecated Please use getAsset endpoint to get this information */ assetCreator: string /** diff --git a/ironfish/src/rpc/types.ts b/ironfish/src/rpc/types.ts index 2af1bd7d15..58680480de 100644 --- a/ironfish/src/rpc/types.ts +++ b/ironfish/src/rpc/types.ts @@ -7,7 +7,7 @@ import { Asset } from '../../../ironfish-rust-nodejs' import { AssetValue as BlochcainAssetValue } from '../blockchain/database/assetValue' import { AssetValue as WalletAssetValue } from '../wallet/walletdb/assetValue' -export interface RpcAsset { +export type RpcAsset = { id: string metadata: string name: string From bc00c672fd79492dcbc319568dfb40e8af3a9191 Mon Sep 17 00:00:00 2001 From: Rahul Patni Date: Tue, 12 Sep 2023 14:00:00 -0700 Subject: [PATCH 10/26] removing optional asset object --- ironfish/src/rpc/routes/wallet/mintAsset.test.ts | 2 +- ironfish/src/rpc/routes/wallet/types.ts | 3 +-- ironfish/src/rpc/routes/wallet/utils.ts | 2 -- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/ironfish/src/rpc/routes/wallet/mintAsset.test.ts b/ironfish/src/rpc/routes/wallet/mintAsset.test.ts index 2a4f7ad34a..73a24249a8 100644 --- a/ironfish/src/rpc/routes/wallet/mintAsset.test.ts +++ b/ironfish/src/rpc/routes/wallet/mintAsset.test.ts @@ -94,7 +94,7 @@ describe('Route wallet/mintAsset', () => { metadata: asset.metadata().toString('hex'), name: asset.name().toString('hex'), creator: asset.creator().toString('hex'), - nonce: asset.nonce() ?? null, + nonce: asset.nonce(), }, assetId: asset.id().toString('hex'), hash: mintTransaction.hash().toString('hex'), diff --git a/ironfish/src/rpc/routes/wallet/types.ts b/ironfish/src/rpc/routes/wallet/types.ts index f4fd388d6d..e6b9f83327 100644 --- a/ironfish/src/rpc/routes/wallet/types.ts +++ b/ironfish/src/rpc/routes/wallet/types.ts @@ -4,7 +4,7 @@ import * as yup from 'yup' import { AccountImport } from '../../../wallet/walletdb/accountValue' -import { RpcAsset, RpcAssetSchema } from '../../types' +import { RpcAssetSchema } from '../../types' export type RpcAccountTransaction = { hash: string @@ -41,7 +41,6 @@ export const RcpAccountAssetBalanceDeltaSchema: yup.ObjectSchema Date: Tue, 12 Sep 2023 14:11:47 -0700 Subject: [PATCH 11/26] removing unused variable --- ironfish/src/rpc/routes/wallet/getBalance.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/ironfish/src/rpc/routes/wallet/getBalance.ts b/ironfish/src/rpc/routes/wallet/getBalance.ts index f62c797d01..ea4528dfb9 100644 --- a/ironfish/src/rpc/routes/wallet/getBalance.ts +++ b/ironfish/src/rpc/routes/wallet/getBalance.ts @@ -79,8 +79,6 @@ routes.register( confirmations, }) - const asset = await account.getAsset(assetId) - request.end({ account: account.name, assetId: assetId.toString('hex'), From 862744adb620c894d66c570157bbc6544b30f089 Mon Sep 17 00:00:00 2001 From: Rahul Patni Date: Tue, 12 Sep 2023 14:37:51 -0700 Subject: [PATCH 12/26] removing construct functions --- ironfish/src/rpc/routes/wallet/burnAsset.ts | 11 ++++++-- ironfish/src/rpc/routes/wallet/getBalances.ts | 3 +-- ironfish/src/rpc/routes/wallet/mintAsset.ts | 10 +++++-- ironfish/src/rpc/types.ts | 26 +------------------ 4 files changed, 19 insertions(+), 31 deletions(-) diff --git a/ironfish/src/rpc/routes/wallet/burnAsset.ts b/ironfish/src/rpc/routes/wallet/burnAsset.ts index caffcd5fa3..22246e7d7a 100644 --- a/ironfish/src/rpc/routes/wallet/burnAsset.ts +++ b/ironfish/src/rpc/routes/wallet/burnAsset.ts @@ -4,7 +4,7 @@ import * as yup from 'yup' import { Assert } from '../../../assert' import { CurrencyUtils, YupUtils } from '../../../utils' -import { constructRpcAsset, RpcAsset, RpcAssetSchema } from '../../types' +import { RpcAsset, RpcAssetSchema } from '../../types' import { ApiNamespace, routes } from '../router' import { getAccount } from './utils' @@ -80,7 +80,14 @@ routes.register( const burn = transaction.burns[0] request.end({ - asset: constructRpcAsset(asset), + asset: { + id: asset.id.toString('hex'), + metadata: asset.metadata.toString('hex'), + name: asset.name.toString('hex'), + nonce: asset.nonce, + creator: asset.creator.toString('hex'), + owner: asset.owner.toString('hex'), + }, assetId: burn.assetId.toString('hex'), hash: transaction.hash().toString('hex'), name: asset.name.toString('hex'), diff --git a/ironfish/src/rpc/routes/wallet/getBalances.ts b/ironfish/src/rpc/routes/wallet/getBalances.ts index 22757b114d..be99393dc3 100644 --- a/ironfish/src/rpc/routes/wallet/getBalances.ts +++ b/ironfish/src/rpc/routes/wallet/getBalances.ts @@ -4,7 +4,7 @@ import * as yup from 'yup' import { AssetVerification } from '../../../assets' import { CurrencyUtils } from '../../../utils' -import { constructRpcAsset, RpcAssetSchema } from '../../types' +import { RpcAssetSchema } from '../../types' import { ApiNamespace, routes } from '../router' import { getAccount } from './utils' @@ -100,7 +100,6 @@ routes.register( const asset = await account.getAsset(balance.assetId) balances.push({ - asset: asset ? constructRpcAsset(asset) : undefined, assetId: balance.assetId.toString('hex'), assetName: asset?.name.toString('hex') ?? '', assetCreator: asset?.creator.toString('hex') ?? '', diff --git a/ironfish/src/rpc/routes/wallet/mintAsset.ts b/ironfish/src/rpc/routes/wallet/mintAsset.ts index 0324a953b8..b4d07c1569 100644 --- a/ironfish/src/rpc/routes/wallet/mintAsset.ts +++ b/ironfish/src/rpc/routes/wallet/mintAsset.ts @@ -6,7 +6,7 @@ import * as yup from 'yup' import { Assert } from '../../../assert' import { CurrencyUtils, YupUtils } from '../../../utils' import { MintAssetOptions } from '../../../wallet/interfaces/mintAssetOptions' -import { constructRpcAssetFromAsset, RpcAsset, RpcAssetSchema } from '../../types' +import { RpcAsset, RpcAssetSchema } from '../../types' import { ApiNamespace, routes } from '../router' import { getAccount } from './utils' @@ -103,7 +103,13 @@ routes.register( const mint = transaction.mints[0] request.end({ - asset: constructRpcAssetFromAsset(mint.asset), + asset: { + id: mint.asset.id().toString('hex'), + metadata: mint.asset.metadata().toString('hex'), + name: mint.asset.name().toString('hex'), + nonce: mint.asset.nonce(), + creator: mint.asset.creator().toString('hex'), + }, assetId: mint.asset.id().toString('hex'), hash: transaction.hash().toString('hex'), name: mint.asset.name().toString('hex'), diff --git a/ironfish/src/rpc/types.ts b/ironfish/src/rpc/types.ts index 58680480de..028d353015 100644 --- a/ironfish/src/rpc/types.ts +++ b/ironfish/src/rpc/types.ts @@ -3,9 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import * as yup from 'yup' -import { Asset } from '../../../ironfish-rust-nodejs' -import { AssetValue as BlochcainAssetValue } from '../blockchain/database/assetValue' -import { AssetValue as WalletAssetValue } from '../wallet/walletdb/assetValue' export type RpcAsset = { id: string @@ -13,6 +10,7 @@ export type RpcAsset = { name: string nonce: number creator: string + owner?: string } export const RpcAssetSchema: yup.ObjectSchema = yup @@ -25,25 +23,3 @@ export const RpcAssetSchema: yup.ObjectSchema = yup owner: yup.string().optional(), }) .defined() - -export const constructRpcAsset = ( - asset: WalletAssetValue | BlochcainAssetValue | Readonly, -): RpcAsset => { - return { - id: asset.id.toString('hex'), - metadata: asset.metadata.toString('hex'), - name: asset.name.toString('hex'), - nonce: asset.nonce, - creator: asset.creator.toString('hex'), - } -} - -export const constructRpcAssetFromAsset = (asset: Asset): RpcAsset => { - return { - id: asset.id().toString('hex'), - metadata: asset.metadata().toString('hex'), - name: asset.name().toString('hex'), - nonce: asset.nonce(), - creator: asset.creator().toString('hex'), - } -} From dee782772cd351c24762178ec0c7f9f2c6e8ddca Mon Sep 17 00:00:00 2001 From: Rahul Patni Date: Tue, 12 Sep 2023 14:42:10 -0700 Subject: [PATCH 13/26] removing optional asset object --- ironfish/src/rpc/routes/wallet/burnAsset.ts | 1 - ironfish/src/rpc/routes/wallet/getBalance.ts | 2 -- ironfish/src/rpc/routes/wallet/getBalances.ts | 2 -- ironfish/src/rpc/routes/wallet/types.ts | 2 -- ironfish/src/rpc/types.ts | 2 -- 5 files changed, 9 deletions(-) diff --git a/ironfish/src/rpc/routes/wallet/burnAsset.ts b/ironfish/src/rpc/routes/wallet/burnAsset.ts index 22246e7d7a..6d42574f2f 100644 --- a/ironfish/src/rpc/routes/wallet/burnAsset.ts +++ b/ironfish/src/rpc/routes/wallet/burnAsset.ts @@ -86,7 +86,6 @@ routes.register( name: asset.name.toString('hex'), nonce: asset.nonce, creator: asset.creator.toString('hex'), - owner: asset.owner.toString('hex'), }, assetId: burn.assetId.toString('hex'), hash: transaction.hash().toString('hex'), diff --git a/ironfish/src/rpc/routes/wallet/getBalance.ts b/ironfish/src/rpc/routes/wallet/getBalance.ts index ea4528dfb9..113ca499e2 100644 --- a/ironfish/src/rpc/routes/wallet/getBalance.ts +++ b/ironfish/src/rpc/routes/wallet/getBalance.ts @@ -4,7 +4,6 @@ import { Asset } from '@ironfish/rust-nodejs' import * as yup from 'yup' import { AssetVerification } from '../../../assets' -import { RpcAssetSchema } from '../../types' import { ApiNamespace, routes } from '../router' import { getAccount } from './utils' @@ -46,7 +45,6 @@ export const GetBalanceResponseSchema: yup.ObjectSchema = yu .object({ account: yup.string().defined(), assetId: yup.string().defined(), - asset: RpcAssetSchema.optional(), assetVerification: yup .object({ status: yup.string().oneOf(['verified', 'unverified', 'unknown']).defined() }) .defined(), diff --git a/ironfish/src/rpc/routes/wallet/getBalances.ts b/ironfish/src/rpc/routes/wallet/getBalances.ts index be99393dc3..0ded87d1a0 100644 --- a/ironfish/src/rpc/routes/wallet/getBalances.ts +++ b/ironfish/src/rpc/routes/wallet/getBalances.ts @@ -4,7 +4,6 @@ import * as yup from 'yup' import { AssetVerification } from '../../../assets' import { CurrencyUtils } from '../../../utils' -import { RpcAssetSchema } from '../../types' import { ApiNamespace, routes } from '../router' import { getAccount } from './utils' @@ -60,7 +59,6 @@ export const GetBalancesResponseSchema: yup.ObjectSchema = yup .object() .shape({ - asset: RpcAssetSchema.defined(), assetId: yup.string().defined(), assetName: yup.string().defined(), assetCreator: yup.string().defined(), diff --git a/ironfish/src/rpc/routes/wallet/types.ts b/ironfish/src/rpc/routes/wallet/types.ts index e6b9f83327..2961471eba 100644 --- a/ironfish/src/rpc/routes/wallet/types.ts +++ b/ironfish/src/rpc/routes/wallet/types.ts @@ -4,7 +4,6 @@ import * as yup from 'yup' import { AccountImport } from '../../../wallet/walletdb/accountValue' -import { RpcAssetSchema } from '../../types' export type RpcAccountTransaction = { hash: string @@ -67,7 +66,6 @@ export const RpcWalletNoteSchema: yup.ObjectSchema = yup .object({ value: yup.string().defined(), assetId: yup.string().defined(), - asset: RpcAssetSchema.optional(), assetName: yup.string().defined(), memo: yup.string().defined(), sender: yup.string().defined(), diff --git a/ironfish/src/rpc/types.ts b/ironfish/src/rpc/types.ts index 028d353015..4c89e72757 100644 --- a/ironfish/src/rpc/types.ts +++ b/ironfish/src/rpc/types.ts @@ -10,7 +10,6 @@ export type RpcAsset = { name: string nonce: number creator: string - owner?: string } export const RpcAssetSchema: yup.ObjectSchema = yup @@ -20,6 +19,5 @@ export const RpcAssetSchema: yup.ObjectSchema = yup name: yup.string().required(), nonce: yup.number().required(), creator: yup.string().required(), - owner: yup.string().optional(), }) .defined() From 416e7dd4ecdf8c5490c1b54fb75eb3df403db28a Mon Sep 17 00:00:00 2001 From: Rahul Patni Date: Wed, 13 Sep 2023 08:31:38 -0700 Subject: [PATCH 14/26] deprecating asset name fields in note, mint, and burn --- ironfish/src/rpc/routes/chain/getTransactionStream.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ironfish/src/rpc/routes/chain/getTransactionStream.ts b/ironfish/src/rpc/routes/chain/getTransactionStream.ts index 47aa41085c..7810addaa5 100644 --- a/ironfish/src/rpc/routes/chain/getTransactionStream.ts +++ b/ironfish/src/rpc/routes/chain/getTransactionStream.ts @@ -15,6 +15,9 @@ import { ApiNamespace, routes } from '../router' interface Note { assetId: string + /** + * @deprecated Please use getAsset endpoint to get this information + */ assetName: string hash: string value: string @@ -22,11 +25,17 @@ interface Note { } interface Mint { assetId: string + /** + * @deprecated Please use getAsset endpoint to get this information + */ assetName: string value: string } interface Burn { assetId: string + /** + * @deprecated Please use getAsset endpoint to get this information + */ assetName: string value: string } From 009d00997e6aeea6dc30967d25870b82ac9ed2d6 Mon Sep 17 00:00:00 2001 From: Rahul Patni Date: Wed, 13 Sep 2023 13:50:50 -0700 Subject: [PATCH 15/26] normalizing rpc asset object for all endpointS --- ironfish/src/rpc/clients/client.ts | 12 ++---- ironfish/src/rpc/routes/chain/getAsset.ts | 31 +++++++--------- ironfish/src/rpc/routes/wallet/burnAsset.ts | 6 +++ .../src/rpc/routes/wallet/getAsset.test.ts | 2 +- ironfish/src/rpc/routes/wallet/getAsset.ts | 37 ++----------------- ironfish/src/rpc/routes/wallet/getAssets.ts | 35 +++--------------- ironfish/src/rpc/routes/wallet/mintAsset.ts | 10 +++++ ironfish/src/rpc/types.ts | 13 +++++++ 8 files changed, 57 insertions(+), 89 deletions(-) diff --git a/ironfish/src/rpc/clients/client.ts b/ironfish/src/rpc/clients/client.ts index d07202c626..4438e892c8 100644 --- a/ironfish/src/rpc/clients/client.ts +++ b/ironfish/src/rpc/clients/client.ts @@ -131,8 +131,9 @@ import { IsValidPublicAddressRequest, IsValidPublicAddressResponse, } from '../routes/chain/isValidPublicAddress' -import { GetWalletAssetRequest, GetWalletAssetResponse } from '../routes/wallet/getAsset' +import { GetWalletAssetRequest } from '../routes/wallet/getAsset' import { GetNotesRequest, GetNotesResponse } from '../routes/wallet/getNotes' +import { RpcAsset } from '../types' export abstract class RpcClient { readonly logger: Logger @@ -319,13 +320,8 @@ export abstract class RpcClient { ).waitForEnd() }, - getAsset: ( - params: GetWalletAssetRequest, - ): Promise> => { - return this.request( - `${ApiNamespace.wallet}/getAsset`, - params, - ).waitForEnd() + getAsset: (params: GetWalletAssetRequest): Promise> => { + return this.request(`${ApiNamespace.wallet}/getAsset`, params).waitForEnd() }, mintAsset: (params: MintAssetRequest): Promise> => { diff --git a/ironfish/src/rpc/routes/chain/getAsset.ts b/ironfish/src/rpc/routes/chain/getAsset.ts index cbb66aa505..5bb1ff55b0 100644 --- a/ironfish/src/rpc/routes/chain/getAsset.ts +++ b/ironfish/src/rpc/routes/chain/getAsset.ts @@ -7,22 +7,14 @@ import { Assert } from '../../../assert' import { FullNode } from '../../../node' import { CurrencyUtils } from '../../../utils' import { NotFoundError, ValidationError } from '../../adapters' +import { RpcAsset } from '../../types' import { ApiNamespace, routes } from '../router' export type GetAssetRequest = { id: string } -export type GetAssetResponse = { - createdTransactionHash: string - id: string - metadata: string - name: string - nonce: number - creator: string - owner: string - supply: string -} +export type GetAssetResponse = Omit export const GetAssetRequestSchema: yup.ObjectSchema = yup .object() @@ -33,14 +25,18 @@ export const GetAssetRequestSchema: yup.ObjectSchema = yup export const GetAssetResponse: yup.ObjectSchema = yup .object({ - createdTransactionHash: yup.string().defined(), - id: yup.string().defined(), - metadata: yup.string().defined(), - name: yup.string().defined(), - nonce: yup.number().defined(), - creator: yup.string().defined(), + id: yup.string().required(), + metadata: yup.string().required(), + name: yup.string().required(), + nonce: yup.number().required(), + creator: yup.string().required(), + verification: yup + .object({ status: yup.string().oneOf(['verified', 'unverified', 'unknown']).defined() }) + .defined(), + // status: yup.string().defined(), // This field is the only difference between this object and RPCAsset + supply: yup.string().optional(), owner: yup.string().defined(), - supply: yup.string().defined(), + createdTransactionHash: yup.string().defined(), }) .defined() @@ -72,6 +68,7 @@ routes.register( creator: asset.creator.toString('hex'), owner: asset.owner.toString('hex'), supply: CurrencyUtils.encode(asset.supply), + verification: node.assetsVerifier.verify(asset.id), }) }, ) diff --git a/ironfish/src/rpc/routes/wallet/burnAsset.ts b/ironfish/src/rpc/routes/wallet/burnAsset.ts index 6d42574f2f..155dcc2967 100644 --- a/ironfish/src/rpc/routes/wallet/burnAsset.ts +++ b/ironfish/src/rpc/routes/wallet/burnAsset.ts @@ -86,6 +86,12 @@ routes.register( name: asset.name.toString('hex'), nonce: asset.nonce, creator: asset.creator.toString('hex'), + verification: node.assetsVerifier.verify(asset.id), + status: await node.wallet.getAssetStatus(account, asset, { + confirmations: request.data.confirmations, + }), + createdTransactionHash: asset.createdTransactionHash.toString('hex'), + owner: asset.owner.toString('hex'), }, assetId: burn.assetId.toString('hex'), hash: transaction.hash().toString('hex'), diff --git a/ironfish/src/rpc/routes/wallet/getAsset.test.ts b/ironfish/src/rpc/routes/wallet/getAsset.test.ts index df6e033d51..6b57cf581c 100644 --- a/ironfish/src/rpc/routes/wallet/getAsset.test.ts +++ b/ironfish/src/rpc/routes/wallet/getAsset.test.ts @@ -120,7 +120,7 @@ describe('Route chain.getAsset', () => { name: asset.name().toString('hex'), nonce: asset.nonce(), status: AssetStatus.PENDING, - supply: null, + supply: undefined, verification: { status: 'unknown' }, }) }) diff --git a/ironfish/src/rpc/routes/wallet/getAsset.ts b/ironfish/src/rpc/routes/wallet/getAsset.ts index e09cbb1004..41c8795f48 100644 --- a/ironfish/src/rpc/routes/wallet/getAsset.ts +++ b/ironfish/src/rpc/routes/wallet/getAsset.ts @@ -3,9 +3,9 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import { ASSET_ID_LENGTH } from '@ironfish/rust-nodejs' import * as yup from 'yup' -import { AssetVerification } from '../../../assets' import { CurrencyUtils } from '../../../utils' import { NotFoundError, ValidationError } from '../../adapters' +import { RpcAsset, RpcAssetSchema } from '../../types' import { ApiNamespace, routes } from '../router' import { getAccount } from './utils' @@ -15,20 +15,6 @@ export type GetWalletAssetRequest = { id: string } -export type GetWalletAssetResponse = { - createdTransactionHash: string - creator: string - owner: string - id: string - metadata: string - name: string - nonce: number - status: string - verification: AssetVerification - // Populated for assets the account owns - supply: string | null -} - export const GetWalletAssetRequestSchema: yup.ObjectSchema = yup .object() .shape({ @@ -38,24 +24,9 @@ export const GetWalletAssetRequestSchema: yup.ObjectSchema = yup - .object({ - createdTransactionHash: yup.string().defined(), - creator: yup.string().defined(), - owner: yup.string().defined(), - id: yup.string().defined(), - metadata: yup.string().defined(), - name: yup.string().defined(), - nonce: yup.number().defined(), - status: yup.string().defined(), - verification: yup - .object({ status: yup.string().oneOf(['verified', 'unverified', 'unknown']).defined() }) - .defined(), - supply: yup.string().nullable().defined(), - }) - .defined() +export const GetWalletAssetResponse: yup.ObjectSchema = RpcAssetSchema.defined() -routes.register( +routes.register( `${ApiNamespace.wallet}/getAsset`, GetWalletAssetRequestSchema, async (request, node): Promise => { @@ -84,7 +55,7 @@ routes.register( status: await node.wallet.getAssetStatus(account, asset, { confirmations: request.data.confirmations, }), - supply: asset.supply ? CurrencyUtils.encode(asset.supply) : null, + supply: asset.supply ? CurrencyUtils.encode(asset.supply) : 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 382a031d7d..4f32d0d380 100644 --- a/ironfish/src/rpc/routes/wallet/getAssets.ts +++ b/ironfish/src/rpc/routes/wallet/getAssets.ts @@ -2,8 +2,8 @@ * 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 { AssetVerification } from '../../../assets' import { CurrencyUtils } from '../../../utils' +import { RpcAsset, RpcAssetSchema } from '../../types' import { ApiNamespace, routes } from '../router' import { getAccount } from './utils' @@ -12,18 +12,7 @@ export type GetAssetsRequest = { confirmations?: number } -export type GetAssetsResponse = { - createdTransactionHash: string - id: string - metadata: string - name: string - creator: string - owner: string - nonce: number - status: string - supply?: string - verification: AssetVerification -} +export type GetAssetsResponse = RpcAsset export const GetAssetsRequestSchema: yup.ObjectSchema = yup .object() @@ -33,22 +22,8 @@ export const GetAssetsRequestSchema: yup.ObjectSchema = yup }) .defined() -export const GetAssetsResponseSchema: yup.ObjectSchema = yup - .object({ - createdTransactionHash: yup.string().defined(), - id: yup.string().defined(), - metadata: yup.string().defined(), - name: yup.string().defined(), - creator: yup.string().defined(), - owner: yup.string().defined(), - status: yup.string().defined(), - nonce: yup.number().defined(), - supply: yup.string().optional(), - verification: yup - .object({ status: yup.string().oneOf(['verified', 'unverified', 'unknown']).defined() }) - .defined(), - }) - .defined() +export const GetAssetsResponseSchema: yup.ObjectSchema = + RpcAssetSchema.defined() routes.register( `${ApiNamespace.wallet}/getAssets`, @@ -62,7 +37,6 @@ routes.register( } request.stream({ - createdTransactionHash: asset.createdTransactionHash.toString('hex'), id: asset.id.toString('hex'), metadata: asset.metadata.toString('hex'), name: asset.name.toString('hex'), @@ -74,6 +48,7 @@ routes.register( }), supply: asset.supply !== null ? CurrencyUtils.encode(asset.supply) : undefined, verification: node.assetsVerifier.verify(asset.id), + createdTransactionHash: asset.createdTransactionHash.toString('hex'), }) } diff --git a/ironfish/src/rpc/routes/wallet/mintAsset.ts b/ironfish/src/rpc/routes/wallet/mintAsset.ts index b4d07c1569..f4ae667cfd 100644 --- a/ironfish/src/rpc/routes/wallet/mintAsset.ts +++ b/ironfish/src/rpc/routes/wallet/mintAsset.ts @@ -102,6 +102,9 @@ routes.register( Assert.isEqual(transaction.mints.length, 1) const mint = transaction.mints[0] + const asset = await account.getAsset(mint.asset.id()) + Assert.isNotUndefined(asset) + request.end({ asset: { id: mint.asset.id().toString('hex'), @@ -109,10 +112,17 @@ routes.register( name: mint.asset.name().toString('hex'), nonce: mint.asset.nonce(), creator: mint.asset.creator().toString('hex'), + owner: asset.owner.toString('hex'), + verification: node.assetsVerifier.verify(mint.asset.id()), + status: await node.wallet.getAssetStatus(account, asset, { + confirmations: request.data.confirmations, + }), + createdTransactionHash: asset.createdTransactionHash.toString('hex'), }, assetId: mint.asset.id().toString('hex'), hash: transaction.hash().toString('hex'), name: mint.asset.name().toString('hex'), + value: mint.value.toString(), }) }, diff --git a/ironfish/src/rpc/types.ts b/ironfish/src/rpc/types.ts index 4c89e72757..1b9a5d80ad 100644 --- a/ironfish/src/rpc/types.ts +++ b/ironfish/src/rpc/types.ts @@ -3,6 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import * as yup from 'yup' +import { AssetVerification } from '../assets' export type RpcAsset = { id: string @@ -10,6 +11,11 @@ export type RpcAsset = { name: string nonce: number creator: string + verification: AssetVerification + createdTransactionHash: string + owner: string + status: string + supply?: string } export const RpcAssetSchema: yup.ObjectSchema = yup @@ -19,5 +25,12 @@ export const RpcAssetSchema: yup.ObjectSchema = yup name: yup.string().required(), nonce: yup.number().required(), creator: yup.string().required(), + verification: yup + .object({ status: yup.string().oneOf(['verified', 'unverified', 'unknown']).defined() }) + .defined(), + status: yup.string().defined(), + supply: yup.string().optional(), + owner: yup.string().defined(), + createdTransactionHash: yup.string().defined(), }) .defined() From 3fdcbb1a4e6c9ab05127563ac548ec45b0a997f2 Mon Sep 17 00:00:00 2001 From: Rahul Patni Date: Wed, 13 Sep 2023 14:02:30 -0700 Subject: [PATCH 16/26] fixing tests --- ironfish/src/rpc/routes/wallet/burnAsset.test.ts | 12 +++++++++++- ironfish/src/rpc/routes/wallet/getAsset.test.ts | 16 +++++++++++++--- ironfish/src/rpc/routes/wallet/mintAsset.test.ts | 15 +++++++++++++++ 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/ironfish/src/rpc/routes/wallet/burnAsset.test.ts b/ironfish/src/rpc/routes/wallet/burnAsset.test.ts index 17ee5968f5..47289e8486 100644 --- a/ironfish/src/rpc/routes/wallet/burnAsset.test.ts +++ b/ironfish/src/rpc/routes/wallet/burnAsset.test.ts @@ -78,6 +78,10 @@ describe('Route wallet/burnAsset', () => { expect(accountAsset).toBeDefined() + if (!accountAsset) { + throw new Error('accountAsset is undefined') + } + const response = await routeTest.client.wallet.burnAsset({ account: account.name, assetId: assetId.toString('hex'), @@ -91,7 +95,13 @@ describe('Route wallet/burnAsset', () => { metadata: asset.metadata().toString('hex'), name: asset.name().toString('hex'), creator: asset.creator().toString('hex'), - nonce: accountAsset?.nonce ?? null, + nonce: accountAsset.nonce ?? null, + owner: accountAsset.owner.toString('hex') ?? '', + status: await node.wallet.getAssetStatus(account, accountAsset, { + confirmations: 0, + }), + verification: node.assetsVerifier.verify(asset.id()), + createdTransactionHash: accountAsset.createdTransactionHash.toString('hex') ?? null, }, assetId: asset.id().toString('hex'), name: asset.name().toString('hex'), diff --git a/ironfish/src/rpc/routes/wallet/getAsset.test.ts b/ironfish/src/rpc/routes/wallet/getAsset.test.ts index 6b57cf581c..4b5d852c5f 100644 --- a/ironfish/src/rpc/routes/wallet/getAsset.test.ts +++ b/ironfish/src/rpc/routes/wallet/getAsset.test.ts @@ -111,6 +111,15 @@ describe('Route chain.getAsset', () => { id: asset.id().toString('hex'), account: account.name, }) + + const accountAsset = await account.getAsset(asset.id()) + + expect(accountAsset).toBeDefined() + + if (!accountAsset) { + throw new Error('accountAsset is undefined') + } + expect(response.content).toEqual({ createdTransactionHash: pendingMint.hash().toString('hex'), creator: account.publicAddress, @@ -119,9 +128,10 @@ describe('Route chain.getAsset', () => { metadata: asset.metadata().toString('hex'), name: asset.name().toString('hex'), nonce: asset.nonce(), - status: AssetStatus.PENDING, - supply: undefined, - verification: { status: 'unknown' }, + status: await node.wallet.getAssetStatus(account, accountAsset, { + confirmations: 0, + }), + verification: node.assetsVerifier.verify(asset.id()), }) }) diff --git a/ironfish/src/rpc/routes/wallet/mintAsset.test.ts b/ironfish/src/rpc/routes/wallet/mintAsset.test.ts index 73a24249a8..ef40da266e 100644 --- a/ironfish/src/rpc/routes/wallet/mintAsset.test.ts +++ b/ironfish/src/rpc/routes/wallet/mintAsset.test.ts @@ -80,6 +80,14 @@ describe('Route wallet/mintAsset', () => { jest.spyOn(wallet, 'mint').mockResolvedValueOnce(mintTransaction) + const accountAsset = await account.getAsset(asset.id()) + + expect(accountAsset).toBeDefined() + + if (!accountAsset) { + throw new Error('accountAsset is undefined') + } + const response = await routeTest.client.wallet.mintAsset({ account: account.name, fee: '1', @@ -95,6 +103,13 @@ describe('Route wallet/mintAsset', () => { name: asset.name().toString('hex'), creator: asset.creator().toString('hex'), nonce: asset.nonce(), + supply: undefined, + owner: accountAsset.owner.toString('hex'), + createdTransactionHash: accountAsset.createdTransactionHash.toString('hex'), + status: await node.wallet.getAssetStatus(account, accountAsset, { + confirmations: 0, + }), + verification: node.assetsVerifier.verify(asset.id()), }, assetId: asset.id().toString('hex'), hash: mintTransaction.hash().toString('hex'), From e06918b1f67ef13ba4e1b8b3e3f59326f8630912 Mon Sep 17 00:00:00 2001 From: Rahul Patni Date: Wed, 13 Sep 2023 14:05:02 -0700 Subject: [PATCH 17/26] using asset value object --- ironfish/src/rpc/routes/wallet/burnAsset.ts | 2 +- ironfish/src/rpc/routes/wallet/mintAsset.ts | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/ironfish/src/rpc/routes/wallet/burnAsset.ts b/ironfish/src/rpc/routes/wallet/burnAsset.ts index 155dcc2967..012dafc911 100644 --- a/ironfish/src/rpc/routes/wallet/burnAsset.ts +++ b/ironfish/src/rpc/routes/wallet/burnAsset.ts @@ -86,12 +86,12 @@ routes.register( name: asset.name.toString('hex'), nonce: asset.nonce, creator: asset.creator.toString('hex'), + owner: asset.owner.toString('hex'), verification: node.assetsVerifier.verify(asset.id), status: await node.wallet.getAssetStatus(account, asset, { confirmations: request.data.confirmations, }), createdTransactionHash: asset.createdTransactionHash.toString('hex'), - owner: asset.owner.toString('hex'), }, assetId: burn.assetId.toString('hex'), hash: transaction.hash().toString('hex'), diff --git a/ironfish/src/rpc/routes/wallet/mintAsset.ts b/ironfish/src/rpc/routes/wallet/mintAsset.ts index f4ae667cfd..5d192ddcbf 100644 --- a/ironfish/src/rpc/routes/wallet/mintAsset.ts +++ b/ironfish/src/rpc/routes/wallet/mintAsset.ts @@ -107,11 +107,11 @@ routes.register( request.end({ asset: { - id: mint.asset.id().toString('hex'), - metadata: mint.asset.metadata().toString('hex'), - name: mint.asset.name().toString('hex'), - nonce: mint.asset.nonce(), - creator: mint.asset.creator().toString('hex'), + id: asset.id.toString('hex'), + metadata: asset.metadata.toString('hex'), + name: asset.name.toString('hex'), + nonce: asset.nonce, + creator: asset.creator.toString('hex'), owner: asset.owner.toString('hex'), verification: node.assetsVerifier.verify(mint.asset.id()), status: await node.wallet.getAssetStatus(account, asset, { @@ -119,10 +119,9 @@ routes.register( }), createdTransactionHash: asset.createdTransactionHash.toString('hex'), }, - assetId: mint.asset.id().toString('hex'), + assetId: asset.id.toString('hex'), hash: transaction.hash().toString('hex'), - name: mint.asset.name().toString('hex'), - + name: asset.name.toString('hex'), value: mint.value.toString(), }) }, From 8153ee0bdb37df4e8b5f0d173f13a3bee349b3ff Mon Sep 17 00:00:00 2001 From: Rahul Patni Date: Wed, 13 Sep 2023 14:07:21 -0700 Subject: [PATCH 18/26] adding back GetAssetResponse --- ironfish/src/rpc/clients/client.ts | 8 +++++--- ironfish/src/rpc/routes/wallet/getAsset.ts | 7 +++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ironfish/src/rpc/clients/client.ts b/ironfish/src/rpc/clients/client.ts index 4438e892c8..1e3b3c0f42 100644 --- a/ironfish/src/rpc/clients/client.ts +++ b/ironfish/src/rpc/clients/client.ts @@ -133,7 +133,6 @@ import { } from '../routes/chain/isValidPublicAddress' import { GetWalletAssetRequest } from '../routes/wallet/getAsset' import { GetNotesRequest, GetNotesResponse } from '../routes/wallet/getNotes' -import { RpcAsset } from '../types' export abstract class RpcClient { readonly logger: Logger @@ -320,8 +319,11 @@ export abstract class RpcClient { ).waitForEnd() }, - getAsset: (params: GetWalletAssetRequest): Promise> => { - return this.request(`${ApiNamespace.wallet}/getAsset`, params).waitForEnd() + getAsset: (params: GetWalletAssetRequest): Promise> => { + return this.request( + `${ApiNamespace.wallet}/getAsset`, + params, + ).waitForEnd() }, mintAsset: (params: MintAssetRequest): Promise> => { diff --git a/ironfish/src/rpc/routes/wallet/getAsset.ts b/ironfish/src/rpc/routes/wallet/getAsset.ts index 41c8795f48..cdbc87866c 100644 --- a/ironfish/src/rpc/routes/wallet/getAsset.ts +++ b/ironfish/src/rpc/routes/wallet/getAsset.ts @@ -15,6 +15,8 @@ export type GetWalletAssetRequest = { id: string } +export type GetWalletAssetResponse = RpcAsset + export const GetWalletAssetRequestSchema: yup.ObjectSchema = yup .object() .shape({ @@ -24,9 +26,10 @@ export const GetWalletAssetRequestSchema: yup.ObjectSchema = RpcAssetSchema.defined() +export const GetWalletAssetResponse: yup.ObjectSchema = + RpcAssetSchema.defined() -routes.register( +routes.register( `${ApiNamespace.wallet}/getAsset`, GetWalletAssetRequestSchema, async (request, node): Promise => { From 93716448b3282765d5c905017382ff4cfd2f955d Mon Sep 17 00:00:00 2001 From: Rahul Patni Date: Wed, 13 Sep 2023 14:08:32 -0700 Subject: [PATCH 19/26] reverting client ts changes --- ironfish/src/rpc/clients/client.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ironfish/src/rpc/clients/client.ts b/ironfish/src/rpc/clients/client.ts index 1e3b3c0f42..d07202c626 100644 --- a/ironfish/src/rpc/clients/client.ts +++ b/ironfish/src/rpc/clients/client.ts @@ -131,7 +131,7 @@ import { IsValidPublicAddressRequest, IsValidPublicAddressResponse, } from '../routes/chain/isValidPublicAddress' -import { GetWalletAssetRequest } from '../routes/wallet/getAsset' +import { GetWalletAssetRequest, GetWalletAssetResponse } from '../routes/wallet/getAsset' import { GetNotesRequest, GetNotesResponse } from '../routes/wallet/getNotes' export abstract class RpcClient { @@ -319,8 +319,10 @@ export abstract class RpcClient { ).waitForEnd() }, - getAsset: (params: GetWalletAssetRequest): Promise> => { - return this.request( + getAsset: ( + params: GetWalletAssetRequest, + ): Promise> => { + return this.request( `${ApiNamespace.wallet}/getAsset`, params, ).waitForEnd() From 804d84b466d5dad48bcc9dd0fe003c86e521627d Mon Sep 17 00:00:00 2001 From: Rahul Patni Date: Wed, 13 Sep 2023 14:16:29 -0700 Subject: [PATCH 20/26] show n/a if supply is not available --- ironfish-cli/src/commands/chain/asset.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ironfish-cli/src/commands/chain/asset.ts b/ironfish-cli/src/commands/chain/asset.ts index 9976d56ddb..378ffb4cb0 100644 --- a/ironfish-cli/src/commands/chain/asset.ts +++ b/ironfish-cli/src/commands/chain/asset.ts @@ -32,7 +32,7 @@ export default class Asset extends IronfishCommand { this.log(`Name: ${BufferUtils.toHuman(Buffer.from(data.content.name, 'hex'))}`) this.log(`Metadata: ${BufferUtils.toHuman(Buffer.from(data.content.metadata, 'hex'))}`) this.log(`Creator: ${data.content.creator}`) - this.log(`Supply: ${data.content.supply}`) + this.log(`Supply: ${data.content.supply ?? 'N/A'}`) this.log(`Identifier: ${data.content.id}`) this.log(`Transaction Created: ${data.content.createdTransactionHash}`) } From 7bb9d341d2026771eebe0680e37b8b369f091203 Mon Sep 17 00:00:00 2001 From: Rahul Patni Date: Wed, 13 Sep 2023 15:23:13 -0700 Subject: [PATCH 21/26] chain get asset uses same asset model --- ironfish/src/rpc/routes/chain/getAsset.ts | 29 +++++++---------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/ironfish/src/rpc/routes/chain/getAsset.ts b/ironfish/src/rpc/routes/chain/getAsset.ts index 5bb1ff55b0..e86aba0038 100644 --- a/ironfish/src/rpc/routes/chain/getAsset.ts +++ b/ironfish/src/rpc/routes/chain/getAsset.ts @@ -7,14 +7,15 @@ import { Assert } from '../../../assert' import { FullNode } from '../../../node' import { CurrencyUtils } from '../../../utils' import { NotFoundError, ValidationError } from '../../adapters' -import { RpcAsset } from '../../types' +import { RpcAsset, RpcAssetSchema } from '../../types' import { ApiNamespace, routes } from '../router' +import { getAccount } from '../wallet/utils' export type GetAssetRequest = { id: string } -export type GetAssetResponse = Omit +export type GetAssetResponse = RpcAsset export const GetAssetRequestSchema: yup.ObjectSchema = yup .object() @@ -23,22 +24,7 @@ export const GetAssetRequestSchema: yup.ObjectSchema = yup }) .defined() -export const GetAssetResponse: yup.ObjectSchema = yup - .object({ - id: yup.string().required(), - metadata: yup.string().required(), - name: yup.string().required(), - nonce: yup.number().required(), - creator: yup.string().required(), - verification: yup - .object({ status: yup.string().oneOf(['verified', 'unverified', 'unknown']).defined() }) - .defined(), - // status: yup.string().defined(), // This field is the only difference between this object and RPCAsset - supply: yup.string().optional(), - owner: yup.string().defined(), - createdTransactionHash: yup.string().defined(), - }) - .defined() +export const GetAssetResponse: yup.ObjectSchema = RpcAssetSchema.defined() routes.register( `${ApiNamespace.chain}/getAsset`, @@ -54,7 +40,9 @@ routes.register( ) } - const asset = await node.chain.getAssetById(id) + const account = getAccount(node.wallet) + const asset = await account.getAsset(id) + if (!asset) { throw new NotFoundError(`No asset found with identifier ${request.data.id}`) } @@ -67,7 +55,8 @@ routes.register( nonce: asset.nonce, creator: asset.creator.toString('hex'), owner: asset.owner.toString('hex'), - supply: CurrencyUtils.encode(asset.supply), + supply: asset.supply ? CurrencyUtils.encode(asset.supply) : undefined, + status: await node.wallet.getAssetStatus(account, asset), verification: node.assetsVerifier.verify(asset.id), }) }, From acfc85c1e76b119486934496937434d5b156627b Mon Sep 17 00:00:00 2001 From: Rahul Patni Date: Wed, 13 Sep 2023 15:24:30 -0700 Subject: [PATCH 22/26] using Assert.isNotUndefined(accountAsset) --- ironfish/src/rpc/routes/wallet/burnAsset.test.ts | 7 ++----- ironfish/src/rpc/routes/wallet/getAsset.test.ts | 5 ++--- ironfish/src/rpc/routes/wallet/mintAsset.test.ts | 5 ++--- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/ironfish/src/rpc/routes/wallet/burnAsset.test.ts b/ironfish/src/rpc/routes/wallet/burnAsset.test.ts index 47289e8486..691dd8695d 100644 --- a/ironfish/src/rpc/routes/wallet/burnAsset.test.ts +++ b/ironfish/src/rpc/routes/wallet/burnAsset.test.ts @@ -2,6 +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 { Asset } from '@ironfish/rust-nodejs' +import { Assert } from '../../../assert' import { useAccountFixture, useMinerBlockFixture, @@ -76,11 +77,7 @@ describe('Route wallet/burnAsset', () => { const accountAsset = await account.getAsset(assetId) - expect(accountAsset).toBeDefined() - - if (!accountAsset) { - throw new Error('accountAsset is undefined') - } + Assert.isNotUndefined(accountAsset) const response = await routeTest.client.wallet.burnAsset({ account: account.name, diff --git a/ironfish/src/rpc/routes/wallet/getAsset.test.ts b/ironfish/src/rpc/routes/wallet/getAsset.test.ts index 4b5d852c5f..28a9d040e3 100644 --- a/ironfish/src/rpc/routes/wallet/getAsset.test.ts +++ b/ironfish/src/rpc/routes/wallet/getAsset.test.ts @@ -4,6 +4,7 @@ import '../../../testUtilities/matchers' import { Asset } from '@ironfish/rust-nodejs' +import { Assert } from '../../../assert' import { FullNode } from '../../../node' import { Block, Transaction } from '../../../primitives' import { @@ -116,9 +117,7 @@ describe('Route chain.getAsset', () => { expect(accountAsset).toBeDefined() - if (!accountAsset) { - throw new Error('accountAsset is undefined') - } + Assert.isNotUndefined(accountAsset) expect(response.content).toEqual({ createdTransactionHash: pendingMint.hash().toString('hex'), diff --git a/ironfish/src/rpc/routes/wallet/mintAsset.test.ts b/ironfish/src/rpc/routes/wallet/mintAsset.test.ts index ef40da266e..782eb53905 100644 --- a/ironfish/src/rpc/routes/wallet/mintAsset.test.ts +++ b/ironfish/src/rpc/routes/wallet/mintAsset.test.ts @@ -2,6 +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 { Asset } from '@ironfish/rust-nodejs' +import { Assert } from '../../../assert' import { useAccountFixture, useMinerBlockFixture, useTxFixture } from '../../../testUtilities' import { createRouteTest } from '../../../testUtilities/routeTest' import { CurrencyUtils } from '../../../utils' @@ -84,9 +85,7 @@ describe('Route wallet/mintAsset', () => { expect(accountAsset).toBeDefined() - if (!accountAsset) { - throw new Error('accountAsset is undefined') - } + Assert.isNotUndefined(accountAsset) const response = await routeTest.client.wallet.mintAsset({ account: account.name, From 425e638521d8010b2bc54420fa73204b266a25b7 Mon Sep 17 00:00:00 2001 From: Rahul Patni Date: Wed, 13 Sep 2023 15:59:10 -0700 Subject: [PATCH 23/26] deprecating the status field on the asset --- .../__fixtures__/blockchain.test.ts.fixture | 78 +++++++++++++++++++ ironfish/src/rpc/routes/chain/getAsset.ts | 29 +++++-- .../src/rpc/routes/wallet/mintAsset.test.ts | 2 - ironfish/src/rpc/types.ts | 3 + 4 files changed, 104 insertions(+), 8 deletions(-) diff --git a/ironfish/src/blockchain/__fixtures__/blockchain.test.ts.fixture b/ironfish/src/blockchain/__fixtures__/blockchain.test.ts.fixture index 3554520e09..e1bb04a8e7 100644 --- a/ironfish/src/blockchain/__fixtures__/blockchain.test.ts.fixture +++ b/ironfish/src/blockchain/__fixtures__/blockchain.test.ts.fixture @@ -1129,6 +1129,84 @@ "data": "base64:AgAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGzKiP////8AAAAACGY/ysrEyXVPju38QQHPqlEuvSvgNOqa3oPIy5XuOfCvAatHFrQYUM5rCU80d030zIR7ryp6R2xqjF2IpgUzc/9nd34Txb0mzChH4TXr6VGFkqe31NhWKd3c4GVIAP6NcI9ZQgYSNPtw6Qv9xmGXI7iZ2knQKSx798XVViPEU8USYKmmdVnbONsjnt5cV3BI/BSH6/0BfYSLZN3VuBsVK4LDzFTKAHYeZv7Rjj+8CAODftQXZnYMjozwvkigFDf7iP60eY96naeGWDmCWtH7uWqFaFP3oqtHg9wn9EYNmw6nPAHDl7BOtNQFWABljOCtAwWoIWFNo8gDn5SMrJ8HoBUguphZpaXI1dPRzi335u4FApz87fsipXKXJsjx3OtpHeqxOihq4F3e5HZN7XPic4YNleCA0Ja31VpcFbd8vU875sIhNv2H3DR03oYCUc3L+eq+fIlIfiri5OEwgcUqMeQxJyjWOUJBPDporTCxrzGHpNrWOMmRmsuhN2wGOfVYs6suknjtbXFx7E0ABgr6nDi7lUBk3iBGsV6pGDO33H1HDW0p51CSl/iwOUJXLSUKMi3LEfwuS36QVzMnBP8Vko0eM0Gtv5FqWX4X7HDkdtA0YvEYFF2YXElyb24gRmlzaCBub3RlIGVuY3J5cHRpb24gbWluZXIga2V5MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAw2oHJuBy4AwksI+TPjeeaWp7G0Bk9c5HkyIMMBjC7FOdM7Nhp5jIOG4nSxxPZa81TJj8H/6Jn8Ib2S962p+dCDQ==" } ] + }, + { + "header": { + "sequence": 2, + "previousBlockHash": "88B6FA8D745A4E53BDA001318E60B04EE2E4EE06A38095688D58049CB6F15ACA", + "noteCommitment": { + "type": "Buffer", + "data": "base64:PIntDEkyH61B+zNCJn7U2invTq8MBLTQYviuHXcKw1c=" + }, + "transactionCommitment": { + "type": "Buffer", + "data": "base64:TWMQ5hKgVlHn8jqIcIJlRVpA9PCDTnUVXUbx2g3vKyM=" + }, + "target": "883423532389192164791648750371459257913741948437809479060803100646309888", + "randomness": "0", + "timestamp": 1694645614457, + "graffiti": "0000000000000000000000000000000000000000000000000000000000000000", + "noteSize": 4, + "work": "0" + }, + "transactions": [ + { + "type": "Buffer", + "data": "base64:AgAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGzKiP////8AAAAAv1d7A2KjuTJseYySgyZRfvu2KJn48uug2Gfv3G8nk+G245IRwkY6ZiQIIJ/LR5gWwGpxYDVaJ4TALAaryGMb67aF5UUq0KOJoFkIDVA+loGZCJAy9emRm1e665A4X0JYdZ+5c5ECxB02KcqL8ifgnL53NK3Hxw2Ai8309NrWRKgBbsua3EKqpLtaQeu+MsBgNQRsGaMRQeixBVvKwkEVyToC4Wbi4YR/8EtyYmf1b2epZqh8Lv0yQrMQ2K/7usWFRcePoFu1D4soqNqz4mmLZumz8HCa4eCbdDKVfOlwKVmCLKhBZIKUewwoXKUW4xgtWaKSER4Ga1OED48lZg2Kva7eHwhowJn+9pCtwVFkabwpVA/ybswzYOy80iouwj48kXzaAQsMSflX2LMhJIY1Ybpv1t6FuQYCOvTprNCy/apoKvTRlMiyNQs+FOEomcggOL0wnlvdYUvbwfW36r3/B3AZyC+iEcNPzcDRsUfZjw16SrmMFPAgz/yziuggc8Bf7wwcwmk5wxgBTvk8i95dnelmGOnvui8NQEJnEwz4ScwvWb7RyfwytERjLXLt+/tyMxJfmTm4gmBrXpY/HFjxk5a0weUAAsC47AQfcvQ32qfCm31sjaTS40lyb24gRmlzaCBub3RlIGVuY3J5cHRpb24gbWluZXIga2V5MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwWUDYbpVxi66rpyWsZVstdGlSS8wSsUZwTpCDXlWCENA849WqQngbyO0IQq1VVaYWdoEDYPuiUhLgr1KpgfpJDA==" + } + ] + }, + { + "header": { + "sequence": 3, + "previousBlockHash": "DF3EC346F36CF1660543945EFF3939D94C11D24282FC4B5A8605EDC04B1B5735", + "noteCommitment": { + "type": "Buffer", + "data": "base64:3TFNd87Uamf9jYx6A12CnHCRgGmbKvRCCanx2W87/RI=" + }, + "transactionCommitment": { + "type": "Buffer", + "data": "base64:5RzUX/ozAMxpKWhNuDn6qX8u995PX57k4nLxPsYFCPk=" + }, + "target": "880842937844725196442695540779332307793253899902937591585455087694081134", + "randomness": "0", + "timestamp": 1694645615703, + "graffiti": "0000000000000000000000000000000000000000000000000000000000000000", + "noteSize": 5, + "work": "0" + }, + "transactions": [ + { + "type": "Buffer", + "data": "base64:AgAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGzKiP////8AAAAA8FXC6jpVA1aMVv3RBcFppvKzhINCS9aX9F9F+aG9C26qEtJv6DkF2IFgiCTq3X5VAKmmXyd4S2KFWHg7H+42JNu5YQrlkeEn7LlXnsQcuEiQNj731MMbzC8lgymR2KzCTulZzoY3q0Vyi1BE6P3wbeSjTKJxGIIdJInF210163sJsZ9shkVIBP9QnX9V/VU8vkGaKJ9PZwvGq9lXuEcUIcOJAix7pI3A0WZ50Jacjd216fVN7OjUC5h3F6XiZmGQ4VqZn8ewodc8bxq5h/8pJYmXvQnQiXOGS1GTVexn2gt7CxJXPeHslvSi6kmUU+Ceksf8lkqiAGaCOlZYT9eH0DXSmenMO49lK9eWPzix4k9EZ0z4i4ZDCKO9JQ9D4itl2qlSYjo6DJIXWyNgRhcr+K2SfOnllLZEHZcUkOZIeZHOAsp54gSHpIO+KcE1F/YKVaqyYhzDLcXs36zruEu6HveXYTw5/JyJ3ixDmGIjaCHnhkwcX9tjQUtOJJFIrY9kFsF0XDvM0VHvaIq6r2VrbqMTVqPOPDrgZnznk68YMGniaSoP09SruMBREI2ZBalAFMARpqO14TJ9rYR72JXX4T6l5x2RK8cY1dlOjRwOkWq07E7Ar0e+vUlyb24gRmlzaCBub3RlIGVuY3J5cHRpb24gbWluZXIga2V5MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwL7+Rw+U6g3RmcpLAEvJzO+w0l5q1i7VR79+WiG+QaA8aWQS2muX49GS6tUlhiHZJ5Q0Kreja7IFn+vjU0DumDQ==" + } + ] + }, + { + "header": { + "sequence": 4, + "previousBlockHash": "24017C8C997A8BA699B2C977D5F8DF01A5B489FF14E3B7DADC11496EC262BCF1", + "noteCommitment": { + "type": "Buffer", + "data": "base64:u/uTfKYVV12Bg+I0XTmZJM5/QalFE2n0gPwQNZWU5l0=" + }, + "transactionCommitment": { + "type": "Buffer", + "data": "base64:1R2pYljzSYJZXqnOMWBk5pb5F4B2zBkV5wZM7uUK7jw=" + }, + "target": "878277375889837647326843029495509009809390053592540685978895509768758568", + "randomness": "0", + "timestamp": 1694645617814, + "graffiti": "0000000000000000000000000000000000000000000000000000000000000000", + "noteSize": 6, + "work": "0" + }, + "transactions": [ + { + "type": "Buffer", + "data": "base64:AgAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGzKiP////8AAAAAnDFdLNdOoCO5DWJA9ckxv2Yt+QxHUWr6kfktO1+edoGMp7oQfUCw6T9s6qBOtvDvzaOeUuSPeyyAiRdTNp7+RKLApNl8Uik8bvzhKS3uddaQzKKSbV48IEpm+uPiWtPBCYngtcblAV8WkhKojcWoqlGoAk9QsjB8Lpvrtq8Ypo4VQ6zcSqoj9/9wW6Vggcy4m3Vrzzh98qnrAFQv86JLC6Nk6utUYWCmx5MM74rwUgSZiVFO4SveM50O9kZ/FUunIlkCTuTcsNxdXe4lgbjSvaaNpu3PwWT4RctjWmljOLIRDHOVmkoaKhdnKqf5VgEMTgYXSBMiYQfmtry6gSopaBD5jpNstiL6mywJr3ogJN09idJ3U4qM3mrWPl6Fa+tdiv1PEV7UmCaveedKEoPQvgc8yGgsAz7XTpwlb5V/UmroNT6v2rcoX/4Ssjj/cxojPE7l1Xv3u9JbAM1JvtQ3p3Fp1GxcnbCYTYx20MQWjAcUIsrF7Hmvbq2ct9nC4OCyGtrh3P/8nWZB/D7Ebso6Bv/RUMtYmCJ1ZiEM696w0JE6e3G/99096jglGs+Pv/+zLQ09fJUX+BRGgCEjOriVUIa3wgTMxhhh+JbLzDCl4H2PADTE7/rDLUlyb24gRmlzaCBub3RlIGVuY3J5cHRpb24gbWluZXIga2V5MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwyrZK3ZhDT95Gq9h1PTSkMbDiOO3oMxqoXjYXxlSqT5R5eZuyPggWm0hlnOOWwYKDnpyWbFtni5biKAtYZeXYAA==" + } + ] } ], "Blockchain MerkleTree + Nullifier Set should add notes to tree and nullifiers to set": [ diff --git a/ironfish/src/rpc/routes/chain/getAsset.ts b/ironfish/src/rpc/routes/chain/getAsset.ts index e86aba0038..eb12410893 100644 --- a/ironfish/src/rpc/routes/chain/getAsset.ts +++ b/ironfish/src/rpc/routes/chain/getAsset.ts @@ -4,12 +4,13 @@ import { ASSET_ID_LENGTH } from '@ironfish/rust-nodejs' 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 { NotFoundError, ValidationError } from '../../adapters' import { RpcAsset, RpcAssetSchema } from '../../types' import { ApiNamespace, routes } from '../router' -import { getAccount } from '../wallet/utils' export type GetAssetRequest = { id: string @@ -26,6 +27,24 @@ export const GetAssetRequestSchema: yup.ObjectSchema = yup export const GetAssetResponse: yup.ObjectSchema = RpcAssetSchema.defined() +async function getAssetStatus(node: FullNode, asset: AssetValue): Promise { + const blockHash = await node.chain.getBlockHashByTransactionHash(asset.createdTransactionHash) + if (!blockHash) { + return AssetStatus.UNKNOWN + } + + const blockHeader = await node.chain.getHeader(blockHash) + + if (!blockHeader) { + return AssetStatus.UNKNOWN + } + + return blockHeader.sequence + node.chain.config.get('confirmations') < + node.chain.head.sequence + ? AssetStatus.CONFIRMED + : AssetStatus.UNCONFIRMED +} + routes.register( `${ApiNamespace.chain}/getAsset`, GetAssetRequestSchema, @@ -40,9 +59,7 @@ routes.register( ) } - const account = getAccount(node.wallet) - const asset = await account.getAsset(id) - + const asset = await node.chain.getAssetById(id) if (!asset) { throw new NotFoundError(`No asset found with identifier ${request.data.id}`) } @@ -55,8 +72,8 @@ routes.register( nonce: asset.nonce, creator: asset.creator.toString('hex'), owner: asset.owner.toString('hex'), - supply: asset.supply ? CurrencyUtils.encode(asset.supply) : undefined, - status: await node.wallet.getAssetStatus(account, asset), + supply: CurrencyUtils.encode(asset.supply), + status: await getAssetStatus(node, asset), verification: node.assetsVerifier.verify(asset.id), }) }, diff --git a/ironfish/src/rpc/routes/wallet/mintAsset.test.ts b/ironfish/src/rpc/routes/wallet/mintAsset.test.ts index 782eb53905..022ba98107 100644 --- a/ironfish/src/rpc/routes/wallet/mintAsset.test.ts +++ b/ironfish/src/rpc/routes/wallet/mintAsset.test.ts @@ -83,8 +83,6 @@ describe('Route wallet/mintAsset', () => { const accountAsset = await account.getAsset(asset.id()) - expect(accountAsset).toBeDefined() - Assert.isNotUndefined(accountAsset) const response = await routeTest.client.wallet.mintAsset({ diff --git a/ironfish/src/rpc/types.ts b/ironfish/src/rpc/types.ts index 1b9a5d80ad..1d598acd9a 100644 --- a/ironfish/src/rpc/types.ts +++ b/ironfish/src/rpc/types.ts @@ -14,6 +14,9 @@ export type RpcAsset = { verification: AssetVerification createdTransactionHash: string owner: string + /** + * @deprecated query for the transaction to find it's status + */ status: string supply?: string } From 0e00ba2622470474e7dcbff46c9657ae99dfa034 Mon Sep 17 00:00:00 2001 From: Rahul Patni Date: Wed, 13 Sep 2023 16:01:48 -0700 Subject: [PATCH 24/26] adding comment --- ironfish/src/rpc/routes/chain/getAsset.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ironfish/src/rpc/routes/chain/getAsset.ts b/ironfish/src/rpc/routes/chain/getAsset.ts index eb12410893..02ae72ab23 100644 --- a/ironfish/src/rpc/routes/chain/getAsset.ts +++ b/ironfish/src/rpc/routes/chain/getAsset.ts @@ -27,6 +27,14 @@ export const GetAssetRequestSchema: yup.ObjectSchema = yup export const GetAssetResponse: yup.ObjectSchema = RpcAssetSchema.defined() +/** + * Note: This logic will be deprecated when we move the field `status` from the Asset response object. The status field has + * more to do with the transaction than the asset itself. + * + * @param node: FullNode + * @param asset: AssetValue + * @returns Promise + */ async function getAssetStatus(node: FullNode, asset: AssetValue): Promise { const blockHash = await node.chain.getBlockHashByTransactionHash(asset.createdTransactionHash) if (!blockHash) { From b4bdc00a12c347adda8a3cbe99f72817806909ec Mon Sep 17 00:00:00 2001 From: Rahul Patni Date: Wed, 13 Sep 2023 16:02:58 -0700 Subject: [PATCH 25/26] removing expect --- ironfish/src/rpc/routes/wallet/getAsset.test.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/ironfish/src/rpc/routes/wallet/getAsset.test.ts b/ironfish/src/rpc/routes/wallet/getAsset.test.ts index 28a9d040e3..4856cb6a12 100644 --- a/ironfish/src/rpc/routes/wallet/getAsset.test.ts +++ b/ironfish/src/rpc/routes/wallet/getAsset.test.ts @@ -115,8 +115,6 @@ describe('Route chain.getAsset', () => { const accountAsset = await account.getAsset(asset.id()) - expect(accountAsset).toBeDefined() - Assert.isNotUndefined(accountAsset) expect(response.content).toEqual({ From cc80b3f4b6bfc23c07daab81bce7f525b6690a9a Mon Sep 17 00:00:00 2001 From: Rahul Patni Date: Wed, 13 Sep 2023 16:05:08 -0700 Subject: [PATCH 26/26] Resetti9ng fixture --- .../__fixtures__/blockchain.test.ts.fixture | 78 ------------------- 1 file changed, 78 deletions(-) diff --git a/ironfish/src/blockchain/__fixtures__/blockchain.test.ts.fixture b/ironfish/src/blockchain/__fixtures__/blockchain.test.ts.fixture index e1bb04a8e7..3554520e09 100644 --- a/ironfish/src/blockchain/__fixtures__/blockchain.test.ts.fixture +++ b/ironfish/src/blockchain/__fixtures__/blockchain.test.ts.fixture @@ -1129,84 +1129,6 @@ "data": "base64:AgAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGzKiP////8AAAAACGY/ysrEyXVPju38QQHPqlEuvSvgNOqa3oPIy5XuOfCvAatHFrQYUM5rCU80d030zIR7ryp6R2xqjF2IpgUzc/9nd34Txb0mzChH4TXr6VGFkqe31NhWKd3c4GVIAP6NcI9ZQgYSNPtw6Qv9xmGXI7iZ2knQKSx798XVViPEU8USYKmmdVnbONsjnt5cV3BI/BSH6/0BfYSLZN3VuBsVK4LDzFTKAHYeZv7Rjj+8CAODftQXZnYMjozwvkigFDf7iP60eY96naeGWDmCWtH7uWqFaFP3oqtHg9wn9EYNmw6nPAHDl7BOtNQFWABljOCtAwWoIWFNo8gDn5SMrJ8HoBUguphZpaXI1dPRzi335u4FApz87fsipXKXJsjx3OtpHeqxOihq4F3e5HZN7XPic4YNleCA0Ja31VpcFbd8vU875sIhNv2H3DR03oYCUc3L+eq+fIlIfiri5OEwgcUqMeQxJyjWOUJBPDporTCxrzGHpNrWOMmRmsuhN2wGOfVYs6suknjtbXFx7E0ABgr6nDi7lUBk3iBGsV6pGDO33H1HDW0p51CSl/iwOUJXLSUKMi3LEfwuS36QVzMnBP8Vko0eM0Gtv5FqWX4X7HDkdtA0YvEYFF2YXElyb24gRmlzaCBub3RlIGVuY3J5cHRpb24gbWluZXIga2V5MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAw2oHJuBy4AwksI+TPjeeaWp7G0Bk9c5HkyIMMBjC7FOdM7Nhp5jIOG4nSxxPZa81TJj8H/6Jn8Ib2S962p+dCDQ==" } ] - }, - { - "header": { - "sequence": 2, - "previousBlockHash": "88B6FA8D745A4E53BDA001318E60B04EE2E4EE06A38095688D58049CB6F15ACA", - "noteCommitment": { - "type": "Buffer", - "data": "base64:PIntDEkyH61B+zNCJn7U2invTq8MBLTQYviuHXcKw1c=" - }, - "transactionCommitment": { - "type": "Buffer", - "data": "base64:TWMQ5hKgVlHn8jqIcIJlRVpA9PCDTnUVXUbx2g3vKyM=" - }, - "target": "883423532389192164791648750371459257913741948437809479060803100646309888", - "randomness": "0", - "timestamp": 1694645614457, - "graffiti": "0000000000000000000000000000000000000000000000000000000000000000", - "noteSize": 4, - "work": "0" - }, - "transactions": [ - { - "type": "Buffer", - "data": "base64:AgAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGzKiP////8AAAAAv1d7A2KjuTJseYySgyZRfvu2KJn48uug2Gfv3G8nk+G245IRwkY6ZiQIIJ/LR5gWwGpxYDVaJ4TALAaryGMb67aF5UUq0KOJoFkIDVA+loGZCJAy9emRm1e665A4X0JYdZ+5c5ECxB02KcqL8ifgnL53NK3Hxw2Ai8309NrWRKgBbsua3EKqpLtaQeu+MsBgNQRsGaMRQeixBVvKwkEVyToC4Wbi4YR/8EtyYmf1b2epZqh8Lv0yQrMQ2K/7usWFRcePoFu1D4soqNqz4mmLZumz8HCa4eCbdDKVfOlwKVmCLKhBZIKUewwoXKUW4xgtWaKSER4Ga1OED48lZg2Kva7eHwhowJn+9pCtwVFkabwpVA/ybswzYOy80iouwj48kXzaAQsMSflX2LMhJIY1Ybpv1t6FuQYCOvTprNCy/apoKvTRlMiyNQs+FOEomcggOL0wnlvdYUvbwfW36r3/B3AZyC+iEcNPzcDRsUfZjw16SrmMFPAgz/yziuggc8Bf7wwcwmk5wxgBTvk8i95dnelmGOnvui8NQEJnEwz4ScwvWb7RyfwytERjLXLt+/tyMxJfmTm4gmBrXpY/HFjxk5a0weUAAsC47AQfcvQ32qfCm31sjaTS40lyb24gRmlzaCBub3RlIGVuY3J5cHRpb24gbWluZXIga2V5MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwWUDYbpVxi66rpyWsZVstdGlSS8wSsUZwTpCDXlWCENA849WqQngbyO0IQq1VVaYWdoEDYPuiUhLgr1KpgfpJDA==" - } - ] - }, - { - "header": { - "sequence": 3, - "previousBlockHash": "DF3EC346F36CF1660543945EFF3939D94C11D24282FC4B5A8605EDC04B1B5735", - "noteCommitment": { - "type": "Buffer", - "data": "base64:3TFNd87Uamf9jYx6A12CnHCRgGmbKvRCCanx2W87/RI=" - }, - "transactionCommitment": { - "type": "Buffer", - "data": "base64:5RzUX/ozAMxpKWhNuDn6qX8u995PX57k4nLxPsYFCPk=" - }, - "target": "880842937844725196442695540779332307793253899902937591585455087694081134", - "randomness": "0", - "timestamp": 1694645615703, - "graffiti": "0000000000000000000000000000000000000000000000000000000000000000", - "noteSize": 5, - "work": "0" - }, - "transactions": [ - { - "type": "Buffer", - "data": "base64:AgAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGzKiP////8AAAAA8FXC6jpVA1aMVv3RBcFppvKzhINCS9aX9F9F+aG9C26qEtJv6DkF2IFgiCTq3X5VAKmmXyd4S2KFWHg7H+42JNu5YQrlkeEn7LlXnsQcuEiQNj731MMbzC8lgymR2KzCTulZzoY3q0Vyi1BE6P3wbeSjTKJxGIIdJInF210163sJsZ9shkVIBP9QnX9V/VU8vkGaKJ9PZwvGq9lXuEcUIcOJAix7pI3A0WZ50Jacjd216fVN7OjUC5h3F6XiZmGQ4VqZn8ewodc8bxq5h/8pJYmXvQnQiXOGS1GTVexn2gt7CxJXPeHslvSi6kmUU+Ceksf8lkqiAGaCOlZYT9eH0DXSmenMO49lK9eWPzix4k9EZ0z4i4ZDCKO9JQ9D4itl2qlSYjo6DJIXWyNgRhcr+K2SfOnllLZEHZcUkOZIeZHOAsp54gSHpIO+KcE1F/YKVaqyYhzDLcXs36zruEu6HveXYTw5/JyJ3ixDmGIjaCHnhkwcX9tjQUtOJJFIrY9kFsF0XDvM0VHvaIq6r2VrbqMTVqPOPDrgZnznk68YMGniaSoP09SruMBREI2ZBalAFMARpqO14TJ9rYR72JXX4T6l5x2RK8cY1dlOjRwOkWq07E7Ar0e+vUlyb24gRmlzaCBub3RlIGVuY3J5cHRpb24gbWluZXIga2V5MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwL7+Rw+U6g3RmcpLAEvJzO+w0l5q1i7VR79+WiG+QaA8aWQS2muX49GS6tUlhiHZJ5Q0Kreja7IFn+vjU0DumDQ==" - } - ] - }, - { - "header": { - "sequence": 4, - "previousBlockHash": "24017C8C997A8BA699B2C977D5F8DF01A5B489FF14E3B7DADC11496EC262BCF1", - "noteCommitment": { - "type": "Buffer", - "data": "base64:u/uTfKYVV12Bg+I0XTmZJM5/QalFE2n0gPwQNZWU5l0=" - }, - "transactionCommitment": { - "type": "Buffer", - "data": "base64:1R2pYljzSYJZXqnOMWBk5pb5F4B2zBkV5wZM7uUK7jw=" - }, - "target": "878277375889837647326843029495509009809390053592540685978895509768758568", - "randomness": "0", - "timestamp": 1694645617814, - "graffiti": "0000000000000000000000000000000000000000000000000000000000000000", - "noteSize": 6, - "work": "0" - }, - "transactions": [ - { - "type": "Buffer", - "data": "base64:AgAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGzKiP////8AAAAAnDFdLNdOoCO5DWJA9ckxv2Yt+QxHUWr6kfktO1+edoGMp7oQfUCw6T9s6qBOtvDvzaOeUuSPeyyAiRdTNp7+RKLApNl8Uik8bvzhKS3uddaQzKKSbV48IEpm+uPiWtPBCYngtcblAV8WkhKojcWoqlGoAk9QsjB8Lpvrtq8Ypo4VQ6zcSqoj9/9wW6Vggcy4m3Vrzzh98qnrAFQv86JLC6Nk6utUYWCmx5MM74rwUgSZiVFO4SveM50O9kZ/FUunIlkCTuTcsNxdXe4lgbjSvaaNpu3PwWT4RctjWmljOLIRDHOVmkoaKhdnKqf5VgEMTgYXSBMiYQfmtry6gSopaBD5jpNstiL6mywJr3ogJN09idJ3U4qM3mrWPl6Fa+tdiv1PEV7UmCaveedKEoPQvgc8yGgsAz7XTpwlb5V/UmroNT6v2rcoX/4Ssjj/cxojPE7l1Xv3u9JbAM1JvtQ3p3Fp1GxcnbCYTYx20MQWjAcUIsrF7Hmvbq2ct9nC4OCyGtrh3P/8nWZB/D7Ebso6Bv/RUMtYmCJ1ZiEM696w0JE6e3G/99096jglGs+Pv/+zLQ09fJUX+BRGgCEjOriVUIa3wgTMxhhh+JbLzDCl4H2PADTE7/rDLUlyb24gRmlzaCBub3RlIGVuY3J5cHRpb24gbWluZXIga2V5MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwyrZK3ZhDT95Gq9h1PTSkMbDiOO3oMxqoXjYXxlSqT5R5eZuyPggWm0hlnOOWwYKDnpyWbFtni5biKAtYZeXYAA==" - } - ] } ], "Blockchain MerkleTree + Nullifier Set should add notes to tree and nullifiers to set": [