Skip to content

Commit

Permalink
Update genesis spec.
Browse files Browse the repository at this point in the history
  • Loading branch information
arijitAD committed Jul 7, 2021
1 parent 6ecef3b commit 292ec91
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
7 changes: 4 additions & 3 deletions chain/dev/genesis-spec.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfb
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
github.com/golang/mock v1.4.4 h1:l75CXGRSwbaYNpl/Z2X1XIIAMSCquvXgpVZDhwEIJsc=
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0=
Expand Down
12 changes: 7 additions & 5 deletions lib/genesis/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func buildRawMap(m map[string]map[string]interface{}) (map[string]string, error)
kv.key = append(kv.key, k)
buildRawMapInterface(v, kv)

if reflect.DeepEqual([]string{"palletBalances", "balances"}, kv.key) {
if reflect.DeepEqual([]string{"Balances", "balances"}, kv.key) {
err := buildBalances(kv, res)
if err != nil {
return nil, err
Expand Down Expand Up @@ -221,10 +221,10 @@ func buildRawArrayInterface(a []interface{}, kv *keyValue) {

func formatKey(kv *keyValue) (string, error) {
switch {
case reflect.DeepEqual([]string{"grandpa", "authorities"}, kv.key):
case reflect.DeepEqual([]string{"Grandpa", "authorities"}, kv.key):
kb := []byte(`:grandpa_authorities`)
return common.BytesToHex(kb), nil
case reflect.DeepEqual([]string{"system", "code"}, kv.key):
case reflect.DeepEqual([]string{"System", "changesTrieConfig", "code"}, kv.key):
kb := []byte(`:code`)
return common.BytesToHex(kb), nil
default:
Expand All @@ -245,7 +245,7 @@ func formatKey(kv *keyValue) (string, error) {

func formatValue(kv *keyValue) (string, error) {
switch {
case reflect.DeepEqual([]string{"grandpa", "authorities"}, kv.key):
case reflect.DeepEqual([]string{"Grandpa", "authorities"}, kv.key):
if kv.valueLen != nil {
lenEnc, err := scale.Encode(kv.valueLen)
if err != nil {
Expand All @@ -255,8 +255,10 @@ func formatValue(kv *keyValue) (string, error) {
return fmt.Sprintf("0x01%x%v", lenEnc, kv.value), nil
}
return "", fmt.Errorf("error formatting value for grandpa authorities")
case reflect.DeepEqual([]string{"system", "code"}, kv.key):
case reflect.DeepEqual([]string{"System", "changesTrieConfig", "code"}, kv.key):
return kv.value, nil
case reflect.DeepEqual([]string{"Sudo", "Key"}, kv.key):
return common.BytesToHex(crypto.PublicAddressToByteArray(common.Address(kv.value))), nil
default:
if kv.valueLen != nil {
lenEnc, err := scale.Encode(kv.valueLen)
Expand Down
10 changes: 6 additions & 4 deletions lib/genesis/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ var TestGenesis = &Genesis{
var TestFieldsHR = Fields{
Raw: map[string]map[string]string{},
Runtime: map[string]map[string]interface{}{
"system": {
"code": "mocktestcode",
"System": {
"changesTrieConfig": "",
"code": "mocktestcode",
},
},
}
Expand Down Expand Up @@ -90,8 +91,9 @@ func CreateTestGenesisJSONFile(asRaw bool) (string, error) {
tGen.Genesis = Fields{
Raw: map[string]map[string]string{},
Runtime: map[string]map[string]interface{}{
"system": {
"code": "mocktestcode",
"System": {
"changesTrieConfig": "",
"code": "mocktestcode",
},
},
}
Expand Down

0 comments on commit 292ec91

Please sign in to comment.