@cmdoss/memwal-sdk 0.6.0 → 0.6.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.
Files changed (224) hide show
  1. package/ARCHITECTURE.md +86 -2
  2. package/BENCHMARKS.md +2 -2
  3. package/README.md +43 -4
  4. package/dist/ai-sdk/types.d.ts +2 -2
  5. package/dist/ai-sdk/types.d.ts.map +1 -1
  6. package/dist/browser.d.ts +9 -9
  7. package/dist/browser.d.ts.map +1 -1
  8. package/dist/browser.js +16 -11
  9. package/dist/browser.js.map +1 -1
  10. package/dist/client/PersonalDataWallet.d.ts.map +1 -1
  11. package/dist/client/SimplePDWClient.d.ts.map +1 -1
  12. package/dist/client/SimplePDWClient.js +4 -4
  13. package/dist/client/SimplePDWClient.js.map +1 -1
  14. package/dist/client/namespaces/BatchNamespace.js +2 -2
  15. package/dist/client/namespaces/BatchNamespace.js.map +1 -1
  16. package/dist/client/namespaces/MemoryNamespace.js +3 -3
  17. package/dist/client/namespaces/MemoryNamespace.js.map +1 -1
  18. package/dist/client/namespaces/StorageNamespace.js +4 -4
  19. package/dist/client/namespaces/StorageNamespace.js.map +1 -1
  20. package/dist/client/namespaces/consolidated/StorageNamespace.js +2 -2
  21. package/dist/client/namespaces/consolidated/StorageNamespace.js.map +1 -1
  22. package/dist/client/signers/DappKitSigner.d.ts +136 -0
  23. package/dist/client/signers/DappKitSigner.d.ts.map +1 -0
  24. package/dist/client/signers/DappKitSigner.js +128 -0
  25. package/dist/client/signers/DappKitSigner.js.map +1 -0
  26. package/dist/client/signers/KeypairSigner.d.ts +4 -0
  27. package/dist/client/signers/KeypairSigner.d.ts.map +1 -1
  28. package/dist/client/signers/KeypairSigner.js +6 -0
  29. package/dist/client/signers/KeypairSigner.js.map +1 -1
  30. package/dist/client/signers/UnifiedSigner.d.ts +10 -0
  31. package/dist/client/signers/UnifiedSigner.d.ts.map +1 -1
  32. package/dist/client/signers/WalletAdapterSigner.d.ts +7 -0
  33. package/dist/client/signers/WalletAdapterSigner.d.ts.map +1 -1
  34. package/dist/client/signers/WalletAdapterSigner.js +9 -0
  35. package/dist/client/signers/WalletAdapterSigner.js.map +1 -1
  36. package/dist/client/signers/index.d.ts +3 -0
  37. package/dist/client/signers/index.d.ts.map +1 -1
  38. package/dist/client/signers/index.js +2 -0
  39. package/dist/client/signers/index.js.map +1 -1
  40. package/dist/generated/utils/index.js +1 -1
  41. package/dist/generated/utils/index.js.map +1 -1
  42. package/dist/index.d.ts +2 -0
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +2 -0
  45. package/dist/index.js.map +1 -1
  46. package/dist/services/CapabilityService.js +1 -1
  47. package/dist/services/CapabilityService.js.map +1 -1
  48. package/dist/services/EncryptionService.js +1 -1
  49. package/dist/services/EncryptionService.js.map +1 -1
  50. package/dist/services/StorageService.d.ts +8 -8
  51. package/dist/services/StorageService.d.ts.map +1 -1
  52. package/dist/services/StorageService.js.map +1 -1
  53. package/dist/services/VectorService.js +2 -2
  54. package/dist/services/VectorService.js.map +1 -1
  55. package/dist/services/storage/BlobAttributesManager.d.ts +4 -4
  56. package/dist/services/storage/BlobAttributesManager.d.ts.map +1 -1
  57. package/dist/services/storage/BlobAttributesManager.js +6 -15
  58. package/dist/services/storage/BlobAttributesManager.js.map +1 -1
  59. package/dist/services/storage/QuiltBatchManager.d.ts +23 -5
  60. package/dist/services/storage/QuiltBatchManager.d.ts.map +1 -1
  61. package/dist/services/storage/QuiltBatchManager.js +118 -35
  62. package/dist/services/storage/QuiltBatchManager.js.map +1 -1
  63. package/dist/services/storage/WalrusMetadataManager.d.ts +2 -2
  64. package/dist/services/storage/WalrusMetadataManager.d.ts.map +1 -1
  65. package/dist/services/storage/WalrusMetadataManager.js +2 -5
  66. package/dist/services/storage/WalrusMetadataManager.js.map +1 -1
  67. package/dist/services/storage/WalrusStorageManager.d.ts +2 -2
  68. package/dist/services/storage/WalrusStorageManager.d.ts.map +1 -1
  69. package/dist/services/storage/WalrusStorageManager.js +7 -11
  70. package/dist/services/storage/WalrusStorageManager.js.map +1 -1
  71. package/dist/wallet/MainWalletService.js +1 -1
  72. package/dist/wallet/MainWalletService.js.map +1 -1
  73. package/package.json +10 -3
  74. package/src/ai-sdk/types.ts +2 -2
  75. package/src/browser.ts +19 -20
  76. package/src/client/SimplePDWClient.ts +18 -14
  77. package/src/client/namespaces/BatchNamespace.ts +2 -2
  78. package/src/client/namespaces/MemoryNamespace.ts +3 -3
  79. package/src/client/namespaces/StorageNamespace.ts +4 -4
  80. package/src/client/namespaces/consolidated/StorageNamespace.ts +2 -2
  81. package/src/client/signers/DappKitSigner.ts +207 -0
  82. package/src/client/signers/KeypairSigner.ts +7 -0
  83. package/src/client/signers/UnifiedSigner.ts +11 -0
  84. package/src/client/signers/WalletAdapterSigner.ts +10 -0
  85. package/src/client/signers/index.ts +7 -0
  86. package/src/generated/pdw/deps/sui/object.ts +12 -12
  87. package/src/generated/pdw/deps/sui/vec_map.ts +32 -32
  88. package/src/generated/pdw/memory.ts +1087 -1087
  89. package/src/generated/pdw/wallet.ts +123 -123
  90. package/src/generated/utils/index.ts +159 -159
  91. package/src/index.ts +16 -0
  92. package/src/services/CapabilityService.ts +1 -1
  93. package/src/services/EncryptionService.ts +1 -1
  94. package/src/services/StorageService.ts +8 -8
  95. package/src/services/VectorService.ts +2 -2
  96. package/src/services/storage/BlobAttributesManager.ts +10 -19
  97. package/src/services/storage/QuiltBatchManager.ts +139 -37
  98. package/src/services/storage/WalrusMetadataManager.ts +4 -7
  99. package/src/services/storage/WalrusStorageManager.ts +10 -13
  100. package/src/wallet/MainWalletService.ts +1 -1
  101. package/dist/api/client.d.ts +0 -43
  102. package/dist/api/client.d.ts.map +0 -1
  103. package/dist/api/client.js +0 -136
  104. package/dist/api/client.js.map +0 -1
  105. package/dist/chat/index.d.ts +0 -13
  106. package/dist/chat/index.d.ts.map +0 -1
  107. package/dist/chat/index.js +0 -14
  108. package/dist/chat/index.js.map +0 -1
  109. package/dist/client/namespaces/ChatNamespace.d.ts +0 -110
  110. package/dist/client/namespaces/ChatNamespace.d.ts.map +0 -1
  111. package/dist/client/namespaces/ChatNamespace.js +0 -123
  112. package/dist/client/namespaces/ChatNamespace.js.map +0 -1
  113. package/dist/encryption/index.d.ts +0 -14
  114. package/dist/encryption/index.d.ts.map +0 -1
  115. package/dist/encryption/index.js +0 -14
  116. package/dist/encryption/index.js.map +0 -1
  117. package/dist/graph/BrowserKnowledgeGraphManager.d.ts +0 -101
  118. package/dist/graph/BrowserKnowledgeGraphManager.d.ts.map +0 -1
  119. package/dist/graph/BrowserKnowledgeGraphManager.js +0 -411
  120. package/dist/graph/BrowserKnowledgeGraphManager.js.map +0 -1
  121. package/dist/hooks.wip/index.d.ts +0 -55
  122. package/dist/hooks.wip/index.d.ts.map +0 -1
  123. package/dist/hooks.wip/index.js +0 -58
  124. package/dist/hooks.wip/index.js.map +0 -1
  125. package/dist/hooks.wip/useCreateMemory.d.ts +0 -111
  126. package/dist/hooks.wip/useCreateMemory.d.ts.map +0 -1
  127. package/dist/hooks.wip/useCreateMemory.js +0 -149
  128. package/dist/hooks.wip/useCreateMemory.js.map +0 -1
  129. package/dist/hooks.wip/useCreateMemoryBatch.d.ts +0 -122
  130. package/dist/hooks.wip/useCreateMemoryBatch.d.ts.map +0 -1
  131. package/dist/hooks.wip/useCreateMemoryBatch.js +0 -221
  132. package/dist/hooks.wip/useCreateMemoryBatch.js.map +0 -1
  133. package/dist/hooks.wip/useKnowledgeGraph.d.ts +0 -66
  134. package/dist/hooks.wip/useKnowledgeGraph.d.ts.map +0 -1
  135. package/dist/hooks.wip/useKnowledgeGraph.js +0 -229
  136. package/dist/hooks.wip/useKnowledgeGraph.js.map +0 -1
  137. package/dist/hooks.wip/useMemoryChat.d.ts +0 -106
  138. package/dist/hooks.wip/useMemoryChat.d.ts.map +0 -1
  139. package/dist/hooks.wip/useMemoryChat.js +0 -284
  140. package/dist/hooks.wip/useMemoryChat.js.map +0 -1
  141. package/dist/hooks.wip/useMemoryIndex.d.ts +0 -90
  142. package/dist/hooks.wip/useMemoryIndex.d.ts.map +0 -1
  143. package/dist/hooks.wip/useMemoryIndex.js +0 -218
  144. package/dist/hooks.wip/useMemoryIndex.js.map +0 -1
  145. package/dist/hooks.wip/useMemoryManager.d.ts +0 -35
  146. package/dist/hooks.wip/useMemoryManager.d.ts.map +0 -1
  147. package/dist/hooks.wip/useMemoryManager.js +0 -86
  148. package/dist/hooks.wip/useMemoryManager.js.map +0 -1
  149. package/dist/hooks.wip/useMemorySearch.d.ts +0 -100
  150. package/dist/hooks.wip/useMemorySearch.d.ts.map +0 -1
  151. package/dist/hooks.wip/useMemorySearch.js +0 -278
  152. package/dist/hooks.wip/useMemorySearch.js.map +0 -1
  153. package/dist/hooks.wip/useMemoryServices.d.ts +0 -80
  154. package/dist/hooks.wip/useMemoryServices.d.ts.map +0 -1
  155. package/dist/hooks.wip/useMemoryServices.js +0 -264
  156. package/dist/hooks.wip/useMemoryServices.js.map +0 -1
  157. package/dist/hooks.wip/usePDWRAG.d.ts +0 -112
  158. package/dist/hooks.wip/usePDWRAG.d.ts.map +0 -1
  159. package/dist/hooks.wip/usePDWRAG.js +0 -121
  160. package/dist/hooks.wip/usePDWRAG.js.map +0 -1
  161. package/dist/hooks.wip/usePDWVectorStore.d.ts +0 -68
  162. package/dist/hooks.wip/usePDWVectorStore.d.ts.map +0 -1
  163. package/dist/hooks.wip/usePDWVectorStore.js +0 -102
  164. package/dist/hooks.wip/usePDWVectorStore.js.map +0 -1
  165. package/dist/hooks.wip/useRetrieveEmbedding.d.ts +0 -138
  166. package/dist/hooks.wip/useRetrieveEmbedding.d.ts.map +0 -1
  167. package/dist/hooks.wip/useRetrieveEmbedding.js +0 -121
  168. package/dist/hooks.wip/useRetrieveEmbedding.js.map +0 -1
  169. package/dist/hooks.wip/useSearchMemories.d.ts +0 -103
  170. package/dist/hooks.wip/useSearchMemories.d.ts.map +0 -1
  171. package/dist/hooks.wip/useSearchMemories.js +0 -146
  172. package/dist/hooks.wip/useSearchMemories.js.map +0 -1
  173. package/dist/hooks.wip/useStoreEmbedding.d.ts +0 -174
  174. package/dist/hooks.wip/useStoreEmbedding.d.ts.map +0 -1
  175. package/dist/hooks.wip/useStoreEmbedding.js +0 -167
  176. package/dist/hooks.wip/useStoreEmbedding.js.map +0 -1
  177. package/dist/hooks.wip/useWalletMemories.d.ts +0 -119
  178. package/dist/hooks.wip/useWalletMemories.d.ts.map +0 -1
  179. package/dist/hooks.wip/useWalletMemories.js +0 -166
  180. package/dist/hooks.wip/useWalletMemories.js.map +0 -1
  181. package/dist/hooks.wip/utils/cache.d.ts +0 -25
  182. package/dist/hooks.wip/utils/cache.d.ts.map +0 -1
  183. package/dist/hooks.wip/utils/cache.js +0 -38
  184. package/dist/hooks.wip/utils/cache.js.map +0 -1
  185. package/dist/hooks.wip/utils/types.d.ts +0 -138
  186. package/dist/hooks.wip/utils/types.d.ts.map +0 -1
  187. package/dist/hooks.wip/utils/types.js +0 -5
  188. package/dist/hooks.wip/utils/types.js.map +0 -1
  189. package/dist/infrastructure/ai/EmbeddingService.d.ts +0 -101
  190. package/dist/infrastructure/ai/EmbeddingService.d.ts.map +0 -1
  191. package/dist/infrastructure/ai/EmbeddingService.js +0 -242
  192. package/dist/infrastructure/ai/EmbeddingService.js.map +0 -1
  193. package/dist/infrastructure/ai/GeminiAIService.d.ts +0 -84
  194. package/dist/infrastructure/ai/GeminiAIService.d.ts.map +0 -1
  195. package/dist/infrastructure/ai/GeminiAIService.js +0 -300
  196. package/dist/infrastructure/ai/GeminiAIService.js.map +0 -1
  197. package/dist/infrastructure/ai/index.d.ts +0 -8
  198. package/dist/infrastructure/ai/index.d.ts.map +0 -1
  199. package/dist/infrastructure/ai/index.js +0 -8
  200. package/dist/infrastructure/ai/index.js.map +0 -1
  201. package/dist/memory/index.d.ts +0 -13
  202. package/dist/memory/index.d.ts.map +0 -1
  203. package/dist/memory/index.js +0 -14
  204. package/dist/memory/index.js.map +0 -1
  205. package/dist/services/ChatService.d.ts +0 -89
  206. package/dist/services/ChatService.d.ts.map +0 -1
  207. package/dist/services/ChatService.js +0 -319
  208. package/dist/services/ChatService.js.map +0 -1
  209. package/dist/transactions/index.d.ts +0 -13
  210. package/dist/transactions/index.d.ts.map +0 -1
  211. package/dist/transactions/index.js +0 -14
  212. package/dist/transactions/index.js.map +0 -1
  213. package/dist/types/wallet.d.ts +0 -12
  214. package/dist/types/wallet.d.ts.map +0 -1
  215. package/dist/types/wallet.js +0 -13
  216. package/dist/types/wallet.js.map +0 -1
  217. package/dist/view/ViewService.d.ts +0 -136
  218. package/dist/view/ViewService.d.ts.map +0 -1
  219. package/dist/view/ViewService.js +0 -325
  220. package/dist/view/ViewService.js.map +0 -1
  221. package/dist/view/index.d.ts +0 -7
  222. package/dist/view/index.d.ts.map +0 -1
  223. package/dist/view/index.js +0 -7
  224. package/dist/view/index.js.map +0 -1
