keyring-agent-core 0.2.65 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +305 -293
- package/dist/index.js +92 -69
- package/dist/index.native.js +197 -174
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -5320,6 +5320,47 @@ declare class TransactionByHashTool extends BaseTool {
|
|
|
5320
5320
|
}>;
|
|
5321
5321
|
}
|
|
5322
5322
|
|
|
5323
|
+
/**
|
|
5324
|
+
* The vocabulary every lending protocol adapter shares: the market kinds, the
|
|
5325
|
+
* per-market facts a protocol reads, and the shapes its APY source returns.
|
|
5326
|
+
*
|
|
5327
|
+
* Split out from the adapters themselves so a protocol file can import the
|
|
5328
|
+
* contract it implements without importing its siblings. See `./index.ts` for
|
|
5329
|
+
* how the adapters are organised and why they declare calls rather than make
|
|
5330
|
+
* them.
|
|
5331
|
+
*/
|
|
5332
|
+
/** Market kinds `/supply/v2` returns; see {@link PROTOCOLS}. */
|
|
5333
|
+
type LendingProtocolType = 'aave-v3' | 'compound-v3' | 'spark' | 'spark-ethereum' | 'spark-l2-susds' | 'morpho-v2';
|
|
5334
|
+
/**
|
|
5335
|
+
* The per-chain facts a protocol needs — the numeric chain id, and nothing else.
|
|
5336
|
+
*
|
|
5337
|
+
* This used to also carry the chain's USDC address and decimals, as the DEFAULT
|
|
5338
|
+
* underlying for a market whose own underlying could not be read. That default
|
|
5339
|
+
* is gone: every market's asset now comes from the market itself ({@link
|
|
5340
|
+
* MarketAsset}), and a market that cannot name its asset is reported unresolved
|
|
5341
|
+
* rather than assumed to be USDC. Keeping the fields around would invite exactly
|
|
5342
|
+
* the assumption they were removed for.
|
|
5343
|
+
*/
|
|
5344
|
+
interface LendingChainInfo {
|
|
5345
|
+
chainId: number;
|
|
5346
|
+
}
|
|
5347
|
+
/**
|
|
5348
|
+
* Endpoints {@link LendingProtocol.fetchApy} may call, injected so they stay
|
|
5349
|
+
* configurable.
|
|
5350
|
+
*
|
|
5351
|
+
* RATE SOURCES ONLY. The CoinPool base URL is deliberately absent: it is the
|
|
5352
|
+
* CATALOGUE's endpoint, not a rate source, and it reaches the catalogue through
|
|
5353
|
+
* its own constructor argument. It sat here unread for as long as the rate
|
|
5354
|
+
* history was CoinPool's, which is exactly the confusion `lendingRatesApy.ts`
|
|
5355
|
+
* is named to avoid — a field here should be one a `fetchApy` actually calls.
|
|
5356
|
+
*/
|
|
5357
|
+
interface ApyEndpoints {
|
|
5358
|
+
/** Supply-rate history API (`<base>/lending-rates/<chainId>/<token>`). */
|
|
5359
|
+
lendingRatesBaseUrl: string;
|
|
5360
|
+
aaveApiUrl: string;
|
|
5361
|
+
morphoApiUrl: string;
|
|
5362
|
+
}
|
|
5363
|
+
|
|
5323
5364
|
/**
|
|
5324
5365
|
* Shared ABI / hex types for the codec layer.
|
|
5325
5366
|
*
|
|
@@ -5456,76 +5497,252 @@ interface MulticallRequest {
|
|
|
5456
5497
|
}
|
|
5457
5498
|
|
|
5458
5499
|
/**
|
|
5459
|
-
*
|
|
5460
|
-
*
|
|
5461
|
-
*
|
|
5462
|
-
* ## Why these classes declare calls instead of making them
|
|
5500
|
+
* Address helpers — EIP-55 checksumming and validation, matching viem's
|
|
5501
|
+
* `isAddress` / `getAddress` / `isAddressEqual`.
|
|
5463
5502
|
*
|
|
5464
|
-
* The
|
|
5465
|
-
*
|
|
5466
|
-
*
|
|
5467
|
-
|
|
5468
|
-
|
|
5469
|
-
|
|
5503
|
+
* The decoder returns CHECKSUMMED addresses (as viem does), so any comparison
|
|
5504
|
+
* against a lowercase literal must go through {@link isAddressEqual} rather than
|
|
5505
|
+
* `===`.
|
|
5506
|
+
*/
|
|
5507
|
+
|
|
5508
|
+
/** True for a well-formed 20-byte hex address (any casing). */
|
|
5509
|
+
declare function isAddress(value: unknown): value is Address;
|
|
5510
|
+
/**
|
|
5511
|
+
* EIP-55 checksum casing for an address. Assumes a well-formed input — use
|
|
5512
|
+
* {@link getAddress} when the value comes from outside.
|
|
5513
|
+
*/
|
|
5514
|
+
declare function checksumAddress(address: string): Address;
|
|
5515
|
+
/** Validate + checksum an address, throwing on anything malformed. */
|
|
5516
|
+
declare function getAddress(address: string): Address;
|
|
5517
|
+
/** Case-insensitive address comparison — the only correct way to compare two. */
|
|
5518
|
+
declare function isAddressEqual(a: string, b: string): boolean;
|
|
5519
|
+
|
|
5520
|
+
/**
|
|
5521
|
+
* Canonical ABI type formatting + the keccak-derived selectors built from it —
|
|
5522
|
+
* viem's `formatAbiItem` / `toFunctionSelector` / `toEventSelector` /
|
|
5523
|
+
* `toErrorSelector`, plus the array/type parsing the codec shares.
|
|
5470
5524
|
*
|
|
5471
|
-
*
|
|
5525
|
+
* A selector is keccak256(canonical signature): the signature MUST use canonical
|
|
5526
|
+
* types (`uint` → `uint256`, tuples flattened to `(a,b)`), which is the whole
|
|
5527
|
+
* reason this lives in one place instead of being spelled out at call sites.
|
|
5528
|
+
*/
|
|
5529
|
+
|
|
5530
|
+
/** 4-byte function selector from an ABI item or a signature string. */
|
|
5531
|
+
declare function toFunctionSelector(fn: AbiItem | string): Hex;
|
|
5532
|
+
/** 32-byte event topic0 from an ABI item or a signature string. */
|
|
5533
|
+
declare function toEventSelector(event: AbiItem | string): Hex;
|
|
5534
|
+
/**
|
|
5535
|
+
* Find one item on an ABI — viem's `getAbiItem`.
|
|
5472
5536
|
*
|
|
5473
|
-
*
|
|
5474
|
-
*
|
|
5475
|
-
*
|
|
5476
|
-
*
|
|
5537
|
+
* `name` accepts three spellings, so callers can be as precise as they need:
|
|
5538
|
+
* a plain name (`'balanceOf'`), a full signature (`'balanceOf(address)'`), or a
|
|
5539
|
+
* 4-byte selector (`'0x70a08231'`). OVERLOADS are resolved with `args`: the
|
|
5540
|
+
* candidate whose input list matches the given arguments wins; without `args`
|
|
5541
|
+
* the first overload is used, exactly as viem does.
|
|
5477
5542
|
*
|
|
5478
|
-
*
|
|
5479
|
-
*
|
|
5480
|
-
|
|
5481
|
-
|
|
5543
|
+
* Returns `undefined` rather than throwing — callers that require an item throw
|
|
5544
|
+
* {@link AbiItemNotFoundError} themselves (see {@link requireAbiItem}).
|
|
5545
|
+
*/
|
|
5546
|
+
declare function getAbiItem({ abi, name, args, type, }: {
|
|
5547
|
+
abi: readonly AbiItem[];
|
|
5548
|
+
name: string;
|
|
5549
|
+
args?: readonly unknown[];
|
|
5550
|
+
/** ABI item kind to search; defaults to `function`. */
|
|
5551
|
+
type?: string;
|
|
5552
|
+
}): AbiItem | undefined;
|
|
5553
|
+
|
|
5554
|
+
/**
|
|
5555
|
+
* ABI parameter ENCODER — head/tail layout per the Solidity ABI spec, mirroring
|
|
5556
|
+
* viem's `encodeAbiParameters` (same `PreparedParam` shape, same recursion).
|
|
5482
5557
|
*
|
|
5483
|
-
*
|
|
5558
|
+
* Sits next to {@link file://../decode/decodeAbiParameters.ts} so the two halves of
|
|
5559
|
+
* the codec share one set of type helpers.
|
|
5560
|
+
*/
|
|
5561
|
+
|
|
5562
|
+
/**
|
|
5563
|
+
* Encode `values` against `params` — the ABI-encoding entry point, positional
|
|
5564
|
+
* like viem's. Tuples accept either an object keyed by component name or a
|
|
5565
|
+
* positional array.
|
|
5566
|
+
*/
|
|
5567
|
+
declare function encodeAbiParameters(params: readonly AbiParameter[], values: readonly unknown[]): Hex;
|
|
5568
|
+
|
|
5569
|
+
/**
|
|
5570
|
+
* Calldata builders: selector + ABI-encoded arguments (viem's
|
|
5571
|
+
* `encodeFunctionData` / `encodeErrorResult`).
|
|
5572
|
+
*/
|
|
5573
|
+
|
|
5574
|
+
interface EncodeFunctionDataParameters {
|
|
5575
|
+
abi: Abi;
|
|
5576
|
+
/** Function name, full signature (`transfer(address,uint256)`) or 4-byte selector. */
|
|
5577
|
+
functionName: string;
|
|
5578
|
+
args?: readonly unknown[];
|
|
5579
|
+
}
|
|
5580
|
+
/**
|
|
5581
|
+
* Encode a function call — `0x` + 4-byte selector + arguments.
|
|
5484
5582
|
*
|
|
5485
|
-
*
|
|
5486
|
-
*
|
|
5487
|
-
*
|
|
5488
|
-
|
|
5583
|
+
* Overloads are resolved from `args` (see `getAbiItem`), so an ABI carrying both
|
|
5584
|
+
* `safeTransferFrom(address,address,uint256)` and its 4-arg variant picks the one
|
|
5585
|
+
* matching what you passed.
|
|
5586
|
+
*/
|
|
5587
|
+
declare function encodeFunctionData({ abi, functionName, args }: EncodeFunctionDataParameters): Hex;
|
|
5588
|
+
interface EncodeErrorResultParameters {
|
|
5589
|
+
abi: Abi;
|
|
5590
|
+
errorName: string;
|
|
5591
|
+
args?: readonly unknown[];
|
|
5592
|
+
}
|
|
5593
|
+
/**
|
|
5594
|
+
* Encode a custom-error revert payload — the shape a reverting contract returns,
|
|
5595
|
+
* useful for tests and for round-tripping {@link file://../decode/decodeErrorResult.ts}.
|
|
5596
|
+
*/
|
|
5597
|
+
declare function encodeErrorResult({ abi, errorName, args }: EncodeErrorResultParameters): Hex;
|
|
5598
|
+
|
|
5599
|
+
/**
|
|
5600
|
+
* ABI parameter DECODER — the exact inverse of
|
|
5601
|
+
* {@link file://../encode/encodeAbiParameters.ts}, matching viem's `decodeAbiParameters`
|
|
5602
|
+
* in both coverage and return shapes:
|
|
5489
5603
|
*
|
|
5490
|
-
*
|
|
5491
|
-
*
|
|
5492
|
-
*
|
|
5493
|
-
*
|
|
5494
|
-
*
|
|
5604
|
+
* - `address` → EIP-55 CHECKSUMMED hex (compare with `isAddressEqual`, not `===`)
|
|
5605
|
+
* - `bool` → boolean
|
|
5606
|
+
* - `string` → string
|
|
5607
|
+
* - `bytes`/`bytesN` → 0x hex
|
|
5608
|
+
* - `(u)intN` → `number` for N ≤ 48, `bigint` above (viem's cut-off: 48 bits is
|
|
5609
|
+
* the largest that always fits a JS number exactly)
|
|
5610
|
+
* - `tuple` → object keyed by component name, or an array when any component
|
|
5611
|
+
* is unnamed
|
|
5612
|
+
* - arrays → arrays, fixed or dynamic, nested to any depth
|
|
5495
5613
|
*
|
|
5496
|
-
*
|
|
5497
|
-
*
|
|
5498
|
-
*
|
|
5499
|
-
|
|
5500
|
-
|
|
5614
|
+
* Every offset/length read is bounds-checked, so a truncated or non-ABI response
|
|
5615
|
+
* raises {@link AbiDecodingOutOfBoundsError} instead of returning silent garbage —
|
|
5616
|
+
* which is what lets `multicall` mark ONE entry as failed and keep the rest.
|
|
5617
|
+
*/
|
|
5618
|
+
|
|
5619
|
+
/**
|
|
5620
|
+
* Decode ABI-encoded `data` against `params`, positionally.
|
|
5501
5621
|
*
|
|
5502
|
-
*
|
|
5503
|
-
*
|
|
5504
|
-
*
|
|
5622
|
+
* Throws {@link AbiDecodingZeroDataError} for `0x` (the classic "not a contract
|
|
5623
|
+
* on this chain" signal) and {@link AbiDecodingDataSizeTooSmallError} /
|
|
5624
|
+
* {@link AbiDecodingOutOfBoundsError} for a payload that can't hold the shape —
|
|
5625
|
+
* never a partially-filled result.
|
|
5505
5626
|
*/
|
|
5506
|
-
|
|
5507
|
-
|
|
5627
|
+
declare function decodeAbiParameters<T extends readonly unknown[] = readonly unknown[]>(params: readonly AbiParameter[], data: Hex | Uint8Array): T;
|
|
5628
|
+
|
|
5508
5629
|
/**
|
|
5509
|
-
*
|
|
5630
|
+
* Return-data decoders for a function call — viem's `decodeFunctionResult`, plus
|
|
5631
|
+
* `decodeFunctionData` for the calldata direction.
|
|
5632
|
+
*/
|
|
5633
|
+
|
|
5634
|
+
interface DecodeFunctionResultParameters {
|
|
5635
|
+
abi: Abi;
|
|
5636
|
+
/** Function name, full signature or 4-byte selector. */
|
|
5637
|
+
functionName: string;
|
|
5638
|
+
/** Args of the CALL — only used to pick between overloads. */
|
|
5639
|
+
args?: readonly unknown[];
|
|
5640
|
+
data: Hex;
|
|
5641
|
+
}
|
|
5642
|
+
/**
|
|
5643
|
+
* Decode a call's return data against its ABI outputs.
|
|
5510
5644
|
*
|
|
5511
|
-
*
|
|
5512
|
-
*
|
|
5513
|
-
*
|
|
5514
|
-
*
|
|
5515
|
-
*
|
|
5516
|
-
* the assumption they were removed for.
|
|
5645
|
+
* Follows viem's unwrapping rule, which is what makes reads ergonomic:
|
|
5646
|
+
* - no outputs → `undefined`
|
|
5647
|
+
* - one output → that value directly (`balanceOf` → `bigint`)
|
|
5648
|
+
* - many outputs → the array of values (a named-tuple output still decodes to
|
|
5649
|
+
* an object, since that is the tuple's own shape)
|
|
5517
5650
|
*/
|
|
5518
|
-
|
|
5519
|
-
|
|
5651
|
+
declare function decodeFunctionResult({ abi, functionName, args, data }: DecodeFunctionResultParameters): unknown;
|
|
5652
|
+
interface DecodeFunctionDataParameters {
|
|
5653
|
+
abi: Abi;
|
|
5654
|
+
data: Hex;
|
|
5520
5655
|
}
|
|
5521
|
-
/**
|
|
5522
|
-
|
|
5523
|
-
|
|
5524
|
-
|
|
5525
|
-
|
|
5526
|
-
|
|
5527
|
-
|
|
5656
|
+
/**
|
|
5657
|
+
* Decode CALLDATA (selector + args) back into `{ functionName, args }` — the
|
|
5658
|
+
* inverse of `encodeFunctionData`. Handy for explaining a pending transaction to
|
|
5659
|
+
* the user before they sign it.
|
|
5660
|
+
*/
|
|
5661
|
+
declare function decodeFunctionData({ abi, data }: DecodeFunctionDataParameters): {
|
|
5662
|
+
functionName: string;
|
|
5663
|
+
args: readonly unknown[];
|
|
5664
|
+
};
|
|
5665
|
+
|
|
5666
|
+
/**
|
|
5667
|
+
* Revert-payload decoder — viem's `decodeErrorResult`.
|
|
5668
|
+
*
|
|
5669
|
+
* A reverting EVM call returns data in one of three shapes, and this resolves
|
|
5670
|
+
* all three:
|
|
5671
|
+
* - `Error(string)` — `require(cond, "reason")` / `revert("reason")`
|
|
5672
|
+
* - `Panic(uint256)` — compiler-inserted assertions (overflow, /0, bad index …),
|
|
5673
|
+
* whose codes are translated to the human sentences Solidity documents
|
|
5674
|
+
* - a CUSTOM error from the contract's own ABI
|
|
5675
|
+
*
|
|
5676
|
+
* That's what turns "execution reverted" into "ERC20: transfer amount exceeds
|
|
5677
|
+
* balance" in a tool's output, so it is worth having even though multicall marks
|
|
5678
|
+
* the entry failed either way.
|
|
5679
|
+
*/
|
|
5680
|
+
|
|
5681
|
+
interface DecodeErrorResultReturnType {
|
|
5682
|
+
/** Decoded error name (`Error`, `Panic`, or a custom one from the ABI). */
|
|
5683
|
+
errorName: string;
|
|
5684
|
+
/** Decoded arguments, `undefined` when the error takes none. */
|
|
5685
|
+
args?: readonly unknown[];
|
|
5686
|
+
/** The ABI item that matched. */
|
|
5687
|
+
abiItem: AbiItem;
|
|
5528
5688
|
}
|
|
5689
|
+
/**
|
|
5690
|
+
* Decode revert data against `abi` plus the two built-in Solidity errors.
|
|
5691
|
+
* Throws when the payload is empty or its selector matches nothing — the caller
|
|
5692
|
+
* (the contract-error layer) then reports the raw data instead.
|
|
5693
|
+
*/
|
|
5694
|
+
declare function decodeErrorResult({ abi, data }: {
|
|
5695
|
+
abi?: Abi;
|
|
5696
|
+
data: Hex;
|
|
5697
|
+
}): DecodeErrorResultReturnType;
|
|
5698
|
+
/**
|
|
5699
|
+
* The one-line human reason for revert data, or `undefined` when it decodes to
|
|
5700
|
+
* nothing meaningful: the `require` string, the panic sentence, or
|
|
5701
|
+
* `CustomError(arg, arg)`.
|
|
5702
|
+
*/
|
|
5703
|
+
declare function getRevertReason({ abi, data }: {
|
|
5704
|
+
abi?: Abi;
|
|
5705
|
+
data: Hex;
|
|
5706
|
+
}): string | undefined;
|
|
5707
|
+
|
|
5708
|
+
/**
|
|
5709
|
+
* Human-readable ABI parser — viem's `parseAbi` / `parseAbiItem` /
|
|
5710
|
+
* `parseAbiParameters`, so an ABI can be written the way it reads in Solidity:
|
|
5711
|
+
*
|
|
5712
|
+
* ```ts
|
|
5713
|
+
* const abi = parseAbi([
|
|
5714
|
+
* 'function balanceOf(address owner) view returns (uint256)',
|
|
5715
|
+
* 'function transfer(address to, uint256 amount) returns (bool)',
|
|
5716
|
+
* 'event Transfer(address indexed from, address indexed to, uint256 value)',
|
|
5717
|
+
* 'error InsufficientBalance(uint256 available, uint256 required)',
|
|
5718
|
+
* ]);
|
|
5719
|
+
* ```
|
|
5720
|
+
*
|
|
5721
|
+
* Supported: functions, events, errors, constructor, fallback, receive; named and
|
|
5722
|
+
* unnamed parameters; `indexed`; data locations (`calldata`/`memory`/`storage`,
|
|
5723
|
+
* ignored as the ABI has no such concept); inline tuples `(uint256 a, bool b)`
|
|
5724
|
+
* with array suffixes at any depth.
|
|
5725
|
+
*
|
|
5726
|
+
* NOT supported (deliberately — it needs a symbol table, and the JSON form is
|
|
5727
|
+
* always available): named `struct` declarations. Write the tuple inline instead.
|
|
5728
|
+
*/
|
|
5729
|
+
|
|
5730
|
+
/** A parameter LIST: `address owner, uint256 amount` (no surrounding parens). */
|
|
5731
|
+
declare function parseAbiParameters(signature: string): AbiParameter[];
|
|
5732
|
+
/** Parse ONE human-readable signature into its ABI item. */
|
|
5733
|
+
declare function parseAbiItem(signature: string): AbiItem;
|
|
5734
|
+
/** Parse a whole human-readable ABI. */
|
|
5735
|
+
declare function parseAbi(signatures: readonly string[]): AbiItem[];
|
|
5736
|
+
|
|
5737
|
+
/**
|
|
5738
|
+
* Cross-chain sUSDS on an L2 — the one market kind with no vault behind it, and
|
|
5739
|
+
* the share-conversion arithmetic that stands in for the `convertToAssets()` it
|
|
5740
|
+
* does not implement.
|
|
5741
|
+
*
|
|
5742
|
+
* Separate from `./spark.ts` despite the shared brand: this reads through an SSR
|
|
5743
|
+
* oracle rather than a vault, so it shares none of the ERC-4626 defaults.
|
|
5744
|
+
*/
|
|
5745
|
+
|
|
5529
5746
|
/**
|
|
5530
5747
|
* `shares × conversionRate`, in RAW units of the underlying — the arithmetic
|
|
5531
5748
|
* that stands in for `convertToAssets()` on a token that has none.
|
|
@@ -5541,6 +5758,22 @@ interface ApyEndpoints {
|
|
|
5541
5758
|
* mismatched decimals gets the correction applied instead of a silent 10^n error.
|
|
5542
5759
|
*/
|
|
5543
5760
|
declare function convertSusdsShares(rawShares: bigint, conversionRateRay: bigint, shareDecimals: number, assetDecimals: number): bigint | null;
|
|
5761
|
+
|
|
5762
|
+
/**
|
|
5763
|
+
* The one table mapping a market `type` to everything this core knows about that
|
|
5764
|
+
* protocol family: the adapter that reads it, the name a reader should see, and
|
|
5765
|
+
* the app it lives at.
|
|
5766
|
+
*
|
|
5767
|
+
* ONE table rather than three parallel ones. These used to be separate
|
|
5768
|
+
* `Record<LendingProtocolType, …>` maps, which made a new protocol three edits in
|
|
5769
|
+
* three places — and the compiler only caught the one you remembered, because
|
|
5770
|
+
* each map was independently exhaustive. A family added to the adapter map but
|
|
5771
|
+
* missed in the label map silently fell back to whatever display string its
|
|
5772
|
+
* source supplied, and one missed in the home map produced no link at all. With
|
|
5773
|
+
* the three folded into a single entry, `Record<LendingProtocolType, …>` makes
|
|
5774
|
+
* adding a market kind a compile error until all three are supplied.
|
|
5775
|
+
*/
|
|
5776
|
+
|
|
5544
5777
|
/**
|
|
5545
5778
|
* Display name of a market's protocol family, derived from its `type`.
|
|
5546
5779
|
*
|
|
@@ -5840,6 +6073,23 @@ declare class MarketDescriber {
|
|
|
5840
6073
|
* cares which asset a chain's "real" stablecoin is.
|
|
5841
6074
|
*/
|
|
5842
6075
|
private resolveAssets;
|
|
6076
|
+
/**
|
|
6077
|
+
* Each Spark market's SHARE token symbol, aligned with `markets` — the value
|
|
6078
|
+
* `marketLink` routes a savings page on.
|
|
6079
|
+
*
|
|
6080
|
+
* An ERC-4626 vault is its own share token, so this is `symbol()` on the
|
|
6081
|
+
* market's `contract`. It is read rather than derived because the share symbol
|
|
6082
|
+
* does not follow from the underlying: Spark's WETH vault is spETH, so
|
|
6083
|
+
* deriving `sp` + underlying builds `spweth` and links to a page that does not
|
|
6084
|
+
* exist.
|
|
6085
|
+
*
|
|
6086
|
+
* Only Spark markets are asked — they are the only ones whose link keys on the
|
|
6087
|
+
* share — so this adds one batched call per description, and none at all for a
|
|
6088
|
+
* chain with no Spark market. A failed round yields all nulls, which drops the
|
|
6089
|
+
* link back to the per-vault table and then to Spark's app: a market is never
|
|
6090
|
+
* left worse off than before this read existed.
|
|
6091
|
+
*/
|
|
6092
|
+
private readShareSymbols;
|
|
5843
6093
|
/** `decimals()` + `symbol()` for each distinct asset address, in one multicall. */
|
|
5844
6094
|
private readAssetMetadata;
|
|
5845
6095
|
/**
|
|
@@ -10467,244 +10717,6 @@ declare function getPublicClient(chainId: string | number, options?: GetPublicCl
|
|
|
10467
10717
|
*/
|
|
10468
10718
|
declare function clearPublicClientCache(): void;
|
|
10469
10719
|
|
|
10470
|
-
/**
|
|
10471
|
-
* Address helpers — EIP-55 checksumming and validation, matching viem's
|
|
10472
|
-
* `isAddress` / `getAddress` / `isAddressEqual`.
|
|
10473
|
-
*
|
|
10474
|
-
* The decoder returns CHECKSUMMED addresses (as viem does), so any comparison
|
|
10475
|
-
* against a lowercase literal must go through {@link isAddressEqual} rather than
|
|
10476
|
-
* `===`.
|
|
10477
|
-
*/
|
|
10478
|
-
|
|
10479
|
-
/** True for a well-formed 20-byte hex address (any casing). */
|
|
10480
|
-
declare function isAddress(value: unknown): value is Address;
|
|
10481
|
-
/**
|
|
10482
|
-
* EIP-55 checksum casing for an address. Assumes a well-formed input — use
|
|
10483
|
-
* {@link getAddress} when the value comes from outside.
|
|
10484
|
-
*/
|
|
10485
|
-
declare function checksumAddress(address: string): Address;
|
|
10486
|
-
/** Validate + checksum an address, throwing on anything malformed. */
|
|
10487
|
-
declare function getAddress(address: string): Address;
|
|
10488
|
-
/** Case-insensitive address comparison — the only correct way to compare two. */
|
|
10489
|
-
declare function isAddressEqual(a: string, b: string): boolean;
|
|
10490
|
-
|
|
10491
|
-
/**
|
|
10492
|
-
* Canonical ABI type formatting + the keccak-derived selectors built from it —
|
|
10493
|
-
* viem's `formatAbiItem` / `toFunctionSelector` / `toEventSelector` /
|
|
10494
|
-
* `toErrorSelector`, plus the array/type parsing the codec shares.
|
|
10495
|
-
*
|
|
10496
|
-
* A selector is keccak256(canonical signature): the signature MUST use canonical
|
|
10497
|
-
* types (`uint` → `uint256`, tuples flattened to `(a,b)`), which is the whole
|
|
10498
|
-
* reason this lives in one place instead of being spelled out at call sites.
|
|
10499
|
-
*/
|
|
10500
|
-
|
|
10501
|
-
/** 4-byte function selector from an ABI item or a signature string. */
|
|
10502
|
-
declare function toFunctionSelector(fn: AbiItem | string): Hex;
|
|
10503
|
-
/** 32-byte event topic0 from an ABI item or a signature string. */
|
|
10504
|
-
declare function toEventSelector(event: AbiItem | string): Hex;
|
|
10505
|
-
/**
|
|
10506
|
-
* Find one item on an ABI — viem's `getAbiItem`.
|
|
10507
|
-
*
|
|
10508
|
-
* `name` accepts three spellings, so callers can be as precise as they need:
|
|
10509
|
-
* a plain name (`'balanceOf'`), a full signature (`'balanceOf(address)'`), or a
|
|
10510
|
-
* 4-byte selector (`'0x70a08231'`). OVERLOADS are resolved with `args`: the
|
|
10511
|
-
* candidate whose input list matches the given arguments wins; without `args`
|
|
10512
|
-
* the first overload is used, exactly as viem does.
|
|
10513
|
-
*
|
|
10514
|
-
* Returns `undefined` rather than throwing — callers that require an item throw
|
|
10515
|
-
* {@link AbiItemNotFoundError} themselves (see {@link requireAbiItem}).
|
|
10516
|
-
*/
|
|
10517
|
-
declare function getAbiItem({ abi, name, args, type, }: {
|
|
10518
|
-
abi: readonly AbiItem[];
|
|
10519
|
-
name: string;
|
|
10520
|
-
args?: readonly unknown[];
|
|
10521
|
-
/** ABI item kind to search; defaults to `function`. */
|
|
10522
|
-
type?: string;
|
|
10523
|
-
}): AbiItem | undefined;
|
|
10524
|
-
|
|
10525
|
-
/**
|
|
10526
|
-
* ABI parameter ENCODER — head/tail layout per the Solidity ABI spec, mirroring
|
|
10527
|
-
* viem's `encodeAbiParameters` (same `PreparedParam` shape, same recursion).
|
|
10528
|
-
*
|
|
10529
|
-
* Sits next to {@link file://../decode/decodeAbiParameters.ts} so the two halves of
|
|
10530
|
-
* the codec share one set of type helpers.
|
|
10531
|
-
*/
|
|
10532
|
-
|
|
10533
|
-
/**
|
|
10534
|
-
* Encode `values` against `params` — the ABI-encoding entry point, positional
|
|
10535
|
-
* like viem's. Tuples accept either an object keyed by component name or a
|
|
10536
|
-
* positional array.
|
|
10537
|
-
*/
|
|
10538
|
-
declare function encodeAbiParameters(params: readonly AbiParameter[], values: readonly unknown[]): Hex;
|
|
10539
|
-
|
|
10540
|
-
/**
|
|
10541
|
-
* Calldata builders: selector + ABI-encoded arguments (viem's
|
|
10542
|
-
* `encodeFunctionData` / `encodeErrorResult`).
|
|
10543
|
-
*/
|
|
10544
|
-
|
|
10545
|
-
interface EncodeFunctionDataParameters {
|
|
10546
|
-
abi: Abi;
|
|
10547
|
-
/** Function name, full signature (`transfer(address,uint256)`) or 4-byte selector. */
|
|
10548
|
-
functionName: string;
|
|
10549
|
-
args?: readonly unknown[];
|
|
10550
|
-
}
|
|
10551
|
-
/**
|
|
10552
|
-
* Encode a function call — `0x` + 4-byte selector + arguments.
|
|
10553
|
-
*
|
|
10554
|
-
* Overloads are resolved from `args` (see `getAbiItem`), so an ABI carrying both
|
|
10555
|
-
* `safeTransferFrom(address,address,uint256)` and its 4-arg variant picks the one
|
|
10556
|
-
* matching what you passed.
|
|
10557
|
-
*/
|
|
10558
|
-
declare function encodeFunctionData({ abi, functionName, args }: EncodeFunctionDataParameters): Hex;
|
|
10559
|
-
interface EncodeErrorResultParameters {
|
|
10560
|
-
abi: Abi;
|
|
10561
|
-
errorName: string;
|
|
10562
|
-
args?: readonly unknown[];
|
|
10563
|
-
}
|
|
10564
|
-
/**
|
|
10565
|
-
* Encode a custom-error revert payload — the shape a reverting contract returns,
|
|
10566
|
-
* useful for tests and for round-tripping {@link file://../decode/decodeErrorResult.ts}.
|
|
10567
|
-
*/
|
|
10568
|
-
declare function encodeErrorResult({ abi, errorName, args }: EncodeErrorResultParameters): Hex;
|
|
10569
|
-
|
|
10570
|
-
/**
|
|
10571
|
-
* ABI parameter DECODER — the exact inverse of
|
|
10572
|
-
* {@link file://../encode/encodeAbiParameters.ts}, matching viem's `decodeAbiParameters`
|
|
10573
|
-
* in both coverage and return shapes:
|
|
10574
|
-
*
|
|
10575
|
-
* - `address` → EIP-55 CHECKSUMMED hex (compare with `isAddressEqual`, not `===`)
|
|
10576
|
-
* - `bool` → boolean
|
|
10577
|
-
* - `string` → string
|
|
10578
|
-
* - `bytes`/`bytesN` → 0x hex
|
|
10579
|
-
* - `(u)intN` → `number` for N ≤ 48, `bigint` above (viem's cut-off: 48 bits is
|
|
10580
|
-
* the largest that always fits a JS number exactly)
|
|
10581
|
-
* - `tuple` → object keyed by component name, or an array when any component
|
|
10582
|
-
* is unnamed
|
|
10583
|
-
* - arrays → arrays, fixed or dynamic, nested to any depth
|
|
10584
|
-
*
|
|
10585
|
-
* Every offset/length read is bounds-checked, so a truncated or non-ABI response
|
|
10586
|
-
* raises {@link AbiDecodingOutOfBoundsError} instead of returning silent garbage —
|
|
10587
|
-
* which is what lets `multicall` mark ONE entry as failed and keep the rest.
|
|
10588
|
-
*/
|
|
10589
|
-
|
|
10590
|
-
/**
|
|
10591
|
-
* Decode ABI-encoded `data` against `params`, positionally.
|
|
10592
|
-
*
|
|
10593
|
-
* Throws {@link AbiDecodingZeroDataError} for `0x` (the classic "not a contract
|
|
10594
|
-
* on this chain" signal) and {@link AbiDecodingDataSizeTooSmallError} /
|
|
10595
|
-
* {@link AbiDecodingOutOfBoundsError} for a payload that can't hold the shape —
|
|
10596
|
-
* never a partially-filled result.
|
|
10597
|
-
*/
|
|
10598
|
-
declare function decodeAbiParameters<T extends readonly unknown[] = readonly unknown[]>(params: readonly AbiParameter[], data: Hex | Uint8Array): T;
|
|
10599
|
-
|
|
10600
|
-
/**
|
|
10601
|
-
* Return-data decoders for a function call — viem's `decodeFunctionResult`, plus
|
|
10602
|
-
* `decodeFunctionData` for the calldata direction.
|
|
10603
|
-
*/
|
|
10604
|
-
|
|
10605
|
-
interface DecodeFunctionResultParameters {
|
|
10606
|
-
abi: Abi;
|
|
10607
|
-
/** Function name, full signature or 4-byte selector. */
|
|
10608
|
-
functionName: string;
|
|
10609
|
-
/** Args of the CALL — only used to pick between overloads. */
|
|
10610
|
-
args?: readonly unknown[];
|
|
10611
|
-
data: Hex;
|
|
10612
|
-
}
|
|
10613
|
-
/**
|
|
10614
|
-
* Decode a call's return data against its ABI outputs.
|
|
10615
|
-
*
|
|
10616
|
-
* Follows viem's unwrapping rule, which is what makes reads ergonomic:
|
|
10617
|
-
* - no outputs → `undefined`
|
|
10618
|
-
* - one output → that value directly (`balanceOf` → `bigint`)
|
|
10619
|
-
* - many outputs → the array of values (a named-tuple output still decodes to
|
|
10620
|
-
* an object, since that is the tuple's own shape)
|
|
10621
|
-
*/
|
|
10622
|
-
declare function decodeFunctionResult({ abi, functionName, args, data }: DecodeFunctionResultParameters): unknown;
|
|
10623
|
-
interface DecodeFunctionDataParameters {
|
|
10624
|
-
abi: Abi;
|
|
10625
|
-
data: Hex;
|
|
10626
|
-
}
|
|
10627
|
-
/**
|
|
10628
|
-
* Decode CALLDATA (selector + args) back into `{ functionName, args }` — the
|
|
10629
|
-
* inverse of `encodeFunctionData`. Handy for explaining a pending transaction to
|
|
10630
|
-
* the user before they sign it.
|
|
10631
|
-
*/
|
|
10632
|
-
declare function decodeFunctionData({ abi, data }: DecodeFunctionDataParameters): {
|
|
10633
|
-
functionName: string;
|
|
10634
|
-
args: readonly unknown[];
|
|
10635
|
-
};
|
|
10636
|
-
|
|
10637
|
-
/**
|
|
10638
|
-
* Revert-payload decoder — viem's `decodeErrorResult`.
|
|
10639
|
-
*
|
|
10640
|
-
* A reverting EVM call returns data in one of three shapes, and this resolves
|
|
10641
|
-
* all three:
|
|
10642
|
-
* - `Error(string)` — `require(cond, "reason")` / `revert("reason")`
|
|
10643
|
-
* - `Panic(uint256)` — compiler-inserted assertions (overflow, /0, bad index …),
|
|
10644
|
-
* whose codes are translated to the human sentences Solidity documents
|
|
10645
|
-
* - a CUSTOM error from the contract's own ABI
|
|
10646
|
-
*
|
|
10647
|
-
* That's what turns "execution reverted" into "ERC20: transfer amount exceeds
|
|
10648
|
-
* balance" in a tool's output, so it is worth having even though multicall marks
|
|
10649
|
-
* the entry failed either way.
|
|
10650
|
-
*/
|
|
10651
|
-
|
|
10652
|
-
interface DecodeErrorResultReturnType {
|
|
10653
|
-
/** Decoded error name (`Error`, `Panic`, or a custom one from the ABI). */
|
|
10654
|
-
errorName: string;
|
|
10655
|
-
/** Decoded arguments, `undefined` when the error takes none. */
|
|
10656
|
-
args?: readonly unknown[];
|
|
10657
|
-
/** The ABI item that matched. */
|
|
10658
|
-
abiItem: AbiItem;
|
|
10659
|
-
}
|
|
10660
|
-
/**
|
|
10661
|
-
* Decode revert data against `abi` plus the two built-in Solidity errors.
|
|
10662
|
-
* Throws when the payload is empty or its selector matches nothing — the caller
|
|
10663
|
-
* (the contract-error layer) then reports the raw data instead.
|
|
10664
|
-
*/
|
|
10665
|
-
declare function decodeErrorResult({ abi, data }: {
|
|
10666
|
-
abi?: Abi;
|
|
10667
|
-
data: Hex;
|
|
10668
|
-
}): DecodeErrorResultReturnType;
|
|
10669
|
-
/**
|
|
10670
|
-
* The one-line human reason for revert data, or `undefined` when it decodes to
|
|
10671
|
-
* nothing meaningful: the `require` string, the panic sentence, or
|
|
10672
|
-
* `CustomError(arg, arg)`.
|
|
10673
|
-
*/
|
|
10674
|
-
declare function getRevertReason({ abi, data }: {
|
|
10675
|
-
abi?: Abi;
|
|
10676
|
-
data: Hex;
|
|
10677
|
-
}): string | undefined;
|
|
10678
|
-
|
|
10679
|
-
/**
|
|
10680
|
-
* Human-readable ABI parser — viem's `parseAbi` / `parseAbiItem` /
|
|
10681
|
-
* `parseAbiParameters`, so an ABI can be written the way it reads in Solidity:
|
|
10682
|
-
*
|
|
10683
|
-
* ```ts
|
|
10684
|
-
* const abi = parseAbi([
|
|
10685
|
-
* 'function balanceOf(address owner) view returns (uint256)',
|
|
10686
|
-
* 'function transfer(address to, uint256 amount) returns (bool)',
|
|
10687
|
-
* 'event Transfer(address indexed from, address indexed to, uint256 value)',
|
|
10688
|
-
* 'error InsufficientBalance(uint256 available, uint256 required)',
|
|
10689
|
-
* ]);
|
|
10690
|
-
* ```
|
|
10691
|
-
*
|
|
10692
|
-
* Supported: functions, events, errors, constructor, fallback, receive; named and
|
|
10693
|
-
* unnamed parameters; `indexed`; data locations (`calldata`/`memory`/`storage`,
|
|
10694
|
-
* ignored as the ABI has no such concept); inline tuples `(uint256 a, bool b)`
|
|
10695
|
-
* with array suffixes at any depth.
|
|
10696
|
-
*
|
|
10697
|
-
* NOT supported (deliberately — it needs a symbol table, and the JSON form is
|
|
10698
|
-
* always available): named `struct` declarations. Write the tuple inline instead.
|
|
10699
|
-
*/
|
|
10700
|
-
|
|
10701
|
-
/** A parameter LIST: `address owner, uint256 amount` (no surrounding parens). */
|
|
10702
|
-
declare function parseAbiParameters(signature: string): AbiParameter[];
|
|
10703
|
-
/** Parse ONE human-readable signature into its ABI item. */
|
|
10704
|
-
declare function parseAbiItem(signature: string): AbiItem;
|
|
10705
|
-
/** Parse a whole human-readable ABI. */
|
|
10706
|
-
declare function parseAbi(signatures: readonly string[]): AbiItem[];
|
|
10707
|
-
|
|
10708
10720
|
/**
|
|
10709
10721
|
* Public facade over the chain stack ({@link file://../chain/index.ts}).
|
|
10710
10722
|
*
|