@oumla/sdk 1.2.4 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -15,6 +15,14 @@ Official TypeScript SDK for Oumla - Blockchain integration made simple. This SDK
15
15
  - 🌐 **Multi-environment** - Support for different deployment environments
16
16
  - ⏱️ **Workflow Tracking** - Monitor async operations with Temporal workflow status
17
17
 
18
+ ## Supported Networks
19
+
20
+ The SDK supports the following blockchain networks:
21
+
22
+ - **tBTC** - Bitcoin Testnet
23
+ - **tETH** - Ethereum Testnet
24
+ - **SANDBOX** - Sandbox Environment
25
+
18
26
  ## Installation
19
27
 
20
28
  ```bash
@@ -57,9 +65,9 @@ async function getProfiles() {
57
65
  // Example: Generate an address (V2 API)
58
66
  async function generateAddress() {
59
67
  try {
60
- const address = await client.addresses.generateAddressV2({
68
+ const address = await client.addresses.createAddressV2({
61
69
  reference: 'profile-reference',
62
- network: 'ETH',
70
+ network: 'network',
63
71
  clientShare: 'your-client-share',
64
72
  });
65
73
  console.log('Generated address:', address);
@@ -86,59 +94,89 @@ const profile = await client.profiles.createProfile({
86
94
  ### 💼 Wallets
87
95
  Create and manage blockchain wallets
88
96
  ```typescript
