@veridex/sdk 1.1.6 → 1.1.7
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/dist/{EVMClient-CTOtNY8I.d.mts → EVMClient-DqDiFak8.d.mts} +1 -1
- package/dist/auth/prepareAuth.d.mts +5 -4
- package/dist/auth/prepareAuth.js +57 -1415
- package/dist/auth/prepareAuth.js.map +1 -1
- package/dist/auth/prepareAuth.mjs +17 -96
- package/dist/auth/prepareAuth.mjs.map +1 -1
- package/dist/chains/aptos/index.d.mts +1 -1
- package/dist/chains/aptos/index.js +11 -33
- package/dist/chains/aptos/index.js.map +1 -1
- package/dist/chains/aptos/index.mjs +2 -2
- package/dist/chains/avalanche/index.d.mts +2 -2
- package/dist/chains/avalanche/index.js +19 -115
- package/dist/chains/avalanche/index.js.map +1 -1
- package/dist/chains/avalanche/index.mjs +3 -3
- package/dist/chains/evm/index.d.mts +3 -3
- package/dist/chains/evm/index.js +19 -115
- package/dist/chains/evm/index.js.map +1 -1
- package/dist/chains/evm/index.mjs +2 -2
- package/dist/chains/solana/index.d.mts +1 -1
- package/dist/chains/solana/index.js +11 -33
- package/dist/chains/solana/index.js.map +1 -1
- package/dist/chains/solana/index.mjs +2 -2
- package/dist/chains/stacks/index.d.mts +1 -1
- package/dist/chains/stacks/index.js +11 -38
- package/dist/chains/stacks/index.js.map +1 -1
- package/dist/chains/stacks/index.mjs +2 -2
- package/dist/chains/starknet/index.d.mts +36 -2
- package/dist/chains/starknet/index.js +208 -37
- package/dist/chains/starknet/index.js.map +1 -1
- package/dist/chains/starknet/index.mjs +9 -4
- package/dist/chains/sui/index.d.mts +1 -1
- package/dist/chains/sui/index.js +11 -27
- package/dist/chains/sui/index.js.map +1 -1
- package/dist/chains/sui/index.mjs +2 -2
- package/dist/{chunk-ZNIVNPGF.mjs → chunk-3PCAVZUZ.mjs} +173 -37
- package/dist/chunk-3PCAVZUZ.mjs.map +1 -0
- package/dist/{chunk-DQOW3G7M.mjs → chunk-6BINP4RT.mjs} +48 -9
- package/dist/{chunk-DQOW3G7M.mjs.map → chunk-6BINP4RT.mjs.map} +1 -1
- package/dist/{chunk-7KN6Y4GX.mjs → chunk-AK5HWYX4.mjs} +12 -40
- package/dist/chunk-AK5HWYX4.mjs.map +1 -0
- package/dist/{chunk-QVTADARB.mjs → chunk-FPSCAGYS.mjs} +12 -35
- package/dist/chunk-FPSCAGYS.mjs.map +1 -0
- package/dist/{chunk-USVZH4QC.mjs → chunk-H3WRT6Y4.mjs} +20 -117
- package/dist/chunk-H3WRT6Y4.mjs.map +1 -0
- package/dist/{chunk-GXJUY2SC.mjs → chunk-MNH22BM2.mjs} +12 -35
- package/dist/chunk-MNH22BM2.mjs.map +1 -0
- package/dist/chunk-N42LPFPJ.mjs +177 -0
- package/dist/chunk-N42LPFPJ.mjs.map +1 -0
- package/dist/{chunk-D57UJ4L5.mjs → chunk-NKSRF45N.mjs} +12 -29
- package/dist/chunk-NKSRF45N.mjs.map +1 -0
- package/dist/{chunk-2CALEUER.mjs → chunk-SKZLZFE2.mjs} +5 -58
- package/dist/chunk-SKZLZFE2.mjs.map +1 -0
- package/dist/{chunk-NVRAQPSF.mjs → chunk-UF5NWMSQ.mjs} +20 -4
- package/dist/chunk-UF5NWMSQ.mjs.map +1 -0
- package/dist/chunk-WC4X3MAO.mjs +58 -0
- package/dist/chunk-WC4X3MAO.mjs.map +1 -0
- package/dist/{chunk-5FH67KLG.mjs → chunk-XHDOSV2F.mjs} +2 -2
- package/dist/{index-9ercn1sa.d.mts → index-D1nb2JV9.d.mts} +1 -1
- package/dist/index-qyOqd8tx.d.mts +517 -0
- package/dist/index.d.mts +27 -364
- package/dist/index.js +2316 -2473
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +978 -51
- package/dist/index.mjs.map +1 -1
- package/dist/passkey.mjs +2 -1
- package/dist/payload.d.mts +22 -28
- package/dist/payload.js +50 -9
- package/dist/payload.js.map +1 -1
- package/dist/payload.mjs +7 -3
- package/dist/platform/index.d.mts +3 -0
- package/dist/platform/index.js +216 -0
- package/dist/platform/index.js.map +1 -0
- package/dist/platform/index.mjs +21 -0
- package/dist/platform/index.mjs.map +1 -0
- package/dist/{portfolio-W2FQ2G3O.mjs → portfolio-MLP2JIFK.mjs} +2 -3
- package/dist/queries/index.mjs +324 -10
- package/dist/queries/index.mjs.map +1 -1
- package/dist/{types-DQ5dtU9x.d.mts → types-CdlEbixV.d.mts} +11 -1
- package/package.json +7 -1
- package/dist/chunk-2CALEUER.mjs.map +0 -1
- package/dist/chunk-72ZA3OYQ.mjs +0 -20
- package/dist/chunk-72ZA3OYQ.mjs.map +0 -1
- package/dist/chunk-7KN6Y4GX.mjs.map +0 -1
- package/dist/chunk-D57UJ4L5.mjs.map +0 -1
- package/dist/chunk-GXJUY2SC.mjs.map +0 -1
- package/dist/chunk-NVRAQPSF.mjs.map +0 -1
- package/dist/chunk-QVTADARB.mjs.map +0 -1
- package/dist/chunk-USVZH4QC.mjs.map +0 -1
- package/dist/chunk-XDIIFIW6.mjs +0 -330
- package/dist/chunk-XDIIFIW6.mjs.map +0 -1
- package/dist/chunk-ZNIVNPGF.mjs.map +0 -1
- package/dist/chunk-ZXMTPBSP.mjs +0 -857
- package/dist/chunk-ZXMTPBSP.mjs.map +0 -1
- /package/dist/{chunk-5FH67KLG.mjs.map → chunk-XHDOSV2F.mjs.map} +0 -0
- /package/dist/{portfolio-W2FQ2G3O.mjs.map → portfolio-MLP2JIFK.mjs.map} +0 -0
package/dist/passkey.mjs
CHANGED
package/dist/payload.d.mts
CHANGED
|
@@ -90,36 +90,30 @@ declare function generateNonce(): bigint;
|
|
|
90
90
|
* Create a message hash for signing (used in authenticateRawAndDispatch)
|
|
91
91
|
*/
|
|
92
92
|
declare function createMessageHash(targetChain: number, actionPayload: string, nonce: bigint): string;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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;
|
|
93
|
+
declare const HUB_NONCE_DOMAIN = 0;
|
|
94
|
+
declare const TIER_T2_AUTHORITATIVE = 3;
|
|
95
|
+
interface DispatchDestinationV3 {
|
|
96
|
+
targetChain: number;
|
|
97
|
+
veridexChainId: number;
|
|
98
|
+
executor: string;
|
|
99
|
+
minTier: number;
|
|
100
|
+
}
|
|
101
|
+
interface GaslessChallengeV1 extends DispatchDestinationV3 {
|
|
102
|
+
actionPayload: string;
|
|
103
|
+
nonce: bigint;
|
|
104
|
+
}
|
|
105
|
+
interface CanonicalChallengeV1 {
|
|
106
|
+
veridexChainId: number;
|
|
107
|
+
executor: string;
|
|
108
|
+
minTier: number;
|
|
109
|
+
nonce: bigint;
|
|
110
|
+
actionHash: string;
|
|
111
|
+
}
|
|
112
|
+
declare function buildCanonicalChallenge(input: CanonicalChallengeV1): Uint8Array;
|
|
113
|
+
declare function buildGaslessChallenge(input: GaslessChallengeV1): Uint8Array;
|
|
120
114
|
/**
|
|
121
115
|
* Build the challenge bytes for WebAuthn signing
|
|
122
116
|
*/
|
|
123
117
|
declare function buildChallenge(userKeyHash: string, targetChain: number, nonce: bigint, actionPayload: string): Uint8Array;
|
|
124
118
|
|
|
125
|
-
export { buildChallenge, buildGaslessChallenge,
|
|
119
|
+
export { type CanonicalChallengeV1, type DispatchDestinationV3, type GaslessChallengeV1, HUB_NONCE_DOMAIN, TIER_T2_AUTHORITATIVE, buildCanonicalChallenge, buildChallenge, buildGaslessChallenge, createMessageHash, decodeActionPayload, decodeBridgeAction, decodeExecuteAction, decodeTransferAction, encodeAptosTransferAction, encodeBridgeAction, encodeConfigAction, encodeExecuteAction, encodeSolanaTransferAction, encodeSuiTransferAction, encodeTransferAction, encodeVeridexPayload, formatAmount, generateNonce, padTo32Bytes, parseAmount, solanaAddressToBytes32, trimTo20Bytes };
|
package/dist/payload.js
CHANGED
|
@@ -20,9 +20,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/payload.ts
|
|
21
21
|
var payload_exports = {};
|
|
22
22
|
__export(payload_exports, {
|
|
23
|
+
HUB_NONCE_DOMAIN: () => HUB_NONCE_DOMAIN,
|
|
24
|
+
TIER_T2_AUTHORITATIVE: () => TIER_T2_AUTHORITATIVE,
|
|
25
|
+
buildCanonicalChallenge: () => buildCanonicalChallenge,
|
|
23
26
|
buildChallenge: () => buildChallenge,
|
|
24
27
|
buildGaslessChallenge: () => buildGaslessChallenge,
|
|
25
|
-
createGaslessMessageHash: () => createGaslessMessageHash,
|
|
26
28
|
createMessageHash: () => createMessageHash,
|
|
27
29
|
decodeActionPayload: () => decodeActionPayload,
|
|
28
30
|
decodeBridgeAction: () => decodeBridgeAction,
|
|
@@ -270,15 +272,52 @@ function createMessageHash(targetChain, actionPayload, nonce) {
|
|
|
270
272
|
)
|
|
271
273
|
);
|
|
272
274
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
275
|
+
var HUB_NONCE_DOMAIN = 0;
|
|
276
|
+
var TIER_T2_AUTHORITATIVE = 3;
|
|
277
|
+
var CHALLENGE_DOMAIN = import_ethers.ethers.sha256(import_ethers.ethers.toUtf8Bytes("veridex.challenge.v1"));
|
|
278
|
+
function buildCanonicalChallenge(input) {
|
|
279
|
+
if (!Number.isInteger(input.veridexChainId) || input.veridexChainId <= 0 || input.veridexChainId > 4294967295) {
|
|
280
|
+
throw new Error("veridexChainId must be an integer between 1 and 4294967295");
|
|
281
|
+
}
|
|
282
|
+
if (!Number.isInteger(input.minTier) || input.minTier < 0 || input.minTier > TIER_T2_AUTHORITATIVE) {
|
|
283
|
+
throw new Error("minTier must be an integer between 0 and 3");
|
|
284
|
+
}
|
|
285
|
+
if (input.nonce < 0n || input.nonce > 0xffffffffffffffffn) {
|
|
286
|
+
throw new Error("nonce must fit in uint64");
|
|
287
|
+
}
|
|
288
|
+
const executor = import_ethers.ethers.hexlify(import_ethers.ethers.zeroPadValue(input.executor, 32));
|
|
289
|
+
if (executor === import_ethers.ethers.ZeroHash) {
|
|
290
|
+
throw new Error("executor must not be zero");
|
|
291
|
+
}
|
|
292
|
+
const preimage = import_ethers.ethers.solidityPacked(
|
|
293
|
+
["bytes32", "uint8", "uint8", "uint32", "bytes32", "uint32", "uint64", "bytes32"],
|
|
294
|
+
[
|
|
295
|
+
CHALLENGE_DOMAIN,
|
|
296
|
+
1,
|
|
297
|
+
input.minTier,
|
|
298
|
+
input.veridexChainId,
|
|
299
|
+
executor,
|
|
300
|
+
HUB_NONCE_DOMAIN,
|
|
301
|
+
input.nonce,
|
|
302
|
+
input.actionHash
|
|
303
|
+
]
|
|
277
304
|
);
|
|
305
|
+
if (import_ethers.ethers.dataLength(preimage) !== 114) {
|
|
306
|
+
throw new Error("canonical challenge preimage must be 114 bytes");
|
|
307
|
+
}
|
|
308
|
+
return import_ethers.ethers.getBytes(import_ethers.ethers.sha256(preimage));
|
|
278
309
|
}
|
|
279
|
-
function buildGaslessChallenge(
|
|
280
|
-
|
|
281
|
-
|
|
310
|
+
function buildGaslessChallenge(input) {
|
|
311
|
+
if (!Number.isInteger(input.targetChain) || input.targetChain < 0 || input.targetChain > 65535) {
|
|
312
|
+
throw new Error("targetChain must fit in uint16");
|
|
313
|
+
}
|
|
314
|
+
return buildCanonicalChallenge({
|
|
315
|
+
veridexChainId: input.veridexChainId,
|
|
316
|
+
executor: input.executor,
|
|
317
|
+
minTier: input.minTier,
|
|
318
|
+
nonce: input.nonce,
|
|
319
|
+
actionHash: import_ethers.ethers.keccak256(input.actionPayload)
|
|
320
|
+
});
|
|
282
321
|
}
|
|
283
322
|
function buildChallenge(userKeyHash, targetChain, nonce, actionPayload) {
|
|
284
323
|
const encoded = import_ethers.ethers.solidityPacked(
|
|
@@ -289,9 +328,11 @@ function buildChallenge(userKeyHash, targetChain, nonce, actionPayload) {
|
|
|
289
328
|
}
|
|
290
329
|
// Annotate the CommonJS export names for ESM import in node:
|
|
291
330
|
0 && (module.exports = {
|
|
331
|
+
HUB_NONCE_DOMAIN,
|
|
332
|
+
TIER_T2_AUTHORITATIVE,
|
|
333
|
+
buildCanonicalChallenge,
|
|
292
334
|
buildChallenge,
|
|
293
335
|
buildGaslessChallenge,
|
|
294
|
-
createGaslessMessageHash,
|
|
295
336
|
createMessageHash,
|
|
296
337
|
decodeActionPayload,
|
|
297
338
|
decodeBridgeAction,
|
package/dist/payload.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/payload.ts","../src/constants.ts"],"sourcesContent":["/**\n * Veridex Protocol SDK - Payload Encoding/Decoding Utilities\n */\n\nimport { ethers } from 'ethers';\nimport {\n ACTION_TRANSFER,\n ACTION_EXECUTE,\n ACTION_CONFIG,\n ACTION_BRIDGE,\n PROTOCOL_VERSION,\n} from './constants.js';\nimport type { TransferAction, BridgeAction, ExecuteAction, ActionPayload } from './types.js';\n\n// ============================================================================\n// Action Encoding\n// ============================================================================\n\n/**\n * Encode a transfer action payload\n * Format: [actionType(1)] [token(32)] [recipient(32)] [amount(32)]\n */\nexport function encodeTransferAction(\n token: string,\n recipient: string,\n amount: bigint\n): string {\n const tokenPadded = padTo32Bytes(token);\n const recipientPadded = padTo32Bytes(recipient);\n const amountBytes = ethers.zeroPadValue(ethers.toBeHex(amount), 32);\n\n return ethers.concat([\n ethers.toBeHex(ACTION_TRANSFER, 1),\n tokenPadded,\n recipientPadded,\n amountBytes,\n ]);\n}\n\n/**\n * Encode a bridge action payload\n * Format: [actionType(1)] [token(32)] [amount(32)] [targetChain(2)] [recipient(32)]\n */\nexport function encodeBridgeAction(\n token: string,\n amount: bigint,\n targetChain: number,\n recipient: string\n): string {\n const tokenPadded = padTo32Bytes(token);\n const amountBytes = ethers.zeroPadValue(ethers.toBeHex(amount), 32);\n const targetChainBytes = ethers.toBeHex(targetChain, 2);\n const recipientPadded = padTo32Bytes(recipient);\n\n return ethers.concat([\n ethers.toBeHex(ACTION_BRIDGE, 1),\n tokenPadded,\n amountBytes,\n targetChainBytes,\n recipientPadded,\n ]);\n}\n\n/**\n * Encode an execute action payload (arbitrary contract call)\n * Format: [actionType(1)] [target(32)] [value(32)] [dataLength(2)] [data(variable)]\n */\nexport function encodeExecuteAction(\n target: string,\n value: bigint,\n data: string\n): string {\n const targetPadded = padTo32Bytes(target);\n const valueBytes = ethers.zeroPadValue(ethers.toBeHex(value), 32);\n const dataBytes = ethers.getBytes(data);\n const dataLengthBytes = ethers.toBeHex(dataBytes.length, 2);\n\n return ethers.concat([\n ethers.toBeHex(ACTION_EXECUTE, 1),\n targetPadded,\n valueBytes,\n dataLengthBytes,\n data,\n ]);\n}\n\n/**\n * Encode a config action payload\n * Format: [actionType(1)] [configType(1)] [configData(variable)]\n */\nexport function encodeConfigAction(configType: number, configData: string): string {\n return ethers.concat([\n ethers.toBeHex(ACTION_CONFIG, 1),\n ethers.toBeHex(configType, 1),\n configData,\n ]);\n}\n\n// ============================================================================\n// Veridex Payload Encoding\n// ============================================================================\n\n/**\n * Encode the full Veridex message payload that gets published via Wormhole\n * Format: [version(1)] [userKeyHash(32)] [targetChain(2)] [nonce(32)] [pubKeyX(32)] [pubKeyY(32)] [actionPayload]\n */\nexport function encodeVeridexPayload(\n userKeyHash: string,\n targetChain: number,\n nonce: bigint,\n publicKeyX: bigint,\n publicKeyY: bigint,\n actionPayload: string\n): string {\n return ethers.concat([\n ethers.toBeHex(PROTOCOL_VERSION, 1),\n userKeyHash,\n ethers.toBeHex(targetChain, 2),\n ethers.zeroPadValue(ethers.toBeHex(nonce), 32),\n ethers.zeroPadValue(ethers.toBeHex(publicKeyX), 32),\n ethers.zeroPadValue(ethers.toBeHex(publicKeyY), 32),\n actionPayload,\n ]);\n}\n\n// ============================================================================\n// Action Decoding\n// ============================================================================\n\n/**\n * Decode an action payload to determine its type and contents\n */\nexport function decodeActionPayload(payload: string): ActionPayload {\n const data = ethers.getBytes(payload);\n const actionType = data[0];\n\n switch (actionType) {\n case ACTION_TRANSFER:\n return decodeTransferAction(payload);\n case ACTION_BRIDGE:\n return decodeBridgeAction(payload);\n case ACTION_EXECUTE:\n return decodeExecuteAction(payload);\n default:\n return { type: `unknown_${actionType}`, raw: payload };\n }\n}\n\n/**\n * Decode a transfer action payload\n */\nexport function decodeTransferAction(payload: string): TransferAction {\n const data = ethers.getBytes(payload);\n\n const tokenBytes = data.slice(1, 33);\n const recipientBytes = data.slice(33, 65);\n const amountBytes = data.slice(65, 97);\n\n return {\n type: 'transfer',\n token: trimTo20Bytes(ethers.hexlify(tokenBytes)),\n recipient: trimTo20Bytes(ethers.hexlify(recipientBytes)),\n amount: BigInt(ethers.hexlify(amountBytes)),\n };\n}\n\n/**\n * Decode a bridge action payload\n */\nexport function decodeBridgeAction(payload: string): BridgeAction {\n const data = ethers.getBytes(payload);\n\n const tokenBytes = data.slice(1, 33);\n const amountBytes = data.slice(33, 65);\n const targetChainByte0 = data[65];\n const targetChainByte1 = data[66];\n const recipientBytes = data.slice(67, 99);\n\n const targetChain = ((targetChainByte0 ?? 0) << 8) | (targetChainByte1 ?? 0);\n\n return {\n type: 'bridge',\n token: trimTo20Bytes(ethers.hexlify(tokenBytes)),\n amount: BigInt(ethers.hexlify(amountBytes)),\n targetChain,\n recipient: ethers.hexlify(recipientBytes),\n };\n}\n\n/**\n * Decode an execute action payload\n */\nexport function decodeExecuteAction(payload: string): ExecuteAction {\n const data = ethers.getBytes(payload);\n\n const targetBytes = data.slice(1, 33);\n const valueBytes = data.slice(33, 65);\n const dataLengthByte0 = data[65];\n const dataLengthByte1 = data[66];\n const dataLength = ((dataLengthByte0 ?? 0) << 8) | (dataLengthByte1 ?? 0);\n const callData = data.slice(67, 67 + dataLength);\n\n return {\n type: 'execute',\n target: trimTo20Bytes(ethers.hexlify(targetBytes)),\n value: BigInt(ethers.hexlify(valueBytes)),\n data: ethers.hexlify(callData),\n };\n}\n\n// ============================================================================\n// Chain-Specific Encodings\n// ============================================================================\n\n/**\n * Encode a Solana-compatible transfer action\n * Solana uses: [actionType(1)] [amount(8 LE)] [recipient(32)]\n */\nexport function encodeSolanaTransferAction(\n amount: bigint,\n recipient: string\n): string {\n const amountBytes = Buffer.alloc(8);\n amountBytes.writeBigUInt64LE(amount);\n\n const recipientBytes = ethers.getBytes(recipient);\n\n return ethers.hexlify(\n Buffer.concat([\n Buffer.from([ACTION_TRANSFER]),\n amountBytes,\n Buffer.from(recipientBytes),\n ])\n );\n}\n\n/**\n * Encode an Aptos-compatible transfer action\n * Aptos uses: [actionType(1)] [amount(8 LE)] [recipient(32)]\n */\nexport function encodeAptosTransferAction(\n amount: bigint,\n recipient: string\n): string {\n const amountBytes = Buffer.alloc(8);\n amountBytes.writeBigUInt64LE(amount);\n\n const recipientPadded = padTo32Bytes(recipient);\n\n return ethers.hexlify(\n Buffer.concat([\n Buffer.from([ACTION_TRANSFER]),\n amountBytes,\n Buffer.from(ethers.getBytes(recipientPadded)),\n ])\n );\n}\n\n/**\n * Encode a Sui-compatible transfer action\n * Sui uses: [actionType(1)] [amount(8 LE)] [recipient(32)]\n */\nexport function encodeSuiTransferAction(\n amount: bigint,\n recipient: string\n): string {\n const amountBytes = Buffer.alloc(8);\n amountBytes.writeBigUInt64LE(amount);\n\n const recipientPadded = padTo32Bytes(recipient);\n\n return ethers.hexlify(\n Buffer.concat([\n Buffer.from([ACTION_TRANSFER]),\n amountBytes,\n Buffer.from(ethers.getBytes(recipientPadded)),\n ])\n );\n}\n\n// ============================================================================\n// Address Utilities\n// ============================================================================\n\n/**\n * Pad an address to 32 bytes (Wormhole standard)\n * Supports both EVM addresses (0x...) and Solana addresses (base58)\n */\nexport function padTo32Bytes(address: string): string {\n // Handle native token - convert to zero address\n if (address.toLowerCase() === 'native') {\n return '0x' + '0'.repeat(64);\n }\n \n // If it starts with 0x, treat as hex\n if (address.startsWith('0x')) {\n const hex = address.replace('0x', '');\n // Validate that hex only contains valid hex characters\n if (!/^[0-9a-fA-F]*$/.test(hex)) {\n throw new Error(`Invalid address: ${address}. Expected hex string or 'native'.`);\n }\n return '0x' + hex.padStart(64, '0');\n }\n \n // Otherwise, assume base58 Solana address and decode it\n // Base58 character set (Bitcoin/Solana style - no 0, O, I, l)\n const base58Chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';\n \n // Validate base58 characters\n for (const char of address) {\n if (!base58Chars.includes(char)) {\n throw new Error(`Invalid address: ${address}. Contains invalid base58 character '${char}'.`);\n }\n }\n \n // Decode base58 to bytes\n let value = BigInt(0);\n for (const char of address) {\n value = value * 58n + BigInt(base58Chars.indexOf(char));\n }\n \n // Convert to 32-byte hex\n let hex = value.toString(16);\n // Ensure it's not longer than 64 chars (32 bytes)\n if (hex.length > 64) {\n throw new Error(`Invalid address: ${address}. Decoded value too large for 32 bytes.`);\n }\n \n return '0x' + hex.padStart(64, '0');\n}\n\n/**\n * Trim a 32-byte hex to a 20-byte EVM address\n */\nexport function trimTo20Bytes(hex32: string): string {\n const clean = hex32.replace('0x', '');\n return '0x' + clean.slice(-40);\n}\n\n/**\n * Convert a Solana public key (base58) to bytes32\n * @deprecated Use padTo32Bytes instead, which now handles both EVM and Solana addresses\n */\nexport function solanaAddressToBytes32(base58Address: string): string {\n return padTo32Bytes(base58Address);\n}\n\n// ============================================================================\n// Amount Utilities\n// ============================================================================\n\n/**\n * Format an amount with decimals for display\n */\nexport function formatAmount(amount: bigint, decimals = 18): string {\n const divisor = 10n ** BigInt(decimals);\n const whole = amount / divisor;\n const fraction = amount % divisor;\n\n if (fraction === 0n) {\n return whole.toString();\n }\n\n const fractionStr = fraction.toString().padStart(decimals, '0');\n const trimmedFraction = fractionStr.replace(/0+$/, '');\n\n return `${whole}.${trimmedFraction}`;\n}\n\n/**\n * Parse an amount string with decimals to bigint\n */\nexport function parseAmount(amountStr: string, decimals = 18): bigint {\n const parts = amountStr.split('.');\n const whole = BigInt(parts[0] ?? '0');\n\n if (parts.length === 1 || !parts[1]) {\n return whole * (10n ** BigInt(decimals));\n }\n\n const fractionStr = parts[1].slice(0, decimals).padEnd(decimals, '0');\n const fraction = BigInt(fractionStr);\n\n return whole * (10n ** BigInt(decimals)) + fraction;\n}\n\n// ============================================================================\n// Nonce Utilities\n// ============================================================================\n\n/**\n * Generate a unique nonce for a transaction\n */\nexport function generateNonce(): bigint {\n const timestamp = BigInt(Date.now());\n const random = BigInt(Math.floor(Math.random() * 1000000));\n return (timestamp << 20n) | random;\n}\n\n/**\n * Create a message hash for signing (used in authenticateRawAndDispatch)\n */\nexport function createMessageHash(\n targetChain: number,\n actionPayload: string,\n nonce: bigint\n): string {\n return ethers.keccak256(\n ethers.solidityPacked(\n ['uint16', 'bytes', 'uint256'],\n [targetChain, actionPayload, nonce]\n )\n );\n}\n\n/**\n * Create the challenge bytes for gasless dispatch (matches Hub's authenticateAndDispatch)\n * \n * The Hub contract passes raw packed bytes to WebAuthn.verify():\n * abi.encodePacked(targetChain, actionPayload, userNonce, hubChainId)\n * \n * The WebAuthn library then base64url-encodes these bytes to match against clientDataJSON.\n * We do NOT hash here - the challenge is the raw packed bytes.\n * \n * @param targetChain - Wormhole chain ID of the destination\n * @param actionPayload - The action payload (hex string)\n * @param nonce - User's current nonce\n * @param hubChainId - Wormhole chain ID of the Hub (e.g., 30 for Base)\n * @returns The packed bytes as hex string (NOT hashed)\n */\nexport function createGaslessMessageHash(\n targetChain: number,\n actionPayload: string,\n nonce: bigint,\n hubChainId: number\n): string {\n // Return raw packed bytes - NO sha256 hash\n // The contract passes these bytes directly to WebAuthn.verify()\n return ethers.solidityPacked(\n ['uint16', 'bytes', 'uint256', 'uint16'],\n [targetChain, actionPayload, nonce, hubChainId]\n );\n}\n\n/**\n * Build the challenge bytes for WebAuthn signing (gasless flow)\n * Returns raw packed bytes that match what the Hub contract expects\n * \n * @param targetChain - Wormhole chain ID of the destination\n * @param actionPayload - The action payload (hex string)\n * @param nonce - User's current nonce\n * @param hubChainId - Wormhole chain ID of the Hub\n * @returns Challenge bytes for WebAuthn signing (raw packed, not hashed)\n */\nexport function buildGaslessChallenge(\n targetChain: number,\n actionPayload: string,\n nonce: bigint,\n hubChainId: number\n): Uint8Array {\n const packed = createGaslessMessageHash(targetChain, actionPayload, nonce, hubChainId);\n return ethers.getBytes(packed);\n}\n\n/**\n * Build the challenge bytes for WebAuthn signing\n */\nexport function buildChallenge(\n userKeyHash: string,\n targetChain: number,\n nonce: bigint,\n actionPayload: string\n): Uint8Array {\n const encoded = ethers.solidityPacked(\n ['bytes32', 'uint16', 'uint256', 'bytes'],\n [userKeyHash, targetChain, nonce, actionPayload]\n );\n return ethers.getBytes(ethers.keccak256(encoded));\n}\n","/**\n * Veridex Protocol SDK - Constants and Chain Configurations\n */\n\nimport type { ChainConfig } from './types.js';\n\n// ============================================================================\n// Action Type Constants\n// ============================================================================\n\nexport const ACTION_TYPES = {\n TRANSFER: 1,\n EXECUTE: 2,\n CONFIG: 3,\n BRIDGE: 4,\n} as const;\n\nexport const ACTION_TRANSFER = 1;\nexport const ACTION_EXECUTE = 2;\nexport const ACTION_CONFIG = 3;\nexport const ACTION_BRIDGE = 4;\n\n// Protocol version\nexport const PROTOCOL_VERSION = 1;\n\n// ============================================================================\n// Wormhole Chain IDs\n// ============================================================================\n\n/**\n * Wormhole Chain IDs organized by network\n * @see https://docs.wormhole.com/wormhole/reference/constants\n */\nexport const WORMHOLE_CHAIN_IDS = {\n MAINNET: {\n SOLANA: 1,\n ETHEREUM: 2,\n TERRA: 3,\n BSC: 4,\n POLYGON: 5,\n AVALANCHE: 6,\n OASIS: 7,\n ALGORAND: 8,\n AURORA: 9,\n FANTOM: 10,\n KARURA: 11,\n ACALA: 12,\n KLAYTN: 13,\n CELO: 14,\n NEAR: 15,\n MOONBEAM: 16,\n NEON: 17,\n TERRA2: 18,\n INJECTIVE: 19,\n OSMOSIS: 20,\n SUI: 21,\n APTOS: 22,\n ARBITRUM: 23,\n OPTIMISM: 24,\n GNOSIS: 25,\n PYTHNET: 26,\n XPLA: 28,\n BASE: 30,\n SEI: 32,\n ROOTSTOCK: 33,\n SCROLL: 34,\n MANTLE: 35,\n BLAST: 36,\n XLAYER: 37,\n LINEA: 38,\n BERACHAIN: 39,\n SEIEVM: 40,\n },\n TESTNET: {\n SOLANA_DEVNET: 1,\n GOERLI: 2,\n BSC_TESTNET: 4,\n POLYGON_AMOY: 10007,\n AVALANCHE_FUJI: 6,\n FANTOM_TESTNET: 10,\n CELO_ALFAJORES: 14,\n MOONBASE_ALPHA: 16,\n SUI_TESTNET: 21,\n APTOS_TESTNET: 22,\n SEPOLIA: 10002,\n ARBITRUM_SEPOLIA: 10003,\n BASE_SEPOLIA: 10004,\n OPTIMISM_SEPOLIA: 10005,\n HOLESKY: 10006,\n POLYGON_SEPOLIA: 10007,\n SEI_ATLANTIC_2: 10066, // Sei Arctic-1 testnet (EVM)\n STARKNET_SEPOLIA: 50001, // Custom bridge (non-Wormhole, relayer-attested)\n },\n} as const;\n\n// Legacy flat exports for backward compatibility\nexport const WORMHOLE_CHAIN_IDS_FLAT = {\n // Mainnets\n SOLANA: 1,\n ETHEREUM: 2,\n TERRA: 3,\n BSC: 4,\n POLYGON: 5,\n AVALANCHE: 6,\n OASIS: 7,\n ALGORAND: 8,\n AURORA: 9,\n FANTOM: 10,\n KARURA: 11,\n ACALA: 12,\n KLAYTN: 13,\n CELO: 14,\n NEAR: 15,\n MOONBEAM: 16,\n NEON: 17,\n TERRA2: 18,\n INJECTIVE: 19,\n OSMOSIS: 20,\n SUI: 21,\n APTOS: 22,\n ARBITRUM: 23,\n OPTIMISM: 24,\n GNOSIS: 25,\n PYTHNET: 26,\n XPLA: 28,\n BASE: 30,\n SEI: 32,\n ROOTSTOCK: 33,\n SCROLL: 34,\n MANTLE: 35,\n BLAST: 36,\n XLAYER: 37,\n LINEA: 38,\n BERACHAIN: 39,\n SEIEVM: 40,\n\n // Testnets\n SOLANA_DEVNET: 1,\n GOERLI: 2,\n BSC_TESTNET: 4,\n POLYGON_AMOY: 10007,\n AVALANCHE_FUJI: 6,\n FANTOM_TESTNET: 10,\n CELO_ALFAJORES: 14,\n MOONBASE_ALPHA: 16,\n SUI_TESTNET: 21,\n APTOS_TESTNET: 22,\n ARBITRUM_SEPOLIA: 10003,\n BASE_SEPOLIA: 10004,\n OPTIMISM_SEPOLIA: 10005,\n POLYGON_SEPOLIA: 10007,\n HOLESKY: 10006,\n STARKNET_SEPOLIA: 50001, // Custom bridge (non-Wormhole)\n} as const;\n\n// ============================================================================\n// Testnet Chain Configurations\n// ============================================================================\n\nexport const TESTNET_CHAINS: Record<string, ChainConfig> = {\n baseSepolia: {\n name: 'Base Sepolia',\n chainId: 84532,\n wormholeChainId: 10004,\n rpcUrl: 'https://sepolia.base.org',\n explorerUrl: 'https://sepolia.basescan.org',\n isEvm: true,\n contracts: {\n hub: '0xD5D29b6EaeE6FF4b765e704298a7e48D22607059',\n vaultFactory: '0xb25b73D5FeD5693dcd1Bb78f8e33387B59A022EC',\n vaultImplementation: '0x2CB8397df988c1880d9e5cFfF65bfC22D7D90EE6',\n wormholeCoreBridge: '0x79A1027a6A159502049F10906D333EC57E95F083',\n tokenBridge: '0x86F55A04690fd7815A3D802bD587e83eA888B239',\n },\n },\n ethereumSepolia: {\n name: 'Ethereum Sepolia',\n chainId: 11155111,\n wormholeChainId: 10002,\n rpcUrl: 'https://ethereum-sepolia-rpc.publicnode.com',\n explorerUrl: 'https://sepolia.etherscan.io',\n isEvm: true,\n contracts: {\n vaultFactory: '0x265c10763B4d16AD970bC3d7670c645e37f63AF4',\n vaultImplementation: '0x942426C94652ebC48f4f404928016B95ADb1DA25',\n wormholeCoreBridge: '0x4a8bc80Ed5a4067f1CCf107057b8270E0cC11A78',\n tokenBridge: '0xDB5492265f6038831E89f495670FF909aDe94bd9',\n },\n },\n optimismSepolia: {\n name: 'Optimism Sepolia',\n chainId: 11155420,\n wormholeChainId: 10005,\n rpcUrl: 'https://sepolia.optimism.io',\n explorerUrl: 'https://sepolia-optimism.etherscan.io',\n isEvm: true,\n contracts: {\n vaultFactory: '0x3c5e4aCdC8Cd53ae5ae603B4c511885191fBb868',\n vaultImplementation: '0xA45dBF322c5A3028687fEEB161603d3BCe02e119',\n wormholeCoreBridge: '0x31377888146f3253211EFEf5c676D41ECe7D58Fe',\n tokenBridge: '0x99737Ec4B815d816c49A385943baf0380e75c0Ac',\n },\n },\n arbitrumSepolia: {\n name: 'Arbitrum Sepolia',\n chainId: 421614,\n wormholeChainId: 10003,\n rpcUrl: 'https://sepolia-rollup.arbitrum.io/rpc',\n explorerUrl: 'https://sepolia.arbiscan.io',\n isEvm: true,\n contracts: {\n vaultFactory: '0xB9C3e6bad3c6f26956be4a4bb5a366376Fd3045D',\n vaultImplementation: '0x8601881b94B68B09b485f407317686103d3CB681',\n wormholeCoreBridge: '0x6b9C8671cdDC8dEab9c719bB87cBd3e782bA6a35',\n tokenBridge: '0xC7A204bDBFe983FCD8d8E61D02b475D4073fF97e',\n },\n },\n monadTestnet: {\n name: 'Monad Testnet',\n chainId: 10143,\n wormholeChainId: 10048,\n rpcUrl: 'https://testnet-rpc.monad.xyz',\n explorerUrl: 'https://testnet.monadexplorer.com',\n isEvm: true,\n contracts: {\n vaultFactory: '0xbE9B9c39956448DA75Ac97E5e3dE17e34171660A',\n vaultImplementation: '0x500853DCc54Fd1A707ec9d443032Bb7748f426d3',\n wormholeCoreBridge: '0xBB73cB66C26740F31d1FabDC6b7A46a038A300dd',\n tokenBridge: '0x0000000000000000000000000000000000000000',\n },\n },\n avalancheFuji: {\n name: 'Avalanche Fuji',\n chainId: 43113,\n wormholeChainId: 6,\n rpcUrl: 'https://api.avax-test.network/ext/bc/C/rpc',\n explorerUrl: 'https://testnet.snowtrace.io',\n isEvm: true,\n contracts: {\n vaultFactory: '0x9e9716442e908A9b61F11432cC38024DD390cd2a',\n vaultImplementation: '0xE0b9919ffDf3415355Db369C8FfA5Dd4e000052c',\n wormholeCoreBridge: '0x7bbcE28e64B3F8b84d876Ab298393c38ad7aac4C',\n tokenBridge: '0x61E44E506Ca5659E6c0bba9b678586fA2d729756',\n },\n },\n polygonAmoy: {\n name: 'Polygon Amoy',\n chainId: 80002,\n wormholeChainId: 10007,\n rpcUrl: 'https://rpc-amoy.polygon.technology',\n explorerUrl: 'https://amoy.polygonscan.com',\n isEvm: true,\n contracts: {\n vaultFactory: '0x07F608AFf6d63b68029488b726d895c4Bb593038',\n vaultImplementation: '0xD66153fccFB6731fB6c4944FbD607ba86A76a1f6',\n wormholeCoreBridge: '0x6b9C8671cdDC8dEab9c719bB87cBd3e782bA6a35',\n tokenBridge: '0xC7A204bDBFe983FCD8d8E61D02b475D4073fF97e',\n },\n },\n solanaDevnet: {\n name: 'Solana Devnet',\n chainId: 0,\n wormholeChainId: 1,\n rpcUrl: 'https://api.devnet.solana.com',\n explorerUrl: 'https://explorer.solana.com',\n isEvm: false,\n contracts: {\n hub: '64ZZBdmGd1YT6Fok7PELvAdfoXyR4PHxHnRqHNqZHJ13',\n wormholeCoreBridge: '3u8hJUVTA4jH1wYAyUur7FFZVQ8H635K3tSHHF4ssjQ5',\n tokenBridge: 'DZnkkTmCiFWfYTfT41X3Rd1kDgozqzxWaHqsw6W4x2oe',\n },\n },\n aptosTestnet: {\n name: 'Aptos Testnet',\n chainId: 0,\n wormholeChainId: 22,\n rpcUrl: 'https://fullnode.testnet.aptoslabs.com/v1',\n explorerUrl: 'https://explorer.aptoslabs.com',\n isEvm: false,\n contracts: {\n hub: '0x9e8641143245ab8b93af1417a1fbc698d40fd351a25f6c17e4210e59bf82c9c7',\n wormholeCoreBridge: '0x5bc11445584a763c1fa7ed39081f1b920954da14e04b32440cba863d03e19625',\n tokenBridge: '0x576410486a2da45eee6c949c995670112ddf2fbeedab20350d506328eefc9d4f',\n },\n },\n suiTestnet: {\n name: 'Sui Testnet',\n chainId: 0,\n wormholeChainId: 21,\n rpcUrl: 'https://fullnode.testnet.sui.io:443',\n explorerUrl: 'https://suiscan.xyz/testnet',\n isEvm: false,\n contracts: {\n hub: '0xaf36d8bc349883b23e78b00a342a656c799319508600583eaee9121ffaa7f5f7',\n wormholeCoreBridge: '0x31358d198147da50db32eda2562951d53973a0c0ad5ed738e9b17d88b213d790',\n },\n },\n starknetSepolia: {\n name: 'Starknet Sepolia',\n chainId: 0,\n wormholeChainId: 50001,\n rpcUrl: 'https://starknet-sepolia-rpc.publicnode.com',\n explorerUrl: 'https://sepolia.starkscan.co',\n isEvm: false,\n contracts: {\n hub: '0x7bb7cbe7d82e910b296611b582035a207343431f98bdd7b692bddfdd6f28737',\n wormholeCoreBridge: '0x30d2e7f26dc75819cfddcd7caa26a76b681d5918f219c99060c42ce1e3f69e4',\n },\n hubChainId: 10004,\n },\n};\n\n// ============================================================================\n// Mainnet Chain Configurations\n// ============================================================================\n\nexport const MAINNET_CHAINS: Record<string, ChainConfig> = {\n ethereum: {\n name: 'Ethereum',\n chainId: 1,\n wormholeChainId: 2,\n rpcUrl: 'https://eth.llamarpc.com',\n explorerUrl: 'https://etherscan.io',\n isEvm: true,\n contracts: {\n wormholeCoreBridge: '0x98f3c9e6E3fAce36bAAd05FE09d375Ef1464288B',\n tokenBridge: '0x3ee18B2214AFF97000D974cf647E7C347E8fa585',\n },\n },\n base: {\n name: 'Base',\n chainId: 8453,\n wormholeChainId: 30,\n rpcUrl: 'https://mainnet.base.org',\n explorerUrl: 'https://basescan.org',\n isEvm: true,\n contracts: {\n wormholeCoreBridge: '0xbebdb6C8ddC678FfA9f8748f85C815C556Dd8ac6',\n tokenBridge: '0x8d2de8d2f73F1F4cAB472AC9A881C9b123C79627',\n },\n },\n optimism: {\n name: 'Optimism',\n chainId: 10,\n wormholeChainId: 24,\n rpcUrl: 'https://mainnet.optimism.io',\n explorerUrl: 'https://optimistic.etherscan.io',\n isEvm: true,\n contracts: {\n wormholeCoreBridge: '0xEe91C335eab126dF5fDB3797EA9d6aD93aeC9722',\n tokenBridge: '0x1D68124e65faFC907325e3EDbF8c4d84499DAa8b',\n },\n },\n arbitrum: {\n name: 'Arbitrum',\n chainId: 42161,\n wormholeChainId: 23,\n rpcUrl: 'https://arb1.arbitrum.io/rpc',\n explorerUrl: 'https://arbiscan.io',\n isEvm: true,\n contracts: {\n wormholeCoreBridge: '0xa5f208e072434bC67592E4C49C1B991BA79BCA46',\n tokenBridge: '0x0b2402144Bb366A632D14B83F244D2e0e21bD39c',\n },\n },\n polygon: {\n name: 'Polygon',\n chainId: 137,\n wormholeChainId: 5,\n rpcUrl: 'https://polygon-rpc.com',\n explorerUrl: 'https://polygonscan.com',\n isEvm: true,\n contracts: {\n wormholeCoreBridge: '0x7A4B5a56256163F07b2C80A7cA55aBE66c4ec4d7',\n tokenBridge: '0x5a58505a96D1dbf8dF91cB21B54419FC36e93fdE',\n },\n },\n solana: {\n name: 'Solana',\n chainId: 0,\n wormholeChainId: 1,\n rpcUrl: 'https://api.mainnet-beta.solana.com',\n explorerUrl: 'https://explorer.solana.com',\n isEvm: false,\n contracts: {\n wormholeCoreBridge: 'worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth',\n tokenBridge: 'wormDTUJ6AWPNvk59vGQbDvGJmqbDTdgWgAqcLBCgUb',\n },\n },\n aptos: {\n name: 'Aptos',\n chainId: 0,\n wormholeChainId: 22,\n rpcUrl: 'https://fullnode.mainnet.aptoslabs.com/v1',\n explorerUrl: 'https://explorer.aptoslabs.com',\n isEvm: false,\n contracts: {\n wormholeCoreBridge: '0x5bc11445584a763c1fa7ed39081f1b920954da14e04b32440cba863d03e19625',\n tokenBridge: '0x576410486a2da45eee6c949c995670112ddf2fbeedab20350d506328eefc9d4f',\n },\n },\n sui: {\n name: 'Sui',\n chainId: 0,\n wormholeChainId: 21,\n rpcUrl: 'https://fullnode.mainnet.sui.io:443',\n explorerUrl: 'https://suiscan.xyz/mainnet',\n isEvm: false,\n contracts: {\n wormholeCoreBridge: '0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c',\n },\n },\n};\n\n// ============================================================================\n// Wormhole API Endpoints\n// ============================================================================\n\nexport const WORMHOLE_API = {\n MAINNET: 'https://api.wormholescan.io',\n TESTNET: 'https://api.testnet.wormholescan.io',\n GUARDIAN_RPC_MAINNET: 'https://wormhole-v2-mainnet-api.certus.one',\n GUARDIAN_RPC_TESTNET: 'https://wormhole-v2-testnet-api.certus.one',\n} as const;\n\n// ============================================================================\n// Hub Contract ABI (minimal)\n// ============================================================================\n\nexport const HUB_ABI = [\n 'function authenticateAndDispatch((bytes authenticatorData, string clientDataJSON, uint256 challengeIndex, uint256 typeIndex, uint256 r, uint256 s) auth, uint256 publicKeyX, uint256 publicKeyY, uint16 targetChain, bytes actionPayload) external payable returns (uint64 sequence)',\n 'function authenticateRawAndDispatch(uint256 r, uint256 s, bytes32 messageHash, uint256 publicKeyX, uint256 publicKeyY, uint16 targetChain, bytes actionPayload, uint256 nonce) external payable returns (uint64 sequence)',\n 'function userNonces(bytes32 userKeyHash) external view returns (uint256)',\n 'function encodeTransferAction(address token, address recipient, uint256 amount) external pure returns (bytes)',\n 'function encodeExecuteAction(address target, uint256 value, bytes data) external pure returns (bytes)',\n 'function encodeBridgeAction(bytes32 token, uint256 amount, uint16 targetChain, bytes32 recipient) external pure returns (bytes)',\n 'function messageFee() external view returns (uint256)',\n 'event Dispatched(bytes32 indexed userKeyHash, uint16 targetChain, uint256 nonce, uint64 sequence, bytes actionPayload)',\n] as const;\n\n// ============================================================================\n// Vault Factory ABI (minimal)\n// ============================================================================\n\nexport const VAULT_FACTORY_ABI = [\n 'function createVault(bytes32 userKeyHash) external returns (address)',\n 'function getVault(bytes32 userKeyHash) external view returns (address)',\n 'function vaultExists(bytes32 userKeyHash) external view returns (bool)',\n 'event VaultCreated(bytes32 indexed userKeyHash, address vault)',\n] as const;\n\n// ============================================================================\n// Vault ABI (minimal)\n// ============================================================================\n\nexport const VAULT_ABI = [\n 'function execute(address target, uint256 value, bytes data) external returns (bytes)',\n 'function executeFromHub(bytes32 vaaHash, uint16 emitterChain, bytes32 emitterAddress, bytes payload) external',\n 'function owner() external view returns (bytes32)',\n 'function hub() external view returns (address)',\n 'receive() external payable',\n] as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,oBAAuB;;;ACahB,IAAM,kBAAkB;AACxB,IAAM,iBAAiB;AACvB,IAAM,gBAAgB;AACtB,IAAM,gBAAgB;AAGtB,IAAM,mBAAmB;;;ADDzB,SAAS,qBACd,OACA,WACA,QACQ;AACR,QAAM,cAAc,aAAa,KAAK;AACtC,QAAM,kBAAkB,aAAa,SAAS;AAC9C,QAAM,cAAc,qBAAO,aAAa,qBAAO,QAAQ,MAAM,GAAG,EAAE;AAElE,SAAO,qBAAO,OAAO;AAAA,IACnB,qBAAO,QAAQ,iBAAiB,CAAC;AAAA,IACjC;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;AAMO,SAAS,mBACd,OACA,QACA,aACA,WACQ;AACR,QAAM,cAAc,aAAa,KAAK;AACtC,QAAM,cAAc,qBAAO,aAAa,qBAAO,QAAQ,MAAM,GAAG,EAAE;AAClE,QAAM,mBAAmB,qBAAO,QAAQ,aAAa,CAAC;AACtD,QAAM,kBAAkB,aAAa,SAAS;AAE9C,SAAO,qBAAO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AAO,SAAS,qBAAO,UAAU,OAAO,CAAC;AAClD;","names":["hex"]}
|
|
1
|
+
{"version":3,"sources":["../src/payload.ts","../src/constants.ts"],"sourcesContent":["/**\n * Veridex Protocol SDK - Payload Encoding/Decoding Utilities\n */\n\nimport { ethers } from 'ethers';\nimport {\n ACTION_TRANSFER,\n ACTION_EXECUTE,\n ACTION_CONFIG,\n ACTION_BRIDGE,\n PROTOCOL_VERSION,\n} from './constants.js';\nimport type { TransferAction, BridgeAction, ExecuteAction, ActionPayload } from './types.js';\n\n// ============================================================================\n// Action Encoding\n// ============================================================================\n\n/**\n * Encode a transfer action payload\n * Format: [actionType(1)] [token(32)] [recipient(32)] [amount(32)]\n */\nexport function encodeTransferAction(\n token: string,\n recipient: string,\n amount: bigint\n): string {\n const tokenPadded = padTo32Bytes(token);\n const recipientPadded = padTo32Bytes(recipient);\n const amountBytes = ethers.zeroPadValue(ethers.toBeHex(amount), 32);\n\n return ethers.concat([\n ethers.toBeHex(ACTION_TRANSFER, 1),\n tokenPadded,\n recipientPadded,\n amountBytes,\n ]);\n}\n\n/**\n * Encode a bridge action payload\n * Format: [actionType(1)] [token(32)] [amount(32)] [targetChain(2)] [recipient(32)]\n */\nexport function encodeBridgeAction(\n token: string,\n amount: bigint,\n targetChain: number,\n recipient: string\n): string {\n const tokenPadded = padTo32Bytes(token);\n const amountBytes = ethers.zeroPadValue(ethers.toBeHex(amount), 32);\n const targetChainBytes = ethers.toBeHex(targetChain, 2);\n const recipientPadded = padTo32Bytes(recipient);\n\n return ethers.concat([\n ethers.toBeHex(ACTION_BRIDGE, 1),\n tokenPadded,\n amountBytes,\n targetChainBytes,\n recipientPadded,\n ]);\n}\n\n/**\n * Encode an execute action payload (arbitrary contract call)\n * Format: [actionType(1)] [target(32)] [value(32)] [dataLength(2)] [data(variable)]\n */\nexport function encodeExecuteAction(\n target: string,\n value: bigint,\n data: string\n): string {\n const targetPadded = padTo32Bytes(target);\n const valueBytes = ethers.zeroPadValue(ethers.toBeHex(value), 32);\n const dataBytes = ethers.getBytes(data);\n const dataLengthBytes = ethers.toBeHex(dataBytes.length, 2);\n\n return ethers.concat([\n ethers.toBeHex(ACTION_EXECUTE, 1),\n targetPadded,\n valueBytes,\n dataLengthBytes,\n data,\n ]);\n}\n\n/**\n * Encode a config action payload\n * Format: [actionType(1)] [configType(1)] [configData(variable)]\n */\nexport function encodeConfigAction(configType: number, configData: string): string {\n return ethers.concat([\n ethers.toBeHex(ACTION_CONFIG, 1),\n ethers.toBeHex(configType, 1),\n configData,\n ]);\n}\n\n// ============================================================================\n// Veridex Payload Encoding\n// ============================================================================\n\n/**\n * Encode the full Veridex message payload that gets published via Wormhole\n * Format: [version(1)] [userKeyHash(32)] [targetChain(2)] [nonce(32)] [pubKeyX(32)] [pubKeyY(32)] [actionPayload]\n */\nexport function encodeVeridexPayload(\n userKeyHash: string,\n targetChain: number,\n nonce: bigint,\n publicKeyX: bigint,\n publicKeyY: bigint,\n actionPayload: string\n): string {\n return ethers.concat([\n ethers.toBeHex(PROTOCOL_VERSION, 1),\n userKeyHash,\n ethers.toBeHex(targetChain, 2),\n ethers.zeroPadValue(ethers.toBeHex(nonce), 32),\n ethers.zeroPadValue(ethers.toBeHex(publicKeyX), 32),\n ethers.zeroPadValue(ethers.toBeHex(publicKeyY), 32),\n actionPayload,\n ]);\n}\n\n// ============================================================================\n// Action Decoding\n// ============================================================================\n\n/**\n * Decode an action payload to determine its type and contents\n */\nexport function decodeActionPayload(payload: string): ActionPayload {\n const data = ethers.getBytes(payload);\n const actionType = data[0];\n\n switch (actionType) {\n case ACTION_TRANSFER:\n return decodeTransferAction(payload);\n case ACTION_BRIDGE:\n return decodeBridgeAction(payload);\n case ACTION_EXECUTE:\n return decodeExecuteAction(payload);\n default:\n return { type: `unknown_${actionType}`, raw: payload };\n }\n}\n\n/**\n * Decode a transfer action payload\n */\nexport function decodeTransferAction(payload: string): TransferAction {\n const data = ethers.getBytes(payload);\n\n const tokenBytes = data.slice(1, 33);\n const recipientBytes = data.slice(33, 65);\n const amountBytes = data.slice(65, 97);\n\n return {\n type: 'transfer',\n token: trimTo20Bytes(ethers.hexlify(tokenBytes)),\n recipient: trimTo20Bytes(ethers.hexlify(recipientBytes)),\n amount: BigInt(ethers.hexlify(amountBytes)),\n };\n}\n\n/**\n * Decode a bridge action payload\n */\nexport function decodeBridgeAction(payload: string): BridgeAction {\n const data = ethers.getBytes(payload);\n\n const tokenBytes = data.slice(1, 33);\n const amountBytes = data.slice(33, 65);\n const targetChainByte0 = data[65];\n const targetChainByte1 = data[66];\n const recipientBytes = data.slice(67, 99);\n\n const targetChain = ((targetChainByte0 ?? 0) << 8) | (targetChainByte1 ?? 0);\n\n return {\n type: 'bridge',\n token: trimTo20Bytes(ethers.hexlify(tokenBytes)),\n amount: BigInt(ethers.hexlify(amountBytes)),\n targetChain,\n recipient: ethers.hexlify(recipientBytes),\n };\n}\n\n/**\n * Decode an execute action payload\n */\nexport function decodeExecuteAction(payload: string): ExecuteAction {\n const data = ethers.getBytes(payload);\n\n const targetBytes = data.slice(1, 33);\n const valueBytes = data.slice(33, 65);\n const dataLengthByte0 = data[65];\n const dataLengthByte1 = data[66];\n const dataLength = ((dataLengthByte0 ?? 0) << 8) | (dataLengthByte1 ?? 0);\n const callData = data.slice(67, 67 + dataLength);\n\n return {\n type: 'execute',\n target: trimTo20Bytes(ethers.hexlify(targetBytes)),\n value: BigInt(ethers.hexlify(valueBytes)),\n data: ethers.hexlify(callData),\n };\n}\n\n// ============================================================================\n// Chain-Specific Encodings\n// ============================================================================\n\n/**\n * Encode a Solana-compatible transfer action\n * Solana uses: [actionType(1)] [amount(8 LE)] [recipient(32)]\n */\nexport function encodeSolanaTransferAction(\n amount: bigint,\n recipient: string\n): string {\n const amountBytes = Buffer.alloc(8);\n amountBytes.writeBigUInt64LE(amount);\n\n const recipientBytes = ethers.getBytes(recipient);\n\n return ethers.hexlify(\n Buffer.concat([\n Buffer.from([ACTION_TRANSFER]),\n amountBytes,\n Buffer.from(recipientBytes),\n ])\n );\n}\n\n/**\n * Encode an Aptos-compatible transfer action\n * Aptos uses: [actionType(1)] [amount(8 LE)] [recipient(32)]\n */\nexport function encodeAptosTransferAction(\n amount: bigint,\n recipient: string\n): string {\n const amountBytes = Buffer.alloc(8);\n amountBytes.writeBigUInt64LE(amount);\n\n const recipientPadded = padTo32Bytes(recipient);\n\n return ethers.hexlify(\n Buffer.concat([\n Buffer.from([ACTION_TRANSFER]),\n amountBytes,\n Buffer.from(ethers.getBytes(recipientPadded)),\n ])\n );\n}\n\n/**\n * Encode a Sui-compatible transfer action\n * Sui uses: [actionType(1)] [amount(8 LE)] [recipient(32)]\n */\nexport function encodeSuiTransferAction(\n amount: bigint,\n recipient: string\n): string {\n const amountBytes = Buffer.alloc(8);\n amountBytes.writeBigUInt64LE(amount);\n\n const recipientPadded = padTo32Bytes(recipient);\n\n return ethers.hexlify(\n Buffer.concat([\n Buffer.from([ACTION_TRANSFER]),\n amountBytes,\n Buffer.from(ethers.getBytes(recipientPadded)),\n ])\n );\n}\n\n// ============================================================================\n// Address Utilities\n// ============================================================================\n\n/**\n * Pad an address to 32 bytes (Wormhole standard)\n * Supports both EVM addresses (0x...) and Solana addresses (base58)\n */\nexport function padTo32Bytes(address: string): string {\n // Handle native token - convert to zero address\n if (address.toLowerCase() === 'native') {\n return '0x' + '0'.repeat(64);\n }\n \n // If it starts with 0x, treat as hex\n if (address.startsWith('0x')) {\n const hex = address.replace('0x', '');\n // Validate that hex only contains valid hex characters\n if (!/^[0-9a-fA-F]*$/.test(hex)) {\n throw new Error(`Invalid address: ${address}. Expected hex string or 'native'.`);\n }\n return '0x' + hex.padStart(64, '0');\n }\n \n // Otherwise, assume base58 Solana address and decode it\n // Base58 character set (Bitcoin/Solana style - no 0, O, I, l)\n const base58Chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';\n \n // Validate base58 characters\n for (const char of address) {\n if (!base58Chars.includes(char)) {\n throw new Error(`Invalid address: ${address}. Contains invalid base58 character '${char}'.`);\n }\n }\n \n // Decode base58 to bytes\n let value = BigInt(0);\n for (const char of address) {\n value = value * 58n + BigInt(base58Chars.indexOf(char));\n }\n \n // Convert to 32-byte hex\n let hex = value.toString(16);\n // Ensure it's not longer than 64 chars (32 bytes)\n if (hex.length > 64) {\n throw new Error(`Invalid address: ${address}. Decoded value too large for 32 bytes.`);\n }\n \n return '0x' + hex.padStart(64, '0');\n}\n\n/**\n * Trim a 32-byte hex to a 20-byte EVM address\n */\nexport function trimTo20Bytes(hex32: string): string {\n const clean = hex32.replace('0x', '');\n return '0x' + clean.slice(-40);\n}\n\n/**\n * Convert a Solana public key (base58) to bytes32\n * @deprecated Use padTo32Bytes instead, which now handles both EVM and Solana addresses\n */\nexport function solanaAddressToBytes32(base58Address: string): string {\n return padTo32Bytes(base58Address);\n}\n\n// ============================================================================\n// Amount Utilities\n// ============================================================================\n\n/**\n * Format an amount with decimals for display\n */\nexport function formatAmount(amount: bigint, decimals = 18): string {\n const divisor = 10n ** BigInt(decimals);\n const whole = amount / divisor;\n const fraction = amount % divisor;\n\n if (fraction === 0n) {\n return whole.toString();\n }\n\n const fractionStr = fraction.toString().padStart(decimals, '0');\n const trimmedFraction = fractionStr.replace(/0+$/, '');\n\n return `${whole}.${trimmedFraction}`;\n}\n\n/**\n * Parse an amount string with decimals to bigint\n */\nexport function parseAmount(amountStr: string, decimals = 18): bigint {\n const parts = amountStr.split('.');\n const whole = BigInt(parts[0] ?? '0');\n\n if (parts.length === 1 || !parts[1]) {\n return whole * (10n ** BigInt(decimals));\n }\n\n const fractionStr = parts[1].slice(0, decimals).padEnd(decimals, '0');\n const fraction = BigInt(fractionStr);\n\n return whole * (10n ** BigInt(decimals)) + fraction;\n}\n\n// ============================================================================\n// Nonce Utilities\n// ============================================================================\n\n/**\n * Generate a unique nonce for a transaction\n */\nexport function generateNonce(): bigint {\n const timestamp = BigInt(Date.now());\n const random = BigInt(Math.floor(Math.random() * 1000000));\n return (timestamp << 20n) | random;\n}\n\n/**\n * Create a message hash for signing (used in authenticateRawAndDispatch)\n */\nexport function createMessageHash(\n targetChain: number,\n actionPayload: string,\n nonce: bigint\n): string {\n return ethers.keccak256(\n ethers.solidityPacked(\n ['uint16', 'bytes', 'uint256'],\n [targetChain, actionPayload, nonce]\n )\n );\n}\n\nexport const HUB_NONCE_DOMAIN = 0;\nexport const TIER_T2_AUTHORITATIVE = 3;\n\nexport interface DispatchDestinationV3 {\n targetChain: number;\n veridexChainId: number;\n executor: string;\n minTier: number;\n}\n\nexport interface GaslessChallengeV1 extends DispatchDestinationV3 {\n actionPayload: string;\n nonce: bigint;\n}\n\nexport interface CanonicalChallengeV1 {\n veridexChainId: number;\n executor: string;\n minTier: number;\n nonce: bigint;\n actionHash: string;\n}\n\nconst CHALLENGE_DOMAIN = ethers.sha256(ethers.toUtf8Bytes('veridex.challenge.v1'));\n\nexport function buildCanonicalChallenge(input: CanonicalChallengeV1): Uint8Array {\n if (!Number.isInteger(input.veridexChainId) || input.veridexChainId <= 0 || input.veridexChainId > 0xffffffff) {\n throw new Error('veridexChainId must be an integer between 1 and 4294967295');\n }\n if (!Number.isInteger(input.minTier) || input.minTier < 0 || input.minTier > TIER_T2_AUTHORITATIVE) {\n throw new Error('minTier must be an integer between 0 and 3');\n }\n if (input.nonce < 0n || input.nonce > 0xffffffffffffffffn) {\n throw new Error('nonce must fit in uint64');\n }\n\n const executor = ethers.hexlify(ethers.zeroPadValue(input.executor, 32));\n if (executor === ethers.ZeroHash) {\n throw new Error('executor must not be zero');\n }\n\n const preimage = ethers.solidityPacked(\n ['bytes32', 'uint8', 'uint8', 'uint32', 'bytes32', 'uint32', 'uint64', 'bytes32'],\n [\n CHALLENGE_DOMAIN,\n 1,\n input.minTier,\n input.veridexChainId,\n executor,\n HUB_NONCE_DOMAIN,\n input.nonce,\n input.actionHash,\n ]\n );\n if (ethers.dataLength(preimage) !== 114) {\n throw new Error('canonical challenge preimage must be 114 bytes');\n }\n return ethers.getBytes(ethers.sha256(preimage));\n}\n\nexport function buildGaslessChallenge(input: GaslessChallengeV1): Uint8Array {\n if (!Number.isInteger(input.targetChain) || input.targetChain < 0 || input.targetChain > 0xffff) {\n throw new Error('targetChain must fit in uint16');\n }\n\n return buildCanonicalChallenge({\n veridexChainId: input.veridexChainId,\n executor: input.executor,\n minTier: input.minTier,\n nonce: input.nonce,\n actionHash: ethers.keccak256(input.actionPayload),\n });\n}\n\n/**\n * Build the challenge bytes for WebAuthn signing\n */\nexport function buildChallenge(\n userKeyHash: string,\n targetChain: number,\n nonce: bigint,\n actionPayload: string\n): Uint8Array {\n const encoded = ethers.solidityPacked(\n ['bytes32', 'uint16', 'uint256', 'bytes'],\n [userKeyHash, targetChain, nonce, actionPayload]\n );\n return ethers.getBytes(ethers.keccak256(encoded));\n}\n","/**\n * Veridex Protocol SDK - Constants and Chain Configurations\n */\n\nimport type { ChainConfig } from './types.js';\n\n// ============================================================================\n// Action Type Constants\n// ============================================================================\n\nexport const ACTION_TYPES = {\n TRANSFER: 1,\n EXECUTE: 2,\n CONFIG: 3,\n BRIDGE: 4,\n} as const;\n\nexport const ACTION_TRANSFER = 1;\nexport const ACTION_EXECUTE = 2;\nexport const ACTION_CONFIG = 3;\nexport const ACTION_BRIDGE = 4;\n\n// Protocol version\nexport const PROTOCOL_VERSION = 1;\n\n// ============================================================================\n// Wormhole Chain IDs\n// ============================================================================\n\n/**\n * Wormhole Chain IDs organized by network\n * @see https://docs.wormhole.com/wormhole/reference/constants\n */\nexport const WORMHOLE_CHAIN_IDS = {\n MAINNET: {\n SOLANA: 1,\n ETHEREUM: 2,\n TERRA: 3,\n BSC: 4,\n POLYGON: 5,\n AVALANCHE: 6,\n OASIS: 7,\n ALGORAND: 8,\n AURORA: 9,\n FANTOM: 10,\n KARURA: 11,\n ACALA: 12,\n KLAYTN: 13,\n CELO: 14,\n NEAR: 15,\n MOONBEAM: 16,\n NEON: 17,\n TERRA2: 18,\n INJECTIVE: 19,\n OSMOSIS: 20,\n SUI: 21,\n APTOS: 22,\n ARBITRUM: 23,\n OPTIMISM: 24,\n GNOSIS: 25,\n PYTHNET: 26,\n XPLA: 28,\n BASE: 30,\n SEI: 32,\n ROOTSTOCK: 33,\n SCROLL: 34,\n MANTLE: 35,\n BLAST: 36,\n XLAYER: 37,\n LINEA: 38,\n BERACHAIN: 39,\n SEIEVM: 40,\n },\n TESTNET: {\n SOLANA_DEVNET: 1,\n GOERLI: 2,\n BSC_TESTNET: 4,\n POLYGON_AMOY: 10007,\n AVALANCHE_FUJI: 6,\n FANTOM_TESTNET: 10,\n CELO_ALFAJORES: 14,\n MOONBASE_ALPHA: 16,\n SUI_TESTNET: 21,\n APTOS_TESTNET: 22,\n SEPOLIA: 10002,\n ARBITRUM_SEPOLIA: 10003,\n BASE_SEPOLIA: 10004,\n OPTIMISM_SEPOLIA: 10005,\n HOLESKY: 10006,\n POLYGON_SEPOLIA: 10007,\n SEI_ATLANTIC_2: 10066, // Sei Arctic-1 testnet (EVM)\n STARKNET_SEPOLIA: 50001, // Custom bridge (non-Wormhole, relayer-attested)\n },\n} as const;\n\n// Legacy flat exports for backward compatibility\nexport const WORMHOLE_CHAIN_IDS_FLAT = {\n // Mainnets\n SOLANA: 1,\n ETHEREUM: 2,\n TERRA: 3,\n BSC: 4,\n POLYGON: 5,\n AVALANCHE: 6,\n OASIS: 7,\n ALGORAND: 8,\n AURORA: 9,\n FANTOM: 10,\n KARURA: 11,\n ACALA: 12,\n KLAYTN: 13,\n CELO: 14,\n NEAR: 15,\n MOONBEAM: 16,\n NEON: 17,\n TERRA2: 18,\n INJECTIVE: 19,\n OSMOSIS: 20,\n SUI: 21,\n APTOS: 22,\n ARBITRUM: 23,\n OPTIMISM: 24,\n GNOSIS: 25,\n PYTHNET: 26,\n XPLA: 28,\n BASE: 30,\n SEI: 32,\n ROOTSTOCK: 33,\n SCROLL: 34,\n MANTLE: 35,\n BLAST: 36,\n XLAYER: 37,\n LINEA: 38,\n BERACHAIN: 39,\n SEIEVM: 40,\n\n // Testnets\n SOLANA_DEVNET: 1,\n GOERLI: 2,\n BSC_TESTNET: 4,\n POLYGON_AMOY: 10007,\n AVALANCHE_FUJI: 6,\n FANTOM_TESTNET: 10,\n CELO_ALFAJORES: 14,\n MOONBASE_ALPHA: 16,\n SUI_TESTNET: 21,\n APTOS_TESTNET: 22,\n ARBITRUM_SEPOLIA: 10003,\n BASE_SEPOLIA: 10004,\n OPTIMISM_SEPOLIA: 10005,\n POLYGON_SEPOLIA: 10007,\n HOLESKY: 10006,\n STARKNET_SEPOLIA: 50001, // Custom bridge (non-Wormhole)\n} as const;\n\n// ============================================================================\n// Testnet Chain Configurations\n// ============================================================================\n\nexport const TESTNET_CHAINS: Record<string, ChainConfig> = {\n baseSepolia: {\n name: 'Base Sepolia',\n chainId: 84532,\n wormholeChainId: 10004,\n rpcUrl: 'https://sepolia.base.org',\n explorerUrl: 'https://sepolia.basescan.org',\n isEvm: true,\n contracts: {\n hub: '0xD5D29b6EaeE6FF4b765e704298a7e48D22607059',\n vaultFactory: '0xb25b73D5FeD5693dcd1Bb78f8e33387B59A022EC',\n vaultImplementation: '0x2CB8397df988c1880d9e5cFfF65bfC22D7D90EE6',\n wormholeCoreBridge: '0x79A1027a6A159502049F10906D333EC57E95F083',\n tokenBridge: '0x86F55A04690fd7815A3D802bD587e83eA888B239',\n },\n },\n ethereumSepolia: {\n name: 'Ethereum Sepolia',\n chainId: 11155111,\n wormholeChainId: 10002,\n rpcUrl: 'https://ethereum-sepolia-rpc.publicnode.com',\n explorerUrl: 'https://sepolia.etherscan.io',\n isEvm: true,\n contracts: {\n vaultFactory: '0x265c10763B4d16AD970bC3d7670c645e37f63AF4',\n vaultImplementation: '0x942426C94652ebC48f4f404928016B95ADb1DA25',\n wormholeCoreBridge: '0x4a8bc80Ed5a4067f1CCf107057b8270E0cC11A78',\n tokenBridge: '0xDB5492265f6038831E89f495670FF909aDe94bd9',\n },\n },\n optimismSepolia: {\n name: 'Optimism Sepolia',\n chainId: 11155420,\n wormholeChainId: 10005,\n rpcUrl: 'https://sepolia.optimism.io',\n explorerUrl: 'https://sepolia-optimism.etherscan.io',\n isEvm: true,\n contracts: {\n vaultFactory: '0x3c5e4aCdC8Cd53ae5ae603B4c511885191fBb868',\n vaultImplementation: '0xA45dBF322c5A3028687fEEB161603d3BCe02e119',\n wormholeCoreBridge: '0x31377888146f3253211EFEf5c676D41ECe7D58Fe',\n tokenBridge: '0x99737Ec4B815d816c49A385943baf0380e75c0Ac',\n },\n },\n arbitrumSepolia: {\n name: 'Arbitrum Sepolia',\n chainId: 421614,\n wormholeChainId: 10003,\n rpcUrl: 'https://sepolia-rollup.arbitrum.io/rpc',\n explorerUrl: 'https://sepolia.arbiscan.io',\n isEvm: true,\n contracts: {\n vaultFactory: '0xB9C3e6bad3c6f26956be4a4bb5a366376Fd3045D',\n vaultImplementation: '0x8601881b94B68B09b485f407317686103d3CB681',\n wormholeCoreBridge: '0x6b9C8671cdDC8dEab9c719bB87cBd3e782bA6a35',\n tokenBridge: '0xC7A204bDBFe983FCD8d8E61D02b475D4073fF97e',\n },\n },\n monadTestnet: {\n name: 'Monad Testnet',\n chainId: 10143,\n wormholeChainId: 10048,\n rpcUrl: 'https://testnet-rpc.monad.xyz',\n explorerUrl: 'https://testnet.monadexplorer.com',\n isEvm: true,\n contracts: {\n vaultFactory: '0xbE9B9c39956448DA75Ac97E5e3dE17e34171660A',\n vaultImplementation: '0x500853DCc54Fd1A707ec9d443032Bb7748f426d3',\n wormholeCoreBridge: '0xBB73cB66C26740F31d1FabDC6b7A46a038A300dd',\n tokenBridge: '0x0000000000000000000000000000000000000000',\n },\n },\n avalancheFuji: {\n name: 'Avalanche Fuji',\n chainId: 43113,\n wormholeChainId: 6,\n rpcUrl: 'https://api.avax-test.network/ext/bc/C/rpc',\n explorerUrl: 'https://testnet.snowtrace.io',\n isEvm: true,\n contracts: {\n vaultFactory: '0x9e9716442e908A9b61F11432cC38024DD390cd2a',\n vaultImplementation: '0xE0b9919ffDf3415355Db369C8FfA5Dd4e000052c',\n wormholeCoreBridge: '0x7bbcE28e64B3F8b84d876Ab298393c38ad7aac4C',\n tokenBridge: '0x61E44E506Ca5659E6c0bba9b678586fA2d729756',\n },\n },\n polygonAmoy: {\n name: 'Polygon Amoy',\n chainId: 80002,\n wormholeChainId: 10007,\n rpcUrl: 'https://rpc-amoy.polygon.technology',\n explorerUrl: 'https://amoy.polygonscan.com',\n isEvm: true,\n contracts: {\n vaultFactory: '0x07F608AFf6d63b68029488b726d895c4Bb593038',\n vaultImplementation: '0xD66153fccFB6731fB6c4944FbD607ba86A76a1f6',\n wormholeCoreBridge: '0x6b9C8671cdDC8dEab9c719bB87cBd3e782bA6a35',\n tokenBridge: '0xC7A204bDBFe983FCD8d8E61D02b475D4073fF97e',\n },\n },\n solanaDevnet: {\n name: 'Solana Devnet',\n chainId: 0,\n wormholeChainId: 1,\n rpcUrl: 'https://api.devnet.solana.com',\n explorerUrl: 'https://explorer.solana.com',\n isEvm: false,\n contracts: {\n hub: '64ZZBdmGd1YT6Fok7PELvAdfoXyR4PHxHnRqHNqZHJ13',\n wormholeCoreBridge: '3u8hJUVTA4jH1wYAyUur7FFZVQ8H635K3tSHHF4ssjQ5',\n tokenBridge: 'DZnkkTmCiFWfYTfT41X3Rd1kDgozqzxWaHqsw6W4x2oe',\n },\n },\n aptosTestnet: {\n name: 'Aptos Testnet',\n chainId: 0,\n wormholeChainId: 22,\n rpcUrl: 'https://fullnode.testnet.aptoslabs.com/v1',\n explorerUrl: 'https://explorer.aptoslabs.com',\n isEvm: false,\n contracts: {\n hub: '0x9e8641143245ab8b93af1417a1fbc698d40fd351a25f6c17e4210e59bf82c9c7',\n wormholeCoreBridge: '0x5bc11445584a763c1fa7ed39081f1b920954da14e04b32440cba863d03e19625',\n tokenBridge: '0x576410486a2da45eee6c949c995670112ddf2fbeedab20350d506328eefc9d4f',\n },\n },\n suiTestnet: {\n name: 'Sui Testnet',\n chainId: 0,\n wormholeChainId: 21,\n rpcUrl: 'https://fullnode.testnet.sui.io:443',\n explorerUrl: 'https://suiscan.xyz/testnet',\n isEvm: false,\n contracts: {\n hub: '0xaf36d8bc349883b23e78b00a342a656c799319508600583eaee9121ffaa7f5f7',\n wormholeCoreBridge: '0x31358d198147da50db32eda2562951d53973a0c0ad5ed738e9b17d88b213d790',\n },\n },\n starknetSepolia: {\n name: 'Starknet Sepolia',\n chainId: 0,\n wormholeChainId: 50001,\n rpcUrl: 'https://starknet-sepolia-rpc.publicnode.com',\n explorerUrl: 'https://sepolia.starkscan.co',\n isEvm: false,\n contracts: {\n hub: '0x7bb7cbe7d82e910b296611b582035a207343431f98bdd7b692bddfdd6f28737',\n wormholeCoreBridge: '0x30d2e7f26dc75819cfddcd7caa26a76b681d5918f219c99060c42ce1e3f69e4',\n },\n hubChainId: 10004,\n },\n};\n\n// ============================================================================\n// Mainnet Chain Configurations\n// ============================================================================\n\nexport const MAINNET_CHAINS: Record<string, ChainConfig> = {\n ethereum: {\n name: 'Ethereum',\n chainId: 1,\n wormholeChainId: 2,\n rpcUrl: 'https://eth.llamarpc.com',\n explorerUrl: 'https://etherscan.io',\n isEvm: true,\n contracts: {\n wormholeCoreBridge: '0x98f3c9e6E3fAce36bAAd05FE09d375Ef1464288B',\n tokenBridge: '0x3ee18B2214AFF97000D974cf647E7C347E8fa585',\n },\n },\n base: {\n name: 'Base',\n chainId: 8453,\n wormholeChainId: 30,\n rpcUrl: 'https://mainnet.base.org',\n explorerUrl: 'https://basescan.org',\n isEvm: true,\n contracts: {\n wormholeCoreBridge: '0xbebdb6C8ddC678FfA9f8748f85C815C556Dd8ac6',\n tokenBridge: '0x8d2de8d2f73F1F4cAB472AC9A881C9b123C79627',\n },\n },\n optimism: {\n name: 'Optimism',\n chainId: 10,\n wormholeChainId: 24,\n rpcUrl: 'https://mainnet.optimism.io',\n explorerUrl: 'https://optimistic.etherscan.io',\n isEvm: true,\n contracts: {\n wormholeCoreBridge: '0xEe91C335eab126dF5fDB3797EA9d6aD93aeC9722',\n tokenBridge: '0x1D68124e65faFC907325e3EDbF8c4d84499DAa8b',\n },\n },\n arbitrum: {\n name: 'Arbitrum',\n chainId: 42161,\n wormholeChainId: 23,\n rpcUrl: 'https://arb1.arbitrum.io/rpc',\n explorerUrl: 'https://arbiscan.io',\n isEvm: true,\n contracts: {\n wormholeCoreBridge: '0xa5f208e072434bC67592E4C49C1B991BA79BCA46',\n tokenBridge: '0x0b2402144Bb366A632D14B83F244D2e0e21bD39c',\n },\n },\n polygon: {\n name: 'Polygon',\n chainId: 137,\n wormholeChainId: 5,\n rpcUrl: 'https://polygon-rpc.com',\n explorerUrl: 'https://polygonscan.com',\n isEvm: true,\n contracts: {\n wormholeCoreBridge: '0x7A4B5a56256163F07b2C80A7cA55aBE66c4ec4d7',\n tokenBridge: '0x5a58505a96D1dbf8dF91cB21B54419FC36e93fdE',\n },\n },\n solana: {\n name: 'Solana',\n chainId: 0,\n wormholeChainId: 1,\n rpcUrl: 'https://api.mainnet-beta.solana.com',\n explorerUrl: 'https://explorer.solana.com',\n isEvm: false,\n contracts: {\n wormholeCoreBridge: 'worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth',\n tokenBridge: 'wormDTUJ6AWPNvk59vGQbDvGJmqbDTdgWgAqcLBCgUb',\n },\n },\n aptos: {\n name: 'Aptos',\n chainId: 0,\n wormholeChainId: 22,\n rpcUrl: 'https://fullnode.mainnet.aptoslabs.com/v1',\n explorerUrl: 'https://explorer.aptoslabs.com',\n isEvm: false,\n contracts: {\n wormholeCoreBridge: '0x5bc11445584a763c1fa7ed39081f1b920954da14e04b32440cba863d03e19625',\n tokenBridge: '0x576410486a2da45eee6c949c995670112ddf2fbeedab20350d506328eefc9d4f',\n },\n },\n sui: {\n name: 'Sui',\n chainId: 0,\n wormholeChainId: 21,\n rpcUrl: 'https://fullnode.mainnet.sui.io:443',\n explorerUrl: 'https://suiscan.xyz/mainnet',\n isEvm: false,\n contracts: {\n wormholeCoreBridge: '0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c',\n },\n },\n};\n\n// ============================================================================\n// Wormhole API Endpoints\n// ============================================================================\n\nexport const WORMHOLE_API = {\n MAINNET: 'https://api.wormholescan.io',\n TESTNET: 'https://api.testnet.wormholescan.io',\n GUARDIAN_RPC_MAINNET: 'https://wormhole-v2-mainnet-api.certus.one',\n GUARDIAN_RPC_TESTNET: 'https://wormhole-v2-testnet-api.certus.one',\n} as const;\n\n// ============================================================================\n// Hub Contract ABI (minimal)\n// ============================================================================\n\nexport const HUB_ABI = [\n 'function authenticateAndDispatch((bytes authenticatorData, string clientDataJSON, uint256 challengeIndex, uint256 typeIndex, uint256 r, uint256 s) auth, uint256 publicKeyX, uint256 publicKeyY, uint16 targetChain, bytes actionPayload) external payable returns (uint64 sequence)',\n 'function authenticateRawAndDispatch(uint256 r, uint256 s, bytes32 messageHash, uint256 publicKeyX, uint256 publicKeyY, uint16 targetChain, bytes actionPayload, uint256 nonce) external payable returns (uint64 sequence)',\n 'function userNonces(bytes32 userKeyHash) external view returns (uint256)',\n 'function encodeTransferAction(address token, address recipient, uint256 amount) external pure returns (bytes)',\n 'function encodeExecuteAction(address target, uint256 value, bytes data) external pure returns (bytes)',\n 'function encodeBridgeAction(bytes32 token, uint256 amount, uint16 targetChain, bytes32 recipient) external pure returns (bytes)',\n 'function messageFee() external view returns (uint256)',\n 'event Dispatched(bytes32 indexed userKeyHash, uint16 targetChain, uint256 nonce, uint64 sequence, bytes actionPayload)',\n] as const;\n\n// ============================================================================\n// Vault Factory ABI (minimal)\n// ============================================================================\n\nexport const VAULT_FACTORY_ABI = [\n 'function createVault(bytes32 userKeyHash) external returns (address)',\n 'function getVault(bytes32 userKeyHash) external view returns (address)',\n 'function vaultExists(bytes32 userKeyHash) external view returns (bool)',\n 'event VaultCreated(bytes32 indexed userKeyHash, address vault)',\n] as const;\n\n// ============================================================================\n// Vault ABI (minimal)\n// ============================================================================\n\nexport const VAULT_ABI = [\n 'function execute(address target, uint256 value, bytes data) external returns (bytes)',\n 'function executeFromHub(bytes32 vaaHash, uint16 emitterChain, bytes32 emitterAddress, bytes payload) external',\n 'function owner() external view returns (bytes32)',\n 'function hub() external view returns (address)',\n 'receive() external payable',\n] as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,oBAAuB;;;ACahB,IAAM,kBAAkB;AACxB,IAAM,iBAAiB;AACvB,IAAM,gBAAgB;AACtB,IAAM,gBAAgB;AAGtB,IAAM,mBAAmB;;;ADDzB,SAAS,qBACd,OACA,WACA,QACQ;AACR,QAAM,cAAc,aAAa,KAAK;AACtC,QAAM,kBAAkB,aAAa,SAAS;AAC9C,QAAM,cAAc,qBAAO,aAAa,qBAAO,QAAQ,MAAM,GAAG,EAAE;AAElE,SAAO,qBAAO,OAAO;AAAA,IACnB,qBAAO,QAAQ,iBAAiB,CAAC;AAAA,IACjC;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;AAMO,SAAS,mBACd,OACA,QACA,aACA,WACQ;AACR,QAAM,cAAc,aAAa,KAAK;AACtC,QAAM,cAAc,qBAAO,aAAa,qBAAO,QAAQ,MAAM,GAAG,EAAE;AAClE,QAAM,mBAAmB,qBAAO,QAAQ,aAAa,CAAC;AACtD,QAAM,kBAAkB,aAAa,SAAS;AAE9C,SAAO,qBAAO,OAAO;AAAA,IACnB,qBAAO,QAAQ,eAAe,CAAC;AAAA,IAC/B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;AAMO,SAAS,oBACd,QACA,OACA,MACQ;AACR,QAAM,eAAe,aAAa,MAAM;AACxC,QAAM,aAAa,qBAAO,aAAa,qBAAO,QAAQ,KAAK,GAAG,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AW,SAAS,SAAS,UAAU,WAAW,UAAU,UAAU,SAAS;AAAA,IAChF;AAAA,MACE;AAAA,MACA;AAAA,MACA,MAAM;AAAA,MACN,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,EACF;AACA,MAAI,qBAAO,WAAW,QAAQ,MAAM,KAAK;AACvC,UAAM,IAAI,MAAM,gDAAgD;AAAA,EAClE;AACA,SAAO,qBAAO,SAAS,qBAAO,OAAO,QAAQ,CAAC;AAChD;AAEO,SAAS,sBAAsB,OAAuC;AAC3E,MAAI,CAAC,OAAO,UAAU,MAAM,WAAW,KAAK,MAAM,cAAc,KAAK,MAAM,cAAc,OAAQ;AAC/F,UAAM,IAAI,MAAM,gCAAgC;AAAA,EAClD;AAEA,SAAO,wBAAwB;AAAA,IAC7B,gBAAgB,MAAM;AAAA,IACtB,UAAU,MAAM;AAAA,IAChB,SAAS,MAAM;AAAA,IACf,OAAO,MAAM;AAAA,IACb,YAAY,qBAAO,UAAU,MAAM,aAAa;AAAA,EAClD,CAAC;AACH;AAKO,SAAS,eACd,aACA,aACA,OACA,eACY;AACZ,QAAM,UAAU,qBAAO;AAAA,IACrB,CAAC,WAAW,UAAU,WAAW,OAAO;AAAA,IACxC,CAAC,aAAa,aAAa,OAAO,aAAa;AAAA,EACjD;AACA,SAAO,qBAAO,SAAS,qBAAO,UAAU,OAAO,CAAC;AAClD;","names":["hex"]}
|
package/dist/payload.mjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
+
HUB_NONCE_DOMAIN,
|
|
3
|
+
TIER_T2_AUTHORITATIVE,
|
|
4
|
+
buildCanonicalChallenge,
|
|
2
5
|
buildChallenge,
|
|
3
6
|
buildGaslessChallenge,
|
|
4
|
-
createGaslessMessageHash,
|
|
5
7
|
createMessageHash,
|
|
6
8
|
decodeActionPayload,
|
|
7
9
|
decodeBridgeAction,
|
|
@@ -21,12 +23,14 @@ import {
|
|
|
21
23
|
parseAmount,
|
|
22
24
|
solanaAddressToBytes32,
|
|
23
25
|
trimTo20Bytes
|
|
24
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-6BINP4RT.mjs";
|
|
25
27
|
import "./chunk-KYOOTSRA.mjs";
|
|
26
28
|
export {
|
|
29
|
+
HUB_NONCE_DOMAIN,
|
|
30
|
+
TIER_T2_AUTHORITATIVE,
|
|
31
|
+
buildCanonicalChallenge,
|
|
27
32
|
buildChallenge,
|
|
28
33
|
buildGaslessChallenge,
|
|
29
|
-
createGaslessMessageHash,
|
|
30
34
|
createMessageHash,
|
|
31
35
|
decodeActionPayload,
|
|
32
36
|
decodeBridgeAction,
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { E as ExecutionAttempt, f as ExecutionRecord, G as GatewayConfigData, g as GatewayConfigResource, u as GatewayTarget, P as PlatformClient, h as PlatformClientConfig, i as ReconciliationIssue, S as SponsorshipFeeLeg } from '../index-qyOqd8tx.mjs';
|
|
2
|
+
export { AtomicAmount, CHARGE_AUTHORIZATION_SIGNATURE_DOMAIN, ChargeAuthorization, Environment as PlatformEnvironment, PlatformEvent, SponsorshipQuote, UnsignedChargeAuthorization, chargeAuthorizationPayer, chargeAuthorizationSigningPayload, createChargeAuthorization, verifyChargeAuthorizationSignature } from '@veridex/platform-events';
|
|
3
|
+
import '../types-CdlEbixV.mjs';
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/platform/index.ts
|
|
21
|
+
var platform_exports = {};
|
|
22
|
+
__export(platform_exports, {
|
|
23
|
+
CHARGE_AUTHORIZATION_SIGNATURE_DOMAIN: () => import_platform_events.CHARGE_AUTHORIZATION_SIGNATURE_DOMAIN,
|
|
24
|
+
PlatformClient: () => PlatformClient,
|
|
25
|
+
chargeAuthorizationPayer: () => import_platform_events.chargeAuthorizationPayer,
|
|
26
|
+
chargeAuthorizationSigningPayload: () => import_platform_events.chargeAuthorizationSigningPayload,
|
|
27
|
+
createChargeAuthorization: () => import_platform_events.createChargeAuthorization,
|
|
28
|
+
verifyChargeAuthorizationSignature: () => import_platform_events.verifyChargeAuthorizationSignature
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(platform_exports);
|
|
31
|
+
|
|
32
|
+
// src/platform/PlatformClient.ts
|
|
33
|
+
var PlatformClient = class {
|
|
34
|
+
tenantId;
|
|
35
|
+
appId;
|
|
36
|
+
environment;
|
|
37
|
+
executionBaseUrl;
|
|
38
|
+
controlPlaneBaseUrl;
|
|
39
|
+
apiKey;
|
|
40
|
+
controlPlaneToken;
|
|
41
|
+
timeoutMs;
|
|
42
|
+
constructor(config) {
|
|
43
|
+
this.executionBaseUrl = trim(config.executionBaseUrl);
|
|
44
|
+
this.controlPlaneBaseUrl = config.controlPlaneBaseUrl ? trim(config.controlPlaneBaseUrl) : void 0;
|
|
45
|
+
this.apiKey = config.apiKey;
|
|
46
|
+
this.controlPlaneToken = config.controlPlaneToken;
|
|
47
|
+
this.tenantId = config.tenantId;
|
|
48
|
+
this.appId = config.appId;
|
|
49
|
+
this.environment = config.environment;
|
|
50
|
+
this.timeoutMs = config.timeoutMs ?? 15e3;
|
|
51
|
+
}
|
|
52
|
+
quote(action, idempotencyKey) {
|
|
53
|
+
return this.execution("/execution/quotes", {
|
|
54
|
+
method: "POST",
|
|
55
|
+
body: action,
|
|
56
|
+
idempotencyKey
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
async reserve(quote, executionId, idempotencyKey, chargeAuthorization) {
|
|
60
|
+
this.assertQuoteScope(quote);
|
|
61
|
+
return await this.execution("/execution/reservations", {
|
|
62
|
+
method: "POST",
|
|
63
|
+
body: { quote, executionId, chargeAuthorization },
|
|
64
|
+
idempotencyKey
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
submitSponsored(action, executionId) {
|
|
68
|
+
return this.execution("/submit", {
|
|
69
|
+
method: "POST",
|
|
70
|
+
body: action,
|
|
71
|
+
extraHeaders: { "X-Execution-Id": executionId }
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
getExecution(executionId) {
|
|
75
|
+
return this.execution(`/executions/${encodeURIComponent(executionId)}`);
|
|
76
|
+
}
|
|
77
|
+
listExecutionAttempts(executionId) {
|
|
78
|
+
return this.execution(`/executions/${encodeURIComponent(executionId)}/attempts`);
|
|
79
|
+
}
|
|
80
|
+
cancelExecution(executionId, reason) {
|
|
81
|
+
return this.execution(`/executions/${encodeURIComponent(executionId)}/cancel`, {
|
|
82
|
+
method: "POST",
|
|
83
|
+
body: { reason }
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
listExecutions(limit = 50) {
|
|
87
|
+
return this.execution(
|
|
88
|
+
`/apps/${encodeURIComponent(this.appId)}/executions?environment=${this.environment}&limit=${limit}`
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
listReconciliationIssues() {
|
|
92
|
+
return this.execution(
|
|
93
|
+
`/apps/${encodeURIComponent(this.appId)}/reconciliation-issues?environment=${this.environment}`
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
listChainCapabilities() {
|
|
97
|
+
return this.execution(
|
|
98
|
+
`/apps/${encodeURIComponent(this.appId)}/chain-capabilities?environment=${this.environment}`
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
getSponsorshipPolicy() {
|
|
102
|
+
return this.controlPlane(`/v1/apps/${encodeURIComponent(this.appId)}/environments/${this.environment}/sponsorship-policy`);
|
|
103
|
+
}
|
|
104
|
+
putSponsorshipPolicy(policy) {
|
|
105
|
+
return this.controlPlane(`/v1/apps/${encodeURIComponent(this.appId)}/environments/${this.environment}/sponsorship-policy`, {
|
|
106
|
+
method: "PUT",
|
|
107
|
+
body: policy
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
listGateways() {
|
|
111
|
+
return this.controlPlane(`/v1/apps/${encodeURIComponent(this.appId)}/environments/${this.environment}/gateways`);
|
|
112
|
+
}
|
|
113
|
+
createGateway(config) {
|
|
114
|
+
return this.controlPlane(`/v1/apps/${encodeURIComponent(this.appId)}/environments/${this.environment}/gateways`, {
|
|
115
|
+
method: "POST",
|
|
116
|
+
body: config
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
updateGateway(gatewayId, config) {
|
|
120
|
+
return this.controlPlane(`/v1/apps/${encodeURIComponent(this.appId)}/environments/${this.environment}/gateways/${encodeURIComponent(gatewayId)}`, {
|
|
121
|
+
method: "PUT",
|
|
122
|
+
body: config
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
listFinancialSummary() {
|
|
126
|
+
return this.execution(`/apps/${encodeURIComponent(this.appId)}/environments/${this.environment}/financial-summary`);
|
|
127
|
+
}
|
|
128
|
+
fund(amount, asset, idempotencyKey) {
|
|
129
|
+
return this.execution(`/apps/${encodeURIComponent(this.appId)}/environments/${this.environment}/funding`, {
|
|
130
|
+
method: "POST",
|
|
131
|
+
body: { amount, asset, idempotencyKey }
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
refund(transactionId, reason, idempotencyKey) {
|
|
135
|
+
return this.execution(`/apps/${encodeURIComponent(this.appId)}/environments/${this.environment}/refunds`, {
|
|
136
|
+
method: "POST",
|
|
137
|
+
body: { transactionId, reason, idempotencyKey }
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
listPayments() {
|
|
141
|
+
return this.controlPlane(`/v1/apps/${encodeURIComponent(this.appId)}/payments`);
|
|
142
|
+
}
|
|
143
|
+
listCharges() {
|
|
144
|
+
return this.execution(`/apps/${encodeURIComponent(this.appId)}/sponsorship/charges`);
|
|
145
|
+
}
|
|
146
|
+
listInvoices() {
|
|
147
|
+
return this.execution(`/apps/${encodeURIComponent(this.appId)}/invoices`);
|
|
148
|
+
}
|
|
149
|
+
listBazaarResources(query = "") {
|
|
150
|
+
return this.controlPlane(`/v1/apps/${encodeURIComponent(this.appId)}/bazaar?q=${encodeURIComponent(query)}`);
|
|
151
|
+
}
|
|
152
|
+
publishResource(resourceId) {
|
|
153
|
+
return this.controlPlane(`/v1/apps/${encodeURIComponent(this.appId)}/resources/${encodeURIComponent(resourceId)}/publish`, { method: "POST" });
|
|
154
|
+
}
|
|
155
|
+
createChargeAuthorization(authorization) {
|
|
156
|
+
if (authorization.tenantId !== this.tenantId || authorization.appId !== this.appId || authorization.environment !== this.environment) {
|
|
157
|
+
throw new Error("CHARGE_AUTHORIZATION_SCOPE_MISMATCH");
|
|
158
|
+
}
|
|
159
|
+
return this.controlPlane(`/v1/apps/${encodeURIComponent(this.appId)}/charge-authorizations`, {
|
|
160
|
+
method: "POST",
|
|
161
|
+
body: authorization
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
assertQuoteScope(quote) {
|
|
165
|
+
if (quote.tenantId !== this.tenantId || quote.appId !== this.appId || quote.environment !== this.environment) {
|
|
166
|
+
throw new Error("SPONSORSHIP_QUOTE_SCOPE_MISMATCH");
|
|
167
|
+
}
|
|
168
|
+
if (Date.parse(quote.expiresAt) <= Date.now()) throw new Error("SPONSORSHIP_QUOTE_EXPIRED");
|
|
169
|
+
}
|
|
170
|
+
execution(path, options = {}) {
|
|
171
|
+
return request(`${this.executionBaseUrl}${path}`, this.timeoutMs, {
|
|
172
|
+
"X-API-Key": this.apiKey,
|
|
173
|
+
"X-Tenant-Id": this.tenantId,
|
|
174
|
+
...options.extraHeaders
|
|
175
|
+
}, options);
|
|
176
|
+
}
|
|
177
|
+
controlPlane(path, options = {}) {
|
|
178
|
+
if (!this.controlPlaneBaseUrl || !this.controlPlaneToken) throw new Error("CONTROL_PLANE_NOT_CONFIGURED");
|
|
179
|
+
return request(`${this.controlPlaneBaseUrl}${path}`, this.timeoutMs, {
|
|
180
|
+
Authorization: `Bearer ${this.controlPlaneToken}`,
|
|
181
|
+
"X-Veridex-Tenant-Id": this.tenantId
|
|
182
|
+
}, options);
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
async function request(url, timeoutMs, baseHeaders, options) {
|
|
186
|
+
const response = await fetch(url, {
|
|
187
|
+
method: options.method ?? "GET",
|
|
188
|
+
headers: {
|
|
189
|
+
Accept: "application/json",
|
|
190
|
+
...baseHeaders,
|
|
191
|
+
...options.body !== void 0 ? { "Content-Type": "application/json" } : {},
|
|
192
|
+
...options.idempotencyKey ? { "Idempotency-Key": options.idempotencyKey } : {}
|
|
193
|
+
},
|
|
194
|
+
...options.body !== void 0 ? { body: JSON.stringify(options.body) } : {},
|
|
195
|
+
signal: AbortSignal.timeout(timeoutMs)
|
|
196
|
+
});
|
|
197
|
+
const body = await response.json().catch(() => ({}));
|
|
198
|
+
if (!response.ok) throw new Error(body.error ?? `Platform request failed (${response.status})`);
|
|
199
|
+
return body;
|
|
200
|
+
}
|
|
201
|
+
function trim(value) {
|
|
202
|
+
return value.replace(/\/+$/, "");
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// src/platform/index.ts
|
|
206
|
+
var import_platform_events = require("@veridex/platform-events");
|
|
207
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
208
|
+
0 && (module.exports = {
|
|
209
|
+
CHARGE_AUTHORIZATION_SIGNATURE_DOMAIN,
|
|
210
|
+
PlatformClient,
|
|
211
|
+
chargeAuthorizationPayer,
|
|
212
|
+
chargeAuthorizationSigningPayload,
|
|
213
|
+
createChargeAuthorization,
|
|
214
|
+
verifyChargeAuthorizationSignature
|
|
215
|
+
});
|
|
216
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/platform/index.ts","../../src/platform/PlatformClient.ts"],"sourcesContent":["export { PlatformClient } from './PlatformClient.js';\nexport {\n CHARGE_AUTHORIZATION_SIGNATURE_DOMAIN,\n chargeAuthorizationPayer,\n chargeAuthorizationSigningPayload,\n createChargeAuthorization,\n verifyChargeAuthorizationSignature,\n} from '@veridex/platform-events';\nexport type {\n AtomicAmount,\n ChargeAuthorization,\n ExecutionAttempt,\n ExecutionRecord,\n GatewayConfigData,\n GatewayConfigResource,\n GatewayTarget,\n PlatformClientConfig,\n PlatformEnvironment,\n PlatformEvent,\n ReconciliationIssue,\n SponsorshipFeeLeg,\n SponsorshipQuote,\n UnsignedChargeAuthorization,\n} from './types.js';\n","import type {\n ChargeAuthorization,\n ExecutionAttempt,\n ExecutionRecord,\n GatewayConfigData,\n GatewayConfigResource,\n PlatformClientConfig,\n ReconciliationIssue,\n SponsorshipQuote,\n} from './types.js';\nimport type { SubmitSignedActionRequest } from '../core/RelayerClient.js';\n\nexport class PlatformClient {\n readonly tenantId: string;\n readonly appId: string;\n readonly environment: 'test' | 'live';\n private readonly executionBaseUrl: string;\n private readonly controlPlaneBaseUrl?: string;\n private readonly apiKey: string;\n private readonly controlPlaneToken?: string;\n private readonly timeoutMs: number;\n\n constructor(config: PlatformClientConfig) {\n this.executionBaseUrl = trim(config.executionBaseUrl);\n this.controlPlaneBaseUrl = config.controlPlaneBaseUrl ? trim(config.controlPlaneBaseUrl) : undefined;\n this.apiKey = config.apiKey;\n this.controlPlaneToken = config.controlPlaneToken;\n this.tenantId = config.tenantId;\n this.appId = config.appId;\n this.environment = config.environment;\n this.timeoutMs = config.timeoutMs ?? 15_000;\n }\n\n quote(action: SubmitSignedActionRequest, idempotencyKey: string) {\n return this.execution<{ quote: SponsorshipQuote; simulation: Record<string, string | number> }>('/execution/quotes', {\n method: 'POST', body: action, idempotencyKey,\n });\n }\n\n async reserve(quote: SponsorshipQuote, executionId: string, idempotencyKey: string, chargeAuthorization?: ChargeAuthorization) {\n this.assertQuoteScope(quote);\n return await this.execution<{ executionId: string; reservations: unknown[] }>('/execution/reservations', {\n method: 'POST', body: { quote, executionId, chargeAuthorization }, idempotencyKey,\n });\n }\n\n submitSponsored(action: SubmitSignedActionRequest, executionId: string) {\n return this.execution<{ success: boolean; transactionHash?: string; sequence?: string; actualSponsoredCost?: string }>('/submit', {\n method: 'POST', body: action, extraHeaders: { 'X-Execution-Id': executionId },\n });\n }\n\n getExecution(executionId: string) {\n return this.execution<{ execution: ExecutionRecord }>(`/executions/${encodeURIComponent(executionId)}`);\n }\n\n listExecutionAttempts(executionId: string) {\n return this.execution<{ attempts: ExecutionAttempt[] }>(`/executions/${encodeURIComponent(executionId)}/attempts`);\n }\n\n cancelExecution(executionId: string, reason?: string) {\n return this.execution<{ execution: ExecutionRecord }>(`/executions/${encodeURIComponent(executionId)}/cancel`, {\n method: 'POST', body: { reason },\n });\n }\n\n listExecutions(limit = 50) {\n return this.execution<{ executions: unknown[] }>(\n `/apps/${encodeURIComponent(this.appId)}/executions?environment=${this.environment}&limit=${limit}`,\n );\n }\n\n listReconciliationIssues() {\n return this.execution<{ issues: ReconciliationIssue[] }>(\n `/apps/${encodeURIComponent(this.appId)}/reconciliation-issues?environment=${this.environment}`,\n );\n }\n\n listChainCapabilities() {\n return this.execution<{ capabilities: unknown[] }>(\n `/apps/${encodeURIComponent(this.appId)}/chain-capabilities?environment=${this.environment}`,\n );\n }\n\n getSponsorshipPolicy() {\n return this.controlPlane<Record<string, unknown>>(`/v1/apps/${encodeURIComponent(this.appId)}/environments/${this.environment}/sponsorship-policy`);\n }\n\n putSponsorshipPolicy(policy: Record<string, unknown>) {\n return this.controlPlane<Record<string, unknown>>(`/v1/apps/${encodeURIComponent(this.appId)}/environments/${this.environment}/sponsorship-policy`, {\n method: 'PUT', body: policy,\n });\n }\n\n listGateways() {\n return this.controlPlane<GatewayConfigResource[]>(`/v1/apps/${encodeURIComponent(this.appId)}/environments/${this.environment}/gateways`);\n }\n\n createGateway(config: Omit<GatewayConfigData, 'appId' | 'environment' | 'updatedBy'>) {\n return this.controlPlane<GatewayConfigResource>(`/v1/apps/${encodeURIComponent(this.appId)}/environments/${this.environment}/gateways`, {\n method: 'POST', body: config,\n });\n }\n\n updateGateway(gatewayId: string, config: Omit<GatewayConfigData, 'appId' | 'environment' | 'updatedBy'>) {\n return this.controlPlane<GatewayConfigResource>(`/v1/apps/${encodeURIComponent(this.appId)}/environments/${this.environment}/gateways/${encodeURIComponent(gatewayId)}`, {\n method: 'PUT', body: config,\n });\n }\n\n listFinancialSummary() {\n return this.execution<Record<string, unknown>>(`/apps/${encodeURIComponent(this.appId)}/environments/${this.environment}/financial-summary`);\n }\n\n fund(amount: string, asset: string, idempotencyKey: string) {\n return this.execution<Record<string, unknown>>(`/apps/${encodeURIComponent(this.appId)}/environments/${this.environment}/funding`, {\n method: 'POST', body: { amount, asset, idempotencyKey },\n });\n }\n\n refund(transactionId: string, reason: string, idempotencyKey: string) {\n return this.execution<Record<string, unknown>>(`/apps/${encodeURIComponent(this.appId)}/environments/${this.environment}/refunds`, {\n method: 'POST', body: { transactionId, reason, idempotencyKey },\n });\n }\n\n listPayments() { return this.controlPlane<{ payments: unknown[] }>(`/v1/apps/${encodeURIComponent(this.appId)}/payments`); }\n listCharges() { return this.execution<{ charges: unknown[] }>(`/apps/${encodeURIComponent(this.appId)}/sponsorship/charges`); }\n listInvoices() { return this.execution<{ invoices: unknown[] }>(`/apps/${encodeURIComponent(this.appId)}/invoices`); }\n listBazaarResources(query = '') { return this.controlPlane<{ resources: unknown[] }>(`/v1/apps/${encodeURIComponent(this.appId)}/bazaar?q=${encodeURIComponent(query)}`); }\n publishResource(resourceId: string) { return this.controlPlane<Record<string, unknown>>(`/v1/apps/${encodeURIComponent(this.appId)}/resources/${encodeURIComponent(resourceId)}/publish`, { method: 'POST' }); }\n\n createChargeAuthorization(authorization: ChargeAuthorization) {\n if (authorization.tenantId !== this.tenantId || authorization.appId !== this.appId || authorization.environment !== this.environment) {\n throw new Error('CHARGE_AUTHORIZATION_SCOPE_MISMATCH');\n }\n return this.controlPlane<Record<string, unknown>>(`/v1/apps/${encodeURIComponent(this.appId)}/charge-authorizations`, {\n method: 'POST', body: authorization,\n });\n }\n\n private assertQuoteScope(quote: SponsorshipQuote) {\n if (quote.tenantId !== this.tenantId || quote.appId !== this.appId || quote.environment !== this.environment) {\n throw new Error('SPONSORSHIP_QUOTE_SCOPE_MISMATCH');\n }\n if (Date.parse(quote.expiresAt) <= Date.now()) throw new Error('SPONSORSHIP_QUOTE_EXPIRED');\n }\n\n private execution<T>(path: string, options: RequestOptions = {}) {\n return request<T>(`${this.executionBaseUrl}${path}`, this.timeoutMs, {\n 'X-API-Key': this.apiKey,\n 'X-Tenant-Id': this.tenantId,\n ...options.extraHeaders,\n }, options);\n }\n\n private controlPlane<T>(path: string, options: RequestOptions = {}) {\n if (!this.controlPlaneBaseUrl || !this.controlPlaneToken) throw new Error('CONTROL_PLANE_NOT_CONFIGURED');\n return request<T>(`${this.controlPlaneBaseUrl}${path}`, this.timeoutMs, {\n Authorization: `Bearer ${this.controlPlaneToken}`,\n 'X-Veridex-Tenant-Id': this.tenantId,\n }, options);\n }\n}\n\ninterface RequestOptions {\n method?: 'GET' | 'POST' | 'PUT' | 'DELETE';\n body?: unknown;\n idempotencyKey?: string;\n extraHeaders?: Record<string, string>;\n}\n\nasync function request<T>(url: string, timeoutMs: number, baseHeaders: Record<string, string>, options: RequestOptions): Promise<T> {\n const response = await fetch(url, {\n method: options.method ?? 'GET',\n headers: {\n Accept: 'application/json',\n ...baseHeaders,\n ...(options.body !== undefined ? { 'Content-Type': 'application/json' } : {}),\n ...(options.idempotencyKey ? { 'Idempotency-Key': options.idempotencyKey } : {}),\n },\n ...(options.body !== undefined ? { body: JSON.stringify(options.body) } : {}),\n signal: AbortSignal.timeout(timeoutMs),\n });\n const body = await response.json().catch(() => ({}));\n if (!response.ok) throw new Error((body as { error?: string }).error ?? `Platform request failed (${response.status})`);\n return body as T;\n}\n\nfunction trim(value: string): string { return value.replace(/\\/+$/, ''); }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACYO,IAAM,iBAAN,MAAqB;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AAAA,EACQ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEjB,YAAY,QAA8B;AACxC,SAAK,mBAAmB,KAAK,OAAO,gBAAgB;AACpD,SAAK,sBAAsB,OAAO,sBAAsB,KAAK,OAAO,mBAAmB,IAAI;AAC3F,SAAK,SAAS,OAAO;AACrB,SAAK,oBAAoB,OAAO;AAChC,SAAK,WAAW,OAAO;AACvB,SAAK,QAAQ,OAAO;AACpB,SAAK,cAAc,OAAO;AAC1B,SAAK,YAAY,OAAO,aAAa;AAAA,EACvC;AAAA,EAEA,MAAM,QAAmC,gBAAwB;AAC/D,WAAO,KAAK,UAAoF,qBAAqB;AAAA,MACnH,QAAQ;AAAA,MAAQ,MAAM;AAAA,MAAQ;AAAA,IAChC,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,QAAQ,OAAyB,aAAqB,gBAAwB,qBAA2C;AAC7H,SAAK,iBAAiB,KAAK;AAC3B,WAAO,MAAM,KAAK,UAA4D,2BAA2B;AAAA,MACvG,QAAQ;AAAA,MAAQ,MAAM,EAAE,OAAO,aAAa,oBAAoB;AAAA,MAA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