import { makeErrorWithCode } from '@neo-one/utils' ; import { common , PrivateKey } from './common' ; import { OpCode } from './models/vm' ; import { ContractParameter } from './types' ; export const UnknownOpError = makeErrorWithCode ( 'UNKNOWN_OP' , ( byteCode ) => `Unknown op: ${ byteCode }` ) ; export const InvalidContractParameterError = makeErrorWithCode ( 'INVALID_CONTRACT_PARAMETER' , ( parameter , expected ) => `Expected one of ${ JSON . stringify ( expected ) } ` + `ContractParameterTypes, found ${ parameter . type }` ) ; export const Base58CheckError = makeErrorWithCode ( 'BASE_58_CHECK' , ( value ) => `Base58 Check Decode Error on decoding: ${ value }` ) ; export const InvalidAddressError = makeErrorWithCode ( 'INVALID_ADDRESS' , ( address ) => `Invalid Address: ${ address }` ) ; export const TooManyPublicKeysError = makeErrorWithCode ( 'TOO_MANY_PUBLIC_KEYS' , ( amount ) => `Too many public keys. Found: ${ amount }, Max: 1024` ) ; export const InvalidNumberOfKeysError = makeErrorWithCode ( 'INVALID_NUMBER_OF_KEYS' , ( m , amount ) => `invalid number of keys. Found: ${ m } keys, must be between 1 and ${ amount } (number of public keys).` ) ; export const InvalidPrivateKeyError = makeErrorWithCode ( 'INVALID_PRIVATE_KEY' , ( privateKey ) => `Invalid Private Key, found: ${ common . privateKeyToString ( privateKey ) }` ) ; export const InvalidSignatureError = makeErrorWithCode ( 'INVALID_SIGNATURE' , ( length ) => `Invalid Signature length. Found: ${ length }, Max: 64` ) ; export const InvalidSysCallError = makeErrorWithCode ( 'INVALID_SYS_CALL_NAME' , ( value ) => `Expected sys call name, found: ${ value }` ) ; export const InvalidVMStateError = makeErrorWithCode ( 'INVALID_VM_STATE' , ( state ) => `Invalid VM State: ${ state }` ) ; export const InvalidParamError = makeErrorWithCode ( 'INVALID_PARAM' , ( paramType ? ) => `Invalid Param${ paramType === undefined ? '.' : `: ${ paramType }` }` ) ; export const InvalidAssetTypeJSONError = makeErrorWithCode ( 'INVALID_ASSET_TYPE_JSON' , ( type ) => `Invalid AssetType: ${ type }` ) ; export const InvalidAssetTypeError = makeErrorWithCode ( 'INVALID_ASSET_TYPE' , ( assetType ) => `Expected asset type, found: ${ assetType . toString ( 16 ) }` ) ; export const InvalidStorageFlagsJSONError = makeErrorWithCode ( 'INVALID_STORAGE_FLAGS_JSON' , ( type ) => `Invalid StorageFlags: ${ type }` ) ; export const InvalidStorageFlagsError = makeErrorWithCode ( 'INVALID_STORAGE_FLAGS' , ( storageFlags ) => `Expected StorageFlags, found: ${ storageFlags . toString ( 16 ) }` ) ; export const InvalidVerifyResultError = makeErrorWithCode ( 'INVALID_RELAY_RESULT_REASON' , ( reason ) => `Expected VerifyResult, found: ${ reason . toString ( 16 ) }` ) ; export const InvalidVerifyResultJSONError = makeErrorWithCode ( 'INVALID_RELAY_RESULT_REASON_JSON' , ( value ) => `Invalid VerifyResult: ${ value }` ) ; export const InvalidDesignationRoleError = makeErrorWithCode ( 'INVALID_DESIGNATION_ROLE' , ( type ) => `Expected designation role, found: ${ type }` ) ; export const InvalidContractParameterTypeJSONError = makeErrorWithCode ( 'INVALID_CONTRACT_PARAMETER_TYPE_JSON' , ( value ) => `Invalid ContractParameterType: ${ value }` ) ; export const InvalidContractParameterTypeError = makeErrorWithCode ( 'INVALID_CONTRACT_PARAMETER_TYPE' , ( contractParameterType ) => `Expected contract parameter type, found: ${ contractParameterType . toString ( 16 ) }` ) ; export const InvalidWitnessScopeJSONError = makeErrorWithCode ( 'INVALID_WITNESS_SCOPE_JSON' , ( value ) => `Invalid WitnessScope: ${ value }` ) ; export const InvalidWitnessScopeError = makeErrorWithCode ( 'INVALID_WITNESS_SCOPE' , ( witnessScope ) => `Expected witness scope, found: ${ witnessScope . toString ( 16 ) }` ) ; export const InvalidAttributeTypeJSONError = makeErrorWithCode ( 'INVALID_ATTRIBUTE_TYPE' , ( value ) => `Invalid AttributeType: ${ value }` ) ; export const InvalidAttributeTypeError = makeErrorWithCode ( 'INVALID_ATTRIBUTE_TYPE' , ( transactionAttributeType ) => `Expected transaction attribute type, found: ${ transactionAttributeType . toString ( 16 ) }` ) ; export const InvalidOracleResponseCodeError = makeErrorWithCode ( 'INVALID_ORACLE_RESPONSE_CODE' , ( value ) => `Expected oracle response code, found: ${ value . toString ( ) }` ) ; export const InvalidAttributeUsageError = makeErrorWithCode ( 'INVALID_ATTRIBUTE_USAGE' , ( transactionAttributeUsage ) => `Expected transaction attribute usage, found: ${ transactionAttributeUsage . toString ( 16 ) }` ) ; export const InvalidAttributeUsageJSONError = makeErrorWithCode ( 'INVALID_ATTRIBUTE_USAGE_JSON' , ( transactionAttributeUsage ) => `Expected transaction attribute usage, found: ${ transactionAttributeUsage }` ) ; export const InvalidTransactionTypeError = makeErrorWithCode ( 'INVALID_TRANSACTION_TYPE' , ( transactionType ) => `Expected transaction type, found: ${ transactionType . toString ( 16 ) }` ) ; export const InvalidVMByteCodeError = makeErrorWithCode ( 'INVALID_VM_OP_CODE' , ( value ) => `Expected VM OpCode, received: ${ value }}` ) ; export const InvalidSignaturesError = makeErrorWithCode ( 'INVALID_SIGNATURES' , ( m , value ) => `Expected ${ m } unique signatures, found: ${ value }.` ) ; export const InvalidBIP32VersionError = makeErrorWithCode ( 'INVALID_BIP32_KEY_VERSION' , ( version , expected ) => `Expected key-version ${ expected }; got ${ version }` ) ; export const InvalidBIP32ExtendedKeyError = makeErrorWithCode ( 'INVALID_BIP32_EXTENDED_KEY' , ( key ) => `Invalid Extended Key: ${ key }` ) ; export const InvalidBIP32ChildIndexError = makeErrorWithCode ( 'INVALID_BIP32_CHILD_INDEX' , ( index ) => `Index must be less than ${ 0x80000000 }; got ${ index }` ) ; export const InvalidBIP32HardenedError = makeErrorWithCode ( 'INVALID_BIP32_HARDENED_CALL' , ( ) => 'Cannot derive a hardened child key from a public key.' ) ; export const InvalidBIP32SerializePrivateNodeError = makeErrorWithCode ( 'INVALID_BIP32_PRIVATE_SERIALIZATION' , ( ) => 'Cannot serialize a private extended key from a public node.' ) ; export const InvalidJumpError = makeErrorWithCode ( 'INVALID_JMP_OPCODE' , ( op ) => `Expected valid JMP instruction; got ${ op }` ) ; export const InvalidScriptError = makeErrorWithCode ( 'INVALID_SCRIPT' , ( op , ip ) => `Invalid instruction ${ op } at position: ${ ip }.` ) ;