@veridex/sdk 1.0.0-beta.9 → 1.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.
Files changed (130) hide show
  1. package/LICENSE +170 -21
  2. package/README.md +574 -117
  3. package/dist/EVMClient-DtqvdfUP.d.mts +376 -0
  4. package/dist/auth/prepareAuth.d.mts +25 -0
  5. package/dist/auth/prepareAuth.js +2406 -0
  6. package/dist/auth/prepareAuth.js.map +1 -0
  7. package/dist/auth/prepareAuth.mjs +151 -0
  8. package/dist/auth/prepareAuth.mjs.map +1 -0
  9. package/dist/chains/aptos/index.d.mts +6 -5
  10. package/dist/chains/aptos/index.js +66 -39
  11. package/dist/chains/aptos/index.js.map +1 -1
  12. package/dist/chains/aptos/index.mjs +5 -547
  13. package/dist/chains/aptos/index.mjs.map +1 -1
  14. package/dist/chains/avalanche/index.d.mts +137 -0
  15. package/dist/chains/avalanche/index.js +1555 -0
  16. package/dist/chains/avalanche/index.js.map +1 -0
  17. package/dist/chains/avalanche/index.mjs +10 -0
  18. package/dist/chains/avalanche/index.mjs.map +1 -0
  19. package/dist/chains/evm/index.d.mts +5 -3
  20. package/dist/chains/evm/index.js +165 -3
  21. package/dist/chains/evm/index.js.map +1 -1
  22. package/dist/chains/evm/index.mjs +8 -1200
  23. package/dist/chains/evm/index.mjs.map +1 -1
  24. package/dist/chains/solana/index.d.mts +1 -1
  25. package/dist/chains/solana/index.js.map +1 -1
  26. package/dist/chains/solana/index.mjs +4 -486
  27. package/dist/chains/solana/index.mjs.map +1 -1
  28. package/dist/chains/stacks/index.d.mts +559 -0
  29. package/dist/chains/stacks/index.js +1207 -0
  30. package/dist/chains/stacks/index.js.map +1 -0
  31. package/dist/chains/stacks/index.mjs +71 -0
  32. package/dist/chains/stacks/index.mjs.map +1 -0
  33. package/dist/chains/starknet/index.d.mts +3 -3
  34. package/dist/chains/starknet/index.js.map +1 -1
  35. package/dist/chains/starknet/index.mjs +5 -503
  36. package/dist/chains/starknet/index.mjs.map +1 -1
  37. package/dist/chains/sui/index.d.mts +2 -2
  38. package/dist/chains/sui/index.js.map +1 -1
  39. package/dist/chains/sui/index.mjs +5 -529
  40. package/dist/chains/sui/index.mjs.map +1 -1
  41. package/dist/chunk-5T6KPH7A.mjs +1082 -0
  42. package/dist/chunk-5T6KPH7A.mjs.map +1 -0
  43. package/dist/chunk-72ZA3OYQ.mjs +20 -0
  44. package/dist/chunk-72ZA3OYQ.mjs.map +1 -0
  45. package/dist/chunk-EFIURACP.mjs +438 -0
  46. package/dist/chunk-EFIURACP.mjs.map +1 -0
  47. package/dist/chunk-F3YAGZSW.mjs +269 -0
  48. package/dist/chunk-F3YAGZSW.mjs.map +1 -0
  49. package/dist/chunk-GWJRKDSA.mjs +549 -0
  50. package/dist/chunk-GWJRKDSA.mjs.map +1 -0
  51. package/dist/chunk-M3MM4YMF.mjs +417 -0
  52. package/dist/chunk-M3MM4YMF.mjs.map +1 -0
  53. package/dist/chunk-N4A2RMUN.mjs +216 -0
  54. package/dist/chunk-N4A2RMUN.mjs.map +1 -0
  55. package/dist/chunk-NUWSMJFJ.mjs +179 -0
  56. package/dist/chunk-NUWSMJFJ.mjs.map +1 -0
  57. package/dist/chunk-OVMMTL6H.mjs +330 -0
  58. package/dist/chunk-OVMMTL6H.mjs.map +1 -0
  59. package/dist/chunk-PDHZ5X5O.mjs +565 -0
  60. package/dist/chunk-PDHZ5X5O.mjs.map +1 -0
  61. package/dist/chunk-PRHNGA4G.mjs +464 -0
  62. package/dist/chunk-PRHNGA4G.mjs.map +1 -0
  63. package/dist/chunk-Q5O3M5LP.mjs +422 -0
  64. package/dist/chunk-Q5O3M5LP.mjs.map +1 -0
  65. package/dist/chunk-QDO6NQ7P.mjs +840 -0
  66. package/dist/chunk-QDO6NQ7P.mjs.map +1 -0
  67. package/dist/chunk-QT4ZZ4GM.mjs +509 -0
  68. package/dist/chunk-QT4ZZ4GM.mjs.map +1 -0
  69. package/dist/chunk-USDA5JTN.mjs +1249 -0
  70. package/dist/chunk-USDA5JTN.mjs.map +1 -0
  71. package/dist/chunk-V636MIV3.mjs +52 -0
  72. package/dist/chunk-V636MIV3.mjs.map +1 -0
  73. package/dist/chunk-X7BZMSPQ.mjs +407 -0
  74. package/dist/chunk-X7BZMSPQ.mjs.map +1 -0
  75. package/dist/chunk-YCUJZ6Z7.mjs +829 -0
  76. package/dist/chunk-YCUJZ6Z7.mjs.map +1 -0
  77. package/dist/constants.d.mts +1 -1
  78. package/dist/constants.js +26 -12
  79. package/dist/constants.js.map +1 -1
  80. package/dist/constants.mjs +16 -375
  81. package/dist/constants.mjs.map +1 -1
  82. package/dist/index-DDalBhAm.d.mts +243 -0
  83. package/dist/index.d.mts +2508 -556
  84. package/dist/index.js +14576 -9628
  85. package/dist/index.js.map +1 -1
  86. package/dist/index.mjs +4108 -7840
  87. package/dist/index.mjs.map +1 -1
  88. package/dist/passkey.d.mts +182 -0
  89. package/dist/passkey.js +914 -0
  90. package/dist/passkey.js.map +1 -0
  91. package/dist/passkey.mjs +15 -0
  92. package/dist/passkey.mjs.map +1 -0
  93. package/dist/payload.js.map +1 -1
  94. package/dist/payload.mjs +25 -244
  95. package/dist/payload.mjs.map +1 -1
  96. package/dist/portfolio-V347KZOL.mjs +13 -0
  97. package/dist/portfolio-V347KZOL.mjs.map +1 -0
  98. package/dist/queries/index.js +145 -12
  99. package/dist/queries/index.js.map +1 -1
  100. package/dist/queries/index.mjs +14 -1496
  101. package/dist/queries/index.mjs.map +1 -1
  102. package/dist/{types-FJL7j6gQ.d.ts → types-B7V5VNbO.d.mts} +6 -2
  103. package/dist/{types-ChIsqCiw.d.mts → types-DP2CQT8p.d.mts} +12 -1
  104. package/dist/types.d.mts +16 -0
  105. package/dist/types.js.map +1 -1
  106. package/dist/utils.js +25 -11
  107. package/dist/utils.js.map +1 -1
  108. package/dist/utils.mjs +19 -371
  109. package/dist/utils.mjs.map +1 -1
  110. package/dist/wormhole.js.map +1 -1
  111. package/dist/wormhole.mjs +25 -397
  112. package/dist/wormhole.mjs.map +1 -1
  113. package/package.json +28 -3
  114. package/scripts/patch-noble-curves.js +78 -0
  115. package/dist/chains/aptos/index.d.ts +0 -145
  116. package/dist/chains/evm/index.d.ts +0 -5
  117. package/dist/chains/solana/index.d.ts +0 -116
  118. package/dist/chains/starknet/index.d.ts +0 -172
  119. package/dist/chains/sui/index.d.ts +0 -182
  120. package/dist/constants.d.ts +0 -150
  121. package/dist/index-0NXfbk0z.d.ts +0 -637
  122. package/dist/index-D0dLVjTA.d.mts +0 -637
  123. package/dist/index.d.ts +0 -3123
  124. package/dist/payload.d.ts +0 -125
  125. package/dist/queries/index.d.ts +0 -148
  126. package/dist/types-ChIsqCiw.d.ts +0 -565
  127. package/dist/types-FJL7j6gQ.d.mts +0 -172
  128. package/dist/types.d.ts +0 -407
  129. package/dist/utils.d.ts +0 -81
  130. package/dist/wormhole.d.ts +0 -167
