@onflow/types
Advanced tools
Comparing version 1.3.0 to 1.4.0
# @onflow/types | ||
## 1.4.0 | ||
### Minor Changes | ||
- [#1863](https://github.com/onflow/fcl-js/pull/1863) [`7ef7edf1`](https://github.com/onflow/fcl-js/commit/7ef7edf1e134041da944f24f49e661caadcc7074) Thanks [@jribbink](https://github.com/jribbink)! - Update SDK encoding/decoding for Cadence 1.0 JSON-CDC changes | ||
## 1.3.0 | ||
@@ -4,0 +10,0 @@ |
@@ -8,2 +8,6 @@ 'use strict'; | ||
/** | ||
* @deprecated Reference values cannot be imported into the Cadence interpreter, will be removed in future versions | ||
*/ | ||
/** | ||
* Creates a type descriptor for a given type | ||
@@ -353,2 +357,34 @@ * @param label - The label for the type | ||
}, v => v); | ||
const Word128 = typedef("Word128", v => { | ||
if (isNumber(v) && isInteger(v)) { | ||
numberValuesDeprecationNotice("Word128"); | ||
return { | ||
type: "Word128", | ||
value: v.toString() | ||
}; | ||
} | ||
if (isString(v)) { | ||
return { | ||
type: "Word128", | ||
value: v | ||
}; | ||
} | ||
return throwTypeError("Expected positive number for Word128"); | ||
}, v => v); | ||
const Word256 = typedef("Word256", v => { | ||
if (isNumber(v) && isInteger(v)) { | ||
numberValuesDeprecationNotice("Word256"); | ||
return { | ||
type: "Word256", | ||
value: v.toString() | ||
}; | ||
} | ||
if (isString(v)) { | ||
return { | ||
type: "Word256", | ||
value: v | ||
}; | ||
} | ||
return throwTypeError("Expected positive number for Word256"); | ||
}, v => v); | ||
const UFix64AndFix64NumberDeprecationNotice = () => { | ||
@@ -452,2 +488,6 @@ utilLogger.log.deprecate({ | ||
}), v => v); | ||
/** | ||
* @deprecated Reference values cannot be imported into the Cadence interpreter, will be removed in future versions | ||
*/ | ||
const Reference = typedef("Reference", v => { | ||
@@ -588,2 +628,35 @@ if (isObj(v)) return { | ||
/** | ||
* InclusiveRange type | ||
* | ||
* @param t - A TypeDescriptor for the type of the range, must be a number (UInt32, Int32, etc.) | ||
* @returns A TypeDescriptor for an InclusiveRange of the given type | ||
* | ||
* @example | ||
* ```javascript | ||
* import * as fcl from "@onflow/fcl" | ||
* import {InclusiveRange, UInt32} from "@onflow/types" | ||
* | ||
* const someArg = fcl.arg({start: 1, end: 5, step: 1}, InclusiveRange(UInt32)) | ||
* ``` | ||
*/ | ||
const InclusiveRange = t => typedef("InclusiveRange", v => { | ||
if (isObj(v)) { | ||
const { | ||
start, | ||
end, | ||
step | ||
} = v; | ||
return { | ||
type: "InclusiveRange", | ||
value: { | ||
start: t.asArgument(start), | ||
end: t.asArgument(end), | ||
step: t.asArgument(step) | ||
} | ||
}; | ||
} | ||
return throwTypeError("Expected Object for type InclusiveRange"); | ||
}, v => v); | ||
exports.Address = Address; | ||
@@ -598,2 +671,3 @@ exports.Array = _Array; | ||
exports.Identity = Identity; | ||
exports.InclusiveRange = InclusiveRange; | ||
exports.Int = Int; | ||
@@ -621,3 +695,5 @@ exports.Int128 = Int128; | ||
exports.Void = Void; | ||
exports.Word128 = Word128; | ||
exports.Word16 = Word16; | ||
exports.Word256 = Word256; | ||
exports.Word32 = Word32; | ||
@@ -624,0 +700,0 @@ exports.Word64 = Word64; |
import { log } from '@onflow/util-logger'; | ||
/** | ||
* @deprecated Reference values cannot be imported into the Cadence interpreter, will be removed in future versions | ||
*/ | ||
/** | ||
* Creates a type descriptor for a given type | ||
@@ -348,2 +352,34 @@ * @param label - The label for the type | ||
}, v => v); | ||
const Word128 = typedef("Word128", v => { | ||
if (isNumber(v) && isInteger(v)) { | ||
numberValuesDeprecationNotice("Word128"); | ||
return { | ||
type: "Word128", | ||
value: v.toString() | ||
}; | ||
} | ||
if (isString(v)) { | ||
return { | ||
type: "Word128", | ||
value: v | ||
}; | ||
} | ||
return throwTypeError("Expected positive number for Word128"); | ||
}, v => v); | ||
const Word256 = typedef("Word256", v => { | ||
if (isNumber(v) && isInteger(v)) { | ||
numberValuesDeprecationNotice("Word256"); | ||
return { | ||
type: "Word256", | ||
value: v.toString() | ||
}; | ||
} | ||
if (isString(v)) { | ||
return { | ||
type: "Word256", | ||
value: v | ||
}; | ||
} | ||
return throwTypeError("Expected positive number for Word256"); | ||
}, v => v); | ||
const UFix64AndFix64NumberDeprecationNotice = () => { | ||
@@ -447,2 +483,6 @@ log.deprecate({ | ||
}), v => v); | ||
/** | ||
* @deprecated Reference values cannot be imported into the Cadence interpreter, will be removed in future versions | ||
*/ | ||
const Reference = typedef("Reference", v => { | ||
@@ -583,3 +623,36 @@ if (isObj(v)) return { | ||
export { Address, _Array as Array, Bool, Character, Dictionary, Enum, Event, Fix64, Identity, Int, Int128, Int16, Int256, Int32, Int64, Int8, Optional, Path, Reference, Resource, String, Struct, UFix64, UInt, UInt128, UInt16, UInt256, UInt32, UInt64, UInt8, Void, Word16, Word32, Word64, Word8, _Array }; | ||
/** | ||
* InclusiveRange type | ||
* | ||
* @param t - A TypeDescriptor for the type of the range, must be a number (UInt32, Int32, etc.) | ||
* @returns A TypeDescriptor for an InclusiveRange of the given type | ||
* | ||
* @example | ||
* ```javascript | ||
* import * as fcl from "@onflow/fcl" | ||
* import {InclusiveRange, UInt32} from "@onflow/types" | ||
* | ||
* const someArg = fcl.arg({start: 1, end: 5, step: 1}, InclusiveRange(UInt32)) | ||
* ``` | ||
*/ | ||
const InclusiveRange = t => typedef("InclusiveRange", v => { | ||
if (isObj(v)) { | ||
const { | ||
start, | ||
end, | ||
step | ||
} = v; | ||
return { | ||
type: "InclusiveRange", | ||
value: { | ||
start: t.asArgument(start), | ||
end: t.asArgument(end), | ||
step: t.asArgument(step) | ||
} | ||
}; | ||
} | ||
return throwTypeError("Expected Object for type InclusiveRange"); | ||
}, v => v); | ||
export { Address, _Array as Array, Bool, Character, Dictionary, Enum, Event, Fix64, Identity, InclusiveRange, Int, Int128, Int16, Int256, Int32, Int64, Int8, Optional, Path, Reference, Resource, String, Struct, UFix64, UInt, UInt128, UInt16, UInt256, UInt32, UInt64, UInt8, Void, Word128, Word16, Word256, Word32, Word64, Word8, _Array }; | ||
//# sourceMappingURL=types.module.js.map |
@@ -8,2 +8,6 @@ (function (global, factory) { | ||
/** | ||
* @deprecated Reference values cannot be imported into the Cadence interpreter, will be removed in future versions | ||
*/ | ||
/** | ||
* Creates a type descriptor for a given type | ||
@@ -353,2 +357,34 @@ * @param label - The label for the type | ||
}, v => v); | ||
const Word128 = typedef("Word128", v => { | ||
if (isNumber(v) && isInteger(v)) { | ||
numberValuesDeprecationNotice("Word128"); | ||
return { | ||
type: "Word128", | ||
value: v.toString() | ||
}; | ||
} | ||
if (isString(v)) { | ||
return { | ||
type: "Word128", | ||
value: v | ||
}; | ||
} | ||
return throwTypeError("Expected positive number for Word128"); | ||
}, v => v); | ||
const Word256 = typedef("Word256", v => { | ||
if (isNumber(v) && isInteger(v)) { | ||
numberValuesDeprecationNotice("Word256"); | ||
return { | ||
type: "Word256", | ||
value: v.toString() | ||
}; | ||
} | ||
if (isString(v)) { | ||
return { | ||
type: "Word256", | ||
value: v | ||
}; | ||
} | ||
return throwTypeError("Expected positive number for Word256"); | ||
}, v => v); | ||
const UFix64AndFix64NumberDeprecationNotice = () => { | ||
@@ -452,2 +488,6 @@ utilLogger.log.deprecate({ | ||
}), v => v); | ||
/** | ||
* @deprecated Reference values cannot be imported into the Cadence interpreter, will be removed in future versions | ||
*/ | ||
const Reference = typedef("Reference", v => { | ||
@@ -588,2 +628,35 @@ if (isObj(v)) return { | ||
/** | ||
* InclusiveRange type | ||
* | ||
* @param t - A TypeDescriptor for the type of the range, must be a number (UInt32, Int32, etc.) | ||
* @returns A TypeDescriptor for an InclusiveRange of the given type | ||
* | ||
* @example | ||
* ```javascript | ||
* import * as fcl from "@onflow/fcl" | ||
* import {InclusiveRange, UInt32} from "@onflow/types" | ||
* | ||
* const someArg = fcl.arg({start: 1, end: 5, step: 1}, InclusiveRange(UInt32)) | ||
* ``` | ||
*/ | ||
const InclusiveRange = t => typedef("InclusiveRange", v => { | ||
if (isObj(v)) { | ||
const { | ||
start, | ||
end, | ||
step | ||
} = v; | ||
return { | ||
type: "InclusiveRange", | ||
value: { | ||
start: t.asArgument(start), | ||
end: t.asArgument(end), | ||
step: t.asArgument(step) | ||
} | ||
}; | ||
} | ||
return throwTypeError("Expected Object for type InclusiveRange"); | ||
}, v => v); | ||
exports.Address = Address; | ||
@@ -598,2 +671,3 @@ exports.Array = _Array; | ||
exports.Identity = Identity; | ||
exports.InclusiveRange = InclusiveRange; | ||
exports.Int = Int; | ||
@@ -621,3 +695,5 @@ exports.Int128 = Int128; | ||
exports.Void = Void; | ||
exports.Word128 = Word128; | ||
exports.Word16 = Word16; | ||
exports.Word256 = Word256; | ||
exports.Word32 = Word32; | ||
@@ -624,0 +700,0 @@ exports.Word64 = Word64; |
{ | ||
"name": "@onflow/types", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "Utilities to transform javascript values into Cadence understandable values", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
@@ -245,2 +245,22 @@ --- | ||
### Word128 | ||
```javascript | ||
import * as t from "@onflow/types" | ||
sdk.build([ | ||
sdk.args([ sdk.arg(128, t.Word128) ]) | ||
]) | ||
``` | ||
### Word256 | ||
```javascript | ||
import * as t from "@onflow/types" | ||
sdk.build([ | ||
sdk.args([ sdk.arg(256, t.Word256) ]) | ||
]) | ||
``` | ||
### UFix64 | ||
@@ -460,1 +480,11 @@ | ||
``` | ||
### InclusiveRange | ||
```javascript | ||
import * as t from "@onflow/types" | ||
sdk.build([ | ||
sdk.args([ sdk.arg({start: "1", end: "10", step: "1"}, t.InclusiveRange(t.Int)) ]) | ||
]) | ||
``` |
@@ -16,2 +16,5 @@ export type JsonCdc<L extends string, T> = { | ||
} | ||
/** | ||
* @deprecated Reference values cannot be imported into the Cadence interpreter, will be removed in future versions | ||
*/ | ||
export interface ReferenceValue { | ||
@@ -101,2 +104,10 @@ type: string; | ||
}>; | ||
export declare const Word128: TypeDescriptor<string | number, { | ||
type: string; | ||
value: string; | ||
}>; | ||
export declare const Word256: TypeDescriptor<string | number, { | ||
type: string; | ||
value: string; | ||
}>; | ||
export declare const UFix64: TypeDescriptor<string | number, { | ||
@@ -130,6 +141,9 @@ type: string; | ||
}>; | ||
export declare const Optional: <T extends TypeDescriptor<any, JsonCdc<string, unknown>>>(children: T) => TypeDescriptor<TypeDescriptorInput<T> | null | undefined, { | ||
export declare const Optional: <T extends TypeDescriptor<any, any>>(children: T) => TypeDescriptor<TypeDescriptorInput<T> | null | undefined, { | ||
type: string; | ||
value: JsonCdc<string, unknown> | null; | ||
value: any; | ||
}>; | ||
/** | ||
* @deprecated Reference values cannot be imported into the Cadence interpreter, will be removed in future versions | ||
*/ | ||
export declare const Reference: TypeDescriptor<ReferenceValue, { | ||
@@ -139,8 +153,8 @@ type: string; | ||
}>; | ||
export declare const _Array: <T extends TypeDescriptor<any, JsonCdc<string, unknown>>>(children?: T | T[]) => TypeDescriptor<TypeDescriptorInput<T>[], { | ||
export declare const _Array: <T extends TypeDescriptor<any, any>>(children?: T | T[]) => TypeDescriptor<TypeDescriptorInput<T>[], { | ||
type: string; | ||
value: JsonCdc<string, unknown>[]; | ||
value: any[]; | ||
}>; | ||
export { _Array as Array }; | ||
export declare const Dictionary: <K extends TypeDescriptor<any, JsonCdc<string, unknown>>, V extends TypeDescriptor<any, JsonCdc<string, unknown>>>(children?: { | ||
export declare const Dictionary: <K extends TypeDescriptor<any, any>, V extends TypeDescriptor<any, any>>(children?: { | ||
key: K; | ||
@@ -160,7 +174,7 @@ value: V; | ||
value: { | ||
key: JsonCdc<string, unknown>; | ||
value: JsonCdc<string, unknown>; | ||
key: any; | ||
value: any; | ||
}[]; | ||
}>; | ||
export declare const Event: <V extends TypeDescriptor<any, JsonCdc<string, unknown>>>(id: string, fields?: { | ||
export declare const Event: <V extends TypeDescriptor<any, any>>(id: string, fields?: { | ||
value: V; | ||
@@ -180,7 +194,7 @@ } | { | ||
name: string; | ||
value: JsonCdc<string, unknown>; | ||
value: any; | ||
}[]; | ||
}; | ||
}>; | ||
export declare const Resource: <V extends TypeDescriptor<any, JsonCdc<string, unknown>>>(id: string, fields?: { | ||
export declare const Resource: <V extends TypeDescriptor<any, any>>(id: string, fields?: { | ||
value: V; | ||
@@ -200,7 +214,7 @@ } | { | ||
name: string; | ||
value: JsonCdc<string, unknown>; | ||
value: any; | ||
}[]; | ||
}; | ||
}>; | ||
export declare const Struct: <V extends TypeDescriptor<any, JsonCdc<string, unknown>>>(id: string, fields?: { | ||
export declare const Struct: <V extends TypeDescriptor<any, any>>(id: string, fields?: { | ||
value: V; | ||
@@ -220,7 +234,7 @@ } | { | ||
name: string; | ||
value: JsonCdc<string, unknown>; | ||
value: any; | ||
}[]; | ||
}; | ||
}>; | ||
export declare const Enum: <V extends TypeDescriptor<any, JsonCdc<string, unknown>>>(id: string, fields?: { | ||
export declare const Enum: <V extends TypeDescriptor<any, any>>(id: string, fields?: { | ||
value: V; | ||
@@ -240,3 +254,3 @@ } | { | ||
name: string; | ||
value: JsonCdc<string, unknown>; | ||
value: any; | ||
}[]; | ||
@@ -252,1 +266,27 @@ }; | ||
}>; | ||
/** | ||
* InclusiveRange type | ||
* | ||
* @param t - A TypeDescriptor for the type of the range, must be a number (UInt32, Int32, etc.) | ||
* @returns A TypeDescriptor for an InclusiveRange of the given type | ||
* | ||
* @example | ||
* ```javascript | ||
* import * as fcl from "@onflow/fcl" | ||
* import {InclusiveRange, UInt32} from "@onflow/types" | ||
* | ||
* const someArg = fcl.arg({start: 1, end: 5, step: 1}, InclusiveRange(UInt32)) | ||
* ``` | ||
*/ | ||
export declare const InclusiveRange: <T extends TypeDescriptor<any, any>>(t: T) => TypeDescriptor<{ | ||
start: TypeDescriptorInput<T>; | ||
end: TypeDescriptorInput<T>; | ||
step: TypeDescriptorInput<T>; | ||
}, { | ||
type: string; | ||
value: { | ||
start: any; | ||
end: any; | ||
step: any; | ||
}; | ||
}>; |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
227998
2354
489