diff --git a/packages/accounts/test/account_multisig.test.js b/packages/accounts/test/account_multisig.test.js index b1c1888ca0..51907fc45e 100644 --- a/packages/accounts/test/account_multisig.test.js +++ b/packages/accounts/test/account_multisig.test.js @@ -7,7 +7,7 @@ const BN = require('bn.js'); const fs = require('fs'); const semver = require('semver'); -const { Account2FA, MULTISIG_DEPOSIT, MULTISIG_GAS } = require('../lib'); +const { Account2FA, MULTISIG_DEPOSIT, MULTISIG_GAS, MultisigStateStatus } = require('../lib'); const testUtils = require('./test-utils'); const { functionCall, transfer } = actionCreators; @@ -47,6 +47,7 @@ const getAccount2FA = async (account, keyMapping = ({ public_key: publicKey }) = account2fa.getRecoveryMethods = () => ({ data: keys.map(keyMapping) }); + account2fa.checkMultisigCodeAndStateStatus = () => ({ codeStatus: 1, stateStatus: MultisigStateStatus.STATE_NOT_INITIALIZED }); await account2fa.deployMultisig([...fs.readFileSync('./test/wasm/multisig.wasm')]); return account2fa; }; diff --git a/packages/accounts/test/providers.test.js b/packages/accounts/test/providers.test.js index 6355090cea..40d60080c6 100644 --- a/packages/accounts/test/providers.test.js +++ b/packages/accounts/test/providers.test.js @@ -70,9 +70,8 @@ describe('providers', () => { expect(response).toEqual({ block_height: expect.any(Number), block_hash: expect.any(String), - proof: expect.any(Array), values: [ - { key: 'bmFtZQ==', proof: expect.any(Array), value: 'aGVsbG8=' } + { key: 'bmFtZQ==', value: 'aGVsbG8=' } ] }); }); diff --git a/packages/utils/fetch_error_schema.js b/packages/utils/fetch_error_schema.js index 0882458e90..c2dd226190 100644 --- a/packages/utils/fetch_error_schema.js +++ b/packages/utils/fetch_error_schema.js @@ -2,8 +2,8 @@ const https = require('https'); const fs = require('fs'); const ERROR_SCHEMA_URL = - 'https://raw.githubusercontent.com/nearprotocol/nearcore/4c1149974ccf899dbcb2253a3e27cbab86dc47be/chain/jsonrpc/res/rpc_errors_schema.json'; -const TARGET_SCHEMA_FILE_PATH = `${process.argv[2] || process.cwd()}/src/errors/rpc_error_schema.json'`; + 'https://raw.githubusercontent.com/near/nearcore/master/chain/jsonrpc/res/rpc_errors_schema.json'; +const TARGET_SCHEMA_FILE_PATH = `${process.argv[2] || process.cwd()}/src/errors/rpc_error_schema.json`; https .get(ERROR_SCHEMA_URL, resp => { diff --git a/packages/utils/src/errors/rpc_error_schema.json b/packages/utils/src/errors/rpc_error_schema.json index e5ac6cec66..1279c61751 100644 --- a/packages/utils/src/errors/rpc_error_schema.json +++ b/packages/utils/src/errors/rpc_error_schema.json @@ -1,452 +1,5 @@ { "schema": { - "BadUTF16": { - "name": "BadUTF16", - "subtypes": [], - "props": {} - }, - "BadUTF8": { - "name": "BadUTF8", - "subtypes": [], - "props": {} - }, - "BalanceExceeded": { - "name": "BalanceExceeded", - "subtypes": [], - "props": {} - }, - "BreakpointTrap": { - "name": "BreakpointTrap", - "subtypes": [], - "props": {} - }, - "CacheError": { - "name": "CacheError", - "subtypes": [ - "ReadError", - "WriteError", - "DeserializationError", - "SerializationError" - ], - "props": {} - }, - "CallIndirectOOB": { - "name": "CallIndirectOOB", - "subtypes": [], - "props": {} - }, - "CannotAppendActionToJointPromise": { - "name": "CannotAppendActionToJointPromise", - "subtypes": [], - "props": {} - }, - "CannotReturnJointPromise": { - "name": "CannotReturnJointPromise", - "subtypes": [], - "props": {} - }, - "CodeDoesNotExist": { - "name": "CodeDoesNotExist", - "subtypes": [], - "props": { - "account_id": "" - } - }, - "CompilationError": { - "name": "CompilationError", - "subtypes": [ - "CodeDoesNotExist", - "PrepareError", - "WasmerCompileError" - ], - "props": {} - }, - "ContractSizeExceeded": { - "name": "ContractSizeExceeded", - "subtypes": [], - "props": { - "limit": "", - "size": "" - } - }, - "Deprecated": { - "name": "Deprecated", - "subtypes": [], - "props": { - "method_name": "" - } - }, - "Deserialization": { - "name": "Deserialization", - "subtypes": [], - "props": {} - }, - "DeserializationError": { - "name": "DeserializationError", - "subtypes": [], - "props": {} - }, - "EmptyMethodName": { - "name": "EmptyMethodName", - "subtypes": [], - "props": {} - }, - "FunctionCallError": { - "name": "FunctionCallError", - "subtypes": [ - "CompilationError", - "LinkError", - "MethodResolveError", - "WasmTrap", - "WasmUnknownError", - "HostError", - "EvmError" - ], - "props": {} - }, - "GasExceeded": { - "name": "GasExceeded", - "subtypes": [], - "props": {} - }, - "GasInstrumentation": { - "name": "GasInstrumentation", - "subtypes": [], - "props": {} - }, - "GasLimitExceeded": { - "name": "GasLimitExceeded", - "subtypes": [], - "props": {} - }, - "GenericTrap": { - "name": "GenericTrap", - "subtypes": [], - "props": {} - }, - "GuestPanic": { - "name": "GuestPanic", - "subtypes": [], - "props": { - "panic_msg": "" - } - }, - "HostError": { - "name": "HostError", - "subtypes": [ - "BadUTF16", - "BadUTF8", - "GasExceeded", - "GasLimitExceeded", - "BalanceExceeded", - "EmptyMethodName", - "GuestPanic", - "IntegerOverflow", - "InvalidPromiseIndex", - "CannotAppendActionToJointPromise", - "CannotReturnJointPromise", - "InvalidPromiseResultIndex", - "InvalidRegisterId", - "IteratorWasInvalidated", - "MemoryAccessViolation", - "InvalidReceiptIndex", - "InvalidIteratorIndex", - "InvalidAccountId", - "InvalidMethodName", - "InvalidPublicKey", - "ProhibitedInView", - "NumberOfLogsExceeded", - "KeyLengthExceeded", - "ValueLengthExceeded", - "TotalLogLengthExceeded", - "NumberPromisesExceeded", - "NumberInputDataDependenciesExceeded", - "ReturnedValueLengthExceeded", - "ContractSizeExceeded", - "Deprecated" - ], - "props": {} - }, - "IllegalArithmetic": { - "name": "IllegalArithmetic", - "subtypes": [], - "props": {} - }, - "IncorrectCallIndirectSignature": { - "name": "IncorrectCallIndirectSignature", - "subtypes": [], - "props": {} - }, - "Instantiate": { - "name": "Instantiate", - "subtypes": [], - "props": {} - }, - "IntegerOverflow": { - "name": "IntegerOverflow", - "subtypes": [], - "props": {} - }, - "InternalMemoryDeclared": { - "name": "InternalMemoryDeclared", - "subtypes": [], - "props": {} - }, - "InvalidAccountId": { - "name": "InvalidAccountId", - "subtypes": [], - "props": { - "account_id": "" - } - }, - "InvalidIteratorIndex": { - "name": "InvalidIteratorIndex", - "subtypes": [], - "props": { - "iterator_index": "" - } - }, - "InvalidMethodName": { - "name": "InvalidMethodName", - "subtypes": [], - "props": {} - }, - "InvalidPromiseIndex": { - "name": "InvalidPromiseIndex", - "subtypes": [], - "props": { - "promise_idx": "" - } - }, - "InvalidPromiseResultIndex": { - "name": "InvalidPromiseResultIndex", - "subtypes": [], - "props": { - "result_idx": "" - } - }, - "InvalidPublicKey": { - "name": "InvalidPublicKey", - "subtypes": [], - "props": {} - }, - "InvalidReceiptIndex": { - "name": "InvalidReceiptIndex", - "subtypes": [], - "props": { - "receipt_index": "" - } - }, - "InvalidRegisterId": { - "name": "InvalidRegisterId", - "subtypes": [], - "props": { - "register_id": "" - } - }, - "IteratorWasInvalidated": { - "name": "IteratorWasInvalidated", - "subtypes": [], - "props": { - "iterator_index": "" - } - }, - "KeyLengthExceeded": { - "name": "KeyLengthExceeded", - "subtypes": [], - "props": { - "length": "", - "limit": "" - } - }, - "LinkError": { - "name": "LinkError", - "subtypes": [], - "props": { - "msg": "" - } - }, - "Memory": { - "name": "Memory", - "subtypes": [], - "props": {} - }, - "MemoryAccessViolation": { - "name": "MemoryAccessViolation", - "subtypes": [], - "props": {} - }, - "MemoryOutOfBounds": { - "name": "MemoryOutOfBounds", - "subtypes": [], - "props": {} - }, - "MethodEmptyName": { - "name": "MethodEmptyName", - "subtypes": [], - "props": {} - }, - "MethodInvalidSignature": { - "name": "MethodInvalidSignature", - "subtypes": [], - "props": {} - }, - "MethodNotFound": { - "name": "MethodNotFound", - "subtypes": [], - "props": {} - }, - "MethodResolveError": { - "name": "MethodResolveError", - "subtypes": [ - "MethodEmptyName", - "MethodUTF8Error", - "MethodNotFound", - "MethodInvalidSignature" - ], - "props": {} - }, - "MethodUTF8Error": { - "name": "MethodUTF8Error", - "subtypes": [], - "props": {} - }, - "MisalignedAtomicAccess": { - "name": "MisalignedAtomicAccess", - "subtypes": [], - "props": {} - }, - "NumberInputDataDependenciesExceeded": { - "name": "NumberInputDataDependenciesExceeded", - "subtypes": [], - "props": { - "limit": "", - "number_of_input_data_dependencies": "" - } - }, - "NumberOfLogsExceeded": { - "name": "NumberOfLogsExceeded", - "subtypes": [], - "props": { - "limit": "" - } - }, - "NumberPromisesExceeded": { - "name": "NumberPromisesExceeded", - "subtypes": [], - "props": { - "limit": "", - "number_of_promises": "" - } - }, - "PrepareError": { - "name": "PrepareError", - "subtypes": [ - "Serialization", - "Deserialization", - "InternalMemoryDeclared", - "GasInstrumentation", - "StackHeightInstrumentation", - "Instantiate", - "Memory" - ], - "props": {} - }, - "ProhibitedInView": { - "name": "ProhibitedInView", - "subtypes": [], - "props": { - "method_name": "" - } - }, - "ReadError": { - "name": "ReadError", - "subtypes": [], - "props": {} - }, - "ReturnedValueLengthExceeded": { - "name": "ReturnedValueLengthExceeded", - "subtypes": [], - "props": { - "length": "", - "limit": "" - } - }, - "Serialization": { - "name": "Serialization", - "subtypes": [], - "props": {} - }, - "SerializationError": { - "name": "SerializationError", - "subtypes": [], - "props": { - "hash": "" - } - }, - "StackHeightInstrumentation": { - "name": "StackHeightInstrumentation", - "subtypes": [], - "props": {} - }, - "StackOverflow": { - "name": "StackOverflow", - "subtypes": [], - "props": {} - }, - "TotalLogLengthExceeded": { - "name": "TotalLogLengthExceeded", - "subtypes": [], - "props": { - "length": "", - "limit": "" - } - }, - "Unreachable": { - "name": "Unreachable", - "subtypes": [], - "props": {} - }, - "ValueLengthExceeded": { - "name": "ValueLengthExceeded", - "subtypes": [], - "props": { - "length": "", - "limit": "" - } - }, - "WasmTrap": { - "name": "WasmTrap", - "subtypes": [ - "Unreachable", - "IncorrectCallIndirectSignature", - "MemoryOutOfBounds", - "CallIndirectOOB", - "IllegalArithmetic", - "MisalignedAtomicAccess", - "BreakpointTrap", - "StackOverflow", - "GenericTrap" - ], - "props": {} - }, - "WasmUnknownError": { - "name": "WasmUnknownError", - "subtypes": [], - "props": {} - }, - "WasmerCompileError": { - "name": "WasmerCompileError", - "subtypes": [], - "props": { - "msg": "" - } - }, - "WriteError": { - "name": "WriteError", - "subtypes": [], - "props": {} - }, "AccessKeyNotFound": { "name": "AccessKeyNotFound", "subtypes": [], @@ -486,7 +39,14 @@ "InsufficientStake", "FunctionCallError", "NewReceiptValidationError", - "OnlyImplicitAccountCreationAllowed" + "OnlyImplicitAccountCreationAllowed", + "DeleteAccountWithLargeState", + "DelegateActionInvalidSignature", + "DelegateActionSenderDoesNotMatchTxReceiver", + "DelegateActionExpired", + "DelegateActionAccessKeyError", + "DelegateActionInvalidNonce", + "DelegateActionNonceTooLarge" ], "props": { "index": "" @@ -506,7 +66,9 @@ "FunctionCallMethodNameLengthExceeded", "FunctionCallArgumentsLengthExceeded", "UnsuitableStakingKey", - "FunctionCallZeroAttachedGas" + "FunctionCallZeroAttachedGas", + "DelegateActionMustBeOnlyOne", + "UnsupportedProtocolFeature" ], "props": {} }, @@ -542,6 +104,28 @@ "total_number_of_bytes": "" } }, + "AltBn128InvalidInput": { + "name": "AltBn128InvalidInput", + "subtypes": [], + "props": { + "msg": "" + } + }, + "BadUTF16": { + "name": "BadUTF16", + "subtypes": [], + "props": {} + }, + "BadUTF8": { + "name": "BadUTF8", + "subtypes": [], + "props": {} + }, + "BalanceExceeded": { + "name": "BalanceExceeded", + "subtypes": [], + "props": {} + }, "BalanceMismatchError": { "name": "BalanceMismatchError", "subtypes": [], @@ -560,6 +144,45 @@ "tx_burnt_amount": "" } }, + "CallIndirectOOB": { + "name": "CallIndirectOOB", + "subtypes": [], + "props": {} + }, + "CannotAppendActionToJointPromise": { + "name": "CannotAppendActionToJointPromise", + "subtypes": [], + "props": {} + }, + "CannotReturnJointPromise": { + "name": "CannotReturnJointPromise", + "subtypes": [], + "props": {} + }, + "CodeDoesNotExist": { + "name": "CodeDoesNotExist", + "subtypes": [], + "props": { + "account_id": "" + } + }, + "CompilationError": { + "name": "CompilationError", + "subtypes": [ + "CodeDoesNotExist", + "PrepareError", + "WasmerCompileError" + ], + "props": {} + }, + "ContractSizeExceeded": { + "name": "ContractSizeExceeded", + "subtypes": [], + "props": { + "limit": "", + "size": "" + } + }, "CostOverflow": { "name": "CostOverflow", "subtypes": [], @@ -582,6 +205,45 @@ "registrar_account_id": "" } }, + "DelegateActionExpired": { + "name": "DelegateActionExpired", + "subtypes": [], + "props": {} + }, + "DelegateActionInvalidNonce": { + "name": "DelegateActionInvalidNonce", + "subtypes": [], + "props": { + "ak_nonce": "", + "delegate_nonce": "" + } + }, + "DelegateActionInvalidSignature": { + "name": "DelegateActionInvalidSignature", + "subtypes": [], + "props": {} + }, + "DelegateActionMustBeOnlyOne": { + "name": "DelegateActionMustBeOnlyOne", + "subtypes": [], + "props": {} + }, + "DelegateActionNonceTooLarge": { + "name": "DelegateActionNonceTooLarge", + "subtypes": [], + "props": { + "delegate_nonce": "", + "upper_bound": "" + } + }, + "DelegateActionSenderDoesNotMatchTxReceiver": { + "name": "DelegateActionSenderDoesNotMatchTxReceiver", + "subtypes": [], + "props": { + "receiver_id": "", + "sender_id": "" + } + }, "DeleteAccountStaking": { "name": "DeleteAccountStaking", "subtypes": [], @@ -589,6 +251,13 @@ "account_id": "" } }, + "DeleteAccountWithLargeState": { + "name": "DeleteAccountWithLargeState", + "subtypes": [], + "props": { + "account_id": "" + } + }, "DeleteActionMustBeFinal": { "name": "DeleteActionMustBeFinal", "subtypes": [], @@ -607,6 +276,37 @@ "subtypes": [], "props": {} }, + "Deprecated": { + "name": "Deprecated", + "subtypes": [], + "props": { + "method_name": "" + } + }, + "Deserialization": { + "name": "Deserialization", + "subtypes": [], + "props": {} + }, + "ECRecoverError": { + "name": "ECRecoverError", + "subtypes": [], + "props": { + "msg": "" + } + }, + "Ed25519VerifyInvalidInput": { + "name": "Ed25519VerifyInvalidInput", + "subtypes": [], + "props": { + "msg": "" + } + }, + "EmptyMethodName": { + "name": "EmptyMethodName", + "subtypes": [], + "props": {} + }, "Expired": { "name": "Expired", "subtypes": [], @@ -628,8 +328,94 @@ "limit": "" } }, - "FunctionCallZeroAttachedGas": { - "name": "FunctionCallZeroAttachedGas", + "FunctionCallZeroAttachedGas": { + "name": "FunctionCallZeroAttachedGas", + "subtypes": [], + "props": {} + }, + "GasExceeded": { + "name": "GasExceeded", + "subtypes": [], + "props": {} + }, + "GasInstrumentation": { + "name": "GasInstrumentation", + "subtypes": [], + "props": {} + }, + "GasLimitExceeded": { + "name": "GasLimitExceeded", + "subtypes": [], + "props": {} + }, + "GenericTrap": { + "name": "GenericTrap", + "subtypes": [], + "props": {} + }, + "GuestPanic": { + "name": "GuestPanic", + "subtypes": [], + "props": { + "panic_msg": "" + } + }, + "HostError": { + "name": "HostError", + "subtypes": [ + "BadUTF16", + "BadUTF8", + "GasExceeded", + "GasLimitExceeded", + "BalanceExceeded", + "EmptyMethodName", + "GuestPanic", + "IntegerOverflow", + "InvalidPromiseIndex", + "CannotAppendActionToJointPromise", + "CannotReturnJointPromise", + "InvalidPromiseResultIndex", + "InvalidRegisterId", + "IteratorWasInvalidated", + "MemoryAccessViolation", + "InvalidReceiptIndex", + "InvalidIteratorIndex", + "InvalidAccountId", + "InvalidMethodName", + "InvalidPublicKey", + "ProhibitedInView", + "NumberOfLogsExceeded", + "KeyLengthExceeded", + "ValueLengthExceeded", + "TotalLogLengthExceeded", + "NumberPromisesExceeded", + "NumberInputDataDependenciesExceeded", + "ReturnedValueLengthExceeded", + "ContractSizeExceeded", + "Deprecated", + "ECRecoverError", + "AltBn128InvalidInput", + "Ed25519VerifyInvalidInput" + ], + "props": {} + }, + "IllegalArithmetic": { + "name": "IllegalArithmetic", + "subtypes": [], + "props": {} + }, + "IncorrectCallIndirectSignature": { + "name": "IncorrectCallIndirectSignature", + "subtypes": [], + "props": {} + }, + "IndirectCallToNull": { + "name": "IndirectCallToNull", + "subtypes": [], + "props": {} + }, + "Instantiate": { + "name": "Instantiate", "subtypes": [], "props": {} }, @@ -642,6 +428,16 @@ "stake": "" } }, + "IntegerOverflow": { + "name": "IntegerOverflow", + "subtypes": [], + "props": {} + }, + "InternalMemoryDeclared": { + "name": "InternalMemoryDeclared", + "subtypes": [], + "props": {} + }, "InvalidAccessKeyError": { "name": "InvalidAccessKeyError", "subtypes": [ @@ -654,6 +450,11 @@ ], "props": {} }, + "InvalidAccountId": { + "name": "InvalidAccountId", + "subtypes": [], + "props": {} + }, "InvalidChain": { "name": "InvalidChain", "subtypes": [], @@ -666,6 +467,18 @@ "account_id": "" } }, + "InvalidIteratorIndex": { + "name": "InvalidIteratorIndex", + "subtypes": [], + "props": { + "iterator_index": "" + } + }, + "InvalidMethodName": { + "name": "InvalidMethodName", + "subtypes": [], + "props": {} + }, "InvalidNonce": { "name": "InvalidNonce", "subtypes": [], @@ -681,6 +494,32 @@ "account_id": "" } }, + "InvalidPromiseIndex": { + "name": "InvalidPromiseIndex", + "subtypes": [], + "props": { + "promise_idx": "" + } + }, + "InvalidPromiseResultIndex": { + "name": "InvalidPromiseResultIndex", + "subtypes": [], + "props": { + "result_idx": "" + } + }, + "InvalidPublicKey": { + "name": "InvalidPublicKey", + "subtypes": [], + "props": {} + }, + "InvalidReceiptIndex": { + "name": "InvalidReceiptIndex", + "subtypes": [], + "props": { + "receipt_index": "" + } + }, "InvalidReceiverId": { "name": "InvalidReceiverId", "subtypes": [], @@ -688,6 +527,13 @@ "account_id": "" } }, + "InvalidRegisterId": { + "name": "InvalidRegisterId", + "subtypes": [], + "props": { + "register_id": "" + } + }, "InvalidSignature": { "name": "InvalidSignature", "subtypes": [], @@ -707,6 +553,7 @@ "InvalidSignerId", "SignerDoesNotExist", "InvalidNonce", + "NonceTooLarge", "InvalidReceiverId", "InvalidSignature", "NotEnoughBalance", @@ -714,10 +561,26 @@ "CostOverflow", "InvalidChain", "Expired", - "ActionsValidation" + "ActionsValidation", + "TransactionSizeExceeded" ], "props": {} }, + "IteratorWasInvalidated": { + "name": "IteratorWasInvalidated", + "subtypes": [], + "props": { + "iterator_index": "" + } + }, + "KeyLengthExceeded": { + "name": "KeyLengthExceeded", + "subtypes": [], + "props": { + "length": "", + "limit": "" + } + }, "LackBalanceForState": { "name": "LackBalanceForState", "subtypes": [], @@ -726,6 +589,31 @@ "amount": "" } }, + "Memory": { + "name": "Memory", + "subtypes": [], + "props": {} + }, + "MemoryAccessViolation": { + "name": "MemoryAccessViolation", + "subtypes": [], + "props": {} + }, + "MemoryOutOfBounds": { + "name": "MemoryOutOfBounds", + "subtypes": [], + "props": {} + }, + "MethodEmptyName": { + "name": "MethodEmptyName", + "subtypes": [], + "props": {} + }, + "MethodInvalidSignature": { + "name": "MethodInvalidSignature", + "subtypes": [], + "props": {} + }, "MethodNameMismatch": { "name": "MethodNameMismatch", "subtypes": [], @@ -733,6 +621,33 @@ "method_name": "" } }, + "MethodNotFound": { + "name": "MethodNotFound", + "subtypes": [], + "props": {} + }, + "MethodResolveError": { + "name": "MethodResolveError", + "subtypes": [ + "MethodEmptyName", + "MethodNotFound", + "MethodInvalidSignature" + ], + "props": {} + }, + "MisalignedAtomicAccess": { + "name": "MisalignedAtomicAccess", + "subtypes": [], + "props": {} + }, + "NonceTooLarge": { + "name": "NonceTooLarge", + "subtypes": [], + "props": { + "tx_nonce": "", + "upper_bound": "" + } + }, "NotEnoughAllowance": { "name": "NotEnoughAllowance", "subtypes": [], @@ -752,6 +667,29 @@ "signer_id": "" } }, + "NumberInputDataDependenciesExceeded": { + "name": "NumberInputDataDependenciesExceeded", + "subtypes": [], + "props": { + "limit": "", + "number_of_input_data_dependencies": "" + } + }, + "NumberOfLogsExceeded": { + "name": "NumberOfLogsExceeded", + "subtypes": [], + "props": { + "limit": "" + } + }, + "NumberPromisesExceeded": { + "name": "NumberPromisesExceeded", + "subtypes": [], + "props": { + "limit": "", + "number_of_promises": "" + } + }, "OnlyImplicitAccountCreationAllowed": { "name": "OnlyImplicitAccountCreationAllowed", "subtypes": [], @@ -759,6 +697,28 @@ "account_id": "" } }, + "PrepareError": { + "name": "PrepareError", + "subtypes": [ + "Serialization", + "Deserialization", + "InternalMemoryDeclared", + "GasInstrumentation", + "StackHeightInstrumentation", + "Instantiate", + "Memory", + "TooManyFunctions", + "TooManyLocals" + ], + "props": {} + }, + "ProhibitedInView": { + "name": "ProhibitedInView", + "subtypes": [], + "props": { + "method_name": "" + } + }, "ReceiptValidationError": { "name": "ReceiptValidationError", "subtypes": [ @@ -785,6 +745,19 @@ "subtypes": [], "props": {} }, + "ReturnedValueLengthExceeded": { + "name": "ReturnedValueLengthExceeded", + "subtypes": [], + "props": { + "length": "", + "limit": "" + } + }, + "Serialization": { + "name": "Serialization", + "subtypes": [], + "props": {} + }, "SignerDoesNotExist": { "name": "SignerDoesNotExist", "subtypes": [], @@ -792,6 +765,34 @@ "signer_id": "" } }, + "StackHeightInstrumentation": { + "name": "StackHeightInstrumentation", + "subtypes": [], + "props": {} + }, + "StackOverflow": { + "name": "StackOverflow", + "subtypes": [], + "props": {} + }, + "TooManyFunctions": { + "name": "TooManyFunctions", + "subtypes": [], + "props": {} + }, + "TooManyLocals": { + "name": "TooManyLocals", + "subtypes": [], + "props": {} + }, + "TotalLogLengthExceeded": { + "name": "TotalLogLengthExceeded", + "subtypes": [], + "props": { + "length": "", + "limit": "" + } + }, "TotalNumberOfActionsExceeded": { "name": "TotalNumberOfActionsExceeded", "subtypes": [], @@ -808,6 +809,14 @@ "total_prepaid_gas": "" } }, + "TransactionSizeExceeded": { + "name": "TransactionSizeExceeded", + "subtypes": [], + "props": { + "limit": "", + "size": "" + } + }, "TriesToStake": { "name": "TriesToStake", "subtypes": [], @@ -833,6 +842,11 @@ ], "props": {} }, + "Unreachable": { + "name": "Unreachable", + "subtypes": [], + "props": {} + }, "UnsuitableStakingKey": { "name": "UnsuitableStakingKey", "subtypes": [], @@ -840,13 +854,46 @@ "public_key": "" } }, - "Closed": { - "name": "Closed", + "UnsupportedProtocolFeature": { + "name": "UnsupportedProtocolFeature", "subtypes": [], + "props": { + "protocol_feature": "", + "version": "" + } + }, + "ValueLengthExceeded": { + "name": "ValueLengthExceeded", + "subtypes": [], + "props": { + "length": "", + "limit": "" + } + }, + "WasmTrap": { + "name": "WasmTrap", + "subtypes": [ + "Unreachable", + "IncorrectCallIndirectSignature", + "MemoryOutOfBounds", + "CallIndirectOOB", + "IllegalArithmetic", + "MisalignedAtomicAccess", + "IndirectCallToNull", + "StackOverflow", + "GenericTrap" + ], "props": {} }, - "InternalError": { - "name": "InternalError", + "WasmerCompileError": { + "name": "WasmerCompileError", + "subtypes": [], + "props": { + "msg": "" + } + }, + "Closed": { + "name": "Closed", "subtypes": [], "props": {} }, @@ -855,8 +902,7 @@ "subtypes": [ "TxExecutionError", "Timeout", - "Closed", - "InternalError" + "Closed" ], "props": {} }, diff --git a/packages/utils/src/errors/rpc_errors.ts b/packages/utils/src/errors/rpc_errors.ts index 9bc0790998..57e73a1529 100644 --- a/packages/utils/src/errors/rpc_errors.ts +++ b/packages/utils/src/errors/rpc_errors.ts @@ -95,9 +95,11 @@ export function getErrorTypeFromErrorMessage(errorMessage, errorType) { case /^access key .*? does not exist while viewing$/.test(errorMessage): return 'AccessKeyDoesNotExist'; case /wasm execution failed with error: FunctionCallError\(CompilationError\(CodeDoesNotExist/.test(errorMessage): + return 'CodeDoesNotExist'; case /wasm execution failed with error: CompilationError\(CodeDoesNotExist/.test(errorMessage): return 'CodeDoesNotExist'; case /wasm execution failed with error: FunctionCallError\(MethodResolveError\(MethodNotFound/.test(errorMessage): + return 'MethodNotFound'; case /wasm execution failed with error: MethodResolveError\(MethodNotFound/.test(errorMessage): return 'MethodNotFound'; case /Transaction nonce \d+ must be larger than nonce of the used access key \d+/.test(errorMessage): diff --git a/packages/utils/test/rpc-errors.test.js b/packages/utils/test/rpc-errors.test.js index 5a62d79b6c..33c5a6c6a3 100644 --- a/packages/utils/test/rpc-errors.test.js +++ b/packages/utils/test/rpc-errors.test.js @@ -53,7 +53,7 @@ describe('rpc-errors', () => { }; let error = parseRpcError(rpc_error); expect(error.type).toBe('ActionError'); - expect(error.message).toBe('{"kind":{"FunctionCallError":{"HostError":{"InvalidIteratorIndex":{"iterator_index":42}}}}}'); + expect(formatError(error.type, error)).toBe('{\"type\":\"ActionError\",\"kind\":{\"FunctionCallError\":{\"HostError\":{\"InvalidIteratorIndex\":{\"iterator_index\":42}}}}}'); }); test('test ActionError::FunctionCallError::GasLimitExceeded error', async () => { @@ -69,7 +69,8 @@ describe('rpc-errors', () => { }; let error = parseRpcError(rpc_error); expect(error.type).toBe('ActionError'); - expect(error.message).toBe('{"index":0,"kind":{"index":0,"kind":{"FunctionCallError":{"HostError":"GasLimitExceeded"}}}}'); + + expect(formatError(error.type, error)).toBe('{\"type\":\"ActionError\",\"index\":0,\"kind\":{\"index\":0,\"kind\":{\"FunctionCallError\":{\"HostError\":\"GasLimitExceeded\"}}}}'); }); test('test parse error object', async () => { @@ -85,12 +86,16 @@ describe('rpc-errors', () => { const err4 = 'wasm execution failed with error: CompilationError(CodeDoesNotExist { account_id: "random.testnet" })'; const err5 = '[-32000] Server error: Invalid transaction: Transaction nonce 1 must be larger than nonce of the used access key 1'; const err6 = 'wasm execution failed with error: MethodResolveError(MethodNotFound)'; + const err7 = 'wasm execution failed with error: FunctionCallError(CompilationError(CodeDoesNotExist { account_id: "random.testnet" }))'; + const err8 = 'wasm execution failed with error: FunctionCallError(MethodResolveError(MethodNotFound))'; expect(getErrorTypeFromErrorMessage(err1)).toEqual('AccountDoesNotExist'); expect(getErrorTypeFromErrorMessage(err2)).toEqual('AccountDoesNotExist'); expect(getErrorTypeFromErrorMessage(err3)).toEqual('AccessKeyDoesNotExist'); expect(getErrorTypeFromErrorMessage(err4)).toEqual('CodeDoesNotExist'); expect(getErrorTypeFromErrorMessage(err5)).toEqual('InvalidNonce'); expect(getErrorTypeFromErrorMessage(err6)).toEqual('MethodNotFound'); + expect(getErrorTypeFromErrorMessage(err7)).toEqual('CodeDoesNotExist'); + expect(getErrorTypeFromErrorMessage(err8)).toEqual('MethodNotFound'); }); test('test NotEnoughBalance message uses human readable values', () => {