@withautonomi/autonomi 0.4.3 → 0.4.4
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/Cargo.toml +1 -1
- package/README.md +76 -0
- package/artifacts/github-pages/artifact.tar +0 -0
- package/index.d.ts +106 -133
- package/package.json +16 -7
- package/src/lib.rs +363 -374
package/index.d.ts
CHANGED
|
@@ -10,7 +10,6 @@ export interface ArchiveFile {
|
|
|
10
10
|
size: bigint
|
|
11
11
|
extra?: string
|
|
12
12
|
}
|
|
13
|
-
export type JsClient = Client
|
|
14
13
|
/** Represents a client for the Autonomi network. */
|
|
15
14
|
export declare class Client {
|
|
16
15
|
/**
|
|
@@ -18,52 +17,52 @@ export declare class Client {
|
|
|
18
17
|
*
|
|
19
18
|
* See `init_with_config`.
|
|
20
19
|
*/
|
|
21
|
-
static init(): Promise<
|
|
20
|
+
static init(): Promise<Client>
|
|
22
21
|
/**
|
|
23
22
|
* Initialize a client that is configured to be local.
|
|
24
23
|
*
|
|
25
24
|
* See `init_with_config`.
|
|
26
25
|
*/
|
|
27
|
-
static initLocal(): Promise<
|
|
26
|
+
static initLocal(): Promise<Client>
|
|
28
27
|
/**
|
|
29
28
|
* Initialize a client that bootstraps from a list of peers.
|
|
30
29
|
*
|
|
31
30
|
* If any of the provided peers is a global address, the client will not be local.
|
|
32
31
|
*/
|
|
33
32
|
static initWithPeers(peers: Array<string>): Promise<Client>
|
|
34
|
-
evmNetwork():
|
|
33
|
+
evmNetwork(): Network
|
|
35
34
|
/** Get a chunk from the network. */
|
|
36
|
-
chunkGet(addr:
|
|
35
|
+
chunkGet(addr: ChunkAddress): Promise<Buffer>
|
|
37
36
|
/**
|
|
38
37
|
* Manually upload a chunk to the network.
|
|
39
38
|
*
|
|
40
39
|
* It is recommended to use the `data_put` method instead to upload data.
|
|
41
40
|
*/
|
|
42
|
-
chunkPut(data: Buffer, paymentOption:
|
|
41
|
+
chunkPut(data: Buffer, paymentOption: PaymentOption): Promise<ChunkPut>
|
|
43
42
|
/** Get the cost of a chunk. */
|
|
44
|
-
chunkCost(addr:
|
|
43
|
+
chunkCost(addr: ChunkAddress): Promise<string>
|
|
45
44
|
/** Fetches a GraphEntry from the network. */
|
|
46
|
-
graphEntryGet(address:
|
|
45
|
+
graphEntryGet(address: GraphEntryAddress): Promise<GraphEntry>
|
|
47
46
|
/** Check if a graph_entry exists on the network */
|
|
48
|
-
graphEntryCheckExistance(address:
|
|
47
|
+
graphEntryCheckExistance(address: GraphEntryAddress): Promise<boolean>
|
|
49
48
|
/** Manually puts a GraphEntry to the network. */
|
|
50
|
-
graphEntryPut(entry:
|
|
49
|
+
graphEntryPut(entry: GraphEntry, paymentOption: PaymentOption): Promise<GraphEntryPut>
|
|
51
50
|
/** Get the cost to create a GraphEntry */
|
|
52
|
-
graphEntryCost(key:
|
|
51
|
+
graphEntryCost(key: PublicKey): Promise<string>
|
|
53
52
|
/** Get a pointer from the network */
|
|
54
|
-
pointerGet(address:
|
|
53
|
+
pointerGet(address: PointerAddress): Promise<Pointer>
|
|
55
54
|
/** Check if a pointer exists on the network */
|
|
56
|
-
pointerCheckExistance(address:
|
|
55
|
+
pointerCheckExistance(address: PointerAddress): Promise<boolean>
|
|
57
56
|
/** Verify a pointer */
|
|
58
|
-
static pointerVerify(pointer:
|
|
57
|
+
static pointerVerify(pointer: Pointer): void
|
|
59
58
|
/** Manually store a pointer on the network */
|
|
60
|
-
pointerPut(pointer:
|
|
59
|
+
pointerPut(pointer: Pointer, paymentOption: PaymentOption): Promise<PointerPut>
|
|
61
60
|
/**
|
|
62
61
|
* Create a new pointer on the network.
|
|
63
62
|
*
|
|
64
63
|
* Make sure that the owner key is not already used for another pointer as each key is associated with one pointer
|
|
65
64
|
*/
|
|
66
|
-
pointerCreate(owner:
|
|
65
|
+
pointerCreate(owner: SecretKey, target: PointerTarget, paymentOption: PaymentOption): Promise<PointerPut>
|
|
67
66
|
/**
|
|
68
67
|
* Update an existing pointer to point to a new target on the network.
|
|
69
68
|
*
|
|
@@ -72,19 +71,19 @@ export declare class Client {
|
|
|
72
71
|
* Only the latest version of the pointer is kept on the Network,
|
|
73
72
|
* previous versions will be overwritten and unrecoverable.
|
|
74
73
|
*/
|
|
75
|
-
pointerUpdate(owner:
|
|
74
|
+
pointerUpdate(owner: SecretKey, target: PointerTarget): Promise<void>
|
|
76
75
|
/** Calculate the cost of storing a pointer */
|
|
77
|
-
pointerCost(key:
|
|
76
|
+
pointerCost(key: PublicKey): Promise<string>
|
|
78
77
|
/** Get Scratchpad from the Network. A Scratchpad is stored at the owner's public key so we can derive the address from it. */
|
|
79
|
-
scratchpadGetFromPublicKey(publicKey:
|
|
78
|
+
scratchpadGetFromPublicKey(publicKey: PublicKey): Promise<Scratchpad>
|
|
80
79
|
/** Get Scratchpad from the Network */
|
|
81
|
-
scratchpadGet(address:
|
|
80
|
+
scratchpadGet(address: ScratchpadAddress): Promise<Scratchpad>
|
|
82
81
|
/** Check if a scratchpad exists on the network */
|
|
83
|
-
scratchpadCheckExistance(address:
|
|
82
|
+
scratchpadCheckExistance(address: ScratchpadAddress): Promise<boolean>
|
|
84
83
|
/** Verify a scratchpad */
|
|
85
|
-
static scratchpadVerify(scratchpad:
|
|
84
|
+
static scratchpadVerify(scratchpad: Scratchpad): void
|
|
86
85
|
/** Manually store a scratchpad on the network */
|
|
87
|
-
scratchpadPut(scratchpad:
|
|
86
|
+
scratchpadPut(scratchpad: Scratchpad, paymentOption: PaymentOption): Promise<ScratchpadPut>
|
|
88
87
|
/**
|
|
89
88
|
* Create a new scratchpad to the network.
|
|
90
89
|
*
|
|
@@ -92,7 +91,7 @@ export declare class Client {
|
|
|
92
91
|
*
|
|
93
92
|
* Returns the cost and the address of the scratchpad.
|
|
94
93
|
*/
|
|
95
|
-
scratchpadCreate(owner:
|
|
94
|
+
scratchpadCreate(owner: SecretKey, contentType: bigint, initialData: Buffer, paymentOption: PaymentOption): Promise<ScratchpadPut>
|
|
96
95
|
/**
|
|
97
96
|
* Update an existing scratchpad to the network.
|
|
98
97
|
* The scratchpad needs to be created first with Client::scratchpad_create.
|
|
@@ -100,42 +99,42 @@ export declare class Client {
|
|
|
100
99
|
* Only the latest version of the scratchpad is kept on the Network,
|
|
101
100
|
* previous versions will be overwritten and unrecoverable.
|
|
102
101
|
*/
|
|
103
|
-
scratchpadUpdate(owner:
|
|
102
|
+
scratchpadUpdate(owner: SecretKey, contentType: bigint, data: Buffer): Promise<void>
|
|
104
103
|
/** Get the cost of creating a new Scratchpad */
|
|
105
|
-
scratchpadCost(owner:
|
|
104
|
+
scratchpadCost(owner: PublicKey): Promise<string>
|
|
106
105
|
/** Fetch a blob of (private) data from the network */
|
|
107
|
-
dataGet(dataMap:
|
|
106
|
+
dataGet(dataMap: DataMapChunk): Promise<Buffer>
|
|
108
107
|
/**
|
|
109
108
|
* Upload a piece of private data to the network. This data will be self-encrypted.
|
|
110
109
|
* The DataMapChunk is not uploaded to the network, keeping the data private.
|
|
111
110
|
*
|
|
112
111
|
* Returns the DataMapChunk containing the map to the encrypted chunks.
|
|
113
112
|
*/
|
|
114
|
-
dataPut(data: Buffer, paymentOption:
|
|
113
|
+
dataPut(data: Buffer, paymentOption: PaymentOption): Promise<DataPutResult>
|
|
115
114
|
/** Fetch a blob of data from the network */
|
|
116
|
-
dataGetPublic(addr:
|
|
115
|
+
dataGetPublic(addr: DataAddress): Promise<Buffer>
|
|
117
116
|
/**
|
|
118
117
|
* Upload a piece of data to the network. This data is publicly accessible.
|
|
119
118
|
*
|
|
120
119
|
* Returns the Data Address at which the data was stored.
|
|
121
120
|
*/
|
|
122
|
-
dataPutPublic(data: Buffer, paymentOption:
|
|
121
|
+
dataPutPublic(data: Buffer, paymentOption: PaymentOption): Promise<DataPutPublicResult>
|
|
123
122
|
/** Get the estimated cost of storing a piece of data. */
|
|
124
123
|
dataCost(data: Buffer): Promise<string>
|
|
125
124
|
/** Fetch a PrivateArchive from the network */
|
|
126
|
-
archiveGet(addr:
|
|
125
|
+
archiveGet(addr: PrivateArchiveDataMap): Promise<PrivateArchive>
|
|
127
126
|
/** Upload a PrivateArchive to the network */
|
|
128
|
-
archivePut(archive:
|
|
127
|
+
archivePut(archive: PrivateArchive, paymentOption: PaymentOption): Promise<ArchivePutResult>
|
|
129
128
|
/** Fetch an archive from the network */
|
|
130
|
-
archiveGetPublic(addr:
|
|
129
|
+
archiveGetPublic(addr: ArchiveAddress): Promise<PublicArchive>
|
|
131
130
|
/** Upload an archive to the network */
|
|
132
|
-
archivePutPublic(archive:
|
|
131
|
+
archivePutPublic(archive: PublicArchive, paymentOption: PaymentOption): Promise<ArchivePutPublicResult>
|
|
133
132
|
/** Get the cost to upload an archive */
|
|
134
|
-
archiveCost(archive:
|
|
133
|
+
archiveCost(archive: PublicArchive): Promise<string>
|
|
135
134
|
/** Download a private file from network to local file system */
|
|
136
|
-
fileDownload(dataMap:
|
|
135
|
+
fileDownload(dataMap: DataMapChunk, toDest: string): Promise<void>
|
|
137
136
|
/** Download a private directory from network to local file system */
|
|
138
|
-
dirDownload(archiveAccess:
|
|
137
|
+
dirDownload(archiveAccess: PrivateArchiveDataMap, toDest: string): Promise<void>
|
|
139
138
|
/**
|
|
140
139
|
* Upload the content of all files in a directory to the network.
|
|
141
140
|
* The directory is recursively walked and each file is uploaded to the network.
|
|
@@ -143,22 +142,22 @@ export declare class Client {
|
|
|
143
142
|
* The data maps of these (private) files are not uploaded but returned within
|
|
144
143
|
* the PrivateArchive return type.
|
|
145
144
|
*/
|
|
146
|
-
dirContentUpload(dirPath: string, paymentOption:
|
|
145
|
+
dirContentUpload(dirPath: string, paymentOption: PaymentOption): Promise<DirContentUpload>
|
|
147
146
|
/**
|
|
148
147
|
* Same as Client::dir_content_upload but also uploads the archive (privately) to the network.
|
|
149
148
|
*
|
|
150
149
|
* Returns the PrivateArchiveDataMap allowing the private archive to be downloaded from the network.
|
|
151
150
|
*/
|
|
152
|
-
dirUpload(dirPath: string, paymentOption:
|
|
151
|
+
dirUpload(dirPath: string, paymentOption: PaymentOption): Promise<DirUpload>
|
|
153
152
|
/**
|
|
154
153
|
* Upload the content of a private file to the network. Reads file, splits into
|
|
155
154
|
* chunks, uploads chunks, uploads datamap, returns DataMapChunk (pointing to the datamap)
|
|
156
155
|
*/
|
|
157
|
-
fileContentUpload(path: string, paymentOption:
|
|
156
|
+
fileContentUpload(path: string, paymentOption: PaymentOption): Promise<FileContentUpload>
|
|
158
157
|
/** Download file from network to local file system */
|
|
159
|
-
fileDownloadPublic(dataAddr:
|
|
158
|
+
fileDownloadPublic(dataAddr: DataAddress, toDest: string): Promise<void>
|
|
160
159
|
/** Download directory from network to local file system */
|
|
161
|
-
dirDownloadPublic(archiveAddr:
|
|
160
|
+
dirDownloadPublic(archiveAddr: ArchiveAddress, toDest: string): Promise<void>
|
|
162
161
|
/**
|
|
163
162
|
* Upload the content of all files in a directory to the network. The directory is recursively walked and each file is uploaded to the network.
|
|
164
163
|
*
|
|
@@ -166,39 +165,39 @@ export declare class Client {
|
|
|
166
165
|
*
|
|
167
166
|
* This returns, but does not upload (!),the PublicArchive containing the data maps of the uploaded files.
|
|
168
167
|
*/
|
|
169
|
-
dirContentUploadPublic(dirPath: string, paymentOption:
|
|
168
|
+
dirContentUploadPublic(dirPath: string, paymentOption: PaymentOption): Promise<DirContentUploadPublic>
|
|
170
169
|
/**
|
|
171
170
|
* Same as Client::dir_content_upload_public but also uploads the archive to the network.
|
|
172
171
|
*
|
|
173
172
|
* Returns the ArchiveAddress of the uploaded archive.
|
|
174
173
|
*/
|
|
175
|
-
dirUploadPublic(dirPath: string, paymentOption:
|
|
174
|
+
dirUploadPublic(dirPath: string, paymentOption: PaymentOption): Promise<DirUploadPublic>
|
|
176
175
|
/**
|
|
177
176
|
* Upload the content of a file to the network. Reads file, splits into chunks,
|
|
178
177
|
* uploads chunks, uploads datamap, returns DataAddr (pointing to the datamap)
|
|
179
178
|
*/
|
|
180
|
-
fileContentUploadPublic(path: string, paymentOption:
|
|
179
|
+
fileContentUploadPublic(path: string, paymentOption: PaymentOption): Promise<FileContentUploadPublic>
|
|
181
180
|
/** Get the cost to upload a file/dir to the network. quick and dirty implementation, please refactor once files are cleanly implemented */
|
|
182
181
|
fileCost(path: string): Promise<string>
|
|
183
182
|
/** Get the user data from the vault */
|
|
184
|
-
getUserDataFromVault(secretKey:
|
|
183
|
+
getUserDataFromVault(secretKey: VaultSecretKey): Promise<UserData>
|
|
185
184
|
/**
|
|
186
185
|
* Put the user data to the vault
|
|
187
186
|
*
|
|
188
187
|
* Returns the total cost of the put operation
|
|
189
188
|
*/
|
|
190
|
-
putUserDataToVault(secretKey:
|
|
189
|
+
putUserDataToVault(secretKey: VaultSecretKey, paymentOption: PaymentOption, userData: UserData): Promise<string>
|
|
191
190
|
/**
|
|
192
191
|
* Retrieves and returns a decrypted vault if one exists.
|
|
193
192
|
*
|
|
194
193
|
* Returns the content type of the bytes in the vault.
|
|
195
194
|
*/
|
|
196
|
-
fetchAndDecryptVault(secretKey:
|
|
195
|
+
fetchAndDecryptVault(secretKey: VaultSecretKey): Promise<FetchAndDecryptVault>
|
|
197
196
|
/**
|
|
198
197
|
* Get the cost of creating a new vault A quick estimation of cost:
|
|
199
198
|
* num_of_graph_entry * graph_entry_cost + num_of_scratchpad * scratchpad_cost
|
|
200
199
|
*/
|
|
201
|
-
vaultCost(owner:
|
|
200
|
+
vaultCost(owner: VaultSecretKey, maxSize: bigint): Promise<string>
|
|
202
201
|
/**
|
|
203
202
|
* Put data into the client’s VaultPacket
|
|
204
203
|
*
|
|
@@ -206,7 +205,7 @@ export declare class Client {
|
|
|
206
205
|
*
|
|
207
206
|
* It is recommended to use the hash of the app name or unique identifier as the content type.
|
|
208
207
|
*/
|
|
209
|
-
writeBytesToVault(data: Buffer, paymentOption:
|
|
208
|
+
writeBytesToVault(data: Buffer, paymentOption: PaymentOption, secretKey: VaultSecretKey, contentType: VaultContentType): Promise<string>
|
|
210
209
|
/**
|
|
211
210
|
* Get the register history, starting from the root to the latest entry.
|
|
212
211
|
*
|
|
@@ -215,13 +214,13 @@ export declare class Client {
|
|
|
215
214
|
* RegisterHistory::next can be used to get the values one by one, from the first to the latest entry.
|
|
216
215
|
* RegisterHistory::collect can be used to get all the register values from the history from the first to the latest entry.
|
|
217
216
|
*/
|
|
218
|
-
registerHistory(addr:
|
|
217
|
+
registerHistory(addr: RegisterAddress): RegisterHistory
|
|
219
218
|
/**
|
|
220
219
|
* Create a new register key from a SecretKey and a name.
|
|
221
220
|
*
|
|
222
221
|
* This derives a new SecretKey from the owner’s SecretKey using the name. Note that you will need to keep track of the names you used to create the register key.
|
|
223
222
|
*/
|
|
224
|
-
static registerKeyFromName(owner:
|
|
223
|
+
static registerKeyFromName(owner: SecretKey, name: string): SecretKey
|
|
225
224
|
/** Create a new RegisterValue from bytes, make sure the bytes are not longer than REGISTER_VALUE_SIZE */
|
|
226
225
|
static registerValueFromBytes(bytes: Uint8Array): Uint8Array
|
|
227
226
|
/**
|
|
@@ -229,72 +228,72 @@ export declare class Client {
|
|
|
229
228
|
*
|
|
230
229
|
* Note that two payments are required, one for the underlying GraphEntry and one for the crate::Pointer
|
|
231
230
|
*/
|
|
232
|
-
registerCreate(owner:
|
|
231
|
+
registerCreate(owner: SecretKey, initialValue: Uint8Array, paymentOption: PaymentOption): Promise<RegisterCreate>
|
|
233
232
|
/**
|
|
234
233
|
* Update the value of a register.
|
|
235
|
-
* The register needs to be created first with Client::register_create
|
|
234
|
+
* The register needs to be created first with autonomi::Client::register_create
|
|
236
235
|
*/
|
|
237
|
-
registerUpdate(owner:
|
|
236
|
+
registerUpdate(owner: SecretKey, newValue: Uint8Array, paymentOption: PaymentOption): Promise<string>
|
|
238
237
|
/** Get the current value of the register */
|
|
239
|
-
registerGet(addr:
|
|
238
|
+
registerGet(addr: RegisterAddress): Promise<Uint8Array>
|
|
240
239
|
/** Get the cost of a register operation. Returns the cost of creation if it doesn’t exist, else returns the cost of an update */
|
|
241
|
-
registerCost(owner:
|
|
240
|
+
registerCost(owner: PublicKey): Promise<string>
|
|
242
241
|
}
|
|
243
242
|
export declare class ChunkPut {
|
|
244
243
|
get cost(): string
|
|
245
|
-
get addr():
|
|
244
|
+
get addr(): ChunkAddress
|
|
246
245
|
}
|
|
247
246
|
export declare class GraphEntryPut {
|
|
248
247
|
get cost(): string
|
|
249
|
-
get addr():
|
|
248
|
+
get addr(): GraphEntryAddress
|
|
250
249
|
}
|
|
251
250
|
export declare class ScratchpadPut {
|
|
252
251
|
get cost(): string
|
|
253
|
-
get addr():
|
|
252
|
+
get addr(): ScratchpadAddress
|
|
254
253
|
}
|
|
255
254
|
export declare class PointerPut {
|
|
256
255
|
get cost(): string
|
|
257
|
-
get addr():
|
|
256
|
+
get addr(): PointerAddress
|
|
258
257
|
}
|
|
259
258
|
export declare class DataPutResult {
|
|
260
259
|
get cost(): string
|
|
261
|
-
get dataMap():
|
|
260
|
+
get dataMap(): DataMapChunk
|
|
262
261
|
}
|
|
263
262
|
export declare class DataPutPublicResult {
|
|
264
263
|
get cost(): string
|
|
265
|
-
get addr():
|
|
264
|
+
get addr(): DataAddress
|
|
266
265
|
}
|
|
267
266
|
export declare class ArchivePutResult {
|
|
268
267
|
get cost(): string
|
|
269
|
-
get dataMap():
|
|
268
|
+
get dataMap(): PrivateArchiveDataMap
|
|
270
269
|
}
|
|
271
270
|
export declare class ArchivePutPublicResult {
|
|
272
271
|
get cost(): string
|
|
273
|
-
get addr():
|
|
272
|
+
get addr(): DataAddress
|
|
274
273
|
}
|
|
275
274
|
export declare class DirContentUpload {
|
|
276
275
|
get cost(): string
|
|
277
|
-
get archive():
|
|
276
|
+
get archive(): PrivateArchive
|
|
278
277
|
}
|
|
279
278
|
export declare class DirUpload {
|
|
280
279
|
get cost(): string
|
|
281
|
-
get dataMap():
|
|
280
|
+
get dataMap(): DataMapChunk
|
|
282
281
|
}
|
|
283
282
|
export declare class FileContentUpload {
|
|
284
283
|
get cost(): string
|
|
285
|
-
get dataMap():
|
|
284
|
+
get dataMap(): DataMapChunk
|
|
286
285
|
}
|
|
287
286
|
export declare class DirContentUploadPublic {
|
|
288
287
|
get cost(): string
|
|
289
|
-
get addr():
|
|
288
|
+
get addr(): PublicArchive
|
|
290
289
|
}
|
|
291
290
|
export declare class DirUploadPublic {
|
|
292
291
|
get cost(): string
|
|
293
|
-
get addr():
|
|
292
|
+
get addr(): ArchiveAddress
|
|
294
293
|
}
|
|
295
294
|
export declare class FileContentUploadPublic {
|
|
296
295
|
get cost(): string
|
|
297
|
-
get addr():
|
|
296
|
+
get addr(): PointerAddress
|
|
298
297
|
}
|
|
299
298
|
export declare class FetchAndDecryptVault {
|
|
300
299
|
get data(): Buffer
|
|
@@ -302,13 +301,12 @@ export declare class FetchAndDecryptVault {
|
|
|
302
301
|
}
|
|
303
302
|
export declare class RegisterCreate {
|
|
304
303
|
get cost(): string
|
|
305
|
-
get addr():
|
|
304
|
+
get addr(): RegisterAddress
|
|
306
305
|
}
|
|
307
306
|
export declare class GraphEntryDescendant {
|
|
308
|
-
get publicKey():
|
|
307
|
+
get publicKey(): PublicKey
|
|
309
308
|
get content(): Uint8Array
|
|
310
309
|
}
|
|
311
|
-
export type JsXorName = XorName
|
|
312
310
|
/**
|
|
313
311
|
* A 256-bit number, viewed as a point in XOR space.
|
|
314
312
|
*
|
|
@@ -321,11 +319,10 @@ export type JsXorName = XorName
|
|
|
321
319
|
*/
|
|
322
320
|
export declare class XorName {
|
|
323
321
|
/** Generate a XorName for the given content. */
|
|
324
|
-
static fromContent(content: Uint8Array):
|
|
322
|
+
static fromContent(content: Uint8Array): XorName
|
|
325
323
|
/** Generate a random XorName */
|
|
326
|
-
static random():
|
|
324
|
+
static random(): XorName
|
|
327
325
|
}
|
|
328
|
-
export type JsChunkAddress = ChunkAddress
|
|
329
326
|
/**
|
|
330
327
|
* Address of a chunk.
|
|
331
328
|
*
|
|
@@ -339,9 +336,8 @@ export declare class ChunkAddress {
|
|
|
339
336
|
/** Returns the hex string representation of the address. */
|
|
340
337
|
toHex(): string
|
|
341
338
|
/** Creates a new ChunkAddress from a hex string. */
|
|
342
|
-
static fromHex(hex: string):
|
|
339
|
+
static fromHex(hex: string): ChunkAddress
|
|
343
340
|
}
|
|
344
|
-
export type JsGraphEntryAddress = GraphEntryAddress
|
|
345
341
|
/**
|
|
346
342
|
* Address of a `GraphEntry`.
|
|
347
343
|
*
|
|
@@ -349,7 +345,7 @@ export type JsGraphEntryAddress = GraphEntryAddress
|
|
|
349
345
|
*/
|
|
350
346
|
export declare class GraphEntryAddress {
|
|
351
347
|
/** Creates a new GraphEntryAddress. */
|
|
352
|
-
constructor(owner:
|
|
348
|
+
constructor(owner: PublicKey)
|
|
353
349
|
/**
|
|
354
350
|
* Return the network name of the scratchpad.
|
|
355
351
|
* This is used to locate the scratchpad on the network.
|
|
@@ -358,9 +354,8 @@ export declare class GraphEntryAddress {
|
|
|
358
354
|
/** Serialize this `GraphEntryAddress` into a hex-encoded string. */
|
|
359
355
|
toHex(): string
|
|
360
356
|
/** Parse a hex-encoded string into a `GraphEntryAddress`. */
|
|
361
|
-
static fromHex(hex: string):
|
|
357
|
+
static fromHex(hex: string): GraphEntryAddress
|
|
362
358
|
}
|
|
363
|
-
export type JsDataAddress = DataAddress
|
|
364
359
|
export declare class DataAddress {
|
|
365
360
|
/** Creates a new DataAddress. */
|
|
366
361
|
constructor(xorName: XorName)
|
|
@@ -369,9 +364,8 @@ export declare class DataAddress {
|
|
|
369
364
|
/** Returns the hex string representation of the address. */
|
|
370
365
|
toHex(): string
|
|
371
366
|
/** Creates a new DataAddress from a hex string. */
|
|
372
|
-
static fromHex(hex: string):
|
|
367
|
+
static fromHex(hex: string): DataAddress
|
|
373
368
|
}
|
|
374
|
-
export type JsArchiveAddress = ArchiveAddress
|
|
375
369
|
export declare class ArchiveAddress {
|
|
376
370
|
/** Creates a new ArchiveAddress. */
|
|
377
371
|
constructor(xorName: XorName)
|
|
@@ -380,13 +374,12 @@ export declare class ArchiveAddress {
|
|
|
380
374
|
/** Returns the hex string representation of the address. */
|
|
381
375
|
toHex(): string
|
|
382
376
|
/** Creates a new ArchiveAddress from a hex string. */
|
|
383
|
-
static fromHex(hex: string):
|
|
377
|
+
static fromHex(hex: string): ArchiveAddress
|
|
384
378
|
}
|
|
385
|
-
export type JsWallet = Wallet
|
|
386
379
|
/** A wallet for interacting with the network's payment system */
|
|
387
380
|
export declare class Wallet {
|
|
388
381
|
/** Creates a new Wallet based on the given Ethereum private key. It will fail with Error::PrivateKeyInvalid if private_key is invalid. */
|
|
389
|
-
static newFromPrivateKey(network:
|
|
382
|
+
static newFromPrivateKey(network: Network, privateKey: string): Wallet
|
|
390
383
|
/** Returns a string representation of the wallet's address */
|
|
391
384
|
address(): string
|
|
392
385
|
/** Returns the raw balance of payment tokens in the wallet */
|
|
@@ -394,48 +387,43 @@ export declare class Wallet {
|
|
|
394
387
|
/** Returns the current balance of gas tokens in the wallet */
|
|
395
388
|
balanceOfGas(): Promise<string>
|
|
396
389
|
}
|
|
397
|
-
export type JsPaymentOption = PaymentOption
|
|
398
390
|
/** Options for making payments on the network */
|
|
399
391
|
export declare class PaymentOption {
|
|
400
|
-
static fromWallet(wallet: Wallet):
|
|
401
|
-
static fromReceipt():
|
|
392
|
+
static fromWallet(wallet: Wallet): PaymentOption
|
|
393
|
+
static fromReceipt(): PaymentOption
|
|
402
394
|
}
|
|
403
|
-
export type JsNetwork = Network
|
|
404
395
|
export declare class Network {
|
|
405
396
|
constructor(local: boolean)
|
|
406
397
|
}
|
|
407
|
-
export type JsPublicKey = PublicKey
|
|
408
398
|
export declare class PublicKey {
|
|
409
399
|
/** Returns a byte string representation of the public key. */
|
|
410
400
|
toBytes(): Uint8Array
|
|
411
401
|
/** Returns the key with the given representation, if valid. */
|
|
412
|
-
static fromBytes(bytes: Uint8Array):
|
|
402
|
+
static fromBytes(bytes: Uint8Array): PublicKey
|
|
413
403
|
/** Returns the hex string representation of the public key. */
|
|
414
404
|
toHex(): string
|
|
415
405
|
/** Creates a new PublicKey from a hex string. */
|
|
416
|
-
static fromHex(hex: string):
|
|
406
|
+
static fromHex(hex: string): PublicKey
|
|
417
407
|
}
|
|
418
|
-
export type JsSecretKey = SecretKey
|
|
419
408
|
export declare class SecretKey {
|
|
420
409
|
/** Generate a random SecretKey */
|
|
421
|
-
static random():
|
|
410
|
+
static random(): SecretKey
|
|
422
411
|
/** Returns the public key corresponding to this secret key. */
|
|
423
412
|
publicKey(): PublicKey
|
|
424
413
|
/** Converts the secret key to big endian bytes */
|
|
425
414
|
toBytes(): Uint8Array
|
|
426
415
|
/** Deserialize from big endian bytes */
|
|
427
|
-
static fromBytes(bytes: Uint8Array):
|
|
416
|
+
static fromBytes(bytes: Uint8Array): SecretKey
|
|
428
417
|
/** Returns the hex string representation of the secret key. */
|
|
429
418
|
toHex(): string
|
|
430
419
|
/** Creates a new SecretKey from a hex string. */
|
|
431
|
-
static fromHex(hex: string):
|
|
420
|
+
static fromHex(hex: string): SecretKey
|
|
432
421
|
}
|
|
433
|
-
export type JsGraphEntry = GraphEntry
|
|
434
422
|
export declare class GraphEntry {
|
|
435
423
|
/** Create a new graph entry, signing it with the provided secret key. */
|
|
436
424
|
constructor(owner: SecretKey, parents: Array<PublicKey>, content: Uint8Array, descendants: Array<[PublicKey, Uint8Array]>)
|
|
437
425
|
/** Create a new graph entry with the signature already calculated. */
|
|
438
|
-
static newWithSignature(owner: PublicKey, parents: Array<PublicKey>, content: Uint8Array, descendants: Array<[PublicKey, Uint8Array]>, signature: Uint8Array):
|
|
426
|
+
static newWithSignature(owner: PublicKey, parents: Array<PublicKey>, content: Uint8Array, descendants: Array<[PublicKey, Uint8Array]>, signature: Uint8Array): GraphEntry
|
|
439
427
|
/** Get the address of the graph entry */
|
|
440
428
|
address(): GraphEntryAddress
|
|
441
429
|
/** Get the owner of the graph entry */
|
|
@@ -456,20 +444,19 @@ export declare class GraphEntry {
|
|
|
456
444
|
/** Returns true if the graph entry is too big */
|
|
457
445
|
isTooBig(): boolean
|
|
458
446
|
}
|
|
459
|
-
export type JsPointer = Pointer
|
|
460
447
|
export declare class Pointer {
|
|
461
448
|
/**
|
|
462
449
|
* Create a new pointer, signing it with the provided secret key.
|
|
463
450
|
* This pointer would be stored on the network at the provided key's public key.
|
|
464
451
|
* There can only be one pointer at a time at the same address (one per key).
|
|
465
452
|
*/
|
|
466
|
-
constructor(owner: SecretKey, counter: number, target:
|
|
453
|
+
constructor(owner: SecretKey, counter: number, target: PointerTarget)
|
|
467
454
|
/** Get the address of the pointer */
|
|
468
|
-
address():
|
|
455
|
+
address(): PointerAddress
|
|
469
456
|
/** Get the owner of the pointer */
|
|
470
457
|
owner(): PublicKey
|
|
471
458
|
/** Get the target of the pointer */
|
|
472
|
-
target():
|
|
459
|
+
target(): PointerTarget
|
|
473
460
|
/** Get the bytes that were signed for this pointer */
|
|
474
461
|
bytesForSignature(): Buffer
|
|
475
462
|
/** Get the xorname of the pointer target */
|
|
@@ -484,22 +471,20 @@ export declare class Pointer {
|
|
|
484
471
|
/** Size of the pointer */
|
|
485
472
|
static size(): bigint
|
|
486
473
|
}
|
|
487
|
-
export type JsPointerTarget = PointerTarget
|
|
488
474
|
export declare class PointerTarget {
|
|
489
475
|
/** Returns the xorname of the target */
|
|
490
476
|
xorname(): XorName
|
|
491
477
|
/** Returns the hex string representation of the target */
|
|
492
478
|
toHex(): string
|
|
493
479
|
/** Creates a new PointerTarget from a ChunkAddress */
|
|
494
|
-
static ChunkAddress(addr: ChunkAddress):
|
|
480
|
+
static ChunkAddress(addr: ChunkAddress): PointerTarget
|
|
495
481
|
/** Creates a new PointerTarget from a GraphEntryAddress */
|
|
496
|
-
static GraphEntryAddress(addr: GraphEntryAddress):
|
|
482
|
+
static GraphEntryAddress(addr: GraphEntryAddress): PointerTarget
|
|
497
483
|
/** Creates a new PointerTarget from a PointerAddress */
|
|
498
|
-
static PointerAddress(addr:
|
|
484
|
+
static PointerAddress(addr: PointerAddress): PointerTarget
|
|
499
485
|
/** Creates a new PointerTarget from a ScratchpadAddress */
|
|
500
|
-
static ScratchpadAddress(addr:
|
|
486
|
+
static ScratchpadAddress(addr: ScratchpadAddress): PointerTarget
|
|
501
487
|
}
|
|
502
|
-
export type JsPointerAddress = PointerAddress
|
|
503
488
|
export declare class PointerAddress {
|
|
504
489
|
/** Creates a new PointerAddress. */
|
|
505
490
|
constructor(owner: PublicKey)
|
|
@@ -513,14 +498,13 @@ export declare class PointerAddress {
|
|
|
513
498
|
/** Serialize this PointerAddress into a hex-encoded string. */
|
|
514
499
|
toHex(): string
|
|
515
500
|
/** Parse a hex-encoded string into a PointerAddress. */
|
|
516
|
-
static fromHex(hex: string):
|
|
501
|
+
static fromHex(hex: string): PointerAddress
|
|
517
502
|
}
|
|
518
|
-
export type JsScratchpad = Scratchpad
|
|
519
503
|
export declare class Scratchpad {
|
|
520
504
|
/** Create a new scratchpad, signing it with the provided secret key. */
|
|
521
505
|
constructor(owner: SecretKey, dataEncoding: bigint, data: Buffer, counter: bigint)
|
|
522
506
|
/** Get the address of the scratchpad */
|
|
523
|
-
address():
|
|
507
|
+
address(): ScratchpadAddress
|
|
524
508
|
/** Get the owner of the scratchpad */
|
|
525
509
|
owner(): PublicKey
|
|
526
510
|
/** Get the data encoding (content type) of the scratchpad */
|
|
@@ -532,7 +516,6 @@ export declare class Scratchpad {
|
|
|
532
516
|
/** Verify the signature of the scratchpad */
|
|
533
517
|
verifySignature(): boolean
|
|
534
518
|
}
|
|
535
|
-
export type JsScratchpadAddress = ScratchpadAddress
|
|
536
519
|
export declare class ScratchpadAddress {
|
|
537
520
|
/** Creates a new ScratchpadAddress. */
|
|
538
521
|
constructor(owner: PublicKey)
|
|
@@ -546,23 +529,20 @@ export declare class ScratchpadAddress {
|
|
|
546
529
|
/** Serialize this ScratchpadAddress into a hex-encoded string. */
|
|
547
530
|
toHex(): string
|
|
548
531
|
/** Parse a hex-encoded string into a ScratchpadAddress. */
|
|
549
|
-
static fromHex(hex: string):
|
|
532
|
+
static fromHex(hex: string): ScratchpadAddress
|
|
550
533
|
}
|
|
551
|
-
export type JsDataMapChunk = DataMapChunk
|
|
552
534
|
export declare class DataMapChunk { }
|
|
553
|
-
export type JsPrivateArchiveDataMap = PrivateArchiveDataMap
|
|
554
535
|
export declare class PrivateArchiveDataMap {
|
|
555
536
|
/** Serialize this PrivateArchiveDataMap into a hex-encoded string. */
|
|
556
537
|
toHex(): string
|
|
557
538
|
/** Parse a hex-encoded string into a PrivateArchiveDataMap. */
|
|
558
|
-
static fromHex(hex: string):
|
|
539
|
+
static fromHex(hex: string): PrivateArchiveDataMap
|
|
559
540
|
}
|
|
560
|
-
export type JsPrivateArchive = PrivateArchive
|
|
561
541
|
export declare class PrivateArchive {
|
|
562
542
|
/** Create a new empty local archive */
|
|
563
543
|
constructor()
|
|
564
544
|
/** Add a file to a local archive */
|
|
565
|
-
addFile(path: string, dataMap: DataMapChunk, metadata:
|
|
545
|
+
addFile(path: string, dataMap: DataMapChunk, metadata: Metadata): void
|
|
566
546
|
/** Rename a file in an archive */
|
|
567
547
|
renameFile(oldPath: string, newPath: string): void
|
|
568
548
|
/** List all files in the archive with their metadata */
|
|
@@ -572,25 +552,21 @@ export declare class PrivateArchive {
|
|
|
572
552
|
/** Convert the archive to bytes */
|
|
573
553
|
toBytes(): Buffer
|
|
574
554
|
/** Create an archive from bytes */
|
|
575
|
-
static fromBytes(data: Buffer):
|
|
555
|
+
static fromBytes(data: Buffer): PrivateArchive
|
|
576
556
|
/** Merge with another archive */
|
|
577
557
|
merge(other: PrivateArchive): void
|
|
578
558
|
}
|
|
579
|
-
export type JsVaultSecretKey = VaultSecretKey
|
|
580
559
|
export declare class VaultSecretKey { }
|
|
581
|
-
export type JsUserData = UserData
|
|
582
560
|
export declare class UserData { }
|
|
583
|
-
export type JsVaultContentType = VaultContentType
|
|
584
561
|
export declare class VaultContentType { }
|
|
585
|
-
export type JsMetadata = Metadata
|
|
586
562
|
/** File metadata */
|
|
587
563
|
export declare class Metadata {
|
|
588
564
|
/** Create a new metadata struct with the current time as uploaded, created and modified. */
|
|
589
|
-
static newWithSize(size: bigint):
|
|
565
|
+
static newWithSize(size: bigint): Metadata
|
|
590
566
|
/** Create new metadata with all custom fields */
|
|
591
|
-
static withCustomFields(created: bigint, modified: bigint, size: bigint, extra?: string | undefined | null):
|
|
567
|
+
static withCustomFields(created: bigint, modified: bigint, size: bigint, extra?: string | undefined | null): Metadata
|
|
592
568
|
/** Create a new empty metadata struct with zeros */
|
|
593
|
-
static empty():
|
|
569
|
+
static empty(): Metadata
|
|
594
570
|
/** Get the creation timestamp */
|
|
595
571
|
get created(): bigint
|
|
596
572
|
/** Get the modification timestamp */
|
|
@@ -600,7 +576,6 @@ export declare class Metadata {
|
|
|
600
576
|
/** Get the extra metadata */
|
|
601
577
|
get extra(): string | null
|
|
602
578
|
}
|
|
603
|
-
export type JsRegisterAddress = RegisterAddress
|
|
604
579
|
export declare class RegisterAddress {
|
|
605
580
|
/** Creates a new RegisterAddress. */
|
|
606
581
|
constructor(owner: PublicKey)
|
|
@@ -613,9 +588,8 @@ export declare class RegisterAddress {
|
|
|
613
588
|
/** Serialize this RegisterAddress into a hex-encoded string. */
|
|
614
589
|
toHex(): string
|
|
615
590
|
/** Parse a hex-encoded string into a RegisterAddress. */
|
|
616
|
-
static fromHex(hex: string):
|
|
591
|
+
static fromHex(hex: string): RegisterAddress
|
|
617
592
|
}
|
|
618
|
-
export type JsRegisterHistory = RegisterHistory
|
|
619
593
|
export declare class RegisterHistory {
|
|
620
594
|
constructor()
|
|
621
595
|
/**
|
|
@@ -627,7 +601,6 @@ export declare class RegisterHistory {
|
|
|
627
601
|
/** Get all the register values from the history, starting from the first to the latest entry */
|
|
628
602
|
collect(): Promise<Array<Uint8Array>>
|
|
629
603
|
}
|
|
630
|
-
export type JsPublicArchive = PublicArchive
|
|
631
604
|
export declare class PublicArchive {
|
|
632
605
|
/** Create a new empty local archive */
|
|
633
606
|
constructor()
|
|
@@ -642,7 +615,7 @@ export declare class PublicArchive {
|
|
|
642
615
|
/** Convert the archive to bytes */
|
|
643
616
|
toBytes(): Buffer
|
|
644
617
|
/** Create an archive from bytes */
|
|
645
|
-
static fromBytes(data: Buffer):
|
|
618
|
+
static fromBytes(data: Buffer): PublicArchive
|
|
646
619
|
/** Merge with another archive */
|
|
647
620
|
merge(other: PublicArchive): void
|
|
648
621
|
}
|