@circle-fin/app-kit 1.15.3 → 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 +53 -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 +1885 -276
- package/bridge.d.cts +86 -12
- package/bridge.d.mts +86 -12
- package/bridge.d.ts +86 -12
- package/bridge.mjs +1885 -276
- 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 +86 -12
- package/context.d.mts +86 -12
- package/context.d.ts +86 -12
- package/context.mjs +1 -0
- package/earn.cjs +4981 -3314
- package/earn.d.cts +1117 -981
- package/earn.d.mts +1117 -981
- package/earn.d.ts +1117 -981
- package/earn.mjs +4981 -3314
- package/estimateBridge.cjs +1883 -274
- package/estimateBridge.d.cts +86 -12
- package/estimateBridge.d.mts +86 -12
- package/estimateBridge.d.ts +86 -12
- package/estimateBridge.mjs +1883 -274
- package/estimateSwap.cjs +8554 -6931
- package/estimateSwap.d.cts +86 -12
- package/estimateSwap.d.mts +86 -12
- package/estimateSwap.d.ts +86 -12
- package/estimateSwap.mjs +8503 -6880
- package/index.cjs +30943 -18928
- package/index.d.cts +23051 -2742
- package/index.d.mts +23051 -2742
- package/index.d.ts +23051 -2742
- package/index.mjs +30884 -18922
- package/package.json +17 -7
- package/server.cjs +101 -6
- package/server.mjs +101 -6
- package/swap.cjs +8554 -6931
- package/swap.d.cts +86 -12
- package/swap.d.mts +86 -12
- package/swap.d.ts +86 -12
- package/swap.mjs +8503 -6880
- 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.mjs
CHANGED
|
@@ -1334,6 +1334,34 @@ let activeRedactor = defaultMessageRedactor;
|
|
|
1334
1334
|
return redactErrorMessage(String(error));
|
|
1335
1335
|
}
|
|
1336
1336
|
|
|
1337
|
+
/**
|
|
1338
|
+
* Render an object value for an error message without letting the rendering
|
|
1339
|
+
* itself throw.
|
|
1340
|
+
*
|
|
1341
|
+
* `JSON.stringify` rejects `BigInt` and circular structures, and a rejected
|
|
1342
|
+
* value is exactly the kind of thing a validation error is built from: an
|
|
1343
|
+
* on-chain read or a receipt log carries `bigint` fields, so serializing one
|
|
1344
|
+
* naively replaces the intended error with a `TypeError`.
|
|
1345
|
+
*
|
|
1346
|
+
* @param value - The value to render.
|
|
1347
|
+
* @returns A JSON string with `bigint` fields stringified, or
|
|
1348
|
+
* `'[unserializable object]'` if serialization still fails.
|
|
1349
|
+
* @throws Never; serialization failures are caught and rendered as a fallback string.
|
|
1350
|
+
* @example
|
|
1351
|
+
* ```typescript
|
|
1352
|
+
* import { describeObjectValue } from '@core/errors'
|
|
1353
|
+
*
|
|
1354
|
+
* describeObjectValue({ amount: 1n })
|
|
1355
|
+
* // '{"amount":"1"}'
|
|
1356
|
+
* ```
|
|
1357
|
+
*/ function describeObjectValue(value) {
|
|
1358
|
+
try {
|
|
1359
|
+
return JSON.stringify(value, (_key, entry)=>typeof entry === 'bigint' ? entry.toString() : entry);
|
|
1360
|
+
} catch {
|
|
1361
|
+
return '[unserializable object]';
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1337
1365
|
/**
|
|
1338
1366
|
* Creates error for network type mismatch between source and destination.
|
|
1339
1367
|
*
|
|
@@ -1562,7 +1590,7 @@ let activeRedactor = defaultMessageRedactor;
|
|
|
1562
1590
|
* // Message: "Validation failed for 'chainId': 999 - Unsupported chain ID"
|
|
1563
1591
|
*
|
|
1564
1592
|
* throw createValidationFailedError('config', { invalid: true }, 'Missing required properties')
|
|
1565
|
-
* // Message: "Validation failed for 'config':
|
|
1593
|
+
* // Message: "Validation failed for 'config': {"invalid":true} - Missing required properties"
|
|
1566
1594
|
* ```
|
|
1567
1595
|
*/ function createValidationFailedError$1(field, value, reason) {
|
|
1568
1596
|
// Convert value to string for display, handling different types appropriately
|
|
@@ -1570,7 +1598,7 @@ let activeRedactor = defaultMessageRedactor;
|
|
|
1570
1598
|
if (typeof value === 'string') {
|
|
1571
1599
|
valueString = `'${value}'`;
|
|
1572
1600
|
} else if (typeof value === 'object' && value !== null) {
|
|
1573
|
-
valueString =
|
|
1601
|
+
valueString = describeObjectValue(value);
|
|
1574
1602
|
} else {
|
|
1575
1603
|
valueString = String(value);
|
|
1576
1604
|
}
|
|
@@ -2969,6 +2997,105 @@ let activeRedactor = defaultMessageRedactor;
|
|
|
2969
2997
|
return chain;
|
|
2970
2998
|
}
|
|
2971
2999
|
|
|
3000
|
+
/**
|
|
3001
|
+
* Extracts the HTTP status code from an error message.
|
|
3002
|
+
*
|
|
3003
|
+
* Attempts to parse HTTP status codes from common error message formats,
|
|
3004
|
+
* such as "HTTP 404" or "Status: 500".
|
|
3005
|
+
*
|
|
3006
|
+
* Shared by `parseApiError` and the backend-error-code parsers that route on
|
|
3007
|
+
* status when no backend code is available, so all of them recognise the same
|
|
3008
|
+
* message shapes.
|
|
3009
|
+
*
|
|
3010
|
+
* @param msg - The error message to extract from
|
|
3011
|
+
* @returns The extracted HTTP status code, or null if not found
|
|
3012
|
+
*
|
|
3013
|
+
* @example
|
|
3014
|
+
* ```typescript
|
|
3015
|
+
* const code = extractHttpStatusCode('HTTP 404')
|
|
3016
|
+
* // Returns: 404
|
|
3017
|
+
* ```
|
|
3018
|
+
*
|
|
3019
|
+
* @example
|
|
3020
|
+
* ```typescript
|
|
3021
|
+
* const code = extractHttpStatusCode('Status: 500 Internal Server Error')
|
|
3022
|
+
* // Returns: 500
|
|
3023
|
+
* ```
|
|
3024
|
+
*
|
|
3025
|
+
* @internal
|
|
3026
|
+
*/ function extractHttpStatusCode(msg) {
|
|
3027
|
+
// Pattern: "HTTP 404" or "HTTP 404 - some message" or "Status: 404"
|
|
3028
|
+
const patterns = [
|
|
3029
|
+
/HTTP (\d{3})/i,
|
|
3030
|
+
/Status:\s*(\d{3})/i,
|
|
3031
|
+
/^(\d{3}) -/
|
|
3032
|
+
];
|
|
3033
|
+
for (const pattern of patterns){
|
|
3034
|
+
const match = pattern.exec(msg);
|
|
3035
|
+
const codeStr = match?.at(1);
|
|
3036
|
+
if (codeStr !== undefined) {
|
|
3037
|
+
const code = Number.parseInt(codeStr, 10);
|
|
3038
|
+
// Validate it's a valid HTTP status code
|
|
3039
|
+
if (code >= 100 && code < 600) {
|
|
3040
|
+
return code;
|
|
3041
|
+
}
|
|
3042
|
+
}
|
|
3043
|
+
}
|
|
3044
|
+
return null;
|
|
3045
|
+
}
|
|
3046
|
+
|
|
3047
|
+
/**
|
|
3048
|
+
* Type guard that narrows an unknown error to one carrying a non-null
|
|
3049
|
+
* object `responseBody` property (attached by `makeApiRequest`).
|
|
3050
|
+
*
|
|
3051
|
+
* Shared by backend-error-code parsers (`parseEarnApiError`,
|
|
3052
|
+
* `parseBorrowApiError`) so the narrowing logic lives in one place.
|
|
3053
|
+
*
|
|
3054
|
+
* @param error - The raw error from the HTTP layer
|
|
3055
|
+
* @returns `true` when `error.responseBody` is a non-null object
|
|
3056
|
+
* @internal
|
|
3057
|
+
*/ function hasResponseBody(error) {
|
|
3058
|
+
return typeof error === 'object' && error !== null && 'responseBody' in error && typeof error['responseBody'] === 'object' && error['responseBody'] !== null;
|
|
3059
|
+
}
|
|
3060
|
+
/**
|
|
3061
|
+
* Narrow an unknown value to a non-null object.
|
|
3062
|
+
*
|
|
3063
|
+
* @param value - The value to check
|
|
3064
|
+
* @returns `true` when `value` is a non-null object
|
|
3065
|
+
* @internal
|
|
3066
|
+
*/ function isRecord(value) {
|
|
3067
|
+
return typeof value === 'object' && value !== null;
|
|
3068
|
+
}
|
|
3069
|
+
/**
|
|
3070
|
+
* Read the machine-readable error fields (`code`, `message`,
|
|
3071
|
+
* `externalMessage`) that a Circle service attaches to an HTTP error body.
|
|
3072
|
+
*
|
|
3073
|
+
* `platform-common-go` serializes app-thrown errors under a nested envelope —
|
|
3074
|
+
* `{ response: { status: { code, message, externalMessage } } }` — for every
|
|
3075
|
+
* HTTP status, so this returns that inner `response.status` object when
|
|
3076
|
+
* present. It otherwise falls back to the top-level body so a flattened shape
|
|
3077
|
+
* (e.g. the stablecoin-kits-proxy) is still read. Callers read
|
|
3078
|
+
* `code` / `message` / `externalMessage` off the returned object uniformly.
|
|
3079
|
+
*
|
|
3080
|
+
* @param error - The raw error from the HTTP layer
|
|
3081
|
+
* @returns The error-status fields, or `undefined` when the error carries no
|
|
3082
|
+
* response body
|
|
3083
|
+
* @internal
|
|
3084
|
+
*/ function extractResponseBody$1(error) {
|
|
3085
|
+
if (!hasResponseBody(error)) {
|
|
3086
|
+
return undefined;
|
|
3087
|
+
}
|
|
3088
|
+
const body = error.responseBody;
|
|
3089
|
+
const response = body['response'];
|
|
3090
|
+
if (isRecord(response)) {
|
|
3091
|
+
const status = response['status'];
|
|
3092
|
+
if (isRecord(status)) {
|
|
3093
|
+
return status;
|
|
3094
|
+
}
|
|
3095
|
+
}
|
|
3096
|
+
return body;
|
|
3097
|
+
}
|
|
3098
|
+
|
|
2972
3099
|
/**
|
|
2973
3100
|
* Proxy-specific structured error codes carried in `responseBody.code`.
|
|
2974
3101
|
*
|
|
@@ -3269,29 +3396,22 @@ let activeRedactor = defaultMessageRedactor;
|
|
|
3269
3396
|
});
|
|
3270
3397
|
}
|
|
3271
3398
|
/**
|
|
3272
|
-
*
|
|
3273
|
-
*
|
|
3399
|
+
* Extract the machine-readable error fields that `makeApiRequest` attaches to
|
|
3400
|
+
* HTTP error instances.
|
|
3274
3401
|
*
|
|
3275
|
-
*
|
|
3276
|
-
*
|
|
3277
|
-
*
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
}
|
|
3281
|
-
/**
|
|
3282
|
-
* Extract the `responseBody` property that `makeApiRequest` attaches to
|
|
3283
|
-
* HTTP error instances when the server returns a JSON body.
|
|
3402
|
+
* Delegates to the shared extractor so this fall-through path reads the same
|
|
3403
|
+
* shape as the backend-code parsers: it unwraps the nested
|
|
3404
|
+
* `{ response: { status } }` envelope when present, otherwise returns the
|
|
3405
|
+
* top-level body. Routing both halves through one extractor keeps an
|
|
3406
|
+
* unmapped-code error from losing the server's `externalMessage`.
|
|
3284
3407
|
*
|
|
3285
3408
|
* @param error - The raw error from the HTTP layer
|
|
3286
|
-
* @returns The parsed body
|
|
3409
|
+
* @returns The parsed body as {@link ApiErrorResponseBody}, or undefined
|
|
3287
3410
|
* @throws Never. Returns `undefined` when the error does not carry a valid
|
|
3288
3411
|
* `responseBody`.
|
|
3289
3412
|
* @internal
|
|
3290
3413
|
*/ function extractResponseBody(error) {
|
|
3291
|
-
|
|
3292
|
-
return undefined;
|
|
3293
|
-
}
|
|
3294
|
-
return error.responseBody;
|
|
3414
|
+
return extractResponseBody$1(error);
|
|
3295
3415
|
}
|
|
3296
3416
|
/**
|
|
3297
3417
|
* Extract a field name from an {@link ApiFieldError}.
|
|
@@ -3400,46 +3520,6 @@ let activeRedactor = defaultMessageRedactor;
|
|
|
3400
3520
|
}
|
|
3401
3521
|
return topMessage ?? fieldDetail;
|
|
3402
3522
|
}
|
|
3403
|
-
/**
|
|
3404
|
-
* Extracts the HTTP status code from an error message.
|
|
3405
|
-
*
|
|
3406
|
-
* Attempts to parse HTTP status codes from common error message formats,
|
|
3407
|
-
* such as "HTTP 404" or "Status: 500".
|
|
3408
|
-
*
|
|
3409
|
-
* @param msg - The error message to extract from
|
|
3410
|
-
* @returns The extracted HTTP status code, or null if not found
|
|
3411
|
-
*
|
|
3412
|
-
* @example
|
|
3413
|
-
* ```typescript
|
|
3414
|
-
* const code = extractHttpStatusCode('HTTP 404')
|
|
3415
|
-
* // Returns: 404
|
|
3416
|
-
* ```
|
|
3417
|
-
*
|
|
3418
|
-
* @example
|
|
3419
|
-
* ```typescript
|
|
3420
|
-
* const code = extractHttpStatusCode('Status: 500 Internal Server Error')
|
|
3421
|
-
* // Returns: 500
|
|
3422
|
-
* ```
|
|
3423
|
-
*/ function extractHttpStatusCode(msg) {
|
|
3424
|
-
// Pattern: "HTTP 404" or "HTTP 404 - some message" or "Status: 404"
|
|
3425
|
-
const patterns = [
|
|
3426
|
-
/HTTP (\d{3})/i,
|
|
3427
|
-
/Status:\s*(\d{3})/i,
|
|
3428
|
-
/^(\d{3}) -/
|
|
3429
|
-
];
|
|
3430
|
-
for (const pattern of patterns){
|
|
3431
|
-
const match = pattern.exec(msg);
|
|
3432
|
-
const codeStr = match?.at(1);
|
|
3433
|
-
if (codeStr !== undefined) {
|
|
3434
|
-
const code = Number.parseInt(codeStr, 10);
|
|
3435
|
-
// Validate it's a valid HTTP status code
|
|
3436
|
-
if (code >= 100 && code < 600) {
|
|
3437
|
-
return code;
|
|
3438
|
-
}
|
|
3439
|
-
}
|
|
3440
|
-
}
|
|
3441
|
-
return null;
|
|
3442
|
-
}
|
|
3443
3523
|
|
|
3444
3524
|
/**
|
|
3445
3525
|
* @packageDocumentation
|
|
@@ -3695,6 +3775,11 @@ var EarnChain;
|
|
|
3695
3775
|
"Arc",
|
|
3696
3776
|
"Arc_Testnet"
|
|
3697
3777
|
];
|
|
3778
|
+
var BorrowChain;
|
|
3779
|
+
(function(BorrowChain) {
|
|
3780
|
+
BorrowChain["Arc"] = "Arc";
|
|
3781
|
+
BorrowChain["Arc_Testnet"] = "Arc_Testnet";
|
|
3782
|
+
})(BorrowChain || (BorrowChain = {}));
|
|
3698
3783
|
|
|
3699
3784
|
/**
|
|
3700
3785
|
* Helper function to define a chain with proper TypeScript typing.
|
|
@@ -4037,6 +4122,29 @@ var EarnChain;
|
|
|
4037
4122
|
* on EVM-compatible testnet chains. Use this address for testnet adapter
|
|
4038
4123
|
* integrations (e.g., Arc Testnet).
|
|
4039
4124
|
*/ const ADAPTER_CONTRACT_EVM_TESTNET = '0xBBD70b01a1CAbc96d5b7b129Ae1AAabdf50dd40b';
|
|
4125
|
+
/**
|
|
4126
|
+
* The sender-preserving batching contract on Arc (`Multicall3From`).
|
|
4127
|
+
*
|
|
4128
|
+
* This predeploy batches calls like the ubiquitous Multicall3, but routes each
|
|
4129
|
+
* subcall through Arc's `CallFrom` precompile
|
|
4130
|
+
* (`0x1800000000000000000000000000000000000003`), which executes on behalf of
|
|
4131
|
+
* the transaction's original sender. Every target therefore sees the calling
|
|
4132
|
+
* EOA as `msg.sender`, which is what makes a plain, un-upgraded EOA capable of
|
|
4133
|
+
* an atomic batch on Arc.
|
|
4134
|
+
*
|
|
4135
|
+
* Deployed at the same address on Arc Testnet and Arc Mainnet.
|
|
4136
|
+
*
|
|
4137
|
+
* @see https://docs.arc.io/arc/concepts/batched-transactions
|
|
4138
|
+
*/ const BATCHER_CONTRACT_ARC_TESTNET = '0x522fAf9A91c41c443c66765030741e4AaCe147D0';
|
|
4139
|
+
/**
|
|
4140
|
+
* The sender-preserving batching contract on Arc Mainnet (`Multicall3From`).
|
|
4141
|
+
*
|
|
4142
|
+
* See {@link BATCHER_CONTRACT_ARC_TESTNET} for how this contract works.
|
|
4143
|
+
* Requires Arc's Zero7 hardfork, which activates the `CallFrom` precompile
|
|
4144
|
+
* this contract depends on.
|
|
4145
|
+
*
|
|
4146
|
+
* @see https://docs.arc.io/arc/concepts/batched-transactions
|
|
4147
|
+
*/ const BATCHER_CONTRACT_ARC_MAINNET = '0x522fAf9A91c41c443c66765030741e4AaCe147D0';
|
|
4040
4148
|
/**
|
|
4041
4149
|
* The GatewayWallet contract address for EVM mainnet networks.
|
|
4042
4150
|
*
|
|
@@ -4186,7 +4294,10 @@ var EarnChain;
|
|
|
4186
4294
|
},
|
|
4187
4295
|
kitContracts: {
|
|
4188
4296
|
bridge: BRIDGE_CONTRACT_EVM_MAINNET,
|
|
4189
|
-
adapter: ADAPTER_CONTRACT_EVM_MAINNET
|
|
4297
|
+
adapter: ADAPTER_CONTRACT_EVM_MAINNET,
|
|
4298
|
+
// Arc is the only chain with a sender-preserving batcher, because it
|
|
4299
|
+
// takes a precompile rather than an ordinary contract to build one.
|
|
4300
|
+
senderPreservingBatcher: BATCHER_CONTRACT_ARC_MAINNET
|
|
4190
4301
|
},
|
|
4191
4302
|
gateway: {
|
|
4192
4303
|
domain: 26,
|
|
@@ -4257,7 +4368,10 @@ var EarnChain;
|
|
|
4257
4368
|
},
|
|
4258
4369
|
kitContracts: {
|
|
4259
4370
|
bridge: BRIDGE_CONTRACT_EVM_TESTNET,
|
|
4260
|
-
adapter: ADAPTER_CONTRACT_EVM_TESTNET
|
|
4371
|
+
adapter: ADAPTER_CONTRACT_EVM_TESTNET,
|
|
4372
|
+
// Arc is the only chain with a sender-preserving batcher, because it
|
|
4373
|
+
// takes a precompile rather than an ordinary contract to build one.
|
|
4374
|
+
senderPreservingBatcher: BATCHER_CONTRACT_ARC_TESTNET
|
|
4261
4375
|
},
|
|
4262
4376
|
gateway: {
|
|
4263
4377
|
domain: 26,
|
|
@@ -7932,7 +8046,8 @@ var Chains = /*#__PURE__*/Object.freeze({
|
|
|
7932
8046
|
cctpx: z.any().optional(),
|
|
7933
8047
|
kitContracts: z.object({
|
|
7934
8048
|
bridge: z.string().optional(),
|
|
7935
|
-
adapter: z.string().optional()
|
|
8049
|
+
adapter: z.string().optional(),
|
|
8050
|
+
senderPreservingBatcher: z.string().optional()
|
|
7936
8051
|
}).optional(),
|
|
7937
8052
|
gateway: gatewayConfigSchema.optional()
|
|
7938
8053
|
});
|
|
@@ -8128,6 +8243,38 @@ var Chains = /*#__PURE__*/Object.freeze({
|
|
|
8128
8243
|
message: `"${chain.chain}" is not a supported earn chain. ` + `Supported chains: ${Object.values(EarnChain).join(', ')}`
|
|
8129
8244
|
}))
|
|
8130
8245
|
]);
|
|
8246
|
+
/**
|
|
8247
|
+
* Zod schema for validating Borrow-specific chain identifiers.
|
|
8248
|
+
*
|
|
8249
|
+
* Validate that the provided chain is supported for Borrow Kit's loan
|
|
8250
|
+
* operations. Unlike {@link earnChainIdentifierSchema}, this includes Arc
|
|
8251
|
+
* mainnet as well as Arc Testnet.
|
|
8252
|
+
*
|
|
8253
|
+
* Accept a BorrowChain enum value, a matching string literal, or a
|
|
8254
|
+
* ChainDefinition for a supported chain.
|
|
8255
|
+
*
|
|
8256
|
+
* @example
|
|
8257
|
+
* ```typescript
|
|
8258
|
+
* import { borrowChainIdentifierSchema } from '@core/chains'
|
|
8259
|
+
* import { Arc, BorrowChain } from '@core/chains'
|
|
8260
|
+
*
|
|
8261
|
+
* // Valid
|
|
8262
|
+
* borrowChainIdentifierSchema.parse(BorrowChain.Arc)
|
|
8263
|
+
* borrowChainIdentifierSchema.parse('Arc')
|
|
8264
|
+
* borrowChainIdentifierSchema.parse(Arc)
|
|
8265
|
+
*
|
|
8266
|
+
* // Invalid (throws ZodError)
|
|
8267
|
+
* borrowChainIdentifierSchema.parse('Solana')
|
|
8268
|
+
* ```
|
|
8269
|
+
*/ z.union([
|
|
8270
|
+
z.string().refine((val)=>val in BorrowChain, (val)=>({
|
|
8271
|
+
message: `"${val}" is not a supported borrow chain. ` + `Supported chains: ${Object.values(BorrowChain).join(', ')}`
|
|
8272
|
+
})),
|
|
8273
|
+
z.nativeEnum(BorrowChain),
|
|
8274
|
+
chainDefinitionSchema$2.refine((chain)=>chain.chain in BorrowChain, (chain)=>({
|
|
8275
|
+
message: `"${chain.chain}" is not a supported borrow chain. ` + `Supported chains: ${Object.values(BorrowChain).join(', ')}`
|
|
8276
|
+
}))
|
|
8277
|
+
]);
|
|
8131
8278
|
// Widened views so `.includes()` accepts arbitrary strings under strict TS.
|
|
8132
8279
|
const EARN_BRIDGE_SOURCE_CHAIN_VALUES = EARN_BRIDGE_SOURCE_BLOCKCHAINS;
|
|
8133
8280
|
const EARN_BRIDGE_DESTINATION_CHAIN_VALUES = EARN_BRIDGE_DESTINATION_BLOCKCHAINS;
|
|
@@ -8382,8 +8529,13 @@ const swapTokenEnumSchema = z.enum([
|
|
|
8382
8529
|
*/ function resolveChainName(value) {
|
|
8383
8530
|
if (value == null) return undefined;
|
|
8384
8531
|
if (typeof value === 'string') return value;
|
|
8385
|
-
|
|
8386
|
-
|
|
8532
|
+
try {
|
|
8533
|
+
if (typeof value === 'object' && 'chain' in value) {
|
|
8534
|
+
const chain = value.chain;
|
|
8535
|
+
if (typeof chain === 'string') return chain;
|
|
8536
|
+
}
|
|
8537
|
+
} catch {
|
|
8538
|
+
return undefined;
|
|
8387
8539
|
}
|
|
8388
8540
|
return undefined;
|
|
8389
8541
|
}
|
|
@@ -8992,6 +9144,7 @@ const swapTokenEnumSchema = z.enum([
|
|
|
8992
9144
|
* - Retries on rate limiting (429)
|
|
8993
9145
|
* - Does not retry on client errors (4xx, except 429)
|
|
8994
9146
|
* - Does not retry on validation failures
|
|
9147
|
+
* - Does not retry when `config.isTerminalError` marks the error terminal
|
|
8995
9148
|
*
|
|
8996
9149
|
* Each HTTP request is given a configurable timeout before it is aborted.
|
|
8997
9150
|
* Between retry attempts the wait depends on the `backoff` strategy. The
|
|
@@ -9071,7 +9224,10 @@ const swapTokenEnumSchema = z.enum([
|
|
|
9071
9224
|
return await makeApiRequest(url, method, isValidType, effectiveConfig, body);
|
|
9072
9225
|
} catch (err) {
|
|
9073
9226
|
const error = err instanceof Error ? err : new Error(String(err));
|
|
9074
|
-
|
|
9227
|
+
// A caller-supplied predicate can mark an error terminal (e.g. a
|
|
9228
|
+
// deterministic 404) so it is surfaced immediately instead of burning
|
|
9229
|
+
// the retry budget on a non-transient answer.
|
|
9230
|
+
if (effectiveConfig.isTerminalError?.(error) === true || !isRetryableError(error)) {
|
|
9075
9231
|
throw error;
|
|
9076
9232
|
}
|
|
9077
9233
|
lastError = error;
|
|
@@ -9155,7 +9311,24 @@ const swapTokenEnumSchema = z.enum([
|
|
|
9155
9311
|
* // After this call, TypeScript knows params is of type BridgeParams
|
|
9156
9312
|
* ```
|
|
9157
9313
|
*/ function validate(value, schema, context) {
|
|
9158
|
-
|
|
9314
|
+
let result;
|
|
9315
|
+
try {
|
|
9316
|
+
result = schema.safeParse(value);
|
|
9317
|
+
} catch (error) {
|
|
9318
|
+
throw new KitError({
|
|
9319
|
+
...InputError.VALIDATION_FAILED,
|
|
9320
|
+
recoverability: 'FATAL',
|
|
9321
|
+
message: `Invalid ${context}: reading a property threw`,
|
|
9322
|
+
cause: {
|
|
9323
|
+
trace: {
|
|
9324
|
+
validationErrors: [
|
|
9325
|
+
'Reading a property of the value threw'
|
|
9326
|
+
],
|
|
9327
|
+
originalError: error
|
|
9328
|
+
}
|
|
9329
|
+
}
|
|
9330
|
+
});
|
|
9331
|
+
}
|
|
9159
9332
|
if (!result.success) {
|
|
9160
9333
|
throw createValidationErrorFromZod(result.error, context);
|
|
9161
9334
|
}
|
|
@@ -11717,7 +11890,7 @@ function resolveOptions(options) {
|
|
|
11717
11890
|
}
|
|
11718
11891
|
|
|
11719
11892
|
var name = "@circle-fin/unified-balance-kit";
|
|
11720
|
-
var version$1 = "1.
|
|
11893
|
+
var version$1 = "1.8.0";
|
|
11721
11894
|
var pkg$1 = {
|
|
11722
11895
|
name: name,
|
|
11723
11896
|
version: version$1};
|
|
@@ -12426,6 +12599,12 @@ const READ_ACTION_KEY_SET = new Set(READ_ACTION_KEYS);
|
|
|
12426
12599
|
/** EIP-2612 standard permit */ PermitType[PermitType["EIP2612"] = 1] = "EIP2612";
|
|
12427
12600
|
})(PermitType || (PermitType = {}));
|
|
12428
12601
|
|
|
12602
|
+
var BorrowPermitType;
|
|
12603
|
+
(function(BorrowPermitType) {
|
|
12604
|
+
/** Tokens must be approved separately. */ BorrowPermitType[BorrowPermitType["NONE"] = 0] = "NONE";
|
|
12605
|
+
/** EIP-2612 permit calldata accompanies the token input. */ BorrowPermitType[BorrowPermitType["EIP2612"] = 1] = "EIP2612";
|
|
12606
|
+
})(BorrowPermitType || (BorrowPermitType = {}));
|
|
12607
|
+
|
|
12429
12608
|
/**
|
|
12430
12609
|
* Default clock implementation.
|
|
12431
12610
|
*
|
|
@@ -17193,7 +17372,7 @@ const abiParameterSchema = z.object({
|
|
|
17193
17372
|
* const result = evmPreparedChainRequestParamsSchema.safeParse(params)
|
|
17194
17373
|
* ```
|
|
17195
17374
|
*/ z.object({
|
|
17196
|
-
type: z.literal('evm'),
|
|
17375
|
+
type: z.literal('evm').optional(),
|
|
17197
17376
|
abi: abiSchema,
|
|
17198
17377
|
address: evmAddressSchema$1,
|
|
17199
17378
|
functionName: z.string({
|
|
@@ -18494,7 +18673,7 @@ function groupKey(alloc) {
|
|
|
18494
18673
|
}
|
|
18495
18674
|
}
|
|
18496
18675
|
|
|
18497
|
-
const hexBytesSchema = z.string().regex(/^0x([0-9a-fA-F]{2})*$/, {
|
|
18676
|
+
const hexBytesSchema$1 = z.string().regex(/^0x([0-9a-fA-F]{2})*$/, {
|
|
18498
18677
|
message: 'value must be a 0x-prefixed even-length hex string'
|
|
18499
18678
|
}).transform((value)=>value);
|
|
18500
18679
|
z.object({
|
|
@@ -18506,6 +18685,53 @@ z.object({
|
|
|
18506
18685
|
amount: z.bigint().refine((value)=>value >= 0n, {
|
|
18507
18686
|
message: 'amount must be a non-negative bigint'
|
|
18508
18687
|
}),
|
|
18688
|
+
permitCalldata: hexBytesSchema$1
|
|
18689
|
+
}))
|
|
18690
|
+
}).passthrough();
|
|
18691
|
+
|
|
18692
|
+
const hexBytesSchema = z.string().regex(/^0x([0-9a-fA-F]{2})*$/, {
|
|
18693
|
+
message: 'value must be a 0x-prefixed even-length hex string'
|
|
18694
|
+
}).transform((value)=>value);
|
|
18695
|
+
function isNonNegativeBigIntLike(value) {
|
|
18696
|
+
try {
|
|
18697
|
+
return BigInt(value) >= 0n;
|
|
18698
|
+
} catch {
|
|
18699
|
+
return false;
|
|
18700
|
+
}
|
|
18701
|
+
}
|
|
18702
|
+
const uint256LikeSchema = z.union([
|
|
18703
|
+
z.string(),
|
|
18704
|
+
z.bigint()
|
|
18705
|
+
]).refine(isNonNegativeBigIntLike, {
|
|
18706
|
+
message: 'value must be a non-negative bigint-compatible string or bigint'
|
|
18707
|
+
});
|
|
18708
|
+
const borrowExecutionParamsSchema = z.object({
|
|
18709
|
+
instructions: z.array(z.object({
|
|
18710
|
+
target: evmAddressSchema$1,
|
|
18711
|
+
data: hexBytesSchema,
|
|
18712
|
+
value: uint256LikeSchema,
|
|
18713
|
+
tokenIn: evmAddressSchema$1,
|
|
18714
|
+
amountToApprove: uint256LikeSchema,
|
|
18715
|
+
tokenOut: evmAddressSchema$1,
|
|
18716
|
+
minTokenOut: uint256LikeSchema
|
|
18717
|
+
}).passthrough()).min(1),
|
|
18718
|
+
tokens: z.array(z.object({
|
|
18719
|
+
token: evmAddressSchema$1,
|
|
18720
|
+
beneficiary: evmAddressSchema$1
|
|
18721
|
+
}).passthrough()),
|
|
18722
|
+
execId: uint256LikeSchema,
|
|
18723
|
+
deadline: uint256LikeSchema,
|
|
18724
|
+
metadata: hexBytesSchema
|
|
18725
|
+
}).passthrough();
|
|
18726
|
+
z.object({
|
|
18727
|
+
executeParams: borrowExecutionParamsSchema,
|
|
18728
|
+
signature: evmSignatureSchema,
|
|
18729
|
+
tokenInputs: z.array(z.object({
|
|
18730
|
+
permitType: z.nativeEnum(BorrowPermitType),
|
|
18731
|
+
token: evmAddressSchema$1,
|
|
18732
|
+
amount: z.bigint().refine((value)=>value >= 0n, {
|
|
18733
|
+
message: 'amount must be a non-negative bigint'
|
|
18734
|
+
}),
|
|
18509
18735
|
permitCalldata: hexBytesSchema
|
|
18510
18736
|
}))
|
|
18511
18737
|
}).passthrough();
|
|
@@ -29011,7 +29237,7 @@ const mockAttestationMessage = {
|
|
|
29011
29237
|
return step;
|
|
29012
29238
|
}
|
|
29013
29239
|
|
|
29014
|
-
var version = "1.14.
|
|
29240
|
+
var version = "1.14.1";
|
|
29015
29241
|
var pkg = {
|
|
29016
29242
|
version: version};
|
|
29017
29243
|
|
|
@@ -31347,9 +31573,9 @@ const allowanceStrategySchema = z.enum([
|
|
|
31347
31573
|
/**
|
|
31348
31574
|
* Schema for validating estimateDeposit parameters.
|
|
31349
31575
|
*
|
|
31350
|
-
* Validates `from` (adapter + chain), `amount`,
|
|
31351
|
-
* optional `token`,
|
|
31352
|
-
* `allowanceStrategy`.
|
|
31576
|
+
* Validates `from` (adapter + chain), `amount`, optional `to.chain`
|
|
31577
|
+
* (defaults to Arc / Arc_Testnet for FAST), optional `token`,
|
|
31578
|
+
* `config.transferSpeed`, `depositAccount`, and `allowanceStrategy`.
|
|
31353
31579
|
*
|
|
31354
31580
|
* @example
|
|
31355
31581
|
* ```typescript
|
|
@@ -31450,12 +31676,12 @@ const allowanceStrategySchema = z.enum([
|
|
|
31450
31676
|
*/ function validateDepositTransferConfig(params) {
|
|
31451
31677
|
const { from, to, config, quote, allowanceStrategy } = params;
|
|
31452
31678
|
const transferSpeed = config?.transferSpeed ?? 'STANDARD';
|
|
31453
|
-
if (
|
|
31454
|
-
throw createValidationFailedError$1('allowanceStrategy', allowanceStrategy, 'cannot be set
|
|
31679
|
+
if (transferSpeed === 'FAST' && allowanceStrategy !== undefined) {
|
|
31680
|
+
throw createValidationFailedError$1('allowanceStrategy', allowanceStrategy, 'cannot be set for FAST cross-chain deposits');
|
|
31455
31681
|
}
|
|
31456
31682
|
if (transferSpeed === 'FAST') {
|
|
31457
31683
|
if (to === undefined) {
|
|
31458
|
-
throw createValidationFailedError$1('to', undefined, 'required when transferSpeed is FAST');
|
|
31684
|
+
throw createValidationFailedError$1('to', undefined, 'required when transferSpeed is FAST and no default destination ' + 'can be derived from from.chain');
|
|
31459
31685
|
}
|
|
31460
31686
|
const dstChain = resolveChainIdentifier(to.chain);
|
|
31461
31687
|
if (!isGatewayFastDepositDestination(dstChain)) {
|
|
@@ -31514,8 +31740,9 @@ const allowanceStrategySchema = z.enum([
|
|
|
31514
31740
|
}
|
|
31515
31741
|
/**
|
|
31516
31742
|
* Run all validations required for estimateDeposit: from context, amount,
|
|
31517
|
-
*
|
|
31518
|
-
* allowanceStrategy.
|
|
31743
|
+
* optional `to.chain`, optional token, config, depositAccount, and
|
|
31744
|
+
* allowanceStrategy. FAST params must already have the default destination
|
|
31745
|
+
* applied (see `applyDefaultFastDepositDestination`).
|
|
31519
31746
|
*
|
|
31520
31747
|
* @param params - The raw estimateDeposit params.
|
|
31521
31748
|
* @returns Nothing; throws on invalid params.
|
|
@@ -31588,6 +31815,90 @@ const allowanceStrategySchema = z.enum([
|
|
|
31588
31815
|
}
|
|
31589
31816
|
}
|
|
31590
31817
|
|
|
31818
|
+
/**
|
|
31819
|
+
* Default destination chain for FAST cross-chain deposits, keyed by the
|
|
31820
|
+
* network of the source chain. Used when `config.transferSpeed` is `'FAST'`
|
|
31821
|
+
* and `to` is omitted.
|
|
31822
|
+
*/ const DEFAULT_FAST_DEPOSIT_DESTINATION = {
|
|
31823
|
+
mainnet: Blockchain.Arc,
|
|
31824
|
+
testnet: Blockchain.Arc_Testnet
|
|
31825
|
+
};
|
|
31826
|
+
/**
|
|
31827
|
+
* Resolve the destination chain for a deposit.
|
|
31828
|
+
*
|
|
31829
|
+
* Return `to` unchanged when it is set or when the transfer speed is not
|
|
31830
|
+
* `'FAST'`. Otherwise return the default FAST deposit destination for the
|
|
31831
|
+
* source chain's network — `Arc` for mainnet sources and `Arc_Testnet` for
|
|
31832
|
+
* testnet sources.
|
|
31833
|
+
*
|
|
31834
|
+
* @param params - Deposit params with `from`, optional `to`, and optional
|
|
31835
|
+
* `config`. `from.chain` must already be validated.
|
|
31836
|
+
* @returns The explicit or defaulted destination, or `undefined` for
|
|
31837
|
+
* STANDARD deposits.
|
|
31838
|
+
* @throws KitError If `from.chain` cannot be resolved.
|
|
31839
|
+
*
|
|
31840
|
+
* @example
|
|
31841
|
+
* ```typescript
|
|
31842
|
+
* const to = resolveFastDepositDestination({
|
|
31843
|
+
* from: { chain: 'Ethereum_Sepolia' },
|
|
31844
|
+
* config: { transferSpeed: 'FAST' },
|
|
31845
|
+
* })
|
|
31846
|
+
* // to → { chain: 'Arc_Testnet' }
|
|
31847
|
+
* ```
|
|
31848
|
+
*/ function resolveFastDepositDestination(params) {
|
|
31849
|
+
const { from, to, config } = params;
|
|
31850
|
+
if (to !== undefined || config?.transferSpeed !== 'FAST') {
|
|
31851
|
+
return to;
|
|
31852
|
+
}
|
|
31853
|
+
const srcChain = resolveChainIdentifier(from.chain);
|
|
31854
|
+
return {
|
|
31855
|
+
chain: srcChain.isTestnet ? DEFAULT_FAST_DEPOSIT_DESTINATION.testnet : DEFAULT_FAST_DEPOSIT_DESTINATION.mainnet
|
|
31856
|
+
};
|
|
31857
|
+
}
|
|
31858
|
+
/**
|
|
31859
|
+
* Return deposit params with the default FAST deposit destination applied.
|
|
31860
|
+
*
|
|
31861
|
+
* Call this at the top of every deposit entry point, before validation, so
|
|
31862
|
+
* all downstream logic (validation, routing, telemetry, and the estimate
|
|
31863
|
+
* result) sees an explicit `to` for every FAST deposit.
|
|
31864
|
+
*
|
|
31865
|
+
* When {@link resolveFastDepositDestination} yields a destination and `to`
|
|
31866
|
+
* is not set, return a shallow copy with `to` filled in. Otherwise return
|
|
31867
|
+
* the params unchanged. Safe to call more than once.
|
|
31868
|
+
*
|
|
31869
|
+
* Runs before validation, so it never throws: when `from.chain` cannot be
|
|
31870
|
+
* resolved (or `params` is malformed plain-JS input) the params are returned
|
|
31871
|
+
* unchanged and schema validation reports the error.
|
|
31872
|
+
*
|
|
31873
|
+
* @typeParam T - The deposit, depositFor, or estimateDeposit params type.
|
|
31874
|
+
* @param params - Raw (unvalidated) deposit params.
|
|
31875
|
+
* @returns Params with `to` set for every resolvable FAST deposit.
|
|
31876
|
+
*
|
|
31877
|
+
* @example
|
|
31878
|
+
* ```typescript
|
|
31879
|
+
* const resolved = applyDefaultFastDepositDestination({
|
|
31880
|
+
* from: { adapter, chain: 'Base' },
|
|
31881
|
+
* amount: '10',
|
|
31882
|
+
* config: { transferSpeed: 'FAST' },
|
|
31883
|
+
* })
|
|
31884
|
+
* // resolved.to → { chain: 'Arc' }
|
|
31885
|
+
* ```
|
|
31886
|
+
*/ function applyDefaultFastDepositDestination(params) {
|
|
31887
|
+
let to;
|
|
31888
|
+
try {
|
|
31889
|
+
to = resolveFastDepositDestination(params);
|
|
31890
|
+
} catch {
|
|
31891
|
+
// Unresolvable source chain — leave params as-is for validation to reject.
|
|
31892
|
+
return params;
|
|
31893
|
+
}
|
|
31894
|
+
if (to === undefined || to === params.to) {
|
|
31895
|
+
return params;
|
|
31896
|
+
}
|
|
31897
|
+
return {
|
|
31898
|
+
...params,
|
|
31899
|
+
to
|
|
31900
|
+
};
|
|
31901
|
+
}
|
|
31591
31902
|
async function resolveDepositParams(params) {
|
|
31592
31903
|
const chain = resolveChainIdentifier(params.from.chain);
|
|
31593
31904
|
params.from.adapter.validateChainSupport(chain);
|
|
@@ -31846,7 +32157,9 @@ function resolveGatewayExecutorContracts(srcChain, dstChain) {
|
|
|
31846
32157
|
* covers the amount) → burn → relay wait.
|
|
31847
32158
|
*
|
|
31848
32159
|
* @param context - Kit context (used for analytics telemetry emissions).
|
|
31849
|
-
* @param params - Deposit params
|
|
32160
|
+
* @param params - Deposit params with `to` set (explicitly or via
|
|
32161
|
+
* `applyDefaultFastDepositDestination`) and `to.chain` differing from
|
|
32162
|
+
* `from.chain`.
|
|
31850
32163
|
* @param depositAccount - Destination Gateway account to credit. When omitted
|
|
31851
32164
|
* (i.e. called from `deposit()`), the signer's own address is used.
|
|
31852
32165
|
* @returns Settled deposit result after Circle's relay has confirmed the mint.
|
|
@@ -32107,7 +32420,8 @@ function resolveGatewayExecutorContracts(srcChain, dstChain) {
|
|
|
32107
32420
|
* (token → `'USDC'`, allowanceStrategy → `'authorize'`), finds a provider,
|
|
32108
32421
|
* and delegates to the provider's deposit operation.
|
|
32109
32422
|
*
|
|
32110
|
-
* For cross-chain (FAST) deposits (when `
|
|
32423
|
+
* For cross-chain (FAST) deposits (when `config.transferSpeed` is `'FAST'`;
|
|
32424
|
+
* `to` defaults to Arc / Arc_Testnet when omitted): fetches or validates a
|
|
32111
32425
|
* fee quote, runs a preflight affordability check, submits the prepaid-FORWARD
|
|
32112
32426
|
* burn on the source chain, and waits for Circle's relay to confirm the mint
|
|
32113
32427
|
* on the destination. The caller's Gateway account is credited on the
|
|
@@ -32146,11 +32460,12 @@ function resolveGatewayExecutorContracts(srcChain, dstChain) {
|
|
|
32146
32460
|
* const crossResult = await deposit(context, { ...estimate, from: { adapter, chain: 'Ethereum_Sepolia' } })
|
|
32147
32461
|
* ```
|
|
32148
32462
|
*/ async function deposit(context, params) {
|
|
32149
|
-
|
|
32150
|
-
|
|
32151
|
-
|
|
32463
|
+
const normalizedParams = applyDefaultFastDepositDestination(params);
|
|
32464
|
+
assertDepositParams(normalizedParams);
|
|
32465
|
+
if (normalizedParams.to !== undefined) {
|
|
32466
|
+
return depositFastCrossChain(context, normalizedParams);
|
|
32152
32467
|
}
|
|
32153
|
-
const resolvedParams = await resolveDepositParams(
|
|
32468
|
+
const resolvedParams = await resolveDepositParams(normalizedParams);
|
|
32154
32469
|
const chain = resolvedParams.from.chain;
|
|
32155
32470
|
if (!isGatewayV1Supported(chain)) {
|
|
32156
32471
|
throw createUnsupportedRouteError(chain.name, chain.name);
|
|
@@ -32165,7 +32480,8 @@ function resolveGatewayExecutorContracts(srcChain, dstChain) {
|
|
|
32165
32480
|
* (token → `'USDC'`, allowanceStrategy → `'approve'`), finds a provider,
|
|
32166
32481
|
* and delegates to the provider's depositFor operation.
|
|
32167
32482
|
*
|
|
32168
|
-
* For cross-chain (FAST) deposits (when `
|
|
32483
|
+
* For cross-chain (FAST) deposits (when `config.transferSpeed` is `'FAST'`;
|
|
32484
|
+
* `to` defaults to Arc / Arc_Testnet when omitted): fetches or validates a
|
|
32169
32485
|
* fee quote, runs a preflight affordability check, submits the prepaid-FORWARD
|
|
32170
32486
|
* burn on the source chain, and waits for Circle's relay to confirm the mint.
|
|
32171
32487
|
* The `depositAccount` is credited on the destination chain.
|
|
@@ -32209,11 +32525,12 @@ function resolveGatewayExecutorContracts(srcChain, dstChain) {
|
|
|
32209
32525
|
* })
|
|
32210
32526
|
* ```
|
|
32211
32527
|
*/ async function depositFor(context, params) {
|
|
32212
|
-
|
|
32213
|
-
|
|
32214
|
-
|
|
32528
|
+
const normalizedParams = applyDefaultFastDepositDestination(params);
|
|
32529
|
+
assertDepositForParams(normalizedParams);
|
|
32530
|
+
if (normalizedParams.to !== undefined) {
|
|
32531
|
+
return depositFastCrossChain(context, normalizedParams, normalizedParams.depositAccount);
|
|
32215
32532
|
}
|
|
32216
|
-
const resolvedParams = await resolveDepositParams(
|
|
32533
|
+
const resolvedParams = await resolveDepositParams(normalizedParams);
|
|
32217
32534
|
const chain = resolvedParams.from.chain;
|
|
32218
32535
|
if (!isGatewayV1Supported(chain)) {
|
|
32219
32536
|
throw createUnsupportedRouteError(chain.name, chain.name);
|
|
@@ -32272,7 +32589,8 @@ async function estimateDepositImpl(context, params) {
|
|
|
32272
32589
|
fee: depositTotalGasFee
|
|
32273
32590
|
}, srcChain));
|
|
32274
32591
|
} else {
|
|
32275
|
-
//
|
|
32592
|
+
// applyDefaultFastDepositDestination + assertEstimateDepositParams
|
|
32593
|
+
// guarantee params.to is set on the FAST path
|
|
32276
32594
|
const { to } = params;
|
|
32277
32595
|
if (to === undefined) {
|
|
32278
32596
|
/* v8 ignore next 6 -- assertEstimateDepositParams guarantees to is set on the FAST path */ throw createValidationFailedError$1('to', undefined, 'required for FAST transfers');
|
|
@@ -32423,7 +32741,8 @@ async function estimateDepositImpl(context, params) {
|
|
|
32423
32741
|
*
|
|
32424
32742
|
* @param context - Kit context (used for analytics telemetry emissions).
|
|
32425
32743
|
* @param params - The estimate parameters: source context, amount, destination
|
|
32426
|
-
* chain, optional token, transfer
|
|
32744
|
+
* chain (defaults to Arc / Arc_Testnet for FAST), optional token, transfer
|
|
32745
|
+
* speed, and allowance strategy.
|
|
32427
32746
|
* @returns Promise resolving to an itemized fee estimate with an optional
|
|
32428
32747
|
* quote for FAST cross-chain transfers.
|
|
32429
32748
|
* @throws KitError If the wallet address cannot be resolved — wallet not connected
|
|
@@ -32456,8 +32775,9 @@ async function estimateDepositImpl(context, params) {
|
|
|
32456
32775
|
* const result = await deposit(context, { ...estimate, from: { adapter, chain: 'Ethereum_Sepolia' } })
|
|
32457
32776
|
* ```
|
|
32458
32777
|
*/ async function estimateDeposit(context, params) {
|
|
32459
|
-
|
|
32460
|
-
|
|
32778
|
+
const normalizedParams = applyDefaultFastDepositDestination(params);
|
|
32779
|
+
assertEstimateDepositParams(normalizedParams);
|
|
32780
|
+
return estimateDepositImpl(context, normalizedParams);
|
|
32461
32781
|
}
|
|
32462
32782
|
|
|
32463
32783
|
// The `as never` cast is required because `unifiedBalanceChainIdentifierSchema`
|
|
@@ -34031,6 +34351,10 @@ const removeFundParamsSchema = z.object({
|
|
|
34031
34351
|
* All three telemetry call sites use this helper to keep the classification
|
|
34032
34352
|
* consistent.
|
|
34033
34353
|
*
|
|
34354
|
+
* Callers must pass params that have been through
|
|
34355
|
+
* `applyDefaultFastDepositDestination`, which sets `to` to Arc / Arc_Testnet
|
|
34356
|
+
* for FAST deposits that omit it.
|
|
34357
|
+
*
|
|
34034
34358
|
* @param params - Deposit or estimate-deposit params to inspect.
|
|
34035
34359
|
* @returns `true` when the transfer is a FAST cross-chain deposit.
|
|
34036
34360
|
*/ function isFastDeposit(params) {
|
|
@@ -34170,21 +34494,22 @@ const removeFundParamsSchema = z.object({
|
|
|
34170
34494
|
*
|
|
34171
34495
|
* @see UnifiedBalanceKit.depositFor to deposit into another account.
|
|
34172
34496
|
*/ async deposit(params) {
|
|
34173
|
-
|
|
34174
|
-
|
|
34175
|
-
|
|
34176
|
-
|
|
34177
|
-
|
|
34178
|
-
|
|
34179
|
-
|
|
34180
|
-
|
|
34497
|
+
const normalizedParams = applyDefaultFastDepositDestination(params);
|
|
34498
|
+
if (isFastDeposit(normalizedParams)) {
|
|
34499
|
+
return withErrorTelemetry(async ()=>deposit(this.context, normalizedParams), EVENT_TYPES.FAST_DEPOSIT, this.telemetryConfig, {
|
|
34500
|
+
sourceChain: resolveChainName(normalizedParams.from?.chain),
|
|
34501
|
+
destinationChain: resolveChainName(normalizedParams.to?.chain),
|
|
34502
|
+
tokenIn: normalizedParams.token ?? 'USDC',
|
|
34503
|
+
amountIn: Number.parseFloat(normalizedParams.amount),
|
|
34504
|
+
...normalizedParams.quote !== undefined && {
|
|
34505
|
+
correlationId: hashSignedQuote(normalizedParams.quote)
|
|
34181
34506
|
}
|
|
34182
34507
|
});
|
|
34183
34508
|
}
|
|
34184
|
-
return withErrorTelemetry(async ()=>deposit(this.context,
|
|
34185
|
-
sourceChain: resolveChainName(
|
|
34186
|
-
tokenIn:
|
|
34187
|
-
amountIn: Number.parseFloat(
|
|
34509
|
+
return withErrorTelemetry(async ()=>deposit(this.context, normalizedParams), EVENT_TYPES.DEPOSIT, this.telemetryConfig, {
|
|
34510
|
+
sourceChain: resolveChainName(normalizedParams.from?.chain),
|
|
34511
|
+
tokenIn: normalizedParams.token ?? 'USDC',
|
|
34512
|
+
amountIn: Number.parseFloat(normalizedParams.amount)
|
|
34188
34513
|
});
|
|
34189
34514
|
}
|
|
34190
34515
|
/**
|
|
@@ -34196,24 +34521,25 @@ const removeFundParamsSchema = z.object({
|
|
|
34196
34521
|
*
|
|
34197
34522
|
* @see UnifiedBalanceKit.deposit to deposit into your own account.
|
|
34198
34523
|
*/ async depositFor(params) {
|
|
34199
|
-
|
|
34524
|
+
const normalizedParams = applyDefaultFastDepositDestination(params);
|
|
34525
|
+
if (isFastDeposit(normalizedParams)) {
|
|
34200
34526
|
// Fast depositFor shares FAST_DEPOSIT event type with fast deposit — the
|
|
34201
34527
|
// success-path emitter in depositFastCrossChain uses a single event type
|
|
34202
34528
|
// for both entry points, so error telemetry mirrors that here.
|
|
34203
|
-
return withErrorTelemetry(async ()=>depositFor(this.context,
|
|
34204
|
-
sourceChain: resolveChainName(
|
|
34205
|
-
destinationChain: resolveChainName(
|
|
34206
|
-
tokenIn:
|
|
34207
|
-
amountIn: Number.parseFloat(
|
|
34208
|
-
...
|
|
34209
|
-
correlationId: hashSignedQuote(
|
|
34529
|
+
return withErrorTelemetry(async ()=>depositFor(this.context, normalizedParams), EVENT_TYPES.FAST_DEPOSIT, this.telemetryConfig, {
|
|
34530
|
+
sourceChain: resolveChainName(normalizedParams.from?.chain),
|
|
34531
|
+
destinationChain: resolveChainName(normalizedParams.to?.chain),
|
|
34532
|
+
tokenIn: normalizedParams.token ?? 'USDC',
|
|
34533
|
+
amountIn: Number.parseFloat(normalizedParams.amount),
|
|
34534
|
+
...normalizedParams.quote !== undefined && {
|
|
34535
|
+
correlationId: hashSignedQuote(normalizedParams.quote)
|
|
34210
34536
|
}
|
|
34211
34537
|
});
|
|
34212
34538
|
}
|
|
34213
|
-
return withErrorTelemetry(async ()=>depositFor(this.context,
|
|
34214
|
-
sourceChain: resolveChainName(
|
|
34215
|
-
tokenIn:
|
|
34216
|
-
amountIn: Number.parseFloat(
|
|
34539
|
+
return withErrorTelemetry(async ()=>depositFor(this.context, normalizedParams), EVENT_TYPES.DEPOSIT_FOR, this.telemetryConfig, {
|
|
34540
|
+
sourceChain: resolveChainName(normalizedParams.from?.chain),
|
|
34541
|
+
tokenIn: normalizedParams.token ?? 'USDC',
|
|
34542
|
+
amountIn: Number.parseFloat(normalizedParams.amount)
|
|
34217
34543
|
});
|
|
34218
34544
|
}
|
|
34219
34545
|
/**
|
|
@@ -34228,23 +34554,25 @@ const removeFundParamsSchema = z.object({
|
|
|
34228
34554
|
* ```
|
|
34229
34555
|
*
|
|
34230
34556
|
* @param params - The estimate parameters including source context, amount,
|
|
34231
|
-
* destination chain
|
|
34557
|
+
* destination chain (defaults to Arc / Arc_Testnet for FAST), optional
|
|
34558
|
+
* transfer speed, and optional allowance strategy.
|
|
34232
34559
|
* @returns Promise resolving to an itemised fee breakdown.
|
|
34233
34560
|
*
|
|
34234
34561
|
* @see UnifiedBalanceKit.deposit to execute after estimating.
|
|
34235
34562
|
*/ async estimateDeposit(params) {
|
|
34236
|
-
|
|
34237
|
-
|
|
34238
|
-
|
|
34239
|
-
|
|
34240
|
-
|
|
34241
|
-
|
|
34563
|
+
const normalizedParams = applyDefaultFastDepositDestination(params);
|
|
34564
|
+
if (isFastDeposit(normalizedParams)) {
|
|
34565
|
+
return withErrorTelemetry(async ()=>estimateDeposit(this.context, normalizedParams), EVENT_TYPES.ESTIMATE_FAST_DEPOSIT, this.telemetryConfig, {
|
|
34566
|
+
sourceChain: resolveChainName(normalizedParams.from?.chain),
|
|
34567
|
+
destinationChain: resolveChainName(normalizedParams.to?.chain),
|
|
34568
|
+
tokenIn: normalizedParams.token ?? 'USDC',
|
|
34569
|
+
amountIn: Number.parseFloat(normalizedParams.amount)
|
|
34242
34570
|
});
|
|
34243
34571
|
}
|
|
34244
|
-
return withErrorTelemetry(async ()=>estimateDeposit(this.context,
|
|
34245
|
-
sourceChain: resolveChainName(
|
|
34246
|
-
tokenIn:
|
|
34247
|
-
amountIn: Number.parseFloat(
|
|
34572
|
+
return withErrorTelemetry(async ()=>estimateDeposit(this.context, normalizedParams), EVENT_TYPES.ESTIMATE_DEPOSIT, this.telemetryConfig, {
|
|
34573
|
+
sourceChain: resolveChainName(normalizedParams.from?.chain),
|
|
34574
|
+
tokenIn: normalizedParams.token ?? 'USDC',
|
|
34575
|
+
amountIn: Number.parseFloat(normalizedParams.amount)
|
|
34248
34576
|
});
|
|
34249
34577
|
}
|
|
34250
34578
|
/**
|
|
@@ -34613,7 +34941,8 @@ registerKit(`${pkg$1.name}/${pkg$1.version}`);
|
|
|
34613
34941
|
* {@link AppKitUnifiedBalance.depositFor}.
|
|
34614
34942
|
*
|
|
34615
34943
|
* @param params - Estimate details including the depositor context, amount,
|
|
34616
|
-
* destination chain, and optional
|
|
34944
|
+
* destination chain (defaults to Arc / Arc_Testnet for FAST), and optional
|
|
34945
|
+
* transfer speed.
|
|
34617
34946
|
* @returns Promise resolving to the itemised fee estimate.
|
|
34618
34947
|
* @throws {KitError} If the estimate parameters are invalid or the route is
|
|
34619
34948
|
* unsupported.
|