Fix parsing of erc20 properties
This commit is contained in:
parent
ec1647c864
commit
4a216fa647
@ -557,6 +557,8 @@ func (w *Worker) GetAddress(address string, page int, txsOnPage int, option GetA
|
|||||||
TotalReceived: w.chainParser.AmountToDecimalString(ba.ReceivedSat()),
|
TotalReceived: w.chainParser.AmountToDecimalString(ba.ReceivedSat()),
|
||||||
TotalSent: w.chainParser.AmountToDecimalString(&ba.SentSat),
|
TotalSent: w.chainParser.AmountToDecimalString(&ba.SentSat),
|
||||||
TxApperances: int(ba.Txs),
|
TxApperances: int(ba.Txs),
|
||||||
|
Erc20Contract: erc20c,
|
||||||
|
Erc20Tokens: erc20t,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
bestheight, _, err := w.db.GetBestBlock()
|
bestheight, _, err := w.db.GetBestBlock()
|
||||||
|
|||||||
@ -118,11 +118,11 @@ func parseErc20StringProperty(contractDesc bchain.AddressDescriptor, data string
|
|||||||
if has0xPrefix(data) {
|
if has0xPrefix(data) {
|
||||||
data = data[2:]
|
data = data[2:]
|
||||||
}
|
}
|
||||||
if len(data) == 192 {
|
if len(data) > 128 {
|
||||||
n := parseErc20NumericProperty(contractDesc, data[64:128])
|
n := parseErc20NumericProperty(contractDesc, data[64:128])
|
||||||
if n != nil {
|
if n != nil {
|
||||||
l := n.Uint64()
|
l := n.Uint64()
|
||||||
if l <= 32 {
|
if 2*int(l) <= len(data)-128 {
|
||||||
b, err := hex.DecodeString(data[128 : 128+2*l])
|
b, err := hex.DecodeString(data[128 : 128+2*l])
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return string(b)
|
return string(b)
|
||||||
|
|||||||
@ -122,9 +122,9 @@ func TestErc20_parseErc20StringProperty(t *testing.T) {
|
|||||||
want: "XPLODDE",
|
want: "XPLODDE",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "1",
|
name: "2",
|
||||||
args: "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000758504c4f44444500000000000000000000000000000000000000000000000000",
|
args: "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000022426974436c617665202d20436f6e73756d657220416374697669747920546f6b656e00000000000000",
|
||||||
want: "XPLODDE",
|
want: "BitClave - Consumer Activity Token",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user