-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(wallet-lib)!: storage layer refactoring (#232)
Co-authored-by: Igor Markin <[email protected]>
- Loading branch information
1 parent
3096f68
commit e440424
Showing
198 changed files
with
2,948 additions
and
5,153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1,087 changes: 1,087 additions & 0 deletions
1,087
packages/wallet-lib/fixtures/chains/for_wallet_c922713eac.json
Large diffs are not rendered by default.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
packages/wallet-lib/fixtures/chains/testnet/blockheaders.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[ | ||
{ | ||
"height": 600000, | ||
"blockheader": "00000020a69faca490012f4371e4bd40a40167809e6fe1b03c9c5dcb7df247f2fa000000b4b8c2d4a78fb35e50a4eda0bd3a5b9b32f4d739b28a4266f24775b3b79d5b61c73275610e04021ea74d0000", | ||
"hash":"000000de786e659950e0f27681faf1a91871d15de264d0b769cb5941c1d807c3" | ||
}, | ||
{ | ||
"height": 610000, | ||
"blockheader": "00000020af5155e1f8d5b60fb247ac9bb8badbdce1fa72302336c7daab53585caf0000006d495b9629989ac3699d528956b1f617fb51a199ef4277c3f45f4606aba8e461d1c78a61210b011e94ef0000", | ||
"hash":"00000094d124cfb68d6d59ffaec9f7d63965cb894855684e23a586274b49708f" | ||
} | ||
] |
14 changes: 14 additions & 0 deletions
14
packages/wallet-lib/fixtures/chains/testnet/transactions.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[ | ||
{ | ||
"blockHash": "000000b2537d9b3468e02dc6f49fb8bbb5c9d8b77895df1e76816fbad5555d7d", | ||
"transaction": "02000000019583d226737edfad682cc1f0297f688bfca4c0046062ed3e88fa47dd47eab2b2010000006a473044022021550232cc659fa412deb2ea98956faf9ff0efea3a04029bb63022f6809105ce0220230a3f955a3ee7563f5b006342d8db940f3b29f4e312701bf51720575c7a7a8a012103f3d2b2ddfe6ffad2b8fc1708f2eafadfed36bf31a05dfa04b1fc176526475b0ffeffffff02a003d806000000001976a91464220a1c12690ec26d837b3be0a2e3588bb4b79188ac4c5bc92b250000001976a9143e89746b9aa52703ab784bc0df467b160406ffb988acb56b0900", | ||
"height": 617398, | ||
"isInstantLocked": true, | ||
"isChainLocked": true | ||
}, | ||
{ | ||
"transaction": "0200000001c7d66bb85e0069c221b44b07f49f52cc4f2e54f70e14430b94888327763a66a9010000006b483045022100da5b319f73e6adfee751f33308f5a8c1fceeab2683e15e132d79053b3118639602204262022fb85f88d9802649a289a1134b678efcf708faaeae8f101e8eab785054012102bc626898b49f31f5194de7bc68004401639a20cfa82e4c2eac9684a91fc47a57feffffff0270f2f605000000001976a91464220a1c12690ec26d837b3be0a2e3588bb4b79188ac912e250c250000001976a91415e1edb5c5d9e67d0e36f94343b3eff26bb76d1088ac266e0900", | ||
"blockHash":"0000005c81a683007e86e75c76b4b2feca229f806702ca92953562f2ae628ce7", | ||
"height": 618023 | ||
} | ||
] |
32 changes: 32 additions & 0 deletions
32
packages/wallet-lib/fixtures/wallets/2a331817b9d6bf85100ef0/getFixtureAccountWithStorage.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const walletStoreMock = require('./wallet-store.json'); | ||
const chainStoreMock = require('./chain-store.json'); | ||
const Storage = require('../../../src/types/Storage/Storage'); | ||
const { KeyChainStore, DerivableKeyChain } = require('../../../src/index'); | ||
|
||
module.exports = (opts = {}) => { | ||
const { walletId } = walletStoreMock; | ||
|
||
const mockedAccount = { | ||
walletId, | ||
index: 0, | ||
storage: new Storage(), | ||
accountPath: 'm/0', | ||
network: 'testnet', | ||
walletType: 'privateKey', | ||
...opts, | ||
}; | ||
|
||
mockedAccount.keyChainStore = new KeyChainStore(); | ||
mockedAccount.keyChainStore.addKeyChain(new DerivableKeyChain({ | ||
privateKey: '2a331817b9d6bf85100ef05503d16f9f57c8855dbf13766b2f26c382b716d396', | ||
lookAheadOpts: { | ||
'm/0': 1, | ||
}, | ||
}), { isMasterKeyChain: true }); | ||
mockedAccount.storage.createWalletStore(walletId); | ||
mockedAccount.storage.createChainStore('testnet'); | ||
mockedAccount.storage.getWalletStore(walletId).importState(walletStoreMock); | ||
mockedAccount.storage.getChainStore('testnet').importState(chainStoreMock); | ||
|
||
return mockedAccount; | ||
}; |
15 changes: 15 additions & 0 deletions
15
packages/wallet-lib/fixtures/wallets/2a331817b9d6bf85100ef0/wallet-store.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"walletId": "6101b44d50", | ||
"state": { | ||
"mnemonic": null, | ||
"paths": { | ||
"m/0": { | ||
"path": "m/0", | ||
"addresses": { | ||
"0": "ycDeuTfs4U77bTb5cq17dame28zdWHVYfk" | ||
} | ||
} | ||
}, | ||
"identities": {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
packages/wallet-lib/fixtures/wallets/apart-trip-dignity/getFixtureAccountWithStorage.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const walletStoreMock = require('./wallet-store.json'); | ||
const chainStoreMock = require('./chain-store.json'); | ||
const Storage = require('../../../src/types/Storage/Storage'); | ||
const { KeyChainStore, DerivableKeyChain } = require('../../../src/index'); | ||
|
||
module.exports = (opts = {}) => { | ||
const { walletId } = walletStoreMock; | ||
|
||
const mockedAccount = { | ||
walletId, | ||
index: 0, | ||
storage: new Storage(), | ||
accountPath: "m/44'/1'/0'", | ||
network: 'testnet', | ||
walletType: 'hdwallet', | ||
...opts, | ||
}; | ||
|
||
mockedAccount.keyChainStore = new KeyChainStore(); | ||
mockedAccount.keyChainStore.addKeyChain(new DerivableKeyChain({ | ||
mnemonic: 'apart trip dignity try point rocket damp reflect raw ten normal young', | ||
lookAheadOpts: { | ||
'm/0': 40, | ||
'm/1': 40, | ||
}, | ||
}), { isMasterKeyChain: true }); | ||
mockedAccount.storage.createWalletStore(walletId); | ||
mockedAccount.storage.createChainStore('testnet'); | ||
mockedAccount.storage.getWalletStore(walletId).importState(walletStoreMock); | ||
mockedAccount.storage.getChainStore('testnet').importState(chainStoreMock); | ||
|
||
return mockedAccount; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.