Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@dfinity/candid

Package Overview
Dependencies
Maintainers
10
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dfinity/candid - npm Package Compare versions

Comparing version 0.10.4 to 0.11.0

23

lib/cjs/idl.d.ts

@@ -93,2 +93,20 @@ import { Principal as PrincipalId } from '@dfinity/principal';

/**
* Represents an IDL Unknown, a placeholder type for deserialization only.
* When decoding a value as Unknown, all fields will be retained but the names are only available in
* hashed form.
* A deserialized unknown will offer it's actual type by calling the `type()` function.
* Unknown cannot be serialized and attempting to do so will throw an error.
*/
export declare class UnknownClass extends Type {
checkType(t: Type): Type;
accept<D, R>(v: Visitor<D, R>, d: D): R;
covariant(x: any): x is any;
encodeValue(): never;
valueToString(): never;
encodeType(): never;
decodeValue(b: Pipe, t: Type): any;
protected _buildTypeTableImpl(): void;
get name(): string;
}
/**
* Represents an IDL Bool

@@ -371,2 +389,3 @@ */

Reserved: ReservedClass;
Unknown: UnknownClass;
Bool: BoolClass;

@@ -400,2 +419,6 @@ Null: NullClass;

export declare const Reserved: ReservedClass;
/**
* Client-only type for deserializing unknown data. Not supported by Candid, and its use is discouraged.
*/
export declare const Unknown: UnknownClass;
export declare const Bool: BoolClass;

@@ -402,0 +425,0 @@ export declare const Null: NullClass;

69

lib/cjs/idl.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Func = exports.Rec = exports.Variant = exports.Record = exports.Opt = exports.Vec = exports.Tuple = exports.Principal = exports.Nat64 = exports.Nat32 = exports.Nat16 = exports.Nat8 = exports.Int64 = exports.Int32 = exports.Int16 = exports.Int8 = exports.Float64 = exports.Float32 = exports.Nat = exports.Int = exports.Text = exports.Null = exports.Bool = exports.Reserved = exports.Empty = exports.decode = exports.encode = exports.ServiceClass = exports.FuncClass = exports.PrincipalClass = exports.RecClass = exports.VariantClass = exports.TupleClass = exports.RecordClass = exports.OptClass = exports.VecClass = exports.FixedNatClass = exports.FixedIntClass = exports.FloatClass = exports.NatClass = exports.IntClass = exports.TextClass = exports.ReservedClass = exports.NullClass = exports.BoolClass = exports.EmptyClass = exports.ConstructType = exports.PrimitiveType = exports.Type = exports.Visitor = void 0;
exports.Service = void 0;
exports.Variant = exports.Record = exports.Opt = exports.Vec = exports.Tuple = exports.Principal = exports.Nat64 = exports.Nat32 = exports.Nat16 = exports.Nat8 = exports.Int64 = exports.Int32 = exports.Int16 = exports.Int8 = exports.Float64 = exports.Float32 = exports.Nat = exports.Int = exports.Text = exports.Null = exports.Bool = exports.Unknown = exports.Reserved = exports.Empty = exports.decode = exports.encode = exports.ServiceClass = exports.FuncClass = exports.PrincipalClass = exports.RecClass = exports.VariantClass = exports.TupleClass = exports.RecordClass = exports.OptClass = exports.VecClass = exports.FixedNatClass = exports.FixedIntClass = exports.FloatClass = exports.NatClass = exports.IntClass = exports.TextClass = exports.ReservedClass = exports.NullClass = exports.BoolClass = exports.UnknownClass = exports.EmptyClass = exports.ConstructType = exports.PrimitiveType = exports.Type = exports.Visitor = void 0;
exports.Service = exports.Func = exports.Rec = void 0;
// tslint:disable:max-classes-per-file

@@ -209,2 +209,63 @@ const principal_1 = require("@dfinity/principal");

/**
* Represents an IDL Unknown, a placeholder type for deserialization only.
* When decoding a value as Unknown, all fields will be retained but the names are only available in
* hashed form.
* A deserialized unknown will offer it's actual type by calling the `type()` function.
* Unknown cannot be serialized and attempting to do so will throw an error.
*/
class UnknownClass extends Type {
checkType(t) {
throw new Error('Method not implemented for unknown.');
}
accept(v, d) {
throw v.visitType(this, d);
}
covariant(x) {
return false;
}
encodeValue() {
throw new Error('Unknown cannot appear as a function argument');
}
valueToString() {
throw new Error('Unknown cannot appear as a value');
}
encodeType() {
throw new Error('Unknown cannot be serialized');
}
decodeValue(b, t) {
let decodedValue = t.decodeValue(b, t);
if (Object(decodedValue) !== decodedValue) {
// decodedValue is primitive. Box it, otherwise we cannot add the type() function.
// The type() function is important for primitives because otherwise we cannot tell apart the
// different number types.
decodedValue = Object(decodedValue);
}
let typeFunc;
if (t instanceof RecClass) {
typeFunc = () => t.getType();
}
else {
typeFunc = () => t;
}
// Do not use 'decodedValue.type = typeFunc' because this would lead to an enumerable property
// 'type' which means it would be serialized if the value would be candid encoded again.
// This in turn leads to problems if the decoded value is a variant because these values are
// only allowed to have a single property.
Object.defineProperty(decodedValue, 'type', {
value: typeFunc,
writable: true,
enumerable: false,
configurable: true,
});
return decodedValue;
}
_buildTypeTableImpl() {
throw new Error('Unknown cannot be serialized');
}
get name() {
return 'Unknown';
}
}
exports.UnknownClass = UnknownClass;
/**
* Represents an IDL Bool

@@ -1340,2 +1401,6 @@ */

