diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 199e4e4f12..be15943ef4 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -1,10 +1,6 @@ name: CD -on: - push: - branches: - - master - - staging +on: [push] jobs: test-ssh: @@ -75,7 +71,7 @@ jobs: env: DOCKER_USER: ${{ secrets.DOCKER_USER }} DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - if: endsWith(github.ref, 'staging') + if: endsWith(github.ref, '/staging') needs: [test-node, test-cf, test-bot, test-daicard] runs-on: ubuntu-latest steps: @@ -89,7 +85,7 @@ jobs: env: DOCKER_USER: ${{ secrets.DOCKER_USER }} DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - if: endsWith(github.ref, 'master') + if: endsWith(github.ref, '/master') needs: [test-node, test-cf, test-bot, test-daicard] runs-on: ubuntu-latest steps: @@ -107,7 +103,7 @@ jobs: SSH_DIR: $HOME/.ssh SSH_KEY: ${{ secrets.SSH_KEY }} STAGING_DOMAINNAME: staging.indra.connext.network - if: endsWith(github.ref, 'staging') + if: endsWith(github.ref, '/staging') needs: [push-latest] runs-on: ubuntu-latest steps: @@ -154,7 +150,7 @@ jobs: RINKEBY_ETH_PROVIDER: ${{ secrets.RINKEBY_ETH_PROVIDER }} SSH_DIR: $HOME/.ssh SSH_KEY: ${{ secrets.SSH_KEY }} - if: endsWith(github.ref, 'master') + if: endsWith(github.ref, '/master') needs: [push-versioned] runs-on: ubuntu-latest steps: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a4c79c9b4b..ae11af826d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ on: jobs: quick-test: - runs-on: self-hosted + runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - run: make clean && make reset diff --git a/Makefile b/Makefile index a4f2755460..a8f227de96 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,6 @@ cf-adjudicator-contracts=$(cwd)/modules/cf-adjudicator-contracts cf-apps=$(cwd)/modules/cf-apps cf-funding-protocol-contracts=$(cwd)/modules/cf-funding-protocol-contracts cf-core=$(cwd)/modules/cf-core -cf-types=$(cwd)/modules/cf-types client=$(cwd)/modules/client contracts=$(cwd)/modules/contracts daicard=$(cwd)/modules/daicard @@ -208,11 +207,6 @@ cf-funding-protocol-contracts: node-modules $(shell find $(cf-funding-protocol-c $(docker_run) "cd modules/cf-funding-protocol-contracts && npm run build" $(log_finish) && mv -f $(totalTime) $(flags)/$@ -cf-types: node-modules $(shell find $(cf-types)/src $(cf-types)/tsconfig.json $(find_options)) - $(log_start) - $(docker_run) "cd modules/cf-types && npm run build" - $(log_finish) && mv -f $(totalTime) $(flags)/$@ - client: cf-core contracts types messaging $(shell find $(client)/src $(client)/tsconfig.json $(find_options)) $(log_start) $(docker_run) "cd modules/client && npm run build" @@ -279,7 +273,7 @@ indra-proxy-prod: daicard-prod dashboard-prod ws-tcp-relay $(shell find $(proxy) docker build --file $(proxy)/indra.connext.network/prod.dockerfile --tag $(project)_proxy:latest . $(log_finish) && mv -f $(totalTime) $(flags)/$@ -types: node-modules cf-types $(shell find $(types)/src $(find_options)) +types: node-modules $(shell find $(types)/src $(find_options)) $(log_start) $(docker_run) "cd modules/types && npm run build" $(log_finish) && mv -f $(totalTime) $(flags)/$@ diff --git a/cypress/tests/daicard.js b/cypress/tests/daicard.js index 46d0d19af6..63cc8f03a3 100644 --- a/cypress/tests/daicard.js +++ b/cypress/tests/daicard.js @@ -11,6 +11,12 @@ describe("Daicard", () => { my.closeIntroModal(); }); + describe("WalletConnext", () => { + it(`should open a modal when activated`, () => { + my.activateWalletConnext(); + }); + }); + describe("Deposit", () => { it(`should accept an Eth deposit to displayed address`, () => { my.deposit(depositEth); @@ -163,7 +169,7 @@ describe("Daicard", () => { my.depositToken(depositToken).then(tokensDeposited => { my.getOnchainTokenBalance().then(balanceBefore => { my.cashoutToken() - my.depositToken(`${depositToken}1`).then(tokensDeposited => { + my.depositToken(`${depositToken}.1`).then(tokensDeposited => { my.getOnchainTokenBalance().then(balanceBefore => { my.cashoutToken(); cy.resolve(my.getOnchainTokenBalance).should(balanceAfter => { diff --git a/cypress/tests/utils.js b/cypress/tests/utils.js index 1a35f14bb3..83f0403659 100644 --- a/cypress/tests/utils.js +++ b/cypress/tests/utils.js @@ -24,6 +24,8 @@ my.xpubRegex = /^xpub[a-zA-Z0-9]{107}/i; my.isStarting = () => cy.contains("span", /starting/i).should("exist"); my.doneStarting = () => cy.contains("span", /starting/i).should("not.exist"); +my.isWalletConnecting = () => cy.contains(/walletconnect/i).should("exist"); + //Dashboard my.goToDebug = () => cy.get(`a[href="/debug"]`).click() my.goToDebugChannel = () => cy.get(`a[href="/dashboard/debug/channel"]`).click() @@ -39,6 +41,15 @@ my.goBack = () => cy.contains("button", /^back$/i).click(); my.goNextIntro = () => cy.contains("button", /^next$/i).click(); my.goCloseIntro = () => cy.contains("button", /^got it!$/i).click(); +my.activateWalletConnext = () => { + my.goToSettings(); + cy.contains("button", /walletconnext/i).click(); + my.isStarting(); + my.isWalletConnecting(); + // TODO: make this actually activate wallet connect + // my.doneStarting(); +} + my.closeIntroModal = () => { my.isStarting(); my.doneStarting(); diff --git a/modules/cf-adjudicator-contracts/package.json b/modules/cf-adjudicator-contracts/package.json index 3952a33bb1..0940324232 100644 --- a/modules/cf-adjudicator-contracts/package.json +++ b/modules/cf-adjudicator-contracts/package.json @@ -20,7 +20,7 @@ "solidity" ], "devDependencies": { - "@connext/types": "1.3.14", + "@connext/types": "1.4.1", "@connext/cf-types": "1.3.14", "@types/node": "12.12.14", "@types/chai": "4.2.6", diff --git a/modules/cf-core/package.json b/modules/cf-core/package.json index 62eb3f2a49..df46f9e79a 100644 --- a/modules/cf-core/package.json +++ b/modules/cf-core/package.json @@ -1,6 +1,6 @@ { "name": "@connext/cf-core", - "version": "1.3.14", + "version": "1.4.1", "main": "dist/src/index.js", "iife": "dist/src/index.iife.js", "types": "dist/src/index.d.ts", @@ -19,7 +19,7 @@ "dependencies": { "@connext/cf-adjudicator-contracts": "0.4.1", "@connext/cf-funding-protocol-contracts": "0.4.1", - "@connext/types": "1.3.14", + "@connext/types": "1.4.1", "ethers": "4.0.40", "eventemitter3": "4.0.0", "loglevel": "1.6.6", diff --git a/modules/cf-core/src/api.ts b/modules/cf-core/src/api.ts index ec5fde2c13..243d27f8e1 100644 --- a/modules/cf-core/src/api.ts +++ b/modules/cf-core/src/api.ts @@ -65,7 +65,7 @@ const controllers = [ /** * Converts the array of connected controllers into a map of - * Node.MethodNames to the _executeMethod_ method of a controller. + * CFCoreTypes.MethodNames to the _executeMethod_ method of a controller. * * Throws a runtime error when package is imported if multiple * controllers overlap (should be caught by compiler anyway). diff --git a/modules/cf-core/src/ethereum/multisig-commitment.ts b/modules/cf-core/src/ethereum/multisig-commitment.ts index 48158d4aef..dabf9efa49 100644 --- a/modules/cf-core/src/ethereum/multisig-commitment.ts +++ b/modules/cf-core/src/ethereum/multisig-commitment.ts @@ -7,7 +7,7 @@ import { } from "ethers/utils"; import { MinimumViableMultisig } from "../contracts"; -import { Node } from "../types"; +import { CFCoreTypes } from "../types"; import { sortSignaturesBySignerAddress } from "../utils"; import { EthereumCommitment, MultisigTransaction } from "./types"; @@ -23,7 +23,7 @@ export abstract class MultisigCommitment extends EthereumCommitment { abstract getTransactionDetails(): MultisigTransaction; - public getSignedTransaction(sigs: Signature[]): Node.MinimalTransaction { + public getSignedTransaction(sigs: Signature[]): CFCoreTypes.MinimalTransaction { const multisigInput = this.getTransactionDetails(); const signaturesList = sortSignaturesBySignerAddress( diff --git a/modules/cf-core/src/ethereum/set-state-commitment.ts b/modules/cf-core/src/ethereum/set-state-commitment.ts index 3e1865d2df..9cc3e9d20a 100644 --- a/modules/cf-core/src/ethereum/set-state-commitment.ts +++ b/modules/cf-core/src/ethereum/set-state-commitment.ts @@ -10,7 +10,7 @@ import { ChallengeRegistry } from "../contracts"; import { AppIdentity, NetworkContext, - Node, + CFCoreTypes, SignedStateHashUpdate } from "../types"; import { sortSignaturesBySignerAddress } from "../utils"; @@ -46,7 +46,7 @@ export class SetStateCommitment extends EthereumCommitment { ); } - public getSignedTransaction(sigs: Signature[]): Node.MinimalTransaction { + public getSignedTransaction(sigs: Signature[]): CFCoreTypes.MinimalTransaction { return { to: this.networkContext.ChallengeRegistry, value: 0, diff --git a/modules/cf-core/src/ethereum/types.ts b/modules/cf-core/src/ethereum/types.ts index 5501933cac..843334d5f0 100644 --- a/modules/cf-core/src/ethereum/types.ts +++ b/modules/cf-core/src/ethereum/types.ts @@ -1,6 +1,6 @@ import { Signature } from "ethers/utils"; -import { Node } from "../types"; +import { CFCoreTypes } from "../types"; export abstract class EthereumCommitment { // todo(xuanji): EthereumCommitment was designed under the assumption that @@ -14,7 +14,7 @@ export abstract class EthereumCommitment { public abstract getSignedTransaction( signatures: Signature[], intermediarySignature?: Signature, - ): Node.MinimalTransaction; + ): CFCoreTypes.MinimalTransaction; } export enum MultisigOperation { @@ -27,6 +27,6 @@ export enum MultisigOperation { Create = 2, } -export type MultisigTransaction = Node.MinimalTransaction & { +export type MultisigTransaction = CFCoreTypes.MinimalTransaction & { operation: MultisigOperation; }; diff --git a/modules/cf-core/src/index.ts b/modules/cf-core/src/index.ts index ae741ccb52..588c8e9ee6 100644 --- a/modules/cf-core/src/index.ts +++ b/modules/cf-core/src/index.ts @@ -28,4 +28,8 @@ export { WithdrawFailedMessage, WithdrawStartedMessage } from "./types"; -export { getCreate2MultisigAddress } from "./utils"; +export { + getCreate2MultisigAddress, + bigNumberifyJson, + deBigNumberifyJson +} from "./utils"; diff --git a/modules/cf-core/src/methods/app-instance/get-all/controller.ts b/modules/cf-core/src/methods/app-instance/get-all/controller.ts index 16dc80054c..84b404220e 100644 --- a/modules/cf-core/src/methods/app-instance/get-all/controller.ts +++ b/modules/cf-core/src/methods/app-instance/get-all/controller.ts @@ -1,39 +1,26 @@ import { jsonRpcMethod } from "rpc-server"; import { RequestHandler } from "../../../request-handler"; -import { Node, AppInstanceJson } from "../../../types"; +import { CFCoreTypes, AppInstanceJson } from "../../../types"; import { NodeController } from "../../controller"; import { StateChannel } from "../../../models"; +import { prettyPrintObject } from "../../../utils"; /** * Gets all installed appInstances across all of the channels open on * this Node. */ export default class GetAppInstancesController extends NodeController { - @jsonRpcMethod(Node.RpcMethodName.GET_APP_INSTANCES) + @jsonRpcMethod(CFCoreTypes.RpcMethodNames.chan_getAppInstances) public executeMethod = super.executeMethod; protected async executeMethodImplementation( requestHandler: RequestHandler, - params: Node.GetAppInstancesParams - ): Promise { + params: CFCoreTypes.GetAppInstancesParams + ): Promise { const { store } = requestHandler; const { multisigAddress } = params; - const channels = await store.getStateChannelsMap(); - - const appInstances = Array.from(channels.values()).reduce( - (acc: AppInstanceJson[], channel: StateChannel) => { - acc.push( - ...Array.from(channel.appInstances.values()).map(appInstance => - appInstance.toJson() - ) - ); - return acc; - }, - [] - ); - return { appInstances: await store.getAppInstances(multisigAddress) }; diff --git a/modules/cf-core/src/methods/app-instance/get-app-instance/controller.ts b/modules/cf-core/src/methods/app-instance/get-app-instance/controller.ts index b68b4dc8d9..22767e524c 100644 --- a/modules/cf-core/src/methods/app-instance/get-app-instance/controller.ts +++ b/modules/cf-core/src/methods/app-instance/get-app-instance/controller.ts @@ -1,7 +1,7 @@ import { jsonRpcMethod } from "rpc-server"; import { RequestHandler } from "../../../request-handler"; -import { Node } from "../../../types"; +import { CFCoreTypes } from "../../../types"; import { NodeController } from "../../controller"; import { NO_APP_INSTANCE_ID_TO_GET_DETAILS } from "../../errors"; @@ -11,11 +11,11 @@ import { NO_APP_INSTANCE_ID_TO_GET_DETAILS } from "../../errors"; * @param params */ export default class GetAppInstanceDetailsController extends NodeController { - @jsonRpcMethod(Node.RpcMethodName.GET_APP_INSTANCE_DETAILS) + @jsonRpcMethod(CFCoreTypes.RpcMethodNames.chan_getAppInstance) protected async executeMethodImplementation( requestHandler: RequestHandler, - params: Node.GetAppInstanceDetailsParams, - ): Promise { + params: CFCoreTypes.GetAppInstanceDetailsParams, + ): Promise { const { store } = requestHandler; const { appInstanceId } = params; diff --git a/modules/cf-core/src/methods/app-instance/get-free-balance/controller.ts b/modules/cf-core/src/methods/app-instance/get-free-balance/controller.ts index 24764cc8e2..4b46187dc3 100644 --- a/modules/cf-core/src/methods/app-instance/get-free-balance/controller.ts +++ b/modules/cf-core/src/methods/app-instance/get-free-balance/controller.ts @@ -2,17 +2,17 @@ import { jsonRpcMethod } from "rpc-server"; import { CONVENTION_FOR_ETH_TOKEN_ADDRESS } from "../../../constants"; import { RequestHandler } from "../../../request-handler"; -import { Node } from "../../../types"; +import { CFCoreTypes } from "../../../types"; import { NodeController } from "../../controller"; export default class GetFreeBalanceController extends NodeController { - @jsonRpcMethod(Node.RpcMethodName.GET_FREE_BALANCE_STATE) + @jsonRpcMethod(CFCoreTypes.RpcMethodNames.chan_getFreeBalanceState) public executeMethod = super.executeMethod; protected async executeMethodImplementation( requestHandler: RequestHandler, - params: Node.GetFreeBalanceStateParams - ): Promise { + params: CFCoreTypes.GetFreeBalanceStateParams + ): Promise { const { store } = requestHandler; const { multisigAddress, tokenAddress: tokenAddressParam } = params; diff --git a/modules/cf-core/src/methods/app-instance/get-state/controller.ts b/modules/cf-core/src/methods/app-instance/get-state/controller.ts index f586af5930..4295f8ddc5 100644 --- a/modules/cf-core/src/methods/app-instance/get-state/controller.ts +++ b/modules/cf-core/src/methods/app-instance/get-state/controller.ts @@ -1,7 +1,7 @@ import { jsonRpcMethod } from "rpc-server"; import { RequestHandler } from "../../../request-handler"; -import { Node } from "../../../types"; +import { CFCoreTypes } from "../../../types"; import { NodeController } from "../../controller"; import { NO_APP_INSTANCE_ID_FOR_GET_STATE } from "../../errors"; @@ -11,11 +11,11 @@ import { NO_APP_INSTANCE_ID_FOR_GET_STATE } from "../../errors"; * @param params */ export default class GetStateController extends NodeController { - @jsonRpcMethod(Node.RpcMethodName.GET_STATE) + @jsonRpcMethod(CFCoreTypes.RpcMethodNames.chan_getState) protected async executeMethodImplementation( requestHandler: RequestHandler, - params: Node.GetStateParams, - ): Promise { + params: CFCoreTypes.GetStateParams, + ): Promise { const { store } = requestHandler; const { appInstanceId } = params; diff --git a/modules/cf-core/src/methods/app-instance/get-token-indexed-free-balances/controller.ts b/modules/cf-core/src/methods/app-instance/get-token-indexed-free-balances/controller.ts index 2621a25bf3..011ececa8e 100644 --- a/modules/cf-core/src/methods/app-instance/get-token-indexed-free-balances/controller.ts +++ b/modules/cf-core/src/methods/app-instance/get-token-indexed-free-balances/controller.ts @@ -1,17 +1,17 @@ import { jsonRpcMethod } from "rpc-server"; import { RequestHandler } from "../../../request-handler"; -import { Node } from "../../../types"; +import { CFCoreTypes } from "../../../types"; import { NodeController } from "../../controller"; export default class GetTokenIndexedFreeBalancesController extends NodeController { - @jsonRpcMethod(Node.RpcMethodName.GET_TOKEN_INDEXED_FREE_BALANCE_STATES) + @jsonRpcMethod(CFCoreTypes.RpcMethodNames.chan_getTokenIndexedFreeBalanceStates) public executeMethod = super.executeMethod; protected async executeMethodImplementation( requestHandler: RequestHandler, - params: Node.GetTokenIndexedFreeBalanceStatesParams, - ): Promise { + params: CFCoreTypes.GetTokenIndexedFreeBalanceStatesParams, + ): Promise { const { store } = requestHandler; const { multisigAddress } = params; diff --git a/modules/cf-core/src/methods/app-instance/install-virtual/controller.ts b/modules/cf-core/src/methods/app-instance/install-virtual/controller.ts index aedd3d8df0..9439106623 100644 --- a/modules/cf-core/src/methods/app-instance/install-virtual/controller.ts +++ b/modules/cf-core/src/methods/app-instance/install-virtual/controller.ts @@ -1,18 +1,18 @@ import { jsonRpcMethod } from "rpc-server"; import { RequestHandler } from "../../../request-handler"; -import { Node } from "../../../types"; +import { CFCoreTypes } from "../../../types"; import { NodeController } from "../../controller"; import { installVirtual } from "./operation"; export default class InstallVirtualController extends NodeController { - @jsonRpcMethod(Node.RpcMethodName.INSTALL_VIRTUAL) + @jsonRpcMethod(CFCoreTypes.RpcMethodNames.chan_installVirtual) public executeMethod = super.executeMethod; protected async getRequiredLockNames( requestHandler: RequestHandler, - params: Node.InstallVirtualParams + params: CFCoreTypes.InstallVirtualParams ) { const { store, publicIdentifier, networkContext } = requestHandler; const { appInstanceId, intermediaryIdentifier } = params; @@ -71,7 +71,7 @@ export default class InstallVirtualController extends NodeController { protected async beforeExecution( requestHandler: RequestHandler, - params: Node.InstallVirtualParams + params: CFCoreTypes.InstallVirtualParams ) { const { store, publicIdentifier, networkContext } = requestHandler; const { intermediaryIdentifier } = params; @@ -108,8 +108,8 @@ export default class InstallVirtualController extends NodeController { protected async executeMethodImplementation( requestHandler: RequestHandler, - params: Node.InstallVirtualParams - ): Promise { + params: CFCoreTypes.InstallVirtualParams + ): Promise { const { store, protocolRunner } = requestHandler; const { appInstanceId } = params; diff --git a/modules/cf-core/src/methods/app-instance/install-virtual/operation.ts b/modules/cf-core/src/methods/app-instance/install-virtual/operation.ts index 7434870169..0a4a4dce2f 100644 --- a/modules/cf-core/src/methods/app-instance/install-virtual/operation.ts +++ b/modules/cf-core/src/methods/app-instance/install-virtual/operation.ts @@ -2,13 +2,13 @@ import { bigNumberify } from "ethers/utils"; import { Protocol, ProtocolRunner } from "../../../machine"; import { Store } from "../../../store"; -import { AppInstanceProposal, Node } from "../../../types"; +import { AppInstanceProposal, CFCoreTypes } from "../../../types"; import { NO_APP_INSTANCE_ID_TO_INSTALL, VIRTUAL_APP_INSTALLATION_FAIL } from "../../errors"; export async function installVirtual( store: Store, protocolRunner: ProtocolRunner, - params: Node.InstallVirtualParams, + params: CFCoreTypes.InstallVirtualParams, ): Promise { const { appInstanceId, intermediaryIdentifier } = params; diff --git a/modules/cf-core/src/methods/app-instance/install/controller.ts b/modules/cf-core/src/methods/app-instance/install/controller.ts index 2175f01c19..a16862d43f 100644 --- a/modules/cf-core/src/methods/app-instance/install/controller.ts +++ b/modules/cf-core/src/methods/app-instance/install/controller.ts @@ -2,7 +2,7 @@ import { jsonRpcMethod } from "rpc-server"; import { StateChannel } from "../../../models"; import { RequestHandler } from "../../../request-handler"; -import { Node } from "../../../types"; +import { CFCoreTypes } from "../../../types"; import { NodeController } from "../../controller"; import { install } from "./operation"; @@ -13,12 +13,12 @@ import { install } from "./operation"; * @param params */ export default class InstallController extends NodeController { - @jsonRpcMethod(Node.RpcMethodName.INSTALL) + @jsonRpcMethod(CFCoreTypes.RpcMethodNames.chan_install) public executeMethod = super.executeMethod; protected async getRequiredLockNames( requestHandler: RequestHandler, - params: Node.InstallParams, + params: CFCoreTypes.InstallParams, ): Promise { const { store } = requestHandler; const { appInstanceId } = params; @@ -30,8 +30,8 @@ export default class InstallController extends NodeController { protected async executeMethodImplementation( requestHandler: RequestHandler, - params: Node.InstallParams, - ): Promise { + params: CFCoreTypes.InstallParams, + ): Promise { const { store, protocolRunner } = requestHandler; const appInstanceProposal = await install(store, protocolRunner, params); diff --git a/modules/cf-core/src/methods/app-instance/install/operation.ts b/modules/cf-core/src/methods/app-instance/install/operation.ts index 36f01a407d..8eca372531 100644 --- a/modules/cf-core/src/methods/app-instance/install/operation.ts +++ b/modules/cf-core/src/methods/app-instance/install/operation.ts @@ -3,13 +3,13 @@ import { bigNumberify } from "ethers/utils"; import { Protocol, ProtocolRunner } from "../../../machine"; import { StateChannel } from "../../../models"; import { Store } from "../../../store"; -import { AppInstanceProposal, Node } from "../../../types"; +import { AppInstanceProposal, CFCoreTypes } from "../../../types"; import { NO_APP_INSTANCE_ID_TO_INSTALL } from "../../errors"; export async function install( store: Store, protocolRunner: ProtocolRunner, - params: Node.InstallParams + params: CFCoreTypes.InstallParams ): Promise { const { appInstanceId } = params; diff --git a/modules/cf-core/src/methods/app-instance/propose-install/controller.ts b/modules/cf-core/src/methods/app-instance/propose-install/controller.ts index 688b2eb60a..f9e2dd10f3 100644 --- a/modules/cf-core/src/methods/app-instance/propose-install/controller.ts +++ b/modules/cf-core/src/methods/app-instance/propose-install/controller.ts @@ -6,7 +6,7 @@ import { CONVENTION_FOR_ETH_TOKEN_ADDRESS } from "../../../constants"; import { Protocol, xkeyKthAddress } from "../../../machine"; import { StateChannel } from "../../../models"; import { RequestHandler } from "../../../request-handler"; -import { Node } from "../../../types"; +import { CFCoreTypes } from "../../../types"; import { NodeController } from "../../controller"; import { INSUFFICIENT_FUNDS_IN_FREE_BALANCE_FOR_ASSET, @@ -20,15 +20,15 @@ import { * @returns The AppInstanceId for the proposed AppInstance */ export default class ProposeInstallController extends NodeController { - @jsonRpcMethod(Node.RpcMethodName.PROPOSE_INSTALL) + @jsonRpcMethod(CFCoreTypes.RpcMethodNames.chan_proposeInstall) public executeMethod: ( requestHandler: RequestHandler, - params: Node.MethodParams - ) => Promise = super.executeMethod; + params: CFCoreTypes.MethodParams + ) => Promise = super.executeMethod; protected async getRequiredLockNames( requestHandler: RequestHandler, - params: Node.ProposeInstallParams + params: CFCoreTypes.ProposeInstallParams ): Promise { const { networkContext, publicIdentifier, store } = requestHandler; const { proposedToIdentifier } = params; @@ -54,7 +54,7 @@ export default class ProposeInstallController extends NodeController { protected async beforeExecution( requestHandler: RequestHandler, - params: Node.ProposeInstallParams + params: CFCoreTypes.ProposeInstallParams ): Promise { const { networkContext, publicIdentifier, store } = requestHandler; const { initialState } = params; @@ -120,8 +120,8 @@ export default class ProposeInstallController extends NodeController { protected async executeMethodImplementation( requestHandler: RequestHandler, - params: Node.ProposeInstallParams - ): Promise { + params: CFCoreTypes.ProposeInstallParams + ): Promise { const { networkContext, protocolRunner, diff --git a/modules/cf-core/src/methods/app-instance/propose-install/operation.ts b/modules/cf-core/src/methods/app-instance/propose-install/operation.ts index bfbb55c9be..e3d7350b0f 100644 --- a/modules/cf-core/src/methods/app-instance/propose-install/operation.ts +++ b/modules/cf-core/src/methods/app-instance/propose-install/operation.ts @@ -2,7 +2,7 @@ import { CONVENTION_FOR_ETH_TOKEN_ADDRESS } from "../../../constants"; import { appIdentityToHash } from "../../../machine"; import { AppInstanceProposal } from "../../../models"; import { Store } from "../../../store"; -import { NetworkContext, Node } from "../../../types"; +import { NetworkContext, CFCoreTypes } from "../../../types"; import { NO_NETWORK_PROVIDER_CREATE2 } from "../../errors"; /** @@ -16,7 +16,7 @@ export async function createProposedAppInstance( myIdentifier: string, store: Store, networkContext: NetworkContext, - params: Node.ProposeInstallParams + params: CFCoreTypes.ProposeInstallParams ): Promise { const { abiEncodings, diff --git a/modules/cf-core/src/methods/app-instance/reject-install/controller.ts b/modules/cf-core/src/methods/app-instance/reject-install/controller.ts index 668de146fe..28af32d557 100644 --- a/modules/cf-core/src/methods/app-instance/reject-install/controller.ts +++ b/modules/cf-core/src/methods/app-instance/reject-install/controller.ts @@ -1,24 +1,24 @@ import { jsonRpcMethod } from "rpc-server"; import { RequestHandler } from "../../../request-handler"; -import { Node, RejectProposalMessage, NodeEvent } from "../../../types"; +import { CFCoreTypes, RejectProposalMessage, NodeEvent } from "../../../types"; import { NodeController } from "../../controller"; export default class RejectInstallController extends NodeController { protected async getRequiredLockNames( requestHandler: RequestHandler, - params: Node.RejectInstallParams + params: CFCoreTypes.RejectInstallParams ): Promise { const { appInstanceId } = params; return [appInstanceId]; } - @jsonRpcMethod(Node.RpcMethodName.REJECT_INSTALL) + @jsonRpcMethod(CFCoreTypes.RpcMethodNames.chan_rejectInstall) protected async executeMethodImplementation( requestHandler: RequestHandler, - params: Node.RejectInstallParams - ): Promise { + params: CFCoreTypes.RejectInstallParams + ): Promise { const { store, messagingService, publicIdentifier } = requestHandler; const { appInstanceId } = params; diff --git a/modules/cf-core/src/methods/app-instance/take-action/controller.ts b/modules/cf-core/src/methods/app-instance/take-action/controller.ts index 523266862c..dba8a80f95 100644 --- a/modules/cf-core/src/methods/app-instance/take-action/controller.ts +++ b/modules/cf-core/src/methods/app-instance/take-action/controller.ts @@ -5,11 +5,8 @@ import { Protocol, ProtocolRunner } from "../../../machine"; import { StateChannel } from "../../../models"; import { RequestHandler } from "../../../request-handler"; import { Store } from "../../../store"; -import { Node, NODE_EVENTS, SolidityValueType, UpdateStateMessage } from "../../../types"; -import { - getFirstElementInListNotEqualTo, - prettyPrintObject -} from "../../../utils"; +import { CFCoreTypes, NODE_EVENTS, SolidityValueType, UpdateStateMessage } from "../../../types"; +import { getFirstElementInListNotEqualTo } from "../../../utils"; import { NodeController } from "../../controller"; import { IMPROPERLY_FORMATTED_STRUCT, @@ -19,13 +16,13 @@ import { } from "../../errors"; export default class TakeActionController extends NodeController { - @jsonRpcMethod(Node.RpcMethodName.TAKE_ACTION) + @jsonRpcMethod(CFCoreTypes.RpcMethodNames.chan_takeAction) public executeMethod = super.executeMethod; protected async getRequiredLockNames( // @ts-ignore requestHandler: RequestHandler, - params: Node.TakeActionParams + params: CFCoreTypes.TakeActionParams ): Promise { const multisigAddress = await requestHandler.store.getMultisigAddressFromAppInstance( params.appInstanceId @@ -35,7 +32,7 @@ export default class TakeActionController extends NodeController { protected async beforeExecution( requestHandler: RequestHandler, - params: Node.TakeActionParams + params: CFCoreTypes.TakeActionParams ): Promise { const { store } = requestHandler; const { appInstanceId, action } = params; @@ -50,7 +47,7 @@ export default class TakeActionController extends NodeController { appInstance.encodeAction(action); } catch (e) { if (e.code === INVALID_ARGUMENT) { - throw Error(`${IMPROPERLY_FORMATTED_STRUCT}: ${prettyPrintObject(e)}`); + throw Error(`${IMPROPERLY_FORMATTED_STRUCT}: ${e.message}`); } throw Error(STATE_OBJECT_NOT_ENCODABLE); } @@ -58,8 +55,8 @@ export default class TakeActionController extends NodeController { protected async executeMethodImplementation( requestHandler: RequestHandler, - params: Node.TakeActionParams - ): Promise { + params: CFCoreTypes.TakeActionParams + ): Promise { const { store, publicIdentifier, protocolRunner } = requestHandler; const { appInstanceId, action } = params; @@ -86,7 +83,7 @@ export default class TakeActionController extends NodeController { protected async afterExecution( requestHandler: RequestHandler, - params: Node.TakeActionParams + params: CFCoreTypes.TakeActionParams ): Promise { const { store, router, publicIdentifier } = requestHandler; const { appInstanceId, action } = params; @@ -132,9 +129,9 @@ async function runTakeActionProtocol( } catch (e) { if (e.toString().indexOf("VM Exception") !== -1) { // TODO: Fetch the revert reason - throw Error(`${INVALID_ACTION}: ${prettyPrintObject(e)}`); + throw Error(`${INVALID_ACTION}: ${e.message}`); } - throw Error(`Couldn't run TakeAction protocol: ${prettyPrintObject(e)}`); + throw Error(`Couldn't run TakeAction protocol: ${e.message}`); } return {}; diff --git a/modules/cf-core/src/methods/app-instance/uninstall-virtual/controller.ts b/modules/cf-core/src/methods/app-instance/uninstall-virtual/controller.ts index da2851736f..aeaf2c8e80 100644 --- a/modules/cf-core/src/methods/app-instance/uninstall-virtual/controller.ts +++ b/modules/cf-core/src/methods/app-instance/uninstall-virtual/controller.ts @@ -1,7 +1,7 @@ import { jsonRpcMethod } from "rpc-server"; import { RequestHandler } from "../../../request-handler"; -import { Node } from "../../../types"; +import { CFCoreTypes } from "../../../types"; import { getFirstElementInListNotEqualTo } from "../../../utils"; import { NodeController } from "../../controller"; import { @@ -13,12 +13,12 @@ import { import { uninstallVirtualAppInstanceFromChannel } from "./operation"; export default class UninstallVirtualController extends NodeController { - @jsonRpcMethod(Node.RpcMethodName.UNINSTALL_VIRTUAL) + @jsonRpcMethod(CFCoreTypes.RpcMethodNames.chan_uninstallVirtual) public executeMethod = super.executeMethod; protected async getRequiredLockNames( requestHandler: RequestHandler, - params: Node.UninstallVirtualParams + params: CFCoreTypes.UninstallVirtualParams ): Promise { const { store, publicIdentifier, networkContext } = requestHandler; const { appInstanceId, intermediaryIdentifier } = params; @@ -75,7 +75,7 @@ export default class UninstallVirtualController extends NodeController { protected async beforeExecution( // @ts-ignore requestHandler: RequestHandler, - params: Node.UninstallVirtualParams + params: CFCoreTypes.UninstallVirtualParams ) { const { appInstanceId } = params; @@ -86,8 +86,8 @@ export default class UninstallVirtualController extends NodeController { protected async executeMethodImplementation( requestHandler: RequestHandler, - params: Node.UninstallVirtualParams - ): Promise { + params: CFCoreTypes.UninstallVirtualParams + ): Promise { const { store, protocolRunner, diff --git a/modules/cf-core/src/methods/app-instance/uninstall/controller.ts b/modules/cf-core/src/methods/app-instance/uninstall/controller.ts index 9e1262243e..51ca454d8e 100644 --- a/modules/cf-core/src/methods/app-instance/uninstall/controller.ts +++ b/modules/cf-core/src/methods/app-instance/uninstall/controller.ts @@ -1,7 +1,7 @@ import { jsonRpcMethod } from "rpc-server"; import { RequestHandler } from "../../../request-handler"; -import { Node } from "../../../types"; +import { CFCoreTypes } from "../../../types"; import { getFirstElementInListNotEqualTo } from "../../../utils"; import { NodeController } from "../../controller"; import { @@ -13,12 +13,12 @@ import { import { uninstallAppInstanceFromChannel } from "./operation"; export default class UninstallController extends NodeController { - @jsonRpcMethod(Node.RpcMethodName.UNINSTALL) + @jsonRpcMethod(CFCoreTypes.RpcMethodNames.chan_uninstall) public executeMethod = super.executeMethod; protected async getRequiredLockNames( requestHandler: RequestHandler, - params: Node.UninstallVirtualParams + params: CFCoreTypes.UninstallVirtualParams ): Promise { const { store } = requestHandler; const { appInstanceId } = params; @@ -35,7 +35,7 @@ export default class UninstallController extends NodeController { protected async beforeExecution( // @ts-ignore requestHandler: RequestHandler, - params: Node.UninstallParams + params: CFCoreTypes.UninstallParams ) { const { appInstanceId } = params; @@ -46,8 +46,8 @@ export default class UninstallController extends NodeController { protected async executeMethodImplementation( requestHandler: RequestHandler, - params: Node.UninstallParams - ): Promise { + params: CFCoreTypes.UninstallParams + ): Promise { const { store, protocolRunner, publicIdentifier } = requestHandler; const { appInstanceId } = params; diff --git a/modules/cf-core/src/methods/app-instance/update-state/controller.ts b/modules/cf-core/src/methods/app-instance/update-state/controller.ts index 782acb7ec5..bc4adc05d7 100644 --- a/modules/cf-core/src/methods/app-instance/update-state/controller.ts +++ b/modules/cf-core/src/methods/app-instance/update-state/controller.ts @@ -5,33 +5,30 @@ import { Protocol, ProtocolRunner } from "../../../machine"; import { StateChannel } from "../../../models"; import { RequestHandler } from "../../../request-handler"; import { Store } from "../../../store"; -import { Node, SolidityValueType } from "../../../types"; -import { - getFirstElementInListNotEqualTo, - prettyPrintObject, -} from "../../../utils"; +import { CFCoreTypes, SolidityValueType } from "../../../types"; +import { getFirstElementInListNotEqualTo } from "../../../utils"; import { NodeController } from "../../controller"; import { IMPROPERLY_FORMATTED_STRUCT, NO_APP_INSTANCE_FOR_TAKE_ACTION, - STATE_OBJECT_NOT_ENCODABLE, + STATE_OBJECT_NOT_ENCODABLE } from "../../errors"; export default class UpdateStateController extends NodeController { - @jsonRpcMethod(Node.RpcMethodName.UPDATE_STATE) + @jsonRpcMethod(CFCoreTypes.RpcMethodNames.chan_updateState) public executeMethod = super.executeMethod; protected async getRequiredLockNames( // @ts-ignore requestHandler: RequestHandler, - params: Node.UpdateStateParams + params: CFCoreTypes.UpdateStateParams ): Promise { return [params.appInstanceId]; } protected async beforeExecution( requestHandler: RequestHandler, - params: Node.UpdateStateParams + params: CFCoreTypes.UpdateStateParams ): Promise { const { store } = requestHandler; const { appInstanceId, newState } = params; @@ -46,7 +43,7 @@ export default class UpdateStateController extends NodeController { appInstance.encodeState(newState); } catch (e) { if (e.code === INVALID_ARGUMENT) { - throw Error(`${IMPROPERLY_FORMATTED_STRUCT}: ${prettyPrintObject(e)}`); + throw Error(`${IMPROPERLY_FORMATTED_STRUCT}: ${e.message}`); } throw Error(STATE_OBJECT_NOT_ENCODABLE); } @@ -54,8 +51,8 @@ export default class UpdateStateController extends NodeController { protected async executeMethodImplementation( requestHandler: RequestHandler, - params: Node.UpdateStateParams - ): Promise { + params: CFCoreTypes.UpdateStateParams + ): Promise { const { store, publicIdentifier, protocolRunner } = requestHandler; const { appInstanceId, newState } = params; diff --git a/modules/cf-core/src/methods/controller.ts b/modules/cf-core/src/methods/controller.ts index 657d0ad319..e8327c54bc 100644 --- a/modules/cf-core/src/methods/controller.ts +++ b/modules/cf-core/src/methods/controller.ts @@ -1,15 +1,15 @@ import { Controller } from "rpc-server"; import { RequestHandler } from "../request-handler"; -import { Node } from "../types"; +import { CFCoreTypes } from "../types"; export abstract class NodeController extends Controller { - public static readonly methodName: Node.MethodName; + public static readonly methodName: CFCoreTypes.MethodName; public async executeMethod( requestHandler: RequestHandler, - params: Node.MethodParams, - ): Promise { + params: CFCoreTypes.MethodParams, + ): Promise { await this.beforeExecution(requestHandler, params); const lockNames = await this.getRequiredLockNames(requestHandler, params); @@ -29,28 +29,28 @@ export abstract class NodeController extends Controller { protected abstract executeMethodImplementation( requestHandler: RequestHandler, - params: Node.MethodParams - ): Promise; + params: CFCoreTypes.MethodParams + ): Promise; protected async beforeExecution( // @ts-ignore requestHandler: RequestHandler, // @ts-ignore - params: Node.MethodParams + params: CFCoreTypes.MethodParams ): Promise {} protected async afterExecution( // @ts-ignore requestHandler: RequestHandler, // @ts-ignore - params: Node.MethodParams + params: CFCoreTypes.MethodParams ): Promise {} protected async getRequiredLockNames( // @ts-ignore requestHandler: RequestHandler, // @ts-ignore - params: Node.MethodParams + params: CFCoreTypes.MethodParams ): Promise { return []; } diff --git a/modules/cf-core/src/methods/proposed-app-instance/get-all/controller.ts b/modules/cf-core/src/methods/proposed-app-instance/get-all/controller.ts index 6b4ada32dc..837b36f04e 100644 --- a/modules/cf-core/src/methods/proposed-app-instance/get-all/controller.ts +++ b/modules/cf-core/src/methods/proposed-app-instance/get-all/controller.ts @@ -1,15 +1,15 @@ import { jsonRpcMethod } from "rpc-server"; import { RequestHandler } from "../../../request-handler"; -import { Node } from "../../../types"; +import { CFCoreTypes } from "../../../types"; import { NodeController } from "../../controller"; export default class GetProposedAppInstancesController extends NodeController { - @jsonRpcMethod(Node.RpcMethodName.GET_PROPOSED_APP_INSTANCES) + @jsonRpcMethod(CFCoreTypes.RpcMethodNames.chan_getProposedAppInstances) protected async executeMethodImplementation( requestHandler: RequestHandler, - params: Node.GetProposedAppInstancesParams - ): Promise { + params: CFCoreTypes.GetProposedAppInstancesParams + ): Promise { const { store } = requestHandler; const { multisigAddress } = params; diff --git a/modules/cf-core/src/methods/proposed-app-instance/get/controller.ts b/modules/cf-core/src/methods/proposed-app-instance/get/controller.ts index baa9de1cdb..1c1e9e2a52 100644 --- a/modules/cf-core/src/methods/proposed-app-instance/get/controller.ts +++ b/modules/cf-core/src/methods/proposed-app-instance/get/controller.ts @@ -1,14 +1,14 @@ import { RequestHandler } from "../../../request-handler"; -import { Node } from "../../../types"; +import { CFCoreTypes } from "../../../types"; import { NodeController } from "../../controller"; export default class GetProposedAppInstanceController extends NodeController { - public static readonly methodName = Node.MethodName.GET_PROPOSED_APP_INSTANCE; + public static readonly methodName = CFCoreTypes.MethodName.GET_PROPOSED_APP_INSTANCE; protected async executeMethodImplementation( requestHandler: RequestHandler, - params: Node.GetProposedAppInstanceParams - ): Promise { + params: CFCoreTypes.GetProposedAppInstanceParams + ): Promise { return { appInstance: await requestHandler.store.getAppInstanceProposal( params.appInstanceId diff --git a/modules/cf-core/src/methods/state-channel/create/controller.ts b/modules/cf-core/src/methods/state-channel/create/controller.ts index 8677276ee7..4a8ff7f6ea 100644 --- a/modules/cf-core/src/methods/state-channel/create/controller.ts +++ b/modules/cf-core/src/methods/state-channel/create/controller.ts @@ -1,7 +1,7 @@ import { jsonRpcMethod } from "rpc-server"; import { RequestHandler } from "../../../request-handler"; -import { CreateChannelMessage, Node, NodeEvent } from "../../../types"; +import { CreateChannelMessage, CFCoreTypes, NodeEvent } from "../../../types"; import { NodeController } from "../../controller"; import { xkeysToSortedKthAddresses } from "../../../machine"; @@ -17,22 +17,20 @@ import { xkeysToSortedKthAddresses } from "../../../machine"; * to whoever subscribed to the `"CREATE_CHANNEL_EVENT"` event on the Node. */ export default class CreateChannelController extends NodeController { - @jsonRpcMethod(Node.RpcMethodName.CREATE_CHANNEL) + @jsonRpcMethod(CFCoreTypes.RpcMethodNames.chan_create) public executeMethod = super.executeMethod; protected async getRequiredLockNames( requestHandler: RequestHandler, - params: Node.CreateChannelParams + params: CFCoreTypes.CreateChannelParams ): Promise { - return [ - `${Node.RpcMethodName.CREATE_CHANNEL}:${params.owners.sort().toString()}` - ]; + return [`${CFCoreTypes.RpcMethodNames.chan_create}:${params.owners.sort().toString()}`]; } protected async executeMethodImplementation( requestHandler: RequestHandler, - params: Node.CreateChannelParams - ): Promise { + params: CFCoreTypes.CreateChannelParams + ): Promise { const { owners } = params; const { networkContext, store } = requestHandler; @@ -59,7 +57,7 @@ export default class CreateChannelController extends NodeController { private async setupAndCreateChannel( multisigAddress: string, requestHandler: RequestHandler, - params: Node.CreateChannelParams + params: CFCoreTypes.CreateChannelParams ) { const { owners } = params; const { @@ -87,7 +85,7 @@ export default class CreateChannelController extends NodeController { multisigAddress, owners: addressOwners, counterpartyXpub: responderXpub - } as Node.CreateChannelResult + } as CFCoreTypes.CreateChannelResult }; outgoing.emit("CREATE_CHANNEL_EVENT", msg); diff --git a/modules/cf-core/src/methods/state-channel/deploy-state-deposit-holder/controller.ts b/modules/cf-core/src/methods/state-channel/deploy-state-deposit-holder/controller.ts index 55cf56e640..24e0023999 100644 --- a/modules/cf-core/src/methods/state-channel/deploy-state-deposit-holder/controller.ts +++ b/modules/cf-core/src/methods/state-channel/deploy-state-deposit-holder/controller.ts @@ -16,7 +16,7 @@ import { } from "../../../machine/xkeys"; import { StateChannel } from "../../../models"; import { RequestHandler } from "../../../request-handler"; -import { NetworkContext, Node } from "../../../types"; +import { NetworkContext, CFCoreTypes } from "../../../types"; import { getCreate2MultisigAddress, prettyPrintObject, @@ -35,12 +35,12 @@ import { const CREATE_PROXY_AND_SETUP_GAS = 500_000; export default class DeployStateDepositHolderController extends NodeController { - @jsonRpcMethod(Node.RpcMethodName.DEPLOY_STATE_DEPOSIT_HOLDER) + @jsonRpcMethod(CFCoreTypes.RpcMethodNames.chan_deployStateDepositHolder) public executeMethod = super.executeMethod; protected async beforeExecution( requestHandler: RequestHandler, - params: Node.DeployStateDepositHolderParams + params: CFCoreTypes.DeployStateDepositHolderParams ): Promise { const { store, provider, networkContext } = requestHandler; const { multisigAddress } = params; @@ -65,8 +65,8 @@ export default class DeployStateDepositHolderController extends NodeController { protected async executeMethodImplementation( requestHandler: RequestHandler, - params: Node.DeployStateDepositHolderParams - ): Promise { + params: CFCoreTypes.DeployStateDepositHolderParams + ): Promise { const { multisigAddress, retryCount } = params; const { networkContext, store, provider, wallet } = requestHandler; diff --git a/modules/cf-core/src/methods/state-channel/deposit/controller.ts b/modules/cf-core/src/methods/state-channel/deposit/controller.ts index bf2d4ff045..ff95c3400a 100644 --- a/modules/cf-core/src/methods/state-channel/deposit/controller.ts +++ b/modules/cf-core/src/methods/state-channel/deposit/controller.ts @@ -6,7 +6,7 @@ import { CONVENTION_FOR_ETH_TOKEN_ADDRESS } from "../../../constants"; import { ERC20 } from "../../../contracts"; import { StateChannel } from "../../../models"; import { RequestHandler } from "../../../request-handler"; -import { DepositConfirmationMessage, Node, NODE_EVENTS, NodeEvent } from "../../../types"; +import { DepositConfirmationMessage, CFCoreTypes, NODE_EVENTS, NodeEvent } from "../../../types"; import { NodeController } from "../../controller"; import { CANNOT_DEPOSIT, @@ -26,22 +26,22 @@ import { import { getCreate2MultisigAddress } from "../../../utils"; export default class DepositController extends NodeController { - @jsonRpcMethod(Node.RpcMethodName.DEPOSIT) + @jsonRpcMethod(CFCoreTypes.RpcMethodNames.chan_deposit) public executeMethod: ( requestHandler: RequestHandler, - params: Node.MethodParams - ) => Promise = super.executeMethod; + params: CFCoreTypes.MethodParams + ) => Promise = super.executeMethod; protected async getRequiredLockNames( requestHandler: RequestHandler, - params: Node.DepositParams + params: CFCoreTypes.DepositParams ): Promise { return [params.multisigAddress]; } protected async beforeExecution( requestHandler: RequestHandler, - params: Node.DepositParams + params: CFCoreTypes.DepositParams ): Promise { const { store, provider, networkContext } = requestHandler; const { multisigAddress, amount, tokenAddress: tokenAddressParam } = params; @@ -116,8 +116,8 @@ export default class DepositController extends NodeController { protected async executeMethodImplementation( requestHandler: RequestHandler, - params: Node.DepositParams - ): Promise { + params: CFCoreTypes.DepositParams + ): Promise { const { outgoing, provider } = requestHandler; const { multisigAddress, tokenAddress } = params; diff --git a/modules/cf-core/src/methods/state-channel/deposit/operation.ts b/modules/cf-core/src/methods/state-channel/deposit/operation.ts index 818fa952e7..d151aed1e1 100644 --- a/modules/cf-core/src/methods/state-channel/deposit/operation.ts +++ b/modules/cf-core/src/methods/state-channel/deposit/operation.ts @@ -22,13 +22,12 @@ import { coinBalanceRefundStateEncoding, DepositFailedMessage, NetworkContext, - Node, + CFCoreTypes, NODE_EVENTS, OutcomeType, SolidityValueType, NodeEvent } from "../../../types"; -import { prettyPrintObject } from "../../../utils"; import { DEPOSIT_FAILED } from "../../errors"; const DEPOSIT_RETRY_COUNT = 3; @@ -40,7 +39,7 @@ interface DepositContext { export async function installBalanceRefundApp( requestHandler: RequestHandler, - params: Node.DepositParams + params: CFCoreTypes.DepositParams ) { const { publicIdentifier, @@ -102,7 +101,7 @@ export async function installBalanceRefundApp( export async function makeDeposit( requestHandler: RequestHandler, - params: Node.DepositParams + params: CFCoreTypes.DepositParams ): Promise { const { multisigAddress, amount, tokenAddress } = params; const { @@ -146,14 +145,14 @@ export async function makeDeposit( }; if (e.toString().includes("reject") || e.toString().includes("denied")) { outgoing.emit(NODE_EVENTS.DEPOSIT_FAILED_EVENT, failMsg); - throw Error(`${DEPOSIT_FAILED}: ${prettyPrintObject(e)}`); + throw Error(`${DEPOSIT_FAILED}: ${e.message}`); } retryCount -= 1; if (retryCount === 0) { outgoing.emit(NODE_EVENTS.DEPOSIT_FAILED_EVENT, failMsg); - throw Error(`${DEPOSIT_FAILED}: ${prettyPrintObject(e)}`); + throw Error(`${DEPOSIT_FAILED}: ${e.message}`); } } } @@ -172,7 +171,7 @@ export async function makeDeposit( export async function uninstallBalanceRefundApp( requestHandler: RequestHandler, - params: Node.DepositParams, + params: CFCoreTypes.DepositParams, blockNumberToUseIfNecessary?: number ) { const { @@ -224,7 +223,7 @@ export async function uninstallBalanceRefundApp( } async function getDepositContext( - params: Node.DepositParams, + params: CFCoreTypes.DepositParams, publicIdentifier: string, provider: BaseProvider, networkContext: NetworkContext, diff --git a/modules/cf-core/src/methods/state-channel/get-all-addresses/controller.ts b/modules/cf-core/src/methods/state-channel/get-all-addresses/controller.ts index 1268cee64f..d5b77c4854 100644 --- a/modules/cf-core/src/methods/state-channel/get-all-addresses/controller.ts +++ b/modules/cf-core/src/methods/state-channel/get-all-addresses/controller.ts @@ -1,16 +1,16 @@ import { jsonRpcMethod } from "rpc-server"; import { RequestHandler } from "../../../request-handler"; -import { Node } from "../../../types"; +import { CFCoreTypes } from "../../../types"; import { NodeController } from "../../controller"; export default class GetAllChannelAddressesController extends NodeController { - @jsonRpcMethod(Node.RpcMethodName.GET_CHANNEL_ADDRESSES) + @jsonRpcMethod(CFCoreTypes.RpcMethodNames.chan_getChannelAddresses) public executeMethod = super.executeMethod; protected async executeMethodImplementation( requestHandler: RequestHandler - ): Promise { + ): Promise { return { multisigAddresses: [ ...(await requestHandler.store.getStateChannelsMap()).keys() diff --git a/modules/cf-core/src/methods/state-channel/get-state-deposit-holder-address/controller.ts b/modules/cf-core/src/methods/state-channel/get-state-deposit-holder-address/controller.ts index fc9e7afb7c..30c9ed196b 100644 --- a/modules/cf-core/src/methods/state-channel/get-state-deposit-holder-address/controller.ts +++ b/modules/cf-core/src/methods/state-channel/get-state-deposit-holder-address/controller.ts @@ -1,19 +1,19 @@ import { jsonRpcMethod } from "rpc-server"; import { RequestHandler } from "../../../request-handler"; -import { Node } from "../../../types"; +import { CFCoreTypes } from "../../../types"; import { getCreate2MultisigAddress } from "../../../utils"; import { NodeController } from "../../controller"; import { NO_NETWORK_PROVIDER_CREATE2 } from "../../errors"; export default class GetStateDepositHolderAddressController extends NodeController { - @jsonRpcMethod(Node.RpcMethodName.GET_STATE_DEPOSIT_HOLDER_ADDRESS) + @jsonRpcMethod(CFCoreTypes.RpcMethodNames.chan_getStateDepositHolderAddress) public executeMethod = super.executeMethod; protected async executeMethodImplementation( requestHandler: RequestHandler, - params: Node.GetStateDepositHolderAddressParams - ): Promise { + params: CFCoreTypes.GetStateDepositHolderAddressParams + ): Promise { const { owners } = params; const { networkContext, store } = requestHandler; if (!networkContext.provider) { diff --git a/modules/cf-core/src/methods/state-channel/get/controller.ts b/modules/cf-core/src/methods/state-channel/get/controller.ts index fcbe561639..27ef98392b 100644 --- a/modules/cf-core/src/methods/state-channel/get/controller.ts +++ b/modules/cf-core/src/methods/state-channel/get/controller.ts @@ -1,17 +1,17 @@ import { jsonRpcMethod } from "rpc-server"; import { RequestHandler } from "../../../request-handler"; -import { Node } from "../../../types"; +import { CFCoreTypes } from "../../../types"; import { NodeController } from "../../controller"; export default class GetStateChannelController extends NodeController { - @jsonRpcMethod(Node.RpcMethodName.GET_STATE_CHANNEL) + @jsonRpcMethod(CFCoreTypes.RpcMethodNames.chan_getStateChannel) public executeMethod = super.executeMethod; protected async executeMethodImplementation( requestHandler: RequestHandler, - params: Node.GetStateChannelParams - ): Promise { + params: CFCoreTypes.GetStateChannelParams + ): Promise { return { data: ( await requestHandler.store.getStateChannel(params.multisigAddress) diff --git a/modules/cf-core/src/methods/state-channel/request-deposit-rights/controller.ts b/modules/cf-core/src/methods/state-channel/request-deposit-rights/controller.ts index 35723ad043..b752845ed4 100644 --- a/modules/cf-core/src/methods/state-channel/request-deposit-rights/controller.ts +++ b/modules/cf-core/src/methods/state-channel/request-deposit-rights/controller.ts @@ -7,7 +7,7 @@ import { CONVENTION_FOR_ETH_TOKEN_ADDRESS } from "../../../constants"; import { ERC20 } from "../../../contracts"; import { xkeyKthAddress } from "../../../machine"; import { RequestHandler } from "../../../request-handler"; -import { Node } from "../../../types"; +import { CFCoreTypes } from "../../../types"; import { getCreate2MultisigAddress } from "../../../utils"; import { NodeController } from "../../controller"; import { @@ -21,22 +21,22 @@ import { // TODO: maybe a better name? since it's a little smarter than just a plain install export default class RequestDepositRightsController extends NodeController { - @jsonRpcMethod(Node.RpcMethodName.REQUEST_DEPOSIT_RIGHTS) + @jsonRpcMethod(CFCoreTypes.RpcMethodNames.chan_requestDepositRights) public executeMethod: ( requestHandler: RequestHandler, - params: Node.MethodParams - ) => Promise = super.executeMethod; + params: CFCoreTypes.MethodParams + ) => Promise = super.executeMethod; protected async getRequiredLockNames( requestHandler: RequestHandler, - params: Node.RequestDepositRightsParams + params: CFCoreTypes.RequestDepositRightsParams ): Promise { return [params.multisigAddress]; } protected async beforeExecution( requestHandler: RequestHandler, - params: Node.RequestDepositRightsParams + params: CFCoreTypes.RequestDepositRightsParams ): Promise { const { store, provider, networkContext } = requestHandler; const { multisigAddress } = params; @@ -61,8 +61,8 @@ export default class RequestDepositRightsController extends NodeController { protected async executeMethodImplementation( requestHandler: RequestHandler, - params: Node.RequestDepositRightsParams - ): Promise { + params: CFCoreTypes.RequestDepositRightsParams + ): Promise { const { provider, store, diff --git a/modules/cf-core/src/methods/state-channel/rescind-deposit-rights/controller.ts b/modules/cf-core/src/methods/state-channel/rescind-deposit-rights/controller.ts index 7cbda77051..7cf7d8d442 100644 --- a/modules/cf-core/src/methods/state-channel/rescind-deposit-rights/controller.ts +++ b/modules/cf-core/src/methods/state-channel/rescind-deposit-rights/controller.ts @@ -4,22 +4,22 @@ import { jsonRpcMethod } from "rpc-server"; import { CONVENTION_FOR_ETH_TOKEN_ADDRESS } from "../../../constants"; import { ERC20 } from "../../../contracts"; import { RequestHandler } from "../../../request-handler"; -import { Node } from "../../../types"; +import { CFCoreTypes } from "../../../types"; import { NodeController } from "../../controller"; import { uninstallBalanceRefundApp } from "../deposit/operation"; import { BigNumber } from "ethers/utils"; import { Contract } from "ethers"; export default class RescindDepositRightsController extends NodeController { - @jsonRpcMethod(Node.RpcMethodName.RESCIND_DEPOSIT_RIGHTS) + @jsonRpcMethod(CFCoreTypes.RpcMethodNames.chan_rescindDepositRights) public executeMethod: ( requestHandler: RequestHandler, - params: Node.MethodParams - ) => Promise = super.executeMethod; + params: CFCoreTypes.MethodParams + ) => Promise = super.executeMethod; protected async getRequiredLockNames( requestHandler: RequestHandler, - params: Node.RescindDepositRightsParams + params: CFCoreTypes.RescindDepositRightsParams ): Promise { return [params.multisigAddress]; } @@ -28,8 +28,8 @@ export default class RescindDepositRightsController extends NodeController { protected async executeMethodImplementation( requestHandler: RequestHandler, - params: Node.RescindDepositRightsParams - ): Promise { + params: CFCoreTypes.RescindDepositRightsParams + ): Promise { const { provider, store, networkContext } = requestHandler; const { multisigAddress } = params; const tokenAddress = diff --git a/modules/cf-core/src/methods/state-channel/withdraw-commitment/controller.ts b/modules/cf-core/src/methods/state-channel/withdraw-commitment/controller.ts index defae57532..05ff727233 100644 --- a/modules/cf-core/src/methods/state-channel/withdraw-commitment/controller.ts +++ b/modules/cf-core/src/methods/state-channel/withdraw-commitment/controller.ts @@ -2,7 +2,7 @@ import { jsonRpcMethod } from "rpc-server"; import { xkeyKthAddress } from "../../../machine"; import { RequestHandler } from "../../../request-handler"; -import { Node } from "../../../types"; +import { CFCoreTypes } from "../../../types"; import { NodeController } from "../../controller"; import WithdrawController from "../withdraw/controller"; import { runWithdrawProtocol } from "../withdraw/operation"; @@ -15,19 +15,19 @@ import { // Note: This can't extend `WithdrawController` because the `methodName` static // members of each class are incompatible. export default class WithdrawCommitmentController extends NodeController { - @jsonRpcMethod(Node.RpcMethodName.WITHDRAW_COMMITMENT) + @jsonRpcMethod(CFCoreTypes.RpcMethodNames.chan_withdrawCommitment) public executeMethod = super.executeMethod; protected async getRequiredLockNames( requestHandler: RequestHandler, - params: Node.WithdrawCommitmentParams + params: CFCoreTypes.WithdrawCommitmentParams ): Promise { return WithdrawController.getRequiredLockNames(requestHandler, params); } protected async beforeExecution( requestHandler: RequestHandler, - params: Node.WithdrawCommitmentParams + params: CFCoreTypes.WithdrawCommitmentParams ): Promise { const { store, provider, networkContext } = requestHandler; const { multisigAddress } = params; @@ -52,8 +52,8 @@ export default class WithdrawCommitmentController extends NodeController { protected async executeMethodImplementation( requestHandler: RequestHandler, - params: Node.WithdrawCommitmentParams - ): Promise { + params: CFCoreTypes.WithdrawCommitmentParams + ): Promise { const { store, publicIdentifier } = requestHandler; const { multisigAddress, recipient } = params; diff --git a/modules/cf-core/src/methods/state-channel/withdraw/controller.ts b/modules/cf-core/src/methods/state-channel/withdraw/controller.ts index d267151254..19116605cf 100644 --- a/modules/cf-core/src/methods/state-channel/withdraw/controller.ts +++ b/modules/cf-core/src/methods/state-channel/withdraw/controller.ts @@ -4,8 +4,8 @@ import { jsonRpcMethod } from "rpc-server"; import { CONVENTION_FOR_ETH_TOKEN_ADDRESS } from "../../../constants"; import { xkeyKthAddress } from "../../../machine"; import { RequestHandler } from "../../../request-handler"; -import { Node, NODE_EVENTS } from "../../../types"; -import { prettyPrintObject, getCreate2MultisigAddress } from "../../../utils"; +import { CFCoreTypes, NODE_EVENTS } from "../../../types"; +import { getCreate2MultisigAddress } from "../../../utils"; import { NodeController } from "../../controller"; import { CANNOT_WITHDRAW, @@ -18,12 +18,12 @@ import { import { runWithdrawProtocol } from "./operation"; export default class WithdrawController extends NodeController { - @jsonRpcMethod(Node.RpcMethodName.WITHDRAW) + @jsonRpcMethod(CFCoreTypes.RpcMethodNames.chan_withdraw) public executeMethod = super.executeMethod; public static async getRequiredLockNames( requestHandler: RequestHandler, - params: Node.WithdrawParams + params: CFCoreTypes.WithdrawParams ): Promise { const { store, publicIdentifier, networkContext } = requestHandler; @@ -62,7 +62,7 @@ export default class WithdrawController extends NodeController { protected async beforeExecution( requestHandler: RequestHandler, - params: Node.WithdrawParams + params: CFCoreTypes.WithdrawParams ): Promise { const { store, provider, networkContext } = requestHandler; const { multisigAddress } = params; @@ -87,8 +87,8 @@ export default class WithdrawController extends NodeController { protected async executeMethodImplementation( requestHandler: RequestHandler, - params: Node.WithdrawParams - ): Promise { + params: CFCoreTypes.WithdrawParams + ): Promise { const { store, provider, @@ -149,7 +149,7 @@ export default class WithdrawController extends NodeController { type: NODE_EVENTS.WITHDRAWAL_FAILED_EVENT, data: e.toString() }); - throw Error(`${WITHDRAWAL_FAILED}: ${prettyPrintObject(e)}`); + throw Error(`${WITHDRAWAL_FAILED}: ${e.message}`); } return { diff --git a/modules/cf-core/src/methods/state-channel/withdraw/operation.ts b/modules/cf-core/src/methods/state-channel/withdraw/operation.ts index 540786cac0..695ed8e97d 100644 --- a/modules/cf-core/src/methods/state-channel/withdraw/operation.ts +++ b/modules/cf-core/src/methods/state-channel/withdraw/operation.ts @@ -2,11 +2,11 @@ import { CONVENTION_FOR_ETH_TOKEN_ADDRESS } from "../../../constants"; import { Protocol } from "../../../machine"; import { StateChannel } from "../../../models"; import { RequestHandler } from "../../../request-handler"; -import { Node } from "../../../types"; +import { CFCoreTypes } from "../../../types"; export async function runWithdrawProtocol( requestHandler: RequestHandler, - params: Node.WithdrawParams + params: CFCoreTypes.WithdrawParams ) { const { publicIdentifier, protocolRunner, store } = requestHandler; const { multisigAddress, amount } = params; diff --git a/modules/cf-core/src/models/app-instance.ts b/modules/cf-core/src/models/app-instance.ts index 033388e3d6..bcdfe064d0 100644 --- a/modules/cf-core/src/models/app-instance.ts +++ b/modules/cf-core/src/models/app-instance.ts @@ -19,7 +19,7 @@ import { twoPartyFixedOutcomeInterpreterParamsEncoding, virtualAppAgreementEncoding, } from "../types"; -import { bigNumberifyJson, prettyPrintObject } from "../utils"; +import { bigNumberifyJson } from "../utils"; /** * Representation of an AppInstance. @@ -284,7 +284,7 @@ export class AppInstance { - appInstanceIdentityHash = ${this.identityHash} - newState = ${newState} - encodingExpected = ${this.appInterface.stateEncoding} - Error: ${prettyPrintObject(e)}` + Error: ${e.message}` ); } diff --git a/modules/cf-core/src/node.ts b/modules/cf-core/src/node.ts index 69a0369f55..4332156039 100644 --- a/modules/cf-core/src/node.ts +++ b/modules/cf-core/src/node.ts @@ -19,7 +19,7 @@ import { RequestHandler } from "./request-handler"; import RpcRouter from "./rpc-router"; import { NetworkContext, - Node as NodeTypes, + CFCoreTypes, NODE_EVENTS, NodeMessageWrappedProtocolMessage } from "./types"; @@ -57,14 +57,14 @@ export class Node { public rpcRouter!: RpcRouter; static async create( - messagingService: NodeTypes.IMessagingService, - storeService: NodeTypes.IStoreService, + messagingService: CFCoreTypes.IMessagingService, + storeService: CFCoreTypes.IStoreService, networkContext: NetworkContext, nodeConfig: NodeConfig, provider: BaseProvider, - lockService?: NodeTypes.ILockService, + lockService?: CFCoreTypes.ILockService, publicExtendedKey?: string, - privateKeyGenerator?: NodeTypes.IPrivateKeyGenerator, + privateKeyGenerator?: CFCoreTypes.IPrivateKeyGenerator, blocksNeededForConfirmation?: number ): Promise { const [ @@ -94,13 +94,13 @@ export class Node { private constructor( private readonly publicExtendedKey: string, private readonly privateKeyGetter: PrivateKeysGetter, - private readonly messagingService: NodeTypes.IMessagingService, - private readonly storeService: NodeTypes.IStoreService, + private readonly messagingService: CFCoreTypes.IMessagingService, + private readonly storeService: CFCoreTypes.IStoreService, private readonly nodeConfig: NodeConfig, private readonly provider: BaseProvider, public readonly networkContext: NetworkContext, public readonly blocksNeededForConfirmation: number = REASONABLE_NUM_BLOCKS_TO_WAIT, - private readonly lockService?: NodeTypes.ILockService + private readonly lockService?: CFCoreTypes.ILockService ) { this.networkContext.provider = this.provider; this.incoming = new EventEmitter(); @@ -266,7 +266,7 @@ export class Node { * @param callback */ on( - event: NodeTypes.EventName | NodeTypes.RpcMethodName, + event: CFCoreTypes.EventName | CFCoreTypes.RpcMethodName, callback: (res: any) => void ) { this.rpcRouter.subscribe(event, async (res: any) => callback(res)); @@ -280,7 +280,7 @@ export class Node { * @param [callback] */ off( - event: NodeTypes.EventName | NodeTypes.RpcMethodName, + event: CFCoreTypes.EventName | CFCoreTypes.RpcMethodName, callback?: (res: any) => void ) { this.rpcRouter.unsubscribe( @@ -298,7 +298,7 @@ export class Node { * @param [callback] */ once( - event: NodeTypes.EventName | NodeTypes.RpcMethodName, + event: CFCoreTypes.EventName | CFCoreTypes.RpcMethodName, callback: (res: any) => void ) { this.rpcRouter.subscribeOnce(event, async (res: any) => callback(res)); @@ -310,8 +310,8 @@ export class Node { * @param req */ emit( - event: NodeTypes.EventName | NodeTypes.RpcMethodName, - req: NodeTypes.MethodRequest + event: CFCoreTypes.EventName | CFCoreTypes.RpcMethodName, + req: CFCoreTypes.MethodRequest ) { this.rpcRouter.emit(event, req); } @@ -322,9 +322,9 @@ export class Node { * @param req */ async call( - method: NodeTypes.MethodName, - req: NodeTypes.MethodRequest - ): Promise { + method: CFCoreTypes.MethodName, + req: CFCoreTypes.MethodRequest + ): Promise { return this.requestHandler.callMethod(method, req); } @@ -337,7 +337,7 @@ export class Node { private registerMessagingConnection() { this.messagingService.onReceive( this.publicIdentifier, - async (msg: NodeTypes.NodeMessage) => { + async (msg: CFCoreTypes.NodeMessage) => { await this.handleReceivedMessage(msg); this.rpcRouter.emit(msg.type, msg, "outgoing"); } @@ -360,12 +360,12 @@ export class Node { * _does have_ an _ioSendDeferral_, in which case the message is dispatched * solely to the deffered promise's resolve callback. */ - private async handleReceivedMessage(msg: NodeTypes.NodeMessage) { + private async handleReceivedMessage(msg: CFCoreTypes.NodeMessage) { if (!Object.values(NODE_EVENTS).includes(msg.type)) { console.error(`Received message with unknown event type: ${msg.type}`); } - const isProtocolMessage = (msg: NodeTypes.NodeMessage) => + const isProtocolMessage = (msg: CFCoreTypes.NodeMessage) => msg.type === NODE_EVENTS.PROTOCOL_MESSAGE_EVENT; const isExpectingResponse = (msg: NodeMessageWrappedProtocolMessage) => diff --git a/modules/cf-core/src/private-keys-generator.ts b/modules/cf-core/src/private-keys-generator.ts index 5c1da3a2f0..0692e07019 100644 --- a/modules/cf-core/src/private-keys-generator.ts +++ b/modules/cf-core/src/private-keys-generator.ts @@ -5,7 +5,7 @@ import log from "loglevel"; import { Memoize } from "typescript-memoize"; import { CF_PATH } from "./constants"; -import { Node } from "./types"; +import { CFCoreTypes } from "./types"; export const EXTENDED_PRIVATE_KEY_PATH = "EXTENDED_PRIVATE_KEY"; @@ -14,7 +14,7 @@ export class PrivateKeysGetter { private readonly privateKeys: Set = new Set(); constructor( - private readonly privateKeyGenerator: Node.IPrivateKeyGenerator + private readonly privateKeyGenerator: CFCoreTypes.IPrivateKeyGenerator ) {} @Memoize() @@ -66,8 +66,8 @@ export class PrivateKeysGetter { } export async function getPrivateKeysGeneratorAndXPubOrThrow( - storeService: Node.IStoreService, - privateKeyGenerator?: Node.IPrivateKeyGenerator, + storeService: CFCoreTypes.IStoreService, + privateKeyGenerator?: CFCoreTypes.IPrivateKeyGenerator, publicExtendedKey?: string ): Promise<[PrivateKeysGetter, string]> { if (publicExtendedKey && !privateKeyGenerator) { @@ -117,7 +117,7 @@ export async function getPrivateKeysGeneratorAndXPubOrThrow( // "Counterfactual" derivation path. export function generatePrivateKeyGeneratorAndXPubPair( extendedPrvKey: string -): [Node.IPrivateKeyGenerator, string] { +): [CFCoreTypes.IPrivateKeyGenerator, string] { const hdNode = fromExtendedKey(extendedPrvKey).derivePath(CF_PATH); return [ diff --git a/modules/cf-core/src/process-queue.ts b/modules/cf-core/src/process-queue.ts index 9335d5ef95..a681aec9d3 100644 --- a/modules/cf-core/src/process-queue.ts +++ b/modules/cf-core/src/process-queue.ts @@ -1,13 +1,13 @@ import Queue, { Task } from "p-queue"; import { addToManyQueues } from "./methods/queued-execution"; -import { Node } from "./types"; +import { CFCoreTypes } from "./types"; import { IO_SEND_AND_WAIT_TIMEOUT } from "./constants"; class QueueWithLockingServiceConnection extends Queue { constructor( private readonly lockName, - private readonly lockingService: Node.ILockService, + private readonly lockingService: CFCoreTypes.ILockService, ...args: any[] ) { super(...args); @@ -33,7 +33,7 @@ export default class ProcessQueue { QueueWithLockingServiceConnection | Queue > = new Map(); - constructor(private readonly lockingService?: Node.ILockService) {} + constructor(private readonly lockingService?: CFCoreTypes.ILockService) {} addTask(lockNames: string[], task: Task) { return addToManyQueues( diff --git a/modules/cf-core/src/request-handler.ts b/modules/cf-core/src/request-handler.ts index 642d05e2d5..4944c3ec05 100644 --- a/modules/cf-core/src/request-handler.ts +++ b/modules/cf-core/src/request-handler.ts @@ -8,8 +8,8 @@ import { ProtocolRunner } from "./machine"; import ProcessQueue from "./process-queue"; import RpcRouter from "./rpc-router"; import { Store } from "./store"; -import { NetworkContext, Node, NODE_EVENTS, NodeEvent } from "./types"; -import { prettyPrintObject } from "./utils"; +import { NetworkContext, CFCoreTypes, NODE_EVENTS, NodeEvent } from "./types"; +import { bigNumberifyJson } from "./utils"; /** * This class registers handlers for requests to get or set some information @@ -26,8 +26,8 @@ export class RequestHandler { readonly publicIdentifier: string, readonly incoming: EventEmitter, readonly outgoing: EventEmitter, - readonly storeService: Node.IStoreService, - readonly messagingService: Node.IMessagingService, + readonly storeService: CFCoreTypes.IStoreService, + readonly messagingService: CFCoreTypes.IMessagingService, readonly protocolRunner: ProtocolRunner, readonly networkContext: NetworkContext, readonly provider: BaseProvider, @@ -52,9 +52,9 @@ export class RequestHandler { * @param req */ public async callMethod( - method: Node.MethodName, - req: Node.MethodRequest - ): Promise { + method: CFCoreTypes.MethodName, + req: CFCoreTypes.MethodRequest + ): Promise { const result = { type: req.type, requestId: req.requestId, @@ -72,11 +72,14 @@ export class RequestHandler { for (const methodName in methodNameToImplementation) { this.methods.set(methodName, methodNameToImplementation[methodName]); - this.incoming.on(methodName, async (req: Node.MethodRequest) => { - const res: Node.MethodResponse = { + this.incoming.on(methodName, async (req: CFCoreTypes.MethodRequest) => { + const res: CFCoreTypes.MethodResponse = { type: req.type, requestId: req.requestId, - result: await this.methods.get(methodName)(this, req.params) + result: await this.methods.get(methodName)( + this, + bigNumberifyJson(req.params) + ) }; // @ts-ignore @@ -103,7 +106,7 @@ export class RequestHandler { * @param event * @param msg */ - public async callEvent(event: NodeEvent, msg: Node.NodeMessage) { + public async callEvent(event: NodeEvent, msg: CFCoreTypes.NodeMessage) { const controllerExecutionMethod = this.events.get(event); const controllerCount = this.router.eventListenerCount(event); diff --git a/modules/cf-core/src/rpc-router.ts b/modules/cf-core/src/rpc-router.ts index 506350e29e..f6a212ed25 100644 --- a/modules/cf-core/src/rpc-router.ts +++ b/modules/cf-core/src/rpc-router.ts @@ -7,6 +7,7 @@ import { } from "rpc-server"; import { RequestHandler } from "./request-handler"; +import { bigNumberifyJson } from "./utils"; type AsyncCallback = (...args: any) => Promise; @@ -17,7 +18,7 @@ export default class RpcRouter extends Router { controllers, requestHandler }: { - controllers: (typeof Controller)[]; + controllers: typeof Controller[]; requestHandler: RequestHandler; }) { super({ controllers }); @@ -38,7 +39,7 @@ export default class RpcRouter extends Router { { result: await new controller.type()[controller.callback]( this.requestHandler, - rpc.parameters + bigNumberifyJson(rpc.parameters) ), type: rpc.methodName }, diff --git a/modules/cf-core/src/signer.ts b/modules/cf-core/src/signer.ts index bfb1596c47..dfca9a67e9 100644 --- a/modules/cf-core/src/signer.ts +++ b/modules/cf-core/src/signer.ts @@ -2,13 +2,12 @@ import { fromExtendedKey, HDNode } from "ethers/utils/hdnode"; import { CF_PATH } from "./constants"; import { computeRandomExtendedPrvKey } from "./machine/xkeys"; -import { Node } from "./types"; -import { prettyPrintObject } from "./utils"; +import { CFCoreTypes } from "./types"; export const EXTENDED_PRIVATE_KEY_PATH = "EXTENDED_PRIVATE_KEY"; export async function getHDNode( - storeService: Node.IStoreService + storeService: CFCoreTypes.IStoreService ): Promise { let xprv = await storeService.get(EXTENDED_PRIVATE_KEY_PATH); @@ -20,6 +19,6 @@ export async function getHDNode( try { return fromExtendedKey(xprv).derivePath(CF_PATH); } catch (e) { - throw Error(`Invalid extended key supplied: ${prettyPrintObject(e)}`); + throw Error(`Invalid extended key supplied: ${e.message}`); } } diff --git a/modules/cf-core/src/store.ts b/modules/cf-core/src/store.ts index c78829be4b..c2681cf92b 100644 --- a/modules/cf-core/src/store.ts +++ b/modules/cf-core/src/store.ts @@ -14,8 +14,8 @@ import { NO_MULTISIG_FOR_COUNTERPARTIES } from "./methods/errors"; import { AppInstance, AppInstanceProposal, StateChannel } from "./models"; -import { Node, SolidityValueType } from "./types"; -import { getCreate2MultisigAddress, prettyPrintObject } from "./utils"; +import { CFCoreTypes, SolidityValueType } from "./types"; +import { getCreate2MultisigAddress } from "./utils"; /** * A simple ORM around StateChannels and AppInstances stored using the @@ -23,7 +23,7 @@ import { getCreate2MultisigAddress, prettyPrintObject } from "./utils"; */ export class Store { constructor( - private readonly storeService: Node.IStoreService, + private readonly storeService: CFCoreTypes.IStoreService, private readonly storeKeyPrefix: string ) {} @@ -233,7 +233,7 @@ export class Store { public async getWithdrawalCommitment( multisigAddress: string - ): Promise { + ): Promise { return this.storeService.get( [this.storeKeyPrefix, DB_NAMESPACE_WITHDRAWALS, multisigAddress].join("/") ); @@ -241,7 +241,7 @@ export class Store { public async storeWithdrawalCommitment( multisigAddress: string, - commitment: Node.MinimalTransaction + commitment: CFCoreTypes.MinimalTransaction ) { return this.storeService.set([ { @@ -255,7 +255,7 @@ export class Store { ]); } - public async setCommitment(args: any[], commitment: Node.MinimalTransaction) { + public async setCommitment(args: any[], commitment: CFCoreTypes.MinimalTransaction) { return this.storeService.set([ { path: [ @@ -301,7 +301,7 @@ export class Store { return stateChannel; } - throw Error(prettyPrintObject(e)); + throw Error(e); } } } diff --git a/modules/cf-core/src/types.ts b/modules/cf-core/src/types.ts index 21732b8482..b23cf51489 100644 --- a/modules/cf-core/src/types.ts +++ b/modules/cf-core/src/types.ts @@ -1,4 +1,4 @@ -import { Node } from "@connext/types"; +import { CFCoreTypes } from "@connext/types"; import { TransactionReceipt } from "ethers/providers"; import { BigNumber } from "ethers/utils"; @@ -16,7 +16,7 @@ export { MultiAssetMultiPartyCoinTransferInterpreterParams, multiAssetMultiPartyCoinTransferInterpreterParamsEncoding, NetworkContext, - Node, + CFCoreTypes, OutcomeType, SignedStateHashUpdate, SingleAssetTwoPartyCoinTransferInterpreterParams, @@ -25,92 +25,92 @@ export { TwoPartyFixedOutcome, TwoPartyFixedOutcomeInterpreterParams, twoPartyFixedOutcomeInterpreterParamsEncoding, - virtualAppAgreementEncoding, + virtualAppAgreementEncoding } from "@connext/types"; import { ProtocolMessage } from "./machine"; -export type NodeEvent = Node.EventName; -export const NODE_EVENTS = Node.EventNames; +export type NodeEvent = CFCoreTypes.EventName; +export const NODE_EVENTS = CFCoreTypes.EventNames; -export interface NodeMessageWrappedProtocolMessage extends Node.NodeMessage { +export interface NodeMessageWrappedProtocolMessage extends CFCoreTypes.NodeMessage { data: ProtocolMessage; } -export interface ProposeMessage extends Node.NodeMessage { +export interface ProposeMessage extends CFCoreTypes.NodeMessage { data: { - params: Node.ProposeInstallParams; + params: CFCoreTypes.ProposeInstallParams; appInstanceId: string; }; } -export interface InstallMessage extends Node.NodeMessage { +export interface InstallMessage extends CFCoreTypes.NodeMessage { data: { - params: Node.InstallParams; + params: CFCoreTypes.InstallParams; }; } -export interface InstallVirtualMessage extends Node.NodeMessage { +export interface InstallVirtualMessage extends CFCoreTypes.NodeMessage { // TODO: update this to include the intermediares data: { - params: Node.InstallParams; + params: CFCoreTypes.InstallParams; }; } -export interface CreateChannelMessage extends Node.NodeMessage { - data: Node.CreateChannelResult; +export interface CreateChannelMessage extends CFCoreTypes.NodeMessage { + data: CFCoreTypes.CreateChannelResult; } -export interface UpdateStateMessage extends Node.NodeMessage { - data: Node.UpdateStateEventData; +export interface UpdateStateMessage extends CFCoreTypes.NodeMessage { + data: CFCoreTypes.UpdateStateEventData; } -export interface UninstallMessage extends Node.NodeMessage { - data: Node.UninstallEventData; +export interface UninstallMessage extends CFCoreTypes.NodeMessage { + data: CFCoreTypes.UninstallEventData; } -export interface UninstallVirtualMessage extends Node.NodeMessage { +export interface UninstallVirtualMessage extends CFCoreTypes.NodeMessage { // TODO: update this to include the intermediares - data: Node.UninstallVirtualParams; + data: CFCoreTypes.UninstallVirtualParams; } -export interface WithdrawStartedMessage extends Node.NodeMessage { - data: { - params: Node.WithdrawParams; +export interface WithdrawStartedMessage extends CFCoreTypes.NodeMessage { + data: { + params: CFCoreTypes.WithdrawParams; txHash?: string; // not included in responder events }; } -export interface WithdrawConfirmationMessage extends Node.NodeMessage { +export interface WithdrawConfirmationMessage extends CFCoreTypes.NodeMessage { data: { txReceipt: TransactionReceipt; }; } -export interface WithdrawFailedMessage extends Node.NodeMessage { +export interface WithdrawFailedMessage extends CFCoreTypes.NodeMessage { data: string; // failure error } -export interface RejectProposalMessage extends Node.NodeMessage { +export interface RejectProposalMessage extends CFCoreTypes.NodeMessage { data: { appInstanceId: string; }; } -export interface DepositConfirmationMessage extends Node.NodeMessage { - data: Node.DepositParams; +export interface DepositConfirmationMessage extends CFCoreTypes.NodeMessage { + data: CFCoreTypes.DepositParams; } -export interface DepositStartedMessage extends Node.NodeMessage { +export interface DepositStartedMessage extends CFCoreTypes.NodeMessage { data: { value: BigNumber; txHash: string; }; } -export interface DepositFailedMessage extends Node.NodeMessage { +export interface DepositFailedMessage extends CFCoreTypes.NodeMessage { data: { - params: Node.DepositParams; + params: CFCoreTypes.DepositParams; errors: string[]; }; } diff --git a/modules/cf-core/test/integration/get-state-deposit-holder-address.spec.ts b/modules/cf-core/test/integration/get-state-deposit-holder-address.spec.ts index 1da320f9e4..587d96b3c3 100644 --- a/modules/cf-core/test/integration/get-state-deposit-holder-address.spec.ts +++ b/modules/cf-core/test/integration/get-state-deposit-holder-address.spec.ts @@ -1,4 +1,4 @@ -import { Node as NodeTypes } from "@connext/types"; +import { CFCoreTypes } from "@connext/types"; import { jsonRpcDeserialize, Node } from "../../src"; @@ -24,7 +24,7 @@ describe("Node method follows spec - getStateDepositHolderAddress", () => { } = await nodeA.rpcRouter.dispatch( jsonRpcDeserialize({ id: Date.now(), - method: NodeTypes.RpcMethodName.GET_STATE_DEPOSIT_HOLDER_ADDRESS, + method: CFCoreTypes.RpcMethodNames.chan_getStateDepositHolderAddress, params: { owners }, jsonrpc: "2.0" }) diff --git a/modules/cf-core/test/integration/install-virtual.spec.ts b/modules/cf-core/test/integration/install-virtual.spec.ts index c121f2f5e9..224cedb06a 100644 --- a/modules/cf-core/test/integration/install-virtual.spec.ts +++ b/modules/cf-core/test/integration/install-virtual.spec.ts @@ -1,9 +1,9 @@ -import { Node, VIRTUAL_APP_INSTALLATION_FAIL } from "../../src"; import { - NODE_EVENTS, - ProposeMessage, - InstallVirtualMessage -} from "../../src/types"; + Node, + VIRTUAL_APP_INSTALLATION_FAIL, + bigNumberifyJson +} from "../../src"; +import { ProposeMessage, InstallVirtualMessage } from "../../src/types"; import { NetworkContextForTestSuite } from "../contracts"; import { setup, SetupContext } from "./setup"; @@ -142,7 +142,7 @@ describe("Node method follows spec - proposeInstallVirtual", () => { // try to install a virtual app with insufficient collateral const { params } = await makeVirtualProposal(nodeA, nodeC, TicTacToeApp); - expect(params.initiatorDeposit.gt(Zero)).toBeTruthy(); + expect(bigNumberifyJson(params.initiatorDeposit).gt(Zero)).toBeTruthy(); const [proposedAppNodeA] = await getProposedAppInstances(nodeA); @@ -167,7 +167,7 @@ describe("Node method follows spec - proposeInstallVirtual", () => { // try to install a virtual app with insufficient collateral const { params } = await makeVirtualProposal(nodeA, nodeC, TicTacToeApp); - expect(params.initiatorDeposit.gt(Zero)).toBeTruthy(); + expect(bigNumberifyJson(params.initiatorDeposit).gt(Zero)).toBeTruthy(); const [proposedAppNodeA] = await getProposedAppInstances(nodeA); diff --git a/modules/cf-core/test/integration/propose.spec.ts b/modules/cf-core/test/integration/propose.spec.ts index 24e99ba333..443fe81ed5 100644 --- a/modules/cf-core/test/integration/propose.spec.ts +++ b/modules/cf-core/test/integration/propose.spec.ts @@ -1,6 +1,6 @@ -import { Node as NodeTypes } from "@connext/types"; +import { CFCoreTypes } from "@connext/types"; -import { Node, NODE_EVENTS, ProposeMessage } from "../../src"; +import { Node, ProposeMessage, deBigNumberifyJson } from "../../src"; import { NetworkContextForTestSuite } from "../contracts"; import { toBeLt } from "../machine/integration/bignumber-jest-matcher"; @@ -11,7 +11,7 @@ import { createChannel, getAppInstanceProposal, getProposedAppInstances, - makeProposeCall, + makeProposeCall } from "./utils"; expect.extend({ toBeLt }); @@ -21,7 +21,7 @@ const { TicTacToeApp } = global["networkContext"] as NetworkContextForTestSuite; async function assertEqualProposedApps( nodeA: Node, nodeB: Node, - expectedAppIds: string[], + expectedAppIds: string[] ): Promise { const proposedA = await getProposedAppInstances(nodeA); const proposedB = await getProposedAppInstances(nodeB); @@ -54,17 +54,17 @@ describe("Node method follows spec - propose install", () => { it("propose install an app with eth and a meta", async (done: jest.DoneCallback) => { const rpc = makeProposeCall(nodeB, TicTacToeApp); const params = { - ...(rpc.parameters as NodeTypes.ProposeInstallParams), + ...(rpc.parameters as CFCoreTypes.ProposeInstallParams), meta: { - info: "Provided meta", - }, + info: "Provided meta" + } }; const expectedMessageB = { data: { - params, + params }, from: nodeA.publicIdentifier, - type: "PROPOSE_INSTALL_EVENT", + type: "PROPOSE_INSTALL_EVENT" }; nodeB.once("PROPOSE_INSTALL_EVENT", async (msg: ProposeMessage) => { @@ -79,7 +79,7 @@ describe("Node method follows spec - propose install", () => { await nodeA.rpcRouter.dispatch({ ...rpc, - parameters: params, + parameters: deBigNumberifyJson(params) }); }); }); diff --git a/modules/cf-core/test/integration/reject-install-virtual-with-slow-store.spec.ts b/modules/cf-core/test/integration/reject-install-virtual-with-slow-store.spec.ts index 7d02f0451b..bde9f80e62 100644 --- a/modules/cf-core/test/integration/reject-install-virtual-with-slow-store.spec.ts +++ b/modules/cf-core/test/integration/reject-install-virtual-with-slow-store.spec.ts @@ -1,4 +1,4 @@ -import { Node as NodeTypes } from "@connext/types"; +import { CFCoreTypes } from "@connext/types"; import { Node } from "../../src"; import { NODE_EVENTS, ProposeMessage } from "../../src/types"; @@ -42,7 +42,7 @@ describe("Node method follows spec - rejectInstallVirtual", () => { await createChannel(nodeA, nodeB); await createChannel(nodeB, nodeC); - let proposalParams: NodeTypes.ProposeInstallVirtualParams; + let proposalParams: CFCoreTypes.ProposeInstallVirtualParams; nodeA.on("REJECT_INSTALL_EVENT", async () => { expect((await getProposedAppInstances(nodeA)).length).toEqual(0); diff --git a/modules/cf-core/test/integration/secure-deposit.spec.ts b/modules/cf-core/test/integration/secure-deposit.spec.ts index 688075e450..8788442965 100644 --- a/modules/cf-core/test/integration/secure-deposit.spec.ts +++ b/modules/cf-core/test/integration/secure-deposit.spec.ts @@ -24,7 +24,7 @@ import { assertNodeMessage, deposit } from "./utils"; -import { Node as NodeTypes } from "@connext/types"; +import { CFCoreTypes } from "@connext/types"; expect.extend({ toBeEq }); @@ -34,7 +34,7 @@ log.setLevel(log.levels.SILENT); function confirmDepositMessages( initiator: Node, responder: Node, - params: NodeTypes.DepositParams + params: CFCoreTypes.DepositParams ) { const startedMsg = { from: initiator.publicIdentifier, diff --git a/modules/cf-core/test/integration/secure-withdraw.spec.ts b/modules/cf-core/test/integration/secure-withdraw.spec.ts index 0e08076fc4..a00d743290 100644 --- a/modules/cf-core/test/integration/secure-withdraw.spec.ts +++ b/modules/cf-core/test/integration/secure-withdraw.spec.ts @@ -21,7 +21,7 @@ import { assertNodeMessage } from "./utils"; import { WithdrawConfirmationMessage } from "../../src/types"; -import { Node as NodeTypes } from "@connext/types"; +import { CFCoreTypes } from "@connext/types"; expect.extend({ toBeEq, toBeLt }); @@ -29,7 +29,7 @@ expect.extend({ toBeEq, toBeLt }); function confirmWithdrawalMessages( initiator: Node, responder: Node, - params: NodeTypes.WithdrawParams + params: CFCoreTypes.WithdrawParams ) { // initiator messages initiator.once( @@ -128,7 +128,7 @@ describe("Node method follows spec - withdraw", () => { confirmWithdrawalMessages( nodeA, nodeB, - withdrawReq.parameters as NodeTypes.WithdrawParams + withdrawReq.parameters as CFCoreTypes.WithdrawParams ); const { @@ -191,7 +191,7 @@ describe("Node method follows spec - withdraw", () => { confirmWithdrawalMessages( nodeA, nodeB, - withdrawReq.parameters as NodeTypes.WithdrawParams + withdrawReq.parameters as CFCoreTypes.WithdrawParams ); await nodeA.rpcRouter.dispatch(withdrawReq); @@ -240,7 +240,7 @@ describe("Node method follows spec - withdraw", () => { confirmWithdrawalMessages( nodeA, nodeB, - withdrawCommitmentReq.parameters as NodeTypes.WithdrawParams + withdrawCommitmentReq.parameters as CFCoreTypes.WithdrawParams ); const { diff --git a/modules/cf-core/test/integration/setup.ts b/modules/cf-core/test/integration/setup.ts index 50cc92c70b..9652bc9f51 100644 --- a/modules/cf-core/test/integration/setup.ts +++ b/modules/cf-core/test/integration/setup.ts @@ -9,7 +9,7 @@ import { parseEther } from "ethers/utils"; import { fromExtendedKey } from "ethers/utils/hdnode"; import { v4 as generateUUID } from "uuid"; -import { EXTENDED_PRIVATE_KEY_PATH, Node } from "../../src"; +import { Node } from "../../src"; import { computeRandomExtendedPrvKey } from "../../src/machine/xkeys"; import MemoryLockService from "../services/memory-lock-service"; import { MemoryMessagingService } from "../services/memory-messaging-service"; diff --git a/modules/cf-core/test/integration/take-action-virtual.spec.ts b/modules/cf-core/test/integration/take-action-virtual.spec.ts index 8eb5ee5d8c..a475d58fde 100644 --- a/modules/cf-core/test/integration/take-action-virtual.spec.ts +++ b/modules/cf-core/test/integration/take-action-virtual.spec.ts @@ -1,4 +1,4 @@ -import { Node as NodeTypes } from "@connext/types"; +import { CFCoreTypes } from "@connext/types"; import { One, Zero } from "ethers/constants"; import { @@ -25,7 +25,7 @@ jest.setTimeout(15000); const { TicTacToeApp } = global["networkContext"] as NetworkContextForTestSuite; // NOTE: no initiator events -function confirmMessages(initiator: Node, responder: Node, expectedData: NodeTypes.UpdateStateEventData) { +function confirmMessages(initiator: Node, responder: Node, expectedData: CFCoreTypes.UpdateStateEventData) { const expected = { from: initiator.publicIdentifier, type: "UPDATE_STATE_EVENT", diff --git a/modules/cf-core/test/integration/take-action.spec.ts b/modules/cf-core/test/integration/take-action.spec.ts index 2dd1aba7a0..b3c55ca88a 100644 --- a/modules/cf-core/test/integration/take-action.spec.ts +++ b/modules/cf-core/test/integration/take-action.spec.ts @@ -1,4 +1,4 @@ -import { Node as NodeTypes } from "@connext/types"; +import { CFCoreTypes } from "@connext/types"; import { One, Zero } from "ethers/constants"; import { @@ -22,7 +22,7 @@ import { const { TicTacToeApp } = global["networkContext"] as NetworkContextForTestSuite; // NOTE: no initiator events -function confirmMessages(initiator: Node, responder: Node, expectedData: NodeTypes.UpdateStateEventData) { +function confirmMessages(initiator: Node, responder: Node, expectedData: CFCoreTypes.UpdateStateEventData) { const expected = { from: initiator.publicIdentifier, type: "UPDATE_STATE_EVENT", diff --git a/modules/cf-core/test/integration/unrolled-deposit.spec.ts b/modules/cf-core/test/integration/unrolled-deposit.spec.ts index 64c2428547..83622597e4 100644 --- a/modules/cf-core/test/integration/unrolled-deposit.spec.ts +++ b/modules/cf-core/test/integration/unrolled-deposit.spec.ts @@ -5,7 +5,7 @@ import { Node } from "../../src"; import { CoinBalanceRefundState, NODE_EVENTS, - Node as NodeTypes, + CFCoreTypes, } from "../../src/types"; import { toBeLt, toBeEq } from "../machine/integration/bignumber-jest-matcher"; @@ -224,7 +224,7 @@ describe("Node method follows spec - install balance refund", () => { nodeB.once("PROPOSE_INSTALL_EVENT", data => res(data)); await nodeA.rpcRouter.dispatch({ id: Date.now(), - methodName: NodeTypes.RpcMethodName.PROPOSE_INSTALL, + methodName: CFCoreTypes.RpcMethodNames.chan_proposeInstall, parameters }); }); @@ -242,7 +242,7 @@ describe("Node method follows spec - install balance refund", () => { nodeB.once("PROPOSE_INSTALL_EVENT", data => res(data)); await nodeA.rpcRouter.dispatch({ id: Date.now(), - methodName: NodeTypes.RpcMethodName.PROPOSE_INSTALL, + methodName: CFCoreTypes.RpcMethodNames.chan_proposeInstall, parameters }); }); diff --git a/modules/cf-core/test/integration/utils.ts b/modules/cf-core/test/integration/utils.ts index 8f2c1b2f20..70465f55b8 100644 --- a/modules/cf-core/test/integration/utils.ts +++ b/modules/cf-core/test/integration/utils.ts @@ -3,7 +3,7 @@ import { AppInstanceJson, AppInstanceProposal, ContractABI, - Node as NodeTypes, + CFCoreTypes, OutcomeType, SolidityValueType } from "@connext/types"; @@ -43,7 +43,7 @@ import { DepositStartedMessage, EventEmittedMessage } from "../../src/types"; -import { deBigNumberifyJson } from "../../src/utils"; +import { deBigNumberifyJson, bigNumberifyJson } from "../../src/utils"; import { ProposeInstallProtocolParams } from "../../src/machine/types"; interface AppContext { @@ -77,7 +77,7 @@ export function constructRequestDepositRightsRpcCall( ) { return { id: Date.now(), - methodName: NodeTypes.RpcMethodName.REQUEST_DEPOSIT_RIGHTS, + methodName: CFCoreTypes.RpcMethodNames.chan_requestDepositRights, parameters: { multisigAddress, tokenAddress @@ -101,7 +101,7 @@ export function constructRescindDepositRightsRpcCall( ) { return { id: Date.now(), - methodName: NodeTypes.RpcMethodName.RESCIND_DEPOSIT_RIGHTS, + methodName: CFCoreTypes.RpcMethodNames.chan_rescindDepositRights, parameters: { multisigAddress, tokenAddress @@ -201,7 +201,7 @@ export async function getMultisigCreationAddress( export function constructChannelCreationRpc(owners: string[]) { return { id: Date.now(), - methodName: NodeTypes.RpcMethodName.CREATE_CHANNEL, + methodName: CFCoreTypes.RpcMethodNames.chan_create, parameters: { owners } @@ -221,7 +221,7 @@ export async function getChannelAddresses(node: Node): Promise> { } } = await node.rpcRouter.dispatch({ id: Date.now(), - methodName: NodeTypes.RpcMethodName.GET_CHANNEL_ADDRESSES, + methodName: CFCoreTypes.RpcMethodNames.chan_getChannelAddresses, parameters: {} }); @@ -238,7 +238,7 @@ export async function getAppInstance( } } = await node.rpcRouter.dispatch({ id: Date.now(), - methodName: NodeTypes.RpcMethodName.GET_APP_INSTANCE_DETAILS, + methodName: CFCoreTypes.RpcMethodNames.chan_getAppInstance, parameters: { appInstanceId } @@ -270,12 +270,12 @@ export async function getFreeBalanceState( node: Node, multisigAddress: string, tokenAddress: string = CONVENTION_FOR_ETH_TOKEN_ADDRESS -): Promise { +): Promise { const { result: { result } } = await node.rpcRouter.dispatch({ id: Date.now(), - methodName: NodeTypes.RpcMethodName.GET_FREE_BALANCE_STATE, + methodName: CFCoreTypes.RpcMethodNames.chan_getFreeBalanceState, parameters: { multisigAddress, tokenAddress @@ -288,18 +288,18 @@ export async function getFreeBalanceState( export async function getTokenIndexedFreeBalanceStates( node: Node, multisigAddress: string -): Promise { +): Promise { const { result: { result } } = await node.rpcRouter.dispatch({ id: Date.now(), - methodName: NodeTypes.RpcMethodName.GET_TOKEN_INDEXED_FREE_BALANCE_STATES, + methodName: CFCoreTypes.RpcMethodNames.chan_getTokenIndexedFreeBalanceStates, parameters: { multisigAddress } }); - return result as NodeTypes.GetTokenIndexedFreeBalanceStatesResult; + return result as CFCoreTypes.GetTokenIndexedFreeBalanceStatesResult; } export async function getInstalledAppInstances( @@ -307,11 +307,11 @@ export async function getInstalledAppInstances( ): Promise { const rpc = { id: Date.now(), - methodName: NodeTypes.RpcMethodName.GET_APP_INSTANCES, - parameters: {} as NodeTypes.GetAppInstancesParams + methodName: CFCoreTypes.RpcMethodNames.chan_getAppInstances, + parameters: {} as CFCoreTypes.GetAppInstancesParams }; const response = (await node.rpcRouter.dispatch(rpc)) as JsonRpcResponse; - const result = response.result.result as NodeTypes.GetAppInstancesResult; + const result = response.result.result as CFCoreTypes.GetAppInstancesResult; return result.appInstances; } @@ -320,12 +320,12 @@ export async function getProposedAppInstances( ): Promise { const rpc = { id: Date.now(), - methodName: NodeTypes.RpcMethodName.GET_PROPOSED_APP_INSTANCES, - parameters: {} as NodeTypes.GetProposedAppInstancesParams + methodName: CFCoreTypes.RpcMethodNames.chan_getProposedAppInstances, + parameters: {} as CFCoreTypes.GetProposedAppInstancesParams }; const response = (await node.rpcRouter.dispatch(rpc)) as JsonRpcResponse; const result = response.result - .result as NodeTypes.GetProposedAppInstancesResult; + .result as CFCoreTypes.GetProposedAppInstancesResult; return result.appInstances; } @@ -334,7 +334,7 @@ export async function getProposeCoinBalanceRefundAppParams( balanceRefundRecipientIdentifer: string, proposedToIdentifier: string, tokenAddress: string = AddressZero -): Promise { +): Promise { const provider = new JsonRpcProvider(global["ganacheURL"]); let threshold: BigNumber; if (tokenAddress === AddressZero) { @@ -391,7 +391,7 @@ export async function deposit( node.rpcRouter.dispatch({ id: Date.now(), - methodName: NodeTypes.RpcMethodName.PROPOSE_INSTALL, + methodName: CFCoreTypes.RpcMethodNames.chan_proposeInstall, parameters: proposeParams }); }); @@ -435,14 +435,14 @@ export async function deployStateDepositHolder( multisigAddress: string ) { const response = await node.rpcRouter.dispatch({ - methodName: NodeTypes.RpcMethodName.DEPLOY_STATE_DEPOSIT_HOLDER, + methodName: CFCoreTypes.RpcMethodNames.chan_deployStateDepositHolder, parameters: { multisigAddress - } as NodeTypes.DeployStateDepositHolderParams + } as CFCoreTypes.DeployStateDepositHolderParams }); const result = response.result - .result as NodeTypes.DeployStateDepositHolderResult; + .result as CFCoreTypes.DeployStateDepositHolderResult; return result.transactionHash; } @@ -454,12 +454,12 @@ export function constructDepositRpc( ): Rpc { return { id: Date.now(), - methodName: NodeTypes.RpcMethodName.DEPOSIT, - parameters: { + methodName: CFCoreTypes.RpcMethodNames.chan_deposit, + parameters: deBigNumberifyJson({ multisigAddress, amount, tokenAddress - } as NodeTypes.DepositParams + }) }; } @@ -477,7 +477,7 @@ export function constructWithdrawCommitmentRpc( ); withdrawCommitmentReq.methodName = - NodeTypes.RpcMethodName.WITHDRAW_COMMITMENT; + CFCoreTypes.RpcMethodNames.chan_withdrawCommitment; return withdrawCommitmentReq; } @@ -490,33 +490,33 @@ export function constructWithdrawRpc( ): Rpc { return { id: Date.now(), - methodName: NodeTypes.RpcMethodName.WITHDRAW, - parameters: { + methodName: CFCoreTypes.RpcMethodNames.chan_withdraw, + parameters: deBigNumberifyJson({ tokenAddress, multisigAddress, amount, recipient - } as NodeTypes.WithdrawParams + }) as CFCoreTypes.WithdrawParams }; } export function constructInstallRpc(appInstanceId: string): Rpc { return { id: Date.now(), - methodName: NodeTypes.RpcMethodName.INSTALL, + methodName: CFCoreTypes.RpcMethodNames.chan_install, parameters: { appInstanceId - } as NodeTypes.InstallParams + } as CFCoreTypes.InstallParams }; } export function constructRejectInstallRpc(appInstanceId: string): Rpc { return { id: Date.now(), - methodName: NodeTypes.RpcMethodName.REJECT_INSTALL, + methodName: CFCoreTypes.RpcMethodNames.chan_rejectInstall, parameters: { appInstanceId - } as NodeTypes.RejectInstallParams + } as CFCoreTypes.RejectInstallParams }; } @@ -533,8 +533,8 @@ export function constructAppProposalRpc( const { outcomeType } = getAppContext(appDefinition, initialState); return { id: Date.now(), - methodName: NodeTypes.RpcMethodName.PROPOSE_INSTALL, - parameters: { + methodName: CFCoreTypes.RpcMethodNames.chan_proposeInstall, + parameters: deBigNumberifyJson({ proposedToIdentifier, initiatorDeposit, initiatorDepositTokenAddress, @@ -545,7 +545,7 @@ export function constructAppProposalRpc( abiEncodings, outcomeType, timeout: One - } as NodeTypes.ProposeInstallParams + } as CFCoreTypes.ProposeInstallParams) }; } @@ -557,9 +557,9 @@ export function constructInstallVirtualRpc( parameters: { appInstanceId, intermediaryIdentifier - } as NodeTypes.InstallVirtualParams, + } as CFCoreTypes.InstallVirtualParams, id: Date.now(), - methodName: NodeTypes.RpcMethodName.INSTALL_VIRTUAL + methodName: CFCoreTypes.RpcMethodNames.chan_installVirtual }; } @@ -582,12 +582,12 @@ export function constructVirtualProposalRpc( initiatorDepositTokenAddress, responderDeposit, responderDepositTokenAddress - ).parameters as NodeTypes.ProposeInstallParams; + ).parameters as CFCoreTypes.ProposeInstallParams; return { parameters: installProposalParams, id: Date.now(), - methodName: NodeTypes.RpcMethodName.PROPOSE_INSTALL + methodName: CFCoreTypes.RpcMethodNames.chan_proposeInstall }; } @@ -596,11 +596,11 @@ export function constructVirtualProposalRpc( * @param appInstanceProposal The proposed app instance contained in the Node. */ export function confirmProposedAppInstance( - methodParams: NodeTypes.MethodParams, + methodParams: CFCoreTypes.MethodParams, appInstanceProposal: AppInstanceProposal, nonInitiatingNode: boolean = false ) { - const proposalParams = methodParams as NodeTypes.ProposeInstallParams; + const proposalParams = methodParams as CFCoreTypes.ProposeInstallParams; expect(proposalParams.abiEncodings).toEqual(appInstanceProposal.abiEncodings); expect(proposalParams.appDefinition).toEqual( appInstanceProposal.appDefinition @@ -636,7 +636,7 @@ export function constructGetStateRpc(appInstanceId: string): Rpc { appInstanceId }, id: Date.now(), - methodName: NodeTypes.RpcMethodName.GET_STATE + methodName: CFCoreTypes.RpcMethodNames.chan_getState }; } @@ -645,12 +645,12 @@ export function constructTakeActionRpc( action: any ): Rpc { return { - parameters: { + parameters: deBigNumberifyJson({ appInstanceId, action - } as NodeTypes.TakeActionParams, + } as CFCoreTypes.TakeActionParams), id: Date.now(), - methodName: NodeTypes.RpcMethodName.TAKE_ACTION + methodName: CFCoreTypes.RpcMethodNames.chan_takeAction }; } @@ -658,7 +658,7 @@ export function constructGetAppsRpc(): Rpc { return { parameters: {}, id: Date.now(), - methodName: NodeTypes.RpcMethodName.GET_APP_INSTANCES + methodName: CFCoreTypes.RpcMethodNames.chan_getAppInstances }; } @@ -666,9 +666,9 @@ export function constructUninstallRpc(appInstanceId: string): Rpc { return { parameters: { appInstanceId - } as NodeTypes.UninstallParams, + } as CFCoreTypes.UninstallParams, id: Date.now(), - methodName: NodeTypes.RpcMethodName.UNINSTALL + methodName: CFCoreTypes.RpcMethodNames.chan_uninstall }; } @@ -680,9 +680,9 @@ export function constructUninstallVirtualRpc( parameters: { appInstanceId, intermediaryIdentifier - } as NodeTypes.UninstallVirtualParams, + } as CFCoreTypes.UninstallVirtualParams, id: Date.now(), - methodName: NodeTypes.RpcMethodName.UNINSTALL_VIRTUAL + methodName: CFCoreTypes.RpcMethodNames.chan_uninstallVirtual }; } @@ -809,7 +809,7 @@ export async function installApp( const response = await nodeA.rpcRouter.dispatch(installationProposalRpc); const { appInstanceId } = response.result - .result as NodeTypes.ProposeInstallResult; + .result as CFCoreTypes.ProposeInstallResult; return appInstanceId; }); } @@ -868,7 +868,7 @@ export async function confirmChannelCreation( nodeA: Node, nodeB: Node, ownersFreeBalanceAddress: string[], - data: NodeTypes.CreateChannelResult + data: CFCoreTypes.CreateChannelResult ) { const openChannelsNodeA = await getChannelAddresses(nodeA); const openChannelsNodeB = await getChannelAddresses(nodeB); @@ -882,15 +882,16 @@ export async function confirmAppInstanceInstallation( proposedParams: ProposeInstallProtocolParams, appInstance: AppInstanceJson ) { - expect(appInstance.appInterface.addr).toEqual(proposedParams.appDefinition); + const params = bigNumberifyJson(proposedParams); + expect(appInstance.appInterface.addr).toEqual(params.appDefinition); expect(appInstance.appInterface.stateEncoding).toEqual( - proposedParams.abiEncodings.stateEncoding + params.abiEncodings.stateEncoding ); expect(appInstance.appInterface.actionEncoding).toEqual( - proposedParams.abiEncodings.actionEncoding + params.abiEncodings.actionEncoding ); - expect(appInstance.defaultTimeout).toEqual(proposedParams.timeout.toNumber()); - expect(appInstance.latestState).toEqual(proposedParams.initialState); + expect(appInstance.defaultTimeout).toEqual(params.timeout.toNumber()); + expect(appInstance.latestState).toEqual(params.initialState); } export async function getState( @@ -899,7 +900,7 @@ export async function getState( ): Promise { const getStateReq = constructGetStateRpc(appInstanceId); const getStateResult = await nodeA.rpcRouter.dispatch(getStateReq); - return (getStateResult.result.result as NodeTypes.GetStateResult).state; + return (getStateResult.result.result as CFCoreTypes.GetStateResult).state; } export async function makeVirtualProposal( @@ -935,7 +936,7 @@ export async function makeVirtualProposal( } } = await nodeA.rpcRouter.dispatch({ parameters: params, - methodName: NodeTypes.RpcMethodName.PROPOSE_INSTALL, + methodName: CFCoreTypes.RpcMethodNames.chan_proposeInstall, id: Date.now() }); @@ -963,7 +964,7 @@ export async function makeVirtualProposeCall( initialState?: SolidityValueType ): Promise<{ appInstanceId: string; - params: NodeTypes.ProposeInstallVirtualParams; + params: CFCoreTypes.ProposeInstallVirtualParams; }> { const appContext = getAppContext(appDefinition, initialState); @@ -977,9 +978,9 @@ export async function makeVirtualProposeCall( const response = await nodeA.rpcRouter.dispatch(virtualProposalRpc); return { - appInstanceId: (response.result as NodeTypes.ProposeInstallVirtualResult) + appInstanceId: (response.result as CFCoreTypes.ProposeInstallVirtualResult) .appInstanceId, - params: virtualProposalRpc.parameters as NodeTypes.ProposeInstallVirtualParams + params: virtualProposalRpc.parameters as CFCoreTypes.ProposeInstallVirtualParams }; } diff --git a/modules/cf-core/test/machine/unit/ethereum/set-state-commitment.spec.ts b/modules/cf-core/test/machine/unit/ethereum/set-state-commitment.spec.ts index 52a539da29..b094bf0e91 100644 --- a/modules/cf-core/test/machine/unit/ethereum/set-state-commitment.spec.ts +++ b/modules/cf-core/test/machine/unit/ethereum/set-state-commitment.spec.ts @@ -1,4 +1,4 @@ -import { Node } from "@connext/types"; +import { CFCoreTypes } from "@connext/types"; import { bigNumberify, Interface, @@ -20,7 +20,7 @@ import { generateRandomNetworkContext } from "../../mocks"; */ describe("Set State Commitment", () => { let commitment: SetStateCommitment; - let tx: Node.MinimalTransaction; + let tx: CFCoreTypes.MinimalTransaction; const networkContext = generateRandomNetworkContext(); diff --git a/modules/cf-core/test/machine/unit/ethereum/withdraw-eth-commitment.spec.ts b/modules/cf-core/test/machine/unit/ethereum/withdraw-eth-commitment.spec.ts index a36d14ad83..382c3d33da 100644 --- a/modules/cf-core/test/machine/unit/ethereum/withdraw-eth-commitment.spec.ts +++ b/modules/cf-core/test/machine/unit/ethereum/withdraw-eth-commitment.spec.ts @@ -1,4 +1,4 @@ -import { Node } from "@connext/types"; +import { CFCoreTypes } from "@connext/types"; import { bigNumberify, getAddress, hexlify, randomBytes } from "ethers/utils"; import { WithdrawETHCommitment } from "../../../../src/ethereum"; @@ -10,7 +10,7 @@ import { WithdrawETHCommitment } from "../../../../src/ethereum"; */ describe("Withdraw ETH Commitment", () => { let commitment: WithdrawETHCommitment; - let tx: Node.MinimalTransaction; + let tx: CFCoreTypes.MinimalTransaction; const multisigAddress = getAddress(hexlify(randomBytes(20))); const multisigOwners = [ diff --git a/modules/cf-core/test/services/memory-lock-service.ts b/modules/cf-core/test/services/memory-lock-service.ts index 7da94bfe30..85788eaa4f 100644 --- a/modules/cf-core/test/services/memory-lock-service.ts +++ b/modules/cf-core/test/services/memory-lock-service.ts @@ -1,8 +1,8 @@ -import { Node } from "@connext/types"; +import { CFCoreTypes } from "@connext/types"; import { Lock } from "./lock"; -export class MemoryLockService implements Node.ILockService { +export class MemoryLockService implements CFCoreTypes.ILockService { public readonly locks: Map = new Map(); async acquireLock( diff --git a/modules/cf-core/test/services/memory-store-service.ts b/modules/cf-core/test/services/memory-store-service.ts index f1c383cf55..b475aad78e 100644 --- a/modules/cf-core/test/services/memory-store-service.ts +++ b/modules/cf-core/test/services/memory-store-service.ts @@ -1,6 +1,6 @@ -import { Node } from "@connext/types"; +import { CFCoreTypes } from "@connext/types"; -export class MemoryStoreService implements Node.IStoreService { +export class MemoryStoreService implements CFCoreTypes.IStoreService { private readonly store: Map = new Map(); constructor(private readonly delay: number = 0) {} async get(path: string): Promise { @@ -45,7 +45,7 @@ export class MemoryStoreService implements Node.IStoreService { } } -export class MemoryStoreServiceFactory implements Node.ServiceFactory { +export class MemoryStoreServiceFactory implements CFCoreTypes.ServiceFactory { constructor(private readonly delay: number = 0) {} createStoreService() { return new MemoryStoreService(this.delay); diff --git a/modules/cf-core/test/services/mock-messaging-service.ts b/modules/cf-core/test/services/mock-messaging-service.ts index 64395d51bb..de286d033d 100644 --- a/modules/cf-core/test/services/mock-messaging-service.ts +++ b/modules/cf-core/test/services/mock-messaging-service.ts @@ -1,6 +1,6 @@ -import { Node } from "@connext/types"; +import { CFCoreTypes } from "@connext/types"; -class MockMessagingService implements Node.IMessagingService { +class MockMessagingService implements CFCoreTypes.IMessagingService { async send() {} onReceive() {} } diff --git a/modules/cf-core/test/services/mock-store-service.ts b/modules/cf-core/test/services/mock-store-service.ts index 35757fe150..43b6611a83 100644 --- a/modules/cf-core/test/services/mock-store-service.ts +++ b/modules/cf-core/test/services/mock-store-service.ts @@ -1,6 +1,6 @@ -import { Node } from "@connext/types"; +import { CFCoreTypes } from "@connext/types"; -class MockStoreService implements Node.IStoreService { +class MockStoreService implements CFCoreTypes.IStoreService { get() { return Promise.resolve(true); } diff --git a/modules/cf-funding-protocol-contracts/package.json b/modules/cf-funding-protocol-contracts/package.json index 66e4adcb2d..880ab10381 100644 --- a/modules/cf-funding-protocol-contracts/package.json +++ b/modules/cf-funding-protocol-contracts/package.json @@ -21,7 +21,7 @@ "solidity" ], "devDependencies": { - "@connext/types": "1.3.14", + "@connext/types": "1.4.1", "@connext/cf-adjudicator-contracts": "0.4.1", "@types/chai": "4.2.6", "@types/node": "12.12.14", diff --git a/modules/cf-types/.gitignore b/modules/cf-types/.gitignore deleted file mode 100644 index de4d1f007d..0000000000 --- a/modules/cf-types/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -dist -node_modules diff --git a/modules/cf-types/.prettierrc b/modules/cf-types/.prettierrc deleted file mode 100644 index c8ef640ed9..0000000000 --- a/modules/cf-types/.prettierrc +++ /dev/null @@ -1,4 +0,0 @@ -{ - "printWidth": 80, - "trailingComma": "none" -} diff --git a/modules/cf-types/package.json b/modules/cf-types/package.json deleted file mode 100644 index 621fd546b6..0000000000 --- a/modules/cf-types/package.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "@connext/cf-types", - "version": "1.3.14", - "description": "TypeScript typings for common Counterfactual types", - "main": "dist/index.js", - "module": "dist/index.esm.js", - "types": "dist/src/index.d.ts", - "iife": "dist/index-iife.js", - "license": "MIT", - "engines": { - "yarn": ">=1.17.3", - "node": "^10 || ^12" - }, - "scripts": { - "build": "tsc -b . && rollup -c" - }, - "devDependencies": { - "ethers": "4.0.40", - "rollup": "1.27.8", - "rollup-plugin-typescript2": "0.25.2", - "rpc-server": "0.0.1", - "typescript": "3.5.3" - } -} diff --git a/modules/cf-types/rollup.config.js b/modules/cf-types/rollup.config.js deleted file mode 100644 index 5c5b8a8d48..0000000000 --- a/modules/cf-types/rollup.config.js +++ /dev/null @@ -1,25 +0,0 @@ -import typescript from "rollup-plugin-typescript2"; - -import pkg from "./package.json"; - -export default [ - { - input: "src/index.ts", - output: [ - { - file: pkg.main, - format: "cjs" - }, - { - file: pkg.module, - format: "esm" - }, - { - file: pkg.iife, - format: "iife", - name: "window.types" - } - ], - plugins: [typescript()] - } -]; diff --git a/modules/cf-types/src/index.js b/modules/cf-types/src/index.js deleted file mode 100644 index c6a8504c3a..0000000000 --- a/modules/cf-types/src/index.js +++ /dev/null @@ -1,8 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var AssetType; -(function (AssetType) { - AssetType[AssetType["ETH"] = 0] = "ETH"; - AssetType[AssetType["ERC20"] = 1] = "ERC20"; -})(AssetType = exports.AssetType || (exports.AssetType = {})); -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/modules/cf-types/tsconfig.json b/modules/cf-types/tsconfig.json deleted file mode 100644 index e8471a556a..0000000000 --- a/modules/cf-types/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "composite": true, - "outDir": "dist" - }, - "include": ["src/*.ts"] -} diff --git a/modules/cf-types/tslint.json b/modules/cf-types/tslint.json deleted file mode 100644 index 3bc90ec6ef..0000000000 --- a/modules/cf-types/tslint.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": ["../../tslint.json"], - "rules": { - "object-literal-shorthand": false, - "object-literal-sort-keys": false, - "trailing-comma": false, - "typedef": false - } -} diff --git a/modules/client/package.json b/modules/client/package.json index 21a60253f4..ba6451a457 100644 --- a/modules/client/package.json +++ b/modules/client/package.json @@ -1,6 +1,6 @@ { "name": "@connext/client", - "version": "1.3.14", + "version": "1.4.1", "description": "Shared code between wallet and node", "main": "dist/index.js", "files": ["dist", "src", "types"], @@ -12,10 +12,10 @@ "test": "./node_modules/.bin/jest" }, "dependencies": { - "@connext/cf-core": "1.3.14", + "@connext/cf-core": "1.4.1", "@connext/cf-funding-protocol-contracts": "0.4.1", - "@connext/messaging": "1.3.14", - "@connext/types": "1.3.14", + "@connext/messaging": "1.4.1", + "@connext/types": "1.4.1", "core-js": "3.4.7", "eth-crypto": "1.5.0", "ethers": "4.0.40", diff --git a/modules/client/src/channelProvider.ts b/modules/client/src/channelProvider.ts new file mode 100644 index 0000000000..cbccaba7ad --- /dev/null +++ b/modules/client/src/channelProvider.ts @@ -0,0 +1,199 @@ +import { Wallet } from "ethers"; +import { arrayify } from "ethers/utils"; +import { RpcParameters } from "rpc-server"; + +import { CFCore, deBigNumberifyJson, xpubToAddress } from "./lib"; +import { + CFChannelProviderOptions, + CFCoreTypes, + ChannelProviderConfig, + ChannelProviderRpcMethod, + RpcConnection, + Store, + StorePair, +} from "./types"; + +export const createCFChannelProvider = async ({ + ethProvider, + keyGen, + lockService, + messaging, + networkContext, + nodeConfig, + nodeUrl, + store, + xpub, +}: CFChannelProviderOptions): Promise => { + const cfCore = await CFCore.create( + messaging as any, + store, + networkContext, + nodeConfig, + ethProvider, + lockService, + xpub, + keyGen, + ); + const channelProviderConfig: ChannelProviderConfig = { + freeBalanceAddress: xpubToAddress(xpub), + nodeUrl, + signerAddress: xpubToAddress(xpub), + userPublicIdentifier: xpub, + }; + const channelProvider = new ChannelProvider( + cfCore, + channelProviderConfig, + store, + await keyGen("0"), + ); + return channelProvider; +}; + +export class ChannelProvider { + private connection: RpcConnection; + private store: Store; + + // TODO: replace this when signing keys are added! + private wallet: Wallet; + + // shouldnt really ever be used + private _config: ChannelProviderConfig; // tslint:disable-line:variable-name + private _multisigAddress: string | undefined = undefined; // tslint:disable-line:variable-name + private _signerAddress: string | undefined = undefined; // tslint:disable-line:variable-name + + constructor( + connection: RpcConnection, + config: ChannelProviderConfig, + store: Store, + authKey: any, + ) { + this.store = store; + this.wallet = authKey ? new Wallet(authKey) : null; + this.connection = connection; + this._config = config; + this._multisigAddress = config.multisigAddress; + this._signerAddress = config.signerAddress; + } + + public enable = async (): Promise => { + return this.config; + }; + + public send = async (method: ChannelProviderRpcMethod, params: any = {}): Promise => { + let result; + switch (method) { + case "chan_storeSet": + result = await this.set(params.pairs); + break; + case "chan_storeGet": + result = await this.get(params.path); + break; + case "chan_nodeAuth": + result = await this.signMessage(params.message); + break; + case "chan_config": + result = this.config; + break; + case "chan_restoreState": + result = await this.restoreState(params.path); + break; + default: + result = await this._send(method, params); + break; + } + return result; + }; + + /////////////////////////////////////////////// + ///// GETTERS / SETTERS + get isSigner(): boolean { + return true; + } + + get config(): ChannelProviderConfig { + return this._config; + } + + get multisigAddress(): string | undefined { + return this._multisigAddress || this.config.multisigAddress; + } + + set multisigAddress(multisigAddress: string) { + this._config.multisigAddress = multisigAddress; + this._multisigAddress = multisigAddress; + } + + get signerAddress(): string { + return this._signerAddress || this.config.signerAddress; + } + + set signerAddress(signerAddress: string) { + this._config.signerAddress = signerAddress; + this._signerAddress = signerAddress; + } + + /////////////////////////////////////////////// + ///// LISTENER METHODS + public on = (event: string, listener: (...args: any[]) => void): RpcConnection => { + this.connection.on(event, listener); + return this.connection; + }; + + public once = (event: string, listener: (...args: any[]) => void): RpcConnection => { + this.connection.once(event, listener); + return this.connection; + }; + + /////////////////////////////////////////////// + ///// SIGNING METHODS + public signMessage = async (message: string): Promise => { + return await this.wallet.signMessage(arrayify(message)); + }; + + /////////////////////////////////////////////// + ///// STORE METHODS + + public get = async (path: string): Promise => { + return await this.store.get(path); + }; + + public set = async (pairs: StorePair[], allowDelete?: Boolean): Promise => { + return await this.store.set(pairs, allowDelete); + }; + + public restore = async (): Promise => { + return await this.store.restore(); + }; + + public reset = async (): Promise => { + return await this.store.reset(); + }; + + public restoreState = async (path: string): Promise => { + this.reset(); + let state; + state = await this.restore(); + if (!state || !state.path) { + throw new Error(`No matching paths found in store backup's state`); + } + state = state.path; + return state; + }; + + /////////////////////////////////////////////// + ///// PRIVATE METHODS + + // tslint:disable-next-line:variable-name + private _send = async ( + methodName: CFCoreTypes.RpcMethodName, + parameters: RpcParameters, + ): Promise => { + const ret = await this.connection.rpcRouter.dispatch({ + id: Date.now(), + methodName, + parameters: deBigNumberifyJson(parameters), + }); + const result = ret.result.result; + return result; + }; +} diff --git a/modules/client/src/channelRouter.ts b/modules/client/src/channelRouter.ts deleted file mode 100644 index b501d04cc8..0000000000 --- a/modules/client/src/channelRouter.ts +++ /dev/null @@ -1,443 +0,0 @@ -import { Wallet } from "ethers"; -import { arrayify, BigNumber } from "ethers/utils"; -import { RpcParameters } from "rpc-server"; - -import { withdrawalKey } from "./lib"; -import { - AppActionBigNumber, - AppStateBigNumber, - CFCoreTypes, - ChannelProviderConfig, - makeChecksum, - makeChecksumOrEthAddress, - RescindDepositRightsParameters, - RescindDepositRightsResponse, - RpcConnection, - RpcType, - Store, -} from "./types"; -import { StateChannelJSON } from "@connext/types"; - -export class ChannelRouter { - private type: RpcType; - private connection: RpcConnection; - - // TODO: replace this when signing keys are added! - // shouldnt really ever be used - private wallet: Wallet | undefined; - private _config: ChannelProviderConfig; - private _multisigAddress: string | undefined = undefined; - private _signerAddress: string | undefined = undefined; - private store: Store | undefined; - private approvedStorePaths: string[]; - - constructor( - connection: RpcConnection, - config: ChannelProviderConfig, - store?: Store, - authKey?: any, - ) { - this.type = config.type; - this.store = store; - this.wallet = authKey ? new Wallet(authKey) : null; - this.connection = connection; - this._config = config; - this._multisigAddress = config.multisigAddress; - this._signerAddress = config.signerAddress; - this.approvedStorePaths = [ - // allow the withdrawal setting to happen - withdrawalKey(this.config.userPublicIdentifier), - ]; - } - - /////////////////////////////////////////////// - ///// GETTERS / SETTERS - get config(): ChannelProviderConfig { - return this._config; - } - - get multisigAddress(): string | undefined { - return this._multisigAddress; - } - - set multisigAddress(multisigAddress: string) { - this._multisigAddress = multisigAddress; - } - - get signerAddress(): string | undefined { - return this._signerAddress; - } - - set signerAddress(signerAddress: string) { - this._signerAddress = signerAddress; - } - - /////////////////////////////////////////////// - ///// LISTENER METHODS - public on = ( - event: CFCoreTypes.EventName | CFCoreTypes.RpcMethodName, - listener: (...args: any[]) => void, - ): RpcConnection => { - this.connection.on(event, listener); - return this.connection; - }; - - public once = ( - event: CFCoreTypes.EventName | CFCoreTypes.RpcMethodName, - listener: (...args: any[]) => void, - ): RpcConnection => { - this.connection.once(event, listener); - return this.connection; - }; - - /////////////////////////////////////////////// - ///// SIGNING METHODS - public signMessage = async (message: string): Promise => { - switch (this.type) { - case RpcType.CounterfactualNode: - if (!this.wallet) { - throw new Error(`Cannot sign without a wallet when using smart client`); - } - // will have a mnemonic, sign with wallet - return await this.wallet.signMessage(arrayify(message)); - - case RpcType.ChannelProvider: - return await this._send("chan_node_auth" as any, { message }); - - default: - throw new Error(`Unrecognized RpcType: ${this.type}. (How'd you even get this far tho...)`); - } - }; - - /////////////////////////////////////////////// - ///// CHANNEL METHODS - - public deposit = async ( - amount: BigNumber, - assetId: string, - multisigAddress: string, - notifyCounterparty: boolean = false, - ): Promise => { - return await this._send(CFCoreTypes.RpcMethodName.DEPOSIT, { - amount, - multisigAddress, - notifyCounterparty, - tokenAddress: makeChecksum(assetId), - } as CFCoreTypes.DepositParams); - }; - - public getStateChannel = async (): Promise<{ data: StateChannelJSON }> => { - return await this._send(CFCoreTypes.RpcMethodName.GET_STATE_CHANNEL, { - multisigAddress: this.multisigAddress, - }); - }; - - public getState = async (appInstanceId: string): Promise => { - return await this._send(CFCoreTypes.RpcMethodName.GET_STATE, { - appInstanceId, - } as CFCoreTypes.GetStateParams); - }; - - public getAppInstances = async ( - multisigAddress?: string, - ): Promise => { - return await this._send(CFCoreTypes.RpcMethodName.GET_APP_INSTANCES, { - multisigAddress, - } as CFCoreTypes.GetAppInstancesParams); - }; - - public getFreeBalance = async ( - assetId: string, - multisigAddress: string, - ): Promise => { - return await this._send(CFCoreTypes.RpcMethodName.GET_FREE_BALANCE_STATE, { - multisigAddress, - tokenAddress: makeChecksum(assetId), - } as CFCoreTypes.GetFreeBalanceStateParams); - }; - - public getProposedAppInstances = async ( - multisigAddress?: string, - ): Promise => { - return await this._send(CFCoreTypes.RpcMethodName.GET_PROPOSED_APP_INSTANCES, { - multisigAddress, - } as CFCoreTypes.GetProposedAppInstancesParams); - }; - - public getProposedAppInstance = async ( - appInstanceId: string, - ): Promise => { - return await this._send(CFCoreTypes.RpcMethodName.GET_PROPOSED_APP_INSTANCES, { - appInstanceId, - } as CFCoreTypes.GetProposedAppInstanceParams); - }; - - public getAppInstanceDetails = async ( - appInstanceId: string, - ): Promise => { - return await this._send(CFCoreTypes.RpcMethodName.GET_APP_INSTANCE_DETAILS, { - appInstanceId, - } as CFCoreTypes.GetAppInstanceDetailsParams); - }; - - public getAppState = async ( - appInstanceId: string, - ): Promise => { - return await this._send(CFCoreTypes.RpcMethodName.GET_STATE, { - appInstanceId, - } as CFCoreTypes.GetStateParams); - }; - - public takeAction = async ( - appInstanceId: string, - action: AppActionBigNumber, - ): Promise => { - return await this._send(CFCoreTypes.RpcMethodName.TAKE_ACTION, { - action, - appInstanceId, - } as CFCoreTypes.TakeActionParams); - }; - - public updateState = async ( - appInstanceId: string, - newState: AppStateBigNumber | any, - // cast to any bc no supported apps use - // the update state method - ): Promise => { - return await this._send(CFCoreTypes.RpcMethodName.UPDATE_STATE, { - appInstanceId, - newState, - } as CFCoreTypes.UpdateStateParams); - }; - - public proposeInstallApp = async ( - params: CFCoreTypes.ProposeInstallParams, // TODO THIS HAS TO CHANGE - ): Promise => { - return await this._send( - CFCoreTypes.RpcMethodName.PROPOSE_INSTALL, - params as CFCoreTypes.ProposeInstallParams, - ); - }; - - public installVirtualApp = async ( - appInstanceId: string, - intermediaryIdentifier: string, - ): Promise => { - return await this._send(CFCoreTypes.RpcMethodName.INSTALL_VIRTUAL, { - appInstanceId, - intermediaryIdentifier, - } as CFCoreTypes.InstallVirtualParams); - }; - - public installApp = async (appInstanceId: string): Promise => { - return await this._send(CFCoreTypes.RpcMethodName.INSTALL, { - appInstanceId, - } as CFCoreTypes.InstallParams); - }; - - public requestDepositRights = async ( - assetId: string, - ): Promise => { - return await this._send(CFCoreTypes.RpcMethodName.REQUEST_DEPOSIT_RIGHTS, { - multisigAddress: this.multisigAddress, - tokenAddress: assetId, - } as CFCoreTypes.RequestDepositRightsParams); - }; - - public uninstallApp = async (appInstanceId: string): Promise => { - return await this._send(CFCoreTypes.RpcMethodName.UNINSTALL, { - appInstanceId, - } as CFCoreTypes.UninstallParams); - }; - - public rescindDepositRights = async ( - params: RescindDepositRightsParameters, - ): Promise => { - return await this._send(CFCoreTypes.RpcMethodName.RESCIND_DEPOSIT_RIGHTS, { - multisigAddress: this.multisigAddress, - tokenAddress: params.assetId, - } as CFCoreTypes.RescindDepositRightsParams); - }; - - public uninstallVirtualApp = async ( - appInstanceId: string, - intermediary: string, // should be string array - ): Promise => { - return await this._send(CFCoreTypes.RpcMethodName.UNINSTALL_VIRTUAL, { - appInstanceId, - intermediaryIdentifier: intermediary, - } as CFCoreTypes.UninstallVirtualParams); - }; - - public rejectInstallApp = async (appInstanceId: string): Promise => { - return await this._send(CFCoreTypes.RpcMethodName.REJECT_INSTALL, { appInstanceId }); - }; - - public withdraw = async ( - amount: BigNumber, - assetId: string, // optional in cf - recipient: string, // optional in cf - ): Promise => { - return await this._send(CFCoreTypes.RpcMethodName.WITHDRAW, { - amount, - multisigAddress: this.multisigAddress, - recipient, - tokenAddress: makeChecksum(assetId), - } as CFCoreTypes.WithdrawParams); - }; - - public withdrawCommitment = async ( - amount: BigNumber, - assetId?: string, - recipient?: string, - ): Promise => { - return await this._send(CFCoreTypes.RpcMethodName.WITHDRAW_COMMITMENT, { - amount, - multisigAddress: this.multisigAddress, - recipient, - tokenAddress: makeChecksumOrEthAddress(assetId), - } as CFCoreTypes.WithdrawCommitmentParams); - }; - - /////////////////////////////////////////////// - ///// STORE METHODS - - public get = async (path: string): Promise => { - this.isApprovedGetSetPath(path); - switch (this.type) { - case RpcType.CounterfactualNode: - if (!this.store) { - throw new Error( - `Should have a defined store ref when provider type is a counterfactual node.`, - ); - } - return await this.store.get(path); - - case RpcType.ChannelProvider: - // route the store get call through the connection - return await this.connection._send("chan_store_get", { - path, - }); - - default: - throw new Error(`Unrecognized RpcType: ${this.type}. (How'd you even get this far tho...)`); - } - }; - - public set = async ( - pairs: { - path: string; - value: any; - }[], - allowDelete?: Boolean, - ): Promise => { - // verify it is in the approved paths for editing - pairs.forEach(({ path, value }) => { - this.isApprovedGetSetPath(path); - }); - switch (this.type) { - case RpcType.CounterfactualNode: - if (!this.store) { - throw new Error( - `Should have a defined store ref when provider type is a counterfactual node.`, - ); - } - return await this.store.set(pairs, allowDelete); - - case RpcType.ChannelProvider: - // route the store get call through the connection - return await this.connection._send("chan_store_set", { - allowDelete, - pairs, - }); - - default: - throw new Error(`Unrecognized RpcType: ${this.type}. (How'd you even get this far tho...)`); - } - }; - - public restore = async (): Promise<{ path: string; value: any }[]> => { - switch (this.type) { - case RpcType.CounterfactualNode: - if (!this.store) { - throw new Error( - `Should have a defined store ref when provider type is a counterfactual node.`, - ); - } - return await this.store.restore(); - - case RpcType.ChannelProvider: - // do not allow channel provider types to restore state - // TODO: can we route to the smart client here? - throw new Error( - `Cannot restore store with channel provider instantiation. Please contact original wallet provider.`, - ); - default: - throw new Error(`Unrecognized RpcType: ${this.type}. (How'd you even get this far tho...)`); - } - }; - - public reset = async (): Promise => { - switch (this.type) { - case RpcType.CounterfactualNode: - if (!this.store) { - throw new Error( - `Should have a defined store ref when provider type is a counterfactual node.`, - ); - } - return await this.store.reset(); - - case RpcType.ChannelProvider: - // do not allow channel provider types to reset store - throw new Error( - `Cannot restore store with channel provider instantiation. Please contact original wallet provider.`, - ); - default: - throw new Error(`Unrecognized RpcType: ${this.type}. (How'd you even get this far tho...)`); - } - }; - - /////////////////////////////////////////////// - ///// PRIVATE METHODS - - private isApprovedGetSetPath(path: string): void { - // if it is a smart client, all paths are approved - if (this.type === RpcType.CounterfactualNode) { - return; - } - - // verify it is in the approved paths for editing - if (this.approvedStorePaths.indexOf(path) === -1) { - throw new Error(`Not an approved store path to get/set: ${path}`); - } - } - - // tslint:disable-next-line: function-name - private async _send( - methodName: CFCoreTypes.RpcMethodName, - parameters: RpcParameters, - ): Promise { - let result: any; - switch (this.type) { - case RpcType.CounterfactualNode: - const ret = await this.connection.rpcRouter.dispatch({ - id: Date.now(), - methodName, - parameters, - }); - // cf module nests the return value in a `.result.result` - // should make sure that the channel provider call - // does not - result = ret.result.result; - break; - - case RpcType.ChannelProvider: - result = await this.connection._send(methodName, parameters); - break; - - default: - throw new Error(`Unknown rpc type: ${this.type}`); - } - return result; - } -} diff --git a/modules/client/src/connect.ts b/modules/client/src/connect.ts new file mode 100644 index 0000000000..a597b19334 --- /dev/null +++ b/modules/client/src/connect.ts @@ -0,0 +1,253 @@ +import { IMessagingService, MessagingServiceFactory } from "@connext/messaging"; +import { CF_PATH } from "@connext/types"; +import "core-js/stable"; +import { Contract, providers } from "ethers"; +import { AddressZero } from "ethers/constants"; +import { fromExtendedKey, fromMnemonic } from "ethers/utils/hdnode"; +import tokenAbi from "human-standard-token-abi"; +import "regenerator-runtime/runtime"; + +import { ChannelProvider, createCFChannelProvider } from "./channelProvider"; +import { ConnextClient } from "./connext"; +import { Logger, stringify } from "./lib"; +import { NodeApiClient } from "./node"; +import { + CFCoreTypes, + ClientOptions, + ConnextClientStorePrefix, + CreateChannelMessage, + GetConfigResponse, + IConnextClient, +} from "./types"; + +const exists = (obj: any): boolean => { + return !!obj && !!Object.keys(obj).length; +}; + +const createMessagingService = async ( + messagingUrl: string, + logLevel: number, +): Promise => { + // create a messaging service client + const messagingFactory = new MessagingServiceFactory({ logLevel, messagingUrl }); + const messaging = messagingFactory.createService("messaging"); + await messaging.connect(); + return messaging; +}; + +const setupMultisigAddress = async ( + node: NodeApiClient, + channelProvider: ChannelProvider, + log: Logger, +): Promise => { + const myChannel = await node.getChannel(); + + let multisigAddress: string; + if (!myChannel) { + log.debug("no channel detected, creating channel.."); + const creationEventData: CFCoreTypes.CreateChannelResult = await new Promise( + async (res: any, rej: any): Promise => { + const timer = setTimeout( + (): void => rej("Create channel event not fired within 30s"), + 30000, + ); + channelProvider.once( + CFCoreTypes.EventNames.CREATE_CHANNEL_EVENT as CFCoreTypes.EventName, + (data: CreateChannelMessage): void => { + clearTimeout(timer); + res(data.data); + }, + ); + + const creationData = await node.createChannel(); + log.debug(`created channel, transaction: ${stringify(creationData)}`); + }, + ); + multisigAddress = creationEventData.multisigAddress; + } else { + multisigAddress = myChannel.multisigAddress; + } + log.debug(`multisigAddress: ${multisigAddress}`); + + channelProvider.multisigAddress = multisigAddress; + return channelProvider; +}; + +export const connect = async (opts: ClientOptions): Promise => { + const { + logLevel, + ethProviderUrl, + nodeUrl, + store, + mnemonic, + channelProvider: providedChannelProvider, + } = opts; + let { xpub, keyGen } = opts; + + const log = new Logger("ConnextConnect", logLevel); + + // setup ethProvider + network information + log.debug(`Creating ethereum provider - ethProviderUrl: ${ethProviderUrl}`); + const ethProvider = new providers.JsonRpcProvider(ethProviderUrl); + const network = await ethProvider.getNetwork(); + + // special case for ganache + if (network.chainId === 4447) { + network.name = "ganache"; + // Enforce using provided signer, not via RPC + ethProvider.getSigner = (addressOrIndex?: string | number): any => { + throw { code: "UNSUPPORTED_OPERATION" }; + }; + } + + // setup messaging and node api + let messaging: IMessagingService; + let node: NodeApiClient; + let config: GetConfigResponse; + + // setup channelProvider + let channelProvider: ChannelProvider; + + if (providedChannelProvider) { + channelProvider = providedChannelProvider; + if (!exists(channelProvider.config)) { + await channelProvider.enable(); + } + log.debug(`Using channelProvider config: ${stringify(channelProvider.config)}`); + + log.debug(`Creating messaging service client ${channelProvider.config.nodeUrl}`); + messaging = await createMessagingService(channelProvider.config.nodeUrl, logLevel); + + // create a new node api instance + node = new NodeApiClient({ logLevel, messaging, channelProvider }); + config = await node.config(); + log.debug(`Node provided config: ${stringify(config)}`); + + // set pubids + channelProvider + node.channelProvider = channelProvider; + node.userPublicIdentifier = channelProvider.config.userPublicIdentifier; + node.nodePublicIdentifier = config.nodePublicIdentifier; + } else if (mnemonic || (xpub && keyGen)) { + if (!store) { + throw new Error("Client must be instantiated with store if not using a channelProvider"); + } + + if (!nodeUrl) { + throw new Error("Client must be instantiated with nodeUrl if not using a channelProvider"); + } + + if (mnemonic) { + log.debug(`Creating channelProvider with mnemonic: ${mnemonic}`); + // Convert mnemonic into xpub + keyGen if provided + const hdNode = fromExtendedKey(fromMnemonic(mnemonic).extendedKey).derivePath(CF_PATH); + xpub = hdNode.neuter().extendedKey; + keyGen = (index: string): Promise => + Promise.resolve(hdNode.derivePath(index).privateKey); + } else { + log.debug(`Creating channelProvider with xpub: ${xpub}`); + log.debug(`Creating channelProvider with keyGen: ${keyGen}`); + } + + log.debug(`Creating messaging service client ${nodeUrl}`); + messaging = await createMessagingService(nodeUrl, logLevel); + + // create a new node api instance + node = new NodeApiClient({ logLevel, messaging }); + config = await node.config(); + log.debug(`Node provided config: ${stringify(config)}`); + + channelProvider = await createCFChannelProvider({ + ethProvider, + keyGen, + lockService: { acquireLock: node.acquireLock.bind(node) }, + messaging: messaging as any, + networkContext: config.contractAddresses, + nodeConfig: { STORE_KEY_PREFIX: ConnextClientStorePrefix }, + nodeUrl, + store, + xpub, + }); + + log.debug(`Using channelProvider config: ${stringify(channelProvider.config)}`); + + // set pubids + channelProvider + node.channelProvider = channelProvider; + node.userPublicIdentifier = channelProvider.config.userPublicIdentifier; + node.nodePublicIdentifier = config.nodePublicIdentifier; + } else { + throw new Error( + // tslint:disable-next-line:max-line-length + `Client must be instantiated with xpub and keyGen, or a channelProvider if not using mnemonic`, + ); + } + + // setup multisigAddress + assign to channelProvider + await setupMultisigAddress(node, channelProvider, log); + + // create a token contract based on the provided token + const token = new Contract(config.contractAddresses.Token, tokenAbi, ethProvider); + + // create appRegistry + const appRegistry = await node.appRegistry(); + + // create the new client + const client = new ConnextClient({ + appRegistry, + channelProvider, + config, + ethProvider, + keyGen, + messaging, + network, + node, + store, + token, + ...opts, // use any provided opts by default + }); + + try { + await client.getFreeBalance(); + } catch (e) { + if (e.message.includes(`StateChannel does not exist yet`)) { + log.debug(`Restoring client state: ${e.stack || e.message}`); + await client.restoreState(); + } else { + log.error(`Failed to get free balance: ${e.stack || e.message}`); + throw e; + } + } + + // 12/11/2019 make sure state is restored if there is no state channel + const { data: sc } = await client.getStateChannel(); + if (!sc.proxyFactoryAddress) { + log.debug(`No proxy factory address found, restoring client state`); + await client.restoreState(); + } + + log.debug("Registering subscriptions"); + await client.registerSubscriptions(); + + // cleanup any hanging registry apps + await client.cleanupRegistryApps(); + + // check if there is a coin refund app installed for eth and tokens + await client.uninstallCoinBalanceIfNeeded(AddressZero); + await client.uninstallCoinBalanceIfNeeded(config.contractAddresses.Token); + + // make sure there is not an active withdrawal with >= MAX_WITHDRAWAL_RETRIES + log.debug("Resubmitting active withdrawals"); + await client.resubmitActiveWithdrawal(); + + // wait for wd verification to reclaim any pending async transfers + // since if the hub never submits you should not continue interacting + log.debug("Reclaiming pending async transfers"); + // NOTE: Removing the following await results in a subtle race condition during bot tests. + // Don't remove this await again unless you really know what you're doing & bot tests pass + // no need to await this if it needs collateral + // TODO: without await causes race conditions in bot, refactor to + // use events + await client.reclaimPendingAsyncTransfers(); + + log.debug("Done creating channel client"); + return client; +}; diff --git a/modules/client/src/connext.ts b/modules/client/src/connext.ts index d856c4af2d..e7e28192fe 100644 --- a/modules/client/src/connext.ts +++ b/modules/client/src/connext.ts @@ -1,15 +1,15 @@ -import { IMessagingService, MessagingServiceFactory } from "@connext/messaging"; -import { CF_PATH, LinkedTransferToRecipientParameters, AppInstanceProposal } from "@connext/types"; +import { IMessagingService } from "@connext/messaging"; +import { AppInstanceProposal, CF_PATH, LinkedTransferToRecipientParameters } from "@connext/types"; import "core-js/stable"; import EthCrypto from "eth-crypto"; import { Contract, providers } from "ethers"; import { AddressZero } from "ethers/constants"; import { BigNumber, bigNumberify, hexlify, Network, randomBytes, Transaction } from "ethers/utils"; -import { fromExtendedKey, fromMnemonic } from "ethers/utils/hdnode"; +import { fromMnemonic } from "ethers/utils/hdnode"; import tokenAbi from "human-standard-token-abi"; import "regenerator-runtime/runtime"; -import { ChannelRouter } from "./channelRouter"; +import { ChannelProvider, createCFChannelProvider } from "./channelProvider"; import { ConditionalTransferController } from "./controllers/ConditionalTransferController"; import { DepositController } from "./controllers/DepositController"; import { RequestDepositRightsController } from "./controllers/RequestDepositRightsController"; @@ -17,7 +17,7 @@ import { ResolveConditionController } from "./controllers/ResolveConditionContro import { SwapController } from "./controllers/SwapController"; import { TransferController } from "./controllers/TransferController"; import { WithdrawalController } from "./controllers/WithdrawalController"; -import { CFCore, Logger, stringify, withdrawalKey, xpubToAddress } from "./lib"; +import { Logger, stringify, withdrawalKey, xpubToAddress } from "./lib"; import { ConnextListener } from "./listener"; import { NodeApiClient } from "./node"; import { @@ -32,12 +32,10 @@ import { ChannelState, CheckDepositRightsParameters, CheckDepositRightsResponse, - ClientOptions, ConditionalTransferParameters, ConditionalTransferResponse, ConnextClientStorePrefix, ConnextEvent, - CreateChannelMessage, CreateChannelResponse, DefaultApp, DepositParameters, @@ -45,17 +43,16 @@ import { GetConfigResponse, IConnextClient, InternalClientOptions, + KeyGen, makeChecksum, makeChecksumOrEthAddress, PaymentProfile, RequestCollateralResponse, RequestDepositRightsParameters, RescindDepositRightsParameters, - RescindDepositRightsResponse, ResolveConditionParameters, ResolveConditionResponse, ResolveLinkedTransferResponse, - RpcType, Store, SupportedApplication, SupportedNetwork, @@ -70,205 +67,9 @@ import { falsy, notLessThanOrEqualTo, notPositive } from "./validation/bn"; const MAX_WITHDRAWAL_RETRIES = 3; -export const connect = async (opts: ClientOptions): Promise => { - const { logLevel, ethProviderUrl, mnemonic, nodeUrl, store, channelProvider } = opts; - const log = new Logger("ConnextConnect", logLevel); - - // set channel provider config - let channelProviderConfig: ChannelProviderConfig; - let xpub: string; - let keyGen: (index: string) => Promise; - if (mnemonic) { - // Convert mnemonic into xpub + keyGen if provided - const hdNode = fromExtendedKey(fromMnemonic(mnemonic).extendedKey).derivePath(CF_PATH); - xpub = hdNode.neuter().extendedKey; - keyGen = (index: string): Promise => - Promise.resolve(hdNode.derivePath(index).privateKey); - channelProviderConfig = { - freeBalanceAddress: xpubToAddress(xpub), - nodeUrl, - signerAddress: xpubToAddress(xpub), - type: RpcType.CounterfactualNode, - userPublicIdentifier: xpub, - }; - } else if (channelProvider) { - // enable the channel provider, which sets the config property - await channelProvider.enable(); - channelProviderConfig = { - ...channelProvider.config, - type: RpcType.ChannelProvider, - }; - } else if (opts.xpub && opts.keyGen) { - xpub = opts.xpub; - keyGen = opts.keyGen; - channelProviderConfig = { - freeBalanceAddress: xpubToAddress(xpub), - nodeUrl, - signerAddress: xpubToAddress(xpub), - type: RpcType.CounterfactualNode, - userPublicIdentifier: xpub, - }; - } else { - throw new Error( - `Client must be instantiated with xpub and keygen, or a channel provider if not using mnemonic`, - ); - } - - log.debug(`Using channel provider config: ${stringify(channelProviderConfig)}`); - - // setup network information - const ethProvider = new providers.JsonRpcProvider(ethProviderUrl); - const network = await ethProvider.getNetwork(); - - // special case for ganache - if (network.chainId === 4447) { - network.name = "ganache"; - // Enforce using provided signer, not via RPC - ethProvider.getSigner = (addressOrIndex?: string | number): any => { - throw { code: "UNSUPPORTED_OPERATION" }; - }; - } - - log.debug(`Creating messaging service client (logLevel: ${logLevel})`); - const messagingFactory = new MessagingServiceFactory({ - logLevel, - messagingUrl: channelProviderConfig.nodeUrl, - }); - const messaging = messagingFactory.createService("messaging"); - await messaging.connect(); - - // create a new node api instance - const node: NodeApiClient = new NodeApiClient({ logLevel, messaging }); - const config = await node.config(); - log.debug(`Node provided config: ${stringify(config)}`); - - let channelRouter: ChannelRouter; - switch (channelProviderConfig.type) { - case RpcType.ChannelProvider: - channelRouter = new ChannelRouter(channelProvider!, channelProviderConfig); - break; - case RpcType.CounterfactualNode: - const cfCore = await CFCore.create( - messaging as any, - store, - config.contractAddresses, - { STORE_KEY_PREFIX: ConnextClientStorePrefix }, - ethProvider, - { acquireLock: node.acquireLock.bind(node) }, - xpub, - keyGen, - ); - channelRouter = new ChannelRouter(cfCore, channelProviderConfig, store, await keyGen("0")); - break; - default: - throw new Error(`Unrecognized channel provider type: ${channelProviderConfig.type}`); - } - - // set pubids + channel router - node.channelRouter = channelRouter; - node.userPublicIdentifier = channelProviderConfig.userPublicIdentifier; - node.nodePublicIdentifier = config.nodePublicIdentifier; - - const myChannel = await node.getChannel(); - let multisigAddress: string; - if (!myChannel) { - log.debug("no channel detected, creating channel.."); - const creationEventData: CFCoreTypes.CreateChannelResult = await new Promise( - async (res: any, rej: any): Promise => { - const timer = setTimeout( - (): void => rej("Create channel event not fired within 30s"), - 30000, - ); - channelRouter.once( - CFCoreTypes.EventNames.CREATE_CHANNEL_EVENT as CFCoreTypes.EventName, - (data: CreateChannelMessage): void => { - clearTimeout(timer); - res(data.data); - }, - ); - - const creationData = await node.createChannel(); - log.debug(`created channel, transaction: ${stringify(creationData)}`); - }, - ); - multisigAddress = creationEventData.multisigAddress; - } else { - multisigAddress = myChannel.multisigAddress; - } - log.debug(`multisigAddress: ${multisigAddress}`); - - channelRouter.multisigAddress = multisigAddress; - - // create a token contract based on the provided token - const token = new Contract(config.contractAddresses.Token, tokenAbi, ethProvider); - - // create the new client - const client = new ConnextClient({ - appRegistry: await node.appRegistry(), - channelRouter, - config, - ethProvider, - keyGen, - messaging, - multisigAddress, - network, - node, - store, - token, - ...opts, // use any provided opts by default - }); - - try { - await client.getFreeBalance(); - } catch (e) { - if (e.message.includes(`StateChannel does not exist yet`)) { - log.debug(`Restoring client state: ${e.stack || e.message}`); - await client.restoreState(); - } else { - log.error(`Failed to get free balance: ${e.stack || e.message}`); - throw e; - } - } - - // 12/11/2019 restore client state if state channel has no - // proxy factory address - const { data: sc } = await client.getStateChannel(); - if (!sc.proxyFactoryAddress) { - log.debug(`No proxy factory address found, restoring client state`); - await client.restoreState(); - } - - log.debug("Registering subscriptions"); - await client.registerSubscriptions(); - - // check if there is a coin refund app installed for eth and tokens - await client.uninstallCoinBalanceIfNeeded(AddressZero); - await client.uninstallCoinBalanceIfNeeded(config.contractAddresses.Token); - - // cleanup any hanging registry apps - await client.cleanupRegistryApps(); - - // make sure there is not an active withdrawal with >= MAX_WITHDRAWAL_RETRIES - log.debug("Resubmitting active withdrawals"); - await client.resubmitActiveWithdrawal(); - - // wait for wd verification to reclaim any pending async transfers - // since if the hub never submits you should not continue interacting - log.debug("Reclaiming pending async transfers"); - // NOTE: Removing the following await results in a subtle race condition during bot tests. - // Don't remove this await again unless you really know what you're doing & bot tests pass - // no need to await this if it needs collateral - // TODO: without await causes race conditions in bot, refactor to - // use events - await client.reclaimPendingAsyncTransfers(); - - log.debug("Done creating channel client"); - return client; -}; - export class ConnextClient implements IConnextClient { public appRegistry: AppRegistry; - public channelRouter: ChannelRouter; + public channelProvider: ChannelProvider; public config: GetConfigResponse; public ethProvider: providers.JsonRpcProvider; public freeBalanceAddress: string; @@ -280,13 +81,12 @@ export class ConnextClient implements IConnextClient { public node: NodeApiClient; public nodePublicIdentifier: string; public publicIdentifier: string; - public routerType: RpcType; public signerAddress: Address; public store: Store; public token: Contract; private opts: InternalClientOptions; - private keyGen: (index: string) => Promise; + private keyGen: KeyGen; private depositController: DepositController; private transferController: TransferController; @@ -299,7 +99,7 @@ export class ConnextClient implements IConnextClient { constructor(opts: InternalClientOptions) { this.opts = opts; this.appRegistry = opts.appRegistry; - this.channelRouter = opts.channelRouter; + this.channelProvider = opts.channelProvider; this.config = opts.config; this.ethProvider = opts.ethProvider; this.keyGen = opts.keyGen; @@ -309,16 +109,15 @@ export class ConnextClient implements IConnextClient { this.token = opts.token; this.store = opts.store; - this.freeBalanceAddress = this.channelRouter.config.freeBalanceAddress; - this.signerAddress = this.channelRouter.config.signerAddress; - this.routerType = this.channelRouter.config.type; - this.publicIdentifier = this.channelRouter.config.userPublicIdentifier; - this.multisigAddress = this.opts.multisigAddress; + this.freeBalanceAddress = this.channelProvider.config.freeBalanceAddress; + this.signerAddress = this.channelProvider.config.signerAddress; + this.publicIdentifier = this.channelProvider.config.userPublicIdentifier; + this.multisigAddress = this.channelProvider.config.multisigAddress; this.nodePublicIdentifier = this.opts.config.nodePublicIdentifier; this.log = new Logger("ConnextClient", opts.logLevel); // establish listeners - this.listener = new ConnextListener(opts.channelRouter, this); + this.listener = new ConnextListener(opts.channelProvider, this); // instantiate controllers with log and cf this.depositController = new DepositController("DepositController", this); @@ -364,7 +163,9 @@ export class ConnextClient implements IConnextClient { * * NOTE: should probably take assetId into account */ - public getBalanceRefundApp = async (assetId: string = AddressZero): Promise => { + public getBalanceRefundApp = async ( + assetId: string = AddressZero, + ): Promise => { const apps = await this.getAppInstances(this.multisigAddress); const filtered = apps.filter( (app: AppInstanceJson) => @@ -383,39 +184,28 @@ export class ConnextClient implements IConnextClient { // Unsorted methods pulled from the old abstract wrapper class public restart = async (): Promise => { - // Create a fresh channelRouter & start using that. - // End goal is to use this to restart the cfNode after restoring state - let channelRouter: ChannelRouter; - switch (this.routerType) { - case RpcType.ChannelProvider: - channelRouter = new ChannelRouter(this.opts.channelProvider!, this.channelRouter.config); - break; - case RpcType.CounterfactualNode: - const cfCore = await CFCore.create( - this.messaging as any, - this.store, - this.config.contractAddresses, - { STORE_KEY_PREFIX: ConnextClientStorePrefix }, - this.ethProvider, - { acquireLock: this.node.acquireLock.bind(this.node) }, - this.publicIdentifier, - this.keyGen, - ); - channelRouter = new ChannelRouter( - cfCore, - this.channelRouter.config, - this.store, - await this.keyGen("0"), - ); - break; - default: - throw new Error(`Unrecognized channel provider type: ${this.routerType}`); + if (!this.channelProvider.isSigner) { + this.log.warn(`Cannot restart with an injected provider.`); + return; } + // Create a fresh channelProvider & start using that. + // End goal is to use this to restart the cfNode after restoring state + const channelProvider = await createCFChannelProvider({ + ethProvider: this.ethProvider, + keyGen: this.keyGen, + lockService: { acquireLock: this.node.acquireLock.bind(this.node) }, + messaging: this.messaging as any, + networkContext: this.config.contractAddresses, + nodeConfig: { STORE_KEY_PREFIX: ConnextClientStorePrefix }, + nodeUrl: this.channelProvider.config.nodeUrl, + store: this.store, + xpub: this.publicIdentifier, + }); // TODO: this is very confusing to have to do, lets try to figure out a better way - channelRouter.multisigAddress = this.multisigAddress; - this.node.channelRouter = channelRouter; - this.channelRouter = channelRouter; - this.listener = new ConnextListener(channelRouter, this); + channelProvider.multisigAddress = this.multisigAddress; + this.node.channelProvider = channelProvider; + this.channelProvider = channelProvider; + this.listener = new ConnextListener(channelProvider, this); await this.isAvailable(); }; @@ -442,7 +232,7 @@ export class ConnextClient implements IConnextClient { }; public channelProviderConfig = async (): Promise => { - return this.channelRouter.config; + return this.channelProvider.config; }; public getLinkedTransfer = async (paymentId: string): Promise => { @@ -499,8 +289,14 @@ export class ConnextClient implements IConnextClient { public rescindDepositRights = async ( params: RescindDepositRightsParameters, - ): Promise => { - return await this.channelRouter.rescindDepositRights(params); + ): Promise => { + return await this.channelProvider.send( + CFCoreTypes.RpcMethodNames.chan_rescindDepositRights as CFCoreTypes.RpcMethodName, + { + multisigAddress: this.multisigAddress, + tokenAddress: params.assetId, + } as CFCoreTypes.RescindDepositRightsParams, + ); }; public checkDepositRights = async ( @@ -565,7 +361,8 @@ export class ConnextClient implements IConnextClient { public getLatestNodeSubmittedWithdrawal = async (): Promise< { retry: number; tx: CFCoreTypes.MinimalTransaction } | undefined > => { - const value = await this.channelRouter.get(withdrawalKey(this.publicIdentifier)); + const path = withdrawalKey(this.publicIdentifier); + const value = await this.channelProvider.send("chan_storeGet", { path }); if (!value || value === "undefined") { return undefined; @@ -596,9 +393,9 @@ export class ConnextClient implements IConnextClient { async (blockNumber: number): Promise => { const found = await this.checkForUserWithdrawal(blockNumber); if (found) { - await this.channelRouter.set([ - { path: withdrawalKey(this.publicIdentifier), value: undefined }, - ]); + await this.channelProvider.send("chan_storeSet", { + pairs: [{ path: withdrawalKey(this.publicIdentifier), value: undefined }], + }); this.ethProvider.removeAllListeners("block"); resolve(); } @@ -621,20 +418,11 @@ export class ConnextClient implements IConnextClient { // Restore State public restoreState = async (): Promise => { - if (!this.store || this.routerType === RpcType.ChannelProvider) { - throw new Error(`Cannot restore state with channel provider`); - } - this.channelRouter.reset(); const path = `${ConnextClientStorePrefix}/${this.publicIdentifier}/channel/${this.multisigAddress}`; let state; try { - // try to recover states from our given store's restore method - state = await this.channelRouter.restore(); - if (!state || !state.path) { - throw new Error(`No matching paths found in store backup's state`); - } + state = await this.channelProvider.send("chan_restoreState", { path }); this.log.info(`Found state to restore from store's backup: ${stringify(state.path)}`); - state = state.path; } catch (e) { state = await this.node.restoreState(this.publicIdentifier); if (!state) { @@ -642,7 +430,9 @@ export class ConnextClient implements IConnextClient { } this.log.info(`Found state to restore from node: ${stringify(state)}`); } - await this.channelRouter.set([{ path, value: state }]); + await this.channelProvider.send("chan_storeSet", { + pairs: [{ path, value: state }], + }); await this.restart(); }; @@ -663,8 +453,14 @@ export class ConnextClient implements IConnextClient { /////////////////////////////////// // PROVIDER/ROUTER METHODS + public getStateChannel = async (): Promise => { - return await this.channelRouter.getStateChannel(); + return await this.channelProvider.send( + CFCoreTypes.RpcMethodNames.chan_getStateChannel as CFCoreTypes.RpcMethodName, + { + multisigAddress: this.multisigAddress, + }, + ); }; public providerDeposit = async ( @@ -693,18 +489,25 @@ export class ConnextClient implements IConnextClient { this.log.error(err); throw new Error(err); } - - return await this.channelRouter.deposit( - amount, - assetId, - this.multisigAddress, - notifyCounterparty, + return await this.channelProvider.send( + CFCoreTypes.RpcMethodNames.chan_deposit as CFCoreTypes.RpcMethodName, + { + amount, + multisigAddress: this.multisigAddress, + notifyCounterparty, + tokenAddress: makeChecksum(assetId), + } as CFCoreTypes.DepositParams, ); }; public getAppInstances = async (multisigAddress?: string): Promise => { - // TODO - return (await this.channelRouter.getAppInstances(multisigAddress)).appInstances; + const { appInstances } = await this.channelProvider.send( + CFCoreTypes.RpcMethodNames.chan_getAppInstances as CFCoreTypes.RpcMethodName, + { + multisigAddress, + } as CFCoreTypes.GetAppInstancesParams, + ); + return appInstances; }; public getFreeBalance = async ( @@ -715,7 +518,13 @@ export class ConnextClient implements IConnextClient { } const normalizedAssetId = makeChecksum(assetId); try { - return await this.channelRouter.getFreeBalance(assetId, this.multisigAddress); + return await this.channelProvider.send( + CFCoreTypes.RpcMethodNames.chan_getFreeBalanceState as CFCoreTypes.RpcMethodName, + { + multisigAddress: this.multisigAddress, + tokenAddress: makeChecksum(assetId), + } as CFCoreTypes.GetFreeBalanceStateParams, + ); } catch (e) { const error = `No free balance exists for the specified token: ${normalizedAssetId}`; if (e.message.includes(error)) { @@ -735,13 +544,23 @@ export class ConnextClient implements IConnextClient { public getProposedAppInstances = async ( multisigAddress?: string, ): Promise => { - return await this.channelRouter.getProposedAppInstances(multisigAddress); + return await this.channelProvider.send( + CFCoreTypes.RpcMethodNames.chan_getProposedAppInstances as CFCoreTypes.RpcMethodName, + { + multisigAddress, + } as CFCoreTypes.GetProposedAppInstancesParams, + ); }; public getProposedAppInstance = async ( appInstanceId: string, ): Promise => { - return await this.channelRouter.getProposedAppInstance(appInstanceId); + return await this.channelProvider.send( + CFCoreTypes.RpcMethodNames.chan_getProposedAppInstances as CFCoreTypes.RpcMethodName, + { + appInstanceId, + } as CFCoreTypes.GetProposedAppInstanceParams, + ); }; public getAppInstanceDetails = async ( @@ -752,7 +571,12 @@ export class ConnextClient implements IConnextClient { this.log.warn(err); return undefined; } - return await this.channelRouter.getAppInstanceDetails(appInstanceId); + return await this.channelProvider.send( + CFCoreTypes.RpcMethodNames.chan_getAppInstance as CFCoreTypes.RpcMethodName, + { + appInstanceId, + } as CFCoreTypes.GetAppInstanceDetailsParams, + ); }; public getAppState = async ( @@ -764,7 +588,12 @@ export class ConnextClient implements IConnextClient { this.log.warn(err); return undefined; } - return await this.channelRouter.getAppState(appInstanceId); + return await this.channelProvider.send( + CFCoreTypes.RpcMethodNames.chan_getState as CFCoreTypes.RpcMethodName, + { + appInstanceId, + } as CFCoreTypes.GetStateParams, + ); }; public takeAction = async ( @@ -783,7 +612,13 @@ export class ConnextClient implements IConnextClient { if ((state.state as any).finalized) { throw new Error("Cannot take action on an app with a finalized state."); } - return await this.channelRouter.takeAction(appInstanceId, action); + return await this.channelProvider.send( + CFCoreTypes.RpcMethodNames.chan_takeAction as CFCoreTypes.RpcMethodName, + { + action, + appInstanceId, + } as CFCoreTypes.TakeActionParams, + ); }; public updateState = async ( @@ -803,13 +638,22 @@ export class ConnextClient implements IConnextClient { if ((state.state as any).finalized) { throw new Error("Cannot take action on an app with a finalized state."); } - return await this.channelRouter.updateState(appInstanceId, newState); + return await this.channelProvider.send( + CFCoreTypes.RpcMethodNames.chan_updateState as CFCoreTypes.RpcMethodName, + { + appInstanceId, + newState, + } as CFCoreTypes.UpdateStateParams, + ); }; public proposeInstallApp = async ( params: CFCoreTypes.ProposeInstallParams, ): Promise => { - return await this.channelRouter.proposeInstallApp(params); + return await this.channelProvider.send( + CFCoreTypes.RpcMethodNames.chan_proposeInstall as CFCoreTypes.RpcMethodName, + params as CFCoreTypes.ProposeInstallParams, + ); }; public installVirtualApp = async ( @@ -820,7 +664,13 @@ export class ConnextClient implements IConnextClient { if (alreadyInstalled) { throw new Error(alreadyInstalled); } - return await this.channelRouter.installVirtualApp(appInstanceId, this.nodePublicIdentifier); + return await this.channelProvider.send( + CFCoreTypes.RpcMethodNames.chan_installVirtual as CFCoreTypes.RpcMethodName, + { + appInstanceId, + intermediaryIdentifier: this.nodePublicIdentifier, + } as CFCoreTypes.InstallVirtualParams, + ); }; public installApp = async (appInstanceId: string): Promise => { @@ -829,7 +679,12 @@ export class ConnextClient implements IConnextClient { if (alreadyInstalled) { throw new Error(alreadyInstalled); } - return await this.channelRouter.installApp(appInstanceId); + return await this.channelProvider.send( + CFCoreTypes.RpcMethodNames.chan_install as CFCoreTypes.RpcMethodName, + { + appInstanceId, + } as CFCoreTypes.InstallParams, + ); }; public uninstallApp = async (appInstanceId: string): Promise => { @@ -839,7 +694,12 @@ export class ConnextClient implements IConnextClient { this.log.error(err); throw new Error(err); } - return await this.channelRouter.uninstallApp(appInstanceId); + return await this.channelProvider.send( + CFCoreTypes.RpcMethodNames.chan_uninstall as CFCoreTypes.RpcMethodName, + { + appInstanceId, + } as CFCoreTypes.UninstallParams, + ); }; public uninstallVirtualApp = async ( @@ -852,11 +712,22 @@ export class ConnextClient implements IConnextClient { throw new Error(err); } - return await this.channelRouter.uninstallVirtualApp(appInstanceId, this.nodePublicIdentifier); + return await this.channelProvider.send( + CFCoreTypes.RpcMethodNames.chan_uninstallVirtual as CFCoreTypes.RpcMethodName, + { + appInstanceId, + intermediaryIdentifier: this.nodePublicIdentifier, + } as CFCoreTypes.UninstallVirtualParams, + ); }; public rejectInstallApp = async (appInstanceId: string): Promise => { - return await this.channelRouter.rejectInstallApp(appInstanceId); + return await this.channelProvider.send( + CFCoreTypes.RpcMethodNames.chan_rejectInstall as CFCoreTypes.RpcMethodName, + { + appInstanceId, + }, + ); }; public providerWithdraw = async ( @@ -876,7 +747,15 @@ export class ConnextClient implements IConnextClient { throw new Error(err); } - return await this.channelRouter.withdraw(amount, assetId, recipient); + return await this.channelProvider.send( + CFCoreTypes.RpcMethodNames.chan_withdraw as CFCoreTypes.RpcMethodName, + { + amount, + multisigAddress: this.multisigAddress, + recipient, + tokenAddress: makeChecksum(assetId), + } as CFCoreTypes.WithdrawParams, + ); }; public withdrawCommitment = async ( @@ -895,10 +774,14 @@ export class ConnextClient implements IConnextClient { this.log.error(err); throw new Error(err); } - return await this.channelRouter.withdrawCommitment( - amount, - makeChecksumOrEthAddress(assetId), - recipient, + return await this.channelProvider.send( + CFCoreTypes.RpcMethodNames.chan_withdrawCommitment as CFCoreTypes.RpcMethodName, + { + amount, + multisigAddress: this.multisigAddress, + recipient, + tokenAddress: makeChecksumOrEthAddress(assetId), + } as CFCoreTypes.WithdrawCommitmentParams, ); }; @@ -906,13 +789,20 @@ export class ConnextClient implements IConnextClient { // NODE METHODS public verifyAppSequenceNumber = async (): Promise => { - const { data: sc } = await this.getStateChannel(); - const [appId, appJson] = sc.appInstances.reduce((prev, curr) => { - const [prevId, prevJson] = prev; - const [currId, currJson] = curr; - return currJson.appSeqNo > prevJson.appSeqNo ? curr : prev; + const { data: sc } = await this.channelProvider.send("chan_getStateChannel" as any, { + multisigAddress: this.multisigAddress, }); - return await this.node.verifyAppSequenceNumber(appJson.appSeqNo); + let appSequenceNumber: number; + try { + appSequenceNumber = (await sc.mostRecentlyInstalledAppInstance()).appSeqNo; + } catch (e) { + if (e.message.includes("There are no installed AppInstances in this StateChannel")) { + appSequenceNumber = 0; + } else { + throw e; + } + } + return await this.node.verifyAppSequenceNumber(appSequenceNumber); }; public reclaimPendingAsyncTransfers = async (): Promise => { @@ -1046,6 +936,7 @@ export class ConnextClient implements IConnextClient { }; public uninstallCoinBalanceIfNeeded = async (assetId: string = AddressZero): Promise => { + // check if there is a coin refund app installed const coinRefund = await this.getBalanceRefundApp(assetId); if (!coinRefund) { this.log.debug("No coin balance refund app found"); @@ -1114,7 +1005,8 @@ export class ConnextClient implements IConnextClient { }; public resubmitActiveWithdrawal = async (): Promise => { - const withdrawal = await this.channelRouter.get(withdrawalKey(this.publicIdentifier)); + const path = withdrawalKey(this.publicIdentifier); + const withdrawal = await this.channelProvider.send("chan_storeGet", { path }); if (!withdrawal || withdrawal === "undefined") { // No active withdrawal, nothing to do @@ -1138,12 +1030,14 @@ export class ConnextClient implements IConnextClient { if (this.matchTx(tx, withdrawal.tx)) { // the withdrawal in our store matches latest submitted tx, // clear value in store and return - await this.channelRouter.set([ - { - path: withdrawalKey(this.publicIdentifier), - value: undefined, - }, - ]); + await this.channelProvider.send("chan_storeSet", { + pairs: [ + { + path: withdrawalKey(this.publicIdentifier), + value: undefined, + }, + ], + }); return; } @@ -1163,12 +1057,14 @@ export class ConnextClient implements IConnextClient { let { retry } = val; const { tx } = val; retry += 1; - await this.channelRouter.set([ - { - path: withdrawalKey(this.publicIdentifier), - value: { tx, retry }, - }, - ]); + await this.channelProvider.send("chan_storeSet", { + pairs: [ + { + path: withdrawalKey(this.publicIdentifier), + value: { tx, retry }, + }, + ], + }); if (retry >= MAX_WITHDRAWAL_RETRIES) { const msg = `Tried to have node submit withdrawal ${MAX_WITHDRAWAL_RETRIES} times and it did not work, try submitting from wallet.`; this.log.error(msg); diff --git a/modules/client/src/controllers/AbstractController.ts b/modules/client/src/controllers/AbstractController.ts index 3ef2908e35..b84da465de 100644 --- a/modules/client/src/controllers/AbstractController.ts +++ b/modules/client/src/controllers/AbstractController.ts @@ -1,6 +1,6 @@ import { providers } from "ethers"; -import { ChannelRouter } from "../channelRouter"; +import { ChannelProvider } from "../channelProvider"; import { ConnextClient } from "../connext"; import { CFCore, Logger } from "../lib"; import { ConnextListener } from "../listener"; @@ -11,7 +11,7 @@ export abstract class AbstractController { public connext: ConnextClient; public log: Logger; public node: INodeApiClient; - public channelRouter: ChannelRouter; + public channelProvider: ChannelProvider; public listener: ConnextListener; public ethProvider: providers.JsonRpcProvider; @@ -19,7 +19,7 @@ export abstract class AbstractController { this.connext = connext; this.name = name; this.node = connext.node; - this.channelRouter = connext.channelRouter; + this.channelProvider = connext.channelProvider; this.listener = connext.listener; this.log = new Logger(name, connext.log.logLevel); this.ethProvider = connext.ethProvider; diff --git a/modules/client/src/controllers/DepositController.ts b/modules/client/src/controllers/DepositController.ts index 39ba532c60..fe741886eb 100644 --- a/modules/client/src/controllers/DepositController.ts +++ b/modules/client/src/controllers/DepositController.ts @@ -53,7 +53,7 @@ export class DepositController extends AbstractController { this.log.info("Registered!"); try { - this.log.info(`Calling ${CFCoreTypes.RpcMethodName.DEPOSIT}`); + this.log.info(`Calling ${CFCoreTypes.RpcMethodNames.chan_deposit}`); await this.connext.rescindDepositRights({ assetId }); // propose the app install const err = await this.proposeDepositInstall(assetId); diff --git a/modules/client/src/controllers/RequestDepositRightsController.ts b/modules/client/src/controllers/RequestDepositRightsController.ts index aafccd8887..1b116aa171 100644 --- a/modules/client/src/controllers/RequestDepositRightsController.ts +++ b/modules/client/src/controllers/RequestDepositRightsController.ts @@ -56,15 +56,18 @@ export class RequestDepositRightsController extends AbstractController { await this.connext.rescindDepositRights({ assetId }); this.log.info(`Balance refund app uninstalled`); } - // propose the app install this.log.info(`Installing balance refund app for ${assetId}`); const err = await this.proposeDepositInstall(assetId); if (err) { throw new Error(err); } - const requestDepositRightsResponse = await this.connext.channelRouter.requestDepositRights( - assetId, + const requestDepositRightsResponse = await this.channelProvider.send( + CFCoreTypes.RpcMethodNames.chan_requestDepositRights as CFCoreTypes.RpcMethodName, + { + multisigAddress: this.channelProvider.multisigAddress, + tokenAddress: assetId, + } as CFCoreTypes.RequestDepositRightsParams, ); this.log.info( `requestDepositRightsResponse Response: ${stringify(requestDepositRightsResponse)}`, @@ -129,23 +132,25 @@ export class RequestDepositRightsController extends AbstractController { let appId: string; try { await Promise.race([ - new Promise(async (res: any, rej: any) => { - boundReject = this.rejectInstallCoinBalance.bind(null, rej); - this.log.info( - `subscribing to indra.node.${this.connext.nodePublicIdentifier}.proposalAccepted.${this.connext.multisigAddress}`, - ); - await this.connext.messaging.subscribe( - `indra.node.${this.connext.nodePublicIdentifier}.proposalAccepted.${this.connext.multisigAddress}`, - res, - ); - const { appInstanceId } = await this.connext.proposeInstallApp(params); - appId = appInstanceId; - this.log.info(`waiting for proposal acceptance of ${appInstanceId}`); - this.listener.on( - CFCoreTypes.EventNames.REJECT_INSTALL_EVENT as CFCoreTypes.EventName, - boundReject, - ); - }), + new Promise( + async (res: any, rej: any): Promise => { + boundReject = this.rejectInstallCoinBalance.bind(null, rej); + this.log.info( + `subscribing to indra.node.${this.connext.nodePublicIdentifier}.proposalAccepted.${this.connext.multisigAddress}`, + ); + await this.connext.messaging.subscribe( + `indra.node.${this.connext.nodePublicIdentifier}.proposalAccepted.${this.connext.multisigAddress}`, + res, + ); + const { appInstanceId } = await this.connext.proposeInstallApp(params); + appId = appInstanceId; + this.log.info(`waiting for proposal acceptance of ${appInstanceId}`); + this.listener.on( + CFCoreTypes.EventNames.REJECT_INSTALL_EVENT as CFCoreTypes.EventName, + boundReject, + ); + }, + ), delayAndThrow( CF_METHOD_TIMEOUT, `App install took longer than ${CF_METHOD_TIMEOUT / 1000} seconds`, diff --git a/modules/client/src/controllers/SwapController.ts b/modules/client/src/controllers/SwapController.ts index 1384e8c224..8ebdadd690 100644 --- a/modules/client/src/controllers/SwapController.ts +++ b/modules/client/src/controllers/SwapController.ts @@ -178,7 +178,7 @@ export class SwapController extends AbstractController { const res = await this.connext.proposeInstallApp(params); // set app instance id - this.log.warn(`Successfully proposed appId: ${res.appInstanceId}`); + this.log.debug(`Successfully proposed appId: ${res.appInstanceId}`); await Promise.race([ new Promise((resolve: (value?: unknown) => void, reject: (value?: string) => void): void => { diff --git a/modules/client/src/controllers/WithdrawalController.ts b/modules/client/src/controllers/WithdrawalController.ts index cb664e4317..061321cef0 100644 --- a/modules/client/src/controllers/WithdrawalController.ts +++ b/modules/client/src/controllers/WithdrawalController.ts @@ -1,5 +1,5 @@ import { TransactionResponse } from "ethers/providers"; -import { getAddress } from "ethers/utils"; +import { getAddress, bigNumberify } from "ethers/utils"; import { stringify, withdrawalKey } from "../lib"; import { BigNumber, CFCoreTypes, convert, WithdrawalResponse, WithdrawParameters } from "../types"; @@ -37,17 +37,16 @@ export class WithdrawalController extends AbstractController { this.log.info(`Calling this.connext.rescindDepositRights before withdrawal for ${assetId}`); await this.connext.rescindDepositRights({ assetId }); if (!userSubmitted) { - this.log.info(`Calling ${CFCoreTypes.RpcMethodName.WITHDRAW_COMMITMENT}`); + this.log.info(`Calling ${CFCoreTypes.RpcMethodNames.chan_withdrawCommitment}`); const withdrawResponse = await this.connext.withdrawCommitment(amount, assetId, recipient); this.log.info(`Withdraw Response: ${stringify(withdrawResponse)}`); const minTx: CFCoreTypes.MinimalTransaction = withdrawResponse.transaction; // set the withdrawal tx in the store - await this.connext.store.set([ - { - path: withdrawalKey(this.connext.publicIdentifier), - value: { tx: minTx, retry: 0 }, - }, - ]); + await this.connext.channelProvider.send("chan_storeSet", { + pairs: [ + { path: withdrawalKey(this.connext.publicIdentifier), value: { tx: minTx, retry: 0 } }, + ], + }); transaction = await this.node.withdraw(minTx); @@ -55,7 +54,7 @@ export class WithdrawalController extends AbstractController { this.log.info(`Node Withdraw Response: ${stringify(transaction)}`); } else { - this.log.info(`Calling ${CFCoreTypes.RpcMethodName.WITHDRAW}`); + this.log.info(`Calling ${CFCoreTypes.RpcMethodNames.chan_withdraw}`); // user submitting the withdrawal const withdrawResponse = await this.connext.providerWithdraw( assetId, @@ -67,7 +66,8 @@ export class WithdrawalController extends AbstractController { } const postWithdrawBalances = await this.connext.getFreeBalance(assetId); - const expectedFreeBal = preWithdrawBalances[myFreeBalanceAddress].sub(amount); + this.log.info(`Pre-Withdraw Balances: ${stringify(preWithdrawBalances)}`); + const expectedFreeBal = bigNumberify(preWithdrawBalances[myFreeBalanceAddress]).sub(amount); // sanity check the free balance decrease if (postWithdrawBalances && !postWithdrawBalances[myFreeBalanceAddress].eq(expectedFreeBal)) { diff --git a/modules/client/src/index.ts b/modules/client/src/index.ts index 4d367b01b3..de04b9f7b0 100644 --- a/modules/client/src/index.ts +++ b/modules/client/src/index.ts @@ -1,4 +1,5 @@ -import { connect, ConnextClient } from "./connext"; +import { connect } from "./connect"; +import { ConnextClient } from "./connext"; import * as utils from "./lib"; export { ConnextClient, connect, utils }; diff --git a/modules/client/src/lib/cfCore.ts b/modules/client/src/lib/cfCore.ts index 69f32c776d..0ca9a0463d 100644 --- a/modules/client/src/lib/cfCore.ts +++ b/modules/client/src/lib/cfCore.ts @@ -1,4 +1,6 @@ export { + bigNumberifyJson, + deBigNumberifyJson, Node as CFCore, sortAddresses, xkeyKthAddress as xpubToAddress, diff --git a/modules/client/src/listener.ts b/modules/client/src/listener.ts index 89834f0581..96340e9c89 100644 --- a/modules/client/src/listener.ts +++ b/modules/client/src/listener.ts @@ -1,7 +1,7 @@ import { bigNumberify } from "ethers/utils"; import { EventEmitter } from "events"; -import { ChannelRouter } from "./channelRouter"; +import { ChannelProvider } from "./channelProvider"; import { ConnextClient } from "./connext"; import { Logger, stringify } from "./lib"; import { @@ -34,7 +34,7 @@ type CallbackStruct = { export class ConnextListener extends EventEmitter { private log: Logger; - private channelRouter: ChannelRouter; + private channelProvider: ChannelProvider; private connext: ConnextClient; // TODO: add custom parsing functions here to convert event data @@ -132,9 +132,9 @@ export class ConnextListener extends EventEmitter { }, }; - constructor(channelRouter: ChannelRouter, connext: ConnextClient) { + constructor(channelProvider: ChannelProvider, connext: ConnextClient) { super(); - this.channelRouter = channelRouter; + this.channelProvider = channelProvider; this.connext = connext; this.log = new Logger("ConnextListener", connext.log.logLevel); } @@ -149,7 +149,7 @@ export class ConnextListener extends EventEmitter { public registerCfListener = (event: CFCoreTypes.EventName, cb: Function): void => { // replace with new fn this.log.debug(`Registering listener for ${event}`); - this.channelRouter.on( + this.channelProvider.on( event, async (res: any): Promise => { await cb(res); @@ -173,11 +173,11 @@ export class ConnextListener extends EventEmitter { public registerDefaultListeners = (): void => { Object.entries(this.defaultCallbacks).forEach(([event, callback]: any): any => { - this.channelRouter.on(CFCoreTypes.EventNames[event], callback); + this.channelProvider.on(CFCoreTypes.EventNames[event], callback); }); - this.channelRouter.on( - CFCoreTypes.RpcMethodName.INSTALL, + this.channelProvider.on( + CFCoreTypes.RpcMethodNames.chan_install as CFCoreTypes.RpcMethodName, async (msg: any): Promise => { const { result: { @@ -191,14 +191,19 @@ export class ConnextListener extends EventEmitter { }, ); - this.channelRouter.on(CFCoreTypes.RpcMethodName.UNINSTALL, (data: any): any => { - const result = data.result.result; - this.log.debug(`Emitting CFCoreTypes.RpcMethodName.UNINSTALL event: ${stringify(result)}`); - this.connext.messaging.publish( - `indra.client.${this.connext.publicIdentifier}.uninstall.${result.appInstanceId}`, - stringify(result), - ); - }); + this.channelProvider.on( + CFCoreTypes.RpcMethodNames.chan_uninstall as CFCoreTypes.RpcMethodName, + (data: any): any => { + const result = data.result.result; + this.log.debug( + `Emitting CFCoreTypes.RpcMethodNames.chan_uninstall event: ${stringify(result)}`, + ); + this.connext.messaging.publish( + `indra.client.${this.connext.publicIdentifier}.uninstall.${result.appInstanceId}`, + stringify(result), + ); + }, + ); }; private emitAndLog = (event: CFCoreTypes.EventName, data: any): void => { diff --git a/modules/client/src/node.ts b/modules/client/src/node.ts index 97c4676d8a..8c3358f3f4 100644 --- a/modules/client/src/node.ts +++ b/modules/client/src/node.ts @@ -3,12 +3,13 @@ import { TransactionResponse } from "ethers/providers"; import { Transaction } from "ethers/utils"; import uuid = require("uuid"); -import { ChannelRouter } from "./channelRouter"; +import { ChannelProvider } from "./channelProvider"; import { Logger, NATS_ATTEMPTS, NATS_TIMEOUT, stringify } from "./lib"; import { AppRegistry, CFCoreTypes, ChannelAppSequences, + ConnextRpcMethod, CreateChannelResponse, GetChannelResponse, GetConfigResponse, @@ -63,46 +64,42 @@ export class NodeApiClient implements INodeApiClient { public latestSwapRates: { [key: string]: string } = {}; public log: Logger; - private innerUserPublicIdentifier: string | undefined; - private innerNodePublicIdentifier: string | undefined; - private innerChannelRouter: ChannelRouter | undefined; - private token: Promise | undefined; + private _userPublicIdentifier: string | undefined; // tslint:disable-line:variable-name + private _nodePublicIdentifier: string | undefined; // tslint:disable-line:variable-name + private _channelProvider: ChannelProvider | undefined; // tslint:disable-line:variable-name constructor(opts: NodeInitializationParameters) { this.messaging = opts.messaging; this.log = new Logger("NodeApiClient", opts.logLevel); - this.innerUserPublicIdentifier = opts.userPublicIdentifier; - this.innerNodePublicIdentifier = opts.nodePublicIdentifier; - this.innerChannelRouter = opts.channelRouter; - if (this.channelRouter) { - this.token = this.getAuthToken(); - } + this._userPublicIdentifier = opts.userPublicIdentifier; + this._nodePublicIdentifier = opts.nodePublicIdentifier; + this._channelProvider = opts.channelProvider; } //////////////////////////////////////// // GETTERS/SETTERS - get channelRouter(): ChannelRouter | undefined { - return this.innerChannelRouter; + get channelProvider(): ChannelProvider | undefined { + return this._channelProvider; } - set channelRouter(channelRouter: ChannelRouter) { - this.innerChannelRouter = channelRouter; + set channelProvider(channelProvider: ChannelProvider) { + this._channelProvider = channelProvider; } get userPublicIdentifier(): string | undefined { - return this.innerUserPublicIdentifier; + return this._userPublicIdentifier; } set userPublicIdentifier(userXpub: string) { - this.innerUserPublicIdentifier = userXpub; + this._userPublicIdentifier = userXpub; } get nodePublicIdentifier(): string | undefined { - return this.innerNodePublicIdentifier; + return this._nodePublicIdentifier; } set nodePublicIdentifier(nodeXpub: string) { - this.innerNodePublicIdentifier = nodeXpub; + this._nodePublicIdentifier = nodeXpub; } //////////////////////////////////////// @@ -277,27 +274,20 @@ export class NodeApiClient implements INodeApiClient { // PRIVATE private async getAuthToken(): Promise { - return new Promise( - async (resolve: any, reject: any): Promise => { - const nonce = await this.send("auth.getNonce", { - address: this.channelRouter.signerAddress, - }); - const sig = await this.channelRouter.signMessage(nonce); - const token = `${nonce}:${sig}`; - return resolve(token); - }, - ); - } - - private assertAuthToken(): void { - if (!this.channelRouter) { + if (!this.channelProvider) { throw new Error( - `Must have instantiated a channel router (ie a signing thing) before setting auth token`, + `Must have instantiated a channel provider (ie a signing thing) before setting auth token`, ); } - if (!this.token) { - this.token = this.getAuthToken(); - } + // TODO: merge: + // https://github.com/WalletConnect/walletconnect-monorepo/pull/210 + // and publish / update package + const nonce = await this.send("auth.getNonce", { + address: this.channelProvider.signerAddress, + }); + const sig = await this.channelProvider.send("chan_nodeAuth", { message: nonce }); + const token = `${nonce}:${sig}`; + return token; } private async send(subject: string, data?: any): Promise { @@ -334,8 +324,7 @@ export class NodeApiClient implements INodeApiClient { id: uuid.v4(), }; if (guardedSubjects.includes(subject.split(".")[0])) { - this.assertAuthToken(); - payload.token = await this.token; + payload.token = await this.getAuthToken(); } let msg; try { @@ -346,8 +335,7 @@ export class NodeApiClient implements INodeApiClient { let error = msg ? (msg.data ? (msg.data.response ? msg.data.response.err : "") : "") : ""; if (error && error.startsWith("Invalid token")) { this.log.info(`Auth error, token might have expired. Let's get a fresh token & try again.`); - this.token = this.getAuthToken(); - payload.token = await this.token; + payload.token = await this.getAuthToken(); msg = await this.messaging.request(subject, NATS_TIMEOUT, payload); error = msg ? (msg.data ? (msg.data.response ? msg.data.response.err : "") : "") : ""; } diff --git a/modules/client/src/types.ts b/modules/client/src/types.ts index 020ea44ada..6e0287298d 100644 --- a/modules/client/src/types.ts +++ b/modules/client/src/types.ts @@ -2,7 +2,6 @@ import { IMessagingService } from "@connext/messaging"; import { AppRegistry, BigNumber as connextBN, - ChannelProvider, ClientOptions, GetConfigResponse, Store, @@ -10,7 +9,7 @@ import { import { Contract, providers } from "ethers"; import { Network } from "ethers/utils"; -import { ChannelRouter } from "./channelRouter"; +import { ChannelProvider } from "./channelProvider"; import { NodeApiClient } from "./node"; export { @@ -42,8 +41,12 @@ export { AppRegistry, AppStateBigNumber, CFCoreChannel, + CFChannelProviderOptions, ChannelAppSequences, + ChannelProvider, ChannelProviderConfig, + ChannelProviderRpcMethod, + ChannelProviderRpcMethods, ChannelState, CheckDepositRightsParameters, CheckDepositRightsResponse, @@ -56,6 +59,7 @@ export { ConnextClientStorePrefix, ConnextEvent, ConnextEvents, + ConnextRpcMethod, convert, CreateChannelResponse, DefaultApp, @@ -63,13 +67,14 @@ export { GetChannelResponse, GetConfigResponse, IConnextClient, + KeyGen, LinkedTransferParameters, LinkedTransferResponse, LinkedTransferToRecipientParameters, LinkedTransferToRecipientResponse, makeChecksum, makeChecksumOrEthAddress, - Node as CFCoreTypes, + CFCoreTypes, PaymentProfile, RequestCollateralResponse, ResolveConditionParameters, @@ -81,7 +86,6 @@ export { RescindDepositRightsParameters, RescindDepositRightsResponse, RpcConnection, - RpcType, SimpleLinkedTransferAppState, SimpleLinkedTransferAppStateBigNumber, SimpleSwapAppState, @@ -90,6 +94,7 @@ export { SimpleTransferAppStateBigNumber, StateChannelJSON, Store, + StorePair, SupportedApplication, SupportedApplications, SupportedNetwork, @@ -106,16 +111,14 @@ export const BigNumber = connextBN; export type InternalClientOptions = ClientOptions & { appRegistry: AppRegistry; - channelRouter: ChannelRouter; - channelProvider?: ChannelProvider; + channelProvider: ChannelProvider; config: GetConfigResponse; ethProvider: providers.JsonRpcProvider; messaging: IMessagingService; - multisigAddress: string; network: Network; node: NodeApiClient; - token: Contract; store: Store; + token: Contract; }; export interface NodeInitializationParameters { @@ -123,5 +126,5 @@ export interface NodeInitializationParameters { logLevel?: number; userPublicIdentifier?: string; nodePublicIdentifier?: string; - channelRouter?: ChannelRouter; + channelProvider?: ChannelProvider; } diff --git a/modules/daicard/package-lock.json b/modules/daicard/package-lock.json new file mode 100644 index 0000000000..b92e7575a7 --- /dev/null +++ b/modules/daicard/package-lock.json @@ -0,0 +1,128 @@ +{ + "name": "daicard", + "version": "0.2.4", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@connext/types": { + "version": "1.3.10", + "resolved": "https://registry.npmjs.org/@connext/types/-/types-1.3.10.tgz", + "integrity": "sha512-OwYyxu4K94jFYnnyfPksu2scDIvejM42uaWocdWN8eycJ9k09D4yXIWGVn0maid4Es5d+6FeXucQ+0Saz47s9A==", + "requires": { + "@connext/cf-types": "1.3.10", + "ethers": "4.0.40" + }, + "dependencies": { + "@connext/cf-types": { + "version": "1.3.10", + "resolved": "https://registry.npmjs.org/@connext/cf-types/-/cf-types-1.3.10.tgz", + "integrity": "sha512-LEJE0chH6cDrlox2HzNw/Q2G3j1VAzK0r9yic8KG/nwyfqYoriCQ4dpZnMey+ly0Daf/rf+ZEIFOr1BPHqk3IA==" + }, + "aes-js": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.0.0.tgz", + "integrity": "sha1-4h3xCtbCBTKVvLuNq0Cwnb6ofk0=" + }, + "bn.js": { + "version": "4.11.8", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", + "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==" + }, + "brorand": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", + "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=" + }, + "elliptic": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.2.tgz", + "integrity": "sha512-f4x70okzZbIQl/NSRLkI/+tteV/9WqL98zx+SQ69KbXxmVrmjwsNUPn/gYJJ0sHvEak24cZgHIPegRePAtA/xw==", + "requires": { + "bn.js": "^4.4.0", + "brorand": "^1.0.1", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.0", + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.0" + } + }, + "ethers": { + "version": "4.0.40", + "resolved": "https://registry.npmjs.org/ethers/-/ethers-4.0.40.tgz", + "integrity": "sha512-MC9BtV7Hpq4dgFONEfanx9aU9GhhoWU270F+/wegHZXA7FR+2KXFdt36YIQYLmVY5ykUWswDxd+f9EVkIa7JOA==", + "requires": { + "aes-js": "3.0.0", + "bn.js": "^4.4.0", + "elliptic": "6.5.2", + "hash.js": "1.1.3", + "js-sha3": "0.5.7", + "scrypt-js": "2.0.4", + "setimmediate": "1.0.4", + "uuid": "2.0.1", + "xmlhttprequest": "1.8.0" + } + }, + "hash.js": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.3.tgz", + "integrity": "sha512-/UETyP0W22QILqS+6HowevwhEFJ3MBJnwTf75Qob9Wz9t0DPuisL8kW8YZMK62dHAKE1c1p+gY1TtOLY+USEHA==", + "requires": { + "inherits": "^2.0.3", + "minimalistic-assert": "^1.0.0" + } + }, + "hmac-drbg": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", + "integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=", + "requires": { + "hash.js": "^1.0.3", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "js-sha3": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.7.tgz", + "integrity": "sha1-DU/9gALVMzqrr0oj7tL2N0yfKOc=" + }, + "minimalistic-assert": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", + "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==" + }, + "minimalistic-crypto-utils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", + "integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=" + }, + "scrypt-js": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/scrypt-js/-/scrypt-js-2.0.4.tgz", + "integrity": "sha512-4KsaGcPnuhtCZQCxFxN3GVYIhKFPTdLd8PLC552XwbMndtD0cjRFAhDuuydXQ0h08ZfPgzqe6EKHozpuH74iDw==" + }, + "setimmediate": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.4.tgz", + "integrity": "sha1-IOgd5iLUoCWIzgyNqJc8vPHTE48=" + }, + "uuid": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.1.tgz", + "integrity": "sha1-wqMN7bPlNdcsz4LjQ5QaULqFM6w=" + }, + "xmlhttprequest": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz", + "integrity": "sha1-Z/4HXFwk/vOfnWX197f+dRcZaPw=" + } + } + } + } +} diff --git a/modules/daicard/package.json b/modules/daicard/package.json index b3e194574e..b97276e41c 100644 --- a/modules/daicard/package.json +++ b/modules/daicard/package.json @@ -1,53 +1,53 @@ { - "name": "daicard", - "version": "0.2.4", - "private": true, - "scripts": { - "start": "react-scripts start", - "test": "make test", - "start-test": "make start-test", - "build": "react-scripts build", - "eject": "react-scripts eject", + "name": "daicard", + "version": "0.2.4", + "private": true, + "scripts": { + "start": "react-scripts start", + "test": "make test", + "start-test": "make start-test", + "build": "react-scripts build", + "eject": "react-scripts eject", "logs": "bash ops/logs.sh", "format": "prettier --write \"src/**/*.js\"" - }, - "dependencies": { - "@connext/client": "1.3.14", - "@connext/types": "1.3.14", - "@material-ui/core": "4.7.1", - "@material-ui/icons": "4.5.1", - "@walletconnect/browser": "1.0.0-beta.39", - "@walletconnect/channel-provider": "1.0.0-beta.39", - "@xstate/react": "0.8.1", - "browserslist": "4.8.0", - "classnames": "2.2.6", - "connext": "4.2.5", - "ethereum-blockies-png": "0.1.3", - "ethers": "4.0.40", - "interval-promise": "1.3.0", - "mdi-material-ui": "6.9.0", - "openzeppelin-solidity": "2.3.0", - "pisa-client": "0.1.4-connext-beta.1", - "prop-types": "15.7.2", - "qrcode.react": "1.0.0", - "query-string": "6.9.0", - "react": "16.12.0", - "react-copy-to-clipboard": "5.0.2", - "react-dom": "16.12.0", - "react-qr-reader": "2.2.1", - "react-router-dom": "5.1.2", - "react-scripts": "3.2.0", - "xstate": "4.7.2" - }, - "devDependencies": { - "@connext/types": "1.3.14", - "bn.js": "5.0.0", - "chai-bn": "0.2.0" - }, - "browserslist": [ - ">0.2%", - "not dead", - "not ie <= 11", - "not op_mini all" - ] + }, + "dependencies": { + "@connext/client": "1.4.1", + "@connext/types": "1.4.1", + "@material-ui/core": "4.7.1", + "@material-ui/icons": "4.5.1", + "@walletconnect/browser": "1.0.0-beta.41", + "@walletconnect/channel-provider": "1.0.0-beta.41", + "@xstate/react": "0.8.1", + "browserslist": "4.8.0", + "classnames": "2.2.6", + "connext": "4.2.5", + "ethereum-blockies-png": "0.1.3", + "ethers": "4.0.40", + "interval-promise": "1.3.0", + "mdi-material-ui": "6.9.0", + "openzeppelin-solidity": "2.3.0", + "pisa-client": "0.1.4-connext-beta.1", + "prop-types": "15.7.2", + "qrcode.react": "1.0.0", + "query-string": "6.9.0", + "react": "16.12.0", + "react-copy-to-clipboard": "5.0.2", + "react-dom": "16.12.0", + "react-qr-reader": "2.2.1", + "react-router-dom": "5.1.2", + "react-scripts": "3.2.0", + "xstate": "4.7.2" + }, + "devDependencies": { + "@connext/types": "1.4.1", + "bn.js": "5.0.0", + "chai-bn": "0.2.0" + }, + "browserslist": [ + ">0.2%", + "not dead", + "not ie <= 11", + "not op_mini all" + ] } diff --git a/modules/daicard/src/App.js b/modules/daicard/src/App.js index 66588544f3..9bfaf47099 100644 --- a/modules/daicard/src/App.js +++ b/modules/daicard/src/App.js @@ -1,5 +1,6 @@ import * as connext from "@connext/client"; import { CF_PATH, ConnextClientStorePrefix } from "@connext/types"; +import WalletConnectChannelProvider from "@walletconnect/channel-provider"; import { Paper, withStyles, Grid } from "@material-ui/core"; import { Contract, ethers as eth } from "ethers"; import { AddressZero, Zero } from "ethers/constants"; @@ -10,7 +11,6 @@ import { PisaClient } from "pisa-client"; import React from "react"; import { BrowserRouter as Router, Route } from "react-router-dom"; import tokenArtifacts from "openzeppelin-solidity/build/contracts/ERC20Mintable.json"; -import WalletConnectChannelProvider from "@walletconnect/channel-provider"; import { interpret } from "xstate"; import "./App.css"; @@ -62,6 +62,9 @@ const urls = { : undefined, }; +// LogLevel for testing ChannelProvider +const LOG_LEVEL = 5; + // Constants for channel max/min - this is also enforced on the hub const WITHDRAW_ESTIMATED_GAS = toBN("300000"); const DEPOSIT_ESTIMATED_GAS = toBN("25000"); @@ -153,11 +156,11 @@ class App extends React.Component { // ************************************************* // setWalletConnext = useWalletConnext => { - if (useWalletConnext) { - localStorage.setItem("useWalletConnext", true); - } else { - localStorage.setItem("useWalletConnext", false); - } + // clear any pre-existing sessions + localStorage.removeItem("wcUri") + localStorage.removeItem("walletconnect") + // set wallet connext + localStorage.setItem("useWalletConnext", !!useWalletConnext) this.setState({ useWalletConnext }); window.location.reload(); }; @@ -168,7 +171,7 @@ class App extends React.Component { return wc === "true"; }; - initWalletConnext = () => { + initWalletConnext = chainId => { // item set when you scan a wallet connect QR // if a wc qr code has been scanned before, make // sure to init the mapping and create new wc @@ -177,7 +180,7 @@ class App extends React.Component { const { channel } = this.state; if (!channel) return; if (!uri) return; - initWalletConnect(uri, channel); + initWalletConnect(uri, channel, chainId); }; // Channel doesn't get set up until after provider is set @@ -241,7 +244,7 @@ class App extends React.Component { // If store has double prefixes, flush and restore for (const k of Object.keys(localStorage)) { if (k.includes(`${ConnextClientStorePrefix}:${ConnextClientStorePrefix}/`)) { - store && await store.reset(); + store && (await store.reset()); window.location.reload(); } } @@ -255,7 +258,7 @@ class App extends React.Component { channel = await connext.connect({ ethProviderUrl: urls.ethProviderUrl, keyGen, - logLevel: 5, + logLevel: LOG_LEVEL, nodeUrl: urls.nodeUrl, store, xpub, @@ -268,13 +271,12 @@ class App extends React.Component { })`, ); } else if (useWalletConnext) { - let rpc = {}; - rpc[network.chainId] = urls.ethProviderUrl; - const channelProvider = new WalletConnectChannelProvider({ - rpc, - chainId: network.chainId, - }); + const channelProvider = new WalletConnectChannelProvider(); console.log(`Using WalletConnect with provider: ${JSON.stringify(channelProvider, null, 2)}`); + await channelProvider.enable(); + console.log( + `ChannelProvider Enabled - config: ${JSON.stringify(channelProvider.config, null, 2)}`, + ); // register channel provider listener for logging channelProvider.on("error", data => { console.error(`Channel provider error: ${JSON.stringify(data, null, 2)}`); @@ -287,7 +289,7 @@ class App extends React.Component { }); channel = await connext.connect({ ethProviderUrl: urls.ethProviderUrl, - logLevel: 4, + logLevel: LOG_LEVEL, channelProvider, }); } else { @@ -307,7 +309,7 @@ class App extends React.Component { console.log(`Client created successfully!`); console.log(` - Public Identifier: ${channel.publicIdentifier}`); - console.log(` - Account multisig address: ${channel.opts.multisigAddress}`); + console.log(` - Account multisig address: ${channel.multisigAddress}`); console.log(` - CF Account address: ${channel.signerAddress}`); console.log(` - Free balance address: ${channel.freeBalanceAddress}`); console.log(` - Token address: ${token.address}`); @@ -356,7 +358,7 @@ class App extends React.Component { } else { machine.send("READY"); } - this.initWalletConnext(); + this.initWalletConnext(network.chainId); await this.startPoller(); } @@ -511,7 +513,7 @@ class App extends React.Component { assetId: token.address.toLowerCase(), }; console.log( - `Depositing ${depositParams.amount} tokens into channel: ${channel.opts.multisigAddress}`, + `Depositing ${depositParams.amount} tokens into channel: ${channel.multisigAddress}`, ); const result = await channel.deposit(depositParams); await this.refreshBalances(); @@ -538,7 +540,7 @@ class App extends React.Component { } const amount = minBN([balance.onChain.ether.wad.sub(minDeposit.wad), nowMaxDeposit]); - console.log(`Depositing ${amount} wei into channel: ${channel.opts.multisigAddress}`); + console.log(`Depositing ${amount} wei into channel: ${channel.multisigAddress}`); const result = await channel.deposit({ amount: amount.toString() }); await this.refreshBalances(); console.log(`Successfully deposited ether! Result: ${JSON.stringify(result, null, 2)}`); @@ -762,11 +764,7 @@ class App extends React.Component { ( - + )} /> )} /> - ( - - )} - /> - + } /> + @@ -807,4 +792,4 @@ class App extends React.Component { } } -export default style(App); \ No newline at end of file +export default style(App); diff --git a/modules/daicard/src/utils/clientWalletConnectMapping.js b/modules/daicard/src/utils/clientWalletConnectMapping.js index 7382319105..27dde56c42 100644 --- a/modules/daicard/src/utils/clientWalletConnectMapping.js +++ b/modules/daicard/src/utils/clientWalletConnectMapping.js @@ -1,20 +1,19 @@ -import { CFCoreTypes } from "@connext/types"; import WalletConnectBrowser from "@walletconnect/browser"; export let walletConnector = null; -export function initWalletConnect(uri, client) { +export function initWalletConnect(uri, client, chainId) { walletConnector = new WalletConnectBrowser({ uri }); - registerWalletConnectListeners(client) + registerWalletConnectListeners(client, chainId); } -export function registerWalletConnectListeners(client) { +export function registerWalletConnectListeners(client, chainId) { walletConnector.on("session_request", (error, payload) => { if (error) { throw error; } - displaySessionApproval(payload.params[0]); + displaySessionApproval(payload.params[0], chainId); }); // Subscribe to call requests @@ -44,140 +43,55 @@ export function cleanWalletConnect() { // Delete walletConnector walletConnector = null; // delete url - localStorage.removeItem(`wcUri`) + localStorage.removeItem(`wcUri`); } -export function displaySessionApproval(payload) { - verifyFields(payload, ["chainId"]); - walletConnector.approveSession({ accounts: [], chainId: payload.chainId }); +export function displaySessionApproval(session, chainId) { //TODO: proc modal that approves the walletconnection from the wallet -} - -function verifyFields(params, keys) { - if (keys.length <= 0 || keys.filter(k => typeof k !== "string").length !== 0) { - throw new Error(`[verifyFields] Must provide an array of fields to check`); - } - if (typeof params !== "object") { - throw new Error(`[verifyFields] Must provide a params object`); - } - - const naStr = keys.filter(k => !!!params[k]); - if (naStr.length !== 0) { - throw new Error( - `[verifyFields] Params missing needed keys. Params: ${prettyPrint( - params, - )}, keys: ${prettyPrint(keys)}`, - ); - } - return; + walletConnector.approveSession({ accounts: [], chainId }); } function prettyPrint(obj) { return JSON.stringify(obj, null, 2); } -async function mapPayloadToClient(payload, channel) { +function verifyPayload(payload) { const { params, id, method } = payload; + if (!params || typeof params !== "object") { - throw new Error(`Invalid payload params. Payload: ${prettyPrint(payload)}`); + throw new Error( + `WalletConnect Error - invalid payload params. Payload: ${prettyPrint(payload)}`, + ); } - if (!id) { - throw new Error(`Invalid payload id. Payload: ${prettyPrint(payload)}`); + if (!id || typeof id !== "number") { + throw new Error(`WalletConnect Error - invalid payload id. Payload: ${prettyPrint(payload)}`); } if (!method || typeof method !== "string") { - throw new Error(`Invalid payload method. Payload: ${prettyPrint(payload)}`); + throw new Error( + `WalletConnect Error - invalid payload method. Payload: ${prettyPrint(payload)}`, + ); } - let result; + return; +} + +async function mapPayloadToClient(payload, channel) { try { - switch (method) { - case "chan_store_set": - verifyFields(params, ["pairs"]); - const { pairs } = params; - result = await channel.channelRouter.set(pairs); - break; - - case "chan_store_get": - verifyFields(params, ["path"]); - const { path } = params; - result = await channel.channelRouter.get(path); - break; - - case "chan_node_auth": - verifyFields(params, ["message"]); - const { message } = params; - result = await channel.channelRouter.signMessage(message); - break; - - case "chan_config": - result = await channel.channelProviderConfig(params); - break; - - case CFCoreTypes.RpcMethodName.DEPOSIT: - result = await channel.providerDeposit(params); - break; - case CFCoreTypes.RpcMethodName.GET_STATE: - result = await channel.getState(params); - break; - case CFCoreTypes.RpcMethodName.GET_APP_INSTANCES: - result = await channel.getAppInstances(params); - break; - case CFCoreTypes.RpcMethodName.GET_FREE_BALANCE_STATE: - verifyFields(params, ["tokenAddress", "multisigAddress"]); - const { tokenAddress } = params; - result = await channel.getFreeBalance(tokenAddress); - break; - - case CFCoreTypes.RpcMethodName.GET_PROPOSED_APP_INSTANCES: - result = await channel.getProposedAppInstances(params); - break; - case CFCoreTypes.RpcMethodName.GET_APP_INSTANCE_DETAILS: - result = await channel.getAppInstanceDetails(params); - break; - case CFCoreTypes.RpcMethodName.TAKE_ACTION: - result = await channel.takeAction(params); - break; - case CFCoreTypes.RpcMethodName.UPDATE_STATE: - result = await channel.updateState(params); - break; - case CFCoreTypes.RpcMethodName.PROPOSE_INSTALL: - result = await channel.proposeInstallApp(params); - break; - case CFCoreTypes.RpcMethodName.INSTALL_VIRTUAL: - result = await channel.installVirtualApp(params); - break; - case CFCoreTypes.RpcMethodName.INSTALL: - result = await channel.installApp(params); - break; - case CFCoreTypes.RpcMethodName.UNINSTALL: - result = await channel.uninstallApp(params); - break; - case CFCoreTypes.RpcMethodName.UNINSTALL_VIRTUAL: - result = await channel.uninstallVirtualApp(params); - break; - case CFCoreTypes.RpcMethodName.REJECT_INSTALL: - result = await channel.rejectInstallApp(params); - break; - case CFCoreTypes.RpcMethodName.WITHDRAW: - result = await channel.providerWithdraw(params); - break; - case CFCoreTypes.RpcMethodName.WITHDRAW_COMMITMENT: - result = await channel.withdrawCommitment(params); - break; - default: - console.error( - `Wallet connect mapping error, unknown method. Payload: ${JSON.stringify( - payload, - null, - 2, - )}`, - ); - break; + verifyPayload(payload); + + let result = await channel.channelProvider.send(payload.method, payload.params); + + if (typeof result === "undefined") { + const message = "WalletConnect Error - result is undefined"; + console.error(message); + walletConnector.rejectRequest({ id: payload.id, error: { message } }); + } else { + walletConnector.approveRequest({ id: payload.id, result }); } } catch (e) { - console.error(`Wallet connect error: ${JSON.stringify(e, null, 2)}`); + console.error(e.message); + walletConnector.rejectRequest({ id: payload.id, error: { message: e.message } }); } - walletConnector.approveRequest({ id, result }); } diff --git a/modules/dashboard/package.json b/modules/dashboard/package.json index 906244da63..8cc8f3ceff 100644 --- a/modules/dashboard/package.json +++ b/modules/dashboard/package.json @@ -9,8 +9,9 @@ "eject": "react-scripts eject" }, "dependencies": { - "@connext/messaging": "1.3.14", - "@connext/types": "1.3.14", + "@connext/cf-funding-protocol-contracts": "0.4.1", + "@connext/messaging": "1.4.1", + "@connext/types": "1.4.1", "@material-ui/core": "4.7.1", "@material-ui/icons": "4.5.1", "react": "16.12.0", diff --git a/modules/dashboard/src/components/Admin/Admin.js b/modules/dashboard/src/components/Admin/Admin.js index 119b969068..c8008d34a6 100644 --- a/modules/dashboard/src/components/Admin/Admin.js +++ b/modules/dashboard/src/components/Admin/Admin.js @@ -1,14 +1,122 @@ -import React from "react"; +import React, { useEffect } from "react"; import Grid from '@material-ui/core/Grid'; import { styled } from '@material-ui/core/styles'; +import { Contract, getDefaultProvider } from "ethers"; +import { getAddress, Interface, keccak256, solidityKeccak256 } from "ethers/utils"; import { GetIncorrectProxyFactoryAddress, FixIncorrectProxyFactoryAddress } from "./IncorrectProxyFactory/IncorrectProxyFactoryAddressView"; +import { fromExtendedKey } from "ethers/utils/hdnode"; +import MinimumViableMultisig from "@connext/cf-funding-protocol-contracts/build/MinimumViableMultisig.json"; +import ProxyFactory from "@connext/cf-funding-protocol-contracts/build/ProxyFactory.json"; +import historicalData from "./historicalData"; const RootGrid = styled(Grid)({ flexGrow: 1, padding: "5%", }); +/* + * Notes re ProxyBytecode + * the first bytecode is "", this is important bc this signals that we should use the one from the factory + */ + +// NOTE: edit these to scan for factory address on page load (output in console.log) +const expectedMultisig = ""; +const owners = []; + const Admin = ({ messaging }) => { + + const legacyGetCreate2MultisigAddress = async ( + owners, + proxyFactoryAddress, + minimumViableMultisigAddress, + ethProvider, + isLegacy = false, + toxicBytecode, + ) => { + const proxyFactory = new Contract(proxyFactoryAddress, ProxyFactory.abi, ethProvider); + // Calculates xpub -> address without the last "/" part of the path + const xkeysToSortedKthAddresses = (xkeys) => + xkeys + .map((xkey) => + isLegacy + ? fromExtendedKey(xkey).address + : fromExtendedKey(xkey).derivePath("0").address + ) + .sort((a, b) => (parseInt(a, 16) < parseInt(b, 16) ? -1 : 1)); + const ownerAddresses = xkeysToSortedKthAddresses(owners); + // console.log(`Got ownerAddresses: ${JSON.stringify(ownerAddresses)}`); + const proxyBytecode = toxicBytecode || await proxyFactory.functions.proxyCreationCode(); + return getAddress( + solidityKeccak256( + ["bytes1", "address", "uint256", "bytes32"], + [ + "0xff", + proxyFactoryAddress, + solidityKeccak256( + ["bytes32", "uint256"], + [ + keccak256( + // see encoding notes + new Interface(MinimumViableMultisig.abi).functions.setup.encode([ + ownerAddresses, + ]), + ), + 0, + ], + ), + solidityKeccak256( + ["bytes", "uint256"], + [`0x${proxyBytecode.replace("0x", "")}`, minimumViableMultisigAddress], + ), + ], + ).slice(-40), + ); + } + + const scanForFactory = async (owners, expectedMultisig) => { + console.log(`Scanning for expected multisig: ${expectedMultisig}`); + if (!owners || !expectedMultisig) return; + const provider = getDefaultProvider("homestead"); + for (const multisig of historicalData.MinimumViableMultisigAddresses) { + for (const factory of historicalData.ProxyFactoryAddresses) { + for (const bytecode of historicalData.proxyBytecode) { + for (const legacy of [true, false]) { + const bc = bytecode.substring(0,8) || `0x000000`; + let calculated = await legacyGetCreate2MultisigAddress( + owners, + factory, + multisig, + provider, + legacy, + bytecode + ); + console.log( + `factory ${factory} + multisig ${multisig} + bytecode ${bc}... + legacy ${legacy}` + + ` => ${calculated}`, + ); + if (calculated === expectedMultisig) { + console.log(`MATCH DETECTED`); + console.log(`calculated: ${calculated}`); + console.log(`legacy: ${legacy}`); + console.log(`multisig: ${multisig}`); + console.log(`factory: ${factory}`); + console.log(`bytecode: ${bytecode}`); + return [legacy, multisig, factory, bytecode]; + } + } + } + } + } + return "oh no none match :(" + } + + useEffect(() => { + if (!messaging) { + return; + } + (async () => console.log(await scanForFactory(owners, expectedMultisig)))() + }); + return ( diff --git a/modules/dashboard/src/components/Admin/historicalData.json b/modules/dashboard/src/components/Admin/historicalData.json new file mode 100644 index 0000000000..8b365620bd --- /dev/null +++ b/modules/dashboard/src/components/Admin/historicalData.json @@ -0,0 +1,29 @@ +{ + "MinimumViableMultisigAddresses": [ + "0x1284958470279156ED4Bca6fA1c012f2208c5CeB", + "0x35a3C667e2274448e52F02C60e45d4662B6BCbC1", + "0x12194a21bca6Ec9504a85ed0a27c736b27980fFf" + ], + "ProxyFactoryAddresses": [ + "0x90Bf287B6870A99E32130CED0Da8b02302a8a4dE", + "0xA16d9511C743d6D6177A65892DC2Eafd417BfD7A", + "0xc756Bf6A685573C6879D4363401940f02B4E27a1", + "0x6CF0c4Ab3F1e66913c0983DC0bb1202d958ABb8f", + "0x711C655e08aaA9081e0BDc431920507CCD96b7a0", + "0xF9015aA98BeBaE3e43945c48dc3fB6c0a5281986" + ], + "proxyBytecode": [ + "", + "608060405234801561001057600080fd5b506040516101b43803806101b48339818101604052602081101561003357600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806101906024913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550506077806101196000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054163660008037600080366000845af43d6000803e6000811415603d573d6000fd5b3d6000f3fea265627a7a723058202b014062fac5bbf2f3a320134dac5811a29f916a0f071e16e4493bf4a28fe8a064736f6c634300050a0032496e76616c6964206d617374657220636f707920616464726573732070726f7669646564", + "608060405234801561001057600080fd5b5060405161014d38038061014d8339818101604052602081101561003357600080fd5b50516001600160a01b038116610094576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806101296024913960400191505060405180910390fd5b600080546001600160a01b039092166001600160a01b03199092169190911790556066806100c36000396000f3fe60806040526001600160a01b03600054163660008037600080366000845af43d6000803e80602c573d6000fd5b3d6000f3fea265627a7a72305820bc67717cd88c5a64c5f777b8f4cedbd06113f319c4b07640557bfaf42313683664736f6c634300050a0032496e76616c6964206d617374657220636f707920616464726573732070726f7669646564", + + "608060405234801561001057600080fd5b5060405161014d38038061014d8339818101604052602081101561003357600080fd5b50516001600160a01b038116610094576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806101296024913960400191505060405180910390fd5b600080546001600160a01b039092166001600160a01b03199092169190911790556066806100c36000396000f3fe60806040526001600160a01b03600054163660008037600080366000845af43d6000803e80602c573d6000fd5b3d6000f3fea265627a7a7231582095e5b1595949a39460224d2c8c0f5f8c5278cf98e564a3dc6df1e85bb67349a264736f6c634300050b0032496e76616c6964206d617374657220636f707920616464726573732070726f7669646564", + "608060405234801561001057600080fd5b5060405161014d38038061014d8339818101604052602081101561003357600080fd5b50516001600160a01b038116610094576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806101296024913960400191505060405180910390fd5b600080546001600160a01b039092166001600160a01b03199092169190911790556066806100c36000396000f3fe60806040526001600160a01b03600054163660008037600080366000845af43d6000803e80602c573d6000fd5b3d6000f3fea265627a7a72315820efb5249fda5b4819439f9adfac4170757400c26a33ff92f56c183d898f6d55ce64736f6c634300050b0032496e76616c6964206d617374657220636f707920616464726573732070726f7669646564", + "608060405234801561001057600080fd5b5060405161014d38038061014d8339818101604052602081101561003357600080fd5b50516001600160a01b038116610094576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806101296024913960400191505060405180910390fd5b600080546001600160a01b039092166001600160a01b03199092169190911790556066806100c36000396000f3fe60806040526001600160a01b03600054163660008037600080366000845af43d6000803e80602c573d6000fd5b3d6000f3fea265627a7a72315820aae145eec1b1605981aa430b58d165b87c33a4e84e98af399921523689897b1c64736f6c634300050c0032496e76616c6964206d617374657220636f707920616464726573732070726f7669646564", + "608060405234801561001057600080fd5b506040516020806102a28339810180604052602081101561003057600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156100c9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602481526020018061027e6024913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050610165806101196000396000f3fe608060405260043610610046576000357c0100000000000000000000000000000000000000000000000000000000900480634555d5c9146100855780635c60da1b146100b0575b73ffffffffffffffffffffffffffffffffffffffff600054163660008037600080366000845af43d6000803e6000811415610080573d6000fd5b3d6000f35b34801561009157600080fd5b5061009a610107565b6040518082815260200191505060405180910390f35b3480156100bc57600080fd5b506100c5610110565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b60006002905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690509056fea165627a7a72305820cbaa55954a7b3721fdaa3d5e751aba99297cffc56a4fe4f725ab8cc357bdc9060029496e76616c6964206d617374657220636f707920616464726573732070726f7669646564", + "608060405234801561001057600080fd5b506040516020806102a28339810180604052602081101561003057600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156100c9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602481526020018061027e6024913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050610165806101196000396000f3fe608060405260043610610046576000357c0100000000000000000000000000000000000000000000000000000000900480634555d5c9146100855780635c60da1b146100b0575b73ffffffffffffffffffffffffffffffffffffffff600054163660008037600080366000845af43d6000803e6000811415610080573d6000fd5b3d6000f35b34801561009157600080fd5b5061009a610107565b6040518082815260200191505060405180910390f35b3480156100bc57600080fd5b506100c5610110565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b60006002905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690509056fea165627a7a7230582042400f597742ac88c2a7e49bbe22dff94df34edae535e3a47623e3bdaa8345050029496e76616c6964206d617374657220636f707920616464726573732070726f7669646564", + "608060405234801561001057600080fd5b506040516101b43803806101b48339818101604052602081101561003357600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806101906024913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550506077806101196000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054163660008037600080366000845af43d6000803e6000811415603d573d6000fd5b3d6000f3fea265627a7a72305820d9d7a14b8ecf449ff9f4e43409de6192e014eca42f91d6ecaef46b0064f2678264736f6c63430005090032496e76616c6964206d617374657220636f707920616464726573732070726f7669646564", + "608060405234801561001057600080fd5b506040516101b43803806101b48339818101604052602081101561003357600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806101906024913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550506077806101196000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054163660008037600080366000845af43d6000803e6000811415603d573d6000fd5b3d6000f3fea265627a7a723058201f7b90d154cc86191d4df66bd6a9e79cb26f293da8b35163c7329d9ebee6704c64736f6c63430005090032496e76616c6964206d617374657220636f707920616464726573732070726f7669646564", + "0x608060405234801561001057600080fd5b5060405161014d38038061014d8339818101604052602081101561003357600080fd5b50516001600160a01b038116610094576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806101296024913960400191505060405180910390fd5b600080546001600160a01b039092166001600160a01b03199092169190911790556066806100c36000396000f3fe60806040526001600160a01b03600054163660008037600080366000845af43d6000803e80602c573d6000fd5b3d6000f3fea265627a7a723058204aa47457df066a39069fe88405c4a43b41fe29d29c9365fe6805f5c66a4723ea64736f6c634300050a0032496e76616c6964206d617374657220636f707920616464726573732070726f7669646564" + ] +} diff --git a/modules/messaging/package.json b/modules/messaging/package.json index f1c43c58ab..b3660554b3 100644 --- a/modules/messaging/package.json +++ b/modules/messaging/package.json @@ -1,6 +1,6 @@ { "name": "@connext/messaging", - "version": "1.3.14", + "version": "1.4.1", "main": "dist/index.js", "iife": "dist/index.iife.js", "types": "dist/index.d.ts", @@ -14,7 +14,7 @@ "prepare": "npm run build" }, "dependencies": { - "@connext/types": "1.3.14", + "@connext/types": "1.4.1", "ts-nats": "1.2.4", "websocket-nats": "0.3.3" }, diff --git a/modules/messaging/src/nats.ts b/modules/messaging/src/nats.ts index b8c8cee391..3a636ca800 100644 --- a/modules/messaging/src/nats.ts +++ b/modules/messaging/src/nats.ts @@ -1,4 +1,4 @@ -import { Node } from "@connext/types"; +import { CFCoreTypes } from "@connext/types"; import * as nats from "ts-nats"; import { Logger } from "./logger"; @@ -32,9 +32,9 @@ export class NatsMessagingService implements IMessagingService { } //////////////////////////////////////// - // Node.IMessagingService Methods + // CFCoreTypes.IMessagingService Methods - async onReceive(subject: string, callback: (msg: Node.NodeMessage) => void): Promise { + async onReceive(subject: string, callback: (msg: CFCoreTypes.NodeMessage) => void): Promise { this.assertConnected(); this.subscriptions[subject] = await this.connection!.subscribe( this.prependKey(`${subject}.>`), @@ -44,13 +44,13 @@ export class NatsMessagingService implements IMessagingService { } else { const data = typeof msg.data === "string" ? JSON.parse(msg).data : msg.data; this.log.debug(`Received message for ${subject}: ${JSON.stringify(data)}`); - callback(data as Node.NodeMessage); + callback(data as CFCoreTypes.NodeMessage); } }, ); } - async send(to: string, msg: Node.NodeMessage): Promise { + async send(to: string, msg: CFCoreTypes.NodeMessage): Promise { this.assertConnected(); this.log.debug(`Sending message to ${to}: ${JSON.stringify(msg)}`); this.connection!.publish(this.prependKey(`${to}.${msg.from}`), msg); @@ -73,7 +73,7 @@ export class NatsMessagingService implements IMessagingService { return response; } - async subscribe(subject: string, callback: (msg: Node.NodeMessage) => void): Promise { + async subscribe(subject: string, callback: (msg: CFCoreTypes.NodeMessage) => void): Promise { this.assertConnected(); this.subscriptions[subject] = await this.connection!.subscribe( subject, @@ -83,7 +83,7 @@ export class NatsMessagingService implements IMessagingService { } else { const data = typeof msg === "string" ? JSON.parse(msg) : msg; this.log.debug(`Subscription for ${subject}: ${JSON.stringify(data)}`); - callback(data as Node.NodeMessage); + callback(data as CFCoreTypes.NodeMessage); } }, ); diff --git a/modules/messaging/src/types.ts b/modules/messaging/src/types.ts index bcef646946..80803dd786 100644 --- a/modules/messaging/src/types.ts +++ b/modules/messaging/src/types.ts @@ -1,4 +1,4 @@ -import { MessagingConfig, Node } from "@connext/types"; +import { MessagingConfig, CFCoreTypes } from "@connext/types"; export interface MessagingConfig { clusterId?: string; @@ -7,11 +7,11 @@ export interface MessagingConfig { logLevel: number; } -export interface IMessagingService extends Node.IMessagingService { +export interface IMessagingService extends CFCoreTypes.IMessagingService { connect(): Promise; disconnect(): Promise; flush(): Promise; - onReceive(subject: string, callback: (msg: Node.NodeMessage) => void): Promise; + onReceive(subject: string, callback: (msg: CFCoreTypes.NodeMessage) => void): Promise; publish(subject: string, data: any): Promise; request( subject: string, @@ -19,7 +19,7 @@ export interface IMessagingService extends Node.IMessagingService { data: object, callback?: (response: any) => any, ): Promise; - send(to: string, msg: Node.NodeMessage): Promise; - subscribe(subject: string, callback: (msg: Node.NodeMessage) => void): Promise; + send(to: string, msg: CFCoreTypes.NodeMessage): Promise; + subscribe(subject: string, callback: (msg: CFCoreTypes.NodeMessage) => void): Promise; unsubscribe(subject: string): Promise; } diff --git a/modules/messaging/src/ws.ts b/modules/messaging/src/ws.ts index cb150e5a16..c4139c870c 100644 --- a/modules/messaging/src/ws.ts +++ b/modules/messaging/src/ws.ts @@ -1,4 +1,4 @@ -import { Node } from "@connext/types"; +import { CFCoreTypes } from "@connext/types"; import * as wsNats from "websocket-nats"; import { Logger } from "./logger"; @@ -27,21 +27,21 @@ export class WsMessagingService implements IMessagingService { } //////////////////////////////////////// - // Node.IMessagingService Methods + // CFCoreTypes.IMessagingService Methods - async onReceive(subject: string, callback: (msg: Node.NodeMessage) => void): Promise { + async onReceive(subject: string, callback: (msg: CFCoreTypes.NodeMessage) => void): Promise { this.assertConnected(); this.subscriptions[subject] = this.connection.subscribe( this.prependKey(`${subject}.>`), (msg: any): void => { const data = typeof msg === "string" ? JSON.parse(msg) : msg; this.log.debug(`Received message for ${subject}: ${JSON.stringify(data)}`); - callback(data as Node.NodeMessage); + callback(data as CFCoreTypes.NodeMessage); }, ); } - async send(to: string, msg: Node.NodeMessage): Promise { + async send(to: string, msg: CFCoreTypes.NodeMessage): Promise { this.assertConnected(); this.log.debug(`Sending message to ${to}: ${JSON.stringify(msg)}`); await this.connection.publish(this.prependKey(`${to}.${msg.from}`), JSON.stringify(msg)); @@ -72,12 +72,12 @@ export class WsMessagingService implements IMessagingService { }); } - async subscribe(subject: string, callback: (msg: Node.NodeMessage) => void): Promise { + async subscribe(subject: string, callback: (msg: CFCoreTypes.NodeMessage) => void): Promise { this.assertConnected(); this.subscriptions[subject] = this.connection.subscribe(subject, (msg: any): void => { const data = typeof msg === "string" ? JSON.parse(msg) : msg; this.log.debug(`Subscription for ${subject}: ${JSON.stringify(data)}`); - callback(data as Node.NodeMessage); + callback(data as CFCoreTypes.NodeMessage); }); } diff --git a/modules/node/package.json b/modules/node/package.json index a6ef14a1ef..4ae3d0b44d 100644 --- a/modules/node/package.json +++ b/modules/node/package.json @@ -1,6 +1,6 @@ { "name": "indra-node", - "version": "2.3.17", + "version": "2.3.18", "description": "", "author": "", "license": "MIT", @@ -20,10 +20,10 @@ "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand" }, "dependencies": { - "@connext/cf-core": "1.3.14", + "@connext/cf-core": "1.4.1", "@connext/cf-funding-protocol-contracts": "0.4.1", - "@connext/messaging": "1.3.14", - "@connext/types": "1.3.14", + "@connext/messaging": "1.4.1", + "@connext/types": "1.4.1", "@nestjs/common": "6.5.3", "@nestjs/core": "6.5.3", "@nestjs/microservices": "6.5.3", diff --git a/modules/node/src/auth/auth.service.ts b/modules/node/src/auth/auth.service.ts index 026addfc27..99251902f1 100644 --- a/modules/node/src/auth/auth.service.ts +++ b/modules/node/src/auth/auth.service.ts @@ -31,7 +31,7 @@ export class AuthService { async getNonce(address: string): Promise { if (!isValidHex(address, 20)) { - return JSON.stringify({ err: "Invalid address" }); + return JSON.stringify({ err: `Invalid address: ${address}` }); } const nonce = hexlify(randomBytes(nonceLen)); const expiry = Date.now() + nonceTTL; diff --git a/modules/node/src/cfCore/cfCore.service.ts b/modules/node/src/cfCore/cfCore.service.ts index 63c13fb6fc..1cf60bf693 100644 --- a/modules/node/src/cfCore/cfCore.service.ts +++ b/modules/node/src/cfCore/cfCore.service.ts @@ -51,7 +51,7 @@ export class CFCoreService { try { const freeBalance = await this.cfCore.rpcRouter.dispatch({ id: Date.now(), - methodName: CFCoreTypes.RpcMethodName.GET_FREE_BALANCE_STATE, + methodName: CFCoreTypes.RpcMethodNames.chan_getFreeBalanceState, parameters: { multisigAddress, tokenAddress: assetId, @@ -77,7 +77,7 @@ export class CFCoreService { async getStateChannel(multisigAddress: string): Promise<{ data: StateChannelJSON }> { const params = { id: Date.now(), - methodName: CFCoreTypes.RpcMethodName.GET_STATE_CHANNEL, + methodName: CFCoreTypes.RpcMethodNames.chan_getStateChannel, parameters: { multisigAddress, }, @@ -91,7 +91,7 @@ export class CFCoreService { ): Promise { const params = { id: Date.now(), - methodName: CFCoreTypes.RpcMethodName.CREATE_CHANNEL, + methodName: CFCoreTypes.RpcMethodNames.chan_create, parameters: { owners: [this.cfCore.publicIdentifier, counterpartyPublicIdentifier], } as CFCoreTypes.CreateChannelParams, @@ -107,7 +107,7 @@ export class CFCoreService { ): Promise { const params = { id: Date.now(), - methodName: CFCoreTypes.RpcMethodName.DEPLOY_STATE_DEPOSIT_HOLDER, + methodName: CFCoreTypes.RpcMethodNames.chan_deployStateDepositHolder, parameters: { multisigAddress, } as CFCoreTypes.DeployStateDepositHolderParams, @@ -126,7 +126,7 @@ export class CFCoreService { assetId: string = AddressZero, ): Promise { logger.debug( - `Calling ${CFCoreTypes.RpcMethodName.DEPOSIT} with params: ${stringify({ + `Calling ${CFCoreTypes.RpcMethodNames.chan_deposit} with params: ${stringify({ amount, multisigAddress, tokenAddress: assetId, @@ -134,7 +134,7 @@ export class CFCoreService { ); const depositRes = await this.cfCore.rpcRouter.dispatch({ id: Date.now(), - methodName: CFCoreTypes.RpcMethodName.DEPOSIT, + methodName: CFCoreTypes.RpcMethodNames.chan_deposit, parameters: { amount, multisigAddress, @@ -155,11 +155,11 @@ export class CFCoreService { params: CFCoreTypes.ProposeInstallParams, ): Promise { logger.debug( - `Calling ${CFCoreTypes.RpcMethodName.PROPOSE_INSTALL} with params: ${stringify(params)}`, + `Calling ${CFCoreTypes.RpcMethodNames.chan_proposeInstall} with params: ${stringify(params)}`, ); const proposeRes = await this.cfCore.rpcRouter.dispatch({ id: Date.now(), - methodName: CFCoreTypes.RpcMethodName.PROPOSE_INSTALL, + methodName: CFCoreTypes.RpcMethodNames.chan_proposeInstall, parameters: params, }); logger.debug(`proposeInstallApp called with result ${stringify(proposeRes.result.result)}`); @@ -260,7 +260,7 @@ export class CFCoreService { async installApp(appInstanceId: string): Promise { const installRes = await this.cfCore.rpcRouter.dispatch({ id: Date.now(), - methodName: CFCoreTypes.RpcMethodName.INSTALL, + methodName: CFCoreTypes.RpcMethodNames.chan_install, parameters: { appInstanceId, } as CFCoreTypes.InstallParams, @@ -272,7 +272,7 @@ export class CFCoreService { async rejectInstallApp(appInstanceId: string): Promise { const rejectRes = await this.cfCore.rpcRouter.dispatch({ id: Date.now(), - methodName: CFCoreTypes.RpcMethodName.REJECT_INSTALL, + methodName: CFCoreTypes.RpcMethodNames.chan_rejectInstall, parameters: { appInstanceId, } as CFCoreTypes.RejectInstallParams, @@ -297,7 +297,7 @@ export class CFCoreService { } const actionResponse = await this.cfCore.rpcRouter.dispatch({ id: Date.now(), - methodName: CFCoreTypes.RpcMethodName.TAKE_ACTION, + methodName: CFCoreTypes.RpcMethodNames.chan_takeAction, parameters: { action, appInstanceId, @@ -314,7 +314,7 @@ export class CFCoreService { logger.log(`Calling uninstallApp for appInstanceId ${appInstanceId}`); const uninstallResponse = await this.cfCore.rpcRouter.dispatch({ id: Date.now(), - methodName: CFCoreTypes.RpcMethodName.UNINSTALL, + methodName: CFCoreTypes.RpcMethodNames.chan_uninstall, parameters: { appInstanceId, }, @@ -332,7 +332,7 @@ export class CFCoreService { logger.log(`Calling rescindDepositRights`); const uninstallResponse = await this.cfCore.rpcRouter.dispatch({ id: Date.now(), - methodName: CFCoreTypes.RpcMethodName.RESCIND_DEPOSIT_RIGHTS, + methodName: CFCoreTypes.RpcMethodNames.chan_rescindDepositRights, parameters: { multisigAddress, tokenAddress } as CFCoreTypes.RescindDepositRightsParams, }); @@ -345,7 +345,7 @@ export class CFCoreService { async getAppInstances(multisigAddress?: string): Promise { const appInstanceResponse = await this.cfCore.rpcRouter.dispatch({ id: Date.now(), - methodName: CFCoreTypes.RpcMethodName.GET_APP_INSTANCES, + methodName: CFCoreTypes.RpcMethodNames.chan_getAppInstances, parameters: { multisigAddress, } as CFCoreTypes.GetAppInstancesParams, @@ -385,7 +385,7 @@ export class CFCoreService { async getProposedAppInstances(multisigAddress?: string): Promise { const appInstanceResponse = await this.cfCore.rpcRouter.dispatch({ id: Date.now(), - methodName: CFCoreTypes.RpcMethodName.GET_PROPOSED_APP_INSTANCES, + methodName: CFCoreTypes.RpcMethodNames.chan_getProposedAppInstances, parameters: { multisigAddress } as CFCoreTypes.GetAppInstancesParams, }); @@ -400,7 +400,7 @@ export class CFCoreService { try { const appInstanceResponse = await this.cfCore.rpcRouter.dispatch({ id: Date.now(), - methodName: CFCoreTypes.RpcMethodName.GET_APP_INSTANCE_DETAILS, + methodName: CFCoreTypes.RpcMethodNames.chan_getAppInstance, parameters: { appInstanceId } as CFCoreTypes.GetAppInstanceDetailsParams, }); appInstance = appInstanceResponse.result.result.appInstance; @@ -425,7 +425,7 @@ export class CFCoreService { } const stateResponse = await this.cfCore.rpcRouter.dispatch({ id: Date.now(), - methodName: CFCoreTypes.RpcMethodName.GET_STATE, + methodName: CFCoreTypes.RpcMethodNames.chan_getState, parameters: { appInstanceId, } as CFCoreTypes.GetStateParams, diff --git a/modules/node/src/listener/listener.service.ts b/modules/node/src/listener/listener.service.ts index 0fab8df8e5..dfff1ffe43 100644 --- a/modules/node/src/listener/listener.service.ts +++ b/modules/node/src/listener/listener.service.ts @@ -192,7 +192,7 @@ export default class ListenerService implements OnModuleInit { ); this.cfCoreService.registerCfCoreListener( - CFCoreTypes.RpcMethodName.INSTALL as any, + CFCoreTypes.RpcMethodNames.chan_install as any, (data: any) => { const appInstance = data.result.result.appInstance; logger.debug( @@ -211,7 +211,7 @@ export default class ListenerService implements OnModuleInit { ); this.cfCoreService.registerCfCoreListener( - CFCoreTypes.RpcMethodName.UNINSTALL as any, + CFCoreTypes.RpcMethodNames.chan_uninstall as any, (data: any) => { logger.debug( `Emitting CFCoreTypes.RpcMethodName.UNINSTALL event: ${JSON.stringify( diff --git a/modules/node/src/test/cfCore.ts b/modules/node/src/test/cfCore.ts index 799f2ec99a..6c11c7cb1a 100644 --- a/modules/node/src/test/cfCore.ts +++ b/modules/node/src/test/cfCore.ts @@ -24,11 +24,11 @@ export const mockCFCoreProvider = { dispatch: (param: any): JsonRpcResponse | undefined => { logger.log(`Called mocked router.dispatch with params: ${JSON.stringify(param)}`); switch (param.methodName) { - case CFCoreTypes.RpcMethodName.CREATE_CHANNEL: + case CFCoreTypes.RpcMethodNames.chan_create: return createMockJsonRpcResponse({ multisigAddress: mockStateDepositHolderAddress, } as CFCoreTypes.CreateChannelResult); - case CFCoreTypes.RpcMethodName.GET_STATE_DEPOSIT_HOLDER_ADDRESS: + case CFCoreTypes.RpcMethodNames.chan_getStateDepositHolderAddress: return createMockJsonRpcResponse({ address: mockStateDepositHolderAddress, } as CFCoreTypes.GetStateDepositHolderAddressResult); diff --git a/modules/node/src/test/node.ts b/modules/node/src/test/node.ts index 4ef792a1b4..f049bc840b 100644 --- a/modules/node/src/test/node.ts +++ b/modules/node/src/test/node.ts @@ -24,11 +24,11 @@ export const mockNodeProvider = { dispatch: (param: any): JsonRpcResponse | undefined => { logger.log(`Called mocked router.dispatch with params: ${JSON.stringify(param)}`); switch (param.methodName) { - case CFCoreTypes.RpcMethodName.CREATE_CHANNEL: + case CFCoreTypes.RpcMethodNames.chan_create: return createMockJsonRpcResponse({ multisigAddress: mockStateDepositHolderAddress, } as CFCoreTypes.CreateChannelResult); - case CFCoreTypes.RpcMethodName.GET_STATE_DEPOSIT_HOLDER_ADDRESS: + case CFCoreTypes.RpcMethodNames.chan_getStateDepositHolderAddress: return createMockJsonRpcResponse({ address: mockStateDepositHolderAddress, } as CFCoreTypes.GetStateDepositHolderAddressResult); diff --git a/modules/node/src/transfer/transfer.service.ts b/modules/node/src/transfer/transfer.service.ts index 4386f1a1e6..2f53ee8fdd 100644 --- a/modules/node/src/transfer/transfer.service.ts +++ b/modules/node/src/transfer/transfer.service.ts @@ -282,7 +282,7 @@ export class TransferService { // add preimage to database to allow unlock from a listener transfer.receiverAppInstanceId = receiverAppInstallRes.appInstanceId; - transfer.preImage = mkHash("0x0"); + transfer.preImage = preImage; transfer.paymentId = paymentId; await this.linkedTransferRepository.save(transfer); diff --git a/modules/node/src/util/cfCore.ts b/modules/node/src/util/cfCore.ts index b9f6a43ceb..cb196c20e8 100644 --- a/modules/node/src/util/cfCore.ts +++ b/modules/node/src/util/cfCore.ts @@ -26,6 +26,6 @@ export { export { AppInstanceJson, AppInstanceProposal, - Node as CFCoreTypes, + CFCoreTypes, OutcomeType, } from "@connext/types"; diff --git a/modules/payment-bot/package.json b/modules/payment-bot/package.json index 4a18cf075e..2e0aed7237 100644 --- a/modules/payment-bot/package.json +++ b/modules/payment-bot/package.json @@ -11,7 +11,7 @@ "author": "", "license": "MIT", "dependencies": { - "@connext/client": "1.3.14", + "@connext/client": "1.4.1", "commander": "4.0.1", "dotenv": "8.2.0", "ethers": "4.0.40", @@ -20,7 +20,7 @@ "uuid": "3.3.3" }, "devDependencies": { - "@connext/types": "1.3.14", + "@connext/types": "1.4.1", "@types/node-fetch": "2.5.4", "env-cmd": "10.0.1", "ts-node": "8.5.4", diff --git a/modules/types/package.json b/modules/types/package.json index aa60e1d3c0..0888a17203 100644 --- a/modules/types/package.json +++ b/modules/types/package.json @@ -1,6 +1,6 @@ { "name": "@connext/types", - "version": "1.3.14", + "version": "1.4.1", "description": "TypeScript typings for common Connext types", "main": "dist/index.js", "module": "dist/index.esm.js", @@ -14,7 +14,6 @@ "test": "./node_modules/.bin/jest" }, "dependencies": { - "@connext/cf-types": "1.3.14", "ethers": "4.0.40" }, "devDependencies": { diff --git a/modules/types/src/cf.ts b/modules/types/src/cf.ts deleted file mode 100644 index 3acfe6bed8..0000000000 --- a/modules/types/src/cf.ts +++ /dev/null @@ -1,34 +0,0 @@ -export { - Address, - AppABIEncodings, - AppIdentity, - AppInstanceInfo, - AppInstanceJson, - AppInstanceProposal, - AppInterface, - CoinBalanceRefundState, - coinBalanceRefundStateEncoding, - ContractABI, - DeployedContractNetworksFileEntry, - EXPECTED_CONTRACT_NAMES_IN_NETWORK_CONTEXT, - multiAssetMultiPartyCoinTransferEncoding, - MultiAssetMultiPartyCoinTransferInterpreterParams, - multiAssetMultiPartyCoinTransferInterpreterParamsEncoding, - NetworkContext, - Node as CFCoreTypes, - Node, - OutcomeType, - SignedStateHashUpdate, - SingleAssetTwoPartyCoinTransferInterpreterParams, - singleAssetTwoPartyCoinTransferInterpreterParamsEncoding, - SingleAssetTwoPartyIntermediaryAgreement, - SolidityValueType, - StateChannelJSON, - TwoPartyFixedOutcome, - TwoPartyFixedOutcomeInterpreterParams, - twoPartyFixedOutcomeInterpreterParamsEncoding, - virtualAppAgreementEncoding, -} from "@connext/cf-types"; - -// 25446 is 0x6366... or "cf" in ascii, for "Counterfactual". -export const CF_PATH = "m/44'/60'/0'/25446"; diff --git a/modules/cf-types/src/app-instance.ts b/modules/types/src/cf/app-instance.ts similarity index 100% rename from modules/cf-types/src/app-instance.ts rename to modules/types/src/cf/app-instance.ts diff --git a/modules/cf-types/src/data-types.ts b/modules/types/src/cf/data-types.ts similarity index 98% rename from modules/cf-types/src/data-types.ts rename to modules/types/src/cf/data-types.ts index e7cb8e34cf..f339a5ea18 100644 --- a/modules/cf-types/src/data-types.ts +++ b/modules/types/src/cf/data-types.ts @@ -1,7 +1,8 @@ // https://github.com/counterfactual/monorepo/blob/master/packages/cf.js/API_REFERENCE.md#data-types import { BigNumber } from "ethers/utils"; -import { AppInterface, SolidityValueType } from "."; +import { AppInterface } from "./app-instance"; +import { SolidityValueType } from "./simple-types"; // Derived from: // cf-funding-protocol/contracts/interpreters/TwoPartyFixedOutcomeInterpreter.sol#L10 diff --git a/modules/cf-types/src/index.ts b/modules/types/src/cf/index.ts similarity index 93% rename from modules/cf-types/src/index.ts rename to modules/types/src/cf/index.ts index 5580646205..cc1a231964 100644 --- a/modules/cf-types/src/index.ts +++ b/modules/types/src/cf/index.ts @@ -25,7 +25,7 @@ import { twoPartyFixedOutcomeInterpreterParamsEncoding, virtualAppAgreementEncoding } from "./data-types"; -import { IRpcNodeProvider, Node } from "./node"; +import { IRpcNodeProvider, CFCoreTypes } from "./node"; import { ABIEncoding, Address, @@ -33,6 +33,9 @@ import { SolidityValueType } from "./simple-types"; +// 25446 is 0x6366... or "cf" in ascii, for "Counterfactual". +export const CF_PATH = "m/44'/60'/0'/25446"; + export interface NetworkContext { ChallengeRegistry: string; CoinBalanceRefundApp: string; @@ -89,7 +92,7 @@ export { SolidityValueType, StateChannelJSON, IRpcNodeProvider, - Node, + CFCoreTypes, SignedStateHashUpdate, OutcomeType, SingleAssetTwoPartyCoinTransferInterpreterParams, diff --git a/modules/cf-types/src/node.ts b/modules/types/src/cf/node.ts similarity index 83% rename from modules/cf-types/src/node.ts rename to modules/types/src/cf/node.ts index 5727417692..104ad98fdb 100644 --- a/modules/cf-types/src/node.ts +++ b/modules/types/src/cf/node.ts @@ -1,20 +1,38 @@ import { BigNumber, BigNumberish } from "ethers/utils"; -import { JsonRpcNotification, JsonRpcResponse, Rpc } from "rpc-server"; - -import { OutcomeType, StateChannelJSON } from "."; -import { - AppABIEncodings, - AppInstanceJson, - AppInstanceProposal -} from "./data-types"; + +import { AppABIEncodings, AppInstanceJson, AppInstanceProposal, OutcomeType, StateChannelJSON } from "./data-types"; import { SolidityValueType } from "./simple-types"; +type JsonRpcProtocolV2 = { + jsonrpc: "2.0"; +}; + +type RpcParameters = + | { + [key: string]: any; + } + | any[]; + +export type JsonRpcNotification = JsonRpcProtocolV2 & { + result: any; +}; + +export type JsonRpcResponse = JsonRpcNotification & { + id: number; +}; + +export type Rpc = { + methodName: string; + parameters: RpcParameters; + id?: number; +}; + export interface IRpcNodeProvider { - onMessage(callback: (message: JsonRpcResponse | JsonRpcNotification) => void); - sendMessage(message: Rpc); + onMessage(callback: (message: JsonRpcResponse | JsonRpcNotification) => void): any; + sendMessage(message: Rpc): any; } -export namespace Node { +export namespace CFCoreTypes { /** * The message type for Nodes to communicate with each other. */ @@ -40,8 +58,8 @@ export namespace Node { } export interface IMessagingService { - send(to: string, msg: Node.NodeMessage): Promise; - onReceive(address: string, callback: (msg: Node.NodeMessage) => void); + send(to: string, msg: CFCoreTypes.NodeMessage): Promise; + onReceive(address: string, callback: (msg: CFCoreTypes.NodeMessage) => void): any; } /** @@ -57,10 +75,7 @@ export namespace Node { */ export interface IStoreService { get(path: string): Promise; - set( - pairs: { path: string; value: any }[], - allowDelete?: Boolean - ): Promise; + set(pairs: { path: string; value: any }[], allowDelete?: Boolean): Promise; reset?(): Promise; } @@ -89,32 +104,34 @@ export namespace Node { GET_PROPOSED_APP_INSTANCE = "getProposedAppInstance" } - export enum RpcMethodName { - CREATE_CHANNEL = "chan_create", - DEPOSIT = "chan_deposit", - DEPLOY_STATE_DEPOSIT_HOLDER = "chan_deployStateDepositHolder", - GET_CHANNEL_ADDRESSES = "chan_getChannelAddresses", - GET_APP_INSTANCE_DETAILS = "chan_getAppInstance", - GET_APP_INSTANCES = "chan_getAppInstances", - GET_STATE_DEPOSIT_HOLDER_ADDRESS = "chan_getStateDepositHolderAddress", - GET_FREE_BALANCE_STATE = "chan_getFreeBalanceState", - GET_TOKEN_INDEXED_FREE_BALANCE_STATES = "chan_getTokenIndexedFreeBalanceStates", - GET_PROPOSED_APP_INSTANCES = "chan_getProposedAppInstances", - GET_STATE = "chan_getState", - GET_STATE_CHANNEL = "chan_getStateChannel", - INSTALL = "chan_install", - REQUEST_DEPOSIT_RIGHTS = "chan_requestDepositRights", - INSTALL_VIRTUAL = "chan_installVirtual", - PROPOSE_INSTALL = "chan_proposeInstall", - REJECT_INSTALL = "chan_rejectInstall", - UPDATE_STATE = "chan_updateState", - TAKE_ACTION = "chan_takeAction", - UNINSTALL = "chan_uninstall", - UNINSTALL_VIRTUAL = "chan_uninstallVirtual", - RESCIND_DEPOSIT_RIGHTS = "chan_rescindDepositRights", - WITHDRAW = "chan_withdraw", - WITHDRAW_COMMITMENT = "chan_withdrawCommitment" - } + export const RpcMethodNames = { + chan_create: "chan_create", + chan_deposit: "chan_deposit", + chan_deployStateDepositHolder: "chan_deployStateDepositHolder", + chan_getChannelAddresses: "chan_getChannelAddresses", + chan_getAppInstance: "chan_getAppInstance", + chan_getAppInstances: "chan_getAppInstances", + chan_getStateDepositHolderAddress: "chan_getStateDepositHolderAddress", + chan_getFreeBalanceState: "chan_getFreeBalanceState", + chan_getTokenIndexedFreeBalanceStates: + "chan_getTokenIndexedFreeBalanceStates", + chan_getProposedAppInstances: "chan_getProposedAppInstances", + chan_getState: "chan_getState", + chan_getStateChannel: "chan_getStateChannel", + chan_install: "chan_install", + chan_requestDepositRights: "chan_requestDepositRights", + chan_installVirtual: "chan_installVirtual", + chan_proposeInstall: "chan_proposeInstall", + chan_rejectInstall: "chan_rejectInstall", + chan_updateState: "chan_updateState", + chan_takeAction: "chan_takeAction", + chan_uninstall: "chan_uninstall", + chan_uninstallVirtual: "chan_uninstallVirtual", + chan_rescindDepositRights: "chan_rescindDepositRights", + chan_withdraw: "chan_withdraw", + chan_withdrawCommitment: "chan_withdrawCommitment" + }; + export type RpcMethodName = keyof typeof RpcMethodNames; // SOURCE: https://github.com/counterfactual/monorepo/blob/master/packages/cf.js/API_REFERENCE.md#events export const EventNames = { diff --git a/modules/cf-types/src/simple-types.ts b/modules/types/src/cf/simple-types.ts similarity index 100% rename from modules/cf-types/src/simple-types.ts rename to modules/types/src/cf/simple-types.ts diff --git a/modules/types/src/channelProvider.ts b/modules/types/src/channelProvider.ts index 94ac34609e..c8f6ca2d6a 100644 --- a/modules/types/src/channelProvider.ts +++ b/modules/types/src/channelProvider.ts @@ -1,3 +1,6 @@ +import { CFCoreTypes, NetworkContext } from "./cf"; +import { Store } from "./client"; + export type ChannelProvider = any; export type ChannelProviderConfig = { @@ -7,14 +10,72 @@ export type ChannelProviderConfig = { natsToken?: string; nodeUrl: string; signerAddress: string; - type: RpcType; userPublicIdentifier: string; }; -export enum RpcType { - ChannelProvider = "ChannelProvider", - CounterfactualNode = "CounterfactualNode", // rename? +export interface CFChannelProviderOptions { + ethProvider: any; + keyGen: CFCoreTypes.IPrivateKeyGenerator; + lockService?: CFCoreTypes.ILockService; + messaging: any; + networkContext: NetworkContext; + nodeConfig: any; + nodeUrl: string; + xpub: string; + store: Store; } // TODO: replace any w interface of cfCore (using implementation directly -> circular dependency) export type RpcConnection = ChannelProvider | any; + +export const ConnextRpcMethods = { + chan_config: "chan_config", + chan_nodeAuth: "chan_nodeAuth", + chan_restoreState: "chan_restoreState", + chan_storeGet: "chan_storeGet", + chan_storeSet: "chan_storeSet", +}; +export type ConnextRpcMethod = keyof typeof ConnextRpcMethods; + +export const ChannelProviderRpcMethods = { + ...CFCoreTypes.RpcMethodNames, + ...ConnextRpcMethods, +}; +export type ChannelProviderRpcMethod = ConnextRpcMethod | CFCoreTypes.RpcMethodName; + +export type StorePair = { + path: string; + value: any; +}; + +export type KeyGen = (index: string) => Promise; + +// export interface IChannelProvider { +// connection: RpcConnection; +// wallet: Wallet | undefined; +// _config: ChannelProviderConfig; +// _multisigAddress: string | undefined; +// _signerAddress: string | undefined; +// store: Store | undefined; + +// enable(): Promise; +// send(method: CFCoreTypes.RpcMethodName | NewRpcMethodName, params: any): Promise; + +// on(event: string, listener: (...args: any[]) => void): RpcConnection; + +// once(event: string, listener: (...args: any[]) => void): RpcConnection; + +// signMessage(message: string): Promise; + +// get(path: string): Promise; + +// set(pairs: StorePair[], allowDelete?: Boolean): Promise; + +// restore(): Promise<{ path: string; value: any }[]>; + +// reset(): Promise; + +// restoreState(path: string): Promise; + +// _send(methodName: CFCoreTypes.RpcMethodName, parameters: RpcParameters): Promise; +// } diff --git a/modules/types/src/client.ts b/modules/types/src/client.ts index fbc118966a..62d2408407 100644 --- a/modules/types/src/client.ts +++ b/modules/types/src/client.ts @@ -10,7 +10,7 @@ import { import { ConnextEvent } from "./basic"; import { AppInstanceJson, CFCoreTypes } from "./cf"; import { CFCoreChannel, ChannelAppSequences, ChannelState, PaymentProfile } from "./channel"; -import { ChannelProvider, ChannelProviderConfig } from "./channelProvider"; +import { ChannelProvider, ChannelProviderConfig, KeyGen, StorePair } from "./channelProvider"; import { CheckDepositRightsParameters, CheckDepositRightsResponse, @@ -36,25 +36,19 @@ import { } from "./node"; export interface Store extends CFCoreTypes.IStoreService { - set( - pairs: { - path: string; - value: any; - }[], - shouldBackup?: Boolean, - ): Promise; - restore(): Promise<{ path: string; value: any }[]>; + set(pairs: StorePair[], shouldBackup?: Boolean): Promise; + restore(): Promise; } // channelProvider, mnemonic, and xpub+keyGen are all optional but one of them needs to be provided export interface ClientOptions { ethProviderUrl: string; - nodeUrl: string; // ws:// or nats:// urls are supported + nodeUrl?: string; // ws:// or nats:// urls are supported channelProvider?: ChannelProvider; - keyGen?: (index: string) => Promise; + keyGen?: KeyGen; mnemonic?: string; xpub?: string; - store: Store; + store?: Store; logLevel?: number; } diff --git a/modules/types/tsconfig.json b/modules/types/tsconfig.json index e8471a556a..e5fddec409 100644 --- a/modules/types/tsconfig.json +++ b/modules/types/tsconfig.json @@ -4,5 +4,5 @@ "composite": true, "outDir": "dist" }, - "include": ["src/*.ts"] + "include": ["src/**/*.ts"] } diff --git a/ops/link-cf.sh b/ops/link-cf.sh deleted file mode 100644 index 512a212930..0000000000 --- a/ops/link-cf.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env bash -set -e - -repos="cf-apps cf-core cf-types cf-adjudicator-contracts cf-funding-protocol-contracts" - -for repo in $repos; -do - - bridge_repo="git@github.com:bohendo/$repo.git" - tmp_dir=".bridge-$repo" - local_dot_git="modules/$repo/.git" - if [[ "${repo:3}" == "core" ]] - then cf_dot_git="counterfactual/packages/node/.git" - elif [[ "${repo:3}" == "apps" ]] - then cf_dot_git="counterfactual/packages/apps/.git" - elif [[ "${repo:3}" == "types" ]] - then cf_dot_git="counterfactual/packages/types/.git" - else cf_dot_git="counterfactual/packages/$repo/.git" - fi - - if [[ -d "$tmp_dir/" ]] - then - cd $tmp_dir - git fetch --all --prune - cd - - else - git clone $bridge_repo $tmp_dir - fi - - mkdir -p "$local_dot_git" - if [[ -f "$local_dot_git/index" ]] - then - cd $local_dot_git - git fetch --all --prune - cd - - else - echo "cp $tmp_dir/.git -> $local_dot_git" - cp -rf $tmp_dir/.git $local_dot_git - fi - - mkdir -p "$cf_dot_git" - if [[ -f "$cf_dot_git/index" ]] - then - cd $cf_dot_git - git fetch --all --prune - cd - - else - echo "cp $tmp_dir/.git -> $cf_dot_git" - cp -rf $tmp_dir/.git $cf_dot_git - fi - -done diff --git a/ops/npm-publish.sh b/ops/npm-publish.sh index c638a0572f..6cd9877102 100644 --- a/ops/npm-publish.sh +++ b/ops/npm-publish.sh @@ -2,7 +2,7 @@ set -e # This is the order they'll be published in -packages="cf-types,types,cf-core,messaging,client" +packages="types,cf-core,messaging,client" project="indra" ######################################## diff --git a/ops/test-bot.sh b/ops/test-bot.sh index 7ae2ff3c46..f201021612 100644 --- a/ops/test-bot.sh +++ b/ops/test-bot.sh @@ -33,12 +33,14 @@ function checkInstalledApps { recipientStore=modules/payment-bot/.payment-bot-db/1.json senderApps=0 recipientApps=0 + set +o pipefail if [[ -f "$senderStore" ]] then senderApps="`cat $senderStore | grep channel | cut -d ":" -f3- | tr -d '\\\' | cut -c 3- | rev | cut -c 3- | rev | jq '.appInstances | length'`" fi if [[ -f "$recipientStore" ]] then recipientApps="`cat $recipientStore | grep channel | cut -d ":" -f3- | tr -d '\\\' | cut -c 3- | rev | cut -c 3- | rev | jq '.appInstances | length'`" fi + set -o pipefail if [[ ("$senderApps" != "0" && "$senderApps" != "") || ("$recipientApps" != "0" && "$recipientApps" != "") ]] then echo -e "$divider";echo "Installed apps:" diff --git a/package-lock.json b/package-lock.json index f2cd96c543..edb6b41cb8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@connext/indra", - "version": "2.3.16", + "version": "2.3.17", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -988,924 +988,34 @@ "@connext/cf-adjudicator-contracts": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/@connext/cf-adjudicator-contracts/-/cf-adjudicator-contracts-0.4.1.tgz", - "integrity": "sha512-KSWdLY5Tfob89ZVyfuXIt+O+dri7aCdIYOf6HkxW8o//ohEFmbS21DeySOSGLhrQctPEGa49lCAKxVU9YR0MPQ==" - }, - "@connext/cf-core": { - "version": "1.2.9", - "resolved": "https://registry.npmjs.org/@connext/cf-core/-/cf-core-1.2.9.tgz", - "integrity": "sha512-t/bQs0CScm8mZInFyy81/xEL85kpQwL+liF43FIOrpmXjZba8b+vwGMP0O1rzBQvSlh3gtaTiZwOchb/BNHiZA==", - "dev": true, - "requires": { - "@connext/cf-adjudicator-contracts": "0.4.1", - "@connext/cf-funding-protocol-contracts": "0.4.1", - "@connext/types": "1.2.9", - "@counterfactual/cf-adjudicator-contracts": "0.0.9", - "@counterfactual/cf-funding-protocol-contracts": "0.0.12", - "ethers": "4.0.39", - "eventemitter3": "4.0.0", - "loglevel": "1.6.6", - "p-queue": "5.0.0", - "rpc-server": "0.0.1", - "typescript-memoize": "1.0.0-alpha.3", - "uuid": "3.3.3" - }, - "dependencies": { - "@connext/cf-core": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/@connext/cf-core/-/cf-core-1.2.8.tgz", - "integrity": "sha512-IXgnEaGF/80luU8cpTNugiyj9UzTFLgLjYNVrlHKzrtYAk4EEVNLfTIRYI3KR1756ZIXZsnx6Fm8+M1GLmAtug==", - "requires": { - "@connext/cf-adjudicator-contracts": "0.4.1", - "@connext/cf-funding-protocol-contracts": "0.4.1", - "@connext/types": "1.2.8", - "@counterfactual/cf-adjudicator-contracts": "0.0.9", - "@counterfactual/cf-funding-protocol-contracts": "0.0.12", - "ethers": "4.0.39", - "eventemitter3": "4.0.0", - "loglevel": "1.6.6", - "p-queue": "5.0.0", - "rpc-server": "0.0.1", - "typescript-memoize": "1.0.0-alpha.3", - "uuid": "3.3.3" - }, - "dependencies": { - "@connext/cf-core": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/@connext/cf-core/-/cf-core-1.2.7.tgz", - "integrity": "sha512-0g3vq2OmvDtuLCKREhA6eX2H8anOkDFekqj2hgKznRXDqHRUbnJ81/4NuIespTEwFbkY5QhKynXIV6shGrHebQ==", - "requires": { - "@connext/cf-adjudicator-contracts": "0.4.1", - "@connext/cf-funding-protocol-contracts": "0.4.1", - "@connext/types": "1.2.7", - "@counterfactual/cf-adjudicator-contracts": "0.0.9", - "@counterfactual/cf-funding-protocol-contracts": "0.0.12", - "ethers": "4.0.39", - "eventemitter3": "4.0.0", - "loglevel": "1.6.6", - "p-queue": "5.0.0", - "rpc-server": "0.0.1", - "typescript-memoize": "1.0.0-alpha.3", - "uuid": "3.3.3" - }, - "dependencies": { - "@connext/cf-core": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/@connext/cf-core/-/cf-core-1.2.6.tgz", - "integrity": "sha512-xoS+1j60SWwS/yN7DaqCS+3WOu0lHk3wpaUV41CTwTSY2m44KGjjROmlOJcKyjzQz4gsxcEdN4kQy6JuOu6Wdg==", - "requires": { - "@connext/cf-adjudicator-contracts": "0.4.1", - "@connext/cf-funding-protocol-contracts": "0.4.1", - "@connext/types": "1.2.6", - "@counterfactual/cf-adjudicator-contracts": "0.0.9", - "@counterfactual/cf-funding-protocol-contracts": "0.0.12", - "ethers": "4.0.39", - "eventemitter3": "4.0.0", - "loglevel": "1.6.6", - "p-queue": "5.0.0", - "rpc-server": "0.0.1", - "typescript-memoize": "1.0.0-alpha.3", - "uuid": "3.3.3" - }, - "dependencies": { - "@connext/cf-core": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@connext/cf-core/-/cf-core-1.1.3.tgz", - "integrity": "sha512-ArgCXQPyDqLpp2wc6a9zq+oB5/2ck71Urlt0cZPOL29L5SVQeUGWi4OXGWkAdnWrerIBllAdxfTfLsY3iZAdHQ==", - "requires": { - "@connext/cf-adjudicator-contracts": "0.4.1", - "@connext/cf-funding-protocol-contracts": "0.4.1", - "@connext/types": "1.1.3", - "@counterfactual/cf-adjudicator-contracts": "0.0.9", - "@counterfactual/cf-funding-protocol-contracts": "0.0.12", - "ethers": "4.0.39", - "eventemitter3": "4.0.0", - "loglevel": "1.6.6", - "p-queue": "5.0.0", - "rpc-server": "0.0.1", - "typescript-memoize": "1.0.0-alpha.3", - "uuid": "3.3.3" - }, - "dependencies": { - "@connext/cf-types": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@connext/cf-types/-/cf-types-1.1.3.tgz", - "integrity": "sha512-OciorXhBa8aIdHM13g3JBr/xsVdjI9XZotMlNlL2ozrgXWo5YSqgFexQ2LgcXrmqJGsLPshYIHChnm9gxUMT+g==" - }, - "@connext/types": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@connext/types/-/types-1.1.3.tgz", - "integrity": "sha512-Y2n2PkDV+xI6JdWNJMH5Oyj9P/cKDHm2filWZDqEfu7DkcuzJzsPhnYnK9PwsduAppv56xXB7Z+Qst8GA1uhlA==", - "requires": { - "@connext/cf-types": "1.1.3", - "ethers": "4.0.39" - } - } - } - }, - "@connext/cf-types": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/@connext/cf-types/-/cf-types-1.2.6.tgz", - "integrity": "sha512-aVVqMSpIF6HSFty8Mf0uOMqiVtUH8iOVftWV4aWE6MtnZF8E3VQKzCKxxt3tVWgFtLUaffVg0CyWdq9w/QPMIA==" - }, - "@connext/types": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/@connext/types/-/types-1.2.6.tgz", - "integrity": "sha512-u0jl7XXF6a6cZctVk4Jtb41SEYw++UM+YcYX7FefD0V1JcwtYT1zTGRhmlvN/+XBOiLQlva4TGr1qdT0pY27VA==", - "requires": { - "@connext/cf-types": "1.2.6", - "ethers": "4.0.39" - } - } - } - }, - "@connext/cf-types": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/@connext/cf-types/-/cf-types-1.2.7.tgz", - "integrity": "sha512-+INl2Zwh3/mwALO9z28eqciDm8n1ZIcI/gpBaU3FTFWaiimoFxWwil773PYMNbsg2SXnG5SAq3lnDbNrncnNnw==" - }, - "@connext/types": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/@connext/types/-/types-1.2.7.tgz", - "integrity": "sha512-qvccuzeEg4duuLJ5tplcyA9DnhpCuh5Gz6KKOw15uBZXXSpW18zVsDRpYJm8oLJD5fR2Pjxu8sPaGmgSYM4DFw==", - "requires": { - "@connext/cf-types": "1.2.7", - "ethers": "4.0.39" - } - } - } - }, - "@connext/cf-types": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/@connext/cf-types/-/cf-types-1.2.8.tgz", - "integrity": "sha512-Cewt7rVs8XMWcXAxGneL4HbLYTyMvBo/7bUZwKybqiiM5jUm9701l/JIgRzGL1wquoPzNWBxZPBVVIfOkUaJ+A==" - }, - "@connext/types": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/@connext/types/-/types-1.2.8.tgz", - "integrity": "sha512-8XunB2UuhYujSU0XezLWLuHfX3lD3O+KegWkEdpjECEqvzsLwSfv+VHAuBA7BnD5FlLMeYxQnTE7jr/HHu9TIg==", - "requires": { - "@connext/cf-types": "1.2.8", - "ethers": "4.0.39" - } - } - } - }, - "@connext/cf-types": { - "version": "1.2.9", - "resolved": "https://registry.npmjs.org/@connext/cf-types/-/cf-types-1.2.9.tgz", - "integrity": "sha512-SYFXixX8KIYhQ4ffO9ycSDJGhqGAqumCHrbt/UBHqgqOdLFNPjL2uKrGUf39PHtVkaUdY3VRPIiDJR8by1LIfw==", - "dev": true - }, - "@connext/types": { - "version": "1.2.9", - "resolved": "https://registry.npmjs.org/@connext/types/-/types-1.2.9.tgz", - "integrity": "sha512-sAlZp0O3WzrF47/sQLPBZwpKP9yPZExuFvmhm7moR/fY+vfdag7Pj2zFMLIQYPeq06BpXb/v9XWPg5C8KFimrg==", - "dev": true, - "requires": { - "@connext/cf-core": "1.2.8", - "@connext/cf-types": "1.2.9", - "ethers": "4.0.39" - }, - "dependencies": { - "@connext/cf-core": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/@connext/cf-core/-/cf-core-1.2.8.tgz", - "integrity": "sha512-IXgnEaGF/80luU8cpTNugiyj9UzTFLgLjYNVrlHKzrtYAk4EEVNLfTIRYI3KR1756ZIXZsnx6Fm8+M1GLmAtug==", - "dev": true, - "requires": { - "@connext/cf-adjudicator-contracts": "0.4.1", - "@connext/cf-funding-protocol-contracts": "0.4.1", - "@connext/types": "1.2.8", - "@counterfactual/cf-adjudicator-contracts": "0.0.9", - "@counterfactual/cf-funding-protocol-contracts": "0.0.12", - "ethers": "4.0.39", - "eventemitter3": "4.0.0", - "loglevel": "1.6.6", - "p-queue": "5.0.0", - "rpc-server": "0.0.1", - "typescript-memoize": "1.0.0-alpha.3", - "uuid": "3.3.3" - }, - "dependencies": { - "@connext/cf-core": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/@connext/cf-core/-/cf-core-1.2.7.tgz", - "integrity": "sha512-0g3vq2OmvDtuLCKREhA6eX2H8anOkDFekqj2hgKznRXDqHRUbnJ81/4NuIespTEwFbkY5QhKynXIV6shGrHebQ==", - "requires": { - "@connext/cf-adjudicator-contracts": "0.4.1", - "@connext/cf-funding-protocol-contracts": "0.4.1", - "@connext/types": "1.2.7", - "@counterfactual/cf-adjudicator-contracts": "0.0.9", - "@counterfactual/cf-funding-protocol-contracts": "0.0.12", - "ethers": "4.0.39", - "eventemitter3": "4.0.0", - "loglevel": "1.6.6", - "p-queue": "5.0.0", - "rpc-server": "0.0.1", - "typescript-memoize": "1.0.0-alpha.3", - "uuid": "3.3.3" - }, - "dependencies": { - "@connext/cf-core": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/@connext/cf-core/-/cf-core-1.2.6.tgz", - "integrity": "sha512-xoS+1j60SWwS/yN7DaqCS+3WOu0lHk3wpaUV41CTwTSY2m44KGjjROmlOJcKyjzQz4gsxcEdN4kQy6JuOu6Wdg==", - "requires": { - "@connext/cf-adjudicator-contracts": "0.4.1", - "@connext/cf-funding-protocol-contracts": "0.4.1", - "@connext/types": "1.2.6", - "@counterfactual/cf-adjudicator-contracts": "0.0.9", - "@counterfactual/cf-funding-protocol-contracts": "0.0.12", - "ethers": "4.0.39", - "eventemitter3": "4.0.0", - "loglevel": "1.6.6", - "p-queue": "5.0.0", - "rpc-server": "0.0.1", - "typescript-memoize": "1.0.0-alpha.3", - "uuid": "3.3.3" - }, - "dependencies": { - "@connext/cf-core": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@connext/cf-core/-/cf-core-1.1.3.tgz", - "integrity": "sha512-ArgCXQPyDqLpp2wc6a9zq+oB5/2ck71Urlt0cZPOL29L5SVQeUGWi4OXGWkAdnWrerIBllAdxfTfLsY3iZAdHQ==", - "requires": { - "@connext/cf-adjudicator-contracts": "0.4.1", - "@connext/cf-funding-protocol-contracts": "0.4.1", - "@connext/types": "1.1.3", - "@counterfactual/cf-adjudicator-contracts": "0.0.9", - "@counterfactual/cf-funding-protocol-contracts": "0.0.12", - "ethers": "4.0.39", - "eventemitter3": "4.0.0", - "loglevel": "1.6.6", - "p-queue": "5.0.0", - "rpc-server": "0.0.1", - "typescript-memoize": "1.0.0-alpha.3", - "uuid": "3.3.3" - }, - "dependencies": { - "@connext/cf-types": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@connext/cf-types/-/cf-types-1.1.3.tgz", - "integrity": "sha512-OciorXhBa8aIdHM13g3JBr/xsVdjI9XZotMlNlL2ozrgXWo5YSqgFexQ2LgcXrmqJGsLPshYIHChnm9gxUMT+g==" - }, - "@connext/types": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@connext/types/-/types-1.1.3.tgz", - "integrity": "sha512-Y2n2PkDV+xI6JdWNJMH5Oyj9P/cKDHm2filWZDqEfu7DkcuzJzsPhnYnK9PwsduAppv56xXB7Z+Qst8GA1uhlA==", - "requires": { - "@connext/cf-types": "1.1.3", - "ethers": "4.0.39" - } - } - } - }, - "@connext/cf-types": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/@connext/cf-types/-/cf-types-1.2.6.tgz", - "integrity": "sha512-aVVqMSpIF6HSFty8Mf0uOMqiVtUH8iOVftWV4aWE6MtnZF8E3VQKzCKxxt3tVWgFtLUaffVg0CyWdq9w/QPMIA==" - }, - "@connext/types": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/@connext/types/-/types-1.2.6.tgz", - "integrity": "sha512-u0jl7XXF6a6cZctVk4Jtb41SEYw++UM+YcYX7FefD0V1JcwtYT1zTGRhmlvN/+XBOiLQlva4TGr1qdT0pY27VA==", - "requires": { - "@connext/cf-types": "1.2.6", - "ethers": "4.0.39" - } - } - } - }, - "@connext/cf-types": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/@connext/cf-types/-/cf-types-1.2.7.tgz", - "integrity": "sha512-+INl2Zwh3/mwALO9z28eqciDm8n1ZIcI/gpBaU3FTFWaiimoFxWwil773PYMNbsg2SXnG5SAq3lnDbNrncnNnw==" - }, - "@connext/types": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/@connext/types/-/types-1.2.7.tgz", - "integrity": "sha512-qvccuzeEg4duuLJ5tplcyA9DnhpCuh5Gz6KKOw15uBZXXSpW18zVsDRpYJm8oLJD5fR2Pjxu8sPaGmgSYM4DFw==", - "requires": { - "@connext/cf-types": "1.2.7", - "ethers": "4.0.39" - } - } - } - }, - "@connext/cf-types": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/@connext/cf-types/-/cf-types-1.2.8.tgz", - "integrity": "sha512-Cewt7rVs8XMWcXAxGneL4HbLYTyMvBo/7bUZwKybqiiM5jUm9701l/JIgRzGL1wquoPzNWBxZPBVVIfOkUaJ+A==", - "dev": true - }, - "@connext/types": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/@connext/types/-/types-1.2.8.tgz", - "integrity": "sha512-8XunB2UuhYujSU0XezLWLuHfX3lD3O+KegWkEdpjECEqvzsLwSfv+VHAuBA7BnD5FlLMeYxQnTE7jr/HHu9TIg==", - "dev": true, - "requires": { - "@connext/cf-core": "1.2.7", - "@connext/cf-types": "1.2.8", - "ethers": "4.0.39" - }, - "dependencies": { - "@connext/cf-core": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/@connext/cf-core/-/cf-core-1.2.7.tgz", - "integrity": "sha512-0g3vq2OmvDtuLCKREhA6eX2H8anOkDFekqj2hgKznRXDqHRUbnJ81/4NuIespTEwFbkY5QhKynXIV6shGrHebQ==", - "dev": true, - "requires": { - "@connext/cf-adjudicator-contracts": "0.4.1", - "@connext/cf-funding-protocol-contracts": "0.4.1", - "@connext/types": "1.2.7", - "@counterfactual/cf-adjudicator-contracts": "0.0.9", - "@counterfactual/cf-funding-protocol-contracts": "0.0.12", - "ethers": "4.0.39", - "eventemitter3": "4.0.0", - "loglevel": "1.6.6", - "p-queue": "5.0.0", - "rpc-server": "0.0.1", - "typescript-memoize": "1.0.0-alpha.3", - "uuid": "3.3.3" - }, - "dependencies": { - "@connext/cf-core": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/@connext/cf-core/-/cf-core-1.2.6.tgz", - "integrity": "sha512-xoS+1j60SWwS/yN7DaqCS+3WOu0lHk3wpaUV41CTwTSY2m44KGjjROmlOJcKyjzQz4gsxcEdN4kQy6JuOu6Wdg==", - "requires": { - "@connext/cf-adjudicator-contracts": "0.4.1", - "@connext/cf-funding-protocol-contracts": "0.4.1", - "@connext/types": "1.2.6", - "@counterfactual/cf-adjudicator-contracts": "0.0.9", - "@counterfactual/cf-funding-protocol-contracts": "0.0.12", - "ethers": "4.0.39", - "eventemitter3": "4.0.0", - "loglevel": "1.6.6", - "p-queue": "5.0.0", - "rpc-server": "0.0.1", - "typescript-memoize": "1.0.0-alpha.3", - "uuid": "3.3.3" - }, - "dependencies": { - "@connext/cf-core": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@connext/cf-core/-/cf-core-1.1.3.tgz", - "integrity": "sha512-ArgCXQPyDqLpp2wc6a9zq+oB5/2ck71Urlt0cZPOL29L5SVQeUGWi4OXGWkAdnWrerIBllAdxfTfLsY3iZAdHQ==", - "requires": { - "@connext/cf-adjudicator-contracts": "0.4.1", - "@connext/cf-funding-protocol-contracts": "0.4.1", - "@connext/types": "1.1.3", - "@counterfactual/cf-adjudicator-contracts": "0.0.9", - "@counterfactual/cf-funding-protocol-contracts": "0.0.12", - "ethers": "4.0.39", - "eventemitter3": "4.0.0", - "loglevel": "1.6.6", - "p-queue": "5.0.0", - "rpc-server": "0.0.1", - "typescript-memoize": "1.0.0-alpha.3", - "uuid": "3.3.3" - }, - "dependencies": { - "@connext/cf-types": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@connext/cf-types/-/cf-types-1.1.3.tgz", - "integrity": "sha512-OciorXhBa8aIdHM13g3JBr/xsVdjI9XZotMlNlL2ozrgXWo5YSqgFexQ2LgcXrmqJGsLPshYIHChnm9gxUMT+g==" - }, - "@connext/types": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@connext/types/-/types-1.1.3.tgz", - "integrity": "sha512-Y2n2PkDV+xI6JdWNJMH5Oyj9P/cKDHm2filWZDqEfu7DkcuzJzsPhnYnK9PwsduAppv56xXB7Z+Qst8GA1uhlA==", - "requires": { - "@connext/cf-types": "1.1.3", - "ethers": "4.0.39" - } - } - } - }, - "@connext/cf-types": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/@connext/cf-types/-/cf-types-1.2.6.tgz", - "integrity": "sha512-aVVqMSpIF6HSFty8Mf0uOMqiVtUH8iOVftWV4aWE6MtnZF8E3VQKzCKxxt3tVWgFtLUaffVg0CyWdq9w/QPMIA==" - }, - "@connext/types": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/@connext/types/-/types-1.2.6.tgz", - "integrity": "sha512-u0jl7XXF6a6cZctVk4Jtb41SEYw++UM+YcYX7FefD0V1JcwtYT1zTGRhmlvN/+XBOiLQlva4TGr1qdT0pY27VA==", - "requires": { - "@connext/cf-types": "1.2.6", - "ethers": "4.0.39" - } - } - } - }, - "@connext/cf-types": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/@connext/cf-types/-/cf-types-1.2.7.tgz", - "integrity": "sha512-+INl2Zwh3/mwALO9z28eqciDm8n1ZIcI/gpBaU3FTFWaiimoFxWwil773PYMNbsg2SXnG5SAq3lnDbNrncnNnw==", - "dev": true - }, - "@connext/types": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/@connext/types/-/types-1.2.7.tgz", - "integrity": "sha512-qvccuzeEg4duuLJ5tplcyA9DnhpCuh5Gz6KKOw15uBZXXSpW18zVsDRpYJm8oLJD5fR2Pjxu8sPaGmgSYM4DFw==", - "dev": true, - "requires": { - "@connext/cf-core": "1.2.6", - "@connext/cf-types": "1.2.7", - "ethers": "4.0.39" - }, - "dependencies": { - "@connext/cf-core": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/@connext/cf-core/-/cf-core-1.2.6.tgz", - "integrity": "sha512-xoS+1j60SWwS/yN7DaqCS+3WOu0lHk3wpaUV41CTwTSY2m44KGjjROmlOJcKyjzQz4gsxcEdN4kQy6JuOu6Wdg==", - "dev": true, - "requires": { - "@connext/cf-adjudicator-contracts": "0.4.1", - "@connext/cf-funding-protocol-contracts": "0.4.1", - "@connext/types": "1.2.6", - "@counterfactual/cf-adjudicator-contracts": "0.0.9", - "@counterfactual/cf-funding-protocol-contracts": "0.0.12", - "ethers": "4.0.39", - "eventemitter3": "4.0.0", - "loglevel": "1.6.6", - "p-queue": "5.0.0", - "rpc-server": "0.0.1", - "typescript-memoize": "1.0.0-alpha.3", - "uuid": "3.3.3" - }, - "dependencies": { - "@connext/cf-core": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@connext/cf-core/-/cf-core-1.1.3.tgz", - "integrity": "sha512-ArgCXQPyDqLpp2wc6a9zq+oB5/2ck71Urlt0cZPOL29L5SVQeUGWi4OXGWkAdnWrerIBllAdxfTfLsY3iZAdHQ==", - "requires": { - "@connext/cf-adjudicator-contracts": "0.4.1", - "@connext/cf-funding-protocol-contracts": "0.4.1", - "@connext/types": "1.1.3", - "@counterfactual/cf-adjudicator-contracts": "0.0.9", - "@counterfactual/cf-funding-protocol-contracts": "0.0.12", - "ethers": "4.0.39", - "eventemitter3": "4.0.0", - "loglevel": "1.6.6", - "p-queue": "5.0.0", - "rpc-server": "0.0.1", - "typescript-memoize": "1.0.0-alpha.3", - "uuid": "3.3.3" - }, - "dependencies": { - "@connext/cf-types": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@connext/cf-types/-/cf-types-1.1.3.tgz", - "integrity": "sha512-OciorXhBa8aIdHM13g3JBr/xsVdjI9XZotMlNlL2ozrgXWo5YSqgFexQ2LgcXrmqJGsLPshYIHChnm9gxUMT+g==" - }, - "@connext/types": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@connext/types/-/types-1.1.3.tgz", - "integrity": "sha512-Y2n2PkDV+xI6JdWNJMH5Oyj9P/cKDHm2filWZDqEfu7DkcuzJzsPhnYnK9PwsduAppv56xXB7Z+Qst8GA1uhlA==", - "requires": { - "@connext/cf-types": "1.1.3", - "ethers": "4.0.39" - } - } - } - }, - "@connext/cf-types": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/@connext/cf-types/-/cf-types-1.2.6.tgz", - "integrity": "sha512-aVVqMSpIF6HSFty8Mf0uOMqiVtUH8iOVftWV4aWE6MtnZF8E3VQKzCKxxt3tVWgFtLUaffVg0CyWdq9w/QPMIA==", - "dev": true - }, - "@connext/types": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/@connext/types/-/types-1.2.6.tgz", - "integrity": "sha512-u0jl7XXF6a6cZctVk4Jtb41SEYw++UM+YcYX7FefD0V1JcwtYT1zTGRhmlvN/+XBOiLQlva4TGr1qdT0pY27VA==", - "dev": true, - "requires": { - "@connext/cf-core": "1.1.3", - "@connext/cf-types": "1.2.6", - "ethers": "4.0.39" - }, - "dependencies": { - "@connext/cf-core": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@connext/cf-core/-/cf-core-1.1.3.tgz", - "integrity": "sha512-ArgCXQPyDqLpp2wc6a9zq+oB5/2ck71Urlt0cZPOL29L5SVQeUGWi4OXGWkAdnWrerIBllAdxfTfLsY3iZAdHQ==", - "dev": true, - "requires": { - "@connext/cf-adjudicator-contracts": "0.4.1", - "@connext/cf-funding-protocol-contracts": "0.4.1", - "@connext/types": "1.1.3", - "@counterfactual/cf-adjudicator-contracts": "0.0.9", - "@counterfactual/cf-funding-protocol-contracts": "0.0.12", - "ethers": "4.0.39", - "eventemitter3": "4.0.0", - "loglevel": "1.6.6", - "p-queue": "5.0.0", - "rpc-server": "0.0.1", - "typescript-memoize": "1.0.0-alpha.3", - "uuid": "3.3.3" - }, - "dependencies": { - "@connext/cf-types": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@connext/cf-types/-/cf-types-1.1.3.tgz", - "integrity": "sha512-OciorXhBa8aIdHM13g3JBr/xsVdjI9XZotMlNlL2ozrgXWo5YSqgFexQ2LgcXrmqJGsLPshYIHChnm9gxUMT+g==", - "dev": true - }, - "@connext/types": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@connext/types/-/types-1.1.3.tgz", - "integrity": "sha512-Y2n2PkDV+xI6JdWNJMH5Oyj9P/cKDHm2filWZDqEfu7DkcuzJzsPhnYnK9PwsduAppv56xXB7Z+Qst8GA1uhlA==", - "dev": true, - "requires": { - "@connext/cf-types": "1.1.3", - "ethers": "4.0.39" - } - } - } - }, - "@connext/types": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@connext/types/-/types-1.1.3.tgz", - "integrity": "sha512-Y2n2PkDV+xI6JdWNJMH5Oyj9P/cKDHm2filWZDqEfu7DkcuzJzsPhnYnK9PwsduAppv56xXB7Z+Qst8GA1uhlA==", - "requires": { - "@connext/cf-types": "1.1.3", - "ethers": "4.0.39" - }, - "dependencies": { - "@connext/cf-types": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@connext/cf-types/-/cf-types-1.1.3.tgz", - "integrity": "sha512-OciorXhBa8aIdHM13g3JBr/xsVdjI9XZotMlNlL2ozrgXWo5YSqgFexQ2LgcXrmqJGsLPshYIHChnm9gxUMT+g==" - } - } - } - } - } - } - }, - "@connext/types": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/@connext/types/-/types-1.2.6.tgz", - "integrity": "sha512-u0jl7XXF6a6cZctVk4Jtb41SEYw++UM+YcYX7FefD0V1JcwtYT1zTGRhmlvN/+XBOiLQlva4TGr1qdT0pY27VA==", - "requires": { - "@connext/cf-core": "1.1.3", - "@connext/cf-types": "1.2.6", - "ethers": "4.0.39" - }, - "dependencies": { - "@connext/cf-core": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@connext/cf-core/-/cf-core-1.1.3.tgz", - "integrity": "sha512-ArgCXQPyDqLpp2wc6a9zq+oB5/2ck71Urlt0cZPOL29L5SVQeUGWi4OXGWkAdnWrerIBllAdxfTfLsY3iZAdHQ==", - "requires": { - "@connext/cf-adjudicator-contracts": "0.4.1", - "@connext/cf-funding-protocol-contracts": "0.4.1", - "@counterfactual/cf-adjudicator-contracts": "0.0.9", - "@counterfactual/cf-funding-protocol-contracts": "0.0.12", - "ethers": "4.0.39", - "eventemitter3": "4.0.0", - "loglevel": "1.6.6", - "p-queue": "5.0.0", - "rpc-server": "0.0.1", - "typescript-memoize": "1.0.0-alpha.3", - "uuid": "3.3.3" - } - }, - "@connext/cf-types": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/@connext/cf-types/-/cf-types-1.2.6.tgz", - "integrity": "sha512-aVVqMSpIF6HSFty8Mf0uOMqiVtUH8iOVftWV4aWE6MtnZF8E3VQKzCKxxt3tVWgFtLUaffVg0CyWdq9w/QPMIA==" - }, - "@connext/types": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@connext/types/-/types-1.1.3.tgz", - "integrity": "sha512-Y2n2PkDV+xI6JdWNJMH5Oyj9P/cKDHm2filWZDqEfu7DkcuzJzsPhnYnK9PwsduAppv56xXB7Z+Qst8GA1uhlA==", - "requires": { - "@connext/cf-types": "1.1.3", - "ethers": "4.0.39" - }, - "dependencies": { - "@connext/cf-types": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@connext/cf-types/-/cf-types-1.1.3.tgz", - "integrity": "sha512-OciorXhBa8aIdHM13g3JBr/xsVdjI9XZotMlNlL2ozrgXWo5YSqgFexQ2LgcXrmqJGsLPshYIHChnm9gxUMT+g==" - } - } - } - } - } - } - } - } - }, - "@connext/types": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/@connext/types/-/types-1.2.7.tgz", - "integrity": "sha512-qvccuzeEg4duuLJ5tplcyA9DnhpCuh5Gz6KKOw15uBZXXSpW18zVsDRpYJm8oLJD5fR2Pjxu8sPaGmgSYM4DFw==", - "requires": { - "@connext/cf-core": "1.2.6", - "@connext/cf-types": "1.2.7", - "ethers": "4.0.39" - }, - "dependencies": { - "@connext/cf-core": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/@connext/cf-core/-/cf-core-1.2.6.tgz", - "integrity": "sha512-xoS+1j60SWwS/yN7DaqCS+3WOu0lHk3wpaUV41CTwTSY2m44KGjjROmlOJcKyjzQz4gsxcEdN4kQy6JuOu6Wdg==", - "requires": { - "@connext/cf-adjudicator-contracts": "0.4.1", - "@connext/cf-funding-protocol-contracts": "0.4.1", - "@counterfactual/cf-adjudicator-contracts": "0.0.9", - "@counterfactual/cf-funding-protocol-contracts": "0.0.12", - "ethers": "4.0.39", - "eventemitter3": "4.0.0", - "loglevel": "1.6.6", - "p-queue": "5.0.0", - "rpc-server": "0.0.1", - "typescript-memoize": "1.0.0-alpha.3", - "uuid": "3.3.3" - } - }, - "@connext/cf-types": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/@connext/cf-types/-/cf-types-1.2.7.tgz", - "integrity": "sha512-+INl2Zwh3/mwALO9z28eqciDm8n1ZIcI/gpBaU3FTFWaiimoFxWwil773PYMNbsg2SXnG5SAq3lnDbNrncnNnw==" - }, - "@connext/types": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/@connext/types/-/types-1.2.6.tgz", - "integrity": "sha512-u0jl7XXF6a6cZctVk4Jtb41SEYw++UM+YcYX7FefD0V1JcwtYT1zTGRhmlvN/+XBOiLQlva4TGr1qdT0pY27VA==", - "requires": { - "@connext/cf-core": "1.1.3", - "@connext/cf-types": "1.2.6", - "ethers": "4.0.39" - }, - "dependencies": { - "@connext/cf-core": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@connext/cf-core/-/cf-core-1.1.3.tgz", - "integrity": "sha512-ArgCXQPyDqLpp2wc6a9zq+oB5/2ck71Urlt0cZPOL29L5SVQeUGWi4OXGWkAdnWrerIBllAdxfTfLsY3iZAdHQ==", - "requires": { - "@connext/cf-adjudicator-contracts": "0.4.1", - "@connext/cf-funding-protocol-contracts": "0.4.1", - "@counterfactual/cf-adjudicator-contracts": "0.0.9", - "@counterfactual/cf-funding-protocol-contracts": "0.0.12", - "ethers": "4.0.39", - "eventemitter3": "4.0.0", - "loglevel": "1.6.6", - "p-queue": "5.0.0", - "rpc-server": "0.0.1", - "typescript-memoize": "1.0.0-alpha.3", - "uuid": "3.3.3" - } - }, - "@connext/cf-types": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/@connext/cf-types/-/cf-types-1.2.6.tgz", - "integrity": "sha512-aVVqMSpIF6HSFty8Mf0uOMqiVtUH8iOVftWV4aWE6MtnZF8E3VQKzCKxxt3tVWgFtLUaffVg0CyWdq9w/QPMIA==" - }, - "@connext/types": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@connext/types/-/types-1.1.3.tgz", - "integrity": "sha512-Y2n2PkDV+xI6JdWNJMH5Oyj9P/cKDHm2filWZDqEfu7DkcuzJzsPhnYnK9PwsduAppv56xXB7Z+Qst8GA1uhlA==", - "requires": { - "@connext/cf-types": "1.1.3", - "ethers": "4.0.39" - }, - "dependencies": { - "@connext/cf-types": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@connext/cf-types/-/cf-types-1.1.3.tgz", - "integrity": "sha512-OciorXhBa8aIdHM13g3JBr/xsVdjI9XZotMlNlL2ozrgXWo5YSqgFexQ2LgcXrmqJGsLPshYIHChnm9gxUMT+g==" - } - } - } - } - } - } - } - } - } - } - }, - "@connext/types": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/@connext/types/-/types-1.2.8.tgz", - "integrity": "sha512-8XunB2UuhYujSU0XezLWLuHfX3lD3O+KegWkEdpjECEqvzsLwSfv+VHAuBA7BnD5FlLMeYxQnTE7jr/HHu9TIg==", - "requires": { - "@connext/cf-core": "1.2.7", - "@connext/cf-types": "1.2.8", - "ethers": "4.0.39" - }, - "dependencies": { - "@connext/cf-core": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/@connext/cf-core/-/cf-core-1.2.7.tgz", - "integrity": "sha512-0g3vq2OmvDtuLCKREhA6eX2H8anOkDFekqj2hgKznRXDqHRUbnJ81/4NuIespTEwFbkY5QhKynXIV6shGrHebQ==", - "requires": { - "@connext/cf-adjudicator-contracts": "0.4.1", - "@connext/cf-funding-protocol-contracts": "0.4.1", - "@counterfactual/cf-adjudicator-contracts": "0.0.9", - "@counterfactual/cf-funding-protocol-contracts": "0.0.12", - "ethers": "4.0.39", - "eventemitter3": "4.0.0", - "loglevel": "1.6.6", - "p-queue": "5.0.0", - "rpc-server": "0.0.1", - "typescript-memoize": "1.0.0-alpha.3", - "uuid": "3.3.3" - } - }, - "@connext/cf-types": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/@connext/cf-types/-/cf-types-1.2.8.tgz", - "integrity": "sha512-Cewt7rVs8XMWcXAxGneL4HbLYTyMvBo/7bUZwKybqiiM5jUm9701l/JIgRzGL1wquoPzNWBxZPBVVIfOkUaJ+A==" - }, - "@connext/types": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/@connext/types/-/types-1.2.7.tgz", - "integrity": "sha512-qvccuzeEg4duuLJ5tplcyA9DnhpCuh5Gz6KKOw15uBZXXSpW18zVsDRpYJm8oLJD5fR2Pjxu8sPaGmgSYM4DFw==", - "requires": { - "@connext/cf-core": "1.2.6", - "@connext/cf-types": "1.2.7", - "ethers": "4.0.39" - }, - "dependencies": { - "@connext/cf-core": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/@connext/cf-core/-/cf-core-1.2.6.tgz", - "integrity": "sha512-xoS+1j60SWwS/yN7DaqCS+3WOu0lHk3wpaUV41CTwTSY2m44KGjjROmlOJcKyjzQz4gsxcEdN4kQy6JuOu6Wdg==", - "requires": { - "@connext/cf-adjudicator-contracts": "0.4.1", - "@connext/cf-funding-protocol-contracts": "0.4.1", - "@counterfactual/cf-adjudicator-contracts": "0.0.9", - "@counterfactual/cf-funding-protocol-contracts": "0.0.12", - "ethers": "4.0.39", - "eventemitter3": "4.0.0", - "loglevel": "1.6.6", - "p-queue": "5.0.0", - "rpc-server": "0.0.1", - "typescript-memoize": "1.0.0-alpha.3", - "uuid": "3.3.3" - } - }, - "@connext/cf-types": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/@connext/cf-types/-/cf-types-1.2.7.tgz", - "integrity": "sha512-+INl2Zwh3/mwALO9z28eqciDm8n1ZIcI/gpBaU3FTFWaiimoFxWwil773PYMNbsg2SXnG5SAq3lnDbNrncnNnw==" - }, - "@connext/types": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/@connext/types/-/types-1.2.6.tgz", - "integrity": "sha512-u0jl7XXF6a6cZctVk4Jtb41SEYw++UM+YcYX7FefD0V1JcwtYT1zTGRhmlvN/+XBOiLQlva4TGr1qdT0pY27VA==", - "requires": { - "@connext/cf-core": "1.1.3", - "@connext/cf-types": "1.2.6", - "ethers": "4.0.39" - }, - "dependencies": { - "@connext/cf-core": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@connext/cf-core/-/cf-core-1.1.3.tgz", - "integrity": "sha512-ArgCXQPyDqLpp2wc6a9zq+oB5/2ck71Urlt0cZPOL29L5SVQeUGWi4OXGWkAdnWrerIBllAdxfTfLsY3iZAdHQ==", - "requires": { - "@connext/cf-adjudicator-contracts": "0.4.1", - "@connext/cf-funding-protocol-contracts": "0.4.1", - "@counterfactual/cf-adjudicator-contracts": "0.0.9", - "@counterfactual/cf-funding-protocol-contracts": "0.0.12", - "ethers": "4.0.39", - "eventemitter3": "4.0.0", - "loglevel": "1.6.6", - "p-queue": "5.0.0", - "rpc-server": "0.0.1", - "typescript-memoize": "1.0.0-alpha.3", - "uuid": "3.3.3" - } - }, - "@connext/cf-types": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/@connext/cf-types/-/cf-types-1.2.6.tgz", - "integrity": "sha512-aVVqMSpIF6HSFty8Mf0uOMqiVtUH8iOVftWV4aWE6MtnZF8E3VQKzCKxxt3tVWgFtLUaffVg0CyWdq9w/QPMIA==" - }, - "@connext/types": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@connext/types/-/types-1.1.3.tgz", - "integrity": "sha512-Y2n2PkDV+xI6JdWNJMH5Oyj9P/cKDHm2filWZDqEfu7DkcuzJzsPhnYnK9PwsduAppv56xXB7Z+Qst8GA1uhlA==", - "requires": { - "@connext/cf-types": "1.1.3", - "ethers": "4.0.39" - }, - "dependencies": { - "@connext/cf-types": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@connext/cf-types/-/cf-types-1.1.3.tgz", - "integrity": "sha512-OciorXhBa8aIdHM13g3JBr/xsVdjI9XZotMlNlL2ozrgXWo5YSqgFexQ2LgcXrmqJGsLPshYIHChnm9gxUMT+g==" - } - } - } - } - } - } - } - } - } - } - }, - "@types/node": { - "version": "10.17.7", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.7.tgz", - "integrity": "sha512-P/82C+0fGuQW8/z2MbcJ337e9rrj32zuag00P+Yim/DU/u/bwERwHiMKE6Nnc/rXZaxa5/6IdvWZXG3/qhStZg==" - }, - "bn.js": { - "version": "4.11.8", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", - "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==" - }, - "ethers": { - "version": "4.0.39", - "resolved": "https://registry.npmjs.org/ethers/-/ethers-4.0.39.tgz", - "integrity": "sha512-QVtC8TTUgTrnlQjQvdFJ7fkSWKwp8HVTbKRmrdbVryrPzJHMTf3WSeRNvLF2enGyAFtyHJyFNnjN0fSshcEr9w==", - "requires": { - "@types/node": "^10.3.2", - "aes-js": "3.0.0", - "bn.js": "^4.4.0", - "elliptic": "6.3.3", - "hash.js": "1.1.3", - "js-sha3": "0.5.7", - "scrypt-js": "2.0.4", - "setimmediate": "1.0.4", - "uuid": "2.0.1", - "xmlhttprequest": "1.8.0" - }, - "dependencies": { - "uuid": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.1.tgz", - "integrity": "sha1-wqMN7bPlNdcsz4LjQ5QaULqFM6w=" - } - } - } - } + "integrity": "sha512-KSWdLY5Tfob89ZVyfuXIt+O+dri7aCdIYOf6HkxW8o//ohEFmbS21DeySOSGLhrQctPEGa49lCAKxVU9YR0MPQ==", + "dev": true }, "@connext/cf-funding-protocol-contracts": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/@connext/cf-funding-protocol-contracts/-/cf-funding-protocol-contracts-0.4.1.tgz", - "integrity": "sha512-Wq0/U01gM/OSGp5sAG3WHltKSdpukdSUI45mG0VxZWqHGunZPVcwXrrf8K+eE8vja1DEnmKhyVx3+T7PE1/Pjw==" + "integrity": "sha512-Wq0/U01gM/OSGp5sAG3WHltKSdpukdSUI45mG0VxZWqHGunZPVcwXrrf8K+eE8vja1DEnmKhyVx3+T7PE1/Pjw==", + "dev": true }, "@connext/cf-types": { - "version": "1.2.14", - "resolved": "https://registry.npmjs.org/@connext/cf-types/-/cf-types-1.2.14.tgz", - "integrity": "sha512-vT7W95DR4pp3lieTa/NMWdmnmYjDOvUwBjTgpucx+D3GbMHJM/+NJst/v7HoGiaZC7/UxzZomeJmFyh8tt3ETw==", - "dev": true + "version": "1.3.14", + "resolved": "https://registry.npmjs.org/@connext/cf-types/-/cf-types-1.3.14.tgz", + "integrity": "sha512-1gRrdGxhkwSY9GIbgWWVJRIEuPChdpeujG9GVEigIOlysgQVP3/sdYU5XwcBKrmzxFDR63g/Z55Ix1NWAe5CwQ==" }, "@connext/types": { - "version": "1.2.14", - "resolved": "https://registry.npmjs.org/@connext/types/-/types-1.2.14.tgz", - "integrity": "sha512-NBACU/S8OIy2xolaXSeeRLbdxP3uvgtmmk8nVhOi5AVcnWvLnbk9J9JO0p9AbO8/5tzkGjiwC09raJmZL8LzoA==", + "version": "1.3.10", + "resolved": "https://registry.npmjs.org/@connext/types/-/types-1.3.10.tgz", + "integrity": "sha512-OwYyxu4K94jFYnnyfPksu2scDIvejM42uaWocdWN8eycJ9k09D4yXIWGVn0maid4Es5d+6FeXucQ+0Saz47s9A==", "dev": true, "requires": { - "@connext/cf-core": "1.2.9", - "@connext/cf-types": "1.2.14", - "ethers": "4.0.39" + "@connext/cf-types": "1.3.10", + "ethers": "4.0.40" }, "dependencies": { - "@types/node": { - "version": "10.17.7", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.7.tgz", - "integrity": "sha512-P/82C+0fGuQW8/z2MbcJ337e9rrj32zuag00P+Yim/DU/u/bwERwHiMKE6Nnc/rXZaxa5/6IdvWZXG3/qhStZg==", - "dev": true - }, - "bn.js": { - "version": "4.11.8", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", - "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", - "dev": true - }, - "ethers": { - "version": "4.0.39", - "resolved": "https://registry.npmjs.org/ethers/-/ethers-4.0.39.tgz", - "integrity": "sha512-QVtC8TTUgTrnlQjQvdFJ7fkSWKwp8HVTbKRmrdbVryrPzJHMTf3WSeRNvLF2enGyAFtyHJyFNnjN0fSshcEr9w==", - "dev": true, - "requires": { - "@types/node": "^10.3.2", - "aes-js": "3.0.0", - "bn.js": "^4.4.0", - "elliptic": "6.3.3", - "hash.js": "1.1.3", - "js-sha3": "0.5.7", - "scrypt-js": "2.0.4", - "setimmediate": "1.0.4", - "uuid": "2.0.1", - "xmlhttprequest": "1.8.0" - } - }, - "uuid": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.1.tgz", - "integrity": "sha1-wqMN7bPlNdcsz4LjQ5QaULqFM6w=", + "@connext/cf-types": { + "version": "1.3.10", + "resolved": "https://registry.npmjs.org/@connext/cf-types/-/cf-types-1.3.10.tgz", + "integrity": "sha512-LEJE0chH6cDrlox2HzNw/Q2G3j1VAzK0r9yic8KG/nwyfqYoriCQ4dpZnMey+ly0Daf/rf+ZEIFOr1BPHqk3IA==", "dev": true } } @@ -1939,9 +1049,9 @@ }, "dependencies": { "@types/node": { - "version": "10.17.7", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.7.tgz", - "integrity": "sha512-P/82C+0fGuQW8/z2MbcJ337e9rrj32zuag00P+Yim/DU/u/bwERwHiMKE6Nnc/rXZaxa5/6IdvWZXG3/qhStZg==" + "version": "10.17.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.9.tgz", + "integrity": "sha512-+6VygF9LbG7Gaqeog2G7u1+RUcmo0q1rI+2ZxdIg2fAUngk5Vz9fOCHXdloNUOHEPd1EuuOpL5O0CdgN9Fx5UQ==" }, "bn.js": { "version": "4.11.8", @@ -5792,59 +4902,70 @@ } }, "@walletconnect/browser": { - "version": "1.0.0-beta.39", - "resolved": "https://registry.npmjs.org/@walletconnect/browser/-/browser-1.0.0-beta.39.tgz", - "integrity": "sha512-u6DI2atFSCUquvXd86p+EY/TVqg9iZf3MYMVbnht2hxmuypBwZvfLkqSxqP/98bmOwUrOwbAt3/fK8vZoSfXiA==", + "version": "1.0.0-beta.41", + "resolved": "https://registry.npmjs.org/@walletconnect/browser/-/browser-1.0.0-beta.41.tgz", + "integrity": "sha512-mz9Vfd1gADEVIr1BPfmrCBtt8ClrCeIyJYhZwE4ZBL8m91cj71DYWCYEHOPHLcgieNdNKzrjadsYmTFFZWxFFQ==", "requires": { - "@walletconnect/core": "^1.0.0-beta.39", - "@walletconnect/types": "^1.0.0-beta.39", - "@walletconnect/utils": "^1.0.0-beta.39" + "@walletconnect/core": "^1.0.0-beta.41", + "@walletconnect/types": "^1.0.0-beta.41", + "@walletconnect/utils": "^1.0.0-beta.41" } }, "@walletconnect/channel-provider": { - "version": "1.0.0-beta.39", - "resolved": "https://registry.npmjs.org/@walletconnect/channel-provider/-/channel-provider-1.0.0-beta.39.tgz", - "integrity": "sha512-b22e4N221EMjE6QSyt/mmBqqDulizpPAzGwuonoTssWolZsH8tT2HQD/KBf8N+OyWsIfWC0CLAiKWzV8Z9H+mw==", - "requires": { - "@walletconnect/browser": "^1.0.0-beta.39", - "@walletconnect/qrcode-modal": "^1.0.0-beta.39", - "@walletconnect/types": "^1.0.0-beta.39", - "@walletconnect/utils": "^1.0.0-beta.39", + "version": "1.0.0-beta.41", + "resolved": "https://registry.npmjs.org/@walletconnect/channel-provider/-/channel-provider-1.0.0-beta.41.tgz", + "integrity": "sha512-P5XPjz7O5hDs88KpozGoFeJjETqNUemluC/MRYsEyGaFoUbqr1rWqIiTUXqiMPMRygM5+Jokw1SfLFh9PRtPhw==", + "requires": { + "@connext/types": "1.4.0", + "@walletconnect/browser": "^1.0.0-beta.41", + "@walletconnect/qrcode-modal": "^1.0.0-beta.41", + "@walletconnect/types": "^1.0.0-beta.41", + "@walletconnect/utils": "^1.0.0-beta.41", "xhr2-cookies": "^1.1.0" + }, + "dependencies": { + "@connext/types": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@connext/types/-/types-1.4.0.tgz", + "integrity": "sha512-8w3QImRQtPUsf4QaDf7gbeR4Y3K1Wm/6HDsvMzHbcApVaGbAdfbOYBgY56Xx+By2DjXBeKmVBkT5abx8+5Bg2Q==", + "requires": { + "ethers": "4.0.40" + } + } } }, "@walletconnect/core": { - "version": "1.0.0-beta.39", - "resolved": "https://registry.npmjs.org/@walletconnect/core/-/core-1.0.0-beta.39.tgz", - "integrity": "sha512-cJSQe2Ao4okSvohNjA7Bs7Z+0BAznfVVTWBECIX/bGoSFpkAWabGY2Pn2gIYhobQMLSFpE6ZlZ4QfvlPO8HyPw==", + "version": "1.0.0-beta.41", + "resolved": "https://registry.npmjs.org/@walletconnect/core/-/core-1.0.0-beta.41.tgz", + "integrity": "sha512-jVj01+K+CyPSG3S2OdeSjJeazGfMBpy/g9wB0yK1svhcsoWbzqQcjvEPlfDOAXAZyjjRneDxgtdF9+SphAD3Hg==", "requires": { - "@walletconnect/types": "^1.0.0-beta.39", - "@walletconnect/utils": "^1.0.0-beta.39" + "@walletconnect/types": "^1.0.0-beta.41", + "@walletconnect/utils": "^1.0.0-beta.41" } }, "@walletconnect/qrcode-modal": { - "version": "1.0.0-beta.39", - "resolved": "https://registry.npmjs.org/@walletconnect/qrcode-modal/-/qrcode-modal-1.0.0-beta.39.tgz", - "integrity": "sha512-8CEtrol3s8Kki1fx3OvHn5mz54WytHunZ9gHMSqPPVe4HJITOfGFUPwM9W5c+dfVAE0ytYKck2UVv3ASpGRi5w==", + "version": "1.0.0-beta.41", + "resolved": "https://registry.npmjs.org/@walletconnect/qrcode-modal/-/qrcode-modal-1.0.0-beta.41.tgz", + "integrity": "sha512-eZTuB/OGrDGBexalD67DK+sy7wnCZqcXNRjPItHh5ge4AV3eGMoIIFfg2kxmhPoUNSqs1kfFIwyM8t+FObKrPg==", "requires": { "qr-image": "^3.2.0", "qrcode-terminal": "^0.12.0" } }, "@walletconnect/types": { - "version": "1.0.0-beta.39", - "resolved": "https://registry.npmjs.org/@walletconnect/types/-/types-1.0.0-beta.39.tgz", - "integrity": "sha512-YO/g1HVnFxcMNiUI9LEWEDe5uVHw8D7JzJol+bT71iXymzolnsbG32OayCJM9nHqT48Rpz1EGIno8EjW9jH2OQ==" + "version": "1.0.0-beta.41", + "resolved": "https://registry.npmjs.org/@walletconnect/types/-/types-1.0.0-beta.41.tgz", + "integrity": "sha512-rqi8vH3q3RDPsJVX8pTPJr/3FK1XX5AAq7cmD4W3kLiAkO/e7NMaf1XrVRCpJOe7rWd9aULlnO4KTw+9GuWcSg==" }, "@walletconnect/utils": { - "version": "1.0.0-beta.39", - "resolved": "https://registry.npmjs.org/@walletconnect/utils/-/utils-1.0.0-beta.39.tgz", - "integrity": "sha512-AOlhPkK+IUzGG5iDTupKdUwNW4on1aAj5NyLMMN1+htr06hqaCV8F9HeYibSen22wdSUuLXkIQNy3SR3LPcehA==", + "version": "1.0.0-beta.41", + "resolved": "https://registry.npmjs.org/@walletconnect/utils/-/utils-1.0.0-beta.41.tgz", + "integrity": "sha512-QEVbueEQ9aBeHk32Ve+neMlYrSILO5ILOyVj9+Ow7OYtgnwDhOuR23esG+W1lgLdtcdV3mmxc8UXRl9OIclkag==", "requires": { "@ethersproject/address": "^5.0.0-beta.125", "@ethersproject/bytes": "^5.0.0-beta.126", "@ethersproject/strings": "^5.0.0-beta.125", - "@walletconnect/types": "^1.0.0-beta.39", + "@walletconnect/types": "^1.0.0-beta.41", "bignumber.js": "^8.1.1" } }, @@ -9319,31 +8440,6 @@ } } }, - "css-loader": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/css-loader/-/css-loader-2.1.1.tgz", - "integrity": "sha512-OcKJU/lt232vl1P9EEDamhoO9iKY3tIjY5GU+XDLblAykTdgs6Ux9P1hTHve8nFKy5KPpOXOsVI/hIwi3841+w==", - "requires": { - "camelcase": "^5.2.0", - "icss-utils": "^4.1.0", - "loader-utils": "^1.2.3", - "normalize-path": "^3.0.0", - "postcss": "^7.0.14", - "postcss-modules-extract-imports": "^2.0.0", - "postcss-modules-local-by-default": "^2.0.6", - "postcss-modules-scope": "^2.1.0", - "postcss-modules-values": "^2.0.0", - "postcss-value-parser": "^3.3.0", - "schema-utils": "^1.0.0" - }, - "dependencies": { - "normalize-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==" - } - } - }, "css-prefers-color-scheme": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/css-prefers-color-scheme/-/css-prefers-color-scheme-3.1.1.tgz", @@ -25755,22 +24851,26 @@ "dependencies": { "abbrev": { "version": "1.1.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", "optional": true }, "ansi-regex": { "version": "2.1.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", "optional": true }, "aproba": { "version": "1.2.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", + "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==", "optional": true }, "are-we-there-yet": { "version": "1.1.5", - "bundled": true, + "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz", + "integrity": "sha512-5hYdAkZlcG8tOLujVDTgCT+uPX0VnpAH28gWsLfzpXYm7wP6mp5Q/gYyR7YQ0cKVJcXJnl3j2kpBan13PtQf6w==", "optional": true, "requires": { "delegates": "^1.0.0", @@ -25779,12 +24879,14 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", "optional": true }, "brace-expansion": { "version": "1.1.11", - "bundled": true, + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "optional": true, "requires": { "balanced-match": "^1.0.0", @@ -25793,32 +24895,38 @@ }, "chownr": { "version": "1.1.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.1.tgz", + "integrity": "sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g==", "optional": true }, "code-point-at": { "version": "1.1.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", "optional": true }, "concat-map": { "version": "0.0.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "optional": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", + "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", "optional": true }, "core-util-is": { "version": "1.0.2", - "bundled": true, + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "optional": true }, "debug": { "version": "4.1.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", "optional": true, "requires": { "ms": "^2.1.1" @@ -25826,22 +24934,26 @@ }, "deep-extend": { "version": "0.6.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", + "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", "optional": true }, "delegates": { "version": "1.0.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", + "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=", "optional": true }, "detect-libc": { "version": "1.0.3", - "bundled": true, + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", + "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=", "optional": true }, "fs-minipass": { "version": "1.2.5", - "bundled": true, + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.5.tgz", + "integrity": "sha512-JhBl0skXjUPCFH7x6x61gQxrKyXsxB5gcgePLZCwfyCGGsTISMoIeObbrvVeP6Xmyaudw4TT43qV2Gz+iyd2oQ==", "optional": true, "requires": { "minipass": "^2.2.1" @@ -25849,12 +24961,14 @@ }, "fs.realpath": { "version": "1.0.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "optional": true }, "gauge": { "version": "2.7.4", - "bundled": true, + "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", + "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", "optional": true, "requires": { "aproba": "^1.0.3", @@ -25869,7 +24983,8 @@ }, "glob": { "version": "7.1.3", - "bundled": true, + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", + "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", "optional": true, "requires": { "fs.realpath": "^1.0.0", @@ -25882,12 +24997,14 @@ }, "has-unicode": { "version": "2.0.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", + "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=", "optional": true }, "iconv-lite": { "version": "0.4.24", - "bundled": true, + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", "optional": true, "requires": { "safer-buffer": ">= 2.1.2 < 3" @@ -25895,7 +25012,8 @@ }, "ignore-walk": { "version": "3.0.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-3.0.1.tgz", + "integrity": "sha512-DTVlMx3IYPe0/JJcYP7Gxg7ttZZu3IInhuEhbchuqneY9wWe5Ojy2mXLBaQFUQmo0AW2r3qG7m1mg86js+gnlQ==", "optional": true, "requires": { "minimatch": "^3.0.4" @@ -25903,7 +25021,8 @@ }, "inflight": { "version": "1.0.6", - "bundled": true, + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "optional": true, "requires": { "once": "^1.3.0", @@ -25912,17 +25031,20 @@ }, "inherits": { "version": "2.0.3", - "bundled": true, + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "optional": true }, "ini": { "version": "1.3.5", - "bundled": true, + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "optional": true }, "is-fullwidth-code-point": { "version": "1.0.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "optional": true, "requires": { "number-is-nan": "^1.0.0" @@ -25930,12 +25052,14 @@ }, "isarray": { "version": "1.0.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", "optional": true }, "minimatch": { "version": "3.0.4", - "bundled": true, + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "optional": true, "requires": { "brace-expansion": "^1.1.7" @@ -25943,12 +25067,14 @@ }, "minimist": { "version": "0.0.8", - "bundled": true, + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", "optional": true }, "minipass": { "version": "2.3.5", - "bundled": true, + "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", + "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", "optional": true, "requires": { "safe-buffer": "^5.1.2", @@ -25957,7 +25083,8 @@ }, "minizlib": { "version": "1.2.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.2.1.tgz", + "integrity": "sha512-7+4oTUOWKg7AuL3vloEWekXY2/D20cevzsrNT2kGWm+39J9hGTCBv8VI5Pm5lXZ/o3/mdR4f8rflAPhnQb8mPA==", "optional": true, "requires": { "minipass": "^2.2.1" @@ -25965,7 +25092,8 @@ }, "mkdirp": { "version": "0.5.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "optional": true, "requires": { "minimist": "0.0.8" @@ -25973,12 +25101,14 @@ }, "ms": { "version": "2.1.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", "optional": true }, "needle": { "version": "2.3.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/needle/-/needle-2.3.0.tgz", + "integrity": "sha512-QBZu7aAFR0522EyaXZM0FZ9GLpq6lvQ3uq8gteiDUp7wKdy0lSd2hPlgFwVuW1CBkfEs9PfDQsQzZghLs/psdg==", "optional": true, "requires": { "debug": "^4.1.0", @@ -25988,7 +25118,8 @@ }, "node-pre-gyp": { "version": "0.12.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.12.0.tgz", + "integrity": "sha512-4KghwV8vH5k+g2ylT+sLTjy5wmUOb9vPhnM8NHvRf9dHmnW/CndrFXy2aRPaPST6dugXSdHXfeaHQm77PIz/1A==", "optional": true, "requires": { "detect-libc": "^1.0.2", @@ -26005,7 +25136,8 @@ }, "nopt": { "version": "4.0.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz", + "integrity": "sha1-0NRoWv1UFRk8jHUFYC0NF81kR00=", "optional": true, "requires": { "abbrev": "1", @@ -26014,12 +25146,14 @@ }, "npm-bundled": { "version": "1.0.6", - "bundled": true, + "resolved": "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.0.6.tgz", + "integrity": "sha512-8/JCaftHwbd//k6y2rEWp6k1wxVfpFzB6t1p825+cUb7Ym2XQfhwIC5KwhrvzZRJu+LtDE585zVaS32+CGtf0g==", "optional": true }, "npm-packlist": { "version": "1.4.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-1.4.1.tgz", + "integrity": "sha512-+TcdO7HJJ8peiiYhvPxsEDhF3PJFGUGRcFsGve3vxvxdcpO2Z4Z7rkosRM0kWj6LfbK/P0gu3dzk5RU1ffvFcw==", "optional": true, "requires": { "ignore-walk": "^3.0.1", @@ -26028,7 +25162,8 @@ }, "npmlog": { "version": "4.1.2", - "bundled": true, + "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", + "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", "optional": true, "requires": { "are-we-there-yet": "~1.1.2", @@ -26039,17 +25174,20 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", "optional": true }, "object-assign": { "version": "4.1.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", "optional": true }, "once": { "version": "1.4.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "optional": true, "requires": { "wrappy": "1" @@ -26057,17 +25195,20 @@ }, "os-homedir": { "version": "1.0.2", - "bundled": true, + "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", "optional": true }, "os-tmpdir": { "version": "1.0.2", - "bundled": true, + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", "optional": true }, "osenv": { "version": "0.1.5", - "bundled": true, + "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.5.tgz", + "integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==", "optional": true, "requires": { "os-homedir": "^1.0.0", @@ -26076,17 +25217,20 @@ }, "path-is-absolute": { "version": "1.0.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "optional": true }, "process-nextick-args": { "version": "2.0.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "optional": true }, "rc": { "version": "1.2.8", - "bundled": true, + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", + "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", "optional": true, "requires": { "deep-extend": "^0.6.0", @@ -26097,14 +25241,16 @@ "dependencies": { "minimist": { "version": "1.2.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "optional": true } } }, "readable-stream": { "version": "2.3.6", - "bundled": true, + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "optional": true, "requires": { "core-util-is": "~1.0.0", @@ -26118,7 +25264,8 @@ }, "rimraf": { "version": "2.6.3", - "bundled": true, + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", + "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", "optional": true, "requires": { "glob": "^7.1.3" @@ -26126,37 +25273,44 @@ }, "safe-buffer": { "version": "5.1.2", - "bundled": true, + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", "optional": true }, "safer-buffer": { "version": "2.1.2", - "bundled": true, + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "optional": true }, "sax": { "version": "1.2.4", - "bundled": true, + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", "optional": true }, "semver": { "version": "5.7.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", + "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==", "optional": true }, "set-blocking": { "version": "2.0.0", - "bundled": true, + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", "optional": true }, "signal-exit": { "version": "3.0.2", - "bundled": true, + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", "optional": true }, "string-width": { "version": "1.0.2", - "bundled": true, + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "optional": true, "requires": { "code-point-at": "^1.0.0", @@ -26166,7 +25320,8 @@ }, "string_decoder": { "version": "1.1.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "optional": true, "requires": { "safe-buffer": "~5.1.0" @@ -26174,7 +25329,8 @@ }, "strip-ansi": { "version": "3.0.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "optional": true, "requires": { "ansi-regex": "^2.0.0" @@ -26182,12 +25338,14 @@ }, "strip-json-comments": { "version": "2.0.1", - "bundled": true, + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", "optional": true }, "tar": { "version": "4.4.8", - "bundled": true, + "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.8.tgz", + "integrity": "sha512-LzHF64s5chPQQS0IYBn9IN5h3i98c12bo4NCO7e0sGM2llXQ3p2FGC5sdENN4cTW48O915Sh+x+EXx7XW96xYQ==", "optional": true, "requires": { "chownr": "^1.1.1", @@ -26201,12 +25359,14 @@ }, "util-deprecate": { "version": "1.0.2", - "bundled": true, + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "optional": true }, "wide-align": { "version": "1.1.3", - "bundled": true, + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", + "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", "optional": true, "requires": { "string-width": "^1.0.2 || 2" @@ -26214,12 +25374,14 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true, + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "optional": true }, "yallist": { "version": "3.0.3", - "bundled": true, + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", + "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==", "optional": true } } @@ -26255,12 +25417,14 @@ "dependencies": { "ansi-regex": { "version": "4.1.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", "dev": true }, "ansi-styles": { "version": "3.2.1", - "bundled": true, + "resolved": false, + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, "requires": { "color-convert": "^1.9.0" @@ -26268,7 +25432,8 @@ }, "bindings": { "version": "1.5.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", "dev": true, "requires": { "file-uri-to-path": "1.0.0" @@ -26276,7 +25441,8 @@ }, "bip66": { "version": "1.1.5", - "bundled": true, + "resolved": false, + "integrity": "sha1-AfqHSHhcpwlV1QESF9GzE5lpyiI=", "dev": true, "requires": { "safe-buffer": "^5.0.1" @@ -26284,17 +25450,20 @@ }, "bn.js": { "version": "4.11.8", - "bundled": true, + "resolved": false, + "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", "dev": true }, "brorand": { "version": "1.1.0", - "bundled": true, + "resolved": false, + "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=", "dev": true }, "browserify-aes": { "version": "1.2.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", "dev": true, "requires": { "buffer-xor": "^1.0.3", @@ -26307,22 +25476,26 @@ }, "buffer-from": { "version": "1.1.1", - "bundled": true, + "resolved": false, + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", "dev": true }, "buffer-xor": { "version": "1.0.3", - "bundled": true, + "resolved": false, + "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=", "dev": true }, "camelcase": { "version": "5.3.1", - "bundled": true, + "resolved": false, + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", "dev": true }, "cipher-base": { "version": "1.0.4", - "bundled": true, + "resolved": false, + "integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==", "dev": true, "requires": { "inherits": "^2.0.1", @@ -26331,7 +25504,8 @@ }, "cliui": { "version": "5.0.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==", "dev": true, "requires": { "string-width": "^3.1.0", @@ -26341,7 +25515,8 @@ }, "color-convert": { "version": "1.9.3", - "bundled": true, + "resolved": false, + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", "dev": true, "requires": { "color-name": "1.1.3" @@ -26349,12 +25524,14 @@ }, "color-name": { "version": "1.1.3", - "bundled": true, + "resolved": false, + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", "dev": true }, "create-hash": { "version": "1.2.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", "dev": true, "requires": { "cipher-base": "^1.0.1", @@ -26366,7 +25543,8 @@ }, "create-hmac": { "version": "1.1.7", - "bundled": true, + "resolved": false, + "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", "dev": true, "requires": { "cipher-base": "^1.0.3", @@ -26379,7 +25557,8 @@ }, "cross-spawn": { "version": "6.0.5", - "bundled": true, + "resolved": false, + "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", "dev": true, "requires": { "nice-try": "^1.0.4", @@ -26391,12 +25570,14 @@ }, "decamelize": { "version": "1.2.0", - "bundled": true, + "resolved": false, + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", "dev": true }, "drbg.js": { "version": "1.0.1", - "bundled": true, + "resolved": false, + "integrity": "sha1-Pja2xCs3BDgjzbwzLVjzHiRFSAs=", "dev": true, "requires": { "browserify-aes": "^1.0.6", @@ -26406,7 +25587,8 @@ }, "elliptic": { "version": "6.5.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-eFOJTMyCYb7xtE/caJ6JJu+bhi67WCYNbkGSknu20pmM8Ke/bqOfdnZWxyoGN26JgfxTbXrsCkEw4KheCT/KGg==", "dev": true, "requires": { "bn.js": "^4.4.0", @@ -26420,12 +25602,14 @@ }, "emoji-regex": { "version": "7.0.3", - "bundled": true, + "resolved": false, + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", "dev": true }, "end-of-stream": { "version": "1.4.1", - "bundled": true, + "resolved": false, + "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", "dev": true, "requires": { "once": "^1.4.0" @@ -26433,7 +25617,8 @@ }, "ethereumjs-util": { "version": "6.1.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-URESKMFbDeJxnAxPppnk2fN6Y3BIatn9fwn76Lm8bQlt+s52TpG8dN9M66MLPuRAiAOIqL3dfwqWJf0sd0fL0Q==", "dev": true, "requires": { "bn.js": "^4.11.0", @@ -26447,7 +25632,8 @@ }, "ethjs-util": { "version": "0.1.6", - "bundled": true, + "resolved": false, + "integrity": "sha512-CUnVOQq7gSpDHZVVrQW8ExxUETWrnrvXYvYz55wOU8Uj4VCgw56XC2B/fVqQN+f7gmrnRHSLVnFAwsCuNwji8w==", "dev": true, "requires": { "is-hex-prefixed": "1.0.0", @@ -26456,7 +25642,8 @@ }, "evp_bytestokey": { "version": "1.0.3", - "bundled": true, + "resolved": false, + "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", "dev": true, "requires": { "md5.js": "^1.3.4", @@ -26465,7 +25652,8 @@ }, "execa": { "version": "1.0.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA==", "dev": true, "requires": { "cross-spawn": "^6.0.0", @@ -26479,12 +25667,14 @@ }, "file-uri-to-path": { "version": "1.0.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", "dev": true }, "find-up": { "version": "3.0.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", "dev": true, "requires": { "locate-path": "^3.0.0" @@ -26492,12 +25682,14 @@ }, "get-caller-file": { "version": "2.0.5", - "bundled": true, + "resolved": false, + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", "dev": true }, "get-stream": { "version": "4.1.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", "dev": true, "requires": { "pump": "^3.0.0" @@ -26505,7 +25697,8 @@ }, "hash-base": { "version": "3.0.4", - "bundled": true, + "resolved": false, + "integrity": "sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=", "dev": true, "requires": { "inherits": "^2.0.1", @@ -26514,7 +25707,8 @@ }, "hash.js": { "version": "1.1.7", - "bundled": true, + "resolved": false, + "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", "dev": true, "requires": { "inherits": "^2.0.3", @@ -26523,7 +25717,8 @@ }, "hmac-drbg": { "version": "1.0.1", - "bundled": true, + "resolved": false, + "integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=", "dev": true, "requires": { "hash.js": "^1.0.3", @@ -26533,37 +25728,44 @@ }, "inherits": { "version": "2.0.4", - "bundled": true, + "resolved": false, + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "dev": true }, "invert-kv": { "version": "2.0.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA==", "dev": true }, "is-fullwidth-code-point": { "version": "2.0.0", - "bundled": true, + "resolved": false, + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", "dev": true }, "is-hex-prefixed": { "version": "1.0.0", - "bundled": true, + "resolved": false, + "integrity": "sha1-fY035q135dEnFIkTxXPggtd39VQ=", "dev": true }, "is-stream": { "version": "1.1.0", - "bundled": true, + "resolved": false, + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", "dev": true }, "isexe": { "version": "2.0.0", - "bundled": true, + "resolved": false, + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", "dev": true }, "keccak": { "version": "1.4.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-eZVaCpblK5formjPjeTBik7TAg+pqnDrMHIffSvi9Lh7PQgM1+hSzakUeZFCk9DVVG0dacZJuaz2ntwlzZUIBw==", "dev": true, "requires": { "bindings": "^1.2.1", @@ -26574,7 +25776,8 @@ }, "lcid": { "version": "2.0.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-avPEb8P8EGnwXKClwsNUgryVjllcRqtMYa49NTsbQagYuT1DcXnl1915oxWjoyGrXR6zH/Y0Zc96xWsPcoDKeA==", "dev": true, "requires": { "invert-kv": "^2.0.0" @@ -26582,7 +25785,8 @@ }, "locate-path": { "version": "3.0.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", "dev": true, "requires": { "p-locate": "^3.0.0", @@ -26591,7 +25795,8 @@ }, "map-age-cleaner": { "version": "0.1.3", - "bundled": true, + "resolved": false, + "integrity": "sha512-bJzx6nMoP6PDLPBFmg7+xRKeFZvFboMrGlxmNj9ClvX53KrmvM5bXFXEWjbz4cz1AFn+jWJ9z/DJSz7hrs0w3w==", "dev": true, "requires": { "p-defer": "^1.0.0" @@ -26599,7 +25804,8 @@ }, "md5.js": { "version": "1.3.5", - "bundled": true, + "resolved": false, + "integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==", "dev": true, "requires": { "hash-base": "^3.0.0", @@ -26609,7 +25815,8 @@ }, "mem": { "version": "4.3.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-qX2bG48pTqYRVmDB37rn/6PT7LcR8T7oAX3bf99u1Tt1nzxYfxkgqDwUwolPlXweM0XzBOBFzSx4kfp7KP1s/w==", "dev": true, "requires": { "map-age-cleaner": "^0.1.1", @@ -26619,32 +25826,38 @@ }, "mimic-fn": { "version": "2.1.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", "dev": true }, "minimalistic-assert": { "version": "1.0.1", - "bundled": true, + "resolved": false, + "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==", "dev": true }, "minimalistic-crypto-utils": { "version": "1.0.1", - "bundled": true, + "resolved": false, + "integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=", "dev": true }, "nan": { "version": "2.14.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==", "dev": true }, "nice-try": { "version": "1.0.5", - "bundled": true, + "resolved": false, + "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", "dev": true }, "npm-run-path": { "version": "2.0.2", - "bundled": true, + "resolved": false, + "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", "dev": true, "requires": { "path-key": "^2.0.0" @@ -26652,7 +25865,8 @@ }, "once": { "version": "1.4.0", - "bundled": true, + "resolved": false, + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, "requires": { "wrappy": "1" @@ -26660,7 +25874,8 @@ }, "os-locale": { "version": "3.1.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-Z8l3R4wYWM40/52Z+S265okfFj8Kt2cC2MKY+xNi3kFs+XGI7WXu/I309QQQYbRW4ijiZ+yxs9pqEhJh0DqW3Q==", "dev": true, "requires": { "execa": "^1.0.0", @@ -26670,22 +25885,26 @@ }, "p-defer": { "version": "1.0.0", - "bundled": true, + "resolved": false, + "integrity": "sha1-n26xgvbJqozXQwBKfU+WsZaw+ww=", "dev": true }, "p-finally": { "version": "1.0.0", - "bundled": true, + "resolved": false, + "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=", "dev": true }, "p-is-promise": { "version": "2.1.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-Y3W0wlRPK8ZMRbNq97l4M5otioeA5lm1z7bkNkxCka8HSPjR0xRWmpCmc9utiaLP9Jb1eD8BgeIxTW4AIF45Pg==", "dev": true }, "p-limit": { "version": "2.2.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-pZbTJpoUsCzV48Mc9Nh51VbwO0X9cuPFE8gYwx9BTCt9SF8/b7Zljd2fVgOxhIF/HDTKgpVzs+GPhyKfjLLFRQ==", "dev": true, "requires": { "p-try": "^2.0.0" @@ -26693,7 +25912,8 @@ }, "p-locate": { "version": "3.0.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", "dev": true, "requires": { "p-limit": "^2.0.0" @@ -26701,22 +25921,26 @@ }, "p-try": { "version": "2.2.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", "dev": true }, "path-exists": { "version": "3.0.0", - "bundled": true, + "resolved": false, + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", "dev": true }, "path-key": { "version": "2.0.1", - "bundled": true, + "resolved": false, + "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", "dev": true }, "pump": { "version": "3.0.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", "dev": true, "requires": { "end-of-stream": "^1.1.0", @@ -26725,17 +25949,20 @@ }, "require-directory": { "version": "2.1.1", - "bundled": true, + "resolved": false, + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", "dev": true }, "require-main-filename": { "version": "2.0.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", "dev": true }, "ripemd160": { "version": "2.0.2", - "bundled": true, + "resolved": false, + "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", "dev": true, "requires": { "hash-base": "^3.0.0", @@ -26744,7 +25971,8 @@ }, "rlp": { "version": "2.2.3", - "bundled": true, + "resolved": false, + "integrity": "sha512-l6YVrI7+d2vpW6D6rS05x2Xrmq8oW7v3pieZOJKBEdjuTF4Kz/iwk55Zyh1Zaz+KOB2kC8+2jZlp2u9L4tTzCQ==", "dev": true, "requires": { "bn.js": "^4.11.1", @@ -26753,12 +25981,14 @@ }, "safe-buffer": { "version": "5.2.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==", "dev": true }, "secp256k1": { "version": "3.7.1", - "bundled": true, + "resolved": false, + "integrity": "sha512-1cf8sbnRreXrQFdH6qsg2H71Xw91fCCS9Yp021GnUNJzWJS/py96fS4lHbnTnouLp08Xj6jBoBB6V78Tdbdu5g==", "dev": true, "requires": { "bindings": "^1.5.0", @@ -26773,17 +26003,20 @@ }, "semver": { "version": "5.7.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==", "dev": true }, "set-blocking": { "version": "2.0.0", - "bundled": true, + "resolved": false, + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", "dev": true }, "sha.js": { "version": "2.4.11", - "bundled": true, + "resolved": false, + "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", "dev": true, "requires": { "inherits": "^2.0.1", @@ -26792,7 +26025,8 @@ }, "shebang-command": { "version": "1.2.0", - "bundled": true, + "resolved": false, + "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", "dev": true, "requires": { "shebang-regex": "^1.0.0" @@ -26800,22 +26034,26 @@ }, "shebang-regex": { "version": "1.0.0", - "bundled": true, + "resolved": false, + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", "dev": true }, "signal-exit": { "version": "3.0.2", - "bundled": true, + "resolved": false, + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", "dev": true }, "source-map": { "version": "0.6.1", - "bundled": true, + "resolved": false, + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "source-map-support": { "version": "0.5.12", - "bundled": true, + "resolved": false, + "integrity": "sha512-4h2Pbvyy15EE02G+JOZpUCmqWJuqrs+sEkzewTm++BPi7Hvn/HwcqLAcNxYAyI0x13CpPPn+kMjl+hplXMHITQ==", "dev": true, "requires": { "buffer-from": "^1.0.0", @@ -26824,7 +26062,8 @@ }, "string-width": { "version": "3.1.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", "dev": true, "requires": { "emoji-regex": "^7.0.1", @@ -26834,7 +26073,8 @@ }, "strip-ansi": { "version": "5.2.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", "dev": true, "requires": { "ansi-regex": "^4.1.0" @@ -26842,12 +26082,14 @@ }, "strip-eof": { "version": "1.0.0", - "bundled": true, + "resolved": false, + "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=", "dev": true }, "strip-hex-prefix": { "version": "1.0.0", - "bundled": true, + "resolved": false, + "integrity": "sha1-DF8VX+8RUTczd96du1iNoFUA428=", "dev": true, "requires": { "is-hex-prefixed": "1.0.0" @@ -26855,7 +26097,8 @@ }, "which": { "version": "1.3.1", - "bundled": true, + "resolved": false, + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", "dev": true, "requires": { "isexe": "^2.0.0" @@ -26863,12 +26106,14 @@ }, "which-module": { "version": "2.0.0", - "bundled": true, + "resolved": false, + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", "dev": true }, "wrap-ansi": { "version": "5.1.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==", "dev": true, "requires": { "ansi-styles": "^3.2.0", @@ -26878,17 +26123,20 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true, + "resolved": false, + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true }, "y18n": { "version": "4.0.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", "dev": true }, "yargs": { "version": "13.2.4", - "bundled": true, + "resolved": false, + "integrity": "sha512-HG/DWAJa1PAnHT9JAhNa8AbAv3FPaiLzioSjCcmuXXhP8MlpHO5vwls4g4j6n30Z74GVQj8Xa62dWVx1QCGklg==", "dev": true, "requires": { "cliui": "^5.0.0", @@ -26906,7 +26154,8 @@ }, "yargs-parser": { "version": "13.1.1", - "bundled": true, + "resolved": false, + "integrity": "sha512-oVAVsHz6uFrg3XQheFII8ESO2ssAf9luWuAd6Wexsu4F3OtIW0o8IribPXYrD4WC24LWtPrJlGy87y5udK+dxQ==", "dev": true, "requires": { "camelcase": "^5.0.0", @@ -45320,6 +44569,15 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" }, + "node-environment-flags": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/node-environment-flags/-/node-environment-flags-1.0.5.tgz", + "integrity": "sha512-VNYPRfGfmZLx0Ye20jWzHUjyTW/c+6Wq+iLhDzUI4XmhrDd9l/FozXV3F2xOaXjvp0co0+v1YSR3CMP6g+VvLQ==", + "requires": { + "object.getownpropertydescriptors": "^2.0.3", + "semver": "^5.7.0" + } + }, "p-locate": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", @@ -45590,15 +44848,6 @@ } } }, - "node-environment-flags": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/node-environment-flags/-/node-environment-flags-1.0.5.tgz", - "integrity": "sha512-VNYPRfGfmZLx0Ye20jWzHUjyTW/c+6Wq+iLhDzUI4XmhrDd9l/FozXV3F2xOaXjvp0co0+v1YSR3CMP6g+VvLQ==", - "requires": { - "object.getownpropertydescriptors": "^2.0.3", - "semver": "^5.7.0" - } - }, "node-fetch": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", @@ -47914,16 +47163,6 @@ "postcss": "^7.0.5" } }, - "postcss-modules-local-by-default": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/postcss-modules-local-by-default/-/postcss-modules-local-by-default-2.0.6.tgz", - "integrity": "sha512-oLUV5YNkeIBa0yQl7EYnxMgy4N6noxmiwZStaEJUSe2xPMcdNc8WmBQuQCx18H5psYbVxz8zoHk0RAAYZXP9gA==", - "requires": { - "postcss": "^7.0.6", - "postcss-selector-parser": "^6.0.0", - "postcss-value-parser": "^3.3.1" - } - }, "postcss-modules-scope": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/postcss-modules-scope/-/postcss-modules-scope-2.1.1.tgz", @@ -47933,15 +47172,6 @@ "postcss-selector-parser": "^6.0.0" } }, - "postcss-modules-values": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/postcss-modules-values/-/postcss-modules-values-2.0.0.tgz", - "integrity": "sha512-Ki7JZa7ff1N3EIMlPnGTZfUMe69FFwiQPnVSXC9mnn3jozCRBYIxiZd44yJOV2AmabOo4qFf8s0dC/+lweG7+w==", - "requires": { - "icss-replace-symbols": "^1.1.0", - "postcss": "^7.0.6" - } - }, "postcss-nesting": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/postcss-nesting/-/postcss-nesting-7.0.1.tgz", @@ -49107,6 +48337,24 @@ } } }, + "css-loader": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/css-loader/-/css-loader-2.1.1.tgz", + "integrity": "sha512-OcKJU/lt232vl1P9EEDamhoO9iKY3tIjY5GU+XDLblAykTdgs6Ux9P1hTHve8nFKy5KPpOXOsVI/hIwi3841+w==", + "requires": { + "camelcase": "^5.2.0", + "icss-utils": "^4.1.0", + "loader-utils": "^1.2.3", + "normalize-path": "^3.0.0", + "postcss": "^7.0.14", + "postcss-modules-extract-imports": "^2.0.0", + "postcss-modules-local-by-default": "^2.0.6", + "postcss-modules-scope": "^2.1.0", + "postcss-modules-values": "^2.0.0", + "postcss-value-parser": "^3.3.0", + "schema-utils": "^1.0.0" + } + }, "dotenv": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-6.2.0.tgz", @@ -49136,6 +48384,30 @@ "graceful-fs": "^4.1.6" } }, + "normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==" + }, + "postcss-modules-local-by-default": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/postcss-modules-local-by-default/-/postcss-modules-local-by-default-2.0.6.tgz", + "integrity": "sha512-oLUV5YNkeIBa0yQl7EYnxMgy4N6noxmiwZStaEJUSe2xPMcdNc8WmBQuQCx18H5psYbVxz8zoHk0RAAYZXP9gA==", + "requires": { + "postcss": "^7.0.6", + "postcss-selector-parser": "^6.0.0", + "postcss-value-parser": "^3.3.1" + } + }, + "postcss-modules-values": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/postcss-modules-values/-/postcss-modules-values-2.0.0.tgz", + "integrity": "sha512-Ki7JZa7ff1N3EIMlPnGTZfUMe69FFwiQPnVSXC9mnn3jozCRBYIxiZd44yJOV2AmabOo4qFf8s0dC/+lweG7+w==", + "requires": { + "icss-replace-symbols": "^1.1.0", + "postcss": "^7.0.6" + } + }, "resolve": { "version": "1.12.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", diff --git a/package.json b/package.json index 3626eb2f4d..7c291b4d12 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@connext/indra", - "version": "2.3.17", + "version": "2.3.18", "description": "", "repository": { "type": "git", @@ -15,7 +15,7 @@ "devDependencies": { "@connext/cf-adjudicator-contracts": "0.4.1", "@connext/cf-funding-protocol-contracts": "0.4.1", - "@connext/types": "1.2.14", + "@connext/types": "1.3.10", "chai-bn": "0.2.0", "cypress": "3.7.0", "ethers": "4.0.40",