From 91e651ed86e377e5b00b12872482968365eaf894 Mon Sep 17 00:00:00 2001 From: Stone monkey Date: Wed, 17 Jul 2024 09:06:07 +0800 Subject: [PATCH] Optimizing data types --- packages/api/tx/contract/contract.go | 6 +++--- packages/modus/contract.go | 4 ++-- packages/pkg/types/custom_tx.go | 2 +- packages/rpc/tx/contract/contract.go | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/api/tx/contract/contract.go b/packages/api/tx/contract/contract.go index f64e92d..8962a2c 100644 --- a/packages/api/tx/contract/contract.go +++ b/packages/api/tx/contract/contract.go @@ -65,7 +65,7 @@ func (c *contract) GetContract(contractName string) (*response.GetContractResult return &result, nil } -func (c *contract) PrepareContractTx(contractName string, form modus.Getter) (params map[string]any, contractId int, err error) { +func (c *contract) PrepareContractTx(contractName string, form modus.Getter) (params map[string]any, contractId uint32, err error) { var contract getContractInfo if err = c.SendGet("contract/"+contractName, nil, &contract); err != nil { return @@ -106,10 +106,10 @@ func (c *contract) PrepareContractTx(contractName string, form modus.Getter) (pa return } } - return params, int(contract.ID), nil + return params, contract.ID, nil } -func (c *contract) NewContractTransaction(contractId int, params map[string]any, expedite string) (data, hash []byte, err error) { +func (c *contract) NewContractTransaction(contractId uint32, params map[string]any, expedite string) (data, hash []byte, err error) { if expedite != "" { //Uniform use min uint d, err := decimal.NewFromString(expedite) diff --git a/packages/modus/contract.go b/packages/modus/contract.go index bff0199..f282c02 100644 --- a/packages/modus/contract.go +++ b/packages/modus/contract.go @@ -22,13 +22,13 @@ type Contract interface { // contain Prepare Contract transaction function // @return params map[string]any "contract params" // @return contractId int "contract id" - PrepareContractTx(contractName string, form Getter) (params map[string]any, contractId int, err error) + PrepareContractTx(contractName string, form Getter) (params map[string]any, contractId uint32, err error) // NewContractTransaction // Build a contract transaction // @return data []byte "contract transaction data" // @return hash []byte "transaction data hash" // expedite: ibax fee - NewContractTransaction(contractId int, params map[string]any, expedite string) (data, hash []byte, err error) + NewContractTransaction(contractId uint32, params map[string]any, expedite string) (data, hash []byte, err error) // AutoCallContract // call Contract and return transaction result AutoCallContract(contractName string, form Getter, expedite string) (*response.TxStatusResult, error) diff --git a/packages/pkg/types/custom_tx.go b/packages/pkg/types/custom_tx.go index 5c0d7a7..d6e7dce 100644 --- a/packages/pkg/types/custom_tx.go +++ b/packages/pkg/types/custom_tx.go @@ -28,7 +28,7 @@ const ( // Header is contain header data type Header struct { - ID int + ID uint32 EcosystemID int64 KeyID int64 Time int64 diff --git a/packages/rpc/tx/contract/contract.go b/packages/rpc/tx/contract/contract.go index 0aac6cf..4fa7a35 100644 --- a/packages/rpc/tx/contract/contract.go +++ b/packages/rpc/tx/contract/contract.go @@ -82,7 +82,7 @@ func (c *contract) GetContract(contractName string) (*response.GetContractResult return &result, nil } -func (c *contract) PrepareContractTx(contractName string, form modus.Getter) (params map[string]any, contractId int, err error) { +func (c *contract) PrepareContractTx(contractName string, form modus.Getter) (params map[string]any, contractId uint32, err error) { var contract getContractInfo message := request.RequestParams{ Namespace: request.NamespaceIBAX, @@ -162,10 +162,10 @@ func (c *contract) PrepareContractTx(contractName string, form modus.Getter) (pa return } } - return params, int(contract.ID), nil + return params, contract.ID, nil } -func (c *contract) NewContractTransaction(contractId int, params map[string]any, expedite string) (data, hash []byte, err error) { +func (c *contract) NewContractTransaction(contractId uint32, params map[string]any, expedite string) (data, hash []byte, err error) { if expedite != "" { //Uniform use min uint d, err := decimal.NewFromString(expedite)