@connext/apps
Advanced tools
Comparing version 6.5.6 to 6.5.7
@@ -120,2 +120,5 @@ this.window = this.window || {}; | ||
const { role, appInstance, stateChannel, params } = context; | ||
if (!provider || !provider.getBalance) { | ||
throw new Error(`Uninstall deposit middleware needs access to a provider, got ${JSON.stringify(provider, null, 2)}`); | ||
} | ||
const latestState = appInstance.latestState; | ||
@@ -284,5 +287,5 @@ const currentMultisigBalance = latestState.assetId === types.CONVENTION_FOR_ETH_ASSET_ID | ||
class WithdrawCommitment extends contracts.MultisigCommitment { | ||
constructor(networkContext, multisigAddress, multisigOwners, recipient, assetId, amount, nonce) { | ||
constructor(contractAddresses, multisigAddress, multisigOwners, recipient, assetId, amount, nonce) { | ||
super(multisigAddress, multisigOwners); | ||
this.networkContext = networkContext; | ||
this.contractAddresses = contractAddresses; | ||
this.multisigAddress = multisigAddress; | ||
@@ -297,3 +300,3 @@ this.multisigOwners = multisigOwners; | ||
return { | ||
to: this.networkContext.ConditionalTransactionDelegateTarget, | ||
to: this.contractAddresses.ConditionalTransactionDelegateTarget, | ||
value: 0, | ||
@@ -311,4 +314,4 @@ data: iface.functions.withdrawWrapper.encode([ | ||
const generateValidationMiddleware = async (contracts) => { | ||
if (!contracts.provider) { | ||
const generateValidationMiddleware = async (network) => { | ||
if (!network.provider) { | ||
throw new Error(`Validation middleware needs access to a provider`); | ||
@@ -324,7 +327,7 @@ } | ||
case types.ProtocolNames.propose: { | ||
await proposeMiddleware(contracts, middlewareContext); | ||
await proposeMiddleware(network, middlewareContext); | ||
break; | ||
} | ||
case types.ProtocolNames.uninstall: { | ||
await uninstallMiddleware(contracts, middlewareContext); | ||
await uninstallMiddleware(network, middlewareContext); | ||
break; | ||
@@ -338,8 +341,8 @@ } | ||
}; | ||
const uninstallMiddleware = async (contracts, middlewareContext) => { | ||
const uninstallMiddleware = async (network, middlewareContext) => { | ||
const { appInstance } = middlewareContext; | ||
const appDef = appInstance.appInterface.addr; | ||
switch (appDef) { | ||
case contracts.DepositApp: { | ||
await uninstallDepositMiddleware(middlewareContext, contracts.provider); | ||
case network.contractAddresses.DepositApp: { | ||
await uninstallDepositMiddleware(middlewareContext, network.provider); | ||
break; | ||
@@ -352,8 +355,8 @@ } | ||
}; | ||
const proposeMiddleware = async (contracts, middlewareContext) => { | ||
const proposeMiddleware = async (network, middlewareContext) => { | ||
const { proposal } = middlewareContext; | ||
const appDef = proposal.appDefinition; | ||
switch (appDef) { | ||
case contracts.DepositApp: { | ||
await proposeDepositMiddleware(middlewareContext, contracts.depositApp); | ||
case network.contractAddresses.DepositApp: { | ||
await proposeDepositMiddleware(middlewareContext, network.contractAddresses.DepositApp); | ||
break; | ||
@@ -360,0 +363,0 @@ } |
@@ -123,2 +123,5 @@ 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'; | ||
const { role, appInstance, stateChannel, params } = context; | ||
if (!provider || !provider.getBalance) { | ||
throw new Error(`Uninstall deposit middleware needs access to a provider, got ${JSON.stringify(provider, null, 2)}`); | ||
} | ||
const latestState = appInstance.latestState; | ||
@@ -287,5 +290,5 @@ const currentMultisigBalance = latestState.assetId === CONVENTION_FOR_ETH_ASSET_ID | ||
class WithdrawCommitment extends MultisigCommitment { | ||
constructor(networkContext, multisigAddress, multisigOwners, recipient, assetId, amount, nonce) { | ||
constructor(contractAddresses, multisigAddress, multisigOwners, recipient, assetId, amount, nonce) { | ||
super(multisigAddress, multisigOwners); | ||
this.networkContext = networkContext; | ||
this.contractAddresses = contractAddresses; | ||
this.multisigAddress = multisigAddress; | ||
@@ -300,3 +303,3 @@ this.multisigOwners = multisigOwners; | ||
return { | ||
to: this.networkContext.ConditionalTransactionDelegateTarget, | ||
to: this.contractAddresses.ConditionalTransactionDelegateTarget, | ||
value: 0, | ||
@@ -314,4 +317,4 @@ data: iface.functions.withdrawWrapper.encode([ | ||
const generateValidationMiddleware = async (contracts) => { | ||
if (!contracts.provider) { | ||
const generateValidationMiddleware = async (network) => { | ||
if (!network.provider) { | ||
throw new Error(`Validation middleware needs access to a provider`); | ||
@@ -327,7 +330,7 @@ } | ||
case ProtocolNames.propose: { | ||
await proposeMiddleware(contracts, middlewareContext); | ||
await proposeMiddleware(network, middlewareContext); | ||
break; | ||
} | ||
case ProtocolNames.uninstall: { | ||
await uninstallMiddleware(contracts, middlewareContext); | ||
await uninstallMiddleware(network, middlewareContext); | ||
break; | ||
@@ -341,8 +344,8 @@ } | ||
}; | ||
const uninstallMiddleware = async (contracts, middlewareContext) => { | ||
const uninstallMiddleware = async (network, middlewareContext) => { | ||
const { appInstance } = middlewareContext; | ||
const appDef = appInstance.appInterface.addr; | ||
switch (appDef) { | ||
case contracts.DepositApp: { | ||
await uninstallDepositMiddleware(middlewareContext, contracts.provider); | ||
case network.contractAddresses.DepositApp: { | ||
await uninstallDepositMiddleware(middlewareContext, network.provider); | ||
break; | ||
@@ -355,8 +358,8 @@ } | ||
}; | ||
const proposeMiddleware = async (contracts, middlewareContext) => { | ||
const proposeMiddleware = async (network, middlewareContext) => { | ||
const { proposal } = middlewareContext; | ||
const appDef = proposal.appDefinition; | ||
switch (appDef) { | ||
case contracts.DepositApp: { | ||
await proposeDepositMiddleware(middlewareContext, contracts.depositApp); | ||
case network.contractAddresses.DepositApp: { | ||
await proposeDepositMiddleware(middlewareContext, network.contractAddresses.DepositApp); | ||
break; | ||
@@ -363,0 +366,0 @@ } |
@@ -127,2 +127,5 @@ 'use strict'; | ||
const { role, appInstance, stateChannel, params } = context; | ||
if (!provider || !provider.getBalance) { | ||
throw new Error(`Uninstall deposit middleware needs access to a provider, got ${JSON.stringify(provider, null, 2)}`); | ||
} | ||
const latestState = appInstance.latestState; | ||
@@ -291,5 +294,5 @@ const currentMultisigBalance = latestState.assetId === types.CONVENTION_FOR_ETH_ASSET_ID | ||
class WithdrawCommitment extends contracts.MultisigCommitment { | ||
constructor(networkContext, multisigAddress, multisigOwners, recipient, assetId, amount, nonce) { | ||
constructor(contractAddresses, multisigAddress, multisigOwners, recipient, assetId, amount, nonce) { | ||
super(multisigAddress, multisigOwners); | ||
this.networkContext = networkContext; | ||
this.contractAddresses = contractAddresses; | ||
this.multisigAddress = multisigAddress; | ||
@@ -304,3 +307,3 @@ this.multisigOwners = multisigOwners; | ||
return { | ||
to: this.networkContext.ConditionalTransactionDelegateTarget, | ||
to: this.contractAddresses.ConditionalTransactionDelegateTarget, | ||
value: 0, | ||
@@ -318,4 +321,4 @@ data: iface.functions.withdrawWrapper.encode([ | ||
const generateValidationMiddleware = async (contracts) => { | ||
if (!contracts.provider) { | ||
const generateValidationMiddleware = async (network) => { | ||
if (!network.provider) { | ||
throw new Error(`Validation middleware needs access to a provider`); | ||
@@ -331,7 +334,7 @@ } | ||
case types.ProtocolNames.propose: { | ||
await proposeMiddleware(contracts, middlewareContext); | ||
await proposeMiddleware(network, middlewareContext); | ||
break; | ||
} | ||
case types.ProtocolNames.uninstall: { | ||
await uninstallMiddleware(contracts, middlewareContext); | ||
await uninstallMiddleware(network, middlewareContext); | ||
break; | ||
@@ -345,8 +348,8 @@ } | ||
}; | ||
const uninstallMiddleware = async (contracts, middlewareContext) => { | ||
const uninstallMiddleware = async (network, middlewareContext) => { | ||
const { appInstance } = middlewareContext; | ||
const appDef = appInstance.appInterface.addr; | ||
switch (appDef) { | ||
case contracts.DepositApp: { | ||
await uninstallDepositMiddleware(middlewareContext, contracts.provider); | ||
case network.contractAddresses.DepositApp: { | ||
await uninstallDepositMiddleware(middlewareContext, network.provider); | ||
break; | ||
@@ -359,8 +362,8 @@ } | ||
}; | ||
const proposeMiddleware = async (contracts, middlewareContext) => { | ||
const proposeMiddleware = async (network, middlewareContext) => { | ||
const { proposal } = middlewareContext; | ||
const appDef = proposal.appDefinition; | ||
switch (appDef) { | ||
case contracts.DepositApp: { | ||
await proposeDepositMiddleware(middlewareContext, contracts.depositApp); | ||
case network.contractAddresses.DepositApp: { | ||
await proposeDepositMiddleware(middlewareContext, network.contractAddresses.DepositApp); | ||
break; | ||
@@ -367,0 +370,0 @@ } |
import { UninstallMiddlewareContext, ProposeMiddlewareContext } from "@connext/types"; | ||
import { BaseProvider, JsonRpcProvider } from "ethers/providers"; | ||
import { JsonRpcProvider } from "ethers/providers"; | ||
export declare const validateDepositApp: (params: { | ||
@@ -17,5 +17,5 @@ abiEncodings: import("@connext/types").AppABIEncodings; | ||
stateTimeout?: import("ethers/utils").BigNumber | undefined; | ||
}, initiatorIdentifier: string, responderIdentifier: string, multisigAddress: string, provider: BaseProvider) => Promise<void>; | ||
}, initiatorIdentifier: string, responderIdentifier: string, multisigAddress: string, provider: JsonRpcProvider) => Promise<void>; | ||
export declare const uninstallDepositMiddleware: (context: UninstallMiddlewareContext, provider: JsonRpcProvider) => Promise<void>; | ||
export declare const proposeDepositMiddleware: (context: ProposeMiddlewareContext, appDefinitionAddress: string) => Promise<void>; | ||
//# sourceMappingURL=validation.d.ts.map |
import { ProtocolRoles, CONVENTION_FOR_ETH_ASSET_ID, } from "@connext/types"; | ||
import { getAddressFromAssetId, getSignerAddressFromPublicIdentifier, stringify, } from "@connext/utils"; | ||
import { MinimumViableMultisig, ERC20 } from "@connext/contracts"; | ||
import { Contract } from "ethers"; | ||
import { Zero } from "ethers/constants"; | ||
import { baseCoinTransferValidation } from "../shared"; | ||
import { Zero } from "ethers/constants"; | ||
import { Contract } from "ethers"; | ||
export const validateDepositApp = async (params, initiatorIdentifier, responderIdentifier, multisigAddress, provider) => { | ||
@@ -55,2 +55,5 @@ const { responderDeposit, initiatorDeposit } = params; | ||
const { role, appInstance, stateChannel, params } = context; | ||
if (!provider || !provider.getBalance) { | ||
throw new Error(`Uninstall deposit middleware needs access to a provider, got ${JSON.stringify(provider, null, 2)}`); | ||
} | ||
const latestState = appInstance.latestState; | ||
@@ -57,0 +60,0 @@ const currentMultisigBalance = latestState.assetId === CONVENTION_FOR_ETH_ASSET_ID |
@@ -1,3 +0,3 @@ | ||
import { ValidationMiddleware, ContractAddresses } from "@connext/types"; | ||
export declare const generateValidationMiddleware: (contracts: ContractAddresses) => Promise<ValidationMiddleware>; | ||
import { ValidationMiddleware, NetworkContext } from "@connext/types"; | ||
export declare const generateValidationMiddleware: (network: NetworkContext) => Promise<ValidationMiddleware>; | ||
//# sourceMappingURL=middleware.d.ts.map |
import { ProtocolNames, } from "@connext/types"; | ||
import { uninstallDepositMiddleware, proposeDepositMiddleware } from "./DepositApp"; | ||
export const generateValidationMiddleware = async (contracts) => { | ||
if (!contracts.provider) { | ||
export const generateValidationMiddleware = async (network) => { | ||
if (!network.provider) { | ||
throw new Error(`Validation middleware needs access to a provider`); | ||
@@ -15,7 +15,7 @@ } | ||
case ProtocolNames.propose: { | ||
await proposeMiddleware(contracts, middlewareContext); | ||
await proposeMiddleware(network, middlewareContext); | ||
break; | ||
} | ||
case ProtocolNames.uninstall: { | ||
await uninstallMiddleware(contracts, middlewareContext); | ||
await uninstallMiddleware(network, middlewareContext); | ||
break; | ||
@@ -29,8 +29,8 @@ } | ||
}; | ||
const uninstallMiddleware = async (contracts, middlewareContext) => { | ||
const uninstallMiddleware = async (network, middlewareContext) => { | ||
const { appInstance } = middlewareContext; | ||
const appDef = appInstance.appInterface.addr; | ||
switch (appDef) { | ||
case contracts.DepositApp: { | ||
await uninstallDepositMiddleware(middlewareContext, contracts.provider); | ||
case network.contractAddresses.DepositApp: { | ||
await uninstallDepositMiddleware(middlewareContext, network.provider); | ||
break; | ||
@@ -43,8 +43,8 @@ } | ||
}; | ||
const proposeMiddleware = async (contracts, middlewareContext) => { | ||
const proposeMiddleware = async (network, middlewareContext) => { | ||
const { proposal } = middlewareContext; | ||
const appDef = proposal.appDefinition; | ||
switch (appDef) { | ||
case contracts.DepositApp: { | ||
await proposeDepositMiddleware(middlewareContext, contracts.depositApp); | ||
case network.contractAddresses.DepositApp: { | ||
await proposeDepositMiddleware(middlewareContext, network.contractAddresses.DepositApp); | ||
break; | ||
@@ -51,0 +51,0 @@ } |
import { MultisigCommitment } from "@connext/contracts"; | ||
import { MultisigTransaction, NetworkContext, ContractAddresses } from "@connext/types"; | ||
import { MultisigTransaction, ContractAddresses } from "@connext/types"; | ||
import { BigNumberish } from "ethers/utils"; | ||
export declare class WithdrawCommitment extends MultisigCommitment { | ||
readonly networkContext: NetworkContext | ContractAddresses; | ||
readonly contractAddresses: ContractAddresses; | ||
readonly multisigAddress: string; | ||
@@ -12,5 +12,5 @@ readonly multisigOwners: string[]; | ||
readonly nonce: string; | ||
constructor(networkContext: NetworkContext | ContractAddresses, multisigAddress: string, multisigOwners: string[], recipient: string, assetId: string, amount: BigNumberish, nonce: string); | ||
constructor(contractAddresses: ContractAddresses, multisigAddress: string, multisigOwners: string[], recipient: string, assetId: string, amount: BigNumberish, nonce: string); | ||
getTransactionDetails(): MultisigTransaction; | ||
} | ||
//# sourceMappingURL=withdrawCommitment.d.ts.map |
@@ -6,5 +6,5 @@ import { MultisigCommitment, ConditionalTransactionDelegateTarget } from "@connext/contracts"; | ||
export class WithdrawCommitment extends MultisigCommitment { | ||
constructor(networkContext, multisigAddress, multisigOwners, recipient, assetId, amount, nonce) { | ||
constructor(contractAddresses, multisigAddress, multisigOwners, recipient, assetId, amount, nonce) { | ||
super(multisigAddress, multisigOwners); | ||
this.networkContext = networkContext; | ||
this.contractAddresses = contractAddresses; | ||
this.multisigAddress = multisigAddress; | ||
@@ -19,3 +19,3 @@ this.multisigOwners = multisigOwners; | ||
return { | ||
to: this.networkContext.ConditionalTransactionDelegateTarget, | ||
to: this.contractAddresses.ConditionalTransactionDelegateTarget, | ||
value: 0, | ||
@@ -22,0 +22,0 @@ data: iface.functions.withdrawWrapper.encode([ |
{ | ||
"name": "@connext/apps", | ||
"version": "6.5.6", | ||
"version": "6.5.7", | ||
"description": "Connext Counterfactual Apps", | ||
@@ -21,5 +21,5 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"@connext/contracts": "3.0.0", | ||
"@connext/utils": "6.5.6", | ||
"@connext/types": "6.5.6", | ||
"@connext/contracts": "3.1.0", | ||
"@connext/utils": "6.5.7", | ||
"@connext/types": "6.5.7", | ||
"ethers": "4.0.47", | ||
@@ -26,0 +26,0 @@ "rollup": "2.7.2", |
@@ -16,8 +16,9 @@ import { | ||
import { MinimumViableMultisig, ERC20 } from "@connext/contracts"; | ||
import { Contract } from "ethers"; | ||
import { Zero } from "ethers/constants"; | ||
import { JsonRpcProvider } from "ethers/providers"; | ||
import { baseCoinTransferValidation } from "../shared"; | ||
import { Zero } from "ethers/constants"; | ||
import { Contract } from "ethers"; | ||
import { BaseProvider, JsonRpcProvider } from "ethers/providers"; | ||
export const validateDepositApp = async ( | ||
@@ -28,3 +29,3 @@ params: MethodParams.ProposeInstall, | ||
multisigAddress: string, | ||
provider: BaseProvider, | ||
provider: JsonRpcProvider, | ||
) => { | ||
@@ -126,2 +127,6 @@ const { responderDeposit, initiatorDeposit } = params; | ||
if (!provider || !provider.getBalance) { | ||
throw new Error(`Uninstall deposit middleware needs access to a provider, got ${JSON.stringify(provider, null, 2)}`); | ||
} | ||
const latestState = appInstance.latestState as DepositAppState; | ||
@@ -128,0 +133,0 @@ const currentMultisigBalance = |
@@ -7,3 +7,3 @@ import { | ||
UninstallMiddlewareContext, | ||
ContractAddresses, | ||
NetworkContext, | ||
ProposeMiddlewareContext, | ||
@@ -15,5 +15,5 @@ } from "@connext/types"; | ||
export const generateValidationMiddleware = async ( | ||
contracts: ContractAddresses, | ||
network: NetworkContext, | ||
): Promise<ValidationMiddleware> => { | ||
if (!contracts.provider) { | ||
if (!network.provider) { | ||
throw new Error(`Validation middleware needs access to a provider`); | ||
@@ -34,3 +34,3 @@ } | ||
case ProtocolNames.propose: { | ||
await proposeMiddleware(contracts, middlewareContext as ProposeMiddlewareContext); | ||
await proposeMiddleware(network, middlewareContext as ProposeMiddlewareContext); | ||
break; | ||
@@ -40,3 +40,3 @@ } | ||
case ProtocolNames.uninstall: { | ||
await uninstallMiddleware(contracts, middlewareContext as UninstallMiddlewareContext); | ||
await uninstallMiddleware(network, middlewareContext as UninstallMiddlewareContext); | ||
break; | ||
@@ -54,3 +54,3 @@ } | ||
const uninstallMiddleware = async ( | ||
contracts: ContractAddresses, | ||
network: NetworkContext, | ||
middlewareContext: UninstallMiddlewareContext, | ||
@@ -61,4 +61,4 @@ ) => { | ||
switch (appDef) { | ||
case contracts.DepositApp: { | ||
await uninstallDepositMiddleware(middlewareContext, contracts.provider); | ||
case network.contractAddresses.DepositApp: { | ||
await uninstallDepositMiddleware(middlewareContext, network.provider); | ||
break; | ||
@@ -73,3 +73,3 @@ } | ||
const proposeMiddleware = async ( | ||
contracts: ContractAddresses, | ||
network: NetworkContext, | ||
middlewareContext: ProposeMiddlewareContext, | ||
@@ -80,4 +80,4 @@ ) => { | ||
switch (appDef) { | ||
case contracts.DepositApp: { | ||
await proposeDepositMiddleware(middlewareContext, contracts.depositApp); | ||
case network.contractAddresses.DepositApp: { | ||
await proposeDepositMiddleware(middlewareContext, network.contractAddresses.DepositApp); | ||
break; | ||
@@ -84,0 +84,0 @@ } |
import { MultisigCommitment, ConditionalTransactionDelegateTarget } from "@connext/contracts"; | ||
import { MultisigTransaction, MultisigOperation, NetworkContext, ContractAddresses } from "@connext/types"; | ||
import { MultisigTransaction, MultisigOperation, ContractAddresses } from "@connext/types"; | ||
import { BigNumberish, Interface } from "ethers/utils"; | ||
@@ -8,3 +8,3 @@ | ||
public constructor( | ||
public readonly networkContext: NetworkContext | ContractAddresses, | ||
public readonly contractAddresses: ContractAddresses, | ||
public readonly multisigAddress: string, | ||
@@ -22,3 +22,3 @@ public readonly multisigOwners: string[], | ||
return { | ||
to: this.networkContext.ConditionalTransactionDelegateTarget, | ||
to: this.contractAddresses.ConditionalTransactionDelegateTarget, | ||
value: 0, | ||
@@ -25,0 +25,0 @@ data: iface.functions.withdrawWrapper.encode([ |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
606669
2495