mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-26 09:42:22 +00:00
vm/cli: add support for loadbase64 command
Neo3 outputs scripts in base64 for transactions and contracts, to quickly parse them add a special `loadbase64` command.
This commit is contained in:
parent
3d6ff3559e
commit
5d63ff100e
1 changed files with 21 additions and 0 deletions
|
@ -2,6 +2,7 @@ package cli
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
@ -73,6 +74,14 @@ var commands = []*ishell.Cmd{
|
|||
> load /path/to/script.avm`,
|
||||
Func: handleLoadAVM,
|
||||
},
|
||||
{
|
||||
Name: "loadbase64",
|
||||
Help: "Load a base64-encoded script string into the VM",
|
||||
LongHelp: `Usage: loadbase64 <string>
|
||||
<string> is mandatory parameter, example:
|
||||
> loadbase64 AwAQpdToAAAADBQV9ehtQR1OrVZVhtHtoUHRfoE+agwUzmFvf3Rhfg/EuAVYOvJgKiON9j8TwAwIdHJhbnNmZXIMFDt9NxHG8Mz5sdypA9G/odiW8SOMQWJ9W1I4`,
|
||||
Func: handleLoadBase64,
|
||||
},
|
||||
{
|
||||
Name: "loadhex",
|
||||
Help: "Load a hex-encoded script string into the VM",
|
||||
|
@ -242,6 +251,18 @@ func handleLoadAVM(c *ishell.Context) {
|
|||
changePrompt(c, v)
|
||||
}
|
||||
|
||||
func handleLoadBase64(c *ishell.Context) {
|
||||
v := getVMFromContext(c)
|
||||
b, err := base64.StdEncoding.DecodeString(c.Args[0])
|
||||
if err != nil {
|
||||
c.Err(err)
|
||||
return
|
||||
}
|
||||
v.Load(b)
|
||||
c.Printf("READY: loaded %d instructions\n", v.Context().LenInstr())
|
||||
changePrompt(c, v)
|
||||
}
|
||||
|
||||
func handleLoadHex(c *ishell.Context) {
|
||||
v := getVMFromContext(c)
|
||||
b, err := hex.DecodeString(c.Args[0])
|
||||
|
|
Loading…
Reference in a new issue