mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-22 09:29:38 +00:00
rpc/client: move to pkg/rpcclient
Better package name, closer to user.
This commit is contained in:
parent
43a59adbd0
commit
8c668765d2
26 changed files with 93 additions and 93 deletions
|
@ -9,7 +9,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/client"
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
|
@ -188,14 +188,14 @@ func ParseParams(args []string, calledFromMain bool) (int, []smartcontract.Param
|
||||||
|
|
||||||
// GetSignersAccounts returns the list of signers combined with the corresponding
|
// GetSignersAccounts returns the list of signers combined with the corresponding
|
||||||
// accounts from the provided wallet.
|
// accounts from the provided wallet.
|
||||||
func GetSignersAccounts(wall *wallet.Wallet, signers []transaction.Signer) ([]client.SignerAccount, error) {
|
func GetSignersAccounts(wall *wallet.Wallet, signers []transaction.Signer) ([]rpcclient.SignerAccount, error) {
|
||||||
signersAccounts := make([]client.SignerAccount, len(signers))
|
signersAccounts := make([]rpcclient.SignerAccount, len(signers))
|
||||||
for i := range signers {
|
for i := range signers {
|
||||||
signerAcc := wall.GetAccount(signers[i].Account)
|
signerAcc := wall.GetAccount(signers[i].Account)
|
||||||
if signerAcc == nil {
|
if signerAcc == nil {
|
||||||
return nil, fmt.Errorf("no account was found in the wallet for signer #%d (%s)", i, address.Uint160ToString(signers[i].Account))
|
return nil, fmt.Errorf("no account was found in the wallet for signer #%d (%s)", i, address.Uint160ToString(signers[i].Account))
|
||||||
}
|
}
|
||||||
signersAccounts[i] = client.SignerAccount{
|
signersAccounts[i] = rpcclient.SignerAccount{
|
||||||
Signer: signers[i],
|
Signer: signers[i],
|
||||||
Account: signerAcc,
|
Account: signerAcc,
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
|
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/client"
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -70,12 +70,12 @@ func GetTimeoutContext(ctx *cli.Context) (context.Context, func()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRPCClient returns an RPC client instance for the given Context.
|
// GetRPCClient returns an RPC client instance for the given Context.
|
||||||
func GetRPCClient(gctx context.Context, ctx *cli.Context) (*client.Client, cli.ExitCoder) {
|
func GetRPCClient(gctx context.Context, ctx *cli.Context) (*rpcclient.Client, cli.ExitCoder) {
|
||||||
endpoint := ctx.String(RPCEndpointFlag)
|
endpoint := ctx.String(RPCEndpointFlag)
|
||||||
if len(endpoint) == 0 {
|
if len(endpoint) == 0 {
|
||||||
return nil, cli.NewExitError(errNoEndpoint, 1)
|
return nil, cli.NewExitError(errNoEndpoint, 1)
|
||||||
}
|
}
|
||||||
c, err := client.New(gctx, endpoint, client.Options{})
|
c, err := rpcclient.New(gctx, endpoint, rpcclient.Options{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, cli.NewExitError(err, 1)
|
return nil, cli.NewExitError(err, 1)
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
|
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/client"
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result"
|
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
||||||
|
@ -645,7 +645,7 @@ func invokeWithArgs(ctx *cli.Context, acc *wallet.Account, wall *wallet.Wallet,
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
gas, sysgas fixedn.Fixed8
|
gas, sysgas fixedn.Fixed8
|
||||||
cosignersAccounts []client.SignerAccount
|
cosignersAccounts []rpcclient.SignerAccount
|
||||||
resp *result.Invoke
|
resp *result.Invoke
|
||||||
sender util.Uint160
|
sender util.Uint160
|
||||||
signAndPush = acc != nil
|
signAndPush = acc != nil
|
||||||
|
|
|
@ -13,7 +13,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
|
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/client"
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||||
|
@ -250,7 +250,7 @@ func transferNEP11(ctx *cli.Context) error {
|
||||||
return transferNEP(ctx, manifest.NEP11StandardName)
|
return transferNEP(ctx, manifest.NEP11StandardName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func signAndSendNEP11Transfer(ctx *cli.Context, c *client.Client, acc *wallet.Account, token, to util.Uint160, tokenID []byte, amount *big.Int, data interface{}, cosigners []client.SignerAccount) error {
|
func signAndSendNEP11Transfer(ctx *cli.Context, c *rpcclient.Client, acc *wallet.Account, token, to util.Uint160, tokenID []byte, amount *big.Int, data interface{}, cosigners []rpcclient.SignerAccount) error {
|
||||||
gas := flags.Fixed8FromContext(ctx, "gas")
|
gas := flags.Fixed8FromContext(ctx, "gas")
|
||||||
sysgas := flags.Fixed8FromContext(ctx, "sysgas")
|
sysgas := flags.Fixed8FromContext(ctx, "sysgas")
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,8 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
|
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
|
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/client"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result"
|
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
||||||
|
@ -278,7 +278,7 @@ func printAssetBalance(ctx *cli.Context, asset util.Uint160, tokenName, tokenSym
|
||||||
fmt.Fprintf(ctx.App.Writer, "\tUpdated: %d\n", balance.LastUpdated)
|
fmt.Fprintf(ctx.App.Writer, "\tUpdated: %d\n", balance.LastUpdated)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getNativeNEP17Symbol(c *client.Client, name string) (string, util.Uint160, error) {
|
func getNativeNEP17Symbol(c *rpcclient.Client, name string) (string, util.Uint160, error) {
|
||||||
h, err := c.GetNativeContractHash(name)
|
h, err := c.GetNativeContractHash(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", util.Uint160{}, fmt.Errorf("failed to get native %s hash: %w", name, err)
|
return "", util.Uint160{}, fmt.Errorf("failed to get native %s hash: %w", name, err)
|
||||||
|
@ -296,7 +296,7 @@ func getMatchingToken(ctx *cli.Context, w *wallet.Wallet, name string, standard
|
||||||
}, len(w.Extra.Tokens), name, standard)
|
}, len(w.Extra.Tokens), name, standard)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getMatchingTokenRPC(ctx *cli.Context, c *client.Client, addr util.Uint160, name string, standard string) (*wallet.Token, error) {
|
func getMatchingTokenRPC(ctx *cli.Context, c *rpcclient.Client, addr util.Uint160, name string, standard string) (*wallet.Token, error) {
|
||||||
switch standard {
|
switch standard {
|
||||||
case manifest.NEP17StandardName:
|
case manifest.NEP17StandardName:
|
||||||
bs, err := c.GetNEP17Balances(addr)
|
bs, err := c.GetNEP17Balances(addr)
|
||||||
|
@ -493,7 +493,7 @@ func multiTransferNEP17(ctx *cli.Context) error {
|
||||||
return cli.NewExitError("empty recipients list", 1)
|
return cli.NewExitError("empty recipients list", 1)
|
||||||
}
|
}
|
||||||
var (
|
var (
|
||||||
recipients []client.TransferTarget
|
recipients []rpcclient.TransferTarget
|
||||||
cosignersOffset = ctx.NArg()
|
cosignersOffset = ctx.NArg()
|
||||||
)
|
)
|
||||||
cache := make(map[string]*wallet.Token)
|
cache := make(map[string]*wallet.Token)
|
||||||
|
@ -526,7 +526,7 @@ func multiTransferNEP17(ctx *cli.Context) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cli.NewExitError(fmt.Errorf("invalid amount: %w", err), 1)
|
return cli.NewExitError(fmt.Errorf("invalid amount: %w", err), 1)
|
||||||
}
|
}
|
||||||
recipients = append(recipients, client.TransferTarget{
|
recipients = append(recipients, rpcclient.TransferTarget{
|
||||||
Token: token.Hash,
|
Token: token.Hash,
|
||||||
Address: addr,
|
Address: addr,
|
||||||
Amount: amount.Int64(),
|
Amount: amount.Int64(),
|
||||||
|
@ -608,7 +608,7 @@ func transferNEP(ctx *cli.Context, standard string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cli.NewExitError(fmt.Errorf("invalid amount: %w", err), 1)
|
return cli.NewExitError(fmt.Errorf("invalid amount: %w", err), 1)
|
||||||
}
|
}
|
||||||
return signAndSendNEP17Transfer(ctx, c, acc, []client.TransferTarget{{
|
return signAndSendNEP17Transfer(ctx, c, acc, []rpcclient.TransferTarget{{
|
||||||
Token: token.Hash,
|
Token: token.Hash,
|
||||||
Address: to,
|
Address: to,
|
||||||
Amount: amount.Int64(),
|
Amount: amount.Int64(),
|
||||||
|
@ -636,7 +636,7 @@ func transferNEP(ctx *cli.Context, standard string) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func signAndSendNEP17Transfer(ctx *cli.Context, c *client.Client, acc *wallet.Account, recipients []client.TransferTarget, cosigners []client.SignerAccount) error {
|
func signAndSendNEP17Transfer(ctx *cli.Context, c *rpcclient.Client, acc *wallet.Account, recipients []rpcclient.TransferTarget, cosigners []rpcclient.SignerAccount) error {
|
||||||
gas := flags.Fixed8FromContext(ctx, "gas")
|
gas := flags.Fixed8FromContext(ctx, "gas")
|
||||||
sysgas := flags.Fixed8FromContext(ctx, "sysgas")
|
sysgas := flags.Fixed8FromContext(ctx, "sysgas")
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/client"
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm/emit"
|
"github.com/nspcc-dev/neo-go/pkg/vm/emit"
|
||||||
|
@ -125,7 +125,7 @@ func handleCandidate(ctx *cli.Context, method string, sysGas int64) error {
|
||||||
w := io.NewBufBinWriter()
|
w := io.NewBufBinWriter()
|
||||||
emit.AppCall(w.BinWriter, neoContractHash, method, callflag.States, acc.PrivateKey().PublicKey().Bytes())
|
emit.AppCall(w.BinWriter, neoContractHash, method, callflag.States, acc.PrivateKey().PublicKey().Bytes())
|
||||||
emit.Opcodes(w.BinWriter, opcode.ASSERT)
|
emit.Opcodes(w.BinWriter, opcode.ASSERT)
|
||||||
res, err := c.SignAndPushInvocationTx(w.Bytes(), acc, sysGas, gas, []client.SignerAccount{{
|
res, err := c.SignAndPushInvocationTx(w.Bytes(), acc, sysGas, gas, []rpcclient.SignerAccount{{
|
||||||
Signer: transaction.Signer{
|
Signer: transaction.Signer{
|
||||||
Account: acc.Contract.ScriptHash(),
|
Account: acc.Contract.ScriptHash(),
|
||||||
Scopes: transaction.CalledByEntry,
|
Scopes: transaction.CalledByEntry,
|
||||||
|
@ -186,7 +186,7 @@ func handleVote(ctx *cli.Context) error {
|
||||||
emit.AppCall(w.BinWriter, neoContractHash, "vote", callflag.States, addr.BytesBE(), pubArg)
|
emit.AppCall(w.BinWriter, neoContractHash, "vote", callflag.States, addr.BytesBE(), pubArg)
|
||||||
emit.Opcodes(w.BinWriter, opcode.ASSERT)
|
emit.Opcodes(w.BinWriter, opcode.ASSERT)
|
||||||
|
|
||||||
res, err := c.SignAndPushInvocationTx(w.Bytes(), acc, -1, gas, []client.SignerAccount{{
|
res, err := c.SignAndPushInvocationTx(w.Bytes(), acc, -1, gas, []rpcclient.SignerAccount{{
|
||||||
Signer: transaction.Signer{
|
Signer: transaction.Signer{
|
||||||
Account: acc.Contract.ScriptHash(),
|
Account: acc.Contract.ScriptHash(),
|
||||||
Scopes: transaction.CalledByEntry,
|
Scopes: transaction.CalledByEntry,
|
||||||
|
|
|
@ -255,7 +255,7 @@ won't pass verification.
|
||||||
Notary native contract supports `onNEP17Payment` method. Thus, to deposit funds to
|
Notary native contract supports `onNEP17Payment` method. Thus, to deposit funds to
|
||||||
the Notary native contract, transfer the desired amount of GAS to the contract
|
the Notary native contract, transfer the desired amount of GAS to the contract
|
||||||
address. Use
|
address. Use
|
||||||
[func (*Client) TransferNEP17](https://pkg.go.dev/github.com/nspcc-dev/neo-go@v0.97.2/pkg/rpc/client#Client.TransferNEP17)
|
[func (*Client) TransferNEP17](https://pkg.go.dev/github.com/nspcc-dev/neo-go@v0.97.2/pkg/rpcclient#Client.TransferNEP17)
|
||||||
with the `data` parameter matching the following requirements:
|
with the `data` parameter matching the following requirements:
|
||||||
- `data` should be an array of two elements: `to` and `till`.
|
- `data` should be an array of two elements: `to` and `till`.
|
||||||
- `to` denotes the receiver of the deposit. It can be nil in case `to` equals
|
- `to` denotes the receiver of the deposit. It can be nil in case `to` equals
|
||||||
|
@ -308,7 +308,7 @@ the steps to create a signature request:
|
||||||
constraints:
|
constraints:
|
||||||
* Notary signer hash is the hash of a native Notary contract that can be fetched
|
* Notary signer hash is the hash of a native Notary contract that can be fetched
|
||||||
from
|
from
|
||||||
[func (*Client) GetNativeContractHash](https://pkg.go.dev/github.com/nspcc-dev/neo-go@v0.97.2/pkg/rpc/client#Client.GetNativeContractHash).
|
[func (*Client) GetNativeContractHash](https://pkg.go.dev/github.com/nspcc-dev/neo-go@v0.97.2/pkg/rpcclient#Client.GetNativeContractHash).
|
||||||
* A notary signer must have `None` scope.
|
* A notary signer must have `None` scope.
|
||||||
* A notary signer shouldn't be placed at the beginning of the signer list
|
* A notary signer shouldn't be placed at the beginning of the signer list
|
||||||
because Notary contract does not pay main transaction fees. Other positions
|
because Notary contract does not pay main transaction fees. Other positions
|
||||||
|
@ -317,11 +317,11 @@ the steps to create a signature request:
|
||||||
field) and calculate system fee using regular rules (that will be `SystemFee`
|
field) and calculate system fee using regular rules (that will be `SystemFee`
|
||||||
transaction field). Probably, you'll perform one of these actions:
|
transaction field). Probably, you'll perform one of these actions:
|
||||||
1. If the script is a contract method call, use `invokefunction` RPC API
|
1. If the script is a contract method call, use `invokefunction` RPC API
|
||||||
[func (*Client) InvokeFunction](https://pkg.go.dev/github.com/nspcc-dev/neo-go@v0.97.2/pkg/rpc/client#Client.InvokeFunction)
|
[func (*Client) InvokeFunction](https://pkg.go.dev/github.com/nspcc-dev/neo-go@v0.97.2/pkg/rpcclient#Client.InvokeFunction)
|
||||||
and fetch the script and the gas consumed from the result.
|
and fetch the script and the gas consumed from the result.
|
||||||
2. If the script is more complicated than just a contract method call,
|
2. If the script is more complicated than just a contract method call,
|
||||||
construct the script manually and use `invokescript` RPC API
|
construct the script manually and use `invokescript` RPC API
|
||||||
[func (*Client) InvokeScript](https://pkg.go.dev/github.com/nspcc-dev/neo-go@v0.97.2/pkg/rpc/client#Client.InvokeScript)
|
[func (*Client) InvokeScript](https://pkg.go.dev/github.com/nspcc-dev/neo-go@v0.97.2/pkg/rpcclient#Client.InvokeScript)
|
||||||
to fetch the gas consumed from the result.
|
to fetch the gas consumed from the result.
|
||||||
3. Or just construct the script and set system fee manually.
|
3. Or just construct the script and set system fee manually.
|
||||||
3. Calculate the height main transaction is valid until (that will be
|
3. Calculate the height main transaction is valid until (that will be
|
||||||
|
@ -361,12 +361,12 @@ the steps to create a signature request:
|
||||||
`NotaryAssisted` attribute usage and for notary contract witness
|
`NotaryAssisted` attribute usage and for notary contract witness
|
||||||
verification (that is to be added by the notary node in the end of
|
verification (that is to be added by the notary node in the end of
|
||||||
signature collection process). Use
|
signature collection process). Use
|
||||||
[func (*Client) CalculateNotaryFee](https://pkg.go.dev/github.com/nspcc-dev/neo-go@v0.97.2/pkg/rpc/client#Client.CalculateNotaryFee)
|
[func (*Client) CalculateNotaryFee](https://pkg.go.dev/github.com/nspcc-dev/neo-go@v0.97.2/pkg/rpcclient#Client.CalculateNotaryFee)
|
||||||
to calculate notary network fee. Use `NKeys` estimated at step 4 as an
|
to calculate notary network fee. Use `NKeys` estimated at step 4 as an
|
||||||
argument.
|
argument.
|
||||||
- *Regular network fee.* That's the amount of GAS to be paid for other witnesses
|
- *Regular network fee.* That's the amount of GAS to be paid for other witnesses
|
||||||
verification. Use
|
verification. Use
|
||||||
[func (*Client) AddNetworkFee](https://pkg.go.dev/github.com/nspcc-dev/neo-go@v0.97.2/pkg/rpc/client#Client.AddNetworkFee)
|
[func (*Client) AddNetworkFee](https://pkg.go.dev/github.com/nspcc-dev/neo-go@v0.97.2/pkg/rpcclient#Client.AddNetworkFee)
|
||||||
to calculate regular network fee and add it to the transaction. Use
|
to calculate regular network fee and add it to the transaction. Use
|
||||||
partially-filled main transaction from the previous steps as `tx` argument.
|
partially-filled main transaction from the previous steps as `tx` argument.
|
||||||
Use notary network fee calculated at the previous substep as `extraFee`
|
Use notary network fee calculated at the previous substep as `extraFee`
|
||||||
|
@ -402,13 +402,13 @@ the steps to create a signature request:
|
||||||
tries to push all associated fallbacks. Use the following rules to define
|
tries to push all associated fallbacks. Use the following rules to define
|
||||||
`fallbackValidFor`:
|
`fallbackValidFor`:
|
||||||
- `fallbackValidFor` shouldn't be more than `MaxNotValidBeforeDelta` value.
|
- `fallbackValidFor` shouldn't be more than `MaxNotValidBeforeDelta` value.
|
||||||
- Use [func (*Client) GetMaxNotValidBeforeDelta](https://pkg.go.dev/github.com/nspcc-dev/neo-go@v0.97.2/pkg/rpc/client#Client.GetMaxNotValidBeforeDelta)
|
- Use [func (*Client) GetMaxNotValidBeforeDelta](https://pkg.go.dev/github.com/nspcc-dev/neo-go@v0.97.2/pkg/rpcclient#Client.GetMaxNotValidBeforeDelta)
|
||||||
to check `MaxNotValidBefore` value.
|
to check `MaxNotValidBefore` value.
|
||||||
11. Construct a script for the fallback transaction. The script may do something useful,
|
11. Construct a script for the fallback transaction. The script may do something useful,
|
||||||
i.g. invoke method of a contract. However, if you don't need to perform anything
|
i.g. invoke method of a contract. However, if you don't need to perform anything
|
||||||
special on fallback invocation, you can use simple `opcode.RET` script.
|
special on fallback invocation, you can use simple `opcode.RET` script.
|
||||||
12. Sign and submit P2P notary request. Use
|
12. Sign and submit P2P notary request. Use
|
||||||
[func (*Client) SignAndPushP2PNotaryRequest](https://pkg.go.dev/github.com/nspcc-dev/neo-go@v0.97.2/pkg/rpc/client#Client.SignAndPushP2PNotaryRequest) for it.
|
[func (*Client) SignAndPushP2PNotaryRequest](https://pkg.go.dev/github.com/nspcc-dev/neo-go@v0.97.2/pkg/rpcclient#Client.SignAndPushP2PNotaryRequest) for it.
|
||||||
- Use the signed main transaction from step 8 as `mainTx` argument.
|
- Use the signed main transaction from step 8 as `mainTx` argument.
|
||||||
- Use the fallback script from step 10 as `fallbackScript` argument.
|
- Use the fallback script from step 10 as `fallbackScript` argument.
|
||||||
- Use `-1` as `fallbackSysFee` argument to define system fee by test
|
- Use `-1` as `fallbackSysFee` argument to define system fee by test
|
||||||
|
|
|
@ -14,7 +14,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
|
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/neotest"
|
"github.com/nspcc-dev/neo-go/pkg/neotest"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/client/nns"
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/nns"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package client
|
package rpcclient
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
Package client implements NEO-specific JSON-RPC 2.0 client.
|
Package rpcclient implements NEO-specific JSON-RPC 2.0 client.
|
||||||
This package is currently in alpha and is subject to change.
|
This package is currently in beta and is subject to change.
|
||||||
|
|
||||||
Client
|
Client
|
||||||
|
|
||||||
|
@ -77,4 +77,4 @@ Unsupported methods
|
||||||
sendtoaddress
|
sendtoaddress
|
||||||
|
|
||||||
*/
|
*/
|
||||||
package client
|
package rpcclient
|
|
@ -1,4 +1,4 @@
|
||||||
package client_test
|
package rpcclient_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
@ -6,14 +6,14 @@ import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/client"
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Example() {
|
func Example() {
|
||||||
endpoint := "http://seed5.bridgeprotocol.io:10332"
|
endpoint := "http://seed5.bridgeprotocol.io:10332"
|
||||||
opts := client.Options{}
|
opts := rpcclient.Options{}
|
||||||
|
|
||||||
c, err := client.New(context.TODO(), endpoint, opts)
|
c, err := rpcclient.New(context.TODO(), endpoint, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
|
@ -1,4 +1,4 @@
|
||||||
package client
|
package rpcclient
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/elliptic"
|
"crypto/elliptic"
|
||||||
|
@ -10,7 +10,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/client/nns"
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/nns"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result"
|
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
|
|
@ -1,4 +1,4 @@
|
||||||
package client
|
package rpcclient
|
||||||
|
|
||||||
// Various non-policy things from native contracts.
|
// Various non-policy things from native contracts.
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
|
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/native/noderoles"
|
"github.com/nspcc-dev/neo-go/pkg/core/native/noderoles"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/client/nns"
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/nns"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result"
|
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
|
@ -1,4 +1,4 @@
|
||||||
package client
|
package rpcclient
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -1,4 +1,4 @@
|
||||||
package client
|
package rpcclient
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -1,4 +1,4 @@
|
||||||
package client
|
package rpcclient
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -1,4 +1,4 @@
|
||||||
package client
|
package rpcclient
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -1,4 +1,4 @@
|
||||||
package client
|
package rpcclient
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
|
@ -1,4 +1,4 @@
|
||||||
package client
|
package rpcclient
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
|
@ -1,4 +1,4 @@
|
||||||
package client
|
package rpcclient
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
|
@ -1,4 +1,4 @@
|
||||||
package client
|
package rpcclient
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
|
@ -4,13 +4,13 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/client"
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RPCClient represent an rpc client for a single node.
|
// RPCClient represent an rpc client for a single node.
|
||||||
type RPCClient struct {
|
type RPCClient struct {
|
||||||
client *client.Client
|
client *rpcclient.Client
|
||||||
addr string
|
addr string
|
||||||
close chan struct{}
|
close chan struct{}
|
||||||
finished chan struct{}
|
finished chan struct{}
|
||||||
|
@ -21,7 +21,7 @@ type RPCClient struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendMethod represents an rpc method for sending data to other nodes.
|
// SendMethod represents an rpc method for sending data to other nodes.
|
||||||
type SendMethod func(*client.Client, []interface{}) error
|
type SendMethod func(*rpcclient.Client, []interface{}) error
|
||||||
|
|
||||||
// NewRPCClient returns a new rpc client for the provided address and method.
|
// NewRPCClient returns a new rpc client for the provided address and method.
|
||||||
func (r *RPCBroadcaster) NewRPCClient(addr string, method SendMethod, timeout time.Duration, ch chan []interface{}) *RPCClient {
|
func (r *RPCBroadcaster) NewRPCClient(addr string, method SendMethod, timeout time.Duration, ch chan []interface{}) *RPCClient {
|
||||||
|
@ -38,7 +38,7 @@ func (r *RPCBroadcaster) NewRPCClient(addr string, method SendMethod, timeout ti
|
||||||
|
|
||||||
func (c *RPCClient) run() {
|
func (c *RPCClient) run() {
|
||||||
// We ignore error as not every node can be available on startup.
|
// We ignore error as not every node can be available on startup.
|
||||||
c.client, _ = client.New(context.Background(), c.addr, client.Options{
|
c.client, _ = rpcclient.New(context.Background(), c.addr, rpcclient.Options{
|
||||||
DialTimeout: c.sendTimeout,
|
DialTimeout: c.sendTimeout,
|
||||||
RequestTimeout: c.sendTimeout,
|
RequestTimeout: c.sendTimeout,
|
||||||
})
|
})
|
||||||
|
@ -50,7 +50,7 @@ run:
|
||||||
case ps := <-c.responses:
|
case ps := <-c.responses:
|
||||||
if c.client == nil {
|
if c.client == nil {
|
||||||
var err error
|
var err error
|
||||||
c.client, err = client.New(context.Background(), c.addr, client.Options{
|
c.client, err = rpcclient.New(context.Background(), c.addr, rpcclient.Options{
|
||||||
DialTimeout: c.sendTimeout,
|
DialTimeout: c.sendTimeout,
|
||||||
RequestTimeout: c.sendTimeout,
|
RequestTimeout: c.sendTimeout,
|
||||||
})
|
})
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/config"
|
"github.com/nspcc-dev/neo-go/pkg/config"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/client"
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/services/helpers/rpcbroadcaster"
|
"github.com/nspcc-dev/neo-go/pkg/services/helpers/rpcbroadcaster"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/services/oracle"
|
"github.com/nspcc-dev/neo-go/pkg/services/oracle"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
@ -33,7 +33,7 @@ func New(cfg config.OracleConfiguration, log *zap.Logger) oracle.Broadcaster {
|
||||||
RPCBroadcaster: *rpcbroadcaster.NewRPCBroadcaster(log, cfg.ResponseTimeout),
|
RPCBroadcaster: *rpcbroadcaster.NewRPCBroadcaster(log, cfg.ResponseTimeout),
|
||||||
}
|
}
|
||||||
for i := range cfg.Nodes {
|
for i := range cfg.Nodes {
|
||||||
r.Clients[cfg.Nodes[i]] = r.NewRPCClient(cfg.Nodes[i], (*client.Client).SubmitRawOracleResponse,
|
r.Clients[cfg.Nodes[i]] = r.NewRPCClient(cfg.Nodes[i], (*rpcclient.Client).SubmitRawOracleResponse,
|
||||||
cfg.ResponseTimeout, make(chan []interface{}, defaultChanCapacity))
|
cfg.ResponseTimeout, make(chan []interface{}, defaultChanCapacity))
|
||||||
}
|
}
|
||||||
return r
|
return r
|
||||||
|
|
|
@ -27,9 +27,9 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/network"
|
"github.com/nspcc-dev/neo-go/pkg/network"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/client"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/client/nns"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result"
|
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/nns"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
||||||
|
@ -48,7 +48,7 @@ func TestClient_NEP17(t *testing.T) {
|
||||||
defer chain.Close()
|
defer chain.Close()
|
||||||
defer rpcSrv.Shutdown()
|
defer rpcSrv.Shutdown()
|
||||||
|
|
||||||
c, err := client.New(context.Background(), httpSrv.URL, client.Options{})
|
c, err := rpcclient.New(context.Background(), httpSrv.URL, rpcclient.Options{})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NoError(t, c.Init())
|
require.NoError(t, c.Init())
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ func TestAddNetworkFeeCalculateNetworkFee(t *testing.T) {
|
||||||
const extraFee = 10
|
const extraFee = 10
|
||||||
var nonce uint32
|
var nonce uint32
|
||||||
|
|
||||||
c, err := client.New(context.Background(), httpSrv.URL, client.Options{})
|
c, err := rpcclient.New(context.Background(), httpSrv.URL, rpcclient.Options{})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NoError(t, c.Init())
|
require.NoError(t, c.Init())
|
||||||
|
|
||||||
|
@ -341,7 +341,7 @@ func TestCalculateNetworkFee(t *testing.T) {
|
||||||
defer rpcSrv.Shutdown()
|
defer rpcSrv.Shutdown()
|
||||||
const extraFee = 10
|
const extraFee = 10
|
||||||
|
|
||||||
c, err := client.New(context.Background(), httpSrv.URL, client.Options{})
|
c, err := rpcclient.New(context.Background(), httpSrv.URL, rpcclient.Options{})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NoError(t, c.Init())
|
require.NoError(t, c.Init())
|
||||||
|
|
||||||
|
@ -410,7 +410,7 @@ func TestSignAndPushInvocationTx(t *testing.T) {
|
||||||
defer chain.Close()
|
defer chain.Close()
|
||||||
defer rpcSrv.Shutdown()
|
defer rpcSrv.Shutdown()
|
||||||
|
|
||||||
c, err := client.New(context.Background(), httpSrv.URL, client.Options{})
|
c, err := rpcclient.New(context.Background(), httpSrv.URL, rpcclient.Options{})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NoError(t, c.Init())
|
require.NoError(t, c.Init())
|
||||||
|
|
||||||
|
@ -458,7 +458,7 @@ func TestSignAndPushInvocationTx(t *testing.T) {
|
||||||
|
|
||||||
t.Run("good", func(t *testing.T) {
|
t.Run("good", func(t *testing.T) {
|
||||||
t.Run("signer0: sig", func(t *testing.T) {
|
t.Run("signer0: sig", func(t *testing.T) {
|
||||||
h, err := c.SignAndPushInvocationTx([]byte{byte(opcode.PUSH1)}, acc0, 30, 0, []client.SignerAccount{
|
h, err := c.SignAndPushInvocationTx([]byte{byte(opcode.PUSH1)}, acc0, 30, 0, []rpcclient.SignerAccount{
|
||||||
{
|
{
|
||||||
Signer: transaction.Signer{
|
Signer: transaction.Signer{
|
||||||
Account: priv0.GetScriptHash(),
|
Account: priv0.GetScriptHash(),
|
||||||
|
@ -471,7 +471,7 @@ func TestSignAndPushInvocationTx(t *testing.T) {
|
||||||
check(t, h)
|
check(t, h)
|
||||||
})
|
})
|
||||||
t.Run("signer0: sig; signer1: sig", func(t *testing.T) {
|
t.Run("signer0: sig; signer1: sig", func(t *testing.T) {
|
||||||
h, err := c.SignAndPushInvocationTx([]byte{byte(opcode.PUSH1)}, acc0, 30, 0, []client.SignerAccount{
|
h, err := c.SignAndPushInvocationTx([]byte{byte(opcode.PUSH1)}, acc0, 30, 0, []rpcclient.SignerAccount{
|
||||||
{
|
{
|
||||||
Signer: transaction.Signer{
|
Signer: transaction.Signer{
|
||||||
Account: priv0.GetScriptHash(),
|
Account: priv0.GetScriptHash(),
|
||||||
|
@ -491,7 +491,7 @@ func TestSignAndPushInvocationTx(t *testing.T) {
|
||||||
check(t, h)
|
check(t, h)
|
||||||
})
|
})
|
||||||
t.Run("signer0: sig; signer1: contract-based paramless", func(t *testing.T) {
|
t.Run("signer0: sig; signer1: contract-based paramless", func(t *testing.T) {
|
||||||
h, err := c.SignAndPushInvocationTx([]byte{byte(opcode.PUSH1)}, acc0, 30, 0, []client.SignerAccount{
|
h, err := c.SignAndPushInvocationTx([]byte{byte(opcode.PUSH1)}, acc0, 30, 0, []rpcclient.SignerAccount{
|
||||||
{
|
{
|
||||||
Signer: transaction.Signer{
|
Signer: transaction.Signer{
|
||||||
Account: priv0.GetScriptHash(),
|
Account: priv0.GetScriptHash(),
|
||||||
|
@ -513,7 +513,7 @@ func TestSignAndPushInvocationTx(t *testing.T) {
|
||||||
})
|
})
|
||||||
t.Run("error", func(t *testing.T) {
|
t.Run("error", func(t *testing.T) {
|
||||||
t.Run("signer0: sig; signer1: contract-based with params", func(t *testing.T) {
|
t.Run("signer0: sig; signer1: contract-based with params", func(t *testing.T) {
|
||||||
_, err := c.SignAndPushInvocationTx([]byte{byte(opcode.PUSH1)}, acc0, 30, 0, []client.SignerAccount{
|
_, err := c.SignAndPushInvocationTx([]byte{byte(opcode.PUSH1)}, acc0, 30, 0, []rpcclient.SignerAccount{
|
||||||
{
|
{
|
||||||
Signer: transaction.Signer{
|
Signer: transaction.Signer{
|
||||||
Account: priv0.GetScriptHash(),
|
Account: priv0.GetScriptHash(),
|
||||||
|
@ -541,7 +541,7 @@ func TestSignAndPushInvocationTx(t *testing.T) {
|
||||||
Parameters: []wallet.ContractParam{{Name: "parameter0", Type: smartcontract.SignatureType}},
|
Parameters: []wallet.ContractParam{{Name: "parameter0", Type: smartcontract.SignatureType}},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
_, err = c.SignAndPushInvocationTx([]byte{byte(opcode.PUSH1)}, acc0, 30, 0, []client.SignerAccount{
|
_, err = c.SignAndPushInvocationTx([]byte{byte(opcode.PUSH1)}, acc0, 30, 0, []rpcclient.SignerAccount{
|
||||||
{
|
{
|
||||||
Signer: transaction.Signer{
|
Signer: transaction.Signer{
|
||||||
Account: priv0.GetScriptHash(),
|
Account: priv0.GetScriptHash(),
|
||||||
|
@ -567,7 +567,7 @@ func TestSignAndPushP2PNotaryRequest(t *testing.T) {
|
||||||
defer chain.Close()
|
defer chain.Close()
|
||||||
defer rpcSrv.Shutdown()
|
defer rpcSrv.Shutdown()
|
||||||
|
|
||||||
c, err := client.New(context.Background(), httpSrv.URL, client.Options{})
|
c, err := rpcclient.New(context.Background(), httpSrv.URL, rpcclient.Options{})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
acc, err := wallet.NewAccount()
|
acc, err := wallet.NewAccount()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -658,7 +658,7 @@ func TestCalculateNotaryFee(t *testing.T) {
|
||||||
defer chain.Close()
|
defer chain.Close()
|
||||||
defer rpcSrv.Shutdown()
|
defer rpcSrv.Shutdown()
|
||||||
|
|
||||||
c, err := client.New(context.Background(), httpSrv.URL, client.Options{})
|
c, err := rpcclient.New(context.Background(), httpSrv.URL, rpcclient.Options{})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
t.Run("client not initialized", func(t *testing.T) {
|
t.Run("client not initialized", func(t *testing.T) {
|
||||||
|
@ -671,7 +671,7 @@ func TestPing(t *testing.T) {
|
||||||
chain, rpcSrv, httpSrv := initServerWithInMemoryChain(t)
|
chain, rpcSrv, httpSrv := initServerWithInMemoryChain(t)
|
||||||
defer chain.Close()
|
defer chain.Close()
|
||||||
|
|
||||||
c, err := client.New(context.Background(), httpSrv.URL, client.Options{})
|
c, err := rpcclient.New(context.Background(), httpSrv.URL, rpcclient.Options{})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NoError(t, c.Init())
|
require.NoError(t, c.Init())
|
||||||
|
|
||||||
|
@ -686,7 +686,7 @@ func TestCreateTxFromScript(t *testing.T) {
|
||||||
defer chain.Close()
|
defer chain.Close()
|
||||||
defer rpcSrv.Shutdown()
|
defer rpcSrv.Shutdown()
|
||||||
|
|
||||||
c, err := client.New(context.Background(), httpSrv.URL, client.Options{})
|
c, err := rpcclient.New(context.Background(), httpSrv.URL, rpcclient.Options{})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NoError(t, c.Init())
|
require.NoError(t, c.Init())
|
||||||
|
|
||||||
|
@ -715,7 +715,7 @@ func TestCreateNEP17TransferTx(t *testing.T) {
|
||||||
defer chain.Close()
|
defer chain.Close()
|
||||||
defer rpcSrv.Shutdown()
|
defer rpcSrv.Shutdown()
|
||||||
|
|
||||||
c, err := client.New(context.Background(), httpSrv.URL, client.Options{})
|
c, err := rpcclient.New(context.Background(), httpSrv.URL, rpcclient.Options{})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NoError(t, c.Init())
|
require.NoError(t, c.Init())
|
||||||
|
|
||||||
|
@ -735,7 +735,7 @@ func TestCreateNEP17TransferTx(t *testing.T) {
|
||||||
require.NoError(t, ic.VM.Run())
|
require.NoError(t, ic.VM.Run())
|
||||||
})
|
})
|
||||||
t.Run("none scope", func(t *testing.T) {
|
t.Run("none scope", func(t *testing.T) {
|
||||||
_, err := c.CreateNEP17TransferTx(acc, util.Uint160{}, gasContractHash, 1000, 0, nil, []client.SignerAccount{{
|
_, err := c.CreateNEP17TransferTx(acc, util.Uint160{}, gasContractHash, 1000, 0, nil, []rpcclient.SignerAccount{{
|
||||||
Signer: transaction.Signer{
|
Signer: transaction.Signer{
|
||||||
Account: priv.PublicKey().GetScriptHash(),
|
Account: priv.PublicKey().GetScriptHash(),
|
||||||
Scopes: transaction.None,
|
Scopes: transaction.None,
|
||||||
|
@ -744,7 +744,7 @@ func TestCreateNEP17TransferTx(t *testing.T) {
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
})
|
})
|
||||||
t.Run("customcontracts scope", func(t *testing.T) {
|
t.Run("customcontracts scope", func(t *testing.T) {
|
||||||
tx, err := c.CreateNEP17TransferTx(acc, util.Uint160{}, gasContractHash, 1000, 0, nil, []client.SignerAccount{{
|
tx, err := c.CreateNEP17TransferTx(acc, util.Uint160{}, gasContractHash, 1000, 0, nil, []rpcclient.SignerAccount{{
|
||||||
Signer: transaction.Signer{
|
Signer: transaction.Signer{
|
||||||
Account: priv.PublicKey().GetScriptHash(),
|
Account: priv.PublicKey().GetScriptHash(),
|
||||||
Scopes: transaction.CustomContracts,
|
Scopes: transaction.CustomContracts,
|
||||||
|
@ -765,7 +765,7 @@ func TestInvokeVerify(t *testing.T) {
|
||||||
defer chain.Close()
|
defer chain.Close()
|
||||||
defer rpcSrv.Shutdown()
|
defer rpcSrv.Shutdown()
|
||||||
|
|
||||||
c, err := client.New(context.Background(), httpSrv.URL, client.Options{})
|
c, err := rpcclient.New(context.Background(), httpSrv.URL, rpcclient.Options{})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NoError(t, c.Init())
|
require.NoError(t, c.Init())
|
||||||
|
|
||||||
|
@ -857,7 +857,7 @@ func TestClient_GetNativeContracts(t *testing.T) {
|
||||||
defer chain.Close()
|
defer chain.Close()
|
||||||
defer rpcSrv.Shutdown()
|
defer rpcSrv.Shutdown()
|
||||||
|
|
||||||
c, err := client.New(context.Background(), httpSrv.URL, client.Options{})
|
c, err := rpcclient.New(context.Background(), httpSrv.URL, rpcclient.Options{})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NoError(t, c.Init())
|
require.NoError(t, c.Init())
|
||||||
|
|
||||||
|
@ -871,7 +871,7 @@ func TestClient_NEP11_ND(t *testing.T) {
|
||||||
defer chain.Close()
|
defer chain.Close()
|
||||||
defer rpcSrv.Shutdown()
|
defer rpcSrv.Shutdown()
|
||||||
|
|
||||||
c, err := client.New(context.Background(), httpSrv.URL, client.Options{})
|
c, err := rpcclient.New(context.Background(), httpSrv.URL, rpcclient.Options{})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NoError(t, c.Init())
|
require.NoError(t, c.Init())
|
||||||
|
|
||||||
|
@ -937,7 +937,7 @@ func TestClient_NEP11_D(t *testing.T) {
|
||||||
defer chain.Close()
|
defer chain.Close()
|
||||||
defer rpcSrv.Shutdown()
|
defer rpcSrv.Shutdown()
|
||||||
|
|
||||||
c, err := client.New(context.Background(), httpSrv.URL, client.Options{})
|
c, err := rpcclient.New(context.Background(), httpSrv.URL, rpcclient.Options{})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NoError(t, c.Init())
|
require.NoError(t, c.Init())
|
||||||
|
|
||||||
|
@ -1016,7 +1016,7 @@ func TestClient_NNS(t *testing.T) {
|
||||||
defer chain.Close()
|
defer chain.Close()
|
||||||
defer rpcSrv.Shutdown()
|
defer rpcSrv.Shutdown()
|
||||||
|
|
||||||
c, err := client.New(context.Background(), httpSrv.URL, client.Options{})
|
c, err := rpcclient.New(context.Background(), httpSrv.URL, rpcclient.Options{})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NoError(t, c.Init())
|
require.NoError(t, c.Init())
|
||||||
|
|
||||||
|
@ -1088,7 +1088,7 @@ func TestClient_IteratorSessions(t *testing.T) {
|
||||||
defer chain.Close()
|
defer chain.Close()
|
||||||
defer rpcSrv.Shutdown()
|
defer rpcSrv.Shutdown()
|
||||||
|
|
||||||
c, err := client.New(context.Background(), httpSrv.URL, client.Options{})
|
c, err := rpcclient.New(context.Background(), httpSrv.URL, rpcclient.Options{})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NoError(t, c.Init())
|
require.NoError(t, c.Init())
|
||||||
|
|
||||||
|
@ -1230,7 +1230,7 @@ func TestClient_GetNotaryServiceFeePerKey(t *testing.T) {
|
||||||
defer chain.Close()
|
defer chain.Close()
|
||||||
defer rpcSrv.Shutdown()
|
defer rpcSrv.Shutdown()
|
||||||
|
|
||||||
c, err := client.New(context.Background(), httpSrv.URL, client.Options{})
|
c, err := rpcclient.New(context.Background(), httpSrv.URL, rpcclient.Options{})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NoError(t, c.Init())
|
require.NoError(t, c.Init())
|
||||||
|
|
||||||
|
@ -1245,7 +1245,7 @@ func TestClient_GetOraclePrice(t *testing.T) {
|
||||||
defer chain.Close()
|
defer chain.Close()
|
||||||
defer rpcSrv.Shutdown()
|
defer rpcSrv.Shutdown()
|
||||||
|
|
||||||
c, err := client.New(context.Background(), httpSrv.URL, client.Options{})
|
c, err := rpcclient.New(context.Background(), httpSrv.URL, rpcclient.Options{})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NoError(t, c.Init())
|
require.NoError(t, c.Init())
|
||||||
|
|
||||||
|
@ -1260,7 +1260,7 @@ func TestClient_InvokeAndPackIteratorResults(t *testing.T) {
|
||||||
defer chain.Close()
|
defer chain.Close()
|
||||||
defer rpcSrv.Shutdown()
|
defer rpcSrv.Shutdown()
|
||||||
|
|
||||||
c, err := client.New(context.Background(), httpSrv.URL, client.Options{})
|
c, err := rpcclient.New(context.Background(), httpSrv.URL, rpcclient.Options{})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NoError(t, c.Init())
|
require.NoError(t, c.Init())
|
||||||
|
|
||||||
|
@ -1319,7 +1319,7 @@ func TestClient_Iterator_SessionConfigVariations(t *testing.T) {
|
||||||
// storageItemsCount is the amount of storage items stored in Storage contract, it's hard-coded in the contract code.
|
// storageItemsCount is the amount of storage items stored in Storage contract, it's hard-coded in the contract code.
|
||||||
const storageItemsCount = 255
|
const storageItemsCount = 255
|
||||||
|
|
||||||
checkSessionEnabled := func(t *testing.T, c *client.Client) {
|
checkSessionEnabled := func(t *testing.T, c *rpcclient.Client) {
|
||||||
// We expect Iterator with designated ID to be presented on stack. It should be possible to retrieve its values via `traverseiterator` call.
|
// We expect Iterator with designated ID to be presented on stack. It should be possible to retrieve its values via `traverseiterator` call.
|
||||||
res, err := c.InvokeFunction(storageHash, "iterateOverValues", []smartcontract.Parameter{}, nil)
|
res, err := c.InvokeFunction(storageHash, "iterateOverValues", []smartcontract.Parameter{}, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -1347,7 +1347,7 @@ func TestClient_Iterator_SessionConfigVariations(t *testing.T) {
|
||||||
require.NoError(t, chain.AddBlock(b))
|
require.NoError(t, chain.AddBlock(b))
|
||||||
}
|
}
|
||||||
|
|
||||||
c, err := client.New(context.Background(), httpSrv.URL, client.Options{})
|
c, err := rpcclient.New(context.Background(), httpSrv.URL, rpcclient.Options{})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NoError(t, c.Init())
|
require.NoError(t, c.Init())
|
||||||
|
|
||||||
|
@ -1386,7 +1386,7 @@ func TestClient_Iterator_SessionConfigVariations(t *testing.T) {
|
||||||
require.NoError(t, chain.AddBlock(b))
|
require.NoError(t, chain.AddBlock(b))
|
||||||
}
|
}
|
||||||
|
|
||||||
c, err := client.New(context.Background(), httpSrv.URL, client.Options{})
|
c, err := rpcclient.New(context.Background(), httpSrv.URL, rpcclient.Options{})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NoError(t, c.Init())
|
require.NoError(t, c.Init())
|
||||||
|
|
||||||
|
@ -1400,7 +1400,7 @@ func TestClient_Iterator_SessionConfigVariations(t *testing.T) {
|
||||||
require.NoError(t, chain.AddBlock(b))
|
require.NoError(t, chain.AddBlock(b))
|
||||||
}
|
}
|
||||||
|
|
||||||
c, err := client.New(context.Background(), httpSrv.URL, client.Options{})
|
c, err := rpcclient.New(context.Background(), httpSrv.URL, rpcclient.Options{})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NoError(t, c.Init())
|
require.NoError(t, c.Init())
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/davecgh/go-spew/spew"
|
"github.com/davecgh/go-spew/spew"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/client"
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
"github.com/pmezard/go-difflib/difflib"
|
"github.com/pmezard/go-difflib/difflib"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
|
@ -15,8 +15,8 @@ import (
|
||||||
|
|
||||||
var errStateMatches = errors.New("state matches")
|
var errStateMatches = errors.New("state matches")
|
||||||
|
|
||||||
func initClient(addr string, name string) (*client.Client, uint32, error) {
|
func initClient(addr string, name string) (*rpcclient.Client, uint32, error) {
|
||||||
c, err := client.New(context.Background(), addr, client.Options{})
|
c, err := rpcclient.New(context.Background(), addr, rpcclient.Options{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, fmt.Errorf("RPC %s: %w", name, err)
|
return nil, 0, fmt.Errorf("RPC %s: %w", name, err)
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ func initClient(addr string, name string) (*client.Client, uint32, error) {
|
||||||
return c, h, nil
|
return c, h, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getRoots(ca *client.Client, cb *client.Client, h uint32) (util.Uint256, util.Uint256, error) {
|
func getRoots(ca *rpcclient.Client, cb *rpcclient.Client, h uint32) (util.Uint256, util.Uint256, error) {
|
||||||
ra, err := ca.GetStateRootByHeight(h)
|
ra, err := ca.GetStateRootByHeight(h)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return util.Uint256{}, util.Uint256{}, fmt.Errorf("getstateroot from A for %d: %w", h, err)
|
return util.Uint256{}, util.Uint256{}, fmt.Errorf("getstateroot from A for %d: %w", h, err)
|
||||||
|
@ -43,7 +43,7 @@ func getRoots(ca *client.Client, cb *client.Client, h uint32) (util.Uint256, uti
|
||||||
return ra.Root, rb.Root, nil
|
return ra.Root, rb.Root, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func bisectState(ca *client.Client, cb *client.Client, h uint32) (uint32, error) {
|
func bisectState(ca *rpcclient.Client, cb *rpcclient.Client, h uint32) (uint32, error) {
|
||||||
ra, rb, err := getRoots(ca, cb, 0)
|
ra, rb, err := getRoots(ca, cb, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
|
|
Loading…
Reference in a new issue