Skip to content

Conversation

@ben-kaufman
Copy link
Contributor

Fix #228
I was unable to do this redundancy check for the custom schemes since I have no pre-knowledge n a "non-null" parameters which they must have. That should be fine for now but suggestions to overcome that are welcomed.

@dOrgJelli
Copy link
Contributor

dOrgJelli commented Nov 17, 2019

@ben-kaufman if you have the desired scheme parameters accessible to you in the script, for example:

const params = {
  someFlag: true,
  someNumber: 5,
  someString: "foo"
}

then you could get the has from the contract:

const hash = customScheme.getParamHash(params);

and then view the params to see if you get a missmatch:

const storageParams = customScheme.getParams(hash);
for (let param of Object.keys(params)) {
  if (storageParams[param] !== params[param]) {
    customScheme.setParams(params);
    break;
  }
}

@dOrgJelli
Copy link
Contributor

I think this should work, made some assumptions about there being a common scheme interface that has getParamHash and getParams available.

@ben-kaufman ben-kaufman merged commit e3e3cad into master Nov 18, 2019
@ben-kaufman ben-kaufman deleted the check-params-exist branch November 18, 2019 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Don't Set VM + Scheme Params If They're Already Set

4 participants