kayicp
November 13, 2023, 2:10am
1
Hi how should the ledger handle the icrc2_transfer_from
method if the spender
’s expires_at
was set and it’s before the current time (ie expired)?
i ask because on
# `ICRC-2`: Approve and Transfer From
| Status |
|:------:|
| [Accepted](https://dashboard.internetcomputer.org/proposal/122613) |
## Abstract
`ICRC-2` is an extension of the base `ICRC-1` standard.
`ICRC-2` specifies a way for an account owner to delegate token transfers to a third party on the owner's behalf.
The approve and transfer-from flow is a 2-step process.
1. Account owner Alice entitles Bob to transfer up to X tokens from her account A by calling the `icrc2_approve` method on the ledger.
2. Bob can transfer up to X tokens from account A to any account by calling the `icrc2_transfer_from` method on the ledger as if A was Bob's account B.
The number of transfers Bob can initiate from account A is not limited as long as the total amount spent is below X.
Approvals are not transitive: if Alice approves transfers from her account A to Bob's account B, and Bob approves transfers from his account B to Eva's account E, Eva cannot withdraw tokens from Alice's account through Bob's approval.
## Motivation
This file has been truncated. show original
the expires_at
was only handled during icrc2_approve
method with the possibility of #Expired : { ledger_time : nat64 }
error.
while icrc2_transfer_from
does not have that error.
should I handle it this way?
When the approval expires, the ledger treats it as if it never existed (the DFINITY implementation actively prunes expired approvals from memory, for example). So the icrc2_transfer_from
method should return the InsufficientAllowance
error when the approval expires.
Also note that the GenericError
variant is reserved for future refinements of the standard, not for the implementors to return custom errors.
2 Likes