From 79e11c93a1f99170417b5a1a3f6a63084cb87cdc Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 27 Jan 2021 22:32:29 +0300 Subject: [PATCH] cli: allow to specify cosigners with Neo addresses Make it a bit more usable. --- cli/contract_test.go | 3 +++ cli/smartcontract/smart_contract.go | 14 +++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/cli/contract_test.go b/cli/contract_test.go index 556dd5cc7..be5d7d24b 100644 --- a/cli/contract_test.go +++ b/cli/contract_test.go @@ -187,6 +187,9 @@ func TestComlileAndInvokeFunction(t *testing.T) { e.Run(t, "neo-go", "contract", "testinvokescript", "--rpc-endpoint", "http://"+e.RPC.Addr, "--in", nefName, "--", util.Uint160{1, 2, 3}.StringLE()) + e.Run(t, "neo-go", "contract", "testinvokescript", + "--rpc-endpoint", "http://"+e.RPC.Addr, + "--in", nefName, "--", address.Uint160ToString(util.Uint160{1, 2, 3})) e.In.WriteString("one\r") e.Run(t, "neo-go", "contract", "deploy", diff --git a/cli/smartcontract/smart_contract.go b/cli/smartcontract/smart_contract.go index 2145df0da..790fb9ec1 100644 --- a/cli/smartcontract/smart_contract.go +++ b/cli/smartcontract/smart_contract.go @@ -266,8 +266,8 @@ func NewCommands() []cli.Command { Signers represent a set of Uint160 hashes with witness scopes and are used to verify hashes in System.Runtime.CheckWitness syscall. First signer is treated as a sender. To specify signers use signer[:scope] syntax where - * 'signer' is hex-encoded 160 bit (20 byte) LE value of signer's address, - which could have '0x' prefix. + * 'signer' is a signer's address (as Neo address or hex-encoded 160 bit (20 byte) + LE value with or without '0x' prefix). * 'scope' is a comma-separated set of cosigner's scopes, which could be: - 'None' - default witness scope which may be used for the sender to only pay fee for the transaction. @@ -286,9 +286,9 @@ func NewCommands() []cli.Command { neo-go RPC server only. C# implementation does not support scopes capability. Examples: - * '0000000009070e030d0f0e020d0c06050e030c02' + * 'NNQk4QXsxvsrr3GSozoWBUxEmfag7B6hz5' + * 'NVquyZHoPirw6zAEPvY1ZezxM493zMWQqs:Global' * '0x0000000009070e030d0f0e020d0c06050e030c02' - * '0x0000000009070e030d0f0e020d0c06050e030c02:Global' * '0000000009070e030d0f0e020d0c06050e030c02:CalledByEntry,CustomGroups' `, Action: testInvokeFunction, @@ -888,7 +888,11 @@ func parseCosigner(c string) (transaction.Signer, error) { if len(s) == 2*util.Uint160Size+2 && s[0:2] == "0x" { s = s[2:] } - res.Account, err = util.Uint160DecodeStringLE(s) + if len(s) == util.Uint160Size*2 { + res.Account, err = util.Uint160DecodeStringLE(s) + } else { + res.Account, err = address.StringToUint160(s) + } if err != nil { return res, err }