-
Notifications
You must be signed in to change notification settings - Fork 683
/
constants.go
40 lines (33 loc) · 1.11 KB
/
constants.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// package devnet contains constants and helper functions for the local deterministic devnet.
// See "Devnet addresses" in DEVELOP.md. Created by setup scripts/migrations.
package devnet
import (
"fmt"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
hdwallet "github.com/miguelmota/go-ethereum-hdwallet"
)
var (
// Contracts (deployed by "truffle migrate" on a deterministic devnet)
GanacheWormholeContractAddress = common.HexToAddress("0xC89Ce4735882C9F0f0FE26686c53074E09B0D550")
)
const (
// Ganache's hardcoded HD Wallet derivation path
ganacheWalletMnemonic = "myth like bonus scare over problem client lizard pioneer submit female collect"
ganacheDerivationPath = "m/44'/60'/0'/0/%d"
)
func DeriveAccount(accountIndex uint) accounts.Account {
path := hdwallet.MustParseDerivationPath(fmt.Sprintf(ganacheDerivationPath, accountIndex))
account, err := Wallet().Derive(path, false)
if err != nil {
panic(err)
}
return account
}
func Wallet() *hdwallet.Wallet {
wallet, err := hdwallet.NewFromMnemonic(ganacheWalletMnemonic)
if err != nil {
panic(err)
}
return wallet
}