Skip to content

Commit

Permalink
Update 'aperture-lens' version and dependencies
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
shuhuiluo committed Jan 4, 2024
1 parent 9bf1659 commit 0dad400
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 43 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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 <engineering@aperture.finance>",
"license": "Apache-2.0",
Expand Down Expand Up @@ -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",
Expand Down
8 changes: 5 additions & 3 deletions src/viem/caller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Abi, AbiFunction } from "abitype";
import {
CallExecutionError,
ContractFunctionResult,
ContractFunctionReturnType,
EncodeDeployDataParameters,
Hex,
PublicClient,
Expand All @@ -20,9 +20,10 @@ export async function callEphemeralContract<TAbi extends Abi>(
deployParams: EncodeDeployDataParameters<TAbi>,
publicClient: PublicClient,
blockNumber?: bigint,
): Promise<ContractFunctionResult<TAbi>> {
): Promise<ContractFunctionReturnType<TAbi>> {
try {
await publicClient.call({
// @ts-ignore
data: encodeDeployData(deployParams),
blockNumber,
});
Expand All @@ -31,10 +32,11 @@ export async function callEphemeralContract<TAbi extends Abi>(
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<TAbi>;
});
} else {
throw new Error("abi should contain exactly one function");
}
Expand Down
10 changes: 5 additions & 5 deletions test/hardhat/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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<typeof EphemeralGetPositions__factory.abi>) {
async function verifyPositionDetails(posArr: ContractFunctionReturnType<typeof EphemeralGetPositions__factory.abi>) {
await Promise.all(
posArr.map(async ({ tokenId, position }) => {
const [, , token0, token1, fee, tickLower, tickUpper, liquidity] = await npm.read.positions([tokenId], {
Expand Down Expand Up @@ -121,7 +121,7 @@ describe("Pool lens test", () => {
await verifyPositionDetails(posArr);
});

async function verifySlots(slots: ContractFunctionResult<typeof EphemeralPoolSlots__factory.abi>) {
async function verifySlots(slots: ContractFunctionReturnType<typeof EphemeralPoolSlots__factory.abi>) {
expect(slots.some(({ data }) => data > 0)).to.be.true;
const address = pool;
const altSlots = await Promise.all(
Expand Down
60 changes: 29 additions & 31 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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==
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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"

Expand Down

0 comments on commit 0dad400

Please sign in to comment.