|
@@ -155,7 +155,7 @@ impl Darkfid {
|
|
|
let mut data_vec: Vec<String> = Vec::new();
|
|
let mut data_vec: Vec<String> = Vec::new();
|
|
|
|
|
|
|
|
if let Some(symbol) = self.drk_tokenlist.clone().symbol_from_id(id)? {
|
|
if let Some(symbol) = self.drk_tokenlist.clone().symbol_from_id(id)? {
|
|
|
- let decimals = decimals(network, &symbol, &self.sol_tokenlist)?;
|
|
|
|
|
|
|
+ let decimals = decimals(&symbol, &self.sol_tokenlist)?;
|
|
|
for amount in balances.values() {
|
|
for amount in balances.values() {
|
|
|
let amount = encode_base10(amount.clone(), decimals);
|
|
let amount = encode_base10(amount.clone(), decimals);
|
|
|
data_vec.push(amount);
|
|
data_vec.push(amount);
|
|
@@ -352,7 +352,7 @@ impl Darkfid {
|
|
|
|
|
|
|
|
let amount = amount.as_str().unwrap();
|
|
let amount = amount.as_str().unwrap();
|
|
|
|
|
|
|
|
- let decimals = match decimals(network, token, &self.sol_tokenlist) {
|
|
|
|
|
|
|
+ let decimals = match decimals(token, &self.sol_tokenlist) {
|
|
|
Ok(d) => d,
|
|
Ok(d) => d,
|
|
|
Err(e) => {
|
|
Err(e) => {
|
|
|
return JsonResult::Err(jsonerr(InternalError, Some(e.to_string()), id));
|
|
return JsonResult::Err(jsonerr(InternalError, Some(e.to_string()), id));
|
|
@@ -402,13 +402,10 @@ impl Darkfid {
|
|
|
let cashier_public: jubjub::SubgroupPoint =
|
|
let cashier_public: jubjub::SubgroupPoint =
|
|
|
deserialize(&bs58::decode(cashier_public).into_vec()?)?;
|
|
deserialize(&bs58::decode(cashier_public).into_vec()?)?;
|
|
|
|
|
|
|
|
- let decimals: usize = 8;
|
|
|
|
|
- let amount = decode_base10(&amount.to_string(), decimals, true)?;
|
|
|
|
|
-
|
|
|
|
|
self.client
|
|
self.client
|
|
|
.lock()
|
|
.lock()
|
|
|
.await
|
|
.await
|
|
|
- .transfer(token_id.clone(), cashier_public, amount)
|
|
|
|
|
|
|
+ .transfer(token_id.clone(), cashier_public, amount_in_apo)
|
|
|
.await?;
|
|
.await?;
|
|
|
|
|
|
|
|
Ok(())
|
|
Ok(())
|
|
@@ -471,6 +468,20 @@ impl Darkfid {
|
|
|
}
|
|
}
|
|
|
let amount = amount.unwrap();
|
|
let amount = amount.unwrap();
|
|
|
|
|
|
|
|
|
|
+ let decimals = match decimals(token, &self.sol_tokenlist) {
|
|
|
|
|
+ Ok(d) => d,
|
|
|
|
|
+ Err(e) => {
|
|
|
|
|
+ return JsonResult::Err(jsonerr(InternalError, Some(e.to_string()), id));
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ let amount_in_apo = match decode_base10(&amount, decimals, true) {
|
|
|
|
|
+ Ok(a) => a,
|
|
|
|
|
+ Err(e) => {
|
|
|
|
|
+ return JsonResult::Err(jsonerr(InternalError, Some(e.to_string()), id));
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
let token_id: &jubjub::Fr;
|
|
let token_id: &jubjub::Fr;
|
|
|
|
|
|
|
|
// get the id for the token
|
|
// get the id for the token
|
|
@@ -484,13 +495,10 @@ impl Darkfid {
|
|
|
let drk_address = bs58::decode(&address).into_vec()?;
|
|
let drk_address = bs58::decode(&address).into_vec()?;
|
|
|
let drk_address: jubjub::SubgroupPoint = deserialize(&drk_address)?;
|
|
let drk_address: jubjub::SubgroupPoint = deserialize(&drk_address)?;
|
|
|
|
|
|
|
|
- let decimals: usize = 8;
|
|
|
|
|
- let amount = decode_base10(&amount, decimals, true)?;
|
|
|
|
|
-
|
|
|
|
|
self.client
|
|
self.client
|
|
|
.lock()
|
|
.lock()
|
|
|
.await
|
|
.await
|
|
|
- .transfer(token_id.clone(), drk_address, amount)
|
|
|
|
|
|
|
+ .transfer(token_id.clone(), drk_address, amount_in_apo)
|
|
|
.await?;
|
|
.await?;
|
|
|
|
|
|
|
|
Ok(())
|
|
Ok(())
|