diff --git a/examples/node/examples/bridge.ts b/examples/node/examples/bridge.ts index ad07c7f1..80f773a8 100644 --- a/examples/node/examples/bridge.ts +++ b/examples/node/examples/bridge.ts @@ -1,4 +1,5 @@ import * as lifiDataTypes from '@lifi/data-types' +import type { RouteExtended, Execution } from '@lifi/sdk' import { executeRoute, getRoutes, @@ -82,12 +83,15 @@ async function run() { // here we are using the update route hook to report the execution steps to the terminal const executionOptions = { - updateRouteHook: (updatedRoute) => { - const lastExecution = updatedRoute.steps.reduce((accum, step) => { - if (step.execution) { - return step.execution - } - }, undefined) + updateRouteHook: (updatedRoute: RouteExtended) => { + const lastExecution = updatedRoute.steps.reduce( + (accum, step) => { + if (step.execution) { + return step.execution + } + }, + undefined as undefined | Execution + ) console.info(lastExecution) }, } diff --git a/examples/node/examples/klimaRetireExactCarbon.ts b/examples/node/examples/klimaRetireExactCarbon.ts index f5716527..246b38dd 100644 --- a/examples/node/examples/klimaRetireExactCarbon.ts +++ b/examples/node/examples/klimaRetireExactCarbon.ts @@ -22,7 +22,6 @@ import { } from 'viem' import { mainnet, arbitrum, optimism, polygon } from 'viem/chains' import { privateKeyToAccount } from 'viem/accounts' -import { publicActionsL2 } from 'viem/op-stack' import 'dotenv/config' import { promptConfirm } from '../helpers/promptConfirm' import { AddressZero } from './constants' @@ -91,7 +90,7 @@ const run = async () => { transport: http(), }) - const sourceAmountDefaultRetirement = await publicClient.readContract({ + const sourceAmountDefaultRetirement = (await publicClient.readContract({ address: KLIMA_ETHEREUM_CONTRACT_POL, abi, functionName: 'getSourceAmountDefaultRetirement', @@ -100,7 +99,7 @@ const run = async () => { Base_Carbon_Tonne_POL, // address poolToken, retireAmount, // uint256 retireAmount, ], - }) + })) as bigint const usdcAmount = parseUnits( sourceAmountDefaultRetirement.toString(), @@ -125,7 +124,6 @@ const run = async () => { ], }) - // quote const contractCallsQuoteRequest: ContractCallsQuoteRequest = { fromChain, fromToken, @@ -168,7 +166,10 @@ const run = async () => { ) // set approval if needed - if (approval < BigInt(contactCallsQuoteResponse.action.fromAmount)) { + if ( + approval && + approval < BigInt(contactCallsQuoteResponse.action.fromAmount) + ) { const txHash = await setTokenAllowance({ walletClient: client, spenderAddress: contactCallsQuoteResponse.estimate.approvalAddress, @@ -191,17 +192,18 @@ const run = async () => { } } - const transactionRequest = contactCallsQuoteResponse.transactionRequest + const transactionRequest = + contactCallsQuoteResponse.transactionRequest || {} console.info('>> Execute transaction', transactionRequest) const hash = await client.sendTransaction({ to: transactionRequest.to as Address, account: client.account!, + data: transactionRequest.data as Hash, value: transactionRequest.value ? BigInt(transactionRequest.value) : undefined, - data: transactionRequest.data as Hash, gas: transactionRequest.gasLimit ? BigInt(transactionRequest.gasLimit as string) : undefined, diff --git a/examples/node/examples/multihop.ts b/examples/node/examples/multihop.ts index 6590a8dd..9083c487 100644 --- a/examples/node/examples/multihop.ts +++ b/examples/node/examples/multihop.ts @@ -136,7 +136,10 @@ const run = async () => { ) // set approval if needed - if (approval < BigInt(contactCallsQuoteResponse.action.fromAmount)) { + if ( + approval && + approval < BigInt(contactCallsQuoteResponse.action.fromAmount) + ) { const txHash = await setTokenAllowance({ walletClient: client, spenderAddress: contactCallsQuoteResponse.estimate.approvalAddress, @@ -159,7 +162,8 @@ const run = async () => { } } - const transactionRequest = contactCallsQuoteResponse.transactionRequest + const transactionRequest = + contactCallsQuoteResponse.transactionRequest || {} console.info('>> Execute transaction', transactionRequest) @@ -177,7 +181,7 @@ const run = async () => { ? BigInt(transactionRequest.gasPrice as string) : undefined, chain: null, - } as any) + }) console.info('>> Transaction sent', hash) diff --git a/examples/node/examples/polynomialDeposit.ts b/examples/node/examples/polynomialDeposit.ts index 49a10078..37c2cfa0 100644 --- a/examples/node/examples/polynomialDeposit.ts +++ b/examples/node/examples/polynomialDeposit.ts @@ -21,7 +21,6 @@ import { privateKeyToAccount } from 'viem/accounts' import { mainnet, arbitrum, optimism, polygon } from 'viem/chains' import 'dotenv/config' import { promptConfirm } from '../helpers/promptConfirm' -import type { WalletClientWithPublicActions } from './types' import { AddressZero } from './constants' const run = async () => { @@ -39,7 +38,7 @@ const run = async () => { account, chain: mainnet, transport: http(), - }).extend(publicActions) as WalletClientWithPublicActions + }).extend(publicActions) const switchChains = [mainnet, arbitrum, optimism, polygon] @@ -124,7 +123,10 @@ const run = async () => { ) // set approval if needed - if (approval < BigInt(contactCallsQuoteResponse.action.fromAmount)) { + if ( + approval && + approval < BigInt(contactCallsQuoteResponse.action.fromAmount) + ) { const txHash = await setTokenAllowance({ walletClient: client, spenderAddress: contactCallsQuoteResponse.estimate.approvalAddress, @@ -147,28 +149,26 @@ const run = async () => { } } - const transactionRequest = contactCallsQuoteResponse.transactionRequest + const transactionRequest = + contactCallsQuoteResponse.transactionRequest || {} console.info('>> Execute transaction', transactionRequest) - const { maxFeePerGas, maxPriorityFeePerGas } = - await client.estimateFeesPerGas() - const hash = await client.sendTransaction({ to: transactionRequest.to as Address, account: client.account!, - value: transactionRequest.value ? transactionRequest.value : undefined, + value: transactionRequest.value + ? BigInt(transactionRequest.value as string) + : undefined, data: transactionRequest.data as Hash, gas: transactionRequest.gasLimit ? BigInt(transactionRequest.gasLimit as string) : undefined, - // gasPrice: transactionRequest.gasPrice - // ? BigInt(transactionRequest.gasPrice as string) - // : undefined, - maxFeePerGas, - maxPriorityFeePerGas, + gasPrice: transactionRequest.gasPrice + ? BigInt(transactionRequest.gasPrice as string) + : undefined, chain: null, - } as any) + }) console.info('>> Transaction sent', hash) diff --git a/examples/node/examples/swap.ts b/examples/node/examples/swap.ts index 20768460..d0593859 100644 --- a/examples/node/examples/swap.ts +++ b/examples/node/examples/swap.ts @@ -1,4 +1,5 @@ import * as lifiDataTypes from '@lifi/data-types' +import type { RouteExtended, Execution } from '@lifi/sdk' import { createConfig, EVM, @@ -73,12 +74,15 @@ async function run() { // here we are using the update route hook to report the execution steps to the terminal const executionOptions = { - updateRouteHook: (updatedRoute) => { - const lastExecution = updatedRoute.steps.reduce((accum, step) => { - if (step.execution) { - return step.execution - } - }, undefined) + updateRouteHook: (updatedRoute: RouteExtended) => { + const lastExecution = updatedRoute.steps.reduce( + (accum, step) => { + if (step.execution) { + return step.execution + } + }, + undefined as undefined | Execution + ) console.info(lastExecution) }, } diff --git a/examples/node/examples/types.ts b/examples/node/examples/types.ts deleted file mode 100644 index 16e81071..00000000 --- a/examples/node/examples/types.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { PublicActions, WalletClient } from 'viem' - -export interface WalletClientWithPublicActions - extends WalletClient, - PublicActions {} diff --git a/examples/node/package.json b/examples/node/package.json index bfe7cea0..707477f1 100644 --- a/examples/node/package.json +++ b/examples/node/package.json @@ -9,12 +9,12 @@ "dependencies": { "@lifi/data-types": "^4.2.1", "@lifi/rpc-wrapper": "^0.0.27", - "@lifi/sdk": "^3.0.0-alpha.62", + "@lifi/sdk": "^3.0.0-alpha.63", "@types/dotenv": "^8.2.0", "@wagmi/connectors": "^4.3.9", "@wagmi/core": "^2.9.7", "dotenv": "^16.4.5", - "viem": "^2.10.0" + "viem": "^2.12.1" }, "scripts": { "example:swap": "tsx examples/swap.ts", diff --git a/examples/node/tsconfig.json b/examples/node/tsconfig.json index 508ac0d7..e42e3621 100644 --- a/examples/node/tsconfig.json +++ b/examples/node/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "strict": true, "module": "ESNext", "moduleResolution": "node", }, diff --git a/examples/node/yarn.lock b/examples/node/yarn.lock index 51c44d03..cb57e883 100644 --- a/examples/node/yarn.lock +++ b/examples/node/yarn.lock @@ -700,20 +700,20 @@ __metadata: languageName: node linkType: hard -"@lifi/sdk@npm:^3.0.0-alpha.62": - version: 3.0.0-alpha.62 - resolution: "@lifi/sdk@npm:3.0.0-alpha.62" +"@lifi/sdk@npm:^3.0.0-alpha.63": + version: 3.0.0-alpha.63 + resolution: "@lifi/sdk@npm:3.0.0-alpha.63" dependencies: - "@lifi/types": "npm:^13.3.0" + "@lifi/types": "npm:^13.7.1" "@solana/wallet-adapter-base": "npm:^0.9.23" "@solana/web3.js": "npm:^1.91.8" eth-rpc-errors: "npm:^4.0.3" - viem: "npm:^2.11.0" + viem: "npm:^2.12.1" peerDependencies: "@solana/wallet-adapter-base": ^0.9.0 "@solana/web3.js": ^1.91.0 viem: ^2.10.0 - checksum: 10/d260664a1c9384cf83dc0f2959853782828eb30c0c8b7d5907cc6cbcfd4bfdb8a9aad818393356e5734f5149913515c649135a4e497f452a860d64a2ba4bee04 + checksum: 10/c1cb9cab1ba8bb8fec1bd24ed0fa20a15d97516a1ebb283a38e9f06ef53022ef58afff65141f1c27368104d19239e8f58a585a02cb5a24b373ae1581e78f8e8b languageName: node linkType: hard @@ -724,6 +724,13 @@ __metadata: languageName: node linkType: hard +"@lifi/types@npm:^13.7.1": + version: 13.7.1 + resolution: "@lifi/types@npm:13.7.1" + checksum: 10/37d4dbb642342a0eb791f7657c19f46623cdf59396cbf7898602e25d5394735c8e8e2d71648d914a7b97e94ee552324f6826ab550407c319dabe653d3deec815 + languageName: node + linkType: hard + "@lit-labs/ssr-dom-shim@npm:^1.0.0, @lit-labs/ssr-dom-shim@npm:^1.1.0": version: 1.2.0 resolution: "@lit-labs/ssr-dom-shim@npm:1.2.0" @@ -4136,7 +4143,7 @@ __metadata: dependencies: "@lifi/data-types": "npm:^4.2.1" "@lifi/rpc-wrapper": "npm:^0.0.27" - "@lifi/sdk": "npm:^3.0.0-alpha.62" + "@lifi/sdk": "npm:^3.0.0-alpha.63" "@types/dotenv": "npm:^8.2.0" "@types/node": "npm:^20.12.12" "@wagmi/connectors": "npm:^4.3.9" @@ -4144,7 +4151,7 @@ __metadata: dotenv: "npm:^16.4.5" tsx: "npm:^4.10.2" typescript: "npm:^5.4.5" - viem: "npm:^2.10.0" + viem: "npm:^2.12.1" languageName: unknown linkType: soft @@ -5945,9 +5952,9 @@ __metadata: languageName: node linkType: hard -"viem@npm:^2.10.0, viem@npm:^2.11.0": - version: 2.11.1 - resolution: "viem@npm:2.11.1" +"viem@npm:^2.12.1": + version: 2.13.1 + resolution: "viem@npm:2.13.1" dependencies: "@adraffy/ens-normalize": "npm:1.10.0" "@noble/curves": "npm:1.2.0" @@ -5962,7 +5969,7 @@ __metadata: peerDependenciesMeta: typescript: optional: true - checksum: 10/1dc5d1455d006e5788e865e6e8a702e7dcf8cd2ca5cdfecc2dccf5886a579044fc8e0915f6a53e6a5db82e52f8660d6cf1d18dfcf75486fde6cea379d02cbb8b + checksum: 10/bfddca57e09d30810eaaa8ea01b281b8b1bcdb6da698404bc0f2b1d0a01a57051d70e911da0f480d9cdd8ec22c04ea88de0f09e29de5b4f1459e93c16d712952 languageName: node linkType: hard