@midnight-ntwrk/wallet-sdk-abstractions 2.0.0-rc.0 → 2.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/dist/NetworkId.js +1 -1
- package/dist/ProtocolVersion.js +1 -1
- package/dist/SerializedTransaction.js +1 -1
- package/dist/SyncProgress.d.ts +22 -0
- package/dist/SyncProgress.js +25 -0
- package/dist/WalletSeed.js +1 -1
- package/dist/WalletState.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -1
- package/package.json +2 -12
package/dist/NetworkId.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// This file is part of MIDNIGHT-WALLET-SDK.
|
|
2
|
-
// Copyright (C)
|
|
2
|
+
// Copyright (C) Midnight Foundation
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
// You may not use this file except in compliance with the License.
|
package/dist/ProtocolVersion.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// This file is part of MIDNIGHT-WALLET-SDK.
|
|
2
|
-
// Copyright (C)
|
|
2
|
+
// Copyright (C) Midnight Foundation
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
// You may not use this file except in compliance with the License.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// This file is part of MIDNIGHT-WALLET-SDK.
|
|
2
|
-
// Copyright (C)
|
|
2
|
+
// Copyright (C) Midnight Foundation
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
// You may not use this file except in compliance with the License.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface SyncProgressData {
|
|
2
|
+
readonly appliedIndex: bigint;
|
|
3
|
+
readonly highestRelevantWalletIndex: bigint;
|
|
4
|
+
readonly highestIndex: bigint;
|
|
5
|
+
readonly highestRelevantIndex: bigint;
|
|
6
|
+
readonly isConnected: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface SyncProgressOps {
|
|
9
|
+
isCompleteWithin(data: SyncProgressData, maxGap?: bigint): boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface SyncProgress extends SyncProgressData {
|
|
12
|
+
isStrictlyComplete(): boolean;
|
|
13
|
+
isCompleteWithin(maxGap?: bigint): boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare const SyncProgress: SyncProgressOps;
|
|
16
|
+
export declare const createSyncProgress: (params?: {
|
|
17
|
+
appliedIndex?: bigint;
|
|
18
|
+
highestRelevantWalletIndex?: bigint;
|
|
19
|
+
highestIndex?: bigint;
|
|
20
|
+
highestRelevantIndex?: bigint;
|
|
21
|
+
isConnected?: boolean;
|
|
22
|
+
}) => SyncProgress;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const SyncProgress = {
|
|
2
|
+
isCompleteWithin(data, maxGap = 50n) {
|
|
3
|
+
const applyLag = BigInt(Math.abs(Number(data.highestRelevantWalletIndex - data.appliedIndex)));
|
|
4
|
+
return data.isConnected && applyLag <= maxGap;
|
|
5
|
+
},
|
|
6
|
+
};
|
|
7
|
+
export const createSyncProgress = (params = {}) => {
|
|
8
|
+
const { appliedIndex = 0n, highestRelevantWalletIndex = 0n, highestIndex = 0n, highestRelevantIndex = 0n, isConnected = false, } = params;
|
|
9
|
+
const data = {
|
|
10
|
+
appliedIndex,
|
|
11
|
+
highestRelevantWalletIndex,
|
|
12
|
+
highestIndex,
|
|
13
|
+
highestRelevantIndex,
|
|
14
|
+
isConnected,
|
|
15
|
+
};
|
|
16
|
+
return {
|
|
17
|
+
...data,
|
|
18
|
+
isStrictlyComplete() {
|
|
19
|
+
return SyncProgress.isCompleteWithin(this, 0n);
|
|
20
|
+
},
|
|
21
|
+
isCompleteWithin(maxGap) {
|
|
22
|
+
return SyncProgress.isCompleteWithin(this, maxGap);
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
};
|
package/dist/WalletSeed.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// This file is part of MIDNIGHT-WALLET-SDK.
|
|
2
|
-
// Copyright (C)
|
|
2
|
+
// Copyright (C) Midnight Foundation
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
// You may not use this file except in compliance with the License.
|
package/dist/WalletState.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// This file is part of MIDNIGHT-WALLET-SDK.
|
|
2
|
-
// Copyright (C)
|
|
2
|
+
// Copyright (C) Midnight Foundation
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
// You may not use this file except in compliance with the License.
|
package/dist/index.d.ts
CHANGED
|
@@ -4,3 +4,4 @@ export * as SerializedTransaction from './SerializedTransaction.js';
|
|
|
4
4
|
export * as ProtocolState from './ProtocolState.js';
|
|
5
5
|
export * as ProtocolVersion from './ProtocolVersion.js';
|
|
6
6
|
export * as NetworkId from './NetworkId.js';
|
|
7
|
+
export * as SyncProgress from './SyncProgress.js';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// This file is part of MIDNIGHT-WALLET-SDK.
|
|
2
|
-
// Copyright (C)
|
|
2
|
+
// Copyright (C) Midnight Foundation
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
// You may not use this file except in compliance with the License.
|
|
@@ -16,3 +16,4 @@ export * as SerializedTransaction from './SerializedTransaction.js';
|
|
|
16
16
|
export * as ProtocolState from './ProtocolState.js';
|
|
17
17
|
export * as ProtocolVersion from './ProtocolVersion.js';
|
|
18
18
|
export * as NetworkId from './NetworkId.js';
|
|
19
|
+
export * as SyncProgress from './SyncProgress.js';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midnight-ntwrk/wallet-sdk-abstractions",
|
|
3
3
|
"description": "Domain-specific abstractions for the wallet SDK",
|
|
4
|
-
"version": "2.0.0
|
|
4
|
+
"version": "2.0.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -25,17 +25,7 @@
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"effect": "^3.19.
|
|
29
|
-
},
|
|
30
|
-
"devDependencies": {
|
|
31
|
-
"eslint": "^9.37.0",
|
|
32
|
-
"fast-check": "^4.2.0",
|
|
33
|
-
"prettier": "^3.7.0",
|
|
34
|
-
"publint": "~0.3.14",
|
|
35
|
-
"rimraf": "^6.0.1",
|
|
36
|
-
"to-words": "^4.5.1",
|
|
37
|
-
"typescript": "^5.9.3",
|
|
38
|
-
"vitest": "^4.0.16"
|
|
28
|
+
"effect": "^3.19.19"
|
|
39
29
|
},
|
|
40
30
|
"scripts": {
|
|
41
31
|
"typecheck": "tsc -b ./tsconfig.json --noEmit --force",
|