From 311d5be84c11caa15c4dc5559bd9561c2f105418 Mon Sep 17 00:00:00 2001 From: Muhammad Altabba <24407834+Muhammad-Altabba@users.noreply.github.com> Date: Fri, 16 Sep 2022 06:58:15 +0200 Subject: [PATCH] Use BigInt when decoding functions' and events' parameters returned from Smart Contracts calls and events (#5435) * Use BigInt when decoding functions' and events' parameters returned from Smart Contracts calls and events * modify tests accordingly and Handle jest issues dealing with BigInt * Add optional innerError to Web3Error class * update CHANGELOG.md --- CHANGELOG.md | 17 ++++++++ packages/web3-errors/CHANGELOG.md | 6 +++ packages/web3-errors/src/web3_error_base.ts | 11 ++++- .../unit/__snapshots__/errors.test.ts.snap | 27 +++++++++++++ packages/web3-eth-abi/CHANGELOG.md | 9 +++++ .../web3-eth-abi/src/api/parameters_api.ts | 2 +- packages/web3-eth-abi/src/ethers_abi_coder.ts | 15 +++---- packages/web3-eth-abi/test/fixtures/data.ts | 9 +++++ .../test/unit/api/logs_api.test.ts | 3 +- .../test/unit/api/parameters_api.test.ts | 14 ++++--- packages/web3-eth-contract/CHANGELOG.md | 6 +++ .../test/integration/contract_erc20.test.ts | 13 +++--- .../test/integration/contract_erc721.test.ts | 2 +- .../test/integration/contract_events.test.ts | 40 +++++++++---------- .../test/integration/contract_methods.test.ts | 2 +- .../web3-eth-ens/test/integration/ens.test.ts | 6 +-- packages/web3-validator/src/errors.ts | 4 -- 17 files changed, 129 insertions(+), 57 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 715a13e1b43..d63bb804723 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -733,3 +733,20 @@ should use 4.0.1-alpha.0 for testing. - Dependency tree cannot be resolved by Yarn due to old deprecated packages picked by yarn - fixed (#5382) ## [Unreleased] + +### Added + +#### web3-error + +- Add optional `innerError` property to the abstract class `Web3Error`. + +### Fixed + +#### web3-eth-contract + +- According to the latest change in `web3-eth-abi`, the decoded values of the large numbers, returned from function calls or events, are now available as `BigInt`. + +#### web3-eth-abi + +- Return `BigInt` instead of `string` when decoding function parameters for large numbers, such as `uint256`. +- If an error happens when decoding a value, preserve that exception at `innerError` inside the `AbiError`. diff --git a/packages/web3-errors/CHANGELOG.md b/packages/web3-errors/CHANGELOG.md index dc93264a3e0..58dd54d066b 100644 --- a/packages/web3-errors/CHANGELOG.md +++ b/packages/web3-errors/CHANGELOG.md @@ -34,3 +34,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - I've improved the security in XY (#1000) --> + +## [Unreleased] + +### Added + +- Add optional `innerError` property to the abstract class `Web3Error`. diff --git a/packages/web3-errors/src/web3_error_base.ts b/packages/web3-errors/src/web3_error_base.ts index 50c542ad267..eaaf87dc593 100644 --- a/packages/web3-errors/src/web3_error_base.ts +++ b/packages/web3-errors/src/web3_error_base.ts @@ -23,9 +23,11 @@ export abstract class Web3Error extends Error implements ErrorInterface { public readonly name: string; public abstract readonly code: number; public stack: string | undefined; + public innerError: Error | undefined; - public constructor(msg?: string) { + public constructor(msg?: string, innerError?: Error) { super(msg); + this.innerError = innerError; this.name = this.constructor.name; if (typeof Error.captureStackTrace === 'function') { @@ -51,7 +53,12 @@ export abstract class Web3Error extends Error implements ErrorInterface { } public toJSON() { - return { name: this.name, code: this.code, message: this.message }; + return { + name: this.name, + code: this.code, + message: this.message, + innerError: this.innerError, + }; } } diff --git a/packages/web3-errors/test/unit/__snapshots__/errors.test.ts.snap b/packages/web3-errors/test/unit/__snapshots__/errors.test.ts.snap index 974cbc16369..f5de39c141a 100644 --- a/packages/web3-errors/test/unit/__snapshots__/errors.test.ts.snap +++ b/packages/web3-errors/test/unit/__snapshots__/errors.test.ts.snap @@ -5,6 +5,7 @@ Object { "code": 504, "errorCode": 10, "errorReason": "reason", + "innerError": undefined, "message": "CONNECTION ERROR: The connection got closed with the close code 10 and the following reason string reason", "name": "ConnectionCloseError", } @@ -15,6 +16,7 @@ Object { "code": 500, "errorCode": 10, "errorReason": "reason", + "innerError": undefined, "message": "error message", "name": "ConnectionError", } @@ -25,6 +27,7 @@ Object { "code": 503, "errorCode": 10, "errorReason": "reason", + "innerError": undefined, "message": "Connection not open", "name": "ConnectionNotOpenError", } @@ -36,6 +39,7 @@ Object { "duration": 5000, "errorCode": undefined, "errorReason": undefined, + "innerError": undefined, "message": "CONNECTION TIMEOUT: timeout of 5000ms achieved", "name": "ConnectionTimeoutError", } @@ -44,6 +48,7 @@ Object { exports[`errors ContractCodeNotStoredError should have valid json structure 1`] = ` Object { "code": 404, + "innerError": undefined, "message": "The contract code couldn't be stored, please check your gas limit.", "name": "ContractCodeNotStoredError", "receipt": Object { @@ -56,6 +61,7 @@ exports[`errors ContractEventDoesNotExistError should have valid json structure Object { "code": 304, "eventName": "eventName", + "innerError": undefined, "message": "Event \\"eventName\\" doesn't exist in this contract.", "name": "ContractEventDoesNotExistError", } @@ -64,6 +70,7 @@ Object { exports[`errors ContractMissingABIError should have valid json structure 1`] = ` Object { "code": 302, + "innerError": undefined, "message": "You must provide the json interface of the contract when instantiating a contract object.", "name": "ContractMissingABIError", } @@ -72,6 +79,7 @@ Object { exports[`errors ContractMissingDeployDataError should have valid json structure 1`] = ` Object { "code": 306, + "innerError": undefined, "message": "No \\"data\\" specified in neither the given options, nor the default options.", "name": "ContractMissingDeployDataError", } @@ -80,6 +88,7 @@ Object { exports[`errors ContractNoAddressDefinedError should have valid json structure 1`] = ` Object { "code": 307, + "innerError": undefined, "message": "This contract object doesn't have address set yet, please set an address first.", "name": "ContractNoAddressDefinedError", } @@ -88,6 +97,7 @@ Object { exports[`errors ContractNoFromAddressDefinedError should have valid json structure 1`] = ` Object { "code": 308, + "innerError": undefined, "message": "No \\"from\\" address specified in neither the given options, nor the default options.", "name": "ContractNoFromAddressDefinedError", } @@ -96,6 +106,7 @@ Object { exports[`errors ContractOnceRequiresCallbackError should have valid json structure 1`] = ` Object { "code": 303, + "innerError": undefined, "message": "Once requires a callback as the second parameter.", "name": "ContractOnceRequiresCallbackError", } @@ -104,6 +115,7 @@ Object { exports[`errors ContractReservedEventError should have valid json structure 1`] = ` Object { "code": 305, + "innerError": undefined, "message": "Event \\"type\\" doesn't exist in this contract.", "name": "ContractReservedEventError", "type": "type", @@ -116,6 +128,7 @@ Object { "errorCode": 10, "errorReason": "reason", "host": "my host", + "innerError": undefined, "message": "CONNECTION ERROR: Couldn't connect to node my host.", "name": "InvalidConnectionError", } @@ -126,6 +139,7 @@ Object { "code": 200, "expected": 20, "got": 10, + "innerError": undefined, "message": "Invalid number of parameters for \\"method\\". Got \\"10\\" expected \\"20\\"!", "method": "method", "name": "InvalidNumberOfParamsError", @@ -135,6 +149,7 @@ Object { exports[`errors InvalidProviderError should have valid json structure 1`] = ` Object { "code": 601, + "innerError": undefined, "message": "Provider with url \\"my url\\" is not set or invalid", "name": "InvalidProviderError", } @@ -147,6 +162,7 @@ Object { "a": "10", "b": "20", }, + "innerError": undefined, "message": "Returned error: error message", "name": "InvalidResponseError", } @@ -157,6 +173,7 @@ Object { "code": 505, "errorCode": undefined, "errorReason": undefined, + "innerError": undefined, "message": "Maximum number of reconnect attempts reached!", "name": "MaxAttemptsReachedOnReconnectingError", } @@ -165,6 +182,7 @@ Object { exports[`errors NoContractAddressFoundError should have valid json structure 1`] = ` Object { "code": 403, + "innerError": undefined, "message": "The transaction receipt didn't contain a contract address.", "name": "NoContractAddressFoundError", "receipt": Object { @@ -178,6 +196,7 @@ Object { "code": 506, "errorCode": undefined, "errorReason": undefined, + "innerError": undefined, "message": "CONNECTION ERROR: Provider started to reconnect before the response got received!", "name": "PendingRequestsOnReconnectingError", } @@ -187,6 +206,7 @@ exports[`errors ResolverMethodMissingError should have valid json structure 1`] Object { "address": "address", "code": 301, + "innerError": undefined, "message": "The resolver at address does not implement requested method: \\"name\\".", "name": "name", } @@ -199,6 +219,7 @@ Object { "a": "10", "b": "20", }, + "innerError": undefined, "message": "Returned error: error message", "name": "ResponseError", } @@ -208,6 +229,7 @@ exports[`errors ResponseError should have valid json structure without data 1`] Object { "code": 100, "data": undefined, + "innerError": undefined, "message": "Returned error: error message", "name": "ResponseError", } @@ -216,6 +238,7 @@ Object { exports[`errors RevertInstructionError should have valid json structure 1`] = ` Object { "code": 401, + "innerError": undefined, "message": "Your request got reverted with the following reason string: message", "name": "RevertInstructionError", "reason": "message", @@ -226,6 +249,7 @@ Object { exports[`errors TransactionError should have valid json structure 1`] = ` Object { "code": 400, + "innerError": undefined, "message": "message", "name": "TransactionError", "receipt": Object { @@ -237,6 +261,7 @@ Object { exports[`errors TransactionOutOfGasError should have valid json structure 1`] = ` Object { "code": 406, + "innerError": undefined, "message": "Transaction ran out of gas. Please provide more gas: { \\"attr1\\": \\"attr1\\" @@ -251,6 +276,7 @@ Object { exports[`errors TransactionRevertError should have valid json structure 1`] = ` Object { "code": 402, + "innerError": undefined, "message": "Transaction has been reverted by the EVM: { \\"attr1\\": \\"attr1\\" @@ -267,6 +293,7 @@ Object { exports[`errors TransactionRevertedWithoutReasonError should have valid json structure 1`] = ` Object { "code": 405, + "innerError": undefined, "message": "Transaction has been reverted by the EVM: { \\"attr1\\": \\"attr1\\" diff --git a/packages/web3-eth-abi/CHANGELOG.md b/packages/web3-eth-abi/CHANGELOG.md index dc93264a3e0..7c2c0e3f978 100644 --- a/packages/web3-eth-abi/CHANGELOG.md +++ b/packages/web3-eth-abi/CHANGELOG.md @@ -34,3 +34,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - I've improved the security in XY (#1000) --> + +## [Unreleased] + +### Fixed + +#### web3-eth-abi + +- Return `BigInt` instead of `string` when decoding function parameters for large numbers, such as `uint256`. +- If an error happens when decoding a value, preserve that exception at `innerError` inside the `AbiError`. diff --git a/packages/web3-eth-abi/src/api/parameters_api.ts b/packages/web3-eth-abi/src/api/parameters_api.ts index 8223c0cd0e9..6cb3cc9aca4 100644 --- a/packages/web3-eth-abi/src/api/parameters_api.ts +++ b/packages/web3-eth-abi/src/api/parameters_api.ts @@ -83,7 +83,7 @@ export const encodeParameters = (abi: ReadonlyArray, params: unknown[] modifiedParams, ); } catch (err) { - throw new AbiError(`Parameter encoding error: ${(err as Error).message}`); + throw new AbiError(`Parameter encoding error`, err as Error); } }; diff --git a/packages/web3-eth-abi/src/ethers_abi_coder.ts b/packages/web3-eth-abi/src/ethers_abi_coder.ts index 356215dba42..e5ac9287848 100644 --- a/packages/web3-eth-abi/src/ethers_abi_coder.ts +++ b/packages/web3-eth-abi/src/ethers_abi_coder.ts @@ -17,16 +17,11 @@ along with web3.js. If not, see . import { AbiCoder } from '@ethersproject/abi'; -const ethersAbiCoder = new AbiCoder((type, value) => { - if ( - /^u?int/.exec(type) && - !Array.isArray(value) && - // eslint-disable-next-line @typescript-eslint/ban-types - (!(!!value && typeof value === 'object') || (value as Function).constructor.name !== 'BN') - ) { - // Because of tye type def from @ethersproject/abi - // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call - return value.toString(); +const ethersAbiCoder = new AbiCoder((_, value) => { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access + if (['BigNumber', 'BN'].includes(value?.constructor?.name)) { + // eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/no-unsafe-argument + return BigInt(value); } // Because of tye type def from @ethersproject/abi diff --git a/packages/web3-eth-abi/test/fixtures/data.ts b/packages/web3-eth-abi/test/fixtures/data.ts index e25f171adf7..1517f3a6213 100644 --- a/packages/web3-eth-abi/test/fixtures/data.ts +++ b/packages/web3-eth-abi/test/fixtures/data.ts @@ -17,6 +17,15 @@ along with web3.js. If not, see . import { encodeParameters, decodeParameters } from '../../src/api/parameters_api'; +// Because Jest does not support BigInt (https://github.com/facebook/jest/issues/12827) +// The BigInt values in this file is in a string format. +// And the following override is to convert BigInt to a string inside the Unit Tests that uses this file, +// i.e when serialization is needed there (because the values in this file is in a string format). +(BigInt.prototype as any).toJSON = function () { + // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call + return this.toString(); +}; + export const jsonInterfaceValidData: [any, string][] = [ [ { diff --git a/packages/web3-eth-abi/test/unit/api/logs_api.test.ts b/packages/web3-eth-abi/test/unit/api/logs_api.test.ts index a4c19963ea6..972cec3fd3b 100644 --- a/packages/web3-eth-abi/test/unit/api/logs_api.test.ts +++ b/packages/web3-eth-abi/test/unit/api/logs_api.test.ts @@ -24,7 +24,8 @@ describe('logs_api', () => { it.each(validDecodeLogsData)( 'should pass for valid values: %j', ({ input: { abi, data, topics }, output }) => { - expect(decodeLog(abi, data, topics)).toEqual(output); + const expected = decodeLog(abi, data, topics); + expect(JSON.parse(JSON.stringify(expected))).toEqual(output); }, ); }); diff --git a/packages/web3-eth-abi/test/unit/api/parameters_api.test.ts b/packages/web3-eth-abi/test/unit/api/parameters_api.test.ts index 041c8a1d2c8..f89dc712cfe 100644 --- a/packages/web3-eth-abi/test/unit/api/parameters_api.test.ts +++ b/packages/web3-eth-abi/test/unit/api/parameters_api.test.ts @@ -32,14 +32,15 @@ describe('parameters_api', () => { it.each(validEncodeParametersData)( '%#: should pass for valid values: %j', ({ input: [abi, params], output }) => { - expect(encodeParameters(abi, params)).toEqual(output); + const expected = encodeParameters(abi, params); + expect(JSON.parse(JSON.stringify(expected))).toEqual(output); }, ); }); describe('invalid data', () => { it.each(inValidEncodeParametersData)( - '%#: should pass for valid values: %j', + '%#: should not pass for invalid values: %j', ({ input: [abi, params], output }) => { expect(() => encodeParameters(abi, params)).toThrow(output); }, @@ -52,7 +53,8 @@ describe('parameters_api', () => { it.each(validEncodeDoesNotMutateData)( '%#: should pass for valid values: %j', ({ input: [abi, params], output, expectedInput }) => { - expect(encodeParameters(abi, params)).toEqual(output); + const expected = encodeParameters(abi, params); + expect(JSON.parse(JSON.stringify(expected))).toEqual(output); // check that params has not been mutated expect(JSON.parse(JSON.stringify(params))).toEqual( JSON.parse(JSON.stringify(expectedInput)), @@ -90,7 +92,7 @@ describe('parameters_api', () => { describe('invalid data', () => { it.each(inValidDecodeParametersData)( - '%#: should pass for valid values: %j', + '%#: should not pass for invalid values: %j', ({ input: [abi, bytes], output }) => { expect(() => decodeParameters(abi, bytes)).toThrow(output); }, @@ -105,9 +107,9 @@ describe('parameters_api', () => { ({ input: [abi, params], output, outputResult }) => { const rwAbi = abi as AbiInput[]; const encodedBytes = encodeParameters(abi, params); - expect(encodedBytes).toEqual(output); + expect(JSON.parse(JSON.stringify(encodedBytes))).toEqual(output); const decodedBytes = decodeParameters(rwAbi, encodedBytes); - expect(decodedBytes).toEqual(outputResult); + expect(JSON.parse(JSON.stringify(decodedBytes))).toEqual(outputResult); }, ); }); diff --git a/packages/web3-eth-contract/CHANGELOG.md b/packages/web3-eth-contract/CHANGELOG.md index 4177b99bb1a..f8e82648fbb 100644 --- a/packages/web3-eth-contract/CHANGELOG.md +++ b/packages/web3-eth-contract/CHANGELOG.md @@ -170,3 +170,9 @@ const transactionHash = receipt.transactionHash;

+ +## [Unreleased] + +### Fixed + +- According to the latest change in `web3-eth-abi`, the decoded values of the large numbers, returned from function calls or events, are now available as `BigInt`. diff --git a/packages/web3-eth-contract/test/integration/contract_erc20.test.ts b/packages/web3-eth-contract/test/integration/contract_erc20.test.ts index c069f671d47..073a2403758 100644 --- a/packages/web3-eth-contract/test/integration/contract_erc20.test.ts +++ b/packages/web3-eth-contract/test/integration/contract_erc20.test.ts @@ -25,7 +25,7 @@ import { } from '../fixtures/system_test_utils'; import { processAsync, toUpperCaseHex } from '../shared_fixtures/utils'; -const initialSupply = '5000000000'; +const initialSupply = BigInt('5000000000'); describe('contract', () => { describe('erc20', () => { @@ -33,7 +33,7 @@ describe('contract', () => { let deployOptions: Record; let sendOptions: Record; - beforeAll(async () => { + beforeAll(() => { contract = new Contract(ERC20TokenAbi, undefined, { provider: getSystemTestProvider(), }); @@ -69,7 +69,7 @@ describe('contract', () => { }); it('should return the decimals', async () => { - expect(await contractDeployed.methods.decimals().call()).toBe('18'); + expect(await contractDeployed.methods.decimals().call()).toBe(BigInt(18)); }); it('should return total supply', async () => { @@ -78,10 +78,11 @@ describe('contract', () => { it('should transfer tokens', async () => { const acc2 = await createTempAccount(); - await contractDeployed.methods.transfer(acc2.address, '10').send(sendOptions); + const value = BigInt(10); + await contractDeployed.methods.transfer(acc2.address, value).send(sendOptions); expect(await contractDeployed.methods.balanceOf(acc2.address).call()).toBe( - '10', + value, ); }); }); @@ -107,7 +108,7 @@ describe('contract', () => { ).resolves.toEqual({ from: toUpperCaseHex(sendOptions.from as string), to: toUpperCaseHex(acc2.address), - value: '100', + value: BigInt(100), }); }); }); diff --git a/packages/web3-eth-contract/test/integration/contract_erc721.test.ts b/packages/web3-eth-contract/test/integration/contract_erc721.test.ts index 315badc7af7..f160b129fe7 100644 --- a/packages/web3-eth-contract/test/integration/contract_erc721.test.ts +++ b/packages/web3-eth-contract/test/integration/contract_erc721.test.ts @@ -111,7 +111,7 @@ describe('contract', () => { ).resolves.toEqual({ from: '0x0000000000000000000000000000000000000000', to: toUpperCaseHex(acc2.address), - tokenId: '0', + tokenId: BigInt(0), }); }); }); diff --git a/packages/web3-eth-contract/test/integration/contract_events.test.ts b/packages/web3-eth-contract/test/integration/contract_events.test.ts index 4de5fde48e8..f1e47bc9d12 100644 --- a/packages/web3-eth-contract/test/integration/contract_events.test.ts +++ b/packages/web3-eth-contract/test/integration/contract_events.test.ts @@ -33,7 +33,7 @@ describe('contract', () => { let deployOptions: Record; let sendOptions: Record; - beforeAll(async () => { + beforeAll(() => { contract = new Contract(BasicAbi, undefined, { provider: getSystemTestProvider(), }); @@ -75,29 +75,25 @@ describe('contract', () => { itIf(isWs)( 'should trigger the "contract.events." for indexed parameters', async () => { - // eslint-disable-next-line jest/no-standalone-expect - return expect( - processAsync(async resolve => { - const event = contractDeployed.events.MultiValueIndexedEvent({ - filter: { val: 100 }, - }); + const res = await processAsync(async resolve => { + const event = contractDeployed.events.MultiValueIndexedEvent({ + filter: { val: 100 }, + }); - event.on('data', resolve); + event.on('data', resolve); - // trigger event - await contractDeployed.methods - .firesMultiValueIndexedEvent('value', 12, true) - .send(sendOptions); - await contractDeployed.methods - .firesMultiValueIndexedEvent('value', 100, true) - .send(sendOptions); - }), - ).resolves.toEqual( - expect.objectContaining({ - event: 'MultiValueIndexedEvent', - returnValues: expect.objectContaining({ val: '100' }), - }), - ); + // trigger event + await contractDeployed.methods + .firesMultiValueIndexedEvent('value', 12, true) + .send(sendOptions); + await contractDeployed.methods + .firesMultiValueIndexedEvent('value', 100, true) + .send(sendOptions); + }); + // eslint-disable-next-line jest/no-standalone-expect + expect((res as any)?.event).toBe('MultiValueIndexedEvent'); + // eslint-disable-next-line jest/no-standalone-expect + expect((res as any)?.returnValues.val).toBe(BigInt(100)); }, ); diff --git a/packages/web3-eth-contract/test/integration/contract_methods.test.ts b/packages/web3-eth-contract/test/integration/contract_methods.test.ts index 5023e479a4e..9763517ffad 100644 --- a/packages/web3-eth-contract/test/integration/contract_methods.test.ts +++ b/packages/web3-eth-contract/test/integration/contract_methods.test.ts @@ -46,7 +46,7 @@ describe('contract', () => { const result = await contractDeployed.methods.getValues().call(); expect(result).toEqual({ - '0': '10', + '0': BigInt(10), '1': 'string init value', '2': false, __length__: 3, diff --git a/packages/web3-eth-ens/test/integration/ens.test.ts b/packages/web3-eth-ens/test/integration/ens.test.ts index b3eaf94dfe1..85c1d7dce2b 100644 --- a/packages/web3-eth-ens/test/integration/ens.test.ts +++ b/packages/web3-eth-ens/test/integration/ens.test.ts @@ -212,7 +212,7 @@ describe('ens', () => { it('should get TTL', async () => { const TTL = await ens.getTTL(web3jsName); - expect(TTL).toBe('0'); + expect(TTL).toBe(BigInt(0)); }); it('should set TTL', async () => { @@ -220,7 +220,7 @@ describe('ens', () => { const ttlResult = await ens.getTTL(web3jsName); - expect(ttlResult).toBe(ttl.toString()); + expect(ttlResult).toBe(BigInt(ttl)); }); it('should set subnode owner', async () => { @@ -245,7 +245,7 @@ describe('ens', () => { const owner = await ens.getOwner(fullDomain); - expect(ttlResult).toBe(ttl.toString()); + expect(ttlResult).toBe(BigInt(ttl)); expect(owner).toBe(toChecksumAddress(accountOne)); }); diff --git a/packages/web3-validator/src/errors.ts b/packages/web3-validator/src/errors.ts index 539c50f8f23..81a9f5720b3 100644 --- a/packages/web3-validator/src/errors.ts +++ b/packages/web3-validator/src/errors.ts @@ -56,10 +56,6 @@ export class Web3ValidatorError extends Web3Error { } error[s]:\n${this._compileErrors().join('\n')}`; } - public toJSON() { - return { name: this.name, message: this.message, code: this.code }; - } - private _compileErrors(): string[] { const errorMsgs = this.errors.map(errorFormatter); return errorMsgs;