@midnightntwrk/wallet-sdk-unshielded-wallet 4.0.0-beta.0 → 4.0.0-beta.1
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/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/v1/SyncSchema.d.ts +14 -0
- package/dist/v1/SyncSchema.js +2 -0
- package/dist/v1/TransactionHistory.d.ts +35 -10
- package/dist/v1/TransactionHistory.js +19 -7
- package/package.json +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export * from './UnshieldedWallet.js';
|
|
2
|
-
export { type UnshieldedTransactionHistoryEntry, UnshieldedSectionSchema } from './v1/TransactionHistory.js';
|
|
2
|
+
export { type UnshieldedTransactionHistoryEntry, UnshieldedSectionSchema, mergeUnshieldedSections, } from './v1/TransactionHistory.js';
|
|
3
3
|
export * from './KeyStore.js';
|
package/dist/index.js
CHANGED
|
@@ -11,5 +11,5 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
export * from './UnshieldedWallet.js';
|
|
14
|
-
export { UnshieldedSectionSchema } from './v1/TransactionHistory.js';
|
|
14
|
+
export { UnshieldedSectionSchema, mergeUnshieldedSections, } from './v1/TransactionHistory.js';
|
|
15
15
|
export * from './KeyStore.js';
|
package/dist/v1/SyncSchema.d.ts
CHANGED
|
@@ -40,6 +40,8 @@ export declare const UnshieldedTransactionSchema: Schema.Data<Schema.Struct<{
|
|
|
40
40
|
protocolVersion: typeof Schema.Number;
|
|
41
41
|
identifiers: Schema.optional<Schema.Array$<typeof Schema.String>>;
|
|
42
42
|
block: Schema.Struct<{
|
|
43
|
+
hash: typeof Schema.String;
|
|
44
|
+
height: typeof Schema.Number;
|
|
43
45
|
timestamp: Schema.transform<typeof Schema.Number, typeof Schema.DateFromSelf>;
|
|
44
46
|
}>;
|
|
45
47
|
fees: Schema.optional<Schema.Struct<{
|
|
@@ -64,6 +66,8 @@ export declare const UnshieldedUpdateSchema: Schema.transform<Schema.Struct<{
|
|
|
64
66
|
protocolVersion: typeof Schema.Number;
|
|
65
67
|
identifiers: Schema.optional<Schema.Array$<typeof Schema.String>>;
|
|
66
68
|
block: Schema.Struct<{
|
|
69
|
+
hash: typeof Schema.String;
|
|
70
|
+
height: typeof Schema.Number;
|
|
67
71
|
timestamp: Schema.transform<typeof Schema.Number, typeof Schema.DateFromSelf>;
|
|
68
72
|
}>;
|
|
69
73
|
fees: Schema.optional<Schema.Struct<{
|
|
@@ -167,6 +171,8 @@ export declare const UnshieldedUpdateSchema: Schema.transform<Schema.Struct<{
|
|
|
167
171
|
readonly hash: string;
|
|
168
172
|
readonly identifiers?: readonly string[] | undefined;
|
|
169
173
|
readonly block: {
|
|
174
|
+
readonly hash: string;
|
|
175
|
+
readonly height: number;
|
|
170
176
|
readonly timestamp: Date;
|
|
171
177
|
};
|
|
172
178
|
readonly fees?: {
|
|
@@ -217,6 +223,8 @@ export declare const UnshieldedUpdateSchema: Schema.transform<Schema.Struct<{
|
|
|
217
223
|
readonly hash: string;
|
|
218
224
|
readonly identifiers?: readonly string[] | undefined;
|
|
219
225
|
readonly block: {
|
|
226
|
+
readonly hash: string;
|
|
227
|
+
readonly height: number;
|
|
220
228
|
readonly timestamp: Date;
|
|
221
229
|
};
|
|
222
230
|
readonly fees?: {
|
|
@@ -259,6 +267,8 @@ export declare const WalletSyncUpdateSchema: Schema.Union<[Schema.transform<Sche
|
|
|
259
267
|
protocolVersion: typeof Schema.Number;
|
|
260
268
|
identifiers: Schema.optional<Schema.Array$<typeof Schema.String>>;
|
|
261
269
|
block: Schema.Struct<{
|
|
270
|
+
hash: typeof Schema.String;
|
|
271
|
+
height: typeof Schema.Number;
|
|
262
272
|
timestamp: Schema.transform<typeof Schema.Number, typeof Schema.DateFromSelf>;
|
|
263
273
|
}>;
|
|
264
274
|
fees: Schema.optional<Schema.Struct<{
|
|
@@ -362,6 +372,8 @@ export declare const WalletSyncUpdateSchema: Schema.Union<[Schema.transform<Sche
|
|
|
362
372
|
readonly hash: string;
|
|
363
373
|
readonly identifiers?: readonly string[] | undefined;
|
|
364
374
|
readonly block: {
|
|
375
|
+
readonly hash: string;
|
|
376
|
+
readonly height: number;
|
|
365
377
|
readonly timestamp: Date;
|
|
366
378
|
};
|
|
367
379
|
readonly fees?: {
|
|
@@ -412,6 +424,8 @@ export declare const WalletSyncUpdateSchema: Schema.Union<[Schema.transform<Sche
|
|
|
412
424
|
readonly hash: string;
|
|
413
425
|
readonly identifiers?: readonly string[] | undefined;
|
|
414
426
|
readonly block: {
|
|
427
|
+
readonly hash: string;
|
|
428
|
+
readonly height: number;
|
|
415
429
|
readonly timestamp: Date;
|
|
416
430
|
};
|
|
417
431
|
readonly fees?: {
|
package/dist/v1/SyncSchema.js
CHANGED
|
@@ -70,6 +70,8 @@ export const UnshieldedTransactionSchema = Schema.Data(Schema.Struct({
|
|
|
70
70
|
protocolVersion: Schema.Number,
|
|
71
71
|
identifiers: Schema.optional(Schema.Array(Schema.String)),
|
|
72
72
|
block: Schema.Struct({
|
|
73
|
+
hash: Schema.String,
|
|
74
|
+
height: Schema.Number,
|
|
73
75
|
timestamp: DateFromMillis,
|
|
74
76
|
}),
|
|
75
77
|
fees: Schema.optional(Schema.Struct({
|
|
@@ -19,8 +19,37 @@ export declare const UnshieldedSectionSchema: Schema.Struct<{
|
|
|
19
19
|
outputIndex: typeof Schema.Number;
|
|
20
20
|
}>>;
|
|
21
21
|
}>;
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
type UnshieldedSection = Schema.Schema.Type<typeof UnshieldedSectionSchema>;
|
|
23
|
+
export declare const mergeUnshieldedSections: (existing: UnshieldedSection, incoming: UnshieldedSection) => UnshieldedSection;
|
|
24
|
+
/**
|
|
25
|
+
* Unshielded entry schema. Extends the common entry shape with an optional `unshielded` section. Tightening — required
|
|
26
|
+
* `unshielded` plus required `protocolVersion`/`status`/`timestamp` — happens at the writer-input type, not on the
|
|
27
|
+
* stored shape. Fees are not unshielded's concern (dust pays them); unshielded never writes `fees`.
|
|
28
|
+
*/
|
|
29
|
+
export declare const UnshieldedTransactionHistoryEntrySchema: Schema.Struct<Readonly<{
|
|
30
|
+
hash: typeof Schema.String;
|
|
31
|
+
identifiers: Schema.Array$<typeof Schema.String>;
|
|
32
|
+
protocolVersion: Schema.optional<typeof Schema.Number>;
|
|
33
|
+
status: Schema.optional<Schema.Literal<["SUCCESS", "FAILURE", "PARTIAL_SUCCESS"]>>;
|
|
34
|
+
timestamp: Schema.optional<typeof Schema.Date>;
|
|
35
|
+
fees: Schema.optional<Schema.NullOr<typeof Schema.BigInt>>;
|
|
36
|
+
lifecycle: Schema.Union<[Schema.Struct<{
|
|
37
|
+
status: Schema.Literal<["pending"]>;
|
|
38
|
+
submittedAt: typeof Schema.Date;
|
|
39
|
+
}>, Schema.Struct<{
|
|
40
|
+
status: Schema.Literal<["finalized"]>;
|
|
41
|
+
finalizedBlock: Schema.Struct<{
|
|
42
|
+
hash: typeof Schema.String;
|
|
43
|
+
height: typeof Schema.Number;
|
|
44
|
+
timestamp: typeof Schema.Date;
|
|
45
|
+
}>;
|
|
46
|
+
}>, Schema.Struct<{
|
|
47
|
+
status: Schema.Literal<["rejected"]>;
|
|
48
|
+
rejectedAt: typeof Schema.Date;
|
|
49
|
+
reason: Schema.optional<typeof Schema.String>;
|
|
50
|
+
}>]>;
|
|
51
|
+
}> & {
|
|
52
|
+
unshielded: Schema.optional<Schema.Struct<{
|
|
24
53
|
id: typeof Schema.Number;
|
|
25
54
|
createdUtxos: Schema.Array$<Schema.Struct<{
|
|
26
55
|
value: Schema.Schema<bigint, string, never>;
|
|
@@ -36,19 +65,15 @@ export declare const UnshieldedTransactionHistoryEntrySchema: Schema.Struct<{
|
|
|
36
65
|
intentHash: typeof Schema.String;
|
|
37
66
|
outputIndex: typeof Schema.Number;
|
|
38
67
|
}>>;
|
|
39
|
-
}
|
|
40
|
-
hash: typeof Schema.String;
|
|
41
|
-
protocolVersion: typeof Schema.Number;
|
|
42
|
-
status: Schema.Literal<["SUCCESS", "FAILURE", "PARTIAL_SUCCESS"]>;
|
|
43
|
-
identifiers: Schema.optional<Schema.Array$<typeof Schema.String>>;
|
|
44
|
-
timestamp: Schema.optional<typeof Schema.Date>;
|
|
45
|
-
fees: Schema.optional<Schema.NullOr<typeof Schema.BigInt>>;
|
|
68
|
+
}>>;
|
|
46
69
|
}>;
|
|
47
70
|
export type UnshieldedTransactionHistoryEntry = Schema.Schema.Type<typeof UnshieldedTransactionHistoryEntrySchema>;
|
|
48
71
|
export type TransactionHistoryService = {
|
|
49
72
|
put(update: UnshieldedUpdate): Effect.Effect<void, TransactionHistoryError>;
|
|
50
73
|
};
|
|
74
|
+
export type UnshieldedHistoryStorage = TransactionHistoryStorage.TransactionHistoryReader<TransactionHistoryStorage.TransactionHistoryEntryWithHash> & TransactionHistoryStorage.TransactionHistoryWriter<UnshieldedTransactionHistoryEntry>;
|
|
51
75
|
export type DefaultTransactionHistoryConfiguration = {
|
|
52
|
-
txHistoryStorage:
|
|
76
|
+
txHistoryStorage: UnshieldedHistoryStorage;
|
|
53
77
|
};
|
|
54
78
|
export declare const makeDefaultTransactionHistoryService: (config: DefaultTransactionHistoryConfiguration, _getContext: () => unknown) => TransactionHistoryService;
|
|
79
|
+
export {};
|
|
@@ -26,17 +26,29 @@ export const UnshieldedSectionSchema = Schema.Struct({
|
|
|
26
26
|
createdUtxos: Schema.Array(UtxoSchema),
|
|
27
27
|
spentUtxos: Schema.Array(UtxoSchema),
|
|
28
28
|
});
|
|
29
|
-
export const
|
|
30
|
-
...
|
|
31
|
-
|
|
29
|
+
export const mergeUnshieldedSections = (existing, incoming) => ({
|
|
30
|
+
...existing,
|
|
31
|
+
...incoming,
|
|
32
32
|
});
|
|
33
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Unshielded entry schema. Extends the common entry shape with an optional `unshielded` section. Tightening — required
|
|
35
|
+
* `unshielded` plus required `protocolVersion`/`status`/`timestamp` — happens at the writer-input type, not on the
|
|
36
|
+
* stored shape. Fees are not unshielded's concern (dust pays them); unshielded never writes `fees`.
|
|
37
|
+
*/
|
|
38
|
+
export const UnshieldedTransactionHistoryEntrySchema = TransactionHistoryStorage.extendEntrySchema({
|
|
39
|
+
unshielded: Schema.optional(UnshieldedSectionSchema),
|
|
40
|
+
});
|
|
41
|
+
const convertUpdateToFinalizedInput = ({ transaction, createdUtxos, spentUtxos, status, }) => ({
|
|
34
42
|
hash: transaction.hash,
|
|
35
43
|
protocolVersion: transaction.protocolVersion,
|
|
36
44
|
status,
|
|
37
45
|
identifiers: transaction.identifiers ?? [],
|
|
38
46
|
timestamp: transaction.block.timestamp,
|
|
39
|
-
|
|
47
|
+
finalizedBlock: {
|
|
48
|
+
hash: transaction.block.hash,
|
|
49
|
+
height: transaction.block.height,
|
|
50
|
+
timestamp: transaction.block.timestamp,
|
|
51
|
+
},
|
|
40
52
|
unshielded: {
|
|
41
53
|
id: transaction.id,
|
|
42
54
|
createdUtxos: createdUtxos.map(({ utxo }) => ({
|
|
@@ -59,8 +71,8 @@ export const makeDefaultTransactionHistoryService = (config, _getContext) => {
|
|
|
59
71
|
const txHistoryStorage = config.txHistoryStorage;
|
|
60
72
|
return {
|
|
61
73
|
put: (update) => Effect.tryPromise({
|
|
62
|
-
try: () => txHistoryStorage.
|
|
63
|
-
catch: (e) => new TransactionHistoryError({ message: 'Failed to
|
|
74
|
+
try: () => txHistoryStorage.gotFinalized(convertUpdateToFinalizedInput(update)),
|
|
75
|
+
catch: (e) => new TransactionHistoryError({ message: 'Failed to record finalized history entry', cause: e }),
|
|
64
76
|
}),
|
|
65
77
|
};
|
|
66
78
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midnightntwrk/wallet-sdk-unshielded-wallet",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@midnightntwrk/ledger-v9": "1.0.0-rc.2",
|
|
34
|
-
"@midnightntwrk/wallet-sdk-abstractions": "
|
|
35
|
-
"@midnightntwrk/wallet-sdk-address-format": "
|
|
36
|
-
"@midnightntwrk/wallet-sdk-capabilities": "
|
|
37
|
-
"@midnightntwrk/wallet-sdk-indexer-client": "
|
|
38
|
-
"@midnightntwrk/wallet-sdk-runtime": "
|
|
39
|
-
"@midnightntwrk/wallet-sdk-utilities": "
|
|
34
|
+
"@midnightntwrk/wallet-sdk-abstractions": "3.0.0-beta.0",
|
|
35
|
+
"@midnightntwrk/wallet-sdk-address-format": "4.0.0-beta.1",
|
|
36
|
+
"@midnightntwrk/wallet-sdk-capabilities": "4.0.0-beta.1",
|
|
37
|
+
"@midnightntwrk/wallet-sdk-indexer-client": "1.3.0-beta.1",
|
|
38
|
+
"@midnightntwrk/wallet-sdk-runtime": "1.0.6-beta.0",
|
|
39
|
+
"@midnightntwrk/wallet-sdk-utilities": "1.2.0",
|
|
40
40
|
"effect": "^3.19.19",
|
|
41
41
|
"rxjs": "^7.8.2"
|
|
42
42
|
},
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"publint": "publint --strict"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@midnightntwrk/wallet-sdk-hd": "^3.1.0-beta.
|
|
57
|
+
"@midnightntwrk/wallet-sdk-hd": "^3.1.0-beta.1",
|
|
58
58
|
"@noble/curves": "^1.9.7",
|
|
59
59
|
"@noble/hashes": "^1.8.0"
|
|
60
60
|
}
|