Skip to content

Commit

Permalink
Make the contract call encoding utility method public (#99)
Browse files Browse the repository at this point in the history
make the contract call encoding utility method public

Co-authored-by: jiangchuan-he <[email protected]>
  • Loading branch information
jiangchuan-he-cb and cryptoriver authored Sep 20, 2023
1 parent 29e64c5 commit c47b4c4
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions services/construction/contract_call_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ import (
"golang.org/x/crypto/sha3"
)

// constructContractCallDataGeneric constructs the data field of a transaction.
// ConstructContractCallDataGeneric constructs the data field of a transaction.
// The methodArgs can be already in ABI encoded format in case of a single string
// It can also be passed in as a slice of args, which requires further encoding.
func constructContractCallDataGeneric(methodSig string, methodArgs interface{}) ([]byte, error) {
func ConstructContractCallDataGeneric(methodSig string, methodArgs interface{}) ([]byte, error) {
data, err := contractCallMethodID(methodSig)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion services/construction/contract_call_data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func TestConstruction_ContractCallData(t *testing.T) {

for name, test := range tests {
t.Run(name, func(t *testing.T) {
bytes, err := constructContractCallDataGeneric(test.methodSig, test.methodArgs)
bytes, err := ConstructContractCallDataGeneric(test.methodSig, test.methodArgs)
if err != nil {
fmt.Println(err)
assert.EqualError(t, err, test.expectedError.Error())
Expand Down
2 changes: 1 addition & 1 deletion services/construction/payloads.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (s *APIService) ConstructionPayloads(
return nil, sdkTypes.WrapErr(sdkTypes.ErrInvalidInput, err)
}

data, err := constructContractCallDataGeneric(metadata.MethodSignature, metadata.MethodArgs)
data, err := ConstructContractCallDataGeneric(metadata.MethodSignature, metadata.MethodArgs)
if err != nil {
return nil, sdkTypes.WrapErr(sdkTypes.ErrInvalidInput, err)
}
Expand Down
2 changes: 1 addition & 1 deletion services/construction/preprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func loadMetadata(req *types.ConstructionPreprocessRequest, options *client.Opti
return fmt.Errorf("%s is not a valid method signature string", v)
}

data, err := constructContractCallDataGeneric(methodSigStringObj, req.Metadata["method_args"])
data, err := ConstructContractCallDataGeneric(methodSigStringObj, req.Metadata["method_args"])
if err != nil {
return err
}
Expand Down

0 comments on commit c47b4c4

Please sign in to comment.