@oumla/sdk 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -13,6 +13,7 @@ Official TypeScript SDK for Oumla - Blockchain integration made simple. This SDK
13
13
  - 📦 **Tree Shakeable** - Optimized bundle size with ES modules support
14
14
  - 🔄 **Auto-generated** - Always up-to-date with the latest API changes
15
15
  - 🌐 **Multi-environment** - Support for different deployment environments
16
+ - ⏱️ **Workflow Tracking** - Monitor async operations with Temporal workflow status
16
17
 
17
18
  ## Installation
18
19
 
@@ -53,16 +54,17 @@ async function getProfiles() {
53
54
  }
54
55
  }
55
56
 
56
- // Example: Create a wallet
57
- async function createWallet() {
57
+ // Example: Generate an address (V2 API)
58
+ async function generateAddress() {
58
59
  try {
59
- const wallet = await client.wallets.createWallet({
60
- profileId: 'your-profile-id',
61
- name: 'My Wallet',
60
+ const address = await client.addresses.generateAddress({
61
+ reference: 'profile-reference',
62
+ network: 'ETH',
63
+ clientShare: 'your-client-share',
62
64
  });
63
- console.log('Created wallet:', wallet);
65
+ console.log('Generated address:', address);
64
66
  } catch (error) {
65
- console.error('Error creating wallet:', error);
67
+ console.error('Error generating address:', error);
66
68
  }
67
69
  }
68
70
  ```
@@ -75,27 +77,43 @@ The SDK provides access to the following resources:
75
77
  Manage user profiles and organizations
76
78
  ```typescript
77
79
  const profiles = await client.profiles.getProfiles();
78
- const profile = await client.profiles.createProfile({ name: 'My Profile' });
80
+ const profile = await client.profiles.createProfile({
81
+ reference: 'my-profile',
82
+ type: 'User'
83
+ });
79
84
  ```
80
85
 
81
86
  ### 💼 Wallets
82
87
  Create and manage blockchain wallets
83
88
  ```typescript
84
- const wallets = await client.wallets.getProfileWallets({ profileId: 'profile-id' });
85
- const wallet = await client.wallets.createWallet({ profileId: 'profile-id', name: 'My Wallet' });
89
+ const wallets = await client.wallets.getProfileWallets('profile-reference');
90
+ const wallet = await client.wallets.generateWallet({
91
+ reference: 'profile-reference',
92
+ network: 'tETH'
93
+ });
86
94
  ```
87
95
 
88
- ### 📍 Addresses
89
- Generate and manage blockchain addresses
96
+ ### 📍 Addresses (V2 API)
97
+ Generate and manage blockchain addresses with the enhanced V2 API
90
98
  ```typescript
91
- const addresses = await client.addresses.getProfileAddresses({ profileId: 'profile-id' });
92
- const address = await client.addresses.createAddress({ walletId: 'wallet-id' });
99
+ // Get addresses for a profile
100
+ const addresses = await client.addresses.getProfileAddresses('profile-reference');
101
+
102
+ // Generate a new address (V2)
103
+ const address = await client.addresses.generateAddress({
104
+ reference: 'profile-reference',
105
+ network: 'ETH', // Supports: BTC, tBTC, ETH, tETH
106
+ clientShare: 'your-client-share',
107
+ });
108
+
109
+ // Get organization addresses
110
+ const orgAddresses = await client.addresses.getOrganizationAddresses();
93
111
  ```
94
112
 
95
113
  ### 💰 Transactions
96
114
  Track and manage blockchain transactions
97
115
  ```typescript
98
- const transactions = await client.transactions.getProfileTransactions({ profileId: 'profile-id' });
116
+ const transactions = await client.transactions.getProfileTransactions('profile-reference');
99
117
  ```
100
118
 
101
119
  ### 🎨 Assets
@@ -133,21 +151,152 @@ const contracts = await client.deployedContracts.getDeployedContracts();
133
151
  ### 🔧 Contract Interactions
134
152
  Read from and write to smart contracts
135
153
  ```typescript
136
- const result = await client.contractInteractions.readFunction({
137
- contractAddress: '0x...',
138
- functionName: 'balanceOf',
139
- parameters: ['0x...'],
140
- });
154
+ // Get available contract functions
155
+ const functions = await client.contractInteractions.getContractFunctions(
156
+ 'network',
157
+ 'contractAddress'
158
+ );
159
+
160
+ // Read from contract
161
+ const result = await client.contractInteractions.callReadFunction(
162
+ 'network',
163
+ 'contractAddress',
164
+ {
165
+ abiFunction: {
166
+ name: 'balanceOf',
167
+ inputs: [{ name: 'account', type: 'address' }],
168
+ outputs: [{ name: '', type: 'uint256' }],
169
+ type: 'function',
170
+ },
171
+ }
172
+ );
173
+
174
+ // Write to contract (triggers async workflow)
175
+ const writeResult = await client.contractInteractions.callWriteFunction(
176
+ 'network',
177
+ 'contractAddress',
178
+ {
179
+ addressId: 'your-address-id',
180
+ clientShare: 'your-client-share',
181
+ abiFunction: {
182
+ name: 'transfer',
183
+ inputs: [
184
+ { name: 'to', type: 'address' },
185
+ { name: 'amount', type: 'uint256' },
186
+ ],
187
+ outputs: [],
188
+ type: 'function',
189
+ },
190
+ }
191
+ );
192
+
193
+ // Get transaction receipt
194
+ const receipt = await client.contractInteractions.getTransactionReceipt(
195
+ 'network',
196
+ 'txId'
197
+ );
141
198
  ```
142
199
 
143
200
  ### 🪙 Tokenization
144
- Create and manage tokens and collections
201
+ Create and manage tokens and collections with full lifecycle support
202
+
203
+ #### Collections
145
204
  ```typescript
205
+ // Get all collections
146
206
  const collections = await client.tokenization.getCollections();
147
- const collection = await client.tokenization.createCollection({
148
- name: 'My NFT Collection',
149
- symbol: 'MNC',
207
+
208
+ // Get a specific collection
209
+ const collection = await client.tokenization.getCollection('collection-id');
210
+
211
+ // Create a new collection (triggers async workflow)
212
+ const newCollection = await client.tokenization.createCollection({
213
+ type: 'NON_FUNGIBLE_TOKEN',
214
+ addressId: 'your-address-id',
215
+ clientShare: 'your-client-share',
216
+ createParams: {
217
+ initializeParams: [{
218
+ name: 'name',
219
+ type: 'string',
220
+ value: 'My NFT Collection',
221
+ }],
222
+ },
223
+ displayName: 'My Collection',
150
224
  });
225
+
226
+ // Delete a collection
227
+ await client.tokenization.deleteCollection('collection-id');
228
+ ```
229
+
230
+ #### Token Operations
231
+ ```typescript
232
+ // Mint a token (triggers async workflow)
233
+ const mintResult = await client.tokenization.mintToken('collection-id', {
234
+ addressId: 'your-address-id',
235
+ clientShare: 'your-client-share',
236
+ to: 'recipient-address',
237
+ tokenId: '1',
238
+ });
239
+
240
+ // Burn a token (triggers async workflow)
241
+ const burnResult = await client.tokenization.burnToken('collection-id', {
242
+ addressId: 'your-address-id',
243
+ clientShare: 'your-client-share',
244
+ tokenId: '1',
245
+ });
246
+
247
+ // Get token details
248
+ const tokenDetails = await client.tokenization.getCollectionTokenDetails(
249
+ 'collection-id',
250
+ 'token-id'
251
+ );
252
+
253
+ // Get collection tokens (mints or burns)
254
+ const tokens = await client.tokenization.getCollectionTokens({
255
+ id: 'collection-id',
256
+ type: 'MINT', // or 'BURN'
257
+ skip: 0,
258
+ take: 50,
259
+ });
260
+
261
+ // Link an existing contract
262
+ await client.tokenization.linkContract({
263
+ contractAddress: '0x...',
264
+ });
265
+
266
+ // Unlink a token
267
+ await client.tokenization.unlinkToken('token-id');
268
+ ```
269
+
270
+ ### ⏱️ Temporal Workflow Status
271
+ Track the status of async operations like collection creation, minting, burning, and contract interactions
272
+
273
+ ```typescript
274
+ // Get workflow status
275
+ const status = await client.temporal.getTemporalWorkflowStatus('workflow-id');
276
+
277
+ console.log('Workflow ID:', status.data.workflowId);
278
+ console.log('Status:', status.data.status); // RUNNING, COMPLETED, FAILED, etc.
279
+ console.log('Start Time:', status.data.startTime);
280
+ console.log('Result:', status.data.result);
281
+
282
+ // Example: Poll until workflow completes
283
+ async function waitForWorkflow(workflowId: string) {
284
+ while (true) {
285
+ const status = await client.temporal.getTemporalWorkflowStatus(workflowId);
286
+
287
+ if (status.data.status === 'COMPLETED') {
288
+ console.log('Workflow completed:', status.data.result);
289
+ return status.data.result;
290
+ }
291
+
292
+ if (status.data.status === 'FAILED') {
293
+ throw new Error(`Workflow failed: ${JSON.stringify(status.data.error)}`);
294
+ }
295
+
296
+ // Wait before polling again
297
+ await new Promise(resolve => setTimeout(resolve, 2000));
298
+ }
299
+ }
151
300
  ```
152
301
 
153
302
  ## Configuration
@@ -217,17 +366,63 @@ import type {
217
366
  CreateProfileRequest,
218
367
  GetProfilesRequest,
219
368
  Profile,
220
- PaginatedResponse
369
+ PaginatedResponse,
370
+ TemporalWorkflowStatusData,
221
371
  } from '@oumla/sdk';
222
372
 
223
373
  // Type-safe request parameters
224
374
  const createProfileRequest: CreateProfileRequest = {
225
- name: 'My Profile',
226
- // TypeScript will enforce the correct structure
375
+ reference: 'my-profile',
376
+ type: 'User',
227
377
  };
228
378
 
229
379
  // Type-safe response handling
230
- const response: PaginatedResponse<Profile> = await client.profiles.getProfiles();
380
+ const response: PaginatedResponse = await client.profiles.getProfiles();
381
+ ```
382
+
383
+ ## Complete Workflow Examples
384
+
385
+ ### Create Collection and Mint NFT with Status Tracking
386
+
387
+ ```typescript
388
+ async function createCollectionAndMint() {
389
+ // 1. Create a collection
390
+ const collectionResponse = await client.tokenization.createCollection({
391
+ type: 'NON_FUNGIBLE_TOKEN',
392
+ addressId: 'your-address-id',
393
+ clientShare: 'your-client-share',
394
+ createParams: {
395
+ initializeParams: [{
396
+ name: 'name',
397
+ type: 'string',
398
+ value: 'My NFT Collection',
399
+ }],
400
+ },
401
+ });
402
+
403
+ // 2. Wait for collection creation workflow to complete
404
+ if (collectionResponse.data?.workflowId) {
405
+ await waitForWorkflow(collectionResponse.data.workflowId);
406
+ }
407
+
408
+ // 3. Mint a token
409
+ const mintResult = await client.tokenization.mintToken(
410
+ collectionResponse.data.id,
411
+ {
412
+ addressId: 'your-address-id',
413
+ clientShare: 'your-client-share',
414
+ to: 'recipient-address',
415
+ tokenId: '1',
416
+ }
417
+ );
418
+
419
+ // 4. Wait for mint workflow to complete
420
+ if (mintResult.data?.workflowId) {
421
+ await waitForWorkflow(mintResult.data.workflowId);
422
+ }
423
+
424
+ console.log('NFT minted successfully!');
425
+ }
231
426
  ```
232
427
 
233
428
  ## Development