Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

@connext/cf-core

Package Overview
Dependencies
193
Maintainers
4
Versions
198
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.0.0-alpha.1 to 7.0.0-alpha.2

2

dist/methods/controller.js

@@ -45,3 +45,3 @@ "use strict";

catch (e) {
log.error(`Caught error in node controller: ${e.stack}`);
log.error(`Caught error in method controller: ${e.stack}`);
error = e;

@@ -48,0 +48,0 @@ }

@@ -160,3 +160,4 @@ "use strict";

async computeStateTransition(action, provider) {
const computedNextState = this.decodeAppState(await this.toEthersContract(provider).applyAction(this.encodedLatestState, this.encodeAction(action)));
const encoded = await this.toEthersContract(provider).applyAction(this.encodedLatestState, this.encodeAction(action));
const computedNextState = this.decodeAppState(encoded);
const keyify = (templateObj, dataObj, key) => {

@@ -186,3 +187,4 @@ const template = key ? templateObj[key] : templateObj;

};
return utils_1.bigNumberifyJson(keyify(this.state, computedNextState));
const keyified = keyify(this.state, computedNextState);
return utils_1.bigNumberifyJson(keyified);
}

@@ -189,0 +191,0 @@ encodeAction(action) {

@@ -57,9 +57,12 @@ "use strict";

log.info(`Action provided. Finalizing app before uninstall`);
substart = Date.now();
const newState = yield __await(appToUninstall.computeStateTransition(action, network.provider));
const isFinal = yield __await(appToUninstall.isStateTerminal(newState, network.provider));
if (!isFinal) {
utils_1.logTime(log, substart, `[${processID}] computeStateTransition for action complete`);
if (!newState.finalized) {
throw new Error(`Action provided did not lead to terminal state, refusing to uninstall.`);
}
log.debug(`Resulting state is terminal state, proceeding with uninstall`);
substart = Date.now();
preUninstallStateChannel = preProtocolStateChannel.setState(appToUninstall, newState, stateTimeout);
utils_1.logTime(log, substart, `[${processID}] setState for action complete`);
}

@@ -70,3 +73,6 @@ else {

const preUninstallApp = preUninstallStateChannel.appInstances.get(appToUninstall.identityHash);
substart = Date.now();
const postProtocolStateChannel = yield __await(computeStateTransition(params, network.provider, preUninstallStateChannel, preUninstallApp, log));
utils_1.logTime(log, substart, `[${processID}] computeStateTransition for uninstall complete`);
substart = Date.now();
const responderFreeBalanceKey = utils_1.getSignerAddressFromPublicIdentifier(responderIdentifier);

@@ -135,9 +141,12 @@ const uninstallCommitment = ethereum_1.getSetStateCommitment(context, postProtocolStateChannel.freeBalance);

log.info(`Action provided. Finalizing app before uninstall`);
substart = Date.now();
const newState = yield __await(appToUninstall.computeStateTransition(action, network.provider));
const isFinal = yield __await(appToUninstall.isStateTerminal(newState, network.provider));
if (!isFinal) {
utils_1.logTime(log, substart, `[${processID}] computeStateTransition for action complete`);
if (!newState.finalized) {
throw new Error(`Action provided did not lead to terminal state, refusing to uninstall.`);
}
log.debug(`Resulting state is terminal state, proceeding with uninstall`);
substart = Date.now();
preUninstallStateChannel = preProtocolStateChannel.setState(appToUninstall, newState, stateTimeout);
utils_1.logTime(log, substart, `[${processID}] setState for action complete`);
}

@@ -148,3 +157,6 @@ else {

const preUninstallApp = preUninstallStateChannel.appInstances.get(appToUninstall.identityHash);
substart = Date.now();
const postProtocolStateChannel = yield __await(computeStateTransition(params, network.provider, preUninstallStateChannel, preUninstallApp, log));
utils_1.logTime(log, substart, `[${processID}] computeStateTransition for uninstall complete`);
substart = Date.now();
const initiatorFreeBalanceKey = utils_1.getSignerAddressFromPublicIdentifier(initiatorIdentifier);

@@ -151,0 +163,0 @@ const uninstallCommitment = ethereum_1.getSetStateCommitment(context, postProtocolStateChannel.freeBalance);

@@ -53,3 +53,3 @@ "use strict";

});
it("should take action + uninstall linked app", async (done) => {
it("should take action + uninstall SimpleLinkedTransferApp app", async (done) => {
[appIdentityHash] = await utils_1.installApp(nodeA, nodeB, multisigAddress, SimpleLinkedTransferApp, initialState, depositAmount, types_1.CONVENTION_FOR_ETH_ASSET_ID, Zero, types_1.CONVENTION_FOR_ETH_ASSET_ID);

@@ -94,4 +94,4 @@ const appPreUninstall = models_1.AppInstance.fromJson(await utils_1.getAppInstance(nodeA, appIdentityHash));

done();
});
}, 30000);
});
//# sourceMappingURL=uninstall-with-action.spec.js.map
{
"name": "@connext/cf-core",
"version": "7.0.0-alpha.1",
"version": "7.0.0-alpha.2",
"main": "dist/index.js",

@@ -22,4 +22,4 @@ "iife": "dist/index.iife.js",

"@connext/contracts": "3.2.3",
"@connext/utils": "7.0.0-alpha.1",
"@connext/types": "7.0.0-alpha.1",
"@connext/utils": "7.0.0-alpha.2",
"@connext/types": "7.0.0-alpha.2",
"async-mutex": "0.2.2",

@@ -37,3 +37,3 @@ "ethers": "5.0.0-beta.190",

"@babel/plugin-proposal-object-rest-spread": "7.10.1",
"@connext/store": "7.0.0-alpha.0",
"@connext/store": "7.0.0-alpha.1",
"@types/chai": "4.2.11",

@@ -40,0 +40,0 @@ "@types/dotenv-safe": "8.1.0",

@@ -66,3 +66,3 @@ import { MethodName, MethodParam, MethodResult } from "@connext/types";

} catch (e) {
log.error(`Caught error in node controller: ${e.stack}`);
log.error(`Caught error in method controller: ${e.stack}`);
error = e;

@@ -69,0 +69,0 @@ }

