From c47b4c4741951e0bb157f6b7195d53a3f8106b7d Mon Sep 17 00:00:00 2001 From: jc2023 <135361438+jiangchuan-he-cb@users.noreply.github.com> Date: Wed, 20 Sep 2023 14:01:13 -0700 Subject: [PATCH] Make the contract call encoding utility method public (#99) make the contract call encoding utility method public Co-authored-by: jiangchuan-he --- services/construction/contract_call_data.go | 4 ++-- services/construction/contract_call_data_test.go | 2 +- services/construction/payloads.go | 2 +- services/construction/preprocess.go | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/services/construction/contract_call_data.go b/services/construction/contract_call_data.go index 28b55f0..797b386 100644 --- a/services/construction/contract_call_data.go +++ b/services/construction/contract_call_data.go @@ -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 diff --git a/services/construction/contract_call_data_test.go b/services/construction/contract_call_data_test.go index 03a01f2..3ab2a68 100644 --- a/services/construction/contract_call_data_test.go +++ b/services/construction/contract_call_data_test.go @@ -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()) diff --git a/services/construction/payloads.go b/services/construction/payloads.go index 4c53473..31e8e66 100644 --- a/services/construction/payloads.go +++ b/services/construction/payloads.go @@ -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) } diff --git a/services/construction/preprocess.go b/services/construction/preprocess.go index 564a45f..6971074 100644 --- a/services/construction/preprocess.go +++ b/services/construction/preprocess.go @@ -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 }