Skip to content

Commit

Permalink
Revert "add abigen"
Browse files Browse the repository at this point in the history
This reverts commit e3dcef9.
  • Loading branch information
wincenteam committed Feb 20, 2020
1 parent f0f2011 commit 8eb9de5
Show file tree
Hide file tree
Showing 25 changed files with 240 additions and 1,909 deletions.
50 changes: 0 additions & 50 deletions accounts/abi/abi.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import (
"encoding/json"
"fmt"
"io"

"github.com/sero-cash/go-czero-import/c_type"
)

// The ABI holds information about a contract's context and available
Expand Down Expand Up @@ -51,39 +49,10 @@ func JSON(reader io.Reader) (ABI, error) {
// of 4 bytes and arguments are all 32 bytes.
// Method ids are created from the first 4 bytes of the hash of the
// methods string signature. (signature = baz(uint32,string32))

func (abi ABI) PackPrefix(name string, rand c_type.Uint128, args ...interface{}) ([]byte, error) {
var ret []byte
ret = append(ret, rand[:]...)
if name == "" {
// constructor
addressPrefix, err := abi.Constructor.Inputs.PackPrefix(args...)
if err != nil {
return nil, err
}
ret = append(ret, addressPrefix...)
return ret, nil

}
method, exist := abi.Methods[name]
if !exist {
return nil, fmt.Errorf("method '%s' not found", name)
}

addressPrefix, err := method.Inputs.PackPrefix(args...)
if err != nil {
return nil, err
}
ret = append(ret, addressPrefix...)

return ret, nil
}

func (abi ABI) Pack(name string, args ...interface{}) ([]byte, error) {
// Fetch the ABI of the requested method
if name == "" {
// constructor

arguments, err := abi.Constructor.Inputs.Pack(args...)
if err != nil {
return nil, err
Expand Down Expand Up @@ -122,25 +91,6 @@ func (abi ABI) Unpack(v interface{}, name string, output []byte) (err error) {
return fmt.Errorf("abi: could not locate named method or event")
}

// UnpackIntoMap unpacks a log into the provided map[string]interface{}
func (abi ABI) UnpackIntoMap(v map[string]interface{}, name string, data []byte) (err error) {
if len(data) == 0 {
return fmt.Errorf("abi: unmarshalling empty output")
}
// since there can't be naming collisions with contracts and events,
// we need to decide whether we're calling a method or an event
if method, ok := abi.Methods[name]; ok {
if len(data)%32 != 0 {
return fmt.Errorf("abi: improperly formatted output")
}
return method.Outputs.UnpackIntoMap(v, data)
}
if event, ok := abi.Events[name]; ok {
return event.Inputs.UnpackIntoMap(v, data)
}
return fmt.Errorf("abi: could not locate named method or event")
}

// UnmarshalJSON implements json.Unmarshaler interface
func (abi *ABI) UnmarshalJSON(data []byte) error {
var fields []struct {
Expand Down
53 changes: 0 additions & 53 deletions accounts/abi/argument.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,8 @@ package abi
import (
"encoding/json"
"fmt"
"math/big"
"reflect"
"strings"

"github.com/sero-cash/go-sero/common/math"

"github.com/sero-cash/go-czero-import/c_type"
)

// Argument holds the name of the argument and the corresponding type.
Expand Down Expand Up @@ -105,29 +100,6 @@ func (arguments Arguments) Unpack(v interface{}, data []byte) error {
return arguments.unpackAtomic(v, marshalledValues)
}

// UnpackIntoMap performs the operation hexdata -> mapping of argument name to argument value
func (arguments Arguments) UnpackIntoMap(v map[string]interface{}, data []byte) error {
marshalledValues, err := arguments.UnpackValues(data)
if err != nil {
return err
}

return arguments.unpackIntoMap(v, marshalledValues)
}

// unpackIntoMap unpacks marshalledValues into the provided map[string]interface{}
func (arguments Arguments) unpackIntoMap(v map[string]interface{}, marshalledValues []interface{}) error {
// Make sure map is not nil
if v == nil {
return fmt.Errorf("abi: cannot unpack into a nil map")
}

for i, arg := range arguments.NonIndexed() {
v[arg.Name] = marshalledValues[i]
}
return nil
}

func (arguments Arguments) unpackTuple(v interface{}, marshalledValues []interface{}) error {

var (
Expand Down Expand Up @@ -257,31 +229,6 @@ func (arguments Arguments) PackValues(args []interface{}) ([]byte, error) {
return arguments.Pack(args...)
}

func (arguments Arguments) PackPrefix(args ...interface{}) ([]byte, error) {
abiArgs := arguments
if len(args) != len(abiArgs) {
return nil, fmt.Errorf("argument count mismatch: %d for %d", len(args), len(abiArgs))
}
var result []c_type.PKr
for i, a := range args {
input := abiArgs[i]
// pack the input
pkrs, err := input.Type.getAllAddress(reflect.ValueOf(a))
if err != nil {
return nil, err
}
result = append(result, pkrs...)
}
var ret []byte
lenBytes := math.PaddedBigBytes(big.NewInt(int64(len(result))), 2)
ret = append(ret, lenBytes...)
for _, pkr := range result {
ret = append(ret, pkr[:]...)
}
return ret, nil

}

// Pack performs the operation Go format -> Hexdata
func (arguments Arguments) Pack(args ...interface{}) ([]byte, error) {
// Make sure arguments match up and pack them
Expand Down
89 changes: 0 additions & 89 deletions accounts/abi/bind/auth.go

This file was deleted.

8 changes: 2 additions & 6 deletions accounts/abi/bind/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import (
"errors"
"math/big"

"github.com/sero-cash/go-sero/zero/txtool"

sero "github.com/sero-cash/go-sero"
"github.com/sero-cash/go-sero/common"
"github.com/sero-cash/go-sero/core/types"
Expand Down Expand Up @@ -82,10 +80,8 @@ type ContractTransactor interface {
// transactions may be added or removed by miners, but it should provide a basis
// for setting a reasonable default.
EstimateGas(ctx context.Context, call sero.CallMsg) (gas uint64, err error)

GenContractTx(ctx context.Context, msg sero.CallMsg) (*txtool.GTxParam, error)

CommitTx(ctx context.Context, arg *txtool.GTx) error
// SendTransaction injects the transaction into the pending pool for execution.
SendTransaction(ctx context.Context, tx *types.Transaction) error
}

// ContractFilterer defines the methods needed to access log events using one-off
Expand Down
Loading

0 comments on commit 8eb9de5

Please sign in to comment.