@storagehub-sdk/core 0.3.5-dev.1 → 0.4.2-dev.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.
@@ -0,0 +1,49 @@
1
+ export declare const filesystemAbi: ({
2
+ anonymous: boolean;
3
+ inputs: {
4
+ indexed: boolean;
5
+ internalType: string;
6
+ name: string;
7
+ type: string;
8
+ }[];
9
+ name: string;
10
+ type: string;
11
+ outputs?: never;
12
+ stateMutability?: never;
13
+ } | {
14
+ inputs: {
15
+ internalType: string;
16
+ name: string;
17
+ type: string;
18
+ }[];
19
+ name: string;
20
+ outputs: {
21
+ internalType: string;
22
+ name: string;
23
+ type: string;
24
+ }[];
25
+ stateMutability: string;
26
+ type: string;
27
+ anonymous?: never;
28
+ } | {
29
+ inputs: ({
30
+ components: {
31
+ internalType: string;
32
+ name: string;
33
+ type: string;
34
+ }[];
35
+ internalType: string;
36
+ name: string;
37
+ type: string;
38
+ } | {
39
+ internalType: string;
40
+ name: string;
41
+ type: string;
42
+ components?: never;
43
+ })[];
44
+ name: string;
45
+ outputs: never[];
46
+ stateMutability: string;
47
+ type: string;
48
+ anonymous?: never;
49
+ })[];
@@ -7,11 +7,11 @@
7
7
  * All arguments are strongly typed. String data (names, paths) are passed as strings and encoded internally.
8
8
  * Binary data (signatures) are passed as Uint8Array. Hex values are 0x-prefixed strings (32-byte IDs).
9
9
  */
10
- import { type Address } from "viem";
11
- import { filesystemAbi } from "../abi/FileSystem.abi";
10
+ import { filesystemAbi } from "../abi/filesystem";
12
11
  import type { FileInfo } from "../types";
13
12
  import type { EvmWriteOptions, StorageHubClientOptions } from "./types";
14
13
  import { type ReplicationLevel } from "./types";
14
+ import { type Address } from "viem";
15
15
  export { filesystemAbi };
16
16
  /**
17
17
  * Default precompile address for FileSystem on StorageHub runtimes.
@@ -27,6 +27,12 @@ export declare class StorageHubClient {
27
27
  private static readonly MAX_PEER_ID_BYTES;
28
28
  private static readonly DEFAULT_GAS_MULTIPLIER;
29
29
  private static readonly DEFAULT_GAS_PRICE;
30
+ /**
31
+ * Get write contract instance bound to the wallet client.
32
+ *
33
+ * @returns Contract instance for write operations (transactions)
34
+ */
35
+ private getWriteContract;
30
36
  /**
31
37
  * Get read contract instance bound to the public client.
32
38
  *
@@ -48,6 +54,10 @@ export declare class StorageHubClient {
48
54
  /**
49
55
  * Build transaction options with gas and fee settings.
50
56
  * Handles both legacy and EIP-1559 fee structures.
57
+ *
58
+ * Note: `chain: null` is set to ensure compatibility with wallet clients that don't
59
+ * properly expose chain information (e.g., Reown's Social Login). This tells viem
60
+ * to use the wallet's currently selected chain rather than trying to fetch chainId.
51
61
  */
52
62
  private buildTxOptions;
53
63
  /**
@@ -58,6 +68,10 @@ export declare class StorageHubClient {
58
68
  * @returns 0x-prefixed hex string
59
69
  */
60
70
  private validateStringLength;
71
+ /**
72
+ * Assert that a value is present (non-null and non-undefined).
73
+ */
74
+ private assertPresent;
61
75
  /**
62
76
  * Serialize FileOperationIntention and sign it
63
77
  */
