@veridex/sdk 1.0.0-beta.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/CHANGELOG.md +73 -0
- package/LICENSE +21 -0
- package/README.md +212 -0
- package/dist/chains/aptos/index.d.mts +140 -0
- package/dist/chains/aptos/index.d.ts +140 -0
- package/dist/chains/aptos/index.js +563 -0
- package/dist/chains/aptos/index.js.map +1 -0
- package/dist/chains/aptos/index.mjs +536 -0
- package/dist/chains/aptos/index.mjs.map +1 -0
- package/dist/chains/evm/index.d.mts +5 -0
- package/dist/chains/evm/index.d.ts +5 -0
- package/dist/chains/evm/index.js +1233 -0
- package/dist/chains/evm/index.js.map +1 -0
- package/dist/chains/evm/index.mjs +1205 -0
- package/dist/chains/evm/index.mjs.map +1 -0
- package/dist/chains/solana/index.d.mts +116 -0
- package/dist/chains/solana/index.d.ts +116 -0
- package/dist/chains/solana/index.js +513 -0
- package/dist/chains/solana/index.js.map +1 -0
- package/dist/chains/solana/index.mjs +491 -0
- package/dist/chains/solana/index.mjs.map +1 -0
- package/dist/chains/starknet/index.d.mts +172 -0
- package/dist/chains/starknet/index.d.ts +172 -0
- package/dist/chains/starknet/index.js +534 -0
- package/dist/chains/starknet/index.js.map +1 -0
- package/dist/chains/starknet/index.mjs +507 -0
- package/dist/chains/starknet/index.mjs.map +1 -0
- package/dist/chains/sui/index.d.mts +182 -0
- package/dist/chains/sui/index.d.ts +182 -0
- package/dist/chains/sui/index.js +560 -0
- package/dist/chains/sui/index.js.map +1 -0
- package/dist/chains/sui/index.mjs +533 -0
- package/dist/chains/sui/index.mjs.map +1 -0
- package/dist/constants.d.mts +150 -0
- package/dist/constants.d.ts +150 -0
- package/dist/constants.js +430 -0
- package/dist/constants.js.map +1 -0
- package/dist/constants.mjs +392 -0
- package/dist/constants.mjs.map +1 -0
- package/dist/index-0NXfbk0z.d.ts +637 -0
- package/dist/index-D0dLVjTA.d.mts +637 -0
- package/dist/index.d.mts +3101 -0
- package/dist/index.d.ts +3101 -0
- package/dist/index.js +13186 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +13011 -0
- package/dist/index.mjs.map +1 -0
- package/dist/payload.d.mts +125 -0
- package/dist/payload.d.ts +125 -0
- package/dist/payload.js +315 -0
- package/dist/payload.js.map +1 -0
- package/dist/payload.mjs +269 -0
- package/dist/payload.mjs.map +1 -0
- package/dist/queries/index.d.mts +148 -0
- package/dist/queries/index.d.ts +148 -0
- package/dist/queries/index.js +1533 -0
- package/dist/queries/index.js.map +1 -0
- package/dist/queries/index.mjs +1508 -0
- package/dist/queries/index.mjs.map +1 -0
- package/dist/types-ChIsqCiw.d.mts +565 -0
- package/dist/types-ChIsqCiw.d.ts +565 -0
- package/dist/types-FJL7j6gQ.d.mts +172 -0
- package/dist/types-FJL7j6gQ.d.ts +172 -0
- package/dist/types.d.mts +407 -0
- package/dist/types.d.ts +407 -0
- package/dist/types.js +19 -0
- package/dist/types.js.map +1 -0
- package/dist/types.mjs +1 -0
- package/dist/types.mjs.map +1 -0
- package/dist/utils.d.mts +81 -0
- package/dist/utils.d.ts +81 -0
- package/dist/utils.js +430 -0
- package/dist/utils.js.map +1 -0
- package/dist/utils.mjs +390 -0
- package/dist/utils.mjs.map +1 -0
- package/dist/wormhole.d.mts +167 -0
- package/dist/wormhole.d.ts +167 -0
- package/dist/wormhole.js +468 -0
- package/dist/wormhole.js.map +1 -0
- package/dist/wormhole.mjs +422 -0
- package/dist/wormhole.mjs.map +1 -0
- package/package.json +151 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to the Veridex SDK will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [1.0.0] - 2025-01-XX
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **Core SDK**
|
|
13
|
+
- `createSDK()` factory function for easy initialization
|
|
14
|
+
- `VeridexSDK` class with full passkey authentication support
|
|
15
|
+
- `PasskeyManager` for WebAuthn credential registration and authentication
|
|
16
|
+
- `WalletManager` for deterministic vault address derivation
|
|
17
|
+
- `BalanceManager` for multi-chain balance queries
|
|
18
|
+
- `TransactionTracker` for transaction status monitoring
|
|
19
|
+
|
|
20
|
+
- **Chain Support**
|
|
21
|
+
- EVM chains: Base, Optimism, Arbitrum, Ethereum, Polygon, and more
|
|
22
|
+
- Solana: SPL token and SOL transfer support
|
|
23
|
+
- Aptos: Fungible asset and APT transfer support
|
|
24
|
+
- Sui: Coin and SUI transfer support
|
|
25
|
+
- Starknet: Custom bridge with multi-relayer attestations
|
|
26
|
+
|
|
27
|
+
- **Cross-Chain Features**
|
|
28
|
+
- Wormhole VAA-based cross-chain messaging
|
|
29
|
+
- Cross-chain balance queries via Wormhole CCQ
|
|
30
|
+
- Bridge operations between supported chains
|
|
31
|
+
- Unified identity across all chains
|
|
32
|
+
|
|
33
|
+
- **Session Keys**
|
|
34
|
+
- `SessionManager` for temporary delegated access
|
|
35
|
+
- Time-limited sessions with value caps
|
|
36
|
+
- Secure key generation and storage
|
|
37
|
+
- Session revocation support
|
|
38
|
+
|
|
39
|
+
- **Gasless Transactions**
|
|
40
|
+
- `RelayerClient` for sponsored transactions
|
|
41
|
+
- `GasSponsor` for integrator-sponsored vault creation
|
|
42
|
+
- Automatic gas estimation and relaying
|
|
43
|
+
|
|
44
|
+
- **Security**
|
|
45
|
+
- P-256 (secp256r1) signature verification
|
|
46
|
+
- RIP-7212 precompile support where available
|
|
47
|
+
- FCL fallback for chains without precompile
|
|
48
|
+
- Replay protection via nonces
|
|
49
|
+
- Guardian quorum validation (13/19)
|
|
50
|
+
|
|
51
|
+
- **Utilities**
|
|
52
|
+
- Payload encoding/decoding functions
|
|
53
|
+
- VAA parsing and validation
|
|
54
|
+
- Chain ID mappings and constants
|
|
55
|
+
- Error handling with categorized error codes
|
|
56
|
+
|
|
57
|
+
### Security
|
|
58
|
+
|
|
59
|
+
- WebAuthn challenge binding enforced
|
|
60
|
+
- Signature malleability protections
|
|
61
|
+
- Cross-chain message validation
|
|
62
|
+
- Nonce-based replay prevention
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## [Unreleased]
|
|
67
|
+
|
|
68
|
+
### Planned
|
|
69
|
+
|
|
70
|
+
- React hooks package (`@veridex/react`)
|
|
71
|
+
- Vue composables package (`@veridex/vue`)
|
|
72
|
+
- Wallet adapter integrations
|
|
73
|
+
- Additional chain support (NEAR, Cosmos)
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Veridex Protocol
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
# @veridex/sdk
|
|
2
|
+
|
|
3
|
+
Veridex Protocol SDK - Client library for **Passkey-based cross-chain authentication**.
|
|
4
|
+
|
|
5
|
+
Build applications with WebAuthn/Passkeys (P-256) that work across EVM, Solana, Aptos, Sui, and Starknet.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Passkey Authentication** - WebAuthn P-256 signature verification (no seed phrases)
|
|
10
|
+
- **Cross-Chain Support** - EVM, Solana, Aptos, Sui, Starknet
|
|
11
|
+
- **Deterministic Vaults** - Same address across all EVM chains
|
|
12
|
+
- **Gasless Transactions** - Relayer-sponsored execution
|
|
13
|
+
- **Session Keys** - Temporary delegated access for smooth UX
|
|
14
|
+
- **Wormhole Integration** - Guardian-attested cross-chain messaging
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @veridex/sdk ethers
|
|
20
|
+
# or
|
|
21
|
+
yarn add @veridex/sdk ethers
|
|
22
|
+
# or
|
|
23
|
+
bun add @veridex/sdk ethers
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Quick Start
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import { createSDK } from '@veridex/sdk';
|
|
30
|
+
|
|
31
|
+
// Initialize SDK (testnet by default)
|
|
32
|
+
const sdk = createSDK('base');
|
|
33
|
+
|
|
34
|
+
// Register a passkey
|
|
35
|
+
const credential = await sdk.passkey.register('user@example.com', 'My Wallet');
|
|
36
|
+
|
|
37
|
+
// Get your vault address (same on all EVM chains!)
|
|
38
|
+
const vaultAddress = sdk.getVaultAddress();
|
|
39
|
+
console.log('Your vault:', vaultAddress);
|
|
40
|
+
|
|
41
|
+
// Transfer tokens
|
|
42
|
+
await sdk.transfer({
|
|
43
|
+
token: '0x036CbD53842c5426634e7929541eC2318f3dCF7e', // USDC
|
|
44
|
+
recipient: '0x742d35Cc6634C0532925a3b844Bc9e7595f5A234',
|
|
45
|
+
amount: 1000000n, // 1 USDC (6 decimals)
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Networks
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
// Testnet (default)
|
|
53
|
+
const testnetSdk = createSDK('base');
|
|
54
|
+
|
|
55
|
+
// Mainnet
|
|
56
|
+
const mainnetSdk = createSDK('base', { network: 'mainnet' });
|
|
57
|
+
|
|
58
|
+
// Custom RPC
|
|
59
|
+
const customSdk = createSDK('base', {
|
|
60
|
+
rpcUrl: 'https://my-rpc.example.com'
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Supported Chains
|
|
65
|
+
|
|
66
|
+
| Chain | Type | Status |
|
|
67
|
+
|-------|------|--------|
|
|
68
|
+
| Base | Hub (EVM) | Testnet + Mainnet |
|
|
69
|
+
| Optimism | Spoke (EVM) | Testnet + Mainnet |
|
|
70
|
+
| Arbitrum | Spoke (EVM) | Testnet + Mainnet |
|
|
71
|
+
| Ethereum | Spoke (EVM) | Testnet + Mainnet |
|
|
72
|
+
| Polygon | Spoke (EVM) | Testnet + Mainnet |
|
|
73
|
+
| Solana | Spoke | Devnet + Mainnet |
|
|
74
|
+
| Aptos | Spoke | Testnet + Mainnet |
|
|
75
|
+
| Sui | Spoke | Testnet + Mainnet |
|
|
76
|
+
| Starknet | Spoke | Sepolia + Mainnet |
|
|
77
|
+
|
|
78
|
+
## Gasless Transactions
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
const sdk = createSDK('base', {
|
|
82
|
+
relayerUrl: 'https://relayer.veridex.io',
|
|
83
|
+
relayerApiKey: 'your-api-key',
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// Transfers are now gasless
|
|
87
|
+
await sdk.transferViaRelayer({
|
|
88
|
+
token: USDC_ADDRESS,
|
|
89
|
+
recipient: '0x...',
|
|
90
|
+
amount: 1000000n,
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Session Keys
|
|
95
|
+
|
|
96
|
+
Enable seamless UX without repeated biometric prompts:
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
// Create a 1-hour session with 0.1 ETH limit
|
|
100
|
+
const session = await sdk.sessions.create({
|
|
101
|
+
duration: 3600,
|
|
102
|
+
maxValue: parseEther('0.1'),
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// Execute multiple transactions without prompts
|
|
106
|
+
await sdk.sessions.transfer(session, { ... });
|
|
107
|
+
await sdk.sessions.transfer(session, { ... });
|
|
108
|
+
|
|
109
|
+
// Revoke when done
|
|
110
|
+
await sdk.sessions.revoke(session);
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Cross-Chain Bridging
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
import { parseUnits } from 'ethers';
|
|
117
|
+
|
|
118
|
+
await sdk.bridge({
|
|
119
|
+
targetChain: 'optimism',
|
|
120
|
+
token: USDC_ADDRESS,
|
|
121
|
+
amount: parseUnits('100', 6),
|
|
122
|
+
recipient: '0x...', // Optional, defaults to your vault
|
|
123
|
+
});
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## API Reference
|
|
127
|
+
|
|
128
|
+
### Core
|
|
129
|
+
|
|
130
|
+
| Export | Description |
|
|
131
|
+
|--------|-------------|
|
|
132
|
+
| `createSDK(chain, config?)` | Create SDK for a chain |
|
|
133
|
+
| `VeridexSDK` | Main SDK class |
|
|
134
|
+
| `PasskeyManager` | WebAuthn credential management |
|
|
135
|
+
| `WalletManager` | Vault address derivation |
|
|
136
|
+
| `SessionManager` | Session key management |
|
|
137
|
+
|
|
138
|
+
### Chain Clients
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
import { EVMClient } from '@veridex/sdk/chains/evm';
|
|
142
|
+
import { SolanaClient } from '@veridex/sdk/chains/solana';
|
|
143
|
+
import { AptosClient } from '@veridex/sdk/chains/aptos';
|
|
144
|
+
import { SuiClient } from '@veridex/sdk/chains/sui';
|
|
145
|
+
import { StarknetClient } from '@veridex/sdk/chains/starknet';
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Utilities
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
import {
|
|
152
|
+
encodeTransferAction,
|
|
153
|
+
encodeBridgeAction,
|
|
154
|
+
parseVAA,
|
|
155
|
+
fetchVAA,
|
|
156
|
+
} from '@veridex/sdk';
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Constants
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
import {
|
|
163
|
+
WORMHOLE_CHAIN_IDS,
|
|
164
|
+
TESTNET_CHAINS,
|
|
165
|
+
MAINNET_CHAINS,
|
|
166
|
+
} from '@veridex/sdk';
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Security
|
|
170
|
+
|
|
171
|
+
- **Passkeys Only** - No EOA or seed phrase assumptions
|
|
172
|
+
- **RIP-7212 Support** - Native P-256 verification (~3,450 gas)
|
|
173
|
+
- **FCL Fallback** - Software verification when precompile unavailable
|
|
174
|
+
- **Wormhole VAA** - 13/19 guardian quorum for cross-chain messages
|
|
175
|
+
- **Replay Protection** - Nonce-based action deduplication
|
|
176
|
+
|
|
177
|
+
## Browser Support
|
|
178
|
+
|
|
179
|
+
WebAuthn requires a secure context (HTTPS) and a compatible browser:
|
|
180
|
+
|
|
181
|
+
| Browser | Minimum Version |
|
|
182
|
+
|---------|-----------------|
|
|
183
|
+
| Chrome | 67+ |
|
|
184
|
+
| Firefox | 60+ |
|
|
185
|
+
| Safari | 14+ |
|
|
186
|
+
| Edge | 18+ |
|
|
187
|
+
|
|
188
|
+
## TypeScript
|
|
189
|
+
|
|
190
|
+
Full TypeScript support with comprehensive type definitions:
|
|
191
|
+
|
|
192
|
+
```typescript
|
|
193
|
+
import type {
|
|
194
|
+
ChainName,
|
|
195
|
+
NetworkType,
|
|
196
|
+
SimpleSDKConfig,
|
|
197
|
+
TransferParams,
|
|
198
|
+
BridgeParams,
|
|
199
|
+
SessionKey,
|
|
200
|
+
} from '@veridex/sdk';
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## License
|
|
204
|
+
|
|
205
|
+
MIT
|
|
206
|
+
|
|
207
|
+
## Links
|
|
208
|
+
|
|
209
|
+
- [Documentation](https://docs.veridex.io)
|
|
210
|
+
- [GitHub](https://github.com/Veridex-Protocol/sdk)
|
|
211
|
+
- [Discord](https://discord.gg/veridex)
|
|
212
|
+
- [Twitter](https://twitter.com/VeridexProtocol)
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { AptosClient as AptosClient$1, Types } from 'aptos';
|
|
2
|
+
import { C as ChainClient, a as ChainConfig, T as TransferParams, E as ExecuteParams, B as BridgeParams, W as WebAuthnSignature, D as DispatchResult, V as VaultCreationResult } from '../../types-ChIsqCiw.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Veridex Protocol SDK - Aptos Chain Client
|
|
6
|
+
*
|
|
7
|
+
* Implementation of ChainClient interface for Aptos blockchain
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
interface AptosClientConfig {
|
|
11
|
+
wormholeChainId: number;
|
|
12
|
+
rpcUrl: string;
|
|
13
|
+
moduleAddress: string;
|
|
14
|
+
wormholeCoreBridge: string;
|
|
15
|
+
tokenBridge: string;
|
|
16
|
+
network?: 'mainnet' | 'testnet' | 'devnet';
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Aptos implementation of the ChainClient interface
|
|
20
|
+
*/
|
|
21
|
+
declare class AptosClient implements ChainClient {
|
|
22
|
+
private config;
|
|
23
|
+
private client;
|
|
24
|
+
private moduleAddress;
|
|
25
|
+
constructor(config: AptosClientConfig);
|
|
26
|
+
getConfig(): ChainConfig;
|
|
27
|
+
getNonce(userKeyHash: string): Promise<bigint>;
|
|
28
|
+
getMessageFee(): Promise<bigint>;
|
|
29
|
+
buildTransferPayload(params: TransferParams): Promise<string>;
|
|
30
|
+
buildExecutePayload(params: ExecuteParams): Promise<string>;
|
|
31
|
+
buildBridgePayload(params: BridgeParams): Promise<string>;
|
|
32
|
+
dispatch(signature: WebAuthnSignature, publicKeyX: bigint, publicKeyY: bigint, targetChain: number, actionPayload: string, nonce: bigint, signer: any): Promise<DispatchResult>;
|
|
33
|
+
/**
|
|
34
|
+
* Dispatch an action via relayer (gasless)
|
|
35
|
+
* Note: On Aptos, this still goes through the Hub chain
|
|
36
|
+
* Aptos is a spoke-only chain in Veridex architecture
|
|
37
|
+
*/
|
|
38
|
+
dispatchGasless(signature: WebAuthnSignature, publicKeyX: bigint, publicKeyY: bigint, targetChain: number, actionPayload: string, nonce: bigint, relayerUrl: string): Promise<DispatchResult>;
|
|
39
|
+
getVaultAddress(userKeyHash: string): Promise<string | null>;
|
|
40
|
+
/**
|
|
41
|
+
* Compute vault address using resource account derivation
|
|
42
|
+
* On Aptos, vaults are derived from the module address + user key hash
|
|
43
|
+
*/
|
|
44
|
+
computeVaultAddress(userKeyHash: string): string;
|
|
45
|
+
private computeVaultAddressFromHash;
|
|
46
|
+
/**
|
|
47
|
+
* Convert hex string to Uint8Array (browser-compatible)
|
|
48
|
+
*/
|
|
49
|
+
private hexToBytes;
|
|
50
|
+
vaultExists(userKeyHash: string): Promise<boolean>;
|
|
51
|
+
createVault(userKeyHash: string, signer: any): Promise<VaultCreationResult>;
|
|
52
|
+
createVaultSponsored?(userKeyHash: string, sponsorPrivateKey: string, rpcUrl?: string): Promise<VaultCreationResult>;
|
|
53
|
+
/**
|
|
54
|
+
* Create a vault via the relayer (sponsored/gasless)
|
|
55
|
+
* This is the recommended way to create Aptos vaults
|
|
56
|
+
*
|
|
57
|
+
* The relayer will dispatch a vault creation action from Hub to Aptos spoke
|
|
58
|
+
*/
|
|
59
|
+
createVaultViaRelayer(userKeyHash: string, relayerUrl: string): Promise<VaultCreationResult>;
|
|
60
|
+
/**
|
|
61
|
+
* Get vault info via relayer (includes existence check)
|
|
62
|
+
*/
|
|
63
|
+
getVaultViaRelayer(userKeyHash: string, relayerUrl: string): Promise<{
|
|
64
|
+
vaultAddress: string;
|
|
65
|
+
exists: boolean;
|
|
66
|
+
}>;
|
|
67
|
+
estimateVaultCreationGas(userKeyHash: string): Promise<bigint>;
|
|
68
|
+
getFactoryAddress(): string | undefined;
|
|
69
|
+
getImplementationAddress(): string | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Get native APT balance
|
|
72
|
+
*/
|
|
73
|
+
getNativeBalance(address: string): Promise<bigint>;
|
|
74
|
+
/**
|
|
75
|
+
* Get fungible asset (FA) or coin balance
|
|
76
|
+
*/
|
|
77
|
+
getTokenBalance(tokenAddress: string, ownerAddress: string): Promise<bigint>;
|
|
78
|
+
/**
|
|
79
|
+
* Compute key hash from public key coordinates
|
|
80
|
+
* Matches EVM keccak256(abi.encode(publicKeyX, publicKeyY))
|
|
81
|
+
*/
|
|
82
|
+
private computeKeyHash;
|
|
83
|
+
/**
|
|
84
|
+
* Build message for signing (matches Hub chain format)
|
|
85
|
+
*/
|
|
86
|
+
private buildMessage;
|
|
87
|
+
/**
|
|
88
|
+
* Get Aptos client instance for advanced usage
|
|
89
|
+
*/
|
|
90
|
+
getClient(): AptosClient$1;
|
|
91
|
+
/**
|
|
92
|
+
* Get module address
|
|
93
|
+
*/
|
|
94
|
+
getModuleAddress(): string;
|
|
95
|
+
/**
|
|
96
|
+
* Get current ledger version
|
|
97
|
+
*/
|
|
98
|
+
getLedgerVersion(): Promise<bigint>;
|
|
99
|
+
/**
|
|
100
|
+
* Get transaction by hash
|
|
101
|
+
*/
|
|
102
|
+
getTransaction(txHash: string): Promise<Types.Transaction>;
|
|
103
|
+
/**
|
|
104
|
+
* Wait for transaction confirmation
|
|
105
|
+
*/
|
|
106
|
+
waitForTransaction(txHash: string, timeoutSecs?: number): Promise<Types.Transaction>;
|
|
107
|
+
/**
|
|
108
|
+
* Get vault resource for an owner
|
|
109
|
+
*
|
|
110
|
+
* @param ownerKeyHash - Owner's passkey hash (32 bytes as hex)
|
|
111
|
+
* @returns Vault resource data or null if not found
|
|
112
|
+
*/
|
|
113
|
+
getVaultResource(ownerKeyHash: string): Promise<{
|
|
114
|
+
ownerKeyHash: string;
|
|
115
|
+
authorizedSigners: string[];
|
|
116
|
+
nonce: bigint;
|
|
117
|
+
} | null>;
|
|
118
|
+
/**
|
|
119
|
+
* Get authorized signers for a vault
|
|
120
|
+
*
|
|
121
|
+
* @param ownerKeyHash - Owner's passkey hash (32 bytes as hex)
|
|
122
|
+
* @returns Array of authorized signer key hashes
|
|
123
|
+
*/
|
|
124
|
+
getAuthorizedSigners(ownerKeyHash: string): Promise<string[]>;
|
|
125
|
+
/**
|
|
126
|
+
* Check if a VAA has been processed (for replay protection)
|
|
127
|
+
*
|
|
128
|
+
* @param vaaHash - VAA hash as hex string
|
|
129
|
+
* @returns Whether the VAA has been processed
|
|
130
|
+
*/
|
|
131
|
+
isVaaProcessed(vaaHash: string): Promise<boolean>;
|
|
132
|
+
/**
|
|
133
|
+
* Check if protocol is paused
|
|
134
|
+
*
|
|
135
|
+
* @returns Whether the protocol is paused
|
|
136
|
+
*/
|
|
137
|
+
isProtocolPaused(): Promise<boolean>;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export { AptosClient, type AptosClientConfig };
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { AptosClient as AptosClient$1, Types } from 'aptos';
|
|
2
|
+
import { C as ChainClient, a as ChainConfig, T as TransferParams, E as ExecuteParams, B as BridgeParams, W as WebAuthnSignature, D as DispatchResult, V as VaultCreationResult } from '../../types-ChIsqCiw.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Veridex Protocol SDK - Aptos Chain Client
|
|
6
|
+
*
|
|
7
|
+
* Implementation of ChainClient interface for Aptos blockchain
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
interface AptosClientConfig {
|
|
11
|
+
wormholeChainId: number;
|
|
12
|
+
rpcUrl: string;
|
|
13
|
+
moduleAddress: string;
|
|
14
|
+
wormholeCoreBridge: string;
|
|
15
|
+
tokenBridge: string;
|
|
16
|
+
network?: 'mainnet' | 'testnet' | 'devnet';
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Aptos implementation of the ChainClient interface
|
|
20
|
+
*/
|
|
21
|
+
declare class AptosClient implements ChainClient {
|
|
22
|
+
private config;
|
|
23
|
+
private client;
|
|
24
|
+
private moduleAddress;
|
|
25
|
+
constructor(config: AptosClientConfig);
|
|
26
|
+
getConfig(): ChainConfig;
|
|
27
|
+
getNonce(userKeyHash: string): Promise<bigint>;
|
|
28
|
+
getMessageFee(): Promise<bigint>;
|
|
29
|
+
buildTransferPayload(params: TransferParams): Promise<string>;
|
|
30
|
+
buildExecutePayload(params: ExecuteParams): Promise<string>;
|
|
31
|
+
buildBridgePayload(params: BridgeParams): Promise<string>;
|
|
32
|
+
dispatch(signature: WebAuthnSignature, publicKeyX: bigint, publicKeyY: bigint, targetChain: number, actionPayload: string, nonce: bigint, signer: any): Promise<DispatchResult>;
|
|
33
|
+
/**
|
|
34
|
+
* Dispatch an action via relayer (gasless)
|
|
35
|
+
* Note: On Aptos, this still goes through the Hub chain
|
|
36
|
+
* Aptos is a spoke-only chain in Veridex architecture
|
|
37
|
+
*/
|
|
38
|
+
dispatchGasless(signature: WebAuthnSignature, publicKeyX: bigint, publicKeyY: bigint, targetChain: number, actionPayload: string, nonce: bigint, relayerUrl: string): Promise<DispatchResult>;
|
|
39
|
+
getVaultAddress(userKeyHash: string): Promise<string | null>;
|
|
40
|
+
/**
|
|
41
|
+
* Compute vault address using resource account derivation
|
|
42
|
+
* On Aptos, vaults are derived from the module address + user key hash
|
|
43
|
+
*/
|
|
44
|
+
computeVaultAddress(userKeyHash: string): string;
|
|
45
|
+
private computeVaultAddressFromHash;
|
|
46
|
+
/**
|
|
47
|
+
* Convert hex string to Uint8Array (browser-compatible)
|
|
48
|
+
*/
|
|
49
|
+
private hexToBytes;
|
|
50
|
+
vaultExists(userKeyHash: string): Promise<boolean>;
|
|
51
|
+
createVault(userKeyHash: string, signer: any): Promise<VaultCreationResult>;
|
|
52
|
+
createVaultSponsored?(userKeyHash: string, sponsorPrivateKey: string, rpcUrl?: string): Promise<VaultCreationResult>;
|
|
53
|
+
/**
|
|
54
|
+
* Create a vault via the relayer (sponsored/gasless)
|
|
55
|
+
* This is the recommended way to create Aptos vaults
|
|
56
|
+
*
|
|
57
|
+
* The relayer will dispatch a vault creation action from Hub to Aptos spoke
|
|
58
|
+
*/
|
|
59
|
+
createVaultViaRelayer(userKeyHash: string, relayerUrl: string): Promise<VaultCreationResult>;
|
|
60
|
+
/**
|
|
61
|
+
* Get vault info via relayer (includes existence check)
|
|
62
|
+
*/
|
|
63
|
+
getVaultViaRelayer(userKeyHash: string, relayerUrl: string): Promise<{
|
|
64
|
+
vaultAddress: string;
|
|
65
|
+
exists: boolean;
|
|
66
|
+
}>;
|
|
67
|
+
estimateVaultCreationGas(userKeyHash: string): Promise<bigint>;
|
|
68
|
+
getFactoryAddress(): string | undefined;
|
|
69
|
+
getImplementationAddress(): string | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Get native APT balance
|
|
72
|
+
*/
|
|
73
|
+
getNativeBalance(address: string): Promise<bigint>;
|
|
74
|
+
/**
|
|
75
|
+
* Get fungible asset (FA) or coin balance
|
|
76
|
+
*/
|
|
77
|
+
getTokenBalance(tokenAddress: string, ownerAddress: string): Promise<bigint>;
|
|
78
|
+
/**
|
|
79
|
+
* Compute key hash from public key coordinates
|
|
80
|
+
* Matches EVM keccak256(abi.encode(publicKeyX, publicKeyY))
|
|
81
|
+
*/
|
|
82
|
+
private computeKeyHash;
|
|
83
|
+
/**
|
|
84
|
+
* Build message for signing (matches Hub chain format)
|
|
85
|
+
*/
|
|
86
|
+
private buildMessage;
|
|
87
|
+
/**
|
|
88
|
+
* Get Aptos client instance for advanced usage
|
|
89
|
+
*/
|
|
90
|
+
getClient(): AptosClient$1;
|
|
91
|
+
/**
|
|
92
|
+
* Get module address
|
|
93
|
+
*/
|
|
94
|
+
getModuleAddress(): string;
|
|
95
|
+
/**
|
|
96
|
+
* Get current ledger version
|
|
97
|
+
*/
|
|
98
|
+
getLedgerVersion(): Promise<bigint>;
|
|
99
|
+
/**
|
|
100
|
+
* Get transaction by hash
|
|
101
|
+
*/
|
|
102
|
+
getTransaction(txHash: string): Promise<Types.Transaction>;
|
|
103
|
+
/**
|
|
104
|
+
* Wait for transaction confirmation
|
|
105
|
+
*/
|
|
106
|
+
waitForTransaction(txHash: string, timeoutSecs?: number): Promise<Types.Transaction>;
|
|
107
|
+
/**
|
|
108
|
+
* Get vault resource for an owner
|
|
109
|
+
*
|
|
110
|
+
* @param ownerKeyHash - Owner's passkey hash (32 bytes as hex)
|
|
111
|
+
* @returns Vault resource data or null if not found
|
|
112
|
+
*/
|
|
113
|
+
getVaultResource(ownerKeyHash: string): Promise<{
|
|
114
|
+
ownerKeyHash: string;
|
|
115
|
+
authorizedSigners: string[];
|
|
116
|
+
nonce: bigint;
|
|
117
|
+
} | null>;
|
|
118
|
+
/**
|
|
119
|
+
* Get authorized signers for a vault
|
|
120
|
+
*
|
|
121
|
+
* @param ownerKeyHash - Owner's passkey hash (32 bytes as hex)
|
|
122
|
+
* @returns Array of authorized signer key hashes
|
|
123
|
+
*/
|
|
124
|
+
getAuthorizedSigners(ownerKeyHash: string): Promise<string[]>;
|
|
125
|
+
/**
|
|
126
|
+
* Check if a VAA has been processed (for replay protection)
|
|
127
|
+
*
|
|
128
|
+
* @param vaaHash - VAA hash as hex string
|
|
129
|
+
* @returns Whether the VAA has been processed
|
|
130
|
+
*/
|
|
131
|
+
isVaaProcessed(vaaHash: string): Promise<boolean>;
|
|
132
|
+
/**
|
|
133
|
+
* Check if protocol is paused
|
|
134
|
+
*
|
|
135
|
+
* @returns Whether the protocol is paused
|
|
136
|
+
*/
|
|
137
|
+
isProtocolPaused(): Promise<boolean>;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export { AptosClient, type AptosClientConfig };
|