Skip to content

XTC is not compatible with DIP20 #53

@seniorjoinu

Description

@seniorjoinu

DIP20 has errors defined like this

pub enum Dip20TxError {
    InsufficientAllowance,
    InsufficientBalance,
    ErrorOperationStyle,
    Unauthorized,
    LedgerTrap,
    ErrorTo,
    Other,
    BlockUsed,
    AmountTooSmall,
}

While XTC's errors are defined like this

pub enum TxError {
    InsufficientAllowance,
    InsufficientBalance,
    ErrorOperationStyle,
    Unauthorized,
    LedgerTrap,
    ErrorTo,
    Other,
    BlockUsed,
    FetchRateFailed,
    NotifyDfxFailed,
    UnexpectedCyclesResponse,
    AmountTooSmall,
    InsufficientXTCFee,
}

As you can see, XTC has more enum entries.
When trying to use DIP20 types against XTC canister and bump into an error, one would get an error message like:

The Replica returned an error: code 5, message: "Canister knhk5-cyaaa-aaaak-aagoq-cai trapped explicitly: Custom(Fail to decode argument 0 from table0 to variant {
  Ok : nat;
  Err : variant {
    InsufficientAllowance;
    InsufficientBalance;
    ErrorOperationStyle;
    Unauthorized;
    LedgerTrap;
    ErrorTo;
    Other;
    BlockUsed;
    AmountTooSmall;
  };
}

Caused by:
    0: input: 4449444c026b02bc8a017dc5fed201016b0dea99f1497fb5da9aa3037fffcc9bc5057fb9d6c894067fa2dab8d7077fd292d883087fd4b4c59a097fd6e89efe097fc3feeeba0b7fb0ad8fcd0c7ff7c295940e7f8afcbca80f7fabb7cef40f7f0100_00dbb301
       table: type table0 = variant { 17_724 : nat; 3_456_837 : table1 }
       type table1 = variant {
         154_946_794;
         879_144_245;
         1_487_332_991;
         1_653_746_489;
         2_062_429_474;
         2_155_219_282;
         2_471_582_292;
         2_680_665_174;
         3_076_243_267;
         3_382_957_744;
         3_800_392_055;
         4_111_416_842;
         4_271_086_507;
       }
       wire_type: table0, expect_type: variant {
         Ok : nat;
         Err : variant {
           InsufficientAllowance;
           InsufficientBalance;
           ErrorOperationStyle;
           Unauthorized;
           LedgerTrap;
           ErrorTo;
           Other;
           BlockUsed;
           AmountTooSmall;
         };
       }
    1: table0 is not a subtype of variant {
         Ok : nat;
         Err : variant {
           InsufficientAllowance;
           InsufficientBalance;
           ErrorOperationStyle;
           Unauthorized;
           LedgerTrap;
           ErrorTo;
           Other;
           BlockUsed;
           AmountTooSmall;
         };
       }
    2: Variant field 3_456_837: table1 is not a subtype of variant {
         InsufficientAllowance;
         InsufficientBalance;
         ErrorOperationStyle;
         Unauthorized;
         LedgerTrap;
         ErrorTo;
         Other;
         BlockUsed;
         AmountTooSmall;
       }
    3: Variant field 154_946_794 not found in the expected type)"

Please, make them compatible. Otherwise, what's the point of the standard?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions