-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: canister call accepts --output json (#3663)
this is the same as dfx canister call ... | idl2json See: https://github.com/dfinity/idl2json Fixes: https://dfinity.atlassian.net/browse/SDK-1370
- Loading branch information
1 parent
731ac56
commit b0405ba
Showing
9 changed files
with
234 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"canisters": { | ||
"hello_backend": { | ||
"type": "motoko", | ||
"main": "main.mo" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import Text "mo:base/Text"; | ||
|
||
actor { | ||
public query func returns_string(name: Text) : async Text { | ||
return "Hello, " # name # "!"; | ||
}; | ||
|
||
public query func returns_opt_string(name: ?Text) : async ?Text { | ||
return switch (name) { | ||
case null null; | ||
case (?x) ?("Hello, " # x # "!"); | ||
}; | ||
}; | ||
|
||
public query func returns_int(v: Int) : async Int { | ||
return v; | ||
}; | ||
|
||
public query func returns_int32(v: Int32) : async Int32 { | ||
return v; | ||
}; | ||
|
||
public query func returns_principal(p: Principal) : async Principal { | ||
return p; | ||
}; | ||
|
||
public query func returns_strings() : async [Text] { | ||
return ["Hello, world!", "Hello, Mars!"]; | ||
}; | ||
|
||
type ObjectReturnType = { | ||
foo: Text; | ||
bar: Int; | ||
}; | ||
|
||
public query func returns_object() : async ObjectReturnType { | ||
return {foo = "baz"; bar = 42}; | ||
}; | ||
|
||
type VariantType = { #foo; #bar : Text; #baz : { a : Int32 }; }; | ||
public query func returns_variant(i: Nat) : async VariantType { | ||
if (i == 0) { | ||
return #foo; | ||
} else if (i == 1) { | ||
return #bar("a bar"); | ||
} else { | ||
return #baz({a = 51}); | ||
} | ||
}; | ||
|
||
public query func returns_blob(s: Text): async Blob { | ||
return Text.encodeUtf8(s); | ||
}; | ||
|
||
public query func returns_tuple(): async (Text, Nat32, Text) { | ||
return ("the first element", 42, "the third element"); | ||
}; | ||
|
||
public query func returns_single_elem_tuple(): async (Text) { | ||
return ("the only element"); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters