ask-lang/ask-old

inconsistent data types for function variable and storage variable

Astrapolis-peasant opened this issue · 1 comments

  protected _transfer(sender: AccountId, recipient: AccountId, amount: u128): void {
    assert(sender.notEq(AccountId.Null), "ERC20: transfer from the zero address");
    assert(recipient.notEq(AccountId.Null), "ERC20: transfer to the zero address");

    let spenderBalance =this.balanceOf(sender);
    assert(spenderBalance >= amount, "ERC20: transfer amount exceeds balance");

    let senderLeft = spenderBalance - amount;
    this.balances.set(sender, new UInt128(senderLeft));

    let recipientLeft = this.balanceOf(recipient) + amount;
    this.balances.set(recipient, new UInt128(recipientLeft));
    (new Transfer(sender, recipient, amount)).emit();
  }

In function parameters, ask uses u128 but when saving to data storage, it requires casting to UInt128.

It seems like the codec used by ask are separated for computation and storage