Skip to content

Commit

Permalink
Set contract address to empty string if missing in response
Browse files Browse the repository at this point in the history
  • Loading branch information
chetan-zilliqa committed Oct 22, 2024
1 parent 780f17a commit 677f88f
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions contract/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ package contract

import (
"errors"
"strconv"
"strings"

"github.com/Zilliqa/gozilliqa-sdk/v3/account"
"github.com/Zilliqa/gozilliqa-sdk/v3/core"
"github.com/Zilliqa/gozilliqa-sdk/v3/provider"
"github.com/Zilliqa/gozilliqa-sdk/v3/transaction"
"github.com/Zilliqa/gozilliqa-sdk/v3/util"
"strconv"
"strings"
)

type ContractStatus int
Expand Down Expand Up @@ -153,12 +154,16 @@ func (c *Contract) Deploy(params DeployParams) (*transaction.Transaction, error)

result := rsp.Result.(map[string]interface{})
hash := result["TranID"].(string)
contractAddress := result["ContractAddress"].(string)

tx.ID = hash
tx.ContractAddress = contractAddress
return tx, nil
// Handle optional contract address
contractAddress, ok := result["contract_address"].(string)
if ok {
tx.ContractAddress = contractAddress
} else {
tx.ContractAddress = ""
}

return tx, nil
}
func (c *Contract) Sign(transition string, args []core.ContractValue, params CallParams, priority bool) (error, *transaction.Transaction) {
if c.Address == "" {
Expand Down

0 comments on commit 677f88f

Please sign in to comment.