@kynesyslabs/demosdk 2.4.19 → 2.4.20

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/build/index.d.ts CHANGED
@@ -12,3 +12,4 @@ export * as abstraction from "./abstraction";
12
12
  export * as web2 from "./websdk/Web2Calls";
13
13
  export * as bridge from "./bridge";
14
14
  export * as instantMessaging from "./instant_messaging";
15
+ export * as storage from "./storage";
package/build/index.js CHANGED
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.instantMessaging = exports.bridge = exports.web2 = exports.abstraction = exports.websdk = exports.l2ps = exports.demoswork = exports.wallet = exports.xmcore = exports.xmwebsdk = exports.xmlocalsdk = exports.utils = exports.encryption = exports.types = void 0;
36
+ exports.storage = exports.instantMessaging = exports.bridge = exports.web2 = exports.abstraction = exports.websdk = exports.l2ps = exports.demoswork = exports.wallet = exports.xmcore = exports.xmwebsdk = exports.xmlocalsdk = exports.utils = exports.encryption = exports.types = void 0;
37
37
  // Common types and constants
38
38
  exports.types = __importStar(require("./types"));
39
39
  // Basic cryptographic and data manipulation functions
@@ -52,4 +52,5 @@ exports.web2 = __importStar(require("./websdk/Web2Calls"));
52
52
  // Export bridge module and its types
53
53
  exports.bridge = __importStar(require("./bridge"));
54
54
  exports.instantMessaging = __importStar(require("./instant_messaging"));
