@storagehub-sdk/core 0.0.5 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +132 -0
- package/dist/_wasm_embed.d.ts +1 -1
- package/dist/abi/FileSystem.abi.json +427 -0
- package/dist/abi/filesystem.d.ts +49 -0
- package/dist/evm/clients.d.ts +49 -0
- package/dist/evm/storageHubClient.d.ts +149 -0
- package/dist/evm/types.d.ts +77 -0
- package/dist/file-manager.d.ts +9 -2
- package/dist/http/HttpClient.d.ts +1 -1
- package/dist/index.browser.js +1 -1
- package/dist/index.browser.js.map +4 -4
- package/dist/index.d.ts +13 -7
- package/dist/index.node.js +1 -1
- package/dist/index.node.js.map +4 -4
- package/dist/wallet/base.d.ts +1 -1
- package/dist/wallet/eip1193.d.ts +2 -2
- package/dist/wallet/errors.d.ts +1 -1
- package/dist/wallet/local.d.ts +2 -2
- package/dist/wasm.d.ts +1 -1
- package/package.json +22 -18
- package/wasm/pkg/storagehub_wasm.d.ts +10 -4
- package/wasm/pkg/storagehub_wasm.js +16 -5
- package/wasm/pkg/storagehub_wasm_bg.wasm +0 -0
- package/wasm/pkg/storagehub_wasm_bg.wasm.d.ts +5 -4
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for StorageHub EVM client
|
|
3
|
+
*/
|
|
4
|
+
import type { Address, Chain, WalletClient } from "viem";
|
|
5
|
+
/**
|
|
6
|
+
* Configuration options for StorageHubClient
|
|
7
|
+
*/
|
|
8
|
+
export type StorageHubClientOptions = {
|
|
9
|
+
/**
|
|
10
|
+
* RPC endpoint URL for the StorageHub chain
|
|
11
|
+
*/
|
|
12
|
+
rpcUrl: string;
|
|
13
|
+
/**
|
|
14
|
+
* Viem chain configuration
|
|
15
|
+
*/
|
|
16
|
+
chain: Chain;
|
|
17
|
+
/**
|
|
18
|
+
* Wallet client for transaction signing
|
|
19
|
+
*/
|
|
20
|
+
walletClient: WalletClient;
|
|
21
|
+
/**
|
|
22
|
+
* Filesystem precompile contract address (optional, defaults to standard address)
|
|
23
|
+
*/
|
|
24
|
+
filesystemContractAddress?: Address;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Optional EVM write overrides for SDK calls.
|
|
28
|
+
*
|
|
29
|
+
* Use these when you need to customize the transaction envelope or
|
|
30
|
+
* sidestep under-estimation issues on Frontier/weight based pallets.
|
|
31
|
+
*
|
|
32
|
+
* - If `gas` is not provided, the SDK will estimate gas for the function
|
|
33
|
+
* and apply `gasMultiplier` (default 5) for headroom.
|
|
34
|
+
* - You can provide legacy `gasPrice`, or EIP-1559 fees via
|
|
35
|
+
* `maxFeePerGas` and `maxPriorityFeePerGas`.
|
|
36
|
+
*/
|
|
37
|
+
export type EvmWriteOptions = {
|
|
38
|
+
/**
|
|
39
|
+
* Explicit gas limit. If omitted, the SDK will estimate and multiply.
|
|
40
|
+
*/
|
|
41
|
+
gas?: bigint;
|
|
42
|
+
/**
|
|
43
|
+
* Multiplier applied over the SDK gas estimate when `gas` is not supplied.
|
|
44
|
+
* Defaults to 5.
|
|
45
|
+
*/
|
|
46
|
+
gasMultiplier?: number;
|
|
47
|
+
/**
|
|
48
|
+
* Legacy gas price (wei). If set, EIP-1559 fields are ignored by most clients.
|
|
49
|
+
*/
|
|
50
|
+
gasPrice?: bigint;
|
|
51
|
+
/**
|
|
52
|
+
* EIP-1559: max fee per gas (wei). Use with `maxPriorityFeePerGas`.
|
|
53
|
+
*/
|
|
54
|
+
maxFeePerGas?: bigint;
|
|
55
|
+
/**
|
|
56
|
+
* EIP-1559: max priority fee per gas (wei).
|
|
57
|
+
*/
|
|
58
|
+
maxPriorityFeePerGas?: bigint;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Replication levels for storage requests.
|
|
62
|
+
* Each level provides different redundancy and availability guarantees.
|
|
63
|
+
*/
|
|
64
|
+
export declare enum ReplicationLevel {
|
|
65
|
+
/** Basic replication (default) */
|
|
66
|
+
Basic = 0,
|
|
67
|
+
/** Standard replication */
|
|
68
|
+
Standard = 1,
|
|
69
|
+
/** High security replication */
|
|
70
|
+
HighSecurity = 2,
|
|
71
|
+
/** Super high security replication */
|
|
72
|
+
SuperHighSecurity = 3,
|
|
73
|
+
/** Ultra high security replication */
|
|
74
|
+
UltraHighSecurity = 4,
|
|
75
|
+
/** Custom replication (requires specifying exact replica count) */
|
|
76
|
+
Custom = 5
|
|
77
|
+
}
|
package/dist/file-manager.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AccountId20, H256 } from "@polkadot/types/interfaces";
|
|
2
2
|
export declare class FileManager {
|
|
3
3
|
private readonly file;
|
|
4
4
|
constructor(file: {
|
|
@@ -7,11 +7,13 @@ export declare class FileManager {
|
|
|
7
7
|
});
|
|
8
8
|
private fingerprint?;
|
|
9
9
|
private fileKey?;
|
|
10
|
+
private fileBlob?;
|
|
10
11
|
/**
|
|
11
12
|
* Stream the file's contents, feed every 1 kB chunk into a new FileTrie, and
|
|
12
13
|
* return the resulting Merkle root.
|
|
13
14
|
*/
|
|
14
15
|
getFingerprint(): Promise<H256>;
|
|
16
|
+
getFileSize(): number;
|
|
15
17
|
/**
|
|
16
18
|
* Compute the FileKey for this file.
|
|
17
19
|
*
|
|
@@ -20,5 +22,10 @@ export declare class FileManager {
|
|
|
20
22
|
* • bucketId – 32-byte BucketId (Uint8Array or 0x-prefixed hex string)
|
|
21
23
|
* • location – path string (encoded to bytes as-is)
|
|
22
24
|
*/
|
|
23
|
-
computeFileKey(owner:
|
|
25
|
+
computeFileKey(owner: AccountId20, bucketId: H256, location: string): Promise<H256>;
|
|
26
|
+
/**
|
|
27
|
+
* Retrieve the file as a Blob. If not already available, this will
|
|
28
|
+
* compute it by streaming the file (also computing and caching the fingerprint).
|
|
29
|
+
*/
|
|
30
|
+
getFileBlob(): Promise<Blob>;
|
|
24
31
|
}
|
|
@@ -26,7 +26,7 @@ export declare class HttpClient {
|
|
|
26
26
|
private readonly defaultHeaders;
|
|
27
27
|
private readonly fetchImpl;
|
|
28
28
|
constructor(options: HttpClientConfig);
|
|
29
|
-
request<T>(method:
|
|
29
|
+
request<T>(method: "GET" | "POST" | "PUT" | "DELETE", path: string, options?: RequestOptions): Promise<T | Response>;
|
|
30
30
|
get<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
31
31
|
post<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
32
32
|
put<T>(path: string, options?: RequestOptions): Promise<T>;
|