@cmdoss/memwal-sdk 0.6.1 → 0.6.2
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/ARCHITECTURE.md +547 -547
- package/BENCHMARKS.md +238 -238
- package/README.md +181 -181
- package/dist/ai-sdk/PDWVectorStore.d.ts.map +1 -1
- package/dist/ai-sdk/PDWVectorStore.js +4 -1
- package/dist/ai-sdk/PDWVectorStore.js.map +1 -1
- package/dist/browser.d.ts +5 -6
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +7 -6
- package/dist/browser.js.map +1 -1
- package/dist/client/ClientMemoryManager.d.ts +1 -0
- package/dist/client/ClientMemoryManager.d.ts.map +1 -1
- package/dist/client/ClientMemoryManager.js +5 -1
- package/dist/client/ClientMemoryManager.js.map +1 -1
- package/dist/client/PersonalDataWallet.d.ts.map +1 -1
- package/dist/client/SimplePDWClient.d.ts +23 -0
- package/dist/client/SimplePDWClient.d.ts.map +1 -1
- package/dist/client/SimplePDWClient.js +15 -2
- package/dist/client/SimplePDWClient.js.map +1 -1
- package/dist/client/namespaces/IndexNamespace.d.ts +38 -9
- package/dist/client/namespaces/IndexNamespace.d.ts.map +1 -1
- package/dist/client/namespaces/IndexNamespace.js +77 -10
- package/dist/client/namespaces/IndexNamespace.js.map +1 -1
- package/dist/client/namespaces/SearchNamespace.d.ts.map +1 -1
- package/dist/client/namespaces/SearchNamespace.js +25 -14
- package/dist/client/namespaces/SearchNamespace.js.map +1 -1
- package/dist/client/namespaces/consolidated/BlockchainNamespace.d.ts.map +1 -1
- package/dist/client/namespaces/consolidated/BlockchainNamespace.js +49 -1
- package/dist/client/namespaces/consolidated/BlockchainNamespace.js.map +1 -1
- package/dist/client/namespaces/consolidated/StorageNamespace.d.ts +46 -0
- package/dist/client/namespaces/consolidated/StorageNamespace.d.ts.map +1 -1
- package/dist/client/namespaces/consolidated/StorageNamespace.js +34 -0
- package/dist/client/namespaces/consolidated/StorageNamespace.js.map +1 -1
- package/dist/graph/GraphService.js +1 -1
- package/dist/permissions/ConsentRepository.browser.d.ts +56 -0
- package/dist/permissions/ConsentRepository.browser.d.ts.map +1 -0
- package/dist/permissions/ConsentRepository.browser.js +198 -0
- package/dist/permissions/ConsentRepository.browser.js.map +1 -0
- package/dist/services/GeminiAIService.d.ts.map +1 -1
- package/dist/services/GeminiAIService.js +283 -27
- package/dist/services/GeminiAIService.js.map +1 -1
- package/dist/services/MemoryIndexService.d.ts +31 -2
- package/dist/services/MemoryIndexService.d.ts.map +1 -1
- package/dist/services/MemoryIndexService.js +75 -3
- package/dist/services/MemoryIndexService.js.map +1 -1
- package/dist/services/storage/QuiltBatchManager.d.ts +10 -3
- package/dist/services/storage/QuiltBatchManager.d.ts.map +1 -1
- package/dist/services/storage/QuiltBatchManager.js +49 -27
- package/dist/services/storage/QuiltBatchManager.js.map +1 -1
- package/dist/utils/rebuildIndexNode.d.ts.map +1 -1
- package/dist/utils/rebuildIndexNode.js +109 -35
- package/dist/utils/rebuildIndexNode.js.map +1 -1
- package/dist/vector/NodeHnswService.d.ts.map +1 -1
- package/dist/vector/NodeHnswService.js +26 -7
- package/dist/vector/NodeHnswService.js.map +1 -1
- package/package.json +1 -1
- package/src/access/index.ts +8 -8
- package/src/aggregation/index.ts +8 -8
- package/src/ai-sdk/PDWVectorStore.ts +4 -1
- package/src/browser.ts +15 -10
- package/src/client/ClientMemoryManager.ts +6 -1
- package/src/client/SimplePDWClient.ts +40 -2
- package/src/client/namespaces/IndexNamespace.ts +89 -11
- package/src/client/namespaces/SearchNamespace.ts +27 -14
- package/src/client/namespaces/consolidated/BlockchainNamespace.ts +55 -1
- package/src/client/namespaces/consolidated/StorageNamespace.ts +57 -0
- package/src/client/signers/DappKitSigner.ts +207 -207
- package/src/generated/pdw/capability.ts +319 -319
- package/src/generated/pdw/deps/sui/object.ts +12 -12
- package/src/generated/pdw/deps/sui/vec_map.ts +32 -32
- package/src/generated/pdw/memory.ts +1087 -1087
- package/src/generated/pdw/wallet.ts +123 -123
- package/src/generated/utils/index.ts +159 -159
- package/src/graph/GraphService.ts +1 -1
- package/src/permissions/ConsentRepository.browser.ts +249 -0
- package/src/permissions/index.ts +9 -9
- package/src/services/GeminiAIService.ts +283 -27
- package/src/services/MemoryIndexService.ts +85 -3
- package/src/services/storage/QuiltBatchManager.ts +55 -29
- package/src/utils/rebuildIndexNode.ts +126 -43
- package/src/vector/NodeHnswService.ts +29 -7
- package/src/wallet/index.ts +17 -17
|
@@ -1,1088 +1,1088 @@
|
|
|
1
|
-
/**************************************************************
|
|
2
|
-
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
-
**************************************************************/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Memory management module for Personal Data Wallet
|
|
8
|
-
*
|
|
9
|
-
* This module provides memory record management with:
|
|
10
|
-
*
|
|
11
|
-
* - Rich metadata for encrypted content stored on Walrus
|
|
12
|
-
* - Support for both capability-based and legacy address-based access
|
|
13
|
-
* - Vector embedding storage for semantic search
|
|
14
|
-
* - Knowledge graph integration
|
|
15
|
-
*
|
|
16
|
-
* V2 Changes (Capability-based):
|
|
17
|
-
*
|
|
18
|
-
* - Added capability_id field to link memories to MemoryCap
|
|
19
|
-
* - New create_memory_with_cap() for capability-based creation
|
|
20
|
-
* - Maintains backward compatibility with existing functions
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';
|
|
24
|
-
import { bcs } from '@mysten/sui/bcs';
|
|
25
|
-
import { type Transaction } from '@mysten/sui/transactions';
|
|
26
|
-
import * as vec_map from './deps/sui/vec_map.js';
|
|
27
|
-
import * as object from './deps/sui/object.js';
|
|
28
|
-
const $moduleName = '@local-pkg/pdw::memory';
|
|
29
|
-
export const MemoryCreated = new MoveStruct({ name: `${$moduleName}::MemoryCreated`, fields: {
|
|
30
|
-
id: bcs.Address,
|
|
31
|
-
owner: bcs.Address,
|
|
32
|
-
category: bcs.string(),
|
|
33
|
-
vector_id: bcs.u64(),
|
|
34
|
-
/** V2: Link to MemoryCap object ID */
|
|
35
|
-
capability_id: bcs.option(bcs.Address),
|
|
36
|
-
/**
|
|
37
|
-
* V2: App context for filtering (e.g., "MEMO", "HEALTH")
|
|
38
|
-
*
|
|
39
|
-
* - Query all: no filter
|
|
40
|
-
* - Query by context: filter by app_id
|
|
41
|
-
*/
|
|
42
|
-
app_id: bcs.option(bcs.string())
|
|
43
|
-
} });
|
|
44
|
-
export const MemoryIndexUpdated = new MoveStruct({ name: `${$moduleName}::MemoryIndexUpdated`, fields: {
|
|
45
|
-
id: bcs.Address,
|
|
46
|
-
owner: bcs.Address,
|
|
47
|
-
version: bcs.u64(),
|
|
48
|
-
index_blob_id: bcs.string(),
|
|
49
|
-
graph_blob_id: bcs.string()
|
|
50
|
-
} });
|
|
51
|
-
export const MemoryMetadataUpdated = new MoveStruct({ name: `${$moduleName}::MemoryMetadataUpdated`, fields: {
|
|
52
|
-
memory_id: bcs.Address,
|
|
53
|
-
metadata_blob_id: bcs.string(),
|
|
54
|
-
embedding_dimension: bcs.u64()
|
|
55
|
-
} });
|
|
56
|
-
export const MemoryUpdated = new MoveStruct({ name: `${$moduleName}::MemoryUpdated`, fields: {
|
|
57
|
-
id: bcs.Address,
|
|
58
|
-
owner: bcs.Address,
|
|
59
|
-
/**
|
|
60
|
-
* Fields that were updated (bitmask: 1=blob_id, 2=category, 4=topic, 8=importance,
|
|
61
|
-
* 16=embedding)
|
|
62
|
-
*/
|
|
63
|
-
updated_fields: bcs.u8(),
|
|
64
|
-
new_blob_id: bcs.option(bcs.string()),
|
|
65
|
-
new_category: bcs.option(bcs.string()),
|
|
66
|
-
updated_at: bcs.u64()
|
|
67
|
-
} });
|
|
68
|
-
export const MemoryMetadata = new MoveStruct({ name: `${$moduleName}::MemoryMetadata`, fields: {
|
|
69
|
-
content_type: bcs.string(),
|
|
70
|
-
content_size: bcs.u64(),
|
|
71
|
-
content_hash: bcs.string(),
|
|
72
|
-
category: bcs.string(),
|
|
73
|
-
topic: bcs.string(),
|
|
74
|
-
importance: bcs.u8(),
|
|
75
|
-
embedding_blob_id: bcs.string(),
|
|
76
|
-
embedding_dimension: bcs.u64(),
|
|
77
|
-
created_timestamp: bcs.u64(),
|
|
78
|
-
updated_timestamp: bcs.u64(),
|
|
79
|
-
custom_metadata: vec_map.VecMap(bcs.string(), bcs.string())
|
|
80
|
-
} });
|
|
81
|
-
export const MemoryIndex = new MoveStruct({ name: `${$moduleName}::MemoryIndex`, fields: {
|
|
82
|
-
id: object.UID,
|
|
83
|
-
owner: bcs.Address,
|
|
84
|
-
version: bcs.u64(),
|
|
85
|
-
index_blob_id: bcs.string(),
|
|
86
|
-
graph_blob_id: bcs.string()
|
|
87
|
-
} });
|
|
88
|
-
export const Memory = new MoveStruct({ name: `${$moduleName}::Memory`, fields: {
|
|
89
|
-
id: object.UID,
|
|
90
|
-
owner: bcs.Address,
|
|
91
|
-
category: bcs.string(),
|
|
92
|
-
vector_id: bcs.u64(),
|
|
93
|
-
blob_id: bcs.string(),
|
|
94
|
-
metadata: MemoryMetadata,
|
|
95
|
-
/**
|
|
96
|
-
* V2: Link to MemoryCap for capability-based access control If set, access is
|
|
97
|
-
* controlled via MemoryCap ownership If none, falls back to owner-based access
|
|
98
|
-
* (legacy)
|
|
99
|
-
*/
|
|
100
|
-
capability_id: bcs.option(bcs.Address),
|
|
101
|
-
/**
|
|
102
|
-
* V2: App context for context-based querying Copied from MemoryCap.app_id for
|
|
103
|
-
* efficient filtering
|
|
104
|
-
*
|
|
105
|
-
* - Query all memories: getOwnedObjects without filter
|
|
106
|
-
* - Query by context: filter by app_id field
|
|
107
|
-
*/
|
|
108
|
-
app_id: bcs.option(bcs.string())
|
|
109
|
-
} });
|
|
110
|
-
export interface CreateMemoryIndexArguments {
|
|
111
|
-
indexBlobId: RawTransactionArgument<number[]>;
|
|
112
|
-
graphBlobId: RawTransactionArgument<number[]>;
|
|
113
|
-
}
|
|
114
|
-
export interface CreateMemoryIndexOptions {
|
|
115
|
-
package?: string;
|
|
116
|
-
arguments: CreateMemoryIndexArguments | [
|
|
117
|
-
indexBlobId: RawTransactionArgument<number[]>,
|
|
118
|
-
graphBlobId: RawTransactionArgument<number[]>
|
|
119
|
-
];
|
|
120
|
-
}
|
|
121
|
-
/** Create a new memory index for a user */
|
|
122
|
-
export function createMemoryIndex(options: CreateMemoryIndexOptions) {
|
|
123
|
-
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
124
|
-
const argumentsTypes = [
|
|
125
|
-
'vector<u8>',
|
|
126
|
-
'vector<u8>'
|
|
127
|
-
] satisfies string[];
|
|
128
|
-
const parameterNames = ["indexBlobId", "graphBlobId"];
|
|
129
|
-
return (tx: Transaction) => tx.moveCall({
|
|
130
|
-
package: packageAddress,
|
|
131
|
-
module: 'memory',
|
|
132
|
-
function: 'create_memory_index',
|
|
133
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
export interface UpdateMemoryIndexArguments {
|
|
137
|
-
memoryIndex: RawTransactionArgument<string>;
|
|
138
|
-
expectedVersion: RawTransactionArgument<number | bigint>;
|
|
139
|
-
newIndexBlobId: RawTransactionArgument<number[]>;
|
|
140
|
-
newGraphBlobId: RawTransactionArgument<number[]>;
|
|
141
|
-
}
|
|
142
|
-
export interface UpdateMemoryIndexOptions {
|
|
143
|
-
package?: string;
|
|
144
|
-
arguments: UpdateMemoryIndexArguments | [
|
|
145
|
-
memoryIndex: RawTransactionArgument<string>,
|
|
146
|
-
expectedVersion: RawTransactionArgument<number | bigint>,
|
|
147
|
-
newIndexBlobId: RawTransactionArgument<number[]>,
|
|
148
|
-
newGraphBlobId: RawTransactionArgument<number[]>
|
|
149
|
-
];
|
|
150
|
-
}
|
|
151
|
-
/** Update an existing memory index with new blob IDs */
|
|
152
|
-
export function updateMemoryIndex(options: UpdateMemoryIndexOptions) {
|
|
153
|
-
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
154
|
-
const argumentsTypes = [
|
|
155
|
-
`${packageAddress}::memory::MemoryIndex`,
|
|
156
|
-
'u64',
|
|
157
|
-
'vector<u8>',
|
|
158
|
-
'vector<u8>'
|
|
159
|
-
] satisfies string[];
|
|
160
|
-
const parameterNames = ["memoryIndex", "expectedVersion", "newIndexBlobId", "newGraphBlobId"];
|
|
161
|
-
return (tx: Transaction) => tx.moveCall({
|
|
162
|
-
package: packageAddress,
|
|
163
|
-
module: 'memory',
|
|
164
|
-
function: 'update_memory_index',
|
|
165
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
export interface CreateMemoryMetadataArguments {
|
|
169
|
-
contentType: RawTransactionArgument<number[]>;
|
|
170
|
-
contentSize: RawTransactionArgument<number | bigint>;
|
|
171
|
-
contentHash: RawTransactionArgument<number[]>;
|
|
172
|
-
category: RawTransactionArgument<number[]>;
|
|
173
|
-
topic: RawTransactionArgument<number[]>;
|
|
174
|
-
importance: RawTransactionArgument<number>;
|
|
175
|
-
embeddingBlobId: RawTransactionArgument<number[]>;
|
|
176
|
-
embeddingDimension: RawTransactionArgument<number | bigint>;
|
|
177
|
-
createdTimestamp: RawTransactionArgument<number | bigint>;
|
|
178
|
-
}
|
|
179
|
-
export interface CreateMemoryMetadataOptions {
|
|
180
|
-
package?: string;
|
|
181
|
-
arguments: CreateMemoryMetadataArguments | [
|
|
182
|
-
contentType: RawTransactionArgument<number[]>,
|
|
183
|
-
contentSize: RawTransactionArgument<number | bigint>,
|
|
184
|
-
contentHash: RawTransactionArgument<number[]>,
|
|
185
|
-
category: RawTransactionArgument<number[]>,
|
|
186
|
-
topic: RawTransactionArgument<number[]>,
|
|
187
|
-
importance: RawTransactionArgument<number>,
|
|
188
|
-
embeddingBlobId: RawTransactionArgument<number[]>,
|
|
189
|
-
embeddingDimension: RawTransactionArgument<number | bigint>,
|
|
190
|
-
createdTimestamp: RawTransactionArgument<number | bigint>
|
|
191
|
-
];
|
|
192
|
-
}
|
|
193
|
-
/** Create metadata struct with embedding */
|
|
194
|
-
export function createMemoryMetadata(options: CreateMemoryMetadataOptions) {
|
|
195
|
-
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
196
|
-
const argumentsTypes = [
|
|
197
|
-
'vector<u8>',
|
|
198
|
-
'u64',
|
|
199
|
-
'vector<u8>',
|
|
200
|
-
'vector<u8>',
|
|
201
|
-
'vector<u8>',
|
|
202
|
-
'u8',
|
|
203
|
-
'vector<u8>',
|
|
204
|
-
'u64',
|
|
205
|
-
'u64'
|
|
206
|
-
] satisfies string[];
|
|
207
|
-
const parameterNames = ["contentType", "contentSize", "contentHash", "category", "topic", "importance", "embeddingBlobId", "embeddingDimension", "createdTimestamp"];
|
|
208
|
-
return (tx: Transaction) => tx.moveCall({
|
|
209
|
-
package: packageAddress,
|
|
210
|
-
module: 'memory',
|
|
211
|
-
function: 'create_memory_metadata',
|
|
212
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
export interface CreateMemoryRecordArguments {
|
|
216
|
-
category: RawTransactionArgument<number[]>;
|
|
217
|
-
vectorId: RawTransactionArgument<number | bigint>;
|
|
218
|
-
blobId: RawTransactionArgument<number[]>;
|
|
219
|
-
contentType: RawTransactionArgument<number[]>;
|
|
220
|
-
contentSize: RawTransactionArgument<number | bigint>;
|
|
221
|
-
contentHash: RawTransactionArgument<number[]>;
|
|
222
|
-
topic: RawTransactionArgument<number[]>;
|
|
223
|
-
importance: RawTransactionArgument<number>;
|
|
224
|
-
embeddingBlobId: RawTransactionArgument<number[]>;
|
|
225
|
-
}
|
|
226
|
-
export interface CreateMemoryRecordOptions {
|
|
227
|
-
package?: string;
|
|
228
|
-
arguments: CreateMemoryRecordArguments | [
|
|
229
|
-
category: RawTransactionArgument<number[]>,
|
|
230
|
-
vectorId: RawTransactionArgument<number | bigint>,
|
|
231
|
-
blobId: RawTransactionArgument<number[]>,
|
|
232
|
-
contentType: RawTransactionArgument<number[]>,
|
|
233
|
-
contentSize: RawTransactionArgument<number | bigint>,
|
|
234
|
-
contentHash: RawTransactionArgument<number[]>,
|
|
235
|
-
topic: RawTransactionArgument<number[]>,
|
|
236
|
-
importance: RawTransactionArgument<number>,
|
|
237
|
-
embeddingBlobId: RawTransactionArgument<number[]>
|
|
238
|
-
];
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Create a new memory record with rich metadata (LEGACY - for backward
|
|
242
|
-
* compatibility)
|
|
243
|
-
*
|
|
244
|
-
* NOTE: For new implementations, use create_memory_with_cap() instead which
|
|
245
|
-
* provides capability-based access control.
|
|
246
|
-
*/
|
|
247
|
-
export function createMemoryRecord(options: CreateMemoryRecordOptions) {
|
|
248
|
-
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
249
|
-
const argumentsTypes = [
|
|
250
|
-
'vector<u8>',
|
|
251
|
-
'u64',
|
|
252
|
-
'vector<u8>',
|
|
253
|
-
'vector<u8>',
|
|
254
|
-
'u64',
|
|
255
|
-
'vector<u8>',
|
|
256
|
-
'vector<u8>',
|
|
257
|
-
'u8',
|
|
258
|
-
'vector<u8>'
|
|
259
|
-
] satisfies string[];
|
|
260
|
-
const parameterNames = ["category", "vectorId", "blobId", "contentType", "contentSize", "contentHash", "topic", "importance", "embeddingBlobId"];
|
|
261
|
-
return (tx: Transaction) => tx.moveCall({
|
|
262
|
-
package: packageAddress,
|
|
263
|
-
module: 'memory',
|
|
264
|
-
function: 'create_memory_record',
|
|
265
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
export interface CreateMemoryWithCapArguments {
|
|
269
|
-
cap: RawTransactionArgument<string>;
|
|
270
|
-
category: RawTransactionArgument<number[]>;
|
|
271
|
-
vectorId: RawTransactionArgument<number | bigint>;
|
|
272
|
-
blobId: RawTransactionArgument<number[]>;
|
|
273
|
-
contentType: RawTransactionArgument<number[]>;
|
|
274
|
-
contentSize: RawTransactionArgument<number | bigint>;
|
|
275
|
-
contentHash: RawTransactionArgument<number[]>;
|
|
276
|
-
topic: RawTransactionArgument<number[]>;
|
|
277
|
-
importance: RawTransactionArgument<number>;
|
|
278
|
-
embeddingBlobId: RawTransactionArgument<number[]>;
|
|
279
|
-
}
|
|
280
|
-
export interface CreateMemoryWithCapOptions {
|
|
281
|
-
package?: string;
|
|
282
|
-
arguments: CreateMemoryWithCapArguments | [
|
|
283
|
-
cap: RawTransactionArgument<string>,
|
|
284
|
-
category: RawTransactionArgument<number[]>,
|
|
285
|
-
vectorId: RawTransactionArgument<number | bigint>,
|
|
286
|
-
blobId: RawTransactionArgument<number[]>,
|
|
287
|
-
contentType: RawTransactionArgument<number[]>,
|
|
288
|
-
contentSize: RawTransactionArgument<number | bigint>,
|
|
289
|
-
contentHash: RawTransactionArgument<number[]>,
|
|
290
|
-
topic: RawTransactionArgument<number[]>,
|
|
291
|
-
importance: RawTransactionArgument<number>,
|
|
292
|
-
embeddingBlobId: RawTransactionArgument<number[]>
|
|
293
|
-
];
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* Create a new memory record with capability-based access control (V2 -
|
|
297
|
-
* RECOMMENDED)
|
|
298
|
-
*
|
|
299
|
-
* This function links the memory to a MemoryCap for SEAL-compliant access control.
|
|
300
|
-
* Benefits:
|
|
301
|
-
*
|
|
302
|
-
* - Access controlled via MemoryCap ownership
|
|
303
|
-
* - Cross-dApp sharing "just works" (same owner = access)
|
|
304
|
-
* - No allowlist management needed
|
|
305
|
-
*
|
|
306
|
-
* @param cap: Reference to the MemoryCap (proves ownership) @param category:
|
|
307
|
-
* Memory category @param vector_id: Links to HNSW index @param blob_id: Pointer to
|
|
308
|
-
* encrypted content on Walrus @param content_type: MIME type @param content_size:
|
|
309
|
-
* Size in bytes @param content_hash: Content hash (blob_id) @param topic: Topic
|
|
310
|
-
* classification @param importance: Importance scale (1-10) @param
|
|
311
|
-
* embedding_blob_id: Pointer to embedding on Walrus @param ctx: Transaction
|
|
312
|
-
* context
|
|
313
|
-
*/
|
|
314
|
-
export function createMemoryWithCap(options: CreateMemoryWithCapOptions) {
|
|
315
|
-
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
316
|
-
const argumentsTypes = [
|
|
317
|
-
`${packageAddress}::capability::MemoryCap`,
|
|
318
|
-
'vector<u8>',
|
|
319
|
-
'u64',
|
|
320
|
-
'vector<u8>',
|
|
321
|
-
'vector<u8>',
|
|
322
|
-
'u64',
|
|
323
|
-
'vector<u8>',
|
|
324
|
-
'vector<u8>',
|
|
325
|
-
'u8',
|
|
326
|
-
'vector<u8>'
|
|
327
|
-
] satisfies string[];
|
|
328
|
-
const parameterNames = ["cap", "category", "vectorId", "blobId", "contentType", "contentSize", "contentHash", "topic", "importance", "embeddingBlobId"];
|
|
329
|
-
return (tx: Transaction) => tx.moveCall({
|
|
330
|
-
package: packageAddress,
|
|
331
|
-
module: 'memory',
|
|
332
|
-
function: 'create_memory_with_cap',
|
|
333
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
export interface UpdateMemoryMetadataArguments {
|
|
337
|
-
memory: RawTransactionArgument<string>;
|
|
338
|
-
newTopic: RawTransactionArgument<number[]>;
|
|
339
|
-
newImportance: RawTransactionArgument<number>;
|
|
340
|
-
}
|
|
341
|
-
export interface UpdateMemoryMetadataOptions {
|
|
342
|
-
package?: string;
|
|
343
|
-
arguments: UpdateMemoryMetadataArguments | [
|
|
344
|
-
memory: RawTransactionArgument<string>,
|
|
345
|
-
newTopic: RawTransactionArgument<number[]>,
|
|
346
|
-
newImportance: RawTransactionArgument<number>
|
|
347
|
-
];
|
|
348
|
-
}
|
|
349
|
-
/** Update metadata for an existing memory */
|
|
350
|
-
export function updateMemoryMetadata(options: UpdateMemoryMetadataOptions) {
|
|
351
|
-
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
352
|
-
const argumentsTypes = [
|
|
353
|
-
`${packageAddress}::memory::Memory`,
|
|
354
|
-
'vector<u8>',
|
|
355
|
-
'u8'
|
|
356
|
-
] satisfies string[];
|
|
357
|
-
const parameterNames = ["memory", "newTopic", "newImportance"];
|
|
358
|
-
return (tx: Transaction) => tx.moveCall({
|
|
359
|
-
package: packageAddress,
|
|
360
|
-
module: 'memory',
|
|
361
|
-
function: 'update_memory_metadata',
|
|
362
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
363
|
-
});
|
|
364
|
-
}
|
|
365
|
-
export interface AddCustomMetadataArguments {
|
|
366
|
-
memory: RawTransactionArgument<string>;
|
|
367
|
-
key: RawTransactionArgument<number[]>;
|
|
368
|
-
value: RawTransactionArgument<number[]>;
|
|
369
|
-
}
|
|
370
|
-
export interface AddCustomMetadataOptions {
|
|
371
|
-
package?: string;
|
|
372
|
-
arguments: AddCustomMetadataArguments | [
|
|
373
|
-
memory: RawTransactionArgument<string>,
|
|
374
|
-
key: RawTransactionArgument<number[]>,
|
|
375
|
-
value: RawTransactionArgument<number[]>
|
|
376
|
-
];
|
|
377
|
-
}
|
|
378
|
-
/** Add custom metadata field */
|
|
379
|
-
export function addCustomMetadata(options: AddCustomMetadataOptions) {
|
|
380
|
-
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
381
|
-
const argumentsTypes = [
|
|
382
|
-
`${packageAddress}::memory::Memory`,
|
|
383
|
-
'vector<u8>',
|
|
384
|
-
'vector<u8>'
|
|
385
|
-
] satisfies string[];
|
|
386
|
-
const parameterNames = ["memory", "key", "value"];
|
|
387
|
-
return (tx: Transaction) => tx.moveCall({
|
|
388
|
-
package: packageAddress,
|
|
389
|
-
module: 'memory',
|
|
390
|
-
function: 'add_custom_metadata',
|
|
391
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
392
|
-
});
|
|
393
|
-
}
|
|
394
|
-
export interface UpdateMemoryRecordArguments {
|
|
395
|
-
memory: RawTransactionArgument<string>;
|
|
396
|
-
newBlobId: RawTransactionArgument<number[]>;
|
|
397
|
-
newCategory: RawTransactionArgument<number[]>;
|
|
398
|
-
newTopic: RawTransactionArgument<number[]>;
|
|
399
|
-
newImportance: RawTransactionArgument<number>;
|
|
400
|
-
newEmbeddingBlobId: RawTransactionArgument<number[]>;
|
|
401
|
-
newContentHash: RawTransactionArgument<number[]>;
|
|
402
|
-
newContentSize: RawTransactionArgument<number | bigint>;
|
|
403
|
-
}
|
|
404
|
-
export interface UpdateMemoryRecordOptions {
|
|
405
|
-
package?: string;
|
|
406
|
-
arguments: UpdateMemoryRecordArguments | [
|
|
407
|
-
memory: RawTransactionArgument<string>,
|
|
408
|
-
newBlobId: RawTransactionArgument<number[]>,
|
|
409
|
-
newCategory: RawTransactionArgument<number[]>,
|
|
410
|
-
newTopic: RawTransactionArgument<number[]>,
|
|
411
|
-
newImportance: RawTransactionArgument<number>,
|
|
412
|
-
newEmbeddingBlobId: RawTransactionArgument<number[]>,
|
|
413
|
-
newContentHash: RawTransactionArgument<number[]>,
|
|
414
|
-
newContentSize: RawTransactionArgument<number | bigint>
|
|
415
|
-
];
|
|
416
|
-
}
|
|
417
|
-
/**
|
|
418
|
-
* Comprehensive update for a memory record
|
|
419
|
-
*
|
|
420
|
-
* Updates multiple fields of a Memory object in a single transaction. Only
|
|
421
|
-
* non-empty values will be updated (empty vector<u8> = skip update).
|
|
422
|
-
*
|
|
423
|
-
* This function follows Sui's object model where:
|
|
424
|
-
*
|
|
425
|
-
* - Objects are passed as mutable references (&mut)
|
|
426
|
-
* - Version number is automatically incremented by Sui runtime
|
|
427
|
-
* - Changes are atomic within the transaction
|
|
428
|
-
*
|
|
429
|
-
* @param memory: Mutable reference to the Memory object @param new_blob_id: New
|
|
430
|
-
* Walrus blob ID (empty = no change) @param new_category: New category (empty = no
|
|
431
|
-
* change) @param new_topic: New topic (empty = no change) @param new_importance:
|
|
432
|
-
* New importance (0 = no change, 1-10 = update) @param new_embedding_blob_id: New
|
|
433
|
-
* embedding blob ID (empty = no change) @param new_content_hash: New content hash
|
|
434
|
-
* (empty = no change) @param new_content_size: New content size (0 = no change)
|
|
435
|
-
* @param ctx: Transaction context
|
|
436
|
-
*/
|
|
437
|
-
export function updateMemoryRecord(options: UpdateMemoryRecordOptions) {
|
|
438
|
-
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
439
|
-
const argumentsTypes = [
|
|
440
|
-
`${packageAddress}::memory::Memory`,
|
|
441
|
-
'vector<u8>',
|
|
442
|
-
'vector<u8>',
|
|
443
|
-
'vector<u8>',
|
|
444
|
-
'u8',
|
|
445
|
-
'vector<u8>',
|
|
446
|
-
'vector<u8>',
|
|
447
|
-
'u64'
|
|
448
|
-
] satisfies string[];
|
|
449
|
-
const parameterNames = ["memory", "newBlobId", "newCategory", "newTopic", "newImportance", "newEmbeddingBlobId", "newContentHash", "newContentSize"];
|
|
450
|
-
return (tx: Transaction) => tx.moveCall({
|
|
451
|
-
package: packageAddress,
|
|
452
|
-
module: 'memory',
|
|
453
|
-
function: 'update_memory_record',
|
|
454
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
455
|
-
});
|
|
456
|
-
}
|
|
457
|
-
export interface UpdateMemoryWithCapArguments {
|
|
458
|
-
cap: RawTransactionArgument<string>;
|
|
459
|
-
memory: RawTransactionArgument<string>;
|
|
460
|
-
newBlobId: RawTransactionArgument<number[]>;
|
|
461
|
-
newCategory: RawTransactionArgument<number[]>;
|
|
462
|
-
newTopic: RawTransactionArgument<number[]>;
|
|
463
|
-
newImportance: RawTransactionArgument<number>;
|
|
464
|
-
newEmbeddingBlobId: RawTransactionArgument<number[]>;
|
|
465
|
-
newContentHash: RawTransactionArgument<number[]>;
|
|
466
|
-
newContentSize: RawTransactionArgument<number | bigint>;
|
|
467
|
-
}
|
|
468
|
-
export interface UpdateMemoryWithCapOptions {
|
|
469
|
-
package?: string;
|
|
470
|
-
arguments: UpdateMemoryWithCapArguments | [
|
|
471
|
-
cap: RawTransactionArgument<string>,
|
|
472
|
-
memory: RawTransactionArgument<string>,
|
|
473
|
-
newBlobId: RawTransactionArgument<number[]>,
|
|
474
|
-
newCategory: RawTransactionArgument<number[]>,
|
|
475
|
-
newTopic: RawTransactionArgument<number[]>,
|
|
476
|
-
newImportance: RawTransactionArgument<number>,
|
|
477
|
-
newEmbeddingBlobId: RawTransactionArgument<number[]>,
|
|
478
|
-
newContentHash: RawTransactionArgument<number[]>,
|
|
479
|
-
newContentSize: RawTransactionArgument<number | bigint>
|
|
480
|
-
];
|
|
481
|
-
}
|
|
482
|
-
/**
|
|
483
|
-
* Update memory record with capability verification (V2)
|
|
484
|
-
*
|
|
485
|
-
* Same as update_memory_record but verifies the caller owns the associated
|
|
486
|
-
* MemoryCap. Use this for capability-based memories to ensure proper access
|
|
487
|
-
* control.
|
|
488
|
-
*
|
|
489
|
-
* @param cap: Reference to the MemoryCap (proves ownership) @param memory: Mutable
|
|
490
|
-
* reference to the Memory object @param new_blob_id: New Walrus blob ID (empty =
|
|
491
|
-
* no change) @param new_category: New category (empty = no change) @param
|
|
492
|
-
* new_topic: New topic (empty = no change) @param new_importance: New importance
|
|
493
|
-
* (0 = no change, 1-10 = update) @param new_embedding_blob_id: New embedding blob
|
|
494
|
-
* ID (empty = no change) @param new_content_hash: New content hash (empty = no
|
|
495
|
-
* change) @param new_content_size: New content size (0 = no change) @param ctx:
|
|
496
|
-
* Transaction context
|
|
497
|
-
*/
|
|
498
|
-
export function updateMemoryWithCap(options: UpdateMemoryWithCapOptions) {
|
|
499
|
-
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
500
|
-
const argumentsTypes = [
|
|
501
|
-
`${packageAddress}::capability::MemoryCap`,
|
|
502
|
-
`${packageAddress}::memory::Memory`,
|
|
503
|
-
'vector<u8>',
|
|
504
|
-
'vector<u8>',
|
|
505
|
-
'vector<u8>',
|
|
506
|
-
'u8',
|
|
507
|
-
'vector<u8>',
|
|
508
|
-
'vector<u8>',
|
|
509
|
-
'u64'
|
|
510
|
-
] satisfies string[];
|
|
511
|
-
const parameterNames = ["cap", "memory", "newBlobId", "newCategory", "newTopic", "newImportance", "newEmbeddingBlobId", "newContentHash", "newContentSize"];
|
|
512
|
-
return (tx: Transaction) => tx.moveCall({
|
|
513
|
-
package: packageAddress,
|
|
514
|
-
module: 'memory',
|
|
515
|
-
function: 'update_memory_with_cap',
|
|
516
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
517
|
-
});
|
|
518
|
-
}
|
|
519
|
-
export interface CreateMemoryRecordLightweightArguments {
|
|
520
|
-
category: RawTransactionArgument<number[]>;
|
|
521
|
-
vectorId: RawTransactionArgument<number | bigint>;
|
|
522
|
-
blobId: RawTransactionArgument<number[]>;
|
|
523
|
-
blobObjectId: RawTransactionArgument<number[]>;
|
|
524
|
-
importance: RawTransactionArgument<number>;
|
|
525
|
-
}
|
|
526
|
-
export interface CreateMemoryRecordLightweightOptions {
|
|
527
|
-
package?: string;
|
|
528
|
-
arguments: CreateMemoryRecordLightweightArguments | [
|
|
529
|
-
category: RawTransactionArgument<number[]>,
|
|
530
|
-
vectorId: RawTransactionArgument<number | bigint>,
|
|
531
|
-
blobId: RawTransactionArgument<number[]>,
|
|
532
|
-
blobObjectId: RawTransactionArgument<number[]>,
|
|
533
|
-
importance: RawTransactionArgument<number>
|
|
534
|
-
];
|
|
535
|
-
}
|
|
536
|
-
/**
|
|
537
|
-
* Create a lightweight memory record (for use with Walrus metadata) - LEGACY
|
|
538
|
-
*
|
|
539
|
-
* This function creates a minimal on-chain Memory struct with only essential
|
|
540
|
-
* queryable fields. Rich metadata should be stored as Walrus blob metadata.
|
|
541
|
-
*
|
|
542
|
-
* Use this when:
|
|
543
|
-
*
|
|
544
|
-
* - Gas costs are a concern
|
|
545
|
-
* - Rich metadata is stored on Walrus blob
|
|
546
|
-
* - Only need basic filtering (category, vector_id)
|
|
547
|
-
*
|
|
548
|
-
* NOTE: For new implementations, use create_memory_lightweight_with_cap() instead
|
|
549
|
-
*/
|
|
550
|
-
export function createMemoryRecordLightweight(options: CreateMemoryRecordLightweightOptions) {
|
|
551
|
-
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
552
|
-
const argumentsTypes = [
|
|
553
|
-
'vector<u8>',
|
|
554
|
-
'u64',
|
|
555
|
-
'vector<u8>',
|
|
556
|
-
'vector<u8>',
|
|
557
|
-
'u8'
|
|
558
|
-
] satisfies string[];
|
|
559
|
-
const parameterNames = ["category", "vectorId", "blobId", "blobObjectId", "importance"];
|
|
560
|
-
return (tx: Transaction) => tx.moveCall({
|
|
561
|
-
package: packageAddress,
|
|
562
|
-
module: 'memory',
|
|
563
|
-
function: 'create_memory_record_lightweight',
|
|
564
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
565
|
-
});
|
|
566
|
-
}
|
|
567
|
-
export interface CreateMemoryLightweightWithCapArguments {
|
|
568
|
-
cap: RawTransactionArgument<string>;
|
|
569
|
-
category: RawTransactionArgument<number[]>;
|
|
570
|
-
vectorId: RawTransactionArgument<number | bigint>;
|
|
571
|
-
blobId: RawTransactionArgument<number[]>;
|
|
572
|
-
blobObjectId: RawTransactionArgument<number[]>;
|
|
573
|
-
importance: RawTransactionArgument<number>;
|
|
574
|
-
}
|
|
575
|
-
export interface CreateMemoryLightweightWithCapOptions {
|
|
576
|
-
package?: string;
|
|
577
|
-
arguments: CreateMemoryLightweightWithCapArguments | [
|
|
578
|
-
cap: RawTransactionArgument<string>,
|
|
579
|
-
category: RawTransactionArgument<number[]>,
|
|
580
|
-
vectorId: RawTransactionArgument<number | bigint>,
|
|
581
|
-
blobId: RawTransactionArgument<number[]>,
|
|
582
|
-
blobObjectId: RawTransactionArgument<number[]>,
|
|
583
|
-
importance: RawTransactionArgument<number>
|
|
584
|
-
];
|
|
585
|
-
}
|
|
586
|
-
/**
|
|
587
|
-
* Create a lightweight memory record with capability-based access (V2 -
|
|
588
|
-
* RECOMMENDED)
|
|
589
|
-
*
|
|
590
|
-
* Gas-optimized version for capability-based access control.
|
|
591
|
-
*
|
|
592
|
-
* @param cap: Reference to the MemoryCap (proves ownership) @param category:
|
|
593
|
-
* Memory category @param vector_id: Links to HNSW index @param blob_id: Pointer to
|
|
594
|
-
* encrypted content on Walrus @param blob_object_id: Optional Walrus blob object
|
|
595
|
-
* ID @param importance: Importance scale (1-10) @param ctx: Transaction context
|
|
596
|
-
*/
|
|
597
|
-
export function createMemoryLightweightWithCap(options: CreateMemoryLightweightWithCapOptions) {
|
|
598
|
-
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
599
|
-
const argumentsTypes = [
|
|
600
|
-
`${packageAddress}::capability::MemoryCap`,
|
|
601
|
-
'vector<u8>',
|
|
602
|
-
'u64',
|
|
603
|
-
'vector<u8>',
|
|
604
|
-
'vector<u8>',
|
|
605
|
-
'u8'
|
|
606
|
-
] satisfies string[];
|
|
607
|
-
const parameterNames = ["cap", "category", "vectorId", "blobId", "blobObjectId", "importance"];
|
|
608
|
-
return (tx: Transaction) => tx.moveCall({
|
|
609
|
-
package: packageAddress,
|
|
610
|
-
module: 'memory',
|
|
611
|
-
function: 'create_memory_lightweight_with_cap',
|
|
612
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
613
|
-
});
|
|
614
|
-
}
|
|
615
|
-
export interface DeleteMemoryRecordArguments {
|
|
616
|
-
memory: RawTransactionArgument<string>;
|
|
617
|
-
}
|
|
618
|
-
export interface DeleteMemoryRecordOptions {
|
|
619
|
-
package?: string;
|
|
620
|
-
arguments: DeleteMemoryRecordArguments | [
|
|
621
|
-
memory: RawTransactionArgument<string>
|
|
622
|
-
];
|
|
623
|
-
}
|
|
624
|
-
/** Delete a memory record */
|
|
625
|
-
export function deleteMemoryRecord(options: DeleteMemoryRecordOptions) {
|
|
626
|
-
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
627
|
-
const argumentsTypes = [
|
|
628
|
-
`${packageAddress}::memory::Memory`
|
|
629
|
-
] satisfies string[];
|
|
630
|
-
const parameterNames = ["memory"];
|
|
631
|
-
return (tx: Transaction) => tx.moveCall({
|
|
632
|
-
package: packageAddress,
|
|
633
|
-
module: 'memory',
|
|
634
|
-
function: 'delete_memory_record',
|
|
635
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
636
|
-
});
|
|
637
|
-
}
|
|
638
|
-
export interface GetIndexBlobIdArguments {
|
|
639
|
-
memoryIndex: RawTransactionArgument<string>;
|
|
640
|
-
}
|
|
641
|
-
export interface GetIndexBlobIdOptions {
|
|
642
|
-
package?: string;
|
|
643
|
-
arguments: GetIndexBlobIdArguments | [
|
|
644
|
-
memoryIndex: RawTransactionArgument<string>
|
|
645
|
-
];
|
|
646
|
-
}
|
|
647
|
-
export function getIndexBlobId(options: GetIndexBlobIdOptions) {
|
|
648
|
-
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
649
|
-
const argumentsTypes = [
|
|
650
|
-
`${packageAddress}::memory::MemoryIndex`
|
|
651
|
-
] satisfies string[];
|
|
652
|
-
const parameterNames = ["memoryIndex"];
|
|
653
|
-
return (tx: Transaction) => tx.moveCall({
|
|
654
|
-
package: packageAddress,
|
|
655
|
-
module: 'memory',
|
|
656
|
-
function: 'get_index_blob_id',
|
|
657
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
658
|
-
});
|
|
659
|
-
}
|
|
660
|
-
export interface GetGraphBlobIdArguments {
|
|
661
|
-
memoryIndex: RawTransactionArgument<string>;
|
|
662
|
-
}
|
|
663
|
-
export interface GetGraphBlobIdOptions {
|
|
664
|
-
package?: string;
|
|
665
|
-
arguments: GetGraphBlobIdArguments | [
|
|
666
|
-
memoryIndex: RawTransactionArgument<string>
|
|
667
|
-
];
|
|
668
|
-
}
|
|
669
|
-
export function getGraphBlobId(options: GetGraphBlobIdOptions) {
|
|
670
|
-
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
671
|
-
const argumentsTypes = [
|
|
672
|
-
`${packageAddress}::memory::MemoryIndex`
|
|
673
|
-
] satisfies string[];
|
|
674
|
-
const parameterNames = ["memoryIndex"];
|
|
675
|
-
return (tx: Transaction) => tx.moveCall({
|
|
676
|
-
package: packageAddress,
|
|
677
|
-
module: 'memory',
|
|
678
|
-
function: 'get_graph_blob_id',
|
|
679
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
680
|
-
});
|
|
681
|
-
}
|
|
682
|
-
export interface GetVersionArguments {
|
|
683
|
-
memoryIndex: RawTransactionArgument<string>;
|
|
684
|
-
}
|
|
685
|
-
export interface GetVersionOptions {
|
|
686
|
-
package?: string;
|
|
687
|
-
arguments: GetVersionArguments | [
|
|
688
|
-
memoryIndex: RawTransactionArgument<string>
|
|
689
|
-
];
|
|
690
|
-
}
|
|
691
|
-
export function getVersion(options: GetVersionOptions) {
|
|
692
|
-
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
693
|
-
const argumentsTypes = [
|
|
694
|
-
`${packageAddress}::memory::MemoryIndex`
|
|
695
|
-
] satisfies string[];
|
|
696
|
-
const parameterNames = ["memoryIndex"];
|
|
697
|
-
return (tx: Transaction) => tx.moveCall({
|
|
698
|
-
package: packageAddress,
|
|
699
|
-
module: 'memory',
|
|
700
|
-
function: 'get_version',
|
|
701
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
702
|
-
});
|
|
703
|
-
}
|
|
704
|
-
export interface GetMemoryBlobIdArguments {
|
|
705
|
-
memory: RawTransactionArgument<string>;
|
|
706
|
-
}
|
|
707
|
-
export interface GetMemoryBlobIdOptions {
|
|
708
|
-
package?: string;
|
|
709
|
-
arguments: GetMemoryBlobIdArguments | [
|
|
710
|
-
memory: RawTransactionArgument<string>
|
|
711
|
-
];
|
|
712
|
-
}
|
|
713
|
-
export function getMemoryBlobId(options: GetMemoryBlobIdOptions) {
|
|
714
|
-
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
715
|
-
const argumentsTypes = [
|
|
716
|
-
`${packageAddress}::memory::Memory`
|
|
717
|
-
] satisfies string[];
|
|
718
|
-
const parameterNames = ["memory"];
|
|
719
|
-
return (tx: Transaction) => tx.moveCall({
|
|
720
|
-
package: packageAddress,
|
|
721
|
-
module: 'memory',
|
|
722
|
-
function: 'get_memory_blob_id',
|
|
723
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
724
|
-
});
|
|
725
|
-
}
|
|
726
|
-
export interface GetMemoryVectorIdArguments {
|
|
727
|
-
memory: RawTransactionArgument<string>;
|
|
728
|
-
}
|
|
729
|
-
export interface GetMemoryVectorIdOptions {
|
|
730
|
-
package?: string;
|
|
731
|
-
arguments: GetMemoryVectorIdArguments | [
|
|
732
|
-
memory: RawTransactionArgument<string>
|
|
733
|
-
];
|
|
734
|
-
}
|
|
735
|
-
export function getMemoryVectorId(options: GetMemoryVectorIdOptions) {
|
|
736
|
-
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
737
|
-
const argumentsTypes = [
|
|
738
|
-
`${packageAddress}::memory::Memory`
|
|
739
|
-
] satisfies string[];
|
|
740
|
-
const parameterNames = ["memory"];
|
|
741
|
-
return (tx: Transaction) => tx.moveCall({
|
|
742
|
-
package: packageAddress,
|
|
743
|
-
module: 'memory',
|
|
744
|
-
function: 'get_memory_vector_id',
|
|
745
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
746
|
-
});
|
|
747
|
-
}
|
|
748
|
-
export interface GetMemoryCategoryArguments {
|
|
749
|
-
memory: RawTransactionArgument<string>;
|
|
750
|
-
}
|
|
751
|
-
export interface GetMemoryCategoryOptions {
|
|
752
|
-
package?: string;
|
|
753
|
-
arguments: GetMemoryCategoryArguments | [
|
|
754
|
-
memory: RawTransactionArgument<string>
|
|
755
|
-
];
|
|
756
|
-
}
|
|
757
|
-
export function getMemoryCategory(options: GetMemoryCategoryOptions) {
|
|
758
|
-
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
759
|
-
const argumentsTypes = [
|
|
760
|
-
`${packageAddress}::memory::Memory`
|
|
761
|
-
] satisfies string[];
|
|
762
|
-
const parameterNames = ["memory"];
|
|
763
|
-
return (tx: Transaction) => tx.moveCall({
|
|
764
|
-
package: packageAddress,
|
|
765
|
-
module: 'memory',
|
|
766
|
-
function: 'get_memory_category',
|
|
767
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
768
|
-
});
|
|
769
|
-
}
|
|
770
|
-
export interface GetMetadataArguments {
|
|
771
|
-
memory: RawTransactionArgument<string>;
|
|
772
|
-
}
|
|
773
|
-
export interface GetMetadataOptions {
|
|
774
|
-
package?: string;
|
|
775
|
-
arguments: GetMetadataArguments | [
|
|
776
|
-
memory: RawTransactionArgument<string>
|
|
777
|
-
];
|
|
778
|
-
}
|
|
779
|
-
export function getMetadata(options: GetMetadataOptions) {
|
|
780
|
-
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
781
|
-
const argumentsTypes = [
|
|
782
|
-
`${packageAddress}::memory::Memory`
|
|
783
|
-
] satisfies string[];
|
|
784
|
-
const parameterNames = ["memory"];
|
|
785
|
-
return (tx: Transaction) => tx.moveCall({
|
|
786
|
-
package: packageAddress,
|
|
787
|
-
module: 'memory',
|
|
788
|
-
function: 'get_metadata',
|
|
789
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
790
|
-
});
|
|
791
|
-
}
|
|
792
|
-
export interface GetEmbeddingBlobIdArguments {
|
|
793
|
-
metadata: RawTransactionArgument<string>;
|
|
794
|
-
}
|
|
795
|
-
export interface GetEmbeddingBlobIdOptions {
|
|
796
|
-
package?: string;
|
|
797
|
-
arguments: GetEmbeddingBlobIdArguments | [
|
|
798
|
-
metadata: RawTransactionArgument<string>
|
|
799
|
-
];
|
|
800
|
-
}
|
|
801
|
-
export function getEmbeddingBlobId(options: GetEmbeddingBlobIdOptions) {
|
|
802
|
-
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
803
|
-
const argumentsTypes = [
|
|
804
|
-
`${packageAddress}::memory::MemoryMetadata`
|
|
805
|
-
] satisfies string[];
|
|
806
|
-
const parameterNames = ["metadata"];
|
|
807
|
-
return (tx: Transaction) => tx.moveCall({
|
|
808
|
-
package: packageAddress,
|
|
809
|
-
module: 'memory',
|
|
810
|
-
function: 'get_embedding_blob_id',
|
|
811
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
812
|
-
});
|
|
813
|
-
}
|
|
814
|
-
export interface GetContentTypeArguments {
|
|
815
|
-
metadata: RawTransactionArgument<string>;
|
|
816
|
-
}
|
|
817
|
-
export interface GetContentTypeOptions {
|
|
818
|
-
package?: string;
|
|
819
|
-
arguments: GetContentTypeArguments | [
|
|
820
|
-
metadata: RawTransactionArgument<string>
|
|
821
|
-
];
|
|
822
|
-
}
|
|
823
|
-
export function getContentType(options: GetContentTypeOptions) {
|
|
824
|
-
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
825
|
-
const argumentsTypes = [
|
|
826
|
-
`${packageAddress}::memory::MemoryMetadata`
|
|
827
|
-
] satisfies string[];
|
|
828
|
-
const parameterNames = ["metadata"];
|
|
829
|
-
return (tx: Transaction) => tx.moveCall({
|
|
830
|
-
package: packageAddress,
|
|
831
|
-
module: 'memory',
|
|
832
|
-
function: 'get_content_type',
|
|
833
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
834
|
-
});
|
|
835
|
-
}
|
|
836
|
-
export interface GetContentSizeArguments {
|
|
837
|
-
metadata: RawTransactionArgument<string>;
|
|
838
|
-
}
|
|
839
|
-
export interface GetContentSizeOptions {
|
|
840
|
-
package?: string;
|
|
841
|
-
arguments: GetContentSizeArguments | [
|
|
842
|
-
metadata: RawTransactionArgument<string>
|
|
843
|
-
];
|
|
844
|
-
}
|
|
845
|
-
export function getContentSize(options: GetContentSizeOptions) {
|
|
846
|
-
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
847
|
-
const argumentsTypes = [
|
|
848
|
-
`${packageAddress}::memory::MemoryMetadata`
|
|
849
|
-
] satisfies string[];
|
|
850
|
-
const parameterNames = ["metadata"];
|
|
851
|
-
return (tx: Transaction) => tx.moveCall({
|
|
852
|
-
package: packageAddress,
|
|
853
|
-
module: 'memory',
|
|
854
|
-
function: 'get_content_size',
|
|
855
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
856
|
-
});
|
|
857
|
-
}
|
|
858
|
-
export interface GetTopicArguments {
|
|
859
|
-
metadata: RawTransactionArgument<string>;
|
|
860
|
-
}
|
|
861
|
-
export interface GetTopicOptions {
|
|
862
|
-
package?: string;
|
|
863
|
-
arguments: GetTopicArguments | [
|
|
864
|
-
metadata: RawTransactionArgument<string>
|
|
865
|
-
];
|
|
866
|
-
}
|
|
867
|
-
export function getTopic(options: GetTopicOptions) {
|
|
868
|
-
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
869
|
-
const argumentsTypes = [
|
|
870
|
-
`${packageAddress}::memory::MemoryMetadata`
|
|
871
|
-
] satisfies string[];
|
|
872
|
-
const parameterNames = ["metadata"];
|
|
873
|
-
return (tx: Transaction) => tx.moveCall({
|
|
874
|
-
package: packageAddress,
|
|
875
|
-
module: 'memory',
|
|
876
|
-
function: 'get_topic',
|
|
877
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
878
|
-
});
|
|
879
|
-
}
|
|
880
|
-
export interface GetImportanceArguments {
|
|
881
|
-
metadata: RawTransactionArgument<string>;
|
|
882
|
-
}
|
|
883
|
-
export interface GetImportanceOptions {
|
|
884
|
-
package?: string;
|
|
885
|
-
arguments: GetImportanceArguments | [
|
|
886
|
-
metadata: RawTransactionArgument<string>
|
|
887
|
-
];
|
|
888
|
-
}
|
|
889
|
-
export function getImportance(options: GetImportanceOptions) {
|
|
890
|
-
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
891
|
-
const argumentsTypes = [
|
|
892
|
-
`${packageAddress}::memory::MemoryMetadata`
|
|
893
|
-
] satisfies string[];
|
|
894
|
-
const parameterNames = ["metadata"];
|
|
895
|
-
return (tx: Transaction) => tx.moveCall({
|
|
896
|
-
package: packageAddress,
|
|
897
|
-
module: 'memory',
|
|
898
|
-
function: 'get_importance',
|
|
899
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
900
|
-
});
|
|
901
|
-
}
|
|
902
|
-
export interface GetCreatedTimestampArguments {
|
|
903
|
-
metadata: RawTransactionArgument<string>;
|
|
904
|
-
}
|
|
905
|
-
export interface GetCreatedTimestampOptions {
|
|
906
|
-
package?: string;
|
|
907
|
-
arguments: GetCreatedTimestampArguments | [
|
|
908
|
-
metadata: RawTransactionArgument<string>
|
|
909
|
-
];
|
|
910
|
-
}
|
|
911
|
-
export function getCreatedTimestamp(options: GetCreatedTimestampOptions) {
|
|
912
|
-
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
913
|
-
const argumentsTypes = [
|
|
914
|
-
`${packageAddress}::memory::MemoryMetadata`
|
|
915
|
-
] satisfies string[];
|
|
916
|
-
const parameterNames = ["metadata"];
|
|
917
|
-
return (tx: Transaction) => tx.moveCall({
|
|
918
|
-
package: packageAddress,
|
|
919
|
-
module: 'memory',
|
|
920
|
-
function: 'get_created_timestamp',
|
|
921
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
922
|
-
});
|
|
923
|
-
}
|
|
924
|
-
export interface GetUpdatedTimestampArguments {
|
|
925
|
-
metadata: RawTransactionArgument<string>;
|
|
926
|
-
}
|
|
927
|
-
export interface GetUpdatedTimestampOptions {
|
|
928
|
-
package?: string;
|
|
929
|
-
arguments: GetUpdatedTimestampArguments | [
|
|
930
|
-
metadata: RawTransactionArgument<string>
|
|
931
|
-
];
|
|
932
|
-
}
|
|
933
|
-
export function getUpdatedTimestamp(options: GetUpdatedTimestampOptions) {
|
|
934
|
-
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
935
|
-
const argumentsTypes = [
|
|
936
|
-
`${packageAddress}::memory::MemoryMetadata`
|
|
937
|
-
] satisfies string[];
|
|
938
|
-
const parameterNames = ["metadata"];
|
|
939
|
-
return (tx: Transaction) => tx.moveCall({
|
|
940
|
-
package: packageAddress,
|
|
941
|
-
module: 'memory',
|
|
942
|
-
function: 'get_updated_timestamp',
|
|
943
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
944
|
-
});
|
|
945
|
-
}
|
|
946
|
-
export interface GetCustomMetadataArguments {
|
|
947
|
-
metadata: RawTransactionArgument<string>;
|
|
948
|
-
}
|
|
949
|
-
export interface GetCustomMetadataOptions {
|
|
950
|
-
package?: string;
|
|
951
|
-
arguments: GetCustomMetadataArguments | [
|
|
952
|
-
metadata: RawTransactionArgument<string>
|
|
953
|
-
];
|
|
954
|
-
}
|
|
955
|
-
export function getCustomMetadata(options: GetCustomMetadataOptions) {
|
|
956
|
-
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
957
|
-
const argumentsTypes = [
|
|
958
|
-
`${packageAddress}::memory::MemoryMetadata`
|
|
959
|
-
] satisfies string[];
|
|
960
|
-
const parameterNames = ["metadata"];
|
|
961
|
-
return (tx: Transaction) => tx.moveCall({
|
|
962
|
-
package: packageAddress,
|
|
963
|
-
module: 'memory',
|
|
964
|
-
function: 'get_custom_metadata',
|
|
965
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
966
|
-
});
|
|
967
|
-
}
|
|
968
|
-
export interface GetCapabilityIdArguments {
|
|
969
|
-
memory: RawTransactionArgument<string>;
|
|
970
|
-
}
|
|
971
|
-
export interface GetCapabilityIdOptions {
|
|
972
|
-
package?: string;
|
|
973
|
-
arguments: GetCapabilityIdArguments | [
|
|
974
|
-
memory: RawTransactionArgument<string>
|
|
975
|
-
];
|
|
976
|
-
}
|
|
977
|
-
/** Get the capability_id from a memory (if linked to a MemoryCap) */
|
|
978
|
-
export function getCapabilityId(options: GetCapabilityIdOptions) {
|
|
979
|
-
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
980
|
-
const argumentsTypes = [
|
|
981
|
-
`${packageAddress}::memory::Memory`
|
|
982
|
-
] satisfies string[];
|
|
983
|
-
const parameterNames = ["memory"];
|
|
984
|
-
return (tx: Transaction) => tx.moveCall({
|
|
985
|
-
package: packageAddress,
|
|
986
|
-
module: 'memory',
|
|
987
|
-
function: 'get_capability_id',
|
|
988
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
989
|
-
});
|
|
990
|
-
}
|
|
991
|
-
export interface HasCapabilityArguments {
|
|
992
|
-
memory: RawTransactionArgument<string>;
|
|
993
|
-
}
|
|
994
|
-
export interface HasCapabilityOptions {
|
|
995
|
-
package?: string;
|
|
996
|
-
arguments: HasCapabilityArguments | [
|
|
997
|
-
memory: RawTransactionArgument<string>
|
|
998
|
-
];
|
|
999
|
-
}
|
|
1000
|
-
/** Check if memory is linked to a capability (V2) */
|
|
1001
|
-
export function hasCapability(options: HasCapabilityOptions) {
|
|
1002
|
-
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
1003
|
-
const argumentsTypes = [
|
|
1004
|
-
`${packageAddress}::memory::Memory`
|
|
1005
|
-
] satisfies string[];
|
|
1006
|
-
const parameterNames = ["memory"];
|
|
1007
|
-
return (tx: Transaction) => tx.moveCall({
|
|
1008
|
-
package: packageAddress,
|
|
1009
|
-
module: 'memory',
|
|
1010
|
-
function: 'has_capability',
|
|
1011
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1012
|
-
});
|
|
1013
|
-
}
|
|
1014
|
-
export interface IsLegacyAccessArguments {
|
|
1015
|
-
memory: RawTransactionArgument<string>;
|
|
1016
|
-
}
|
|
1017
|
-
export interface IsLegacyAccessOptions {
|
|
1018
|
-
package?: string;
|
|
1019
|
-
arguments: IsLegacyAccessArguments | [
|
|
1020
|
-
memory: RawTransactionArgument<string>
|
|
1021
|
-
];
|
|
1022
|
-
}
|
|
1023
|
-
/** Check if memory is using legacy owner-based access */
|
|
1024
|
-
export function isLegacyAccess(options: IsLegacyAccessOptions) {
|
|
1025
|
-
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
1026
|
-
const argumentsTypes = [
|
|
1027
|
-
`${packageAddress}::memory::Memory`
|
|
1028
|
-
] satisfies string[];
|
|
1029
|
-
const parameterNames = ["memory"];
|
|
1030
|
-
return (tx: Transaction) => tx.moveCall({
|
|
1031
|
-
package: packageAddress,
|
|
1032
|
-
module: 'memory',
|
|
1033
|
-
function: 'is_legacy_access',
|
|
1034
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1035
|
-
});
|
|
1036
|
-
}
|
|
1037
|
-
export interface GetAppIdArguments {
|
|
1038
|
-
memory: RawTransactionArgument<string>;
|
|
1039
|
-
}
|
|
1040
|
-
export interface GetAppIdOptions {
|
|
1041
|
-
package?: string;
|
|
1042
|
-
arguments: GetAppIdArguments | [
|
|
1043
|
-
memory: RawTransactionArgument<string>
|
|
1044
|
-
];
|
|
1045
|
-
}
|
|
1046
|
-
/**
|
|
1047
|
-
* Get the app_id from a memory (for context-based querying) Returns None for
|
|
1048
|
-
* legacy memories without capability
|
|
1049
|
-
*/
|
|
1050
|
-
export function getAppId(options: GetAppIdOptions) {
|
|
1051
|
-
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
1052
|
-
const argumentsTypes = [
|
|
1053
|
-
`${packageAddress}::memory::Memory`
|
|
1054
|
-
] satisfies string[];
|
|
1055
|
-
const parameterNames = ["memory"];
|
|
1056
|
-
return (tx: Transaction) => tx.moveCall({
|
|
1057
|
-
package: packageAddress,
|
|
1058
|
-
module: 'memory',
|
|
1059
|
-
function: 'get_app_id',
|
|
1060
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1061
|
-
});
|
|
1062
|
-
}
|
|
1063
|
-
export interface IsAppContextArguments {
|
|
1064
|
-
memory: RawTransactionArgument<string>;
|
|
1065
|
-
appId: RawTransactionArgument<string>;
|
|
1066
|
-
}
|
|
1067
|
-
export interface IsAppContextOptions {
|
|
1068
|
-
package?: string;
|
|
1069
|
-
arguments: IsAppContextArguments | [
|
|
1070
|
-
memory: RawTransactionArgument<string>,
|
|
1071
|
-
appId: RawTransactionArgument<string>
|
|
1072
|
-
];
|
|
1073
|
-
}
|
|
1074
|
-
/** Check if memory belongs to a specific app context */
|
|
1075
|
-
export function isAppContext(options: IsAppContextOptions) {
|
|
1076
|
-
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
1077
|
-
const argumentsTypes = [
|
|
1078
|
-
`${packageAddress}::memory::Memory`,
|
|
1079
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001::string::String'
|
|
1080
|
-
] satisfies string[];
|
|
1081
|
-
const parameterNames = ["memory", "appId"];
|
|
1082
|
-
return (tx: Transaction) => tx.moveCall({
|
|
1083
|
-
package: packageAddress,
|
|
1084
|
-
module: 'memory',
|
|
1085
|
-
function: 'is_app_context',
|
|
1086
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1087
|
-
});
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Memory management module for Personal Data Wallet
|
|
8
|
+
*
|
|
9
|
+
* This module provides memory record management with:
|
|
10
|
+
*
|
|
11
|
+
* - Rich metadata for encrypted content stored on Walrus
|
|
12
|
+
* - Support for both capability-based and legacy address-based access
|
|
13
|
+
* - Vector embedding storage for semantic search
|
|
14
|
+
* - Knowledge graph integration
|
|
15
|
+
*
|
|
16
|
+
* V2 Changes (Capability-based):
|
|
17
|
+
*
|
|
18
|
+
* - Added capability_id field to link memories to MemoryCap
|
|
19
|
+
* - New create_memory_with_cap() for capability-based creation
|
|
20
|
+
* - Maintains backward compatibility with existing functions
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';
|
|
24
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
25
|
+
import { type Transaction } from '@mysten/sui/transactions';
|
|
26
|
+
import * as vec_map from './deps/sui/vec_map.js';
|
|
27
|
+
import * as object from './deps/sui/object.js';
|
|
28
|
+
const $moduleName = '@local-pkg/pdw::memory';
|
|
29
|
+
export const MemoryCreated = new MoveStruct({ name: `${$moduleName}::MemoryCreated`, fields: {
|
|
30
|
+
id: bcs.Address,
|
|
31
|
+
owner: bcs.Address,
|
|
32
|
+
category: bcs.string(),
|
|
33
|
+
vector_id: bcs.u64(),
|
|
34
|
+
/** V2: Link to MemoryCap object ID */
|
|
35
|
+
capability_id: bcs.option(bcs.Address),
|
|
36
|
+
/**
|
|
37
|
+
* V2: App context for filtering (e.g., "MEMO", "HEALTH")
|
|
38
|
+
*
|
|
39
|
+
* - Query all: no filter
|
|
40
|
+
* - Query by context: filter by app_id
|
|
41
|
+
*/
|
|
42
|
+
app_id: bcs.option(bcs.string())
|
|
43
|
+
} });
|
|
44
|
+
export const MemoryIndexUpdated = new MoveStruct({ name: `${$moduleName}::MemoryIndexUpdated`, fields: {
|
|
45
|
+
id: bcs.Address,
|
|
46
|
+
owner: bcs.Address,
|
|
47
|
+
version: bcs.u64(),
|
|
48
|
+
index_blob_id: bcs.string(),
|
|
49
|
+
graph_blob_id: bcs.string()
|
|
50
|
+
} });
|
|
51
|
+
export const MemoryMetadataUpdated = new MoveStruct({ name: `${$moduleName}::MemoryMetadataUpdated`, fields: {
|
|
52
|
+
memory_id: bcs.Address,
|
|
53
|
+
metadata_blob_id: bcs.string(),
|
|
54
|
+
embedding_dimension: bcs.u64()
|
|
55
|
+
} });
|
|
56
|
+
export const MemoryUpdated = new MoveStruct({ name: `${$moduleName}::MemoryUpdated`, fields: {
|
|
57
|
+
id: bcs.Address,
|
|
58
|
+
owner: bcs.Address,
|
|
59
|
+
/**
|
|
60
|
+
* Fields that were updated (bitmask: 1=blob_id, 2=category, 4=topic, 8=importance,
|
|
61
|
+
* 16=embedding)
|
|
62
|
+
*/
|
|
63
|
+
updated_fields: bcs.u8(),
|
|
64
|
+
new_blob_id: bcs.option(bcs.string()),
|
|
65
|
+
new_category: bcs.option(bcs.string()),
|
|
66
|
+
updated_at: bcs.u64()
|
|
67
|
+
} });
|
|
68
|
+
export const MemoryMetadata = new MoveStruct({ name: `${$moduleName}::MemoryMetadata`, fields: {
|
|
69
|
+
content_type: bcs.string(),
|
|
70
|
+
content_size: bcs.u64(),
|
|
71
|
+
content_hash: bcs.string(),
|
|
72
|
+
category: bcs.string(),
|
|
73
|
+
topic: bcs.string(),
|
|
74
|
+
importance: bcs.u8(),
|
|
75
|
+
embedding_blob_id: bcs.string(),
|
|
76
|
+
embedding_dimension: bcs.u64(),
|
|
77
|
+
created_timestamp: bcs.u64(),
|
|
78
|
+
updated_timestamp: bcs.u64(),
|
|
79
|
+
custom_metadata: vec_map.VecMap(bcs.string(), bcs.string())
|
|
80
|
+
} });
|
|
81
|
+
export const MemoryIndex = new MoveStruct({ name: `${$moduleName}::MemoryIndex`, fields: {
|
|
82
|
+
id: object.UID,
|
|
83
|
+
owner: bcs.Address,
|
|
84
|
+
version: bcs.u64(),
|
|
85
|
+
index_blob_id: bcs.string(),
|
|
86
|
+
graph_blob_id: bcs.string()
|
|
87
|
+
} });
|
|
88
|
+
export const Memory = new MoveStruct({ name: `${$moduleName}::Memory`, fields: {
|
|
89
|
+
id: object.UID,
|
|
90
|
+
owner: bcs.Address,
|
|
91
|
+
category: bcs.string(),
|
|
92
|
+
vector_id: bcs.u64(),
|
|
93
|
+
blob_id: bcs.string(),
|
|
94
|
+
metadata: MemoryMetadata,
|
|
95
|
+
/**
|
|
96
|
+
* V2: Link to MemoryCap for capability-based access control If set, access is
|
|
97
|
+
* controlled via MemoryCap ownership If none, falls back to owner-based access
|
|
98
|
+
* (legacy)
|
|
99
|
+
*/
|
|
100
|
+
capability_id: bcs.option(bcs.Address),
|
|
101
|
+
/**
|
|
102
|
+
* V2: App context for context-based querying Copied from MemoryCap.app_id for
|
|
103
|
+
* efficient filtering
|
|
104
|
+
*
|
|
105
|
+
* - Query all memories: getOwnedObjects without filter
|
|
106
|
+
* - Query by context: filter by app_id field
|
|
107
|
+
*/
|
|
108
|
+
app_id: bcs.option(bcs.string())
|
|
109
|
+
} });
|
|
110
|
+
export interface CreateMemoryIndexArguments {
|
|
111
|
+
indexBlobId: RawTransactionArgument<number[]>;
|
|
112
|
+
graphBlobId: RawTransactionArgument<number[]>;
|
|
113
|
+
}
|
|
114
|
+
export interface CreateMemoryIndexOptions {
|
|
115
|
+
package?: string;
|
|
116
|
+
arguments: CreateMemoryIndexArguments | [
|
|
117
|
+
indexBlobId: RawTransactionArgument<number[]>,
|
|
118
|
+
graphBlobId: RawTransactionArgument<number[]>
|
|
119
|
+
];
|
|
120
|
+
}
|
|
121
|
+
/** Create a new memory index for a user */
|
|
122
|
+
export function createMemoryIndex(options: CreateMemoryIndexOptions) {
|
|
123
|
+
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
124
|
+
const argumentsTypes = [
|
|
125
|
+
'vector<u8>',
|
|
126
|
+
'vector<u8>'
|
|
127
|
+
] satisfies string[];
|
|
128
|
+
const parameterNames = ["indexBlobId", "graphBlobId"];
|
|
129
|
+
return (tx: Transaction) => tx.moveCall({
|
|
130
|
+
package: packageAddress,
|
|
131
|
+
module: 'memory',
|
|
132
|
+
function: 'create_memory_index',
|
|
133
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
export interface UpdateMemoryIndexArguments {
|
|
137
|
+
memoryIndex: RawTransactionArgument<string>;
|
|
138
|
+
expectedVersion: RawTransactionArgument<number | bigint>;
|
|
139
|
+
newIndexBlobId: RawTransactionArgument<number[]>;
|
|
140
|
+
newGraphBlobId: RawTransactionArgument<number[]>;
|
|
141
|
+
}
|
|
142
|
+
export interface UpdateMemoryIndexOptions {
|
|
143
|
+
package?: string;
|
|
144
|
+
arguments: UpdateMemoryIndexArguments | [
|
|
145
|
+
memoryIndex: RawTransactionArgument<string>,
|
|
146
|
+
expectedVersion: RawTransactionArgument<number | bigint>,
|
|
147
|
+
newIndexBlobId: RawTransactionArgument<number[]>,
|
|
148
|
+
newGraphBlobId: RawTransactionArgument<number[]>
|
|
149
|
+
];
|
|
150
|
+
}
|
|
151
|
+
/** Update an existing memory index with new blob IDs */
|
|
152
|
+
export function updateMemoryIndex(options: UpdateMemoryIndexOptions) {
|
|
153
|
+
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
154
|
+
const argumentsTypes = [
|
|
155
|
+
`${packageAddress}::memory::MemoryIndex`,
|
|
156
|
+
'u64',
|
|
157
|
+
'vector<u8>',
|
|
158
|
+
'vector<u8>'
|
|
159
|
+
] satisfies string[];
|
|
160
|
+
const parameterNames = ["memoryIndex", "expectedVersion", "newIndexBlobId", "newGraphBlobId"];
|
|
161
|
+
return (tx: Transaction) => tx.moveCall({
|
|
162
|
+
package: packageAddress,
|
|
163
|
+
module: 'memory',
|
|
164
|
+
function: 'update_memory_index',
|
|
165
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
export interface CreateMemoryMetadataArguments {
|
|
169
|
+
contentType: RawTransactionArgument<number[]>;
|
|
170
|
+
contentSize: RawTransactionArgument<number | bigint>;
|
|
171
|
+
contentHash: RawTransactionArgument<number[]>;
|
|
172
|
+
category: RawTransactionArgument<number[]>;
|
|
173
|
+
topic: RawTransactionArgument<number[]>;
|
|
174
|
+
importance: RawTransactionArgument<number>;
|
|
175
|
+
embeddingBlobId: RawTransactionArgument<number[]>;
|
|
176
|
+
embeddingDimension: RawTransactionArgument<number | bigint>;
|
|
177
|
+
createdTimestamp: RawTransactionArgument<number | bigint>;
|
|
178
|
+
}
|
|
179
|
+
export interface CreateMemoryMetadataOptions {
|
|
180
|
+
package?: string;
|
|
181
|
+
arguments: CreateMemoryMetadataArguments | [
|
|
182
|
+
contentType: RawTransactionArgument<number[]>,
|
|
183
|
+
contentSize: RawTransactionArgument<number | bigint>,
|
|
184
|
+
contentHash: RawTransactionArgument<number[]>,
|
|
185
|
+
category: RawTransactionArgument<number[]>,
|
|
186
|
+
topic: RawTransactionArgument<number[]>,
|
|
187
|
+
importance: RawTransactionArgument<number>,
|
|
188
|
+
embeddingBlobId: RawTransactionArgument<number[]>,
|
|
189
|
+
embeddingDimension: RawTransactionArgument<number | bigint>,
|
|
190
|
+
createdTimestamp: RawTransactionArgument<number | bigint>
|
|
191
|
+
];
|
|
192
|
+
}
|
|
193
|
+
/** Create metadata struct with embedding */
|
|
194
|
+
export function createMemoryMetadata(options: CreateMemoryMetadataOptions) {
|
|
195
|
+
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
196
|
+
const argumentsTypes = [
|
|
197
|
+
'vector<u8>',
|
|
198
|
+
'u64',
|
|
199
|
+
'vector<u8>',
|
|
200
|
+
'vector<u8>',
|
|
201
|
+
'vector<u8>',
|
|
202
|
+
'u8',
|
|
203
|
+
'vector<u8>',
|
|
204
|
+
'u64',
|
|
205
|
+
'u64'
|
|
206
|
+
] satisfies string[];
|
|
207
|
+
const parameterNames = ["contentType", "contentSize", "contentHash", "category", "topic", "importance", "embeddingBlobId", "embeddingDimension", "createdTimestamp"];
|
|
208
|
+
return (tx: Transaction) => tx.moveCall({
|
|
209
|
+
package: packageAddress,
|
|
210
|
+
module: 'memory',
|
|
211
|
+
function: 'create_memory_metadata',
|
|
212
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
export interface CreateMemoryRecordArguments {
|
|
216
|
+
category: RawTransactionArgument<number[]>;
|
|
217
|
+
vectorId: RawTransactionArgument<number | bigint>;
|
|
218
|
+
blobId: RawTransactionArgument<number[]>;
|
|
219
|
+
contentType: RawTransactionArgument<number[]>;
|
|
220
|
+
contentSize: RawTransactionArgument<number | bigint>;
|
|
221
|
+
contentHash: RawTransactionArgument<number[]>;
|
|
222
|
+
topic: RawTransactionArgument<number[]>;
|
|
223
|
+
importance: RawTransactionArgument<number>;
|
|
224
|
+
embeddingBlobId: RawTransactionArgument<number[]>;
|
|
225
|
+
}
|
|
226
|
+
export interface CreateMemoryRecordOptions {
|
|
227
|
+
package?: string;
|
|
228
|
+
arguments: CreateMemoryRecordArguments | [
|
|
229
|
+
category: RawTransactionArgument<number[]>,
|
|
230
|
+
vectorId: RawTransactionArgument<number | bigint>,
|
|
231
|
+
blobId: RawTransactionArgument<number[]>,
|
|
232
|
+
contentType: RawTransactionArgument<number[]>,
|
|
233
|
+
contentSize: RawTransactionArgument<number | bigint>,
|
|
234
|
+
contentHash: RawTransactionArgument<number[]>,
|
|
235
|
+
topic: RawTransactionArgument<number[]>,
|
|
236
|
+
importance: RawTransactionArgument<number>,
|
|
237
|
+
embeddingBlobId: RawTransactionArgument<number[]>
|
|
238
|
+
];
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Create a new memory record with rich metadata (LEGACY - for backward
|
|
242
|
+
* compatibility)
|
|
243
|
+
*
|
|
244
|
+
* NOTE: For new implementations, use create_memory_with_cap() instead which
|
|
245
|
+
* provides capability-based access control.
|
|
246
|
+
*/
|
|
247
|
+
export function createMemoryRecord(options: CreateMemoryRecordOptions) {
|
|
248
|
+
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
249
|
+
const argumentsTypes = [
|
|
250
|
+
'vector<u8>',
|
|
251
|
+
'u64',
|
|
252
|
+
'vector<u8>',
|
|
253
|
+
'vector<u8>',
|
|
254
|
+
'u64',
|
|
255
|
+
'vector<u8>',
|
|
256
|
+
'vector<u8>',
|
|
257
|
+
'u8',
|
|
258
|
+
'vector<u8>'
|
|
259
|
+
] satisfies string[];
|
|
260
|
+
const parameterNames = ["category", "vectorId", "blobId", "contentType", "contentSize", "contentHash", "topic", "importance", "embeddingBlobId"];
|
|
261
|
+
return (tx: Transaction) => tx.moveCall({
|
|
262
|
+
package: packageAddress,
|
|
263
|
+
module: 'memory',
|
|
264
|
+
function: 'create_memory_record',
|
|
265
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
export interface CreateMemoryWithCapArguments {
|
|
269
|
+
cap: RawTransactionArgument<string>;
|
|
270
|
+
category: RawTransactionArgument<number[]>;
|
|
271
|
+
vectorId: RawTransactionArgument<number | bigint>;
|
|
272
|
+
blobId: RawTransactionArgument<number[]>;
|
|
273
|
+
contentType: RawTransactionArgument<number[]>;
|
|
274
|
+
contentSize: RawTransactionArgument<number | bigint>;
|
|
275
|
+
contentHash: RawTransactionArgument<number[]>;
|
|
276
|
+
topic: RawTransactionArgument<number[]>;
|
|
277
|
+
importance: RawTransactionArgument<number>;
|
|
278
|
+
embeddingBlobId: RawTransactionArgument<number[]>;
|
|
279
|
+
}
|
|
280
|
+
export interface CreateMemoryWithCapOptions {
|
|
281
|
+
package?: string;
|
|
282
|
+
arguments: CreateMemoryWithCapArguments | [
|
|
283
|
+
cap: RawTransactionArgument<string>,
|
|
284
|
+
category: RawTransactionArgument<number[]>,
|
|
285
|
+
vectorId: RawTransactionArgument<number | bigint>,
|
|
286
|
+
blobId: RawTransactionArgument<number[]>,
|
|
287
|
+
contentType: RawTransactionArgument<number[]>,
|
|
288
|
+
contentSize: RawTransactionArgument<number | bigint>,
|
|
289
|
+
contentHash: RawTransactionArgument<number[]>,
|
|
290
|
+
topic: RawTransactionArgument<number[]>,
|
|
291
|
+
importance: RawTransactionArgument<number>,
|
|
292
|
+
embeddingBlobId: RawTransactionArgument<number[]>
|
|
293
|
+
];
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Create a new memory record with capability-based access control (V2 -
|
|
297
|
+
* RECOMMENDED)
|
|
298
|
+
*
|
|
299
|
+
* This function links the memory to a MemoryCap for SEAL-compliant access control.
|
|
300
|
+
* Benefits:
|
|
301
|
+
*
|
|
302
|
+
* - Access controlled via MemoryCap ownership
|
|
303
|
+
* - Cross-dApp sharing "just works" (same owner = access)
|
|
304
|
+
* - No allowlist management needed
|
|
305
|
+
*
|
|
306
|
+
* @param cap: Reference to the MemoryCap (proves ownership) @param category:
|
|
307
|
+
* Memory category @param vector_id: Links to HNSW index @param blob_id: Pointer to
|
|
308
|
+
* encrypted content on Walrus @param content_type: MIME type @param content_size:
|
|
309
|
+
* Size in bytes @param content_hash: Content hash (blob_id) @param topic: Topic
|
|
310
|
+
* classification @param importance: Importance scale (1-10) @param
|
|
311
|
+
* embedding_blob_id: Pointer to embedding on Walrus @param ctx: Transaction
|
|
312
|
+
* context
|
|
313
|
+
*/
|
|
314
|
+
export function createMemoryWithCap(options: CreateMemoryWithCapOptions) {
|
|
315
|
+
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
316
|
+
const argumentsTypes = [
|
|
317
|
+
`${packageAddress}::capability::MemoryCap`,
|
|
318
|
+
'vector<u8>',
|
|
319
|
+
'u64',
|
|
320
|
+
'vector<u8>',
|
|
321
|
+
'vector<u8>',
|
|
322
|
+
'u64',
|
|
323
|
+
'vector<u8>',
|
|
324
|
+
'vector<u8>',
|
|
325
|
+
'u8',
|
|
326
|
+
'vector<u8>'
|
|
327
|
+
] satisfies string[];
|
|
328
|
+
const parameterNames = ["cap", "category", "vectorId", "blobId", "contentType", "contentSize", "contentHash", "topic", "importance", "embeddingBlobId"];
|
|
329
|
+
return (tx: Transaction) => tx.moveCall({
|
|
330
|
+
package: packageAddress,
|
|
331
|
+
module: 'memory',
|
|
332
|
+
function: 'create_memory_with_cap',
|
|
333
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
export interface UpdateMemoryMetadataArguments {
|
|
337
|
+
memory: RawTransactionArgument<string>;
|
|
338
|
+
newTopic: RawTransactionArgument<number[]>;
|
|
339
|
+
newImportance: RawTransactionArgument<number>;
|
|
340
|
+
}
|
|
341
|
+
export interface UpdateMemoryMetadataOptions {
|
|
342
|
+
package?: string;
|
|
343
|
+
arguments: UpdateMemoryMetadataArguments | [
|
|
344
|
+
memory: RawTransactionArgument<string>,
|
|
345
|
+
newTopic: RawTransactionArgument<number[]>,
|
|
346
|
+
newImportance: RawTransactionArgument<number>
|
|
347
|
+
];
|
|
348
|
+
}
|
|
349
|
+
/** Update metadata for an existing memory */
|
|
350
|
+
export function updateMemoryMetadata(options: UpdateMemoryMetadataOptions) {
|
|
351
|
+
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
352
|
+
const argumentsTypes = [
|
|
353
|
+
`${packageAddress}::memory::Memory`,
|
|
354
|
+
'vector<u8>',
|
|
355
|
+
'u8'
|
|
356
|
+
] satisfies string[];
|
|
357
|
+
const parameterNames = ["memory", "newTopic", "newImportance"];
|
|
358
|
+
return (tx: Transaction) => tx.moveCall({
|
|
359
|
+
package: packageAddress,
|
|
360
|
+
module: 'memory',
|
|
361
|
+
function: 'update_memory_metadata',
|
|
362
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
export interface AddCustomMetadataArguments {
|
|
366
|
+
memory: RawTransactionArgument<string>;
|
|
367
|
+
key: RawTransactionArgument<number[]>;
|
|
368
|
+
value: RawTransactionArgument<number[]>;
|
|
369
|
+
}
|
|
370
|
+
export interface AddCustomMetadataOptions {
|
|
371
|
+
package?: string;
|
|
372
|
+
arguments: AddCustomMetadataArguments | [
|
|
373
|
+
memory: RawTransactionArgument<string>,
|
|
374
|
+
key: RawTransactionArgument<number[]>,
|
|
375
|
+
value: RawTransactionArgument<number[]>
|
|
376
|
+
];
|
|
377
|
+
}
|
|
378
|
+
/** Add custom metadata field */
|
|
379
|
+
export function addCustomMetadata(options: AddCustomMetadataOptions) {
|
|
380
|
+
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
381
|
+
const argumentsTypes = [
|
|
382
|
+
`${packageAddress}::memory::Memory`,
|
|
383
|
+
'vector<u8>',
|
|
384
|
+
'vector<u8>'
|
|
385
|
+
] satisfies string[];
|
|
386
|
+
const parameterNames = ["memory", "key", "value"];
|
|
387
|
+
return (tx: Transaction) => tx.moveCall({
|
|
388
|
+
package: packageAddress,
|
|
389
|
+
module: 'memory',
|
|
390
|
+
function: 'add_custom_metadata',
|
|
391
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
export interface UpdateMemoryRecordArguments {
|
|
395
|
+
memory: RawTransactionArgument<string>;
|
|
396
|
+
newBlobId: RawTransactionArgument<number[]>;
|
|
397
|
+
newCategory: RawTransactionArgument<number[]>;
|
|
398
|
+
newTopic: RawTransactionArgument<number[]>;
|
|
399
|
+
newImportance: RawTransactionArgument<number>;
|
|
400
|
+
newEmbeddingBlobId: RawTransactionArgument<number[]>;
|
|
401
|
+
newContentHash: RawTransactionArgument<number[]>;
|
|
402
|
+
newContentSize: RawTransactionArgument<number | bigint>;
|
|
403
|
+
}
|
|
404
|
+
export interface UpdateMemoryRecordOptions {
|
|
405
|
+
package?: string;
|
|
406
|
+
arguments: UpdateMemoryRecordArguments | [
|
|
407
|
+
memory: RawTransactionArgument<string>,
|
|
408
|
+
newBlobId: RawTransactionArgument<number[]>,
|
|
409
|
+
newCategory: RawTransactionArgument<number[]>,
|
|
410
|
+
newTopic: RawTransactionArgument<number[]>,
|
|
411
|
+
newImportance: RawTransactionArgument<number>,
|
|
412
|
+
newEmbeddingBlobId: RawTransactionArgument<number[]>,
|
|
413
|
+
newContentHash: RawTransactionArgument<number[]>,
|
|
414
|
+
newContentSize: RawTransactionArgument<number | bigint>
|
|
415
|
+
];
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Comprehensive update for a memory record
|
|
419
|
+
*
|
|
420
|
+
* Updates multiple fields of a Memory object in a single transaction. Only
|
|
421
|
+
* non-empty values will be updated (empty vector<u8> = skip update).
|
|
422
|
+
*
|
|
423
|
+
* This function follows Sui's object model where:
|
|
424
|
+
*
|
|
425
|
+
* - Objects are passed as mutable references (&mut)
|
|
426
|
+
* - Version number is automatically incremented by Sui runtime
|
|
427
|
+
* - Changes are atomic within the transaction
|
|
428
|
+
*
|
|
429
|
+
* @param memory: Mutable reference to the Memory object @param new_blob_id: New
|
|
430
|
+
* Walrus blob ID (empty = no change) @param new_category: New category (empty = no
|
|
431
|
+
* change) @param new_topic: New topic (empty = no change) @param new_importance:
|
|
432
|
+
* New importance (0 = no change, 1-10 = update) @param new_embedding_blob_id: New
|
|
433
|
+
* embedding blob ID (empty = no change) @param new_content_hash: New content hash
|
|
434
|
+
* (empty = no change) @param new_content_size: New content size (0 = no change)
|
|
435
|
+
* @param ctx: Transaction context
|
|
436
|
+
*/
|
|
437
|
+
export function updateMemoryRecord(options: UpdateMemoryRecordOptions) {
|
|
438
|
+
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
439
|
+
const argumentsTypes = [
|
|
440
|
+
`${packageAddress}::memory::Memory`,
|
|
441
|
+
'vector<u8>',
|
|
442
|
+
'vector<u8>',
|
|
443
|
+
'vector<u8>',
|
|
444
|
+
'u8',
|
|
445
|
+
'vector<u8>',
|
|
446
|
+
'vector<u8>',
|
|
447
|
+
'u64'
|
|
448
|
+
] satisfies string[];
|
|
449
|
+
const parameterNames = ["memory", "newBlobId", "newCategory", "newTopic", "newImportance", "newEmbeddingBlobId", "newContentHash", "newContentSize"];
|
|
450
|
+
return (tx: Transaction) => tx.moveCall({
|
|
451
|
+
package: packageAddress,
|
|
452
|
+
module: 'memory',
|
|
453
|
+
function: 'update_memory_record',
|
|
454
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
export interface UpdateMemoryWithCapArguments {
|
|
458
|
+
cap: RawTransactionArgument<string>;
|
|
459
|
+
memory: RawTransactionArgument<string>;
|
|
460
|
+
newBlobId: RawTransactionArgument<number[]>;
|
|
461
|
+
newCategory: RawTransactionArgument<number[]>;
|
|
462
|
+
newTopic: RawTransactionArgument<number[]>;
|
|
463
|
+
newImportance: RawTransactionArgument<number>;
|
|
464
|
+
newEmbeddingBlobId: RawTransactionArgument<number[]>;
|
|
465
|
+
newContentHash: RawTransactionArgument<number[]>;
|
|
466
|
+
newContentSize: RawTransactionArgument<number | bigint>;
|
|
467
|
+
}
|
|
468
|
+
export interface UpdateMemoryWithCapOptions {
|
|
469
|
+
package?: string;
|
|
470
|
+
arguments: UpdateMemoryWithCapArguments | [
|
|
471
|
+
cap: RawTransactionArgument<string>,
|
|
472
|
+
memory: RawTransactionArgument<string>,
|
|
473
|
+
newBlobId: RawTransactionArgument<number[]>,
|
|
474
|
+
newCategory: RawTransactionArgument<number[]>,
|
|
475
|
+
newTopic: RawTransactionArgument<number[]>,
|
|
476
|
+
newImportance: RawTransactionArgument<number>,
|
|
477
|
+
newEmbeddingBlobId: RawTransactionArgument<number[]>,
|
|
478
|
+
newContentHash: RawTransactionArgument<number[]>,
|
|
479
|
+
newContentSize: RawTransactionArgument<number | bigint>
|
|
480
|
+
];
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Update memory record with capability verification (V2)
|
|
484
|
+
*
|
|
485
|
+
* Same as update_memory_record but verifies the caller owns the associated
|
|
486
|
+
* MemoryCap. Use this for capability-based memories to ensure proper access
|
|
487
|
+
* control.
|
|
488
|
+
*
|
|
489
|
+
* @param cap: Reference to the MemoryCap (proves ownership) @param memory: Mutable
|
|
490
|
+
* reference to the Memory object @param new_blob_id: New Walrus blob ID (empty =
|
|
491
|
+
* no change) @param new_category: New category (empty = no change) @param
|
|
492
|
+
* new_topic: New topic (empty = no change) @param new_importance: New importance
|
|
493
|
+
* (0 = no change, 1-10 = update) @param new_embedding_blob_id: New embedding blob
|
|
494
|
+
* ID (empty = no change) @param new_content_hash: New content hash (empty = no
|
|
495
|
+
* change) @param new_content_size: New content size (0 = no change) @param ctx:
|
|
496
|
+
* Transaction context
|
|
497
|
+
*/
|
|
498
|
+
export function updateMemoryWithCap(options: UpdateMemoryWithCapOptions) {
|
|
499
|
+
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
500
|
+
const argumentsTypes = [
|
|
501
|
+
`${packageAddress}::capability::MemoryCap`,
|
|
502
|
+
`${packageAddress}::memory::Memory`,
|
|
503
|
+
'vector<u8>',
|
|
504
|
+
'vector<u8>',
|
|
505
|
+
'vector<u8>',
|
|
506
|
+
'u8',
|
|
507
|
+
'vector<u8>',
|
|
508
|
+
'vector<u8>',
|
|
509
|
+
'u64'
|
|
510
|
+
] satisfies string[];
|
|
511
|
+
const parameterNames = ["cap", "memory", "newBlobId", "newCategory", "newTopic", "newImportance", "newEmbeddingBlobId", "newContentHash", "newContentSize"];
|
|
512
|
+
return (tx: Transaction) => tx.moveCall({
|
|
513
|
+
package: packageAddress,
|
|
514
|
+
module: 'memory',
|
|
515
|
+
function: 'update_memory_with_cap',
|
|
516
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
export interface CreateMemoryRecordLightweightArguments {
|
|
520
|
+
category: RawTransactionArgument<number[]>;
|
|
521
|
+
vectorId: RawTransactionArgument<number | bigint>;
|
|
522
|
+
blobId: RawTransactionArgument<number[]>;
|
|
523
|
+
blobObjectId: RawTransactionArgument<number[]>;
|
|
524
|
+
importance: RawTransactionArgument<number>;
|
|
525
|
+
}
|
|
526
|
+
export interface CreateMemoryRecordLightweightOptions {
|
|
527
|
+
package?: string;
|
|
528
|
+
arguments: CreateMemoryRecordLightweightArguments | [
|
|
529
|
+
category: RawTransactionArgument<number[]>,
|
|
530
|
+
vectorId: RawTransactionArgument<number | bigint>,
|
|
531
|
+
blobId: RawTransactionArgument<number[]>,
|
|
532
|
+
blobObjectId: RawTransactionArgument<number[]>,
|
|
533
|
+
importance: RawTransactionArgument<number>
|
|
534
|
+
];
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* Create a lightweight memory record (for use with Walrus metadata) - LEGACY
|
|
538
|
+
*
|
|
539
|
+
* This function creates a minimal on-chain Memory struct with only essential
|
|
540
|
+
* queryable fields. Rich metadata should be stored as Walrus blob metadata.
|
|
541
|
+
*
|
|
542
|
+
* Use this when:
|
|
543
|
+
*
|
|
544
|
+
* - Gas costs are a concern
|
|
545
|
+
* - Rich metadata is stored on Walrus blob
|
|
546
|
+
* - Only need basic filtering (category, vector_id)
|
|
547
|
+
*
|
|
548
|
+
* NOTE: For new implementations, use create_memory_lightweight_with_cap() instead
|
|
549
|
+
*/
|
|
550
|
+
export function createMemoryRecordLightweight(options: CreateMemoryRecordLightweightOptions) {
|
|
551
|
+
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
552
|
+
const argumentsTypes = [
|
|
553
|
+
'vector<u8>',
|
|
554
|
+
'u64',
|
|
555
|
+
'vector<u8>',
|
|
556
|
+
'vector<u8>',
|
|
557
|
+
'u8'
|
|
558
|
+
] satisfies string[];
|
|
559
|
+
const parameterNames = ["category", "vectorId", "blobId", "blobObjectId", "importance"];
|
|
560
|
+
return (tx: Transaction) => tx.moveCall({
|
|
561
|
+
package: packageAddress,
|
|
562
|
+
module: 'memory',
|
|
563
|
+
function: 'create_memory_record_lightweight',
|
|
564
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
export interface CreateMemoryLightweightWithCapArguments {
|
|
568
|
+
cap: RawTransactionArgument<string>;
|
|
569
|
+
category: RawTransactionArgument<number[]>;
|
|
570
|
+
vectorId: RawTransactionArgument<number | bigint>;
|
|
571
|
+
blobId: RawTransactionArgument<number[]>;
|
|
572
|
+
blobObjectId: RawTransactionArgument<number[]>;
|
|
573
|
+
importance: RawTransactionArgument<number>;
|
|
574
|
+
}
|
|
575
|
+
export interface CreateMemoryLightweightWithCapOptions {
|
|
576
|
+
package?: string;
|
|
577
|
+
arguments: CreateMemoryLightweightWithCapArguments | [
|
|
578
|
+
cap: RawTransactionArgument<string>,
|
|
579
|
+
category: RawTransactionArgument<number[]>,
|
|
580
|
+
vectorId: RawTransactionArgument<number | bigint>,
|
|
581
|
+
blobId: RawTransactionArgument<number[]>,
|
|
582
|
+
blobObjectId: RawTransactionArgument<number[]>,
|
|
583
|
+
importance: RawTransactionArgument<number>
|
|
584
|
+
];
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* Create a lightweight memory record with capability-based access (V2 -
|
|
588
|
+
* RECOMMENDED)
|
|
589
|
+
*
|
|
590
|
+
* Gas-optimized version for capability-based access control.
|
|
591
|
+
*
|
|
592
|
+
* @param cap: Reference to the MemoryCap (proves ownership) @param category:
|
|
593
|
+
* Memory category @param vector_id: Links to HNSW index @param blob_id: Pointer to
|
|
594
|
+
* encrypted content on Walrus @param blob_object_id: Optional Walrus blob object
|
|
595
|
+
* ID @param importance: Importance scale (1-10) @param ctx: Transaction context
|
|
596
|
+
*/
|
|
597
|
+
export function createMemoryLightweightWithCap(options: CreateMemoryLightweightWithCapOptions) {
|
|
598
|
+
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
599
|
+
const argumentsTypes = [
|
|
600
|
+
`${packageAddress}::capability::MemoryCap`,
|
|
601
|
+
'vector<u8>',
|
|
602
|
+
'u64',
|
|
603
|
+
'vector<u8>',
|
|
604
|
+
'vector<u8>',
|
|
605
|
+
'u8'
|
|
606
|
+
] satisfies string[];
|
|
607
|
+
const parameterNames = ["cap", "category", "vectorId", "blobId", "blobObjectId", "importance"];
|
|
608
|
+
return (tx: Transaction) => tx.moveCall({
|
|
609
|
+
package: packageAddress,
|
|
610
|
+
module: 'memory',
|
|
611
|
+
function: 'create_memory_lightweight_with_cap',
|
|
612
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
export interface DeleteMemoryRecordArguments {
|
|
616
|
+
memory: RawTransactionArgument<string>;
|
|
617
|
+
}
|
|
618
|
+
export interface DeleteMemoryRecordOptions {
|
|
619
|
+
package?: string;
|
|
620
|
+
arguments: DeleteMemoryRecordArguments | [
|
|
621
|
+
memory: RawTransactionArgument<string>
|
|
622
|
+
];
|
|
623
|
+
}
|
|
624
|
+
/** Delete a memory record */
|
|
625
|
+
export function deleteMemoryRecord(options: DeleteMemoryRecordOptions) {
|
|
626
|
+
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
627
|
+
const argumentsTypes = [
|
|
628
|
+
`${packageAddress}::memory::Memory`
|
|
629
|
+
] satisfies string[];
|
|
630
|
+
const parameterNames = ["memory"];
|
|
631
|
+
return (tx: Transaction) => tx.moveCall({
|
|
632
|
+
package: packageAddress,
|
|
633
|
+
module: 'memory',
|
|
634
|
+
function: 'delete_memory_record',
|
|
635
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
export interface GetIndexBlobIdArguments {
|
|
639
|
+
memoryIndex: RawTransactionArgument<string>;
|
|
640
|
+
}
|
|
641
|
+
export interface GetIndexBlobIdOptions {
|
|
642
|
+
package?: string;
|
|
643
|
+
arguments: GetIndexBlobIdArguments | [
|
|
644
|
+
memoryIndex: RawTransactionArgument<string>
|
|
645
|
+
];
|
|
646
|
+
}
|
|
647
|
+
export function getIndexBlobId(options: GetIndexBlobIdOptions) {
|
|
648
|
+
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
649
|
+
const argumentsTypes = [
|
|
650
|
+
`${packageAddress}::memory::MemoryIndex`
|
|
651
|
+
] satisfies string[];
|
|
652
|
+
const parameterNames = ["memoryIndex"];
|
|
653
|
+
return (tx: Transaction) => tx.moveCall({
|
|
654
|
+
package: packageAddress,
|
|
655
|
+
module: 'memory',
|
|
656
|
+
function: 'get_index_blob_id',
|
|
657
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
export interface GetGraphBlobIdArguments {
|
|
661
|
+
memoryIndex: RawTransactionArgument<string>;
|
|
662
|
+
}
|
|
663
|
+
export interface GetGraphBlobIdOptions {
|
|
664
|
+
package?: string;
|
|
665
|
+
arguments: GetGraphBlobIdArguments | [
|
|
666
|
+
memoryIndex: RawTransactionArgument<string>
|
|
667
|
+
];
|
|
668
|
+
}
|
|
669
|
+
export function getGraphBlobId(options: GetGraphBlobIdOptions) {
|
|
670
|
+
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
671
|
+
const argumentsTypes = [
|
|
672
|
+
`${packageAddress}::memory::MemoryIndex`
|
|
673
|
+
] satisfies string[];
|
|
674
|
+
const parameterNames = ["memoryIndex"];
|
|
675
|
+
return (tx: Transaction) => tx.moveCall({
|
|
676
|
+
package: packageAddress,
|
|
677
|
+
module: 'memory',
|
|
678
|
+
function: 'get_graph_blob_id',
|
|
679
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
export interface GetVersionArguments {
|
|
683
|
+
memoryIndex: RawTransactionArgument<string>;
|
|
684
|
+
}
|
|
685
|
+
export interface GetVersionOptions {
|
|
686
|
+
package?: string;
|
|
687
|
+
arguments: GetVersionArguments | [
|
|
688
|
+
memoryIndex: RawTransactionArgument<string>
|
|
689
|
+
];
|
|
690
|
+
}
|
|
691
|
+
export function getVersion(options: GetVersionOptions) {
|
|
692
|
+
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
693
|
+
const argumentsTypes = [
|
|
694
|
+
`${packageAddress}::memory::MemoryIndex`
|
|
695
|
+
] satisfies string[];
|
|
696
|
+
const parameterNames = ["memoryIndex"];
|
|
697
|
+
return (tx: Transaction) => tx.moveCall({
|
|
698
|
+
package: packageAddress,
|
|
699
|
+
module: 'memory',
|
|
700
|
+
function: 'get_version',
|
|
701
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
export interface GetMemoryBlobIdArguments {
|
|
705
|
+
memory: RawTransactionArgument<string>;
|
|
706
|
+
}
|
|
707
|
+
export interface GetMemoryBlobIdOptions {
|
|
708
|
+
package?: string;
|
|
709
|
+
arguments: GetMemoryBlobIdArguments | [
|
|
710
|
+
memory: RawTransactionArgument<string>
|
|
711
|
+
];
|
|
712
|
+
}
|
|
713
|
+
export function getMemoryBlobId(options: GetMemoryBlobIdOptions) {
|
|
714
|
+
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
715
|
+
const argumentsTypes = [
|
|
716
|
+
`${packageAddress}::memory::Memory`
|
|
717
|
+
] satisfies string[];
|
|
718
|
+
const parameterNames = ["memory"];
|
|
719
|
+
return (tx: Transaction) => tx.moveCall({
|
|
720
|
+
package: packageAddress,
|
|
721
|
+
module: 'memory',
|
|
722
|
+
function: 'get_memory_blob_id',
|
|
723
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
export interface GetMemoryVectorIdArguments {
|
|
727
|
+
memory: RawTransactionArgument<string>;
|
|
728
|
+
}
|
|
729
|
+
export interface GetMemoryVectorIdOptions {
|
|
730
|
+
package?: string;
|
|
731
|
+
arguments: GetMemoryVectorIdArguments | [
|
|
732
|
+
memory: RawTransactionArgument<string>
|
|
733
|
+
];
|
|
734
|
+
}
|
|
735
|
+
export function getMemoryVectorId(options: GetMemoryVectorIdOptions) {
|
|
736
|
+
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
737
|
+
const argumentsTypes = [
|
|
738
|
+
`${packageAddress}::memory::Memory`
|
|
739
|
+
] satisfies string[];
|
|
740
|
+
const parameterNames = ["memory"];
|
|
741
|
+
return (tx: Transaction) => tx.moveCall({
|
|
742
|
+
package: packageAddress,
|
|
743
|
+
module: 'memory',
|
|
744
|
+
function: 'get_memory_vector_id',
|
|
745
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
export interface GetMemoryCategoryArguments {
|
|
749
|
+
memory: RawTransactionArgument<string>;
|
|
750
|
+
}
|
|
751
|
+
export interface GetMemoryCategoryOptions {
|
|
752
|
+
package?: string;
|
|
753
|
+
arguments: GetMemoryCategoryArguments | [
|
|
754
|
+
memory: RawTransactionArgument<string>
|
|
755
|
+
];
|
|
756
|
+
}
|
|
757
|
+
export function getMemoryCategory(options: GetMemoryCategoryOptions) {
|
|
758
|
+
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
759
|
+
const argumentsTypes = [
|
|
760
|
+
`${packageAddress}::memory::Memory`
|
|
761
|
+
] satisfies string[];
|
|
762
|
+
const parameterNames = ["memory"];
|
|
763
|
+
return (tx: Transaction) => tx.moveCall({
|
|
764
|
+
package: packageAddress,
|
|
765
|
+
module: 'memory',
|
|
766
|
+
function: 'get_memory_category',
|
|
767
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
768
|
+
});
|
|
769
|
+
}
|
|
770
|
+
export interface GetMetadataArguments {
|
|
771
|
+
memory: RawTransactionArgument<string>;
|
|
772
|
+
}
|
|
773
|
+
export interface GetMetadataOptions {
|
|
774
|
+
package?: string;
|
|
775
|
+
arguments: GetMetadataArguments | [
|
|
776
|
+
memory: RawTransactionArgument<string>
|
|
777
|
+
];
|
|
778
|
+
}
|
|
779
|
+
export function getMetadata(options: GetMetadataOptions) {
|
|
780
|
+
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
781
|
+
const argumentsTypes = [
|
|
782
|
+
`${packageAddress}::memory::Memory`
|
|
783
|
+
] satisfies string[];
|
|
784
|
+
const parameterNames = ["memory"];
|
|
785
|
+
return (tx: Transaction) => tx.moveCall({
|
|
786
|
+
package: packageAddress,
|
|
787
|
+
module: 'memory',
|
|
788
|
+
function: 'get_metadata',
|
|
789
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
export interface GetEmbeddingBlobIdArguments {
|
|
793
|
+
metadata: RawTransactionArgument<string>;
|
|
794
|
+
}
|
|
795
|
+
export interface GetEmbeddingBlobIdOptions {
|
|
796
|
+
package?: string;
|
|
797
|
+
arguments: GetEmbeddingBlobIdArguments | [
|
|
798
|
+
metadata: RawTransactionArgument<string>
|
|
799
|
+
];
|
|
800
|
+
}
|
|
801
|
+
export function getEmbeddingBlobId(options: GetEmbeddingBlobIdOptions) {
|
|
802
|
+
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
803
|
+
const argumentsTypes = [
|
|
804
|
+
`${packageAddress}::memory::MemoryMetadata`
|
|
805
|
+
] satisfies string[];
|
|
806
|
+
const parameterNames = ["metadata"];
|
|
807
|
+
return (tx: Transaction) => tx.moveCall({
|
|
808
|
+
package: packageAddress,
|
|
809
|
+
module: 'memory',
|
|
810
|
+
function: 'get_embedding_blob_id',
|
|
811
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
export interface GetContentTypeArguments {
|
|
815
|
+
metadata: RawTransactionArgument<string>;
|
|
816
|
+
}
|
|
817
|
+
export interface GetContentTypeOptions {
|
|
818
|
+
package?: string;
|
|
819
|
+
arguments: GetContentTypeArguments | [
|
|
820
|
+
metadata: RawTransactionArgument<string>
|
|
821
|
+
];
|
|
822
|
+
}
|
|
823
|
+
export function getContentType(options: GetContentTypeOptions) {
|
|
824
|
+
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
825
|
+
const argumentsTypes = [
|
|
826
|
+
`${packageAddress}::memory::MemoryMetadata`
|
|
827
|
+
] satisfies string[];
|
|
828
|
+
const parameterNames = ["metadata"];
|
|
829
|
+
return (tx: Transaction) => tx.moveCall({
|
|
830
|
+
package: packageAddress,
|
|
831
|
+
module: 'memory',
|
|
832
|
+
function: 'get_content_type',
|
|
833
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
834
|
+
});
|
|
835
|
+
}
|
|
836
|
+
export interface GetContentSizeArguments {
|
|
837
|
+
metadata: RawTransactionArgument<string>;
|
|
838
|
+
}
|
|
839
|
+
export interface GetContentSizeOptions {
|
|
840
|
+
package?: string;
|
|
841
|
+
arguments: GetContentSizeArguments | [
|
|
842
|
+
metadata: RawTransactionArgument<string>
|
|
843
|
+
];
|
|
844
|
+
}
|
|
845
|
+
export function getContentSize(options: GetContentSizeOptions) {
|
|
846
|
+
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
847
|
+
const argumentsTypes = [
|
|
848
|
+
`${packageAddress}::memory::MemoryMetadata`
|
|
849
|
+
] satisfies string[];
|
|
850
|
+
const parameterNames = ["metadata"];
|
|
851
|
+
return (tx: Transaction) => tx.moveCall({
|
|
852
|
+
package: packageAddress,
|
|
853
|
+
module: 'memory',
|
|
854
|
+
function: 'get_content_size',
|
|
855
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
856
|
+
});
|
|
857
|
+
}
|
|
858
|
+
export interface GetTopicArguments {
|
|
859
|
+
metadata: RawTransactionArgument<string>;
|
|
860
|
+
}
|
|
861
|
+
export interface GetTopicOptions {
|
|
862
|
+
package?: string;
|
|
863
|
+
arguments: GetTopicArguments | [
|
|
864
|
+
metadata: RawTransactionArgument<string>
|
|
865
|
+
];
|
|
866
|
+
}
|
|
867
|
+
export function getTopic(options: GetTopicOptions) {
|
|
868
|
+
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
869
|
+
const argumentsTypes = [
|
|
870
|
+
`${packageAddress}::memory::MemoryMetadata`
|
|
871
|
+
] satisfies string[];
|
|
872
|
+
const parameterNames = ["metadata"];
|
|
873
|
+
return (tx: Transaction) => tx.moveCall({
|
|
874
|
+
package: packageAddress,
|
|
875
|
+
module: 'memory',
|
|
876
|
+
function: 'get_topic',
|
|
877
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
878
|
+
});
|
|
879
|
+
}
|
|
880
|
+
export interface GetImportanceArguments {
|
|
881
|
+
metadata: RawTransactionArgument<string>;
|
|
882
|
+
}
|
|
883
|
+
export interface GetImportanceOptions {
|
|
884
|
+
package?: string;
|
|
885
|
+
arguments: GetImportanceArguments | [
|
|
886
|
+
metadata: RawTransactionArgument<string>
|
|
887
|
+
];
|
|
888
|
+
}
|
|
889
|
+
export function getImportance(options: GetImportanceOptions) {
|
|
890
|
+
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
891
|
+
const argumentsTypes = [
|
|
892
|
+
`${packageAddress}::memory::MemoryMetadata`
|
|
893
|
+
] satisfies string[];
|
|
894
|
+
const parameterNames = ["metadata"];
|
|
895
|
+
return (tx: Transaction) => tx.moveCall({
|
|
896
|
+
package: packageAddress,
|
|
897
|
+
module: 'memory',
|
|
898
|
+
function: 'get_importance',
|
|
899
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
|
+
export interface GetCreatedTimestampArguments {
|
|
903
|
+
metadata: RawTransactionArgument<string>;
|
|
904
|
+
}
|
|
905
|
+
export interface GetCreatedTimestampOptions {
|
|
906
|
+
package?: string;
|
|
907
|
+
arguments: GetCreatedTimestampArguments | [
|
|
908
|
+
metadata: RawTransactionArgument<string>
|
|
909
|
+
];
|
|
910
|
+
}
|
|
911
|
+
export function getCreatedTimestamp(options: GetCreatedTimestampOptions) {
|
|
912
|
+
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
913
|
+
const argumentsTypes = [
|
|
914
|
+
`${packageAddress}::memory::MemoryMetadata`
|
|
915
|
+
] satisfies string[];
|
|
916
|
+
const parameterNames = ["metadata"];
|
|
917
|
+
return (tx: Transaction) => tx.moveCall({
|
|
918
|
+
package: packageAddress,
|
|
919
|
+
module: 'memory',
|
|
920
|
+
function: 'get_created_timestamp',
|
|
921
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
922
|
+
});
|
|
923
|
+
}
|
|
924
|
+
export interface GetUpdatedTimestampArguments {
|
|
925
|
+
metadata: RawTransactionArgument<string>;
|
|
926
|
+
}
|
|
927
|
+
export interface GetUpdatedTimestampOptions {
|
|
928
|
+
package?: string;
|
|
929
|
+
arguments: GetUpdatedTimestampArguments | [
|
|
930
|
+
metadata: RawTransactionArgument<string>
|
|
931
|
+
];
|
|
932
|
+
}
|
|
933
|
+
export function getUpdatedTimestamp(options: GetUpdatedTimestampOptions) {
|
|
934
|
+
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
935
|
+
const argumentsTypes = [
|
|
936
|
+
`${packageAddress}::memory::MemoryMetadata`
|
|
937
|
+
] satisfies string[];
|
|
938
|
+
const parameterNames = ["metadata"];
|
|
939
|
+
return (tx: Transaction) => tx.moveCall({
|
|
940
|
+
package: packageAddress,
|
|
941
|
+
module: 'memory',
|
|
942
|
+
function: 'get_updated_timestamp',
|
|
943
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
944
|
+
});
|
|
945
|
+
}
|
|
946
|
+
export interface GetCustomMetadataArguments {
|
|
947
|
+
metadata: RawTransactionArgument<string>;
|
|
948
|
+
}
|
|
949
|
+
export interface GetCustomMetadataOptions {
|
|
950
|
+
package?: string;
|
|
951
|
+
arguments: GetCustomMetadataArguments | [
|
|
952
|
+
metadata: RawTransactionArgument<string>
|
|
953
|
+
];
|
|
954
|
+
}
|
|
955
|
+
export function getCustomMetadata(options: GetCustomMetadataOptions) {
|
|
956
|
+
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
957
|
+
const argumentsTypes = [
|
|
958
|
+
`${packageAddress}::memory::MemoryMetadata`
|
|
959
|
+
] satisfies string[];
|
|
960
|
+
const parameterNames = ["metadata"];
|
|
961
|
+
return (tx: Transaction) => tx.moveCall({
|
|
962
|
+
package: packageAddress,
|
|
963
|
+
module: 'memory',
|
|
964
|
+
function: 'get_custom_metadata',
|
|
965
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
export interface GetCapabilityIdArguments {
|
|
969
|
+
memory: RawTransactionArgument<string>;
|
|
970
|
+
}
|
|
971
|
+
export interface GetCapabilityIdOptions {
|
|
972
|
+
package?: string;
|
|
973
|
+
arguments: GetCapabilityIdArguments | [
|
|
974
|
+
memory: RawTransactionArgument<string>
|
|
975
|
+
];
|
|
976
|
+
}
|
|
977
|
+
/** Get the capability_id from a memory (if linked to a MemoryCap) */
|
|
978
|
+
export function getCapabilityId(options: GetCapabilityIdOptions) {
|
|
979
|
+
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
980
|
+
const argumentsTypes = [
|
|
981
|
+
`${packageAddress}::memory::Memory`
|
|
982
|
+
] satisfies string[];
|
|
983
|
+
const parameterNames = ["memory"];
|
|
984
|
+
return (tx: Transaction) => tx.moveCall({
|
|
985
|
+
package: packageAddress,
|
|
986
|
+
module: 'memory',
|
|
987
|
+
function: 'get_capability_id',
|
|
988
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
989
|
+
});
|
|
990
|
+
}
|
|
991
|
+
export interface HasCapabilityArguments {
|
|
992
|
+
memory: RawTransactionArgument<string>;
|
|
993
|
+
}
|
|
994
|
+
export interface HasCapabilityOptions {
|
|
995
|
+
package?: string;
|
|
996
|
+
arguments: HasCapabilityArguments | [
|
|
997
|
+
memory: RawTransactionArgument<string>
|
|
998
|
+
];
|
|
999
|
+
}
|
|
1000
|
+
/** Check if memory is linked to a capability (V2) */
|
|
1001
|
+
export function hasCapability(options: HasCapabilityOptions) {
|
|
1002
|
+
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
1003
|
+
const argumentsTypes = [
|
|
1004
|
+
`${packageAddress}::memory::Memory`
|
|
1005
|
+
] satisfies string[];
|
|
1006
|
+
const parameterNames = ["memory"];
|
|
1007
|
+
return (tx: Transaction) => tx.moveCall({
|
|
1008
|
+
package: packageAddress,
|
|
1009
|
+
module: 'memory',
|
|
1010
|
+
function: 'has_capability',
|
|
1011
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1012
|
+
});
|
|
1013
|
+
}
|
|
1014
|
+
export interface IsLegacyAccessArguments {
|
|
1015
|
+
memory: RawTransactionArgument<string>;
|
|
1016
|
+
}
|
|
1017
|
+
export interface IsLegacyAccessOptions {
|
|
1018
|
+
package?: string;
|
|
1019
|
+
arguments: IsLegacyAccessArguments | [
|
|
1020
|
+
memory: RawTransactionArgument<string>
|
|
1021
|
+
];
|
|
1022
|
+
}
|
|
1023
|
+
/** Check if memory is using legacy owner-based access */
|
|
1024
|
+
export function isLegacyAccess(options: IsLegacyAccessOptions) {
|
|
1025
|
+
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
1026
|
+
const argumentsTypes = [
|
|
1027
|
+
`${packageAddress}::memory::Memory`
|
|
1028
|
+
] satisfies string[];
|
|
1029
|
+
const parameterNames = ["memory"];
|
|
1030
|
+
return (tx: Transaction) => tx.moveCall({
|
|
1031
|
+
package: packageAddress,
|
|
1032
|
+
module: 'memory',
|
|
1033
|
+
function: 'is_legacy_access',
|
|
1034
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1035
|
+
});
|
|
1036
|
+
}
|
|
1037
|
+
export interface GetAppIdArguments {
|
|
1038
|
+
memory: RawTransactionArgument<string>;
|
|
1039
|
+
}
|
|
1040
|
+
export interface GetAppIdOptions {
|
|
1041
|
+
package?: string;
|
|
1042
|
+
arguments: GetAppIdArguments | [
|
|
1043
|
+
memory: RawTransactionArgument<string>
|
|
1044
|
+
];
|
|
1045
|
+
}
|
|
1046
|
+
/**
|
|
1047
|
+
* Get the app_id from a memory (for context-based querying) Returns None for
|
|
1048
|
+
* legacy memories without capability
|
|
1049
|
+
*/
|
|
1050
|
+
export function getAppId(options: GetAppIdOptions) {
|
|
1051
|
+
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
1052
|
+
const argumentsTypes = [
|
|
1053
|
+
`${packageAddress}::memory::Memory`
|
|
1054
|
+
] satisfies string[];
|
|
1055
|
+
const parameterNames = ["memory"];
|
|
1056
|
+
return (tx: Transaction) => tx.moveCall({
|
|
1057
|
+
package: packageAddress,
|
|
1058
|
+
module: 'memory',
|
|
1059
|
+
function: 'get_app_id',
|
|
1060
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1061
|
+
});
|
|
1062
|
+
}
|
|
1063
|
+
export interface IsAppContextArguments {
|
|
1064
|
+
memory: RawTransactionArgument<string>;
|
|
1065
|
+
appId: RawTransactionArgument<string>;
|
|
1066
|
+
}
|
|
1067
|
+
export interface IsAppContextOptions {
|
|
1068
|
+
package?: string;
|
|
1069
|
+
arguments: IsAppContextArguments | [
|
|
1070
|
+
memory: RawTransactionArgument<string>,
|
|
1071
|
+
appId: RawTransactionArgument<string>
|
|
1072
|
+
];
|
|
1073
|
+
}
|
|
1074
|
+
/** Check if memory belongs to a specific app context */
|
|
1075
|
+
export function isAppContext(options: IsAppContextOptions) {
|
|
1076
|
+
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
1077
|
+
const argumentsTypes = [
|
|
1078
|
+
`${packageAddress}::memory::Memory`,
|
|
1079
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001::string::String'
|
|
1080
|
+
] satisfies string[];
|
|
1081
|
+
const parameterNames = ["memory", "appId"];
|
|
1082
|
+
return (tx: Transaction) => tx.moveCall({
|
|
1083
|
+
package: packageAddress,
|
|
1084
|
+
module: 'memory',
|
|
1085
|
+
function: 'is_app_context',
|
|
1086
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1087
|
+
});
|
|
1088
1088
|
}
|