diff --git a/packages/cf.js/rollup.config.js b/packages/cf.js/rollup.config.js index 48496a738..c45191c6c 100644 --- a/packages/cf.js/rollup.config.js +++ b/packages/cf.js/rollup.config.js @@ -17,7 +17,8 @@ export default { format: "iife", exports: "named", globals: { - "ethers/utils": "ethers.utils" + "ethers/utils": "ethers.utils", + "ethers/constants": "ethers.constants" } } ], diff --git a/packages/cf.js/src/legacy/app-instance.ts b/packages/cf.js/src/legacy/app-instance.ts index 09a57e48b..2a2b7241f 100644 --- a/packages/cf.js/src/legacy/app-instance.ts +++ b/packages/cf.js/src/legacy/app-instance.ts @@ -1,4 +1,4 @@ -import { ethers } from "ethers"; +import { formatParamType, Interface, ParamType } from "ethers/utils"; import { Terms } from "./app"; import { AbiEncodings, AppDefinition } from "./types"; @@ -13,25 +13,23 @@ export class AppInstance { // TODO: temp hack necessary until ethers support https://github.com/ethers-io/ethers.js/issues/325 static generateAbiEncodings( - abi: string | (string | ethers.utils.ParamType)[] + abi: string | (string | ParamType)[] ): AbiEncodings { - const iface = new ethers.utils.Interface(abi); + const iface = new Interface(abi); const appFunctionNames = Object.keys(iface.functions).filter(fn => { return fn.indexOf("(") === -1; }); const appActions = appFunctionNames.map(fn => { const inputs = iface.functions[fn].inputs; const tuples = inputs.map(input => { - return ethers.utils.formatParamType(input); + return formatParamType(input); }); return `${fn}(${tuples.join(",")})`; }); return { - appStateEncoding: ethers.utils.formatParamType( - iface.functions.resolve.inputs[0] - ), + appStateEncoding: formatParamType(iface.functions.resolve.inputs[0]), appActionEncoding: JSON.stringify([appActions.join(",")]) }; } diff --git a/packages/cf.js/src/legacy/app/index.ts b/packages/cf.js/src/legacy/app/index.ts index b7bb40e56..96f388661 100644 --- a/packages/cf.js/src/legacy/app/index.ts +++ b/packages/cf.js/src/legacy/app/index.ts @@ -1,5 +1,5 @@ -import { ethers } from "ethers"; -import { defaultAbiCoder, keccak256 } from "ethers/utils"; +import { HashZero } from "ethers/constants"; +import { BigNumber, defaultAbiCoder, keccak256 } from "ethers/utils"; import * as abi from "../../utils/abi"; import { StateChannelInfo } from "../channel"; @@ -67,7 +67,7 @@ export class AppInterface { console.error( "WARNING: Can't compute hash for AppInterface because its address is 0x0" ); - return ethers.constants.HashZero; + return HashZero; } return keccak256( abi.encode( @@ -91,7 +91,7 @@ export class AppInterface { export class Terms { constructor( readonly assetType: number, - readonly limit: ethers.utils.BigNumber, + readonly limit: BigNumber, readonly token: Address ) {} @@ -118,8 +118,8 @@ export interface UpdateData { } export interface UninstallOptions { - peerABalance: ethers.utils.BigNumber; - peerBBalance: ethers.utils.BigNumber; + peerABalance: BigNumber; + peerBBalance: BigNumber; } export interface InstallData { @@ -138,8 +138,8 @@ export interface InstallOptions { stateEncoding: string; abiEncoding: string; state: object; - peerABalance: ethers.utils.BigNumber; - peerBBalance: ethers.utils.BigNumber; + peerABalance: BigNumber; + peerBBalance: BigNumber; } export interface AppInstanceInfo { diff --git a/packages/cf.js/src/legacy/eth-balance-refund-app.ts b/packages/cf.js/src/legacy/eth-balance-refund-app.ts index 150cc03f7..c01630db0 100644 --- a/packages/cf.js/src/legacy/eth-balance-refund-app.ts +++ b/packages/cf.js/src/legacy/eth-balance-refund-app.ts @@ -1,6 +1,5 @@ import BuildArtifact from "@counterfactual/contracts/build/contracts/ETHBalanceRefundApp.json"; - -import { ethers } from "ethers"; +import { AddressZero, Zero } from "ethers/constants"; import { Terms } from "./app"; import { AppInstance } from "./app-instance"; @@ -9,11 +8,7 @@ import { AppDefinition } from "./types"; export class ETHBalanceRefundApp extends AppInstance { constructor(appAddress: string, signingKeys: string[]) { const timeout = 100; - const terms = new Terms( - 0, - ethers.utils.bigNumberify("0"), - ethers.constants.AddressZero - ); + const terms = new Terms(0, Zero, AddressZero); const abiEncodings = AppInstance.generateAbiEncodings(BuildArtifact.abi); const appDefinition: AppDefinition = { diff --git a/packages/cf.js/src/legacy/node/index.ts b/packages/cf.js/src/legacy/node/index.ts index 580456f89..74c836736 100644 --- a/packages/cf.js/src/legacy/node/index.ts +++ b/packages/cf.js/src/legacy/node/index.ts @@ -1,4 +1,4 @@ -import { ethers } from "ethers"; +import { Signature } from "ethers/utils"; // FIXME: move operation action names away from client action names // https://github.com/counterfactual/monorepo/issues/144 @@ -47,5 +47,5 @@ export interface ClientActionMessage { toAddress: string; fromAddress: string; seq: number; - signature?: ethers.utils.Signature; + signature?: Signature; } diff --git a/packages/cf.js/src/legacy/types.ts b/packages/cf.js/src/legacy/types.ts index 1c9ee5224..c9705241f 100644 --- a/packages/cf.js/src/legacy/types.ts +++ b/packages/cf.js/src/legacy/types.ts @@ -1,4 +1,4 @@ -import { ethers } from "ethers"; +import { BigNumber } from "ethers/utils"; export interface AppDefinition { address: string; @@ -12,7 +12,7 @@ export interface AbiEncodings { } export interface Deposits { - [s: string]: ethers.utils.BigNumber; + [s: string]: BigNumber; } export type DeserializationCondition = { diff --git a/packages/cf.js/src/legacy/utils/free-balance.ts b/packages/cf.js/src/legacy/utils/free-balance.ts index 5a8de434c..ad663a619 100644 --- a/packages/cf.js/src/legacy/utils/free-balance.ts +++ b/packages/cf.js/src/legacy/utils/free-balance.ts @@ -1,4 +1,5 @@ -import { ethers } from "ethers"; +import { AddressZero } from "ethers/constants"; +import { BigNumber, Interface, parseEther } from "ethers/utils"; import { AppInterface, Terms } from "../app"; @@ -15,14 +16,14 @@ export class FreeBalance { // https://github.com/counterfactual/monorepo/issues/118 return new Terms( 0, // 0 means ETH - ethers.utils.parseEther("0.001"), // FIXME: un-hardcode (https://github.com/counterfactual/monorepo/issues/117) - ethers.constants.AddressZero + parseEther("0.001"), // FIXME: un-hardcode (https://github.com/counterfactual/monorepo/issues/117) + AddressZero ); } public static contractInterface(address: string): AppInterface { const applyAction = "0x00000000"; // not used - const resolver = new ethers.utils.Interface([ + const resolver = new Interface([ // TODO: Put this somewhere eh // https://github.com/counterfactual/monorepo/issues/134 "resolve(tuple(address,address,uint256,uint256),tuple(uint8,uint256,address))" @@ -41,16 +42,16 @@ export class FreeBalance { constructor( readonly alice: Address, // first person in free balance object - readonly aliceBalance: ethers.utils.BigNumber, + readonly aliceBalance: BigNumber, readonly bob: Address, // second person in free balance object - readonly bobBalance: ethers.utils.BigNumber, + readonly bobBalance: BigNumber, readonly uniqueId: number, readonly localNonce: number, readonly timeout: number, readonly dependencyNonce: Nonce ) {} - public balanceOfAddress(address: Address): ethers.utils.BigNumber { + public balanceOfAddress(address: Address): BigNumber { if (address === this.alice) return this.aliceBalance; if (address === this.bob) return this.bobBalance; throw Error(`address ${address} not in free balance`); diff --git a/packages/cf.js/src/legacy/utils/peer-balance.ts b/packages/cf.js/src/legacy/utils/peer-balance.ts index 0ce932df1..cf222e2a3 100644 --- a/packages/cf.js/src/legacy/utils/peer-balance.ts +++ b/packages/cf.js/src/legacy/utils/peer-balance.ts @@ -1,6 +1,6 @@ -import { ethers } from "ethers"; +import { BigNumber, bigNumberify } from "ethers/utils"; -import { Address } from "."; +import { Address } from "./index"; export class PeerBalance { /** @@ -8,9 +8,9 @@ export class PeerBalance { */ public static balances( address1: Address, - balance1: ethers.utils.BigNumber, + balance1: BigNumber, address2: Address, - balance2: ethers.utils.BigNumber + balance2: BigNumber ): CanonicalPeerBalance { if (address2.localeCompare(address1) < 0) { return new CanonicalPeerBalance( @@ -61,13 +61,10 @@ export class PeerBalance { ) ]; } - public balance: ethers.utils.BigNumber; + public balance: BigNumber; - constructor( - readonly address: Address, - balance: number | ethers.utils.BigNumber - ) { - this.balance = ethers.utils.bigNumberify(balance.toString()); + constructor(readonly address: Address, balance: number | BigNumber) { + this.balance = bigNumberify(balance.toString()); } } diff --git a/packages/cf.js/src/legacy/utils/serializer.ts b/packages/cf.js/src/legacy/utils/serializer.ts index 04e463a9e..34bfcc990 100644 --- a/packages/cf.js/src/legacy/utils/serializer.ts +++ b/packages/cf.js/src/legacy/utils/serializer.ts @@ -1,4 +1,4 @@ -import { ethers } from "ethers"; +import { bigNumberify } from "ethers/utils"; import { DeserializationCase } from "../types"; @@ -24,7 +24,7 @@ const isSignature = data => const deserializeArray = data => data.map(value => deserialize(value)); -const deserializeBigNumber = data => ethers.utils.bigNumberify(data._hex); +const deserializeBigNumber = data => bigNumberify(data._hex); const identity = data => data; diff --git a/packages/cf.js/src/utils/abi.ts b/packages/cf.js/src/utils/abi.ts index e4ec5d6e1..8b4b4faf2 100644 --- a/packages/cf.js/src/utils/abi.ts +++ b/packages/cf.js/src/utils/abi.ts @@ -1,13 +1,13 @@ -import { ethers } from "ethers"; +import { Arrayish, defaultAbiCoder, solidityPack } from "ethers/utils"; export function encode(types: string[], values: any[]) { - return ethers.utils.defaultAbiCoder.encode(types, values); + return defaultAbiCoder.encode(types, values); } -export function decode(types: string[], data: ethers.utils.Arrayish) { - return ethers.utils.defaultAbiCoder.decode(types, data); +export function decode(types: string[], data: Arrayish) { + return defaultAbiCoder.decode(types, data); } export function encodePacked(types: string[], values: any[]) { - return ethers.utils.solidityPack(types, values); + return solidityPack(types, values); } diff --git a/packages/cf.js/src/utils/signature.ts b/packages/cf.js/src/utils/signature.ts index 16cf8042a..abd069b15 100644 --- a/packages/cf.js/src/utils/signature.ts +++ b/packages/cf.js/src/utils/signature.ts @@ -1,12 +1,14 @@ -import { ethers } from "ethers"; - import { Bytes32 } from "@counterfactual/common-types"; +import { + BigNumber, + joinSignature, + recoverAddress, + Signature +} from "ethers/utils"; -export function signaturesToBytes( - ...signatures: ethers.utils.Signature[] -): string { +export function signaturesToBytes(...signatures: Signature[]): string { const signaturesHexString = signatures - .map(ethers.utils.joinSignature) + .map(joinSignature) .map(s => s.substr(2)) .join(""); return `0x${signaturesHexString}`; @@ -14,13 +16,13 @@ export function signaturesToBytes( export function signaturesToSortedBytes( digest: Bytes32, - ...signatures: ethers.utils.Signature[] + ...signatures: Signature[] ): string { const sigs = signatures.slice(); sigs.sort((sigA, sigB) => { - const addrA = ethers.utils.recoverAddress(digest, signaturesToBytes(sigA)); - const addrB = ethers.utils.recoverAddress(digest, signaturesToBytes(sigB)); - return new ethers.utils.BigNumber(addrA).lt(addrB) ? -1 : 1; + const addrA = recoverAddress(digest, signaturesToBytes(sigA)); + const addrB = recoverAddress(digest, signaturesToBytes(sigB)); + return new BigNumber(addrA).lt(addrB) ? -1 : 1; }); return signaturesToBytes(...sigs); } diff --git a/packages/cf.js/test/app-factory.spec.ts b/packages/cf.js/test/app-factory.spec.ts index 9a4e5bfdf..afbbe2e5a 100644 --- a/packages/cf.js/test/app-factory.spec.ts +++ b/packages/cf.js/test/app-factory.spec.ts @@ -1,5 +1,5 @@ import { AssetType, Node } from "@counterfactual/common-types"; -import { ethers } from "ethers"; +import { parseEther } from "ethers/utils"; import { AppFactory } from "../src/app-factory"; import { Provider } from "../src/provider"; @@ -37,7 +37,7 @@ describe("CF.js AppFactory", () => { expect(request.type).toBe(Node.MethodName.PROPOSE_INSTALL); const params = request.params as Node.ProposeInstallParams; expect(params.initialState).toBe(testState); - expect(params.myDeposit).toEqual(ethers.utils.parseEther("0.5")); + expect(params.myDeposit).toEqual(parseEther("0.5")); nodeProvider.simulateMessageFromNode({ type: Node.MethodName.PROPOSE_INSTALL, requestId: request.requestId, @@ -51,8 +51,8 @@ describe("CF.js AppFactory", () => { asset: { assetType: AssetType.ETH }, - peerDeposit: ethers.utils.parseEther("0.5"), - myDeposit: ethers.utils.parseEther("0.5"), + peerDeposit: parseEther("0.5"), + myDeposit: parseEther("0.5"), timeout: "100", initialState: testState }); @@ -66,8 +66,8 @@ describe("CF.js AppFactory", () => { asset: { assetType: AssetType.ETH }, - peerDeposit: ethers.utils.parseEther("0.5"), - myDeposit: ethers.utils.parseEther("0.5"), + peerDeposit: parseEther("0.5"), + myDeposit: parseEther("0.5"), timeout: "100", initialState: "4000" }); @@ -86,7 +86,7 @@ describe("CF.js AppFactory", () => { asset: { assetType: AssetType.ETH }, - peerDeposit: ethers.utils.parseEther("0.5"), + peerDeposit: parseEther("0.5"), myDeposit: "$%GARBAGE$%", timeout: "100", initialState: "4000" diff --git a/packages/cf.js/test/utils/signature.spec.ts b/packages/cf.js/test/utils/signature.spec.ts index 8700fb19d..c4e981bc2 100644 --- a/packages/cf.js/test/utils/signature.spec.ts +++ b/packages/cf.js/test/utils/signature.spec.ts @@ -1,14 +1,14 @@ -import { ethers } from "ethers"; +import { keccak256, SigningKey, toUtf8Bytes } from "ethers/utils"; import { signaturesToBytes, signaturesToSortedBytes } from "../../src/utils"; const privateKey = "0x0123456789012345678901234567890123456789012345678901234567890123"; -const signingKey = new ethers.utils.SigningKey(privateKey); +const signingKey = new SigningKey(privateKey); const signaturesAndDigests = ["sig1", "sig3", "sig2"].map(message => { - const bytes = ethers.utils.toUtf8Bytes(message); - const digest = ethers.utils.keccak256(bytes); + const bytes = toUtf8Bytes(message); + const digest = keccak256(bytes); const signature = signingKey.signDigest(digest); return { diff --git a/packages/contracts/test/app-registry.spec.ts b/packages/contracts/test/app-registry.spec.ts index f4e741553..6ea6c9ca9 100644 --- a/packages/contracts/test/app-registry.spec.ts +++ b/packages/contracts/test/app-registry.spec.ts @@ -1,5 +1,6 @@ -import { ethers } from "ethers"; -import { Web3Provider } from "ethers/providers"; +import { Contract, ContractFactory } from "ethers"; +import { AddressZero, HashZero } from "ethers/constants"; +import { JsonRpcSigner, Web3Provider } from "ethers/providers"; import { hexlify, randomBytes } from "ethers/utils"; import { ALICE, BOB } from "./constants"; @@ -16,9 +17,9 @@ import { const ONCHAIN_CHALLENGE_TIMEOUT = 30; contract("AppRegistry", (accounts: string[]) => { - let provider: ethers.providers.Web3Provider; - let wallet: ethers.providers.JsonRpcSigner; - let appRegistry: ethers.Contract; + let provider: Web3Provider; + let wallet: JsonRpcSigner; + let appRegistry: Contract; let setStateAsOwner: (nonce: number, appState?: string) => Promise; let setStateWithSignatures: ( @@ -40,7 +41,7 @@ contract("AppRegistry", (accounts: string[]) => { artifact.link(artifacts.require("LibStaticCall")); artifact.link(artifacts.require("Transfer")); - appRegistry = await new ethers.ContractFactory( + appRegistry = await new ContractFactory( artifact.abi, artifact.binary, wallet @@ -60,7 +61,7 @@ contract("AppRegistry", (accounts: string[]) => { hexlify(randomBytes(4)), hexlify(randomBytes(4)) ), - new Terms(AssetType.ETH, 0, ethers.constants.AddressZero), + new Terms(AssetType.ETH, 0, AddressZero), 10 ); @@ -77,26 +78,23 @@ contract("AppRegistry", (accounts: string[]) => { setStateAsOwner = (nonce: number, appState?: string) => appRegistry.functions.setState(appInstance.appIdentity, { nonce, - stateHash: appState || ethers.constants.HashZero, + stateHash: appState || HashZero, timeout: ONCHAIN_CHALLENGE_TIMEOUT, - signatures: ethers.constants.HashZero + signatures: HashZero }); cancelChallenge = () => - appRegistry.functions.cancelChallenge( - appInstance.appIdentity, - ethers.constants.HashZero - ); + appRegistry.functions.cancelChallenge(appInstance.appIdentity, HashZero); setStateWithSignatures = async (nonce: number, appState?: string) => appRegistry.functions.setState(appInstance.appIdentity, { nonce, - stateHash: appState || ethers.constants.HashZero, + stateHash: appState || HashZero, timeout: ONCHAIN_CHALLENGE_TIMEOUT, signatures: await wallet.signMessage( computeStateHash( appInstance.id, - appState || ethers.constants.HashZero, + appState || HashZero, nonce, ONCHAIN_CHALLENGE_TIMEOUT ) diff --git a/packages/node/src/channels.ts b/packages/node/src/channels.ts index c80607251..33689697c 100644 --- a/packages/node/src/channels.ts +++ b/packages/node/src/channels.ts @@ -1,5 +1,5 @@ import { Address, AppInstanceInfo, Node } from "@counterfactual/common-types"; -import { ethers } from "ethers"; +import { Wallet } from "ethers"; import { v4 as generateUUID } from "uuid"; import { APP_INSTANCE_STATUS, Channel } from "./models"; @@ -447,6 +447,6 @@ export class Channels { private generateNewMultisigAddress(owners: Address[]): Address { // TODO: implement this using CREATE2 - return ethers.Wallet.createRandom().address; + return Wallet.createRandom().address; } } diff --git a/packages/node/src/models.ts b/packages/node/src/models.ts index 5f86e2040..0ecf15c5b 100644 --- a/packages/node/src/models.ts +++ b/packages/node/src/models.ts @@ -4,8 +4,7 @@ import { AppInstanceInfo, AssetType } from "@counterfactual/common-types"; - -import { zeroBalance } from "./utils"; +import { Zero } from "ethers/constants"; import Nonce = legacy.utils.Nonce; import FreeBalance = legacy.utils.FreeBalance; @@ -93,9 +92,9 @@ export class Channel { // TODO: extend to all asset types const ethFreeBalance = new FreeBalance( multisigOwners[0], - zeroBalance, + Zero, multisigOwners[1], - zeroBalance, + Zero, 0, 0, 0, diff --git a/packages/node/src/node.ts b/packages/node/src/node.ts index 601cefbb9..89dd5d8a3 100644 --- a/packages/node/src/node.ts +++ b/packages/node/src/node.ts @@ -1,5 +1,5 @@ import { Address, Node as NodeTypes } from "@counterfactual/common-types"; -import { ethers } from "ethers"; +import { SigningKey } from "ethers/utils"; import EventEmitter from "eventemitter3"; import { Channels } from "./channels"; @@ -22,7 +22,7 @@ export class Node { private readonly outgoing: EventEmitter; private readonly channels: Channels; - private readonly signer: ethers.utils.SigningKey; + private readonly signer: SigningKey; protected readonly requestHandler: RequestHandler; /** @@ -35,7 +35,7 @@ export class Node { private readonly storeService: IStoreService, nodeConfig: NodeConfig ) { - this.signer = new ethers.utils.SigningKey(privateKey); + this.signer = new SigningKey(privateKey); this.incoming = new EventEmitter(); this.outgoing = new EventEmitter(); this.channels = new Channels( diff --git a/packages/node/src/utils.ts b/packages/node/src/utils.ts index 5fb36c7d0..cc01d5198 100644 --- a/packages/node/src/utils.ts +++ b/packages/node/src/utils.ts @@ -1,11 +1,9 @@ import { Address } from "@counterfactual/common-types"; -import { ethers } from "ethers"; - -export const zeroBalance = ethers.utils.bigNumberify("0"); +import { BigNumber, hashMessage } from "ethers/utils"; export function orderedAddressesHash(addresses: Address[]): string { addresses.sort((addrA: Address, addrB: Address) => { - return new ethers.utils.BigNumber(addrA).lt(addrB) ? -1 : 1; + return new BigNumber(addrA).lt(addrB) ? -1 : 1; }); - return ethers.utils.hashMessage(addresses.join("")); + return hashMessage(addresses.join("")); } diff --git a/packages/node/test/integration/get-app-instances.spec.ts b/packages/node/test/integration/get-app-instances.spec.ts index 3ba17d974..ede2a4cd7 100644 --- a/packages/node/test/integration/get-app-instances.spec.ts +++ b/packages/node/test/integration/get-app-instances.spec.ts @@ -4,7 +4,7 @@ import { } from "@counterfactual/common-types"; import cuid from "cuid"; import dotenv from "dotenv"; -import { ethers } from "ethers"; +import { Wallet } from "ethers"; import FirebaseServer from "firebase-server"; import { IStoreService, Node, NodeConfig } from "../../src"; @@ -63,7 +63,7 @@ describe("Node method follows spec - getAppInstances", () => { it("can accept a valid call to get non-empty list of app instances", async done => { // the peer with whom an installation proposal is being made - const peerAddress = new ethers.Wallet(B_PRIVATE_KEY).address; + const peerAddress = new Wallet(B_PRIVATE_KEY).address; // first, a channel must be opened for it to have an app instance const multisigAddress = await getNewMultisig(node, [ diff --git a/packages/node/test/integration/node-communication.spec.ts b/packages/node/test/integration/node-communication.spec.ts index 7f1311385..fc5b276e0 100644 --- a/packages/node/test/integration/node-communication.spec.ts +++ b/packages/node/test/integration/node-communication.spec.ts @@ -1,5 +1,5 @@ import dotenv from "dotenv"; -import { ethers } from "ethers"; +import { AddressZero } from "ethers/constants"; import FirebaseServer from "firebase-server"; import { IMessagingService } from "../../src"; @@ -28,7 +28,7 @@ describe("Two nodes can communicate with each other", () => { }); it("can setup listeners for events through messaging service", done => { - const address = ethers.constants.AddressZero; + const address = AddressZero; const testMsg = { event: "testEvent", data: { diff --git a/packages/node/test/integration/node-store.spec.ts b/packages/node/test/integration/node-store.spec.ts index 36bcc3d72..a524f31e1 100644 --- a/packages/node/test/integration/node-store.spec.ts +++ b/packages/node/test/integration/node-store.spec.ts @@ -1,9 +1,9 @@ import dotenv from "dotenv"; -import { ethers } from "ethers"; +import { Wallet } from "ethers"; +import { AddressZero } from "ethers/constants"; import FirebaseServer from "firebase-server"; import { IStoreService, Node, NodeConfig } from "../../src"; - import { A_PRIVATE_KEY, B_PRIVATE_KEY } from "../env"; import { MOCK_MESSAGING_SERVICE } from "../mock-services/mock-messaging-service"; @@ -42,12 +42,9 @@ describe("Node can use storage service", () => { }); it("can save multiple channels under respective multisig indeces and query for all channels", async () => { - const channelA = { owners: [node.address, ethers.constants.AddressZero] }; + const channelA = { owners: [node.address, AddressZero] }; const channelB = { - owners: [ - new ethers.Wallet(B_PRIVATE_KEY).address, - ethers.constants.AddressZero - ] + owners: [new Wallet(B_PRIVATE_KEY).address, AddressZero] }; await storeService.set([{ key: "multisigAddress/0x111", value: channelA }]); await storeService.set([{ key: "multisigAddress/0x222", value: channelB }]); @@ -62,12 +59,9 @@ describe("Node can use storage service", () => { }); it("can save multiple channels under respective multisig indeces in one call and query for all channels", async () => { - const channelA = { owners: [node.address, ethers.constants.AddressZero] }; + const channelA = { owners: [node.address, AddressZero] }; const channelB = { - owners: [ - new ethers.Wallet(B_PRIVATE_KEY).address, - ethers.constants.AddressZero - ] + owners: [new Wallet(B_PRIVATE_KEY).address, AddressZero] }; await storeService.set([ { key: "multisigAddress/0x111", value: channelA }, diff --git a/packages/node/test/integration/utils.ts b/packages/node/test/integration/utils.ts index c88fdb08c..77c21da16 100644 --- a/packages/node/test/integration/utils.ts +++ b/packages/node/test/integration/utils.ts @@ -5,7 +5,7 @@ import { Node as NodeTypes } from "@counterfactual/common-types"; import cuid from "cuid"; -import { ethers } from "ethers"; +import { One } from "ethers/constants"; import { Node } from "../../src"; import { APP_INSTANCE_STATUS } from "../../src/models"; @@ -95,9 +95,9 @@ export function makeProposalRequest( asset: { assetType: AssetType.ETH }, - myDeposit: ethers.utils.bigNumberify("1"), - peerDeposit: ethers.utils.bigNumberify("1"), - timeout: ethers.utils.bigNumberify("1"), + myDeposit: One, + peerDeposit: One, + timeout: One, initialState: { propertyA: "A", propertyB: "B"