Skip to content

Commit

Permalink
Format result as candid values
Browse files Browse the repository at this point in the history
  • Loading branch information
ninegua committed Jun 18, 2021
1 parent 9e0e7e4 commit 09a8768
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/bare-agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,10 @@ async function try_decode(canister_id, method_name, reply) {
let mod = await eval('import("' + dataUri + '")');
let services = mod.default({ IDL });
let func = lookup(services._fields, method_name);
if (func) {
reply.reply = IDL.decode(
func.retTypes,
Buffer.from(reply.reply.arg)
);
}
reply = IDL.decode(func.retTypes, Buffer.from(reply.reply.arg));
reply = func.retTypes
.map((t, i) => t.valueToString(reply[i]))
.toString();
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@
margin: 10px auto;
display: block;
}
pre {
overflow-x: auto;
white-space: pre-wrap;
white-space: -moz-pre-wrap;
white-space: -pre-wrap;
white-space: -o-pre-wrap;
word-wrap: break-word;
}
</style>
</head>
<body>
Expand Down

0 comments on commit 09a8768

Please sign in to comment.