From 172ddad2e77a03d67e2ab564bb9e567529c2a8b4 Mon Sep 17 00:00:00 2001 From: oXtxNt9U <120286271+oXtxNt9U@users.noreply.github.com> Date: Tue, 14 Jan 2025 12:01:54 +0900 Subject: [PATCH 1/2] deserialize value as bigint --- packages/crypto-transaction/source/deserializer.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/crypto-transaction/source/deserializer.ts b/packages/crypto-transaction/source/deserializer.ts index fd95053d8..6e37ccb53 100644 --- a/packages/crypto-transaction/source/deserializer.ts +++ b/packages/crypto-transaction/source/deserializer.ts @@ -1,7 +1,7 @@ import { inject, injectable } from "@mainsail/container"; import { Contracts, Identifiers } from "@mainsail/contracts"; import { BigNumber } from "@mainsail/utils"; -import { decodeRlp } from "ethers"; +import { decodeRlp, ethers } from "ethers"; @injectable() export class Deserializer implements Contracts.Crypto.TransactionDeserializer { @@ -21,7 +21,7 @@ export class Deserializer implements Contracts.Crypto.TransactionDeserializer { data.gasPrice = this.#parseNumber(decoded[3].toString()); data.gasLimit = this.#parseNumber(decoded[4].toString()); data.recipientAddress = this.#parseAddress(decoded[5].toString()); - data.value = BigNumber.make(this.#parseNumber(decoded[6].toString())); + data.value = this.#parseBigNumber(decoded[6].toString()); data.data = this.#parseData(decoded[7].toString()); if (decoded.length === 12) { @@ -42,6 +42,10 @@ export class Deserializer implements Contracts.Crypto.TransactionDeserializer { return value === "0x" ? 0 : Number(value); } + #parseBigNumber(value: string): BigNumber { + return value === "0x" ? BigNumber.ZERO : BigNumber.make(ethers.getBigInt(value)); + } + #parseAddress(value: string): string | undefined { return value === "0x" ? undefined : value; } From 6d8bfd5fef67359069092bae1702b2ff06f601c5 Mon Sep 17 00:00:00 2001 From: oXtxNt9U <120286271+oXtxNt9U@users.noreply.github.com> Date: Tue, 14 Jan 2025 12:02:19 +0900 Subject: [PATCH 2/2] Empty commit