Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor (generalize) the invalidTransactionError() to cover more cases. #1771

Open
shimkiv opened this issue Jul 25, 2024 · 1 comment
Open
Assignees
Labels
enhancement New feature or request

Comments

@shimkiv
Copy link
Member

shimkiv commented Jul 25, 2024

In #1769 we introduced the humanizeErrors() in order to act on community members' feedback faster.

But it will be good to refactor the existing invalidTransactionError() method to make it cover more cases: txns broadcasting issues / declined txns (one we receive immediately even before txn gets into the mempool) and txns processing failures issue (the current behaviour, when txns were processed by the blockchain but failed and failure reasons returned in GQL response).

@shimkiv shimkiv added the enhancement New feature or request label Jul 25, 2024
@shimkiv shimkiv self-assigned this Jul 25, 2024
@Trivo25
Copy link
Member

Trivo25 commented Jul 25, 2024

+100, we need to do this for all graphql/transaction errors

There's already a list of description for each error in the OCaml code base, we just need to copy/paste

  let describe = function
    | Predicate ->
        "A predicate failed"
    | Source_not_present ->
        "The source account does not exist"
    | Receiver_not_present ->
        "The receiver account does not exist"
    | Amount_insufficient_to_create_account ->
        "Cannot create account: transaction amount is smaller than the account \
         creation fee"
    | Cannot_pay_creation_fee_in_token ->
        "Cannot create account: account creation fees cannot be paid in \
         non-default tokens"
    | Source_insufficient_balance ->
        "The source account has an insufficient balance"
    | Source_minimum_balance_violation ->
        "The source account requires a minimum balance"
    | Receiver_already_exists ->
        "Attempted to create an account that already exists"
    | Token_owner_not_caller ->
        "An account update used a non-default token but its caller was not the \
         token owner"
    | Overflow ->
        "The resulting balance is too large to store"
    | Global_excess_overflow ->
        "The resulting global fee excess is too large to store"
    | Local_excess_overflow ->
        "The resulting local fee excess is too large to store"
    | Local_supply_increase_overflow ->
        "The resulting local supply increase is too large to store"
    | Global_supply_increase_overflow ->
        "The resulting global supply increase is too large to store"
    | Signed_command_on_zkapp_account ->
        "The source of a signed command cannot be a snapp account"
    | Zkapp_account_not_present ->
        "A zkApp account does not exist"
    | Update_not_permitted_balance ->
        "The authentication for an account didn't allow the requested update \
         to its balance"
    | Update_not_permitted_access ->
        "The authentication for an account didn't allow it to be accessed"
    | Update_not_permitted_timing ->
        "The authentication for an account didn't allow the requested update \
         to its timing"
    | Update_not_permitted_delegate ->
        "The authentication for an account didn't allow the requested update \
         to its delegate"
    | Update_not_permitted_app_state ->
        "The authentication for an account didn't allow the requested update \
         to its app state"
    | Update_not_permitted_verification_key ->
        "The authentication for an account didn't allow the requested update \
         to its verification key"
    | Update_not_permitted_action_state ->
        "The authentication for an account didn't allow the requested update \
         to its action state"
    | Update_not_permitted_zkapp_uri ->
        "The authentication for an account didn't allow the requested update \
         to its snapp URI"
    | Update_not_permitted_token_symbol ->
        "The authentication for an account didn't allow the requested update \
         to its token symbol"
    | Update_not_permitted_permissions ->
        "The authentication for an account didn't allow the requested update \
         to its permissions"
    | Update_not_permitted_nonce ->
        "The authentication for an account didn't allow the requested update \
         to its nonce"
    | Update_not_permitted_voting_for ->
        "The authentication for an account didn't allow the requested update \
         to its voted-for state hash"
    | Zkapp_command_replay_check_failed ->
        "Check to avoid replays failed. The account update must increment \
         nonce or use full commitment if the authorization is a signature"
    | Fee_payer_nonce_must_increase ->
        "Fee payer account update must increment its nonce"
    | Fee_payer_must_be_signed ->
        "Fee payer account update must have a valid signature"
    | Account_balance_precondition_unsatisfied ->
        "The account update's account balance precondition was unsatisfied"
    | Account_nonce_precondition_unsatisfied ->
        "The account update's account nonce precondition was unsatisfied"
    | Account_receipt_chain_hash_precondition_unsatisfied ->
        "The account update's account receipt-chain hash precondition was \
         unsatisfied"
    | Account_delegate_precondition_unsatisfied ->
        "The account update's account delegate precondition was unsatisfied"
    | Account_action_state_precondition_unsatisfied ->
        "The account update's account action state precondition was unsatisfied"
    | Account_app_state_precondition_unsatisfied i ->
        sprintf
          "The account update's account app state (%i) precondition was \
           unsatisfied"
          i
    | Account_proved_state_precondition_unsatisfied ->
        "The account update's account proved state precondition was unsatisfied"
    | Account_is_new_precondition_unsatisfied ->
        "The account update's account is-new state precondition was unsatisfied"
    | Protocol_state_precondition_unsatisfied ->
        "The account update's protocol state precondition unsatisfied"
    | Valid_while_precondition_unsatisfied ->
        "The account update's valid-until precondition was unsatisfied"
    | Unexpected_verification_key_hash ->
        "The account update's verification key hash does not match the \
         verification key in the ledger account"
    | Incorrect_nonce ->
        "Incorrect nonce"
    | Invalid_fee_excess ->
        "Fee excess from zkapp_command transaction more than the transaction \
         fees"
    | Cancelled ->
        "The account update is cancelled because there's a failure in the \
         zkApp transaction"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants