@circle-fin/app-kit 1.15.2 → 1.16.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 +59 -0
- package/README.md +5 -2
- package/borrow.cjs +28028 -0
- package/borrow.cjs.map +1 -0
- package/borrow.d.cts +10723 -0
- package/borrow.d.mts +10723 -0
- package/borrow.d.ts +10723 -0
- package/borrow.mjs +28000 -0
- package/borrow.mjs.map +1 -0
- package/bridge.cjs +1942 -290
- package/bridge.d.cts +157 -12
- package/bridge.d.mts +157 -12
- package/bridge.d.ts +157 -12
- package/bridge.mjs +1942 -290
- package/chains.cjs +70 -3
- package/chains.d.cts +2 -0
- package/chains.d.mts +2 -0
- package/chains.d.ts +2 -0
- package/chains.mjs +70 -3
- package/context.cjs +1 -0
- package/context.d.cts +157 -12
- package/context.d.mts +157 -12
- package/context.d.ts +157 -12
- package/context.mjs +1 -0
- package/earn.cjs +5466 -3459
- package/earn.d.cts +1112 -983
- package/earn.d.mts +1112 -983
- package/earn.d.ts +1112 -983
- package/earn.mjs +5466 -3459
- package/estimateBridge.cjs +1940 -288
- package/estimateBridge.d.cts +157 -12
- package/estimateBridge.d.mts +157 -12
- package/estimateBridge.d.ts +157 -12
- package/estimateBridge.mjs +1940 -288
- package/estimateSwap.cjs +8497 -6831
- package/estimateSwap.d.cts +157 -12
- package/estimateSwap.d.mts +157 -12
- package/estimateSwap.d.ts +157 -12
- package/estimateSwap.mjs +8498 -6832
- package/index.cjs +30741 -18498
- package/index.d.cts +22724 -2322
- package/index.d.mts +22724 -2322
- package/index.d.ts +22724 -2322
- package/index.mjs +30682 -18492
- package/package.json +17 -7
- package/server.cjs +113 -22
- package/server.d.cts +10 -9
- package/server.d.mts +10 -9
- package/server.d.ts +10 -9
- package/server.mjs +113 -22
- package/swap.cjs +8497 -6831
- package/swap.d.cts +157 -12
- package/swap.d.mts +157 -12
- package/swap.d.ts +157 -12
- package/swap.mjs +8498 -6832
- package/unifiedBalance.cjs +457 -128
- package/unifiedBalance.d.cts +108 -11
- package/unifiedBalance.d.mts +108 -11
- package/unifiedBalance.d.ts +108 -11
- package/unifiedBalance.mjs +457 -128
package/unifiedBalance.cjs
CHANGED
|
@@ -1341,6 +1341,34 @@ let activeRedactor = defaultMessageRedactor;
|
|
|
1341
1341
|
return redactErrorMessage(String(error));
|
|
1342
1342
|
}
|
|
1343
1343
|
|
|
1344
|
+
/**
|
|
1345
|
+
* Render an object value for an error message without letting the rendering
|
|
1346
|
+
* itself throw.
|
|
1347
|
+
*
|
|
1348
|
+
* `JSON.stringify` rejects `BigInt` and circular structures, and a rejected
|
|
1349
|
+
* value is exactly the kind of thing a validation error is built from: an
|
|
1350
|
+
* on-chain read or a receipt log carries `bigint` fields, so serializing one
|
|
1351
|
+
* naively replaces the intended error with a `TypeError`.
|
|
1352
|
+
*
|
|
1353
|
+
* @param value - The value to render.
|
|
1354
|
+
* @returns A JSON string with `bigint` fields stringified, or
|
|
1355
|
+
* `'[unserializable object]'` if serialization still fails.
|
|
1356
|
+
* @throws Never; serialization failures are caught and rendered as a fallback string.
|
|
1357
|
+
* @example
|
|
1358
|
+
* ```typescript
|
|
1359
|
+
* import { describeObjectValue } from '@core/errors'
|
|
1360
|
+
*
|
|
1361
|
+
* describeObjectValue({ amount: 1n })
|
|
1362
|
+
* // '{"amount":"1"}'
|
|
1363
|
+
* ```
|
|
1364
|
+
*/ function describeObjectValue(value) {
|
|
1365
|
+
try {
|
|
1366
|
+
return JSON.stringify(value, (_key, entry)=>typeof entry === 'bigint' ? entry.toString() : entry);
|
|
1367
|
+
} catch {
|
|
1368
|
+
return '[unserializable object]';
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1344
1372
|
/**
|
|
1345
1373
|
* Creates error for network type mismatch between source and destination.
|
|
1346
1374
|
*
|
|
@@ -1569,7 +1597,7 @@ let activeRedactor = defaultMessageRedactor;
|
|
|
1569
1597
|
* // Message: "Validation failed for 'chainId': 999 - Unsupported chain ID"
|
|
1570
1598
|
*
|
|
1571
1599
|
* throw createValidationFailedError('config', { invalid: true }, 'Missing required properties')
|
|
1572
|
-
* // Message: "Validation failed for 'config':
|
|
1600
|
+
* // Message: "Validation failed for 'config': {"invalid":true} - Missing required properties"
|
|
1573
1601
|
* ```
|
|
1574
1602
|
*/ function createValidationFailedError$1(field, value, reason) {
|
|
1575
1603
|
// Convert value to string for display, handling different types appropriately
|
|
@@ -1577,7 +1605,7 @@ let activeRedactor = defaultMessageRedactor;
|
|
|
1577
1605
|
if (typeof value === 'string') {
|
|
1578
1606
|
valueString = `'${value}'`;
|
|
1579
1607
|
} else if (typeof value === 'object' && value !== null) {
|
|
1580
|
-
valueString =
|
|
1608
|
+
valueString = describeObjectValue(value);
|
|
1581
1609
|
} else {
|
|
1582
1610
|
valueString = String(value);
|
|
1583
1611
|
}
|
|
@@ -2976,6 +3004,105 @@ let activeRedactor = defaultMessageRedactor;
|
|
|
2976
3004
|
return chain;
|
|
2977
3005
|
}
|
|
2978
3006
|
|
|
3007
|
+
/**
|
|
3008
|
+
* Extracts the HTTP status code from an error message.
|
|
3009
|
+
*
|
|
3010
|
+
* Attempts to parse HTTP status codes from common error message formats,
|
|
3011
|
+
* such as "HTTP 404" or "Status: 500".
|
|
3012
|
+
*
|
|
3013
|
+
* Shared by `parseApiError` and the backend-error-code parsers that route on
|
|
3014
|
+
* status when no backend code is available, so all of them recognise the same
|
|
3015
|
+
* message shapes.
|
|
3016
|
+
*
|
|
3017
|
+
* @param msg - The error message to extract from
|
|
3018
|
+
* @returns The extracted HTTP status code, or null if not found
|
|
3019
|
+
*
|
|
3020
|
+
* @example
|
|
3021
|
+
* ```typescript
|
|
3022
|
+
* const code = extractHttpStatusCode('HTTP 404')
|
|
3023
|
+
* // Returns: 404
|
|
3024
|
+
* ```
|
|
3025
|
+
*
|
|
3026
|
+
* @example
|
|
3027
|
+
* ```typescript
|
|
3028
|
+
* const code = extractHttpStatusCode('Status: 500 Internal Server Error')
|
|
3029
|
+
* // Returns: 500
|
|
3030
|
+
* ```
|
|
3031
|
+
*
|
|
3032
|
+
* @internal
|
|
3033
|
+
*/ function extractHttpStatusCode(msg) {
|
|
3034
|
+
// Pattern: "HTTP 404" or "HTTP 404 - some message" or "Status: 404"
|
|
3035
|
+
const patterns = [
|
|
3036
|
+
/HTTP (\d{3})/i,
|
|
3037
|
+
/Status:\s*(\d{3})/i,
|
|
3038
|
+
/^(\d{3}) -/
|
|
3039
|
+
];
|
|
3040
|
+
for (const pattern of patterns){
|
|
3041
|
+
const match = pattern.exec(msg);
|
|
3042
|
+
const codeStr = match?.at(1);
|
|
3043
|
+
if (codeStr !== undefined) {
|
|
3044
|
+
const code = Number.parseInt(codeStr, 10);
|
|
3045
|
+
// Validate it's a valid HTTP status code
|
|
3046
|
+
if (code >= 100 && code < 600) {
|
|
3047
|
+
return code;
|
|
3048
|
+
}
|
|
3049
|
+
}
|
|
3050
|
+
}
|
|
3051
|
+
return null;
|
|
3052
|
+
}
|
|
3053
|
+
|
|
3054
|
+
/**
|
|
3055
|
+
* Type guard that narrows an unknown error to one carrying a non-null
|
|
3056
|
+
* object `responseBody` property (attached by `makeApiRequest`).
|
|
3057
|
+
*
|
|
3058
|
+
* Shared by backend-error-code parsers (`parseEarnApiError`,
|
|
3059
|
+
* `parseBorrowApiError`) so the narrowing logic lives in one place.
|
|
3060
|
+
*
|
|
3061
|
+
* @param error - The raw error from the HTTP layer
|
|
3062
|
+
* @returns `true` when `error.responseBody` is a non-null object
|
|
3063
|
+
* @internal
|
|
3064
|
+
*/ function hasResponseBody(error) {
|
|
3065
|
+
return typeof error === 'object' && error !== null && 'responseBody' in error && typeof error['responseBody'] === 'object' && error['responseBody'] !== null;
|
|
3066
|
+
}
|
|
3067
|
+
/**
|
|
3068
|
+
* Narrow an unknown value to a non-null object.
|
|
3069
|
+
*
|
|
3070
|
+
* @param value - The value to check
|
|
3071
|
+
* @returns `true` when `value` is a non-null object
|
|
3072
|
+
* @internal
|
|
3073
|
+
*/ function isRecord(value) {
|
|
3074
|
+
return typeof value === 'object' && value !== null;
|
|
3075
|
+
}
|
|
3076
|
+
/**
|
|
3077
|
+
* Read the machine-readable error fields (`code`, `message`,
|
|
3078
|
+
* `externalMessage`) that a Circle service attaches to an HTTP error body.
|
|
3079
|
+
*
|
|
3080
|
+
* `platform-common-go` serializes app-thrown errors under a nested envelope —
|
|
3081
|
+
* `{ response: { status: { code, message, externalMessage } } }` — for every
|
|
3082
|
+
* HTTP status, so this returns that inner `response.status` object when
|
|
3083
|
+
* present. It otherwise falls back to the top-level body so a flattened shape
|
|
3084
|
+
* (e.g. the stablecoin-kits-proxy) is still read. Callers read
|
|
3085
|
+
* `code` / `message` / `externalMessage` off the returned object uniformly.
|
|
3086
|
+
*
|
|
3087
|
+
* @param error - The raw error from the HTTP layer
|
|
3088
|
+
* @returns The error-status fields, or `undefined` when the error carries no
|
|
3089
|
+
* response body
|
|
3090
|
+
* @internal
|
|
3091
|
+
*/ function extractResponseBody$1(error) {
|
|
3092
|
+
if (!hasResponseBody(error)) {
|
|
3093
|
+
return undefined;
|
|
3094
|
+
}
|
|
3095
|
+
const body = error.responseBody;
|
|
3096
|
+
const response = body['response'];
|
|
3097
|
+
if (isRecord(response)) {
|
|
3098
|
+
const status = response['status'];
|
|
3099
|
+
if (isRecord(status)) {
|
|
3100
|
+
return status;
|
|
3101
|
+
}
|
|
3102
|
+
}
|
|
3103
|
+
return body;
|
|
3104
|
+
}
|
|
3105
|
+
|
|
2979
3106
|
/**
|
|
2980
3107
|
* Proxy-specific structured error codes carried in `responseBody.code`.
|
|
2981
3108
|
*
|
|
@@ -3276,29 +3403,22 @@ let activeRedactor = defaultMessageRedactor;
|
|
|
3276
3403
|
});
|
|
3277
3404
|
}
|
|
3278
3405
|
/**
|
|
3279
|
-
*
|
|
3280
|
-
*
|
|
3406
|
+
* Extract the machine-readable error fields that `makeApiRequest` attaches to
|
|
3407
|
+
* HTTP error instances.
|
|
3281
3408
|
*
|
|
3282
|
-
*
|
|
3283
|
-
*
|
|
3284
|
-
*
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
}
|
|
3288
|
-
/**
|
|
3289
|
-
* Extract the `responseBody` property that `makeApiRequest` attaches to
|
|
3290
|
-
* HTTP error instances when the server returns a JSON body.
|
|
3409
|
+
* Delegates to the shared extractor so this fall-through path reads the same
|
|
3410
|
+
* shape as the backend-code parsers: it unwraps the nested
|
|
3411
|
+
* `{ response: { status } }` envelope when present, otherwise returns the
|
|
3412
|
+
* top-level body. Routing both halves through one extractor keeps an
|
|
3413
|
+
* unmapped-code error from losing the server's `externalMessage`.
|
|
3291
3414
|
*
|
|
3292
3415
|
* @param error - The raw error from the HTTP layer
|
|
3293
|
-
* @returns The parsed body
|
|
3416
|
+
* @returns The parsed body as {@link ApiErrorResponseBody}, or undefined
|
|
3294
3417
|
* @throws Never. Returns `undefined` when the error does not carry a valid
|
|
3295
3418
|
* `responseBody`.
|
|
3296
3419
|
* @internal
|
|
3297
3420
|
*/ function extractResponseBody(error) {
|
|
3298
|
-
|
|
3299
|
-
return undefined;
|
|
3300
|
-
}
|
|
3301
|
-
return error.responseBody;
|
|
3421
|
+
return extractResponseBody$1(error);
|
|
3302
3422
|
}
|
|
3303
3423
|
/**
|
|
3304
3424
|
* Extract a field name from an {@link ApiFieldError}.
|
|
@@ -3407,46 +3527,6 @@ let activeRedactor = defaultMessageRedactor;
|
|
|
3407
3527
|
}
|
|
3408
3528
|
return topMessage ?? fieldDetail;
|
|
3409
3529
|
}
|
|
3410
|
-
/**
|
|
3411
|
-
* Extracts the HTTP status code from an error message.
|
|
3412
|
-
*
|
|
3413
|
-
* Attempts to parse HTTP status codes from common error message formats,
|
|
3414
|
-
* such as "HTTP 404" or "Status: 500".
|
|
3415
|
-
*
|
|
3416
|
-
* @param msg - The error message to extract from
|
|
3417
|
-
* @returns The extracted HTTP status code, or null if not found
|
|
3418
|
-
*
|
|
3419
|
-
* @example
|
|
3420
|
-
* ```typescript
|
|
3421
|
-
* const code = extractHttpStatusCode('HTTP 404')
|
|
3422
|
-
* // Returns: 404
|
|
3423
|
-
* ```
|
|
3424
|
-
*
|
|
3425
|
-
* @example
|
|
3426
|
-
* ```typescript
|
|
3427
|
-
* const code = extractHttpStatusCode('Status: 500 Internal Server Error')
|
|
3428
|
-
* // Returns: 500
|
|
3429
|
-
* ```
|
|
3430
|
-
*/ function extractHttpStatusCode(msg) {
|
|
3431
|
-
// Pattern: "HTTP 404" or "HTTP 404 - some message" or "Status: 404"
|
|
3432
|
-
const patterns = [
|
|
3433
|
-
/HTTP (\d{3})/i,
|
|
3434
|
-
/Status:\s*(\d{3})/i,
|
|
3435
|
-
/^(\d{3}) -/
|
|
3436
|
-
];
|
|
3437
|
-
for (const pattern of patterns){
|
|
3438
|
-
const match = pattern.exec(msg);
|
|
3439
|
-
const codeStr = match?.at(1);
|
|
3440
|
-
if (codeStr !== undefined) {
|
|
3441
|
-
const code = Number.parseInt(codeStr, 10);
|
|
3442
|
-
// Validate it's a valid HTTP status code
|
|
3443
|
-
if (code >= 100 && code < 600) {
|
|
3444
|
-
return code;
|
|
3445
|
-
}
|
|
3446
|
-
}
|
|
3447
|
-
}
|
|
3448
|
-
return null;
|
|
3449
|
-
}
|
|
3450
3530
|
|
|
3451
3531
|
/**
|
|
3452
3532
|
* @packageDocumentation
|
|
@@ -3702,6 +3782,11 @@ var EarnChain;
|
|
|
3702
3782
|
"Arc",
|
|
3703
3783
|
"Arc_Testnet"
|
|
3704
3784
|
];
|
|
3785
|
+
var BorrowChain;
|
|
3786
|
+
(function(BorrowChain) {
|
|
3787
|
+
BorrowChain["Arc"] = "Arc";
|
|
3788
|
+
BorrowChain["Arc_Testnet"] = "Arc_Testnet";
|
|
3789
|
+
})(BorrowChain || (BorrowChain = {}));
|
|
3705
3790
|
|
|
3706
3791
|
/**
|
|
3707
3792
|
* Helper function to define a chain with proper TypeScript typing.
|
|
@@ -4044,6 +4129,29 @@ var EarnChain;
|
|
|
4044
4129
|
* on EVM-compatible testnet chains. Use this address for testnet adapter
|
|
4045
4130
|
* integrations (e.g., Arc Testnet).
|
|
4046
4131
|
*/ const ADAPTER_CONTRACT_EVM_TESTNET = '0xBBD70b01a1CAbc96d5b7b129Ae1AAabdf50dd40b';
|
|
4132
|
+
/**
|
|
4133
|
+
* The sender-preserving batching contract on Arc (`Multicall3From`).
|
|
4134
|
+
*
|
|
4135
|
+
* This predeploy batches calls like the ubiquitous Multicall3, but routes each
|
|
4136
|
+
* subcall through Arc's `CallFrom` precompile
|
|
4137
|
+
* (`0x1800000000000000000000000000000000000003`), which executes on behalf of
|
|
4138
|
+
* the transaction's original sender. Every target therefore sees the calling
|
|
4139
|
+
* EOA as `msg.sender`, which is what makes a plain, un-upgraded EOA capable of
|
|
4140
|
+
* an atomic batch on Arc.
|
|
4141
|
+
*
|
|
4142
|
+
* Deployed at the same address on Arc Testnet and Arc Mainnet.
|
|
4143
|
+
*
|
|
4144
|
+
* @see https://docs.arc.io/arc/concepts/batched-transactions
|
|
4145
|
+
*/ const BATCHER_CONTRACT_ARC_TESTNET = '0x522fAf9A91c41c443c66765030741e4AaCe147D0';
|
|
4146
|
+
/**
|
|
4147
|
+
* The sender-preserving batching contract on Arc Mainnet (`Multicall3From`).
|
|
4148
|
+
*
|
|
4149
|
+
* See {@link BATCHER_CONTRACT_ARC_TESTNET} for how this contract works.
|
|
4150
|
+
* Requires Arc's Zero7 hardfork, which activates the `CallFrom` precompile
|
|
4151
|
+
* this contract depends on.
|
|
4152
|
+
*
|
|
4153
|
+
* @see https://docs.arc.io/arc/concepts/batched-transactions
|
|
4154
|
+
*/ const BATCHER_CONTRACT_ARC_MAINNET = '0x522fAf9A91c41c443c66765030741e4AaCe147D0';
|
|
4047
4155
|
/**
|
|
4048
4156
|
* The GatewayWallet contract address for EVM mainnet networks.
|
|
4049
4157
|
*
|
|
@@ -4193,7 +4301,10 @@ var EarnChain;
|
|
|
4193
4301
|
},
|
|
4194
4302
|
kitContracts: {
|
|
4195
4303
|
bridge: BRIDGE_CONTRACT_EVM_MAINNET,
|
|
4196
|
-
adapter: ADAPTER_CONTRACT_EVM_MAINNET
|
|
4304
|
+
adapter: ADAPTER_CONTRACT_EVM_MAINNET,
|
|
4305
|
+
// Arc is the only chain with a sender-preserving batcher, because it
|
|
4306
|
+
// takes a precompile rather than an ordinary contract to build one.
|
|
4307
|
+
senderPreservingBatcher: BATCHER_CONTRACT_ARC_MAINNET
|
|
4197
4308
|
},
|
|
4198
4309
|
gateway: {
|
|
4199
4310
|
domain: 26,
|
|
@@ -4264,7 +4375,10 @@ var EarnChain;
|
|
|
4264
4375
|
},
|
|
4265
4376
|
kitContracts: {
|
|
4266
4377
|
bridge: BRIDGE_CONTRACT_EVM_TESTNET,
|
|
4267
|
-
adapter: ADAPTER_CONTRACT_EVM_TESTNET
|
|
4378
|
+
adapter: ADAPTER_CONTRACT_EVM_TESTNET,
|
|
4379
|
+
// Arc is the only chain with a sender-preserving batcher, because it
|
|
4380
|
+
// takes a precompile rather than an ordinary contract to build one.
|
|
4381
|
+
senderPreservingBatcher: BATCHER_CONTRACT_ARC_TESTNET
|
|
4268
4382
|
},
|
|
4269
4383
|
gateway: {
|
|
4270
4384
|
domain: 26,
|
|
@@ -7939,7 +8053,8 @@ var Chains = {
|
|
|
7939
8053
|
cctpx: zod.z.any().optional(),
|
|
7940
8054
|
kitContracts: zod.z.object({
|
|
7941
8055
|
bridge: zod.z.string().optional(),
|
|
7942
|
-
adapter: zod.z.string().optional()
|
|
8056
|
+
adapter: zod.z.string().optional(),
|
|
8057
|
+
senderPreservingBatcher: zod.z.string().optional()
|
|
7943
8058
|
}).optional(),
|
|
7944
8059
|
gateway: gatewayConfigSchema.optional()
|
|
7945
8060
|
});
|
|
@@ -8135,6 +8250,38 @@ var Chains = {
|
|
|
8135
8250
|
message: `"${chain.chain}" is not a supported earn chain. ` + `Supported chains: ${Object.values(EarnChain).join(', ')}`
|
|
8136
8251
|
}))
|
|
8137
8252
|
]);
|
|
8253
|
+
/**
|
|
8254
|
+
* Zod schema for validating Borrow-specific chain identifiers.
|
|
8255
|
+
*
|
|
8256
|
+
* Validate that the provided chain is supported for Borrow Kit's loan
|
|
8257
|
+
* operations. Unlike {@link earnChainIdentifierSchema}, this includes Arc
|
|
8258
|
+
* mainnet as well as Arc Testnet.
|
|
8259
|
+
*
|
|
8260
|
+
* Accept a BorrowChain enum value, a matching string literal, or a
|
|
8261
|
+
* ChainDefinition for a supported chain.
|
|
8262
|
+
*
|
|
8263
|
+
* @example
|
|
8264
|
+
* ```typescript
|
|
8265
|
+
* import { borrowChainIdentifierSchema } from '@core/chains'
|
|
8266
|
+
* import { Arc, BorrowChain } from '@core/chains'
|
|
8267
|
+
*
|
|
8268
|
+
* // Valid
|
|
8269
|
+
* borrowChainIdentifierSchema.parse(BorrowChain.Arc)
|
|
8270
|
+
* borrowChainIdentifierSchema.parse('Arc')
|
|
8271
|
+
* borrowChainIdentifierSchema.parse(Arc)
|
|
8272
|
+
*
|
|
8273
|
+
* // Invalid (throws ZodError)
|
|
8274
|
+
* borrowChainIdentifierSchema.parse('Solana')
|
|
8275
|
+
* ```
|
|
8276
|
+
*/ zod.z.union([
|
|
8277
|
+
zod.z.string().refine((val)=>val in BorrowChain, (val)=>({
|
|
8278
|
+
message: `"${val}" is not a supported borrow chain. ` + `Supported chains: ${Object.values(BorrowChain).join(', ')}`
|
|
8279
|
+
})),
|
|
8280
|
+
zod.z.nativeEnum(BorrowChain),
|
|
8281
|
+
chainDefinitionSchema$2.refine((chain)=>chain.chain in BorrowChain, (chain)=>({
|
|
8282
|
+
message: `"${chain.chain}" is not a supported borrow chain. ` + `Supported chains: ${Object.values(BorrowChain).join(', ')}`
|
|
8283
|
+
}))
|
|
8284
|
+
]);
|
|
8138
8285
|
// Widened views so `.includes()` accepts arbitrary strings under strict TS.
|
|
8139
8286
|
const EARN_BRIDGE_SOURCE_CHAIN_VALUES = EARN_BRIDGE_SOURCE_BLOCKCHAINS;
|
|
8140
8287
|
const EARN_BRIDGE_DESTINATION_CHAIN_VALUES = EARN_BRIDGE_DESTINATION_BLOCKCHAINS;
|
|
@@ -8389,8 +8536,13 @@ const swapTokenEnumSchema = zod.z.enum([
|
|
|
8389
8536
|
*/ function resolveChainName(value) {
|
|
8390
8537
|
if (value == null) return undefined;
|
|
8391
8538
|
if (typeof value === 'string') return value;
|
|
8392
|
-
|
|
8393
|
-
|
|
8539
|
+
try {
|
|
8540
|
+
if (typeof value === 'object' && 'chain' in value) {
|
|
8541
|
+
const chain = value.chain;
|
|
8542
|
+
if (typeof chain === 'string') return chain;
|
|
8543
|
+
}
|
|
8544
|
+
} catch {
|
|
8545
|
+
return undefined;
|
|
8394
8546
|
}
|
|
8395
8547
|
return undefined;
|
|
8396
8548
|
}
|
|
@@ -8999,6 +9151,7 @@ const swapTokenEnumSchema = zod.z.enum([
|
|
|
8999
9151
|
* - Retries on rate limiting (429)
|
|
9000
9152
|
* - Does not retry on client errors (4xx, except 429)
|
|
9001
9153
|
* - Does not retry on validation failures
|
|
9154
|
+
* - Does not retry when `config.isTerminalError` marks the error terminal
|
|
9002
9155
|
*
|
|
9003
9156
|
* Each HTTP request is given a configurable timeout before it is aborted.
|
|
9004
9157
|
* Between retry attempts the wait depends on the `backoff` strategy. The
|
|
@@ -9078,7 +9231,10 @@ const swapTokenEnumSchema = zod.z.enum([
|
|
|
9078
9231
|
return await makeApiRequest(url, method, isValidType, effectiveConfig, body);
|
|
9079
9232
|
} catch (err) {
|
|
9080
9233
|
const error = err instanceof Error ? err : new Error(String(err));
|
|
9081
|
-
|
|
9234
|
+
// A caller-supplied predicate can mark an error terminal (e.g. a
|
|
9235
|
+
// deterministic 404) so it is surfaced immediately instead of burning
|
|
9236
|
+
// the retry budget on a non-transient answer.
|
|
9237
|
+
if (effectiveConfig.isTerminalError?.(error) === true || !isRetryableError(error)) {
|
|
9082
9238
|
throw error;
|
|
9083
9239
|
}
|
|
9084
9240
|
lastError = error;
|
|
@@ -9162,7 +9318,24 @@ const swapTokenEnumSchema = zod.z.enum([
|
|
|
9162
9318
|
* // After this call, TypeScript knows params is of type BridgeParams
|
|
9163
9319
|
* ```
|
|
9164
9320
|
*/ function validate(value, schema, context) {
|
|
9165
|
-
|
|
9321
|
+
let result;
|
|
9322
|
+
try {
|
|
9323
|
+
result = schema.safeParse(value);
|
|
9324
|
+
} catch (error) {
|
|
9325
|
+
throw new KitError({
|
|
9326
|
+
...InputError.VALIDATION_FAILED,
|
|
9327
|
+
recoverability: 'FATAL',
|
|
9328
|
+
message: `Invalid ${context}: reading a property threw`,
|
|
9329
|
+
cause: {
|
|
9330
|
+
trace: {
|
|
9331
|
+
validationErrors: [
|
|
9332
|
+
'Reading a property of the value threw'
|
|
9333
|
+
],
|
|
9334
|
+
originalError: error
|
|
9335
|
+
}
|
|
9336
|
+
}
|
|
9337
|
+
});
|
|
9338
|
+
}
|
|
9166
9339
|
if (!result.success) {
|
|
9167
9340
|
throw createValidationErrorFromZod(result.error, context);
|
|
9168
9341
|
}
|
|
@@ -11724,7 +11897,7 @@ function resolveOptions(options) {
|
|
|
11724
11897
|
}
|
|
11725
11898
|
|
|
11726
11899
|
var name = "@circle-fin/unified-balance-kit";
|
|
11727
|
-
var version$1 = "1.
|
|
11900
|
+
var version$1 = "1.8.0";
|
|
11728
11901
|
var pkg$1 = {
|
|
11729
11902
|
name: name,
|
|
11730
11903
|
version: version$1};
|
|
@@ -12433,6 +12606,12 @@ const READ_ACTION_KEY_SET = new Set(READ_ACTION_KEYS);
|
|
|
12433
12606
|
/** EIP-2612 standard permit */ PermitType[PermitType["EIP2612"] = 1] = "EIP2612";
|
|
12434
12607
|
})(PermitType || (PermitType = {}));
|
|
12435
12608
|
|
|
12609
|
+
var BorrowPermitType;
|
|
12610
|
+
(function(BorrowPermitType) {
|
|
12611
|
+
/** Tokens must be approved separately. */ BorrowPermitType[BorrowPermitType["NONE"] = 0] = "NONE";
|
|
12612
|
+
/** EIP-2612 permit calldata accompanies the token input. */ BorrowPermitType[BorrowPermitType["EIP2612"] = 1] = "EIP2612";
|
|
12613
|
+
})(BorrowPermitType || (BorrowPermitType = {}));
|
|
12614
|
+
|
|
12436
12615
|
/**
|
|
12437
12616
|
* Default clock implementation.
|
|
12438
12617
|
*
|
|
@@ -17200,7 +17379,7 @@ const abiParameterSchema = zod.z.object({
|
|
|
17200
17379
|
* const result = evmPreparedChainRequestParamsSchema.safeParse(params)
|
|
17201
17380
|
* ```
|
|
17202
17381
|
*/ zod.z.object({
|
|
17203
|
-
type: zod.z.literal('evm'),
|
|
17382
|
+
type: zod.z.literal('evm').optional(),
|
|
17204
17383
|
abi: abiSchema,
|
|
17205
17384
|
address: evmAddressSchema$1,
|
|
17206
17385
|
functionName: zod.z.string({
|
|
@@ -18501,7 +18680,7 @@ function groupKey(alloc) {
|
|
|
18501
18680
|
}
|
|
18502
18681
|
}
|
|
18503
18682
|
|
|
18504
|
-
const hexBytesSchema = zod.z.string().regex(/^0x([0-9a-fA-F]{2})*$/, {
|
|
18683
|
+
const hexBytesSchema$1 = zod.z.string().regex(/^0x([0-9a-fA-F]{2})*$/, {
|
|
18505
18684
|
message: 'value must be a 0x-prefixed even-length hex string'
|
|
18506
18685
|
}).transform((value)=>value);
|
|
18507
18686
|
zod.z.object({
|
|
@@ -18513,6 +18692,53 @@ zod.z.object({
|
|
|
18513
18692
|
amount: zod.z.bigint().refine((value)=>value >= 0n, {
|
|
18514
18693
|
message: 'amount must be a non-negative bigint'
|
|
18515
18694
|
}),
|
|
18695
|
+
permitCalldata: hexBytesSchema$1
|
|
18696
|
+
}))
|
|
18697
|
+
}).passthrough();
|
|
18698
|
+
|
|
18699
|
+
const hexBytesSchema = zod.z.string().regex(/^0x([0-9a-fA-F]{2})*$/, {
|
|
18700
|
+
message: 'value must be a 0x-prefixed even-length hex string'
|
|
18701
|
+
}).transform((value)=>value);
|
|
18702
|
+
function isNonNegativeBigIntLike(value) {
|
|
18703
|
+
try {
|
|
18704
|
+
return BigInt(value) >= 0n;
|
|
18705
|
+
} catch {
|
|
18706
|
+
return false;
|
|
18707
|
+
}
|
|
18708
|
+
}
|
|
18709
|
+
const uint256LikeSchema = zod.z.union([
|
|
18710
|
+
zod.z.string(),
|
|
18711
|
+
zod.z.bigint()
|
|
18712
|
+
]).refine(isNonNegativeBigIntLike, {
|
|
18713
|
+
message: 'value must be a non-negative bigint-compatible string or bigint'
|
|
18714
|
+
});
|
|
18715
|
+
const borrowExecutionParamsSchema = zod.z.object({
|
|
18716
|
+
instructions: zod.z.array(zod.z.object({
|
|
18717
|
+
target: evmAddressSchema$1,
|
|
18718
|
+
data: hexBytesSchema,
|
|
18719
|
+
value: uint256LikeSchema,
|
|
18720
|
+
tokenIn: evmAddressSchema$1,
|
|
18721
|
+
amountToApprove: uint256LikeSchema,
|
|
18722
|
+
tokenOut: evmAddressSchema$1,
|
|
18723
|
+
minTokenOut: uint256LikeSchema
|
|
18724
|
+
}).passthrough()).min(1),
|
|
18725
|
+
tokens: zod.z.array(zod.z.object({
|
|
18726
|
+
token: evmAddressSchema$1,
|
|
18727
|
+
beneficiary: evmAddressSchema$1
|
|
18728
|
+
}).passthrough()),
|
|
18729
|
+
execId: uint256LikeSchema,
|
|
18730
|
+
deadline: uint256LikeSchema,
|
|
18731
|
+
metadata: hexBytesSchema
|
|
18732
|
+
}).passthrough();
|
|
18733
|
+
zod.z.object({
|
|
18734
|
+
executeParams: borrowExecutionParamsSchema,
|
|
18735
|
+
signature: evmSignatureSchema,
|
|
18736
|
+
tokenInputs: zod.z.array(zod.z.object({
|
|
18737
|
+
permitType: zod.z.nativeEnum(BorrowPermitType),
|
|
18738
|
+
token: evmAddressSchema$1,
|
|
18739
|
+
amount: zod.z.bigint().refine((value)=>value >= 0n, {
|
|
18740
|
+
message: 'amount must be a non-negative bigint'
|
|
18741
|
+
}),
|
|
18516
18742
|
permitCalldata: hexBytesSchema
|
|
18517
18743
|
}))
|
|
18518
18744
|
}).passthrough();
|
|
@@ -29018,7 +29244,7 @@ const mockAttestationMessage = {
|
|
|
29018
29244
|
return step;
|
|
29019
29245
|
}
|
|
29020
29246
|
|
|
29021
|
-
var version = "1.14.
|
|
29247
|
+
var version = "1.14.1";
|
|
29022
29248
|
var pkg = {
|
|
29023
29249
|
version: version};
|
|
29024
29250
|
|
|
@@ -31354,9 +31580,9 @@ const allowanceStrategySchema = zod.z.enum([
|
|
|
31354
31580
|
/**
|
|
31355
31581
|
* Schema for validating estimateDeposit parameters.
|
|
31356
31582
|
*
|
|
31357
|
-
* Validates `from` (adapter + chain), `amount`,
|
|
31358
|
-
* optional `token`,
|
|
31359
|
-
* `allowanceStrategy`.
|
|
31583
|
+
* Validates `from` (adapter + chain), `amount`, optional `to.chain`
|
|
31584
|
+
* (defaults to Arc / Arc_Testnet for FAST), optional `token`,
|
|
31585
|
+
* `config.transferSpeed`, `depositAccount`, and `allowanceStrategy`.
|
|
31360
31586
|
*
|
|
31361
31587
|
* @example
|
|
31362
31588
|
* ```typescript
|
|
@@ -31457,12 +31683,12 @@ const allowanceStrategySchema = zod.z.enum([
|
|
|
31457
31683
|
*/ function validateDepositTransferConfig(params) {
|
|
31458
31684
|
const { from, to, config, quote, allowanceStrategy } = params;
|
|
31459
31685
|
const transferSpeed = config?.transferSpeed ?? 'STANDARD';
|
|
31460
|
-
if (
|
|
31461
|
-
throw createValidationFailedError$1('allowanceStrategy', allowanceStrategy, 'cannot be set
|
|
31686
|
+
if (transferSpeed === 'FAST' && allowanceStrategy !== undefined) {
|
|
31687
|
+
throw createValidationFailedError$1('allowanceStrategy', allowanceStrategy, 'cannot be set for FAST cross-chain deposits');
|
|
31462
31688
|
}
|
|
31463
31689
|
if (transferSpeed === 'FAST') {
|
|
31464
31690
|
if (to === undefined) {
|
|
31465
|
-
throw createValidationFailedError$1('to', undefined, 'required when transferSpeed is FAST');
|
|
31691
|
+
throw createValidationFailedError$1('to', undefined, 'required when transferSpeed is FAST and no default destination ' + 'can be derived from from.chain');
|
|
31466
31692
|
}
|
|
31467
31693
|
const dstChain = resolveChainIdentifier(to.chain);
|
|
31468
31694
|
if (!isGatewayFastDepositDestination(dstChain)) {
|
|
@@ -31521,8 +31747,9 @@ const allowanceStrategySchema = zod.z.enum([
|
|
|
31521
31747
|
}
|
|
31522
31748
|
/**
|
|
31523
31749
|
* Run all validations required for estimateDeposit: from context, amount,
|
|
31524
|
-
*
|
|
31525
|
-
* allowanceStrategy.
|
|
31750
|
+
* optional `to.chain`, optional token, config, depositAccount, and
|
|
31751
|
+
* allowanceStrategy. FAST params must already have the default destination
|
|
31752
|
+
* applied (see `applyDefaultFastDepositDestination`).
|
|
31526
31753
|
*
|
|
31527
31754
|
* @param params - The raw estimateDeposit params.
|
|
31528
31755
|
* @returns Nothing; throws on invalid params.
|
|
@@ -31595,6 +31822,90 @@ const allowanceStrategySchema = zod.z.enum([
|
|
|
31595
31822
|
}
|
|
31596
31823
|
}
|
|
31597
31824
|
|
|
31825
|
+
/**
|
|
31826
|
+
* Default destination chain for FAST cross-chain deposits, keyed by the
|
|
31827
|
+
* network of the source chain. Used when `config.transferSpeed` is `'FAST'`
|
|
31828
|
+
* and `to` is omitted.
|
|
31829
|
+
*/ const DEFAULT_FAST_DEPOSIT_DESTINATION = {
|
|
31830
|
+
mainnet: Blockchain.Arc,
|
|
31831
|
+
testnet: Blockchain.Arc_Testnet
|
|
31832
|
+
};
|
|
31833
|
+
/**
|
|
31834
|
+
* Resolve the destination chain for a deposit.
|
|
31835
|
+
*
|
|
31836
|
+
* Return `to` unchanged when it is set or when the transfer speed is not
|
|
31837
|
+
* `'FAST'`. Otherwise return the default FAST deposit destination for the
|
|
31838
|
+
* source chain's network — `Arc` for mainnet sources and `Arc_Testnet` for
|
|
31839
|
+
* testnet sources.
|
|
31840
|
+
*
|
|
31841
|
+
* @param params - Deposit params with `from`, optional `to`, and optional
|
|
31842
|
+
* `config`. `from.chain` must already be validated.
|
|
31843
|
+
* @returns The explicit or defaulted destination, or `undefined` for
|
|
31844
|
+
* STANDARD deposits.
|
|
31845
|
+
* @throws KitError If `from.chain` cannot be resolved.
|
|
31846
|
+
*
|
|
31847
|
+
* @example
|
|
31848
|
+
* ```typescript
|
|
31849
|
+
* const to = resolveFastDepositDestination({
|
|
31850
|
+
* from: { chain: 'Ethereum_Sepolia' },
|
|
31851
|
+
* config: { transferSpeed: 'FAST' },
|
|
31852
|
+
* })
|
|
31853
|
+
* // to → { chain: 'Arc_Testnet' }
|
|
31854
|
+
* ```
|
|
31855
|
+
*/ function resolveFastDepositDestination(params) {
|
|
31856
|
+
const { from, to, config } = params;
|
|
31857
|
+
if (to !== undefined || config?.transferSpeed !== 'FAST') {
|
|
31858
|
+
return to;
|
|
31859
|
+
}
|
|
31860
|
+
const srcChain = resolveChainIdentifier(from.chain);
|
|
31861
|
+
return {
|
|
31862
|
+
chain: srcChain.isTestnet ? DEFAULT_FAST_DEPOSIT_DESTINATION.testnet : DEFAULT_FAST_DEPOSIT_DESTINATION.mainnet
|
|
31863
|
+
};
|
|
31864
|
+
}
|
|
31865
|
+
/**
|
|
31866
|
+
* Return deposit params with the default FAST deposit destination applied.
|
|
31867
|
+
*
|
|
31868
|
+
* Call this at the top of every deposit entry point, before validation, so
|
|
31869
|
+
* all downstream logic (validation, routing, telemetry, and the estimate
|
|
31870
|
+
* result) sees an explicit `to` for every FAST deposit.
|
|
31871
|
+
*
|
|
31872
|
+
* When {@link resolveFastDepositDestination} yields a destination and `to`
|
|
31873
|
+
* is not set, return a shallow copy with `to` filled in. Otherwise return
|
|
31874
|
+
* the params unchanged. Safe to call more than once.
|
|
31875
|
+
*
|
|
31876
|
+
* Runs before validation, so it never throws: when `from.chain` cannot be
|
|
31877
|
+
* resolved (or `params` is malformed plain-JS input) the params are returned
|
|
31878
|
+
* unchanged and schema validation reports the error.
|
|
31879
|
+
*
|
|
31880
|
+
* @typeParam T - The deposit, depositFor, or estimateDeposit params type.
|
|
31881
|
+
* @param params - Raw (unvalidated) deposit params.
|
|
31882
|
+
* @returns Params with `to` set for every resolvable FAST deposit.
|
|
31883
|
+
*
|
|
31884
|
+
* @example
|
|
31885
|
+
* ```typescript
|
|
31886
|
+
* const resolved = applyDefaultFastDepositDestination({
|
|
31887
|
+
* from: { adapter, chain: 'Base' },
|
|
31888
|
+
* amount: '10',
|
|
31889
|
+
* config: { transferSpeed: 'FAST' },
|
|
31890
|
+
* })
|
|
31891
|
+
* // resolved.to → { chain: 'Arc' }
|
|
31892
|
+
* ```
|
|
31893
|
+
*/ function applyDefaultFastDepositDestination(params) {
|
|
31894
|
+
let to;
|
|
31895
|
+
try {
|
|
31896
|
+
to = resolveFastDepositDestination(params);
|
|
31897
|
+
} catch {
|
|
31898
|
+
// Unresolvable source chain — leave params as-is for validation to reject.
|
|
31899
|
+
return params;
|
|
31900
|
+
}
|
|
31901
|
+
if (to === undefined || to === params.to) {
|
|
31902
|
+
return params;
|
|
31903
|
+
}
|
|
31904
|
+
return {
|
|
31905
|
+
...params,
|
|
31906
|
+
to
|
|
31907
|
+
};
|
|
31908
|
+
}
|
|
31598
31909
|
async function resolveDepositParams(params) {
|
|
31599
31910
|
const chain = resolveChainIdentifier(params.from.chain);
|
|
31600
31911
|
params.from.adapter.validateChainSupport(chain);
|
|
@@ -31853,7 +32164,9 @@ function resolveGatewayExecutorContracts(srcChain, dstChain) {
|
|
|
31853
32164
|
* covers the amount) → burn → relay wait.
|
|
31854
32165
|
*
|
|
31855
32166
|
* @param context - Kit context (used for analytics telemetry emissions).
|
|
31856
|
-
* @param params - Deposit params
|
|
32167
|
+
* @param params - Deposit params with `to` set (explicitly or via
|
|
32168
|
+
* `applyDefaultFastDepositDestination`) and `to.chain` differing from
|
|
32169
|
+
* `from.chain`.
|
|
31857
32170
|
* @param depositAccount - Destination Gateway account to credit. When omitted
|
|
31858
32171
|
* (i.e. called from `deposit()`), the signer's own address is used.
|
|
31859
32172
|
* @returns Settled deposit result after Circle's relay has confirmed the mint.
|
|
@@ -32114,7 +32427,8 @@ function resolveGatewayExecutorContracts(srcChain, dstChain) {
|
|
|
32114
32427
|
* (token → `'USDC'`, allowanceStrategy → `'authorize'`), finds a provider,
|
|
32115
32428
|
* and delegates to the provider's deposit operation.
|
|
32116
32429
|
*
|
|
32117
|
-
* For cross-chain (FAST) deposits (when `
|
|
32430
|
+
* For cross-chain (FAST) deposits (when `config.transferSpeed` is `'FAST'`;
|
|
32431
|
+
* `to` defaults to Arc / Arc_Testnet when omitted): fetches or validates a
|
|
32118
32432
|
* fee quote, runs a preflight affordability check, submits the prepaid-FORWARD
|
|
32119
32433
|
* burn on the source chain, and waits for Circle's relay to confirm the mint
|
|
32120
32434
|
* on the destination. The caller's Gateway account is credited on the
|
|
@@ -32153,11 +32467,12 @@ function resolveGatewayExecutorContracts(srcChain, dstChain) {
|
|
|
32153
32467
|
* const crossResult = await deposit(context, { ...estimate, from: { adapter, chain: 'Ethereum_Sepolia' } })
|
|
32154
32468
|
* ```
|
|
32155
32469
|
*/ async function deposit(context, params) {
|
|
32156
|
-
|
|
32157
|
-
|
|
32158
|
-
|
|
32470
|
+
const normalizedParams = applyDefaultFastDepositDestination(params);
|
|
32471
|
+
assertDepositParams(normalizedParams);
|
|
32472
|
+
if (normalizedParams.to !== undefined) {
|
|
32473
|
+
return depositFastCrossChain(context, normalizedParams);
|
|
32159
32474
|
}
|
|
32160
|
-
const resolvedParams = await resolveDepositParams(
|
|
32475
|
+
const resolvedParams = await resolveDepositParams(normalizedParams);
|
|
32161
32476
|
const chain = resolvedParams.from.chain;
|
|
32162
32477
|
if (!isGatewayV1Supported(chain)) {
|
|
32163
32478
|
throw createUnsupportedRouteError(chain.name, chain.name);
|
|
@@ -32172,7 +32487,8 @@ function resolveGatewayExecutorContracts(srcChain, dstChain) {
|
|
|
32172
32487
|
* (token → `'USDC'`, allowanceStrategy → `'approve'`), finds a provider,
|
|
32173
32488
|
* and delegates to the provider's depositFor operation.
|
|
32174
32489
|
*
|
|
32175
|
-
* For cross-chain (FAST) deposits (when `
|
|
32490
|
+
* For cross-chain (FAST) deposits (when `config.transferSpeed` is `'FAST'`;
|
|
32491
|
+
* `to` defaults to Arc / Arc_Testnet when omitted): fetches or validates a
|
|
32176
32492
|
* fee quote, runs a preflight affordability check, submits the prepaid-FORWARD
|
|
32177
32493
|
* burn on the source chain, and waits for Circle's relay to confirm the mint.
|
|
32178
32494
|
* The `depositAccount` is credited on the destination chain.
|
|
@@ -32216,11 +32532,12 @@ function resolveGatewayExecutorContracts(srcChain, dstChain) {
|
|
|
32216
32532
|
* })
|
|
32217
32533
|
* ```
|
|
32218
32534
|
*/ async function depositFor(context, params) {
|
|
32219
|
-
|
|
32220
|
-
|
|
32221
|
-
|
|
32535
|
+
const normalizedParams = applyDefaultFastDepositDestination(params);
|
|
32536
|
+
assertDepositForParams(normalizedParams);
|
|
32537
|
+
if (normalizedParams.to !== undefined) {
|
|
32538
|
+
return depositFastCrossChain(context, normalizedParams, normalizedParams.depositAccount);
|
|
32222
32539
|
}
|
|
32223
|
-
const resolvedParams = await resolveDepositParams(
|
|
32540
|
+
const resolvedParams = await resolveDepositParams(normalizedParams);
|
|
32224
32541
|
const chain = resolvedParams.from.chain;
|
|
32225
32542
|
if (!isGatewayV1Supported(chain)) {
|
|
32226
32543
|
throw createUnsupportedRouteError(chain.name, chain.name);
|
|
@@ -32279,7 +32596,8 @@ async function estimateDepositImpl(context, params) {
|
|
|
32279
32596
|
fee: depositTotalGasFee
|
|
32280
32597
|
}, srcChain));
|
|
32281
32598
|
} else {
|
|
32282
|
-
//
|
|
32599
|
+
// applyDefaultFastDepositDestination + assertEstimateDepositParams
|
|
32600
|
+
// guarantee params.to is set on the FAST path
|
|
32283
32601
|
const { to } = params;
|
|
32284
32602
|
if (to === undefined) {
|
|
32285
32603
|
/* v8 ignore next 6 -- assertEstimateDepositParams guarantees to is set on the FAST path */ throw createValidationFailedError$1('to', undefined, 'required for FAST transfers');
|
|
@@ -32430,7 +32748,8 @@ async function estimateDepositImpl(context, params) {
|
|
|
32430
32748
|
*
|
|
32431
32749
|
* @param context - Kit context (used for analytics telemetry emissions).
|
|
32432
32750
|
* @param params - The estimate parameters: source context, amount, destination
|
|
32433
|
-
* chain, optional token, transfer
|
|
32751
|
+
* chain (defaults to Arc / Arc_Testnet for FAST), optional token, transfer
|
|
32752
|
+
* speed, and allowance strategy.
|
|
32434
32753
|
* @returns Promise resolving to an itemized fee estimate with an optional
|
|
32435
32754
|
* quote for FAST cross-chain transfers.
|
|
32436
32755
|
* @throws KitError If the wallet address cannot be resolved — wallet not connected
|
|
@@ -32463,8 +32782,9 @@ async function estimateDepositImpl(context, params) {
|
|
|
32463
32782
|
* const result = await deposit(context, { ...estimate, from: { adapter, chain: 'Ethereum_Sepolia' } })
|
|
32464
32783
|
* ```
|
|
32465
32784
|
*/ async function estimateDeposit(context, params) {
|
|
32466
|
-
|
|
32467
|
-
|
|
32785
|
+
const normalizedParams = applyDefaultFastDepositDestination(params);
|
|
32786
|
+
assertEstimateDepositParams(normalizedParams);
|
|
32787
|
+
return estimateDepositImpl(context, normalizedParams);
|
|
32468
32788
|
}
|
|
32469
32789
|
|
|
32470
32790
|
// The `as never` cast is required because `unifiedBalanceChainIdentifierSchema`
|
|
@@ -34038,6 +34358,10 @@ const removeFundParamsSchema = zod.z.object({
|
|
|
34038
34358
|
* All three telemetry call sites use this helper to keep the classification
|
|
34039
34359
|
* consistent.
|
|
34040
34360
|
*
|
|
34361
|
+
* Callers must pass params that have been through
|
|
34362
|
+
* `applyDefaultFastDepositDestination`, which sets `to` to Arc / Arc_Testnet
|
|
34363
|
+
* for FAST deposits that omit it.
|
|
34364
|
+
*
|
|
34041
34365
|
* @param params - Deposit or estimate-deposit params to inspect.
|
|
34042
34366
|
* @returns `true` when the transfer is a FAST cross-chain deposit.
|
|
34043
34367
|
*/ function isFastDeposit(params) {
|
|
@@ -34177,21 +34501,22 @@ const removeFundParamsSchema = zod.z.object({
|
|
|
34177
34501
|
*
|
|
34178
34502
|
* @see UnifiedBalanceKit.depositFor to deposit into another account.
|
|
34179
34503
|
*/ async deposit(params) {
|
|
34180
|
-
|
|
34181
|
-
|
|
34182
|
-
|
|
34183
|
-
|
|
34184
|
-
|
|
34185
|
-
|
|
34186
|
-
|
|
34187
|
-
|
|
34504
|
+
const normalizedParams = applyDefaultFastDepositDestination(params);
|
|
34505
|
+
if (isFastDeposit(normalizedParams)) {
|
|
34506
|
+
return withErrorTelemetry(async ()=>deposit(this.context, normalizedParams), EVENT_TYPES.FAST_DEPOSIT, this.telemetryConfig, {
|
|
34507
|
+
sourceChain: resolveChainName(normalizedParams.from?.chain),
|
|
34508
|
+
destinationChain: resolveChainName(normalizedParams.to?.chain),
|
|
34509
|
+
tokenIn: normalizedParams.token ?? 'USDC',
|
|
34510
|
+
amountIn: Number.parseFloat(normalizedParams.amount),
|
|
34511
|
+
...normalizedParams.quote !== undefined && {
|
|
34512
|
+
correlationId: hashSignedQuote(normalizedParams.quote)
|
|
34188
34513
|
}
|
|
34189
34514
|
});
|
|
34190
34515
|
}
|
|
34191
|
-
return withErrorTelemetry(async ()=>deposit(this.context,
|
|
34192
|
-
sourceChain: resolveChainName(
|
|
34193
|
-
tokenIn:
|
|
34194
|
-
amountIn: Number.parseFloat(
|
|
34516
|
+
return withErrorTelemetry(async ()=>deposit(this.context, normalizedParams), EVENT_TYPES.DEPOSIT, this.telemetryConfig, {
|
|
34517
|
+
sourceChain: resolveChainName(normalizedParams.from?.chain),
|
|
34518
|
+
tokenIn: normalizedParams.token ?? 'USDC',
|
|
34519
|
+
amountIn: Number.parseFloat(normalizedParams.amount)
|
|
34195
34520
|
});
|
|
34196
34521
|
}
|
|
34197
34522
|
/**
|
|
@@ -34203,24 +34528,25 @@ const removeFundParamsSchema = zod.z.object({
|
|
|
34203
34528
|
*
|
|
34204
34529
|
* @see UnifiedBalanceKit.deposit to deposit into your own account.
|
|
34205
34530
|
*/ async depositFor(params) {
|
|
34206
|
-
|
|
34531
|
+
const normalizedParams = applyDefaultFastDepositDestination(params);
|
|
34532
|
+
if (isFastDeposit(normalizedParams)) {
|
|
34207
34533
|
// Fast depositFor shares FAST_DEPOSIT event type with fast deposit — the
|
|
34208
34534
|
// success-path emitter in depositFastCrossChain uses a single event type
|
|
34209
34535
|
// for both entry points, so error telemetry mirrors that here.
|
|
34210
|
-
return withErrorTelemetry(async ()=>depositFor(this.context,
|
|
34211
|
-
sourceChain: resolveChainName(
|
|
34212
|
-
destinationChain: resolveChainName(
|
|
34213
|
-
tokenIn:
|
|
34214
|
-
amountIn: Number.parseFloat(
|
|
34215
|
-
...
|
|
34216
|
-
correlationId: hashSignedQuote(
|
|
34536
|
+
return withErrorTelemetry(async ()=>depositFor(this.context, normalizedParams), EVENT_TYPES.FAST_DEPOSIT, this.telemetryConfig, {
|
|
34537
|
+
sourceChain: resolveChainName(normalizedParams.from?.chain),
|
|
34538
|
+
destinationChain: resolveChainName(normalizedParams.to?.chain),
|
|
34539
|
+
tokenIn: normalizedParams.token ?? 'USDC',
|
|
34540
|
+
amountIn: Number.parseFloat(normalizedParams.amount),
|
|
34541
|
+
...normalizedParams.quote !== undefined && {
|
|
34542
|
+
correlationId: hashSignedQuote(normalizedParams.quote)
|
|
34217
34543
|
}
|
|
34218
34544
|
});
|
|
34219
34545
|
}
|
|
34220
|
-
return withErrorTelemetry(async ()=>depositFor(this.context,
|
|
34221
|
-
sourceChain: resolveChainName(
|
|
34222
|
-
tokenIn:
|
|
34223
|
-
amountIn: Number.parseFloat(
|
|
34546
|
+
return withErrorTelemetry(async ()=>depositFor(this.context, normalizedParams), EVENT_TYPES.DEPOSIT_FOR, this.telemetryConfig, {
|
|
34547
|
+
sourceChain: resolveChainName(normalizedParams.from?.chain),
|
|
34548
|
+
tokenIn: normalizedParams.token ?? 'USDC',
|
|
34549
|
+
amountIn: Number.parseFloat(normalizedParams.amount)
|
|
34224
34550
|
});
|
|
34225
34551
|
}
|
|
34226
34552
|
/**
|
|
@@ -34235,23 +34561,25 @@ const removeFundParamsSchema = zod.z.object({
|
|
|
34235
34561
|
* ```
|
|
34236
34562
|
*
|
|
34237
34563
|
* @param params - The estimate parameters including source context, amount,
|
|
34238
|
-
* destination chain
|
|
34564
|
+
* destination chain (defaults to Arc / Arc_Testnet for FAST), optional
|
|
34565
|
+
* transfer speed, and optional allowance strategy.
|
|
34239
34566
|
* @returns Promise resolving to an itemised fee breakdown.
|
|
34240
34567
|
*
|
|
34241
34568
|
* @see UnifiedBalanceKit.deposit to execute after estimating.
|
|
34242
34569
|
*/ async estimateDeposit(params) {
|
|
34243
|
-
|
|
34244
|
-
|
|
34245
|
-
|
|
34246
|
-
|
|
34247
|
-
|
|
34248
|
-
|
|
34570
|
+
const normalizedParams = applyDefaultFastDepositDestination(params);
|
|
34571
|
+
if (isFastDeposit(normalizedParams)) {
|
|
34572
|
+
return withErrorTelemetry(async ()=>estimateDeposit(this.context, normalizedParams), EVENT_TYPES.ESTIMATE_FAST_DEPOSIT, this.telemetryConfig, {
|
|
34573
|
+
sourceChain: resolveChainName(normalizedParams.from?.chain),
|
|
34574
|
+
destinationChain: resolveChainName(normalizedParams.to?.chain),
|
|
34575
|
+
tokenIn: normalizedParams.token ?? 'USDC',
|
|
34576
|
+
amountIn: Number.parseFloat(normalizedParams.amount)
|
|
34249
34577
|
});
|
|
34250
34578
|
}
|
|
34251
|
-
return withErrorTelemetry(async ()=>estimateDeposit(this.context,
|
|
34252
|
-
sourceChain: resolveChainName(
|
|
34253
|
-
tokenIn:
|
|
34254
|
-
amountIn: Number.parseFloat(
|
|
34579
|
+
return withErrorTelemetry(async ()=>estimateDeposit(this.context, normalizedParams), EVENT_TYPES.ESTIMATE_DEPOSIT, this.telemetryConfig, {
|
|
34580
|
+
sourceChain: resolveChainName(normalizedParams.from?.chain),
|
|
34581
|
+
tokenIn: normalizedParams.token ?? 'USDC',
|
|
34582
|
+
amountIn: Number.parseFloat(normalizedParams.amount)
|
|
34255
34583
|
});
|
|
34256
34584
|
}
|
|
34257
34585
|
/**
|
|
@@ -34620,7 +34948,8 @@ registerKit(`${pkg$1.name}/${pkg$1.version}`);
|
|
|
34620
34948
|
* {@link AppKitUnifiedBalance.depositFor}.
|
|
34621
34949
|
*
|
|
34622
34950
|
* @param params - Estimate details including the depositor context, amount,
|
|
34623
|
-
* destination chain, and optional
|
|
34951
|
+
* destination chain (defaults to Arc / Arc_Testnet for FAST), and optional
|
|
34952
|
+
* transfer speed.
|
|
34624
34953
|
* @returns Promise resolving to the itemised fee estimate.
|
|
34625
34954
|
* @throws {KitError} If the estimate parameters are invalid or the route is
|
|
34626
34955
|
* unsupported.
|