Merge pull request #322 from dinhln89/genesis

Fixed genesis for add team MSW contract.
This commit is contained in:
Tuna 2018-12-07 09:26:40 +07:00 committed by GitHub
commit 780a91e76f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 48 additions and 9 deletions

View file

@ -207,7 +207,7 @@ func (w *wizard) makeGenesis() {
}
fmt.Println()
fmt.Println("Which accounts are allowed to confirm in MultiSignWallet?")
fmt.Println("Which accounts are allowed to confirm in Foudation MultiSignWallet?")
var owners []common.Address
for {
if address := w.readAddress(); address != nil {
@ -219,7 +219,7 @@ func (w *wizard) makeGenesis() {
}
}
fmt.Println()
fmt.Println("How many require for confirm tx in MultiSignWallet? (default = 2)")
fmt.Println("How many require for confirm tx in Foudation MultiSignWallet? (default = 2)")
required := int64(w.readDefaultInt(2))
// MultiSigWallet.
@ -231,8 +231,11 @@ func (w *wizard) makeGenesis() {
code, _ = contractBackend.CodeAt(ctx, multiSignWalletAddr, nil)
storage = make(map[common.Hash]common.Hash)
contractBackend.ForEachStorageAt(ctx, multiSignWalletAddr, nil, f)
fBalance := big.NewInt(0) // 16m
fBalance.Add(fBalance, big.NewInt(16*1000*1000))
fBalance.Mul(fBalance, big.NewInt(1000000000000000000))
genesis.Alloc[common.HexToAddress(common.FoudationAddr)] = core.GenesisAccount{
Balance: big.NewInt(0),
Balance: fBalance,
Code: code,
Storage: storage,
}
@ -269,16 +272,51 @@ func (w *wizard) makeGenesis() {
Storage: storage,
}
fmt.Println()
fmt.Println("Which accounts are allowed to confirm in Team MultiSignWallet?")
var teams []common.Address
for {
if address := w.readAddress(); address != nil {
teams = append(teams, *address)
continue
}
if len(teams) > 0 {
break
}
}
fmt.Println()
fmt.Println("How many require for confirm tx in Team MultiSignWallet? (default = 2)")
required = int64(w.readDefaultInt(2))
// MultiSigWallet.
multiSignWalletTeamAddr, _, err := multiSignWalletContract.DeployMultiSigWallet(transactOpts, contractBackend, teams, big.NewInt(required))
if err != nil {
fmt.Println("Can't deploy MultiSignWallet SMC")
}
contractBackend.Commit()
code, _ = contractBackend.CodeAt(ctx, multiSignWalletTeamAddr, nil)
storage = make(map[common.Hash]common.Hash)
contractBackend.ForEachStorageAt(ctx, multiSignWalletTeamAddr, nil, f)
// Team balance.
balance := big.NewInt(0) // 12m
balance.Add(balance, big.NewInt(12*1000*1000))
balance.Mul(balance, big.NewInt(1000000000000000000))
subBalance := big.NewInt(0) // i * 50k
subBalance.Add(subBalance, big.NewInt(int64(len(signers))*50*1000))
subBalance.Mul(subBalance, big.NewInt(1000000000000000000))
balance.Sub(balance, subBalance) // 12m - i * 50k
genesis.Alloc[common.HexToAddress(common.TeamAddr)] = core.GenesisAccount{
Balance: balance,
Code: code,
Storage: storage,
}
fmt.Println()
fmt.Println("What is swap wallet address for fund 55m tomo?")
swapAddr := w.readDefaultAddress(common.HexToAddress(common.FoudationAddr))
swapAddr := *w.readAddress()
baseBalance := big.NewInt(0) // 55m
baseBalance.Add(baseBalance, big.NewInt(55*1000*1000))
baseBalance.Mul(baseBalance, big.NewInt(1000000000000000000))
subBalance := big.NewInt(0) // 150k
subBalance.Add(subBalance, big.NewInt(150*1000))
subBalance.Mul(subBalance, big.NewInt(1000000000000000000))
baseBalance.Sub(baseBalance, subBalance) // 55m - 150k
genesis.Alloc[swapAddr] = core.GenesisAccount{
Balance: baseBalance,
}
@ -301,7 +339,7 @@ func (w *wizard) makeGenesis() {
}
// Add a batch of precompile balances to avoid them getting deleted
for i := int64(0); i < 2; i++ {
genesis.Alloc[common.BigToAddress(big.NewInt(i))] = core.GenesisAccount{Balance: big.NewInt(1)}
genesis.Alloc[common.BigToAddress(big.NewInt(i))] = core.GenesisAccount{Balance: big.NewInt(0)}
}
// Query the user for some custom extras
fmt.Println()

View file

@ -34,6 +34,7 @@ const (
MasternodeVotingSMC = "0x0000000000000000000000000000000000000088"
RandomizeSMC = "0x0000000000000000000000000000000000000090"
FoudationAddr = "0x0000000000000000000000000000000000000068"
TeamAddr = "0x0000000000000000000000000000000000000099"
)
var (