@voidaisdk/bridge-sdk 0.0.1
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 +435 -0
- package/dist/api/client.d.ts +118 -0
- package/dist/api/client.js +449 -0
- package/dist/config.d.ts +19 -0
- package/dist/config.js +41 -0
- package/dist/core/bridge.d.ts +70 -0
- package/dist/core/bridge.js +213 -0
- package/dist/index.d.ts +55 -0
- package/dist/index.js +72 -0
- package/dist/types/index.d.ts +280 -0
- package/dist/types/index.js +2 -0
- package/dist/utils/validation.d.ts +2 -0
- package/dist/utils/validation.js +12 -0
- package/dist/wallet/bittensor.d.ts +59 -0
- package/dist/wallet/bittensor.js +143 -0
- package/dist/wallet/ethereum.d.ts +42 -0
- package/dist/wallet/ethereum.js +107 -0
- package/dist/wallet/solana.d.ts +36 -0
- package/dist/wallet/solana.js +100 -0
- package/dist-browser/voidai-sdk.js +2 -0
- package/dist-browser/voidai-sdk.js.LICENSE.txt +5 -0
- package/package.json +56 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Bridge = void 0;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
/**
|
|
6
|
+
* Bridge API Methods
|
|
7
|
+
* Provides read-only API methods for bridge operations
|
|
8
|
+
*/
|
|
9
|
+
class Bridge {
|
|
10
|
+
constructor(apiClient) {
|
|
11
|
+
this.apiClient = apiClient;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Get transaction status
|
|
15
|
+
*/
|
|
16
|
+
async getTransactionStatus(txId) {
|
|
17
|
+
const { status } = await this.apiClient.get(`/transactions/${txId}/status`);
|
|
18
|
+
return status;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Get transaction history for an address
|
|
22
|
+
*/
|
|
23
|
+
async getHistory(address) {
|
|
24
|
+
return this.apiClient.get(`/transactions/history/${address}`);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Initiate a bridge operation (formerly swap).
|
|
28
|
+
*/
|
|
29
|
+
async bridge(payload) {
|
|
30
|
+
try {
|
|
31
|
+
const response = await this.apiClient.bridgeSwap(payload);
|
|
32
|
+
// For EVM flows that return encodedData + signature, prepare
|
|
33
|
+
// a ready-to-send Ethereum transaction for the bridge contract.
|
|
34
|
+
const maybeWithEncoded = response;
|
|
35
|
+
if (maybeWithEncoded.encodedData && maybeWithEncoded.signature) {
|
|
36
|
+
// IMPORTANT:
|
|
37
|
+
// - The bridge contract address is configured per environment
|
|
38
|
+
// in BridgeConfig (config.ts). The encodedData & signature are
|
|
39
|
+
// already validated/constructed by the backend.
|
|
40
|
+
// - We simply ABI-encode the function call so frontend integrators
|
|
41
|
+
// can pass it directly to MetaMask / wallet providers.
|
|
42
|
+
const bridgeContractAddress = this.apiClient.getBridgeContractAddress();
|
|
43
|
+
const calldata = (0, viem_1.encodeFunctionData)({
|
|
44
|
+
abi: [
|
|
45
|
+
{
|
|
46
|
+
type: 'function',
|
|
47
|
+
name: 'burn',
|
|
48
|
+
stateMutability: 'nonpayable',
|
|
49
|
+
inputs: [
|
|
50
|
+
{ name: 'encodedData', type: 'bytes' },
|
|
51
|
+
{ name: 'signature', type: 'bytes' },
|
|
52
|
+
],
|
|
53
|
+
outputs: [],
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
functionName: 'burn',
|
|
57
|
+
args: [maybeWithEncoded.encodedData, maybeWithEncoded.signature],
|
|
58
|
+
});
|
|
59
|
+
// Attach the prepared transaction payload in a non-breaking way.
|
|
60
|
+
maybeWithEncoded.evmTransaction = {
|
|
61
|
+
to: bridgeContractAddress,
|
|
62
|
+
data: calldata,
|
|
63
|
+
value: '0x0',
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
return response;
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
// Surface a clean error message while preserving the original error for debugging.
|
|
70
|
+
const message = error?.message || 'Failed to execute bridge swap';
|
|
71
|
+
throw new Error(message);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Alias for backward compatibility.
|
|
76
|
+
*/
|
|
77
|
+
async swap(payload) {
|
|
78
|
+
return this.bridge(payload);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Route a SWAP operation through the unified route-transaction API.
|
|
82
|
+
*/
|
|
83
|
+
async routeSwap(payload) {
|
|
84
|
+
try {
|
|
85
|
+
return await this.apiClient.routeTransaction(payload);
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
const message = error?.message || 'Failed to route SWAP transaction';
|
|
89
|
+
throw new Error(message);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Route a BRIDGE operation through the unified route-transaction API.
|
|
94
|
+
*/
|
|
95
|
+
async routeBridge(payload) {
|
|
96
|
+
try {
|
|
97
|
+
return await this.apiClient.routeTransaction(payload);
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
const message = error?.message || 'Failed to route BRIDGE transaction';
|
|
101
|
+
throw new Error(message);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Route a CCIP operation through the unified route-transaction API.
|
|
106
|
+
*/
|
|
107
|
+
async routeCcip(payload) {
|
|
108
|
+
try {
|
|
109
|
+
return await this.apiClient.routeTransaction(payload);
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
const message = error?.message || 'Failed to route CCIP transaction';
|
|
113
|
+
throw new Error(message);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Get bridge fee estimate
|
|
118
|
+
*/
|
|
119
|
+
async getBridgeFeeEstimate(params) {
|
|
120
|
+
try {
|
|
121
|
+
return await this.apiClient.getBridgeFeeEstimate(params);
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
const message = error?.message || 'Failed to get bridge fee estimate';
|
|
125
|
+
throw new Error(message);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Get router swap fee estimate
|
|
130
|
+
*/
|
|
131
|
+
async getRouterSwapFeeEstimate(params) {
|
|
132
|
+
try {
|
|
133
|
+
return await this.apiClient.getRouterSwapFeeEstimate(params);
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
const message = error?.message || 'Failed to get router swap fee estimate';
|
|
137
|
+
throw new Error(message);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Cancel a CCIP route transaction
|
|
142
|
+
*/
|
|
143
|
+
async cancelCcipRoute(params) {
|
|
144
|
+
try {
|
|
145
|
+
return await this.apiClient.cancelCcip(params);
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
const message = error?.message || 'Failed to cancel CCIP transaction';
|
|
149
|
+
throw new Error(message);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Cancel a router swap transaction
|
|
154
|
+
*/
|
|
155
|
+
async cancelRouterSwap(params) {
|
|
156
|
+
try {
|
|
157
|
+
return await this.apiClient.cancelRouterSwap(params);
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
const message = error?.message || 'Failed to cancel router swap transaction';
|
|
161
|
+
throw new Error(message);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Cancel a bridge swap transaction
|
|
166
|
+
*/
|
|
167
|
+
async cancelBridgeSwap(params) {
|
|
168
|
+
try {
|
|
169
|
+
return await this.apiClient.cancelBridgeSwap(params);
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
const message = error?.message || 'Failed to cancel bridge transaction';
|
|
173
|
+
throw new Error(message);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Get recent API transactions for the current tenant
|
|
178
|
+
*/
|
|
179
|
+
async getRecentTransactions(page = 1, limit = 20) {
|
|
180
|
+
try {
|
|
181
|
+
return await this.apiClient.getApiTransactions(page, limit);
|
|
182
|
+
}
|
|
183
|
+
catch (error) {
|
|
184
|
+
const message = error?.message || 'Failed to fetch recent transactions';
|
|
185
|
+
throw new Error(message);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Manually validate a bridge burn transaction
|
|
190
|
+
*/
|
|
191
|
+
async validateBurnTransaction(params) {
|
|
192
|
+
try {
|
|
193
|
+
return await this.apiClient.validateBurn(params);
|
|
194
|
+
}
|
|
195
|
+
catch (error) {
|
|
196
|
+
const message = error?.message || 'Failed to validate burn transaction';
|
|
197
|
+
throw new Error(message);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Manually confirm a CCIP transaction
|
|
202
|
+
*/
|
|
203
|
+
async confirmCcipTransaction(params) {
|
|
204
|
+
try {
|
|
205
|
+
return await this.apiClient.confirmCcipTransaction(params);
|
|
206
|
+
}
|
|
207
|
+
catch (error) {
|
|
208
|
+
const message = error?.message || 'Failed to confirm CCIP transaction';
|
|
209
|
+
throw new Error(message);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
exports.Bridge = Bridge;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { BridgeConfig } from './config';
|
|
2
|
+
import { VoidAIBridgeClient } from './api/client';
|
|
3
|
+
import { BittensorWallet } from './wallet/bittensor';
|
|
4
|
+
import { EthereumWallet } from './wallet/ethereum';
|
|
5
|
+
import { SolanaWallet } from './wallet/solana';
|
|
6
|
+
import { Bridge } from './core/bridge';
|
|
7
|
+
import { BridgeSDKOptions, BridgeSDKServerOptions, ApiKeyValidationData } from './types';
|
|
8
|
+
export * from './types';
|
|
9
|
+
export * from './config';
|
|
10
|
+
export * from './wallet/bittensor';
|
|
11
|
+
export * from './wallet/ethereum';
|
|
12
|
+
export * from './wallet/solana';
|
|
13
|
+
/**
|
|
14
|
+
* BridgeSDK – for frontend/browser usage.
|
|
15
|
+
* Use apiKey only; do not pass secretKey in frontend.
|
|
16
|
+
*/
|
|
17
|
+
export declare class BridgeSDK {
|
|
18
|
+
readonly config: BridgeConfig;
|
|
19
|
+
readonly api: VoidAIBridgeClient;
|
|
20
|
+
readonly wallets: {
|
|
21
|
+
bittensor: BittensorWallet;
|
|
22
|
+
ethereum: EthereumWallet;
|
|
23
|
+
solana: SolanaWallet;
|
|
24
|
+
};
|
|
25
|
+
readonly bridge: Bridge;
|
|
26
|
+
/**
|
|
27
|
+
* Resolves once the SDK has validated the API key (or rejects if invalid).
|
|
28
|
+
* Consumers can await this if they want to gate UI on readiness.
|
|
29
|
+
*/
|
|
30
|
+
readonly ready: Promise<void>;
|
|
31
|
+
constructor(options: BridgeSDKOptions);
|
|
32
|
+
/**
|
|
33
|
+
* Get validated API key data (available after successful validation)
|
|
34
|
+
*/
|
|
35
|
+
getValidatedApiKeyData(): ApiKeyValidationData | null;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* BridgeSDKServer – for backend/server usage.
|
|
39
|
+
* Requires apiKey + secretKey for JWT authentication.
|
|
40
|
+
* No wallet integrations (use BridgeSDK in frontend for that).
|
|
41
|
+
*/
|
|
42
|
+
export declare class BridgeSDKServer {
|
|
43
|
+
readonly config: BridgeConfig;
|
|
44
|
+
readonly api: VoidAIBridgeClient;
|
|
45
|
+
readonly bridge: Bridge;
|
|
46
|
+
/**
|
|
47
|
+
* Resolves once the SDK has validated the API key (or rejects if invalid).
|
|
48
|
+
*/
|
|
49
|
+
readonly ready: Promise<void>;
|
|
50
|
+
constructor(options: BridgeSDKServerOptions);
|
|
51
|
+
/**
|
|
52
|
+
* Get validated API key data (available after successful validation)
|
|
53
|
+
*/
|
|
54
|
+
getValidatedApiKeyData(): ApiKeyValidationData | null;
|
|
55
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.BridgeSDKServer = exports.BridgeSDK = void 0;
|
|
18
|
+
const config_1 = require("./config");
|
|
19
|
+
const client_1 = require("./api/client");
|
|
20
|
+
const bittensor_1 = require("./wallet/bittensor");
|
|
21
|
+
const ethereum_1 = require("./wallet/ethereum");
|
|
22
|
+
const solana_1 = require("./wallet/solana");
|
|
23
|
+
const bridge_1 = require("./core/bridge");
|
|
24
|
+
__exportStar(require("./types"), exports);
|
|
25
|
+
__exportStar(require("./config"), exports);
|
|
26
|
+
__exportStar(require("./wallet/bittensor"), exports);
|
|
27
|
+
__exportStar(require("./wallet/ethereum"), exports);
|
|
28
|
+
__exportStar(require("./wallet/solana"), exports);
|
|
29
|
+
/**
|
|
30
|
+
* BridgeSDK – for frontend/browser usage.
|
|
31
|
+
* Use apiKey only; do not pass secretKey in frontend.
|
|
32
|
+
*/
|
|
33
|
+
class BridgeSDK {
|
|
34
|
+
constructor(options) {
|
|
35
|
+
this.config = new config_1.BridgeConfig(options);
|
|
36
|
+
this.api = new client_1.VoidAIBridgeClient(this.config);
|
|
37
|
+
this.ready = this.api.ready;
|
|
38
|
+
this.wallets = {
|
|
39
|
+
bittensor: new bittensor_1.BittensorWallet(),
|
|
40
|
+
ethereum: new ethereum_1.EthereumWallet(),
|
|
41
|
+
solana: new solana_1.SolanaWallet()
|
|
42
|
+
};
|
|
43
|
+
this.bridge = new bridge_1.Bridge(this.api);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get validated API key data (available after successful validation)
|
|
47
|
+
*/
|
|
48
|
+
getValidatedApiKeyData() {
|
|
49
|
+
return this.api.getValidatedApiKeyData();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.BridgeSDK = BridgeSDK;
|
|
53
|
+
/**
|
|
54
|
+
* BridgeSDKServer – for backend/server usage.
|
|
55
|
+
* Requires apiKey + secretKey for JWT authentication.
|
|
56
|
+
* No wallet integrations (use BridgeSDK in frontend for that).
|
|
57
|
+
*/
|
|
58
|
+
class BridgeSDKServer {
|
|
59
|
+
constructor(options) {
|
|
60
|
+
this.config = new config_1.BridgeConfig(options);
|
|
61
|
+
this.api = new client_1.VoidAIBridgeClient(this.config);
|
|
62
|
+
this.ready = this.api.ready;
|
|
63
|
+
this.bridge = new bridge_1.Bridge(this.api);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Get validated API key data (available after successful validation)
|
|
67
|
+
*/
|
|
68
|
+
getValidatedApiKeyData() {
|
|
69
|
+
return this.api.getValidatedApiKeyData();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.BridgeSDKServer = BridgeSDKServer;
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
export type Environment = 'devnet' | 'testnet' | 'mainnet';
|
|
2
|
+
/**
|
|
3
|
+
* Options for BridgeSDK (frontend usage).
|
|
4
|
+
* Use apiKey only; secretKey is not supported for frontend.
|
|
5
|
+
*/
|
|
6
|
+
export interface BridgeSDKOptions {
|
|
7
|
+
apiKey: string;
|
|
8
|
+
environment?: Environment;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Options for BridgeSDKServer (backend usage).
|
|
12
|
+
* Requires both apiKey and secretKey for JWT authentication.
|
|
13
|
+
*/
|
|
14
|
+
export interface BridgeSDKServerOptions {
|
|
15
|
+
apiKey: string;
|
|
16
|
+
secretKey: string;
|
|
17
|
+
environment?: Environment;
|
|
18
|
+
}
|
|
19
|
+
export interface Chain {
|
|
20
|
+
id: number;
|
|
21
|
+
name: string;
|
|
22
|
+
chainId: string;
|
|
23
|
+
network: string;
|
|
24
|
+
isActive: boolean;
|
|
25
|
+
logoUri: string;
|
|
26
|
+
isCcipSupported: boolean;
|
|
27
|
+
ccipBridgeConfigurationStatus: string;
|
|
28
|
+
ccipChainSelector: string | null;
|
|
29
|
+
ccipRouterAddress: string | null;
|
|
30
|
+
ccipAdminRegistryContract: string | null;
|
|
31
|
+
ccipSupportedInBounds: string[];
|
|
32
|
+
ccipSupportedOutBounds: string[];
|
|
33
|
+
voidAiRouterAddress: string | null;
|
|
34
|
+
ccipRmnProxy?: string | null;
|
|
35
|
+
ccipRegistryModuleOwnerCustom?: string | null;
|
|
36
|
+
createdAt: string;
|
|
37
|
+
updatedAt: string;
|
|
38
|
+
}
|
|
39
|
+
export interface AssetBalance {
|
|
40
|
+
tokenAddress: string;
|
|
41
|
+
balance: string;
|
|
42
|
+
decimals: number;
|
|
43
|
+
formatted: string;
|
|
44
|
+
}
|
|
45
|
+
export interface Asset {
|
|
46
|
+
id: number;
|
|
47
|
+
chainId: string;
|
|
48
|
+
tokenName: string;
|
|
49
|
+
symbol: string;
|
|
50
|
+
decimal: number;
|
|
51
|
+
type: string | null;
|
|
52
|
+
tokenPoolAddress: string;
|
|
53
|
+
tokenPoolType: string;
|
|
54
|
+
tokenAddress: string;
|
|
55
|
+
isActive: boolean;
|
|
56
|
+
metadata: Record<string, any>;
|
|
57
|
+
subnetId: number;
|
|
58
|
+
createdAt: string;
|
|
59
|
+
updatedAt: string;
|
|
60
|
+
}
|
|
61
|
+
export interface Pagination {
|
|
62
|
+
total: number;
|
|
63
|
+
page: number;
|
|
64
|
+
limit: number;
|
|
65
|
+
totalPages: number;
|
|
66
|
+
}
|
|
67
|
+
export interface ChainsApiResponse {
|
|
68
|
+
success: boolean;
|
|
69
|
+
message: string;
|
|
70
|
+
data: {
|
|
71
|
+
chains: Chain[];
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export interface AssetsApiResponse {
|
|
75
|
+
success: boolean;
|
|
76
|
+
message: string;
|
|
77
|
+
data: {
|
|
78
|
+
assets: Asset[];
|
|
79
|
+
pagination: Pagination;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
export interface ApiKeyValidationData {
|
|
83
|
+
keyId: string;
|
|
84
|
+
tenantId: string;
|
|
85
|
+
name: string;
|
|
86
|
+
}
|
|
87
|
+
export interface ApiKeyValidationSuccessResponse {
|
|
88
|
+
success: true;
|
|
89
|
+
data: ApiKeyValidationData;
|
|
90
|
+
}
|
|
91
|
+
export interface ApiKeyValidationErrorResponse {
|
|
92
|
+
success: false;
|
|
93
|
+
error: {
|
|
94
|
+
code: string;
|
|
95
|
+
message: string;
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
export type ApiKeyValidationResponse = ApiKeyValidationSuccessResponse | ApiKeyValidationErrorResponse;
|
|
99
|
+
export interface AuthLoginRequest {
|
|
100
|
+
apiKey: string;
|
|
101
|
+
secretKey?: string;
|
|
102
|
+
}
|
|
103
|
+
export interface AuthLoginSuccessResponse {
|
|
104
|
+
success: true;
|
|
105
|
+
accessToken: string;
|
|
106
|
+
}
|
|
107
|
+
export interface AuthLoginErrorResponse {
|
|
108
|
+
success: false;
|
|
109
|
+
error?: {
|
|
110
|
+
code?: string;
|
|
111
|
+
message?: string;
|
|
112
|
+
};
|
|
113
|
+
message?: string;
|
|
114
|
+
}
|
|
115
|
+
export type AuthLoginResponse = AuthLoginSuccessResponse | AuthLoginErrorResponse;
|
|
116
|
+
export interface BridgeSwapRequest {
|
|
117
|
+
fromWallet: string;
|
|
118
|
+
toWallet: string;
|
|
119
|
+
fromToken: string;
|
|
120
|
+
toToken: string;
|
|
121
|
+
fromChain: string;
|
|
122
|
+
toChain: string;
|
|
123
|
+
amount: number;
|
|
124
|
+
subnetId?: number;
|
|
125
|
+
}
|
|
126
|
+
export interface BridgeSwapResponseBase {
|
|
127
|
+
identifier: string;
|
|
128
|
+
/**
|
|
129
|
+
* Destination address that must receive the bridged funds.
|
|
130
|
+
* For BITTENSOR -> EVM/TAO flows, this is the hot wallet /
|
|
131
|
+
* recipient address returned by the backend.
|
|
132
|
+
*/
|
|
133
|
+
toAddress?: string;
|
|
134
|
+
}
|
|
135
|
+
export interface BridgeSwapResponseWithEncodedData extends BridgeSwapResponseBase {
|
|
136
|
+
encodedData: string;
|
|
137
|
+
signature: string;
|
|
138
|
+
/**
|
|
139
|
+
* Optional helper payload prepared by the SDK for
|
|
140
|
+
* EVM burn transactions (wTAO/wALPHA -> TAO/ALPHA).
|
|
141
|
+
* Frontends can pass this directly to wallet providers.
|
|
142
|
+
*/
|
|
143
|
+
evmTransaction?: {
|
|
144
|
+
to: string;
|
|
145
|
+
data: string;
|
|
146
|
+
value: string;
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
export interface BridgeSwapResponseWithSubnet extends BridgeSwapResponseBase {
|
|
150
|
+
subnetDestinationHotkey: string;
|
|
151
|
+
}
|
|
152
|
+
export type BridgeSwapResponse = BridgeSwapResponseWithEncodedData | BridgeSwapResponseWithSubnet | BridgeSwapResponseBase;
|
|
153
|
+
export type RouteOperationType = 'SWAP' | 'BRIDGE' | 'CCIP';
|
|
154
|
+
export interface RouteSwapRequest {
|
|
155
|
+
operationType: 'SWAP';
|
|
156
|
+
originAssetId: number;
|
|
157
|
+
destinationAssetId: number;
|
|
158
|
+
fromAddress: string;
|
|
159
|
+
toAddress: string;
|
|
160
|
+
amount: number;
|
|
161
|
+
}
|
|
162
|
+
export interface RouteBridgeRequest {
|
|
163
|
+
operationType: 'BRIDGE';
|
|
164
|
+
fromChain: string;
|
|
165
|
+
toChain: string;
|
|
166
|
+
fromToken: string;
|
|
167
|
+
toToken: string;
|
|
168
|
+
fromWallet: string;
|
|
169
|
+
toWallet: string;
|
|
170
|
+
amount: number;
|
|
171
|
+
subnetId?: number;
|
|
172
|
+
}
|
|
173
|
+
export interface RouteCcipRequest {
|
|
174
|
+
operationType: 'CCIP';
|
|
175
|
+
originAssetId: number;
|
|
176
|
+
destinationAssetId: number;
|
|
177
|
+
fromAddress: string;
|
|
178
|
+
toAddress: string;
|
|
179
|
+
amount: number;
|
|
180
|
+
}
|
|
181
|
+
export type RouteTransactionRequest = RouteSwapRequest | RouteBridgeRequest | RouteCcipRequest;
|
|
182
|
+
export interface RouteTransactionResponseData {
|
|
183
|
+
to: string;
|
|
184
|
+
data: string;
|
|
185
|
+
value: string;
|
|
186
|
+
chainId: number;
|
|
187
|
+
}
|
|
188
|
+
export interface RouteTransactionResponse {
|
|
189
|
+
operationType: RouteOperationType;
|
|
190
|
+
identifier: string;
|
|
191
|
+
success: boolean;
|
|
192
|
+
message: string;
|
|
193
|
+
data?: RouteTransactionResponseData;
|
|
194
|
+
ccipFee?: string;
|
|
195
|
+
}
|
|
196
|
+
export interface BridgeFeeEstimateRequest {
|
|
197
|
+
fromToken: string;
|
|
198
|
+
toToken: string;
|
|
199
|
+
amount: number;
|
|
200
|
+
}
|
|
201
|
+
export interface BridgeFeeEstimateResponse {
|
|
202
|
+
success: boolean;
|
|
203
|
+
message: string;
|
|
204
|
+
data: {
|
|
205
|
+
fee: string;
|
|
206
|
+
recipientAmount: string;
|
|
207
|
+
tenantFee: string;
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
export interface RouterSwapFeeEstimateRequest {
|
|
211
|
+
originAssetId: number;
|
|
212
|
+
destinationAssetId: number;
|
|
213
|
+
amount: number;
|
|
214
|
+
operationType: RouteOperationType;
|
|
215
|
+
toAddress: string;
|
|
216
|
+
}
|
|
217
|
+
export interface RouterSwapFeeEstimateResponse {
|
|
218
|
+
swapAmount: string;
|
|
219
|
+
totalFee: string;
|
|
220
|
+
platformFee: string;
|
|
221
|
+
ccipFee: string;
|
|
222
|
+
tenantFee: string;
|
|
223
|
+
}
|
|
224
|
+
export interface CancelCcipRequest {
|
|
225
|
+
operationType: 'CCIP';
|
|
226
|
+
fromToken: string;
|
|
227
|
+
toToken: string;
|
|
228
|
+
uuid: string;
|
|
229
|
+
}
|
|
230
|
+
export interface CancelRouterSwapRequest {
|
|
231
|
+
uuid: string;
|
|
232
|
+
}
|
|
233
|
+
export interface CancelBridgeSwapRequest {
|
|
234
|
+
fromToken: string;
|
|
235
|
+
toToken: string;
|
|
236
|
+
uuid: string;
|
|
237
|
+
}
|
|
238
|
+
export interface CancelOperationResponse {
|
|
239
|
+
success: boolean;
|
|
240
|
+
message: string;
|
|
241
|
+
}
|
|
242
|
+
export interface ValidateBurnRequest {
|
|
243
|
+
transactionHash: string;
|
|
244
|
+
identifier: string;
|
|
245
|
+
}
|
|
246
|
+
export interface ValidateBurnResponse {
|
|
247
|
+
success: boolean;
|
|
248
|
+
message: string;
|
|
249
|
+
identifier: string;
|
|
250
|
+
burnDetails: Record<string, any>;
|
|
251
|
+
}
|
|
252
|
+
export interface CcipTxConfirmationRequest {
|
|
253
|
+
transactionId: string;
|
|
254
|
+
txnHash: string;
|
|
255
|
+
operationType: string;
|
|
256
|
+
txnStatus: string;
|
|
257
|
+
}
|
|
258
|
+
export interface CcipTxConfirmationResponse {
|
|
259
|
+
success: boolean;
|
|
260
|
+
message?: string;
|
|
261
|
+
}
|
|
262
|
+
export interface ApiTransactionItem {
|
|
263
|
+
id: string;
|
|
264
|
+
transactionUuid: string;
|
|
265
|
+
functionName: string;
|
|
266
|
+
feeAmount: string;
|
|
267
|
+
status: string;
|
|
268
|
+
transactionHash: {
|
|
269
|
+
chain_hash?: string;
|
|
270
|
+
completion_hash?: string;
|
|
271
|
+
};
|
|
272
|
+
createdAt: string;
|
|
273
|
+
}
|
|
274
|
+
export interface ApiTransactionsResponse {
|
|
275
|
+
items: ApiTransactionItem[];
|
|
276
|
+
page: number;
|
|
277
|
+
limit: number;
|
|
278
|
+
totalItems: number;
|
|
279
|
+
totalPages: number;
|
|
280
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isValidHash = exports.isValidAddress = void 0;
|
|
4
|
+
const isValidAddress = (address) => {
|
|
5
|
+
// Basic hex validation for generic blockchain address
|
|
6
|
+
return /^0x[a-fA-F0-9]{40,}$/.test(address);
|
|
7
|
+
};
|
|
8
|
+
exports.isValidAddress = isValidAddress;
|
|
9
|
+
const isValidHash = (hash) => {
|
|
10
|
+
return /^0x[a-fA-F0-9]{64}$/.test(hash);
|
|
11
|
+
};
|
|
12
|
+
exports.isValidHash = isValidHash;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bittensor Wallet Connection
|
|
3
|
+
* Handles connection to Bittensor-compatible wallets (Talisman, Subwallet, Polkadot.js)
|
|
4
|
+
*/
|
|
5
|
+
export interface BittensorAccount {
|
|
6
|
+
address: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
source: string;
|
|
9
|
+
}
|
|
10
|
+
export interface BittensorWalletExtension {
|
|
11
|
+
accounts: {
|
|
12
|
+
get: () => Promise<BittensorAccount[]>;
|
|
13
|
+
};
|
|
14
|
+
signer?: {
|
|
15
|
+
signRaw?: (options: {
|
|
16
|
+
address: string;
|
|
17
|
+
data: string;
|
|
18
|
+
}) => Promise<{
|
|
19
|
+
signature: string;
|
|
20
|
+
}>;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export declare class BittensorWallet {
|
|
24
|
+
private extension;
|
|
25
|
+
private account;
|
|
26
|
+
private extensionName;
|
|
27
|
+
/**
|
|
28
|
+
* Connect to a Bittensor-compatible wallet
|
|
29
|
+
* @param extensionName - Optional: specific extension name ('talisman', 'subwallet-js', 'polkadot-js')
|
|
30
|
+
* @returns Connected account information
|
|
31
|
+
*/
|
|
32
|
+
connect(extensionName?: string): Promise<BittensorAccount>;
|
|
33
|
+
/**
|
|
34
|
+
* Get currently connected account
|
|
35
|
+
*/
|
|
36
|
+
getAccount(): BittensorAccount | null;
|
|
37
|
+
/**
|
|
38
|
+
* Get extension name
|
|
39
|
+
*/
|
|
40
|
+
getExtensionName(): string | null;
|
|
41
|
+
/**
|
|
42
|
+
* Check if wallet is connected
|
|
43
|
+
*/
|
|
44
|
+
isConnected(): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Disconnect wallet
|
|
47
|
+
* Note: This only disconnects from the SDK. To fully disconnect from the extension,
|
|
48
|
+
* users need to disconnect accounts in their wallet extension settings.
|
|
49
|
+
*/
|
|
50
|
+
disconnect(): void;
|
|
51
|
+
/**
|
|
52
|
+
* Check if wallet extension is available
|
|
53
|
+
*/
|
|
54
|
+
static isExtensionAvailable(extensionName?: string): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Get the wallet extension instance (for advanced usage)
|
|
57
|
+
*/
|
|
58
|
+
getExtension(): BittensorWalletExtension | null;
|
|
59
|
+
}
|