caivega / ipfslib

Other
2 stars 1 forks source link

[enhancement]接口调用中底层币及代币数值表示 #148

Open caivega opened 3 years ago

caivega commented 3 years ago

现在情况:

转帐(value):

发行(total_supply):

备注:小数位数不得超过该币的decimals,底层币现在是6位小数 版本:v0.5.3-dev-20201215-6f1c7784362ef2ca7245c0ad9cca4cc195e2a57d

总之一句话:带币Symbol的会乘上10(该币发行时的decimals),不带的就是最小单位

foreso-GitHub commented 3 years ago

赞同

zyd82 commented 3 years ago

@caivega 目前在转账时,"100/TEST"代表的就是100,如果"100.5/TEST"代表的是100.5 10(该币发行时的decimals),那么"100/TEST"建议也要改成100 10(该币发行时的decimals)

除了这个,其他没啥问题。

foreso-GitHub commented 3 years ago

还有一个问题,我们查询tx得到的结果中的数量,是否都是最小单位来显示的?我观察到SWT是这样的,发送1/SWT,交易显示:

"Amount": {
            "value": "1000000",
            "currency": "SWT",
            "issuer": "jjjjjjjjjjjjjjjjjjjjjhoLvTp"
        },

这是正确的。

但代币不是这样,发送1/TEST,交易显示:

"Amount": {
            "value": "1",
            "currency": "TEST",
            "issuer": "jjjjjjjjjjjjjjjjjjjjjhoLvTp"
        },

应该和SWT保持一致,显示 1 * 10(TEST发行时的decimals)

caivega commented 3 years ago

还有一个问题,我们查询tx得到的结果中的数量,是否都是最小单位来显示的?我观察到SWT是这样的,发送1/SWT,交易显示:

"Amount": {
            "value": "1000000",
            "currency": "SWT",
            "issuer": "jjjjjjjjjjjjjjjjjjjjjhoLvTp"
        },

这是正确的。

但代币不是这样,发送1/TEST,交易显示:

"Amount": {
            "value": "1",
            "currency": "TEST",
            "issuer": "jjjjjjjjjjjjjjjjjjjjjhoLvTp"
        },

应该和SWT保持一致,显示 1 * 10(TEST发行时的decimals)。

帐本与查询都是按最小单位来显示的,不影响的,所以现在讨论的是rpc接口中数值的问题。。。

caivega commented 3 years ago

@caivega 目前在转账时,"100/TEST"代表的就是100,如果"100.5/TEST"代表的是100.5 10(该币发行时的decimals),那么"100/TEST"建议也要改成100 10(该币发行时的decimals)。

除了这个,其他没啥问题。

现在 "100/TEST"代表的就是100 * 10(该币发行时的decimals),可以用昨天的版本(v0.5.3-dev-20201215-6f1c7784362ef2ca7245c0ad9cca4cc195e2a57d)试试,只是举例的时候特意强调下100.5,带小数。。。,测试环境还没有更新,现在还是20201214版本的,更新后再试试看,如果有问题,就是bug了

foreso-GitHub commented 3 years ago

还有一个问题,我们查询tx得到的结果中的数量,是否都是最小单位来显示的?我观察到SWT是这样的,发送1/SWT,交易显示:

"Amount": {
            "value": "1000000",
            "currency": "SWT",
            "issuer": "jjjjjjjjjjjjjjjjjjjjjhoLvTp"
        },

这是正确的。

但代币不是这样,发送1/TEST,交易显示:

"Amount": {
            "value": "1",
            "currency": "TEST",
            "issuer": "jjjjjjjjjjjjjjjjjjjjjhoLvTp"
        },

应该和SWT保持一致,显示 1 * 10(TEST发行时的decimals)。

这个问题已经报issue: #149

zyd82 commented 3 years ago

@caivega 现在的版本v0.5.3-dev-20201222-4d79cede520d8eb6752703f588cd4a9b83370d91不能发行带小数的代币了,你看下。

{
    "jsonrpc": "2.0",
    "method": "jt_sendTransaction",
    "params": [
        { 
            "type": "IssueCoin",
            "from": "jPdx7mG595P6CowtGYbxRkik9HdWUWtB2J",
            "secret": "shhquPeZm7uQ6Rvjrqn6L2cR6H33u",
            "name": "",
            "symbol": "BBT",
            "decimals": "6",
            "total_supply": "10000.5",
            "local": false,
            "flags": 196608
        }
    ],
    "id": 1
}
{
    "error": "1 errors",
    "id": 1,
    "jsonrpc": "2.0",
    "result": [
        {
            "error": "total_supply must be integer type",
            "message": {
                "decimals": "6",
                "flags": 196608,
                "from": "jPdx7mG595P6CowtGYbxRkik9HdWUWtB2J",
                "local": false,
                "name": "",
                "symbol": "BBTT",
                "total_supply": "10000.5",
                "type": "IssueCoin"
            },
            "status": -278,
            "type": "temINVALID"
        }
    ],
    "status": -278,
    "type": "temINVALID"
}
caivega commented 3 years ago

@caivega 现在的版本v0.5.3-dev-20201222-4d79cede520d8eb6752703f588cd4a9b83370d91不能发行带小数的代币了,你看下。

{
    "jsonrpc": "2.0",
    "method": "jt_sendTransaction",
    "params": [
        { 
            "type": "IssueCoin",
            "from": "jPdx7mG595P6CowtGYbxRkik9HdWUWtB2J",
            "secret": "shhquPeZm7uQ6Rvjrqn6L2cR6H33u",
            "name": "",
            "symbol": "BBT",
            "decimals": "6",
            "total_supply": "10000.5",
            "local": false,
            "flags": 196608
        }
    ],
    "id": 1
}
{
    "error": "1 errors",
    "id": 1,
    "jsonrpc": "2.0",
    "result": [
        {
            "error": "total_supply must be integer type",
            "message": {
                "decimals": "6",
                "flags": 196608,
                "from": "jPdx7mG595P6CowtGYbxRkik9HdWUWtB2J",
                "local": false,
                "name": "",
                "symbol": "BBTT",
                "total_supply": "10000.5",
                "type": "IssueCoin"
            },
            "status": -278,
            "type": "temINVALID"
        }
    ],
    "status": -278,
    "type": "temINVALID"
}

见上边,总之一句话,带币Symbol的会乘上10(该币发行时的decimals),不带的就是最小单位