Skip to content

Commit

Permalink
Merge pull request #56 from GridPlus/dl/0123
Browse files Browse the repository at this point in the history
  • Loading branch information
netbonus authored Sep 26, 2022
2 parents 58f8f01 + 166ae5a commit ce7e628
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 561 deletions.
81 changes: 0 additions & 81 deletions cache.js

This file was deleted.

27 changes: 3 additions & 24 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ const SDK = require('gridplus-sdk');
const EthTx = require('@ethereumjs/tx');
const { addHexPrefix } = require("@ethereumjs/util");
const rlp = require('rlp');
const {
serializeCache,
deserializeCache,
getCachedDef,
saveDefToCache,
} = require("./cache");
const keyringType = 'Lattice Hardware';
const HARDENED_OFFSET = 0x80000000;
const PER_PAGE = 5;
Expand All @@ -22,7 +16,6 @@ const CONNECT_TIMEOUT = 20000;
class LatticeKeyring extends EventEmitter {
constructor (opts={}) {
super()
this.requestCache = new Map();
this.type = keyringType;
this._resetDefaults();
this.deserialize(opts);
Expand Down Expand Up @@ -52,8 +45,6 @@ class LatticeKeyring extends EventEmitter {
this.network = opts.network;
if (opts.page)
this.page = opts.page;
if (opts.requestCache)
this.requestCache = deserializeCache(opts.requestCache)
return;
}

Expand All @@ -73,7 +64,6 @@ class LatticeKeyring extends EventEmitter {
network: this.network,
page: this.page,
hdPath: this.hdPath,
requestCache: serializeCache(this.requestCache),
};
}

Expand Down Expand Up @@ -187,18 +177,9 @@ class LatticeKeyring extends EventEmitter {
encodingType: SDK.Constants.SIGNING.ENCODINGS.EVM,
signerPath,
};
let def;
const cachedDef = getCachedDef(tx, this.requestCache)

if (cachedDef) {
def = cachedDef
} else {
const supportsDecoderRecursion = fwVersion.major > 0 || fwVersion.minor >=16;
// Check if we can decode the calldata
const { def: fetchedDef } = await SDK.Utils.fetchCalldataDecoder(tx.data, tx.to, chainId, supportsDecoderRecursion);
saveDefToCache(tx, this.requestCache, fetchedDef);
def = fetchedDef
}
const supportsDecoderRecursion = fwVersion.major > 0 || fwVersion.minor >=16;
// Check if we can decode the calldata
const { def } = await SDK.Utils.fetchCalldataDecoder(tx.data, tx.to, chainId, supportsDecoderRecursion);
if (def) {
data.decoder = def;
}
Expand Down Expand Up @@ -448,7 +429,6 @@ class LatticeKeyring extends EventEmitter {
this.unlockedAccount = 0;
this.network = null;
this.hdPath = STANDARD_HD_PATH;
this.requestCache = new Map()
}

async _openConnectorTab(url) {
Expand Down Expand Up @@ -731,7 +711,6 @@ class LatticeKeyring extends EventEmitter {
}
return activeWallet.uid.toString('hex');
}

}

// -----
Expand Down
Loading

0 comments on commit ce7e628

Please sign in to comment.