From 0dad400071d0a250bd82cf503a3f77aab877eb91 Mon Sep 17 00:00:00 2001 From: Shuhui Luo <107524008+shuhuiluo@users.noreply.github.com> Date: Thu, 4 Jan 2024 03:48:19 -0800 Subject: [PATCH] Update 'aperture-lens' version and dependencies Bumped up the version of 'aperture-lens' to 0.4.0. Updated the 'viem' dependency to version 2.0.0, along with minor changes in their respective test scenarios. --- Cargo.lock | 2 +- Cargo.toml | 2 +- package.json | 4 +-- src/viem/caller.ts | 8 +++--- test/hardhat/test.ts | 10 ++++---- yarn.lock | 60 +++++++++++++++++++++----------------------- 6 files changed, 43 insertions(+), 43 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 50f48c5..3b1e916 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -55,7 +55,7 @@ checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" [[package]] name = "aperture-lens" -version = "0.3.1" +version = "0.4.0" dependencies = [ "anyhow", "ethers", diff --git a/Cargo.toml b/Cargo.toml index 50bf343..58be0cf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "aperture-lens" -version = "0.3.1" +version = "0.4.0" edition = "2021" license = "Apache-2.0" repository = "https://github.com/Aperture-Finance/Aperture-Lens" diff --git a/package.json b/package.json index d248fc5..920b9b8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aperture-lens", - "version": "0.3.1", + "version": "0.4.0", "description": "Contains ephemeral lens contracts that can be called without deployment and their interfaces in various Web3 libraries.", "author": "Aperture Finance ", "license": "Apache-2.0", @@ -50,7 +50,7 @@ "@aperture_finance/uni-v3-lib": "^1.2.0", "@openzeppelin/contracts": "^5.0.1", "ethers": "5.7.2", - "viem": "^1.21.4" + "viem": "^2.0.0" }, "devDependencies": { "@aperture_finance/uniswap-v3-automation-sdk": "^1.13.1", diff --git a/src/viem/caller.ts b/src/viem/caller.ts index 096a3c0..f046190 100644 --- a/src/viem/caller.ts +++ b/src/viem/caller.ts @@ -1,7 +1,7 @@ import { Abi, AbiFunction } from "abitype"; import { CallExecutionError, - ContractFunctionResult, + ContractFunctionReturnType, EncodeDeployDataParameters, Hex, PublicClient, @@ -20,9 +20,10 @@ export async function callEphemeralContract( deployParams: EncodeDeployDataParameters, publicClient: PublicClient, blockNumber?: bigint, -): Promise> { +): Promise> { try { await publicClient.call({ + // @ts-ignore data: encodeDeployData(deployParams), blockNumber, }); @@ -31,10 +32,11 @@ export async function callEphemeralContract( if ("data" in baseError) { const abiFunctions = deployParams.abi.filter((x) => x.type === "function"); if (abiFunctions.length === 1) { + // @ts-ignore return decodeFunctionResult({ abi: abiFunctions as [AbiFunction], data: baseError.data as Hex, - }) as ContractFunctionResult; + }); } else { throw new Error("abi should contain exactly one function"); } diff --git a/test/hardhat/test.ts b/test/hardhat/test.ts index 0c264fc..34dc62d 100644 --- a/test/hardhat/test.ts +++ b/test/hardhat/test.ts @@ -2,7 +2,7 @@ import { ApertureSupportedChainId, getChainInfo, viem } from "@aperture_finance/ import { TickMath } from "@uniswap/v3-sdk"; import { expect } from "chai"; import { config as dotenvConfig } from "dotenv"; -import { ContractFunctionResult, createPublicClient, getContract, http, toHex } from "viem"; +import { ContractFunctionReturnType, createPublicClient, getContract, http, toHex } from "viem"; import { getAllPositionsByOwner, getPopulatedTicksInRange, @@ -36,7 +36,7 @@ describe("Pool lens test", () => { const poolContract = getContract({ address: pool, abi: IUniswapV3Pool__factory.abi, - publicClient, + client: publicClient, }); const npm = viem.getNPM(chainId, publicClient); @@ -77,13 +77,13 @@ describe("Pool lens test", () => { const [_sqrtPriceX96, _tick] = await getContract({ address: viem.computePoolAddress(uniswap_v3_factory, token0, token1, fee), abi: IUniswapV3Pool__factory.abi, - publicClient, + client: publicClient, }).read.slot0({ blockNumber }); expect(sqrtPriceX96).to.be.eq(_sqrtPriceX96); expect(tick).to.be.eq(_tick); }); - async function verifyPositionDetails(posArr: ContractFunctionResult) { + async function verifyPositionDetails(posArr: ContractFunctionReturnType) { await Promise.all( posArr.map(async ({ tokenId, position }) => { const [, , token0, token1, fee, tickLower, tickUpper, liquidity] = await npm.read.positions([tokenId], { @@ -121,7 +121,7 @@ describe("Pool lens test", () => { await verifyPositionDetails(posArr); }); - async function verifySlots(slots: ContractFunctionResult) { + async function verifySlots(slots: ContractFunctionReturnType) { expect(slots.some(({ data }) => data > 0)).to.be.true; const address = pool; const altSlots = await Promise.all( diff --git a/yarn.lock b/yarn.lock index f552b2a..b6ee9cd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -880,14 +880,7 @@ resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-10.0.6.tgz#818551d39113081048bdddbef96701b4e8bb9d1b" integrity sha512-dJvrYWxP/UcXm36Qn36fxhUKu8A/xMRXVT2cliFF1Z7UA9liG5Psj3ezNSZw+5puH2czDXRLcXQxf8JbJt0ejg== -"@types/node@*": - version "20.10.4" - resolved "https://registry.yarnpkg.com/@types/node/-/node-20.10.4.tgz#b246fd84d55d5b1b71bf51f964bd514409347198" - integrity sha512-D08YG6rr8X90YB56tSIuBaddy/UXAA9RKJoFvrsnogAum/0pmjkgi4+2nx96A330FmioegBWmEYQ+syqCFaveg== - dependencies: - undici-types "~5.26.4" - -"@types/node@^20.10.6": +"@types/node@*", "@types/node@^20.10.6": version "20.10.6" resolved "https://registry.yarnpkg.com/@types/node/-/node-20.10.6.tgz#a3ec84c22965802bf763da55b2394424f22bfbb5" integrity sha512-Vac8H+NlRNNlAmDfGUP7b5h/KA+AtWIzuXy0E6OyP8f1tCLYAtPvKRRDJjAPqhpCb0t6U2j7/xqAuLEebW2kiw== @@ -927,9 +920,9 @@ integrity sha512-f6UIliwBbRsgVLxIaBANF6w09tYqc6Y/qXdsrbEmXHyFA7ILiKrIwRFXe1yOg8M3cksgVsO9N7yuL2DdCGQKBA== "@uniswap/sdk-core@^4": - version "4.0.9" - resolved "https://registry.yarnpkg.com/@uniswap/sdk-core/-/sdk-core-4.0.9.tgz#7aef87de6d944307ce9bd57d1e1adfdcb2fed3ee" - integrity sha512-/0K+u3ZWokpj9VyRuGwrwx7jy31auJdsw5UbKnvHqUSfejrp6XhmMPNOElPgL6jiUhAN1NhVHfjX01tNHFxeLA== + version "4.0.10" + resolved "https://registry.yarnpkg.com/@uniswap/sdk-core/-/sdk-core-4.0.10.tgz#6173cc39d4e6b5ed679775447bb96a5b3c3fb2f2" + integrity sha512-RiobXJKXvVVb+wfNM09Ik8djOMOuRQGfyRP5pHgUjojicK/7nscZILjZ87DjVCGjXEoD8yTSIps0UAQuz6pJIw== dependencies: "@ethersproject/address" "^5.0.2" big.js "^5.2.2" @@ -999,6 +992,11 @@ "@uniswap/v3-core" "1.0.0" "@uniswap/v3-periphery" "^1.0.1" +abitype@0.10.0: + version "0.10.0" + resolved "https://registry.yarnpkg.com/abitype/-/abitype-0.10.0.tgz#d3504747cc81df2acaa6c460250ef7bc9219a77c" + integrity sha512-QvMHEUzgI9nPj9TWtUGnS2scas80/qaL5PBxGdwWhhvzqXfOph+IEiiiWrzuisu3U3JgDQVruW9oLbJoQ3oZ3A== + abitype@0.9.8: version "0.9.8" resolved "https://registry.yarnpkg.com/abitype/-/abitype-0.9.8.tgz#1f120b6b717459deafd213dfbf3a3dd1bf10ae8c" @@ -1023,9 +1021,9 @@ acorn-walk@^8.1.1: integrity sha512-TgUZgYvqZprrl7YldZNoa9OciCAyZR+Ejm9eXzKCmjsF5IKp/wgQ7Z/ZpjpGTIUPwrHQIcYeI8qDh4PsEwxMbw== acorn@^8.4.1: - version "8.11.2" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.11.2.tgz#ca0d78b51895be5390a5903c5b3bdcdaf78ae40b" - integrity sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w== + version "8.11.3" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.11.3.tgz#71e0b14e13a4ec160724b38fb7b0f233b1b81d7a" + integrity sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg== adm-zip@^0.4.16: version "0.4.16" @@ -1142,11 +1140,11 @@ at-least-node@^1.0.0: integrity sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg== axios@^1.6.2: - version "1.6.2" - resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.2.tgz#de67d42c755b571d3e698df1b6504cde9b0ee9f2" - integrity sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A== + version "1.6.4" + resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.4.tgz#184ee1f63d412caffcf30d2c50982253c3ee86e0" + integrity sha512-heJnIs6N4aa1eSthhN9M5ioILu8Wi8vmQW9iHQ9NUvfkJb0lEEDUiIdQNAuBtfUt3FxReaKdpQA5DbmMOqzF/A== dependencies: - follow-redirects "^1.15.0" + follow-redirects "^1.15.4" form-data "^4.0.0" proxy-from-env "^1.1.0" @@ -1770,10 +1768,10 @@ flat@^5.0.2: resolved "https://registry.yarnpkg.com/flat/-/flat-5.0.2.tgz#8ca6fe332069ffa9d324c327198c598259ceb241" integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ== -follow-redirects@^1.12.1, follow-redirects@^1.15.0: - version "1.15.3" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.3.tgz#fe2f3ef2690afce7e82ed0b44db08165b207123a" - integrity sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q== +follow-redirects@^1.12.1, follow-redirects@^1.15.4: + version "1.15.4" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.4.tgz#cdc7d308bf6493126b17ea2191ea0ccf3e535adf" + integrity sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw== form-data@^4.0.0: version "4.0.0" @@ -3068,10 +3066,10 @@ v8-compile-cache-lib@^3.0.1: resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz#6336e8d71965cb3d35a1bbb7868445a7c05264bf" integrity sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg== -viem@^1.20.1: - version "1.20.1" - resolved "https://registry.yarnpkg.com/viem/-/viem-1.20.1.tgz#ea92f9bab2fded4be556be4d4be724805d11780e" - integrity sha512-PaYyfuCVkNFzdaVoV8HefMIt5YtjIG6UPqxOz0rYchN52cD05YcRJlO0h/XrehQfo8ib2RSOkZ0ChJ6Adlh1Jg== +viem@^1.20.1, viem@^1.20.3: + version "1.21.4" + resolved "https://registry.yarnpkg.com/viem/-/viem-1.21.4.tgz#883760e9222540a5a7e0339809202b45fe6a842d" + integrity sha512-BNVYdSaUjeS2zKQgPs+49e5JKocfo60Ib2yiXOWBT6LuVxY1I/6fFX3waEtpXvL1Xn4qu+BVitVtMh9lyThyhQ== dependencies: "@adraffy/ens-normalize" "1.10.0" "@noble/curves" "1.2.0" @@ -3082,17 +3080,17 @@ viem@^1.20.1: isows "1.0.3" ws "8.13.0" -viem@^1.20.3, viem@^1.21.4: - version "1.21.4" - resolved "https://registry.yarnpkg.com/viem/-/viem-1.21.4.tgz#883760e9222540a5a7e0339809202b45fe6a842d" - integrity sha512-BNVYdSaUjeS2zKQgPs+49e5JKocfo60Ib2yiXOWBT6LuVxY1I/6fFX3waEtpXvL1Xn4qu+BVitVtMh9lyThyhQ== +viem@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/viem/-/viem-2.0.0.tgz#1871512fbb4baa48164dc96765cc548dbfa964a8" + integrity sha512-WYPwVAs/wrQE1Li9mgHMZaZTnRZuyPJMauIhnpZKeZgtx7f+bWU3uvVSR5kxTf1aBFdaTuRc/umzX2ucQUurnA== dependencies: "@adraffy/ens-normalize" "1.10.0" "@noble/curves" "1.2.0" "@noble/hashes" "1.3.2" "@scure/bip32" "1.3.2" "@scure/bip39" "1.2.1" - abitype "0.9.8" + abitype "0.10.0" isows "1.0.3" ws "8.13.0"