This library was originally incentivized by ICDevs. You can view more about the bounty on the forum or website. The bounty was funded by The ICDevs.org commuity and the award paid to @Gekctek. If you use this library and gain value from it, please consider a donation to ICDevs.
This is a library that enables encoding/decoding of bytes to candid values
mops install candid
To setup MOPS package manage, follow the instructions from the MOPS Site
let encodedArgs : Blob = ...;
let ?args: ?[Arg.Arg] = Decoder.decode(encodedArgs) else Debug.trap("Invalid candid");
let returnArgs: [Arg.Arg] = [
{
type_=#bool;
value=#bool(true)
}
];
let encodedArgs : Blob = Encoder.encode(returnArgs);
decode(candidBytes: Blob) : ?[Arg.Arg]
Decodes a series of bytes to CandiArgs. If invalid candid bytes, will return null
encode(args: [Arg.Arg]) : Blob
Encodes an array of candid arguments to bytes
encodeToBuffer(buffer : Buffer.Buffer<Nat8>, args : [Arg.Arg]) : ()
Encodes an array of candid arguments to a byte buffer
hash(t : Tag) : Nat32
Hashes a tag name to a Nat32. If already hashed, will use hash value
hashName(name : Text) : Nat32
Hashes a tag name to a Nat32
equal(t1: Tag, t2: Tag) : Bool
Checks for equality between two tags
compare(t1: Tag, t2: Tag) : Order.Order
Compares order between two tags
equal(v1: Type, v2: Type): Bool
Checks for equality between two types
hash(t : Type) : Hash.Hash
Hashes a type to a Nat32
equal(v1: Value, v2: Value): Bool
Checks for equality between two values
mops test
- Opaque reference byte encoding/decoding
- Error messaging vs null return type for decoding
- Better/Documented error messages
- More test cases