Skip to content

Commit

Permalink
Merge 089f457 into 368ff47
Browse files Browse the repository at this point in the history
  • Loading branch information
robdefeo committed Aug 19, 2020
2 parents 368ff47 + 089f457 commit 777dce1
Show file tree
Hide file tree
Showing 35 changed files with 187 additions and 191 deletions.
10 changes: 5 additions & 5 deletions cmd/indexer/internal/substrate/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestBlock_Run(t *testing.T) {
args{
context.Background(),
protocols.Substrate,
networks.EdgewareBerlin,
networks.EdgewareBeresheet,
&types.Extrinsic{},
},
true,
Expand All @@ -53,14 +53,14 @@ func TestBlock_Run(t *testing.T) {
fields{
func() actions.Transaction {
m := actionstest.NewMockTransaction(mockCtrl)
m.EXPECT().Run(context.Background(), protocols.Substrate, networks.EdgewareBerlin, gomock.Any(), gomock.Any()).Return(errors.New("error"))
m.EXPECT().Run(context.Background(), protocols.Substrate, networks.EdgewareBeresheet, gomock.Any(), gomock.Any()).Return(errors.New("error"))
return m
}(),
},
args{
context.Background(),
protocols.Substrate,
networks.EdgewareBerlin,
networks.EdgewareBeresheet,
&types.Block{
Header: types.Header{},
Extrinsics: []types.Extrinsic{
Expand All @@ -82,14 +82,14 @@ func TestBlock_Run(t *testing.T) {
fields{
func() actions.Transaction {
m := actionstest.NewMockTransaction(mockCtrl)
m.EXPECT().Run(context.Background(), protocols.Substrate, networks.EdgewareBerlin, gomock.Any(), gomock.Any()).Return(nil)
m.EXPECT().Run(context.Background(), protocols.Substrate, networks.EdgewareBeresheet, gomock.Any(), gomock.Any()).Return(nil)
return m
}(),
},
args{
context.Background(),
protocols.Substrate,
networks.EdgewareBerlin,
networks.EdgewareBeresheet,
&types.Block{
Header: types.Header{},
Extrinsics: []types.Extrinsic{
Expand Down
6 changes: 3 additions & 3 deletions cmd/indexer/internal/substrate/extrinsic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ func TestExtrinsic_Run(t *testing.T) {
fields{
func() datastore.TransactionStore {
m := datastoretest.NewMockTransactionStore(mockCtrl)
m.EXPECT().PutTransaction(context.Background(), protocols.Substrate, networks.EdgewareBerlin, gomock.Any(), gomock.Any())
m.EXPECT().PutTransaction(context.Background(), protocols.Substrate, networks.EdgewareBeresheet, gomock.Any(), gomock.Any())
return m
}(),
func() datastore.RawTransactionStore {
m := datastoretest.NewMockRawTransactionStore(mockCtrl)
m.EXPECT().PutRawTransaction(context.Background(), protocols.Substrate, networks.EdgewareBerlin, gomock.Any(), gomock.Any())
m.EXPECT().PutRawTransaction(context.Background(), protocols.Substrate, networks.EdgewareBeresheet, gomock.Any(), gomock.Any())
return m
}(),
func() datastore.PublicKeyStore {
Expand All @@ -58,7 +58,7 @@ func TestExtrinsic_Run(t *testing.T) {
args{
context.Background(),
"substrate",
"edgeware-berlin",
"edgeware-beresheet",
func() *types.Extrinsic {
b := getBlock(t, "0x61c83ac28eec9ac530df6f117edc761e3c3a0861f73dc8534f2e0682f1d9ef75")
e := b.Extrinsics[2]
Expand Down
4 changes: 2 additions & 2 deletions cmd/internal/datastore/pq/mappings.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ var protocolNetworkUint8 = map[string]map[string]uint8{ //nolint:gochecknoglobal
ethereum.Ropsten: 5,
},
protocols.Substrate: {
substrate.EdgewareBerlin: 1,
substrate.EdgewareMainnet: 2,
substrate.EdgewareBeresheet: 1,
substrate.EdgewareMainnet: 2,
},
}

Expand Down
8 changes: 7 additions & 1 deletion cmd/mailchain/commands/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/mailchain/mailchain/cmd/mailchain/internal/settings"
"github.com/mailchain/mailchain/crypto/multikey"
"github.com/mailchain/mailchain/encoding"
"github.com/mailchain/mailchain/internal/address"
"github.com/mailchain/mailchain/internal/keystore"
"github.com/mailchain/mailchain/internal/keystore/kdf/multi"
"github.com/mailchain/mailchain/internal/keystore/kdf/scrypt"
Expand Down Expand Up @@ -124,7 +125,12 @@ func accountListCmd(ks keystore.Store) *cobra.Command {
return errors.WithMessage(err, "could not get addresses")
}
for _, x := range addresses {
cmd.Println(encoding.EncodeHex(x))
encoded, encoding, err := address.EncodeByProtocol(x, protocol)
if err != nil {
return errors.WithMessage(err, "could not encode address")
}

cmd.Printf("Encoding: %s, address: %s\n", encoding, encoded)
}
return nil
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/mailchain/commands/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func Test_accountListCmd(t *testing.T) {
"protocol": "ethereum",
"network": "mainnet",
},
"5602ea95540bee46d03ba335eed6f49d117eab95c8ab8b71bae2cdd1e564a761\n4cb0a77b76667dac586c40cc9523ace73b5d772bd503c63ed0ca596eae1658b2\n",
"Encoding: hex/0x-prefix, address: 0x5602ea95540bee46d03ba335eed6f49d117eab95c8ab8b71bae2cdd1e564a761\nEncoding: hex/0x-prefix, address: 0x4cb0a77b76667dac586c40cc9523ace73b5d772bd503c63ed0ca596eae1658b2\n",
false,
},
{
Expand Down
4 changes: 2 additions & 2 deletions cmd/mailchain/internal/http/handlers/addresses_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func TestGetAddresses(t *testing.T) {
args{
func() keystore.Store {
store := keystoretest.NewMockStore(mockCtrl)
store.EXPECT().GetAddresses("substrate", "edgeware-berlin").Return(
store.EXPECT().GetAddresses("substrate", "edgeware-beresheet").Return(
[][]byte{
encodingtest.MustDecodeHex("2a169a11721851f5dff3541dd5c4b0b478ac1cd092c9d5976e83daa0d03f26620c464b"),
encodingtest.MustDecodeHex("2a84623e7252e41138af6904e1b02304c941625f39e5762589125dc1a2f2cf2e30e02a"),
Expand All @@ -102,7 +102,7 @@ func TestGetAddresses(t *testing.T) {
return store
}(),
},
httptest.NewRequest("GET", "/?network=edgeware-berlin&protocol=substrate", nil),
httptest.NewRequest("GET", "/?network=edgeware-beresheet&protocol=substrate", nil),
"{\"addresses\":[\"5602ea95540bee46d03ba335eed6f49d117eab95c8ab8b71bae2cdd1e564a761\"]}\n",
http.StatusOK,
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/mailchain/internal/http/handlers/protocols.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func GetProtocols(base *settings.Root) func(w http.ResponseWriter, r *http.Reque
networks = append(networks, Network{Name: network.Kind(), ID: ""})
} else if !network.Disabled() && protocol.Kind == "substrate" {
switch network.Kind() {
case substrate.EdgewareBerlin, substrate.EdgewareMainnet:
case substrate.EdgewareBeresheet, substrate.EdgewareMainnet:
networks = append(networks, Network{Name: network.Kind(), ID: "7"})
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/mailchain/internal/http/handlers/protocols_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func TestGetProtocols(t *testing.T) {
return settings.FromStore(m)
}(),
},
"{\"protocols\":[{\"name\":\"substrate\",\"networks\":[{\"name\":\"edgeware-berlin\",\"id\":\"7\"},{\"name\":\"edgeware-mainnet\",\"id\":\"7\"}]}]}\n",
"{\"protocols\":[{\"name\":\"substrate\",\"networks\":[{\"name\":\"edgeware-beresheet\",\"id\":\"7\"},{\"name\":\"edgeware-mainnet\",\"id\":\"7\"}]}]}\n",
http.StatusOK,
},
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/mailchain/internal/http/handlers/pubkey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,13 @@ func TestGetPublicKey(t *testing.T) {
args{
func() map[string]mailbox.PubKeyFinder {
finder := mailboxtest.NewMockPubKeyFinder(mockCtrl)
finder.EXPECT().PublicKeyFromAddress(gomock.Any(), "substrate", "edgeware-berlin", encodingtest.MustDecodeBase58("5CaLgJUDdDRxw6KQXJY2f5hFkMEEGHvtUPQYDWdSbku42Dv2")).Return(sr25519test.CharlottePublicKey, nil).Times(1)
return map[string]mailbox.PubKeyFinder{"substrate/edgeware-berlin": finder}
finder.EXPECT().PublicKeyFromAddress(gomock.Any(), "substrate", "edgeware-beresheet", encodingtest.MustDecodeBase58("5CaLgJUDdDRxw6KQXJY2f5hFkMEEGHvtUPQYDWdSbku42Dv2")).Return(sr25519test.CharlottePublicKey, nil).Times(1)
return map[string]mailbox.PubKeyFinder{"substrate/edgeware-beresheet": finder}
}(),
},
map[string]string{
"address": "5CaLgJUDdDRxw6KQXJY2f5hFkMEEGHvtUPQYDWdSbku42Dv2",
"network": "edgeware-berlin",
"network": "edgeware-beresheet",
"protocol": "substrate",
},
http.StatusOK,
Expand Down
2 changes: 1 addition & 1 deletion cmd/mailchain/internal/settings/receiver_mailchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func mailchainReceiverNoAuth(s values.Store) *MailchainReceiver {
Address: values.NewDefaultString("http://localhost:8081", s, "receivers.mailchain.address"),
EnabledProtocolNetworks: values.NewDefaultStringSlice(
[]string{
protocols.Substrate + "/" + substrate.EdgewareBerlin,
protocols.Substrate + "/" + substrate.EdgewareBeresheet,
protocols.Substrate + "/" + substrate.EdgewareMainnet,
},
s,
Expand Down
4 changes: 2 additions & 2 deletions cmd/mailchain/internal/settings/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ func FromStore(s values.Store) *Root {
ethereum.Ropsten: network(s, protocols.Ethereum, ethereum.Ropsten, defaults.EthereumNetworkAny()),
}),
protocols.Substrate: protocol(s, protocols.Substrate, map[string]NetworkClient{
substrate.EdgewareMainnet: network(s, protocols.Substrate, substrate.EdgewareMainnet, defaults.SubstrateNetworkAny(substrate.EdgewareMainnet)),
substrate.EdgewareBerlin: network(s, protocols.Substrate, substrate.EdgewareBerlin, defaults.SubstrateNetworkAny(substrate.EdgewareBerlin)),
substrate.EdgewareMainnet: network(s, protocols.Substrate, substrate.EdgewareMainnet, defaults.SubstrateNetworkAny(substrate.EdgewareMainnet)),
substrate.EdgewareBeresheet: network(s, protocols.Substrate, substrate.EdgewareBeresheet, defaults.SubstrateNetworkAny(substrate.EdgewareBeresheet)),
}),
},
// other
Expand Down
16 changes: 8 additions & 8 deletions cmd/mailchain/internal/settings/senders.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import (
func senders(s values.Store) *Senders {
return &Senders{
clients: map[string]SenderClient{
"ethereum-rpc2-" + ethereum.Goerli: ethereumRPC2Sender(s, ethereum.Goerli),
"ethereum-rpc2-" + ethereum.Kovan: ethereumRPC2Sender(s, ethereum.Kovan),
"ethereum-rpc2-" + ethereum.Mainnet: ethereumRPC2Sender(s, ethereum.Mainnet),
"ethereum-rpc2-" + ethereum.Rinkeby: ethereumRPC2Sender(s, ethereum.Rinkeby),
"ethereum-rpc2-" + ethereum.Ropsten: ethereumRPC2Sender(s, ethereum.Ropsten),
protocols.Ethereum + "-relay": relaySender(s, protocols.Ethereum),
"substrate-rpc-" + substrate.EdgewareMainnet: substrateRPCSender(s, substrate.EdgewareMainnet),
"substrate-rpc-" + substrate.EdgewareBerlin: substrateRPCSender(s, substrate.EdgewareBerlin),
"ethereum-rpc2-" + ethereum.Goerli: ethereumRPC2Sender(s, ethereum.Goerli),
"ethereum-rpc2-" + ethereum.Kovan: ethereumRPC2Sender(s, ethereum.Kovan),
"ethereum-rpc2-" + ethereum.Mainnet: ethereumRPC2Sender(s, ethereum.Mainnet),
"ethereum-rpc2-" + ethereum.Rinkeby: ethereumRPC2Sender(s, ethereum.Rinkeby),
"ethereum-rpc2-" + ethereum.Ropsten: ethereumRPC2Sender(s, ethereum.Ropsten),
protocols.Ethereum + "-relay": relaySender(s, protocols.Ethereum),
"substrate-rpc-" + substrate.EdgewareMainnet: substrateRPCSender(s, substrate.EdgewareMainnet),
"substrate-rpc-" + substrate.EdgewareBeresheet: substrateRPCSender(s, substrate.EdgewareBeresheet),
},
}
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/mailchain/internal/settings/substraterpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (

func substrateRPCSender(s values.Store, network string) *SubstrateRPC {
var defaultAddress = map[string]string{
substrate.EdgewareMainnet: "ws://mainnet1.edgewa.re:9944",
substrate.EdgewareBerlin: "ws://berlin1.edgewa.re:9944",
substrate.EdgewareMainnet: "ws://mainnet1.edgewa.re:9944",
substrate.EdgewareBeresheet: "ws://beresheet1.edgewa.re:9944",
}

return &SubstrateRPC{
Expand Down
14 changes: 7 additions & 7 deletions cmd/mailchain/internal/settings/substraterpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ func Test_substrateRPCSender(t *testing.T) {
args{
func() values.Store {
m := valuestest.NewMockStore(mockCtrl)
m.EXPECT().IsSet("senders.substrate-rpc-edgeware-berlin.address").Return(false)
m.EXPECT().IsSet("senders.substrate-rpc-edgeware-beresheet.address").Return(false)
return m
}(),
substrate.EdgewareBerlin,
substrate.EdgewareBeresheet,
},
"ws://berlin1.edgewa.re:9944",
"edgeware-berlin",
"ws://beresheet1.edgewa.re:9944",
"edgeware-beresheet",
},
}
for _, tt := range tests {
Expand Down Expand Up @@ -76,7 +76,7 @@ func TestSubstrateRPC_Produce(t *testing.T) {
m.EXPECT().Get().Return(server.URL)
return m
}(),
substrate.EdgewareBerlin,
substrate.EdgewareBeresheet,
},
false,
false,
Expand Down Expand Up @@ -119,9 +119,9 @@ func TestSubstrateRPC_Supports(t *testing.T) {
m := valuestest.NewMockString(mockCtrl)
return m
}(),
substrate.EdgewareBerlin,
substrate.EdgewareBeresheet,
},
map[string]bool{"substrate/edgeware-berlin": true},
map[string]bool{"substrate/edgeware-beresheet": true},
},
}
for _, tt := range tests {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@
# substrate:
# disabled: false
# networks:
# edgeware-berlin:
# edgeware-beresheet:
# disabled: false
# nameservice-address: ""
# nameservice-domain-name: ""
# public-key-finder: "substrate-public-key-finder"
# receiver: "mailchain"
# sender: "substrate-rpc-edgeware-berlin"
# sender: "substrate-rpc-edgeware-beresheet"
# edgeware-mainnet:
# disabled: false
# nameservice-address: ""
Expand Down Expand Up @@ -96,7 +96,7 @@
# disabled: false
# enabled-networks:
# - "substrate/edgeware-mainnet"
# - "substrate/edgeware-berlin"
# - "substrate/edgeware-beresheet"
# receivers:
# blockscout-no-auth:
# enabled-networks:
Expand All @@ -120,7 +120,7 @@
# mailchain:
# address: "http://localhost:8081"
# enabled-networks:
# - "substrate/edgeware-berlin"
# - "substrate/edgeware-beresheet"
# - "substrate/edgeware-mainnet"
# senders:
# ethereum-relay:
Expand All @@ -141,8 +141,8 @@
# address: "https://relay.mailchain.xyz/json-rpc/ethereum/rinkeby"
# ethereum-rpc2-ropsten:
# address: "https://relay.mailchain.xyz/json-rpc/ethereum/ropsten"
# substrate-rpc-edgeware-berlin:
# address: "ws://berlin1.edgewa.re:9944"
# substrate-rpc-edgeware-beresheet:
# address: "ws://beresheet1.edgewa.re:9944"
# substrate-rpc-edgeware-mainnet:
# address: "ws://mainnet1.edgewa.re:9944"
keystore:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ protocols:
substrate:
disabled: false
networks:
edgeware-berlin:
edgeware-beresheet:
disabled: false
nameservice-address: ""
nameservice-domain-name: ""
public-key-finder: "substrate-public-key-finder"
receiver: "mailchain"
sender: "substrate-rpc-edgeware-berlin"
sender: "substrate-rpc-edgeware-beresheet"
edgeware-mainnet:
disabled: false
nameservice-address: ""
Expand Down Expand Up @@ -96,7 +96,7 @@ public-key-finders:
disabled: false
enabled-networks:
- "substrate/edgeware-mainnet"
- "substrate/edgeware-berlin"
- "substrate/edgeware-beresheet"
receivers:
blockscout-no-auth:
enabled-networks:
Expand All @@ -120,7 +120,7 @@ receivers:
mailchain:
address: "http://localhost:8081"
enabled-networks:
- "substrate/edgeware-berlin"
- "substrate/edgeware-beresheet"
- "substrate/edgeware-mainnet"
senders:
ethereum-relay:
Expand All @@ -141,8 +141,8 @@ senders:
address: "https://relay.mailchain.xyz/json-rpc/ethereum/rinkeby"
ethereum-rpc2-ropsten:
address: "https://relay.mailchain.xyz/json-rpc/ethereum/ropsten"
substrate-rpc-edgeware-berlin:
address: "ws://berlin1.edgewa.re:9944"
substrate-rpc-edgeware-beresheet:
address: "ws://beresheet1.edgewa.re:9944"
substrate-rpc-edgeware-mainnet:
address: "ws://mainnet1.edgewa.re:9944"
keystore:
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.substrate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ services:
entrypoint: ["/indexer", "database", "up", "--postgres-host=database", "--master-postgres-password=mailchain", "--master-postgres-user=mailchain", "--indexer-postgres-password=indexer", "--envelope-postgres-password=envelope", "--pubkey-postgres-password=pubkey"]
depends_on:
- database
indexer-substrate-berlin:
indexer-substrate-mainnet:
image: mailchain/indexer
entrypoint: ["/indexer", "substrate", "--start-block=latest", "--network=edgeware-berlin", "--rpc-address=ws://berlin1.edgewa.re:9944", "--postgres-host=database", "--envelope-postgres-password=envelope", "--indexer-postgres-password=indexer", "--indexer-postgres-password=indexer", "--envelope-postgres-password=envelope", "--pubkey-postgres-password=pubkey", "--raw-store-path=./tmp/tx"]
entrypoint: ["/indexer", "substrate", "--start-block=latest", "--network=edgeware-mainnet", "--rpc-address=ws://mainnet1.edgewa.re:9944", "--postgres-host=database", "--envelope-postgres-password=envelope", "--indexer-postgres-password=indexer", "--indexer-postgres-password=indexer", "--envelope-postgres-password=envelope", "--pubkey-postgres-password=pubkey", "--raw-store-path=./tmp/tx"]
depends_on:
- database
receiver:
Expand Down
12 changes: 5 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ require (
github.com/Masterminds/squirrel v1.4.0
github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412
github.com/andreburgaud/crypt2go v0.11.0
github.com/aws/aws-sdk-go v1.33.1
github.com/aws/aws-sdk-go v1.34.6
github.com/cenkalti/backoff v2.2.1+incompatible
github.com/centrifuge/go-substrate-rpc-client v1.1.0 // indirect

github.com/dgraph-io/badger/v2 v2.0.3
github.com/ethereum/go-ethereum v1.9.15
github.com/golang/mock v1.4.3
github.com/ethereum/go-ethereum v1.9.19
github.com/golang/mock v1.4.4
github.com/golang/protobuf v1.4.2
github.com/google/uuid v1.1.1
github.com/gorilla/mux v1.7.4
Expand All @@ -22,13 +21,12 @@ require (
github.com/ipfs/go-cid v0.0.6
github.com/jmoiron/sqlx v1.2.0
github.com/lib/pq v1.7.0
github.com/mailchain/go-substrate-rpc-client v1.1.1-0.20200711220547-b44a964b0cd8
github.com/mailchain/go-substrate-rpc-client v1.1.1-0.20200817221053-ff085ba46ae9
github.com/manifoldco/promptui v0.7.0
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1
github.com/mitchellh/go-homedir v1.1.0
github.com/mr-tron/base58 v1.2.0
github.com/multiformats/go-multihash v0.0.14
github.com/pierrec/xxHash v0.1.5 // indirect
github.com/pkg/errors v0.9.1
github.com/rs/cors v1.7.0
github.com/rubenv/sql-migrate v0.0.0-20200616145509-8d140a17f351
Expand All @@ -41,6 +39,6 @@ require (
github.com/ttacon/chalk v0.0.0-20160626202418-22c06c80ed31
github.com/urfave/negroni v1.0.0
github.com/wealdtech/go-ens/v3 v3.4.3
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de
gopkg.in/resty.v1 v1.12.0
)
Loading

0 comments on commit 777dce1

Please sign in to comment.