@storagehub-sdk/core 0.2.0 → 0.3.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/README.md CHANGED
@@ -45,7 +45,7 @@ The Core SDK provides seamless integration with StorageHub's EVM precompiles, of
45
45
  #### StorageHubClient - Unified EVM Interface
46
46
 
47
47
  ```ts
48
- import { StorageHubClient } from '@storagehub-sdk/core';
48
+ import { StorageHubClient, SH_FILE_SYSTEM_PRECOMPILE_ADDRESS } from '@storagehub-sdk/core';
49
49
  import { createWalletClient, defineChain, http } from 'viem';
50
50
  import { privateKeyToAccount } from 'viem/accounts';
51
51
 
@@ -69,7 +69,8 @@ const walletClient = createWalletClient({
69
69
  const hub = new StorageHubClient({
70
70
  rpcUrl: 'http://localhost:9944',
71
71
  chain: storageHubChain,
72
- walletClient
72
+ walletClient,
73
+ filesystemContractAddress: SH_FILE_SYSTEM_PRECOMPILE_ADDRESS
73
74
  });
74
75
  ```
75
76
 
@@ -107,7 +108,7 @@ const txHash2 = await hub.updateBucketPrivacy('0xBucketId', true, {
107
108
  **Storage Operations:**
108
109
  - `issueStorageRequest(bucketId, location, fingerprint, size, mspId, peerIds, replicationTarget, customReplicationTarget, options?)`
109
110
  - `revokeStorageRequest(fileKey, options?)`
110
- - `requestDeleteFile(signedIntention, signature, bucketId, location, size, fingerprint, options?)`
111
+ - `requestDeleteFile(fileInfo, options?)`
111
112
 
112
113
  **Collections:**
113
114
  - `createAndAssociateCollectionWithBucket(bucketId, options?)`
@@ -8,10 +8,16 @@
8
8
  * Binary data (signatures) are passed as Uint8Array. Hex values are 0x-prefixed strings (32-byte IDs).
9
9
  */
10
10
  import { filesystemAbi } from "../abi/filesystem";
11
+ import type { FileInfo } from "../types";
11
12
  import type { EvmWriteOptions, StorageHubClientOptions } from "./types";
12
- import type { ReplicationLevel } from "./types";
13
+ import { type ReplicationLevel } from "./types";
13
14
  import { type Address } from "viem";
14
15
  export { filesystemAbi };
16
+ /**
17
+ * Default precompile address for FileSystem on StorageHub runtimes.
18
+ * If a chain uses a different address, this constant should be updated accordingly.
19
+ */
20
+ export declare const SH_FILE_SYSTEM_PRECOMPILE_ADDRESS: Address;
15
21
  export declare class StorageHubClient {
16
22
  private readonly publicClient;
17
23
  private readonly walletClient;
@@ -58,13 +64,21 @@ export declare class StorageHubClient {
58
64
  * @returns 0x-prefixed hex string
59
65
  */
60
66
  private validateStringLength;
67
+ /**
68
+ * Assert that a value is present (non-null and non-undefined).
69
+ */
70
+ private assertPresent;
71
+ /**
72
+ * Serialize FileOperationIntention and sign it
73
+ */
74
+ private signIntention;
61
75
  /**
62
76
  * Create a StorageHub client with automatic gas estimation.
63
77
  *
64
78
  * @param opts.rpcUrl - RPC endpoint URL for the StorageHub chain
65
79
  * @param opts.chain - Viem chain configuration
66
80
  * @param opts.walletClient - Wallet client for transaction signing
67
- * @param opts.filesystemContractAddress - Optional filesystem precompile address
81
+ * @param opts.filesystemContractAddress - Filesystem precompile address
68
82
  */
69
83
  constructor(opts: StorageHubClientOptions);
70
84
  /**
@@ -136,14 +150,10 @@ export declare class StorageHubClient {
136
150
  */
137
151
  revokeStorageRequest(fileKey: `0x${string}`, options?: EvmWriteOptions): Promise<`0x${string}` | undefined>;
138
152
  /**
139
- * Request deletion of a file using a signed intention.
140
- * @param signedIntention - tuple [fileKey: 0x32, operation: number] where operation must be 0 (Delete)
141
- * @param signature - 65-byte secp256k1 signature over the SCALE-encoded intention
142
- * @param bucketId - 32-byte bucket ID
143
- * @param location - file path as string (max 512 UTF-8 bytes)
144
- * @param size - file size as bigint (storage units)
145
- * @param fingerprint - 32-byte file fingerprint
146
- * @param options - optional gas and fee overrides
153
+ * Request deletion of a file from the network.
154
+ * @param fileInfo File information containing all required data
155
+ * @param options Optional transaction options
156
+ * @returns Transaction hash
147
157
  */
148
- requestDeleteFile(signedIntention: readonly [`0x${string}`, number], signature: Uint8Array, bucketId: `0x${string}`, location: string, size: bigint, fingerprint: `0x${string}`, options?: EvmWriteOptions): Promise<`0x${string}` | undefined>;
158
+ requestDeleteFile(fileInfo: FileInfo, options?: EvmWriteOptions): Promise<`0x${string}`>;
149
159
  }
@@ -19,9 +19,9 @@ export type StorageHubClientOptions = {
19
19
  */
20
20
  walletClient: WalletClient;
21
21
  /**
22
- * Filesystem precompile contract address (optional, defaults to standard address)
22
+ * Filesystem precompile contract address
23
23
  */
24
- filesystemContractAddress?: Address;
24
+ filesystemContractAddress: Address;
25
25
  };
26
26
  /**
27
27
  * Optional EVM write overrides for SDK calls.
@@ -75,3 +75,10 @@ export declare enum ReplicationLevel {
75
75
  /** Custom replication (requires specifying exact replica count) */
76
76
  Custom = 5
77
77
  }
78
+ /**
79
+ * File operations supported by the StorageHub protocol.
80
+ */
81
+ export declare enum FileOperation {
82
+ /** Delete operation for a file */
83
+ Delete = 0
84
+ }