Skip to content

Commit

Permalink
Merge pull request #3425 from jorgemmsilva/impr/acc-dump-json
Browse files Browse the repository at this point in the history
fix: improve accounts-dump json format
  • Loading branch information
jorgemmsilva authored Jun 3, 2024
2 parents 7eb8c58 + 165f3a3 commit 41f8a66
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions packages/isc/request_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ func RequestToJSONObject(request Request) RequestJSON {
gasBudget, isEVM := request.GasBudget()

return RequestJSON{
Allowance: assetsToJSONObject(request.Allowance()),
Allowance: AssetsToJSONObject(request.Allowance()),
CallTarget: callTargetToJSONObject(request.CallTarget()),
Assets: assetsToJSONObject(request.Assets()),
Assets: AssetsToJSONObject(request.Assets()),
GasBudget: strconv.FormatUint(gasBudget, 10),
IsEVM: isEVM,
IsOffLedger: request.IsOffLedger(),
Expand All @@ -53,7 +53,7 @@ type AssetsJSON struct {
NFTs []string `json:"nfts" swagger:"required"`
}

func assetsToJSONObject(assets *Assets) *AssetsJSON {
func AssetsToJSONObject(assets *Assets) *AssetsJSON {
if assets == nil {
return nil
}
Expand Down
3 changes: 2 additions & 1 deletion packages/webapi/controllers/chain/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

iotago "github.com/iotaledger/iota.go/v3"
"github.com/iotaledger/wasp/packages/chain"
"github.com/iotaledger/wasp/packages/isc"
"github.com/iotaledger/wasp/packages/kv"
"github.com/iotaledger/wasp/packages/vm/core/accounts"
"github.com/iotaledger/wasp/packages/webapi/apierrors"
Expand Down Expand Up @@ -201,7 +202,7 @@ func (c *Controller) dumpAccounts(e echo.Context) error {
accKey := kv.Key(key)
agentID := lo.Must(accounts.AgentIDFromKey(accKey, ch.ID()))
accountAssets := sa.AssetsOwnedBy(accKey, agentID)
assetsJSON, err2 := json.Marshal(accountAssets)
assetsJSON, err2 := json.Marshal(isc.AssetsToJSONObject(accountAssets))
if err2 != nil {
c.log.Errorf("dumpAccounts - generating JSON for account %s assets failed%s", agentID.String(), err2.Error())
return false
Expand Down

0 comments on commit 41f8a66

Please sign in to comment.