55
+ exports.storage = __importStar(require("./storage"));
55
56
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAA6B;AAC7B,iDAAgC;AAChC,sDAAsD;AACtD,2DAA0C;AAC1C,iDAAgC;AAEhC,gCAAgC;AAChC,oEAAmD;AACnD,gEAA+C;AAC/C,4DAA2C,CAAC,gCAAgC;AAE5E,mDAAkC;AAClC,yDAAwC;AAExC,+CAA8B;AAE9B,mDAAkC;AAClC,6DAA4C;AAC5C,2DAA0C;AAE1C,qCAAqC;AACrC,mDAAkC;AAElC,wEAAuD"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAA6B;AAC7B,iDAAgC;AAChC,sDAAsD;AACtD,2DAA0C;AAC1C,iDAAgC;AAEhC,gCAAgC;AAChC,oEAAmD;AACnD,gEAA+C;AAC/C,4DAA2C,CAAC,gCAAgC;AAE5E,mDAAkC;AAClC,yDAAwC;AAExC,+CAA8B;AAE9B,mDAAkC;AAClC,6DAA4C;AAC5C,2DAA0C;AAE1C,qCAAqC;AACrC,mDAAkC;AAElC,wEAAuD;AAEvD,qDAAoC"}
@@ -0,0 +1,192 @@
1
+ import type { StorageProgramPayload, StorageProgramAccessControl } from "../types/blockchain/TransactionSubtypes/StorageProgramTransaction";
2
+ /**
3
+ * Storage Program class for creating and managing key-value storage on Demos Network
4
+ *
5
+ * Features:
6
+ * - Deterministic address derivation (stor-{sha256})
7
+ * - Key-value storage with 128KB limit
8
+ * - Access control (private, public, restricted, deployer-only)
9
+ * - Nested data structures (max 64 levels)
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * import { StorageProgram } from '@kynesyslabs/demosdk'
14
+ *
15
+ * // Derive storage address
16
+ * const address = StorageProgram.deriveStorageAddress(
17
+ * 'myDeployerAddress',
18
+ * 'myAppConfig',
19
+ * 'randomSalt123'
20
+ * )
21
+ *
22
+ * // Create storage program
23
+ * const payload = StorageProgram.createStorageProgram(
24
+ * 'myDeployerAddress',
25
+ * 'myAppConfig',
26
+ * { apiKey: 'secret', endpoint: 'https://api.example.com' },
27
+ * 'public',
28
+ * 'randomSalt123'
29
+ * )
30
+ * ```
31
+ */
32
+ export declare class StorageProgram {
33
+ /**
34
+ * Derive a deterministic storage program address
35
+ *
36
+ * @param deployerAddress - Address of the program deployer
37
+ * @param programName - Name of the storage program
38
+ * @param salt - Optional random salt for uniqueness (default: empty string)
39
+ * @returns Storage address in format: stor-{first 40 chars of sha256}
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * const address = StorageProgram.deriveStorageAddress(
44
+ * 'demos1abc...',
45
+ * 'myConfig',
46
+ * 'salt123'
47
+ * )
48
+ * // Returns: 'stor-7a8b9c...' (40 chars after prefix)
49
+ * ```
50
+ */
51
+ static deriveStorageAddress(deployerAddress: string, programName: string, salt?: string): string;
52
+ /**
53
+ * Create a new Storage Program
54
+ *
55
+ * @param deployerAddress - Address creating the storage program (will be the deployer)
56
+ * @param programName - Name of the storage program
57
+ * @param initialData - Initial key-value data to store
58
+ * @param accessControl - Access control mode (default: 'private')
59
+ * @param salt - Optional random salt for address derivation
60
+ * @param allowedAddresses - List of allowed addresses (for 'restricted' mode)
61
+ * @returns StorageProgramPayload for transaction creation
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * const payload = StorageProgram.createStorageProgram(
66
+ * 'demos1abc...',
67
+ * 'userPreferences',
68
+ * { theme: 'dark', language: 'en' },
69
+ * 'private'
70
+ * )
71
+ * ```
72
+ */
73
+ static createStorageProgram(deployerAddress: string, programName: string, initialData: Record<string, any>, accessControl?: StorageProgramAccessControl, salt?: string, allowedAddresses?: string[]): StorageProgramPayload;
74
+ /**
75
+ * Write or update key-value data in a Storage Program
76
+ *
77
+ * @param storageAddress - The storage program address (stor-{hash})
78
+ * @param data - Key-value data to write/update
79
+ * @returns StorageProgramPayload for transaction creation
80
+ *
81
+ * @example
82
+ * ```typescript
83
+ * const payload = StorageProgram.writeStorage(
84
+ * 'stor-7a8b9c...',
85
+ * { newKey: 'value', existingKey: 'updatedValue' }
86
+ * )
87
+ * ```
88
+ */
89
+ static writeStorage(storageAddress: string, data: Record<string, any>): StorageProgramPayload;
90
+ /**
91
+ * Read data from a Storage Program (query operation, not a transaction)
92
+ *
93
+ * Note: This creates a payload for validation purposes.
94
+ * Actual reads should use RPC endpoints like GET /storage-program/:address
95
+ *
96
+ * @param storageAddress - The storage program address to read from
97
+ * @returns StorageProgramPayload for validation
98
+ *
99
+ * @example
100
+ * ```typescript
101
+ * // For transaction validation (not typical usage)
102
+ * const payload = StorageProgram.readStorage('stor-7a8b9c...')
103
+ *
104
+ * // Typical usage: Use RPC endpoint
105
+ * // fetch(`${rpcUrl}/storage-program/${storageAddress}`)
106
+ * ```
107
+ */
108
+ static readStorage(storageAddress: string): StorageProgramPayload;
109
+ /**
110
+ * Update access control settings for a Storage Program (deployer only)
111
+ *
112
+ * @param storageAddress - The storage program address
113
+ * @param accessControl - New access control mode
114
+ * @param allowedAddresses - Updated list of allowed addresses (for 'restricted' mode)
115
+ * @returns StorageProgramPayload for transaction creation
116
+ *
117
+ * @example
118
+ * ```typescript
119
+ * // Change from private to public
120
+ * const payload = StorageProgram.updateAccessControl(
121
+ * 'stor-7a8b9c...',
122
+ * 'public'
123
+ * )
124
+ *
125
+ * // Set restricted access with allowlist
126
+ * const payload = StorageProgram.updateAccessControl(
127
+ * 'stor-7a8b9c...',
128
+ * 'restricted',
129
+ * ['demos1user1...', 'demos1user2...']
130
+ * )
131
+ * ```
132
+ */
133
+ static updateAccessControl(storageAddress: string, accessControl: StorageProgramAccessControl, allowedAddresses?: string[]): StorageProgramPayload;
134
+ /**
135
+ * Delete an entire Storage Program (deployer only)
136
+ *
137
+ * WARNING: This operation is irreversible and will delete all stored data.
138
+ *
139
+ * @param storageAddress - The storage program address to delete
140
+ * @returns StorageProgramPayload for transaction creation
141
+ *
142
+ * @example
143
+ * ```typescript
144
+ * const payload = StorageProgram.deleteStorageProgram('stor-7a8b9c...')
145
+ * ```
146
+ */
147
+ static deleteStorageProgram(storageAddress: string): StorageProgramPayload;
148
+ /**
149
+ * Validate storage size against 128KB limit
150
+ *
151
+ * @param data - The data object to validate
152
+ * @returns true if size is within limit, false otherwise
153
+ *
154
+ * @example
155
+ * ```typescript
156
+ * const data = { key: 'value', nested: { data: 'here' } }
157
+ * if (StorageProgram.validateSize(data)) {
158
+ * // Safe to store
159
+ * }
160
+ * ```
161
+ */
162
+ static validateSize(data: Record<string, any>): boolean;
163
+ /**
164
+ * Get the size of data in bytes
165
+ *
166
+ * @param data - The data object to measure
167
+ * @returns Size in bytes
168
+ *
169
+ * @example
170
+ * ```typescript
171
+ * const size = StorageProgram.getDataSize({ key: 'value' })
172
+ * console.log(`Data size: ${size} bytes`)
173
+ * ```
174
+ */
175
+ static getDataSize(data: Record<string, any>): number;
176
+ /**
177
+ * Validate nesting depth (max 64 levels)
178
+ *
179
+ * @param data - The data object to validate
180
+ * @param maxDepth - Maximum allowed nesting depth (default: 64)
181
+ * @returns true if nesting depth is within limit
182
+ *
183
+ * @example
184
+ * ```typescript
185
+ * const data = { level1: { level2: { level3: 'value' } } }
186
+ * if (StorageProgram.validateNestingDepth(data)) {
187
+ * // Safe nesting depth
188
+ * }
189
+ * ```
190
+ */
191
+ static validateNestingDepth(data: any, maxDepth?: number): boolean;
192
+ }
@@ -0,0 +1,257 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StorageProgram = void 0;
4
+ const crypto_1 = require("crypto");
5
+ // REVIEW: Storage Program class for key-value storage with access control
6
+ /**
7
+ * Storage Program class for creating and managing key-value storage on Demos Network
8
+ *
9
+ * Features:
10
+ * - Deterministic address derivation (stor-{sha256})
11
+ * - Key-value storage with 128KB limit
12
+ * - Access control (private, public, restricted, deployer-only)
13
+ * - Nested data structures (max 64 levels)
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * import { StorageProgram } from '@kynesyslabs/demosdk'
18
+ *
19
+ * // Derive storage address
20
+ * const address = StorageProgram.deriveStorageAddress(
21
+ * 'myDeployerAddress',
22
+ * 'myAppConfig',
23
+ * 'randomSalt123'
24
+ * )
25
+ *
26
+ * // Create storage program
27
+ * const payload = StorageProgram.createStorageProgram(
28
+ * 'myDeployerAddress',
29
+ * 'myAppConfig',
30
+ * { apiKey: 'secret', endpoint: 'https://api.example.com' },
31
+ * 'public',
32
+ * 'randomSalt123'
33
+ * )
34
+ * ```
35
+ */
36
+ class StorageProgram {
37
+ /**
38
+ * Derive a deterministic storage program address
39
+ *
40
+ * @param deployerAddress - Address of the program deployer
41
+ * @param programName - Name of the storage program
42
+ * @param salt - Optional random salt for uniqueness (default: empty string)
43
+ * @returns Storage address in format: stor-{first 40 chars of sha256}
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * const address = StorageProgram.deriveStorageAddress(
48
+ * 'demos1abc...',
49
+ * 'myConfig',
50
+ * 'salt123'
51
+ * )
52
+ * // Returns: 'stor-7a8b9c...' (40 chars after prefix)
53
+ * ```
54
+ */
55
+ static deriveStorageAddress(deployerAddress, programName, salt = "") {
56
+ // Create hash input: deployerAddress:programName:salt
57
+ const hashInput = `${deployerAddress}:${programName}:${salt}`;
58
+ // SHA-256 hash and take first 40 characters
59
+ const hash = (0, crypto_1.createHash)("sha256").update(hashInput).digest("hex");
60
+ const addressHash = hash.substring(0, 40);
61
+ return `stor-${addressHash}`;
62
+ }
63
+ /**
64
+ * Create a new Storage Program
65
+ *
66
+ * @param deployerAddress - Address creating the storage program (will be the deployer)
67
+ * @param programName - Name of the storage program
68
+ * @param initialData - Initial key-value data to store
69
+ * @param accessControl - Access control mode (default: 'private')
70
+ * @param salt - Optional random salt for address derivation
71
+ * @param allowedAddresses - List of allowed addresses (for 'restricted' mode)
72
+ * @returns StorageProgramPayload for transaction creation
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * const payload = StorageProgram.createStorageProgram(
77
+ * 'demos1abc...',
78
+ * 'userPreferences',
79
+ * { theme: 'dark', language: 'en' },
80
+ * 'private'
81
+ * )
82
+ * ```
83
+ */
84
+ static createStorageProgram(deployerAddress, programName, initialData, accessControl = "private", salt, allowedAddresses) {
85
+ // Derive storage address
86
+ const storageAddress = this.deriveStorageAddress(deployerAddress, programName, salt || "");
87
+ return {
88
+ operation: "CREATE_STORAGE_PROGRAM",
89
+ storageAddress,
90
+ programName,
91
+ data: initialData,
92
+ accessControl,
93
+ allowedAddresses,
94
+ salt,
95
+ };
96
+ }
97
+ /**
98
+ * Write or update key-value data in a Storage Program
99
+ *
100
+ * @param storageAddress - The storage program address (stor-{hash})
101
+ * @param data - Key-value data to write/update
102
+ * @returns StorageProgramPayload for transaction creation
103
+ *
104
+ * @example
105
+ * ```typescript
106
+ * const payload = StorageProgram.writeStorage(
107
+ * 'stor-7a8b9c...',
108
+ * { newKey: 'value', existingKey: 'updatedValue' }
109
+ * )
110
+ * ```
111
+ */
112
+ static writeStorage(storageAddress, data) {
113
+ return {
114
+ operation: "WRITE_STORAGE",
115
+ storageAddress,
116
+ data,
117
+ };
118
+ }
119
+ /**
120
+ * Read data from a Storage Program (query operation, not a transaction)
121
+ *
122
+ * Note: This creates a payload for validation purposes.
123
+ * Actual reads should use RPC endpoints like GET /storage-program/:address
124
+ *
125
+ * @param storageAddress - The storage program address to read from
126
+ * @returns StorageProgramPayload for validation
127
+ *
128
+ * @example
129
+ * ```typescript
130
+ * // For transaction validation (not typical usage)
131
+ * const payload = StorageProgram.readStorage('stor-7a8b9c...')
132
+ *
133
+ * // Typical usage: Use RPC endpoint
134
+ * // fetch(`${rpcUrl}/storage-program/${storageAddress}`)
135
+ * ```
136
+ */
137
+ static readStorage(storageAddress) {
138
+ return {
139
+ operation: "READ_STORAGE",
140
+ storageAddress,
141
+ };
142
+ }
143
+ /**
144
+ * Update access control settings for a Storage Program (deployer only)
145
+ *
146
+ * @param storageAddress - The storage program address
147
+ * @param accessControl - New access control mode
148
+ * @param allowedAddresses - Updated list of allowed addresses (for 'restricted' mode)
149
+ * @returns StorageProgramPayload for transaction creation
150
+ *
151
+ * @example
152
+ * ```typescript
153
+ * // Change from private to public
154
+ * const payload = StorageProgram.updateAccessControl(
155
+ * 'stor-7a8b9c...',
156
+ * 'public'
157
+ * )
158
+ *
159
+ * // Set restricted access with allowlist
160
+ * const payload = StorageProgram.updateAccessControl(
161
+ * 'stor-7a8b9c...',
162
+ * 'restricted',
163
+ * ['demos1user1...', 'demos1user2...']
164
+ * )
165
+ * ```
166
+ */
167
+ static updateAccessControl(storageAddress, accessControl, allowedAddresses) {
168
+ return {
169
+ operation: "UPDATE_ACCESS_CONTROL",
170
+ storageAddress,
171
+ accessControl,
172
+ allowedAddresses,
173
+ };
174
+ }
175
+ /**
176
+ * Delete an entire Storage Program (deployer only)
177
+ *
178
+ * WARNING: This operation is irreversible and will delete all stored data.
179
+ *
180
+ * @param storageAddress - The storage program address to delete
181
+ * @returns StorageProgramPayload for transaction creation
182
+ *
183
+ * @example
184
+ * ```typescript
185
+ * const payload = StorageProgram.deleteStorageProgram('stor-7a8b9c...')
186
+ * ```
187
+ */
188
+ static deleteStorageProgram(storageAddress) {
189
+ return {
190
+ operation: "DELETE_STORAGE_PROGRAM",
191
+ storageAddress,
192
+ };
193
+ }
194
+ /**
195
+ * Validate storage size against 128KB limit
196
+ *
197
+ * @param data - The data object to validate
198
+ * @returns true if size is within limit, false otherwise
199
+ *
200
+ * @example
201
+ * ```typescript
202
+ * const data = { key: 'value', nested: { data: 'here' } }
203
+ * if (StorageProgram.validateSize(data)) {
204
+ * // Safe to store
205
+ * }
206
+ * ```
207
+ */
208
+ static validateSize(data) {
209
+ const jsonString = JSON.stringify(data);
210
+ const sizeInBytes = new TextEncoder().encode(jsonString).length;
211
+ const maxSizeInBytes = 128 * 1024; // 128KB
212
+ return sizeInBytes <= maxSizeInBytes;
213
+ }
214
+ /**
215
+ * Get the size of data in bytes
216
+ *
217
+ * @param data - The data object to measure
218
+ * @returns Size in bytes
219
+ *
220
+ * @example
221
+ * ```typescript
222
+ * const size = StorageProgram.getDataSize({ key: 'value' })
223
+ * console.log(`Data size: ${size} bytes`)
224
+ * ```
225
+ */
226
+ static getDataSize(data) {
227
+ const jsonString = JSON.stringify(data);
228
+ return new TextEncoder().encode(jsonString).length;
229
+ }
230
+ /**
231
+ * Validate nesting depth (max 64 levels)
232
+ *
233
+ * @param data - The data object to validate
234
+ * @param maxDepth - Maximum allowed nesting depth (default: 64)
235
+ * @returns true if nesting depth is within limit
236
+ *
237
+ * @example
238
+ * ```typescript
239
+ * const data = { level1: { level2: { level3: 'value' } } }
240
+ * if (StorageProgram.validateNestingDepth(data)) {
241
+ * // Safe nesting depth
242
+ * }
243
+ * ```
244
+ */
245
+ static validateNestingDepth(data, maxDepth = 64) {
246
+ const getDepth = (obj, currentDepth = 1) => {
247
+ if (typeof obj !== "object" || obj === null) {
248
+ return currentDepth;
249
+ }
250
+ const depths = Object.values(obj).map(value => getDepth(value, currentDepth + 1));
251
+ return Math.max(...depths, currentDepth);
252
+ };
253
+ return getDepth(data) <= maxDepth;
254
+ }
255
+ }
256
+ exports.StorageProgram = StorageProgram;
257
+ //# sourceMappingURL=StorageProgram.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StorageProgram.js","sourceRoot":"","sources":["../../../src/storage/StorageProgram.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,2 @@
1
+ export { StorageProgram } from "./StorageProgram";
2
+ export type { StorageProgramPayload, StorageProgramAccessControl, StorageProgramOperation, StorageProgramTransactionContent, StorageProgramTransaction, } from "../types/blockchain/TransactionSubtypes/StorageProgramTransaction";
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StorageProgram = void 0;
4
+ var StorageProgram_1 = require("./StorageProgram");
5
+ Object.defineProperty(exports, "StorageProgram", { enumerable: true, get: function () { return StorageProgram_1.StorageProgram; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/storage/index.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AAAxC,gHAAA,cAAc,OAAA"}
@@ -10,12 +10,13 @@ import { InstantMessagingPayload } from "../instantMessaging";
10
10
  import { NativeBridgeTxPayload } from "../../bridge/nativeBridgeTypes";
11
11
  import { L2PSEncryptedPayload } from "../../l2ps";
12
12
  import { StoragePayload } from "./TransactionSubtypes/StorageTransaction";
13
+ import { StorageProgramPayload } from "./TransactionSubtypes/StorageProgramTransaction";
13
14
  import { L2PSHashPayload } from "./TransactionSubtypes/L2PSHashTransaction";
14
15
  import { ContractDeployPayload } from "./TransactionSubtypes/ContractDeployTransaction";
15
16
  import { ContractCallPayload } from "./TransactionSubtypes/ContractCallTransaction";
16
- export type TransactionContentData = ["web2Request", IWeb2Payload] | ["crosschainOperation", XMScript] | ["native", INativePayload] | ["demoswork", DemoScript] | ["l2psEncryptedTx", L2PSEncryptedPayload] | ["identity", IdentityPayload] | ["instantMessaging", InstantMessagingPayload] | ["nativeBridge", NativeBridgeTxPayload] | ["storage", StoragePayload] | ["l2ps_hash_update", L2PSHashPayload] | ["contractDeploy", ContractDeployPayload] | ["contractCall", ContractCallPayload];
17
+ export type TransactionContentData = ["web2Request", IWeb2Payload] | ["crosschainOperation", XMScript] | ["native", INativePayload] | ["demoswork", DemoScript] | ["l2psEncryptedTx", L2PSEncryptedPayload] | ["identity", IdentityPayload] | ["instantMessaging", InstantMessagingPayload] | ["nativeBridge", NativeBridgeTxPayload] | ["storage", StoragePayload] | ["storageProgram", StorageProgramPayload] | ["l2ps_hash_update", L2PSHashPayload] | ["contractDeploy", ContractDeployPayload] | ["contractCall", ContractCallPayload];
17
18
  export interface TransactionContent {
18
- type: "web2Request" | "crosschainOperation" | "subnet" | "native" | "demoswork" | "genesis" | "NODE_ONLINE" | "identity" | "instantMessaging" | "nativeBridge" | "l2psEncryptedTx" | "storage" | "l2ps_hash_update" | "contractDeploy" | "contractCall";
19
+ type: "web2Request" | "crosschainOperation" | "subnet" | "native" | "demoswork" | "genesis" | "NODE_ONLINE" | "identity" | "instantMessaging" | "nativeBridge" | "l2psEncryptedTx" | "storage" | "storageProgram" | "l2ps_hash_update" | "contractDeploy" | "contractCall";
19
20
  from: string;
20
21
  from_ed25519_address: string;
21
22
  to: string;
@@ -1 +1 @@
1
- {"version":3,"file":"Transaction.js","sourceRoot":"","sources":["../../../../src/types/blockchain/Transaction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAqFA,uCAAuC;AACvC,wDAAqC"}
1
+ {"version":3,"file":"Transaction.js","sourceRoot":"","sources":["../../../../src/types/blockchain/Transaction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAwFA,uCAAuC;AACvC,wDAAqC"}
@@ -0,0 +1,70 @@
1
+ import { Transaction, TransactionContent } from "../Transaction";
2
+ /**
3
+ * Storage Program operations
4
+ *
5
+ * - CREATE_STORAGE_PROGRAM: Initialize a new storage program with access control
6
+ * - WRITE_STORAGE: Write/update key-value pairs in the storage
7
+ * - READ_STORAGE: Query operation (not a transaction, used for validation)
8
+ * - UPDATE_ACCESS_CONTROL: Modify access control settings (deployer only)
9
+ * - DELETE_STORAGE_PROGRAM: Remove the entire storage program (deployer only)
10
+ */
11
+ export type StorageProgramOperation = "CREATE_STORAGE_PROGRAM" | "WRITE_STORAGE" | "READ_STORAGE" | "UPDATE_ACCESS_CONTROL" | "DELETE_STORAGE_PROGRAM";
12
+ /**
13
+ * Access control modes for Storage Programs
14
+ *
15
+ * - private: Only deployer can read and write
16
+ * - public: Anyone can read, only deployer can write
17
+ * - restricted: Only addresses in allowedAddresses can read/write
18
+ * - deployer-only: Only deployer has all permissions (same as private but explicit)
19
+ */
20
+ export type StorageProgramAccessControl = "private" | "public" | "restricted" | "deployer-only";
21
+ /**
22
+ * Storage Program payload for transaction data
23
+ *
24
+ * @property operation - The storage operation to perform
25
+ * @property storageAddress - The storage program address (stor-{hash})
26
+ * @property programName - Name of the storage program (required for CREATE)
27
+ * @property data - Key-value data to write (required for CREATE and WRITE)
28
+ * @property accessControl - Access control mode (optional for CREATE, required for UPDATE_ACCESS_CONTROL)
29
+ * @property allowedAddresses - List of allowed addresses for 'restricted' mode
30
+ * @property salt - Random salt for address derivation (optional for CREATE)
31
+ */
32
+ export interface StorageProgramPayload {
33
+ /** The storage operation to perform */
34
+ operation: StorageProgramOperation;
35
+ /** The storage program address (stor-{hash format}) */
36
+ storageAddress: string;
37
+ /** Name of the storage program (required for CREATE_STORAGE_PROGRAM) */
38
+ programName?: string;
39
+ /** Key-value data to write (for CREATE_STORAGE_PROGRAM and WRITE_STORAGE) */
40
+ data?: Record<string, any>;
41
+ /** Access control mode */
42
+ accessControl?: StorageProgramAccessControl;
43
+ /** Allowed addresses for 'restricted' access control */
44
+ allowedAddresses?: string[];
45
+ /** Random salt for deterministic address derivation (optional) */
46
+ salt?: string;
47
+ }
48
+ /**
49
+ * Transaction content type for Storage Program operations.
50
+ * Extends the base TransactionContent with storageProgram-specific type and data.
51
+ */
52
+ export type StorageProgramTransactionContent = Omit<TransactionContent, "type" | "data"> & {
53
+ type: "storageProgram";
54
+ data: ["storageProgram", StorageProgramPayload];
55
+ };
56
+ /**
57
+ * Complete Storage Program transaction interface.
58
+ * Used for structured key-value storage on the blockchain with access control.
59
+ *
60
+ * Storage Programs support:
61
+ * - Key-value storage (max 128KB per program)
62
+ * - Access control (private, public, restricted, deployer-only)
63
+ * - Deterministic address derivation
64
+ * - Nested data structures (max 64 levels)
65
+ *
66
+ * @see STORAGE_PROGRAMS_SPEC.md for complete specification
67
+ */
68
+ export interface StorageProgramTransaction extends Omit<Transaction, "content"> {
69
+ content: StorageProgramTransactionContent;
70
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=StorageProgramTransaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StorageProgramTransaction.js","sourceRoot":"","sources":["../../../../../src/types/blockchain/TransactionSubtypes/StorageProgramTransaction.ts"],"names":[],"mappings":""}
@@ -8,6 +8,7 @@ export * from './IdentityTransaction';
8
8
  export * from './InstantMessagingTransaction';
9
9
  export * from './NativeBridgeTransaction';
10
10
  export * from './StorageTransaction';
11
+ export * from './StorageProgramTransaction';
11
12
  export * from './ContractDeployTransaction';
12
13
  export * from './ContractCallTransaction';
13
14
  import { L2PSTransaction } from './L2PSTransaction';
@@ -20,6 +21,7 @@ import { IdentityTransaction } from './IdentityTransaction';
20
21
  import { InstantMessagingTransaction } from './InstantMessagingTransaction';
21
22
  import { NativeBridgeTransaction } from './NativeBridgeTransaction';
22
23
  import { StorageTransaction } from './StorageTransaction';
24
+ import { StorageProgramTransaction } from './StorageProgramTransaction';
23
25
  import { ContractDeployTransaction } from './ContractDeployTransaction';
24
26
  import { ContractCallTransaction } from './ContractCallTransaction';
25
- export type SpecificTransaction = L2PSTransaction | L2PSHashTransaction | Web2Transaction | CrosschainTransaction | NativeTransaction | DemosworkTransaction | IdentityTransaction | InstantMessagingTransaction | NativeBridgeTransaction | StorageTransaction | ContractDeployTransaction | ContractCallTransaction;
27
+ export type SpecificTransaction = L2PSTransaction | L2PSHashTransaction | Web2Transaction | CrosschainTransaction | NativeTransaction | DemosworkTransaction | IdentityTransaction | InstantMessagingTransaction | NativeBridgeTransaction | StorageTransaction | StorageProgramTransaction | ContractDeployTransaction | ContractCallTransaction;
@@ -24,6 +24,7 @@ __exportStar(require("./IdentityTransaction"), exports);
24
24
  __exportStar(require("./InstantMessagingTransaction"), exports);
25
25
  __exportStar(require("./NativeBridgeTransaction"), exports);
26
26
  __exportStar(require("./StorageTransaction"), exports);
27
+ __exportStar(require("./StorageProgramTransaction"), exports);
27
28
  __exportStar(require("./ContractDeployTransaction"), exports);
28
29
  __exportStar(require("./ContractCallTransaction"), exports);
29
30
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/types/blockchain/TransactionSubtypes/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAiC;AACjC,wDAAqC;AACrC,oDAAiC;AACjC,0DAAuC;AACvC,sDAAmC;AACnC,yDAAsC;AACtC,wDAAqC;AACrC,gEAA6C;AAC7C,4DAAyC;AACzC,uDAAoC;AACpC,8DAA2C;AAC3C,4DAAyC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/types/blockchain/TransactionSubtypes/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAiC;AACjC,wDAAqC;AACrC,oDAAiC;AACjC,0DAAuC;AACvC,sDAAmC;AACnC,yDAAsC;AACtC,wDAAqC;AACrC,gEAA6C;AAC7C,4DAAyC;AACzC,uDAAoC;AACpC,8DAA2C;AAC3C,8DAA2C;AAC3C,4DAAyC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kynesyslabs/demosdk",
3
- "version": "2.4.19",
3
+ "version": "2.4.20",
4
4
  "description": "Demosdk is a JavaScript/TypeScript SDK that provides a unified interface for interacting with Demos network",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",