@@ -35,3 +35,2 @@ import {

const { defaultAbiCoder, keccak256 } = utils;
/**

@@ -291,12 +290,11 @@ * Representation of an AppInstance.

): Promise<SolidityValueType> {
const computedNextState = this.decodeAppState(
await this.toEthersContract(provider).applyAction(
this.encodedLatestState,
this.encodeAction(action),
),
const encoded = await this.toEthersContract(provider).applyAction(
this.encodedLatestState,
this.encodeAction(action),
);
const computedNextState = this.decodeAppState(encoded);
// ethers returns an array of [ <each value by index>, <each value by key> ]
// so we need to recursively clean this response before returning
const keyify = (templateObj: any, dataObj: any, key?: string): any => {
const keyify = (templateObj: any, dataObj: any, key?: string): Promise<any> => {
const template = key ? templateObj[key] : templateObj;

@@ -323,3 +321,4 @@ const data = key ? dataObj[key] : dataObj;

return bigNumberifyJson(keyify(this.state, computedNextState)) as any;
const keyified = keyify(this.state, computedNextState);
return bigNumberifyJson(keyified);
}

@@ -326,0 +325,0 @@

@@ -69,9 +69,11 @@ import {

// apply action
substart = Date.now();
const newState = await appToUninstall.computeStateTransition(action, network.provider);
logTime(log, substart, `[${processID}] computeStateTransition for action complete`);
// ensure state is finalized after applying action
const isFinal = await appToUninstall.isStateTerminal(newState, network.provider);
if (!isFinal) {
if (!(newState as any).finalized) {
throw new Error(`Action provided did not lead to terminal state, refusing to uninstall.`);
}
log.debug(`Resulting state is terminal state, proceeding with uninstall`);
substart = Date.now();
preUninstallStateChannel = preProtocolStateChannel.setState(

@@ -82,2 +84,3 @@ appToUninstall,

);
logTime(log, substart, `[${processID}] setState for action complete`);
} else {

@@ -89,3 +92,3 @@ preUninstallStateChannel = preProtocolStateChannel;

// 47ms
substart = Date.now();
const postProtocolStateChannel = await computeStateTransition(

@@ -98,4 +101,5 @@ params as ProtocolParams.Uninstall,

);
logTime(log, substart, `[${processID}] computeStateTransition for uninstall complete`);
// 0ms
substart = Date.now();
const responderFreeBalanceKey = getSignerAddressFromPublicIdentifier(responderIdentifier);

@@ -203,9 +207,11 @@

// apply action
substart = Date.now();
const newState = await appToUninstall.computeStateTransition(action, network.provider);
logTime(log, substart, `[${processID}] computeStateTransition for action complete`);
// ensure state is finalized after applying action
const isFinal = await appToUninstall.isStateTerminal(newState, network.provider);
if (!isFinal) {
if (!(newState as any).finalized) {
throw new Error(`Action provided did not lead to terminal state, refusing to uninstall.`);
}
log.debug(`Resulting state is terminal state, proceeding with uninstall`);
substart = Date.now();
preUninstallStateChannel = preProtocolStateChannel.setState(

@@ -216,2 +222,3 @@ appToUninstall,

);
logTime(log, substart, `[${processID}] setState for action complete`);
} else {

@@ -223,3 +230,3 @@ preUninstallStateChannel = preProtocolStateChannel;

// 40ms
substart = Date.now();
const postProtocolStateChannel = await computeStateTransition(

@@ -232,4 +239,5 @@ params as ProtocolParams.Uninstall,

);
logTime(log, substart, `[${processID}] computeStateTransition for uninstall complete`);
// 0ms
substart = Date.now();
const initiatorFreeBalanceKey = getSignerAddressFromPublicIdentifier(initiatorIdentifier);

@@ -236,0 +244,0 @@

@@ -92,3 +92,3 @@ import {

it("should take action + uninstall linked app", async (done) => {
it("should take action + uninstall SimpleLinkedTransferApp app", async (done) => {
[appIdentityHash] = await installApp(

@@ -155,3 +155,3 @@ nodeA,

done();
});
}, 30_000);
});

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

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc