Skip to content

Commit

Permalink
Merge 34e91ed into a0b287c
Browse files Browse the repository at this point in the history
  • Loading branch information
robdefeo committed Mar 11, 2020
2 parents a0b287c + 34e91ed commit 8fd1caa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
7 changes: 5 additions & 2 deletions internal/protocols/substrate/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,12 @@ func addSS58Prefix(pubKey []byte) []byte {
func prefixWithNetwork(network string, publicKey crypto.PublicKey) ([]byte, error) {
// https://github.com/paritytech/substrate/wiki/External-Address-Format-(SS58)#address-type defines different prefixes by network
switch network {
case EdgewareMainnet, EdgewareBerlin:
// 7 = 0x07
case EdgewareMainnet:
// 7 = 0x07 https://raw.githubusercontent.com/hicommonwealth/edgeware-node/master/chains/mainnet.chainspec.json
return append([]byte{0x07}, publicKey.Bytes()...), nil
case EdgewareBerlin:
// 42 = 0x2A https://raw.githubusercontent.com/hicommonwealth/edgeware-node/master/chains/berlin.chainspec.json
return append([]byte{0x2A}, publicKey.Bytes()...), nil
default:
return nil, errors.Errorf("unknown address prefix for %q", network)
}
Expand Down
18 changes: 9 additions & 9 deletions internal/protocols/substrate/address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func Test_prefixWithNetwork(t *testing.T) {
EdgewareBerlin,
ed25519test.SofiaPublicKey,
},
[]byte{0x7, 0x72, 0x3c, 0xaa, 0x23, 0xa5, 0xb5, 0x11, 0xaf, 0x5a, 0xd7, 0xb7, 0xef, 0x60, 0x76, 0xe4, 0x14, 0xab, 0x7e, 0x75, 0xa9, 0xdc, 0x91, 0xe, 0xa6, 0xe, 0x41, 0x7a, 0x2b, 0x77, 0xa, 0x56, 0x71},
[]byte{0x2a, 0x72, 0x3c, 0xaa, 0x23, 0xa5, 0xb5, 0x11, 0xaf, 0x5a, 0xd7, 0xb7, 0xef, 0x60, 0x76, 0xe4, 0x14, 0xab, 0x7e, 0x75, 0xa9, 0xdc, 0x91, 0xe, 0xa6, 0xe, 0x41, 0x7a, 0x2b, 0x77, 0xa, 0x56, 0x71},
false,
},
{
Expand Down Expand Up @@ -165,8 +165,8 @@ func TestSS58AddressFormat(t *testing.T) {
EdgewareBerlin,
ed25519test.SofiaPublicKey,
},
[]byte{0x7, 0x72, 0x3c, 0xaa, 0x23, 0xa5, 0xb5, 0x11, 0xaf, 0x5a, 0xd7, 0xb7, 0xef, 0x60, 0x76, 0xe4, 0x14, 0xab, 0x7e, 0x75, 0xa9, 0xdc, 0x91, 0xe, 0xa6, 0xe, 0x41, 0x7a, 0x2b, 0x77, 0xa, 0x56, 0x71, 0xda, 0xb},
"k6QHnYGfD7oioVwk2jRwR2H5uSW7fV2yiBU1BdBsJ7ebqHC",
[]byte{0x2a, 0x72, 0x3c, 0xaa, 0x23, 0xa5, 0xb5, 0x11, 0xaf, 0x5a, 0xd7, 0xb7, 0xef, 0x60, 0x76, 0xe4, 0x14, 0xab, 0x7e, 0x75, 0xa9, 0xdc, 0x91, 0xe, 0xa6, 0xe, 0x41, 0x7a, 0x2b, 0x77, 0xa, 0x56, 0x71, 0x63, 0x83},
"5EeVLWVP7PjFBrfBSfXG9xL9htSo35XFada4Y78j5DviSz9Q",
false,
},
{
Expand All @@ -175,8 +175,8 @@ func TestSS58AddressFormat(t *testing.T) {
EdgewareBerlin,
ed25519test.CharlottePublicKey,
},
[]byte{0x7, 0x2e, 0x32, 0x2f, 0x87, 0x40, 0xc6, 0x1, 0x72, 0x11, 0x1a, 0xc8, 0xea, 0xdc, 0xdd, 0xa2, 0x51, 0x2f, 0x90, 0xd0, 0x6d, 0xe, 0x50, 0x3e, 0xf1, 0x89, 0x97, 0x9a, 0x15, 0x9b, 0xec, 0xe1, 0xe8, 0x9b, 0x76},
"iZBvP2dtRccehTbT7syTGzGSiRQaAXhwCuk5K6GGJWGSBBK",
[]byte{0x2a, 0x2e, 0x32, 0x2f, 0x87, 0x40, 0xc6, 0x1, 0x72, 0x11, 0x1a, 0xc8, 0xea, 0xdc, 0xdd, 0xa2, 0x51, 0x2f, 0x90, 0xd0, 0x6d, 0xe, 0x50, 0x3e, 0xf1, 0x89, 0x97, 0x9a, 0x15, 0x9b, 0xec, 0xe1, 0xe8, 0x6d, 0x48},
"5D7Gy6ykLcE47kcq9kfofpJ94hRhVaZvY8JLcEboUEKLHRYs",
false,
},
{
Expand All @@ -185,8 +185,8 @@ func TestSS58AddressFormat(t *testing.T) {
EdgewareBerlin,
sr25519test.SofiaPublicKey,
},
[]byte{0x7, 0x16, 0x9a, 0x11, 0x72, 0x18, 0x51, 0xf5, 0xdf, 0xf3, 0x54, 0x1d, 0xd5, 0xc4, 0xb0, 0xb4, 0x78, 0xac, 0x1c, 0xd0, 0x92, 0xc9, 0xd5, 0x97, 0x6e, 0x83, 0xda, 0xa0, 0xd0, 0x3f, 0x26, 0x62, 0xc, 0x35, 0x20},
"i2FdaX7B2pXU3AApfkCSYPP8NDwLstfsU1wgb7uPq5zAtis",
[]byte{0x2a, 0x16, 0x9a, 0x11, 0x72, 0x18, 0x51, 0xf5, 0xdf, 0xf3, 0x54, 0x1d, 0xd5, 0xc4, 0xb0, 0xb4, 0x78, 0xac, 0x1c, 0xd0, 0x92, 0xc9, 0xd5, 0x97, 0x6e, 0x83, 0xda, 0xa0, 0xd0, 0x3f, 0x26, 0x62, 0xc, 0x46, 0x4b},
"5CaLgJUDdDRxw6KQXJY2f5hFkMEEGHvtUPQYDWdSbku42Dv2",
false,
},
{
Expand All @@ -195,8 +195,8 @@ func TestSS58AddressFormat(t *testing.T) {
EdgewareBerlin,
sr25519test.CharlottePublicKey,
},
[]byte{0x7, 0x84, 0x62, 0x3e, 0x72, 0x52, 0xe4, 0x11, 0x38, 0xaf, 0x69, 0x4, 0xe1, 0xb0, 0x23, 0x4, 0xc9, 0x41, 0x62, 0x5f, 0x39, 0xe5, 0x76, 0x25, 0x89, 0x12, 0x5d, 0xc1, 0xa2, 0xf2, 0xcf, 0x2e, 0x30, 0xf0, 0xec},
"kWCKFhkg5m5XmGz2pbcUYhJK7RAf6jLj1wLM5J5junonVTH",
[]byte{0x2a, 0x84, 0x62, 0x3e, 0x72, 0x52, 0xe4, 0x11, 0x38, 0xaf, 0x69, 0x4, 0xe1, 0xb0, 0x23, 0x4, 0xc9, 0x41, 0x62, 0x5f, 0x39, 0xe5, 0x76, 0x25, 0x89, 0x12, 0x5d, 0xc1, 0xa2, 0xf2, 0xcf, 0x2e, 0x30, 0xe0, 0x2a},
"5F4HMyes8GNWzpSDjTPSh61Aw6RTaWmZKwKvszocwqbsdn4h",
false,
},
// {
Expand Down

0 comments on commit 8fd1caa

Please sign in to comment.