瀏覽代碼

Merge pull request #83 from Relayz-io/silvestr/near-primitives-function-call-err

Add a new error type for a View call -> FunctionCallError
develop
Predko Silvestr 2 年之前
父節點
當前提交
0c9d9b68b5
沒有連結到貢獻者的電子郵件帳戶。
共有 2 個檔案被更改,包括 10 行新增0 行删除
  1. 1
    0
      near-primitives-light/Cargo.toml
  2. 9
    0
      near-primitives-light/src/errors.rs

+ 1
- 0
near-primitives-light/Cargo.toml 查看文件

@@ -14,3 +14,4 @@ common-api = { path = "../common-api" }
14 14
 chrono = { version = "0.4", features = ["serde"] }
15 15
 serde = { version = "1", default-features = false, features = ["derive", "rc"] }
16 16
 near-primitives-core = "0.15"
17
+near-vm-errors = "3.1"

+ 9
- 0
near-primitives-light/src/errors.rs 查看文件

@@ -401,6 +401,11 @@ pub enum ActionErrorKind {
401 401
         #[serde(with = "dec_format")]
402 402
         minimum_stake: Balance,
403 403
     },
404
+    /// An error occurred during a `FunctionCall` Action, parameter is debug message.
405
+    FunctionCallError(near_vm_errors::FunctionCallErrorSer),
406
+    /// Error occurs when a new `ActionReceipt` created by the `FunctionCall` action fails
407
+    /// receipt validation.
408
+    NewReceiptValidationError(ReceiptValidationError),
404 409
     /// Error occurs when a `CreateAccount` action is called on hex-characters
405 410
     /// account of length 64.  See implicit account creation NEP:
406 411
     /// <https://github.com/nearprotocol/NEPs/pull/71>.
@@ -744,6 +749,10 @@ impl Display for ActionErrorKind {
744 749
             ActionErrorKind::DeleteAccountStaking { account_id } => {
745 750
                 write!(f, "Account {:?} is staking and can not be deleted", account_id)
746 751
             }
752
+            ActionErrorKind::FunctionCallError(s) => write!(f, "{:?}", s),
753
+            ActionErrorKind::NewReceiptValidationError(e) => {
754
+                write!(f, "An new action receipt created during a FunctionCall is not valid: {}", e)
755
+            }
747 756
             ActionErrorKind::InsufficientStake { account_id, stake, minimum_stake } => write!(f, "Account {} tries to stake {} but minimum required stake is {}", account_id, stake, minimum_stake),
748 757
             ActionErrorKind::OnlyImplicitAccountCreationAllowed { account_id } => write!(f, "CreateAccount action is called on hex-characters account of length 64 {}", account_id),
749 758
             ActionErrorKind::DeleteAccountWithLargeState { account_id } => write!(f, "The state of account {} is too large and therefore cannot be deleted", account_id),

Loading…
取消
儲存