Some comments.
This commit is contained in:
parent
9fe536a853
commit
88ea58d25e
2 changed files with 6 additions and 0 deletions
|
@ -34,6 +34,8 @@ impl DB {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if let Some(receiver_safe) = self.safes.get(send_to) {
|
if let Some(receiver_safe) = self.safes.get(send_to) {
|
||||||
|
// TODO should return "limited or not"
|
||||||
|
// edge should contain token balance and transfer limit (which can be unlimited)
|
||||||
let limit = safe.trust_transfer_limit(receiver_safe, *percentage);
|
let limit = safe.trust_transfer_limit(receiver_safe, *percentage);
|
||||||
if limit != U256::from(0) {
|
if limit != U256::from(0) {
|
||||||
edges.push(Edge {
|
edges.push(Edge {
|
||||||
|
@ -53,6 +55,7 @@ impl DB {
|
||||||
from: *user,
|
from: *user,
|
||||||
to: *owner,
|
to: *owner,
|
||||||
token: *owner,
|
token: *owner,
|
||||||
|
// TODO capacity should be only limited by own balance.
|
||||||
capacity: *balance,
|
capacity: *balance,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ impl Safe {
|
||||||
pub fn trust_transfer_limit(&self, receiver: &Safe, trust_percentage: u8) -> U256 {
|
pub fn trust_transfer_limit(&self, receiver: &Safe, trust_percentage: u8) -> U256 {
|
||||||
if receiver.organization {
|
if receiver.organization {
|
||||||
// TODO treat this as "return to owner"
|
// TODO treat this as "return to owner"
|
||||||
|
// i.e. limited / only constrained by the balance edge.
|
||||||
self.balance(&self.token_address)
|
self.balance(&self.token_address)
|
||||||
} else {
|
} else {
|
||||||
let receiver_balance = receiver.balance(&self.token_address);
|
let receiver_balance = receiver.balance(&self.token_address);
|
||||||
|
@ -30,6 +31,8 @@ impl Safe {
|
||||||
if amount < receiver_balance {
|
if amount < receiver_balance {
|
||||||
U256::from(0)
|
U256::from(0)
|
||||||
} else {
|
} else {
|
||||||
|
// TODO it should not be "min" - the second constraint
|
||||||
|
// is set by the balance edge.
|
||||||
min(amount - receiver_balance, self.balance(&self.token_address))
|
min(amount - receiver_balance, self.balance(&self.token_address))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue