diff --git a/README.md b/README.md index e79fe80dfe..a675e6574f 100644 --- a/README.md +++ b/README.md @@ -36,3 +36,13 @@ yarn test ``` Tests use sample contract from `near-hello` npm package, see https://github.com/nearprotocol/near-hello + +## Update error messages + +Follow next steps: + +1. [Change hash for the commit with errors in the nearcore](https://github.com/nearprotocol/nearlib/blob/master/gen_error_types.js#L7-L9) +2. Generate new types for errors: `node gen_error_types.js` +3. `yarn lint --fix` fix any issues with linter. +4. `yarn build` to update `lib/**.js` files + diff --git a/gen_error_types.js b/gen_error_types.js index 2211531e8d..a10c462f98 100644 --- a/gen_error_types.js +++ b/gen_error_types.js @@ -6,7 +6,7 @@ const { } = require('ts-morph'); const ERROR_SCHEMA_URL = - 'https://raw.githubusercontent.com/nearprotocol/nearcore/2b12956e3787fa876e0ba959559e67edb73635c5/chain/jsonrpc/res/rpc_errors_schema.json'; + 'https://raw.githubusercontent.com/nearprotocol/nearcore/84a805e0fe4d507d03d6525f68fec99b7d1d6048/chain/jsonrpc/res/rpc_errors_schema.json'; const TARGET_DIR = process.argv[2] || process.cwd() + '/src.ts/generated'; const TARGET_TS_FILE_PATH = TARGET_DIR + '/rpc_error_types.ts'; const TARGET_SCHEMA_FILE_PATH = TARGET_DIR + '/rpc_error_schema.json'; diff --git a/lib/generated/rpc_error_schema.json b/lib/generated/rpc_error_schema.json index 30c9ddb724..9699f4c885 100644 --- a/lib/generated/rpc_error_schema.json +++ b/lib/generated/rpc_error_schema.json @@ -123,7 +123,8 @@ "NumberPromisesExceeded", "NumberInputDataDependenciesExceeded", "ReturnedValueLengthExceeded", - "ContractSizeExceeded" + "ContractSizeExceeded", + "Deprecated" ], "props": {} }, @@ -377,10 +378,11 @@ "DeleteKeyDoesNotExist", "AddKeyAlreadyExists", "DeleteAccountStaking", - "DeleteAccountHasRent", - "RentUnpaid", + "DeleteAccountHasEnoughBalance", + "LackBalanceForState", "TriesToUnstake", "TriesToStake", + "UnsuitableStakingKey", "FunctionCallError", "NewReceiptValidationError" ], @@ -523,7 +525,7 @@ "InvalidReceiverId", "InvalidSignature", "NotEnoughBalance", - "RentUnpaid", + "LackBalanceForState", "CostOverflow", "InvalidChain", "Expired", @@ -628,6 +630,37 @@ "name": "Timeout", "subtypes": [], "props": {} + }, + "UnsuitableStakingKey": { + "name": "UnsuitableStakingKey", + "subtypes": [], + "props": { + "public_key": "" + } + }, + "LackBalanceForState": { + "name": "LackBalanceForState", + "subtypes": [], + "props": { + "amount": "", + "signer_id": "", + "account_id": "" + } + }, + "DeleteAccountHasEnoughBalance": { + "name": "DeleteAccountHasEnoughBalance", + "subtypes": [], + "props": { + "account_id": "", + "balance": "" + } + }, + "Deprecated": { + "name": "Deprecated", + "subtypes": [], + "props": { + "method_name": "" + } } } } diff --git a/lib/generated/rpc_error_types.d.ts b/lib/generated/rpc_error_types.d.ts index 4e1b70c1a7..627cc96514 100644 --- a/lib/generated/rpc_error_types.d.ts +++ b/lib/generated/rpc_error_types.d.ts @@ -1,4 +1,4 @@ -import { TypedError } from '../utils/errors'; +import { TypedError } from "../utils/errors"; export declare class ServerError extends TypedError { } export declare class TxExecutionError extends ServerError { @@ -174,7 +174,7 @@ export declare class CreateAccountNotAllowed extends ActionError { account_id: any; predecessor_id: any; } -export declare class DeleteAccountHasRent extends ActionError { +export declare class DeleteAccountHasRent extends TypedError { account_id: any; balance: any; } @@ -221,7 +221,7 @@ export declare class ReceiverMismatch extends InvalidAccessKeyError { ak_receiver: any; tx_receiver: any; } -export declare class RentUnpaid extends ActionError { +export declare class RentUnpaid extends TypedError { account_id: any; amount: any; } @@ -243,3 +243,18 @@ export declare class Closed extends ServerError { } export declare class Timeout extends ServerError { } +export declare class UnsuitableStakingKey extends ActionError { + public_key: any; +} +export declare class LackBalanceForState extends ActionError { + amount: any; + signer_id: any; + account_id: any; +} +export declare class DeleteAccountHasEnoughBalance extends ActionError { + account_id: any; + balance: any; +} +export declare class Deprecated extends HostError { + method_name: any; +} diff --git a/lib/generated/rpc_error_types.js b/lib/generated/rpc_error_types.js index 0413447724..69f1a37a6f 100644 --- a/lib/generated/rpc_error_types.js +++ b/lib/generated/rpc_error_types.js @@ -187,7 +187,7 @@ exports.CostOverflow = CostOverflow; class CreateAccountNotAllowed extends ActionError { } exports.CreateAccountNotAllowed = CreateAccountNotAllowed; -class DeleteAccountHasRent extends ActionError { +class DeleteAccountHasRent extends errors_1.TypedError { } exports.DeleteAccountHasRent = DeleteAccountHasRent; class DeleteAccountStaking extends ActionError { @@ -229,7 +229,7 @@ exports.NotEnoughBalance = NotEnoughBalance; class ReceiverMismatch extends InvalidAccessKeyError { } exports.ReceiverMismatch = ReceiverMismatch; -class RentUnpaid extends ActionError { +class RentUnpaid extends errors_1.TypedError { } exports.RentUnpaid = RentUnpaid; class RequiresFullAccess extends InvalidAccessKeyError { @@ -250,3 +250,15 @@ exports.Closed = Closed; class Timeout extends ServerError { } exports.Timeout = Timeout; +class UnsuitableStakingKey extends ActionError { +} +exports.UnsuitableStakingKey = UnsuitableStakingKey; +class LackBalanceForState extends ActionError { +} +exports.LackBalanceForState = LackBalanceForState; +class DeleteAccountHasEnoughBalance extends ActionError { +} +exports.DeleteAccountHasEnoughBalance = DeleteAccountHasEnoughBalance; +class Deprecated extends HostError { +} +exports.Deprecated = Deprecated; diff --git a/src.ts/generated/rpc_error_schema.json b/src.ts/generated/rpc_error_schema.json index ffd8828e37..855d060799 100644 --- a/src.ts/generated/rpc_error_schema.json +++ b/src.ts/generated/rpc_error_schema.json @@ -123,7 +123,8 @@ "NumberPromisesExceeded", "NumberInputDataDependenciesExceeded", "ReturnedValueLengthExceeded", - "ContractSizeExceeded" + "ContractSizeExceeded", + "Deprecated" ], "props": {} }, @@ -377,10 +378,11 @@ "DeleteKeyDoesNotExist", "AddKeyAlreadyExists", "DeleteAccountStaking", - "DeleteAccountHasRent", - "RentUnpaid", + "DeleteAccountHasEnoughBalance", + "LackBalanceForState", "TriesToUnstake", "TriesToStake", + "UnsuitableStakingKey", "FunctionCallError", "NewReceiptValidationError" ], @@ -523,7 +525,7 @@ "InvalidReceiverId", "InvalidSignature", "NotEnoughBalance", - "RentUnpaid", + "LackBalanceForState", "CostOverflow", "InvalidChain", "Expired", @@ -628,6 +630,37 @@ "name": "Timeout", "subtypes": [], "props": {} + }, + "UnsuitableStakingKey": { + "name": "UnsuitableStakingKey", + "subtypes": [], + "props": { + "public_key": "" + } + }, + "LackBalanceForState": { + "name": "LackBalanceForState", + "subtypes": [], + "props": { + "amount": "", + "signer_id": "", + "account_id": "" + } + }, + "DeleteAccountHasEnoughBalance": { + "name": "DeleteAccountHasEnoughBalance", + "subtypes": [], + "props": { + "account_id": "", + "balance": "" + } + }, + "Deprecated": { + "name": "Deprecated", + "subtypes": [], + "props": { + "method_name": "" + } } } } \ No newline at end of file diff --git a/src.ts/generated/rpc_error_types.ts b/src.ts/generated/rpc_error_types.ts index fed68af512..aa4e08ece6 100644 --- a/src.ts/generated/rpc_error_types.ts +++ b/src.ts/generated/rpc_error_types.ts @@ -237,7 +237,7 @@ export class CreateAccountNotAllowed extends ActionError { public predecessor_id; } -export class DeleteAccountHasRent extends ActionError { +export class DeleteAccountHasRent extends TypedError { public account_id; public balance; } @@ -298,7 +298,7 @@ export class ReceiverMismatch extends InvalidAccessKeyError { public tx_receiver; } -export class RentUnpaid extends ActionError { +export class RentUnpaid extends TypedError { public account_id; public amount; } @@ -326,3 +326,22 @@ export class Closed extends ServerError { export class Timeout extends ServerError { } + +export class UnsuitableStakingKey extends ActionError { + public public_key; +} + +export class LackBalanceForState extends ActionError { + public amount; + public signer_id; + public account_id; +} + +export class DeleteAccountHasEnoughBalance extends ActionError { + public account_id; + public balance; +} + +export class Deprecated extends HostError { + public method_name; +} diff --git a/src.ts/res/error_messages.json b/src.ts/res/error_messages.json index ad15d66477..487c0012fb 100644 --- a/src.ts/res/error_messages.json +++ b/src.ts/res/error_messages.json @@ -37,6 +37,7 @@ "InvalidPublicKey": "VM Logic provided an invalid public key", "ActorNoPermission": "Actor {{actor_id}} doesn't have permission to account {{account_id}} to complete the action", "RentUnpaid": "The account {{account_id}} wouldn't have enough balance to pay required rent {{amount}}", + "LackBalanceForState": "The account {{account_id}} wouldn't have enough balance to cover storage, required to have {{amount}}", "ReceiverMismatch": "Wrong AccessKey used for transaction: transaction is sent to receiver_id={{tx_receiver}}, but is signed with function call access key that restricted to only use with receiver_id={{ak_receiver}}. Either change receiver_id in your transaction or switch to use a FullAccessKey.", "CostOverflow": "Transaction gas or balance cost is too high", "InvalidSignature": "Transaction is not signed with the given public key", @@ -58,8 +59,9 @@ "AccountDoesNotExist": "Can't complete the action because account {{account_id}} doesn't exist", "MethodNameMismatch": "Transaction method name {{method_name}} isn't allowed by the access key", "DeleteAccountHasRent": "Account {{account_id}} can't be deleted. It has {balance{}}, which is enough to cover the rent", + "DeleteAccountHasEnoughBalance": "Account {{account_id}} can't be deleted. It has {balance{}}, which is enough to cover it's storage", "InvalidReceiver": "Invalid receiver account ID {{receiver_id}} according to requirements", "DeleteKeyDoesNotExist": "Account {{account_id}} tries to remove an access key that doesn't exist", "Timeout": "Timeout exceeded", "Closed": "Connection closed" -} \ No newline at end of file +}