package/dist/payload.d.ts DELETED
@@ -1,125 +0,0 @@
1
- import { ActionPayload, TransferAction, BridgeAction, ExecuteAction } from './types.js';
2
-
3
- /**
4
- * Veridex Protocol SDK - Payload Encoding/Decoding Utilities
5
- */
6
-
7
- /**
8
- * Encode a transfer action payload
9
- * Format: [actionType(1)] [token(32)] [recipient(32)] [amount(32)]
10
- */
11
- declare function encodeTransferAction(token: string, recipient: string, amount: bigint): string;
12
- /**
13
- * Encode a bridge action payload
14
- * Format: [actionType(1)] [token(32)] [amount(32)] [targetChain(2)] [recipient(32)]
15
- */
16
- declare function encodeBridgeAction(token: string, amount: bigint, targetChain: number, recipient: string): string;
17
- /**
18
- * Encode an execute action payload (arbitrary contract call)
19
- * Format: [actionType(1)] [target(32)] [value(32)] [dataLength(2)] [data(variable)]
20
- */
21
- declare function encodeExecuteAction(target: string, value: bigint, data: string): string;
22
- /**
23
- * Encode a config action payload
24
- * Format: [actionType(1)] [configType(1)] [configData(variable)]
25
- */
26
- declare function encodeConfigAction(configType: number, configData: string): string;
27
- /**
28
- * Encode the full Veridex message payload that gets published via Wormhole
29
- * Format: [version(1)] [userKeyHash(32)] [targetChain(2)] [nonce(32)] [pubKeyX(32)] [pubKeyY(32)] [actionPayload]
30
- */
31
- declare function encodeVeridexPayload(userKeyHash: string, targetChain: number, nonce: bigint, publicKeyX: bigint, publicKeyY: bigint, actionPayload: string): string;
32
- /**
33
- * Decode an action payload to determine its type and contents
34
- */
35
- declare function decodeActionPayload(payload: string): ActionPayload;
36
- /**
37
- * Decode a transfer action payload
38
- */
39
- declare function decodeTransferAction(payload: string): TransferAction;
40
- /**
41
- * Decode a bridge action payload
42
- */
43
- declare function decodeBridgeAction(payload: string): BridgeAction;
44
- /**
45
- * Decode an execute action payload
46
- */
47
- declare function decodeExecuteAction(payload: string): ExecuteAction;
48
- /**
49
- * Encode a Solana-compatible transfer action
50
- * Solana uses: [actionType(1)] [amount(8 LE)] [recipient(32)]
51
- */
52
- declare function encodeSolanaTransferAction(amount: bigint, recipient: string): string;
53
- /**
54
- * Encode an Aptos-compatible transfer action
55
- * Aptos uses: [actionType(1)] [amount(8 LE)] [recipient(32)]
56
- */
57
- declare function encodeAptosTransferAction(amount: bigint, recipient: string): string;
58
- /**
59
- * Encode a Sui-compatible transfer action
60
- * Sui uses: [actionType(1)] [amount(8 LE)] [recipient(32)]
61
- */
62
- declare function encodeSuiTransferAction(amount: bigint, recipient: string): string;
63
- /**
64
- * Pad an address to 32 bytes (Wormhole standard)
65
- * Supports both EVM addresses (0x...) and Solana addresses (base58)
66
- */
67
- declare function padTo32Bytes(address: string): string;
68
- /**
69
- * Trim a 32-byte hex to a 20-byte EVM address
70
- */
71
- declare function trimTo20Bytes(hex32: string): string;
72
- /**
73
- * Convert a Solana public key (base58) to bytes32
74
- * @deprecated Use padTo32Bytes instead, which now handles both EVM and Solana addresses
75
- */
76
- declare function solanaAddressToBytes32(base58Address: string): string;
77
- /**
78
- * Format an amount with decimals for display
79
- */
80
- declare function formatAmount(amount: bigint, decimals?: number): string;
81
- /**
82
- * Parse an amount string with decimals to bigint
83
- */
84
- declare function parseAmount(amountStr: string, decimals?: number): bigint;
85
- /**
86
- * Generate a unique nonce for a transaction
87
- */
88
- declare function generateNonce(): bigint;
89
- /**
90
- * Create a message hash for signing (used in authenticateRawAndDispatch)
91
- */
92
- declare function createMessageHash(targetChain: number, actionPayload: string, nonce: bigint): string;
93
- /**
94
- * Create the challenge bytes for gasless dispatch (matches Hub's authenticateAndDispatch)
95
- *
96
- * The Hub contract passes raw packed bytes to WebAuthn.verify():
97
- * abi.encodePacked(targetChain, actionPayload, userNonce, hubChainId)
98
- *
99
- * The WebAuthn library then base64url-encodes these bytes to match against clientDataJSON.
100
- * We do NOT hash here - the challenge is the raw packed bytes.
101
- *
102
- * @param targetChain - Wormhole chain ID of the destination
103
- * @param actionPayload - The action payload (hex string)
104
- * @param nonce - User's current nonce
105
- * @param hubChainId - Wormhole chain ID of the Hub (e.g., 30 for Base)
106
- * @returns The packed bytes as hex string (NOT hashed)
107
- */
108
- declare function createGaslessMessageHash(targetChain: number, actionPayload: string, nonce: bigint, hubChainId: number): string;
109
- /**
110
- * Build the challenge bytes for WebAuthn signing (gasless flow)
111
- * Returns raw packed bytes that match what the Hub contract expects
112
- *
113
- * @param targetChain - Wormhole chain ID of the destination
114
- * @param actionPayload - The action payload (hex string)
115
- * @param nonce - User's current nonce
116
- * @param hubChainId - Wormhole chain ID of the Hub
117
- * @returns Challenge bytes for WebAuthn signing (raw packed, not hashed)
118
- */
119
- declare function buildGaslessChallenge(targetChain: number, actionPayload: string, nonce: bigint, hubChainId: number): Uint8Array;
120
- /**
121
- * Build the challenge bytes for WebAuthn signing
122
- */
123
- declare function buildChallenge(userKeyHash: string, targetChain: number, nonce: bigint, actionPayload: string): Uint8Array;
124
-
125
- export { buildChallenge, buildGaslessChallenge, createGaslessMessageHash, createMessageHash, decodeActionPayload, decodeBridgeAction, decodeExecuteAction, decodeTransferAction, encodeAptosTransferAction, encodeBridgeAction, encodeConfigAction, encodeExecuteAction, encodeSolanaTransferAction, encodeSuiTransferAction, encodeTransferAction, encodeVeridexPayload, formatAmount, generateNonce, padTo32Bytes, parseAmount, solanaAddressToBytes32, trimTo20Bytes };
@@ -1,148 +0,0 @@
1
- import { QueryRequest as QueryRequest$1, QueryResponse as QueryResponse$1 } from '@wormhole-foundation/wormhole-query-sdk';
2
-
3
- type QueryNetwork = 'mainnet' | 'testnet';
4
- /**
5
- * Configuration for calling the Wormhole Query Proxy.
6
- *
7
- * `apiKey` is required for hosted Query Proxy access.
8
- * `endpoint` may be overridden for custom proxy deployments.
9
- */
10
- interface QueryConfig {
11
- apiKey: string;
12
- endpoint?: string;
13
- timeoutMs?: number;
14
- }
15
- /**
16
- * Re-exported Wormhole Query SDK types (type-only).
17
- * These map directly to the request/response shapes expected by the Query Proxy.
18
- */
19
- type QueryRequest = QueryRequest$1;
20
- type QueryResponse = QueryResponse$1;
21
- type QueryOperationType = 'hubState' | 'portfolio';
22
- interface HubStateQuery {
23
- type: 'hubState';
24
- wormholeChainId: number;
25
- hubAddress: string;
26
- }
27
- interface PortfolioQuery {
28
- type: 'portfolio';
29
- walletAddress: string;
30
- wormholeChainIds: readonly number[];
31
- }
32
- type QueryOperation = HubStateQuery | PortfolioQuery;
33
-
34
- declare const WORMHOLE_QUERY_PROXY_URLS: {
35
- readonly mainnet: "https://query.wormhole.com/v1/query";
36
- readonly testnet: "https://testnet.query.wormhole.com/v1/query";
37
- };
38
- /**
39
- * Wormhole Query Proxy rate limit: 6 queries per second.
40
- * SDK callers should throttle requests accordingly.
41
- */
42
- declare const WORMHOLE_QUERY_RATE_LIMIT_PER_SECOND = 6;
43
- /**
44
- * Convenience set of Wormhole chain IDs commonly supported by Queries.
45
- * This is not an exhaustive list of all Wormhole chains.
46
- */
47
- declare const WORMHOLE_QUERY_CHAIN_IDS: {
48
- readonly ETHEREUM: 2;
49
- readonly POLYGON: 5;
50
- readonly ARBITRUM: 23;
51
- readonly OPTIMISM: 24;
52
- readonly BASE: 30;
53
- };
54
-
55
- type QueryHubStateNetwork = 'testnet' | 'mainnet';
56
- type QueryHubStateOptions = {
57
- /** Max response age in seconds (default: 60). */
58
- maxAge?: number;
59
- network?: QueryHubStateNetwork;
60
- /** Maximum attempts including the first try (default: 4). */
61
- maxAttempts?: number;
62
- };
63
- type HubStateResult = {
64
- nonce: bigint;
65
- isRegistered: boolean;
66
- blockTime: number;
67
- proof: Uint8Array;
68
- /** Last action hash (Issue #9/#10 - for action-hash binding) */
69
- lastActionHash?: string;
70
- };
71
- type QueryHubStateErrorCode = 'INVALID_ARGUMENT' | 'UNSUPPORTED_NETWORK' | 'MISSING_HUB_ADDRESS' | 'PROXY_HTTP_ERROR' | 'PROXY_RESPONSE_INVALID' | 'ATTESTATION_STALE' | 'QUERY_RESPONSE_INVALID';
72
- declare class QueryHubStateError extends Error {
73
- code: QueryHubStateErrorCode;
74
- cause?: unknown;
75
- constructor(code: QueryHubStateErrorCode, message: string, cause?: unknown);
76
- }
77
- /** * Fetch Guardian-attested Hub state directly from the Wormhole Query Proxy.
78
- *
79
- * Client-side only: this avoids relayer API costs and produces a Guardian-signed proof
80
- * that can be forwarded to the relayer for on-chain verification/submission.
81
- */
82
- declare function queryHubState(userKeyHash: string, apiKey: string, options?: QueryHubStateOptions): Promise<HubStateResult>;
83
-
84
- type QueryPortfolioNetwork = 'testnet' | 'mainnet';
85
- type QueryPortfolioOptions = {
86
- /** Max response age in seconds (default: 60). */
87
- maxAge?: number;
88
- network?: QueryPortfolioNetwork;
89
- /** Maximum attempts including the first try (default: 4). */
90
- maxAttempts?: number;
91
- /** Cache TTL in ms (default: 30_000). */
92
- cacheTtlMs?: number;
93
- /** Request timeout in ms (default: 15_000 for testnet, 10_000 for mainnet). */
94
- timeout?: number;
95
- /** Override Query Proxy endpoint. */
96
- endpoint?: string;
97
- /** Override per-chain RPC URLs used for block tag lookups. */
98
- rpcUrls?: Record<number, string>;
99
- /** Override derived vault addresses for specific Wormhole chain IDs. */
100
- vaultAddresses?: Record<number, string>;
101
- /** Override token lists (ERC20 only) for specific Wormhole chain IDs. */
102
- evmTokenAddresses?: Record<number, string[]>;
103
- /** Additional Solana accounts to include in the Solana account query (base58). */
104
- solanaAccounts?: string[];
105
- /** Optional USD prices by symbol/address for aggregation (e.g. { USDC: 1 }). */
106
- pricesUsd?: Record<string, number>;
107
- };
108
- type PortfolioBalance = {
109
- assetId: string;
110
- amount: bigint;
111
- decimals?: number;
112
- symbol?: string;
113
- usdValue?: number;
114
- };
115
- type PortfolioChainErrorCode = 'UNSUPPORTED_CHAIN' | 'MISSING_VAULT' | 'MISSING_TOKENS' | 'ATTESTATION_STALE' | 'DECODE_ERROR';
116
- type PortfolioChainResult = {
117
- wormholeChainId: number;
118
- chainName?: string;
119
- vaultAddress?: string;
120
- blockTime?: number;
121
- balances: PortfolioBalance[];
122
- error?: {
123
- code: PortfolioChainErrorCode;
124
- message: string;
125
- };
126
- };
127
- type PortfolioResult = {
128
- proof: Uint8Array;
129
- totalUsd?: number;
130
- chains: PortfolioChainResult[];
131
- };
132
- type QueryPortfolioErrorCode = 'INVALID_ARGUMENT' | 'NETWORK_ERROR' | 'PROXY_HTTP_ERROR' | 'PROXY_RESPONSE_INVALID' | 'QUERY_RESPONSE_INVALID';
133
- declare class QueryPortfolioError extends Error {
134
- code: QueryPortfolioErrorCode;
135
- cause?: unknown;
136
- constructor(code: QueryPortfolioErrorCode, message: string, cause?: unknown);
137
- }
138
- /**
139
- * Fetch Guardian-attested vault balances across multiple chains in one Query Proxy request.
140
- *
141
- * Notes:
142
- * - EVM balances are ERC20-only via `eth_call` (native ETH is not queryable via this query type).
143
- * - Solana balance uses lamports of the Veridex vault PDA (plus optional extra accounts).
144
- * - Aptos is included only if/when Wormhole Queries adds Aptos query types (currently returned as unsupported).
145
- */
146
- declare function queryPortfolio(userKeyHash: string, apiKey: string, options?: QueryPortfolioOptions): Promise<PortfolioResult>;
147
-
148
- export { type HubStateQuery, type HubStateResult, type PortfolioBalance, type PortfolioChainErrorCode, type PortfolioChainResult, type PortfolioQuery, type PortfolioResult, type QueryConfig, QueryHubStateError, type QueryHubStateErrorCode, type QueryHubStateNetwork, type QueryHubStateOptions, type QueryNetwork, type QueryOperation, type QueryOperationType, QueryPortfolioError, type QueryPortfolioErrorCode, type QueryPortfolioNetwork, type QueryPortfolioOptions, type QueryRequest, type QueryResponse, WORMHOLE_QUERY_CHAIN_IDS, WORMHOLE_QUERY_PROXY_URLS, WORMHOLE_QUERY_RATE_LIMIT_PER_SECOND, queryHubState, queryPortfolio };