Skip to content

Commit

Permalink
Merge pull request #138 from urbit/keyfile-fix
Browse files Browse the repository at this point in the history
Ensure we generate the keyfile for latest-set keys
  • Loading branch information
Fang- committed May 17, 2019
2 parents 9128082 + bacec7e commit 883c00b
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 42 deletions.
53 changes: 17 additions & 36 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@ledgerhq/hw-app-eth": "^4.35.0",
"@ledgerhq/hw-transport-u2f": "^4.35.0",
"PaperCollateralRenderer": "github:urbit/PaperCollateralRenderer",
"azimuth-js": "^0.10.0",
"azimuth-js": "^0.13.2",
"azimuth-solidity": "1.0.2",
"babel-polyfill": "^6.26.0",
"bip32": "^1.0.2",
Expand Down
7 changes: 5 additions & 2 deletions src/bridge/Bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,10 @@ class Bridge extends React.Component {
}
}

setNetworkSeedCache(networkSeed) {
setNetworkSeedCache(networkSeed, revision) {
this.setState({
networkSeedCache: networkSeed
networkSeedCache: networkSeed,
networkRevisionCache: revision
})
}

Expand Down Expand Up @@ -263,6 +264,7 @@ class Bridge extends React.Component {
urbitWallet,
authMnemonic,
networkSeedCache,
networkRevisionCache,
pointCursor,
pointCache,
txnHashCursor,
Expand Down Expand Up @@ -316,6 +318,7 @@ class Bridge extends React.Component {
pointCursor={ pointCursor }
pointCache={ pointCache }
networkSeedCache= { networkSeedCache }
networkRevisionCache={ networkRevisionCache }
setNetworkSeedCache= { this.setNetworkSeedCache }
// txn
setTxnHashCursor={ this.setTxnHashCursor }
Expand Down
5 changes: 3 additions & 2 deletions src/bridge/components/StatelessTransaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ class StatelessTransaction extends React.Component {
props.setTxnHashCursor(sent)
props.popRoute()

if (props.networkSeed) {
props.setNetworkSeedCache(props.networkSeed)
//TODO this special logic should live in a handler in SetKeys.
if (props.networkSeed && props.newRevision) {
props.setNetworkSeedCache(props.networkSeed, props.newRevision)
props.pushRoute(ROUTE_NAMES.SENT_TRANSACTION, {promptKeyfile: true})
} else {
props.pushRoute(ROUTE_NAMES.SENT_TRANSACTION)
Expand Down
5 changes: 4 additions & 1 deletion src/bridge/views/GenKeyfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ class GenKeyfile extends React.Component {
? pointCache[point]
: (() => { throw BRIDGE_ERROR.MISSING_POINT })()

const revision = parseInt(pointDetails.keyRevisionNumber)
// in case we did SetKeys earlier this session, make sure to generate the
// newer keyfile, rather than the one that will expire soon
const revision = (this.props.networkRevisionCache ||
parseInt(pointDetails.keyRevisionNumber));

return {
point,
Expand Down
1 change: 1 addition & 0 deletions src/bridge/views/SetKeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ class SetKeys extends React.Component {
canGenerate={ canGenerate }
createUnsignedTxn={this.createUnsignedTxn}
networkSeed={ state.networkSeed }
newRevision={ (parseInt(pointDetails.keyRevisionNumber) + 1) }
setNetworkSeedCache={ props.setNetworkSeedCache } />

</Col>
Expand Down

0 comments on commit 883c00b

Please sign in to comment.