@arcadiasystems/morse-uploader 0.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/CHANGELOG.md +23 -0
- package/LICENSE +21 -0
- package/README.md +167 -0
- package/dist/chunk-2FYBTRTH.js +562 -0
- package/dist/chunk-2FYBTRTH.js.map +1 -0
- package/dist/chunk-A2AMSP5S.js +136 -0
- package/dist/chunk-A2AMSP5S.js.map +1 -0
- package/dist/index.d.ts +241 -0
- package/dist/index.js +138 -0
- package/dist/index.js.map +1 -0
- package/dist/styles.css +472 -0
- package/dist/types-COaFRpWK.d.ts +251 -0
- package/dist/ui.d.ts +27 -0
- package/dist/ui.js +225 -0
- package/dist/ui.js.map +1 -0
- package/dist/wallet-standard.d.ts +29 -0
- package/dist/wallet-standard.js +3 -0
- package/dist/wallet-standard.js.map +1 -0
- package/package.json +116 -0
package/dist/styles.css
ADDED
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Default skin for @arcadiasystems/morse-uploader. Import this file once in
|
|
3
|
+
* your app. Override the --mu-* variables (or the .mu-* rules) to theme it.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
.mu-uploader,
|
|
7
|
+
.mu-view,
|
|
8
|
+
.mu-members {
|
|
9
|
+
--mu-gap: 0.85rem;
|
|
10
|
+
--mu-radius: 14px;
|
|
11
|
+
--mu-radius-sm: 9px;
|
|
12
|
+
--mu-border-color-r: var(--mu-border-color, #e4e4e7);
|
|
13
|
+
--mu-border: 1px solid var(--mu-border-color-r);
|
|
14
|
+
--mu-fg: var(--mu-fg-color, #18181b);
|
|
15
|
+
--mu-muted: var(--mu-muted-color, #71717a);
|
|
16
|
+
--mu-accent: var(--mu-accent-color, #4f46e5);
|
|
17
|
+
--mu-accent-fg: var(--mu-accent-fg-color, #ffffff);
|
|
18
|
+
--mu-surface: var(--mu-surface-color, #ffffff);
|
|
19
|
+
--mu-surface-2: var(--mu-surface-2-color, #f4f4f5);
|
|
20
|
+
--mu-drag: var(--mu-drag-color, #eef2ff);
|
|
21
|
+
--mu-error: var(--mu-error-color, #dc2626);
|
|
22
|
+
--mu-success: var(--mu-success-color, #16a34a);
|
|
23
|
+
--mu-warning: var(--mu-warning-color, #eab308);
|
|
24
|
+
--mu-ring: color-mix(in srgb, var(--mu-accent) 35%, transparent);
|
|
25
|
+
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-direction: column;
|
|
28
|
+
gap: var(--mu-gap);
|
|
29
|
+
color: var(--mu-fg);
|
|
30
|
+
font-family: var(--mu-font, system-ui, sans-serif);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* ----- Dropzone ----- */
|
|
34
|
+
.mu-dropzone {
|
|
35
|
+
display: flex;
|
|
36
|
+
flex-direction: column;
|
|
37
|
+
align-items: center;
|
|
38
|
+
justify-content: center;
|
|
39
|
+
gap: 0.35rem;
|
|
40
|
+
padding: 2rem 1.5rem;
|
|
41
|
+
border: 1.5px dashed var(--mu-border-color-r);
|
|
42
|
+
border-radius: var(--mu-radius);
|
|
43
|
+
background: var(--mu-surface);
|
|
44
|
+
color: var(--mu-muted);
|
|
45
|
+
cursor: pointer;
|
|
46
|
+
outline: none;
|
|
47
|
+
text-align: center;
|
|
48
|
+
transition:
|
|
49
|
+
border-color 0.18s ease,
|
|
50
|
+
background 0.18s ease,
|
|
51
|
+
transform 0.18s ease;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.mu-dropzone:hover {
|
|
55
|
+
border-color: var(--mu-accent);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.mu-dropzone:focus-visible {
|
|
59
|
+
border-color: var(--mu-accent);
|
|
60
|
+
box-shadow: 0 0 0 4px var(--mu-ring);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.mu-dropzone[data-dragging="true"] {
|
|
64
|
+
border-color: var(--mu-accent);
|
|
65
|
+
background: var(--mu-drag);
|
|
66
|
+
transform: scale(1.01);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.mu-dropzone[aria-disabled="true"] {
|
|
70
|
+
cursor: not-allowed;
|
|
71
|
+
opacity: 0.6;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.mu-dropzone-icon {
|
|
75
|
+
width: 2.25rem;
|
|
76
|
+
height: 2.25rem;
|
|
77
|
+
background-color: var(--mu-accent);
|
|
78
|
+
mask: var(--mu-upload-icon) center / contain no-repeat;
|
|
79
|
+
-webkit-mask: var(--mu-upload-icon) center / contain no-repeat;
|
|
80
|
+
--mu-upload-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 16V4M7 9l5-5 5 5'/%3E%3Cpath d='M5 16v3a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-3'/%3E%3C/svg%3E");
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.mu-dropzone-hint {
|
|
84
|
+
color: var(--mu-fg);
|
|
85
|
+
font-weight: 550;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.mu-dropzone-sub {
|
|
89
|
+
font-size: 0.8125rem;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* ----- Inputs / fields ----- */
|
|
93
|
+
.mu-input,
|
|
94
|
+
.mu-epochs-input {
|
|
95
|
+
padding: 0.6rem 0.7rem;
|
|
96
|
+
border: var(--mu-border);
|
|
97
|
+
border-radius: var(--mu-radius-sm);
|
|
98
|
+
background: var(--mu-surface);
|
|
99
|
+
color: var(--mu-fg);
|
|
100
|
+
font: inherit;
|
|
101
|
+
transition:
|
|
102
|
+
border-color 0.18s ease,
|
|
103
|
+
box-shadow 0.18s ease;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.mu-input:focus,
|
|
107
|
+
.mu-epochs-input:focus {
|
|
108
|
+
outline: none;
|
|
109
|
+
border-color: var(--mu-accent);
|
|
110
|
+
box-shadow: 0 0 0 4px var(--mu-ring);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.mu-field {
|
|
114
|
+
display: flex;
|
|
115
|
+
flex-direction: column;
|
|
116
|
+
gap: 0.3rem;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.mu-field-label {
|
|
120
|
+
color: var(--mu-muted);
|
|
121
|
+
font-size: 0.8125rem;
|
|
122
|
+
font-weight: 550;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.mu-field-help {
|
|
126
|
+
color: var(--mu-muted);
|
|
127
|
+
font-size: 0.8125rem;
|
|
128
|
+
cursor: help;
|
|
129
|
+
width: fit-content;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.mu-encrypt {
|
|
133
|
+
display: flex;
|
|
134
|
+
align-items: center;
|
|
135
|
+
gap: 0.5rem;
|
|
136
|
+
padding: 0.6rem 0.7rem;
|
|
137
|
+
border: var(--mu-border);
|
|
138
|
+
border-radius: var(--mu-radius-sm);
|
|
139
|
+
background: var(--mu-surface-2);
|
|
140
|
+
cursor: pointer;
|
|
141
|
+
font-size: 0.9rem;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.mu-encrypt input {
|
|
145
|
+
accent-color: var(--mu-accent);
|
|
146
|
+
width: 1rem;
|
|
147
|
+
height: 1rem;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/* ----- Cost ----- */
|
|
151
|
+
.mu-cost {
|
|
152
|
+
display: flex;
|
|
153
|
+
align-items: center;
|
|
154
|
+
gap: var(--mu-gap);
|
|
155
|
+
padding: 0.6rem 0.8rem;
|
|
156
|
+
border-radius: var(--mu-radius-sm);
|
|
157
|
+
background: var(--mu-surface-2);
|
|
158
|
+
font-size: 0.875rem;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.mu-cost-label {
|
|
162
|
+
color: var(--mu-muted);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.mu-cost-value {
|
|
166
|
+
margin-left: auto;
|
|
167
|
+
font-weight: 650;
|
|
168
|
+
font-variant-numeric: tabular-nums;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/* ----- Buttons ----- */
|
|
172
|
+
.mu-upload,
|
|
173
|
+
.mu-ghost,
|
|
174
|
+
.mu-remove {
|
|
175
|
+
display: inline-flex;
|
|
176
|
+
align-items: center;
|
|
177
|
+
justify-content: center;
|
|
178
|
+
gap: 0.4rem;
|
|
179
|
+
border-radius: var(--mu-radius-sm);
|
|
180
|
+
font: inherit;
|
|
181
|
+
font-weight: 600;
|
|
182
|
+
cursor: pointer;
|
|
183
|
+
transition:
|
|
184
|
+
filter 0.16s ease,
|
|
185
|
+
transform 0.06s ease,
|
|
186
|
+
box-shadow 0.16s ease,
|
|
187
|
+
background 0.16s ease;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.mu-upload {
|
|
191
|
+
padding: 0.7rem 1rem;
|
|
192
|
+
border: none;
|
|
193
|
+
background: var(--mu-accent);
|
|
194
|
+
color: var(--mu-accent-fg);
|
|
195
|
+
text-decoration: none;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.mu-upload:hover {
|
|
199
|
+
filter: brightness(1.07);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.mu-upload:active {
|
|
203
|
+
transform: translateY(1px);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.mu-upload:focus-visible {
|
|
207
|
+
outline: none;
|
|
208
|
+
box-shadow: 0 0 0 4px var(--mu-ring);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.mu-upload:disabled {
|
|
212
|
+
opacity: 0.5;
|
|
213
|
+
cursor: not-allowed;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.mu-ghost {
|
|
217
|
+
padding: 0.7rem 1rem;
|
|
218
|
+
border: var(--mu-border);
|
|
219
|
+
background: transparent;
|
|
220
|
+
color: var(--mu-fg);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
.mu-ghost:hover {
|
|
224
|
+
background: var(--mu-surface-2);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
.mu-remove {
|
|
228
|
+
margin-left: auto;
|
|
229
|
+
padding: 0.35rem 0.7rem;
|
|
230
|
+
border: var(--mu-border);
|
|
231
|
+
background: transparent;
|
|
232
|
+
color: var(--mu-muted);
|
|
233
|
+
font-weight: 500;
|
|
234
|
+
font-size: 0.8125rem;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.mu-remove:hover:not(:disabled) {
|
|
238
|
+
color: var(--mu-error);
|
|
239
|
+
border-color: var(--mu-error);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.mu-remove:disabled {
|
|
243
|
+
opacity: 0.5;
|
|
244
|
+
cursor: not-allowed;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/* ----- Progress stepper ----- */
|
|
248
|
+
.mu-stepper {
|
|
249
|
+
list-style: none;
|
|
250
|
+
margin: 0;
|
|
251
|
+
padding: 0.25rem 0;
|
|
252
|
+
display: flex;
|
|
253
|
+
flex-wrap: wrap;
|
|
254
|
+
gap: 1.25rem;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.mu-step {
|
|
258
|
+
display: flex;
|
|
259
|
+
flex-direction: column;
|
|
260
|
+
align-items: center;
|
|
261
|
+
gap: 0.35rem;
|
|
262
|
+
color: var(--mu-muted);
|
|
263
|
+
font-size: 0.75rem;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
.mu-step-dot {
|
|
267
|
+
display: grid;
|
|
268
|
+
place-items: center;
|
|
269
|
+
width: 1.75rem;
|
|
270
|
+
height: 1.75rem;
|
|
271
|
+
border-radius: 50%;
|
|
272
|
+
border: 2px solid var(--mu-border-color-r);
|
|
273
|
+
background: var(--mu-surface);
|
|
274
|
+
font-size: 0.8125rem;
|
|
275
|
+
font-weight: 650;
|
|
276
|
+
transition:
|
|
277
|
+
border-color 0.2s ease,
|
|
278
|
+
background 0.2s ease,
|
|
279
|
+
color 0.2s ease;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/* Current step: amber and pulsing. */
|
|
283
|
+
.mu-step[data-state="active"] {
|
|
284
|
+
color: var(--mu-warning);
|
|
285
|
+
font-weight: 600;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.mu-step[data-state="active"] .mu-step-dot {
|
|
289
|
+
border-color: var(--mu-warning);
|
|
290
|
+
color: var(--mu-warning);
|
|
291
|
+
animation: mu-pulse 1.4s ease-out infinite;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/* Completed step: solid green. */
|
|
295
|
+
.mu-step[data-state="done"] {
|
|
296
|
+
color: var(--mu-success);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
.mu-step[data-state="done"] .mu-step-dot {
|
|
300
|
+
border-color: var(--mu-success);
|
|
301
|
+
background: var(--mu-success);
|
|
302
|
+
color: #fff;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
@keyframes mu-pulse {
|
|
306
|
+
0% {
|
|
307
|
+
box-shadow: 0 0 0 0 color-mix(in srgb, var(--mu-warning) 55%, transparent);
|
|
308
|
+
}
|
|
309
|
+
70% {
|
|
310
|
+
box-shadow: 0 0 0 8px transparent;
|
|
311
|
+
}
|
|
312
|
+
100% {
|
|
313
|
+
box-shadow: 0 0 0 0 transparent;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/* ----- Error ----- */
|
|
318
|
+
.mu-error {
|
|
319
|
+
display: flex;
|
|
320
|
+
flex-direction: column;
|
|
321
|
+
gap: 0.125rem;
|
|
322
|
+
padding: 0.65rem 0.85rem;
|
|
323
|
+
border-radius: var(--mu-radius-sm);
|
|
324
|
+
background: color-mix(in srgb, var(--mu-error) 12%, transparent);
|
|
325
|
+
color: var(--mu-error);
|
|
326
|
+
font-size: 0.875rem;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/* ----- Upload result ----- */
|
|
330
|
+
.mu-result {
|
|
331
|
+
display: flex;
|
|
332
|
+
flex-direction: column;
|
|
333
|
+
gap: 0.6rem;
|
|
334
|
+
padding: 0.85rem 1rem;
|
|
335
|
+
border-radius: var(--mu-radius);
|
|
336
|
+
border: 1px solid color-mix(in srgb, var(--mu-success) 35%, transparent);
|
|
337
|
+
background: color-mix(in srgb, var(--mu-success) 9%, transparent);
|
|
338
|
+
animation: mu-fade-in 0.25s ease;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
.mu-result-head {
|
|
342
|
+
display: flex;
|
|
343
|
+
align-items: center;
|
|
344
|
+
gap: 0.5rem;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
.mu-result-badge {
|
|
348
|
+
display: grid;
|
|
349
|
+
place-items: center;
|
|
350
|
+
width: 1.4rem;
|
|
351
|
+
height: 1.4rem;
|
|
352
|
+
border-radius: 50%;
|
|
353
|
+
background: var(--mu-success);
|
|
354
|
+
color: #fff;
|
|
355
|
+
font-size: 0.85rem;
|
|
356
|
+
font-weight: 700;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
.mu-result-actions {
|
|
360
|
+
display: flex;
|
|
361
|
+
flex-wrap: wrap;
|
|
362
|
+
gap: 0.5rem;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
.mu-result-id {
|
|
366
|
+
color: var(--mu-muted);
|
|
367
|
+
font-size: 0.75rem;
|
|
368
|
+
word-break: break-all;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
.mu-result-note {
|
|
372
|
+
color: var(--mu-muted);
|
|
373
|
+
font-size: 0.8125rem;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/* ----- Downloader view ----- */
|
|
377
|
+
.mu-view {
|
|
378
|
+
gap: 1rem;
|
|
379
|
+
padding: 1.1rem;
|
|
380
|
+
border: var(--mu-border);
|
|
381
|
+
border-radius: var(--mu-radius);
|
|
382
|
+
background: var(--mu-surface);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
.mu-view-head {
|
|
386
|
+
display: flex;
|
|
387
|
+
flex-direction: column;
|
|
388
|
+
gap: 0.15rem;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
.mu-view-name {
|
|
392
|
+
word-break: break-all;
|
|
393
|
+
font-size: 1.05rem;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
.mu-view-body {
|
|
397
|
+
display: flex;
|
|
398
|
+
flex-direction: column;
|
|
399
|
+
gap: var(--mu-gap);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
.mu-view-img {
|
|
403
|
+
max-width: 100%;
|
|
404
|
+
border-radius: var(--mu-radius-sm);
|
|
405
|
+
border: var(--mu-border);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
.mu-view-state {
|
|
409
|
+
color: var(--mu-muted);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/* ----- Allowlist members ----- */
|
|
413
|
+
.mu-members-add {
|
|
414
|
+
display: flex;
|
|
415
|
+
gap: 0.5rem;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
.mu-members-add .mu-input {
|
|
419
|
+
flex: 1;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
.mu-members-list {
|
|
423
|
+
list-style: none;
|
|
424
|
+
margin: 0;
|
|
425
|
+
padding: 0;
|
|
426
|
+
display: flex;
|
|
427
|
+
flex-direction: column;
|
|
428
|
+
gap: 0.35rem;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
.mu-members-row {
|
|
432
|
+
display: flex;
|
|
433
|
+
align-items: center;
|
|
434
|
+
gap: var(--mu-gap);
|
|
435
|
+
padding: 0.55rem 0.7rem;
|
|
436
|
+
border: var(--mu-border);
|
|
437
|
+
border-radius: var(--mu-radius-sm);
|
|
438
|
+
background: var(--mu-surface);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
.mu-members-addr {
|
|
442
|
+
word-break: break-all;
|
|
443
|
+
font-size: 0.8125rem;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
.mu-muted {
|
|
447
|
+
color: var(--mu-muted);
|
|
448
|
+
font-size: 0.875rem;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
@keyframes mu-fade-in {
|
|
452
|
+
from {
|
|
453
|
+
opacity: 0;
|
|
454
|
+
transform: translateY(4px);
|
|
455
|
+
}
|
|
456
|
+
to {
|
|
457
|
+
opacity: 1;
|
|
458
|
+
transform: translateY(0);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
@media (prefers-reduced-motion: reduce) {
|
|
463
|
+
.mu-dropzone,
|
|
464
|
+
.mu-upload,
|
|
465
|
+
.mu-ghost,
|
|
466
|
+
.mu-remove,
|
|
467
|
+
.mu-step-dot,
|
|
468
|
+
.mu-result {
|
|
469
|
+
transition: none;
|
|
470
|
+
animation: none;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { RecipientFileId, RecipientFile, FileUploadProgressEvent, SuiAddress, NetworkConfig, WalletAdapter, WalrusWriteAdapter, WalrusFlowCapable, WalrusReadAdapter, SealAdapter, RecipientFilesReader, WalletSignTransaction, WalletSignPersonalMessage, WalletStandardAccount, PubkeyCache } from '@arcadiasystems/morse-sdk';
|
|
2
|
+
import { SealCompatibleClient } from '@mysten/seal';
|
|
3
|
+
import { Signer } from '@mysten/sui/cryptography';
|
|
4
|
+
import { SuiGrpcClient } from '@mysten/sui/grpc';
|
|
5
|
+
import { Transaction } from '@mysten/sui/transactions';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Types for the 0.4.0 RecipientFile module. A RecipientFile carries its
|
|
9
|
+
* recipient set directly; there is no separate allowlist object. Declarations
|
|
10
|
+
* only; no runtime code.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** Wallet callbacks the setup hook needs (typically from dapp-kit mutateAsync). */
|
|
14
|
+
interface MorseFilesWalletCallbacks {
|
|
15
|
+
readonly signTransaction: WalletSignTransaction;
|
|
16
|
+
readonly signPersonalMessage: WalletSignPersonalMessage;
|
|
17
|
+
readonly signAndExecuteTransaction: (input: {
|
|
18
|
+
transaction: Transaction;
|
|
19
|
+
}) => Promise<{
|
|
20
|
+
digest: string;
|
|
21
|
+
}>;
|
|
22
|
+
}
|
|
23
|
+
/** Options for the {@link useMorseFiles} setup hook. */
|
|
24
|
+
interface UseMorseFilesOptions {
|
|
25
|
+
readonly network: "testnet" | "mainnet";
|
|
26
|
+
readonly account: WalletStandardAccount;
|
|
27
|
+
readonly callbacks: MorseFilesWalletCallbacks;
|
|
28
|
+
/**
|
|
29
|
+
* A `SuiGrpcClient` to build and read with. Provide one pointed at a
|
|
30
|
+
* dedicated RPC so it resolves the same chain state your wallet executes
|
|
31
|
+
* against (the public load-balanced endpoint can skew object versions and
|
|
32
|
+
* fail the certify step). Defaults to a gRPC client on the network's public
|
|
33
|
+
* RPC. Must be a gRPC client; the SDK relies on its method surface.
|
|
34
|
+
*/
|
|
35
|
+
readonly suiClient?: SuiGrpcClient;
|
|
36
|
+
/** Prebuilt flow-capable Walrus write adapter; overrides the default. */
|
|
37
|
+
readonly walrusWrite?: WalrusWriteAdapter & WalrusFlowCapable;
|
|
38
|
+
/** Options for the default direct write adapter (wasm/relay), if not overridden. */
|
|
39
|
+
readonly walrusWriteConfig?: {
|
|
40
|
+
readonly wasmUrl?: string;
|
|
41
|
+
readonly uploadRelay?: {
|
|
42
|
+
readonly host: string;
|
|
43
|
+
readonly sendTip?: unknown;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
/** Prebuilt Walrus read adapter; defaults to the aggregator. */
|
|
47
|
+
readonly walrusRead?: WalrusReadAdapter;
|
|
48
|
+
/** Pubkey cache for fromAccountAsync; defaults to BrowserStoragePubkeyCache. */
|
|
49
|
+
readonly pubkeyCache?: PubkeyCache;
|
|
50
|
+
}
|
|
51
|
+
/** The injected SDK objects the files hooks and components consume. */
|
|
52
|
+
interface MorseFilesHandles {
|
|
53
|
+
/** The network the handles were built for; drives USD epoch pricing. */
|
|
54
|
+
readonly network: "testnet" | "mainnet";
|
|
55
|
+
/**
|
|
56
|
+
* The full `morseConfig({ network })` output. It must include
|
|
57
|
+
* `recipientFileEventOriginPackageId`; the upload helpers need it to match
|
|
58
|
+
* created objects by their type-origin package after a contract upgrade.
|
|
59
|
+
*/
|
|
60
|
+
readonly config: NetworkConfig;
|
|
61
|
+
/** Sui client (also the SealCompatibleClient used for SessionKey). */
|
|
62
|
+
readonly client: SealCompatibleClient;
|
|
63
|
+
readonly address: SuiAddress;
|
|
64
|
+
/** WalletAdapter for ops (the on-chain PTBs). */
|
|
65
|
+
readonly adapter: WalletAdapter;
|
|
66
|
+
/** Sui signer for Walrus writes and the Seal SessionKey. */
|
|
67
|
+
readonly signer: Signer;
|
|
68
|
+
/** Flow-capable write adapter (required for the single-PTB file ops). */
|
|
69
|
+
readonly walrusWrite: WalrusWriteAdapter & WalrusFlowCapable;
|
|
70
|
+
readonly walrusRead: WalrusReadAdapter;
|
|
71
|
+
readonly seal: SealAdapter;
|
|
72
|
+
readonly reader: RecipientFilesReader;
|
|
73
|
+
}
|
|
74
|
+
/** Status of the async {@link useMorseFiles} setup. */
|
|
75
|
+
type SetupStatus = "idle" | "preparing" | "ready" | "error";
|
|
76
|
+
/** Return value of {@link useMorseFiles}. */
|
|
77
|
+
interface UseMorseFilesResult {
|
|
78
|
+
readonly status: SetupStatus;
|
|
79
|
+
readonly handles: MorseFilesHandles | null;
|
|
80
|
+
readonly error: unknown;
|
|
81
|
+
}
|
|
82
|
+
/** A single upload progress phase. */
|
|
83
|
+
type FilePhase = FileUploadProgressEvent["phase"];
|
|
84
|
+
/** Status of a single upload tracked by {@link useFileUpload}. */
|
|
85
|
+
type FileUploadStatus = "idle" | "uploading" | "success" | "error";
|
|
86
|
+
/** The Seal identity material returned by an encrypted upload. */
|
|
87
|
+
interface SealMaterial {
|
|
88
|
+
readonly sealIdPrefix: Uint8Array;
|
|
89
|
+
readonly sealNonce: Uint8Array;
|
|
90
|
+
}
|
|
91
|
+
/** Input to the {@link useFileUpload} upload action. */
|
|
92
|
+
interface FileUploadInput {
|
|
93
|
+
readonly file: File;
|
|
94
|
+
/** Wallets that can decrypt (encrypted) or are tagged as recipients (public). The owner is auto-added on chain. */
|
|
95
|
+
readonly recipients?: readonly SuiAddress[];
|
|
96
|
+
/** Encrypt under Seal; the recipient set gates decryption. */
|
|
97
|
+
readonly encrypt?: boolean;
|
|
98
|
+
readonly epochs: number;
|
|
99
|
+
readonly deletable?: boolean;
|
|
100
|
+
}
|
|
101
|
+
/** A completed upload plus its share link. */
|
|
102
|
+
interface CompletedFileUpload {
|
|
103
|
+
readonly fileId: RecipientFileId;
|
|
104
|
+
readonly blobId: string;
|
|
105
|
+
readonly encrypted: boolean;
|
|
106
|
+
/** Present for encrypted uploads; persist with the nonce so recipients can decrypt. */
|
|
107
|
+
readonly sealIdPrefix: Uint8Array | null;
|
|
108
|
+
readonly sealNonce: Uint8Array | null;
|
|
109
|
+
readonly shareLink: string;
|
|
110
|
+
}
|
|
111
|
+
/** Return value of {@link useFileUpload}. */
|
|
112
|
+
interface UseFileUploadResult {
|
|
113
|
+
readonly status: FileUploadStatus;
|
|
114
|
+
readonly phase: FilePhase | null;
|
|
115
|
+
readonly data: CompletedFileUpload | null;
|
|
116
|
+
readonly error: unknown;
|
|
117
|
+
readonly upload: (input: FileUploadInput) => Promise<CompletedFileUpload>;
|
|
118
|
+
readonly reset: () => void;
|
|
119
|
+
}
|
|
120
|
+
/** Status of a decrypt/download tracked by {@link useFileDecrypt}. */
|
|
121
|
+
type FileDecryptStatus = "idle" | "working" | "success" | "error";
|
|
122
|
+
/** Input to {@link useFileDecrypt} decrypt action. */
|
|
123
|
+
interface FileDecryptInput {
|
|
124
|
+
readonly file: RecipientFile;
|
|
125
|
+
/** Seal identity material from the share link or your store. */
|
|
126
|
+
readonly sealIdPrefix: Uint8Array;
|
|
127
|
+
readonly sealNonce: Uint8Array;
|
|
128
|
+
readonly ttlMin?: number;
|
|
129
|
+
}
|
|
130
|
+
/** Return value of {@link useFileDecrypt}. */
|
|
131
|
+
interface UseFileDecryptResult {
|
|
132
|
+
readonly status: FileDecryptStatus;
|
|
133
|
+
readonly data: Uint8Array | null;
|
|
134
|
+
readonly error: unknown;
|
|
135
|
+
readonly decrypt: (input: FileDecryptInput) => Promise<Uint8Array>;
|
|
136
|
+
readonly reset: () => void;
|
|
137
|
+
}
|
|
138
|
+
/** Generic load status for the read hooks. */
|
|
139
|
+
type LoadStatus = "idle" | "loading" | "success" | "error";
|
|
140
|
+
/** Return value of {@link useRecipientFile}. */
|
|
141
|
+
interface UseRecipientFileResult {
|
|
142
|
+
readonly status: LoadStatus;
|
|
143
|
+
readonly file: RecipientFile | null;
|
|
144
|
+
readonly error: unknown;
|
|
145
|
+
readonly refresh: () => Promise<RecipientFile | null>;
|
|
146
|
+
}
|
|
147
|
+
/** Options for the {@link useStorageCostEstimate} hook. */
|
|
148
|
+
interface UseStorageCostEstimateOptions {
|
|
149
|
+
readonly sizeBytes: number;
|
|
150
|
+
readonly epochs: number;
|
|
151
|
+
/** Add the Seal envelope overhead to the priced size. */
|
|
152
|
+
readonly encrypt?: boolean;
|
|
153
|
+
/** Override the default $0.023/GB/month rate. */
|
|
154
|
+
readonly usdPerGbPerMonth?: number;
|
|
155
|
+
}
|
|
156
|
+
/** Return value of {@link useStorageCostEstimate}. */
|
|
157
|
+
interface UseStorageCostEstimateResult {
|
|
158
|
+
readonly estimate: UsdCostEstimate;
|
|
159
|
+
}
|
|
160
|
+
/** Load/work status for {@link useFileDownload}. */
|
|
161
|
+
type FileDownloadStatus = "idle" | "loading" | "ready" | "error";
|
|
162
|
+
/** Return value of {@link useFileDownload}. */
|
|
163
|
+
interface UseFileDownloadResult {
|
|
164
|
+
/** Status of the on-chain metadata load. */
|
|
165
|
+
readonly metaStatus: LoadStatus;
|
|
166
|
+
readonly file: RecipientFile | null;
|
|
167
|
+
/** Status of fetching (and decrypting) the bytes. */
|
|
168
|
+
readonly status: FileDownloadStatus;
|
|
169
|
+
/** Object URL for the fetched bytes; null until loaded. */
|
|
170
|
+
readonly objectUrl: string | null;
|
|
171
|
+
/** True when the share link carries Seal material (the file is encrypted). */
|
|
172
|
+
readonly encrypted: boolean;
|
|
173
|
+
/** True when the content type is a previewable image. */
|
|
174
|
+
readonly isImage: boolean;
|
|
175
|
+
readonly error: unknown;
|
|
176
|
+
/** Fetch the bytes (public read or Seal decrypt) and build the object URL. */
|
|
177
|
+
readonly load: () => Promise<void>;
|
|
178
|
+
/** Trigger a browser download of the already-loaded bytes. */
|
|
179
|
+
readonly save: () => void;
|
|
180
|
+
/** Load (if needed) and download in one call. */
|
|
181
|
+
readonly download: () => Promise<void>;
|
|
182
|
+
}
|
|
183
|
+
/** Arguments for {@link estimateStorageUsd}. */
|
|
184
|
+
interface UsdCostArgs {
|
|
185
|
+
readonly sizeBytes: number;
|
|
186
|
+
readonly epochs: number;
|
|
187
|
+
/** Epoch length in ms (testnet ~1 day, mainnet ~2 weeks); read from chain. */
|
|
188
|
+
readonly epochDurationMs: number;
|
|
189
|
+
/** Bytes the Seal envelope adds when encrypting; folded into the priced size. */
|
|
190
|
+
readonly encryptionOverheadBytes?: number;
|
|
191
|
+
/** Override the default $0.023/GB/month rate. */
|
|
192
|
+
readonly usdPerGbPerMonth?: number;
|
|
193
|
+
}
|
|
194
|
+
/** Result of {@link estimateStorageUsd}. */
|
|
195
|
+
interface UsdCostEstimate {
|
|
196
|
+
readonly usd: number;
|
|
197
|
+
readonly gb: number;
|
|
198
|
+
readonly months: number;
|
|
199
|
+
/** Storage duration in days (epochs times the network epoch length). */
|
|
200
|
+
readonly days: number;
|
|
201
|
+
readonly sizeBytes: number;
|
|
202
|
+
}
|
|
203
|
+
/** Props for the `<MorseFileUploader>` drop-in component. */
|
|
204
|
+
interface MorseFileUploaderProps {
|
|
205
|
+
readonly className?: string;
|
|
206
|
+
/** Recipient wallets (the connected wallet is auto-added on chain). */
|
|
207
|
+
readonly recipients?: readonly SuiAddress[];
|
|
208
|
+
/** Encrypt the file under Seal so only recipients can decrypt. */
|
|
209
|
+
readonly encrypt?: boolean;
|
|
210
|
+
/** Default storage duration in epochs. */
|
|
211
|
+
readonly defaultEpochs?: number;
|
|
212
|
+
/** Minimum selectable epochs. Defaults to 1. */
|
|
213
|
+
readonly minEpochs?: number;
|
|
214
|
+
/** Maximum selectable epochs. Defaults to the Walrus lease cap (53). */
|
|
215
|
+
readonly maxEpochs?: number;
|
|
216
|
+
/** Called when an upload completes; receives the seal material and share link. */
|
|
217
|
+
readonly onUploaded?: (result: CompletedFileUpload) => void;
|
|
218
|
+
}
|
|
219
|
+
/** Props for the `<MorseFileDownloader>` drop-in component. */
|
|
220
|
+
interface MorseFileDownloaderProps {
|
|
221
|
+
/** The on-chain RecipientFile id (from the share link). */
|
|
222
|
+
readonly fileId: RecipientFileId;
|
|
223
|
+
/** Seal material for encrypted files; omit/null for public files. */
|
|
224
|
+
readonly sealIdPrefix?: Uint8Array | null;
|
|
225
|
+
readonly sealNonce?: Uint8Array | null;
|
|
226
|
+
readonly className?: string;
|
|
227
|
+
}
|
|
228
|
+
/** Arguments for {@link buildShareLink}. */
|
|
229
|
+
interface BuildShareLinkArgs {
|
|
230
|
+
/** The on-chain RecipientFile object id. */
|
|
231
|
+
readonly fileId: string;
|
|
232
|
+
/**
|
|
233
|
+
* Seal identity material, persisted so recipients can decrypt. Not a secret:
|
|
234
|
+
* decryption is still gated by the file's recipient set. Omit for public files.
|
|
235
|
+
*/
|
|
236
|
+
readonly sealIdPrefix?: Uint8Array;
|
|
237
|
+
readonly sealNonce?: Uint8Array;
|
|
238
|
+
/** Base URL; defaults to the current browser origin. */
|
|
239
|
+
readonly baseUrl?: string;
|
|
240
|
+
/** Fragment path pattern containing `:fileId`; defaults to `/#/f/:fileId`. */
|
|
241
|
+
readonly pattern?: string;
|
|
242
|
+
}
|
|
243
|
+
/** Result of {@link parseShareLink}. */
|
|
244
|
+
interface ParsedShareLink {
|
|
245
|
+
readonly fileId: string;
|
|
246
|
+
/** Seal material if present in the link, else null (public file). */
|
|
247
|
+
readonly sealIdPrefix: Uint8Array | null;
|
|
248
|
+
readonly sealNonce: Uint8Array | null;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export type { BuildShareLinkArgs as B, CompletedFileUpload as C, FilePhase as F, LoadStatus as L, MorseFilesHandles as M, ParsedShareLink as P, SealMaterial as S, UsdCostArgs as U, UsdCostEstimate as a, UseFileDecryptResult as b, UseFileDownloadResult as c, UseFileUploadResult as d, UseMorseFilesOptions as e, UseMorseFilesResult as f, UseRecipientFileResult as g, UseStorageCostEstimateOptions as h, UseStorageCostEstimateResult as i, FileDecryptInput as j, FileDecryptStatus as k, FileDownloadStatus as l, FileUploadInput as m, FileUploadStatus as n, MorseFileDownloaderProps as o, MorseFileUploaderProps as p, MorseFilesWalletCallbacks as q, SetupStatus as r };
|