Skip to content

Commit

Permalink
feat(FI-805) [ICP Ledger] Add allowance field to CandidOperation::App…
Browse files Browse the repository at this point in the history
…rove
  • Loading branch information
Nikolas Haimerl committed Jul 5, 2023
1 parent e0f5a6a commit 30c9eec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions rs/rosetta-api/icp_ledger/ledger.did
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ type Operation = variant {
Approve : record {
from : AccountIdentifier;
spender : AccountIdentifier;
// This field is deprecated and should not be used.
allowance_e8s : int;
allowance: Tokens;
fee : Tokens;
expires_at : opt TimeStamp;
};
Expand Down
12 changes: 8 additions & 4 deletions rs/rosetta-api/icp_ledger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,9 @@ pub enum CandidOperation {
Approve {
from: AccountIdBlob,
spender: AccountIdBlob,
allowance_e8s: u64,
// This field is deprecated and should not be used.
allowance_e8s: i128,
allowance: Tokens,
fee: Tokens,
expires_at: Option<TimeStamp>,
},
Expand Down Expand Up @@ -812,9 +814,10 @@ impl From<Operation> for CandidOperation {
} => Self::Approve {
from: from.to_address(),
spender: spender.to_address(),
allowance_e8s: allowance.get_e8s(),
allowance_e8s: allowance.get_e8s() as i128,
fee,
expires_at,
allowance,
},
Operation::TransferFrom {
from,
Expand Down Expand Up @@ -863,13 +866,14 @@ impl TryFrom<CandidOperation> for Operation {
CandidOperation::Approve {
from,
spender,
allowance_e8s,
fee,
expires_at,
allowance,
..
} => Operation::Approve {
spender: address_to_accountidentifier(spender)?,
from: address_to_accountidentifier(from)?,
allowance: Tokens::from_e8s(allowance_e8s),
allowance,
fee,
expires_at,
},
Expand Down

0 comments on commit 30c9eec

Please sign in to comment.