@oumla/sdk 1.2.3 → 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 +104 -31
- package/dist/index.cjs +3396 -1057
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2430 -1165
- package/dist/index.js +3396 -1057
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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
|
|
@@ -41,7 +49,7 @@ import { OumlaSdkApiClient, OumlaSdkApiEnvironment } from '@oumla/sdk';
|
|
|
41
49
|
// Initialize the client
|
|
42
50
|
const client = new OumlaSdkApiClient({
|
|
43
51
|
apiKey: 'your-api-key-here',
|
|
44
|
-
environment: OumlaSdkApiEnvironment.
|
|
52
|
+
environment: OumlaSdkApiEnvironment.Mainnet,
|
|
45
53
|
});
|
|
46
54
|
|
|
47
55
|
// Example: Get profiles
|
|
@@ -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.
|
|
68
|
+
const address = await client.addresses.createAddressV2({
|
|
61
69
|
reference: 'profile-reference',
|
|
62
|
-
network: '
|
|
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.
|
|
90
|
-
const wallet = await client.wallets.
|
|
97
|
+
const wallets = await client.wallets.getWalletsByProfile('profile-reference');
|
|
98
|
+
const wallet = await client.wallets.createWallet({
|
|
91
99
|
reference: 'profile-reference',
|
|
92
|
-
network: '
|
|
100
|
+
network: 'network'
|
|
93
101
|
});
|
|
94
102
|
```
|
|
95
103
|
|
|
96
|
-
### 📍 Addresses
|
|
97
|
-
Generate and manage blockchain addresses
|
|
104
|
+
### 📍 Addresses
|
|
105
|
+
Generate and manage blockchain addresses
|
|
98
106
|
```typescript
|
|
99
107
|
// Get addresses for a profile
|
|
100
|
-
const addresses = await client.addresses.
|
|
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.
|
|
112
|
+
// Generate a new address (V2 API - recommended)
|
|
113
|
+
const address = await client.addresses.createAddressV2({
|
|
104
114
|
reference: 'profile-reference',
|
|
105
|
-
network: '
|
|
115
|
+
network: 'network',
|
|
106
116
|
clientShare: 'your-client-share',
|
|
107
117
|
});
|
|
108
118
|
|
|
109
119
|
// Get organization addresses
|
|
110
|
-
const orgAddresses = await client.addresses.
|
|
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
|
-
|
|
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
|
-
###
|
|
120
|
-
Manage digital assets and
|
|
142
|
+
### 💼 Portfolio
|
|
143
|
+
Manage digital assets and portfolio tracking
|
|
121
144
|
```typescript
|
|
122
|
-
|
|
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.
|
|
164
|
+
const withdrawal = await client.withdrawals.createWithdraw({
|
|
129
165
|
walletId: 'wallet-id',
|
|
130
166
|
amount: '1.0',
|
|
131
|
-
currency: '
|
|
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.
|
|
139
|
-
const template = await client.contractTemplates.
|
|
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
|
|
155
|
-
const
|
|
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.
|
|
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.
|
|
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
|
|
|
@@ -308,7 +348,7 @@ import { OumlaSdkApiClient, OumlaSdkApiEnvironment } from '@oumla/sdk';
|
|
|
308
348
|
|
|
309
349
|
const client = new OumlaSdkApiClient({
|
|
310
350
|
apiKey: process.env.OUMLA_API_KEY!,
|
|
311
|
-
environment: OumlaSdkApiEnvironment.
|
|
351
|
+
environment: OumlaSdkApiEnvironment.Mainnet, // or custom URL
|
|
312
352
|
baseUrl: 'https://custom-api.oumla.com', // Optional: custom base URL
|
|
313
353
|
headers: {
|
|
314
354
|
'Custom-Header': 'value', // Optional: additional headers
|
|
@@ -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 {
|
|
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
|
|
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
|
}
|