Skip to content

Commit

Permalink
AccountId decode value add 0x
Browse files Browse the repository at this point in the history
  • Loading branch information
freehere107 committed Mar 21, 2024
1 parent 908ae59 commit 43ef503
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ func TestMetadataV15DecoderProcess(t *testing.T) {
if m.Version != "MetadataV15Decoder" {
t.Errorf("MetadataV15version should equal 15")
}
utiles.Debug(m.Metadata)
// utiles.Debug(m.Metadata)
}
2 changes: 1 addition & 1 deletion types/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func EncodeWithOpt(typeString string, data interface{}, opt *ScaleDecoderOption)
}
out := value.MethodByName("Encode").Call([]reflect.Value{val})
if len(out) > 0 {
return strings.ToLower(out[0].String())
return utiles.TrimHex(strings.ToLower(out[0].String()))
}
return ""
}
Expand Down
2 changes: 1 addition & 1 deletion types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ type AccountId struct {
}

func (s *AccountId) Process() {
s.Value = xstrings.RightJustify(utiles.BytesToHex(s.NextBytes(32)), 64, "0")
s.Value = utiles.AddHex(xstrings.RightJustify(utiles.BytesToHex(s.NextBytes(32)), 64, "0"))
}

func (s *AccountId) Encode(value string) string {
Expand Down
2 changes: 1 addition & 1 deletion types/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ func TestEncode(t *testing.T) {
assert.Equal(t, "070736c8230a", Encode("compact<u128>", decimal.New(43549996551, 0)))
assert.Equal(t, "87d61200000000000000000000000000", Encode("U128", decimal.NewFromInt32(1234567)))
assert.Equal(t, "47a952404f2b1568e6881efeb58c8918", Encode("U128", decimal.RequireFromString("32615670524745285411807346420584982855")))
assert.Equal(t, "0x9a5b8a1b7bca89cdb3931d8ee71aa468081d971c", Encode("H160", "0x9a5b8a1B7Bca89CDB3931D8eE71AA468081D971c"))
assert.Equal(t, "9a5b8a1b7bca89cdb3931d8ee71aa468081d971c", Encode("H160", "0x9a5b8a1B7Bca89CDB3931D8eE71AA468081D971c"))
}

func TestSubstrateFixedU64(t *testing.T) {
Expand Down

0 comments on commit 43ef503

Please sign in to comment.