@@ -15,7 +15,7 @@
15
15
  import { SuiClient, getFullnodeUrl } from '@mysten/sui/client';
16
16
  import { Transaction } from '@mysten/sui/transactions';
17
17
  import { WalrusClient, WalrusFile } from '@mysten/walrus';
18
- import type { Signer } from '@mysten/sui/cryptography';
18
+ import type { UnifiedSigner } from '../client/signers/UnifiedSigner';
19
19
  import type { ClientWithExtensions } from '@mysten/sui/experimental';
20
20
  import type { SealService } from '../infrastructure/seal/SealService';
21
21
  import type { BatchService } from './BatchService';
@@ -71,7 +71,7 @@ export interface WalrusUploadResult {
71
71
  }
72
72
 
73
73
  export interface BlobUploadOptions {
74
- signer: Signer;
74
+ signer: UnifiedSigner;
75
75
  epochs?: number;
76
76
  deletable?: boolean;
77
77
  useUploadRelay?: boolean;
@@ -817,7 +817,7 @@ export class StorageService {
817
817
  summary?: string;
818
818
  }>,
819
819
  options: {
820
- signer: Signer;
820
+ signer: UnifiedSigner;
821
821
  epochs?: number;
822
822
  userAddress: string;
823
823
  }
@@ -856,7 +856,7 @@ export class StorageService {
856
856
  tags?: Record<string, string>;
857
857
  }>,
858
858
  options: {
859
- signer: Signer;
859
+ signer: UnifiedSigner;
860
860
  epochs?: number;
861
861
  userAddress: string;
862
862
  }
@@ -924,7 +924,7 @@ export class StorageService {
924
924
  async setBlobAttributes(
925
925
  blobObjectId: string,
926
926
  attributes: Record<string, string>,
927
- signer: Signer
927
+ signer: UnifiedSigner
928
928
  ): Promise<string> {
929
929
  return this.blobAttributes.setBlobAttributes(blobObjectId, attributes, signer);
930
930
  }
@@ -945,7 +945,7 @@ export class StorageService {
945
945
  async updateBlobAttributes(
946
946
  blobObjectId: string,
947
947
  attributes: Record<string, string>,
948
- signer: Signer
948
+ signer: UnifiedSigner
949
949
  ): Promise<string> {
950
950
  return this.blobAttributes.updateBlobAttributes(blobObjectId, attributes, signer);
951
951
  }
@@ -956,7 +956,7 @@ export class StorageService {
956
956
  async removeBlobAttributes(
957
957
  blobObjectId: string,
958
958
  attributeKeys: string[],
959
- signer: Signer
959
+ signer: UnifiedSigner
960
960
  ): Promise<string> {
961
961
  return this.blobAttributes.removeBlobAttributes(blobObjectId, attributeKeys, signer);
962
962
  }
@@ -1009,7 +1009,7 @@ export class StorageService {
1009
1009
  async attachMetadataToBlob(
1010
1010
  blobId: string,
1011
1011
  metadata: WalrusMemoryMetadata,
1012
- signer: Signer
1012
+ signer: UnifiedSigner
1013
1013
  ): Promise<{ digest: string; effects: any }> {
1014
1014
  const walrusPackageId = this.config.network === 'mainnet'
1015
1015
  ? '0x<mainnet-walrus-package-id>'
@@ -238,14 +238,14 @@ export class VectorService {
238
238
 
239
239
  const searchTime = performance.now() - startTime;
240
240
 
241
- // Get metadata from local cache
241
+ // Get metadata - prefer HNSW service metadata (loaded from disk) over local cache
242
242
  return {
243
243
  results: searchResults.map((result) => ({
244
244
  memoryId: result.vectorId.toString(),
245
245
  vectorId: result.vectorId,
246
246
  similarity: result.score,
247
247
  distance: result.distance,
248
- metadata: entry?.metadata.get(result.vectorId) || result.metadata
248
+ metadata: result.metadata || entry?.metadata.get(result.vectorId)
249
249
  })),
250
250
  searchStats: {
251
251
  searchTime,
@@ -12,8 +12,8 @@
12
12
  */
13
13
 
14
14
  import type { SuiClient } from '@mysten/sui/client';
15
- import type { Signer } from '@mysten/sui/cryptography';
16
15
  import { Transaction } from '@mysten/sui/transactions';
16
+ import type { UnifiedSigner } from '../../client/signers/UnifiedSigner';
17
17
 
18
18
  export interface BlobQueryResult {
19
19
  blobObjectId: string;
@@ -44,7 +44,7 @@ export class BlobAttributesManager {
44
44
  async setBlobAttributes(
45
45
  blobObjectId: string,
46
46
  attributes: Record<string, string>,
47
- signer: Signer
47
+ signer: UnifiedSigner
48
48
  ): Promise<string> {
49
49
  try {
50
50
  console.log(`🏷️ Setting ${Object.keys(attributes).length} attributes on blob ${blobObjectId.slice(0, 10)}...`);
@@ -69,12 +69,9 @@ export class BlobAttributesManager {
69
69
  console.log(` ✓ ${key}: ${value.slice(0, 50)}${value.length > 50 ? '...' : ''}`);
70
70
  }
71
71
 
72
- tx.setSender(signer.toSuiAddress());
72
+ tx.setSender(signer.getAddress());
73
73
 
74
- const result = await signer.signAndExecuteTransaction({
75
- transaction: tx,
76
- client: this.suiClient,
77
- });
74
+ const result = await signer.signAndExecuteTransaction(tx);
78
75
 
79
76
  console.log(`✅ Attributes set successfully!`);
80
77
  console.log(` Transaction: ${result.digest}`);
@@ -163,7 +160,7 @@ export class BlobAttributesManager {
163
160
  async updateBlobAttributes(
164
161
  blobObjectId: string,
165
162
  attributes: Record<string, string>,
166
- signer: Signer
163
+ signer: UnifiedSigner
167
164
  ): Promise<string> {
168
165
  try {
169
166
  console.log(`📝 Updating ${Object.keys(attributes).length} attributes on blob ${blobObjectId.slice(0, 10)}...`);
@@ -202,12 +199,9 @@ export class BlobAttributesManager {
202
199
  console.log(` ✓ Updated ${key}: ${value.slice(0, 50)}${value.length > 50 ? '...' : ''}`);
203
200
  }
204
201
 
205
- tx.setSender(signer.toSuiAddress());
202
+ tx.setSender(signer.getAddress());
206
203
 
207
- const result = await signer.signAndExecuteTransaction({
208
- transaction: tx,
209
- client: this.suiClient,
210
- });
204
+ const result = await signer.signAndExecuteTransaction(tx);
211
205
 
212
206
  console.log(`✅ Attributes updated successfully!`);
213
207
  console.log(` Transaction: ${result.digest}`);
@@ -226,7 +220,7 @@ export class BlobAttributesManager {
226
220
  async removeBlobAttributes(
227
221
  blobObjectId: string,
228
222
  attributeKeys: string[],
229
- signer: Signer
223
+ signer: UnifiedSigner
230
224
  ): Promise<string> {
231
225
  try {
232
226
  console.log(`🗑️ Removing ${attributeKeys.length} attributes from blob ${blobObjectId.slice(0, 10)}...`);
@@ -249,12 +243,9 @@ export class BlobAttributesManager {
249
243
  console.log(` ✓ Removed ${key}`);
250
244
  }
251
245
 
252
- tx.setSender(signer.toSuiAddress());
246
+ tx.setSender(signer.getAddress());
253
247
 
254
- const result = await signer.signAndExecuteTransaction({
255
- transaction: tx,
256
- client: this.suiClient,
257
- });
248
+ const result = await signer.signAndExecuteTransaction(tx);
258
249
 
259
250
  console.log(`✅ Attributes removed successfully!`);
260
251
  console.log(` Transaction: ${result.digest}`);
@@ -8,7 +8,7 @@
8
8
  * - Batch upload with ~90% gas savings (single transaction for multiple files)
9
9
  * - Tag-based filtering at the Walrus level
10
10
  * - Multi-file retrieval via quiltPatchId
11
- * - Browser-compatible using writeFilesFlow
11
+ * - Browser-compatible using writeFilesFlow (2 user signatures)
12
12
  *
13
13
  * Quilt Structure:
14
14
  * - quiltId: ID of the entire batch (blob containing all files)
@@ -16,13 +16,19 @@
16
16
  * - identifier: Human-readable name for each file
17
17
  * - tags: Metadata for filtering (category, importance, etc.)
18
18
  *
19
+ * Upload Flow (writeFilesFlow - works with DappKitSigner):
20
+ * 1. encode() - Encode files into blob format (no signature)
21
+ * 2. register() - Register blob on-chain (USER SIGNS - Transaction 1)
22
+ * 3. upload() - Upload to Walrus storage nodes (no signature)
23
+ * 4. certify() - Certify upload on-chain (USER SIGNS - Transaction 2)
24
+ *
19
25
  * @see https://sdk.mystenlabs.com/walrus/index
20
26
  */
21
27
 
22
28
  import { WalrusClient, WalrusFile } from '@mysten/walrus';
23
- import type { Signer } from '@mysten/sui/cryptography';
24
29
  import type { ClientWithExtensions } from '@mysten/sui/experimental';
25
30
  import type { SuiClient } from '@mysten/sui/client';
31
+ import type { UnifiedSigner } from '../../client/signers/UnifiedSigner';
26
32
 
27
33
  // ============================================================================
28
34
  // Types
@@ -40,7 +46,7 @@ export interface BatchMemory {
40
46
  }
41
47
 
42
48
  export interface QuiltUploadOptions {
43
- signer: Signer;
49
+ signer: UnifiedSigner;
44
50
  epochs?: number;
45
51
  userAddress: string;
46
52
  deletable?: boolean;
@@ -119,7 +125,13 @@ export class QuiltBatchManager {
119
125
  // ==========================================================================
120
126
 
121
127
  /**
122
- * Upload batch of memories as a Quilt
128
+ * Upload batch of memories as a Quilt using writeFilesFlow
129
+ *
130
+ * Uses the writeFilesFlow pattern which works with DappKitSigner:
131
+ * 1. encode() - Encode files (no signature)
132
+ * 2. register() - Register blob on-chain (USER SIGNS)
133
+ * 3. upload() - Upload to storage nodes (no signature)
134
+ * 4. certify() - Certify upload on-chain (USER SIGNS)
123
135
  *
124
136
  * Each memory becomes a WalrusFile with:
125
137
  * - Identifier: unique file name (memory-{timestamp}-{index}-{random}.json)
@@ -137,7 +149,7 @@ export class QuiltBatchManager {
137
149
  const startTime = performance.now();
138
150
  let totalSize = 0;
139
151
 
140
- console.log(`📦 Uploading batch of ${memories.length} memories as Quilt...`);
152
+ console.log(`📦 Uploading batch of ${memories.length} memories as Quilt (writeFilesFlow)...`);
141
153
 
142
154
  try {
143
155
  // Create WalrusFile for each memory with plaintext tags
@@ -181,42 +193,70 @@ export class QuiltBatchManager {
181
193
  console.log(` Total size: ${(totalSize / 1024).toFixed(2)} KB`);
182
194
  console.log(` Using upload relay: ${this.useUploadRelay}`);
183
195
 
184
- // Upload as Quilt using writeFiles
196
+ // Use writeFilesFlow pattern (works with DappKitSigner)
185
197
  const walrusClient = this.useUploadRelay
186
198
  ? this.walrusWithRelay
187
199
  : this.walrusWithoutRelay;
188
200
 
189
- const results = await walrusClient.writeFiles({
190
- files,
201
+ // Step 1: Create flow and encode files (no signature needed)
202
+ console.log(` Step 1/4: Encoding files...`);
203
+ const flow = walrusClient.writeFilesFlow({ files });
204
+ await flow.encode();
205
+ console.log(` ✓ Files encoded`);
206
+
207
+ // Step 2: Register blob on-chain (USER SIGNS - Transaction 1)
208
+ console.log(` Step 2/4: Registering blob (requires signature)...`);
209
+ const registerTx = flow.register({
191
210
  epochs: options.epochs || this.epochs,
192
- deletable: options.deletable ?? true,
193
- signer: options.signer
211
+ owner: options.userAddress,
212
+ deletable: options.deletable ?? true
194
213
  });
195
214
 
215
+ const registerResult = await options.signer.signAndExecuteTransaction(registerTx);
216
+ console.log(` ✓ Blob registered, digest: ${registerResult.digest}`);
217
+
218
+ // Step 3: Upload to Walrus storage nodes (no signature needed)
219
+ console.log(` Step 3/4: Uploading to storage nodes...`);
220
+ await flow.upload({ digest: registerResult.digest });
221
+ console.log(` ✓ Uploaded to storage nodes`);
222
+
223
+ // Step 4: Certify upload on-chain (USER SIGNS - Transaction 2)
224
+ console.log(` Step 4/4: Certifying upload (requires signature)...`);
225
+ const certifyTx = flow.certify();
226
+
227
+ if (certifyTx) {
228
+ const certifyResult = await options.signer.signAndExecuteTransaction(certifyTx);
229
+ console.log(` ✓ Upload certified, digest: ${certifyResult.digest}`);
230
+ } else {
231
+ console.log(` ✓ No certification needed (already certified)`);
232
+ }
233
+
234
+ // Get uploaded files info from flow
235
+ const uploadedFilesInfo = await flow.listFiles();
236
+
196
237
  const uploadTimeMs = performance.now() - startTime;
197
238
  const gasSaved = memories.length > 1
198
239
  ? `~${((1 - 1 / memories.length) * 100).toFixed(0)}%`
199
240
  : '0%';
200
241
 
201
242
  console.log(`✅ Quilt upload successful!`);
202
- console.log(` Quilt ID: ${results[0]?.id || 'N/A'}`);
203
- console.log(` Blob ID: ${results[0]?.blobId || 'N/A'}`);
204
- console.log(` Files uploaded: ${results.length}`);
243
+ console.log(` Files uploaded: ${uploadedFilesInfo.length}`);
205
244
  console.log(` Upload time: ${uploadTimeMs.toFixed(1)}ms`);
206
245
  console.log(` Gas saved: ${gasSaved} vs individual uploads`);
207
246
 
208
- // Build file results with identifiers (use original files array, not WalrusFile objects)
247
+ // Build file results using original WalrusFile objects for metadata
248
+ // and uploadedFilesInfo for blobId
209
249
  const fileResults: QuiltFileResult[] = await Promise.all(
210
- results.map(async (r, i) => {
211
- // Get identifier from original WalrusFile object
212
- const file = files[i];
213
- const identifier = await file?.getIdentifier() || `file-${i}`;
214
- const tags = await file?.getTags() || {};
250
+ files.map(async (originalFile, i) => {
251
+ const identifier = await originalFile.getIdentifier() || `file-${i}`;
252
+ const tags = await originalFile.getTags() || {};
253
+ // Get blobId from uploadedFilesInfo if available
254
+ const blobId = uploadedFilesInfo[i]?.blobId || '';
215
255
 
216
256
  return {
217
257
  identifier,
218
- blobId: r.blobId,
219
- quiltPatchId: undefined, // Not available from writeFiles result
258
+ blobId,
259
+ quiltPatchId: undefined,
220
260
  tags: Object.fromEntries(
221
261
  Object.entries(tags).map(([k, v]) => [k, String(v)])
222
262
  ),
@@ -225,9 +265,12 @@ export class QuiltBatchManager {
225
265
  })
226
266
  );
227
267
 
268
+ // Get quiltId from first uploaded file
269
+ const quiltId = uploadedFilesInfo[0]?.blobId || '';
270
+
228
271
  return {
229
- quiltId: results[0]?.id || results[0]?.blobId,
230
- blobObjectId: results[0]?.blobObject?.id?.id,
272
+ quiltId,
273
+ blobObjectId: undefined, // Not available from flow
231
274
  files: fileResults,
232
275
  uploadTimeMs,
233
276
  totalSize,
@@ -241,7 +284,13 @@ export class QuiltBatchManager {
241
284
  }
242
285
 
243
286
  /**
244
- * Upload raw files as a Quilt (non-memory data)
287
+ * Upload raw files as a Quilt using writeFilesFlow
288
+ *
289
+ * Uses the writeFilesFlow pattern which works with DappKitSigner:
290
+ * 1. encode() - Encode files (no signature)
291
+ * 2. register() - Register blob on-chain (USER SIGNS)
292
+ * 3. upload() - Upload to storage nodes (no signature)
293
+ * 4. certify() - Certify upload on-chain (USER SIGNS)
245
294
  *
246
295
  * @param files - Array of { identifier, data, tags }
247
296
  * @param options - Upload options
@@ -258,7 +307,7 @@ export class QuiltBatchManager {
258
307
  const startTime = performance.now();
259
308
  let totalSize = 0;
260
309
 
261
- console.log(`📁 Uploading ${files.length} files as Quilt...`);
310
+ console.log(`📁 Uploading ${files.length} files as Quilt (writeFilesFlow)...`);
262
311
 
263
312
  try {
264
313
  const walrusFiles = files.map(file => {
@@ -276,28 +325,81 @@ export class QuiltBatchManager {
276
325
  });
277
326
  });
278
327
 
328
+ // Use writeFilesFlow pattern (works with DappKitSigner)
279
329
  const walrusClient = this.useUploadRelay
280
330
  ? this.walrusWithRelay
281
331
  : this.walrusWithoutRelay;
282
332
 
283
- const results = await walrusClient.writeFiles({
284
- files: walrusFiles,
333
+ // Step 1: Create flow and encode files (no signature needed)
334
+ console.log(` Step 1/4: Encoding files...`);
335
+ const flow = walrusClient.writeFilesFlow({ files: walrusFiles });
336
+ await flow.encode();
337
+ console.log(` ✓ Files encoded`);
338
+
339
+ // Step 2: Register blob on-chain (USER SIGNS - Transaction 1)
340
+ console.log(` Step 2/4: Registering blob (requires signature)...`);
341
+ const registerTx = flow.register({
285
342
  epochs: options.epochs || this.epochs,
286
- deletable: options.deletable ?? true,
287
- signer: options.signer
343
+ owner: options.userAddress,
344
+ deletable: options.deletable ?? true
288
345
  });
289
346
 
347
+ const registerResult = await options.signer.signAndExecuteTransaction(registerTx);
348
+ console.log(` ✓ Blob registered, digest: ${registerResult.digest}`);
349
+
350
+ // Step 3: Upload to Walrus storage nodes (no signature needed)
351
+ console.log(` Step 3/4: Uploading to storage nodes...`);
352
+ await flow.upload({ digest: registerResult.digest });
353
+ console.log(` ✓ Uploaded to storage nodes`);
354
+
355
+ // Step 4: Certify upload on-chain (USER SIGNS - Transaction 2)
356
+ console.log(` Step 4/4: Certifying upload (requires signature)...`);
357
+ const certifyTx = flow.certify();
358
+
359
+ if (certifyTx) {
360
+ const certifyResult = await options.signer.signAndExecuteTransaction(certifyTx);
361
+ console.log(` ✓ Upload certified, digest: ${certifyResult.digest}`);
362
+ } else {
363
+ console.log(` ✓ No certification needed (already certified)`);
364
+ }
365
+
366
+ // Get uploaded files info from flow
367
+ const uploadedFilesInfo = await flow.listFiles();
368
+
290
369
  const uploadTimeMs = performance.now() - startTime;
291
370
 
371
+ console.log(`✅ Files batch upload successful!`);
372
+ console.log(` Files uploaded: ${uploadedFilesInfo.length}`);
373
+ console.log(` Upload time: ${uploadTimeMs.toFixed(1)}ms`);
374
+
375
+ // Build file results using original WalrusFile objects for metadata
376
+ // and uploadedFilesInfo for blobId
377
+ const fileResults: QuiltFileResult[] = await Promise.all(
378
+ walrusFiles.map(async (originalFile, i) => {
379
+ const identifier = await originalFile.getIdentifier() || files[i]?.identifier || `file-${i}`;
380
+ const tags = await originalFile.getTags() || {};
381
+ // Get blobId from uploadedFilesInfo if available
382
+ const blobId = uploadedFilesInfo[i]?.blobId || '';
383
+
384
+ return {
385
+ identifier,
386
+ blobId,
387
+ quiltPatchId: undefined,
388
+ tags: Object.fromEntries(
389
+ Object.entries(tags).map(([k, v]) => [k, String(v)])
390
+ ),
391
+ size: files[i]?.data.length || 0
392
+ };
393
+ })
394
+ );
395
+
396
+ // Get quiltId from first uploaded file
397
+ const quiltId = uploadedFilesInfo[0]?.blobId || '';
398
+
292
399
  return {
293
- quiltId: results[0]?.id || results[0]?.blobId,
294
- blobObjectId: results[0]?.blobObject?.id?.id,
295
- files: results.map((r, i) => ({
296
- identifier: files[i].identifier,
297
- blobId: r.blobId,
298
- tags: files[i].tags || {},
299
- size: files[i].data.length
300
- })),
400
+ quiltId,
401
+ blobObjectId: undefined, // Not available from flow
402
+ files: fileResults,
301
403
  uploadTimeMs,
302
404
  totalSize,
303
405
  gasSaved: files.length > 1 ? `~${((1 - 1 / files.length) * 100).toFixed(0)}%` : '0%'
@@ -12,8 +12,8 @@
12
12
  */
13
13
 
14
14
  import type { SuiClient } from '@mysten/sui/client';
15
- import type { Signer } from '@mysten/sui/cryptography';
16
15
  import { Transaction } from '@mysten/sui/transactions';
16
+ import type { UnifiedSigner } from '../../client/signers/UnifiedSigner';
17
17
 
18
18
  export interface WalrusMemoryMetadata {
19
19
  // Content identification
@@ -154,7 +154,7 @@ export class WalrusMetadataManager {
154
154
  async attachMetadataToBlob(
155
155
  blobId: string,
156
156
  metadata: WalrusMemoryMetadata,
157
- signer: Signer,
157
+ signer: UnifiedSigner,
158
158
  walrusPackageId: string
159
159
  ): Promise<{ digest: string; effects: any }> {
160
160
  try {
@@ -179,12 +179,9 @@ export class WalrusMetadataManager {
179
179
  ],
180
180
  });
181
181
 
182
- tx.setSender(signer.toSuiAddress());
182
+ tx.setSender(signer.getAddress());
183
183
 
184
- const result = await signer.signAndExecuteTransaction({
185
- transaction: tx,
186
- client: this.suiClient,
187
- });
184
+ const result = await signer.signAndExecuteTransaction(tx);
188
185
 
189
186
  console.log(`✅ Metadata attached successfully. Digest: ${result.digest}`);
190
187
 
@@ -15,8 +15,8 @@
15
15
 
16
16
  import { SuiClient, getFullnodeUrl } from '@mysten/sui/client';
17
17
  import { WalrusClient } from '@mysten/walrus';
18
- import type { Signer } from '@mysten/sui/cryptography';
19
18
  import type { ClientWithExtensions } from '@mysten/sui/experimental';
19
+ import type { UnifiedSigner } from '../../client/signers/UnifiedSigner';
20
20
 
21
21
  export interface WalrusStorageConfig {
22
22
  suiClient?: SuiClient;
@@ -28,7 +28,7 @@ export interface WalrusStorageConfig {
28
28
  }
29
29
 
30
30
  export interface BlobUploadOptions {
31
- signer: Signer;
31
+ signer: UnifiedSigner;
32
32
  epochs?: number;
33
33
  deletable?: boolean;
34
34
  useUploadRelay?: boolean;
@@ -160,29 +160,26 @@ export class WalrusStorageManager {
160
160
  // Step 1: Encode blob
161
161
  await flow.encode();
162
162
 
163
+ // Get signer address
164
+ const signerAddress = options.signer.getAddress();
165
+
163
166
  // Step 2: Register blob on-chain
164
167
  const registerTx = flow.register({
165
168
  epochs: options.epochs || this.config.epochs || 3,
166
169
  deletable: options.deletable ?? true,
167
- owner: options.signer.toSuiAddress(),
170
+ owner: signerAddress,
168
171
  });
169
172
 
170
- registerTx.setSender(options.signer.toSuiAddress());
171
- const { digest: registerDigest } = await options.signer.signAndExecuteTransaction({
172
- transaction: registerTx,
173
- client: this.suiClient,
174
- });
173
+ registerTx.setSender(signerAddress);
174
+ const { digest: registerDigest } = await options.signer.signAndExecuteTransaction(registerTx);
175
175
 
176
176
  // Step 3: Upload to storage
177
177
  await flow.upload({ digest: registerDigest });
178
178
 
179
179
  // Step 4: Certify blob on-chain
180
180
  const certifyTx = flow.certify();
181
- certifyTx.setSender(options.signer.toSuiAddress());
182
- await options.signer.signAndExecuteTransaction({
183
- transaction: certifyTx,
184
- client: this.suiClient,
185
- });
181
+ certifyTx.setSender(signerAddress);
182
+ await options.signer.signAndExecuteTransaction(certifyTx);
186
183
 
187
184
  // Get blob info
188
185
  const blob = await flow.getBlob();
@@ -24,7 +24,7 @@
24
24
  * - On-chain wallet registry integration
25
25
  */
26
26
 
27
- import { sha3_256 } from '@noble/hashes/sha3';
27
+ import { sha3_256 } from '@noble/hashes/sha3.js';
28
28
  import { SuiClient } from '@mysten/sui/client';
29
29
  import { Transaction } from '@mysten/sui/transactions';
30
30
  // Use Web Crypto API (browser-compatible)
@@ -1,43 +0,0 @@
1
- /**
2
- * API Client for Personal Data Wallet Backend
3
- *
4
- * Handles HTTP communication with the NestJS backend API
5
- */
6
- import type { APIResponse, MemoryCreateOptions, MemorySearchOptions, MemorySearchResult, MemoryContext, MemoryContextOptions, ChatOptions, ChatSession, CreateSessionOptions, MemoryStatsResponse } from '../types';
7
- import type { BatchStats } from '../core';
8
- export declare class PDWApiClient {
9
- private baseUrl;
10
- private headers;
11
- get baseURL(): string;
12
- get defaultHeaders(): Record<string, string>;
13
- constructor(apiUrl: string);
14
- private request;
15
- createMemory(options: MemoryCreateOptions): Promise<APIResponse<{
16
- memoryId: string;
17
- }>>;
18
- getUserMemories(userAddress: string): Promise<APIResponse<{
19
- memories: MemorySearchResult[];
20
- }>>;
21
- searchMemories(options: MemorySearchOptions): Promise<APIResponse<{
22
- results: MemorySearchResult[];
23
- }>>;
24
- getMemoryContext(options: MemoryContextOptions): Promise<APIResponse<MemoryContext>>;
25
- getMemoryStats(userAddress: string): Promise<APIResponse<MemoryStatsResponse>>;
26
- deleteMemory(memoryId: string, userAddress: string): Promise<APIResponse<void>>;
27
- getBatchStats(): Promise<APIResponse<BatchStats>>;
28
- getChatSessions(userAddress: string): Promise<APIResponse<{
29
- sessions: ChatSession[];
30
- }>>;
31
- getChatSession(sessionId: string, userAddress: string): Promise<APIResponse<ChatSession>>;
32
- createChatSession(options: CreateSessionOptions): Promise<APIResponse<ChatSession>>;
33
- deleteChatSession(sessionId: string, userAddress: string): Promise<APIResponse<void>>;
34
- sendChatMessage(options: ChatOptions): Promise<APIResponse<any>>;
35
- updateChatSessionTitle(sessionId: string, userAddress: string, title: string): Promise<APIResponse<void>>;
36
- addMessageToSession(sessionId: string, content: string, type: string, userAddress: string): Promise<APIResponse<void>>;
37
- saveChatSummary(sessionId: string, summary: string, userAddress: string): Promise<APIResponse<void>>;
38
- /**
39
- * Create EventSource for streaming chat responses
40
- */
41
- createChatStream(options: ChatOptions): EventSource;
42
- }
43
- //# sourceMappingURL=client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACb,oBAAoB,EACpB,WAAW,EACX,WAAW,EACX,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,OAAO,CAAyB;IAExC,IAAI,OAAO,WAA2B;IACtC,IAAI,cAAc,2BAA2B;gBAEjC,MAAM,EAAE,MAAM;YAOZ,OAAO;IAwBf,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IActF,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;QAAE,QAAQ,EAAE,kBAAkB,EAAE,CAAA;KAAE,CAAC,CAAC;IAI9F,cAAc,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,CAAC;QAAE,OAAO,EAAE,kBAAkB,EAAE,CAAA;KAAE,CAAC,CAAC;IAOrG,gBAAgB,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;IAOpF,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC;IAI9E,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAO/E,aAAa,IAAI,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAMjD,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;QAAE,QAAQ,EAAE,WAAW,EAAE,CAAA;KAAE,CAAC,CAAC;IAIvF,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;IAIzF,iBAAiB,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;IAOnF,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAOrF,eAAe,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAchE,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAOzG,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAOtH,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAO1G;;OAEG;IACH,gBAAgB,CAAC,OAAO,EAAE,WAAW,GAAG,WAAW;CAYpD"}