@voidaisdk/bridge-sdk 0.0.4 → 1.0.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 +31 -27
- package/dist/api/client.js +13 -13
- package/dist/config.js +3 -3
- package/dist-browser/voidai-sdk.js +1 -1
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# VoidAI Bridge SDK
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/@voidaisdk/bridge-sdk)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
|
|
6
6
|
**TypeScript SDK for VoidAI Bridge** - Cross-chain asset bridging and routing across Bittensor, Ethereum, Solana, and other supported chains.
|
|
@@ -20,11 +20,11 @@ Perfect for building DeFi applications, cross-chain DEXs, or any app that needs
|
|
|
20
20
|
## 📦 Installation
|
|
21
21
|
|
|
22
22
|
```bash
|
|
23
|
-
npm install
|
|
23
|
+
npm install @voidaisdk/bridge-sdk
|
|
24
24
|
# or
|
|
25
|
-
yarn add
|
|
25
|
+
yarn add @voidaisdk/bridge-sdk
|
|
26
26
|
# or
|
|
27
|
-
pnpm add
|
|
27
|
+
pnpm add @voidaisdk/bridge-sdk
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
### Requirements
|
|
@@ -38,7 +38,7 @@ pnpm add voidai-sdk
|
|
|
38
38
|
### 1. Initialize the SDK
|
|
39
39
|
|
|
40
40
|
```typescript
|
|
41
|
-
import { BridgeSDK } from '
|
|
41
|
+
import { BridgeSDK } from '@voidaisdk/bridge-sdk';
|
|
42
42
|
|
|
43
43
|
const sdk = new BridgeSDK({
|
|
44
44
|
apiKey: process.env.VOIDAI_API_KEY!,
|
|
@@ -170,12 +170,16 @@ console.log('Total fee:', swapFee.totalFee);
|
|
|
170
170
|
|
|
171
171
|
**📖 [Full Documentation](docs/README.md)** - Complete API reference, guides, and examples
|
|
172
172
|
|
|
173
|
-
- [Getting Started
|
|
174
|
-
- [
|
|
175
|
-
- [
|
|
176
|
-
- [
|
|
177
|
-
- [
|
|
178
|
-
- [
|
|
173
|
+
- [Getting Started](docs/getting-started.md) – Installation, authentication, configuration
|
|
174
|
+
- [Wallets](docs/wallets.md) – Bittensor, EVM, Solana wallet connections
|
|
175
|
+
- [Bridge Operations](docs/bridge.md) – Cross-chain bridging
|
|
176
|
+
- [Router Swaps](docs/swap.md) – Token swaps via VoidAI Router
|
|
177
|
+
- [CCIP Routing](docs/ccip.md) – Cross-chain CCIP operations
|
|
178
|
+
- [Transactions](docs/transactions.md) – History, cancel, confirm
|
|
179
|
+
- [Server-Side Usage](docs/server.md) – Backend integration with BridgeSDKServer
|
|
180
|
+
- [API Reference](docs/api-reference.md) – SDK methods and types
|
|
181
|
+
- [FAQ](docs/FAQ.md) – Frequently asked questions
|
|
182
|
+
- [Error Handling](docs/error-handling.md) – Troubleshooting and error codes
|
|
179
183
|
|
|
180
184
|
## 💡 Key Features
|
|
181
185
|
|
|
@@ -224,12 +228,12 @@ console.log('Total fee:', swapFee.totalFee);
|
|
|
224
228
|
For server-side or backend integrations, use `BridgeSDKServer` with both `apiKey` and `secretKey`:
|
|
225
229
|
|
|
226
230
|
```typescript
|
|
227
|
-
import { BridgeSDKServer } from '
|
|
231
|
+
import { BridgeSDKServer } from '@voidaisdk/bridge-sdk';
|
|
228
232
|
|
|
229
233
|
const sdk = new BridgeSDKServer({
|
|
230
234
|
apiKey: process.env.VOIDAI_API_KEY!,
|
|
231
235
|
secretKey: process.env.VOIDAI_SECRET_KEY!,
|
|
232
|
-
environment: '
|
|
236
|
+
environment: 'mainnet', // 'devnet' | 'testnet' | 'mainnet'
|
|
233
237
|
});
|
|
234
238
|
|
|
235
239
|
await sdk.ready;
|
|
@@ -245,24 +249,24 @@ const result = await sdk.bridge.bridge({
|
|
|
245
249
|
|
|
246
250
|
## 🔧 Environment Configuration
|
|
247
251
|
|
|
248
|
-
The SDK supports three environments
|
|
252
|
+
The SDK supports three environments. The base URL and EVM bridge contract address are set per environment in the SDK config.
|
|
249
253
|
|
|
250
|
-
| Environment
|
|
251
|
-
|
|
|
252
|
-
| `
|
|
253
|
-
| `
|
|
254
|
-
| `
|
|
254
|
+
| Environment | Base URL | Bridge Contract (EVM) | Use Case |
|
|
255
|
+
| ----------- | ------------------------------------------------------ | ------------------------------------------- | -------------------------- |
|
|
256
|
+
| `devnet` | `https://api-sdk-dev.voidai.envistudios.com/api` | `0x6266ce15aC4f32F096Ff91881dd887a0F4bBa569` | Development & testing |
|
|
257
|
+
| `testnet` | `https://sdk-backend.voidai.com/sdk` | `0x4aA4396BfD6F268b427077079800F420dF947b63` | Staging / pre-production |
|
|
258
|
+
| `mainnet` | `https://sdk.voidai.com/sdk` | `0x604e8Ef901C0E69E79463D997ba7D0724A909b84` | Production |
|
|
255
259
|
|
|
256
260
|
## 📝 Example: Complete Bridge Flow
|
|
257
261
|
|
|
258
262
|
```typescript
|
|
259
|
-
import { BridgeSDK } from '
|
|
263
|
+
import { BridgeSDK } from '@voidaisdk/bridge-sdk';
|
|
260
264
|
|
|
261
265
|
async function bridgeTAO() {
|
|
262
266
|
// 1. Initialize SDK
|
|
263
267
|
const sdk = new BridgeSDK({
|
|
264
268
|
apiKey: process.env.VOIDAI_API_KEY!,
|
|
265
|
-
environment: '
|
|
269
|
+
environment: 'testnet', // or 'mainnet' for production
|
|
266
270
|
});
|
|
267
271
|
|
|
268
272
|
await sdk.ready;
|
|
@@ -365,11 +369,11 @@ bridge-sdk/
|
|
|
365
369
|
|
|
366
370
|
```html
|
|
367
371
|
<script type="module">
|
|
368
|
-
import { BridgeSDK } from './node_modules/
|
|
372
|
+
import { BridgeSDK } from './node_modules/@voidaisdk/bridge-sdk/dist-browser/voidai-sdk.js';
|
|
369
373
|
|
|
370
374
|
const sdk = new BridgeSDK({
|
|
371
375
|
apiKey: 'your-api-key',
|
|
372
|
-
environment: '
|
|
376
|
+
environment: 'mainnet', // 'devnet' | 'testnet' | 'mainnet'
|
|
373
377
|
});
|
|
374
378
|
</script>
|
|
375
379
|
```
|
|
@@ -377,10 +381,10 @@ bridge-sdk/
|
|
|
377
381
|
### Bundler (Webpack/Vite/Rollup)
|
|
378
382
|
|
|
379
383
|
```typescript
|
|
380
|
-
import { BridgeSDK } from '
|
|
384
|
+
import { BridgeSDK } from '@voidaisdk/bridge-sdk';
|
|
381
385
|
|
|
382
386
|
// Use normally - bundler will handle it
|
|
383
|
-
const sdk = new BridgeSDK({ apiKey, environment: '
|
|
387
|
+
const sdk = new BridgeSDK({ apiKey, environment: 'mainnet' }); // 'devnet' | 'testnet' | 'mainnet'
|
|
384
388
|
```
|
|
385
389
|
|
|
386
390
|
## ⚠️ Error Handling
|
|
@@ -412,7 +416,7 @@ See [Error Handling Guide](docs/error-handling.md) for detailed patterns.
|
|
|
412
416
|
- ✅ **Validate user inputs** before passing to SDK
|
|
413
417
|
- ✅ **Keep dependencies updated** - Monitor security advisories
|
|
414
418
|
|
|
415
|
-
See [
|
|
419
|
+
See [Full Documentation](docs/README.md) for more guidance.
|
|
416
420
|
|
|
417
421
|
## 📖 Examples
|
|
418
422
|
|
|
@@ -429,7 +433,7 @@ Check out the [example frontend app](examples/frontend/) for a complete integrat
|
|
|
429
433
|
|
|
430
434
|
- **Documentation**: [Full docs](docs/README.md)
|
|
431
435
|
- **Issues**: [GitHub Issues](https://github.com/your-org/bridge-sdk/issues)
|
|
432
|
-
- **FAQ**: [
|
|
436
|
+
- **FAQ**: [FAQ](docs/FAQ.md)
|
|
433
437
|
|
|
434
438
|
## 📄 License
|
|
435
439
|
|
package/dist/api/client.js
CHANGED
|
@@ -40,7 +40,7 @@ class VoidAIBridgeClient {
|
|
|
40
40
|
getLoginUrl() {
|
|
41
41
|
const baseUrl = this.config.getBaseUrl();
|
|
42
42
|
const cleanBase = baseUrl.replace(/\/$/, '');
|
|
43
|
-
return `${cleanBase}/
|
|
43
|
+
return `${cleanBase}/v1/auth/login`;
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
46
|
* Get EVM bridge contract address for burn operations.
|
|
@@ -222,7 +222,7 @@ class VoidAIBridgeClient {
|
|
|
222
222
|
* Bridge swap operation
|
|
223
223
|
*/
|
|
224
224
|
async bridgeSwap(payload) {
|
|
225
|
-
return this.post('
|
|
225
|
+
return this.post('v1/bridge/swap', payload);
|
|
226
226
|
}
|
|
227
227
|
/**
|
|
228
228
|
* Route transaction operation (SWAP / BRIDGE / CCIP)
|
|
@@ -234,7 +234,7 @@ class VoidAIBridgeClient {
|
|
|
234
234
|
...payload,
|
|
235
235
|
amount: String(payload.amount),
|
|
236
236
|
};
|
|
237
|
-
return this.post('
|
|
237
|
+
return this.post('v1/bridge/route-transaction', normalizedPayload);
|
|
238
238
|
}
|
|
239
239
|
/**
|
|
240
240
|
* Cancel a CCIP route transaction
|
|
@@ -246,7 +246,7 @@ class VoidAIBridgeClient {
|
|
|
246
246
|
toToken: params.toToken,
|
|
247
247
|
uuid: params.uuid,
|
|
248
248
|
};
|
|
249
|
-
return this.delete('
|
|
249
|
+
return this.delete('v1/bridge/cancel-ccip', queryParams);
|
|
250
250
|
}
|
|
251
251
|
/**
|
|
252
252
|
* Cancel a router swap transaction
|
|
@@ -255,13 +255,13 @@ class VoidAIBridgeClient {
|
|
|
255
255
|
const queryParams = {
|
|
256
256
|
uuid: params.uuid,
|
|
257
257
|
};
|
|
258
|
-
return this.delete('
|
|
258
|
+
return this.delete('v1/bridge/cancel-router-swap', queryParams);
|
|
259
259
|
}
|
|
260
260
|
/**
|
|
261
261
|
* Cancel a bridge swap transaction
|
|
262
262
|
*/
|
|
263
263
|
async cancelBridgeSwap(params) {
|
|
264
|
-
return this.patch('
|
|
264
|
+
return this.patch('v1/bridge/swap/cancel', params);
|
|
265
265
|
}
|
|
266
266
|
/**
|
|
267
267
|
* Get recent API transactions (tenant-level)
|
|
@@ -271,19 +271,19 @@ class VoidAIBridgeClient {
|
|
|
271
271
|
page: String(page),
|
|
272
272
|
limit: String(limit),
|
|
273
273
|
};
|
|
274
|
-
return this.get('
|
|
274
|
+
return this.get('v1/bridge/api-transactions', queryParams);
|
|
275
275
|
}
|
|
276
276
|
/**
|
|
277
277
|
* Manually validate a bridge burn transaction (EVM burn completion)
|
|
278
278
|
*/
|
|
279
279
|
async validateBurn(params) {
|
|
280
|
-
return this.post('
|
|
280
|
+
return this.post('v1/bridge/validate-burn', params);
|
|
281
281
|
}
|
|
282
282
|
/**
|
|
283
283
|
* Manually confirm a CCIP transaction
|
|
284
284
|
*/
|
|
285
285
|
async confirmCcipTransaction(params) {
|
|
286
|
-
const path = `
|
|
286
|
+
const path = `v1/bridge/transactions/${encodeURIComponent(params.transactionId)}/tx`;
|
|
287
287
|
const body = {
|
|
288
288
|
txnHash: params.txnHash,
|
|
289
289
|
operationType: params.operationType,
|
|
@@ -309,7 +309,7 @@ class VoidAIBridgeClient {
|
|
|
309
309
|
if (options?.chainId !== undefined) {
|
|
310
310
|
params.chain_id = options.chainId;
|
|
311
311
|
}
|
|
312
|
-
const response = await this.get('
|
|
312
|
+
const response = await this.get('v1/chain/chains', params);
|
|
313
313
|
if (!response.success || !response.data) {
|
|
314
314
|
throw new Error(response.message || 'Failed to fetch chains');
|
|
315
315
|
}
|
|
@@ -323,7 +323,7 @@ class VoidAIBridgeClient {
|
|
|
323
323
|
page: String(page),
|
|
324
324
|
limit: String(limit),
|
|
325
325
|
};
|
|
326
|
-
const response = await this.get('
|
|
326
|
+
const response = await this.get('v1/asset/assets', queryParams);
|
|
327
327
|
if (!response.success || !response.data) {
|
|
328
328
|
throw new Error(response.message || 'Failed to fetch assets');
|
|
329
329
|
}
|
|
@@ -343,7 +343,7 @@ class VoidAIBridgeClient {
|
|
|
343
343
|
toToken: params.toToken,
|
|
344
344
|
amount: String(params.amount),
|
|
345
345
|
};
|
|
346
|
-
return this.get('
|
|
346
|
+
return this.get('v1/bridge/call-fee', queryParams);
|
|
347
347
|
}
|
|
348
348
|
/**
|
|
349
349
|
* Get router swap fee estimate
|
|
@@ -357,7 +357,7 @@ class VoidAIBridgeClient {
|
|
|
357
357
|
operationType: params.operationType,
|
|
358
358
|
toAddress: params.toAddress,
|
|
359
359
|
};
|
|
360
|
-
return this.get('
|
|
360
|
+
return this.get('v1/router-swap/call-fee', queryParams);
|
|
361
361
|
}
|
|
362
362
|
/**
|
|
363
363
|
* Normalize and rethrow errors with backend message (if available) so
|
package/dist/config.js
CHANGED
|
@@ -27,15 +27,15 @@ class BridgeConfig {
|
|
|
27
27
|
exports.BridgeConfig = BridgeConfig;
|
|
28
28
|
BridgeConfig.DEFAULTS = {
|
|
29
29
|
devnet: {
|
|
30
|
-
baseUrl: 'https://api-sdk-dev.voidai.envistudios.com/',
|
|
30
|
+
baseUrl: 'https://api-sdk-dev.voidai.envistudios.com/api',
|
|
31
31
|
bridgeContractAddress: '0x6266ce15aC4f32F096Ff91881dd887a0F4bBa569',
|
|
32
32
|
},
|
|
33
33
|
testnet: {
|
|
34
|
-
baseUrl: 'https://sdk-backend.voidai.com/',
|
|
34
|
+
baseUrl: 'https://sdk-backend.voidai.com/sdk',
|
|
35
35
|
bridgeContractAddress: '0x4aA4396BfD6F268b427077079800F420dF947b63',
|
|
36
36
|
},
|
|
37
37
|
mainnet: {
|
|
38
|
-
baseUrl: 'https://
|
|
38
|
+
baseUrl: 'https://sdk.voidai.com/sdk',
|
|
39
39
|
bridgeContractAddress: '0x604e8Ef901C0E69E79463D997ba7D0724A909b84',
|
|
40
40
|
},
|
|
41
41
|
};
|