EOSIO / eos

An open source smart contract platform
https://developers.eos.io/manuals/eos
MIT License
11.28k stars 3.6k forks source link

eosc transfer is still in larimers #561

Closed jcalfee closed 6 years ago

jcalfee commented 7 years ago

I was expecting this to transfer 1 EOS .. Instead it transfered only 1 lairmer (1/1000 of a EOS)..

To be honest: eosjs has the same problem ;) .. I'm here looking for ideas.

The transaction format looks ok to me (specifically "amount": 1,) .. Seems like the eosc client should do something to be clear though. Some options are:

./programs/eosc/eosc transfer inita initb 1 ''
{
  "transaction_id": "52069ce0e8eb2f3211a872297f29201728a4ca1a503b7f54295f41aa71b3c37c",
  "processed": {
    "refBlockNum": 741,
    "refBlockPrefix": 1807148942,
    "expiration": "2017-10-12T15:26:33",
    "scope": [
      "inita",
      "initb"
    ],
    "signatures": [
      "1f01c882ec168823e68769a59f50e5049d432eb526bfb132b8a9cd435655f6e9964b1f5b548e457f12abed265b22a4531d706b8e08c87bd8b566b770578a8ba4ab"
    ],
    "messages": [{
        "code": "eos",
        "type": "transfer",
        "authorization": [{
            "account": "inita",
            "permission": "active"
          }
        ],
        "data": {
          "from": "inita",
          "to": "initb",
          "amount": 1,
          "memo": ""
        },
        "hex_data": "000000000093dd74000000008093dd74010000000000000000"
      }
      ....

Note, the prior balance was 1000000.0000:

./programs/eosc/eosc get account initb
{
  "name": "initb",
  "eos_balance": "1000000.0001 EOS",
   ...

Please let me know your thoughts in the comment section below.

jcalfee commented 7 years ago

I think it is better UX to accept 1 or 1.1 and not require 1.000..

In related code, this should not try to transfer 1 EOS:

./programs/eosc/eosc transfer inita initb '1 ABC' ''

thomasbcox commented 7 years ago

@jcalfee would you be okay with a "fix" to the effect of changing the documentation to make the current behavior be the documented behavior? Or does that offend your sense of what is right and good? I'm leaning toward a doc change but not if it would be aesthetically ugly

jcalfee commented 7 years ago

I think we are committed to 1.000 EOS meaning {amount: 10000, symbol: 'EOS'} or 1000 in binary.. See the following:

The Asset type in the create account json ( "deposit" in newaccount for example) looks like this: image

And shows up like this: image

Although it looks like that the precision is not widely used and perhaps only used for the EOS "Asset" type. So, in binary, I check the symbol which is has a precision byte prefix and throw an error if it is not 4 as hard-coded here:

image

That should make it future proof in that it will fail if symbols show up in other precisions. That is fair it is not implemented or required yet (that is my understanding at least).

Keep in mind, the currency smart contract does not use an Asset type it uses a uint64 amount so that one would not trigger the exception.

If anything you could postpone this and get more information. I simply added the error because it was minimal and safer to have it. Maybe that is the right thing for you to do.. Just have a few asserts and be consistent to avoid all confusion.

jcalfee commented 7 years ago

back on topic..

The EOS amount is a uint64.. I think if you want to set a precision this is going to need a type change from from a uint64 to an Asset.

Maybe the ABI should look like this:

    "types": [
      {
        "type": "Asset",
        "newTypeName": "EosAsset",
        "params": { "symbol": "EOS", "precision": 4}
      }
    ]
jcalfee commented 7 years ago

Asset names have to be unique so 'symbol' above is not going to work well. A default precision for an account could work though. The uppercase version of the account name can become the symbol.

jcalfee commented 6 years ago

Can you just take the quantity field here:

cleos push action eosio transfer '{"from":"inita", "to":"exchange", "quantity": "1.0000 EOS", "memo": "deposit"}' -p inita@active

And change the command-line interface to require the same quantity format here:

cleos transfer inita exchange '1.0000 EOS' 'deposit'

At is it coded now, the second command tries to transfer 0.0001 EOS instead of 1 EOS.

heifner commented 6 years ago

All the Asset issues have been addressed at this point. If not feel free to re-open.