@knuth/js-wasm 3.0.0 → 4.0.0
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/README.md +62 -6
- package/SHA256SUMS +4 -0
- package/package.json +10 -2
- package/src/browser_headers_persistent_v1.js +2 -0
- package/src/browser_headers_persistent_v1.wasm +0 -0
- package/src/kth.js +1 -1
- package/src/kth.wasm +0 -0
- package/types/AsyncResults.d.ts +11 -0
- package/types/ListHelper.d.ts +2 -2
- package/types/PaymentAddress.d.ts +2 -2
- package/types/nativeScope.d.ts +1 -0
- package/types/wasm/callbacks.d.ts +30 -0
- package/types/wasm/glue.d.ts +26 -3
- package/types/wasm/mem.d.ts +2 -2
package/src/kth.wasm
CHANGED
|
Binary file
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Copyright (c) 2016-present Knuth Project developers.
|
|
2
|
+
// Distributed under the MIT software license, see the accompanying
|
|
3
|
+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
4
|
+
|
|
5
|
+
type Conversion = {
|
|
6
|
+
owned: boolean;
|
|
7
|
+
adopt: boolean;
|
|
8
|
+
read: (value: any) => unknown;
|
|
9
|
+
};
|
|
10
|
+
export declare function convertAsyncResults(values: readonly unknown[], conversions: readonly Conversion[]): unknown[];
|
|
11
|
+
export {};
|
package/types/ListHelper.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
4
4
|
|
|
5
5
|
import { ListNative } from './ListNative';
|
|
6
|
-
export declare function fromNative<T, N, L extends ListNative<N>>(nativeList: L, fromNativeFunc: (nativeItem: N) => T): Array<T>;
|
|
6
|
+
export declare function fromNative<T, N, L extends ListNative<N>>(nativeList: L, fromNativeFunc: (nativeItem: N) => T, releaseElement?: (item: T) => void): Array<T>;
|
|
7
7
|
export declare function toNative<T, N, L extends ListNative<N>>(items: Array<T>, toNativeFunc: (item: T) => N, NativeConstructor: new () => L): L;
|
|
8
8
|
export declare function toNativeCopied<T, N, L extends ListNative<N>>(items: Array<T>, toNativeFunc: (item: T) => N, NativeConstructor: new () => L): L;
|
|
9
9
|
export declare function fromNativePrimitive<T, L extends ListNative<T>>(nativeList: L): Array<T>;
|
|
@@ -14,4 +14,4 @@ export interface ListAdapter<T, L> {
|
|
|
14
14
|
}
|
|
15
15
|
export declare function definePrimitiveList<T, L extends ListNative<T>>(NativeConstructor: new () => L): ListAdapter<T, L>;
|
|
16
16
|
export declare function defineCopiedList<T, N, L extends ListNative<N>>(NativeConstructor: new () => L, readElement: (native: N) => T, writeElement: (item: T) => N): ListAdapter<T, L>;
|
|
17
|
-
export declare function defineBorrowedList<T, N, L extends ListNative<N>>(NativeConstructor: new () => L, readElement: (native: N) => T, writeElement: (item: T) => N): ListAdapter<T, L>;
|
|
17
|
+
export declare function defineBorrowedList<T, N, L extends ListNative<N>>(NativeConstructor: new () => L, readElement: (native: N) => T, writeElement: (item: T) => N, releaseElement?: (item: T) => void): ListAdapter<T, L>;
|
|
@@ -21,8 +21,8 @@ export declare class PaymentAddress {
|
|
|
21
21
|
private static parse;
|
|
22
22
|
static fromString(addressStr: string): PaymentAddress | undefined;
|
|
23
23
|
static isValid(addressStr: string): boolean;
|
|
24
|
-
static fromScript(script: Script, version: number): PaymentAddress;
|
|
25
|
-
static fromPayPublicKeyHashScript(script: Script, version: number): PaymentAddress;
|
|
24
|
+
static fromScript(script: Script, version: number): PaymentAddress | undefined;
|
|
25
|
+
static fromPayPublicKeyHashScript(script: Script, version: number): PaymentAddress | undefined;
|
|
26
26
|
get hash20(): ShortHash;
|
|
27
27
|
get hash32(): Hash;
|
|
28
28
|
get hash(): ShortHash;
|
package/types/nativeScope.d.ts
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Copyright (c) 2016-present Knuth Project developers.
|
|
2
|
+
// Distributed under the MIT software license, see the accompanying
|
|
3
|
+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
4
|
+
|
|
5
|
+
export declare class CallbackStatusError extends Error {
|
|
6
|
+
readonly code: number;
|
|
7
|
+
constructor(code: number);
|
|
8
|
+
}
|
|
9
|
+
export interface CallbackConversion<T> {
|
|
10
|
+
take(value: unknown): T;
|
|
11
|
+
release(value: unknown): void;
|
|
12
|
+
}
|
|
13
|
+
/** One registry per module/executor. The native terminal callback owns completion.
|
|
14
|
+
* A JS timeout/abort must not release the receiver while C++ still uses it.
|
|
15
|
+
*/
|
|
16
|
+
export declare class CallbackRegistry {
|
|
17
|
+
private readonly capacity;
|
|
18
|
+
private readonly pending;
|
|
19
|
+
private readonly owners;
|
|
20
|
+
private sequence;
|
|
21
|
+
constructor(capacity?: number);
|
|
22
|
+
get size(): number;
|
|
23
|
+
assertIdle(owner: object): void;
|
|
24
|
+
invoke<T>(owner: object, start: (id: number, enterNative: () => void) => void): Promise<T>;
|
|
25
|
+
/** Call enterNative immediately before crossing the native boundary.
|
|
26
|
+
* Once entered, only terminal completion releases ownership pins/inputs.
|
|
27
|
+
*/
|
|
28
|
+
invokeWithOwners<T>(receivers: readonly object[], start: (id: number, enterNative: () => void) => void, conversion?: CallbackConversion<T>): Promise<T>;
|
|
29
|
+
complete(id: number, status: number, value: unknown): boolean;
|
|
30
|
+
}
|
package/types/wasm/glue.d.ts
CHANGED
|
@@ -50,7 +50,7 @@ export declare class LibConfig {
|
|
|
50
50
|
static getEmscriptenVersionTiny(): number;
|
|
51
51
|
static getBuildTimestamp(): number;
|
|
52
52
|
}
|
|
53
|
-
declare const _NetworkIntToKey: readonly ["mainnet", "testnet", "regtest", "testnet4", "scalenet", "chipnet"];
|
|
53
|
+
declare const _NetworkIntToKey: readonly ["mainnet", "testnet", "regtest", "testnet4", "scalenet", "chipnet", "tempnet"];
|
|
54
54
|
export declare type Network = (typeof _NetworkIntToKey)[number];
|
|
55
55
|
export declare function NetworkToInt(value: Network): number;
|
|
56
56
|
export declare function NetworkFromInt(value: number): Network;
|
|
@@ -291,10 +291,9 @@ export declare class HdPrivateNative {
|
|
|
291
291
|
}
|
|
292
292
|
export declare class PaymentAddressNative {
|
|
293
293
|
private readonly [ptrSym];
|
|
294
|
+
private constructor();
|
|
294
295
|
static _create(ptr: number): PaymentAddressNative;
|
|
295
296
|
protected _destructor(): void;
|
|
296
|
-
constructor(short_hash: ShortHashNative, version: number);
|
|
297
|
-
constructor(hash: HashNative, version: number);
|
|
298
297
|
copy(): PaymentAddressNative;
|
|
299
298
|
static cashaddrPrefixFor(net: Network): string;
|
|
300
299
|
static parseFromSimple(address: string): PaymentAddressNative;
|
|
@@ -304,6 +303,9 @@ export declare class PaymentAddressNative {
|
|
|
304
303
|
static fromEcPublic(point: EcPublicNative, version: number): PaymentAddressNative;
|
|
305
304
|
static fromScript(script: ScriptNative, version: number): PaymentAddressNative;
|
|
306
305
|
static fromPayPublicKeyHashScript(script: ScriptNative, version: number): PaymentAddressNative;
|
|
306
|
+
static fromShorthash(hash: ShortHashNative, version: number): PaymentAddressNative;
|
|
307
|
+
static fromHash(hash: HashNative, version: number): PaymentAddressNative;
|
|
308
|
+
static isSupportedVersion(version: number): boolean;
|
|
307
309
|
equals(other: PaymentAddressNative): boolean;
|
|
308
310
|
notEqual(other: PaymentAddressNative): boolean;
|
|
309
311
|
less(x: PaymentAddressNative): boolean;
|
|
@@ -869,6 +871,7 @@ export declare class OutputPointNative {
|
|
|
869
871
|
copy(): OutputPointNative;
|
|
870
872
|
static createNull(): OutputPointNative;
|
|
871
873
|
isMature(height: number): boolean;
|
|
874
|
+
isMatureWithTicks(ticks: BlockTicksNative, height: number): boolean;
|
|
872
875
|
equals(other: OutputPointNative): boolean;
|
|
873
876
|
notEqual(other: OutputPointNative): boolean;
|
|
874
877
|
less(x: OutputPointNative): boolean;
|
|
@@ -988,6 +991,7 @@ export declare class InputNative {
|
|
|
988
991
|
addresses(): PaymentAddressListNative;
|
|
989
992
|
isFinal(): boolean;
|
|
990
993
|
isLocked(block_height: number, median_time_past: number): boolean;
|
|
994
|
+
isLockedWithTicks(ticks: BlockTicksNative, block_height: number, median_time_past: number): boolean;
|
|
991
995
|
signatureOperations(bip16: boolean, bip141: boolean): number;
|
|
992
996
|
extractEmbeddedScript(): ScriptNative;
|
|
993
997
|
}
|
|
@@ -1085,17 +1089,21 @@ export declare class TransactionNative {
|
|
|
1085
1089
|
isNullNonCoinbase(): boolean;
|
|
1086
1090
|
isOversizedCoinbase(): boolean;
|
|
1087
1091
|
isMature(height: number): boolean;
|
|
1092
|
+
isMatureWithTicks(ticks: BlockTicksNative, height: number): boolean;
|
|
1088
1093
|
isInternalDoubleSpend(): boolean;
|
|
1089
1094
|
isDoubleSpend(include_unconfirmed: boolean): boolean;
|
|
1090
1095
|
isDusty(minimum_output_value: bigint): boolean;
|
|
1091
1096
|
isMissingPreviousOutputs(): boolean;
|
|
1092
1097
|
isFinal(block_height: number, block_time: number): boolean;
|
|
1098
|
+
isFinalWithTicks(ticks: BlockTicksNative, block_height: number, block_time: number): boolean;
|
|
1093
1099
|
isLocked(block_height: number, median_time_past: number): boolean;
|
|
1100
|
+
isLockedWithTicks(ticks: BlockTicksNative, block_height: number, median_time_past: number): boolean;
|
|
1094
1101
|
isLocktimeConflict(): boolean;
|
|
1095
1102
|
isOverspent(): boolean;
|
|
1096
1103
|
check(max_block_size: number, transaction_pool: boolean, retarget: boolean): number;
|
|
1097
1104
|
minTxSize(flags: bigint): number;
|
|
1098
1105
|
accept(flags: bigint, height: number, median_time_past: number, max_sigops: number, is_under_checkpoint: boolean, transaction_pool: boolean, duplicate: boolean): number;
|
|
1106
|
+
acceptWithTicks(ticks: BlockTicksNative, flags: bigint, height: number, median_time_past: number, max_sigops: number, is_under_checkpoint: boolean, transaction_pool: boolean, duplicate: boolean): number;
|
|
1099
1107
|
isStandardSimple(): boolean;
|
|
1100
1108
|
isStandard(flags: bigint): boolean;
|
|
1101
1109
|
}
|
|
@@ -1325,6 +1333,21 @@ export declare class ProgramNative {
|
|
|
1325
1333
|
closed(): boolean;
|
|
1326
1334
|
succeeded(): boolean;
|
|
1327
1335
|
}
|
|
1336
|
+
export declare class BlockTicksNative {
|
|
1337
|
+
private readonly [ptrSym];
|
|
1338
|
+
static _create(ptr: number): BlockTicksNative;
|
|
1339
|
+
protected _destructor(): void;
|
|
1340
|
+
constructor();
|
|
1341
|
+
copy(): BlockTicksNative;
|
|
1342
|
+
static activatedAt(activation_height: bigint): BlockTicksNative;
|
|
1343
|
+
heightToTick(height: bigint): bigint;
|
|
1344
|
+
tickToHeight(tick: bigint): bigint;
|
|
1345
|
+
blockInterval(height: bigint): bigint;
|
|
1346
|
+
nextBlockInterval(height: bigint): bigint;
|
|
1347
|
+
nextBlockTick(tip: bigint): bigint;
|
|
1348
|
+
equals(other: BlockTicksNative): boolean;
|
|
1349
|
+
notEqual(other: BlockTicksNative): boolean;
|
|
1350
|
+
}
|
|
1328
1351
|
declare const _RuleForkEnumNativeIntToKey: readonly ["no_rules", "easy_blocks", "bip16_rule", "bip30_rule", "bip34_rule", "bip66_rule", "bip65_rule", "bip90_rule", "allow_collisions", "bip68_rule", "bip112_rule", "bip113_rule", "bch_uahf", "bch_daa_cw144", "bch_pythagoras", "bch_euclid", "bch_pisano", "bch_mersenne", "bch_fermat", "bch_euler", "bch_gauss", "bch_descartes", "bch_lobachevski", "bch_galois", "bch_leibniz", "retarget", "unverified", "bip34_activations", "bip9_bit0_group", "bip9_bit1_group", "all_rules"];
|
|
1329
1352
|
export declare type RuleForkEnumNative = (typeof _RuleForkEnumNativeIntToKey)[number];
|
|
1330
1353
|
export declare function RuleForkEnumNativeToInt(value: RuleForkEnumNative): number;
|
package/types/wasm/mem.d.ts
CHANGED
|
@@ -25,9 +25,9 @@ declare function allocZeroedSlot(): number;
|
|
|
25
25
|
*/
|
|
26
26
|
declare function takeByteArray(ptr: number, sizePtr: number, release?: (ptr: number) => void): Uint8Array<ArrayBuffer>;
|
|
27
27
|
/** An input byte array must be a non-null Uint8Array (checked before any buffer is allocated). */
|
|
28
|
-
declare function checkBytes(value:
|
|
28
|
+
declare function checkBytes(value: unknown, name: string): asserts value is Uint8Array;
|
|
29
29
|
/** A fixed-size value struct passed as bytes: exactly `size` bytes, because the C function takes no length. */
|
|
30
|
-
declare function checkFixedBytes(value:
|
|
30
|
+
declare function checkFixedBytes(value: unknown, name: string, size: number): asserts value is Uint8Array;
|
|
31
31
|
/** Copy `size` bytes out of native memory. */
|
|
32
32
|
declare function readBytes(ptr: number, size: number): Uint8Array;
|
|
33
33
|
/**
|