Skip to content

Commit

Permalink
fix getapplicationlog
Browse files Browse the repository at this point in the history
  • Loading branch information
joeqian10 committed Apr 21, 2021
1 parent b47d2f1 commit 939a38c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
27 changes: 11 additions & 16 deletions rpc/models/rpcApplicationLog.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,20 @@ type RpcApplicationLog struct {
}

type RpcExecution struct {
Trigger string `json:"trigger"`
Contract string `json:"contract"`
VMState string `json:"vmstate"`
GasConsumed string `json:"gas_consumed"`
Stack []RpcContractParameter `json:"stack"`
Notifications []RpcNotification `json:"notifications"`
}

type RpcContractParameter struct {
Type string `json:"type"`
Value string `json:"value"`
}

type RpcState struct {
Type string `json:"type"`
Value []RpcContractParameter `json:"value"`
Trigger string `json:"trigger"`
Contract string `json:"contract"`
VMState string `json:"vmstate"`
GasConsumed string `json:"gas_consumed"`
Stack []InvokeStack `json:"stack"`
Notifications []RpcNotification `json:"notifications"`
}

type RpcNotification struct {
Contract string `json:"contract"`
State RpcState `json:"state"`
}

type RpcState struct {
Type string `json:"type"`
Value []InvokeStack `json:"value"`
}
17 changes: 15 additions & 2 deletions rpc/models/rpcInvoke.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package models

import "strconv"

type InvokeResult struct {
Script string `json:"script"`
State string `json:"state"`
Expand All @@ -14,9 +16,20 @@ type InvokeStack struct {
}

// Convert converts interface{} "Value" to string or []InvokeStack depending on the "Type"
func (s *InvokeStack) Convert() {
func (s *InvokeStack) Convert() {
if s.Type != "Array" {
s.Value = s.Value.(string)
switch s.Type {
case "Boolean":
if b, ok := s.Value.(bool); ok {
s.Value = strconv.FormatBool(b)
}
break
case "Integer":
if num, ok := s.Value.(int); ok {
s.Value = strconv.Itoa(num)
}
break
}
} else {
vs := s.Value.([]interface{})
result := make([]InvokeStack, len(vs))
Expand Down

0 comments on commit 939a38c

Please sign in to comment.