Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set contract address to empty string if missing in response #123

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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["ContractAddress"].(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