@midnight-ntwrk/wallet-sdk-unshielded-wallet 1.0.0-beta.13 → 1.0.0-beta.14
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/KeyStore.d.ts +3 -7
- package/dist/KeyStore.js +2 -2
- package/dist/UnshieldedWallet.d.ts +57 -0
- package/dist/UnshieldedWallet.js +120 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -2
- package/dist/{tx-history-storage → storage}/InMemoryTransactionHistoryStorage.d.ts +3 -7
- package/dist/{tx-history-storage → storage}/TransactionHistoryStorage.d.ts +3 -7
- package/dist/{tx-history-storage → storage}/TransactionHistoryStorage.js +3 -7
- package/dist/{tx-history-storage → storage}/index.d.ts +1 -0
- package/dist/{tx-history-storage → storage}/index.js +1 -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 +41 -0
- package/dist/v1/RunningV1Variant.js +91 -0
- package/dist/v1/Serialization.d.ts +12 -0
- package/dist/v1/Serialization.js +64 -0
- package/dist/v1/Simulator.d.ts +22 -0
- package/dist/v1/Simulator.js +102 -0
- package/dist/v1/Sync.d.ts +32 -0
- package/dist/v1/Sync.js +85 -0
- package/dist/v1/SyncProgress.d.ts +18 -0
- package/dist/v1/SyncProgress.js +23 -0
- package/dist/v1/SyncSchema.d.ts +449 -0
- package/dist/v1/SyncSchema.js +123 -0
- package/dist/v1/Transacting.d.ts +45 -0
- package/dist/v1/Transacting.js +252 -0
- package/dist/v1/Transaction.d.ts +25 -0
- package/dist/v1/Transaction.js +155 -0
- package/dist/v1/TransactionHistory.d.ts +12 -0
- package/dist/v1/TransactionHistory.js +29 -0
- package/dist/v1/TransactionImbalances.d.ts +8 -0
- package/dist/v1/TransactionImbalances.js +21 -0
- package/dist/v1/UnshieldedState.d.ts +37 -0
- package/dist/v1/UnshieldedState.js +67 -0
- package/dist/v1/V1Builder.d.ts +97 -0
- package/dist/v1/V1Builder.js +160 -0
- package/dist/v1/WalletError.d.ts +89 -0
- package/dist/v1/WalletError.js +53 -0
- package/dist/v1/index.d.ts +15 -0
- package/dist/v1/index.js +27 -0
- package/package.json +4 -4
- package/dist/State.d.ts +0 -21
- package/dist/State.js +0 -43
- package/dist/SyncService.d.ts +0 -55
- package/dist/SyncService.js +0 -88
- package/dist/TransactionHistoryService.d.ts +0 -31
- package/dist/TransactionHistoryService.js +0 -49
- package/dist/TransactionService.d.ts +0 -43
- package/dist/TransactionService.js +0 -291
- package/dist/WalletBuilder.d.ts +0 -37
- package/dist/WalletBuilder.js +0 -137
- /package/dist/{tx-history-storage → storage}/InMemoryTransactionHistoryStorage.js +0 -0
- /package/dist/{tx-history-storage → storage}/NoOpTransactionHistoryStorage.d.ts +0 -0
- /package/dist/{tx-history-storage → storage}/NoOpTransactionHistoryStorage.js +0 -0
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
import { Schema } from 'effect';
|
|
2
|
+
export declare const BigIntSchema: Schema.declare<bigint, bigint, readonly [], never>;
|
|
3
|
+
export declare const SafeBigInt: Schema.Schema<bigint, string>;
|
|
4
|
+
declare const UtxoWithMetaSchema: Schema.transform<Schema.Struct<{
|
|
5
|
+
value: Schema.Schema<bigint, string, never>;
|
|
6
|
+
owner: typeof Schema.String;
|
|
7
|
+
tokenType: typeof Schema.String;
|
|
8
|
+
intentHash: typeof Schema.String;
|
|
9
|
+
outputIndex: typeof Schema.Number;
|
|
10
|
+
ctime: typeof Schema.Number;
|
|
11
|
+
registeredForDustGeneration: typeof Schema.Boolean;
|
|
12
|
+
}>, Schema.SchemaClass<{
|
|
13
|
+
readonly utxo: {
|
|
14
|
+
readonly type: string;
|
|
15
|
+
readonly value: bigint;
|
|
16
|
+
readonly owner: string;
|
|
17
|
+
readonly intentHash: string;
|
|
18
|
+
readonly outputNo: number;
|
|
19
|
+
};
|
|
20
|
+
readonly meta: {
|
|
21
|
+
readonly ctime: Date;
|
|
22
|
+
readonly registeredForDustGeneration: boolean;
|
|
23
|
+
};
|
|
24
|
+
}, {
|
|
25
|
+
readonly utxo: {
|
|
26
|
+
readonly type: string;
|
|
27
|
+
readonly value: bigint;
|
|
28
|
+
readonly owner: string;
|
|
29
|
+
readonly intentHash: string;
|
|
30
|
+
readonly outputNo: number;
|
|
31
|
+
};
|
|
32
|
+
readonly meta: {
|
|
33
|
+
readonly ctime: Date;
|
|
34
|
+
readonly registeredForDustGeneration: boolean;
|
|
35
|
+
};
|
|
36
|
+
}, never>>;
|
|
37
|
+
export type UtxoWithMeta = Schema.Schema.Type<typeof UtxoWithMetaSchema>;
|
|
38
|
+
export declare const UnshieldedTransactionSchema: Schema.Data<Schema.Struct<{
|
|
39
|
+
id: typeof Schema.Number;
|
|
40
|
+
hash: typeof Schema.String;
|
|
41
|
+
type: Schema.Literal<["RegularTransaction", "SystemTransaction"]>;
|
|
42
|
+
protocolVersion: typeof Schema.Number;
|
|
43
|
+
identifiers: Schema.optional<Schema.Array$<typeof Schema.String>>;
|
|
44
|
+
block: Schema.Struct<{
|
|
45
|
+
timestamp: Schema.transform<typeof Schema.Number, typeof Schema.DateFromSelf>;
|
|
46
|
+
}>;
|
|
47
|
+
fees: Schema.optional<Schema.Struct<{
|
|
48
|
+
paidFees: Schema.Schema<bigint, string, never>;
|
|
49
|
+
estimatedFees: Schema.Schema<bigint, string, never>;
|
|
50
|
+
}>>;
|
|
51
|
+
transactionResult: Schema.optional<Schema.Struct<{
|
|
52
|
+
status: Schema.Literal<["SUCCESS", "FAILURE", "PARTIAL_SUCCESS"]>;
|
|
53
|
+
segments: Schema.NullOr<Schema.Array$<Schema.Struct<{
|
|
54
|
+
id: typeof Schema.Number;
|
|
55
|
+
success: typeof Schema.Boolean;
|
|
56
|
+
}>>>;
|
|
57
|
+
}>>;
|
|
58
|
+
}>>;
|
|
59
|
+
export type UnshieldedTransaction = Schema.Schema.Type<typeof UnshieldedTransactionSchema>;
|
|
60
|
+
export declare const UnshieldedUpdateSchema: Schema.transform<Schema.Struct<{
|
|
61
|
+
type: Schema.Literal<["UnshieldedTransaction"]>;
|
|
62
|
+
transaction: Schema.Data<Schema.Struct<{
|
|
63
|
+
id: typeof Schema.Number;
|
|
64
|
+
hash: typeof Schema.String;
|
|
65
|
+
type: Schema.Literal<["RegularTransaction", "SystemTransaction"]>;
|
|
66
|
+
protocolVersion: typeof Schema.Number;
|
|
67
|
+
identifiers: Schema.optional<Schema.Array$<typeof Schema.String>>;
|
|
68
|
+
block: Schema.Struct<{
|
|
69
|
+
timestamp: Schema.transform<typeof Schema.Number, typeof Schema.DateFromSelf>;
|
|
70
|
+
}>;
|
|
71
|
+
fees: Schema.optional<Schema.Struct<{
|
|
72
|
+
paidFees: Schema.Schema<bigint, string, never>;
|
|
73
|
+
estimatedFees: Schema.Schema<bigint, string, never>;
|
|
74
|
+
}>>;
|
|
75
|
+
transactionResult: Schema.optional<Schema.Struct<{
|
|
76
|
+
status: Schema.Literal<["SUCCESS", "FAILURE", "PARTIAL_SUCCESS"]>;
|
|
77
|
+
segments: Schema.NullOr<Schema.Array$<Schema.Struct<{
|
|
78
|
+
id: typeof Schema.Number;
|
|
79
|
+
success: typeof Schema.Boolean;
|
|
80
|
+
}>>>;
|
|
81
|
+
}>>;
|
|
82
|
+
}>>;
|
|
83
|
+
createdUtxos: Schema.Array$<Schema.transform<Schema.Struct<{
|
|
84
|
+
value: Schema.Schema<bigint, string, never>;
|
|
85
|
+
owner: typeof Schema.String;
|
|
86
|
+
tokenType: typeof Schema.String;
|
|
87
|
+
intentHash: typeof Schema.String;
|
|
88
|
+
outputIndex: typeof Schema.Number;
|
|
89
|
+
ctime: typeof Schema.Number;
|
|
90
|
+
registeredForDustGeneration: typeof Schema.Boolean;
|
|
91
|
+
}>, Schema.SchemaClass<{
|
|
92
|
+
readonly utxo: {
|
|
93
|
+
readonly type: string;
|
|
94
|
+
readonly value: bigint;
|
|
95
|
+
readonly owner: string;
|
|
96
|
+
readonly intentHash: string;
|
|
97
|
+
readonly outputNo: number;
|
|
98
|
+
};
|
|
99
|
+
readonly meta: {
|
|
100
|
+
readonly ctime: Date;
|
|
101
|
+
readonly registeredForDustGeneration: boolean;
|
|
102
|
+
};
|
|
103
|
+
}, {
|
|
104
|
+
readonly utxo: {
|
|
105
|
+
readonly type: string;
|
|
106
|
+
readonly value: bigint;
|
|
107
|
+
readonly owner: string;
|
|
108
|
+
readonly intentHash: string;
|
|
109
|
+
readonly outputNo: number;
|
|
110
|
+
};
|
|
111
|
+
readonly meta: {
|
|
112
|
+
readonly ctime: Date;
|
|
113
|
+
readonly registeredForDustGeneration: boolean;
|
|
114
|
+
};
|
|
115
|
+
}, never>>>;
|
|
116
|
+
spentUtxos: Schema.Array$<Schema.transform<Schema.Struct<{
|
|
117
|
+
value: Schema.Schema<bigint, string, never>;
|
|
118
|
+
owner: typeof Schema.String;
|
|
119
|
+
tokenType: typeof Schema.String;
|
|
120
|
+
intentHash: typeof Schema.String;
|
|
121
|
+
outputIndex: typeof Schema.Number;
|
|
122
|
+
ctime: typeof Schema.Number;
|
|
123
|
+
registeredForDustGeneration: typeof Schema.Boolean;
|
|
124
|
+
}>, Schema.SchemaClass<{
|
|
125
|
+
readonly utxo: {
|
|
126
|
+
readonly type: string;
|
|
127
|
+
readonly value: bigint;
|
|
128
|
+
readonly owner: string;
|
|
129
|
+
readonly intentHash: string;
|
|
130
|
+
readonly outputNo: number;
|
|
131
|
+
};
|
|
132
|
+
readonly meta: {
|
|
133
|
+
readonly ctime: Date;
|
|
134
|
+
readonly registeredForDustGeneration: boolean;
|
|
135
|
+
};
|
|
136
|
+
}, {
|
|
137
|
+
readonly utxo: {
|
|
138
|
+
readonly type: string;
|
|
139
|
+
readonly value: bigint;
|
|
140
|
+
readonly owner: string;
|
|
141
|
+
readonly intentHash: string;
|
|
142
|
+
readonly outputNo: number;
|
|
143
|
+
};
|
|
144
|
+
readonly meta: {
|
|
145
|
+
readonly ctime: Date;
|
|
146
|
+
readonly registeredForDustGeneration: boolean;
|
|
147
|
+
};
|
|
148
|
+
}, never>>>;
|
|
149
|
+
}>, Schema.SchemaClass<{
|
|
150
|
+
readonly type: "UnshieldedTransaction";
|
|
151
|
+
readonly spentUtxos: readonly {
|
|
152
|
+
readonly utxo: {
|
|
153
|
+
readonly type: string;
|
|
154
|
+
readonly value: bigint;
|
|
155
|
+
readonly owner: string;
|
|
156
|
+
readonly intentHash: string;
|
|
157
|
+
readonly outputNo: number;
|
|
158
|
+
};
|
|
159
|
+
readonly meta: {
|
|
160
|
+
readonly ctime: Date;
|
|
161
|
+
readonly registeredForDustGeneration: boolean;
|
|
162
|
+
};
|
|
163
|
+
}[];
|
|
164
|
+
readonly status: "SUCCESS" | "FAILURE" | "PARTIAL_SUCCESS";
|
|
165
|
+
readonly transaction: {
|
|
166
|
+
readonly type: "RegularTransaction" | "SystemTransaction";
|
|
167
|
+
readonly protocolVersion: number;
|
|
168
|
+
readonly id: number;
|
|
169
|
+
readonly hash: string;
|
|
170
|
+
readonly identifiers?: readonly string[] | undefined;
|
|
171
|
+
readonly fees?: {
|
|
172
|
+
readonly paidFees: bigint;
|
|
173
|
+
readonly estimatedFees: bigint;
|
|
174
|
+
} | undefined;
|
|
175
|
+
readonly block: {
|
|
176
|
+
readonly timestamp: Date;
|
|
177
|
+
};
|
|
178
|
+
readonly transactionResult?: {
|
|
179
|
+
readonly status: "SUCCESS" | "FAILURE" | "PARTIAL_SUCCESS";
|
|
180
|
+
readonly segments: readonly {
|
|
181
|
+
readonly id: number;
|
|
182
|
+
readonly success: boolean;
|
|
183
|
+
}[] | null;
|
|
184
|
+
} | undefined;
|
|
185
|
+
};
|
|
186
|
+
readonly createdUtxos: readonly {
|
|
187
|
+
readonly utxo: {
|
|
188
|
+
readonly type: string;
|
|
189
|
+
readonly value: bigint;
|
|
190
|
+
readonly owner: string;
|
|
191
|
+
readonly intentHash: string;
|
|
192
|
+
readonly outputNo: number;
|
|
193
|
+
};
|
|
194
|
+
readonly meta: {
|
|
195
|
+
readonly ctime: Date;
|
|
196
|
+
readonly registeredForDustGeneration: boolean;
|
|
197
|
+
};
|
|
198
|
+
}[];
|
|
199
|
+
}, {
|
|
200
|
+
readonly type: "UnshieldedTransaction";
|
|
201
|
+
readonly spentUtxos: readonly {
|
|
202
|
+
readonly utxo: {
|
|
203
|
+
readonly type: string;
|
|
204
|
+
readonly value: bigint;
|
|
205
|
+
readonly owner: string;
|
|
206
|
+
readonly intentHash: string;
|
|
207
|
+
readonly outputNo: number;
|
|
208
|
+
};
|
|
209
|
+
readonly meta: {
|
|
210
|
+
readonly ctime: Date;
|
|
211
|
+
readonly registeredForDustGeneration: boolean;
|
|
212
|
+
};
|
|
213
|
+
}[];
|
|
214
|
+
readonly status: "SUCCESS" | "FAILURE" | "PARTIAL_SUCCESS";
|
|
215
|
+
readonly transaction: {
|
|
216
|
+
readonly type: "RegularTransaction" | "SystemTransaction";
|
|
217
|
+
readonly protocolVersion: number;
|
|
218
|
+
readonly id: number;
|
|
219
|
+
readonly hash: string;
|
|
220
|
+
readonly identifiers?: readonly string[] | undefined;
|
|
221
|
+
readonly fees?: {
|
|
222
|
+
readonly paidFees: bigint;
|
|
223
|
+
readonly estimatedFees: bigint;
|
|
224
|
+
} | undefined;
|
|
225
|
+
readonly block: {
|
|
226
|
+
readonly timestamp: Date;
|
|
227
|
+
};
|
|
228
|
+
readonly transactionResult?: {
|
|
229
|
+
readonly status: "SUCCESS" | "FAILURE" | "PARTIAL_SUCCESS";
|
|
230
|
+
readonly segments: readonly {
|
|
231
|
+
readonly id: number;
|
|
232
|
+
readonly success: boolean;
|
|
233
|
+
}[] | null;
|
|
234
|
+
} | undefined;
|
|
235
|
+
};
|
|
236
|
+
readonly createdUtxos: readonly {
|
|
237
|
+
readonly utxo: {
|
|
238
|
+
readonly type: string;
|
|
239
|
+
readonly value: bigint;
|
|
240
|
+
readonly owner: string;
|
|
241
|
+
readonly intentHash: string;
|
|
242
|
+
readonly outputNo: number;
|
|
243
|
+
};
|
|
244
|
+
readonly meta: {
|
|
245
|
+
readonly ctime: Date;
|
|
246
|
+
readonly registeredForDustGeneration: boolean;
|
|
247
|
+
};
|
|
248
|
+
}[];
|
|
249
|
+
}, never>>;
|
|
250
|
+
export type UnshieldedUpdate = Schema.Schema.Type<typeof UnshieldedUpdateSchema>;
|
|
251
|
+
export declare const ProgressSchema: Schema.Struct<{
|
|
252
|
+
type: Schema.Literal<["UnshieldedTransactionsProgress"]>;
|
|
253
|
+
highestTransactionId: typeof Schema.Number;
|
|
254
|
+
}>;
|
|
255
|
+
export declare const WalletSyncUpdateSchema: Schema.Union<[Schema.transform<Schema.Struct<{
|
|
256
|
+
type: Schema.Literal<["UnshieldedTransaction"]>;
|
|
257
|
+
transaction: Schema.Data<Schema.Struct<{
|
|
258
|
+
id: typeof Schema.Number;
|
|
259
|
+
hash: typeof Schema.String;
|
|
260
|
+
type: Schema.Literal<["RegularTransaction", "SystemTransaction"]>;
|
|
261
|
+
protocolVersion: typeof Schema.Number;
|
|
262
|
+
identifiers: Schema.optional<Schema.Array$<typeof Schema.String>>;
|
|
263
|
+
block: Schema.Struct<{
|
|
264
|
+
timestamp: Schema.transform<typeof Schema.Number, typeof Schema.DateFromSelf>;
|
|
265
|
+
}>;
|
|
266
|
+
fees: Schema.optional<Schema.Struct<{
|
|
267
|
+
paidFees: Schema.Schema<bigint, string, never>;
|
|
268
|
+
estimatedFees: Schema.Schema<bigint, string, never>;
|
|
269
|
+
}>>;
|
|
270
|
+
transactionResult: Schema.optional<Schema.Struct<{
|
|
271
|
+
status: Schema.Literal<["SUCCESS", "FAILURE", "PARTIAL_SUCCESS"]>;
|
|
272
|
+
segments: Schema.NullOr<Schema.Array$<Schema.Struct<{
|
|
273
|
+
id: typeof Schema.Number;
|
|
274
|
+
success: typeof Schema.Boolean;
|
|
275
|
+
}>>>;
|
|
276
|
+
}>>;
|
|
277
|
+
}>>;
|
|
278
|
+
createdUtxos: Schema.Array$<Schema.transform<Schema.Struct<{
|
|
279
|
+
value: Schema.Schema<bigint, string, never>;
|
|
280
|
+
owner: typeof Schema.String;
|
|
281
|
+
tokenType: typeof Schema.String;
|
|
282
|
+
intentHash: typeof Schema.String;
|
|
283
|
+
outputIndex: typeof Schema.Number;
|
|
284
|
+
ctime: typeof Schema.Number;
|
|
285
|
+
registeredForDustGeneration: typeof Schema.Boolean;
|
|
286
|
+
}>, Schema.SchemaClass<{
|
|
287
|
+
readonly utxo: {
|
|
288
|
+
readonly type: string;
|
|
289
|
+
readonly value: bigint;
|
|
290
|
+
readonly owner: string;
|
|
291
|
+
readonly intentHash: string;
|
|
292
|
+
readonly outputNo: number;
|
|
293
|
+
};
|
|
294
|
+
readonly meta: {
|
|
295
|
+
readonly ctime: Date;
|
|
296
|
+
readonly registeredForDustGeneration: boolean;
|
|
297
|
+
};
|
|
298
|
+
}, {
|
|
299
|
+
readonly utxo: {
|
|
300
|
+
readonly type: string;
|
|
301
|
+
readonly value: bigint;
|
|
302
|
+
readonly owner: string;
|
|
303
|
+
readonly intentHash: string;
|
|
304
|
+
readonly outputNo: number;
|
|
305
|
+
};
|
|
306
|
+
readonly meta: {
|
|
307
|
+
readonly ctime: Date;
|
|
308
|
+
readonly registeredForDustGeneration: boolean;
|
|
309
|
+
};
|
|
310
|
+
}, never>>>;
|
|
311
|
+
spentUtxos: Schema.Array$<Schema.transform<Schema.Struct<{
|
|
312
|
+
value: Schema.Schema<bigint, string, never>;
|
|
313
|
+
owner: typeof Schema.String;
|
|
314
|
+
tokenType: typeof Schema.String;
|
|
315
|
+
intentHash: typeof Schema.String;
|
|
316
|
+
outputIndex: typeof Schema.Number;
|
|
317
|
+
ctime: typeof Schema.Number;
|
|
318
|
+
registeredForDustGeneration: typeof Schema.Boolean;
|
|
319
|
+
}>, Schema.SchemaClass<{
|
|
320
|
+
readonly utxo: {
|
|
321
|
+
readonly type: string;
|
|
322
|
+
readonly value: bigint;
|
|
323
|
+
readonly owner: string;
|
|
324
|
+
readonly intentHash: string;
|
|
325
|
+
readonly outputNo: number;
|
|
326
|
+
};
|
|
327
|
+
readonly meta: {
|
|
328
|
+
readonly ctime: Date;
|
|
329
|
+
readonly registeredForDustGeneration: boolean;
|
|
330
|
+
};
|
|
331
|
+
}, {
|
|
332
|
+
readonly utxo: {
|
|
333
|
+
readonly type: string;
|
|
334
|
+
readonly value: bigint;
|
|
335
|
+
readonly owner: string;
|
|
336
|
+
readonly intentHash: string;
|
|
337
|
+
readonly outputNo: number;
|
|
338
|
+
};
|
|
339
|
+
readonly meta: {
|
|
340
|
+
readonly ctime: Date;
|
|
341
|
+
readonly registeredForDustGeneration: boolean;
|
|
342
|
+
};
|
|
343
|
+
}, never>>>;
|
|
344
|
+
}>, Schema.SchemaClass<{
|
|
345
|
+
readonly type: "UnshieldedTransaction";
|
|
346
|
+
readonly spentUtxos: readonly {
|
|
347
|
+
readonly utxo: {
|
|
348
|
+
readonly type: string;
|
|
349
|
+
readonly value: bigint;
|
|
350
|
+
readonly owner: string;
|
|
351
|
+
readonly intentHash: string;
|
|
352
|
+
readonly outputNo: number;
|
|
353
|
+
};
|
|
354
|
+
readonly meta: {
|
|
355
|
+
readonly ctime: Date;
|
|
356
|
+
readonly registeredForDustGeneration: boolean;
|
|
357
|
+
};
|
|
358
|
+
}[];
|
|
359
|
+
readonly status: "SUCCESS" | "FAILURE" | "PARTIAL_SUCCESS";
|
|
360
|
+
readonly transaction: {
|
|
361
|
+
readonly type: "RegularTransaction" | "SystemTransaction";
|
|
362
|
+
readonly protocolVersion: number;
|
|
363
|
+
readonly id: number;
|
|
364
|
+
readonly hash: string;
|
|
365
|
+
readonly identifiers?: readonly string[] | undefined;
|
|
366
|
+
readonly fees?: {
|
|
367
|
+
readonly paidFees: bigint;
|
|
368
|
+
readonly estimatedFees: bigint;
|
|
369
|
+
} | undefined;
|
|
370
|
+
readonly block: {
|
|
371
|
+
readonly timestamp: Date;
|
|
372
|
+
};
|
|
373
|
+
readonly transactionResult?: {
|
|
374
|
+
readonly status: "SUCCESS" | "FAILURE" | "PARTIAL_SUCCESS";
|
|
375
|
+
readonly segments: readonly {
|
|
376
|
+
readonly id: number;
|
|
377
|
+
readonly success: boolean;
|
|
378
|
+
}[] | null;
|
|
379
|
+
} | undefined;
|
|
380
|
+
};
|
|
381
|
+
readonly createdUtxos: readonly {
|
|
382
|
+
readonly utxo: {
|
|
383
|
+
readonly type: string;
|
|
384
|
+
readonly value: bigint;
|
|
385
|
+
readonly owner: string;
|
|
386
|
+
readonly intentHash: string;
|
|
387
|
+
readonly outputNo: number;
|
|
388
|
+
};
|
|
389
|
+
readonly meta: {
|
|
390
|
+
readonly ctime: Date;
|
|
391
|
+
readonly registeredForDustGeneration: boolean;
|
|
392
|
+
};
|
|
393
|
+
}[];
|
|
394
|
+
}, {
|
|
395
|
+
readonly type: "UnshieldedTransaction";
|
|
396
|
+
readonly spentUtxos: readonly {
|
|
397
|
+
readonly utxo: {
|
|
398
|
+
readonly type: string;
|
|
399
|
+
readonly value: bigint;
|
|
400
|
+
readonly owner: string;
|
|
401
|
+
readonly intentHash: string;
|
|
402
|
+
readonly outputNo: number;
|
|
403
|
+
};
|
|
404
|
+
readonly meta: {
|
|
405
|
+
readonly ctime: Date;
|
|
406
|
+
readonly registeredForDustGeneration: boolean;
|
|
407
|
+
};
|
|
408
|
+
}[];
|
|
409
|
+
readonly status: "SUCCESS" | "FAILURE" | "PARTIAL_SUCCESS";
|
|
410
|
+
readonly transaction: {
|
|
411
|
+
readonly type: "RegularTransaction" | "SystemTransaction";
|
|
412
|
+
readonly protocolVersion: number;
|
|
413
|
+
readonly id: number;
|
|
414
|
+
readonly hash: string;
|
|
415
|
+
readonly identifiers?: readonly string[] | undefined;
|
|
416
|
+
readonly fees?: {
|
|
417
|
+
readonly paidFees: bigint;
|
|
418
|
+
readonly estimatedFees: bigint;
|
|
419
|
+
} | undefined;
|
|
420
|
+
readonly block: {
|
|
421
|
+
readonly timestamp: Date;
|
|
422
|
+
};
|
|
423
|
+
readonly transactionResult?: {
|
|
424
|
+
readonly status: "SUCCESS" | "FAILURE" | "PARTIAL_SUCCESS";
|
|
425
|
+
readonly segments: readonly {
|
|
426
|
+
readonly id: number;
|
|
427
|
+
readonly success: boolean;
|
|
428
|
+
}[] | null;
|
|
429
|
+
} | undefined;
|
|
430
|
+
};
|
|
431
|
+
readonly createdUtxos: readonly {
|
|
432
|
+
readonly utxo: {
|
|
433
|
+
readonly type: string;
|
|
434
|
+
readonly value: bigint;
|
|
435
|
+
readonly owner: string;
|
|
436
|
+
readonly intentHash: string;
|
|
437
|
+
readonly outputNo: number;
|
|
438
|
+
};
|
|
439
|
+
readonly meta: {
|
|
440
|
+
readonly ctime: Date;
|
|
441
|
+
readonly registeredForDustGeneration: boolean;
|
|
442
|
+
};
|
|
443
|
+
}[];
|
|
444
|
+
}, never>>, Schema.Struct<{
|
|
445
|
+
type: Schema.Literal<["UnshieldedTransactionsProgress"]>;
|
|
446
|
+
highestTransactionId: typeof Schema.Number;
|
|
447
|
+
}>]>;
|
|
448
|
+
export type WalletSyncUpdate = Schema.Schema.Type<typeof WalletSyncUpdateSchema>;
|
|
449
|
+
export {};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// This file is part of MIDNIGHT-WALLET-SDK.
|
|
2
|
+
// Copyright (C) 2025 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 { Effect, Schema, ParseResult } from 'effect';
|
|
14
|
+
export const BigIntSchema = Schema.declare((input) => typeof input === 'bigint').annotations({
|
|
15
|
+
identifier: 'BigIntSchema',
|
|
16
|
+
});
|
|
17
|
+
export const SafeBigInt = Schema.transformOrFail(Schema.String, BigIntSchema, {
|
|
18
|
+
decode: (value) => Effect.try({
|
|
19
|
+
try: () => BigInt(value),
|
|
20
|
+
catch: (err) => new ParseResult.Unexpected(err, 'Could not parse bigint'),
|
|
21
|
+
}),
|
|
22
|
+
encode: (value) => Effect.succeed(value.toString()),
|
|
23
|
+
});
|
|
24
|
+
const DateFromMillis = Schema.transform(Schema.Number, Schema.DateFromSelf, {
|
|
25
|
+
strict: true,
|
|
26
|
+
decode: (millis) => new Date(millis),
|
|
27
|
+
encode: (date) => date.getTime(),
|
|
28
|
+
});
|
|
29
|
+
const WireUtxoSchema = Schema.Struct({
|
|
30
|
+
value: SafeBigInt,
|
|
31
|
+
owner: Schema.String,
|
|
32
|
+
tokenType: Schema.String,
|
|
33
|
+
intentHash: Schema.String,
|
|
34
|
+
outputIndex: Schema.Number,
|
|
35
|
+
ctime: Schema.Number,
|
|
36
|
+
registeredForDustGeneration: Schema.Boolean,
|
|
37
|
+
});
|
|
38
|
+
const UtxoWithMetaSchema = Schema.transform(WireUtxoSchema, Schema.typeSchema(Schema.Struct({
|
|
39
|
+
utxo: Schema.Struct({
|
|
40
|
+
value: BigIntSchema,
|
|
41
|
+
owner: Schema.String,
|
|
42
|
+
type: Schema.String,
|
|
43
|
+
intentHash: Schema.String,
|
|
44
|
+
outputNo: Schema.Number,
|
|
45
|
+
}),
|
|
46
|
+
meta: Schema.Struct({
|
|
47
|
+
ctime: Schema.DateFromSelf,
|
|
48
|
+
registeredForDustGeneration: Schema.Boolean,
|
|
49
|
+
}),
|
|
50
|
+
})), {
|
|
51
|
+
strict: true,
|
|
52
|
+
decode: (wire) => ({
|
|
53
|
+
utxo: {
|
|
54
|
+
value: wire.value,
|
|
55
|
+
owner: wire.owner,
|
|
56
|
+
type: wire.tokenType,
|
|
57
|
+
intentHash: wire.intentHash,
|
|
58
|
+
outputNo: wire.outputIndex,
|
|
59
|
+
},
|
|
60
|
+
meta: {
|
|
61
|
+
ctime: new Date(wire.ctime * 1000),
|
|
62
|
+
registeredForDustGeneration: wire.registeredForDustGeneration,
|
|
63
|
+
},
|
|
64
|
+
}),
|
|
65
|
+
encode: (domain) => ({
|
|
66
|
+
value: domain.utxo.value,
|
|
67
|
+
owner: domain.utxo.owner,
|
|
68
|
+
tokenType: domain.utxo.type,
|
|
69
|
+
intentHash: domain.utxo.intentHash,
|
|
70
|
+
outputIndex: domain.utxo.outputNo,
|
|
71
|
+
ctime: Math.floor(domain.meta.ctime.getTime() / 1000),
|
|
72
|
+
registeredForDustGeneration: domain.meta.registeredForDustGeneration,
|
|
73
|
+
}),
|
|
74
|
+
});
|
|
75
|
+
export const UnshieldedTransactionSchema = Schema.Data(Schema.Struct({
|
|
76
|
+
id: Schema.Number,
|
|
77
|
+
hash: Schema.String,
|
|
78
|
+
type: Schema.Literal('RegularTransaction', 'SystemTransaction'),
|
|
79
|
+
protocolVersion: Schema.Number,
|
|
80
|
+
identifiers: Schema.optional(Schema.Array(Schema.String)),
|
|
81
|
+
block: Schema.Struct({
|
|
82
|
+
timestamp: DateFromMillis,
|
|
83
|
+
}),
|
|
84
|
+
fees: Schema.optional(Schema.Struct({
|
|
85
|
+
paidFees: SafeBigInt,
|
|
86
|
+
estimatedFees: SafeBigInt,
|
|
87
|
+
})),
|
|
88
|
+
transactionResult: Schema.optional(Schema.Struct({
|
|
89
|
+
status: Schema.Literal('SUCCESS', 'FAILURE', 'PARTIAL_SUCCESS'),
|
|
90
|
+
segments: Schema.NullOr(Schema.Array(Schema.Struct({
|
|
91
|
+
id: Schema.Number,
|
|
92
|
+
success: Schema.Boolean,
|
|
93
|
+
}))),
|
|
94
|
+
})),
|
|
95
|
+
}));
|
|
96
|
+
const UnshieldedUpdateWireSchema = Schema.Struct({
|
|
97
|
+
type: Schema.Literal('UnshieldedTransaction'),
|
|
98
|
+
transaction: UnshieldedTransactionSchema,
|
|
99
|
+
createdUtxos: Schema.Array(UtxoWithMetaSchema),
|
|
100
|
+
spentUtxos: Schema.Array(UtxoWithMetaSchema),
|
|
101
|
+
});
|
|
102
|
+
export const UnshieldedUpdateSchema = Schema.transform(UnshieldedUpdateWireSchema, Schema.typeSchema(Schema.Struct({
|
|
103
|
+
type: Schema.Literal('UnshieldedTransaction'),
|
|
104
|
+
transaction: UnshieldedTransactionSchema,
|
|
105
|
+
createdUtxos: Schema.Array(Schema.typeSchema(UtxoWithMetaSchema)),
|
|
106
|
+
spentUtxos: Schema.Array(Schema.typeSchema(UtxoWithMetaSchema)),
|
|
107
|
+
status: Schema.Literal('SUCCESS', 'FAILURE', 'PARTIAL_SUCCESS'),
|
|
108
|
+
})), {
|
|
109
|
+
strict: true,
|
|
110
|
+
decode: (wire) => {
|
|
111
|
+
const isSystemTransaction = wire.transaction.type === 'SystemTransaction';
|
|
112
|
+
return {
|
|
113
|
+
...wire,
|
|
114
|
+
status: isSystemTransaction ? 'SUCCESS' : wire.transaction.transactionResult.status,
|
|
115
|
+
};
|
|
116
|
+
},
|
|
117
|
+
encode: ({ status: _status, ...rest }) => rest,
|
|
118
|
+
});
|
|
119
|
+
export const ProgressSchema = Schema.Struct({
|
|
120
|
+
type: Schema.Literal('UnshieldedTransactionsProgress'),
|
|
121
|
+
highestTransactionId: Schema.Number,
|
|
122
|
+
});
|
|
123
|
+
export const WalletSyncUpdateSchema = Schema.Union(UnshieldedUpdateSchema, ProgressSchema);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as ledger from '@midnight-ntwrk/ledger-v6';
|
|
2
|
+
import { NetworkId } from '@midnight-ntwrk/wallet-sdk-abstractions';
|
|
3
|
+
import { Either } from 'effect';
|
|
4
|
+
import { CoreWallet } from './CoreWallet.js';
|
|
5
|
+
import { WalletError } from './WalletError.js';
|
|
6
|
+
import { CoinSelection } from '@midnight-ntwrk/wallet-sdk-capabilities';
|
|
7
|
+
import { TransactionTrait } from './Transaction.js';
|
|
8
|
+
import { CoinsAndBalancesCapability } from './CoinsAndBalances.js';
|
|
9
|
+
import { KeysCapability } from './Keys.js';
|
|
10
|
+
export interface TokenTransfer {
|
|
11
|
+
readonly amount: bigint;
|
|
12
|
+
readonly type: ledger.RawTokenType;
|
|
13
|
+
readonly receiverAddress: string;
|
|
14
|
+
}
|
|
15
|
+
export type TransactingResult<TTransaction, TState> = {
|
|
16
|
+
readonly newState: TState;
|
|
17
|
+
readonly transaction: TTransaction;
|
|
18
|
+
};
|
|
19
|
+
export interface TransactingCapability<_TTransaction, TState> {
|
|
20
|
+
makeTransfer(wallet: CoreWallet, outputs: ReadonlyArray<TokenTransfer>, ttl: Date): Either.Either<TransactingResult<ledger.UnprovenTransaction, TState>, WalletError>;
|
|
21
|
+
initSwap(wallet: CoreWallet, desiredInputs: Record<string, bigint>, outputs: ReadonlyArray<TokenTransfer>, ttl: Date): Either.Either<TransactingResult<ledger.UnprovenTransaction, TState>, WalletError>;
|
|
22
|
+
balanceTransaction(wallet: CoreWallet, transaction: ledger.Transaction<ledger.SignatureEnabled, ledger.Proofish, ledger.Bindingish>): Either.Either<TransactingResult<ledger.Transaction<ledger.SignatureEnabled, ledger.Proofish, ledger.Bindingish>, TState>, WalletError>;
|
|
23
|
+
signTransaction(transaction: ledger.UnprovenTransaction, signSegment: (data: Uint8Array) => ledger.Signature): Either.Either<ledger.UnprovenTransaction, WalletError>;
|
|
24
|
+
}
|
|
25
|
+
export type DefaultTransactingConfiguration = {
|
|
26
|
+
networkId: NetworkId.NetworkId;
|
|
27
|
+
};
|
|
28
|
+
export type DefaultTransactingContext = {
|
|
29
|
+
coinSelection: CoinSelection<ledger.Utxo>;
|
|
30
|
+
coinsAndBalancesCapability: CoinsAndBalancesCapability<CoreWallet>;
|
|
31
|
+
keysCapability: KeysCapability<CoreWallet>;
|
|
32
|
+
};
|
|
33
|
+
export declare const makeDefaultTransactingCapability: (config: DefaultTransactingConfiguration, getContext: () => DefaultTransactingContext) => TransactingCapability<ledger.UnprovenTransaction, CoreWallet>;
|
|
34
|
+
export declare class TransactingCapabilityImplementation<TTransaction extends ledger.UnprovenTransaction> implements TransactingCapability<ledger.UnprovenTransaction, CoreWallet> {
|
|
35
|
+
readonly networkId: NetworkId.NetworkId;
|
|
36
|
+
readonly getCoinSelection: () => CoinSelection<ledger.Utxo>;
|
|
37
|
+
readonly txTrait: TransactionTrait<TTransaction>;
|
|
38
|
+
readonly getCoins: () => CoinsAndBalancesCapability<CoreWallet>;
|
|
39
|
+
readonly getKeys: () => KeysCapability<CoreWallet>;
|
|
40
|
+
constructor(networkId: NetworkId.NetworkId, getCoinSelection: () => CoinSelection<ledger.Utxo>, getCoins: () => CoinsAndBalancesCapability<CoreWallet>, getKeys: () => KeysCapability<CoreWallet>, txTrait: TransactionTrait<TTransaction>);
|
|
41
|
+
balanceTransaction(wallet: CoreWallet, transaction: TTransaction): Either.Either<TransactingResult<TTransaction, CoreWallet>, WalletError>;
|
|
42
|
+
makeTransfer(wallet: CoreWallet, outputs: ReadonlyArray<TokenTransfer>, ttl: Date): Either.Either<TransactingResult<TTransaction, CoreWallet>, WalletError>;
|
|
43
|
+
initSwap(wallet: CoreWallet, desiredInputs: Record<ledger.RawTokenType, bigint>, desiredOutputs: ReadonlyArray<TokenTransfer>, ttl: Date): Either.Either<TransactingResult<TTransaction, CoreWallet>, WalletError>;
|
|
44
|
+
signTransaction(transaction: ledger.UnprovenTransaction, signSegment: (data: Uint8Array) => ledger.Signature): Either.Either<ledger.UnprovenTransaction, WalletError>;
|
|
45
|
+
}
|