@@ -77,13 +91,13 @@ export declare class StorageHubClient {
77
91
  * @param name - bucket name as string (max 100 UTF-8 bytes)
78
92
  * @returns bucketId as 0x-prefixed 32-byte hex
79
93
  */
80
- deriveBucketId(owner: Address, name: string): Promise<`0x${string}`>;
94
+ deriveBucketId(owner: Address, name: string): Promise<unknown> | undefined;
81
95
  /**
82
96
  * Get how many file deletion requests a user currently has pending.
83
97
  * @param user - user EVM address
84
98
  * @returns count as number
85
99
  */
86
- getPendingFileDeletionRequestsCount(user: Address): Promise<number>;
100
+ getPendingFileDeletionRequestsCount(user: Address): Promise<unknown> | undefined;
87
101
  /**
88
102
  * Create a new bucket.
89
103
  * @param mspId - 32-byte MSP ID (0x-prefixed hex)
@@ -92,7 +106,7 @@ export declare class StorageHubClient {
92
106
  * @param valuePropId - 32-byte value proposition ID (0x-prefixed hex)
93
107
  * @param options - optional gas and fee overrides
94
108
  */
95
- createBucket(mspId: `0x${string}`, name: string, isPrivate: boolean, valuePropId: `0x${string}`, options?: EvmWriteOptions): Promise<`0x${string}`>;
109
+ createBucket(mspId: `0x${string}`, name: string, isPrivate: boolean, valuePropId: `0x${string}`, options?: EvmWriteOptions): Promise<`0x${string}` | undefined>;
96
110
  /**
97
111
  * Request moving a bucket to a new MSP/value proposition.
98
112
  * @param bucketId - 32-byte bucket ID
@@ -100,26 +114,26 @@ export declare class StorageHubClient {
100
114
  * @param newValuePropId - 32-byte new value proposition ID
101
115
  * @param options - optional gas and fee overrides
102
116
  */
103
- requestMoveBucket(bucketId: `0x${string}`, newMspId: `0x${string}`, newValuePropId: `0x${string}`, options?: EvmWriteOptions): Promise<`0x${string}`>;
117
+ requestMoveBucket(bucketId: `0x${string}`, newMspId: `0x${string}`, newValuePropId: `0x${string}`, options?: EvmWriteOptions): Promise<`0x${string}` | undefined>;
104
118
  /**
105
119
  * Update bucket privacy flag.
106
120
  * @param bucketId - 32-byte bucket ID
107
121
  * @param isPrivate - true for private
108
122
  * @param options - optional gas and fee overrides
109
123
  */
110
- updateBucketPrivacy(bucketId: `0x${string}`, isPrivate: boolean, options?: EvmWriteOptions): Promise<`0x${string}`>;
124
+ updateBucketPrivacy(bucketId: `0x${string}`, isPrivate: boolean, options?: EvmWriteOptions): Promise<`0x${string}` | undefined>;
111
125
  /**
112
126
  * Create and associate a collection with a bucket.
113
127
  * @param bucketId - 32-byte bucket ID
114
128
  * @param options - optional gas and fee overrides
115
129
  */
116
- createAndAssociateCollectionWithBucket(bucketId: `0x${string}`, options?: EvmWriteOptions): Promise<`0x${string}`>;
130
+ createAndAssociateCollectionWithBucket(bucketId: `0x${string}`, options?: EvmWriteOptions): Promise<`0x${string}` | undefined>;
117
131
  /**
118
132
  * Delete an empty bucket.
119
133
  * @param bucketId - 32-byte bucket ID
120
134
  * @param options - optional gas and fee overrides
121
135
  */
122
- deleteBucket(bucketId: `0x${string}`, options?: EvmWriteOptions): Promise<`0x${string}`>;
136
+ deleteBucket(bucketId: `0x${string}`, options?: EvmWriteOptions): Promise<`0x${string}` | undefined>;
123
137
  /**
124
138
  * Issue a storage request for a file.
125
139
  * @param bucketId - 32-byte bucket ID
@@ -132,13 +146,13 @@ export declare class StorageHubClient {
132
146
  * @param replicas - number of replicas (only required for ReplicationLevel.Custom)
133
147
  * @param options - optional gas and fee overrides
134
148
  */
135
- issueStorageRequest(bucketId: `0x${string}`, location: string, fingerprint: `0x${string}`, size: bigint, mspId: `0x${string}`, peerIds: string[], replicationLevel: ReplicationLevel, replicas: number, options?: EvmWriteOptions): Promise<`0x${string}`>;
149
+ issueStorageRequest(bucketId: `0x${string}`, location: string, fingerprint: `0x${string}`, size: bigint, mspId: `0x${string}`, peerIds: string[], replicationLevel: ReplicationLevel, replicas: number, options?: EvmWriteOptions): Promise<`0x${string}` | undefined>;
136
150
  /**
137
151
  * Revoke a pending storage request by file key.
138
152
  * @param fileKey - 32-byte file key
139
153
  * @param options - optional gas and fee overrides
140
154
  */
141
- revokeStorageRequest(fileKey: `0x${string}`, options?: EvmWriteOptions): Promise<`0x${string}`>;
155
+ revokeStorageRequest(fileKey: `0x${string}`, options?: EvmWriteOptions): Promise<`0x${string}` | undefined>;
142
156
  /**
143
157
  * Request deletion of a file from the network.
144
158
  * @param fileInfo File information containing all required data