@midnightntwrk/wallet-sdk-unshielded-wallet 3.1.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 +123 -0
- package/dist/KeyStore.d.ts +19 -0
- package/dist/KeyStore.js +37 -0
- package/dist/UnshieldedWallet.d.ts +72 -0
- package/dist/UnshieldedWallet.js +156 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +15 -0
- package/dist/v1/CoinsAndBalances.d.ts +13 -0
- package/dist/v1/CoinsAndBalances.js +36 -0
- package/dist/v1/CoreWallet.d.ts +24 -0
- package/dist/v1/CoreWallet.js +60 -0
- package/dist/v1/Keys.d.ts +8 -0
- package/dist/v1/Keys.js +23 -0
- package/dist/v1/RunningV1Variant.d.ts +48 -0
- package/dist/v1/RunningV1Variant.js +114 -0
- package/dist/v1/Serialization.d.ts +12 -0
- package/dist/v1/Serialization.js +64 -0
- package/dist/v1/Sync.d.ts +46 -0
- package/dist/v1/Sync.js +137 -0
- package/dist/v1/SyncProgress.d.ts +18 -0
- package/dist/v1/SyncProgress.js +23 -0
- package/dist/v1/SyncSchema.d.ts +447 -0
- package/dist/v1/SyncSchema.js +114 -0
- package/dist/v1/Transacting.d.ts +125 -0
- package/dist/v1/Transacting.js +385 -0
- package/dist/v1/TransactionHistory.d.ts +54 -0
- package/dist/v1/TransactionHistory.js +66 -0
- package/dist/v1/TransactionOps.d.ts +19 -0
- package/dist/v1/TransactionOps.js +98 -0
- package/dist/v1/UnshieldedState.d.ts +37 -0
- package/dist/v1/UnshieldedState.js +67 -0
- package/dist/v1/V1Builder.d.ts +91 -0
- package/dist/v1/V1Builder.js +149 -0
- package/dist/v1/WalletError.d.ts +94 -0
- package/dist/v1/WalletError.js +35 -0
- package/dist/v1/index.d.ts +14 -0
- package/dist/v1/index.js +26 -0
- package/package.json +57 -0
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
import { Schema } from 'effect';
|
|
2
|
+
declare const UtxoWithMetaSchema: Schema.transform<Schema.Struct<{
|
|
3
|
+
value: Schema.Schema<bigint, string, never>;
|
|
4
|
+
owner: typeof Schema.String;
|
|
5
|
+
tokenType: typeof Schema.String;
|
|
6
|
+
intentHash: typeof Schema.String;
|
|
7
|
+
outputIndex: typeof Schema.Number;
|
|
8
|
+
ctime: typeof Schema.Number;
|
|
9
|
+
registeredForDustGeneration: typeof Schema.Boolean;
|
|
10
|
+
}>, Schema.SchemaClass<{
|
|
11
|
+
readonly utxo: {
|
|
12
|
+
readonly type: string;
|
|
13
|
+
readonly value: bigint;
|
|
14
|
+
readonly owner: string;
|
|
15
|
+
readonly intentHash: string;
|
|
16
|
+
readonly outputNo: number;
|
|
17
|
+
};
|
|
18
|
+
readonly meta: {
|
|
19
|
+
readonly ctime: Date;
|
|
20
|
+
readonly registeredForDustGeneration: boolean;
|
|
21
|
+
};
|
|
22
|
+
}, {
|
|
23
|
+
readonly utxo: {
|
|
24
|
+
readonly type: string;
|
|
25
|
+
readonly value: bigint;
|
|
26
|
+
readonly owner: string;
|
|
27
|
+
readonly intentHash: string;
|
|
28
|
+
readonly outputNo: number;
|
|
29
|
+
};
|
|
30
|
+
readonly meta: {
|
|
31
|
+
readonly ctime: Date;
|
|
32
|
+
readonly registeredForDustGeneration: boolean;
|
|
33
|
+
};
|
|
34
|
+
}, never>>;
|
|
35
|
+
export type UtxoWithMeta = Schema.Schema.Type<typeof UtxoWithMetaSchema>;
|
|
36
|
+
export declare const UnshieldedTransactionSchema: Schema.Data<Schema.Struct<{
|
|
37
|
+
id: typeof Schema.Number;
|
|
38
|
+
hash: typeof Schema.String;
|
|
39
|
+
type: Schema.Literal<["RegularTransaction", "SystemTransaction"]>;
|
|
40
|
+
protocolVersion: typeof Schema.Number;
|
|
41
|
+
identifiers: Schema.optional<Schema.Array$<typeof Schema.String>>;
|
|
42
|
+
block: Schema.Struct<{
|
|
43
|
+
timestamp: Schema.transform<typeof Schema.Number, typeof Schema.DateFromSelf>;
|
|
44
|
+
}>;
|
|
45
|
+
fees: Schema.optional<Schema.Struct<{
|
|
46
|
+
paidFees: Schema.Schema<bigint, string, never>;
|
|
47
|
+
estimatedFees: Schema.Schema<bigint, string, never>;
|
|
48
|
+
}>>;
|
|
49
|
+
transactionResult: Schema.optional<Schema.Struct<{
|
|
50
|
+
status: Schema.Literal<["SUCCESS", "FAILURE", "PARTIAL_SUCCESS"]>;
|
|
51
|
+
segments: Schema.NullOr<Schema.Array$<Schema.Struct<{
|
|
52
|
+
id: typeof Schema.Number;
|
|
53
|
+
success: typeof Schema.Boolean;
|
|
54
|
+
}>>>;
|
|
55
|
+
}>>;
|
|
56
|
+
}>>;
|
|
57
|
+
export type UnshieldedTransaction = Schema.Schema.Type<typeof UnshieldedTransactionSchema>;
|
|
58
|
+
export declare const UnshieldedUpdateSchema: Schema.transform<Schema.Struct<{
|
|
59
|
+
type: Schema.Literal<["UnshieldedTransaction"]>;
|
|
60
|
+
transaction: Schema.Data<Schema.Struct<{
|
|
61
|
+
id: typeof Schema.Number;
|
|
62
|
+
hash: typeof Schema.String;
|
|
63
|
+
type: Schema.Literal<["RegularTransaction", "SystemTransaction"]>;
|
|
64
|
+
protocolVersion: typeof Schema.Number;
|
|
65
|
+
identifiers: Schema.optional<Schema.Array$<typeof Schema.String>>;
|
|
66
|
+
block: Schema.Struct<{
|
|
67
|
+
timestamp: Schema.transform<typeof Schema.Number, typeof Schema.DateFromSelf>;
|
|
68
|
+
}>;
|
|
69
|
+
fees: Schema.optional<Schema.Struct<{
|
|
70
|
+
paidFees: Schema.Schema<bigint, string, never>;
|
|
71
|
+
estimatedFees: Schema.Schema<bigint, string, never>;
|
|
72
|
+
}>>;
|
|
73
|
+
transactionResult: Schema.optional<Schema.Struct<{
|
|
74
|
+
status: Schema.Literal<["SUCCESS", "FAILURE", "PARTIAL_SUCCESS"]>;
|
|
75
|
+
segments: Schema.NullOr<Schema.Array$<Schema.Struct<{
|
|
76
|
+
id: typeof Schema.Number;
|
|
77
|
+
success: typeof Schema.Boolean;
|
|
78
|
+
}>>>;
|
|
79
|
+
}>>;
|
|
80
|
+
}>>;
|
|
81
|
+
createdUtxos: Schema.Array$<Schema.transform<Schema.Struct<{
|
|
82
|
+
value: Schema.Schema<bigint, string, never>;
|
|
83
|
+
owner: typeof Schema.String;
|
|
84
|
+
tokenType: typeof Schema.String;
|
|
85
|
+
intentHash: typeof Schema.String;
|
|
86
|
+
outputIndex: typeof Schema.Number;
|
|
87
|
+
ctime: typeof Schema.Number;
|
|
88
|
+
registeredForDustGeneration: typeof Schema.Boolean;
|
|
89
|
+
}>, Schema.SchemaClass<{
|
|
90
|
+
readonly utxo: {
|
|
91
|
+
readonly type: string;
|
|
92
|
+
readonly value: bigint;
|
|
93
|
+
readonly owner: string;
|
|
94
|
+
readonly intentHash: string;
|
|
95
|
+
readonly outputNo: number;
|
|
96
|
+
};
|
|
97
|
+
readonly meta: {
|
|
98
|
+
readonly ctime: Date;
|
|
99
|
+
readonly registeredForDustGeneration: boolean;
|
|
100
|
+
};
|
|
101
|
+
}, {
|
|
102
|
+
readonly utxo: {
|
|
103
|
+
readonly type: string;
|
|
104
|
+
readonly value: bigint;
|
|
105
|
+
readonly owner: string;
|
|
106
|
+
readonly intentHash: string;
|
|
107
|
+
readonly outputNo: number;
|
|
108
|
+
};
|
|
109
|
+
readonly meta: {
|
|
110
|
+
readonly ctime: Date;
|
|
111
|
+
readonly registeredForDustGeneration: boolean;
|
|
112
|
+
};
|
|
113
|
+
}, never>>>;
|
|
114
|
+
spentUtxos: Schema.Array$<Schema.transform<Schema.Struct<{
|
|
115
|
+
value: Schema.Schema<bigint, string, never>;
|
|
116
|
+
owner: typeof Schema.String;
|
|
117
|
+
tokenType: typeof Schema.String;
|
|
118
|
+
intentHash: typeof Schema.String;
|
|
119
|
+
outputIndex: typeof Schema.Number;
|
|
120
|
+
ctime: typeof Schema.Number;
|
|
121
|
+
registeredForDustGeneration: typeof Schema.Boolean;
|
|
122
|
+
}>, Schema.SchemaClass<{
|
|
123
|
+
readonly utxo: {
|
|
124
|
+
readonly type: string;
|
|
125
|
+
readonly value: bigint;
|
|
126
|
+
readonly owner: string;
|
|
127
|
+
readonly intentHash: string;
|
|
128
|
+
readonly outputNo: number;
|
|
129
|
+
};
|
|
130
|
+
readonly meta: {
|
|
131
|
+
readonly ctime: Date;
|
|
132
|
+
readonly registeredForDustGeneration: boolean;
|
|
133
|
+
};
|
|
134
|
+
}, {
|
|
135
|
+
readonly utxo: {
|
|
136
|
+
readonly type: string;
|
|
137
|
+
readonly value: bigint;
|
|
138
|
+
readonly owner: string;
|
|
139
|
+
readonly intentHash: string;
|
|
140
|
+
readonly outputNo: number;
|
|
141
|
+
};
|
|
142
|
+
readonly meta: {
|
|
143
|
+
readonly ctime: Date;
|
|
144
|
+
readonly registeredForDustGeneration: boolean;
|
|
145
|
+
};
|
|
146
|
+
}, never>>>;
|
|
147
|
+
}>, Schema.SchemaClass<{
|
|
148
|
+
readonly type: "UnshieldedTransaction";
|
|
149
|
+
readonly spentUtxos: readonly {
|
|
150
|
+
readonly utxo: {
|
|
151
|
+
readonly type: string;
|
|
152
|
+
readonly value: bigint;
|
|
153
|
+
readonly owner: string;
|
|
154
|
+
readonly intentHash: string;
|
|
155
|
+
readonly outputNo: number;
|
|
156
|
+
};
|
|
157
|
+
readonly meta: {
|
|
158
|
+
readonly ctime: Date;
|
|
159
|
+
readonly registeredForDustGeneration: boolean;
|
|
160
|
+
};
|
|
161
|
+
}[];
|
|
162
|
+
readonly status: "SUCCESS" | "FAILURE" | "PARTIAL_SUCCESS";
|
|
163
|
+
readonly transaction: {
|
|
164
|
+
readonly type: "RegularTransaction" | "SystemTransaction";
|
|
165
|
+
readonly protocolVersion: number;
|
|
166
|
+
readonly id: number;
|
|
167
|
+
readonly hash: string;
|
|
168
|
+
readonly identifiers?: readonly string[] | undefined;
|
|
169
|
+
readonly block: {
|
|
170
|
+
readonly timestamp: Date;
|
|
171
|
+
};
|
|
172
|
+
readonly fees?: {
|
|
173
|
+
readonly paidFees: bigint;
|
|
174
|
+
readonly estimatedFees: bigint;
|
|
175
|
+
} | undefined;
|
|
176
|
+
readonly transactionResult?: {
|
|
177
|
+
readonly status: "SUCCESS" | "FAILURE" | "PARTIAL_SUCCESS";
|
|
178
|
+
readonly segments: readonly {
|
|
179
|
+
readonly id: number;
|
|
180
|
+
readonly success: boolean;
|
|
181
|
+
}[] | null;
|
|
182
|
+
} | undefined;
|
|
183
|
+
};
|
|
184
|
+
readonly createdUtxos: readonly {
|
|
185
|
+
readonly utxo: {
|
|
186
|
+
readonly type: string;
|
|
187
|
+
readonly value: bigint;
|
|
188
|
+
readonly owner: string;
|
|
189
|
+
readonly intentHash: string;
|
|
190
|
+
readonly outputNo: number;
|
|
191
|
+
};
|
|
192
|
+
readonly meta: {
|
|
193
|
+
readonly ctime: Date;
|
|
194
|
+
readonly registeredForDustGeneration: boolean;
|
|
195
|
+
};
|
|
196
|
+
}[];
|
|
197
|
+
}, {
|
|
198
|
+
readonly type: "UnshieldedTransaction";
|
|
199
|
+
readonly spentUtxos: readonly {
|
|
200
|
+
readonly utxo: {
|
|
201
|
+
readonly type: string;
|
|
202
|
+
readonly value: bigint;
|
|
203
|
+
readonly owner: string;
|
|
204
|
+
readonly intentHash: string;
|
|
205
|
+
readonly outputNo: number;
|
|
206
|
+
};
|
|
207
|
+
readonly meta: {
|
|
208
|
+
readonly ctime: Date;
|
|
209
|
+
readonly registeredForDustGeneration: boolean;
|
|
210
|
+
};
|
|
211
|
+
}[];
|
|
212
|
+
readonly status: "SUCCESS" | "FAILURE" | "PARTIAL_SUCCESS";
|
|
213
|
+
readonly transaction: {
|
|
214
|
+
readonly type: "RegularTransaction" | "SystemTransaction";
|
|
215
|
+
readonly protocolVersion: number;
|
|
216
|
+
readonly id: number;
|
|
217
|
+
readonly hash: string;
|
|
218
|
+
readonly identifiers?: readonly string[] | undefined;
|
|
219
|
+
readonly block: {
|
|
220
|
+
readonly timestamp: Date;
|
|
221
|
+
};
|
|
222
|
+
readonly fees?: {
|
|
223
|
+
readonly paidFees: bigint;
|
|
224
|
+
readonly estimatedFees: bigint;
|
|
225
|
+
} | undefined;
|
|
226
|
+
readonly transactionResult?: {
|
|
227
|
+
readonly status: "SUCCESS" | "FAILURE" | "PARTIAL_SUCCESS";
|
|
228
|
+
readonly segments: readonly {
|
|
229
|
+
readonly id: number;
|
|
230
|
+
readonly success: boolean;
|
|
231
|
+
}[] | null;
|
|
232
|
+
} | undefined;
|
|
233
|
+
};
|
|
234
|
+
readonly createdUtxos: readonly {
|
|
235
|
+
readonly utxo: {
|
|
236
|
+
readonly type: string;
|
|
237
|
+
readonly value: bigint;
|
|
238
|
+
readonly owner: string;
|
|
239
|
+
readonly intentHash: string;
|
|
240
|
+
readonly outputNo: number;
|
|
241
|
+
};
|
|
242
|
+
readonly meta: {
|
|
243
|
+
readonly ctime: Date;
|
|
244
|
+
readonly registeredForDustGeneration: boolean;
|
|
245
|
+
};
|
|
246
|
+
}[];
|
|
247
|
+
}, never>>;
|
|
248
|
+
export type UnshieldedUpdate = Schema.Schema.Type<typeof UnshieldedUpdateSchema>;
|
|
249
|
+
export declare const ProgressSchema: Schema.Struct<{
|
|
250
|
+
type: Schema.Literal<["UnshieldedTransactionsProgress"]>;
|
|
251
|
+
highestTransactionId: typeof Schema.Number;
|
|
252
|
+
}>;
|
|
253
|
+
export declare const WalletSyncUpdateSchema: Schema.Union<[Schema.transform<Schema.Struct<{
|
|
254
|
+
type: Schema.Literal<["UnshieldedTransaction"]>;
|
|
255
|
+
transaction: Schema.Data<Schema.Struct<{
|
|
256
|
+
id: typeof Schema.Number;
|
|
257
|
+
hash: typeof Schema.String;
|
|
258
|
+
type: Schema.Literal<["RegularTransaction", "SystemTransaction"]>;
|
|
259
|
+
protocolVersion: typeof Schema.Number;
|
|
260
|
+
identifiers: Schema.optional<Schema.Array$<typeof Schema.String>>;
|
|
261
|
+
block: Schema.Struct<{
|
|
262
|
+
timestamp: Schema.transform<typeof Schema.Number, typeof Schema.DateFromSelf>;
|
|
263
|
+
}>;
|
|
264
|
+
fees: Schema.optional<Schema.Struct<{
|
|
265
|
+
paidFees: Schema.Schema<bigint, string, never>;
|
|
266
|
+
estimatedFees: Schema.Schema<bigint, string, never>;
|
|
267
|
+
}>>;
|
|
268
|
+
transactionResult: Schema.optional<Schema.Struct<{
|
|
269
|
+
status: Schema.Literal<["SUCCESS", "FAILURE", "PARTIAL_SUCCESS"]>;
|
|
270
|
+
segments: Schema.NullOr<Schema.Array$<Schema.Struct<{
|
|
271
|
+
id: typeof Schema.Number;
|
|
272
|
+
success: typeof Schema.Boolean;
|
|
273
|
+
}>>>;
|
|
274
|
+
}>>;
|
|
275
|
+
}>>;
|
|
276
|
+
createdUtxos: Schema.Array$<Schema.transform<Schema.Struct<{
|
|
277
|
+
value: Schema.Schema<bigint, string, never>;
|
|
278
|
+
owner: typeof Schema.String;
|
|
279
|
+
tokenType: typeof Schema.String;
|
|
280
|
+
intentHash: typeof Schema.String;
|
|
281
|
+
outputIndex: typeof Schema.Number;
|
|
282
|
+
ctime: typeof Schema.Number;
|
|
283
|
+
registeredForDustGeneration: typeof Schema.Boolean;
|
|
284
|
+
}>, Schema.SchemaClass<{
|
|
285
|
+
readonly utxo: {
|
|
286
|
+
readonly type: string;
|
|
287
|
+
readonly value: bigint;
|
|
288
|
+
readonly owner: string;
|
|
289
|
+
readonly intentHash: string;
|
|
290
|
+
readonly outputNo: number;
|
|
291
|
+
};
|
|
292
|
+
readonly meta: {
|
|
293
|
+
readonly ctime: Date;
|
|
294
|
+
readonly registeredForDustGeneration: boolean;
|
|
295
|
+
};
|
|
296
|
+
}, {
|
|
297
|
+
readonly utxo: {
|
|
298
|
+
readonly type: string;
|
|
299
|
+
readonly value: bigint;
|
|
300
|
+
readonly owner: string;
|
|
301
|
+
readonly intentHash: string;
|
|
302
|
+
readonly outputNo: number;
|
|
303
|
+
};
|
|
304
|
+
readonly meta: {
|
|
305
|
+
readonly ctime: Date;
|
|
306
|
+
readonly registeredForDustGeneration: boolean;
|
|
307
|
+
};
|
|
308
|
+
}, never>>>;
|
|
309
|
+
spentUtxos: Schema.Array$<Schema.transform<Schema.Struct<{
|
|
310
|
+
value: Schema.Schema<bigint, string, never>;
|
|
311
|
+
owner: typeof Schema.String;
|
|
312
|
+
tokenType: typeof Schema.String;
|
|
313
|
+
intentHash: typeof Schema.String;
|
|
314
|
+
outputIndex: typeof Schema.Number;
|
|
315
|
+
ctime: typeof Schema.Number;
|
|
316
|
+
registeredForDustGeneration: typeof Schema.Boolean;
|
|
317
|
+
}>, Schema.SchemaClass<{
|
|
318
|
+
readonly utxo: {
|
|
319
|
+
readonly type: string;
|
|
320
|
+
readonly value: bigint;
|
|
321
|
+
readonly owner: string;
|
|
322
|
+
readonly intentHash: string;
|
|
323
|
+
readonly outputNo: number;
|
|
324
|
+
};
|
|
325
|
+
readonly meta: {
|
|
326
|
+
readonly ctime: Date;
|
|
327
|
+
readonly registeredForDustGeneration: boolean;
|
|
328
|
+
};
|
|
329
|
+
}, {
|
|
330
|
+
readonly utxo: {
|
|
331
|
+
readonly type: string;
|
|
332
|
+
readonly value: bigint;
|
|
333
|
+
readonly owner: string;
|
|
334
|
+
readonly intentHash: string;
|
|
335
|
+
readonly outputNo: number;
|
|
336
|
+
};
|
|
337
|
+
readonly meta: {
|
|
338
|
+
readonly ctime: Date;
|
|
339
|
+
readonly registeredForDustGeneration: boolean;
|
|
340
|
+
};
|
|
341
|
+
}, never>>>;
|
|
342
|
+
}>, Schema.SchemaClass<{
|
|
343
|
+
readonly type: "UnshieldedTransaction";
|
|
344
|
+
readonly spentUtxos: readonly {
|
|
345
|
+
readonly utxo: {
|
|
346
|
+
readonly type: string;
|
|
347
|
+
readonly value: bigint;
|
|
348
|
+
readonly owner: string;
|
|
349
|
+
readonly intentHash: string;
|
|
350
|
+
readonly outputNo: number;
|
|
351
|
+
};
|
|
352
|
+
readonly meta: {
|
|
353
|
+
readonly ctime: Date;
|
|
354
|
+
readonly registeredForDustGeneration: boolean;
|
|
355
|
+
};
|
|
356
|
+
}[];
|
|
357
|
+
readonly status: "SUCCESS" | "FAILURE" | "PARTIAL_SUCCESS";
|
|
358
|
+
readonly transaction: {
|
|
359
|
+
readonly type: "RegularTransaction" | "SystemTransaction";
|
|
360
|
+
readonly protocolVersion: number;
|
|
361
|
+
readonly id: number;
|
|
362
|
+
readonly hash: string;
|
|
363
|
+
readonly identifiers?: readonly string[] | undefined;
|
|
364
|
+
readonly block: {
|
|
365
|
+
readonly timestamp: Date;
|
|
366
|
+
};
|
|
367
|
+
readonly fees?: {
|
|
368
|
+
readonly paidFees: bigint;
|
|
369
|
+
readonly estimatedFees: bigint;
|
|
370
|
+
} | undefined;
|
|
371
|
+
readonly transactionResult?: {
|
|
372
|
+
readonly status: "SUCCESS" | "FAILURE" | "PARTIAL_SUCCESS";
|
|
373
|
+
readonly segments: readonly {
|
|
374
|
+
readonly id: number;
|
|
375
|
+
readonly success: boolean;
|
|
376
|
+
}[] | null;
|
|
377
|
+
} | undefined;
|
|
378
|
+
};
|
|
379
|
+
readonly createdUtxos: readonly {
|
|
380
|
+
readonly utxo: {
|
|
381
|
+
readonly type: string;
|
|
382
|
+
readonly value: bigint;
|
|
383
|
+
readonly owner: string;
|
|
384
|
+
readonly intentHash: string;
|
|
385
|
+
readonly outputNo: number;
|
|
386
|
+
};
|
|
387
|
+
readonly meta: {
|
|
388
|
+
readonly ctime: Date;
|
|
389
|
+
readonly registeredForDustGeneration: boolean;
|
|
390
|
+
};
|
|
391
|
+
}[];
|
|
392
|
+
}, {
|
|
393
|
+
readonly type: "UnshieldedTransaction";
|
|
394
|
+
readonly spentUtxos: readonly {
|
|
395
|
+
readonly utxo: {
|
|
396
|
+
readonly type: string;
|
|
397
|
+
readonly value: bigint;
|
|
398
|
+
readonly owner: string;
|
|
399
|
+
readonly intentHash: string;
|
|
400
|
+
readonly outputNo: number;
|
|
401
|
+
};
|
|
402
|
+
readonly meta: {
|
|
403
|
+
readonly ctime: Date;
|
|
404
|
+
readonly registeredForDustGeneration: boolean;
|
|
405
|
+
};
|
|
406
|
+
}[];
|
|
407
|
+
readonly status: "SUCCESS" | "FAILURE" | "PARTIAL_SUCCESS";
|
|
408
|
+
readonly transaction: {
|
|
409
|
+
readonly type: "RegularTransaction" | "SystemTransaction";
|
|
410
|
+
readonly protocolVersion: number;
|
|
411
|
+
readonly id: number;
|
|
412
|
+
readonly hash: string;
|
|
413
|
+
readonly identifiers?: readonly string[] | undefined;
|
|
414
|
+
readonly block: {
|
|
415
|
+
readonly timestamp: Date;
|
|
416
|
+
};
|
|
417
|
+
readonly fees?: {
|
|
418
|
+
readonly paidFees: bigint;
|
|
419
|
+
readonly estimatedFees: bigint;
|
|
420
|
+
} | undefined;
|
|
421
|
+
readonly transactionResult?: {
|
|
422
|
+
readonly status: "SUCCESS" | "FAILURE" | "PARTIAL_SUCCESS";
|
|
423
|
+
readonly segments: readonly {
|
|
424
|
+
readonly id: number;
|
|
425
|
+
readonly success: boolean;
|
|
426
|
+
}[] | null;
|
|
427
|
+
} | undefined;
|
|
428
|
+
};
|
|
429
|
+
readonly createdUtxos: readonly {
|
|
430
|
+
readonly utxo: {
|
|
431
|
+
readonly type: string;
|
|
432
|
+
readonly value: bigint;
|
|
433
|
+
readonly owner: string;
|
|
434
|
+
readonly intentHash: string;
|
|
435
|
+
readonly outputNo: number;
|
|
436
|
+
};
|
|
437
|
+
readonly meta: {
|
|
438
|
+
readonly ctime: Date;
|
|
439
|
+
readonly registeredForDustGeneration: boolean;
|
|
440
|
+
};
|
|
441
|
+
}[];
|
|
442
|
+
}, never>>, Schema.Struct<{
|
|
443
|
+
type: Schema.Literal<["UnshieldedTransactionsProgress"]>;
|
|
444
|
+
highestTransactionId: typeof Schema.Number;
|
|
445
|
+
}>]>;
|
|
446
|
+
export type WalletSyncUpdate = Schema.Schema.Type<typeof WalletSyncUpdateSchema>;
|
|
447
|
+
export {};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// This file is part of MIDNIGHT-WALLET-SDK.
|
|
2
|
+
// Copyright (C) Midnight Foundation
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
// You may not use this file except in compliance with the License.
|
|
6
|
+
// You may obtain a copy of the License at
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { Schema } from 'effect';
|
|
14
|
+
import { SafeBigInt } from '@midnightntwrk/wallet-sdk-utilities';
|
|
15
|
+
const DateFromMillis = Schema.transform(Schema.Number, Schema.DateFromSelf, {
|
|
16
|
+
strict: true,
|
|
17
|
+
decode: (millis) => new Date(millis),
|
|
18
|
+
encode: (date) => date.getTime(),
|
|
19
|
+
});
|
|
20
|
+
const WireUtxoSchema = Schema.Struct({
|
|
21
|
+
value: SafeBigInt.SafeBigInt,
|
|
22
|
+
owner: Schema.String,
|
|
23
|
+
tokenType: Schema.String,
|
|
24
|
+
intentHash: Schema.String,
|
|
25
|
+
outputIndex: Schema.Number,
|
|
26
|
+
ctime: Schema.Number,
|
|
27
|
+
registeredForDustGeneration: Schema.Boolean,
|
|
28
|
+
});
|
|
29
|
+
const UtxoWithMetaSchema = Schema.transform(WireUtxoSchema, Schema.typeSchema(Schema.Struct({
|
|
30
|
+
utxo: Schema.Struct({
|
|
31
|
+
value: SafeBigInt.BigIntSchema,
|
|
32
|
+
owner: Schema.String,
|
|
33
|
+
type: Schema.String,
|
|
34
|
+
intentHash: Schema.String,
|
|
35
|
+
outputNo: Schema.Number,
|
|
36
|
+
}),
|
|
37
|
+
meta: Schema.Struct({
|
|
38
|
+
ctime: Schema.DateFromSelf,
|
|
39
|
+
registeredForDustGeneration: Schema.Boolean,
|
|
40
|
+
}),
|
|
41
|
+
})), {
|
|
42
|
+
strict: true,
|
|
43
|
+
decode: (wire) => ({
|
|
44
|
+
utxo: {
|
|
45
|
+
value: wire.value,
|
|
46
|
+
owner: wire.owner,
|
|
47
|
+
type: wire.tokenType,
|
|
48
|
+
intentHash: wire.intentHash,
|
|
49
|
+
outputNo: wire.outputIndex,
|
|
50
|
+
},
|
|
51
|
+
meta: {
|
|
52
|
+
ctime: new Date(wire.ctime * 1000),
|
|
53
|
+
registeredForDustGeneration: wire.registeredForDustGeneration,
|
|
54
|
+
},
|
|
55
|
+
}),
|
|
56
|
+
encode: (domain) => ({
|
|
57
|
+
value: domain.utxo.value,
|
|
58
|
+
owner: domain.utxo.owner,
|
|
59
|
+
tokenType: domain.utxo.type,
|
|
60
|
+
intentHash: domain.utxo.intentHash,
|
|
61
|
+
outputIndex: domain.utxo.outputNo,
|
|
62
|
+
ctime: Math.floor(domain.meta.ctime.getTime() / 1000),
|
|
63
|
+
registeredForDustGeneration: domain.meta.registeredForDustGeneration,
|
|
64
|
+
}),
|
|
65
|
+
});
|
|
66
|
+
export const UnshieldedTransactionSchema = Schema.Data(Schema.Struct({
|
|
67
|
+
id: Schema.Number,
|
|
68
|
+
hash: Schema.String,
|
|
69
|
+
type: Schema.Literal('RegularTransaction', 'SystemTransaction'),
|
|
70
|
+
protocolVersion: Schema.Number,
|
|
71
|
+
identifiers: Schema.optional(Schema.Array(Schema.String)),
|
|
72
|
+
block: Schema.Struct({
|
|
73
|
+
timestamp: DateFromMillis,
|
|
74
|
+
}),
|
|
75
|
+
fees: Schema.optional(Schema.Struct({
|
|
76
|
+
paidFees: SafeBigInt.SafeBigInt,
|
|
77
|
+
estimatedFees: SafeBigInt.SafeBigInt,
|
|
78
|
+
})),
|
|
79
|
+
transactionResult: Schema.optional(Schema.Struct({
|
|
80
|
+
status: Schema.Literal('SUCCESS', 'FAILURE', 'PARTIAL_SUCCESS'),
|
|
81
|
+
segments: Schema.NullOr(Schema.Array(Schema.Struct({
|
|
82
|
+
id: Schema.Number,
|
|
83
|
+
success: Schema.Boolean,
|
|
84
|
+
}))),
|
|
85
|
+
})),
|
|
86
|
+
}));
|
|
87
|
+
const UnshieldedUpdateWireSchema = Schema.Struct({
|
|
88
|
+
type: Schema.Literal('UnshieldedTransaction'),
|
|
89
|
+
transaction: UnshieldedTransactionSchema,
|
|
90
|
+
createdUtxos: Schema.Array(UtxoWithMetaSchema),
|
|
91
|
+
spentUtxos: Schema.Array(UtxoWithMetaSchema),
|
|
92
|
+
});
|
|
93
|
+
export const UnshieldedUpdateSchema = Schema.transform(UnshieldedUpdateWireSchema, Schema.typeSchema(Schema.Struct({
|
|
94
|
+
type: Schema.Literal('UnshieldedTransaction'),
|
|
95
|
+
transaction: UnshieldedTransactionSchema,
|
|
96
|
+
createdUtxos: Schema.Array(Schema.typeSchema(UtxoWithMetaSchema)),
|
|
97
|
+
spentUtxos: Schema.Array(Schema.typeSchema(UtxoWithMetaSchema)),
|
|
98
|
+
status: Schema.Literal('SUCCESS', 'FAILURE', 'PARTIAL_SUCCESS'),
|
|
99
|
+
})), {
|
|
100
|
+
strict: true,
|
|
101
|
+
decode: (wire) => {
|
|
102
|
+
const isSystemTransaction = wire.transaction.type === 'SystemTransaction';
|
|
103
|
+
return {
|
|
104
|
+
...wire,
|
|
105
|
+
status: isSystemTransaction ? 'SUCCESS' : wire.transaction.transactionResult.status,
|
|
106
|
+
};
|
|
107
|
+
},
|
|
108
|
+
encode: ({ status: _status, ...rest }) => rest,
|
|
109
|
+
});
|
|
110
|
+
export const ProgressSchema = Schema.Struct({
|
|
111
|
+
type: Schema.Literal('UnshieldedTransactionsProgress'),
|
|
112
|
+
highestTransactionId: Schema.Number,
|
|
113
|
+
});
|
|
114
|
+
export const WalletSyncUpdateSchema = Schema.Union(UnshieldedUpdateSchema, ProgressSchema);
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import * as ledger from '@midnight-ntwrk/ledger-v8';
|
|
2
|
+
import { type NetworkId } from '@midnightntwrk/wallet-sdk-abstractions';
|
|
3
|
+
import { Either } from 'effect';
|
|
4
|
+
import { CoreWallet } from './CoreWallet.js';
|
|
5
|
+
import { type WalletError } from './WalletError.js';
|
|
6
|
+
import { type UtxoWithMeta } from './UnshieldedState.js';
|
|
7
|
+
import { type CoinSelection } from '@midnightntwrk/wallet-sdk-capabilities';
|
|
8
|
+
import { TransactionOps, type UnboundTransaction } from './TransactionOps.js';
|
|
9
|
+
import { type CoinsAndBalancesCapability } from './CoinsAndBalances.js';
|
|
10
|
+
import { type KeysCapability } from './Keys.js';
|
|
11
|
+
import { type UnshieldedAddress } from '@midnightntwrk/wallet-sdk-address-format';
|
|
12
|
+
export interface TokenTransfer {
|
|
13
|
+
readonly amount: bigint;
|
|
14
|
+
readonly type: ledger.RawTokenType;
|
|
15
|
+
readonly receiverAddress: UnshieldedAddress;
|
|
16
|
+
}
|
|
17
|
+
export type FinalizedTransactionBalanceResult = ledger.UnprovenTransaction | undefined;
|
|
18
|
+
export type UnboundTransactionBalanceResult = UnboundTransaction | undefined;
|
|
19
|
+
export type UnprovenTransactionBalanceResult = ledger.UnprovenTransaction | undefined;
|
|
20
|
+
export type TransactingResult<TTransaction, TState> = {
|
|
21
|
+
readonly newState: TState;
|
|
22
|
+
readonly transaction: TTransaction;
|
|
23
|
+
};
|
|
24
|
+
export interface TransactingCapability<TState> {
|
|
25
|
+
makeTransfer(wallet: CoreWallet, outputs: ReadonlyArray<TokenTransfer>, ttl: Date): Either.Either<TransactingResult<ledger.UnprovenTransaction, TState>, WalletError>;
|
|
26
|
+
initSwap(wallet: CoreWallet, desiredInputs: Record<string, bigint>, outputs: ReadonlyArray<TokenTransfer>, ttl: Date): Either.Either<TransactingResult<ledger.UnprovenTransaction, TState>, WalletError>;
|
|
27
|
+
/**
|
|
28
|
+
* Builds an unproven transaction that moves a caller-supplied set of Night UTxOs back to their current owner,
|
|
29
|
+
* splitting them between the guaranteed and fallible sections of a single intent. The provided UTxOs are booked in
|
|
30
|
+
* the wallet state (moved from available to pending) so that no subsequent build call can pick them.
|
|
31
|
+
*
|
|
32
|
+
* Used by the Dust wallet's registration/deregistration flow, where the Dust wallet picks the guaranteed slot (based
|
|
33
|
+
* on dust generation) and hands both sets here for booking and intent construction. The Dust wallet then attaches its
|
|
34
|
+
* DustActions onto the returned intent.
|
|
35
|
+
*
|
|
36
|
+
* @param wallet - The wallet whose UTxOs are being passed through
|
|
37
|
+
* @param guaranteedUtxos - UTxOs to place in the guaranteed offer (segment 0)
|
|
38
|
+
* @param fallibleUtxos - UTxOs to place in the fallible offer (segment 1+)
|
|
39
|
+
* @param nightVerifyingKey - The verifying key used as the input owner and the address for the consolidating output
|
|
40
|
+
* @param ttl - The TTL for the transaction
|
|
41
|
+
* @returns The new wallet state (with all provided UTxOs booked) and the unproven transaction
|
|
42
|
+
*/
|
|
43
|
+
rotateUtxos(wallet: CoreWallet, guaranteedUtxos: ReadonlyArray<UtxoWithMeta>, fallibleUtxos: ReadonlyArray<UtxoWithMeta>, nightVerifyingKey: ledger.SignatureVerifyingKey, ttl: Date): Either.Either<TransactingResult<ledger.UnprovenTransaction, TState>, WalletError>;
|
|
44
|
+
balanceFinalizedTransaction(wallet: CoreWallet, transaction: ledger.FinalizedTransaction): Either.Either<[FinalizedTransactionBalanceResult, CoreWallet], WalletError>;
|
|
45
|
+
balanceUnboundTransaction(wallet: CoreWallet, transaction: UnboundTransaction): Either.Either<[UnboundTransactionBalanceResult, CoreWallet], WalletError>;
|
|
46
|
+
balanceUnprovenTransaction(wallet: CoreWallet, transaction: ledger.UnprovenTransaction): Either.Either<[UnprovenTransactionBalanceResult, CoreWallet], WalletError>;
|
|
47
|
+
signUnprovenTransaction(transaction: ledger.UnprovenTransaction, signSegment: (data: Uint8Array) => ledger.Signature): Either.Either<ledger.UnprovenTransaction, WalletError>;
|
|
48
|
+
revertTransaction(wallet: CoreWallet, transaction: ledger.Transaction<ledger.SignatureEnabled, ledger.Proofish, ledger.Bindingish>): Either.Either<CoreWallet, WalletError>;
|
|
49
|
+
signUnboundTransaction(transaction: UnboundTransaction, signSegment: (data: Uint8Array) => ledger.Signature): Either.Either<UnboundTransaction, WalletError>;
|
|
50
|
+
}
|
|
51
|
+
export type DefaultTransactingConfiguration = {
|
|
52
|
+
networkId: NetworkId.NetworkId;
|
|
53
|
+
};
|
|
54
|
+
export type DefaultTransactingContext = {
|
|
55
|
+
coinSelection: CoinSelection<ledger.Utxo>;
|
|
56
|
+
coinsAndBalancesCapability: CoinsAndBalancesCapability<CoreWallet>;
|
|
57
|
+
keysCapability: KeysCapability<CoreWallet>;
|
|
58
|
+
};
|
|
59
|
+
export declare const makeDefaultTransactingCapability: (config: DefaultTransactingConfiguration, getContext: () => DefaultTransactingContext) => TransactingCapability<CoreWallet>;
|
|
60
|
+
export declare class TransactingCapabilityImplementation implements TransactingCapability<CoreWallet> {
|
|
61
|
+
#private;
|
|
62
|
+
readonly networkId: NetworkId.NetworkId;
|
|
63
|
+
readonly getCoinSelection: () => CoinSelection<ledger.Utxo>;
|
|
64
|
+
readonly txOps: TransactionOps;
|
|
65
|
+
readonly getCoins: () => CoinsAndBalancesCapability<CoreWallet>;
|
|
66
|
+
readonly getKeys: () => KeysCapability<CoreWallet>;
|
|
67
|
+
constructor(networkId: NetworkId.NetworkId, getCoinSelection: () => CoinSelection<ledger.Utxo>, getCoins: () => CoinsAndBalancesCapability<CoreWallet>, getKeys: () => KeysCapability<CoreWallet>, txOps: TransactionOps);
|
|
68
|
+
/**
|
|
69
|
+
* Balances an unbound transaction Note: Unbound transactions are balanced in place and returned
|
|
70
|
+
*
|
|
71
|
+
* @param wallet - The wallet to balance the transaction with
|
|
72
|
+
* @param transaction - The transaction to balance
|
|
73
|
+
* @returns The balanced transaction and the new wallet state if successful, otherwise an error
|
|
74
|
+
*/
|
|
75
|
+
balanceUnboundTransaction(wallet: CoreWallet, transaction: UnboundTransaction): Either.Either<[UnboundTransactionBalanceResult, CoreWallet], WalletError>;
|
|
76
|
+
/**
|
|
77
|
+
* Balances an unproven transaction Note: This method does the same thing as balanceUnboundTransaction but is provided
|
|
78
|
+
* for convenience and type safety
|
|
79
|
+
*
|
|
80
|
+
* @param wallet - The wallet to balance the transaction with
|
|
81
|
+
* @param transaction - The transaction to balance
|
|
82
|
+
* @returns The balanced transaction and the new wallet state if successful, otherwise an error
|
|
83
|
+
*/
|
|
84
|
+
balanceUnprovenTransaction(wallet: CoreWallet, transaction: ledger.UnprovenTransaction): Either.Either<[UnprovenTransactionBalanceResult, CoreWallet], WalletError>;
|
|
85
|
+
/**
|
|
86
|
+
* Balances a bound transaction Note: In bound transactions we can only balance the guaranteed section in intents
|
|
87
|
+
*
|
|
88
|
+
* @param wallet - The wallet to balance the transaction with
|
|
89
|
+
* @param transaction - The transaction to balance
|
|
90
|
+
* @returns A balancing counterpart transaction (which should be merged with the original transaction ) and the new
|
|
91
|
+
* wallet state if successful, otherwise an error
|
|
92
|
+
*/
|
|
93
|
+
balanceFinalizedTransaction(wallet: CoreWallet, transaction: ledger.FinalizedTransaction): Either.Either<[FinalizedTransactionBalanceResult, CoreWallet], WalletError>;
|
|
94
|
+
/**
|
|
95
|
+
* Makes a transfer transaction
|
|
96
|
+
*
|
|
97
|
+
* @param wallet - The wallet to make the transfer with
|
|
98
|
+
* @param outputs - The outputs for the transfer
|
|
99
|
+
* @param ttl - The TTL for the transaction
|
|
100
|
+
* @returns The balanced transfer transaction and the new wallet state if successful, otherwise an error
|
|
101
|
+
*/
|
|
102
|
+
makeTransfer(wallet: CoreWallet, outputs: ReadonlyArray<TokenTransfer>, ttl: Date): Either.Either<TransactingResult<ledger.UnprovenTransaction, CoreWallet>, WalletError>;
|
|
103
|
+
rotateUtxos(wallet: CoreWallet, guaranteedUtxos: ReadonlyArray<UtxoWithMeta>, fallibleUtxos: ReadonlyArray<UtxoWithMeta>, nightVerifyingKey: ledger.SignatureVerifyingKey, ttl: Date): Either.Either<TransactingResult<ledger.UnprovenTransaction, CoreWallet>, WalletError>;
|
|
104
|
+
/**
|
|
105
|
+
* Initializes a swap transaction
|
|
106
|
+
*
|
|
107
|
+
* @param wallet - The wallet to initialize the swap for
|
|
108
|
+
* @param desiredInputs - The desired inputs for the swap
|
|
109
|
+
* @param desiredOutputs - The desired outputs for the swap
|
|
110
|
+
* @param ttl - The TTL for the swap
|
|
111
|
+
* @returns The initialized swap transaction and the new wallet state if successful, otherwise an error
|
|
112
|
+
*/
|
|
113
|
+
initSwap(wallet: CoreWallet, desiredInputs: Record<ledger.RawTokenType, bigint>, desiredOutputs: ReadonlyArray<TokenTransfer>, ttl: Date): Either.Either<TransactingResult<ledger.UnprovenTransaction, CoreWallet>, WalletError>;
|
|
114
|
+
signUnprovenTransaction(transaction: ledger.UnprovenTransaction, signSegment: (data: Uint8Array) => ledger.Signature): Either.Either<ledger.UnprovenTransaction, WalletError>;
|
|
115
|
+
signUnboundTransaction(transaction: UnboundTransaction, signSegment: (data: Uint8Array) => ledger.Signature): Either.Either<UnboundTransaction, WalletError>;
|
|
116
|
+
/**
|
|
117
|
+
* Reverts a transaction by rolling back all inputs owned by this wallet
|
|
118
|
+
*
|
|
119
|
+
* @param wallet - The wallet to revert the transaction for
|
|
120
|
+
* @param transaction - The transaction to revert (can be FinalizedTransaction, UnboundTransaction, or
|
|
121
|
+
* UnprovenTransaction)
|
|
122
|
+
* @returns The updated wallet with rolled back UTXOs if successful, otherwise an error
|
|
123
|
+
*/
|
|
124
|
+
revertTransaction(wallet: CoreWallet, transaction: ledger.Transaction<ledger.SignatureEnabled, ledger.Proofish, ledger.Bindingish>): Either.Either<CoreWallet, WalletError>;
|
|
125
|
+
}
|