exports.Reserved = new ReservedClass();
/**
* Client-only type for deserializing unknown data. Not supported by Candid, and its use is discouraged.
*/
exports.Unknown = new UnknownClass();
exports.Bool = new BoolClass();

@@ -1342,0 +1407,0 @@ exports.Null = new NullClass();

@@ -93,2 +93,20 @@ import { Principal as PrincipalId } from '@dfinity/principal';

/**
* Represents an IDL Unknown, a placeholder type for deserialization only.
* When decoding a value as Unknown, all fields will be retained but the names are only available in
* hashed form.
* A deserialized unknown will offer it's actual type by calling the `type()` function.
* Unknown cannot be serialized and attempting to do so will throw an error.
*/
export declare class UnknownClass extends Type {
checkType(t: Type): Type;
accept<D, R>(v: Visitor<D, R>, d: D): R;
covariant(x: any): x is any;
encodeValue(): never;
valueToString(): never;
encodeType(): never;
decodeValue(b: Pipe, t: Type): any;
protected _buildTypeTableImpl(): void;
get name(): string;
}
/**
* Represents an IDL Bool

@@ -371,2 +389,3 @@ */

Reserved: ReservedClass;
Unknown: UnknownClass;
Bool: BoolClass;

@@ -400,2 +419,6 @@ Null: NullClass;

export declare const Reserved: ReservedClass;
/**
* Client-only type for deserializing unknown data. Not supported by Candid, and its use is discouraged.
*/
export declare const Unknown: UnknownClass;
export declare const Bool: BoolClass;

@@ -402,0 +425,0 @@ export declare const Null: NullClass;

@@ -200,2 +200,62 @@ // tslint:disable:max-classes-per-file

/**
* Represents an IDL Unknown, a placeholder type for deserialization only.
* When decoding a value as Unknown, all fields will be retained but the names are only available in
* hashed form.
* A deserialized unknown will offer it's actual type by calling the `type()` function.
* Unknown cannot be serialized and attempting to do so will throw an error.
*/
export class UnknownClass extends Type {
checkType(t) {
throw new Error('Method not implemented for unknown.');
}
accept(v, d) {
throw v.visitType(this, d);
}
covariant(x) {
return false;
}
encodeValue() {
throw new Error('Unknown cannot appear as a function argument');
}
valueToString() {
throw new Error('Unknown cannot appear as a value');
}
encodeType() {
throw new Error('Unknown cannot be serialized');
}
decodeValue(b, t) {
let decodedValue = t.decodeValue(b, t);
if (Object(decodedValue) !== decodedValue) {
// decodedValue is primitive. Box it, otherwise we cannot add the type() function.
// The type() function is important for primitives because otherwise we cannot tell apart the
// different number types.
decodedValue = Object(decodedValue);
}
let typeFunc;
if (t instanceof RecClass) {
typeFunc = () => t.getType();
}
else {
typeFunc = () => t;
}
// Do not use 'decodedValue.type = typeFunc' because this would lead to an enumerable property
// 'type' which means it would be serialized if the value would be candid encoded again.
// This in turn leads to problems if the decoded value is a variant because these values are
// only allowed to have a single property.
Object.defineProperty(decodedValue, 'type', {
value: typeFunc,
writable: true,
enumerable: false,
configurable: true,
});
return decodedValue;
}
_buildTypeTableImpl() {
throw new Error('Unknown cannot be serialized');
}
get name() {
return 'Unknown';
}
}
/**
* Represents an IDL Bool

@@ -1311,2 +1371,6 @@ */

export const Reserved = new ReservedClass();
/**
* Client-only type for deserializing unknown data. Not supported by Candid, and its use is discouraged.
*/
export const Unknown = new UnknownClass();
export const Bool = new BoolClass();

@@ -1313,0 +1377,0 @@ export const Null = new NullClass();

3

package.json
{
"name": "@dfinity/candid",
"version": "0.10.4",
"version": "0.11.0",
"author": "DFINITY Stiftung <sdk@dfinity.org>",

@@ -48,3 +48,2 @@ "license": "Apache-2.0",

"jest-diff": "^27.3.1",
"jest-expect-message": "^1.0.2",
"node-fetch": "^2.6.7",

@@ -51,0 +50,0 @@ "prettier": "^2.0.5",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc