-
Notifications
You must be signed in to change notification settings - Fork 1
/
aspectownable.go
64 lines (58 loc) · 2.12 KB
/
aspectownable.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
package contract
import (
"fmt"
"math/big"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
)
// 1. brew tap ethereum/ethereum
// 2. brew install solidity
//go:generate solc onwer.sol --combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize -o ./ --overwrite
//go:generate abigen --pkg contract --out aspectownable_contract.go --combined-json ./combined.json
var AspectOwnableMetaData = &bind.MetaData{
ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"isOwner\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"result\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]",
Sigs: map[string]string{
"2f54bf6e": "isOwner(address)",
},
}
func PackIsOwnerMsg(from common.Address, to *common.Address, nonce uint64, amount *big.Int, gasLimit uint64, gasPrice, gasFeeCap, gasTipCap *big.Int, accessList types.AccessList, sender common.Address) (*core.Message, error) {
parsed, err := AspectOwnableMetaData.GetAbi()
if err != nil {
return &core.Message{}, err
}
// Pack the input, call and unpack the results
input, err := parsed.Pack("isOwner", &sender)
if err != nil {
return &core.Message{}, err
}
message := &core.Message{
To: to,
From: from,
Nonce: nonce,
Value: amount,
GasLimit: gasLimit,
GasPrice: gasPrice,
GasFeeCap: gasFeeCap,
GasTipCap: gasTipCap,
Data: input,
AccessList: accessList,
SkipAccountChecks: false,
}
return message, nil
}
func UnpackIsOwnerResult(data []byte) (bool, error) {
parsed, err := AspectOwnableMetaData.GetAbi()
if err != nil {
return false, err
}
maps := make(map[string]interface{}, 0)
err2 := parsed.UnpackIntoMap(maps, "isOwner", data)
if err2 != nil {
fmt.Println("pack error", err2)
}
out0 := *abi.ConvertType(maps["result"], new(bool)).(*bool)
return out0, nil
}