-
Notifications
You must be signed in to change notification settings - Fork 109
/
deployFarmCmd.go
75 lines (63 loc) · 2.24 KB
/
deployFarmCmd.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package offline
import (
"crypto/ecdsa"
"math/big"
"strings"
"github.com/33cn/plugin/plugin/dapp/dex/contracts/pancake-farm/src/cakeToken"
"github.com/33cn/plugin/plugin/dapp/dex/contracts/pancake-farm/src/masterChef"
"github.com/33cn/plugin/plugin/dapp/dex/contracts/pancake-farm/src/syrupBar"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
)
type SignCakeToken struct {
}
func (s *SignCakeToken) reWriteDeployCakeToken(nonce uint64, gasPrice *big.Int, key *ecdsa.PrivateKey, params ...interface{}) (signedTx, hash string, err error) {
parsed, err := abi.JSON(strings.NewReader(cakeToken.CakeTokenABI))
if err != nil {
return
}
input, err := parsed.Pack("", params...)
if err != nil {
return
}
abiBin := cakeToken.CakeTokenBin
data := append(common.FromHex(abiBin), input...)
var amount = new(big.Int)
ntx := types.NewContractCreation(nonce, amount, gasLimit, gasPrice, data)
return SignTx(key, ntx)
}
type signsyrupBar struct {
}
func (s *signsyrupBar) reWriteDeploysyrupBar(nonce uint64, gasPrice *big.Int, key *ecdsa.PrivateKey, cakeAddress common.Address) (signedTx, hash string, err error) {
parsed, err := abi.JSON(strings.NewReader(syrupBar.SyrupBarABI))
if err != nil {
return
}
input, err := parsed.Pack("", cakeAddress)
if err != nil {
return
}
abiBin := syrupBar.SyrupBarBin
data := append(common.FromHex(abiBin), input...)
var amount = new(big.Int)
ntx := types.NewContractCreation(nonce, amount, gasLimit, gasPrice, data)
return SignTx(key, ntx)
}
type signMasterChef struct {
}
func (s *signMasterChef) reWriteDeployMasterChef(nonce uint64, gasPrice *big.Int, key *ecdsa.PrivateKey, cakeAddress, syruBarAddress, fromaddr common.Address, reward, _startBlock *big.Int) (signedTx, hash string, err error) {
parsed, err := abi.JSON(strings.NewReader(masterChef.MasterChefABI))
if err != nil {
return
}
input, err := parsed.Pack("", cakeAddress, syruBarAddress, fromaddr, reward, _startBlock)
if err != nil {
return
}
abiBin := masterChef.MasterChefBin
data := append(common.FromHex(abiBin), input...)
var amount = new(big.Int)
ntx := types.NewContractCreation(nonce, amount, gasLimit, gasPrice, data)
return SignTx(key, ntx)
}