@polkadot/types-codec 8.9.2-9 → 8.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/native/Float.js +136 -0
- package/cjs/native/Json.js +4 -0
- package/cjs/native/index.js +8 -0
- package/cjs/packageInfo.js +1 -1
- package/cjs/primitive/F32.js +23 -0
- package/cjs/primitive/F64.js +23 -0
- package/cjs/primitive/index.js +28 -0
- package/native/Float.d.ts +63 -0
- package/native/Float.js +125 -0
- package/native/Json.d.ts +3 -0
- package/native/Json.js +4 -0
- package/native/index.d.ts +1 -0
- package/native/index.js +1 -0
- package/package.json +19 -5
- package/packageInfo.js +1 -1
- package/primitive/F32.d.ts +11 -0
- package/primitive/F32.js +13 -0
- package/primitive/F64.d.ts +11 -0
- package/primitive/F64.js +13 -0
- package/primitive/index.d.ts +2 -0
- package/primitive/index.js +2 -0
- package/types/helpers.d.ts +1 -0
- package/types/interfaces.d.ts +3 -0
- package/mod.ts +0 -4
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Float = void 0;
|
|
7
|
+
|
|
8
|
+
var _util = require("@polkadot/util");
|
|
9
|
+
|
|
10
|
+
// Copyright 2017-2022 @polkadot/types-codec authors & contributors
|
|
11
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @name Float
|
|
15
|
+
* @description
|
|
16
|
+
* A Codec wrapper for F32 & F64 values. You generally don't want to be using
|
|
17
|
+
* f32/f64 in your runtime, operations on fixed points numbers are preferable. This class
|
|
18
|
+
* was explicitly added since scale-codec has a flag that enables this and it is available
|
|
19
|
+
* in some eth_* RPCs
|
|
20
|
+
*/
|
|
21
|
+
class Float extends Number {
|
|
22
|
+
#bitLength;
|
|
23
|
+
|
|
24
|
+
constructor(registry, value) {
|
|
25
|
+
let {
|
|
26
|
+
bitLength = 32
|
|
27
|
+
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
28
|
+
super((0, _util.isU8a)(value) || (0, _util.isHex)(value) ? value.length === 0 ? 0 : (0, _util.u8aToFloat)((0, _util.u8aToU8a)(value), {
|
|
29
|
+
bitLength
|
|
30
|
+
}) : value || 0);
|
|
31
|
+
this.#bitLength = bitLength;
|
|
32
|
+
this.encodedLength = bitLength / 8;
|
|
33
|
+
this.initialU8aLength = this.encodedLength;
|
|
34
|
+
this.registry = registry;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static with(bitLength) {
|
|
38
|
+
return class extends Float {
|
|
39
|
+
constructor(registry, value) {
|
|
40
|
+
super(registry, value, {
|
|
41
|
+
bitLength
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* @description returns a hash of the contents
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
get hash() {
|
|
53
|
+
return this.registry.hash(this.toU8a());
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* @description Returns true if the type wraps an empty/default all-0 value
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
get isEmpty() {
|
|
61
|
+
return this.valueOf() === 0;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* @description Compares the value of the input to see if there is a match
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
eq(other) {
|
|
69
|
+
return this.valueOf() === Number(other);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* @description Returns a breakdown of the hex encoding for this Codec
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
inspect() {
|
|
77
|
+
return {
|
|
78
|
+
outer: [this.toU8a()]
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* @description Returns a hex string representation of the value
|
|
83
|
+
*/
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
toHex() {
|
|
87
|
+
return (0, _util.u8aToHex)(this.toU8a());
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
toHuman() {
|
|
95
|
+
return this.toString();
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* @description Converts the Object to JSON, typically used for RPC transfers
|
|
99
|
+
*/
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
toJSON() {
|
|
103
|
+
// Not sure if this is actually a hex or a string value
|
|
104
|
+
// (would need to check against RPCs to see the result here)
|
|
105
|
+
return this.toHex();
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* @description Returns the number representation (Same as valueOf)
|
|
109
|
+
*/
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
toNumber() {
|
|
113
|
+
return this.valueOf();
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* @description Returns the base runtime type name for this instance
|
|
117
|
+
*/
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
toRawType() {
|
|
121
|
+
return `f${this.#bitLength}`;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* @description Encodes the value as a Uint8Array as per the SCALE specifications
|
|
125
|
+
*/
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
toU8a() {
|
|
129
|
+
return (0, _util.floatToU8a)(this, {
|
|
130
|
+
bitLength: this.#bitLength
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
exports.Float = Float;
|
package/cjs/native/Json.js
CHANGED
package/cjs/native/index.js
CHANGED
|
@@ -27,6 +27,12 @@ Object.defineProperty(exports, "Date", {
|
|
|
27
27
|
return _Date.CodecDate;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
+
Object.defineProperty(exports, "Float", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _Float.Float;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
30
36
|
Object.defineProperty(exports, "Json", {
|
|
31
37
|
enumerable: true,
|
|
32
38
|
get: function () {
|
|
@@ -68,6 +74,8 @@ var _Bool = require("./Bool");
|
|
|
68
74
|
|
|
69
75
|
var _Date = require("./Date");
|
|
70
76
|
|
|
77
|
+
var _Float = require("./Float");
|
|
78
|
+
|
|
71
79
|
var _Json = require("./Json");
|
|
72
80
|
|
|
73
81
|
var _Raw = require("./Raw");
|
package/cjs/packageInfo.js
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.f32 = void 0;
|
|
7
|
+
|
|
8
|
+
var _Float = require("../native/Float");
|
|
9
|
+
|
|
10
|
+
// Copyright 2017-2022 @polkadot/types-codec authors & contributors
|
|
11
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @name f32
|
|
15
|
+
* @description
|
|
16
|
+
* A 32-bit float
|
|
17
|
+
*/
|
|
18
|
+
class f32 extends _Float.Float.with(32) {
|
|
19
|
+
// NOTE without this, we cannot properly determine extensions
|
|
20
|
+
__FloatType = 'f32';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
exports.f32 = f32;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.f64 = void 0;
|
|
7
|
+
|
|
8
|
+
var _Float = require("../native/Float");
|
|
9
|
+
|
|
10
|
+
// Copyright 2017-2022 @polkadot/types-codec authors & contributors
|
|
11
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @name f64
|
|
15
|
+
* @description
|
|
16
|
+
* A 64-bit float
|
|
17
|
+
*/
|
|
18
|
+
class f64 extends _Float.Float.with(64) {
|
|
19
|
+
// NOTE without this, we cannot properly determine extensions
|
|
20
|
+
__FloatType = 'f64';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
exports.f64 = f64;
|
package/cjs/primitive/index.js
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
Object.defineProperty(exports, "F32", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _F.f32;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "F64", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _F2.f64;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
6
18
|
Object.defineProperty(exports, "I128", {
|
|
7
19
|
enumerable: true,
|
|
8
20
|
get: function () {
|
|
@@ -81,6 +93,18 @@ Object.defineProperty(exports, "USize", {
|
|
|
81
93
|
return _USize.usize;
|
|
82
94
|
}
|
|
83
95
|
});
|
|
96
|
+
Object.defineProperty(exports, "f32", {
|
|
97
|
+
enumerable: true,
|
|
98
|
+
get: function () {
|
|
99
|
+
return _F.f32;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
Object.defineProperty(exports, "f64", {
|
|
103
|
+
enumerable: true,
|
|
104
|
+
get: function () {
|
|
105
|
+
return _F2.f64;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
84
108
|
Object.defineProperty(exports, "i128", {
|
|
85
109
|
enumerable: true,
|
|
86
110
|
get: function () {
|
|
@@ -160,6 +184,10 @@ Object.defineProperty(exports, "usize", {
|
|
|
160
184
|
}
|
|
161
185
|
});
|
|
162
186
|
|
|
187
|
+
var _F = require("./F32");
|
|
188
|
+
|
|
189
|
+
var _F2 = require("./F64");
|
|
190
|
+
|
|
163
191
|
var _I = require("./I8");
|
|
164
192
|
|
|
165
193
|
var _I2 = require("./I16");
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { HexString } from '@polkadot/util/types';
|
|
2
|
+
import type { AnyFloat, CodecClass, IFloat, Inspect, IU8a, Registry } from '../types';
|
|
3
|
+
interface Options {
|
|
4
|
+
bitLength?: 32 | 64;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* @name Float
|
|
8
|
+
* @description
|
|
9
|
+
* A Codec wrapper for F32 & F64 values. You generally don't want to be using
|
|
10
|
+
* f32/f64 in your runtime, operations on fixed points numbers are preferable. This class
|
|
11
|
+
* was explicitly added since scale-codec has a flag that enables this and it is available
|
|
12
|
+
* in some eth_* RPCs
|
|
13
|
+
*/
|
|
14
|
+
export declare class Float extends Number implements IFloat {
|
|
15
|
+
#private;
|
|
16
|
+
createdAtHash?: IU8a;
|
|
17
|
+
readonly encodedLength: number;
|
|
18
|
+
readonly initialU8aLength?: number;
|
|
19
|
+
readonly registry: Registry;
|
|
20
|
+
constructor(registry: Registry, value?: AnyFloat, { bitLength }?: Options);
|
|
21
|
+
static with(bitLength: 32 | 64): CodecClass<Float>;
|
|
22
|
+
/**
|
|
23
|
+
* @description returns a hash of the contents
|
|
24
|
+
*/
|
|
25
|
+
get hash(): IU8a;
|
|
26
|
+
/**
|
|
27
|
+
* @description Returns true if the type wraps an empty/default all-0 value
|
|
28
|
+
*/
|
|
29
|
+
get isEmpty(): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* @description Compares the value of the input to see if there is a match
|
|
32
|
+
*/
|
|
33
|
+
eq(other?: unknown): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* @description Returns a breakdown of the hex encoding for this Codec
|
|
36
|
+
*/
|
|
37
|
+
inspect(): Inspect;
|
|
38
|
+
/**
|
|
39
|
+
* @description Returns a hex string representation of the value
|
|
40
|
+
*/
|
|
41
|
+
toHex(): HexString;
|
|
42
|
+
/**
|
|
43
|
+
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
|
|
44
|
+
*/
|
|
45
|
+
toHuman(): string;
|
|
46
|
+
/**
|
|
47
|
+
* @description Converts the Object to JSON, typically used for RPC transfers
|
|
48
|
+
*/
|
|
49
|
+
toJSON(): string;
|
|
50
|
+
/**
|
|
51
|
+
* @description Returns the number representation (Same as valueOf)
|
|
52
|
+
*/
|
|
53
|
+
toNumber(): number;
|
|
54
|
+
/**
|
|
55
|
+
* @description Returns the base runtime type name for this instance
|
|
56
|
+
*/
|
|
57
|
+
toRawType(): string;
|
|
58
|
+
/**
|
|
59
|
+
* @description Encodes the value as a Uint8Array as per the SCALE specifications
|
|
60
|
+
*/
|
|
61
|
+
toU8a(): Uint8Array;
|
|
62
|
+
}
|
|
63
|
+
export {};
|
package/native/Float.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// Copyright 2017-2022 @polkadot/types-codec authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { floatToU8a, isHex, isU8a, u8aToFloat, u8aToHex, u8aToU8a } from '@polkadot/util';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @name Float
|
|
7
|
+
* @description
|
|
8
|
+
* A Codec wrapper for F32 & F64 values. You generally don't want to be using
|
|
9
|
+
* f32/f64 in your runtime, operations on fixed points numbers are preferable. This class
|
|
10
|
+
* was explicitly added since scale-codec has a flag that enables this and it is available
|
|
11
|
+
* in some eth_* RPCs
|
|
12
|
+
*/
|
|
13
|
+
export class Float extends Number {
|
|
14
|
+
#bitLength;
|
|
15
|
+
|
|
16
|
+
constructor(registry, value, {
|
|
17
|
+
bitLength = 32
|
|
18
|
+
} = {}) {
|
|
19
|
+
super(isU8a(value) || isHex(value) ? value.length === 0 ? 0 : u8aToFloat(u8aToU8a(value), {
|
|
20
|
+
bitLength
|
|
21
|
+
}) : value || 0);
|
|
22
|
+
this.#bitLength = bitLength;
|
|
23
|
+
this.encodedLength = bitLength / 8;
|
|
24
|
+
this.initialU8aLength = this.encodedLength;
|
|
25
|
+
this.registry = registry;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
static with(bitLength) {
|
|
29
|
+
return class extends Float {
|
|
30
|
+
constructor(registry, value) {
|
|
31
|
+
super(registry, value, {
|
|
32
|
+
bitLength
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* @description returns a hash of the contents
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
get hash() {
|
|
44
|
+
return this.registry.hash(this.toU8a());
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* @description Returns true if the type wraps an empty/default all-0 value
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
get isEmpty() {
|
|
52
|
+
return this.valueOf() === 0;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* @description Compares the value of the input to see if there is a match
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
eq(other) {
|
|
60
|
+
return this.valueOf() === Number(other);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* @description Returns a breakdown of the hex encoding for this Codec
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
inspect() {
|
|
68
|
+
return {
|
|
69
|
+
outer: [this.toU8a()]
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* @description Returns a hex string representation of the value
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
toHex() {
|
|
78
|
+
return u8aToHex(this.toU8a());
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
|
|
82
|
+
*/
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
toHuman() {
|
|
86
|
+
return this.toString();
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* @description Converts the Object to JSON, typically used for RPC transfers
|
|
90
|
+
*/
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
toJSON() {
|
|
94
|
+
// Not sure if this is actually a hex or a string value
|
|
95
|
+
// (would need to check against RPCs to see the result here)
|
|
96
|
+
return this.toHex();
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* @description Returns the number representation (Same as valueOf)
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
toNumber() {
|
|
104
|
+
return this.valueOf();
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* @description Returns the base runtime type name for this instance
|
|
108
|
+
*/
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
toRawType() {
|
|
112
|
+
return `f${this.#bitLength}`;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* @description Encodes the value as a Uint8Array as per the SCALE specifications
|
|
116
|
+
*/
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
toU8a() {
|
|
120
|
+
return floatToU8a(this, {
|
|
121
|
+
bitLength: this.#bitLength
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
}
|
package/native/Json.d.ts
CHANGED
|
@@ -28,6 +28,9 @@ export declare class Json extends Map<string, any> implements Codec {
|
|
|
28
28
|
* @description Compares the value of the input to see if there is a match
|
|
29
29
|
*/
|
|
30
30
|
eq(other?: unknown): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* @description Returns a typed value from the internal map
|
|
33
|
+
*/
|
|
31
34
|
getT<T>(key: string): T;
|
|
32
35
|
/**
|
|
33
36
|
* @description Unimplemented, will throw
|
package/native/Json.js
CHANGED
package/native/index.d.ts
CHANGED
package/native/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
export { bool, bool as Bool } from "./Bool.js";
|
|
4
4
|
export { CodecDate, CodecDate as Date } from "./Date.js";
|
|
5
|
+
export { Float } from "./Float.js";
|
|
5
6
|
export { Json } from "./Json.js";
|
|
6
7
|
export { Raw } from "./Raw.js";
|
|
7
8
|
export { CodecSet, CodecSet as Set } from "./Set.js";
|
package/package.json
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"./cjs/detectPackage.js"
|
|
21
21
|
],
|
|
22
22
|
"type": "module",
|
|
23
|
-
"version": "8.
|
|
23
|
+
"version": "8.11.2",
|
|
24
24
|
"main": "./cjs/index.js",
|
|
25
25
|
"module": "./index.js",
|
|
26
26
|
"types": "./index.d.ts",
|
|
@@ -213,7 +213,6 @@
|
|
|
213
213
|
"default": "./extended/WrapperOpaque.js"
|
|
214
214
|
},
|
|
215
215
|
"./mod.d.ts": "./mod.d.ts",
|
|
216
|
-
"./mod.ts": "./mod.ts",
|
|
217
216
|
"./native": {
|
|
218
217
|
"types": "./native/index.d.ts",
|
|
219
218
|
"require": "./cjs/native/index.js",
|
|
@@ -229,6 +228,11 @@
|
|
|
229
228
|
"require": "./cjs/native/Date.js",
|
|
230
229
|
"default": "./native/Date.js"
|
|
231
230
|
},
|
|
231
|
+
"./native/Float": {
|
|
232
|
+
"types": "./native/Float.d.ts",
|
|
233
|
+
"require": "./cjs/native/Float.js",
|
|
234
|
+
"default": "./native/Float.js"
|
|
235
|
+
},
|
|
232
236
|
"./native/Json": {
|
|
233
237
|
"types": "./native/Json.d.ts",
|
|
234
238
|
"require": "./cjs/native/Json.js",
|
|
@@ -274,6 +278,16 @@
|
|
|
274
278
|
"require": "./cjs/primitive/index.js",
|
|
275
279
|
"default": "./primitive/index.js"
|
|
276
280
|
},
|
|
281
|
+
"./primitive/F32": {
|
|
282
|
+
"types": "./primitive/F32.d.ts",
|
|
283
|
+
"require": "./cjs/primitive/F32.js",
|
|
284
|
+
"default": "./primitive/F32.js"
|
|
285
|
+
},
|
|
286
|
+
"./primitive/F64": {
|
|
287
|
+
"types": "./primitive/F64.d.ts",
|
|
288
|
+
"require": "./cjs/primitive/F64.js",
|
|
289
|
+
"default": "./primitive/F64.js"
|
|
290
|
+
},
|
|
277
291
|
"./primitive/I128": {
|
|
278
292
|
"types": "./primitive/I128.d.ts",
|
|
279
293
|
"require": "./cjs/primitive/I128.js",
|
|
@@ -421,8 +435,8 @@
|
|
|
421
435
|
}
|
|
422
436
|
},
|
|
423
437
|
"dependencies": {
|
|
424
|
-
"@babel/runtime": "^7.18.
|
|
425
|
-
"@polkadot/util": "^9.
|
|
426
|
-
"@polkadot/x-bigint": "^9.
|
|
438
|
+
"@babel/runtime": "^7.18.6",
|
|
439
|
+
"@polkadot/util": "^9.7.2",
|
|
440
|
+
"@polkadot/x-bigint": "^9.7.2"
|
|
427
441
|
}
|
|
428
442
|
}
|
package/packageInfo.js
CHANGED
|
@@ -5,5 +5,5 @@ export const packageInfo = {
|
|
|
5
5
|
name: '@polkadot/types-codec',
|
|
6
6
|
path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
|
|
7
7
|
type: 'esm',
|
|
8
|
-
version: '8.
|
|
8
|
+
version: '8.11.2'
|
|
9
9
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Float } from '../native/Float';
|
|
2
|
+
declare const f32_base: import("../types").CodecClass<Float>;
|
|
3
|
+
/**
|
|
4
|
+
* @name f32
|
|
5
|
+
* @description
|
|
6
|
+
* A 32-bit float
|
|
7
|
+
*/
|
|
8
|
+
export declare class f32 extends f32_base {
|
|
9
|
+
readonly __FloatType = "f32";
|
|
10
|
+
}
|
|
11
|
+
export {};
|
package/primitive/F32.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Copyright 2017-2022 @polkadot/types-codec authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { Float } from "../native/Float.js";
|
|
4
|
+
/**
|
|
5
|
+
* @name f32
|
|
6
|
+
* @description
|
|
7
|
+
* A 32-bit float
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export class f32 extends Float.with(32) {
|
|
11
|
+
// NOTE without this, we cannot properly determine extensions
|
|
12
|
+
__FloatType = 'f32';
|
|
13
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Float } from '../native/Float';
|
|
2
|
+
declare const f64_base: import("../types").CodecClass<Float>;
|
|
3
|
+
/**
|
|
4
|
+
* @name f64
|
|
5
|
+
* @description
|
|
6
|
+
* A 64-bit float
|
|
7
|
+
*/
|
|
8
|
+
export declare class f64 extends f64_base {
|
|
9
|
+
readonly __FloatType = "f64";
|
|
10
|
+
}
|
|
11
|
+
export {};
|
package/primitive/F64.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Copyright 2017-2022 @polkadot/types-codec authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { Float } from "../native/Float.js";
|
|
4
|
+
/**
|
|
5
|
+
* @name f64
|
|
6
|
+
* @description
|
|
7
|
+
* A 64-bit float
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export class f64 extends Float.with(64) {
|
|
11
|
+
// NOTE without this, we cannot properly determine extensions
|
|
12
|
+
__FloatType = 'f64';
|
|
13
|
+
}
|
package/primitive/index.d.ts
CHANGED
package/primitive/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// Copyright 2017-2022 @polkadot/types-codec authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
export { f32, f32 as F32 } from "./F32.js";
|
|
4
|
+
export { f64, f64 as F64 } from "./F64.js";
|
|
3
5
|
export { i8, i8 as I8 } from "./I8.js";
|
|
4
6
|
export { i16, i16 as I16 } from "./I16.js";
|
|
5
7
|
export { i32, i32 as I32 } from "./I32.js";
|
package/types/helpers.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export declare type AnyJson = string | number | boolean | null | undefined | Any
|
|
|
6
6
|
};
|
|
7
7
|
export declare type AnyFunction = (...args: any[]) => any;
|
|
8
8
|
export declare type AnyNumber = BN | bigint | Uint8Array | number | string;
|
|
9
|
+
export declare type AnyFloat = Number | number | Uint8Array | string;
|
|
9
10
|
export declare type AnyString = String | string;
|
|
10
11
|
export declare type AnyBool = Boolean | boolean;
|
|
11
12
|
export declare type AnyTuple = Codec[];
|
package/types/interfaces.d.ts
CHANGED
|
@@ -25,6 +25,9 @@ export interface INumber extends Codec {
|
|
|
25
25
|
toBn(): BN;
|
|
26
26
|
toNumber(): number;
|
|
27
27
|
}
|
|
28
|
+
export interface IFloat extends Codec {
|
|
29
|
+
toNumber(): number;
|
|
30
|
+
}
|
|
28
31
|
export interface IOption<T extends Codec = Codec> extends Codec {
|
|
29
32
|
readonly isNone: boolean;
|
|
30
33
|
readonly isSome: boolean;
|
package/mod.ts
DELETED