Skip to content

Commit

Permalink
updated restoring and recovering vault
Browse files Browse the repository at this point in the history
  • Loading branch information
SDargarh committed May 7, 2024
1 parent e68b954 commit aee6d96
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/lib/keyring.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,11 @@ class Keyring {
const numberOfAcc = this.decryptedVault[chainData.chain.toLowerCase()].numberOfAccounts;

for (let i = 0; i < numberOfAcc; i++) {
await this[chainData.chain].addAccount();
if(chainData.chain.toLowerCase() === 'stacks' && i === 0) {
await this[chainData.chain].generateWallet()
} else {
await this[chainData.chain].addAccount();
}
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/test/keyring.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let impAccAddress

let chains
const ethUrl = 'https://mainnet.infura.io/v3/6145d532688844c4b6db32574d90e19f';
const polygonRpcUrl = 'https://rpc-mumbai.maticvigil.com';
const polygonRpcUrl = 'https://polygon-testnet.public.blastapi.io';
const bscRpcUrl = 'https://rpc.ankr.com/bsc';
beforeAll(async() => {

Expand Down
15 changes: 13 additions & 2 deletions src/lib/vault.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,20 @@ class Vault extends Keyring {
let obj = {}
for ( let chain of nonEvmChainList) {
const keyringInstance = await helper.getCoinInstance(chain.toLowerCase(), mnemonic);

let {address} = await keyringInstance.addAccount();
let address
if(chain === 'stacks') {
address = (await keyringInstance.generateWallet()).address;
} else {
address = (await keyringInstance.addAccount()).address;
}

const accArray = await helper.getAccountsFromLogs(chain, keyringInstance, vaultState, logs, address);

if(chain === 'stacks') {
for( let ele of accArray) {
ele.address = ele.address.toUpperCase();
}
}
const numberOfAcc = accArray.length;

rawVault[chain.toLowerCase()] = { public: accArray, numberOfAccounts: numberOfAcc }
Expand Down

1 comment on commit aee6d96

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage Report (73%)
File% Stmts% Branch% Funcs% LinesUncovered Line #s
All files73.165.0683.7873.88 
chains100100100100 
   index.js100100100100 
config100100100100 
   index.js100100100100 
constants100100100100 
   index.js100100100100 
constants/responses100100100100 
   index.js100100100100 
lib70.8465.2481.6671.5 
   keyring.js66.6662.6679.5967.345, 58, 67–68, 139–151, 171, 179–188, 198–201, 246–278, 289, 293, 298–300, 312–387, 403–441, 504–507, 650, 677–722, 795, 812–813, 829–831, 862–870, 893–897, 917–921, 940–948, 975, 981
   vault.js92.5585.4190.992.5521, 28, 43–46, 66, 76
utils80.5363.6392.8581.81 
   helper.js80.5363.6392.8581.819–16, 51–52, 77, 91, 103–105, 114–115, 131–133, 154, 166, 178

Please sign in to comment.