89
- const wallets = await client.wallets.getProfileWallets('profile-reference');
90
- const wallet = await client.wallets.generateWallet({
97
+ const wallets = await client.wallets.getWalletsByProfile('profile-reference');
98
+ const wallet = await client.wallets.createWallet({
91
99
  reference: 'profile-reference',
92
- network: 'tETH'
100
+ network: 'network'
93
101
  });
94
102
  ```
95
103
 
96
- ### 📍 Addresses (V2 API)
97
- Generate and manage blockchain addresses with the enhanced V2 API
104
+ ### 📍 Addresses
105
+ Generate and manage blockchain addresses
98
106
  ```typescript
99
107
  // Get addresses for a profile
100
- const addresses = await client.addresses.getProfileAddresses('profile-reference');
108
+ const addresses = await client.addresses.getAddressForProfile({
109
+ reference: 'profile-reference'
110
+ });
101
111
 
102
- // Generate a new address (V2)
103
- const address = await client.addresses.generateAddressV2({
112
+ // Generate a new address (V2 API - recommended)
113
+ const address = await client.addresses.createAddressV2({
104
114
  reference: 'profile-reference',
105
- network: 'ETH', // Supports: BTC, tBTC, ETH, tETH
115
+ network: 'network',
106
116
  clientShare: 'your-client-share',
107
117
  });
108
118
 
109
119
  // Get organization addresses
110
- const orgAddresses = await client.addresses.getOrganizationAddresses();
120
+ const orgAddresses = await client.addresses.getAddressForOrganization();
111
121
  ```
112
122
 
113
123
  ### 💰 Transactions
114
124
  Track and manage blockchain transactions
115
125
  ```typescript
116
- const transactions = await client.transactions.getProfileTransactions('profile-reference');
126
+ // Get transactions by profile
127
+ const transactions = await client.transactions.getTransactionsByProfile({
128
+ reference: 'profile-reference'
129
+ });
130
+
131
+ // Get transactions by address
132
+ const addressTransactions = await client.transactions.getTransactionsByAddress({
133
+ address: '0x...'
134
+ });
135
+
136
+ // Get transactions by organization
137
+ const orgTransactions = await client.transactions.getTransactionsByOrganization({
138
+ reference: 'org-reference'
139
+ });
117
140
  ```
118
141
 
119
- ### 🎨 Assets
120
- Manage digital assets and collections
142
+ ### 💼 Portfolio
143
+ Manage digital assets and portfolio tracking
121
144
  ```typescript
122
- const assets = await client.assets.getAssets();
145
+ // Get assets for address, wallet, or contract
146
+ const assets = await client.portfolio.getAssets({
147
+ address: '0x...',
148
+ walletId: 'wallet-id',
149
+ contractAddress: '0x...',
150
+ tokenizationId: 'token-id'
151
+ });
152
+
153
+ // Get native balance for network, address, or wallet
154
+ const balance = await client.portfolio.getNativeBalance({
155
+ network: 'network',
156
+ address: '0x...',
157
+ walletId: 'wallet-id'
158
+ });
123
159
  ```
124
160
 
125
161
  ### 🔥 Withdrawals
126
162
  Handle withdrawal operations
127
163
  ```typescript
128
- const withdrawal = await client.withdrawals.createWithdrawal({
164
+ const withdrawal = await client.withdrawals.createWithdraw({
129
165
  walletId: 'wallet-id',
130
166
  amount: '1.0',
131
- currency: 'ETH',
167
+ currency: 'network',
132
168
  });
133
169
  ```
134
170
 
135
171
  ### 📋 Contract Templates
136
172
  Deploy and manage smart contract templates
137
173
  ```typescript
138
- const templates = await client.contractTemplates.getContractTemplates();
139
- const template = await client.contractTemplates.createContractTemplate({
174
+ const templates = await client.contractTemplates.getContracts();
175
+ const template = await client.contractTemplates.createContract({
140
176
  name: 'My Contract',
141
177
  abi: contractAbi,
178
+ bytecode: '0x...',
179
+ description: 'Contract description'
142
180
  });
143
181
  ```
144
182
 
@@ -151,14 +189,14 @@ const contracts = await client.deployedContracts.getDeployedContracts();
151
189
  ### 🔧 Contract Interactions
152
190
  Read from and write to smart contracts
153
191
  ```typescript
154
- // Get available contract functions
155
- const functions = await client.contractInteractions.getContractFunctions(
192
+ // Get ABI functions for a deployed contract
193
+ const abi = await client.contractInteractions.getDeployedContractAbi(
156
194
  'network',
157
195
  'contractAddress'
158
196
  );
159
197
 
160
198
  // Read from contract
161
- const result = await client.contractInteractions.callReadFunction(
199
+ const result = await client.contractInteractions.readCallFunction(
162
200
  'network',
163
201
  'contractAddress',
164
202
  {
@@ -168,11 +206,12 @@ const result = await client.contractInteractions.callReadFunction(
168
206
  outputs: [{ name: '', type: 'uint256' }],
169
207
  type: 'function',
170
208
  },
209
+ parameters: ['0x...']
171
210
  }
172
211
  );
173
212
 
174
213
  // Write to contract (triggers async workflow)
175
- const writeResult = await client.contractInteractions.callWriteFunction(
214
+ const writeResult = await client.contractInteractions.writeCallFunction(
176
215
  'network',
177
216
  'contractAddress',
178
217
  {
@@ -187,6 +226,7 @@ const writeResult = await client.contractInteractions.callWriteFunction(
187
226
  outputs: [],
188
227
  type: 'function',
189
228
  },
229
+ parameters: ['0x...', '1000000000000000000']
190
230
  }
191
231
  );
192
232
 
@@ -337,20 +377,53 @@ const profiles = await client.profiles.getProfiles({
337
377
 
338
378
  ## Error Handling
339
379
 
340
- The SDK provides comprehensive error handling:
380
+ The SDK provides comprehensive error handling with specific error types for different HTTP status codes:
341
381
 
342
382
  ```typescript
343
- import { OumlaSdkApiError, OumlaSdkApiTimeoutError } from '@oumla/sdk';
383
+ import {
384
+ OumlaSdkApiError,
385
+ OumlaSdkApiTimeoutError,
386
+ BadRequestError,
387
+ UnauthorizedError,
388
+ ForbiddenError,
389
+ NotFoundError,
390
+ ConflictError,
391
+ UnprocessableEntityError,
392
+ InternalServerError,
393
+ BadGatewayError,
394
+ ServiceUnavailableError,
395
+ GatewayTimeoutError
396
+ } from '@oumla/sdk';
344
397
 
345
398
  try {
346
399
  const result = await client.profiles.getProfiles();
347
400
  } catch (error) {
348
- if (error instanceof OumlaSdkApiError) {
401
+ if (error instanceof BadRequestError) {
402
+ console.error('Bad Request (400):', error.message);
403
+ } else if (error instanceof UnauthorizedError) {
404
+ console.error('Unauthorized (401):', error.message);
405
+ } else if (error instanceof ForbiddenError) {
406
+ console.error('Forbidden (403):', error.message);
407
+ } else if (error instanceof NotFoundError) {
408
+ console.error('Not Found (404):', error.message);
409
+ } else if (error instanceof ConflictError) {
410
+ console.error('Conflict (409):', error.message);
411
+ } else if (error instanceof UnprocessableEntityError) {
412
+ console.error('Unprocessable Entity (422):', error.message);
413
+ } else if (error instanceof InternalServerError) {
414
+ console.error('Internal Server Error (500):', error.message);
415
+ } else if (error instanceof BadGatewayError) {
416
+ console.error('Bad Gateway (502):', error.message);
417
+ } else if (error instanceof ServiceUnavailableError) {
418
+ console.error('Service Unavailable (503):', error.message);
419
+ } else if (error instanceof GatewayTimeoutError) {
420
+ console.error('Gateway Timeout (504):', error.message);
421
+ } else if (error instanceof OumlaSdkApiTimeoutError) {
422
+ console.error('Request timeout:', error.message);
423
+ } else if (error instanceof OumlaSdkApiError) {
349
424
  console.error('API Error:', error.message);
350
425
  console.error('Status Code:', error.statusCode);
351
426
  console.error('Response Body:', error.body);
352
- } else if (error instanceof OumlaSdkApiTimeoutError) {
353
- console.error('Request timeout:', error.message);
354
427
  } else {
355
428
  console.error('Unexpected error:', error);
356
429
  }