@circle-fin/app-kit 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -0
- package/README.md +30 -5
- package/chains.cjs +8 -8
- package/chains.d.ts +8 -8
- package/chains.mjs +8 -8
- package/index.cjs +289 -46
- package/index.d.ts +108 -27
- package/index.mjs +289 -46
- package/package.json +4 -3
package/index.cjs
CHANGED
|
@@ -4231,7 +4231,7 @@ const Codex = defineChain({
|
|
|
4231
4231
|
},
|
|
4232
4232
|
forwarderSupported: {
|
|
4233
4233
|
source: true,
|
|
4234
|
-
destination:
|
|
4234
|
+
destination: true,
|
|
4235
4235
|
},
|
|
4236
4236
|
},
|
|
4237
4237
|
kitContracts: {
|
|
@@ -4274,7 +4274,7 @@ const CodexTestnet = defineChain({
|
|
|
4274
4274
|
},
|
|
4275
4275
|
forwarderSupported: {
|
|
4276
4276
|
source: true,
|
|
4277
|
-
destination:
|
|
4277
|
+
destination: true,
|
|
4278
4278
|
},
|
|
4279
4279
|
},
|
|
4280
4280
|
kitContracts: {
|
|
@@ -4536,7 +4536,7 @@ const HyperEVM = defineChain({
|
|
|
4536
4536
|
},
|
|
4537
4537
|
chainId: 999,
|
|
4538
4538
|
isTestnet: false,
|
|
4539
|
-
explorerUrl: 'https://
|
|
4539
|
+
explorerUrl: 'https://app.hyperliquid.xyz/explorer/tx/{hash}',
|
|
4540
4540
|
rpcEndpoints: ['https://rpc.hyperliquid.xyz/evm'],
|
|
4541
4541
|
eurcAddress: null,
|
|
4542
4542
|
usdcAddress: '0xb88339CB7199b77E23DB6E890353E22632Ba630f',
|
|
@@ -4581,7 +4581,7 @@ const HyperEVMTestnet = defineChain({
|
|
|
4581
4581
|
},
|
|
4582
4582
|
chainId: 998,
|
|
4583
4583
|
isTestnet: true,
|
|
4584
|
-
explorerUrl: 'https://
|
|
4584
|
+
explorerUrl: 'https://app.hyperliquid-testnet.xyz/explorer/tx/{hash}',
|
|
4585
4585
|
rpcEndpoints: ['https://rpc.hyperliquid-testnet.xyz/evm'],
|
|
4586
4586
|
eurcAddress: null,
|
|
4587
4587
|
usdcAddress: '0x2B3370eE501B4a559b57D449569354196457D8Ab',
|
|
@@ -5227,7 +5227,7 @@ const Plume = defineChain({
|
|
|
5227
5227
|
},
|
|
5228
5228
|
forwarderSupported: {
|
|
5229
5229
|
source: true,
|
|
5230
|
-
destination:
|
|
5230
|
+
destination: true,
|
|
5231
5231
|
},
|
|
5232
5232
|
},
|
|
5233
5233
|
kitContracts: {
|
|
@@ -5272,7 +5272,7 @@ const PlumeTestnet = defineChain({
|
|
|
5272
5272
|
},
|
|
5273
5273
|
forwarderSupported: {
|
|
5274
5274
|
source: true,
|
|
5275
|
-
destination:
|
|
5275
|
+
destination: true,
|
|
5276
5276
|
},
|
|
5277
5277
|
},
|
|
5278
5278
|
kitContracts: {
|
|
@@ -6050,7 +6050,7 @@ const XDC = defineChain({
|
|
|
6050
6050
|
},
|
|
6051
6051
|
forwarderSupported: {
|
|
6052
6052
|
source: true,
|
|
6053
|
-
destination:
|
|
6053
|
+
destination: true,
|
|
6054
6054
|
},
|
|
6055
6055
|
},
|
|
6056
6056
|
kitContracts: {
|
|
@@ -6094,7 +6094,7 @@ const XDCApothem = defineChain({
|
|
|
6094
6094
|
},
|
|
6095
6095
|
forwarderSupported: {
|
|
6096
6096
|
source: true,
|
|
6097
|
-
destination:
|
|
6097
|
+
destination: true,
|
|
6098
6098
|
},
|
|
6099
6099
|
},
|
|
6100
6100
|
kitContracts: {
|
|
@@ -9207,7 +9207,7 @@ function buildForwardingHookData() {
|
|
|
9207
9207
|
}
|
|
9208
9208
|
|
|
9209
9209
|
var name$1 = "@circle-fin/bridge-kit";
|
|
9210
|
-
var version$2 = "1.
|
|
9210
|
+
var version$2 = "1.8.0";
|
|
9211
9211
|
var pkg$2 = {
|
|
9212
9212
|
name: name$1,
|
|
9213
9213
|
version: version$2};
|
|
@@ -13297,7 +13297,184 @@ function dispatchStepEvent(name, step, provider, invocation) {
|
|
|
13297
13297
|
}
|
|
13298
13298
|
}
|
|
13299
13299
|
|
|
13300
|
-
|
|
13300
|
+
/**
|
|
13301
|
+
* Check whether the source adapter supports EIP-5792 atomic batching and
|
|
13302
|
+
* the consumer has not explicitly opted out via `config.batchTransactions`.
|
|
13303
|
+
*
|
|
13304
|
+
* @param params - Bridge parameters (used for adapter and config access).
|
|
13305
|
+
* @returns `true` when batched execution should be attempted.
|
|
13306
|
+
*
|
|
13307
|
+
* @example
|
|
13308
|
+
* ```typescript
|
|
13309
|
+
* const useBatched = await shouldUseBatchedExecution(params)
|
|
13310
|
+
* if (useBatched) {
|
|
13311
|
+
* // take the batched approve + burn path
|
|
13312
|
+
* }
|
|
13313
|
+
* ```
|
|
13314
|
+
*/
|
|
13315
|
+
async function shouldUseBatchedExecution(params) {
|
|
13316
|
+
if (params.config?.batchTransactions === false) {
|
|
13317
|
+
return false;
|
|
13318
|
+
}
|
|
13319
|
+
const { chain } = params.source;
|
|
13320
|
+
if (chain.type !== 'evm') {
|
|
13321
|
+
return false;
|
|
13322
|
+
}
|
|
13323
|
+
const adapter = params.source
|
|
13324
|
+
.adapter;
|
|
13325
|
+
if (typeof adapter.supportsAtomicBatch !== 'function' ||
|
|
13326
|
+
typeof adapter.batchExecute !== 'function') {
|
|
13327
|
+
return false;
|
|
13328
|
+
}
|
|
13329
|
+
try {
|
|
13330
|
+
return await adapter.supportsAtomicBatch(chain);
|
|
13331
|
+
}
|
|
13332
|
+
catch {
|
|
13333
|
+
return false;
|
|
13334
|
+
}
|
|
13335
|
+
}
|
|
13336
|
+
/**
|
|
13337
|
+
* Execute the approve and burn steps as a single EIP-5792 batched call.
|
|
13338
|
+
*
|
|
13339
|
+
* Prepare both `PreparedChainRequest` objects upfront, extract their raw
|
|
13340
|
+
* call data via `getCallData()`, submit both via `adapter.batchExecute()`,
|
|
13341
|
+
* then map the individual receipts back to standard {@link BridgeStep}
|
|
13342
|
+
* objects so downstream consumers (event callbacks, result tracking) are
|
|
13343
|
+
* unaffected.
|
|
13344
|
+
*
|
|
13345
|
+
* @param params - The CCTP v2 bridge parameters.
|
|
13346
|
+
* @param provider - The CCTP v2 bridging provider.
|
|
13347
|
+
* @returns Approve and burn steps with a shared context containing the burn tx hash.
|
|
13348
|
+
* @throws {@link KitError} when the source chain is not EVM.
|
|
13349
|
+
* @throws {@link KitError} when calldata extraction (`getCallData`) is not supported
|
|
13350
|
+
* by the prepared requests.
|
|
13351
|
+
* @remarks
|
|
13352
|
+
* Errors that occur after the batch has been submitted to the wallet
|
|
13353
|
+
* (e.g. polling timeout, insufficient receipts) are **not thrown** — they
|
|
13354
|
+
* are captured as `state: 'error'` on the returned steps to prevent
|
|
13355
|
+
* accidental double-spend on retry.
|
|
13356
|
+
*
|
|
13357
|
+
* @example
|
|
13358
|
+
* ```typescript
|
|
13359
|
+
* const { approveStep, burnStep, context } = await executeBatchedApproveAndBurn(
|
|
13360
|
+
* params,
|
|
13361
|
+
* provider,
|
|
13362
|
+
* )
|
|
13363
|
+
* result.steps.push(approveStep, burnStep)
|
|
13364
|
+
* ```
|
|
13365
|
+
*/
|
|
13366
|
+
async function executeBatchedApproveAndBurn(params, provider) {
|
|
13367
|
+
// Double-unknown cast: Adapter<TFrom> has no structural overlap with
|
|
13368
|
+
// BatchCapableAdapter (a duck-typed interface for EIP-5792 methods).
|
|
13369
|
+
// A direct cast fails because TS cannot prove the intersection; the
|
|
13370
|
+
// runtime capability check below guards against unsupported adapters.
|
|
13371
|
+
const adapter = params.source.adapter;
|
|
13372
|
+
const sourceChain = params.source.chain;
|
|
13373
|
+
if (sourceChain.type !== 'evm') {
|
|
13374
|
+
throw new KitError({
|
|
13375
|
+
...InputError.INVALID_CHAIN,
|
|
13376
|
+
recoverability: 'FATAL',
|
|
13377
|
+
message: 'Batched execution is only supported on EVM chains.',
|
|
13378
|
+
});
|
|
13379
|
+
}
|
|
13380
|
+
const chain = sourceChain;
|
|
13381
|
+
// customFee.value is in base units (integer string) at this point.
|
|
13382
|
+
const customFee = BigInt(params.config?.customFee?.value ?? '0');
|
|
13383
|
+
const amountBigInt = BigInt(params.amount);
|
|
13384
|
+
const approvalAmount = (amountBigInt + customFee).toString();
|
|
13385
|
+
const [approveRequest, burnRequest] = await Promise.all([
|
|
13386
|
+
provider.approve(params.source, approvalAmount),
|
|
13387
|
+
provider.burn(params),
|
|
13388
|
+
]);
|
|
13389
|
+
if (approveRequest.type !== 'evm' ||
|
|
13390
|
+
burnRequest.type !== 'evm' ||
|
|
13391
|
+
!approveRequest.getCallData ||
|
|
13392
|
+
!burnRequest.getCallData) {
|
|
13393
|
+
throw new KitError({
|
|
13394
|
+
...InputError.UNSUPPORTED_ACTION,
|
|
13395
|
+
recoverability: 'FATAL',
|
|
13396
|
+
message: 'Batched execution requires EVM prepared requests with getCallData() support.',
|
|
13397
|
+
});
|
|
13398
|
+
}
|
|
13399
|
+
const approveCallData = approveRequest.getCallData();
|
|
13400
|
+
const burnCallData = burnRequest.getCallData();
|
|
13401
|
+
// batchExecute may throw before submission (wallet declined) but never
|
|
13402
|
+
// after — post-submission errors are returned as empty receipts.
|
|
13403
|
+
const batchResult = await adapter.batchExecute([approveCallData, burnCallData], chain);
|
|
13404
|
+
const approveReceipt = batchResult.receipts[0];
|
|
13405
|
+
const burnReceipt = batchResult.receipts[1];
|
|
13406
|
+
const approveStep = await buildBatchedStep('approve', approveReceipt, batchResult.batchId, adapter, chain);
|
|
13407
|
+
const burnStep = await buildBatchedStep('burn', burnReceipt, batchResult.batchId, adapter, chain);
|
|
13408
|
+
if (burnStep.state !== 'error' && !burnStep.txHash) {
|
|
13409
|
+
burnStep.state = 'error';
|
|
13410
|
+
burnStep.errorMessage =
|
|
13411
|
+
'Batched burn step completed but no transaction hash was returned.';
|
|
13412
|
+
}
|
|
13413
|
+
const context = { burnTxHash: burnStep.txHash ?? '' };
|
|
13414
|
+
return { approveStep, burnStep, context };
|
|
13415
|
+
}
|
|
13416
|
+
/**
|
|
13417
|
+
* Build a {@link BridgeStep} from a single receipt within a batch.
|
|
13418
|
+
*
|
|
13419
|
+
* Map the raw receipt from `batchExecute` into a standard `BridgeStep`,
|
|
13420
|
+
* waiting for on-chain confirmation via `adapter.waitForTransaction`.
|
|
13421
|
+
* All errors are captured on the step (never thrown) so the caller
|
|
13422
|
+
* can inspect each step independently.
|
|
13423
|
+
*
|
|
13424
|
+
* @param name - Human-readable step name (e.g. `'approve'`, `'burn'`).
|
|
13425
|
+
* @param receipt - Per-call receipt from `batchExecute`, or `undefined`
|
|
13426
|
+
* when the wallet returned fewer receipts than submitted calls.
|
|
13427
|
+
* @param batchId - Wallet-assigned batch identifier.
|
|
13428
|
+
* @param adapter - The batch-capable adapter (used for confirmation).
|
|
13429
|
+
* @param chain - The EVM chain the batch was executed on.
|
|
13430
|
+
* @returns A fully-populated bridge step with state, tx hash and explorer URL.
|
|
13431
|
+
*
|
|
13432
|
+
* @internal
|
|
13433
|
+
*/
|
|
13434
|
+
async function buildBatchedStep(name, receipt, batchId, adapter, chain) {
|
|
13435
|
+
const step = {
|
|
13436
|
+
name,
|
|
13437
|
+
state: 'pending',
|
|
13438
|
+
batched: true,
|
|
13439
|
+
batchId,
|
|
13440
|
+
};
|
|
13441
|
+
if (!receipt) {
|
|
13442
|
+
step.state = 'error';
|
|
13443
|
+
step.errorMessage = `No receipt returned for ${name} in batch ${batchId}.`;
|
|
13444
|
+
return step;
|
|
13445
|
+
}
|
|
13446
|
+
step.txHash = receipt.txHash;
|
|
13447
|
+
if (receipt.txHash) {
|
|
13448
|
+
step.explorerUrl = buildExplorerUrl(chain, receipt.txHash);
|
|
13449
|
+
}
|
|
13450
|
+
if (receipt.status !== 'success') {
|
|
13451
|
+
step.state = 'error';
|
|
13452
|
+
step.errorMessage = `${name} call failed within batch ${batchId}.`;
|
|
13453
|
+
return step;
|
|
13454
|
+
}
|
|
13455
|
+
if (!receipt.txHash) {
|
|
13456
|
+
step.state = 'error';
|
|
13457
|
+
step.errorMessage = `${name} succeeded in batch but returned an empty transaction hash.`;
|
|
13458
|
+
return step;
|
|
13459
|
+
}
|
|
13460
|
+
try {
|
|
13461
|
+
const transaction = await adapter.waitForTransaction(receipt.txHash, { confirmations: 1 }, chain);
|
|
13462
|
+
step.state = transaction.blockNumber === undefined ? 'error' : 'success';
|
|
13463
|
+
step.data = transaction;
|
|
13464
|
+
if (transaction.blockNumber === undefined) {
|
|
13465
|
+
step.errorMessage = 'Transaction was not confirmed on-chain.';
|
|
13466
|
+
}
|
|
13467
|
+
}
|
|
13468
|
+
catch (err) {
|
|
13469
|
+
step.state = 'error';
|
|
13470
|
+
step.error = err;
|
|
13471
|
+
step.errorMessage =
|
|
13472
|
+
err instanceof Error ? err.message : 'Unknown error during confirmation.';
|
|
13473
|
+
}
|
|
13474
|
+
return step;
|
|
13475
|
+
}
|
|
13476
|
+
|
|
13477
|
+
var version$1 = "1.6.0";
|
|
13301
13478
|
var pkg$1 = {
|
|
13302
13479
|
version: version$1};
|
|
13303
13480
|
|
|
@@ -13326,6 +13503,67 @@ function resolveBridgeInvocation(invocationMeta) {
|
|
|
13326
13503
|
};
|
|
13327
13504
|
return extendInvocationContext(resolveInvocationContext(invocationMeta, defaults), BRIDGE_CALLER);
|
|
13328
13505
|
}
|
|
13506
|
+
/**
|
|
13507
|
+
* Execute the batched approve + burn path via EIP-5792.
|
|
13508
|
+
*
|
|
13509
|
+
* Mutate `result` with step data and error state as needed. Return the
|
|
13510
|
+
* batch context on success, or `undefined` when the batch failed (in
|
|
13511
|
+
* which case `result.state` is set to `'error'`).
|
|
13512
|
+
*
|
|
13513
|
+
* @internal
|
|
13514
|
+
* @param params - Bridge parameters (read-only).
|
|
13515
|
+
* @param provider - The CCTP v2 bridging provider (read-only).
|
|
13516
|
+
* @param result - Bridge result object — **mutated in place** with step
|
|
13517
|
+
* data and, on failure, `state: 'error'` plus an `error` payload.
|
|
13518
|
+
* @param invocation - Invocation context for telemetry (read-only).
|
|
13519
|
+
* @returns The step context on success, or `undefined` when the batch failed.
|
|
13520
|
+
*/
|
|
13521
|
+
async function executeBatchedPath(params, provider, result, invocation) {
|
|
13522
|
+
// IMPORTANT: once executeBatchedApproveAndBurn is called, we NEVER
|
|
13523
|
+
// fall back to sequential. The wallet may have already signed &
|
|
13524
|
+
// submitted the batch; retrying as individual txs would double-spend.
|
|
13525
|
+
try {
|
|
13526
|
+
const { approveStep, burnStep, context: batchContext, } = await executeBatchedApproveAndBurn(params, provider);
|
|
13527
|
+
for (const step of [approveStep, burnStep]) {
|
|
13528
|
+
const stepName = step.name;
|
|
13529
|
+
if (step.state === 'error') {
|
|
13530
|
+
ensureStepErrorMessage(step.name, step);
|
|
13531
|
+
result.steps.push(step);
|
|
13532
|
+
result.state = 'error';
|
|
13533
|
+
dispatchStepEvent(stepName, step, provider, invocation);
|
|
13534
|
+
return undefined;
|
|
13535
|
+
}
|
|
13536
|
+
dispatchStepEvent(stepName, step, provider, invocation);
|
|
13537
|
+
result.steps.push(step);
|
|
13538
|
+
}
|
|
13539
|
+
return batchContext;
|
|
13540
|
+
}
|
|
13541
|
+
catch (error_) {
|
|
13542
|
+
// Only handles pre-submission failures (prepare rejected, wallet
|
|
13543
|
+
// declined, etc.). batchExecute never throws after sendCalls succeeds.
|
|
13544
|
+
result.state = 'error';
|
|
13545
|
+
result.steps.push({
|
|
13546
|
+
name: 'batch',
|
|
13547
|
+
state: 'error',
|
|
13548
|
+
batched: true,
|
|
13549
|
+
error: error_,
|
|
13550
|
+
errorMessage: error_ instanceof Error
|
|
13551
|
+
? error_.message
|
|
13552
|
+
: 'Batched approve + burn failed.',
|
|
13553
|
+
});
|
|
13554
|
+
return undefined;
|
|
13555
|
+
}
|
|
13556
|
+
}
|
|
13557
|
+
/**
|
|
13558
|
+
* Ensure `step.errorMessage` is populated when an error object exists.
|
|
13559
|
+
*
|
|
13560
|
+
* @internal
|
|
13561
|
+
*/
|
|
13562
|
+
function ensureStepErrorMessage(name, step) {
|
|
13563
|
+
if (!step.errorMessage && step.error) {
|
|
13564
|
+
step.errorMessage = `${name} step failed: ${getErrorMessage(step.error)}`;
|
|
13565
|
+
}
|
|
13566
|
+
}
|
|
13329
13567
|
/**
|
|
13330
13568
|
* Execute a cross-chain USDC bridge using the CCTP v2 protocol.
|
|
13331
13569
|
*
|
|
@@ -13359,9 +13597,7 @@ function resolveBridgeInvocation(invocationMeta) {
|
|
|
13359
13597
|
* ```
|
|
13360
13598
|
*/
|
|
13361
13599
|
async function bridge$1(params, provider) {
|
|
13362
|
-
// Check if forwarder is enabled (on destination)
|
|
13363
13600
|
const useForwarder = params.destination.useForwarder === true;
|
|
13364
|
-
// Resolve invocation metadata to full context for event dispatching
|
|
13365
13601
|
const invocation = resolveBridgeInvocation(params.invocationMeta);
|
|
13366
13602
|
const result = {
|
|
13367
13603
|
state: 'pending',
|
|
@@ -13374,11 +13610,9 @@ async function bridge$1(params, provider) {
|
|
|
13374
13610
|
destination: {
|
|
13375
13611
|
address: params.destination.address,
|
|
13376
13612
|
chain: params.destination.chain,
|
|
13377
|
-
// Preserve recipientAddress
|
|
13378
13613
|
...(params.destination.recipientAddress && {
|
|
13379
13614
|
recipientAddress: params.destination.recipientAddress,
|
|
13380
13615
|
}),
|
|
13381
|
-
// Preserve useForwarder
|
|
13382
13616
|
...(useForwarder && {
|
|
13383
13617
|
useForwarder: true,
|
|
13384
13618
|
}),
|
|
@@ -13387,29 +13621,38 @@ async function bridge$1(params, provider) {
|
|
|
13387
13621
|
config: params.config,
|
|
13388
13622
|
provider: provider.name,
|
|
13389
13623
|
};
|
|
13390
|
-
// Context shared between steps
|
|
13391
13624
|
let context = undefined;
|
|
13392
|
-
|
|
13625
|
+
let useBatched = false;
|
|
13626
|
+
try {
|
|
13627
|
+
useBatched = await shouldUseBatchedExecution(params);
|
|
13628
|
+
}
|
|
13629
|
+
catch {
|
|
13630
|
+
// Silently fall back to sequential
|
|
13631
|
+
}
|
|
13393
13632
|
const executors = createStepExecutors(useForwarder);
|
|
13394
|
-
|
|
13395
|
-
|
|
13633
|
+
if (useBatched) {
|
|
13634
|
+
const batchContext = await executeBatchedPath(params, provider, result, invocation);
|
|
13635
|
+
if (result.state === 'error') {
|
|
13636
|
+
return result;
|
|
13637
|
+
}
|
|
13638
|
+
context = batchContext;
|
|
13639
|
+
}
|
|
13640
|
+
const stepsToRun = useBatched
|
|
13641
|
+
? executors.filter(({ name }) => name !== 'approve' && name !== 'burn')
|
|
13642
|
+
: executors;
|
|
13643
|
+
for (const { name, executor, updateContext } of stepsToRun) {
|
|
13396
13644
|
try {
|
|
13397
13645
|
const step = await executor(params, provider, context);
|
|
13398
13646
|
if (step.state === 'error') {
|
|
13399
|
-
|
|
13400
|
-
if (!step.errorMessage && step.error) {
|
|
13401
|
-
step.errorMessage = `${name} step failed: ${getErrorMessage(step.error)}`;
|
|
13402
|
-
}
|
|
13647
|
+
ensureStepErrorMessage(name, step);
|
|
13403
13648
|
result.steps.push(step);
|
|
13404
13649
|
result.state = 'error';
|
|
13405
|
-
// Dispatch event even for error steps
|
|
13406
13650
|
dispatchStepEvent(name, step, provider, invocation);
|
|
13407
13651
|
return result;
|
|
13408
13652
|
}
|
|
13409
|
-
// Merge new context with existing context to preserve data from previous steps
|
|
13410
13653
|
const newContext = updateContext?.(step);
|
|
13411
13654
|
if (newContext) {
|
|
13412
|
-
context = { ...
|
|
13655
|
+
context = { ...context, ...newContext };
|
|
13413
13656
|
}
|
|
13414
13657
|
dispatchStepEvent(name, step, provider, invocation);
|
|
13415
13658
|
result.steps.push(step);
|
|
@@ -16041,7 +16284,7 @@ const createBridgeKit = (context) => {
|
|
|
16041
16284
|
};
|
|
16042
16285
|
|
|
16043
16286
|
var name = "@circle-fin/swap-kit";
|
|
16044
|
-
var version = "1.0.
|
|
16287
|
+
var version = "1.0.2";
|
|
16045
16288
|
var pkg = {
|
|
16046
16289
|
name: name,
|
|
16047
16290
|
version: version};
|
|
@@ -25026,8 +25269,8 @@ const adapterContextSchema = zod.z.object({
|
|
|
25026
25269
|
* Schema for validating send parameters.
|
|
25027
25270
|
* Ensure required fields are present and properly typed. Parameters must include:
|
|
25028
25271
|
* - A valid `amount` (non-empty numeric string \> 0; supports "," or "." decimal separators and thousands separators).
|
|
25029
|
-
* - A valid `from` context (an adapter
|
|
25030
|
-
* - A valid `to`
|
|
25272
|
+
* - A valid `from` context (an adapter context with `adapter` and `chain`).
|
|
25273
|
+
* - A valid `to` destination (an adapter instance or a wallet address string).
|
|
25031
25274
|
* - An optional `token` selection: 'USDC' (default), 'USDT', 'NATIVE', or a custom token address string.
|
|
25032
25275
|
*
|
|
25033
25276
|
* @returns Zod schema validating a send parameters object.
|
|
@@ -25040,7 +25283,7 @@ const adapterContextSchema = zod.z.object({
|
|
|
25040
25283
|
* const params = {
|
|
25041
25284
|
* amount: '100.50',
|
|
25042
25285
|
* from: { adapter: sourceAdapter, chain: 'Ethereum' },
|
|
25043
|
-
* to: '
|
|
25286
|
+
* to: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e', // or destAdapter
|
|
25044
25287
|
* token: 'USDC',
|
|
25045
25288
|
* }
|
|
25046
25289
|
*
|
|
@@ -25099,7 +25342,7 @@ const sendParamsSchema = zod.z.object({
|
|
|
25099
25342
|
* The validation includes:
|
|
25100
25343
|
* - Basic parameter structure and types.
|
|
25101
25344
|
* - Amount validation (non-empty decimal string strictly greater than 0).
|
|
25102
|
-
* - Recipient validation (either an address string or an adapter
|
|
25345
|
+
* - Recipient validation (either an address string or an adapter instance).
|
|
25103
25346
|
* - Adapter shape validation (required methods present).
|
|
25104
25347
|
* - Optional config validation (when provided).
|
|
25105
25348
|
*
|
|
@@ -25110,7 +25353,7 @@ const sendParamsSchema = zod.z.object({
|
|
|
25110
25353
|
* ```typescript
|
|
25111
25354
|
* // Narrow unknown input to SendParams
|
|
25112
25355
|
* const input: unknown = {
|
|
25113
|
-
* from: sourceAdapter,
|
|
25356
|
+
* from: { adapter: sourceAdapter, chain: 'Ethereum' },
|
|
25114
25357
|
* to: '0x742d35Cc6634C0532925a3b8D1a7aDBa359cfA7',
|
|
25115
25358
|
* amount: '1'
|
|
25116
25359
|
* }
|
|
@@ -25129,7 +25372,7 @@ const tokens = createTokenRegistry();
|
|
|
25129
25372
|
* Prepare a chain request to send USDC, USDT, native gas tokens, or custom ERC-20/SPL tokens.
|
|
25130
25373
|
*
|
|
25131
25374
|
* Validate inputs, obtain the sender address from the `from` adapter, resolve the recipient
|
|
25132
|
-
* from `to` (explicit address string or adapter
|
|
25375
|
+
* from `to` (explicit address string or adapter), and normalize the human‑readable
|
|
25133
25376
|
* `amount` into token units.
|
|
25134
25377
|
*
|
|
25135
25378
|
* For known token aliases, uses dedicated transfer actions
|
|
@@ -25240,7 +25483,7 @@ const prepareSend = async (params) => {
|
|
|
25240
25483
|
* For custom token addresses, uses the generic token.transfer action with dynamically
|
|
25241
25484
|
* fetched decimals.
|
|
25242
25485
|
*
|
|
25243
|
-
* @param params - The send parameters: source context, destination (address or adapter
|
|
25486
|
+
* @param params - The send parameters: source context, destination (address or adapter),
|
|
25244
25487
|
* human-readable `amount`, and optional `token` ('USDC' | 'USDT' | 'NATIVE' or custom address, defaults to 'USDC').
|
|
25245
25488
|
* @returns A BridgeStep object with transaction details including hash, status, and explorer URL.
|
|
25246
25489
|
* @throws KitError INPUT_VALIDATION_FAILED if parameters are invalid.
|
|
@@ -25302,17 +25545,17 @@ const send = async (params) => {
|
|
|
25302
25545
|
* Estimate the network fees to send USDC, USDT, or a supported native token.
|
|
25303
25546
|
*
|
|
25304
25547
|
* Prepare the send operation (including validating inputs and resolving the recipient when
|
|
25305
|
-
* provided as an adapter
|
|
25548
|
+
* provided as an adapter) and return an {@link EstimatedGas} object. This function does
|
|
25306
25549
|
* not submit any transaction.
|
|
25307
25550
|
*
|
|
25308
25551
|
* @remarks
|
|
25309
25552
|
* - Selects the transfer handler based on `token` ('USDC' by default, 'USDT', or 'NATIVE').
|
|
25310
|
-
* - When `to` is an
|
|
25553
|
+
* - When `to` is an {@link Adapter}, the recipient address is derived from the adapter.
|
|
25311
25554
|
* - Rejects transfers where the resolved `to` equals the source `from` address.
|
|
25312
25555
|
* - Interprets `amount` as a human-readable decimal string (USDC and USDT scaled to 6 decimals,
|
|
25313
25556
|
* native EVM value typically scaled to 18 decimals).
|
|
25314
25557
|
*
|
|
25315
|
-
* @param params - The send parameters: source context, destination (address or adapter
|
|
25558
|
+
* @param params - The send parameters: source context, destination (address or adapter),
|
|
25316
25559
|
* human-readable `amount`, and optional `token` ('USDC' | 'USDT' | 'NATIVE', defaults to 'USDC').
|
|
25317
25560
|
* @returns The estimated gas information including `gas`, `gasPrice`, and total `fee`.
|
|
25318
25561
|
* @throws Error If parameters are invalid.
|
|
@@ -25714,10 +25957,10 @@ class AppKit {
|
|
|
25714
25957
|
*
|
|
25715
25958
|
* @example
|
|
25716
25959
|
* ```typescript
|
|
25717
|
-
* // Send USDC to
|
|
25960
|
+
* // Send USDC to a recipient adapter (same chain)
|
|
25718
25961
|
* const result = await kit.send({
|
|
25719
|
-
* from: sourceAdapter,
|
|
25720
|
-
* to:
|
|
25962
|
+
* from: { adapter: sourceAdapter, chain: 'Ethereum' },
|
|
25963
|
+
* to: recipientAdapter,
|
|
25721
25964
|
* amount: '100.50',
|
|
25722
25965
|
* token: 'USDC'
|
|
25723
25966
|
* })
|
|
@@ -25728,7 +25971,7 @@ class AppKit {
|
|
|
25728
25971
|
* ```typescript
|
|
25729
25972
|
* // Send a custom token to an explicit address
|
|
25730
25973
|
* const result = await kit.send({
|
|
25731
|
-
* from: sourceAdapter,
|
|
25974
|
+
* from: { adapter: sourceAdapter, chain: 'Ethereum' },
|
|
25732
25975
|
* to: '0x742d35Cc4634C0532925a3b8D1d7',
|
|
25733
25976
|
* amount: '100.50',
|
|
25734
25977
|
* token: '0x6B175474E89094C44Da98b954EedeAC495271d0F' // DAI on Ethereum
|
|
@@ -25740,8 +25983,8 @@ class AppKit {
|
|
|
25740
25983
|
* ```typescript
|
|
25741
25984
|
* // Send USDT to an explicit address
|
|
25742
25985
|
* const result = await kit.send({
|
|
25743
|
-
* from: sourceAdapter,
|
|
25744
|
-
* to:
|
|
25986
|
+
* from: { adapter: sourceAdapter, chain: 'Ethereum' },
|
|
25987
|
+
* to: '0x742d35Cc4634C0532925a3b8D1d7',
|
|
25745
25988
|
* amount: '50.25',
|
|
25746
25989
|
* token: 'USDT'
|
|
25747
25990
|
* })
|
|
@@ -25767,8 +26010,8 @@ class AppKit {
|
|
|
25767
26010
|
* @example
|
|
25768
26011
|
* ```typescript
|
|
25769
26012
|
* const estimate = await kit.estimateSend({
|
|
25770
|
-
* from: sourceAdapter,
|
|
25771
|
-
* to:
|
|
26013
|
+
* from: { adapter: sourceAdapter, chain: 'Ethereum' },
|
|
26014
|
+
* to: recipientAdapter,
|
|
25772
26015
|
* amount: '100.50',
|
|
25773
26016
|
* token: 'USDC'
|
|
25774
26017
|
* })
|
|
@@ -25779,8 +26022,8 @@ class AppKit {
|
|
|
25779
26022
|
* @example
|
|
25780
26023
|
* ```typescript
|
|
25781
26024
|
* const estimate = await kit.estimateSend({
|
|
25782
|
-
* from: sourceAdapter,
|
|
25783
|
-
* to:
|
|
26025
|
+
* from: { adapter: sourceAdapter, chain: 'Ethereum' },
|
|
26026
|
+
* to: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e',
|
|
25784
26027
|
* amount: '50.0',
|
|
25785
26028
|
* token: 'USDT'
|
|
25786
26029
|
* })
|