diff --git a/ironfish/src/rpc/routes/wallet/burnAsset.test.ts b/ironfish/src/rpc/routes/wallet/burnAsset.test.ts index c2b78cc7c1..d1038c78b1 100644 --- a/ironfish/src/rpc/routes/wallet/burnAsset.test.ts +++ b/ironfish/src/rpc/routes/wallet/burnAsset.test.ts @@ -11,6 +11,7 @@ import { } from '../../../testUtilities' import { createRouteTest } from '../../../testUtilities/routeTest' import { CurrencyUtils } from '../../../utils' +import { serializeRpcWalletTransaction } from './utils' describe('Route wallet/burnAsset', () => { const routeTest = createRouteTest(true) @@ -86,6 +87,9 @@ describe('Route wallet/burnAsset', () => { value: CurrencyUtils.encode(value), }) + const walletTransaction = await account.getTransaction(burnTransaction.hash()) + Assert.isNotUndefined(walletTransaction) + expect(response.content).toEqual({ asset: { id: asset.id().toString('hex'), @@ -100,11 +104,11 @@ describe('Route wallet/burnAsset', () => { verification: node.assetsVerifier.verify(asset.id()), createdTransactionHash: accountAsset.createdTransactionHash.toString('hex') ?? null, }, + transaction: await serializeRpcWalletTransaction(node, account, walletTransaction), id: asset.id().toString('hex'), assetId: asset.id().toString('hex'), name: asset.name().toString('hex'), assetName: asset.name().toString('hex'), - transactionHash: burnTransaction.hash().toString('hex'), hash: burnTransaction.hash().toString('hex'), value: burnTransaction.burns[0].value.toString(), }) diff --git a/ironfish/src/rpc/routes/wallet/burnAsset.ts b/ironfish/src/rpc/routes/wallet/burnAsset.ts index 4f4a28c76b..eb37fdf2a5 100644 --- a/ironfish/src/rpc/routes/wallet/burnAsset.ts +++ b/ironfish/src/rpc/routes/wallet/burnAsset.ts @@ -6,7 +6,8 @@ import { Assert } from '../../../assert' import { CurrencyUtils, YupUtils } from '../../../utils' import { RpcAsset, RpcAssetSchema, RpcBurn, RpcBurnSchema } from '../../types' import { ApiNamespace, routes } from '../router' -import { getAccount } from './utils' +import { RpcWalletTransaction, RpcWalletTransactionSchema } from './types' +import { getAccount, serializeRpcWalletTransaction } from './utils' export interface BurnAssetRequest { account?: string @@ -33,9 +34,9 @@ export const BurnAssetRequestSchema: yup.ObjectSchema = yup export type BurnAssetResponse = RpcBurn & { asset: RpcAsset - transactionHash: string + transaction: RpcWalletTransaction /** - * @deprecated Please use `transactionHash` instead + * @deprecated Please use `transaction.hash` instead */ hash: string /** @@ -48,10 +49,10 @@ export const BurnAssetResponseSchema: yup.ObjectSchema = RpcBurnSchema.concat( yup .object({ - name: yup.string().defined(), asset: RpcAssetSchema.defined(), + transaction: RpcWalletTransactionSchema.defined(), + name: yup.string().defined(), hash: yup.string().defined(), - transactionHash: yup.string().defined(), }) .defined(), ).defined() @@ -89,6 +90,9 @@ routes.register( Assert.isEqual(transaction.burns.length, 1) const burn = transaction.burns[0] + const transactionValue = await account.getTransaction(transaction.hash()) + Assert.isNotUndefined(transactionValue) + request.end({ asset: { id: asset.id.toString('hex'), @@ -103,12 +107,12 @@ routes.register( }), createdTransactionHash: asset.createdTransactionHash.toString('hex'), }, + transaction: await serializeRpcWalletTransaction(node, account, transactionValue), id: burn.assetId.toString('hex'), assetId: burn.assetId.toString('hex'), hash: transaction.hash().toString('hex'), name: asset.name.toString('hex'), assetName: asset.name.toString('hex'), - transactionHash: transaction.hash().toString('hex'), value: CurrencyUtils.encode(burn.value), }) }, diff --git a/ironfish/src/rpc/routes/wallet/mintAsset.test.ts b/ironfish/src/rpc/routes/wallet/mintAsset.test.ts index de7164a012..92c2613dac 100644 --- a/ironfish/src/rpc/routes/wallet/mintAsset.test.ts +++ b/ironfish/src/rpc/routes/wallet/mintAsset.test.ts @@ -6,6 +6,7 @@ import { Assert } from '../../../assert' import { useAccountFixture, useMinerBlockFixture, useTxFixture } from '../../../testUtilities' import { createRouteTest } from '../../../testUtilities/routeTest' import { CurrencyUtils } from '../../../utils' +import { serializeRpcWalletTransaction } from './utils' describe('Route wallet/mintAsset', () => { const routeTest = createRouteTest(true) @@ -93,6 +94,9 @@ describe('Route wallet/mintAsset', () => { value: CurrencyUtils.encode(mintData.value), }) + const walletTransaction = await account.getTransaction(mintTransaction.hash()) + Assert.isNotUndefined(walletTransaction) + expect(response.content).toEqual({ asset: { id: asset.id().toString('hex'), @@ -108,11 +112,11 @@ describe('Route wallet/mintAsset', () => { }), verification: node.assetsVerifier.verify(asset.id()), }, + transaction: await serializeRpcWalletTransaction(node, account, walletTransaction), id: asset.id().toString('hex'), creator: asset.creator().toString('hex'), assetId: asset.id().toString('hex'), metadata: asset.metadata().toString('hex'), - transactionHash: mintTransaction.hash().toString('hex'), hash: mintTransaction.hash().toString('hex'), name: asset.name().toString('hex'), assetName: asset.name().toString('hex'), diff --git a/ironfish/src/rpc/routes/wallet/mintAsset.ts b/ironfish/src/rpc/routes/wallet/mintAsset.ts index 7e6c0ee4a5..ae4882751b 100644 --- a/ironfish/src/rpc/routes/wallet/mintAsset.ts +++ b/ironfish/src/rpc/routes/wallet/mintAsset.ts @@ -8,7 +8,8 @@ import { CurrencyUtils, YupUtils } from '../../../utils' import { MintAssetOptions } from '../../../wallet/interfaces/mintAssetOptions' import { RpcAsset, RpcAssetSchema, RpcMint, RpcMintSchema } from '../../types' import { ApiNamespace, routes } from '../router' -import { getAccount } from './utils' +import { RpcWalletTransaction, RpcWalletTransactionSchema } from './types' +import { getAccount, serializeRpcWalletTransaction } from './utils' export interface MintAssetRequest { account?: string @@ -39,9 +40,9 @@ export const MintAssetRequestSchema: yup.ObjectSchema = yup export type MintAssetResponse = RpcMint & { asset: RpcAsset - transactionHash: string + transaction: RpcWalletTransaction /** - * @deprecated Please use `transactionHash` instead + * @deprecated Please use `transaction.hash` instead */ hash: string } @@ -51,8 +52,8 @@ export const MintAssetResponseSchema: yup.ObjectSchema = yup .object({ asset: RpcAssetSchema.defined(), + transaction: RpcWalletTransactionSchema.defined(), hash: yup.string().defined(), - transactionHash: yup.string().defined(), }) .defined(), ).defined() @@ -110,6 +111,9 @@ routes.register( const asset = await account.getAsset(mint.asset.id()) Assert.isNotUndefined(asset) + const transactionValue = await account.getTransaction(transaction.hash()) + Assert.isNotUndefined(transactionValue) + request.end({ asset: { id: asset.id.toString('hex'), @@ -124,9 +128,9 @@ routes.register( }), createdTransactionHash: asset.createdTransactionHash.toString('hex'), }, + transaction: await serializeRpcWalletTransaction(node, account, transactionValue), assetId: asset.id.toString('hex'), hash: transaction.hash().toString('hex'), - transactionHash: transaction.hash().toString('hex'), name: asset.name.toString('hex'), value: mint.value.toString(), id: mint.asset.id().toString('hex'),