github.com/0xPolygon/supernets2-node@v0.0.0-20230711153321-2fe574524eaa/tools/genesis/genesisparser/genesisparser.go (about) 1 package genesisparser 2 3 import ( 4 "github.com/0xPolygon/supernets2-node/merkletree" 5 "github.com/0xPolygon/supernets2-node/state" 6 ) 7 8 // GenesisAccountTest struct 9 type GenesisAccountTest struct { 10 Balance string 11 Nonce string 12 Address string 13 Bytecode string 14 Storage map[string]string 15 } 16 17 // GenesisTest2Actions change format from testvector to the used internaly 18 func GenesisTest2Actions(accounts []GenesisAccountTest) []*state.GenesisAction { 19 leafs := make([]*state.GenesisAction, 0) 20 21 for _, acc := range accounts { 22 if len(acc.Balance) != 0 && acc.Balance != "0" { 23 leafs = append(leafs, &state.GenesisAction{ 24 Address: acc.Address, 25 Type: int(merkletree.LeafTypeBalance), 26 Value: acc.Balance, 27 }) 28 } 29 if len(acc.Nonce) != 0 && acc.Nonce != "0" { 30 leafs = append(leafs, &state.GenesisAction{ 31 Address: acc.Address, 32 Type: int(merkletree.LeafTypeNonce), 33 Value: acc.Nonce, 34 }) 35 } 36 if len(acc.Bytecode) != 0 { 37 leafs = append(leafs, &state.GenesisAction{ 38 Address: acc.Address, 39 Type: int(merkletree.LeafTypeCode), 40 Bytecode: acc.Bytecode, 41 }) 42 } 43 for key, value := range acc.Storage { 44 leafs = append(leafs, &state.GenesisAction{ 45 Address: acc.Address, 46 Type: int(merkletree.LeafTypeStorage), 47 StoragePosition: key, 48 Value: value, 49 }) 50 } 51 } 52 return leafs 53 }