Skip to content
This repository has been archived by the owner on May 28, 2021. It is now read-only.

Commit

Permalink
Deploy indra-4.0.12
Browse files Browse the repository at this point in the history
  • Loading branch information
LayneHaber committed Feb 8, 2020
2 parents 1cb8d38 + 963b404 commit eced421
Show file tree
Hide file tree
Showing 83 changed files with 2,583 additions and 1,291 deletions.
7 changes: 3 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
module.exports = {
rules: {
"@typescript-eslint/no-unused-expressions": "off",
"comma-dangle": ["error", "only-multiline"],
"indent": ["error", 2],
"max-len": ["warn", { code: 120, ignoreTemplateLiterals: true, ignoreStrings: true }],
"comma-dangle": ["error", "always-multiline"],
"max-len": ["warn", { code: 120, ignoreTemplateLiterals: true }],
"no-async-promise-executor": "off",
"no-undef": ["error"],
"no-unused-vars": ["error"],
"no-var": ["error"],
"object-curly-spacing": ["error", "always"],
"quotes": ["error", "double", { allowTemplateLiterals: true }],
"semi": ["error", "always"],
"spaced-comment": "off",
"no-prototype-builtins": "off",
"sort-keys": ["error"],
},
settings: {
react: {
Expand Down
6 changes: 4 additions & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"printWidth": 100,
"trailingComma": "all"
"tabWidth": 2,
"useTabs": false,
"trailingComma": "all",
"printWidth": 120
}
4 changes: 0 additions & 4 deletions modules/cf-core/.prettierrc

This file was deleted.

4 changes: 2 additions & 2 deletions modules/cf-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@connext/cf-core",
"version": "4.0.9",
"version": "4.0.11",
"main": "dist/src/index.js",
"iife": "dist/src/index.iife.js",
"types": "dist/src/index.d.ts",
Expand All @@ -20,7 +20,7 @@
},
"dependencies": {
"@connext/contracts": "1.0.4",
"@connext/types": "4.0.9",
"@connext/types": "4.0.11",
"ethers": "4.0.41",
"eventemitter3": "4.0.0",
"loglevel": "1.6.6",
Expand Down
36 changes: 13 additions & 23 deletions modules/cf-core/src/methods/app-instance/uninstall/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
APP_ALREADY_UNINSTALLED,
CANNOT_UNINSTALL_FREE_BALANCE,
NO_APP_INSTANCE_ID_TO_UNINSTALL,
USE_RESCIND_DEPOSIT_RIGHTS
USE_RESCIND_DEPOSIT_RIGHTS,
} from "../../errors";

import { RequestHandler } from "../../../request-handler";
Expand All @@ -20,31 +20,30 @@ export default class UninstallController extends NodeController {

protected async getRequiredLockNames(
requestHandler: RequestHandler,
params: CFCoreTypes.UninstallVirtualParams
params: CFCoreTypes.UninstallVirtualParams,
): Promise<string[]> {
const { store } = requestHandler;
const { appInstanceId } = params;

const sc = await store.getChannelFromAppInstanceID(appInstanceId);

if (sc.freeBalance.identityHash === appInstanceId) {
throw Error(CANNOT_UNINSTALL_FREE_BALANCE(sc.multisigAddress));
}

return [sc.multisigAddress, appInstanceId];
}

protected async beforeExecution(
requestHandler: RequestHandler,
params: CFCoreTypes.UninstallParams
) {
protected async beforeExecution(requestHandler: RequestHandler, params: CFCoreTypes.UninstallParams) {
const { store, networkContext } = requestHandler;
const { appInstanceId } = params;

if (!appInstanceId) {
throw Error(NO_APP_INSTANCE_ID_TO_UNINSTALL);
}

const sc = await store.getChannelFromAppInstanceID(appInstanceId);

if (sc.freeBalance.identityHash === appInstanceId) {
throw Error(CANNOT_UNINSTALL_FREE_BALANCE(sc.multisigAddress));
}

// check if its the balance refund app
const app = await store.getAppInstance(appInstanceId);
if (app.appInterface.addr === networkContext.CoinBalanceRefundApp) {
Expand All @@ -54,7 +53,7 @@ export default class UninstallController extends NodeController {

protected async executeMethodImplementation(
requestHandler: RequestHandler,
params: CFCoreTypes.UninstallParams
params: CFCoreTypes.UninstallParams,
): Promise<CFCoreTypes.UninstallResult> {
const { store, protocolRunner, publicIdentifier } = requestHandler;
const { appInstanceId } = params;
Expand All @@ -69,18 +68,9 @@ export default class UninstallController extends NodeController {
throw Error(APP_ALREADY_UNINSTALLED(appInstanceId));
}

const to = getFirstElementInListNotEqualTo(
publicIdentifier,
stateChannel.userNeuteredExtendedKeys
);

await uninstallAppInstanceFromChannel(
store,
protocolRunner,
publicIdentifier,
to,
appInstanceId
);
const to = getFirstElementInListNotEqualTo(publicIdentifier, stateChannel.userNeuteredExtendedKeys);

await uninstallAppInstanceFromChannel(store, protocolRunner, publicIdentifier, to, appInstanceId);

return { appInstanceId };
}
Expand Down
118 changes: 37 additions & 81 deletions modules/cf-core/src/methods/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,56 +6,40 @@ import { prettyPrintObject } from "../utils";
export const APP_ALREADY_UNINSTALLED = (id: string): string =>
`Cannot uninstall app ${id}, it has already been uninstalled`;

export const CANNOT_DEPOSIT =
"Cannot deposit while another deposit is occurring in the channel.";
export const CANNOT_DEPOSIT = "Cannot deposit while another deposit is occurring in the channel.";

export const COIN_BALANCE_NOT_PROPOSED =
"No coin balance refund app proposed in channel.";
export const COIN_BALANCE_NOT_PROPOSED = "No coin balance refund app proposed in channel.";

export const NOT_YOUR_BALANCE_REFUND_APP =
"Cannot uninstall a balance refund app without being the recipient";
export const NOT_YOUR_BALANCE_REFUND_APP = "Cannot uninstall a balance refund app without being the recipient";

export const USE_RESCIND_DEPOSIT_RIGHTS =
"Use `rescindDepositRights` to uninstall coin balance refund app.";
export const USE_RESCIND_DEPOSIT_RIGHTS = "Use `rescindDepositRights` to uninstall coin balance refund app.";

export const BALANCE_REFUND_APP_ALREADY_INSTALLED =
"Balance refund app is installed, please uninstall first.";
export const BALANCE_REFUND_APP_ALREADY_INSTALLED = "Balance refund app is installed, please uninstall first.";

export const BALANCE_REFUND_APP_NOT_INSTALLED =
"Balance refund app is not installed.";
export const BALANCE_REFUND_APP_NOT_INSTALLED = "Balance refund app is not installed.";

export const CANNOT_UNINSTALL_FREE_BALANCE = (
multisigAddress: string
): string => `Cannot uninstall the FreeBalance of channel: ${multisigAddress}`;
export const CANNOT_UNINSTALL_FREE_BALANCE = (multisigAddress: string): string =>
`Cannot uninstall the FreeBalance of channel: ${multisigAddress}`;

export const CANNOT_WITHDRAW =
"Cannot withdraw while another deposit / withdraw app is active in the channel.";
export const CANNOT_WITHDRAW = "Cannot withdraw while another deposit / withdraw app is active in the channel.";

export const CHANNEL_CREATION_FAILED =
"Failed to create channel. Multisignature wallet cannot be deployed properly";
export const CHANNEL_CREATION_FAILED = "Failed to create channel. Multisignature wallet cannot be deployed properly";

export const DEPOSIT_FAILED = "Failed to send funds to the multisig contract";

export const ETH_BALANCE_REFUND_NOT_UNINSTALLED =
"The ETH balance refund AppInstance is still installed when it's not supposed to be";

export const FAILED_TO_GET_ERC20_BALANCE = (
tokenAddress: string,
address: string
): string =>
export const FAILED_TO_GET_ERC20_BALANCE = (tokenAddress: string, address: string): string =>
`Failed to get the balance of address: ${address} for ERC20 token: ${tokenAddress}`;

export const IMPROPERLY_FORMATTED_STRUCT =
"Improperly formatted ABIEncoderV2 struct";
export const IMPROPERLY_FORMATTED_STRUCT = "Improperly formatted ABIEncoderV2 struct";

export const INCORRECT_MULTISIG_ADDRESS =
"Channel multisig address does not match expected";
export const INCORRECT_MULTISIG_ADDRESS = "Channel multisig address does not match expected";

export const INVALID_FACTORY_ADDRESS = (address: string): string =>
`Channel factory address is invalid: ${address}`;
export const INVALID_FACTORY_ADDRESS = (address: string): string => `Channel factory address is invalid: ${address}`;

export const INVALID_MASTERCOPY_ADDRESS = (address: string): string =>
`Multisig master address is invalid: ${address}`;
export const INVALID_MASTERCOPY_ADDRESS = (address: string): string => `Multisig master address is invalid: ${address}`;

export const NO_NETWORK_PROVIDER_CREATE2 =
"`getCreate2MultisigAddress` needs access to an eth provider within the network context";
Expand All @@ -64,15 +48,11 @@ export const INSUFFICIENT_ERC20_FUNDS_TO_DEPOSIT = (
address: string,
tokenAddress: string,
amount: BigNumber,
balance: BigNumber
balance: BigNumber,
): string =>
`Node's default signer ${address} has ${balance} and needs ${amount} of the specified ERC20 token ${tokenAddress} to deposit`;

export const INSUFFICIENT_FUNDS_TO_WITHDRAW = (
address: string,
amount: BigNumber,
balance: BigNumber
): string => {
export const INSUFFICIENT_FUNDS_TO_WITHDRAW = (address: string, amount: BigNumber, balance: BigNumber): string => {
if (address === CONVENTION_FOR_ETH_TOKEN_ADDRESS) {
return `Node has ${balance} and needs ${amount} ETH to withdraw`;
}
Expand All @@ -84,78 +64,54 @@ export const INSUFFICIENT_FUNDS_IN_FREE_BALANCE_FOR_ASSET = (
multisigAddress: string,
tokenAddress: string,
balance: BigNumber,
allocationAmount: BigNumber
allocationAmount: BigNumber,
): string =>
`Node with public identifier ${publicIdentifier} has insufficient funds in channel ${multisigAddress}
for token ${tokenAddress} to allocate towards an AppInstance. Current free balance for token is ${balance},
attempted allocation amount: ${allocationAmount} `;

export const INSUFFICIENT_FUNDS =
"Node's default signer does not have enough funds for this action";
export const INSUFFICIENT_FUNDS = "Node's default signer does not have enough funds for this action";

export const INVALID_ACTION = "Invalid action taken";

export const INVALID_NETWORK_NAME =
"Invalid network name provided for initializing Node";
export const INVALID_NETWORK_NAME = "Invalid network name provided for initializing Node";

export const NO_ACTION_ENCODING_FOR_APP_INSTANCE =
"The AppInstance does not have an Action encoding defined";
export const NO_ACTION_ENCODING_FOR_APP_INSTANCE = "The AppInstance does not have an Action encoding defined";

export const NO_APP_CONTRACT_ADDR = "The App Contract address is empty";

export const NO_APP_INSTANCE_FOR_GIVEN_ID =
"No AppInstance exists for the given ID";
export const NO_APP_INSTANCE_FOR_GIVEN_ID = "No AppInstance exists for the given ID";

export const NO_APP_INSTANCE_FOR_TAKE_ACTION =
"No AppInstanceId specified to takeAction on";
export const NO_APP_INSTANCE_FOR_TAKE_ACTION = "No AppInstanceId specified to takeAction on";

export const NO_APP_INSTANCE_ID_FOR_GET_STATE =
"No string specified to get state for";
export const NO_APP_INSTANCE_ID_FOR_GET_STATE = "No string specified to get state for";

export const NO_APP_INSTANCE_ID_TO_GET_DETAILS =
"No string specified to get details for";
export const NO_APP_INSTANCE_ID_TO_GET_DETAILS = "No string specified to get details for";

export const NO_APP_INSTANCE_ID_TO_INSTALL =
"No AppInstanceId specified to install";
export const NO_APP_INSTANCE_ID_TO_INSTALL = "No AppInstanceId specified to install";

export const NO_APP_INSTANCE_ID_TO_UNINSTALL =
"No AppInstanceId specified to uninstall";
export const NO_APP_INSTANCE_ID_TO_UNINSTALL = "No AppInstanceId specified to uninstall";

export const NO_MULTISIG_FOR_APP_INSTANCE_ID =
"No multisig address exists for the given appInstanceId";
export const NO_MULTISIG_FOR_APP_INSTANCE_ID = "No multisig address exists for the given appInstanceId";

export const NO_PROPOSED_APP_INSTANCE_FOR_APP_INSTANCE_ID = (
id: string
): string =>
export const NO_PROPOSED_APP_INSTANCE_FOR_APP_INSTANCE_ID = (id: string): string =>
`No proposed AppInstance exists for the given appInstanceId: ${id}`;

export const NO_STATE_CHANNEL_FOR_MULTISIG_ADDR = (
multisigAddress: string
): string =>
export const NO_STATE_CHANNEL_FOR_MULTISIG_ADDR = (multisigAddress: string): string =>
`Call to getStateChannel failed when searching for multisig address: ${multisigAddress}. This probably means that the StateChannel does not exist yet.`;

export const NO_TRANSACTION_HASH_FOR_MULTISIG_DEPLOYMENT =
"The multisig deployment transaction does not have a hash";
export const NO_TRANSACTION_HASH_FOR_MULTISIG_DEPLOYMENT = "The multisig deployment transaction does not have a hash";

export const NULL_INITIAL_STATE_FOR_PROPOSAL =
"A proposed AppInstance cannot have an empty initial state";
export const NULL_INITIAL_STATE_FOR_PROPOSAL = "A proposed AppInstance cannot have an empty initial state";

export const STATE_OBJECT_NOT_ENCODABLE =
"The state object is not encodable by the AppInstance's state encoding";
export const STATE_OBJECT_NOT_ENCODABLE = "The state object is not encodable by the AppInstance's state encoding";

export const TWO_PARTY_OUTCOME_DIFFERENT_ASSETS = (
assetA: string,
assetB: string
): string =>
export const TWO_PARTY_OUTCOME_DIFFERENT_ASSETS = (assetA: string, assetB: string): string =>
`For a TWO_PARTY_FIXED_OUTCOME there cannot be two kinds of tokens deposited: ${assetA} and ${assetB}`;

export const VIRTUAL_APP_INSTALLATION_FAIL =
"Failed to install the virtual App Instance";
export const VIRTUAL_APP_INSTALLATION_FAIL = "Failed to install the virtual App Instance";

export const WITHDRAWAL_FAILED =
"Failed to withdraw funds out of the multisig contract";
export const WITHDRAWAL_FAILED = "Failed to withdraw funds out of the multisig contract";

export const NO_MULTISIG_FOR_COUNTERPARTIES = (owners: string[]): string =>
`Could not find multisig address between counterparties ${prettyPrintObject(
owners
)}`;
`Could not find multisig address between counterparties ${prettyPrintObject(owners)}`;
Loading

0 comments on commit eced421

Please sign in to comment.