Skip to content

Commit

Permalink
Revert client to old implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
amateima committed Aug 25, 2021
1 parent 51028e1 commit 1a4391a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 27 deletions.
31 changes: 6 additions & 25 deletions packages/sdk/src/clients/multicall/client.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,18 @@ import { ethers } from "ethers";
import { emp } from "..";

// multicall contract deployed to mainnet
const multicallV1Address = "0xeefba1e63905ef1d7acba5a8513c70307c1ce441";
const multicallV2Address = "0x5ba1e12693dc8f9c48aad8770482f4739beed696";
const address = "0xeefba1e63905ef1d7acba5a8513c70307c1ce441";
const empAddress = "0xd81028a6fbAAaf604316F330b20D24bFbFd14478";
// these require integration testing, skip for ci
describe("multicall", function () {
let clientV1: Client.Instance;
let clientV2: Client.Instance;
let client: Client.Instance;
let empClient: emp.Instance;

test("inits", function () {
const provider = ethers.providers.getDefaultProvider(process.env.CUSTOM_NODE_URL);
clientV1 = Client.connect(multicallV1Address, provider);
clientV2 = Client.connect(multicallV2Address, provider);
client = Client.connect(address, provider);
empClient = emp.connect(empAddress, provider);
assert.ok(clientV1);
assert.ok(clientV2);
assert.ok(client);
assert.ok(empClient);
});

Expand All @@ -31,27 +28,11 @@ describe("multicall", function () {
callData: empClient.interface.encodeFunctionData(call),
};
});
const response = await clientV1.callStatic.aggregate(multicalls);
const response = await client.callStatic.aggregate(multicalls);
const decoded = calls.map((call: any, i: number) => {
const result = response.returnData[i];
return empClient.interface.decodeFunctionResult(call, result);
});
assert.equal(decoded.length, calls.length);
});

test("multicall2 on emp", async function () {
const calls = ["priceIdentifier", "tokenCurrency", "collateralCurrency"];
const multicalls = calls.map((call: any) => {
return {
target: empAddress,
callData: empClient.interface.encodeFunctionData(call),
};
});
const response = await clientV2.callStatic.tryBlockAndAggregate(false, multicalls);
const decoded = calls.map((call: any, i: number) => {
const result = response.returnData[i];
return empClient.interface.decodeFunctionResult(call, result[1]);
});
assert.equal(decoded.length, calls.length);
});
});
4 changes: 2 additions & 2 deletions packages/sdk/src/clients/multicall/client.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { EthersContracts } from "@uma/core";
import type { SignerOrProvider } from "../..";

export type Instance = EthersContracts.Multicall2;
const Factory = EthersContracts.Multicall2__factory;
export type Instance = EthersContracts.Multicall;
const Factory = EthersContracts.Multicall__factory;

export function connect(address: string, provider: SignerOrProvider): Instance {
return Factory.connect(address, provider);
Expand Down

0 comments on commit 1a4391a

Please sign in to comment.