crypto-aio 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +151 -1
- package/README.md +32 -12
- package/dist/adapters/evm/builder.js +64 -4
- package/dist/adapters/evm/builder.js.map +1 -1
- package/dist/adapters/evm/decode.js +6 -1
- package/dist/adapters/evm/decode.js.map +1 -1
- package/dist/adapters/evm/ethers-client.js +4 -0
- package/dist/adapters/evm/ethers-client.js.map +1 -1
- package/dist/adapters/evm/fees.d.ts +24 -0
- package/dist/adapters/evm/fees.js +47 -4
- package/dist/adapters/evm/fees.js.map +1 -1
- package/dist/adapters/evm/index.d.ts +1 -1
- package/dist/adapters/evm/index.js +2 -1
- package/dist/adapters/evm/index.js.map +1 -1
- package/dist/adapters/evm/network.d.ts +5 -0
- package/dist/adapters/evm/network.js +21 -2
- package/dist/adapters/evm/network.js.map +1 -1
- package/dist/adapters/evm/plugin.d.ts +5 -6
- package/dist/adapters/evm/plugin.js +50 -2
- package/dist/adapters/evm/plugin.js.map +1 -1
- package/dist/adapters/evm/proofs.js +17 -5
- package/dist/adapters/evm/proofs.js.map +1 -1
- package/dist/adapters/evm/reader.d.ts +18 -0
- package/dist/adapters/evm/reader.js +34 -0
- package/dist/adapters/evm/reader.js.map +1 -1
- package/dist/adapters/evm/tokens.d.ts +3 -0
- package/dist/adapters/evm/tokens.js.map +1 -1
- package/dist/adapters/evm/types.d.ts +10 -0
- package/dist/adapters/evm/types.js.map +1 -1
- package/dist/adapters/evm/web3-client.d.ts +6 -3
- package/dist/adapters/evm/web3-client.js +19 -2
- package/dist/adapters/evm/web3-client.js.map +1 -1
- package/dist/adapters/solana/builder.js +29 -18
- package/dist/adapters/solana/builder.js.map +1 -1
- package/dist/adapters/solana/fees.d.ts +12 -3
- package/dist/adapters/solana/fees.js +13 -4
- package/dist/adapters/solana/fees.js.map +1 -1
- package/dist/adapters/solana/message.d.ts +15 -0
- package/dist/adapters/solana/message.js +120 -0
- package/dist/adapters/solana/message.js.map +1 -0
- package/dist/adapters/solana/plugin.js +4 -1
- package/dist/adapters/solana/plugin.js.map +1 -1
- package/dist/adapters/solana/types.d.ts +8 -5
- package/dist/adapters/solana/types.js.map +1 -1
- package/dist/adapters/solana/web3.js +10 -32
- package/dist/adapters/solana/web3.js.map +1 -1
- package/dist/adapters/ton/proofs.js +18 -76
- package/dist/adapters/ton/proofs.js.map +1 -1
- package/dist/adapters/ton/reader.d.ts +45 -4
- package/dist/adapters/ton/reader.js +200 -5
- package/dist/adapters/ton/reader.js.map +1 -1
- package/dist/adapters/ton/trace.d.ts +26 -0
- package/dist/adapters/ton/trace.js +35 -9
- package/dist/adapters/ton/trace.js.map +1 -1
- package/dist/adapters/tron/abi.d.ts +2 -0
- package/dist/adapters/tron/abi.js +2 -0
- package/dist/adapters/tron/abi.js.map +1 -1
- package/dist/adapters/tron/builder.js +20 -4
- package/dist/adapters/tron/builder.js.map +1 -1
- package/dist/adapters/tron/decode.d.ts +2 -0
- package/dist/adapters/tron/decode.js +1 -1
- package/dist/adapters/tron/decode.js.map +1 -1
- package/dist/adapters/tron/proofs.js +1 -0
- package/dist/adapters/tron/proofs.js.map +1 -1
- package/dist/adapters/tron/reader.d.ts +10 -0
- package/dist/adapters/tron/reader.js +17 -0
- package/dist/adapters/tron/reader.js.map +1 -1
- package/dist/adapters/tron/tokens.d.ts +2 -0
- package/dist/adapters/tron/tokens.js.map +1 -1
- package/dist/adapters/utxo/builder.js +1 -1
- package/dist/adapters/utxo/builder.js.map +1 -1
- package/dist/adapters/utxo/chains.js +2 -1
- package/dist/adapters/utxo/chains.js.map +1 -1
- package/dist/adapters/utxo/context.d.ts +6 -0
- package/dist/adapters/utxo/context.js +8 -1
- package/dist/adapters/utxo/context.js.map +1 -1
- package/dist/adapters/utxo/decode.d.ts +8 -0
- package/dist/adapters/utxo/decode.js +36 -0
- package/dist/adapters/utxo/decode.js.map +1 -1
- package/dist/adapters/utxo/driver.js +5 -0
- package/dist/adapters/utxo/driver.js.map +1 -1
- package/dist/adapters/utxo/esplora.d.ts +23 -2
- package/dist/adapters/utxo/esplora.js +49 -2
- package/dist/adapters/utxo/esplora.js.map +1 -1
- package/dist/adapters/utxo/proofs.d.ts +15 -6
- package/dist/adapters/utxo/proofs.js +185 -47
- package/dist/adapters/utxo/proofs.js.map +1 -1
- package/dist/adapters/utxo/rawblock.d.ts +46 -0
- package/dist/adapters/utxo/rawblock.js +159 -0
- package/dist/adapters/utxo/rawblock.js.map +1 -0
- package/dist/adapters/utxo/rawtx.d.ts +14 -0
- package/dist/adapters/utxo/rawtx.js +44 -14
- package/dist/adapters/utxo/rawtx.js.map +1 -1
- package/dist/core/blockchain/handle.d.ts +6 -27
- package/dist/core/blockchain/handle.js +112 -112
- package/dist/core/blockchain/handle.js.map +1 -1
- package/dist/core/config/types.d.ts +15 -0
- package/dist/core/config/types.js.map +1 -1
- package/dist/core/container/container.d.ts +1 -8
- package/dist/core/container/container.js +42 -8
- package/dist/core/container/container.js.map +1 -1
- package/dist/core/driver/types.d.ts +34 -1
- package/dist/core/driver/types.js.map +1 -1
- package/dist/core/errors/codes.d.ts +10 -0
- package/dist/core/errors/codes.js +4 -0
- package/dist/core/errors/codes.js.map +1 -1
- package/dist/core/lifecycle/engine-rules.d.ts +3 -4
- package/dist/core/lifecycle/engine-rules.js +16 -6
- package/dist/core/lifecycle/engine-rules.js.map +1 -1
- package/dist/core/lifecycle/engine.d.ts +2 -0
- package/dist/core/lifecycle/engine.js +19 -1
- package/dist/core/lifecycle/engine.js.map +1 -1
- package/dist/core/lifecycle/evaluate.js +9 -4
- package/dist/core/lifecycle/evaluate.js.map +1 -1
- package/dist/core/lifecycle/monitor.js +16 -6
- package/dist/core/lifecycle/monitor.js.map +1 -1
- package/dist/core/lifecycle/reconcile.d.ts +1 -1
- package/dist/core/lifecycle/reconcile.js +1 -1
- package/dist/core/lifecycle/reconcile.js.map +1 -1
- package/dist/core/lifecycle/workers.d.ts +9 -3
- package/dist/core/lifecycle/workers.js +32 -14
- package/dist/core/lifecycle/workers.js.map +1 -1
- package/dist/core/model/ids.d.ts +1 -0
- package/dist/core/model/ids.js +1 -0
- package/dist/core/model/ids.js.map +1 -1
- package/dist/core/model/ordering.d.ts +8 -0
- package/dist/core/model/ordering.js.map +1 -1
- package/dist/core/model/transaction.d.ts +7 -0
- package/dist/core/model/transaction.js.map +1 -1
- package/dist/core/observe/scanner.js +3 -0
- package/dist/core/observe/scanner.js.map +1 -1
- package/dist/core/signing/wallet.js +8 -0
- package/dist/core/signing/wallet.js.map +1 -1
- package/dist/core/store/format.d.ts +20 -0
- package/dist/core/store/format.js +86 -0
- package/dist/core/store/format.js.map +1 -0
- package/dist/core/store/memory.js +2 -2
- package/dist/core/store/memory.js.map +1 -1
- package/dist/core/store/types.d.ts +15 -3
- package/dist/core/store/types.js +2 -0
- package/dist/core/store/types.js.map +1 -1
- package/dist/core/transport/http-transport.js +21 -13
- package/dist/core/transport/http-transport.js.map +1 -1
- package/dist/core/transport/types.d.ts +16 -1
- package/dist/core/transport/types.js.map +1 -1
- package/dist/core/util/json.d.ts +7 -1
- package/dist/core/util/json.js +13 -4
- package/dist/core/util/json.js.map +1 -1
- package/dist/core/util/names.d.ts +6 -0
- package/dist/core/util/names.js +10 -0
- package/dist/core/util/names.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/testing/contracts/operations.js +20 -1
- package/dist/testing/contracts/operations.js.map +1 -1
- package/dist/testing/env.d.ts +5 -0
- package/dist/testing/env.js +1 -1
- package/dist/testing/env.js.map +1 -1
- package/dist/testing/faulty-store.d.ts +2 -0
- package/dist/testing/faulty-store.js +5 -0
- package/dist/testing/faulty-store.js.map +1 -1
- package/package.json +17 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/adapters/evm/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * SDK-free types of the EVM family: the `ext.evm` API, fee details and overrides, and the\n * narrow `EvmClient` strategy that `EthersClient` and `Web3Client` implement.\n * Nothing here imports an SDK, so the composition root can export these types.\n */\nimport type { DisposableNativeClient } from '../../core/driver/types';\nimport type { CallOptions } from '../../core/transport/types';\n\n// Augment the registries through the package entry, as users do with 'crypto-aio'.\ndeclare module '../../index' {\n interface ChainRegistry {\n ethereum: { family: 'evm'; network: 'mainnet' | 'sepolia' | 'hoodi' };\n bsc: { family: 'evm'; network: 'mainnet' | 'testnet' };\n polygon: { family: 'evm'; network: 'mainnet' | 'amoy' };\n avalanche: { family: 'evm'; network: 'mainnet' | 'fuji' };\n arbitrum: { family: 'evm'; network: 'mainnet' | 'sepolia' };\n optimism: { family: 'evm'; network: 'mainnet' | 'sepolia' };\n base: { family: 'evm'; network: 'mainnet' | 'sepolia' };\n }\n interface FamilyRegistry {\n evm: { library: 'ethers' | 'web3'; ext: EvmExt; fee: EvmFeeDetails };\n }\n}\n\n/** `bc.ext.evm`: the EVM family extension. */\nexport interface EvmExt {\n readonly evm: {\n /** The account nonce at `latest` (default) or including the mempool (`pending`). */\n getNonce(address: string, block?: 'latest' | 'pending'): Promise<bigint>;\n };\n}\n\n/** `FeeEstimate.details` of the `evm-1559` and `evm-legacy` fee kinds (wei, gas units). */\nexport interface EvmFeeDetails {\n readonly gasLimit: bigint;\n /** `evm-1559` only. */\n readonly maxFeePerGas?: bigint;\n /** `evm-1559` only. */\n readonly maxPriorityFeePerGas?: bigint;\n /** `evm-1559` only: the base fee the estimate expects for the next block. */\n readonly baseFeePerGas?: bigint;\n /** `evm-legacy` only. */\n readonly gasPrice?: bigint;\n /** OP Stack networks: the L1 data fee estimate, also charged as `l1-data`. */\n readonly l1Fee?: bigint;\n /** The expected total cost in wei; the `network` charge is its upper bound. */\n readonly expected: bigint;\n}\n\n/**\n * An explicit EVM fee (`TransferIntent.fee`). It must match the network's fee model:\n * `evm-1559` networks take `{ maxFeePerGas, maxPriorityFeePerGas }`, `evm-legacy` networks\n * take `{ gasPrice }`. `gasLimit` replaces the node's gas estimate.\n */\nexport type EvmFeeOverride =\n | {\n readonly maxFeePerGas: bigint;\n readonly maxPriorityFeePerGas: bigint;\n readonly gasLimit?: bigint;\n }\n | { readonly gasPrice: bigint; readonly gasLimit?: bigint };\n\n/**\n * The transport tags every EVM I/O call carries: purpose, retry, quorum, fanout,\n * signal. Under a quorum, `quorumKey` replaces the method's consensus facts (`rpc.ts`) with\n * the caller's own projection, e.g. a proof's finality attestation.\n */\nexport type EvmCallTags = Pick<\n CallOptions,\n 'purpose' | 'retry' | 'quorum' | 'quorumKey' | 'fanout' | 'signal'\n>;\n\n/** A block number or a JSON-RPC block tag. */\nexport type EvmBlockTag = bigint | 'latest' | 'pending' | 'safe' | 'finalized';\n\nexport interface EvmBlock {\n readonly number: bigint;\n readonly hash: string;\n readonly parentHash: string;\n readonly timestamp: number;\n readonly baseFeePerGas?: bigint;\n readonly transactions: readonly string[];\n}\n\nexport interface EvmTx {\n readonly hash: string;\n readonly from: string;\n readonly to: string | null;\n readonly nonce: bigint;\n readonly value: bigint;\n readonly input: string;\n readonly type: number;\n readonly gasLimit: bigint;\n readonly gasPrice?: bigint;\n readonly maxFeePerGas?: bigint;\n readonly maxPriorityFeePerGas?: bigint;\n readonly blockHash: string | null;\n readonly blockNumber: bigint | null;\n}\n\nexport interface EvmFullBlock extends Omit<EvmBlock, 'transactions'> {\n readonly transactions: readonly EvmTx[];\n /** The block's 256-byte log bloom, when the node serves a well-formed one. */\n readonly logsBloom?: string;\n}\n\nexport interface EvmLog {\n readonly address: string;\n readonly topics: readonly string[];\n readonly data: string;\n readonly logIndex: number;\n readonly blockHash: string;\n readonly blockNumber: bigint;\n readonly transactionHash: string;\n readonly removed: boolean;\n}\n\nexport interface EvmReceipt {\n readonly transactionHash: string;\n readonly blockHash: string;\n readonly blockNumber: bigint;\n readonly status: 0 | 1;\n readonly from: string;\n readonly to: string | null;\n readonly contractAddress: string | null;\n readonly gasUsed: bigint;\n readonly effectiveGasPrice: bigint;\n /** OP Stack receipts: the L1 data fee paid. */\n readonly l1Fee?: bigint;\n /** Arbitrum receipts: the part of `gasUsed` that paid for L1 data. */\n readonly gasUsedForL1?: bigint;\n readonly logs: readonly EvmLog[];\n}\n\nexport interface EvmFeeHistory {\n readonly oldestBlock: bigint;\n /** One entry per block, plus the next block's base fee last. */\n readonly baseFeePerGas: readonly bigint[];\n /** Per block, the requested percentiles of the priority fees paid. */\n readonly reward: readonly (readonly bigint[])[];\n readonly gasUsedRatio: readonly number[];\n}\n\nexport interface EvmCallRequest {\n readonly from?: string;\n readonly to: string;\n readonly value?: bigint;\n readonly data?: string;\n}\n\ninterface EvmTxFieldsBase {\n readonly chainId: bigint;\n readonly nonce: bigint;\n readonly to: string;\n readonly value: bigint;\n readonly data: string;\n readonly gasLimit: bigint;\n}\n\n/** The fields of an unsigned transaction: EIP-1559 (type 2) or legacy with EIP-155. */\nexport type EvmTxFields = EvmTxFieldsBase &\n (\n | {\n readonly type: 'eip1559';\n readonly maxFeePerGas: bigint;\n readonly maxPriorityFeePerGas: bigint;\n }\n | { readonly type: 'legacy'; readonly gasPrice: bigint }\n );\n\n/** A secp256k1 signature: 32-byte `r` and `s` as 0x-hex, and the y parity (0 or 1). */\nexport interface EvmSignature {\n readonly r: string;\n readonly s: string;\n readonly yParity: 0 | 1;\n}\n\n/** ABI work for the ERC-20 calls and events the driver uses, done by the SDK. */\nexport interface EvmAbi {\n /** `keccak256(\"Transfer(address,address,uint256)\")`. */\n readonly transferTopic: string;\n encodeTransfer(to: string, amount: bigint): string;\n encodeBalanceOf(owner: string): string;\n encodeDecimals(): string;\n encodeSymbol(): string;\n /** OP Stack `GasPriceOracle.getL1Fee(bytes)` over an unsigned serialized transaction. */\n encodeGetL1Fee(unsignedTx: string): string;\n /** Throws on data that is not one ABI `uint256` word. */\n decodeUint256(data: string): bigint;\n /** Throws on data that is not an ABI `string`. */\n decodeString(data: string): string;\n /** An ERC-20 `Transfer` log's parties and amount; `null` for any other log. */\n decodeTransfer(log: {\n readonly topics: readonly string[];\n readonly data: string;\n }): { readonly from: string; readonly to: string; readonly amount: bigint } | null;\n}\n\n/**\n * The EVM strategy: the SDK-specific part of the EVM driver. I/O methods take the call's\n * transport tags and return plain data (bigint, hex strings, plain objects), never SDK\n * objects, so any result can go into a store record; `null` means not found. Codec\n * methods are synchronous.\n */\nexport interface EvmClient {\n readonly library: string;\n blockNumber(tags: EvmCallTags): Promise<bigint>;\n getBalance(address: string, block: EvmBlockTag, tags: EvmCallTags): Promise<bigint>;\n getTransactionCount(\n address: string,\n block: EvmBlockTag,\n tags: EvmCallTags,\n ): Promise<bigint>;\n call(request: EvmCallRequest, block: EvmBlockTag, tags: EvmCallTags): Promise<string>;\n estimateGas(request: EvmCallRequest, tags: EvmCallTags): Promise<bigint>;\n gasPrice(tags: EvmCallTags): Promise<bigint>;\n feeHistory(\n blockCount: number,\n newest: EvmBlockTag,\n percentiles: readonly number[],\n tags: EvmCallTags,\n ): Promise<EvmFeeHistory>;\n /** By number or tag, or by hash when `block` is a 0x-prefixed 32-byte hash. */\n getBlock(block: EvmBlockTag | string, tags: EvmCallTags): Promise<EvmBlock | null>;\n getBlockWithTransactions(\n block: bigint,\n tags: EvmCallTags,\n ): Promise<EvmFullBlock | null>;\n getTransaction(hash: string, tags: EvmCallTags): Promise<EvmTx | null>;\n getReceipt(hash: string, tags: EvmCallTags): Promise<EvmReceipt | null>;\n /**\n * Every receipt of the block with this hash, in block order (`eth_getBlockReceipts`):\n * read by block, so a node serves them without a transaction or log index. `null` for a\n * block the node does not know.\n */\n getBlockReceipts(\n blockHash: string,\n tags: EvmCallTags,\n ): Promise<readonly EvmReceipt[] | null>;\n getLogs(\n filter: { readonly blockHash: string; readonly topics: readonly (string | null)[] },\n tags: EvmCallTags,\n ): Promise<readonly EvmLog[]>;\n /** Resolves with the transaction hash the node reports. */\n sendRawTransaction(raw: string, tags: EvmCallTags): Promise<string>;\n /** Strict: `0x` and 40 hex digits; mixed case must be a valid EIP-55 checksum. */\n isAddress(value: string): boolean;\n /** EIP-55 checksum form; throws on an invalid address. */\n checksum(address: string): string;\n /** From a 33-byte compressed or 65-byte uncompressed secp256k1 public key. */\n addressFromPublicKey(publicKey: Uint8Array): string;\n serializeUnsigned(tx: EvmTxFields): string;\n /** The keccak-256 digest a signer signs. */\n unsignedHash(tx: EvmTxFields): string;\n serializeSigned(\n tx: EvmTxFields,\n signature: EvmSignature,\n ): { readonly raw: string; readonly hash: string };\n readonly abi: EvmAbi;\n /** A fresh SDK client on the same transport, for `crypto-aio/native`. */\n createNative(): DisposableNativeClient;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/adapters/evm/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * SDK-free types of the EVM family: the `ext.evm` API, fee details and overrides, and the\n * narrow `EvmClient` strategy that `EthersClient` and `Web3Client` implement.\n * Nothing here imports an SDK, so the composition root can export these types.\n */\nimport type { DisposableNativeClient } from '../../core/driver/types';\nimport type { CallOptions } from '../../core/transport/types';\n\n// Augment the registries through the package entry, as users do with 'crypto-aio'.\ndeclare module '../../index' {\n interface ChainRegistry {\n ethereum: { family: 'evm'; network: 'mainnet' | 'sepolia' | 'hoodi' };\n bsc: { family: 'evm'; network: 'mainnet' | 'testnet' };\n polygon: { family: 'evm'; network: 'mainnet' | 'amoy' };\n avalanche: { family: 'evm'; network: 'mainnet' | 'fuji' };\n arbitrum: { family: 'evm'; network: 'mainnet' | 'sepolia' };\n optimism: { family: 'evm'; network: 'mainnet' | 'sepolia' };\n base: { family: 'evm'; network: 'mainnet' | 'sepolia' };\n }\n interface FamilyRegistry {\n evm: { library: 'ethers' | 'web3'; ext: EvmExt; fee: EvmFeeDetails };\n }\n}\n\n/** `bc.ext.evm`: the EVM family extension. */\nexport interface EvmExt {\n readonly evm: {\n /** The account nonce at `latest` (default) or including the mempool (`pending`). */\n getNonce(address: string, block?: 'latest' | 'pending'): Promise<bigint>;\n };\n}\n\n/** `FeeEstimate.details` of the `evm-1559` and `evm-legacy` fee kinds (wei, gas units). */\nexport interface EvmFeeDetails {\n readonly gasLimit: bigint;\n /** `evm-1559` only. */\n readonly maxFeePerGas?: bigint;\n /** `evm-1559` only. */\n readonly maxPriorityFeePerGas?: bigint;\n /** `evm-1559` only: the base fee the estimate expects for the next block. */\n readonly baseFeePerGas?: bigint;\n /** `evm-legacy` only. */\n readonly gasPrice?: bigint;\n /** OP Stack networks: the L1 data fee estimate, also charged as `l1-data`. */\n readonly l1Fee?: bigint;\n /**\n * OP Stack networks since Isthmus, where it is not zero: the operator fee for the whole\n * gas limit (an upper bound at the chain's current operator settings), also charged as\n * `operator`.\n */\n readonly operatorFee?: bigint;\n /** The expected total cost in wei; the `network` charge is its upper bound. */\n readonly expected: bigint;\n}\n\n/**\n * An explicit EVM fee (`TransferIntent.fee`). It must match the network's fee model:\n * `evm-1559` networks take `{ maxFeePerGas, maxPriorityFeePerGas }`, `evm-legacy` networks\n * take `{ gasPrice }`. `gasLimit` replaces the node's gas estimate.\n */\nexport type EvmFeeOverride =\n | {\n readonly maxFeePerGas: bigint;\n readonly maxPriorityFeePerGas: bigint;\n readonly gasLimit?: bigint;\n }\n | { readonly gasPrice: bigint; readonly gasLimit?: bigint };\n\n/**\n * The transport tags every EVM I/O call carries: purpose, retry, quorum, fanout,\n * signal. Under a quorum, `quorumKey` replaces the method's consensus facts (`rpc.ts`) with\n * the caller's own projection, e.g. a proof's finality attestation.\n */\nexport type EvmCallTags = Pick<\n CallOptions,\n 'purpose' | 'retry' | 'quorum' | 'quorumKey' | 'fanout' | 'signal'\n>;\n\n/** A block number or a JSON-RPC block tag. */\nexport type EvmBlockTag = bigint | 'latest' | 'pending' | 'safe' | 'finalized';\n\nexport interface EvmBlock {\n readonly number: bigint;\n readonly hash: string;\n readonly parentHash: string;\n readonly timestamp: number;\n readonly baseFeePerGas?: bigint;\n readonly transactions: readonly string[];\n}\n\nexport interface EvmTx {\n readonly hash: string;\n readonly from: string;\n readonly to: string | null;\n readonly nonce: bigint;\n readonly value: bigint;\n readonly input: string;\n readonly type: number;\n readonly gasLimit: bigint;\n readonly gasPrice?: bigint;\n readonly maxFeePerGas?: bigint;\n readonly maxPriorityFeePerGas?: bigint;\n readonly blockHash: string | null;\n readonly blockNumber: bigint | null;\n}\n\nexport interface EvmFullBlock extends Omit<EvmBlock, 'transactions'> {\n readonly transactions: readonly EvmTx[];\n /** The block's 256-byte log bloom, when the node serves a well-formed one. */\n readonly logsBloom?: string;\n}\n\nexport interface EvmLog {\n readonly address: string;\n readonly topics: readonly string[];\n readonly data: string;\n readonly logIndex: number;\n readonly blockHash: string;\n readonly blockNumber: bigint;\n readonly transactionHash: string;\n readonly removed: boolean;\n}\n\nexport interface EvmReceipt {\n readonly transactionHash: string;\n readonly blockHash: string;\n readonly blockNumber: bigint;\n readonly status: 0 | 1;\n readonly from: string;\n readonly to: string | null;\n readonly contractAddress: string | null;\n readonly gasUsed: bigint;\n readonly effectiveGasPrice: bigint;\n /** OP Stack receipts: the L1 data fee paid. */\n readonly l1Fee?: bigint;\n /** Arbitrum receipts: the part of `gasUsed` that paid for L1 data. */\n readonly gasUsedForL1?: bigint;\n readonly logs: readonly EvmLog[];\n}\n\nexport interface EvmFeeHistory {\n readonly oldestBlock: bigint;\n /** One entry per block, plus the next block's base fee last. */\n readonly baseFeePerGas: readonly bigint[];\n /** Per block, the requested percentiles of the priority fees paid. */\n readonly reward: readonly (readonly bigint[])[];\n readonly gasUsedRatio: readonly number[];\n}\n\nexport interface EvmCallRequest {\n readonly from?: string;\n readonly to: string;\n readonly value?: bigint;\n readonly data?: string;\n}\n\ninterface EvmTxFieldsBase {\n readonly chainId: bigint;\n readonly nonce: bigint;\n readonly to: string;\n readonly value: bigint;\n readonly data: string;\n readonly gasLimit: bigint;\n}\n\n/** The fields of an unsigned transaction: EIP-1559 (type 2) or legacy with EIP-155. */\nexport type EvmTxFields = EvmTxFieldsBase &\n (\n | {\n readonly type: 'eip1559';\n readonly maxFeePerGas: bigint;\n readonly maxPriorityFeePerGas: bigint;\n }\n | { readonly type: 'legacy'; readonly gasPrice: bigint }\n );\n\n/** A secp256k1 signature: 32-byte `r` and `s` as 0x-hex, and the y parity (0 or 1). */\nexport interface EvmSignature {\n readonly r: string;\n readonly s: string;\n readonly yParity: 0 | 1;\n}\n\n/** ABI work for the ERC-20 calls and events the driver uses, done by the SDK. */\nexport interface EvmAbi {\n /** `keccak256(\"Transfer(address,address,uint256)\")`. */\n readonly transferTopic: string;\n encodeTransfer(to: string, amount: bigint): string;\n encodeBalanceOf(owner: string): string;\n encodeDecimals(): string;\n encodeSymbol(): string;\n /** `deprecated()`, which Tether's `TetherToken` answers `true` once it forwards transfers. */\n encodeDeprecated(): string;\n /** OP Stack `GasPriceOracle.getL1Fee(bytes)` over an unsigned serialized transaction. */\n encodeGetL1Fee(unsignedTx: string): string;\n /** OP Stack `GasPriceOracle.getOperatorFee(uint256)` for `gasUsed` (since Isthmus). */\n encodeGetOperatorFee(gasUsed: bigint): string;\n /** Throws on data that is not one ABI `uint256` word. */\n decodeUint256(data: string): bigint;\n /** Throws on data that is not an ABI `string`. */\n decodeString(data: string): string;\n /** An ERC-20 `Transfer` log's parties and amount; `null` for any other log. */\n decodeTransfer(log: {\n readonly topics: readonly string[];\n readonly data: string;\n }): { readonly from: string; readonly to: string; readonly amount: bigint } | null;\n}\n\n/**\n * The EVM strategy: the SDK-specific part of the EVM driver. I/O methods take the call's\n * transport tags and return plain data (bigint, hex strings, plain objects), never SDK\n * objects, so any result can go into a store record; `null` means not found. Codec\n * methods are synchronous.\n */\nexport interface EvmClient {\n readonly library: string;\n blockNumber(tags: EvmCallTags): Promise<bigint>;\n getBalance(address: string, block: EvmBlockTag, tags: EvmCallTags): Promise<bigint>;\n getTransactionCount(\n address: string,\n block: EvmBlockTag,\n tags: EvmCallTags,\n ): Promise<bigint>;\n call(request: EvmCallRequest, block: EvmBlockTag, tags: EvmCallTags): Promise<string>;\n estimateGas(request: EvmCallRequest, tags: EvmCallTags): Promise<bigint>;\n gasPrice(tags: EvmCallTags): Promise<bigint>;\n feeHistory(\n blockCount: number,\n newest: EvmBlockTag,\n percentiles: readonly number[],\n tags: EvmCallTags,\n ): Promise<EvmFeeHistory>;\n /** By number or tag, or by hash when `block` is a 0x-prefixed 32-byte hash. */\n getBlock(block: EvmBlockTag | string, tags: EvmCallTags): Promise<EvmBlock | null>;\n getBlockWithTransactions(\n block: bigint,\n tags: EvmCallTags,\n ): Promise<EvmFullBlock | null>;\n getTransaction(hash: string, tags: EvmCallTags): Promise<EvmTx | null>;\n getReceipt(hash: string, tags: EvmCallTags): Promise<EvmReceipt | null>;\n /**\n * Every receipt of the block with this hash, in block order (`eth_getBlockReceipts`):\n * read by block, so a node serves them without a transaction or log index. `null` for a\n * block the node does not know.\n */\n getBlockReceipts(\n blockHash: string,\n tags: EvmCallTags,\n ): Promise<readonly EvmReceipt[] | null>;\n getLogs(\n filter: { readonly blockHash: string; readonly topics: readonly (string | null)[] },\n tags: EvmCallTags,\n ): Promise<readonly EvmLog[]>;\n /** Resolves with the transaction hash the node reports. */\n sendRawTransaction(raw: string, tags: EvmCallTags): Promise<string>;\n /** Strict: `0x` and 40 hex digits; mixed case must be a valid EIP-55 checksum. */\n isAddress(value: string): boolean;\n /** EIP-55 checksum form; throws on an invalid address. */\n checksum(address: string): string;\n /** From a 33-byte compressed or 65-byte uncompressed secp256k1 public key. */\n addressFromPublicKey(publicKey: Uint8Array): string;\n serializeUnsigned(tx: EvmTxFields): string;\n /** The keccak-256 digest a signer signs. */\n unsignedHash(tx: EvmTxFields): string;\n serializeSigned(\n tx: EvmTxFields,\n signature: EvmSignature,\n ): { readonly raw: string; readonly hash: string };\n readonly abi: EvmAbi;\n /** A fresh SDK client on the same transport, for `crypto-aio/native`. */\n createNative(): DisposableNativeClient;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DisposableNativeClient } from '../../core/driver/types';
|
|
1
|
+
import type { DisposableNativeClient, DriverFactory } from '../../core/driver/types';
|
|
2
2
|
import type { Transport } from '../../core/transport/types';
|
|
3
3
|
import { EvmClientBase } from './client';
|
|
4
4
|
import type { EvmAbi, EvmCallTags, EvmSignature, EvmTxFields } from './types';
|
|
@@ -19,5 +19,8 @@ export declare class Web3Client extends EvmClientBase {
|
|
|
19
19
|
};
|
|
20
20
|
createNative(): DisposableNativeClient;
|
|
21
21
|
}
|
|
22
|
-
/**
|
|
23
|
-
|
|
22
|
+
/**
|
|
23
|
+
* The web3 strategy's factory: its first driver in a process warns, once, that the library
|
|
24
|
+
* is deprecated (a Node.js `DeprecationWarning`, code `CRYPTO_AIO_WEB3`).
|
|
25
|
+
*/
|
|
26
|
+
export declare const web3DriverFactory: DriverFactory;
|
|
@@ -5,7 +5,7 @@ exports.web3DriverFactory = exports.Web3Client = void 0;
|
|
|
5
5
|
* `Web3Client`: the web3 v4 strategy. Its I/O goes through an EIP-1193 provider object whose
|
|
6
6
|
* `request` hands every call to the core transport, one request manager per call so each
|
|
7
7
|
* request carries that call's tags. ChainSafe sunset web3.js in 2025 (4.16.0 is the last
|
|
8
|
-
* release); ethers stays the default.
|
|
8
|
+
* release); ethers stays the default, and `library: 'web3'` is deprecated (removed in 2.0).
|
|
9
9
|
*/
|
|
10
10
|
const web3_1 = require("web3");
|
|
11
11
|
const error_1 = require("../../core/errors/error");
|
|
@@ -31,7 +31,9 @@ const web3Abi = {
|
|
|
31
31
|
encodeBalanceOf: (owner) => web3_1.eth.abi.encodeFunctionCall(fn('balanceOf', ['address']), [owner]),
|
|
32
32
|
encodeDecimals: () => web3_1.eth.abi.encodeFunctionCall(fn('decimals', []), []),
|
|
33
33
|
encodeSymbol: () => web3_1.eth.abi.encodeFunctionCall(fn('symbol', []), []),
|
|
34
|
+
encodeDeprecated: () => web3_1.eth.abi.encodeFunctionCall(fn('deprecated', []), []),
|
|
34
35
|
encodeGetL1Fee: (unsignedTx) => web3_1.eth.abi.encodeFunctionCall(fn('getL1Fee', ['bytes']), [unsignedTx]),
|
|
36
|
+
encodeGetOperatorFee: (gasUsed) => web3_1.eth.abi.encodeFunctionCall(fn('getOperatorFee', ['uint256']), [gasUsed]),
|
|
35
37
|
decodeUint256: (data) => {
|
|
36
38
|
if (!client_1.ABI_WORD.test(data))
|
|
37
39
|
throw new Error('not one ABI word');
|
|
@@ -155,5 +157,20 @@ class Web3Client extends client_1.EvmClientBase {
|
|
|
155
157
|
}
|
|
156
158
|
exports.Web3Client = Web3Client;
|
|
157
159
|
/** The `web3` adapter's driver factory; the manifest's `load()` returns it. */
|
|
158
|
-
|
|
160
|
+
const factory = (0, driver_1.evmDriverFactory)((transport, chainId) => new Web3Client(transport, chainId));
|
|
161
|
+
let warned = false;
|
|
162
|
+
/**
|
|
163
|
+
* The web3 strategy's factory: its first driver in a process warns, once, that the library
|
|
164
|
+
* is deprecated (a Node.js `DeprecationWarning`, code `CRYPTO_AIO_WEB3`).
|
|
165
|
+
*/
|
|
166
|
+
exports.web3DriverFactory = {
|
|
167
|
+
create(ctx) {
|
|
168
|
+
if (!warned) {
|
|
169
|
+
warned = true;
|
|
170
|
+
process.emitWarning("crypto-aio: library 'web3' is deprecated: web3.js is no longer maintained (4.16.0 " +
|
|
171
|
+
"is its last release). Use 'ethers', the default; 'web3' is removed in crypto-aio 2.0.", { type: 'DeprecationWarning', code: 'CRYPTO_AIO_WEB3' });
|
|
172
|
+
}
|
|
173
|
+
return factory.create(ctx);
|
|
174
|
+
},
|
|
175
|
+
};
|
|
159
176
|
//# sourceMappingURL=web3-client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web3-client.js","sourceRoot":"","sources":["../../../src/adapters/evm/web3-client.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,+BAA8C;AAE9C,mDAA0E;AAE1E,qCAMkB;AAClB,qCAA4C;AAC5C,+BAA8D;AAO9D,2EAA2E;AAC3E,SAAS,OAAO,CACd,IAA2D;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AAC,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC5D,EACD,OAAO,CACR,CAAC;IACJ,CAAC;CACF;AAlHD,gCAkHC;AAED,+EAA+E;AAClE,QAAA,iBAAiB,GAAG,IAAA,yBAAgB,EAC/C,CAAC,SAAS,EAAE,OAAO,EAAE,EAAE,CAAC,IAAI,UAAU,CAAC,SAAS,EAAE,OAAO,CAAC,CAC3D,CAAC","sourcesContent":["/**\n * `Web3Client`: the web3 v4 strategy. Its I/O goes through an EIP-1193 provider object whose\n * `request` hands every call to the core transport, one request manager per call so each\n * request carries that call's tags. ChainSafe sunset web3.js in 2025 (4.16.0 is the last\n * release); ethers stays the default.\n */\nimport { Web3, core, eth, utils } from 'web3';\nimport type { DisposableNativeClient } from '../../core/driver/types';\nimport { ProviderError, isCryptoAioError } from '../../core/errors/error';\nimport type { Transport } from '../../core/transport/types';\nimport {\n ABI_WORD,\n ADDRESS,\n EvmClientBase,\n transferLogWords,\n uncompressedPublicKey,\n} from './client';\nimport { evmDriverFactory } from './driver';\nimport { nativeTags, throughSdk, transportCall } from './rpc';\nimport type { EvmAbi, EvmCallTags, EvmSignature, EvmTxFields } from './types';\n\ninterface Eip1193Provider {\n request(args: { readonly method: string; readonly params?: unknown }): Promise<unknown>;\n}\n\n/** An EIP-1193 provider bridged onto the core transport through `call`. */\nfunction eip1193(\n call: (method: string, params: unknown) => Promise<unknown>,\n): Eip1193Provider {\n // An async function, so web3 4.16 takes its EIP-1193 path (it checks the function's\n // constructor name), not its legacy request-provider path. The EIP-1193 path arms no\n // timer, so a driver request never waits on one.\n return { request: async ({ method, params }) => call(method, params) };\n}\n\nconst fn = (name: string, inputs: readonly string[]) => ({\n name,\n type: 'function',\n inputs: inputs.map((type, i) => ({ type, name: `a${i}` })),\n});\nconst TRANSFER_TOPIC = eth.abi.encodeEventSignature('Transfer(address,address,uint256)');\n\nconst web3Abi: EvmAbi = {\n transferTopic: TRANSFER_TOPIC,\n encodeTransfer: (to, amount) =>\n eth.abi.encodeFunctionCall(fn('transfer', ['address', 'uint256']), [to, amount]),\n encodeBalanceOf: (owner) =>\n eth.abi.encodeFunctionCall(fn('balanceOf', ['address']), [owner]),\n encodeDecimals: () => eth.abi.encodeFunctionCall(fn('decimals', []), []),\n encodeSymbol: () => eth.abi.encodeFunctionCall(fn('symbol', []), []),\n encodeGetL1Fee: (unsignedTx) =>\n eth.abi.encodeFunctionCall(fn('getL1Fee', ['bytes']), [unsignedTx]),\n decodeUint256: (data) => {\n if (!ABI_WORD.test(data)) throw new Error('not one ABI word');\n return BigInt(eth.abi.decodeParameter('uint256', data) as bigint);\n },\n decodeString: (data) => eth.abi.decodeParameter('string', data) as string,\n decodeTransfer: (log) => {\n const words = transferLogWords(log, TRANSFER_TOPIC);\n if (!words) return null;\n const address = (word: string) =>\n utils.toChecksumAddress(eth.abi.decodeParameter('address', word) as string);\n return {\n from: address(words.from),\n to: address(words.to),\n amount: BigInt(eth.abi.decodeParameter('uint256', words.data) as bigint),\n };\n },\n};\n\n/** RLP of a list of byte strings (web3 exposes no RLP encoder; used for legacy payloads). */\nfunction rlpList(items: readonly Uint8Array[]): Uint8Array {\n const length = (size: number, offset: number): number[] => {\n if (size < 56) return [offset + size];\n const bytes: number[] = [];\n for (let rest = size; rest > 0; rest = Math.floor(rest / 256))\n bytes.unshift(rest % 256);\n return [offset + 55 + bytes.length, ...bytes];\n };\n const encoded = items.map((item) =>\n item.length === 1 && (item[0] as number) < 0x80\n ? [...item]\n : [...length(item.length, 0x80), ...item],\n );\n const payload = encoded.flat();\n return Uint8Array.from([...length(payload.length, 0xc0), ...payload]);\n}\n\nexport class Web3Client extends EvmClientBase {\n readonly library = 'web3';\n readonly abi = web3Abi;\n readonly #transport: Transport;\n readonly #common: InstanceType<typeof eth.accounts.Common>;\n\n constructor(transport: Transport, chainId: bigint) {\n super(chainId);\n this.#transport = transport;\n this.#common = eth.accounts.Common.custom(\n { chainId: Number(chainId), networkId: Number(chainId) },\n { hardfork: 'london' },\n );\n }\n\n protected send(\n method: string,\n params: readonly unknown[],\n tags: EvmCallTags,\n ): Promise<unknown> {\n return throughSdk(\n async (call) => {\n const manager = new core.Web3RequestManager(eip1193(call) as never);\n try {\n return await manager.send({ method, params: [...params] } as never);\n } catch (error) {\n // web3 reads an answer shaped like a JSON-RPC error as an error of its own.\n // A transport failure is put back by `throughSdk`; anything else is the answer's.\n if (isCryptoAioError(error)) throw error;\n throw new ProviderError('PROVIDER_UNAVAILABLE', 'malformed JSON-RPC answer');\n }\n },\n this.#transport,\n tags,\n );\n }\n\n isAddress(value: string): boolean {\n return ADDRESS.test(value) && utils.isAddress(value);\n }\n\n checksum(address: string): string {\n return this.checked(address, (value) => {\n if (!utils.isAddress(value)) throw new Error('bad checksum');\n return utils.toChecksumAddress(value);\n });\n }\n\n addressFromPublicKey(publicKey: Uint8Array): string {\n // The shared strict decode, so both clients refuse exactly the same keys.\n const digest = utils.keccak256(uncompressedPublicKey(publicKey).slice(1));\n return utils.toChecksumAddress(`0x${digest.slice(-40)}`);\n }\n\n protected encodeUnsigned(tx: EvmTxFields): string {\n const message = this.#tx(tx).getMessageToSign(false);\n return utils.bytesToHex(Array.isArray(message) ? rlpList(message) : message);\n }\n\n protected hashUnsigned(tx: EvmTxFields): string {\n return utils.bytesToHex(this.#tx(tx).getMessageToSign(true));\n }\n\n protected encodeSigned(\n tx: EvmTxFields,\n signature: EvmSignature,\n ): { raw: string; hash: string } {\n const signed = this.#tx(tx, signature);\n return {\n raw: utils.bytesToHex(signed.serialize()),\n hash: utils.bytesToHex(signed.hash()),\n };\n }\n\n createNative(): DisposableNativeClient {\n const call = (method: string, params: unknown) =>\n transportCall(this.#transport, method, params, nativeTags(method));\n return { client: new Web3(eip1193(call) as never) };\n }\n\n #tx(tx: EvmTxFields, signature?: EvmSignature) {\n const common = {\n nonce: tx.nonce,\n to: tx.to,\n value: tx.value,\n data: tx.data,\n gasLimit: tx.gasLimit,\n };\n const options = { common: this.#common };\n if (tx.type === 'eip1559') {\n return eth.accounts.FeeMarketEIP1559Transaction.fromTxData(\n {\n ...common,\n chainId: tx.chainId,\n maxFeePerGas: tx.maxFeePerGas,\n maxPriorityFeePerGas: tx.maxPriorityFeePerGas,\n accessList: [],\n ...(signature\n ? { v: BigInt(signature.yParity), r: signature.r, s: signature.s }\n : {}),\n },\n options,\n );\n }\n const v = signature && this.chainId * 2n + 35n + BigInt(signature.yParity);\n return eth.accounts.Transaction.fromTxData(\n {\n ...common,\n gasPrice: tx.gasPrice,\n ...(signature ? { v, r: signature.r, s: signature.s } : {}),\n },\n options,\n );\n }\n}\n\n/** The `web3` adapter's driver factory; the manifest's `load()` returns it. */\nexport const web3DriverFactory = evmDriverFactory(\n (transport, chainId) => new Web3Client(transport, chainId),\n);\n"]}
|
|
1
|
+
{"version":3,"file":"web3-client.js","sourceRoot":"","sources":["../../../src/adapters/evm/web3-client.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,+BAA8C;AAE9C,mDAA0E;AAE1E,qCAMkB;AAClB,qCAA4C;AAC5C,+BAA8D;AAO9D,2EAA2E;AAC3E,SAAS,OAAO,CACd,IAA2D;IAE3D,oFAAoF;IACpF,qFAAqF;IACrF,iDAAiD;IACjD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;AACzE,CAAC;AAED,MAAM,EAAE,GAAG,CAAC,IAAY,EAAE,MAAyB,EAAE,EAAE,CAAC,CAAC;IACvD,IAAI;IACJ,IAAI,EAAE,UAAU;IAChB,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;CAC3D,CAAC,CAAC;AACH,MAAM,cAAc,GAAG,UAAG,CA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AO,EAAE,EAAE,CAAC,IAAI,UAAU,CAAC,SAAS,EAAE,OAAO,CAAC,CAC3D,CAAC;AAEF,IAAI,MAAM,GAAG,KAAK,CAAC;AAEnB;;;GAGG;AACU,QAAA,iBAAiB,GAAkB;IAC9C,MAAM,CAAC,GAAG;QACR,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,GAAG,IAAI,CAAC;YACd,OAAO,CAAC,WAAW,CACjB,oFAAoF;gBAClF,uFAAuF,EACzF,EAAE,IAAI,EAAE,oBAAoB,EAAE,IAAI,EAAE,iBAAiB,EAAE,CACxD,CAAC;QACJ,CAAC;QACD,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;CACF,CAAC","sourcesContent":["/**\n * `Web3Client`: the web3 v4 strategy. Its I/O goes through an EIP-1193 provider object whose\n * `request` hands every call to the core transport, one request manager per call so each\n * request carries that call's tags. ChainSafe sunset web3.js in 2025 (4.16.0 is the last\n * release); ethers stays the default, and `library: 'web3'` is deprecated (removed in 2.0).\n */\nimport { Web3, core, eth, utils } from 'web3';\nimport type { DisposableNativeClient, DriverFactory } from '../../core/driver/types';\nimport { ProviderError, isCryptoAioError } from '../../core/errors/error';\nimport type { Transport } from '../../core/transport/types';\nimport {\n ABI_WORD,\n ADDRESS,\n EvmClientBase,\n transferLogWords,\n uncompressedPublicKey,\n} from './client';\nimport { evmDriverFactory } from './driver';\nimport { nativeTags, throughSdk, transportCall } from './rpc';\nimport type { EvmAbi, EvmCallTags, EvmSignature, EvmTxFields } from './types';\n\ninterface Eip1193Provider {\n request(args: { readonly method: string; readonly params?: unknown }): Promise<unknown>;\n}\n\n/** An EIP-1193 provider bridged onto the core transport through `call`. */\nfunction eip1193(\n call: (method: string, params: unknown) => Promise<unknown>,\n): Eip1193Provider {\n // An async function, so web3 4.16 takes its EIP-1193 path (it checks the function's\n // constructor name), not its legacy request-provider path. The EIP-1193 path arms no\n // timer, so a driver request never waits on one.\n return { request: async ({ method, params }) => call(method, params) };\n}\n\nconst fn = (name: string, inputs: readonly string[]) => ({\n name,\n type: 'function',\n inputs: inputs.map((type, i) => ({ type, name: `a${i}` })),\n});\nconst TRANSFER_TOPIC = eth.abi.encodeEventSignature('Transfer(address,address,uint256)');\n\nconst web3Abi: EvmAbi = {\n transferTopic: TRANSFER_TOPIC,\n encodeTransfer: (to, amount) =>\n eth.abi.encodeFunctionCall(fn('transfer', ['address', 'uint256']), [to, amount]),\n encodeBalanceOf: (owner) =>\n eth.abi.encodeFunctionCall(fn('balanceOf', ['address']), [owner]),\n encodeDecimals: () => eth.abi.encodeFunctionCall(fn('decimals', []), []),\n encodeSymbol: () => eth.abi.encodeFunctionCall(fn('symbol', []), []),\n encodeDeprecated: () => eth.abi.encodeFunctionCall(fn('deprecated', []), []),\n encodeGetL1Fee: (unsignedTx) =>\n eth.abi.encodeFunctionCall(fn('getL1Fee', ['bytes']), [unsignedTx]),\n encodeGetOperatorFee: (gasUsed) =>\n eth.abi.encodeFunctionCall(fn('getOperatorFee', ['uint256']), [gasUsed]),\n decodeUint256: (data) => {\n if (!ABI_WORD.test(data)) throw new Error('not one ABI word');\n return BigInt(eth.abi.decodeParameter('uint256', data) as bigint);\n },\n decodeString: (data) => eth.abi.decodeParameter('string', data) as string,\n decodeTransfer: (log) => {\n const words = transferLogWords(log, TRANSFER_TOPIC);\n if (!words) return null;\n const address = (word: string) =>\n utils.toChecksumAddress(eth.abi.decodeParameter('address', word) as string);\n return {\n from: address(words.from),\n to: address(words.to),\n amount: BigInt(eth.abi.decodeParameter('uint256', words.data) as bigint),\n };\n },\n};\n\n/** RLP of a list of byte strings (web3 exposes no RLP encoder; used for legacy payloads). */\nfunction rlpList(items: readonly Uint8Array[]): Uint8Array {\n const length = (size: number, offset: number): number[] => {\n if (size < 56) return [offset + size];\n const bytes: number[] = [];\n for (let rest = size; rest > 0; rest = Math.floor(rest / 256))\n bytes.unshift(rest % 256);\n return [offset + 55 + bytes.length, ...bytes];\n };\n const encoded = items.map((item) =>\n item.length === 1 && (item[0] as number) < 0x80\n ? [...item]\n : [...length(item.length, 0x80), ...item],\n );\n const payload = encoded.flat();\n return Uint8Array.from([...length(payload.length, 0xc0), ...payload]);\n}\n\nexport class Web3Client extends EvmClientBase {\n readonly library = 'web3';\n readonly abi = web3Abi;\n readonly #transport: Transport;\n readonly #common: InstanceType<typeof eth.accounts.Common>;\n\n constructor(transport: Transport, chainId: bigint) {\n super(chainId);\n this.#transport = transport;\n this.#common = eth.accounts.Common.custom(\n { chainId: Number(chainId), networkId: Number(chainId) },\n { hardfork: 'london' },\n );\n }\n\n protected send(\n method: string,\n params: readonly unknown[],\n tags: EvmCallTags,\n ): Promise<unknown> {\n return throughSdk(\n async (call) => {\n const manager = new core.Web3RequestManager(eip1193(call) as never);\n try {\n return await manager.send({ method, params: [...params] } as never);\n } catch (error) {\n // web3 reads an answer shaped like a JSON-RPC error as an error of its own.\n // A transport failure is put back by `throughSdk`; anything else is the answer's.\n if (isCryptoAioError(error)) throw error;\n throw new ProviderError('PROVIDER_UNAVAILABLE', 'malformed JSON-RPC answer');\n }\n },\n this.#transport,\n tags,\n );\n }\n\n isAddress(value: string): boolean {\n return ADDRESS.test(value) && utils.isAddress(value);\n }\n\n checksum(address: string): string {\n return this.checked(address, (value) => {\n if (!utils.isAddress(value)) throw new Error('bad checksum');\n return utils.toChecksumAddress(value);\n });\n }\n\n addressFromPublicKey(publicKey: Uint8Array): string {\n // The shared strict decode, so both clients refuse exactly the same keys.\n const digest = utils.keccak256(uncompressedPublicKey(publicKey).slice(1));\n return utils.toChecksumAddress(`0x${digest.slice(-40)}`);\n }\n\n protected encodeUnsigned(tx: EvmTxFields): string {\n const message = this.#tx(tx).getMessageToSign(false);\n return utils.bytesToHex(Array.isArray(message) ? rlpList(message) : message);\n }\n\n protected hashUnsigned(tx: EvmTxFields): string {\n return utils.bytesToHex(this.#tx(tx).getMessageToSign(true));\n }\n\n protected encodeSigned(\n tx: EvmTxFields,\n signature: EvmSignature,\n ): { raw: string; hash: string } {\n const signed = this.#tx(tx, signature);\n return {\n raw: utils.bytesToHex(signed.serialize()),\n hash: utils.bytesToHex(signed.hash()),\n };\n }\n\n createNative(): DisposableNativeClient {\n const call = (method: string, params: unknown) =>\n transportCall(this.#transport, method, params, nativeTags(method));\n return { client: new Web3(eip1193(call) as never) };\n }\n\n #tx(tx: EvmTxFields, signature?: EvmSignature) {\n const common = {\n nonce: tx.nonce,\n to: tx.to,\n value: tx.value,\n data: tx.data,\n gasLimit: tx.gasLimit,\n };\n const options = { common: this.#common };\n if (tx.type === 'eip1559') {\n return eth.accounts.FeeMarketEIP1559Transaction.fromTxData(\n {\n ...common,\n chainId: tx.chainId,\n maxFeePerGas: tx.maxFeePerGas,\n maxPriorityFeePerGas: tx.maxPriorityFeePerGas,\n accessList: [],\n ...(signature\n ? { v: BigInt(signature.yParity), r: signature.r, s: signature.s }\n : {}),\n },\n options,\n );\n }\n const v = signature && this.chainId * 2n + 35n + BigInt(signature.yParity);\n return eth.accounts.Transaction.fromTxData(\n {\n ...common,\n gasPrice: tx.gasPrice,\n ...(signature ? { v, r: signature.r, s: signature.s } : {}),\n },\n options,\n );\n }\n}\n\n/** The `web3` adapter's driver factory; the manifest's `load()` returns it. */\nconst factory = evmDriverFactory(\n (transport, chainId) => new Web3Client(transport, chainId),\n);\n\nlet warned = false;\n\n/**\n * The web3 strategy's factory: its first driver in a process warns, once, that the library\n * is deprecated (a Node.js `DeprecationWarning`, code `CRYPTO_AIO_WEB3`).\n */\nexport const web3DriverFactory: DriverFactory = {\n create(ctx) {\n if (!warned) {\n warned = true;\n process.emitWarning(\n \"crypto-aio: library 'web3' is deprecated: web3.js is no longer maintained (4.16.0 \" +\n \"is its last release). Use 'ethers', the default; 'web3' is removed in crypto-aio 2.0.\",\n { type: 'DeprecationWarning', code: 'CRYPTO_AIO_WEB3' },\n );\n }\n return factory.create(ctx);\n },\n};\n"]}
|
|
@@ -101,7 +101,7 @@ function tokenPlan(ctx, from, to, mint, decimals) {
|
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
103
|
/** The one output and the recipient's on-chain checks (no key: a fee needs none). */
|
|
104
|
-
async function planTransfer(ctx, intent, tags) {
|
|
104
|
+
async function planTransfer(ctx, intent, tags, scaledWith) {
|
|
105
105
|
const output = onlyOutput(intent);
|
|
106
106
|
const { from } = intent;
|
|
107
107
|
const text = memoOf(intent.memo);
|
|
@@ -128,6 +128,12 @@ async function planTransfer(ctx, intent, tags) {
|
|
|
128
128
|
// signed into `transferChecked`, so a lagging endpoint without the mint decides
|
|
129
129
|
// nothing.
|
|
130
130
|
const decimals = await (0, reader_1.mintDecimals)(ctx, mint, (0, rpc_1.withSignal)(reader_1.METADATA, tags.signal));
|
|
131
|
+
// The core scaled the amount with the decimals it knows for the mint (registered, or
|
|
132
|
+
// read before). `transferChecked` signs the chain's: a mismatch means the amount was
|
|
133
|
+
// scaled wrong, by a factor of ten or more.
|
|
134
|
+
if (scaledWith !== undefined && scaledWith !== decimals) {
|
|
135
|
+
throw new error_1.ValidationError('ASSET_RESOLUTION', 'the mint has other decimals than the amount was scaled with: fix the registered asset');
|
|
136
|
+
}
|
|
131
137
|
// Nobody can sign for a program's associated token account.
|
|
132
138
|
if (recipient?.executable) {
|
|
133
139
|
throw invalid('the recipient is a program; send to a wallet or a PDA owner');
|
|
@@ -314,7 +320,7 @@ function createSolanaBuilder(ctx) {
|
|
|
314
320
|
if (override && override.computeUnitPrice > bound) {
|
|
315
321
|
throw (0, fees_1.aboveMaxPrice)(override.computeUnitPrice, bound);
|
|
316
322
|
}
|
|
317
|
-
const plan = await planTransfer(ctx, intent, tags);
|
|
323
|
+
const plan = await planTransfer(ctx, intent, tags, build.decimals);
|
|
318
324
|
const list = transferInstructions(plan);
|
|
319
325
|
const variant = (0, fees_1.variantOffsets)(ctx.nextVariant());
|
|
320
326
|
let price;
|
|
@@ -344,29 +350,34 @@ function createSolanaBuilder(ctx) {
|
|
|
344
350
|
const limit = base + variant.limit > programs_1.MAX_COMPUTE_UNIT_LIMIT
|
|
345
351
|
? programs_1.MAX_COMPUTE_UNIT_LIMIT
|
|
346
352
|
: base + variant.limit;
|
|
347
|
-
// A fee is a u64 of lamports. An explicit price without one is the
|
|
348
|
-
// caller's; a node's recent prices or quote without one decide nothing (retryable).
|
|
349
|
-
const unpriced = (what) => override
|
|
350
|
-
? invalid('Solana fee override: the fee does not fit in u64')
|
|
351
|
-
: (0, rpc_1.malformed)(what);
|
|
352
|
-
const priority = (0, fees_1.priorityFee)(price, limit);
|
|
353
|
-
if (priority > U64_MAX)
|
|
354
|
-
throw unpriced('getRecentPrioritizationFees');
|
|
355
353
|
const message = ctx.codec.compileMessage(plan.from, blockhash, withBudget(limit, price, list));
|
|
356
|
-
|
|
354
|
+
// The fee follows from the message alone (agave `calculate_fee`): its signatures at
|
|
355
|
+
// the fixed rate, plus the priority fee its budget costs.
|
|
356
|
+
const { required: signatures } = readBack(message, plan.from);
|
|
357
|
+
const baseFee = fees_1.LAMPORTS_PER_SIGNATURE * BigInt(signatures);
|
|
358
|
+
const priority = (0, fees_1.priorityFee)(price, limit);
|
|
359
|
+
// A fee is a u64 of lamports, and agave's fee arithmetic saturates at u64::MAX, so a
|
|
360
|
+
// fee there may stand for a larger one: no fee. An explicit price without one is the
|
|
361
|
+
// caller's; a node's recent prices without one decide nothing (retryable).
|
|
362
|
+
if (baseFee + priority >= U64_MAX) {
|
|
363
|
+
throw override
|
|
364
|
+
? invalid('Solana fee override: the fee does not fit in u64')
|
|
365
|
+
: (0, rpc_1.malformed)('getRecentPrioritizationFees');
|
|
366
|
+
}
|
|
357
367
|
const quoted = (0, rpc_1.contextValue)(await (0, rpc_1.call)(ctx.transport, 'getFeeForMessage', [base64(message), { commitment: 'confirmed' }], tags), 'getFeeForMessage');
|
|
358
368
|
// `null`: the endpoint does not know the blockhash yet.
|
|
359
369
|
if (quoted === null)
|
|
360
370
|
throw (0, rpc_1.notYet)('the fee of the message');
|
|
361
|
-
|
|
362
|
-
//
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
if (
|
|
371
|
+
// The quote confirms that fee and nothing else: one endpoint's inflated quote would
|
|
372
|
+
// refuse a transfer the wallet can pay (the funds check), a deflated one would pass a
|
|
373
|
+
// transfer the node then refuses. Any other value, a protocol change to the fee
|
|
374
|
+
// included, decides nothing (retryable) rather than mis-state the estimate.
|
|
375
|
+
if ((0, rpc_1.u64)(quoted, 'getFeeForMessage') !== baseFee + priority) {
|
|
366
376
|
throw (0, rpc_1.malformed)('getFeeForMessage');
|
|
377
|
+
}
|
|
367
378
|
const details = {
|
|
368
|
-
signatures
|
|
369
|
-
baseFee
|
|
379
|
+
signatures,
|
|
380
|
+
baseFee,
|
|
370
381
|
computeUnitLimit: limit,
|
|
371
382
|
computeUnitPrice: price,
|
|
372
383
|
priorityFee: priority,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.js","sourceRoot":"","sources":["../../../src/adapters/solana/builder.ts"],"names":[],"mappings":";;AAshBA,kDAoQC;AAED,0DAiCC;AAzyBD,mDAIiC;AACjC,kDAAiD;AACjD,8CAAiE;AAGjE,iDAAmD;AACnD,qCAAgD;AAChD,iCAYgB;AAChB,iCAA0E;AAC1E,yCAeoB;AACpB,qCAMkB;AAClB,+BAYe;AAOf,iCAA4E;AAE5E,MAAM,OAAO,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,IAAI,uBAAe,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;AAClF,4EAA4E;AAC5E,MAAM,cAAc,GAClB,wEAAwE,CAAC;AAC3E,MAAM,OAAO,GAAG,EAAE,IAAI,GAAG,GAAG,EAAE,CAAC;AAC/B,MAAM,eAAe,GAAG,EAAE,CAAC;AAC3B,0FAA0F;AAC1F,MAAM,gBAAgB,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,+BAAoB,GAAG,CAAC,CAAC,CAAC;AACjE,MAAM,aAAa,GAAG,CAAC,GAAG,+BAAoB,CAAC;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BACF,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;YAC9B,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,gFAAgF;gBAChF,0EAA0E;gBAC1E,iFAAiF;gBACjF,wDAAwD;gBACxD,MAAM,IAAI,GAAG,IAAA,aAAO,EAAC,KAAK,CAAC,CAAC;gBAC5B,IAAI,IAAI,KAAK,SAAS;oBAAE,MAAM,KAAK,CAAC;gBACpC,MAAM,OAAO,GAAG,KAAuB,CAAC;gBACxC,OAAO,IAAA,6BAAoB,EACzB,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,EAC9B,IAAI,EACJ,IAAA,gBAAU,EAAC,OAAO,CAAC,EACnB,OAAO,CAAC,OAAO,EAAE,OAAO,CACzB,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Solana transfers: SystemProgram and SPL `transferChecked`, with\n * `createAssociatedTokenAccountIdempotent` when the recipient's token account is missing,\n * an optional Memo, and compute-budget instructions. Expiry ordering: the recent blockhash's\n * `lastValidBlockHeight` is the Attempt's ordering, recorded with the blockhash and the slot\n * of its block (`SolanaExpiryOrdering`) so proofs can attest the height before a\n * verdict rests on it. One `ed25519` signing request per required signer, over the\n * message; the Attempt ref is the first signature (canonical).\n *\n * Nothing is signed before the compiled bytes are read back, SDK-free (`wire.ts`): one legacy\n * message whose only signer is the sender, on our blockhash, with exactly our instructions,\n * whose transfer pays the intent's recipient (the landing guard in `decode.ts` trusts it).\n * No transaction over the 1,232-byte packet limit is simulated, quoted, signed or sent.\n */\nimport type {\n BroadcastResult,\n Broadcaster,\n TxBuilder,\n WalletKey,\n} from '../../core/driver/types';\nimport {\n SigningError,\n ValidationError,\n type CryptoAioError,\n} from '../../core/errors/error';\nimport { assetId } from '../../core/model/asset';\nimport { isFeeSpeed, type FeeSpeed } from '../../core/model/fee';\nimport type { DriverIntent, DriverOutput } from '../../core/model/intent';\nimport type { RawTx, SignedTx, UnsignedTx } from '../../core/model/transaction';\nimport { equalBytes } from '../../core/util/bytes';\nimport { classifyOwnBroadcast } from './errors';\nimport {\n aboveMaxPrice,\n computeUnitLimitFor,\n fallbackComputeUnitLimit,\n feeDraft,\n lamportsCharged,\n parseOverride,\n priceForSpeed,\n priorityFee,\n signedFee,\n speedPrice,\n variantOffsets,\n} from './fees';\nimport { addressFromPublicKey, decodeBase58, encodeBase58 } from './keys';\nimport {\n MAX_COMPUTE_UNIT_LIMIT,\n MAX_MEMO_BYTES,\n MAX_TRANSACTION_SIZE,\n SYSTEM_PROGRAM,\n TOKEN_2022_PROGRAM,\n TOKEN_ACCOUNT_SIZE,\n TOKEN_PROGRAM,\n createAssociatedTokenAccountIdempotent,\n decodeTokenAccount,\n memo,\n setComputeUnitLimit,\n setComputeUnitPrice,\n systemTransfer,\n transferChecked,\n} from './programs';\nimport {\n METADATA,\n accountInfo,\n mintDecimals,\n mintOf,\n type SolanaContext,\n} from './reader';\nimport {\n BROADCAST,\n READ,\n call,\n contextValue,\n malformed,\n notYet,\n record,\n rpcCode,\n rpcMessage,\n u64,\n withSignal,\n} from './rpc';\nimport type {\n SolanaCallTags,\n SolanaExpiryOrdering,\n SolanaFeeDetails,\n SolanaInstruction,\n} from './types';\nimport { parseMessage, signedTransaction, type MessageParts } from './wire';\n\nconst invalid = (reason: string) => new ValidationError('INVALID_INTENT', reason);\n/** A UTF-16 surrogate without its pair: text that has no UTF-8 encoding. */\nconst LONE_SURROGATE =\n /[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?<![\\uD800-\\uDBFF])[\\uDC00-\\uDFFF]/;\nconst U64_MAX = 2n ** 64n - 1n;\nconst SIGNATURE_BYTES = 64;\n/** The longest text of a packet-sized transaction: 1,644 base64 characters, 2,464 hex. */\nconst MAX_BASE64_CHARS = 4 * Math.ceil(MAX_TRANSACTION_SIZE / 3);\nconst MAX_HEX_CHARS = 2 * MAX_TRANSACTION_SIZE;\nconst TOO_LARGE = `the transaction exceeds ${MAX_TRANSACTION_SIZE} bytes`;\n/** Every node refuses a transaction over the packet limit; it is refused here, unsent. */\nconst REFUSED_TOO_LARGE: BroadcastResult = Object.freeze({\n kind: 'refused',\n code: 'TX_REFUSED',\n reason: 'transaction too large',\n});\n\n/** What a transfer needs on chain, resolved once per estimate. */\ninterface TransferPlan {\n readonly from: string;\n readonly to: string;\n readonly amount: bigint;\n readonly memo?: string;\n readonly token?: {\n readonly mint: string;\n readonly decimals: number;\n readonly source: string;\n readonly destination: string;\n };\n readonly createsRecipientAccount: boolean;\n}\n\nfunction onlyOutput(intent: DriverIntent): DriverOutput {\n const output = intent.outputs[0];\n if (!output || intent.outputs.length !== 1) {\n throw invalid('Solana transfers have exactly one output');\n }\n return output;\n}\n\nconst addressOf = (publicKey: Uint8Array): string | null => {\n try {\n return addressFromPublicKey(publicKey);\n } catch {\n return null;\n }\n};\n\n/** The wallet's ed25519 key whose address is the sending address. */\nfunction keyOf(from: string, keys: readonly WalletKey[]): WalletKey {\n const key = keys.find((k) => k.scheme === 'ed25519' && addressOf(k.publicKey) === from);\n if (!key) {\n throw new SigningError(\n 'SIGNER_UNAVAILABLE',\n 'no ed25519 key for the sending address',\n );\n }\n return key;\n}\n\n/** At most 256 UTF-8 bytes of well-formed text (the intent's policy, not `memo()`'s). */\nfunction memoOf(text: string | undefined): string | undefined {\n if (text === undefined) return undefined;\n if (LONE_SURROGATE.test(text))\n throw invalid('the memo is not well-formed Unicode text');\n if (new TextEncoder().encode(text).length > MAX_MEMO_BYTES) {\n throw invalid(`the memo exceeds ${MAX_MEMO_BYTES} UTF-8 bytes`);\n }\n return text;\n}\n\nasync function rentExemptMinimum(\n ctx: SolanaContext,\n bytes: number,\n tags: SolanaCallTags,\n): Promise<bigint> {\n return u64(\n await call(\n ctx.transport,\n 'getMinimumBalanceForRentExemption',\n [bytes, { commitment: 'confirmed' }],\n tags,\n ),\n 'getMinimumBalanceForRentExemption',\n );\n}\n\n/**\n * The classic token account of `owner` for `mint` at its associated address, or `null`\n * while that account is not created. An address that only holds lamports is not created\n * yet: the ATA program keeps those lamports when it creates the account, so nobody can\n * block a transfer by funding the address first. Anything else there is not the owner's\n * account for the mint (a reassigned owner included), and is refused.\n */\nasync function associatedAccount(\n ctx: SolanaContext,\n address: string,\n owner: string,\n mint: string,\n whose: 'source' | 'recipient',\n tags: SolanaCallTags,\n): Promise<{ readonly amount: bigint; readonly frozen: boolean } | null> {\n const info = await accountInfo(ctx, address, tags);\n if (\n !info ||\n (info.owner === SYSTEM_PROGRAM && !info.executable && info.data.length === 0)\n ) {\n return null;\n }\n const account = info.owner === TOKEN_PROGRAM ? decodeTokenAccount(info.data) : null;\n if (\n !account ||\n encodeBase58(account.owner) !== owner ||\n encodeBase58(account.mint) !== mint\n ) {\n throw invalid(`the ${whose} token account does not match`);\n }\n return { amount: account.amount, frozen: account.frozen };\n}\n\n/**\n * Where a transfer pays the recipient `to` (the binding the landing guard trusts): SOL to\n * `to` itself; SPL into `to`'s associated token account for the mint, derived with the\n * mint's own program, classic Token (`mintDecimals` refuses every other owner).\n */\nconst destinationOf = (ctx: SolanaContext, to: string, mint: string | undefined) =>\n mint === undefined ? to : ctx.codec.associatedTokenAddress(to, mint);\n\nfunction tokenPlan(\n ctx: SolanaContext,\n from: string,\n to: string,\n mint: string,\n decimals: number,\n): NonNullable<TransferPlan['token']> {\n return {\n mint,\n decimals,\n source: ctx.codec.associatedTokenAddress(from, mint),\n destination: destinationOf(ctx, to, mint),\n };\n}\n\n/** The one output and the recipient's on-chain checks (no key: a fee needs none). */\nasync function planTransfer(\n ctx: SolanaContext,\n intent: DriverIntent,\n tags: SolanaCallTags,\n): Promise<TransferPlan> {\n const output = onlyOutput(intent);\n const { from } = intent;\n const text = memoOf(intent.memo);\n const base = {\n from,\n to: output.to,\n amount: output.amount,\n ...(text !== undefined ? { memo: text } : {}),\n };\n const recipient = output.to === from ? null : await accountInfo(ctx, output.to, tags);\n if (intent.asset === 'native') {\n if (recipient && (recipient.executable || recipient.owner !== SYSTEM_PROGRAM)) {\n throw invalid('the recipient is a program-owned account');\n }\n if (\n !recipient &&\n output.to !== from &&\n output.amount < (await rentExemptMinimum(ctx, 0, tags))\n ) {\n throw new ValidationError(\n 'INVALID_AMOUNT',\n 'a new account needs at least the rent-exempt minimum',\n );\n }\n return { ...base, createsRecipientAccount: false };\n }\n const mint = mintOf(intent.asset);\n // Token metadata under the proof quorum, with the caller's signal: the decimals are\n // signed into `transferChecked`, so a lagging endpoint without the mint decides\n // nothing.\n const decimals = await mintDecimals(ctx, mint, withSignal(METADATA, tags.signal));\n // Nobody can sign for a program's associated token account.\n if (recipient?.executable) {\n throw invalid('the recipient is a program; send to a wallet or a PDA owner');\n }\n if (\n recipient &&\n (recipient.owner === TOKEN_PROGRAM || recipient.owner === TOKEN_2022_PROGRAM)\n ) {\n throw invalid('the recipient is a token account; send to its owner');\n }\n const token = tokenPlan(ctx, from, output.to, mint, decimals);\n const existing = await associatedAccount(\n ctx,\n token.destination,\n output.to,\n mint,\n 'recipient',\n tags,\n );\n if (existing?.frozen) throw invalid('the recipient token account is frozen');\n return { ...base, token, createsRecipientAccount: existing === null };\n}\n\n/** The transfer's own instructions (no compute budget). */\nfunction transferInstructions(plan: TransferPlan): SolanaInstruction[] {\n const list: SolanaInstruction[] = [];\n const { token } = plan;\n if (token) {\n if (plan.createsRecipientAccount) {\n list.push(\n createAssociatedTokenAccountIdempotent(\n plan.from,\n token.destination,\n plan.to,\n token.mint,\n ),\n );\n }\n list.push(\n transferChecked(\n token.source,\n token.mint,\n token.destination,\n plan.from,\n plan.amount,\n token.decimals,\n ),\n );\n } else {\n list.push(systemTransfer(plan.from, plan.to, plan.amount));\n }\n if (plan.memo !== undefined) list.push(memo(plan.memo));\n return list;\n}\n\nconst withBudget = (limit: bigint, price: bigint, list: readonly SolanaInstruction[]) => [\n setComputeUnitLimit(limit),\n setComputeUnitPrice(price),\n ...list,\n];\n\n/**\n * The newest blockhash at `confirmed`, its last valid height, and the slot of its block:\n * agave answers from one bank (`rpc.rs` `get_latest_blockhash`: the bank's last blockhash,\n * that blockhash's last valid height, and `new_response`'s context slot, the bank's own).\n * One endpoint's word: proofs attest the three together before using the height.\n */\nasync function latestBlockhash(\n ctx: SolanaContext,\n tags: SolanaCallTags,\n): Promise<{\n readonly blockhash: string;\n readonly lastValidBlockHeight: bigint;\n readonly slot: bigint;\n}> {\n const result = await call(\n ctx.transport,\n 'getLatestBlockhash',\n [{ commitment: 'confirmed' }],\n tags,\n );\n const value = contextValue(result, 'getLatestBlockhash') as {\n blockhash?: unknown;\n lastValidBlockHeight?: unknown;\n } | null;\n if (!value || decodeBase58(value.blockhash, 32) === null) {\n throw malformed('getLatestBlockhash');\n }\n return {\n blockhash: value.blockhash as string,\n lastValidBlockHeight: u64(value.lastValidBlockHeight, 'lastValidBlockHeight'),\n slot: u64(record(record(result)?.context)?.slot, 'getLatestBlockhash context slot'),\n };\n}\n\nconst base64 = (bytes: Uint8Array): string => Buffer.from(bytes).toString('base64');\n\n/** Whether `bytes` (a key read from a message) is the key `address`. */\nfunction isKey(bytes: Uint8Array | undefined, address: string): boolean {\n const expected = decodeBase58(address, 32);\n return bytes !== undefined && expected !== null && equalBytes(bytes, expected);\n}\n\n/** The transaction with a zero signature for each required signer. */\nconst withPlaceholders = (parts: MessageParts, message: Uint8Array): Uint8Array =>\n signedTransaction(\n Array.from({ length: parts.required }, () => new Uint8Array(SIGNATURE_BYTES)),\n message,\n );\n\n/**\n * A compiled message read back from its bytes before it is simulated, quoted or signed: one\n * legacy message (a `null` from the reader is a refusal, never \"no signers needed\") whose\n * only signer is `from`, the fee payer, and whose transaction fits the packet limit.\n */\nfunction readBack(message: Uint8Array, from: string): MessageParts {\n const parts = parseMessage(message);\n if (!parts) throw invalid('the compiled message is not one legacy message');\n if (parts.required !== 1 || !isKey(parts.keys[0], from)) {\n throw invalid('the compiled message has unexpected signers');\n }\n if (withPlaceholders(parts, message).length > MAX_TRANSACTION_SIZE) {\n throw invalid(TOO_LARGE);\n }\n return parts;\n}\n\nconst isWritable = (parts: MessageParts, index: number): boolean =>\n index < parts.required\n ? index < parts.required - parts.readonlySigned\n : index < parts.keys.length - parts.readonlyUnsigned;\n\n/** A little-endian u64 of `data` at `at`, or `null` when the data is too short. */\nconst u64At = (data: Uint8Array, at: number): bigint | null =>\n data.length < at + 8\n ? null\n : new DataView(data.buffer, data.byteOffset + at, 8).getBigUint64(0, true);\n\n/**\n * The recipient binding the landing guard trusts, read from the bytes and re-derived from\n * the intent alone: exactly one transfer (System `Transfer`, or Token `TransferChecked`)\n * moves the intent's amount into `destinationOf` the intent's recipient. The sender is\n * bound by `readBack`: it is the message's only signer.\n */\nfunction checkRecipient(\n ctx: SolanaContext,\n parts: MessageParts,\n output: DriverOutput,\n mint: string | undefined,\n): void {\n const program = mint === undefined ? SYSTEM_PROGRAM : TOKEN_PROGRAM;\n // The destination's position and the amount's offset: System [from, to], data\n // [u32 2, u64 lamports]; Token [source, mint, destination, authority], data\n // [12, u64 amount, u8 decimals].\n const [destination, amountAt] = mint === undefined ? [1, 4] : [2, 1];\n const transfers = parts.instructions.filter((ix) =>\n isKey(parts.keys[ix.program], program),\n );\n const transfer = transfers[0];\n if (\n transfers.length !== 1 ||\n !transfer ||\n !isKey(\n parts.keys[transfer.accounts[destination] as number],\n destinationOf(ctx, output.to, mint),\n ) ||\n u64At(transfer.data, amountAt) !== output.amount\n ) {\n throw invalid('the transfer does not pay the recipient');\n }\n}\n\n/**\n * The bytes carry exactly `list` on `blockhash`: each instruction's program, accounts and\n * data, and no other instruction. An account the list writes must be writable (the message\n * merges flags per key); its signers are `readBack`'s.\n */\nfunction checkInstructions(\n parts: MessageParts,\n blockhash: string,\n list: readonly SolanaInstruction[],\n): void {\n const mismatch = () => invalid('the compiled message does not match the transfer');\n if (!isKey(parts.blockhash, blockhash) || parts.instructions.length !== list.length) {\n throw mismatch();\n }\n list.forEach((expected, i) => {\n const found = parts.instructions[i];\n if (\n !found ||\n !isKey(parts.keys[found.program], expected.programId) ||\n found.accounts.length !== expected.accounts.length ||\n !equalBytes(found.data, expected.data)\n ) {\n throw mismatch();\n }\n expected.accounts.forEach((account, j) => {\n const index = found.accounts[j] as number;\n if (\n !isKey(parts.keys[index], account.address) ||\n (account.writable && !isWritable(parts, index))\n ) {\n throw mismatch();\n }\n });\n });\n}\n\n/** The simulated compute units of the transfer, or `null` when it cannot be measured. */\nasync function simulatedUnits(\n ctx: SolanaContext,\n from: string,\n price: bigint,\n list: readonly SolanaInstruction[],\n blockhash: string,\n tags: SolanaCallTags,\n): Promise<bigint | null> {\n const message = ctx.codec.compileMessage(\n from,\n blockhash,\n withBudget(MAX_COMPUTE_UNIT_LIMIT, price, list),\n );\n const unsignedTx = withPlaceholders(readBack(message, from), message);\n const value = contextValue(\n await call(\n ctx.transport,\n 'simulateTransaction',\n [\n base64(unsignedTx),\n {\n encoding: 'base64',\n sigVerify: false,\n replaceRecentBlockhash: true,\n commitment: 'confirmed',\n },\n ],\n tags,\n ),\n 'simulateTransaction',\n ) as { err?: unknown; unitsConsumed?: unknown } | null;\n if (!value) throw malformed('simulateTransaction');\n // A failing simulation (e.g. insufficient funds) still lets `checkFunds` explain itself.\n if (value.err !== null || value.unitsConsumed === undefined) return null;\n return u64(value.unitsConsumed, 'unitsConsumed');\n}\n\n/**\n * The base64 wire bytes of a signed transaction, or `null` when they exceed the packet\n * limit. The text is capped before it is decoded, and only a canonical text is\n * read: `Buffer` skips what it cannot decode, and a truncated transaction is never sent.\n */\nfunction wirePayload(raw: RawTx): string | null {\n const { encoding, data } = raw;\n if (encoding === 'json') throw invalid('a Solana transaction is bytes (base64 or hex)');\n if (typeof data !== 'string') throw invalid('a Solana transaction is a text of bytes');\n if (data.length > (encoding === 'hex' ? MAX_HEX_CHARS : MAX_BASE64_CHARS)) return null;\n const bytes = Buffer.from(data, encoding);\n const canonical =\n encoding === 'hex'\n ? bytes.toString('hex') === data.toLowerCase()\n : bytes.toString('base64') === data;\n if (!canonical) throw invalid(`the transaction is not canonical ${encoding}`);\n return bytes.length > MAX_TRANSACTION_SIZE ? null : bytes.toString('base64');\n}\n\nexport function createSolanaBuilder(ctx: SolanaContext): TxBuilder {\n return {\n async estimateFee(intent, build) {\n const tags = withSignal(READ, build.signal);\n // The handle's bound, which no endpoint can raise. An explicit price above it is\n // refused before any request; a speed's is clamped below it.\n const bound = ctx.config.maxComputeUnitPrice;\n const override = isFeeSpeed(intent.fee) ? undefined : parseOverride(intent.fee);\n if (override && override.computeUnitPrice > bound) {\n throw aboveMaxPrice(override.computeUnitPrice, bound);\n }\n const plan = await planTransfer(ctx, intent, tags);\n const list = transferInstructions(plan);\n const variant = variantOffsets(ctx.nextVariant());\n let price: bigint;\n if (override) {\n price = override.computeUnitPrice;\n } else {\n const writable = plan.token\n ? [plan.from, plan.token.source, plan.token.destination]\n : [plan.from, plan.to];\n const recent = await call(\n ctx.transport,\n 'getRecentPrioritizationFees',\n [writable],\n tags,\n );\n price = speedPrice(\n priceForSpeed(recent, intent.fee as FeeSpeed),\n variant.price,\n bound,\n );\n }\n const { blockhash } = await latestBlockhash(ctx, tags);\n let base = override?.computeUnitLimit;\n if (base === undefined) {\n const units = await simulatedUnits(ctx, plan.from, price, list, blockhash, tags);\n base =\n units === null\n ? fallbackComputeUnitLimit(list.length)\n : computeUnitLimitFor(units);\n }\n // Every build varies the limit, an explicit one included, so identical transfers\n // sign different bytes (the price of an explicit fee is kept exactly). At the\n // protocol maximum no variant fits, and only the core's guard against two\n // Operations sharing one Attempt ref keeps them apart.\n const limit =\n base + variant.limit > MAX_COMPUTE_UNIT_LIMIT\n ? MAX_COMPUTE_UNIT_LIMIT\n : base + variant.limit;\n // A fee is a u64 of lamports. An explicit price without one is the\n // caller's; a node's recent prices or quote without one decide nothing (retryable).\n const unpriced = (what: string) =>\n override\n ? invalid('Solana fee override: the fee does not fit in u64')\n : malformed(what);\n const priority = priorityFee(price, limit);\n if (priority > U64_MAX) throw unpriced('getRecentPrioritizationFees');\n const message = ctx.codec.compileMessage(\n plan.from,\n blockhash,\n withBudget(limit, price, list),\n );\n readBack(message, plan.from);\n const quoted = contextValue(\n await call(\n ctx.transport,\n 'getFeeForMessage',\n [base64(message), { commitment: 'confirmed' }],\n tags,\n ),\n 'getFeeForMessage',\n );\n // `null`: the endpoint does not know the blockhash yet.\n if (quoted === null) throw notYet('the fee of the message');\n const total = u64(quoted, 'getFeeForMessage');\n // agave's fee arithmetic saturates: a quote of u64::MAX is no fee.\n if (total === U64_MAX) throw unpriced('getFeeForMessage');\n if (total < priority) throw malformed('getFeeForMessage');\n const details: SolanaFeeDetails = {\n signatures: 1,\n baseFee: total - priority,\n computeUnitLimit: limit,\n computeUnitPrice: price,\n priorityFee: priority,\n rent: plan.createsRecipientAccount\n ? await rentExemptMinimum(ctx, TOKEN_ACCOUNT_SIZE, tags)\n : 0n,\n createsRecipientAccount: plan.createsRecipientAccount,\n };\n return feeDraft(override ? 'custom' : (intent.fee as FeeSpeed), details);\n },\n\n async checkFunds(intent, fee, build) {\n const output = onlyOutput(intent);\n const tags = withSignal(READ, build.signal);\n const balance = u64(\n contextValue(\n await call(\n ctx.transport,\n 'getBalance',\n [intent.from, { commitment: 'confirmed' }],\n tags,\n ),\n 'getBalance',\n ),\n 'balance',\n );\n if (intent.asset !== 'native') {\n const mint = mintOf(intent.asset);\n const source = await associatedAccount(\n ctx,\n ctx.codec.associatedTokenAddress(intent.from, mint),\n intent.from,\n mint,\n 'source',\n tags,\n );\n if (source?.frozen) throw invalid('the source token account is frozen');\n const available = source?.amount ?? 0n;\n if (available < output.amount) {\n return { ok: false, asset: intent.asset, required: output.amount, available };\n }\n }\n // A system account may end at 0 or at the rent-exempt minimum, nothing in between.\n const spent =\n lamportsCharged(fee) + (intent.asset === 'native' ? output.amount : 0n);\n const minimum = await rentExemptMinimum(ctx, 0, tags);\n if (balance < spent) {\n return { ok: false, asset: 'native', required: spent, available: balance };\n }\n const left = balance - spent;\n if (left !== 0n && left < minimum) {\n return {\n ok: false,\n asset: 'native',\n required: spent + minimum,\n available: balance,\n };\n }\n return { ok: true };\n },\n\n async build(intent, fee, build) {\n const output = onlyOutput(intent);\n const details = signedFee(fee, ctx.config.maxComputeUnitPrice);\n const key = keyOf(intent.from, build.keys);\n const text = memoOf(intent.memo);\n const tags = withSignal(READ, build.signal);\n const mint = intent.asset === 'native' ? undefined : mintOf(intent.asset);\n const plan: TransferPlan = {\n from: intent.from,\n to: output.to,\n amount: output.amount,\n ...(text !== undefined ? { memo: text } : {}),\n createsRecipientAccount: details.createsRecipientAccount,\n ...(mint === undefined\n ? {}\n : {\n token: tokenPlan(\n ctx,\n intent.from,\n output.to,\n mint,\n await mintDecimals(ctx, mint, withSignal(METADATA, build.signal)),\n ),\n }),\n };\n const list = withBudget(\n details.computeUnitLimit,\n details.computeUnitPrice,\n transferInstructions(plan),\n );\n const { blockhash, lastValidBlockHeight, slot } = await latestBlockhash(ctx, tags);\n // The payload, the signing request and the ordering all come from this one message,\n // read back before it is offered for signing.\n const message = ctx.codec.compileMessage(plan.from, blockhash, list);\n const parts = readBack(message, plan.from);\n checkRecipient(ctx, parts, output, mint);\n checkInstructions(parts, blockhash, list);\n // The height, with the blockhash and slot that let a proof attest it.\n const ordering: SolanaExpiryOrdering = {\n kind: 'expiry',\n lastValidHeight: lastValidBlockHeight,\n blockhash,\n blockhashSlot: slot,\n };\n const unsigned: UnsignedTx = {\n payload: { encoding: 'base64', data: base64(message) },\n signingRequests: [\n {\n id: 's0',\n scheme: 'ed25519',\n payload: message,\n payloadKind: 'message',\n publicKey: key.publicKey,\n ...(key.keyRef ? { keyRef: key.keyRef } : {}),\n },\n ],\n ordering,\n fee,\n summary: {\n asset: assetId(ctx.chain.id, ctx.network.id, intent.asset),\n outputs: [{ to: output.to, amount: output.amount.toString() }],\n ...(text !== undefined ? { memo: text } : {}),\n },\n };\n return unsigned;\n },\n\n async assemble(unsigned, signatures): Promise<SignedTx> {\n const failed = (reason: string) => new SigningError('SIGNING_FAILED', reason);\n const mismatch = () => failed('the message and its signing requests do not match');\n const { encoding, data } = unsigned.payload;\n if (encoding !== 'base64') throw failed('not a Solana message');\n const message = new Uint8Array(Buffer.from(data, 'base64'));\n if (base64(message) !== data) throw failed('not a Solana message');\n // A `null` is a refusal, never \"no signers needed\": one request per required signer.\n const parts = parseMessage(message);\n if (!parts || parts.required !== unsigned.signingRequests.length) throw mismatch();\n // The core stores this `ordering` as the Attempt's, and the expiry proof reads its\n // blockhash as the message's. A changed one between build and signing would\n // misplace the window.\n const ordering = unsigned.ordering as Partial<SolanaExpiryOrdering>;\n if (\n ordering.kind !== 'expiry' ||\n typeof ordering.blockhash !== 'string' ||\n !isKey(parts.blockhash, ordering.blockhash) ||\n typeof ordering.lastValidHeight !== 'bigint' ||\n typeof ordering.blockhashSlot !== 'bigint'\n ) {\n throw failed(\"the Attempt's ordering does not match the signed message\");\n }\n const bytes = unsigned.signingRequests.map((request, i) => {\n if (\n request.scheme !== 'ed25519' ||\n request.payloadKind !== 'message' ||\n !equalBytes(request.publicKey, parts.keys[i] as Uint8Array) ||\n !equalBytes(request.payload, message)\n ) {\n throw mismatch();\n }\n const signature = signatures.find((s) => s.requestId === request.id);\n if (!signature || signature.bytes.length !== SIGNATURE_BYTES) {\n throw failed(`missing signature for request ${request.id}`);\n }\n return signature.bytes;\n });\n const raw = signedTransaction(bytes, message);\n if (raw.length > MAX_TRANSACTION_SIZE) throw failed(TOO_LARGE);\n return {\n raw: { encoding: 'base64', data: base64(raw) },\n ref: {\n id: encodeBase58(bytes[0] as Uint8Array),\n idKind: 'signature',\n canonical: true,\n },\n };\n },\n };\n}\n\nexport function createSolanaBroadcaster(ctx: SolanaContext): Broadcaster {\n return {\n async broadcast(signed, options = {}) {\n const payload = wirePayload(signed.raw);\n if (payload === null) return REFUSED_TOO_LARGE;\n try {\n await call(\n ctx.transport,\n 'sendTransaction',\n [payload, { encoding: 'base64', preflightCommitment: 'confirmed' }],\n {\n ...withSignal(BROADCAST, options.signal),\n ...(options.fanout !== undefined ? { fanout: options.fanout } : {}),\n },\n );\n return { kind: 'accepted' };\n } catch (error) {\n // Only a definitive, non-ambiguous node answer is classified: by its code, then\n // its structured data (a preflight failure's simulation result), then its\n // anchored text. Anything else may have been sent: rethrown unchanged. A claimed\n // bad signature stands only when these bytes carry one.\n const code = rpcCode(error);\n if (code === undefined) throw error;\n const failure = error as CryptoAioError;\n return classifyOwnBroadcast(\n Buffer.from(payload, 'base64'),\n code,\n rpcMessage(failure),\n failure.details?.rpcData,\n );\n }\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"builder.js","sourceRoot":"","sources":["../../../src/adapters/solana/builder.ts"],"names":[],"mappings":";;AAiiBA,kDA2QC;AAED,0DAiCC;AA3zBD,mDAIiC;AACjC,kDAAiD;AACjD,8CAAiE;AAGjE,iDAAmD;AACnD,qCAAgD;AAChD,iCAagB;AAChB,iCAA0E;AAC1E,yCAeoB;AACpB,qCAMkB;AAClB,+BAYe;AAOf,iCAA4E;AAE5E,MAAM,OAAO,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,IAAI,uBAAe,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;AAClF,4EAA4E;AAC5E,MAAM,cAAc,GAClB,wEAAwE,CAAC;AAC3E,MAAM,OAAO,GAAG,EAAE,IAAI,GAAG,GAAG,EAAE,CAAC;AAC/B,MAAM,eAAe,GAAG,EAAE,CAAC;AAC3B,0FAA0F;AAC1F,MAAM,gBAAgB,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,+BAAoB,GAAG,CAAC,CAAC,CAAC;AACjE,MAAM,aAAa,GAAG,CAAC,GAAG,+BAAoB,CAAC;AAC/C,MAAM,SAAS,GAAG,2BAA2B,+BAAoB,QAAQ,CAAC;AAC1E,0FAA0F;AAC1F,MAAM,iBAAiB,GAAoB,MAAM,CAAC,MAAM,CAAC;IACvD,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,YAAY;IAClB,MAAM,EAAE,uBAAuB;CAChC,CAA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EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBACpE,CACF,CAAC;gBACF,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;YAC9B,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,gFAAgF;gBAChF,0EAA0E;gBAC1E,iFAAiF;gBACjF,wDAAwD;gBACxD,MAAM,IAAI,GAAG,IAAA,aAAO,EAAC,KAAK,CAAC,CAAC;gBAC5B,IAAI,IAAI,KAAK,SAAS;oBAAE,MAAM,KAAK,CAAC;gBACpC,MAAM,OAAO,GAAG,KAAuB,CAAC;gBACxC,OAAO,IAAA,6BAAoB,EACzB,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,EAC9B,IAAI,EACJ,IAAA,gBAAU,EAAC,OAAO,CAAC,EACnB,OAAO,CAAC,OAAO,EAAE,OAAO,CACzB,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Solana transfers: SystemProgram and SPL `transferChecked`, with\n * `createAssociatedTokenAccountIdempotent` when the recipient's token account is missing,\n * an optional Memo, and compute-budget instructions. Expiry ordering: the recent blockhash's\n * `lastValidBlockHeight` is the Attempt's ordering, recorded with the blockhash and the slot\n * of its block (`SolanaExpiryOrdering`) so proofs can attest the height before a\n * verdict rests on it. One `ed25519` signing request per required signer, over the\n * message; the Attempt ref is the first signature (canonical).\n *\n * Nothing is signed before the compiled bytes are read back, SDK-free (`wire.ts`): one legacy\n * message whose only signer is the sender, on our blockhash, with exactly our instructions,\n * whose transfer pays the intent's recipient (the landing guard in `decode.ts` trusts it).\n * No transaction over the 1,232-byte packet limit is simulated, quoted, signed or sent.\n */\nimport type {\n BroadcastResult,\n Broadcaster,\n TxBuilder,\n WalletKey,\n} from '../../core/driver/types';\nimport {\n SigningError,\n ValidationError,\n type CryptoAioError,\n} from '../../core/errors/error';\nimport { assetId } from '../../core/model/asset';\nimport { isFeeSpeed, type FeeSpeed } from '../../core/model/fee';\nimport type { DriverIntent, DriverOutput } from '../../core/model/intent';\nimport type { RawTx, SignedTx, UnsignedTx } from '../../core/model/transaction';\nimport { equalBytes } from '../../core/util/bytes';\nimport { classifyOwnBroadcast } from './errors';\nimport {\n LAMPORTS_PER_SIGNATURE,\n aboveMaxPrice,\n computeUnitLimitFor,\n fallbackComputeUnitLimit,\n feeDraft,\n lamportsCharged,\n parseOverride,\n priceForSpeed,\n priorityFee,\n signedFee,\n speedPrice,\n variantOffsets,\n} from './fees';\nimport { addressFromPublicKey, decodeBase58, encodeBase58 } from './keys';\nimport {\n MAX_COMPUTE_UNIT_LIMIT,\n MAX_MEMO_BYTES,\n MAX_TRANSACTION_SIZE,\n SYSTEM_PROGRAM,\n TOKEN_2022_PROGRAM,\n TOKEN_ACCOUNT_SIZE,\n TOKEN_PROGRAM,\n createAssociatedTokenAccountIdempotent,\n decodeTokenAccount,\n memo,\n setComputeUnitLimit,\n setComputeUnitPrice,\n systemTransfer,\n transferChecked,\n} from './programs';\nimport {\n METADATA,\n accountInfo,\n mintDecimals,\n mintOf,\n type SolanaContext,\n} from './reader';\nimport {\n BROADCAST,\n READ,\n call,\n contextValue,\n malformed,\n notYet,\n record,\n rpcCode,\n rpcMessage,\n u64,\n withSignal,\n} from './rpc';\nimport type {\n SolanaCallTags,\n SolanaExpiryOrdering,\n SolanaFeeDetails,\n SolanaInstruction,\n} from './types';\nimport { parseMessage, signedTransaction, type MessageParts } from './wire';\n\nconst invalid = (reason: string) => new ValidationError('INVALID_INTENT', reason);\n/** A UTF-16 surrogate without its pair: text that has no UTF-8 encoding. */\nconst LONE_SURROGATE =\n /[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?<![\\uD800-\\uDBFF])[\\uDC00-\\uDFFF]/;\nconst U64_MAX = 2n ** 64n - 1n;\nconst SIGNATURE_BYTES = 64;\n/** The longest text of a packet-sized transaction: 1,644 base64 characters, 2,464 hex. */\nconst MAX_BASE64_CHARS = 4 * Math.ceil(MAX_TRANSACTION_SIZE / 3);\nconst MAX_HEX_CHARS = 2 * MAX_TRANSACTION_SIZE;\nconst TOO_LARGE = `the transaction exceeds ${MAX_TRANSACTION_SIZE} bytes`;\n/** Every node refuses a transaction over the packet limit; it is refused here, unsent. */\nconst REFUSED_TOO_LARGE: BroadcastResult = Object.freeze({\n kind: 'refused',\n code: 'TX_REFUSED',\n reason: 'transaction too large',\n});\n\n/** What a transfer needs on chain, resolved once per estimate. */\ninterface TransferPlan {\n readonly from: string;\n readonly to: string;\n readonly amount: bigint;\n readonly memo?: string;\n readonly token?: {\n readonly mint: string;\n readonly decimals: number;\n readonly source: string;\n readonly destination: string;\n };\n readonly createsRecipientAccount: boolean;\n}\n\nfunction onlyOutput(intent: DriverIntent): DriverOutput {\n const output = intent.outputs[0];\n if (!output || intent.outputs.length !== 1) {\n throw invalid('Solana transfers have exactly one output');\n }\n return output;\n}\n\nconst addressOf = (publicKey: Uint8Array): string | null => {\n try {\n return addressFromPublicKey(publicKey);\n } catch {\n return null;\n }\n};\n\n/** The wallet's ed25519 key whose address is the sending address. */\nfunction keyOf(from: string, keys: readonly WalletKey[]): WalletKey {\n const key = keys.find((k) => k.scheme === 'ed25519' && addressOf(k.publicKey) === from);\n if (!key) {\n throw new SigningError(\n 'SIGNER_UNAVAILABLE',\n 'no ed25519 key for the sending address',\n );\n }\n return key;\n}\n\n/** At most 256 UTF-8 bytes of well-formed text (the intent's policy, not `memo()`'s). */\nfunction memoOf(text: string | undefined): string | undefined {\n if (text === undefined) return undefined;\n if (LONE_SURROGATE.test(text))\n throw invalid('the memo is not well-formed Unicode text');\n if (new TextEncoder().encode(text).length > MAX_MEMO_BYTES) {\n throw invalid(`the memo exceeds ${MAX_MEMO_BYTES} UTF-8 bytes`);\n }\n return text;\n}\n\nasync function rentExemptMinimum(\n ctx: SolanaContext,\n bytes: number,\n tags: SolanaCallTags,\n): Promise<bigint> {\n return u64(\n await call(\n ctx.transport,\n 'getMinimumBalanceForRentExemption',\n [bytes, { commitment: 'confirmed' }],\n tags,\n ),\n 'getMinimumBalanceForRentExemption',\n );\n}\n\n/**\n * The classic token account of `owner` for `mint` at its associated address, or `null`\n * while that account is not created. An address that only holds lamports is not created\n * yet: the ATA program keeps those lamports when it creates the account, so nobody can\n * block a transfer by funding the address first. Anything else there is not the owner's\n * account for the mint (a reassigned owner included), and is refused.\n */\nasync function associatedAccount(\n ctx: SolanaContext,\n address: string,\n owner: string,\n mint: string,\n whose: 'source' | 'recipient',\n tags: SolanaCallTags,\n): Promise<{ readonly amount: bigint; readonly frozen: boolean } | null> {\n const info = await accountInfo(ctx, address, tags);\n if (\n !info ||\n (info.owner === SYSTEM_PROGRAM && !info.executable && info.data.length === 0)\n ) {\n return null;\n }\n const account = info.owner === TOKEN_PROGRAM ? decodeTokenAccount(info.data) : null;\n if (\n !account ||\n encodeBase58(account.owner) !== owner ||\n encodeBase58(account.mint) !== mint\n ) {\n throw invalid(`the ${whose} token account does not match`);\n }\n return { amount: account.amount, frozen: account.frozen };\n}\n\n/**\n * Where a transfer pays the recipient `to` (the binding the landing guard trusts): SOL to\n * `to` itself; SPL into `to`'s associated token account for the mint, derived with the\n * mint's own program, classic Token (`mintDecimals` refuses every other owner).\n */\nconst destinationOf = (ctx: SolanaContext, to: string, mint: string | undefined) =>\n mint === undefined ? to : ctx.codec.associatedTokenAddress(to, mint);\n\nfunction tokenPlan(\n ctx: SolanaContext,\n from: string,\n to: string,\n mint: string,\n decimals: number,\n): NonNullable<TransferPlan['token']> {\n return {\n mint,\n decimals,\n source: ctx.codec.associatedTokenAddress(from, mint),\n destination: destinationOf(ctx, to, mint),\n };\n}\n\n/** The one output and the recipient's on-chain checks (no key: a fee needs none). */\nasync function planTransfer(\n ctx: SolanaContext,\n intent: DriverIntent,\n tags: SolanaCallTags,\n scaledWith: number | undefined,\n): Promise<TransferPlan> {\n const output = onlyOutput(intent);\n const { from } = intent;\n const text = memoOf(intent.memo);\n const base = {\n from,\n to: output.to,\n amount: output.amount,\n ...(text !== undefined ? { memo: text } : {}),\n };\n const recipient = output.to === from ? null : await accountInfo(ctx, output.to, tags);\n if (intent.asset === 'native') {\n if (recipient && (recipient.executable || recipient.owner !== SYSTEM_PROGRAM)) {\n throw invalid('the recipient is a program-owned account');\n }\n if (\n !recipient &&\n output.to !== from &&\n output.amount < (await rentExemptMinimum(ctx, 0, tags))\n ) {\n throw new ValidationError(\n 'INVALID_AMOUNT',\n 'a new account needs at least the rent-exempt minimum',\n );\n }\n return { ...base, createsRecipientAccount: false };\n }\n const mint = mintOf(intent.asset);\n // Token metadata under the proof quorum, with the caller's signal: the decimals are\n // signed into `transferChecked`, so a lagging endpoint without the mint decides\n // nothing.\n const decimals = await mintDecimals(ctx, mint, withSignal(METADATA, tags.signal));\n // The core scaled the amount with the decimals it knows for the mint (registered, or\n // read before). `transferChecked` signs the chain's: a mismatch means the amount was\n // scaled wrong, by a factor of ten or more.\n if (scaledWith !== undefined && scaledWith !== decimals) {\n throw new ValidationError(\n 'ASSET_RESOLUTION',\n 'the mint has other decimals than the amount was scaled with: fix the registered asset',\n );\n }\n // Nobody can sign for a program's associated token account.\n if (recipient?.executable) {\n throw invalid('the recipient is a program; send to a wallet or a PDA owner');\n }\n if (\n recipient &&\n (recipient.owner === TOKEN_PROGRAM || recipient.owner === TOKEN_2022_PROGRAM)\n ) {\n throw invalid('the recipient is a token account; send to its owner');\n }\n const token = tokenPlan(ctx, from, output.to, mint, decimals);\n const existing = await associatedAccount(\n ctx,\n token.destination,\n output.to,\n mint,\n 'recipient',\n tags,\n );\n if (existing?.frozen) throw invalid('the recipient token account is frozen');\n return { ...base, token, createsRecipientAccount: existing === null };\n}\n\n/** The transfer's own instructions (no compute budget). */\nfunction transferInstructions(plan: TransferPlan): SolanaInstruction[] {\n const list: SolanaInstruction[] = [];\n const { token } = plan;\n if (token) {\n if (plan.createsRecipientAccount) {\n list.push(\n createAssociatedTokenAccountIdempotent(\n plan.from,\n token.destination,\n plan.to,\n token.mint,\n ),\n );\n }\n list.push(\n transferChecked(\n token.source,\n token.mint,\n token.destination,\n plan.from,\n plan.amount,\n token.decimals,\n ),\n );\n } else {\n list.push(systemTransfer(plan.from, plan.to, plan.amount));\n }\n if (plan.memo !== undefined) list.push(memo(plan.memo));\n return list;\n}\n\nconst withBudget = (limit: bigint, price: bigint, list: readonly SolanaInstruction[]) => [\n setComputeUnitLimit(limit),\n setComputeUnitPrice(price),\n ...list,\n];\n\n/**\n * The newest blockhash at `confirmed`, its last valid height, and the slot of its block:\n * agave answers from one bank (`rpc.rs` `get_latest_blockhash`: the bank's last blockhash,\n * that blockhash's last valid height, and `new_response`'s context slot, the bank's own).\n * One endpoint's word: proofs attest the three together before using the height.\n */\nasync function latestBlockhash(\n ctx: SolanaContext,\n tags: SolanaCallTags,\n): Promise<{\n readonly blockhash: string;\n readonly lastValidBlockHeight: bigint;\n readonly slot: bigint;\n}> {\n const result = await call(\n ctx.transport,\n 'getLatestBlockhash',\n [{ commitment: 'confirmed' }],\n tags,\n );\n const value = contextValue(result, 'getLatestBlockhash') as {\n blockhash?: unknown;\n lastValidBlockHeight?: unknown;\n } | null;\n if (!value || decodeBase58(value.blockhash, 32) === null) {\n throw malformed('getLatestBlockhash');\n }\n return {\n blockhash: value.blockhash as string,\n lastValidBlockHeight: u64(value.lastValidBlockHeight, 'lastValidBlockHeight'),\n slot: u64(record(record(result)?.context)?.slot, 'getLatestBlockhash context slot'),\n };\n}\n\nconst base64 = (bytes: Uint8Array): string => Buffer.from(bytes).toString('base64');\n\n/** Whether `bytes` (a key read from a message) is the key `address`. */\nfunction isKey(bytes: Uint8Array | undefined, address: string): boolean {\n const expected = decodeBase58(address, 32);\n return bytes !== undefined && expected !== null && equalBytes(bytes, expected);\n}\n\n/** The transaction with a zero signature for each required signer. */\nconst withPlaceholders = (parts: MessageParts, message: Uint8Array): Uint8Array =>\n signedTransaction(\n Array.from({ length: parts.required }, () => new Uint8Array(SIGNATURE_BYTES)),\n message,\n );\n\n/**\n * A compiled message read back from its bytes before it is simulated, quoted or signed: one\n * legacy message (a `null` from the reader is a refusal, never \"no signers needed\") whose\n * only signer is `from`, the fee payer, and whose transaction fits the packet limit.\n */\nfunction readBack(message: Uint8Array, from: string): MessageParts {\n const parts = parseMessage(message);\n if (!parts) throw invalid('the compiled message is not one legacy message');\n if (parts.required !== 1 || !isKey(parts.keys[0], from)) {\n throw invalid('the compiled message has unexpected signers');\n }\n if (withPlaceholders(parts, message).length > MAX_TRANSACTION_SIZE) {\n throw invalid(TOO_LARGE);\n }\n return parts;\n}\n\nconst isWritable = (parts: MessageParts, index: number): boolean =>\n index < parts.required\n ? index < parts.required - parts.readonlySigned\n : index < parts.keys.length - parts.readonlyUnsigned;\n\n/** A little-endian u64 of `data` at `at`, or `null` when the data is too short. */\nconst u64At = (data: Uint8Array, at: number): bigint | null =>\n data.length < at + 8\n ? null\n : new DataView(data.buffer, data.byteOffset + at, 8).getBigUint64(0, true);\n\n/**\n * The recipient binding the landing guard trusts, read from the bytes and re-derived from\n * the intent alone: exactly one transfer (System `Transfer`, or Token `TransferChecked`)\n * moves the intent's amount into `destinationOf` the intent's recipient. The sender is\n * bound by `readBack`: it is the message's only signer.\n */\nfunction checkRecipient(\n ctx: SolanaContext,\n parts: MessageParts,\n output: DriverOutput,\n mint: string | undefined,\n): void {\n const program = mint === undefined ? SYSTEM_PROGRAM : TOKEN_PROGRAM;\n // The destination's position and the amount's offset: System [from, to], data\n // [u32 2, u64 lamports]; Token [source, mint, destination, authority], data\n // [12, u64 amount, u8 decimals].\n const [destination, amountAt] = mint === undefined ? [1, 4] : [2, 1];\n const transfers = parts.instructions.filter((ix) =>\n isKey(parts.keys[ix.program], program),\n );\n const transfer = transfers[0];\n if (\n transfers.length !== 1 ||\n !transfer ||\n !isKey(\n parts.keys[transfer.accounts[destination] as number],\n destinationOf(ctx, output.to, mint),\n ) ||\n u64At(transfer.data, amountAt) !== output.amount\n ) {\n throw invalid('the transfer does not pay the recipient');\n }\n}\n\n/**\n * The bytes carry exactly `list` on `blockhash`: each instruction's program, accounts and\n * data, and no other instruction. An account the list writes must be writable (the message\n * merges flags per key); its signers are `readBack`'s.\n */\nfunction checkInstructions(\n parts: MessageParts,\n blockhash: string,\n list: readonly SolanaInstruction[],\n): void {\n const mismatch = () => invalid('the compiled message does not match the transfer');\n if (!isKey(parts.blockhash, blockhash) || parts.instructions.length !== list.length) {\n throw mismatch();\n }\n list.forEach((expected, i) => {\n const found = parts.instructions[i];\n if (\n !found ||\n !isKey(parts.keys[found.program], expected.programId) ||\n found.accounts.length !== expected.accounts.length ||\n !equalBytes(found.data, expected.data)\n ) {\n throw mismatch();\n }\n expected.accounts.forEach((account, j) => {\n const index = found.accounts[j] as number;\n if (\n !isKey(parts.keys[index], account.address) ||\n (account.writable && !isWritable(parts, index))\n ) {\n throw mismatch();\n }\n });\n });\n}\n\n/** The simulated compute units of the transfer, or `null` when it cannot be measured. */\nasync function simulatedUnits(\n ctx: SolanaContext,\n from: string,\n price: bigint,\n list: readonly SolanaInstruction[],\n blockhash: string,\n tags: SolanaCallTags,\n): Promise<bigint | null> {\n const message = ctx.codec.compileMessage(\n from,\n blockhash,\n withBudget(MAX_COMPUTE_UNIT_LIMIT, price, list),\n );\n const unsignedTx = withPlaceholders(readBack(message, from), message);\n const value = contextValue(\n await call(\n ctx.transport,\n 'simulateTransaction',\n [\n base64(unsignedTx),\n {\n encoding: 'base64',\n sigVerify: false,\n replaceRecentBlockhash: true,\n commitment: 'confirmed',\n },\n ],\n tags,\n ),\n 'simulateTransaction',\n ) as { err?: unknown; unitsConsumed?: unknown } | null;\n if (!value) throw malformed('simulateTransaction');\n // A failing simulation (e.g. insufficient funds) still lets `checkFunds` explain itself.\n if (value.err !== null || value.unitsConsumed === undefined) return null;\n return u64(value.unitsConsumed, 'unitsConsumed');\n}\n\n/**\n * The base64 wire bytes of a signed transaction, or `null` when they exceed the packet\n * limit. The text is capped before it is decoded, and only a canonical text is\n * read: `Buffer` skips what it cannot decode, and a truncated transaction is never sent.\n */\nfunction wirePayload(raw: RawTx): string | null {\n const { encoding, data } = raw;\n if (encoding === 'json') throw invalid('a Solana transaction is bytes (base64 or hex)');\n if (typeof data !== 'string') throw invalid('a Solana transaction is a text of bytes');\n if (data.length > (encoding === 'hex' ? MAX_HEX_CHARS : MAX_BASE64_CHARS)) return null;\n const bytes = Buffer.from(data, encoding);\n const canonical =\n encoding === 'hex'\n ? bytes.toString('hex') === data.toLowerCase()\n : bytes.toString('base64') === data;\n if (!canonical) throw invalid(`the transaction is not canonical ${encoding}`);\n return bytes.length > MAX_TRANSACTION_SIZE ? null : bytes.toString('base64');\n}\n\nexport function createSolanaBuilder(ctx: SolanaContext): TxBuilder {\n return {\n async estimateFee(intent, build) {\n const tags = withSignal(READ, build.signal);\n // The handle's bound, which no endpoint can raise. An explicit price above it is\n // refused before any request; a speed's is clamped below it.\n const bound = ctx.config.maxComputeUnitPrice;\n const override = isFeeSpeed(intent.fee) ? undefined : parseOverride(intent.fee);\n if (override && override.computeUnitPrice > bound) {\n throw aboveMaxPrice(override.computeUnitPrice, bound);\n }\n const plan = await planTransfer(ctx, intent, tags, build.decimals);\n const list = transferInstructions(plan);\n const variant = variantOffsets(ctx.nextVariant());\n let price: bigint;\n if (override) {\n price = override.computeUnitPrice;\n } else {\n const writable = plan.token\n ? [plan.from, plan.token.source, plan.token.destination]\n : [plan.from, plan.to];\n const recent = await call(\n ctx.transport,\n 'getRecentPrioritizationFees',\n [writable],\n tags,\n );\n price = speedPrice(\n priceForSpeed(recent, intent.fee as FeeSpeed),\n variant.price,\n bound,\n );\n }\n const { blockhash } = await latestBlockhash(ctx, tags);\n let base = override?.computeUnitLimit;\n if (base === undefined) {\n const units = await simulatedUnits(ctx, plan.from, price, list, blockhash, tags);\n base =\n units === null\n ? fallbackComputeUnitLimit(list.length)\n : computeUnitLimitFor(units);\n }\n // Every build varies the limit, an explicit one included, so identical transfers\n // sign different bytes (the price of an explicit fee is kept exactly). At the\n // protocol maximum no variant fits, and only the core's guard against two\n // Operations sharing one Attempt ref keeps them apart.\n const limit =\n base + variant.limit > MAX_COMPUTE_UNIT_LIMIT\n ? MAX_COMPUTE_UNIT_LIMIT\n : base + variant.limit;\n const message = ctx.codec.compileMessage(\n plan.from,\n blockhash,\n withBudget(limit, price, list),\n );\n // The fee follows from the message alone (agave `calculate_fee`): its signatures at\n // the fixed rate, plus the priority fee its budget costs.\n const { required: signatures } = readBack(message, plan.from);\n const baseFee = LAMPORTS_PER_SIGNATURE * BigInt(signatures);\n const priority = priorityFee(price, limit);\n // A fee is a u64 of lamports, and agave's fee arithmetic saturates at u64::MAX, so a\n // fee there may stand for a larger one: no fee. An explicit price without one is the\n // caller's; a node's recent prices without one decide nothing (retryable).\n if (baseFee + priority >= U64_MAX) {\n throw override\n ? invalid('Solana fee override: the fee does not fit in u64')\n : malformed('getRecentPrioritizationFees');\n }\n const quoted = contextValue(\n await call(\n ctx.transport,\n 'getFeeForMessage',\n [base64(message), { commitment: 'confirmed' }],\n tags,\n ),\n 'getFeeForMessage',\n );\n // `null`: the endpoint does not know the blockhash yet.\n if (quoted === null) throw notYet('the fee of the message');\n // The quote confirms that fee and nothing else: one endpoint's inflated quote would\n // refuse a transfer the wallet can pay (the funds check), a deflated one would pass a\n // transfer the node then refuses. Any other value, a protocol change to the fee\n // included, decides nothing (retryable) rather than mis-state the estimate.\n if (u64(quoted, 'getFeeForMessage') !== baseFee + priority) {\n throw malformed('getFeeForMessage');\n }\n const details: SolanaFeeDetails = {\n signatures,\n baseFee,\n computeUnitLimit: limit,\n computeUnitPrice: price,\n priorityFee: priority,\n rent: plan.createsRecipientAccount\n ? await rentExemptMinimum(ctx, TOKEN_ACCOUNT_SIZE, tags)\n : 0n,\n createsRecipientAccount: plan.createsRecipientAccount,\n };\n return feeDraft(override ? 'custom' : (intent.fee as FeeSpeed), details);\n },\n\n async checkFunds(intent, fee, build) {\n const output = onlyOutput(intent);\n const tags = withSignal(READ, build.signal);\n const balance = u64(\n contextValue(\n await call(\n ctx.transport,\n 'getBalance',\n [intent.from, { commitment: 'confirmed' }],\n tags,\n ),\n 'getBalance',\n ),\n 'balance',\n );\n if (intent.asset !== 'native') {\n const mint = mintOf(intent.asset);\n const source = await associatedAccount(\n ctx,\n ctx.codec.associatedTokenAddress(intent.from, mint),\n intent.from,\n mint,\n 'source',\n tags,\n );\n if (source?.frozen) throw invalid('the source token account is frozen');\n const available = source?.amount ?? 0n;\n if (available < output.amount) {\n return { ok: false, asset: intent.asset, required: output.amount, available };\n }\n }\n // A system account may end at 0 or at the rent-exempt minimum, nothing in between.\n const spent =\n lamportsCharged(fee) + (intent.asset === 'native' ? output.amount : 0n);\n const minimum = await rentExemptMinimum(ctx, 0, tags);\n if (balance < spent) {\n return { ok: false, asset: 'native', required: spent, available: balance };\n }\n const left = balance - spent;\n if (left !== 0n && left < minimum) {\n return {\n ok: false,\n asset: 'native',\n required: spent + minimum,\n available: balance,\n };\n }\n return { ok: true };\n },\n\n async build(intent, fee, build) {\n const output = onlyOutput(intent);\n const details = signedFee(fee, ctx.config.maxComputeUnitPrice);\n const key = keyOf(intent.from, build.keys);\n const text = memoOf(intent.memo);\n const tags = withSignal(READ, build.signal);\n const mint = intent.asset === 'native' ? undefined : mintOf(intent.asset);\n const plan: TransferPlan = {\n from: intent.from,\n to: output.to,\n amount: output.amount,\n ...(text !== undefined ? { memo: text } : {}),\n createsRecipientAccount: details.createsRecipientAccount,\n ...(mint === undefined\n ? {}\n : {\n token: tokenPlan(\n ctx,\n intent.from,\n output.to,\n mint,\n await mintDecimals(ctx, mint, withSignal(METADATA, build.signal)),\n ),\n }),\n };\n const list = withBudget(\n details.computeUnitLimit,\n details.computeUnitPrice,\n transferInstructions(plan),\n );\n const { blockhash, lastValidBlockHeight, slot } = await latestBlockhash(ctx, tags);\n // The payload, the signing request and the ordering all come from this one message,\n // read back before it is offered for signing.\n const message = ctx.codec.compileMessage(plan.from, blockhash, list);\n const parts = readBack(message, plan.from);\n checkRecipient(ctx, parts, output, mint);\n checkInstructions(parts, blockhash, list);\n // The height, with the blockhash and slot that let a proof attest it.\n const ordering: SolanaExpiryOrdering = {\n kind: 'expiry',\n lastValidHeight: lastValidBlockHeight,\n blockhash,\n blockhashSlot: slot,\n };\n const unsigned: UnsignedTx = {\n payload: { encoding: 'base64', data: base64(message) },\n signingRequests: [\n {\n id: 's0',\n scheme: 'ed25519',\n payload: message,\n payloadKind: 'message',\n publicKey: key.publicKey,\n ...(key.keyRef ? { keyRef: key.keyRef } : {}),\n },\n ],\n ordering,\n fee,\n summary: {\n asset: assetId(ctx.chain.id, ctx.network.id, intent.asset),\n outputs: [{ to: output.to, amount: output.amount.toString() }],\n ...(text !== undefined ? { memo: text } : {}),\n },\n };\n return unsigned;\n },\n\n async assemble(unsigned, signatures): Promise<SignedTx> {\n const failed = (reason: string) => new SigningError('SIGNING_FAILED', reason);\n const mismatch = () => failed('the message and its signing requests do not match');\n const { encoding, data } = unsigned.payload;\n if (encoding !== 'base64') throw failed('not a Solana message');\n const message = new Uint8Array(Buffer.from(data, 'base64'));\n if (base64(message) !== data) throw failed('not a Solana message');\n // A `null` is a refusal, never \"no signers needed\": one request per required signer.\n const parts = parseMessage(message);\n if (!parts || parts.required !== unsigned.signingRequests.length) throw mismatch();\n // The core stores this `ordering` as the Attempt's, and the expiry proof reads its\n // blockhash as the message's. A changed one between build and signing would\n // misplace the window.\n const ordering = unsigned.ordering as Partial<SolanaExpiryOrdering>;\n if (\n ordering.kind !== 'expiry' ||\n typeof ordering.blockhash !== 'string' ||\n !isKey(parts.blockhash, ordering.blockhash) ||\n typeof ordering.lastValidHeight !== 'bigint' ||\n typeof ordering.blockhashSlot !== 'bigint'\n ) {\n throw failed(\"the Attempt's ordering does not match the signed message\");\n }\n const bytes = unsigned.signingRequests.map((request, i) => {\n if (\n request.scheme !== 'ed25519' ||\n request.payloadKind !== 'message' ||\n !equalBytes(request.publicKey, parts.keys[i] as Uint8Array) ||\n !equalBytes(request.payload, message)\n ) {\n throw mismatch();\n }\n const signature = signatures.find((s) => s.requestId === request.id);\n if (!signature || signature.bytes.length !== SIGNATURE_BYTES) {\n throw failed(`missing signature for request ${request.id}`);\n }\n return signature.bytes;\n });\n const raw = signedTransaction(bytes, message);\n if (raw.length > MAX_TRANSACTION_SIZE) throw failed(TOO_LARGE);\n return {\n raw: { encoding: 'base64', data: base64(raw) },\n ref: {\n id: encodeBase58(bytes[0] as Uint8Array),\n idKind: 'signature',\n canonical: true,\n },\n };\n },\n };\n}\n\nexport function createSolanaBroadcaster(ctx: SolanaContext): Broadcaster {\n return {\n async broadcast(signed, options = {}) {\n const payload = wirePayload(signed.raw);\n if (payload === null) return REFUSED_TOO_LARGE;\n try {\n await call(\n ctx.transport,\n 'sendTransaction',\n [payload, { encoding: 'base64', preflightCommitment: 'confirmed' }],\n {\n ...withSignal(BROADCAST, options.signal),\n ...(options.fanout !== undefined ? { fanout: options.fanout } : {}),\n },\n );\n return { kind: 'accepted' };\n } catch (error) {\n // Only a definitive, non-ambiguous node answer is classified: by its code, then\n // its structured data (a preflight failure's simulation result), then its\n // anchored text. Anything else may have been sent: rethrown unchanged. A claimed\n // bad signature stands only when these bytes carry one.\n const code = rpcCode(error);\n if (code === undefined) throw error;\n const failure = error as CryptoAioError;\n return classifyOwnBroadcast(\n Buffer.from(payload, 'base64'),\n code,\n rpcMessage(failure),\n failure.details?.rpcData,\n );\n }\n },\n };\n}\n"]}
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The Solana fee policy (base fee plus priority), pure and bigint-only. The
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* The Solana fee policy (base fee plus priority), pure and bigint-only. The base fee is
|
|
3
|
+
* `LAMPORTS_PER_SIGNATURE` per signature, and the priority fee is
|
|
4
|
+
* `ceil(computeUnitPrice × computeUnitLimit / 1_000_000)` lamports, charged on the requested
|
|
5
|
+
* limit (Solana's fee documentation; agave `get_prioritization_fee`).
|
|
5
6
|
*/
|
|
6
7
|
import { ValidationError } from '../../core/errors/error';
|
|
7
8
|
import type { FeeEstimateDraft, FeeOverride, FeeSpeed } from '../../core/model/fee';
|
|
8
9
|
import type { SolanaFeeDetails, SolanaFeeOverride } from './types';
|
|
10
|
+
/**
|
|
11
|
+
* The signature fee, in lamports per signature of a message: agave's `FeeStructure` rate,
|
|
12
|
+
* which every bank charges since the fee-rate governor was retired (`get_fee_for_message`
|
|
13
|
+
* reads the blockhash's recorded rate only to know the blockhash). agave's
|
|
14
|
+
* `calculate_signature_fee` also counts precompile (ed25519, secp256k1, secp256r1)
|
|
15
|
+
* signatures; a transfer carries none, so its base fee follows from its signers alone.
|
|
16
|
+
*/
|
|
17
|
+
export declare const LAMPORTS_PER_SIGNATURE = 5000n;
|
|
9
18
|
/** Library policy: the percentile of recent prioritization fees each speed pays. */
|
|
10
19
|
export declare const SPEED_PERCENTILE: Readonly<Record<FeeSpeed, number>>;
|
|
11
20
|
/** Library policy: the compute-unit limit is the simulated usage plus 20% and 1,000 units. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.lamportsCharged = exports.MAX_PRICE_VARIANT = exports.VARIANTS = exports.SPEED_PERCENTILE = void 0;
|
|
3
|
+
exports.lamportsCharged = exports.MAX_PRICE_VARIANT = exports.VARIANTS = exports.SPEED_PERCENTILE = exports.LAMPORTS_PER_SIGNATURE = void 0;
|
|
4
4
|
exports.computeUnitLimitFor = computeUnitLimitFor;
|
|
5
5
|
exports.fallbackComputeUnitLimit = fallbackComputeUnitLimit;
|
|
6
6
|
exports.variantOffsets = variantOffsets;
|
|
@@ -14,13 +14,22 @@ exports.feeDraft = feeDraft;
|
|
|
14
14
|
exports.detailsOf = detailsOf;
|
|
15
15
|
exports.signedFee = signedFee;
|
|
16
16
|
/**
|
|
17
|
-
* The Solana fee policy (base fee plus priority), pure and bigint-only. The
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* The Solana fee policy (base fee plus priority), pure and bigint-only. The base fee is
|
|
18
|
+
* `LAMPORTS_PER_SIGNATURE` per signature, and the priority fee is
|
|
19
|
+
* `ceil(computeUnitPrice × computeUnitLimit / 1_000_000)` lamports, charged on the requested
|
|
20
|
+
* limit (Solana's fee documentation; agave `get_prioritization_fee`).
|
|
20
21
|
*/
|
|
21
22
|
const error_1 = require("../../core/errors/error");
|
|
22
23
|
const programs_1 = require("./programs");
|
|
23
24
|
const rpc_1 = require("./rpc");
|
|
25
|
+
/**
|
|
26
|
+
* The signature fee, in lamports per signature of a message: agave's `FeeStructure` rate,
|
|
27
|
+
* which every bank charges since the fee-rate governor was retired (`get_fee_for_message`
|
|
28
|
+
* reads the blockhash's recorded rate only to know the blockhash). agave's
|
|
29
|
+
* `calculate_signature_fee` also counts precompile (ed25519, secp256k1, secp256r1)
|
|
30
|
+
* signatures; a transfer carries none, so its base fee follows from its signers alone.
|
|
31
|
+
*/
|
|
32
|
+
exports.LAMPORTS_PER_SIGNATURE = 5000n;
|
|
24
33
|
/** Library policy: the percentile of recent prioritization fees each speed pays. */
|
|
25
34
|
exports.SPEED_PERCENTILE = Object.freeze({
|
|
26
35
|
slow: 25,
|