@mysten/walrus 0.7.4 → 0.8.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 +24 -0
- package/README.md +105 -74
- package/dist/cjs/client.d.ts +11 -9
- package/dist/cjs/client.js +48 -15
- package/dist/cjs/client.js.map +2 -2
- package/dist/cjs/index.d.ts +3 -3
- package/dist/cjs/index.js +2 -1
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/types.d.ts +7 -5
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/utils/bcs.d.ts +5 -15
- package/dist/cjs/utils/bcs.js +1 -1
- package/dist/cjs/utils/bcs.js.map +2 -2
- package/dist/esm/client.d.ts +11 -9
- package/dist/esm/client.js +49 -17
- package/dist/esm/client.js.map +2 -2
- package/dist/esm/index.d.ts +3 -3
- package/dist/esm/index.js +3 -2
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/types.d.ts +7 -5
- package/dist/esm/utils/bcs.d.ts +5 -15
- package/dist/esm/utils/bcs.js +1 -1
- package/dist/esm/utils/bcs.js.map +2 -2
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @mysten/walrus
|
|
2
2
|
|
|
3
|
+
## 0.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 8894443: Set \_walrusBlobType for quilts
|
|
8
|
+
- f3b19a7: Use bcs.byteVector and bcs.bytes instead of bcs.vector(bcs.u8()) and bcs.fixedArrray(n,
|
|
9
|
+
bcs.u8()) to improve performance
|
|
10
|
+
- bf9f85c: deprecate asClientExtension methods
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [f3b19a7]
|
|
15
|
+
- Updated dependencies [f3b19a7]
|
|
16
|
+
- Updated dependencies [bf9f85c]
|
|
17
|
+
- @mysten/sui@1.43.0
|
|
18
|
+
- @mysten/bcs@1.9.0
|
|
19
|
+
|
|
20
|
+
## 0.7.5
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- Updated dependencies [98c8a27]
|
|
25
|
+
- @mysten/sui@1.42.0
|
|
26
|
+
|
|
3
27
|
## 0.7.4
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -8,51 +8,63 @@ npm install --save @mysten/walrus @mysten/sui
|
|
|
8
8
|
|
|
9
9
|
## Setup
|
|
10
10
|
|
|
11
|
-
To use the walrus SDK you will need to create
|
|
12
|
-
|
|
11
|
+
To use the walrus SDK you will need to create a Client from the typescript SDK, and extend it with
|
|
12
|
+
the walrus SDK.
|
|
13
13
|
|
|
14
14
|
```ts
|
|
15
|
-
import { getFullnodeUrl,
|
|
16
|
-
import {
|
|
15
|
+
import { getFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
|
|
16
|
+
import { walrus } from '@mysten/walrus';
|
|
17
17
|
|
|
18
|
-
const
|
|
18
|
+
const client = new SuiJsonRpcClient({
|
|
19
19
|
url: getFullnodeUrl('testnet'),
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const walrusClient = new WalrusClient({
|
|
20
|
+
// Setting network on your client is required for walrus to work correctly
|
|
23
21
|
network: 'testnet',
|
|
24
|
-
|
|
25
|
-
});
|
|
22
|
+
}).$extend(walrus());
|
|
26
23
|
```
|
|
27
24
|
|
|
28
25
|
The walrus SDK currently includes all the relevant package and object IDs needed for connecting to
|
|
29
|
-
testnet. You can also manually configure the
|
|
30
|
-
|
|
26
|
+
testnet. You can also manually configure the walrus sdk to use a different set of ids, allowing you
|
|
27
|
+
to connect to a different network or updated deployment of the walrus contracts.
|
|
31
28
|
|
|
32
29
|
```ts
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
30
|
+
import { getFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
|
|
31
|
+
import { walrus } from '@mysten/walrus';
|
|
32
|
+
|
|
33
|
+
const client = new SuiJsonRpcClient({
|
|
34
|
+
url: getFullnodeUrl('testnet'),
|
|
35
|
+
// Setting network on your client is required for walrus to work correctly
|
|
36
|
+
network: 'testnet',
|
|
37
|
+
}).$extend(
|
|
38
|
+
walrus({
|
|
39
|
+
packageConfig: {
|
|
40
|
+
systemObjectId: '0x98ebc47370603fe81d9e15491b2f1443d619d1dab720d586e429ed233e1255c1',
|
|
41
|
+
stakingPoolId: '0x20266a17b4f1a216727f3eef5772f8d486a9e3b5e319af80a5b75809c035561d',
|
|
42
|
+
},
|
|
43
|
+
}),
|
|
44
|
+
);
|
|
40
45
|
```
|
|
41
46
|
|
|
42
47
|
For some environments you may need to customize how data is fetched:
|
|
43
48
|
|
|
44
49
|
```ts
|
|
45
|
-
|
|
50
|
+
import { getFullnodeUrl, SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
|
|
51
|
+
import { walrus } from '@mysten/walrus';
|
|
52
|
+
|
|
53
|
+
const client = new SuiJsonRpcClient({
|
|
54
|
+
url: getFullnodeUrl('testnet'),
|
|
55
|
+
// Setting network on your client is required for walrus to work correctly
|
|
46
56
|
network: 'testnet',
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
57
|
+
}).$extend(
|
|
58
|
+
walrus({
|
|
59
|
+
storageNodeClientOptions: {
|
|
60
|
+
fetch: (url, options) => {
|
|
61
|
+
console.log('fetching', url);
|
|
62
|
+
return fetch(url, options);
|
|
63
|
+
},
|
|
64
|
+
timeout: 60_000,
|
|
52
65
|
},
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
});
|
|
66
|
+
}),
|
|
67
|
+
);
|
|
56
68
|
```
|
|
57
69
|
|
|
58
70
|
This can be used to implement a fetch function with custom timeouts, rate limits, retry logic, or
|
|
@@ -69,7 +81,7 @@ aggregators is recommended, but the TS SDK can be useful when building applicati
|
|
|
69
81
|
application needs to directly interact with walrus or users need to pay for their own storage
|
|
70
82
|
directly.
|
|
71
83
|
|
|
72
|
-
The
|
|
84
|
+
The walrus sdk exposes high level methods for reading and writing blobs, as well as lower level
|
|
73
85
|
methods for the individual steps in the process that can be used to implement more complex flows
|
|
74
86
|
when you want more control to implement more optimized implementations.
|
|
75
87
|
|
|
@@ -88,7 +100,7 @@ It is encouraged to always read files in batches when possible, which will allow
|
|
|
88
100
|
more efficient when loading multiple files from the same quilt.
|
|
89
101
|
|
|
90
102
|
```ts
|
|
91
|
-
const [file1, file2] = await
|
|
103
|
+
const [file1, file2] = await client.walrus.getFiles({ ids: [anyBlobId, orQuiltId] });
|
|
92
104
|
```
|
|
93
105
|
|
|
94
106
|
A `WalrusFile` works like a `Response` object from the `fetch` API:
|
|
@@ -115,7 +127,7 @@ const tags: Record<string, string> = await file1.getTags();
|
|
|
115
127
|
You can also get a `WalrusBlob` instead of a `WalrusFile` if you have the blobId:
|
|
116
128
|
|
|
117
129
|
```ts
|
|
118
|
-
const blob = await
|
|
130
|
+
const blob = await client.walrus.getBlob({ blobId });
|
|
119
131
|
```
|
|
120
132
|
|
|
121
133
|
If the blob is a quilt, you can read the files in the quilt:
|
|
@@ -137,9 +149,16 @@ You can also construct a `WalrusFile` from a `Uint8Array`, `Blob`, or a `string`
|
|
|
137
149
|
stored on walrus:
|
|
138
150
|
|
|
139
151
|
```ts
|
|
140
|
-
const file1 = WalrusFile.from(
|
|
141
|
-
|
|
142
|
-
|
|
152
|
+
const file1 = WalrusFile.from({
|
|
153
|
+
contents: new Uint8Array([1, 2, 3]),
|
|
154
|
+
identifier: 'file1.bin',
|
|
155
|
+
});
|
|
156
|
+
const file2 = WalrusFile.from({
|
|
157
|
+
contents: new Blob([new Uint8Array([1, 2, 3])]),
|
|
158
|
+
identifier: 'file2.bin',
|
|
159
|
+
});
|
|
160
|
+
const file3 = WalrusFile.from({
|
|
161
|
+
contents: new TextEncoder().encode('Hello from the TS SDK!!!\n'),
|
|
143
162
|
identifier: 'README.md',
|
|
144
163
|
tags: {
|
|
145
164
|
'content-type': 'text/plain',
|
|
@@ -162,7 +181,7 @@ const results: {
|
|
|
162
181
|
id: string;
|
|
163
182
|
blobId: string;
|
|
164
183
|
blobObject: Blob.$inferType;
|
|
165
|
-
}[] =
|
|
184
|
+
}[] = client.walrus.writeFiles({
|
|
166
185
|
files: [file1, file2, file3],
|
|
167
186
|
epochs: 3,
|
|
168
187
|
deletable: true,
|
|
@@ -199,7 +218,7 @@ Here's a simplified example showing the core API usage with separate user intera
|
|
|
199
218
|
|
|
200
219
|
```tsx
|
|
201
220
|
// Step 1: Create and encode the flow (can be done immediately when file is selected)
|
|
202
|
-
const flow =
|
|
221
|
+
const flow = client.walrus.writeFilesFlow({
|
|
203
222
|
files: [
|
|
204
223
|
WalrusFile.from({
|
|
205
224
|
contents: new Uint8Array(fileData),
|
|
@@ -244,14 +263,14 @@ Writing blobs directly from a client requires a lot of requests to write data to
|
|
|
244
263
|
nodes. An upload relay can be used to offload the work of these writes to a server, reducing
|
|
245
264
|
complexity for the client.
|
|
246
265
|
|
|
247
|
-
To use an upload relay, you can add the `uploadRelay` option when
|
|
266
|
+
To use an upload relay, you can add the `uploadRelay` option when adding the walrus extension:
|
|
248
267
|
|
|
249
268
|
```ts
|
|
250
|
-
const client = new
|
|
269
|
+
const client = new SuiJsonRpcClient({
|
|
251
270
|
url: getFullnodeUrl('testnet'),
|
|
252
271
|
network: 'testnet',
|
|
253
272
|
}).$extend(
|
|
254
|
-
|
|
273
|
+
walrus({
|
|
255
274
|
uploadRelay: {
|
|
256
275
|
host: 'https://upload-relay.testnet.walrus.space',
|
|
257
276
|
sendTip: {
|
|
@@ -276,11 +295,11 @@ tip.
|
|
|
276
295
|
A `const` will send a fixed amount for each blob written to the upload relay.
|
|
277
296
|
|
|
278
297
|
```ts
|
|
279
|
-
const client = new
|
|
298
|
+
const client = new SuiJsonRpcClient({
|
|
280
299
|
url: getFullnodeUrl('testnet'),
|
|
281
300
|
network: 'testnet',
|
|
282
301
|
}).$extend(
|
|
283
|
-
|
|
302
|
+
walrus({
|
|
284
303
|
uploadRelay: {
|
|
285
304
|
host: 'https://upload-relay.testnet.walrus.space',
|
|
286
305
|
sendTip: {
|
|
@@ -300,11 +319,11 @@ A `linear` tip will send a fixed amount for each blob written to the fan out pro
|
|
|
300
319
|
multiplier based on the size of the blob.
|
|
301
320
|
|
|
302
321
|
```ts
|
|
303
|
-
const client = new
|
|
322
|
+
const client = new SuiJsonRpcClient({
|
|
304
323
|
url: getFullnodeUrl('testnet'),
|
|
305
324
|
network: 'testnet',
|
|
306
325
|
}).$extend(
|
|
307
|
-
|
|
326
|
+
walrus({
|
|
308
327
|
uploadRelay: {
|
|
309
328
|
host: 'https://upload-relay.testnet.walrus.space',
|
|
310
329
|
sendTip: {
|
|
@@ -332,7 +351,7 @@ The `readBlob` method will read a blob given the blobId and return Uint8Array co
|
|
|
332
351
|
content:
|
|
333
352
|
|
|
334
353
|
```ts
|
|
335
|
-
const blob = await
|
|
354
|
+
const blob = await client.walrus.readBlob({ blobId });
|
|
336
355
|
```
|
|
337
356
|
|
|
338
357
|
### Writing Blobs
|
|
@@ -343,7 +362,7 @@ specify how long the blob should be stored for, and if the blob should be deleta
|
|
|
343
362
|
```ts
|
|
344
363
|
const file = new TextEncoder().encode('Hello from the TS SDK!!!\n');
|
|
345
364
|
|
|
346
|
-
const { blobId } = await
|
|
365
|
+
const { blobId } = await client.walrus.writeBlob({
|
|
347
366
|
blob: file,
|
|
348
367
|
deletable: false,
|
|
349
368
|
epochs: 3,
|
|
@@ -376,7 +395,7 @@ You can check for these errors, and reset the client before retrying:
|
|
|
376
395
|
import { RetryableWalrusClientError } from '@mysten/walrus';
|
|
377
396
|
|
|
378
397
|
if (error instanceof RetryableWalrusClientError) {
|
|
379
|
-
|
|
398
|
+
client.walrus.reset();
|
|
380
399
|
|
|
381
400
|
/* retry your operation */
|
|
382
401
|
}
|
|
@@ -403,13 +422,16 @@ You can pass an `onError` option in the storageNodeClientOptions to get the indi
|
|
|
403
422
|
failed requests:
|
|
404
423
|
|
|
405
424
|
```ts
|
|
406
|
-
const
|
|
425
|
+
const client = new SuiJsonRpcClient({
|
|
426
|
+
url: getFullnodeUrl('testnet'),
|
|
407
427
|
network: 'testnet',
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
}
|
|
428
|
+
}).$extend(
|
|
429
|
+
walrus({
|
|
430
|
+
storageNodeClientOptions: {
|
|
431
|
+
onError: (error) => console.log(error),
|
|
432
|
+
},
|
|
433
|
+
}),
|
|
434
|
+
);
|
|
413
435
|
```
|
|
414
436
|
|
|
415
437
|
## Configuring network requests
|
|
@@ -429,22 +451,25 @@ behavior defined by your runtime. To customize how requests are made, you can pr
|
|
|
429
451
|
import type { RequestInfo, RequestInit } from 'undici';
|
|
430
452
|
import { Agent, fetch, setGlobalDispatcher } from 'undici';
|
|
431
453
|
|
|
432
|
-
const
|
|
454
|
+
const client = new SuiJsonRpcClient({
|
|
455
|
+
url: getFullnodeUrl('testnet'),
|
|
433
456
|
network: 'testnet',
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
457
|
+
}).$extend(
|
|
458
|
+
walrus({
|
|
459
|
+
storageNodeClientOptions: {
|
|
460
|
+
timeout: 60_000,
|
|
461
|
+
fetch: (url, init) => {
|
|
462
|
+
// Some casting may be required because undici types may not exactly match the @node/types types
|
|
463
|
+
return fetch(url as RequestInfo, {
|
|
464
|
+
...(init as RequestInit),
|
|
465
|
+
dispatcher: new Agent({
|
|
466
|
+
connectTimeout: 60_000,
|
|
467
|
+
}),
|
|
468
|
+
}) as unknown as Promise<Response>;
|
|
469
|
+
},
|
|
445
470
|
},
|
|
446
|
-
},
|
|
447
|
-
|
|
471
|
+
}),
|
|
472
|
+
);
|
|
448
473
|
```
|
|
449
474
|
|
|
450
475
|
## Loading the wasm module in vite or client side apps
|
|
@@ -460,22 +485,28 @@ and then passed into the walrus client:
|
|
|
460
485
|
```ts
|
|
461
486
|
import walrusWasmUrl from '@mysten/walrus-wasm/web/walrus_wasm_bg.wasm?url';
|
|
462
487
|
|
|
463
|
-
const
|
|
488
|
+
const client = new SuiJsonRpcClient({
|
|
489
|
+
url: getFullnodeUrl('testnet'),
|
|
464
490
|
network: 'testnet',
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
491
|
+
}).$extend(
|
|
492
|
+
walrus({
|
|
493
|
+
wasmUrl: walrusWasmUrl,
|
|
494
|
+
}),
|
|
495
|
+
);
|
|
468
496
|
```
|
|
469
497
|
|
|
470
498
|
If you are unable to get a url for the wasm file in your bundler or build system, you can self host
|
|
471
499
|
the wasm bindings, or load them from a CDN:
|
|
472
500
|
|
|
473
501
|
```ts
|
|
474
|
-
const
|
|
502
|
+
const client = new SuiJsonRpcClient({
|
|
503
|
+
url: getFullnodeUrl('testnet'),
|
|
475
504
|
network: 'testnet',
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
505
|
+
}).$extend(
|
|
506
|
+
walrus({
|
|
507
|
+
wasmUrl: 'https://unpkg.com/@mysten/walrus-wasm@latest/web/walrus_wasm_bg.wasm',
|
|
508
|
+
}),
|
|
509
|
+
);
|
|
479
510
|
```
|
|
480
511
|
|
|
481
512
|
In next.js when using walrus in API routes, you may need to tell next.js to skip bundling for the
|
package/dist/cjs/client.d.ts
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import { SuiClient } from '@mysten/sui/client';
|
|
2
1
|
import type { Signer } from '@mysten/sui/cryptography';
|
|
3
|
-
import type {
|
|
2
|
+
import type { ClientWithCoreApi } from '@mysten/sui/experimental';
|
|
4
3
|
import type { TransactionResult } from '@mysten/sui/transactions';
|
|
5
4
|
import { Transaction } from '@mysten/sui/transactions';
|
|
6
5
|
import { Blob } from './contracts/walrus/blob.js';
|
|
7
6
|
import type { BlobStatus } from './storage-node/types.js';
|
|
8
|
-
import type { CertifyBlobOptions, ComputeBlobMetadataOptions, DeleteBlobOptions, ExtendBlobOptions, GetBlobMetadataOptions, GetSecondarySliverOptions, GetSliversOptions, GetStorageConfirmationOptions, GetVerifiedBlobStatusOptions, ProtocolMessageCertificate, ReadBlobOptions, RegisterBlobOptions, SliversForNode, StorageWithSizeOptions, WalrusClientConfig, WalrusClientExtensionOptions, WriteBlobAttributesOptions, WriteBlobOptions, WriteBlobToUploadRelayOptions, WriteEncodedBlobOptions, WriteEncodedBlobToNodesOptions, WriteMetadataOptions, WriteQuiltOptions, WriteSliverOptions, WriteSliversToNodeOptions, WriteFilesOptions, WriteFilesFlowOptions, WriteFilesFlow, WriteBlobFlow, WriteBlobFlowOptions } from './types.js';
|
|
7
|
+
import type { CertifyBlobOptions, ComputeBlobMetadataOptions, DeleteBlobOptions, ExtendBlobOptions, GetBlobMetadataOptions, GetSecondarySliverOptions, GetSliversOptions, GetStorageConfirmationOptions, GetVerifiedBlobStatusOptions, ProtocolMessageCertificate, ReadBlobOptions, RegisterBlobOptions, SliversForNode, StorageWithSizeOptions, WalrusClientConfig, WalrusClientExtensionOptions, WriteBlobAttributesOptions, WriteBlobOptions, WriteBlobToUploadRelayOptions, WriteEncodedBlobOptions, WriteEncodedBlobToNodesOptions, WriteMetadataOptions, WriteQuiltOptions, WriteSliverOptions, WriteSliversToNodeOptions, WriteFilesOptions, WriteFilesFlowOptions, WriteFilesFlow, WriteBlobFlow, WriteBlobFlowOptions, WalrusOptions } from './types.js';
|
|
9
8
|
import { WalrusBlob } from './files/blob.js';
|
|
10
9
|
import { WalrusFile } from './files/file.js';
|
|
10
|
+
export declare function walrus<const Name = 'walrus'>({ packageConfig, network, name, ...options }?: WalrusOptions<Name>): {
|
|
11
|
+
name: Name;
|
|
12
|
+
register: (client: ClientWithCoreApi) => WalrusClient;
|
|
13
|
+
};
|
|
11
14
|
export declare class WalrusClient {
|
|
12
15
|
#private;
|
|
13
16
|
constructor(config: WalrusClientConfig);
|
|
17
|
+
/** @deprecated use `walrus()` instead */
|
|
14
18
|
static experimental_asClientExtension({ packageConfig, network, ...options }?: WalrusClientExtensionOptions): {
|
|
15
19
|
name: "walrus";
|
|
16
|
-
register: (client:
|
|
17
|
-
jsonRpc: SuiClient;
|
|
18
|
-
}>) => WalrusClient;
|
|
20
|
+
register: (client: ClientWithCoreApi) => WalrusClient;
|
|
19
21
|
};
|
|
20
22
|
/** The Move type for a Blob object */
|
|
21
23
|
getBlobType(): string | Promise<string>;
|
|
@@ -191,21 +193,21 @@ export declare class WalrusClient {
|
|
|
191
193
|
}>;
|
|
192
194
|
getSecondarySliver: ({ blobId, index, signal }: GetSecondarySliverOptions) => Promise<{
|
|
193
195
|
symbols: {
|
|
194
|
-
data:
|
|
196
|
+
data: Uint8Array<ArrayBufferLike>;
|
|
195
197
|
symbol_size: number;
|
|
196
198
|
};
|
|
197
199
|
index: number;
|
|
198
200
|
}>;
|
|
199
201
|
internalGetSecondarySliver({ blobId, index, signal }: GetSecondarySliverOptions): Promise<{
|
|
200
202
|
symbols: {
|
|
201
|
-
data:
|
|
203
|
+
data: Uint8Array<ArrayBufferLike>;
|
|
202
204
|
symbol_size: number;
|
|
203
205
|
};
|
|
204
206
|
index: number;
|
|
205
207
|
}>;
|
|
206
208
|
getSlivers({ blobId, signal }: GetSliversOptions): Promise<{
|
|
207
209
|
symbols: {
|
|
208
|
-
data:
|
|
210
|
+
data: Uint8Array<ArrayBufferLike>;
|
|
209
211
|
symbol_size: number;
|
|
210
212
|
};
|
|
211
213
|
index: number;
|
package/dist/cjs/client.js
CHANGED
|
@@ -36,7 +36,8 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
36
36
|
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
37
37
|
var client_exports = {};
|
|
38
38
|
__export(client_exports, {
|
|
39
|
-
WalrusClient: () => WalrusClient
|
|
39
|
+
WalrusClient: () => WalrusClient,
|
|
40
|
+
walrus: () => walrus
|
|
40
41
|
});
|
|
41
42
|
module.exports = __toCommonJS(client_exports);
|
|
42
43
|
var import_bcs = require("@mysten/bcs");
|
|
@@ -70,6 +71,33 @@ var import_quilt_file = require("./files/readers/quilt-file.js");
|
|
|
70
71
|
var import_quilt = require("./files/readers/quilt.js");
|
|
71
72
|
var import_retry = require("./utils/retry.js");
|
|
72
73
|
var _storageNodeClient, _wasmUrl, _packageConfig, _suiClient, _objectLoader, _blobMetadataConcurrencyLimit, _readCommittee, _cache, _uploadRelayConfig, _uploadRelayClient, _WalrusClient_instances, walType_fn, getPackageId_fn, getWalrusPackageId_fn, wasmBindings_fn, internalReadBlob_fn, getCertificationEpoch_fn, getReadCommittee_fn, forceGetReadCommittee_fn, withWal_fn, loadTipConfig_fn, getCreatedBlob_fn, writeBlobAttributesForRef_fn, executeTransaction_fn, getCommittee_fn, getActiveCommittee_fn, stakingPool_fn, getNodeByShardIndex_fn, retryOnPossibleEpochChange_fn;
|
|
74
|
+
function walrus({
|
|
75
|
+
packageConfig,
|
|
76
|
+
network,
|
|
77
|
+
name = "walrus",
|
|
78
|
+
...options
|
|
79
|
+
} = {}) {
|
|
80
|
+
return {
|
|
81
|
+
name,
|
|
82
|
+
register: (client) => {
|
|
83
|
+
const walrusNetwork = network || client.network;
|
|
84
|
+
if (walrusNetwork !== "mainnet" && walrusNetwork !== "testnet") {
|
|
85
|
+
throw new import_error.WalrusClientError("Walrus client only supports mainnet and testnet");
|
|
86
|
+
}
|
|
87
|
+
return new WalrusClient(
|
|
88
|
+
packageConfig ? {
|
|
89
|
+
packageConfig,
|
|
90
|
+
suiClient: client,
|
|
91
|
+
...options
|
|
92
|
+
} : {
|
|
93
|
+
network: walrusNetwork,
|
|
94
|
+
suiClient: client,
|
|
95
|
+
...options
|
|
96
|
+
}
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
73
101
|
const _WalrusClient = class _WalrusClient {
|
|
74
102
|
constructor(config) {
|
|
75
103
|
__privateAdd(this, _WalrusClient_instances);
|
|
@@ -113,6 +141,7 @@ const _WalrusClient = class _WalrusClient {
|
|
|
113
141
|
__privateSet(this, _objectLoader, new import_object_loader.SuiObjectDataLoader(__privateGet(this, _suiClient)));
|
|
114
142
|
__privateSet(this, _cache, __privateGet(this, _suiClient).cache.scope("@mysten/walrus"));
|
|
115
143
|
}
|
|
144
|
+
/** @deprecated use `walrus()` instead */
|
|
116
145
|
static experimental_asClientExtension({
|
|
117
146
|
packageConfig,
|
|
118
147
|
network,
|
|
@@ -1354,8 +1383,12 @@ const _WalrusClient = class _WalrusClient {
|
|
|
1354
1383
|
async writeQuilt({ blobs, ...options }) {
|
|
1355
1384
|
const encoded = await this.encodeQuilt({ blobs });
|
|
1356
1385
|
const result = await this.writeBlob({
|
|
1386
|
+
...options,
|
|
1357
1387
|
blob: encoded.quilt,
|
|
1358
|
-
|
|
1388
|
+
attributes: {
|
|
1389
|
+
_walrusBlobType: "quilt",
|
|
1390
|
+
...options.attributes
|
|
1391
|
+
}
|
|
1359
1392
|
});
|
|
1360
1393
|
return {
|
|
1361
1394
|
...result,
|
|
@@ -1508,7 +1541,10 @@ const _WalrusClient = class _WalrusClient {
|
|
|
1508
1541
|
blobId: metadata2.blobId,
|
|
1509
1542
|
rootHash: metadata2.rootHash,
|
|
1510
1543
|
deletable,
|
|
1511
|
-
attributes
|
|
1544
|
+
attributes: {
|
|
1545
|
+
_walrusBlobType: "quilt",
|
|
1546
|
+
...attributes
|
|
1547
|
+
}
|
|
1512
1548
|
})
|
|
1513
1549
|
],
|
|
1514
1550
|
owner
|
|
@@ -1774,21 +1810,18 @@ _WalrusClient_instances = new WeakSet();
|
|
|
1774
1810
|
/** The Move type for a WAL coin */
|
|
1775
1811
|
walType_fn = function() {
|
|
1776
1812
|
return __privateGet(this, _cache).read(["walType"], async () => {
|
|
1777
|
-
const
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1813
|
+
const stakeWithPool = await __privateGet(this, _suiClient).core.getMoveFunction({
|
|
1814
|
+
packageId: await __privateMethod(this, _WalrusClient_instances, getPackageId_fn).call(this),
|
|
1815
|
+
moduleName: "staking",
|
|
1816
|
+
name: "stake_with_pool"
|
|
1781
1817
|
});
|
|
1782
|
-
const
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
const parsed = (0, import_utils.parseStructTag)((0, import_utils2.toTypeString)(balanceType));
|
|
1787
|
-
const coinType = parsed.typeParams[0];
|
|
1788
|
-
if (!coinType) {
|
|
1818
|
+
const toStake = stakeWithPool.function.parameters[1];
|
|
1819
|
+
const toStakeCoin = toStake.body.$kind === "datatype" ? toStake.body.datatype : null;
|
|
1820
|
+
const toStakeCoinType = toStakeCoin?.typeParameters[0]?.$kind === "datatype" ? toStakeCoin.typeParameters[0] : null;
|
|
1821
|
+
if (toStakeCoinType?.$kind !== "datatype") {
|
|
1789
1822
|
throw new import_error.WalrusClientError("WAL type not found");
|
|
1790
1823
|
}
|
|
1791
|
-
return (0, import_utils.normalizeStructTag)(
|
|
1824
|
+
return (0, import_utils.normalizeStructTag)(toStakeCoinType.datatype.typeName);
|
|
1792
1825
|
});
|
|
1793
1826
|
};
|
|
1794
1827
|
getPackageId_fn = function() {
|