Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@connext/apps

Package Overview
Dependencies
Maintainers
4
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@connext/apps - npm Package Compare versions

Comparing version 6.1.5 to 6.2.0

34

dist/index-iife.js

@@ -92,4 +92,4 @@ this.window = this.window || {};

}
if (initialState.assetId !== utils.getAddressFromAssetId(params.initiatorDepositAssetId)
|| initialState.assetId !== utils.getAddressFromAssetId(params.responderDepositAssetId)) {
if (initialState.assetId !== utils.getAddressFromAssetId(params.initiatorDepositAssetId) ||
initialState.assetId !== utils.getAddressFromAssetId(params.responderDepositAssetId)) {
throw new Error(`Cannot install deposit app with invalid token address. Expected ${utils.getAddressFromAssetId(params.initiatorDepositAssetId)}, got ${initialState.assetId}`);

@@ -99,11 +99,7 @@ }

? await provider.getBalance(multisigAddress)
: await new ethers.Contract(initialState.assetId, contracts.ERC20.abi, provider)
.functions
.balanceOf(multisigAddress);
: await new ethers.Contract(initialState.assetId, contracts.ERC20.abi, provider).functions.balanceOf(multisigAddress);
const multisig = new ethers.Contract(multisigAddress, contracts.MinimumViableMultisig.abi, provider);
let startingTotalAmountWithdrawn;
try {
startingTotalAmountWithdrawn = await multisig
.functions
.totalAmountWithdrawn(initialState.assetId);
startingTotalAmountWithdrawn = await multisig.functions.totalAmountWithdrawn(initialState.assetId);
}

@@ -125,14 +121,12 @@ catch (e) {

const uninstallDepositMiddleware = async (context, provider) => {
const { role, appInstance, stateChannel, params, } = context;
const { role, appInstance, stateChannel, params } = context;
const latestState = appInstance.latestState;
const currentMultisigBalance = latestState.assetId === types.CONVENTION_FOR_ETH_ASSET_ID
? await provider.getBalance(stateChannel.multisigAddress)
: await new ethers.Contract(latestState.assetId, contracts.ERC20.abi, provider)
.functions
.balanceOf(stateChannel.multisigAddress);
: await new ethers.Contract(latestState.assetId, contracts.ERC20.abi, provider).functions.balanceOf(stateChannel.multisigAddress);
if (currentMultisigBalance.lt(latestState.startingMultisigBalance)) {
throw new Error(`Refusing to uninstall, current multisig balance (${currentMultisigBalance.toString()}) is less than starting multsig balance (${latestState.startingMultisigBalance.toString()})`);
}
if (role === types.ProtocolRoles.initiator
&& latestState.transfers[0].to !== utils.getSignerAddressFromPublicIdentifier(params.initiatorIdentifier)) {
if (role === types.ProtocolRoles.initiator &&
latestState.transfers[0].to !== utils.getSignerAddressFromPublicIdentifier(params.initiatorIdentifier)) {
throw new Error(`Cannot uninstall deposit app without being the initiator`);

@@ -313,9 +307,9 @@ }

switch (protocol) {
case (types.ProtocolNames.setup):
case (types.ProtocolNames.propose):
case (types.ProtocolNames.install):
case (types.ProtocolNames.takeAction): {
case types.ProtocolNames.setup:
case types.ProtocolNames.propose:
case types.ProtocolNames.install:
case types.ProtocolNames.takeAction: {
break;
}
case (types.ProtocolNames.uninstall): {
case types.ProtocolNames.uninstall: {
await uninstallMiddleware(contracts, middlewareContext);

@@ -334,3 +328,3 @@ break;

switch (appDef) {
case (contracts.DepositApp): {
case contracts.DepositApp: {
await uninstallDepositMiddleware(middlewareContext, contracts.provider);

@@ -337,0 +331,0 @@ break;

@@ -96,4 +96,4 @@ import { enumify, SimpleLinkedTransferAppName, SimpleSignedTransferAppName, SimpleTwoPartySwapAppName, WithdrawAppName, HashLockTransferAppName, DepositAppName, OutcomeType, DepositAppStateEncoding, CONVENTION_FOR_ETH_ASSET_ID, ProtocolRoles, HashLockTransferAppActionEncoding, HashLockTransferAppStateEncoding, SimpleLinkedTransferAppActionEncoding, SimpleLinkedTransferAppStateEncoding, SimpleSignedTransferAppStateEncoding, SimpleSignedTransferAppActionEncoding, SimpleSwapAppStateEncoding, WithdrawAppStateEncoding, WithdrawAppActionEncoding, MultisigOperation, ProtocolNames } from '@connext/types';

}
if (initialState.assetId !== getAddressFromAssetId(params.initiatorDepositAssetId)
|| initialState.assetId !== getAddressFromAssetId(params.responderDepositAssetId)) {
if (initialState.assetId !== getAddressFromAssetId(params.initiatorDepositAssetId) ||
initialState.assetId !== getAddressFromAssetId(params.responderDepositAssetId)) {
throw new Error(`Cannot install deposit app with invalid token address. Expected ${getAddressFromAssetId(params.initiatorDepositAssetId)}, got ${initialState.assetId}`);

@@ -103,11 +103,7 @@ }

? await provider.getBalance(multisigAddress)
: await new Contract(initialState.assetId, ERC20.abi, provider)
.functions
.balanceOf(multisigAddress);
: await new Contract(initialState.assetId, ERC20.abi, provider).functions.balanceOf(multisigAddress);
const multisig = new Contract(multisigAddress, MinimumViableMultisig.abi, provider);
let startingTotalAmountWithdrawn;
try {
startingTotalAmountWithdrawn = await multisig
.functions
.totalAmountWithdrawn(initialState.assetId);
startingTotalAmountWithdrawn = await multisig.functions.totalAmountWithdrawn(initialState.assetId);
}

@@ -129,14 +125,12 @@ catch (e) {

const uninstallDepositMiddleware = async (context, provider) => {
const { role, appInstance, stateChannel, params, } = context;
const { role, appInstance, stateChannel, params } = context;
const latestState = appInstance.latestState;
const currentMultisigBalance = latestState.assetId === CONVENTION_FOR_ETH_ASSET_ID
? await provider.getBalance(stateChannel.multisigAddress)
: await new Contract(latestState.assetId, ERC20.abi, provider)
.functions
.balanceOf(stateChannel.multisigAddress);
: await new Contract(latestState.assetId, ERC20.abi, provider).functions.balanceOf(stateChannel.multisigAddress);
if (currentMultisigBalance.lt(latestState.startingMultisigBalance)) {
throw new Error(`Refusing to uninstall, current multisig balance (${currentMultisigBalance.toString()}) is less than starting multsig balance (${latestState.startingMultisigBalance.toString()})`);
}
if (role === ProtocolRoles.initiator
&& latestState.transfers[0].to !== getSignerAddressFromPublicIdentifier(params.initiatorIdentifier)) {
if (role === ProtocolRoles.initiator &&
latestState.transfers[0].to !== getSignerAddressFromPublicIdentifier(params.initiatorIdentifier)) {
throw new Error(`Cannot uninstall deposit app without being the initiator`);

@@ -317,9 +311,9 @@ }

switch (protocol) {
case (ProtocolNames.setup):
case (ProtocolNames.propose):
case (ProtocolNames.install):
case (ProtocolNames.takeAction): {
case ProtocolNames.setup:
case ProtocolNames.propose:
case ProtocolNames.install:
case ProtocolNames.takeAction: {
break;
}
case (ProtocolNames.uninstall): {
case ProtocolNames.uninstall: {
await uninstallMiddleware(contracts, middlewareContext);

@@ -338,3 +332,3 @@ break;

switch (appDef) {
case (contracts.DepositApp): {
case contracts.DepositApp: {
await uninstallDepositMiddleware(middlewareContext, contracts.provider);

@@ -341,0 +335,0 @@ break;

@@ -100,4 +100,4 @@ 'use strict';

}
if (initialState.assetId !== utils.getAddressFromAssetId(params.initiatorDepositAssetId)
|| initialState.assetId !== utils.getAddressFromAssetId(params.responderDepositAssetId)) {
if (initialState.assetId !== utils.getAddressFromAssetId(params.initiatorDepositAssetId) ||
initialState.assetId !== utils.getAddressFromAssetId(params.responderDepositAssetId)) {
throw new Error(`Cannot install deposit app with invalid token address. Expected ${utils.getAddressFromAssetId(params.initiatorDepositAssetId)}, got ${initialState.assetId}`);

@@ -107,11 +107,7 @@ }

? await provider.getBalance(multisigAddress)
: await new ethers.Contract(initialState.assetId, contracts.ERC20.abi, provider)
.functions
.balanceOf(multisigAddress);
: await new ethers.Contract(initialState.assetId, contracts.ERC20.abi, provider).functions.balanceOf(multisigAddress);
const multisig = new ethers.Contract(multisigAddress, contracts.MinimumViableMultisig.abi, provider);
let startingTotalAmountWithdrawn;
try {
startingTotalAmountWithdrawn = await multisig
.functions
.totalAmountWithdrawn(initialState.assetId);
startingTotalAmountWithdrawn = await multisig.functions.totalAmountWithdrawn(initialState.assetId);
}

@@ -133,14 +129,12 @@ catch (e) {

const uninstallDepositMiddleware = async (context, provider) => {
const { role, appInstance, stateChannel, params, } = context;
const { role, appInstance, stateChannel, params } = context;
const latestState = appInstance.latestState;
const currentMultisigBalance = latestState.assetId === types.CONVENTION_FOR_ETH_ASSET_ID
? await provider.getBalance(stateChannel.multisigAddress)
: await new ethers.Contract(latestState.assetId, contracts.ERC20.abi, provider)
.functions
.balanceOf(stateChannel.multisigAddress);
: await new ethers.Contract(latestState.assetId, contracts.ERC20.abi, provider).functions.balanceOf(stateChannel.multisigAddress);
if (currentMultisigBalance.lt(latestState.startingMultisigBalance)) {
throw new Error(`Refusing to uninstall, current multisig balance (${currentMultisigBalance.toString()}) is less than starting multsig balance (${latestState.startingMultisigBalance.toString()})`);
}
if (role === types.ProtocolRoles.initiator
&& latestState.transfers[0].to !== utils.getSignerAddressFromPublicIdentifier(params.initiatorIdentifier)) {
if (role === types.ProtocolRoles.initiator &&
latestState.transfers[0].to !== utils.getSignerAddressFromPublicIdentifier(params.initiatorIdentifier)) {
throw new Error(`Cannot uninstall deposit app without being the initiator`);

@@ -321,9 +315,9 @@ }

switch (protocol) {
case (types.ProtocolNames.setup):
case (types.ProtocolNames.propose):
case (types.ProtocolNames.install):
case (types.ProtocolNames.takeAction): {
case types.ProtocolNames.setup:
case types.ProtocolNames.propose:
case types.ProtocolNames.install:
case types.ProtocolNames.takeAction: {
break;
}
case (types.ProtocolNames.uninstall): {
case types.ProtocolNames.uninstall: {
await uninstallMiddleware(contracts, middlewareContext);

@@ -342,3 +336,3 @@ break;

switch (appDef) {
case (contracts.DepositApp): {
case contracts.DepositApp: {
await uninstallDepositMiddleware(middlewareContext, contracts.provider);

@@ -345,0 +339,0 @@ break;

import { ProtocolRoles, CONVENTION_FOR_ETH_ASSET_ID, } from "@connext/types";
import { getAddressFromAssetId, getSignerAddressFromPublicIdentifier, stringify } from "@connext/utils";
import { getAddressFromAssetId, getSignerAddressFromPublicIdentifier, stringify, } from "@connext/utils";
import { MinimumViableMultisig, ERC20 } from "@connext/contracts";

@@ -27,4 +27,4 @@ import { baseCoinTransferValidation } from "../shared";

}
if (initialState.assetId !== getAddressFromAssetId(params.initiatorDepositAssetId)
|| initialState.assetId !== getAddressFromAssetId(params.responderDepositAssetId)) {
if (initialState.assetId !== getAddressFromAssetId(params.initiatorDepositAssetId) ||
initialState.assetId !== getAddressFromAssetId(params.responderDepositAssetId)) {
throw new Error(`Cannot install deposit app with invalid token address. Expected ${getAddressFromAssetId(params.initiatorDepositAssetId)}, got ${initialState.assetId}`);

@@ -34,11 +34,7 @@ }

? await provider.getBalance(multisigAddress)
: await new Contract(initialState.assetId, ERC20.abi, provider)
.functions
.balanceOf(multisigAddress);
: await new Contract(initialState.assetId, ERC20.abi, provider).functions.balanceOf(multisigAddress);
const multisig = new Contract(multisigAddress, MinimumViableMultisig.abi, provider);
let startingTotalAmountWithdrawn;
try {
startingTotalAmountWithdrawn = await multisig
.functions
.totalAmountWithdrawn(initialState.assetId);
startingTotalAmountWithdrawn = await multisig.functions.totalAmountWithdrawn(initialState.assetId);
}

@@ -60,14 +56,12 @@ catch (e) {

export const uninstallDepositMiddleware = async (context, provider) => {
const { role, appInstance, stateChannel, params, } = context;
const { role, appInstance, stateChannel, params } = context;
const latestState = appInstance.latestState;
const currentMultisigBalance = latestState.assetId === CONVENTION_FOR_ETH_ASSET_ID
? await provider.getBalance(stateChannel.multisigAddress)
: await new Contract(latestState.assetId, ERC20.abi, provider)
.functions
.balanceOf(stateChannel.multisigAddress);
: await new Contract(latestState.assetId, ERC20.abi, provider).functions.balanceOf(stateChannel.multisigAddress);
if (currentMultisigBalance.lt(latestState.startingMultisigBalance)) {
throw new Error(`Refusing to uninstall, current multisig balance (${currentMultisigBalance.toString()}) is less than starting multsig balance (${latestState.startingMultisigBalance.toString()})`);
}
if (role === ProtocolRoles.initiator
&& latestState.transfers[0].to !== getSignerAddressFromPublicIdentifier(params.initiatorIdentifier)) {
if (role === ProtocolRoles.initiator &&
latestState.transfers[0].to !== getSignerAddressFromPublicIdentifier(params.initiatorIdentifier)) {
throw new Error(`Cannot uninstall deposit app without being the initiator`);

@@ -74,0 +68,0 @@ }

@@ -9,9 +9,9 @@ import { ProtocolNames, } from "@connext/types";

switch (protocol) {
case (ProtocolNames.setup):
case (ProtocolNames.propose):
case (ProtocolNames.install):
case (ProtocolNames.takeAction): {
case ProtocolNames.setup:
case ProtocolNames.propose:
case ProtocolNames.install:
case ProtocolNames.takeAction: {
break;
}
case (ProtocolNames.uninstall): {
case ProtocolNames.uninstall: {
await uninstallMiddleware(contracts, middlewareContext);

@@ -30,3 +30,3 @@ break;

switch (appDef) {
case (contracts.DepositApp): {
case contracts.DepositApp: {
await uninstallDepositMiddleware(middlewareContext, contracts.provider);

@@ -33,0 +33,0 @@ break;

{
"name": "@connext/apps",
"version": "6.1.5",
"version": "6.2.0",
"description": "Connext Counterfactual Apps",

@@ -21,6 +21,6 @@ "main": "dist/index.js",

"devDependencies": {
"@connext/cf-core": "6.1.5",
"@connext/cf-core": "6.2.0",
"@connext/contracts": "2.0.2",
"@connext/utils": "6.1.5",
"@connext/types": "6.1.5",
"@connext/utils": "6.2.0",
"@connext/types": "6.2.0",
"ethers": "4.0.47",

@@ -27,0 +27,0 @@ "rollup": "2.7.2",

@@ -8,3 +8,7 @@ import {

} from "@connext/types";
import { getAddressFromAssetId, getSignerAddressFromPublicIdentifier, stringify } from "@connext/utils";
import {
getAddressFromAssetId,
getSignerAddressFromPublicIdentifier,
stringify,
} from "@connext/utils";
import { MinimumViableMultisig, ERC20 } from "@connext/contracts";

@@ -41,30 +45,44 @@

if (initiatorSignerAddress !== initiatorTransfer.to) {
throw new Error(`Cannot install deposit app with incorrect initiator transfer to address: Expected ${initiatorSignerAddress}, got ${initiatorTransfer.to}`);
throw new Error(
`Cannot install deposit app with incorrect initiator transfer to address: Expected ${initiatorSignerAddress}, got ${initiatorTransfer.to}`,
);
}
if (responderSignerAddress !== responderTransfer.to) {
throw new Error(`Cannot install deposit app with incorrect responder transfer to address: Expected ${responderSignerAddress}, got ${responderTransfer.to}`);
throw new Error(
`Cannot install deposit app with incorrect responder transfer to address: Expected ${responderSignerAddress}, got ${responderTransfer.to}`,
);
}
if (!initialState.transfers[0].amount.isZero() || !initialState.transfers[1].amount.isZero()) {
throw new Error(`Cannot install deposit app with nonzero initial balance: ${stringify(initialState.transfers)}`);
throw new Error(
`Cannot install deposit app with nonzero initial balance: ${stringify(
initialState.transfers,
)}`,
);
}
if (initialState.multisigAddress !== multisigAddress) {
throw new Error(`Cannot install deposit app with invalid multisig address. Expected ${multisigAddress}, got ${initialState.multisigAddress}`);
throw new Error(
`Cannot install deposit app with invalid multisig address. Expected ${multisigAddress}, got ${initialState.multisigAddress}`,
);
}
if (
initialState.assetId !== getAddressFromAssetId(params.initiatorDepositAssetId)
|| initialState.assetId !== getAddressFromAssetId(params.responderDepositAssetId)
initialState.assetId !== getAddressFromAssetId(params.initiatorDepositAssetId) ||
initialState.assetId !== getAddressFromAssetId(params.responderDepositAssetId)
) {
throw new Error(`Cannot install deposit app with invalid token address. Expected ${getAddressFromAssetId(params.initiatorDepositAssetId)}, got ${initialState.assetId}`);
throw new Error(
`Cannot install deposit app with invalid token address. Expected ${getAddressFromAssetId(
params.initiatorDepositAssetId,
)}, got ${initialState.assetId}`,
);
}
const startingMultisigBalance =
const startingMultisigBalance =
initialState.assetId === CONVENTION_FOR_ETH_ASSET_ID
? await provider.getBalance(multisigAddress)
: await new Contract(initialState.assetId, ERC20.abi as any, provider)
.functions
.balanceOf(multisigAddress);
: await new Contract(initialState.assetId, ERC20.abi as any, provider).functions.balanceOf(
multisigAddress,
);

@@ -74,5 +92,5 @@ const multisig = new Contract(multisigAddress, MinimumViableMultisig.abi as any, provider);

try {
startingTotalAmountWithdrawn = await multisig
.functions
.totalAmountWithdrawn(initialState.assetId);
startingTotalAmountWithdrawn = await multisig.functions.totalAmountWithdrawn(
initialState.assetId,
);
} catch (e) {

@@ -89,7 +107,11 @@ const NOT_DEPLOYED_ERR = `contract not deployed (contractAddress="${multisigAddress}"`;

if (!initialState.startingTotalAmountWithdrawn.eq(startingTotalAmountWithdrawn)) {
throw new Error(`Cannot install deposit app with invalid totalAmountWithdrawn. Expected ${startingTotalAmountWithdrawn}, got ${initialState.startingTotalAmountWithdrawn}`);
throw new Error(
`Cannot install deposit app with invalid totalAmountWithdrawn. Expected ${startingTotalAmountWithdrawn}, got ${initialState.startingTotalAmountWithdrawn}`,
);
}
if (!initialState.startingMultisigBalance.eq(startingMultisigBalance)) {
throw new Error(`Cannot install deposit app with invalid startingMultisigBalance. Expected ${startingMultisigBalance}, got ${initialState.startingMultisigBalance}`);
throw new Error(
`Cannot install deposit app with invalid startingMultisigBalance. Expected ${startingMultisigBalance}, got ${initialState.startingMultisigBalance}`,
);
}

@@ -102,24 +124,21 @@ };

) => {
const {
role,
appInstance,
stateChannel,
params,
} = context;
const { role, appInstance, stateChannel, params } = context;
const latestState = appInstance.latestState as DepositAppState;
const currentMultisigBalance =
const currentMultisigBalance =
latestState.assetId === CONVENTION_FOR_ETH_ASSET_ID
? await provider.getBalance(stateChannel.multisigAddress)
: await new Contract(latestState.assetId, ERC20.abi as any, provider)
.functions
.balanceOf(stateChannel.multisigAddress);
: await new Contract(latestState.assetId, ERC20.abi as any, provider).functions.balanceOf(
stateChannel.multisigAddress,
);
if (currentMultisigBalance.lt(latestState.startingMultisigBalance)) {
throw new Error(`Refusing to uninstall, current multisig balance (${currentMultisigBalance.toString()}) is less than starting multsig balance (${latestState.startingMultisigBalance.toString()})`);
throw new Error(
`Refusing to uninstall, current multisig balance (${currentMultisigBalance.toString()}) is less than starting multsig balance (${latestState.startingMultisigBalance.toString()})`,
);
}
if (
role === ProtocolRoles.initiator
&& latestState.transfers[0].to !== getSignerAddressFromPublicIdentifier(params.initiatorIdentifier)
role === ProtocolRoles.initiator &&
latestState.transfers[0].to !== getSignerAddressFromPublicIdentifier(params.initiatorIdentifier)
) {

@@ -126,0 +145,0 @@ throw new Error(`Cannot uninstall deposit app without being the initiator`);

@@ -1,2 +0,2 @@

import {
import {
ValidationMiddleware,

@@ -16,3 +16,3 @@ ProtocolNames,

if (!contracts.provider) {
throw new Error(`Validation middleware needs access to a provider`)
throw new Error(`Validation middleware needs access to a provider`);
}

@@ -25,19 +25,16 @@

switch (protocol) {
case (ProtocolNames.setup):
case (ProtocolNames.propose):
case (ProtocolNames.install):
case (ProtocolNames.takeAction): {
case ProtocolNames.setup:
case ProtocolNames.propose:
case ProtocolNames.install:
case ProtocolNames.takeAction: {
break;
}
case (ProtocolNames.uninstall): {
await uninstallMiddleware(
contracts,
middlewareContext as UninstallMiddlewareContext,
);
case ProtocolNames.uninstall: {
await uninstallMiddleware(contracts, middlewareContext as UninstallMiddlewareContext);
break;
}
default:
throw new Error(`Unrecognized protocol name: ${protocol}`);
default:
throw new Error(`Unrecognized protocol name: ${protocol}`);
}

@@ -56,3 +53,3 @@ };

switch (appDef) {
case (contracts.DepositApp): {
case contracts.DepositApp: {
await uninstallDepositMiddleware(middlewareContext, contracts.provider);

@@ -65,2 +62,2 @@ break;

}
};
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc