forked from ethereum/go-ethereum
/
multisigwallet.go
57 lines (49 loc) · 1.93 KB
/
multisigwallet.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
// Copyright (c) 2018 XDCchain
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package multisigwallet
import (
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/contracts/multisigwallet/contract"
"math/big"
)
type MultiSigWallet struct {
*contract.MultiSigWalletSession
contractBackend bind.ContractBackend
}
func NewMultiSigWallet(transactOpts *bind.TransactOpts, contractAddr common.Address, contractBackend bind.ContractBackend) (*MultiSigWallet, error) {
blockSigner, err := contract.NewMultiSigWallet(contractAddr, contractBackend)
if err != nil {
return nil, err
}
return &MultiSigWallet{
&contract.MultiSigWalletSession{
Contract: blockSigner,
TransactOpts: *transactOpts,
},
contractBackend,
}, nil
}
func DeployMultiSigWallet(transactOpts *bind.TransactOpts, contractBackend bind.ContractBackend, _owners []common.Address, _required *big.Int) (common.Address, *MultiSigWallet, error) {
blockSignerAddr, _, _, err := contract.DeployMultiSigWallet(transactOpts, contractBackend, _owners, _required)
if err != nil {
return blockSignerAddr, nil, err
}
blockSigner, err := NewMultiSigWallet(transactOpts, blockSignerAddr, contractBackend)
if err != nil {
return blockSignerAddr, nil, err
}
return blockSignerAddr, blockSigner, nil
}