Skip to content
This repository has been archived by the owner on Jan 25, 2021. It is now read-only.

Commit

Permalink
Argument fixes and moved some of the parsing logic into the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Wyatt Mufson committed Jan 28, 2019
1 parent d773808 commit 1afcc06
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
17 changes: 4 additions & 13 deletions neoutils/ont.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ func ClaimONG(endpoint string, gasPrice int, gasLimit int, wif string) (string,
return txid, nil
}

func BuildOntologyInvocationTransaction(contractHex string, operation string, argString string, gasPrice uint, gasLimit uint, wif string) (string, error) {
raw, err := ontmobile.BuildInvocationTransaction(contractHex, operation, argString, gasPrice, gasLimit, wif)
func BuildOntologyInvocationTransaction(contract string, method string, args string, gasPrice int, gasLimit int, wif string) (string, error) {
raw, err := ontmobile.BuildInvocationTransaction(contract, method, args, uint(gasPrice), uint(gasLimit), wif)
if err != nil {
return "", err
}
Expand All @@ -45,8 +45,8 @@ func BuildOntologyInvocationTransaction(contractHex string, operation string, ar
}

// OntologyInvoke : Invoke a neovm contract in Ontology
func OntologyInvoke(endpoint string, contractHex string, operation string, argString string, gasPrice uint, gasLimit uint, wif string) (string, error) {
raw, err := ontmobile.BuildInvocationTransaction(contractHex, operation, argString, gasPrice, gasLimit, wif)
func OntologyInvoke(endpoint string, contract string, method string, args string, gasPrice int, gasLimit int, wif string) (string, error) {
raw, err := ontmobile.BuildInvocationTransaction(contract, method, args, uint(gasPrice), uint(gasLimit), wif)
if err != nil {
return "", err
}
Expand All @@ -58,12 +58,3 @@ func OntologyInvoke(endpoint string, contractHex string, operation string, argSt

return txid, nil
}

type ParameterJSONArrayForm struct {
A []ParameterJSONForm `json:"array"`
}

type ParameterJSONForm struct {
T string `json:"type"`
V interface{} `json:"value"`
}
29 changes: 19 additions & 10 deletions neoutils/ont_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ import (
"github.com/o3labs/neo-utils/neoutils"
)

type parameterJSONArrayForm struct {
A []parameterJSONForm `json:"array"`
}

type parameterJSONForm struct {
T string `json:"type"`
V interface{} `json:"value"`
}

func TestONTTransfer(t *testing.T) {

for i := 1; i <= 100; i++ {
Expand Down Expand Up @@ -60,15 +69,15 @@ func TestBuildOntologyInvocation(t *testing.T) {
account, _ := neoutils.GenerateFromWIF(wif)
address := account.Address

addr := neoutils.ParameterJSONForm{T: "Address", V: address}
val := neoutils.ParameterJSONForm{T: "String", V: "Hi there"}
addr := parameterJSONForm{T: "Address", V: address}
val := parameterJSONForm{T: "String", V: "Hi there"}

jsondat := &neoutils.ParameterJSONArrayForm{A: []neoutils.ParameterJSONForm{addr, val}}
jsondat := &parameterJSONArrayForm{A: []parameterJSONForm{addr, val}}
argData, _ := json.Marshal(jsondat)
argString := string(argData)

gasPrice := uint(500)
gasLimit := uint(20000)
gasPrice := int(500)
gasLimit := int(20000)

txData, err := neoutils.BuildOntologyInvocationTransaction("c168e0fb1a2bddcd385ad013c2c98358eca5d4dc", "put", argString, gasPrice, gasLimit, wif)
if err != nil {
Expand All @@ -89,15 +98,15 @@ func TestOntologyInvoke(t *testing.T) {
account, _ := neoutils.GenerateFromWIF(wif)
address := account.Address

addr := neoutils.ParameterJSONForm{T: "Address", V: address}
val := neoutils.ParameterJSONForm{T: "String", V: "Hi there"}
addr := parameterJSONForm{T: "Address", V: address}
val := parameterJSONForm{T: "String", V: "Hi there"}

jsondat := &neoutils.ParameterJSONArrayForm{A: []neoutils.ParameterJSONForm{addr, val}}
jsondat := &parameterJSONArrayForm{A: []parameterJSONForm{addr, val}}
argData, _ := json.Marshal(jsondat)
argString := string(argData)

gasPrice := uint(500)
gasLimit := uint(20000)
gasPrice := int(500)
gasLimit := int(20000)

endpoint := "http://polaris2.ont.io:20336"

Expand Down

0 comments on commit 1afcc06

Please sign in to comment.