Merge pull request #2011 from nspcc-dev/hashy-fix

examples: use base64 encoding to create HASHY token ID
This commit is contained in:
Roman Khimov 2021-06-11 14:13:24 +03:00 committed by GitHub
commit 61c204f875
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 8 deletions

View file

@ -125,7 +125,6 @@ func TestNEP11_OwnerOf_BalanceOf_Transfer(t *testing.T) {
e.Run(t, "neo-go", "wallet", "nep17", "transfer",
"--rpc-endpoint", "http://"+e.RPC.Addr,
"--wallet", wall,
"--gas", "0.001", // test fails sometimes running out of GAS
"--to", h.StringLE(),
"--token", "GAS",
"--amount", "10",
@ -214,7 +213,7 @@ func TestNEP11_OwnerOf_BalanceOf_Transfer(t *testing.T) {
// tokensOf: good
e.Run(t, cmdTokensOf...)
e.checkNextLine(t, string(tokenID))
require.Equal(t, string(tokenID), e.getNextLine(t))
// properties: no contract
cmdProperties := []string{
@ -240,8 +239,8 @@ func TestNEP11_OwnerOf_BalanceOf_Transfer(t *testing.T) {
fst, snd = snd, fst
}
e.checkNextLine(t, string(fst))
e.checkNextLine(t, string(snd))
require.Equal(t, string(fst), e.getNextLine(t))
require.Equal(t, string(snd), e.getNextLine(t))
// tokens: missing contract hash
cmdTokens := []string{"neo-go", "wallet", "nep11", "tokens",
@ -252,8 +251,8 @@ func TestNEP11_OwnerOf_BalanceOf_Transfer(t *testing.T) {
// tokens: good, several tokens
e.Run(t, cmdTokens...)
e.checkNextLine(t, string(fst))
e.checkNextLine(t, string(snd))
require.Equal(t, string(fst), e.getNextLine(t))
require.Equal(t, string(snd), e.getNextLine(t))
// balance check: several tokens, ok
e.Run(t, append(cmdCheckBalance, "--token", h.StringLE())...)

View file

@ -2,7 +2,7 @@
Package nft contains non-divisible non-fungible NEP11-compatible token
implementation. This token can be minted with GAS transfer to contract address,
it will hash some data (including data provided in transfer) and produce
base58-encoded string that is your NFT. Since it's based on hashing and basically
base64-encoded string that is your NFT. Since it's based on hashing and basically
you own a hash it's HASHY.
*/
package nft
@ -230,7 +230,7 @@ func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) {
}
tokenHash := crypto.Ripemd160(tokIn)
token := std.Base58Encode(tokenHash)
token := std.Base64Encode(tokenHash)
addToken(ctx, from, []byte(token))
setOwnerOf(ctx, []byte(token), from)