@connext/apps
Advanced tools
Comparing version 6.6.5 to 6.7.0
this.window = this.window || {}; | ||
this.window.apps = (function (exports, constants, types, utils, contracts, ethers, utils$1) { | ||
this.window.apps = (function (exports, ethers, types, utils, contracts) { | ||
'use strict'; | ||
const SupportedApplications = types.enumify({ | ||
[types.SimpleLinkedTransferAppName]: types.SimpleLinkedTransferAppName, | ||
[types.SimpleSignedTransferAppName]: types.SimpleSignedTransferAppName, | ||
[types.SimpleTwoPartySwapAppName]: types.SimpleTwoPartySwapAppName, | ||
[types.WithdrawAppName]: types.WithdrawAppName, | ||
[types.HashLockTransferAppName]: types.HashLockTransferAppName, | ||
[types.DepositAppName]: types.DepositAppName, | ||
}); | ||
const DEFAULT_APP_TIMEOUT = utils.toBN(8640); | ||
const MINIMUM_APP_TIMEOUT = DEFAULT_APP_TIMEOUT.div(2); | ||
const { Zero } = ethers.constants; | ||
const appProposalMatchesRegistry = (proposal, appRegistryInfo) => { | ||
@@ -36,12 +29,12 @@ if (proposal.abiEncodings.actionEncoding && | ||
baseCoinTransferValidation(initiatorDeposit, responderDeposit, initiatorTransfer, responderTransfer); | ||
if (!responderDeposit.eq(constants.Zero)) { | ||
if (!responderDeposit.eq(Zero)) { | ||
throw new Error(`Will not accept transfer install where responder deposit is != 0. Responder deposit: ${responderDeposit.toString()}`); | ||
} | ||
if (initiatorDeposit.lte(constants.Zero)) { | ||
if (initiatorDeposit.lte(Zero)) { | ||
throw new Error(`Will not accept transfer install where initiator deposit is <= 0. Initiator deposit: ${initiatorDeposit.toString()}`); | ||
} | ||
if (initiatorTransfer.amount.lte(constants.Zero)) { | ||
if (initiatorTransfer.amount.lte(Zero)) { | ||
throw new Error(`Cannot install a linked transfer app with a sender transfer of <= 0. Transfer amount: ${initiatorTransfer.amount.toString()}`); | ||
} | ||
if (!responderTransfer.amount.eq(constants.Zero)) { | ||
if (!responderTransfer.amount.eq(Zero)) { | ||
throw new Error(`Cannot install a linked transfer app with a redeemer transfer of != 0. Transfer amount: ${responderTransfer.amount.toString()}`); | ||
@@ -81,2 +74,3 @@ } | ||
const { Zero: Zero$1 } = ethers.constants; | ||
const validateDepositApp = async (params, channel, provider) => { | ||
@@ -120,3 +114,3 @@ const { responderDeposit, initiatorDeposit, initiatorIdentifier, responderIdentifier } = params; | ||
} | ||
startingTotalAmountWithdrawn = constants.Zero; | ||
startingTotalAmountWithdrawn = Zero$1; | ||
} | ||
@@ -160,2 +154,3 @@ if (!initialState.startingTotalAmountWithdrawn.eq(startingTotalAmountWithdrawn)) { | ||
const { Zero: Zero$2 } = ethers.constants; | ||
const HashLockTransferAppRegistryInfo = { | ||
@@ -168,3 +163,3 @@ name: types.HashLockTransferAppName, | ||
}; | ||
const HASHLOCK_TRANSFER_STATE_TIMEOUT = constants.Zero; | ||
const HASHLOCK_TRANSFER_STATE_TIMEOUT = Zero$2; | ||
@@ -194,2 +189,3 @@ const validateHashLockTransferApp = (params, blockNumber) => { | ||
const { Zero: Zero$3 } = ethers.constants; | ||
const SimpleLinkedTransferAppRegistryInfo = { | ||
@@ -202,3 +198,3 @@ actionEncoding: types.SimpleLinkedTransferAppActionEncoding, | ||
}; | ||
const LINKED_TRANSFER_STATE_TIMEOUT = constants.Zero; | ||
const LINKED_TRANSFER_STATE_TIMEOUT = Zero$3; | ||
@@ -224,2 +220,3 @@ const validateSimpleLinkedTransferApp = (params) => { | ||
const { Zero: Zero$4 } = ethers.constants; | ||
const SimpleSignedTransferAppRegistryInfo = { | ||
@@ -232,3 +229,3 @@ allowNodeInstall: true, | ||
}; | ||
const SIGNED_TRANSFER_STATE_TIMEOUT = constants.Zero; | ||
const SIGNED_TRANSFER_STATE_TIMEOUT = Zero$4; | ||
@@ -254,2 +251,3 @@ const validateSignedTransferApp = (params) => { | ||
const { Zero: Zero$5 } = ethers.constants; | ||
const WithdrawAppRegistryInfo = { | ||
@@ -262,4 +260,5 @@ allowNodeInstall: true, | ||
}; | ||
const WITHDRAW_STATE_TIMEOUT = constants.Zero; | ||
const WITHDRAW_STATE_TIMEOUT = Zero$5; | ||
const { HashZero, Zero: Zero$6 } = ethers.constants; | ||
const validateWithdrawApp = async (params) => { | ||
@@ -276,3 +275,3 @@ const { responderDeposit, initiatorDeposit, initiatorIdentifier, responderIdentifier } = params; | ||
} | ||
if (initialState.signatures[1] !== constants.HashZero) { | ||
if (initialState.signatures[1] !== HashZero) { | ||
throw new Error(`Cannot install a withdraw app with a populated signatures[1] field. Signatures[1]: ${initialState.signatures[1]}`); | ||
@@ -284,6 +283,6 @@ } | ||
} | ||
if (!initialState.transfers[1].amount.eq(constants.Zero)) { | ||
if (!initialState.transfers[1].amount.eq(Zero$6)) { | ||
throw new Error(`Cannot install a withdraw app with nonzero recipient amount. ${initialState.transfers[1].amount.toString()}`); | ||
} | ||
let recovered = await utils.recoverAddressFromChannelMessage(initialState.data, initialState.signatures[0]); | ||
const recovered = await utils.recoverAddressFromChannelMessage(initialState.data, initialState.signatures[0]); | ||
if (recovered !== initialState.signers[0]) { | ||
@@ -295,3 +294,4 @@ throw new Error(`Cannot install withdraw app - incorrect signer recovered from initiator sig on data. | ||
const iface = new utils$1.Interface(contracts.ConditionalTransactionDelegateTarget.abi); | ||
const { Interface } = ethers.utils; | ||
const iface = new Interface(contracts.ConditionalTransactionDelegateTarget.abi); | ||
class WithdrawCommitment extends contracts.MultisigCommitment { | ||
@@ -328,2 +328,3 @@ constructor(contractAddresses, multisigAddress, multisigOwners, recipient, assetId, amount, nonce) { | ||
const { Zero: Zero$7 } = ethers.constants; | ||
const SimpleTwoPartySwapAppRegistryInfo = { | ||
@@ -335,4 +336,5 @@ allowNodeInstall: true, | ||
}; | ||
const SWAP_STATE_TIMEOUT = constants.Zero; | ||
const SWAP_STATE_TIMEOUT = Zero$7; | ||
const { bigNumberify } = ethers.utils; | ||
const ALLOWED_DISCREPANCY_PCT = 5; | ||
@@ -349,3 +351,3 @@ const validateSimpleSwapApp = (params, allowedSwaps, ourRate) => { | ||
const allowedDiscrepancy = calculated | ||
.mul(utils$1.bigNumberify(100).sub(ALLOWED_DISCREPANCY_PCT)) | ||
.mul(bigNumberify(100).sub(ALLOWED_DISCREPANCY_PCT)) | ||
.div(100); | ||
@@ -456,3 +458,4 @@ if (calculatedToActualDiscrepancy.gt(allowedDiscrepancy)) { | ||
const TRANSFER_TIMEOUT = constants.Zero; | ||
const { Zero: Zero$8 } = ethers.constants; | ||
const TRANSFER_TIMEOUT = Zero$8; | ||
@@ -472,3 +475,2 @@ exports.AppRegistry = AppRegistry; | ||
exports.SimpleTwoPartySwapAppRegistryInfo = SimpleTwoPartySwapAppRegistryInfo; | ||
exports.SupportedApplications = SupportedApplications; | ||
exports.TRANSFER_TIMEOUT = TRANSFER_TIMEOUT; | ||
@@ -499,2 +501,2 @@ exports.WITHDRAW_STATE_TIMEOUT = WITHDRAW_STATE_TIMEOUT; | ||
}({}, constants, types, utils, contracts, ethers, utils$1)); | ||
}({}, ethers, types, utils, contracts)); |
@@ -1,19 +0,10 @@ | ||
import { Zero, HashZero } from 'ethers/constants'; | ||
import { enumify, SimpleLinkedTransferAppName, SimpleSignedTransferAppName, SimpleTwoPartySwapAppName, WithdrawAppName, HashLockTransferAppName, DepositAppName, OutcomeType, DepositAppStateEncoding, CONVENTION_FOR_ETH_ASSET_ID, Contract as Contract$1, ProtocolRoles, HashLockTransferAppActionEncoding, HashLockTransferAppStateEncoding, SimpleLinkedTransferAppActionEncoding, SimpleLinkedTransferAppStateEncoding, SimpleSignedTransferAppStateEncoding, SimpleSignedTransferAppActionEncoding, WithdrawAppStateEncoding, WithdrawAppActionEncoding, MultisigOperation, SimpleSwapAppStateEncoding, ProtocolNames } from '@connext/types'; | ||
import { constants, Contract, utils } from 'ethers'; | ||
import { DepositAppName, OutcomeType, DepositAppStateEncoding, CONVENTION_FOR_ETH_ASSET_ID, Contract as Contract$1, ProtocolRoles, HashLockTransferAppName, HashLockTransferAppActionEncoding, HashLockTransferAppStateEncoding, SimpleLinkedTransferAppActionEncoding, SimpleLinkedTransferAppName, SimpleLinkedTransferAppStateEncoding, SimpleSignedTransferAppName, SimpleSignedTransferAppStateEncoding, SimpleSignedTransferAppActionEncoding, WithdrawAppName, WithdrawAppStateEncoding, WithdrawAppActionEncoding, MultisigOperation, SimpleTwoPartySwapAppName, SimpleSwapAppStateEncoding, ProtocolNames } from '@connext/types'; | ||
import { toBN, getAddressFromAssetId, stringify, getSignerAddressFromPublicIdentifier, bigNumberifyJson, recoverAddressFromChannelMessage, calculateExchange } from '@connext/utils'; | ||
import { ERC20, MinimumViableMultisig, ConditionalTransactionDelegateTarget, MultisigCommitment } from '@connext/contracts'; | ||
import { Contract } from 'ethers'; | ||
import { Interface, bigNumberify } from 'ethers/utils'; | ||
const SupportedApplications = enumify({ | ||
[SimpleLinkedTransferAppName]: SimpleLinkedTransferAppName, | ||
[SimpleSignedTransferAppName]: SimpleSignedTransferAppName, | ||
[SimpleTwoPartySwapAppName]: SimpleTwoPartySwapAppName, | ||
[WithdrawAppName]: WithdrawAppName, | ||
[HashLockTransferAppName]: HashLockTransferAppName, | ||
[DepositAppName]: DepositAppName, | ||
}); | ||
const DEFAULT_APP_TIMEOUT = toBN(8640); | ||
const MINIMUM_APP_TIMEOUT = DEFAULT_APP_TIMEOUT.div(2); | ||
const { Zero } = constants; | ||
const appProposalMatchesRegistry = (proposal, appRegistryInfo) => { | ||
@@ -83,2 +74,3 @@ if (proposal.abiEncodings.actionEncoding && | ||
const { Zero: Zero$1 } = constants; | ||
const validateDepositApp = async (params, channel, provider) => { | ||
@@ -122,3 +114,3 @@ const { responderDeposit, initiatorDeposit, initiatorIdentifier, responderIdentifier } = params; | ||
} | ||
startingTotalAmountWithdrawn = Zero; | ||
startingTotalAmountWithdrawn = Zero$1; | ||
} | ||
@@ -162,2 +154,3 @@ if (!initialState.startingTotalAmountWithdrawn.eq(startingTotalAmountWithdrawn)) { | ||
const { Zero: Zero$2 } = constants; | ||
const HashLockTransferAppRegistryInfo = { | ||
@@ -170,3 +163,3 @@ name: HashLockTransferAppName, | ||
}; | ||
const HASHLOCK_TRANSFER_STATE_TIMEOUT = Zero; | ||
const HASHLOCK_TRANSFER_STATE_TIMEOUT = Zero$2; | ||
@@ -196,2 +189,3 @@ const validateHashLockTransferApp = (params, blockNumber) => { | ||
const { Zero: Zero$3 } = constants; | ||
const SimpleLinkedTransferAppRegistryInfo = { | ||
@@ -204,3 +198,3 @@ actionEncoding: SimpleLinkedTransferAppActionEncoding, | ||
}; | ||
const LINKED_TRANSFER_STATE_TIMEOUT = Zero; | ||
const LINKED_TRANSFER_STATE_TIMEOUT = Zero$3; | ||
@@ -226,2 +220,3 @@ const validateSimpleLinkedTransferApp = (params) => { | ||
const { Zero: Zero$4 } = constants; | ||
const SimpleSignedTransferAppRegistryInfo = { | ||
@@ -234,3 +229,3 @@ allowNodeInstall: true, | ||
}; | ||
const SIGNED_TRANSFER_STATE_TIMEOUT = Zero; | ||
const SIGNED_TRANSFER_STATE_TIMEOUT = Zero$4; | ||
@@ -256,2 +251,3 @@ const validateSignedTransferApp = (params) => { | ||
const { Zero: Zero$5 } = constants; | ||
const WithdrawAppRegistryInfo = { | ||
@@ -264,4 +260,5 @@ allowNodeInstall: true, | ||
}; | ||
const WITHDRAW_STATE_TIMEOUT = Zero; | ||
const WITHDRAW_STATE_TIMEOUT = Zero$5; | ||
const { HashZero, Zero: Zero$6 } = constants; | ||
const validateWithdrawApp = async (params) => { | ||
@@ -285,6 +282,6 @@ const { responderDeposit, initiatorDeposit, initiatorIdentifier, responderIdentifier } = params; | ||
} | ||
if (!initialState.transfers[1].amount.eq(Zero)) { | ||
if (!initialState.transfers[1].amount.eq(Zero$6)) { | ||
throw new Error(`Cannot install a withdraw app with nonzero recipient amount. ${initialState.transfers[1].amount.toString()}`); | ||
} | ||
let recovered = await recoverAddressFromChannelMessage(initialState.data, initialState.signatures[0]); | ||
const recovered = await recoverAddressFromChannelMessage(initialState.data, initialState.signatures[0]); | ||
if (recovered !== initialState.signers[0]) { | ||
@@ -296,2 +293,3 @@ throw new Error(`Cannot install withdraw app - incorrect signer recovered from initiator sig on data. | ||
const { Interface } = utils; | ||
const iface = new Interface(ConditionalTransactionDelegateTarget.abi); | ||
@@ -329,2 +327,3 @@ class WithdrawCommitment extends MultisigCommitment { | ||
const { Zero: Zero$7 } = constants; | ||
const SimpleTwoPartySwapAppRegistryInfo = { | ||
@@ -336,4 +335,5 @@ allowNodeInstall: true, | ||
}; | ||
const SWAP_STATE_TIMEOUT = Zero; | ||
const SWAP_STATE_TIMEOUT = Zero$7; | ||
const { bigNumberify } = utils; | ||
const ALLOWED_DISCREPANCY_PCT = 5; | ||
@@ -456,4 +456,5 @@ const validateSimpleSwapApp = (params, allowedSwaps, ourRate) => { | ||
const TRANSFER_TIMEOUT = Zero; | ||
const { Zero: Zero$8 } = constants; | ||
const TRANSFER_TIMEOUT = Zero$8; | ||
export { AppRegistry, DEFAULT_APP_TIMEOUT, DEPOSIT_STATE_TIMEOUT, DepositAppRegistryInfo, HASHLOCK_TRANSFER_STATE_TIMEOUT, HashLockTransferAppRegistryInfo, LINKED_TRANSFER_STATE_TIMEOUT, MINIMUM_APP_TIMEOUT, SIGNED_TRANSFER_STATE_TIMEOUT, SWAP_STATE_TIMEOUT, SimpleLinkedTransferAppRegistryInfo, SimpleSignedTransferAppRegistryInfo, SimpleTwoPartySwapAppRegistryInfo, SupportedApplications, TRANSFER_TIMEOUT, WITHDRAW_STATE_TIMEOUT, WithdrawAppRegistryInfo, WithdrawCommitment, baseCoinTransferValidation, commonAppProposalValidation, generateValidationMiddleware, proposeDepositMiddleware, proposeHashLockTransferMiddleware, proposeLinkedTransferMiddleware, proposeSignedTransferMiddleware, proposeSwapMiddleware, proposeWithdrawMiddleware, sharedProposalMiddleware, unidirectionalCoinTransferValidation, uninstallDepositMiddleware, validateDepositApp, validateHashLockTransferApp, validateSignedTransferApp, validateSimpleLinkedTransferApp, validateSimpleSwapApp, validateWithdrawApp }; | ||
export { AppRegistry, DEFAULT_APP_TIMEOUT, DEPOSIT_STATE_TIMEOUT, DepositAppRegistryInfo, HASHLOCK_TRANSFER_STATE_TIMEOUT, HashLockTransferAppRegistryInfo, LINKED_TRANSFER_STATE_TIMEOUT, MINIMUM_APP_TIMEOUT, SIGNED_TRANSFER_STATE_TIMEOUT, SWAP_STATE_TIMEOUT, SimpleLinkedTransferAppRegistryInfo, SimpleSignedTransferAppRegistryInfo, SimpleTwoPartySwapAppRegistryInfo, TRANSFER_TIMEOUT, WITHDRAW_STATE_TIMEOUT, WithdrawAppRegistryInfo, WithdrawCommitment, baseCoinTransferValidation, commonAppProposalValidation, generateValidationMiddleware, proposeDepositMiddleware, proposeHashLockTransferMiddleware, proposeLinkedTransferMiddleware, proposeSignedTransferMiddleware, proposeSwapMiddleware, proposeWithdrawMiddleware, sharedProposalMiddleware, unidirectionalCoinTransferValidation, uninstallDepositMiddleware, validateDepositApp, validateHashLockTransferApp, validateSignedTransferApp, validateSimpleLinkedTransferApp, validateSimpleSwapApp, validateWithdrawApp }; |
@@ -5,20 +5,11 @@ 'use strict'; | ||
var constants = require('ethers/constants'); | ||
var ethers = require('ethers'); | ||
var types = require('@connext/types'); | ||
var utils = require('@connext/utils'); | ||
var contracts = require('@connext/contracts'); | ||
var ethers = require('ethers'); | ||
var utils$1 = require('ethers/utils'); | ||
const SupportedApplications = types.enumify({ | ||
[types.SimpleLinkedTransferAppName]: types.SimpleLinkedTransferAppName, | ||
[types.SimpleSignedTransferAppName]: types.SimpleSignedTransferAppName, | ||
[types.SimpleTwoPartySwapAppName]: types.SimpleTwoPartySwapAppName, | ||
[types.WithdrawAppName]: types.WithdrawAppName, | ||
[types.HashLockTransferAppName]: types.HashLockTransferAppName, | ||
[types.DepositAppName]: types.DepositAppName, | ||
}); | ||
const DEFAULT_APP_TIMEOUT = utils.toBN(8640); | ||
const MINIMUM_APP_TIMEOUT = DEFAULT_APP_TIMEOUT.div(2); | ||
const { Zero } = ethers.constants; | ||
const appProposalMatchesRegistry = (proposal, appRegistryInfo) => { | ||
@@ -44,12 +35,12 @@ if (proposal.abiEncodings.actionEncoding && | ||
baseCoinTransferValidation(initiatorDeposit, responderDeposit, initiatorTransfer, responderTransfer); | ||
if (!responderDeposit.eq(constants.Zero)) { | ||
if (!responderDeposit.eq(Zero)) { | ||
throw new Error(`Will not accept transfer install where responder deposit is != 0. Responder deposit: ${responderDeposit.toString()}`); | ||
} | ||
if (initiatorDeposit.lte(constants.Zero)) { | ||
if (initiatorDeposit.lte(Zero)) { | ||
throw new Error(`Will not accept transfer install where initiator deposit is <= 0. Initiator deposit: ${initiatorDeposit.toString()}`); | ||
} | ||
if (initiatorTransfer.amount.lte(constants.Zero)) { | ||
if (initiatorTransfer.amount.lte(Zero)) { | ||
throw new Error(`Cannot install a linked transfer app with a sender transfer of <= 0. Transfer amount: ${initiatorTransfer.amount.toString()}`); | ||
} | ||
if (!responderTransfer.amount.eq(constants.Zero)) { | ||
if (!responderTransfer.amount.eq(Zero)) { | ||
throw new Error(`Cannot install a linked transfer app with a redeemer transfer of != 0. Transfer amount: ${responderTransfer.amount.toString()}`); | ||
@@ -89,2 +80,3 @@ } | ||
const { Zero: Zero$1 } = ethers.constants; | ||
const validateDepositApp = async (params, channel, provider) => { | ||
@@ -128,3 +120,3 @@ const { responderDeposit, initiatorDeposit, initiatorIdentifier, responderIdentifier } = params; | ||
} | ||
startingTotalAmountWithdrawn = constants.Zero; | ||
startingTotalAmountWithdrawn = Zero$1; | ||
} | ||
@@ -168,2 +160,3 @@ if (!initialState.startingTotalAmountWithdrawn.eq(startingTotalAmountWithdrawn)) { | ||
const { Zero: Zero$2 } = ethers.constants; | ||
const HashLockTransferAppRegistryInfo = { | ||
@@ -176,3 +169,3 @@ name: types.HashLockTransferAppName, | ||
}; | ||
const HASHLOCK_TRANSFER_STATE_TIMEOUT = constants.Zero; | ||
const HASHLOCK_TRANSFER_STATE_TIMEOUT = Zero$2; | ||
@@ -202,2 +195,3 @@ const validateHashLockTransferApp = (params, blockNumber) => { | ||
const { Zero: Zero$3 } = ethers.constants; | ||
const SimpleLinkedTransferAppRegistryInfo = { | ||
@@ -210,3 +204,3 @@ actionEncoding: types.SimpleLinkedTransferAppActionEncoding, | ||
}; | ||
const LINKED_TRANSFER_STATE_TIMEOUT = constants.Zero; | ||
const LINKED_TRANSFER_STATE_TIMEOUT = Zero$3; | ||
@@ -232,2 +226,3 @@ const validateSimpleLinkedTransferApp = (params) => { | ||
const { Zero: Zero$4 } = ethers.constants; | ||
const SimpleSignedTransferAppRegistryInfo = { | ||
@@ -240,3 +235,3 @@ allowNodeInstall: true, | ||
}; | ||
const SIGNED_TRANSFER_STATE_TIMEOUT = constants.Zero; | ||
const SIGNED_TRANSFER_STATE_TIMEOUT = Zero$4; | ||
@@ -262,2 +257,3 @@ const validateSignedTransferApp = (params) => { | ||
const { Zero: Zero$5 } = ethers.constants; | ||
const WithdrawAppRegistryInfo = { | ||
@@ -270,4 +266,5 @@ allowNodeInstall: true, | ||
}; | ||
const WITHDRAW_STATE_TIMEOUT = constants.Zero; | ||
const WITHDRAW_STATE_TIMEOUT = Zero$5; | ||
const { HashZero, Zero: Zero$6 } = ethers.constants; | ||
const validateWithdrawApp = async (params) => { | ||
@@ -284,3 +281,3 @@ const { responderDeposit, initiatorDeposit, initiatorIdentifier, responderIdentifier } = params; | ||
} | ||
if (initialState.signatures[1] !== constants.HashZero) { | ||
if (initialState.signatures[1] !== HashZero) { | ||
throw new Error(`Cannot install a withdraw app with a populated signatures[1] field. Signatures[1]: ${initialState.signatures[1]}`); | ||
@@ -292,6 +289,6 @@ } | ||
} | ||
if (!initialState.transfers[1].amount.eq(constants.Zero)) { | ||
if (!initialState.transfers[1].amount.eq(Zero$6)) { | ||
throw new Error(`Cannot install a withdraw app with nonzero recipient amount. ${initialState.transfers[1].amount.toString()}`); | ||
} | ||
let recovered = await utils.recoverAddressFromChannelMessage(initialState.data, initialState.signatures[0]); | ||
const recovered = await utils.recoverAddressFromChannelMessage(initialState.data, initialState.signatures[0]); | ||
if (recovered !== initialState.signers[0]) { | ||
@@ -303,3 +300,4 @@ throw new Error(`Cannot install withdraw app - incorrect signer recovered from initiator sig on data. | ||
const iface = new utils$1.Interface(contracts.ConditionalTransactionDelegateTarget.abi); | ||
const { Interface } = ethers.utils; | ||
const iface = new Interface(contracts.ConditionalTransactionDelegateTarget.abi); | ||
class WithdrawCommitment extends contracts.MultisigCommitment { | ||
@@ -336,2 +334,3 @@ constructor(contractAddresses, multisigAddress, multisigOwners, recipient, assetId, amount, nonce) { | ||
const { Zero: Zero$7 } = ethers.constants; | ||
const SimpleTwoPartySwapAppRegistryInfo = { | ||
@@ -343,4 +342,5 @@ allowNodeInstall: true, | ||
}; | ||
const SWAP_STATE_TIMEOUT = constants.Zero; | ||
const SWAP_STATE_TIMEOUT = Zero$7; | ||
const { bigNumberify } = ethers.utils; | ||
const ALLOWED_DISCREPANCY_PCT = 5; | ||
@@ -357,3 +357,3 @@ const validateSimpleSwapApp = (params, allowedSwaps, ourRate) => { | ||
const allowedDiscrepancy = calculated | ||
.mul(utils$1.bigNumberify(100).sub(ALLOWED_DISCREPANCY_PCT)) | ||
.mul(bigNumberify(100).sub(ALLOWED_DISCREPANCY_PCT)) | ||
.div(100); | ||
@@ -464,3 +464,4 @@ if (calculatedToActualDiscrepancy.gt(allowedDiscrepancy)) { | ||
const TRANSFER_TIMEOUT = constants.Zero; | ||
const { Zero: Zero$8 } = ethers.constants; | ||
const TRANSFER_TIMEOUT = Zero$8; | ||
@@ -480,3 +481,2 @@ exports.AppRegistry = AppRegistry; | ||
exports.SimpleTwoPartySwapAppRegistryInfo = SimpleTwoPartySwapAppRegistryInfo; | ||
exports.SupportedApplications = SupportedApplications; | ||
exports.TRANSFER_TIMEOUT = TRANSFER_TIMEOUT; | ||
@@ -483,0 +483,0 @@ exports.WITHDRAW_STATE_TIMEOUT = WITHDRAW_STATE_TIMEOUT; |
import { ProtocolParams, StateChannelJSON } from "@connext/types"; | ||
import { JsonRpcProvider } from "ethers/providers"; | ||
export declare const validateDepositApp: (params: ProtocolParams.Propose, channel: StateChannelJSON, provider: JsonRpcProvider) => Promise<void>; | ||
import { providers } from "ethers"; | ||
export declare const validateDepositApp: (params: ProtocolParams.Propose, channel: StateChannelJSON, provider: providers.JsonRpcProvider) => Promise<void>; | ||
//# sourceMappingURL=validation.d.ts.map |
import { 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 { Contract, constants } from "ethers"; | ||
import { baseCoinTransferValidation } from "../shared"; | ||
const { Zero } = constants; | ||
export const validateDepositApp = async (params, channel, provider) => { | ||
@@ -8,0 +8,0 @@ const { responderDeposit, initiatorDeposit, initiatorIdentifier, responderIdentifier } = params; |
import { OutcomeType, HashLockTransferAppActionEncoding, HashLockTransferAppStateEncoding, HashLockTransferAppName, } from "@connext/types"; | ||
import { Zero } from "ethers/constants"; | ||
import { constants } from "ethers"; | ||
const { Zero } = constants; | ||
export const HashLockTransferAppRegistryInfo = { | ||
@@ -4,0 +5,0 @@ name: HashLockTransferAppName, |
@@ -1,2 +0,3 @@ | ||
import { Zero } from "ethers/constants"; | ||
import { constants } from "ethers"; | ||
const { Zero } = constants; | ||
export const TRANSFER_TIMEOUT = Zero; | ||
@@ -3,0 +4,0 @@ export * from "./DepositApp"; |
@@ -1,15 +0,6 @@ | ||
import { DepositAppName, HashLockTransferAppName, OutcomeType, SimpleLinkedTransferAppName, SimpleSignedTransferAppName, SimpleTwoPartySwapAppName, WithdrawAppName } from "@connext/types"; | ||
export declare const SupportedApplications: { | ||
SimpleLinkedTransferApp: "SimpleLinkedTransferApp"; | ||
SimpleSignedTransferApp: "SimpleSignedTransferApp"; | ||
SimpleTwoPartySwapApp: "SimpleTwoPartySwapApp"; | ||
WithdrawApp: "WithdrawApp"; | ||
HashLockTransferApp: "HashLockTransferApp"; | ||
DepositApp: "DepositApp"; | ||
}; | ||
export declare type SupportedApplications = (typeof SupportedApplications)[keyof typeof SupportedApplications]; | ||
import { OutcomeType, SupportedApplicationNames } from "@connext/types"; | ||
export declare type AppRegistryInfo = { | ||
actionEncoding?: string; | ||
allowNodeInstall: boolean; | ||
name: SupportedApplications; | ||
name: SupportedApplicationNames; | ||
outcomeType: OutcomeType; | ||
@@ -16,0 +7,0 @@ stateEncoding: string; |
@@ -1,13 +0,4 @@ | ||
import { DepositAppName, enumify, HashLockTransferAppName, SimpleLinkedTransferAppName, SimpleSignedTransferAppName, SimpleTwoPartySwapAppName, WithdrawAppName, } from "@connext/types"; | ||
import { toBN } from "@connext/utils"; | ||
export const SupportedApplications = enumify({ | ||
[SimpleLinkedTransferAppName]: SimpleLinkedTransferAppName, | ||
[SimpleSignedTransferAppName]: SimpleSignedTransferAppName, | ||
[SimpleTwoPartySwapAppName]: SimpleTwoPartySwapAppName, | ||
[WithdrawAppName]: WithdrawAppName, | ||
[HashLockTransferAppName]: HashLockTransferAppName, | ||
[DepositAppName]: DepositAppName, | ||
}); | ||
export const DEFAULT_APP_TIMEOUT = toBN(8640); | ||
export const MINIMUM_APP_TIMEOUT = DEFAULT_APP_TIMEOUT.div(2); | ||
//# sourceMappingURL=registry.js.map |
import { CoinTransfer, ProtocolParams } from "@connext/types"; | ||
import { BigNumber } from "ethers/utils"; | ||
import { utils } from "ethers"; | ||
import { AppRegistryInfo } from "./registry"; | ||
export declare const baseCoinTransferValidation: (initiatorDeposit: BigNumber, responderDeposit: BigNumber, initiatorTransfer: CoinTransfer, responderTransfer: CoinTransfer) => void; | ||
export declare const unidirectionalCoinTransferValidation: (initiatorDeposit: BigNumber, responderDeposit: BigNumber, initiatorTransfer: CoinTransfer, responderTransfer: CoinTransfer) => void; | ||
export declare const baseCoinTransferValidation: (initiatorDeposit: utils.BigNumber, responderDeposit: utils.BigNumber, initiatorTransfer: CoinTransfer, responderTransfer: CoinTransfer) => void; | ||
export declare const unidirectionalCoinTransferValidation: (initiatorDeposit: utils.BigNumber, responderDeposit: utils.BigNumber, initiatorTransfer: CoinTransfer, responderTransfer: CoinTransfer) => void; | ||
export declare const commonAppProposalValidation: (params: ProtocolParams.Propose, appRegistryInfo: AppRegistryInfo, supportedTokenAddresses: string[]) => void; | ||
//# sourceMappingURL=validation.d.ts.map |
import { DepositAppName } from "@connext/types"; | ||
import { getAddressFromAssetId, stringify } from "@connext/utils"; | ||
import { Zero } from "ethers/constants"; | ||
import { constants } from "ethers"; | ||
import { DEFAULT_APP_TIMEOUT, MINIMUM_APP_TIMEOUT } from "./registry"; | ||
const { Zero } = constants; | ||
const appProposalMatchesRegistry = (proposal, appRegistryInfo) => { | ||
@@ -6,0 +7,0 @@ if (proposal.abiEncodings.actionEncoding && |
import { OutcomeType, SimpleLinkedTransferAppName, SimpleLinkedTransferAppActionEncoding, SimpleLinkedTransferAppStateEncoding, } from "@connext/types"; | ||
import { Zero } from "ethers/constants"; | ||
import { constants } from "ethers"; | ||
const { Zero } = constants; | ||
export const SimpleLinkedTransferAppRegistryInfo = { | ||
@@ -4,0 +5,0 @@ actionEncoding: SimpleLinkedTransferAppActionEncoding, |
import { OutcomeType, SimpleSignedTransferAppName, SimpleSignedTransferAppStateEncoding, SimpleSignedTransferAppActionEncoding, } from "@connext/types"; | ||
import { Zero } from "ethers/constants"; | ||
import { constants } from "ethers"; | ||
const { Zero } = constants; | ||
export const SimpleSignedTransferAppRegistryInfo = { | ||
@@ -4,0 +5,0 @@ allowNodeInstall: true, |
@@ -1,3 +0,4 @@ | ||
import { OutcomeType, SimpleSwapAppStateEncoding, SimpleTwoPartySwapAppName, } from "@connext/types"; | ||
import { Zero } from "ethers/constants"; | ||
import { OutcomeType, SimpleSwapAppStateEncoding, SimpleTwoPartySwapAppName } from "@connext/types"; | ||
import { constants } from "ethers"; | ||
const { Zero } = constants; | ||
export const SimpleTwoPartySwapAppRegistryInfo = { | ||
@@ -4,0 +5,0 @@ allowNodeInstall: true, |
import { calculateExchange, getAddressFromAssetId, stringify } from "@connext/utils"; | ||
import { bigNumberify } from "ethers/utils"; | ||
import { utils } from "ethers"; | ||
const { bigNumberify } = utils; | ||
const ALLOWED_DISCREPANCY_PCT = 5; | ||
@@ -4,0 +5,0 @@ export const validateSimpleSwapApp = (params, allowedSwaps, ourRate) => { |
import { OutcomeType, WithdrawAppStateEncoding, WithdrawAppActionEncoding, WithdrawAppName, } from "@connext/types"; | ||
import { Zero } from "ethers/constants"; | ||
import { constants } from "ethers"; | ||
const { Zero } = constants; | ||
export const WithdrawAppRegistryInfo = { | ||
@@ -4,0 +5,0 @@ allowNodeInstall: true, |
import { bigNumberifyJson, getSignerAddressFromPublicIdentifier, recoverAddressFromChannelMessage, } from "@connext/utils"; | ||
import { HashZero, Zero } from "ethers/constants"; | ||
import { constants } from "ethers"; | ||
import { unidirectionalCoinTransferValidation } from "../shared"; | ||
const { HashZero, Zero } = constants; | ||
export const validateWithdrawApp = async (params) => { | ||
@@ -25,3 +26,3 @@ const { responderDeposit, initiatorDeposit, initiatorIdentifier, responderIdentifier } = params; | ||
} | ||
let recovered = await recoverAddressFromChannelMessage(initialState.data, initialState.signatures[0]); | ||
const recovered = await recoverAddressFromChannelMessage(initialState.data, initialState.signatures[0]); | ||
if (recovered !== initialState.signers[0]) { | ||
@@ -28,0 +29,0 @@ throw new Error(`Cannot install withdraw app - incorrect signer recovered from initiator sig on data. |
import { MultisigCommitment } from "@connext/contracts"; | ||
import { MultisigTransaction, ContractAddresses } from "@connext/types"; | ||
import { BigNumberish } from "ethers/utils"; | ||
import { utils } from "ethers"; | ||
export declare class WithdrawCommitment extends MultisigCommitment { | ||
@@ -10,7 +10,7 @@ readonly contractAddresses: ContractAddresses; | ||
readonly assetId: string; | ||
readonly amount: BigNumberish; | ||
readonly amount: utils.BigNumberish; | ||
readonly nonce: string; | ||
constructor(contractAddresses: 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: utils.BigNumberish, nonce: string); | ||
getTransactionDetails(): MultisigTransaction; | ||
} | ||
//# sourceMappingURL=withdrawCommitment.d.ts.map |
import { MultisigCommitment, ConditionalTransactionDelegateTarget } from "@connext/contracts"; | ||
import { MultisigOperation } from "@connext/types"; | ||
import { Interface } from "ethers/utils"; | ||
import { utils } from "ethers"; | ||
const { Interface } = utils; | ||
const iface = new Interface(ConditionalTransactionDelegateTarget.abi); | ||
@@ -5,0 +6,0 @@ export class WithdrawCommitment extends MultisigCommitment { |
{ | ||
"name": "@connext/apps", | ||
"version": "6.6.5", | ||
"version": "6.7.0", | ||
"description": "Connext Counterfactual Apps", | ||
@@ -21,5 +21,5 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"@connext/contracts": "3.2.0", | ||
"@connext/utils": "6.6.5", | ||
"@connext/types": "6.6.5", | ||
"@connext/contracts": "3.2.1", | ||
"@connext/utils": "6.7.0", | ||
"@connext/types": "6.7.0", | ||
"ethers": "4.0.47", | ||
@@ -26,0 +26,0 @@ "rollup": "2.12.0", |
@@ -13,12 +13,12 @@ import { | ||
import { MinimumViableMultisig, ERC20 } from "@connext/contracts"; | ||
import { Contract } from "ethers"; | ||
import { Zero } from "ethers/constants"; | ||
import { JsonRpcProvider } from "ethers/providers"; | ||
import { Contract, providers, constants } from "ethers"; | ||
import { baseCoinTransferValidation } from "../shared"; | ||
const { Zero } = constants; | ||
export const validateDepositApp = async ( | ||
params: ProtocolParams.Propose, | ||
channel: StateChannelJSON, | ||
provider: JsonRpcProvider, | ||
provider: providers.JsonRpcProvider, | ||
) => { | ||
@@ -25,0 +25,0 @@ const { responderDeposit, initiatorDeposit, initiatorIdentifier, responderIdentifier } = params; |
@@ -7,6 +7,8 @@ import { | ||
} from "@connext/types"; | ||
import { Zero } from "ethers/constants"; | ||
import { constants } from "ethers"; | ||
import { AppRegistryInfo } from "../shared"; | ||
const { Zero } = constants; | ||
export const HashLockTransferAppRegistryInfo: AppRegistryInfo = { | ||
@@ -13,0 +15,0 @@ name: HashLockTransferAppName, |
@@ -1,3 +0,5 @@ | ||
import { Zero } from "ethers/constants"; | ||
import { constants } from "ethers"; | ||
const { Zero } = constants; | ||
export const TRANSFER_TIMEOUT = Zero; | ||
@@ -4,0 +6,0 @@ |
@@ -1,29 +0,8 @@ | ||
import { | ||
DepositAppName, | ||
enumify, | ||
HashLockTransferAppName, | ||
OutcomeType, | ||
SimpleLinkedTransferAppName, | ||
SimpleSignedTransferAppName, | ||
SimpleTwoPartySwapAppName, | ||
WithdrawAppName, | ||
} from "@connext/types"; | ||
import { OutcomeType, SupportedApplicationNames } from "@connext/types"; | ||
import { toBN } from "@connext/utils"; | ||
export const SupportedApplications = enumify({ | ||
[SimpleLinkedTransferAppName]: SimpleLinkedTransferAppName, | ||
[SimpleSignedTransferAppName]: SimpleSignedTransferAppName, | ||
[SimpleTwoPartySwapAppName]: SimpleTwoPartySwapAppName, | ||
[WithdrawAppName]: WithdrawAppName, | ||
[HashLockTransferAppName]: HashLockTransferAppName, | ||
[DepositAppName]: DepositAppName, | ||
}); | ||
export type SupportedApplications = | ||
(typeof SupportedApplications)[keyof typeof SupportedApplications]; | ||
export type AppRegistryInfo = { | ||
actionEncoding?: string; | ||
allowNodeInstall: boolean; | ||
name: SupportedApplications; | ||
name: SupportedApplicationNames; | ||
outcomeType: OutcomeType; | ||
@@ -37,2 +16,2 @@ stateEncoding: string; | ||
export const DEFAULT_APP_TIMEOUT = toBN(8640); // 6 blocks per min (ethereum) * 60 mins * 24h | ||
export const MINIMUM_APP_TIMEOUT = DEFAULT_APP_TIMEOUT.div(2) | ||
export const MINIMUM_APP_TIMEOUT = DEFAULT_APP_TIMEOUT.div(2); |
import { CoinTransfer, DepositAppName, ProtocolParams } from "@connext/types"; | ||
import { getAddressFromAssetId, stringify } from "@connext/utils"; | ||
import { Zero } from "ethers/constants"; | ||
import { BigNumber } from "ethers/utils"; | ||
import { constants, utils } from "ethers"; | ||
import { AppRegistryInfo, DEFAULT_APP_TIMEOUT, MINIMUM_APP_TIMEOUT } from "./registry"; | ||
const { Zero } = constants; | ||
const appProposalMatchesRegistry = ( | ||
@@ -41,4 +42,4 @@ proposal: ProtocolParams.Propose, | ||
export const baseCoinTransferValidation = ( | ||
initiatorDeposit: BigNumber, | ||
responderDeposit: BigNumber, | ||
initiatorDeposit: utils.BigNumber, | ||
responderDeposit: utils.BigNumber, | ||
initiatorTransfer: CoinTransfer, | ||
@@ -72,4 +73,4 @@ responderTransfer: CoinTransfer, | ||
export const unidirectionalCoinTransferValidation = ( | ||
initiatorDeposit: BigNumber, | ||
responderDeposit: BigNumber, | ||
initiatorDeposit: utils.BigNumber, | ||
responderDeposit: utils.BigNumber, | ||
initiatorTransfer: CoinTransfer, | ||
@@ -145,4 +146,4 @@ responderTransfer: CoinTransfer, | ||
throw new Error( | ||
`Cannot install an app with default timeout: ${params.defaultTimeout}, less than minimum timeout: ${MINIMUM_APP_TIMEOUT})` | ||
) | ||
`Cannot install an app with default timeout: ${params.defaultTimeout}, less than minimum timeout: ${MINIMUM_APP_TIMEOUT})`, | ||
); | ||
} | ||
@@ -152,4 +153,4 @@ | ||
throw new Error( | ||
`Cannot install an app with default timeout: ${params.defaultTimeout}, greater than max timeout: ${DEFAULT_APP_TIMEOUT}` | ||
) | ||
`Cannot install an app with default timeout: ${params.defaultTimeout}, greater than max timeout: ${DEFAULT_APP_TIMEOUT}`, | ||
); | ||
} | ||
@@ -156,0 +157,0 @@ |
@@ -7,6 +7,8 @@ import { | ||
} from "@connext/types"; | ||
import { Zero } from "ethers/constants"; | ||
import { constants } from "ethers"; | ||
import { AppRegistryInfo } from "../shared"; | ||
const { Zero } = constants; | ||
export const SimpleLinkedTransferAppRegistryInfo: AppRegistryInfo = { | ||
@@ -13,0 +15,0 @@ actionEncoding: SimpleLinkedTransferAppActionEncoding, |
@@ -7,6 +7,8 @@ import { | ||
} from "@connext/types"; | ||
import { Zero } from "ethers/constants"; | ||
import { constants } from "ethers"; | ||
import { AppRegistryInfo } from "../shared"; | ||
const { Zero } = constants; | ||
export const SimpleSignedTransferAppRegistryInfo: AppRegistryInfo = { | ||
@@ -13,0 +15,0 @@ allowNodeInstall: true, |
@@ -1,10 +0,8 @@ | ||
import { | ||
OutcomeType, | ||
SimpleSwapAppStateEncoding, | ||
SimpleTwoPartySwapAppName, | ||
} from "@connext/types"; | ||
import { Zero } from "ethers/constants"; | ||
import { OutcomeType, SimpleSwapAppStateEncoding, SimpleTwoPartySwapAppName } from "@connext/types"; | ||
import { constants } from "ethers"; | ||
import { AppRegistryInfo } from "../shared"; | ||
const { Zero } = constants; | ||
export const SimpleTwoPartySwapAppRegistryInfo: AppRegistryInfo = { | ||
@@ -11,0 +9,0 @@ allowNodeInstall: true, |
import { AllowedSwap, SwapRate, ProtocolParams } from "@connext/types"; | ||
import { calculateExchange, getAddressFromAssetId, stringify } from "@connext/utils"; | ||
import { bigNumberify } from "ethers/utils"; | ||
import { utils } from "ethers"; | ||
const { bigNumberify } = utils; | ||
const ALLOWED_DISCREPANCY_PCT = 5; | ||
@@ -6,0 +8,0 @@ |
@@ -7,6 +7,8 @@ import { | ||
} from "@connext/types"; | ||
import { Zero } from "ethers/constants"; | ||
import { constants } from "ethers"; | ||
import { AppRegistryInfo } from "../shared"; | ||
const { Zero } = constants; | ||
export const WithdrawAppRegistryInfo: AppRegistryInfo = { | ||
@@ -13,0 +15,0 @@ allowNodeInstall: true, |
@@ -7,6 +7,8 @@ import { WithdrawAppState, ProtocolParams } from "@connext/types"; | ||
} from "@connext/utils"; | ||
import { HashZero, Zero } from "ethers/constants"; | ||
import { constants } from "ethers"; | ||
import { unidirectionalCoinTransferValidation } from "../shared"; | ||
const { HashZero, Zero } = constants; | ||
export const validateWithdrawApp = async (params: ProtocolParams.Propose) => { | ||
@@ -54,3 +56,3 @@ const { responderDeposit, initiatorDeposit, initiatorIdentifier, responderIdentifier } = params; | ||
let recovered = await recoverAddressFromChannelMessage( | ||
const recovered = await recoverAddressFromChannelMessage( | ||
initialState.data, | ||
@@ -57,0 +59,0 @@ initialState.signatures[0], |
import { MultisigCommitment, ConditionalTransactionDelegateTarget } from "@connext/contracts"; | ||
import { MultisigTransaction, MultisigOperation, ContractAddresses } from "@connext/types"; | ||
import { BigNumberish, Interface } from "ethers/utils"; | ||
import { utils } from "ethers"; | ||
const { Interface } = utils; | ||
const iface = new Interface(ConditionalTransactionDelegateTarget.abi); | ||
@@ -13,3 +15,3 @@ export class WithdrawCommitment extends MultisigCommitment { | ||
public readonly assetId: string, | ||
public readonly amount: BigNumberish, | ||
public readonly amount: utils.BigNumberish, | ||
public readonly nonce: string, | ||
@@ -16,0 +18,0 @@ ) { |
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
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
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
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
649643
2792