@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.mjs
CHANGED
|
@@ -4224,7 +4224,7 @@ const Codex = defineChain({
|
|
|
4224
4224
|
},
|
|
4225
4225
|
forwarderSupported: {
|
|
4226
4226
|
source: true,
|
|
4227
|
-
destination:
|
|
4227
|
+
destination: true,
|
|
4228
4228
|
},
|
|
4229
4229
|
},
|
|
4230
4230
|
kitContracts: {
|
|
@@ -4267,7 +4267,7 @@ const CodexTestnet = defineChain({
|
|
|
4267
4267
|
},
|
|
4268
4268
|
forwarderSupported: {
|
|
4269
4269
|
source: true,
|
|
4270
|
-
destination:
|
|
4270
|
+
destination: true,
|
|
4271
4271
|
},
|
|
4272
4272
|
},
|
|
4273
4273
|
kitContracts: {
|
|
@@ -4529,7 +4529,7 @@ const HyperEVM = defineChain({
|
|
|
4529
4529
|
},
|
|
4530
4530
|
chainId: 999,
|
|
4531
4531
|
isTestnet: false,
|
|
4532
|
-
explorerUrl: 'https://
|
|
4532
|
+
explorerUrl: 'https://app.hyperliquid.xyz/explorer/tx/{hash}',
|
|
4533
4533
|
rpcEndpoints: ['https://rpc.hyperliquid.xyz/evm'],
|
|
4534
4534
|
eurcAddress: null,
|
|
4535
4535
|
usdcAddress: '0xb88339CB7199b77E23DB6E890353E22632Ba630f',
|
|
@@ -4574,7 +4574,7 @@ const HyperEVMTestnet = defineChain({
|
|
|
4574
4574
|
},
|
|
4575
4575
|
chainId: 998,
|
|
4576
4576
|
isTestnet: true,
|
|
4577
|
-
explorerUrl: 'https://
|
|
4577
|
+
explorerUrl: 'https://app.hyperliquid-testnet.xyz/explorer/tx/{hash}',
|
|
4578
4578
|
rpcEndpoints: ['https://rpc.hyperliquid-testnet.xyz/evm'],
|
|
4579
4579
|
eurcAddress: null,
|
|
4580
4580
|
usdcAddress: '0x2B3370eE501B4a559b57D449569354196457D8Ab',
|
|
@@ -5220,7 +5220,7 @@ const Plume = defineChain({
|
|
|
5220
5220
|
},
|
|
5221
5221
|
forwarderSupported: {
|
|
5222
5222
|
source: true,
|
|
5223
|
-
destination:
|
|
5223
|
+
destination: true,
|
|
5224
5224
|
},
|
|
5225
5225
|
},
|
|
5226
5226
|
kitContracts: {
|
|
@@ -5265,7 +5265,7 @@ const PlumeTestnet = defineChain({
|
|
|
5265
5265
|
},
|
|
5266
5266
|
forwarderSupported: {
|
|
5267
5267
|
source: true,
|
|
5268
|
-
destination:
|
|
5268
|
+
destination: true,
|
|
5269
5269
|
},
|
|
5270
5270
|
},
|
|
5271
5271
|
kitContracts: {
|
|
@@ -6043,7 +6043,7 @@ const XDC = defineChain({
|
|
|
6043
6043
|
},
|
|
6044
6044
|
forwarderSupported: {
|
|
6045
6045
|
source: true,
|
|
6046
|
-
destination:
|
|
6046
|
+
destination: true,
|
|
6047
6047
|
},
|
|
6048
6048
|
},
|
|
6049
6049
|
kitContracts: {
|
|
@@ -6087,7 +6087,7 @@ const XDCApothem = defineChain({
|
|
|
6087
6087
|
},
|
|
6088
6088
|
forwarderSupported: {
|
|
6089
6089
|
source: true,
|
|
6090
|
-
destination:
|
|
6090
|
+
destination: true,
|
|
6091
6091
|
},
|
|
6092
6092
|
},
|
|
6093
6093
|
kitContracts: {
|
|
@@ -9200,7 +9200,7 @@ function buildForwardingHookData() {
|
|
|
9200
9200
|
}
|
|
9201
9201
|
|
|
9202
9202
|
var name$1 = "@circle-fin/bridge-kit";
|
|
9203
|
-
var version$2 = "1.
|
|
9203
|
+
var version$2 = "1.8.0";
|
|
9204
9204
|
var pkg$2 = {
|
|
9205
9205
|
name: name$1,
|
|
9206
9206
|
version: version$2};
|
|
@@ -13290,7 +13290,184 @@ function dispatchStepEvent(name, step, provider, invocation) {
|
|
|
13290
13290
|
}
|
|
13291
13291
|
}
|
|
13292
13292
|
|
|
13293
|
-
|
|
13293
|
+
/**
|
|
13294
|
+
* Check whether the source adapter supports EIP-5792 atomic batching and
|
|
13295
|
+
* the consumer has not explicitly opted out via `config.batchTransactions`.
|
|
13296
|
+
*
|
|
13297
|
+
* @param params - Bridge parameters (used for adapter and config access).
|
|
13298
|
+
* @returns `true` when batched execution should be attempted.
|
|
13299
|
+
*
|
|
13300
|
+
* @example
|
|
13301
|
+
* ```typescript
|
|
13302
|
+
* const useBatched = await shouldUseBatchedExecution(params)
|
|
13303
|
+
* if (useBatched) {
|
|
13304
|
+
* // take the batched approve + burn path
|
|
13305
|
+
* }
|
|
13306
|
+
* ```
|
|
13307
|
+
*/
|
|
13308
|
+
async function shouldUseBatchedExecution(params) {
|
|
13309
|
+
if (params.config?.batchTransactions === false) {
|
|
13310
|
+
return false;
|
|
13311
|
+
}
|
|
13312
|
+
const { chain } = params.source;
|
|
13313
|
+
if (chain.type !== 'evm') {
|
|
13314
|
+
return false;
|
|
13315
|
+
}
|
|
13316
|
+
const adapter = params.source
|
|
13317
|
+
.adapter;
|
|
13318
|
+
if (typeof adapter.supportsAtomicBatch !== 'function' ||
|
|
13319
|
+
typeof adapter.batchExecute !== 'function') {
|
|
13320
|
+
return false;
|
|
13321
|
+
}
|
|
13322
|
+
try {
|
|
13323
|
+
return await adapter.supportsAtomicBatch(chain);
|
|
13324
|
+
}
|
|
13325
|
+
catch {
|
|
13326
|
+
return false;
|
|
13327
|
+
}
|
|
13328
|
+
}
|
|
13329
|
+
/**
|
|
13330
|
+
* Execute the approve and burn steps as a single EIP-5792 batched call.
|
|
13331
|
+
*
|
|
13332
|
+
* Prepare both `PreparedChainRequest` objects upfront, extract their raw
|
|
13333
|
+
* call data via `getCallData()`, submit both via `adapter.batchExecute()`,
|
|
13334
|
+
* then map the individual receipts back to standard {@link BridgeStep}
|
|
13335
|
+
* objects so downstream consumers (event callbacks, result tracking) are
|
|
13336
|
+
* unaffected.
|
|
13337
|
+
*
|
|
13338
|
+
* @param params - The CCTP v2 bridge parameters.
|
|
13339
|
+
* @param provider - The CCTP v2 bridging provider.
|
|
13340
|
+
* @returns Approve and burn steps with a shared context containing the burn tx hash.
|
|
13341
|
+
* @throws {@link KitError} when the source chain is not EVM.
|
|
13342
|
+
* @throws {@link KitError} when calldata extraction (`getCallData`) is not supported
|
|
13343
|
+
* by the prepared requests.
|
|
13344
|
+
* @remarks
|
|
13345
|
+
* Errors that occur after the batch has been submitted to the wallet
|
|
13346
|
+
* (e.g. polling timeout, insufficient receipts) are **not thrown** — they
|
|
13347
|
+
* are captured as `state: 'error'` on the returned steps to prevent
|
|
13348
|
+
* accidental double-spend on retry.
|
|
13349
|
+
*
|
|
13350
|
+
* @example
|
|
13351
|
+
* ```typescript
|
|
13352
|
+
* const { approveStep, burnStep, context } = await executeBatchedApproveAndBurn(
|
|
13353
|
+
* params,
|
|
13354
|
+
* provider,
|
|
13355
|
+
* )
|
|
13356
|
+
* result.steps.push(approveStep, burnStep)
|
|
13357
|
+
* ```
|
|
13358
|
+
*/
|
|
13359
|
+
async function executeBatchedApproveAndBurn(params, provider) {
|
|
13360
|
+
// Double-unknown cast: Adapter<TFrom> has no structural overlap with
|
|
13361
|
+
// BatchCapableAdapter (a duck-typed interface for EIP-5792 methods).
|
|
13362
|
+
// A direct cast fails because TS cannot prove the intersection; the
|
|
13363
|
+
// runtime capability check below guards against unsupported adapters.
|
|
13364
|
+
const adapter = params.source.adapter;
|
|
13365
|
+
const sourceChain = params.source.chain;
|
|
13366
|
+
if (sourceChain.type !== 'evm') {
|
|
13367
|
+
throw new KitError({
|
|
13368
|
+
...InputError.INVALID_CHAIN,
|
|
13369
|
+
recoverability: 'FATAL',
|
|
13370
|
+
message: 'Batched execution is only supported on EVM chains.',
|
|
13371
|
+
});
|
|
13372
|
+
}
|
|
13373
|
+
const chain = sourceChain;
|
|
13374
|
+
// customFee.value is in base units (integer string) at this point.
|
|
13375
|
+
const customFee = BigInt(params.config?.customFee?.value ?? '0');
|
|
13376
|
+
const amountBigInt = BigInt(params.amount);
|
|
13377
|
+
const approvalAmount = (amountBigInt + customFee).toString();
|
|
13378
|
+
const [approveRequest, burnRequest] = await Promise.all([
|
|
13379
|
+
provider.approve(params.source, approvalAmount),
|
|
13380
|
+
provider.burn(params),
|
|
13381
|
+
]);
|
|
13382
|
+
if (approveRequest.type !== 'evm' ||
|
|
13383
|
+
burnRequest.type !== 'evm' ||
|
|
13384
|
+
!approveRequest.getCallData ||
|
|
13385
|
+
!burnRequest.getCallData) {
|
|
13386
|
+
throw new KitError({
|
|
13387
|
+
...InputError.UNSUPPORTED_ACTION,
|
|
13388
|
+
recoverability: 'FATAL',
|
|
13389
|
+
message: 'Batched execution requires EVM prepared requests with getCallData() support.',
|
|
13390
|
+
});
|
|
13391
|
+
}
|
|
13392
|
+
const approveCallData = approveRequest.getCallData();
|
|
13393
|
+
const burnCallData = burnRequest.getCallData();
|
|
13394
|
+
// batchExecute may throw before submission (wallet declined) but never
|
|
13395
|
+
// after — post-submission errors are returned as empty receipts.
|
|
13396
|
+
const batchResult = await adapter.batchExecute([approveCallData, burnCallData], chain);
|
|
13397
|
+
const approveReceipt = batchResult.receipts[0];
|
|
13398
|
+
const burnReceipt = batchResult.receipts[1];
|
|
13399
|
+
const approveStep = await buildBatchedStep('approve', approveReceipt, batchResult.batchId, adapter, chain);
|
|
13400
|
+
const burnStep = await buildBatchedStep('burn', burnReceipt, batchResult.batchId, adapter, chain);
|
|
13401
|
+
if (burnStep.state !== 'error' && !burnStep.txHash) {
|
|
13402
|
+
burnStep.state = 'error';
|
|
13403
|
+
burnStep.errorMessage =
|
|
13404
|
+
'Batched burn step completed but no transaction hash was returned.';
|
|
13405
|
+
}
|
|
13406
|
+
const context = { burnTxHash: burnStep.txHash ?? '' };
|
|
13407
|
+
return { approveStep, burnStep, context };
|
|
13408
|
+
}
|
|
13409
|
+
/**
|
|
13410
|
+
* Build a {@link BridgeStep} from a single receipt within a batch.
|
|
13411
|
+
*
|
|
13412
|
+
* Map the raw receipt from `batchExecute` into a standard `BridgeStep`,
|
|
13413
|
+
* waiting for on-chain confirmation via `adapter.waitForTransaction`.
|
|
13414
|
+
* All errors are captured on the step (never thrown) so the caller
|
|
13415
|
+
* can inspect each step independently.
|
|
13416
|
+
*
|
|
13417
|
+
* @param name - Human-readable step name (e.g. `'approve'`, `'burn'`).
|
|
13418
|
+
* @param receipt - Per-call receipt from `batchExecute`, or `undefined`
|
|
13419
|
+
* when the wallet returned fewer receipts than submitted calls.
|
|
13420
|
+
* @param batchId - Wallet-assigned batch identifier.
|
|
13421
|
+
* @param adapter - The batch-capable adapter (used for confirmation).
|
|
13422
|
+
* @param chain - The EVM chain the batch was executed on.
|
|
13423
|
+
* @returns A fully-populated bridge step with state, tx hash and explorer URL.
|
|
13424
|
+
*
|
|
13425
|
+
* @internal
|
|
13426
|
+
*/
|
|
13427
|
+
async function buildBatchedStep(name, receipt, batchId, adapter, chain) {
|
|
13428
|
+
const step = {
|
|
13429
|
+
name,
|
|
13430
|
+
state: 'pending',
|
|
13431
|
+
batched: true,
|
|
13432
|
+
batchId,
|
|
13433
|
+
};
|
|
13434
|
+
if (!receipt) {
|
|
13435
|
+
step.state = 'error';
|
|
13436
|
+
step.errorMessage = `No receipt returned for ${name} in batch ${batchId}.`;
|
|
13437
|
+
return step;
|
|
13438
|
+
}
|
|
13439
|
+
step.txHash = receipt.txHash;
|
|
13440
|
+
if (receipt.txHash) {
|
|
13441
|
+
step.explorerUrl = buildExplorerUrl(chain, receipt.txHash);
|
|
13442
|
+
}
|
|
13443
|
+
if (receipt.status !== 'success') {
|
|
13444
|
+
step.state = 'error';
|
|
13445
|
+
step.errorMessage = `${name} call failed within batch ${batchId}.`;
|
|
13446
|
+
return step;
|
|
13447
|
+
}
|
|
13448
|
+
if (!receipt.txHash) {
|
|
13449
|
+
step.state = 'error';
|
|
13450
|
+
step.errorMessage = `${name} succeeded in batch but returned an empty transaction hash.`;
|
|
13451
|
+
return step;
|
|
13452
|
+
}
|
|
13453
|
+
try {
|
|
13454
|
+
const transaction = await adapter.waitForTransaction(receipt.txHash, { confirmations: 1 }, chain);
|
|
13455
|
+
step.state = transaction.blockNumber === undefined ? 'error' : 'success';
|
|
13456
|
+
step.data = transaction;
|
|
13457
|
+
if (transaction.blockNumber === undefined) {
|
|
13458
|
+
step.errorMessage = 'Transaction was not confirmed on-chain.';
|
|
13459
|
+
}
|
|
13460
|
+
}
|
|
13461
|
+
catch (err) {
|
|
13462
|
+
step.state = 'error';
|
|
13463
|
+
step.error = err;
|
|
13464
|
+
step.errorMessage =
|
|
13465
|
+
err instanceof Error ? err.message : 'Unknown error during confirmation.';
|
|
13466
|
+
}
|
|
13467
|
+
return step;
|
|
13468
|
+
}
|
|
13469
|
+
|
|
13470
|
+
var version$1 = "1.6.0";
|
|
13294
13471
|
var pkg$1 = {
|
|
13295
13472
|
version: version$1};
|
|
13296
13473
|
|
|
@@ -13319,6 +13496,67 @@ function resolveBridgeInvocation(invocationMeta) {
|
|
|
13319
13496
|
};
|
|
13320
13497
|
return extendInvocationContext(resolveInvocationContext(invocationMeta, defaults), BRIDGE_CALLER);
|
|
13321
13498
|
}
|
|
13499
|
+
/**
|
|
13500
|
+
* Execute the batched approve + burn path via EIP-5792.
|
|
13501
|
+
*
|
|
13502
|
+
* Mutate `result` with step data and error state as needed. Return the
|
|
13503
|
+
* batch context on success, or `undefined` when the batch failed (in
|
|
13504
|
+
* which case `result.state` is set to `'error'`).
|
|
13505
|
+
*
|
|
13506
|
+
* @internal
|
|
13507
|
+
* @param params - Bridge parameters (read-only).
|
|
13508
|
+
* @param provider - The CCTP v2 bridging provider (read-only).
|
|
13509
|
+
* @param result - Bridge result object — **mutated in place** with step
|
|
13510
|
+
* data and, on failure, `state: 'error'` plus an `error` payload.
|
|
13511
|
+
* @param invocation - Invocation context for telemetry (read-only).
|
|
13512
|
+
* @returns The step context on success, or `undefined` when the batch failed.
|
|
13513
|
+
*/
|
|
13514
|
+
async function executeBatchedPath(params, provider, result, invocation) {
|
|
13515
|
+
// IMPORTANT: once executeBatchedApproveAndBurn is called, we NEVER
|
|
13516
|
+
// fall back to sequential. The wallet may have already signed &
|
|
13517
|
+
// submitted the batch; retrying as individual txs would double-spend.
|
|
13518
|
+
try {
|
|
13519
|
+
const { approveStep, burnStep, context: batchContext, } = await executeBatchedApproveAndBurn(params, provider);
|
|
13520
|
+
for (const step of [approveStep, burnStep]) {
|
|
13521
|
+
const stepName = step.name;
|
|
13522
|
+
if (step.state === 'error') {
|
|
13523
|
+
ensureStepErrorMessage(step.name, step);
|
|
13524
|
+
result.steps.push(step);
|
|
13525
|
+
result.state = 'error';
|
|
13526
|
+
dispatchStepEvent(stepName, step, provider, invocation);
|
|
13527
|
+
return undefined;
|
|
13528
|
+
}
|
|
13529
|
+
dispatchStepEvent(stepName, step, provider, invocation);
|
|
13530
|
+
result.steps.push(step);
|
|
13531
|
+
}
|
|
13532
|
+
return batchContext;
|
|
13533
|
+
}
|
|
13534
|
+
catch (error_) {
|
|
13535
|
+
// Only handles pre-submission failures (prepare rejected, wallet
|
|
13536
|
+
// declined, etc.). batchExecute never throws after sendCalls succeeds.
|
|
13537
|
+
result.state = 'error';
|
|
13538
|
+
result.steps.push({
|
|
13539
|
+
name: 'batch',
|
|
13540
|
+
state: 'error',
|
|
13541
|
+
batched: true,
|
|
13542
|
+
error: error_,
|
|
13543
|
+
errorMessage: error_ instanceof Error
|
|
13544
|
+
? error_.message
|
|
13545
|
+
: 'Batched approve + burn failed.',
|
|
13546
|
+
});
|
|
13547
|
+
return undefined;
|
|
13548
|
+
}
|
|
13549
|
+
}
|
|
13550
|
+
/**
|
|
13551
|
+
* Ensure `step.errorMessage` is populated when an error object exists.
|
|
13552
|
+
*
|
|
13553
|
+
* @internal
|
|
13554
|
+
*/
|
|
13555
|
+
function ensureStepErrorMessage(name, step) {
|
|
13556
|
+
if (!step.errorMessage && step.error) {
|
|
13557
|
+
step.errorMessage = `${name} step failed: ${getErrorMessage(step.error)}`;
|
|
13558
|
+
}
|
|
13559
|
+
}
|
|
13322
13560
|
/**
|
|
13323
13561
|
* Execute a cross-chain USDC bridge using the CCTP v2 protocol.
|
|
13324
13562
|
*
|
|
@@ -13352,9 +13590,7 @@ function resolveBridgeInvocation(invocationMeta) {
|
|
|
13352
13590
|
* ```
|
|
13353
13591
|
*/
|
|
13354
13592
|
async function bridge$1(params, provider) {
|
|
13355
|
-
// Check if forwarder is enabled (on destination)
|
|
13356
13593
|
const useForwarder = params.destination.useForwarder === true;
|
|
13357
|
-
// Resolve invocation metadata to full context for event dispatching
|
|
13358
13594
|
const invocation = resolveBridgeInvocation(params.invocationMeta);
|
|
13359
13595
|
const result = {
|
|
13360
13596
|
state: 'pending',
|
|
@@ -13367,11 +13603,9 @@ async function bridge$1(params, provider) {
|
|
|
13367
13603
|
destination: {
|
|
13368
13604
|
address: params.destination.address,
|
|
13369
13605
|
chain: params.destination.chain,
|
|
13370
|
-
// Preserve recipientAddress
|
|
13371
13606
|
...(params.destination.recipientAddress && {
|
|
13372
13607
|
recipientAddress: params.destination.recipientAddress,
|
|
13373
13608
|
}),
|
|
13374
|
-
// Preserve useForwarder
|
|
13375
13609
|
...(useForwarder && {
|
|
13376
13610
|
useForwarder: true,
|
|
13377
13611
|
}),
|
|
@@ -13380,29 +13614,38 @@ async function bridge$1(params, provider) {
|
|
|
13380
13614
|
config: params.config,
|
|
13381
13615
|
provider: provider.name,
|
|
13382
13616
|
};
|
|
13383
|
-
// Context shared between steps
|
|
13384
13617
|
let context = undefined;
|
|
13385
|
-
|
|
13618
|
+
let useBatched = false;
|
|
13619
|
+
try {
|
|
13620
|
+
useBatched = await shouldUseBatchedExecution(params);
|
|
13621
|
+
}
|
|
13622
|
+
catch {
|
|
13623
|
+
// Silently fall back to sequential
|
|
13624
|
+
}
|
|
13386
13625
|
const executors = createStepExecutors(useForwarder);
|
|
13387
|
-
|
|
13388
|
-
|
|
13626
|
+
if (useBatched) {
|
|
13627
|
+
const batchContext = await executeBatchedPath(params, provider, result, invocation);
|
|
13628
|
+
if (result.state === 'error') {
|
|
13629
|
+
return result;
|
|
13630
|
+
}
|
|
13631
|
+
context = batchContext;
|
|
13632
|
+
}
|
|
13633
|
+
const stepsToRun = useBatched
|
|
13634
|
+
? executors.filter(({ name }) => name !== 'approve' && name !== 'burn')
|
|
13635
|
+
: executors;
|
|
13636
|
+
for (const { name, executor, updateContext } of stepsToRun) {
|
|
13389
13637
|
try {
|
|
13390
13638
|
const step = await executor(params, provider, context);
|
|
13391
13639
|
if (step.state === 'error') {
|
|
13392
|
-
|
|
13393
|
-
if (!step.errorMessage && step.error) {
|
|
13394
|
-
step.errorMessage = `${name} step failed: ${getErrorMessage(step.error)}`;
|
|
13395
|
-
}
|
|
13640
|
+
ensureStepErrorMessage(name, step);
|
|
13396
13641
|
result.steps.push(step);
|
|
13397
13642
|
result.state = 'error';
|
|
13398
|
-
// Dispatch event even for error steps
|
|
13399
13643
|
dispatchStepEvent(name, step, provider, invocation);
|
|
13400
13644
|
return result;
|
|
13401
13645
|
}
|
|
13402
|
-
// Merge new context with existing context to preserve data from previous steps
|
|
13403
13646
|
const newContext = updateContext?.(step);
|
|
13404
13647
|
if (newContext) {
|
|
13405
|
-
context = { ...
|
|
13648
|
+
context = { ...context, ...newContext };
|
|
13406
13649
|
}
|
|
13407
13650
|
dispatchStepEvent(name, step, provider, invocation);
|
|
13408
13651
|
result.steps.push(step);
|
|
@@ -16034,7 +16277,7 @@ const createBridgeKit = (context) => {
|
|
|
16034
16277
|
};
|
|
16035
16278
|
|
|
16036
16279
|
var name = "@circle-fin/swap-kit";
|
|
16037
|
-
var version = "1.0.
|
|
16280
|
+
var version = "1.0.2";
|
|
16038
16281
|
var pkg = {
|
|
16039
16282
|
name: name,
|
|
16040
16283
|
version: version};
|
|
@@ -25019,8 +25262,8 @@ const adapterContextSchema = z.object({
|
|
|
25019
25262
|
* Schema for validating send parameters.
|
|
25020
25263
|
* Ensure required fields are present and properly typed. Parameters must include:
|
|
25021
25264
|
* - A valid `amount` (non-empty numeric string \> 0; supports "," or "." decimal separators and thousands separators).
|
|
25022
|
-
* - A valid `from` context (an adapter
|
|
25023
|
-
* - A valid `to`
|
|
25265
|
+
* - A valid `from` context (an adapter context with `adapter` and `chain`).
|
|
25266
|
+
* - A valid `to` destination (an adapter instance or a wallet address string).
|
|
25024
25267
|
* - An optional `token` selection: 'USDC' (default), 'USDT', 'NATIVE', or a custom token address string.
|
|
25025
25268
|
*
|
|
25026
25269
|
* @returns Zod schema validating a send parameters object.
|
|
@@ -25033,7 +25276,7 @@ const adapterContextSchema = z.object({
|
|
|
25033
25276
|
* const params = {
|
|
25034
25277
|
* amount: '100.50',
|
|
25035
25278
|
* from: { adapter: sourceAdapter, chain: 'Ethereum' },
|
|
25036
|
-
* to: '
|
|
25279
|
+
* to: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e', // or destAdapter
|
|
25037
25280
|
* token: 'USDC',
|
|
25038
25281
|
* }
|
|
25039
25282
|
*
|
|
@@ -25092,7 +25335,7 @@ const sendParamsSchema = z.object({
|
|
|
25092
25335
|
* The validation includes:
|
|
25093
25336
|
* - Basic parameter structure and types.
|
|
25094
25337
|
* - Amount validation (non-empty decimal string strictly greater than 0).
|
|
25095
|
-
* - Recipient validation (either an address string or an adapter
|
|
25338
|
+
* - Recipient validation (either an address string or an adapter instance).
|
|
25096
25339
|
* - Adapter shape validation (required methods present).
|
|
25097
25340
|
* - Optional config validation (when provided).
|
|
25098
25341
|
*
|
|
@@ -25103,7 +25346,7 @@ const sendParamsSchema = z.object({
|
|
|
25103
25346
|
* ```typescript
|
|
25104
25347
|
* // Narrow unknown input to SendParams
|
|
25105
25348
|
* const input: unknown = {
|
|
25106
|
-
* from: sourceAdapter,
|
|
25349
|
+
* from: { adapter: sourceAdapter, chain: 'Ethereum' },
|
|
25107
25350
|
* to: '0x742d35Cc6634C0532925a3b8D1a7aDBa359cfA7',
|
|
25108
25351
|
* amount: '1'
|
|
25109
25352
|
* }
|
|
@@ -25122,7 +25365,7 @@ const tokens = createTokenRegistry();
|
|
|
25122
25365
|
* Prepare a chain request to send USDC, USDT, native gas tokens, or custom ERC-20/SPL tokens.
|
|
25123
25366
|
*
|
|
25124
25367
|
* Validate inputs, obtain the sender address from the `from` adapter, resolve the recipient
|
|
25125
|
-
* from `to` (explicit address string or adapter
|
|
25368
|
+
* from `to` (explicit address string or adapter), and normalize the human‑readable
|
|
25126
25369
|
* `amount` into token units.
|
|
25127
25370
|
*
|
|
25128
25371
|
* For known token aliases, uses dedicated transfer actions
|
|
@@ -25233,7 +25476,7 @@ const prepareSend = async (params) => {
|
|
|
25233
25476
|
* For custom token addresses, uses the generic token.transfer action with dynamically
|
|
25234
25477
|
* fetched decimals.
|
|
25235
25478
|
*
|
|
25236
|
-
* @param params - The send parameters: source context, destination (address or adapter
|
|
25479
|
+
* @param params - The send parameters: source context, destination (address or adapter),
|
|
25237
25480
|
* human-readable `amount`, and optional `token` ('USDC' | 'USDT' | 'NATIVE' or custom address, defaults to 'USDC').
|
|
25238
25481
|
* @returns A BridgeStep object with transaction details including hash, status, and explorer URL.
|
|
25239
25482
|
* @throws KitError INPUT_VALIDATION_FAILED if parameters are invalid.
|
|
@@ -25295,17 +25538,17 @@ const send = async (params) => {
|
|
|
25295
25538
|
* Estimate the network fees to send USDC, USDT, or a supported native token.
|
|
25296
25539
|
*
|
|
25297
25540
|
* Prepare the send operation (including validating inputs and resolving the recipient when
|
|
25298
|
-
* provided as an adapter
|
|
25541
|
+
* provided as an adapter) and return an {@link EstimatedGas} object. This function does
|
|
25299
25542
|
* not submit any transaction.
|
|
25300
25543
|
*
|
|
25301
25544
|
* @remarks
|
|
25302
25545
|
* - Selects the transfer handler based on `token` ('USDC' by default, 'USDT', or 'NATIVE').
|
|
25303
|
-
* - When `to` is an
|
|
25546
|
+
* - When `to` is an {@link Adapter}, the recipient address is derived from the adapter.
|
|
25304
25547
|
* - Rejects transfers where the resolved `to` equals the source `from` address.
|
|
25305
25548
|
* - Interprets `amount` as a human-readable decimal string (USDC and USDT scaled to 6 decimals,
|
|
25306
25549
|
* native EVM value typically scaled to 18 decimals).
|
|
25307
25550
|
*
|
|
25308
|
-
* @param params - The send parameters: source context, destination (address or adapter
|
|
25551
|
+
* @param params - The send parameters: source context, destination (address or adapter),
|
|
25309
25552
|
* human-readable `amount`, and optional `token` ('USDC' | 'USDT' | 'NATIVE', defaults to 'USDC').
|
|
25310
25553
|
* @returns The estimated gas information including `gas`, `gasPrice`, and total `fee`.
|
|
25311
25554
|
* @throws Error If parameters are invalid.
|
|
@@ -25707,10 +25950,10 @@ class AppKit {
|
|
|
25707
25950
|
*
|
|
25708
25951
|
* @example
|
|
25709
25952
|
* ```typescript
|
|
25710
|
-
* // Send USDC to
|
|
25953
|
+
* // Send USDC to a recipient adapter (same chain)
|
|
25711
25954
|
* const result = await kit.send({
|
|
25712
|
-
* from: sourceAdapter,
|
|
25713
|
-
* to:
|
|
25955
|
+
* from: { adapter: sourceAdapter, chain: 'Ethereum' },
|
|
25956
|
+
* to: recipientAdapter,
|
|
25714
25957
|
* amount: '100.50',
|
|
25715
25958
|
* token: 'USDC'
|
|
25716
25959
|
* })
|
|
@@ -25721,7 +25964,7 @@ class AppKit {
|
|
|
25721
25964
|
* ```typescript
|
|
25722
25965
|
* // Send a custom token to an explicit address
|
|
25723
25966
|
* const result = await kit.send({
|
|
25724
|
-
* from: sourceAdapter,
|
|
25967
|
+
* from: { adapter: sourceAdapter, chain: 'Ethereum' },
|
|
25725
25968
|
* to: '0x742d35Cc4634C0532925a3b8D1d7',
|
|
25726
25969
|
* amount: '100.50',
|
|
25727
25970
|
* token: '0x6B175474E89094C44Da98b954EedeAC495271d0F' // DAI on Ethereum
|
|
@@ -25733,8 +25976,8 @@ class AppKit {
|
|
|
25733
25976
|
* ```typescript
|
|
25734
25977
|
* // Send USDT to an explicit address
|
|
25735
25978
|
* const result = await kit.send({
|
|
25736
|
-
* from: sourceAdapter,
|
|
25737
|
-
* to:
|
|
25979
|
+
* from: { adapter: sourceAdapter, chain: 'Ethereum' },
|
|
25980
|
+
* to: '0x742d35Cc4634C0532925a3b8D1d7',
|
|
25738
25981
|
* amount: '50.25',
|
|
25739
25982
|
* token: 'USDT'
|
|
25740
25983
|
* })
|
|
@@ -25760,8 +26003,8 @@ class AppKit {
|
|
|
25760
26003
|
* @example
|
|
25761
26004
|
* ```typescript
|
|
25762
26005
|
* const estimate = await kit.estimateSend({
|
|
25763
|
-
* from: sourceAdapter,
|
|
25764
|
-
* to:
|
|
26006
|
+
* from: { adapter: sourceAdapter, chain: 'Ethereum' },
|
|
26007
|
+
* to: recipientAdapter,
|
|
25765
26008
|
* amount: '100.50',
|
|
25766
26009
|
* token: 'USDC'
|
|
25767
26010
|
* })
|
|
@@ -25772,8 +26015,8 @@ class AppKit {
|
|
|
25772
26015
|
* @example
|
|
25773
26016
|
* ```typescript
|
|
25774
26017
|
* const estimate = await kit.estimateSend({
|
|
25775
|
-
* from: sourceAdapter,
|
|
25776
|
-
* to:
|
|
26018
|
+
* from: { adapter: sourceAdapter, chain: 'Ethereum' },
|
|
26019
|
+
* to: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e',
|
|
25777
26020
|
* amount: '50.0',
|
|
25778
26021
|
* token: 'USDT'
|
|
25779
26022
|
* })
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@circle-fin/app-kit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=16.0.0"
|
|
6
6
|
},
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
"module": "./index.mjs",
|
|
9
9
|
"types": "./index.d.ts",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@circle-fin/bridge-kit": "1.
|
|
12
|
-
"@circle-fin/swap-kit": "1.0.
|
|
11
|
+
"@circle-fin/bridge-kit": "1.8.0",
|
|
12
|
+
"@circle-fin/swap-kit": "1.0.2",
|
|
13
13
|
"zod": "3.25.67",
|
|
14
14
|
"@ethersproject/address": "^5.8.0",
|
|
15
15
|
"@ethersproject/bytes": "^5.8.0",
|
|
@@ -63,6 +63,7 @@
|
|
|
63
63
|
"index.*",
|
|
64
64
|
"README.md",
|
|
65
65
|
"QUICKSTART.md",
|
|
66
|
+
"CHANGELOG.md",
|
|
66
67
|
"package.json",
|
|
67
68
|
"LICENSE"
|
|
68
69
|
],
|