Closed zshchou closed 6 years ago
@jcalfee any ideas here?
I believe the precision is not available in the API yet. I had to hard-code it to 4.. I'll ask about this..
Kevin in the c++ team is aware of the ticket above to add the asset precision to the API.
Having some issues using the docker release which may have been fixed in master. On vacation next week. I'll continue this using the next dawn3 release when I get back.
https://github.com/EOSIO/eos/issues/1857#issuecomment-379066952
eos3.22 and eos3.28 is middle state, now wait rc2.
Precision can be derived from the supply
in this API call using eosio in master (eosio/eos:20180420 for example). This does not work in eosio/eos:dawn3x ..
> eos.getCurrencyStats('currency', 'CUR', (error, result) => console.log(error, result))
undefined
> null { CUR:
{ supply: '2000000000.0000 CUR',
max_supply: '1000000000.0000 CUR',
issuer: 'currency' } }
now eosjs and eos3 is ok, can create new account, can transfre asset, but if init currency precision is 8, then transfer asset will is 4 . for instance:
cleos push action inkcoin issue '{"to":"inkcoin","quantity":"1000000000.00000000 AYA","memo":"issue"}' -p inkcoin@active
cleos push action inkcoin transfer '{"from":"inkcoin","to":"inita","quantity":"1000.00000000 AYA","memo":"to inita"}' -p inkcoin@active
cleos push action inkcoin transfer '{"from":"inita","to":"initb","quantity":"1.00000000 AYA","memo":"to initb"}' -p inita@active
the command is ok, the result:
➜ ~ cleos get table inkcoin inita accounts
{
"rows": [{
"balance": "999.00000000 AYA",
"frozen": 0,
"whitelist": 1
}
],
"more": false
}
if I use eosjs transfer 1 AYA from inita to other:
let data = {form: inita, to: initb, amount: 1};
let quantity = format.UDecimalPad(data.amount, 8) + " AYA";
let res = await eos.transaction(inkcoin, coin => {
coin.transfer(data.from, data.to, quantity, "eosapi");
});
the inita asset is error.
{
"status": 200,
"balance": "998.99990000",
"coinname": "AYA"
}
the expected inita asset is:
{
"status": 200,
"balance": "998.00000000",
"coinname": "AYA"
}
@jcalfee
This is working in the unit test under the custom token call PHI
.
for DAWN3:
i define my token: S(8, ZSH)
if i transfer my token, it will error, because "structs.js" set precision for 4 /* @example '0.0001 CUR' /
var symbolCache = function symbolCache(symbol) { return { precision: 4 }; };
still structs.js: var prefix = '\x04'; // 4 decimals in EOS