rpc: check RPC client is initialised where appropriate

We don't need magic to create tx anymore, but we need it to sign tx.
This commit is contained in:
Anna Shaleva 2021-03-24 13:12:33 +03:00
parent 626ec8a82b
commit ffc2ad3cc3

View file

@ -129,9 +129,6 @@ func (c *Client) CreateTxFromScript(script []byte, acc *wallet.Account, sysFee,
sysFee = result.GasConsumed sysFee = result.GasConsumed
} }
if !c.initDone {
return nil, errNetworkNotInitialized
}
tx := transaction.New(script, sysFee) tx := transaction.New(script, sysFee)
tx.Signers = signers tx.Signers = signers
@ -153,6 +150,10 @@ func (c *Client) CreateTxFromScript(script []byte, acc *wallet.Account, sysFee,
// using contract's number of decimals) to given account with data specified and // using contract's number of decimals) to given account with data specified and
// sends it to the network returning just a hash of it. // sends it to the network returning just a hash of it.
func (c *Client) TransferNEP17(acc *wallet.Account, to util.Uint160, token util.Uint160, amount int64, gas int64, data interface{}) (util.Uint256, error) { func (c *Client) TransferNEP17(acc *wallet.Account, to util.Uint160, token util.Uint160, amount int64, gas int64, data interface{}) (util.Uint256, error) {
if !c.initDone {
return util.Uint256{}, errNetworkNotInitialized
}
tx, err := c.CreateNEP17TransferTx(acc, to, token, amount, gas, data) tx, err := c.CreateNEP17TransferTx(acc, to, token, amount, gas, data)
if err != nil { if err != nil {
return util.Uint256{}, err return util.Uint256{}, err
@ -167,6 +168,10 @@ func (c *Client) TransferNEP17(acc *wallet.Account, to util.Uint160, token util.
// MultiTransferNEP17 is similar to TransferNEP17, buf allows to have multiple recipients. // MultiTransferNEP17 is similar to TransferNEP17, buf allows to have multiple recipients.
func (c *Client) MultiTransferNEP17(acc *wallet.Account, gas int64, recipients []TransferTarget, data []interface{}) (util.Uint256, error) { func (c *Client) MultiTransferNEP17(acc *wallet.Account, gas int64, recipients []TransferTarget, data []interface{}) (util.Uint256, error) {
if !c.initDone {
return util.Uint256{}, errNetworkNotInitialized
}
tx, err := c.CreateNEP17MultiTransferTx(acc, gas, recipients, data) tx, err := c.CreateNEP17MultiTransferTx(acc, gas, recipients, data)
if err != nil { if err != nil {
return util.Uint256{}, err return util.Uint256{}, err