@connext/cf-core
Advanced tools
Comparing version 1.4.2 to 1.4.3
@@ -28,6 +28,6 @@ "use strict"; | ||
async executeMethodImplementation(requestHandler, params) { | ||
const { store, protocolRunner } = requestHandler; | ||
const appInstanceProposal = await operation_1.install(store, protocolRunner, params); | ||
const { store, protocolRunner, publicIdentifier } = requestHandler; | ||
const appInstanceProposal = await operation_1.install(store, protocolRunner, params, publicIdentifier); | ||
return { | ||
appInstance: (await store.getAppInstance(appInstanceProposal.identityHash)).toJson(), | ||
appInstance: (await store.getAppInstance(appInstanceProposal.identityHash)).toJson() | ||
}; | ||
@@ -34,0 +34,0 @@ } |
import { ProtocolRunner } from "../../../machine"; | ||
import { Store } from "../../../store"; | ||
import { AppInstanceProposal, CFCoreTypes } from "../../../types"; | ||
export declare function install(store: Store, protocolRunner: ProtocolRunner, params: CFCoreTypes.InstallParams): Promise<AppInstanceProposal>; | ||
export declare function install(store: Store, protocolRunner: ProtocolRunner, params: CFCoreTypes.InstallParams, initiatorXpub: string): Promise<AppInstanceProposal>; | ||
//# sourceMappingURL=operation.d.ts.map |
@@ -6,3 +6,3 @@ "use strict"; | ||
const errors_1 = require("../../errors"); | ||
async function install(store, protocolRunner, params) { | ||
async function install(store, protocolRunner, params, initiatorXpub) { | ||
const { appInstanceId } = params; | ||
@@ -17,4 +17,6 @@ if (!appInstanceId || !appInstanceId.trim()) { | ||
]), { | ||
initiatorXpub: proposal.proposedToIdentifier, | ||
responderXpub: proposal.proposedByIdentifier, | ||
initiatorXpub, | ||
responderXpub: initiatorXpub === proposal.proposedToIdentifier | ||
? proposal.proposedByIdentifier | ||
: proposal.proposedToIdentifier, | ||
initiatorBalanceDecrement: utils_1.bigNumberify(proposal.initiatorDeposit), | ||
@@ -21,0 +23,0 @@ responderBalanceDecrement: utils_1.bigNumberify(proposal.responderDeposit), |
@@ -71,2 +71,4 @@ "use strict"; | ||
} | ||
const signerAddress = await signer.getAddress(); | ||
const nonce = await provider.getTransactionCount(signerAddress); | ||
let error; | ||
@@ -79,3 +81,4 @@ for (let tryCount = 1; tryCount < retryCount + 1; tryCount += 1) { | ||
gasLimit: CREATE_PROXY_AND_SETUP_GAS, | ||
gasPrice: provider.getGasPrice() | ||
gasPrice: provider.getGasPrice(), | ||
nonce | ||
}); | ||
@@ -82,0 +85,0 @@ if (!tx.hash) { |
@@ -45,8 +45,3 @@ "use strict"; | ||
const signer = await requestHandler.getSigner(); | ||
const tx = { | ||
to: multisigAddress, | ||
value: utils_1.bigNumberify(amount), | ||
gasLimit: 30000, | ||
gasPrice: await provider.getGasPrice() | ||
}; | ||
const signerAddress = await signer.getAddress(); | ||
let txResponse; | ||
@@ -58,2 +53,9 @@ let retryCount = DEPOSIT_RETRY_COUNT; | ||
if (tokenAddress === constants_2.CONVENTION_FOR_ETH_TOKEN_ADDRESS) { | ||
const tx = { | ||
to: multisigAddress, | ||
value: utils_1.bigNumberify(amount), | ||
gasLimit: 30000, | ||
gasPrice: await provider.getGasPrice(), | ||
nonce: provider.getTransactionCount(signerAddress, "pending"), | ||
}; | ||
txResponse = await signer.sendTransaction(tx); | ||
@@ -63,3 +65,5 @@ } | ||
const erc20Contract = new ethers_1.Contract(tokenAddress, contracts_1.ERC20.abi, signer); | ||
txResponse = await erc20Contract.functions.transfer(multisigAddress, utils_1.bigNumberify(amount)); | ||
txResponse = await erc20Contract.functions.transfer(multisigAddress, utils_1.bigNumberify(amount), { | ||
nonce: provider.getTransactionCount(signerAddress, "pending"), | ||
}); | ||
} | ||
@@ -66,0 +70,0 @@ break; |
@@ -55,2 +55,5 @@ "use strict"; | ||
const { multisigAddress, recipient } = params; | ||
const signer = await requestHandler.getSigner(); | ||
const signerAddress = await signer.getAddress(); | ||
const nonce = await provider.getTransactionCount(signerAddress); | ||
params.recipient = recipient || machine_1.xkeyKthAddress(publicIdentifier, 0); | ||
@@ -65,3 +68,3 @@ await operation_1.runWithdrawProtocol(requestHandler, params); | ||
} | ||
const tx = Object.assign({}, commitment, { gasPrice: await provider.getGasPrice(), gasLimit: 300000 }); | ||
const tx = Object.assign({}, commitment, { gasPrice: await provider.getGasPrice(), gasLimit: 300000, nonce }); | ||
let txResponse; | ||
@@ -68,0 +71,0 @@ try { |
@@ -21,14 +21,16 @@ "use strict"; | ||
let protocolRunner; | ||
let initiatorIdentifier; | ||
beforeAll(() => { | ||
store = new store_1.Store(new memory_store_service_1.MemoryStoreService(), "install.spec.ts-test-store"); | ||
protocolRunner = new machine_1.ProtocolRunner(NETWORK_CONTEXT_OF_ALL_ZERO_ADDRESSES, {}); | ||
initiatorIdentifier = utils_1.HDNode.fromMnemonic(ethers_1.Wallet.createRandom().mnemonic).neuter().extendedKey; | ||
}); | ||
it("fails to install with undefined appInstanceId", async () => { | ||
await expect(operation_1.install(store, protocolRunner, { appInstanceId: undefined })).rejects.toThrowError(src_1.NO_APP_INSTANCE_ID_TO_INSTALL); | ||
await expect(operation_1.install(store, protocolRunner, { appInstanceId: undefined }, initiatorIdentifier)).rejects.toThrowError(src_1.NO_APP_INSTANCE_ID_TO_INSTALL); | ||
}); | ||
it("fails to install with empty string appInstanceId", async () => { | ||
await expect(operation_1.install(store, protocolRunner, { appInstanceId: "" })).rejects.toThrowError(src_1.NO_APP_INSTANCE_ID_TO_INSTALL); | ||
await expect(operation_1.install(store, protocolRunner, { appInstanceId: "" }, initiatorIdentifier)).rejects.toThrowError(src_1.NO_APP_INSTANCE_ID_TO_INSTALL); | ||
}); | ||
it("fails to install without the AppInstance being proposed first", async () => { | ||
await expect(operation_1.install(store, protocolRunner, { appInstanceId: constants_1.HashZero })).rejects.toThrowError(src_1.NO_MULTISIG_FOR_APP_INSTANCE_ID); | ||
await expect(operation_1.install(store, protocolRunner, { appInstanceId: constants_1.HashZero }, initiatorIdentifier)).rejects.toThrowError(src_1.NO_MULTISIG_FOR_APP_INSTANCE_ID); | ||
}); | ||
@@ -42,3 +44,3 @@ it("fails to install without the AppInstanceId being in a channel", async () => { | ||
ts_mockito_1.when(mockedStore.getChannelFromAppInstanceID(appInstanceId)).thenThrow(Error(src_1.NO_MULTISIG_FOR_APP_INSTANCE_ID)); | ||
await expect(operation_1.install(ts_mockito_1.instance(mockedStore), protocolRunner, { appInstanceId })).rejects.toThrowError(src_1.NO_MULTISIG_FOR_APP_INSTANCE_ID); | ||
await expect(operation_1.install(ts_mockito_1.instance(mockedStore), protocolRunner, { appInstanceId }, initiatorIdentifier)).rejects.toThrowError(src_1.NO_MULTISIG_FOR_APP_INSTANCE_ID); | ||
}); | ||
@@ -68,5 +70,5 @@ it("succeeds to install a proposed AppInstance", async () => { | ||
appInstanceId | ||
})).resolves.toEqual(appInstanceProposal); | ||
}, extendedKeys[0])).resolves.toEqual(appInstanceProposal); | ||
}); | ||
}); | ||
//# sourceMappingURL=install.spec.js.map |
{ | ||
"name": "@connext/cf-core", | ||
"version": "1.4.2", | ||
"version": "1.4.3", | ||
"main": "dist/src/index.js", | ||
@@ -22,3 +22,3 @@ "iife": "dist/src/index.iife.js", | ||
"@connext/cf-funding-protocol-contracts": "0.4.1", | ||
"@connext/types": "1.4.2", | ||
"@connext/types": "1.4.3", | ||
"ethers": "4.0.41", | ||
@@ -25,0 +25,0 @@ "eventemitter3": "4.0.0", |
import { jsonRpcMethod } from "rpc-server"; | ||
import { StateChannel } from "../../../models"; | ||
import { RequestHandler } from "../../../request-handler"; | ||
@@ -21,3 +20,3 @@ import { CFCoreTypes } from "../../../types"; | ||
requestHandler: RequestHandler, | ||
params: CFCoreTypes.InstallParams, | ||
params: CFCoreTypes.InstallParams | ||
): Promise<string[]> { | ||
@@ -34,12 +33,19 @@ const { store } = requestHandler; | ||
requestHandler: RequestHandler, | ||
params: CFCoreTypes.InstallParams, | ||
params: CFCoreTypes.InstallParams | ||
): Promise<CFCoreTypes.InstallResult> { | ||
const { store, protocolRunner } = requestHandler; | ||
const { store, protocolRunner, publicIdentifier } = requestHandler; | ||
const appInstanceProposal = await install(store, protocolRunner, params); | ||
const appInstanceProposal = await install( | ||
store, | ||
protocolRunner, | ||
params, | ||
publicIdentifier | ||
); | ||
return { | ||
appInstance: (await store.getAppInstance(appInstanceProposal.identityHash)).toJson(), | ||
appInstance: ( | ||
await store.getAppInstance(appInstanceProposal.identityHash) | ||
).toJson() | ||
}; | ||
} | ||
} |
@@ -12,3 +12,4 @@ import { bigNumberify } from "ethers/utils"; | ||
protocolRunner: ProtocolRunner, | ||
params: CFCoreTypes.InstallParams | ||
params: CFCoreTypes.InstallParams, | ||
initiatorXpub: string | ||
): Promise<AppInstanceProposal> { | ||
@@ -34,4 +35,7 @@ const { appInstanceId } = params; | ||
{ | ||
initiatorXpub: proposal.proposedToIdentifier, | ||
responderXpub: proposal.proposedByIdentifier, | ||
initiatorXpub, | ||
responderXpub: | ||
initiatorXpub === proposal.proposedToIdentifier | ||
? proposal.proposedByIdentifier | ||
: proposal.proposedToIdentifier, | ||
initiatorBalanceDecrement: bigNumberify(proposal.initiatorDeposit), | ||
@@ -38,0 +42,0 @@ responderBalanceDecrement: bigNumberify(proposal.responderDeposit), |
@@ -127,2 +127,5 @@ import { Contract, Signer } from "ethers"; | ||
const signerAddress = await signer.getAddress(); | ||
const nonce = await provider.getTransactionCount(signerAddress); | ||
let error; | ||
@@ -139,3 +142,4 @@ for (let tryCount = 1; tryCount < retryCount + 1; tryCount += 1) { | ||
gasLimit: CREATE_PROXY_AND_SETUP_GAS, | ||
gasPrice: provider.getGasPrice() | ||
gasPrice: provider.getGasPrice(), | ||
nonce | ||
} | ||
@@ -142,0 +146,0 @@ ); |
@@ -115,10 +115,4 @@ import { Contract } from "ethers"; | ||
const signer = await requestHandler.getSigner(); | ||
const signerAddress = await signer.getAddress(); | ||
const tx: TransactionRequest = { | ||
to: multisigAddress, | ||
value: bigNumberify(amount), | ||
gasLimit: 30000, | ||
gasPrice: await provider.getGasPrice() | ||
}; | ||
let txResponse: TransactionResponse; | ||
@@ -131,2 +125,10 @@ | ||
if (tokenAddress === CONVENTION_FOR_ETH_TOKEN_ADDRESS) { | ||
const tx: TransactionRequest = { | ||
to: multisigAddress, | ||
value: bigNumberify(amount), | ||
gasLimit: 30000, | ||
gasPrice: await provider.getGasPrice(), | ||
nonce: provider.getTransactionCount(signerAddress, "pending"), | ||
}; | ||
txResponse = await signer.sendTransaction(tx); | ||
@@ -137,3 +139,6 @@ } else { | ||
multisigAddress, | ||
bigNumberify(amount) | ||
bigNumberify(amount), | ||
{ | ||
nonce: provider.getTransactionCount(signerAddress, "pending"), | ||
} | ||
); | ||
@@ -140,0 +145,0 @@ } |
@@ -103,2 +103,6 @@ import { JsonRpcProvider, TransactionResponse } from "ethers/providers"; | ||
const signer = await requestHandler.getSigner(); | ||
const signerAddress = await signer.getAddress(); | ||
const nonce = await provider.getTransactionCount(signerAddress); | ||
params.recipient = recipient || xkeyKthAddress(publicIdentifier, 0); | ||
@@ -121,3 +125,4 @@ | ||
gasPrice: await provider.getGasPrice(), | ||
gasLimit: 300000 | ||
gasLimit: 300000, | ||
nonce | ||
}; | ||
@@ -124,0 +129,0 @@ |
@@ -8,3 +8,7 @@ import { MaxUint256 } from "ethers/constants"; | ||
import { Opcode, Protocol } from "../machine/enums"; | ||
import { Context, InstallProtocolParams, ProtocolMessage } from "../machine/types"; | ||
import { | ||
Context, | ||
InstallProtocolParams, | ||
ProtocolMessage | ||
} from "../machine/types"; | ||
import { TWO_PARTY_OUTCOME_DIFFERENT_ASSETS } from "../methods/errors"; | ||
@@ -11,0 +15,0 @@ import { AppInstance, StateChannel } from "../models"; |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1629631
23623
+ Added@connext/types@1.4.3(transitive)
- Removed@connext/types@1.4.2(transitive)
Updated@connext/types@1.4.3