-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use ioc for wallet repository indexes
Instead of registering magistrate wallet repository indexes in boot method they are registered through dependency injection and injected through multiInject. Default indexes are nothing special now, and are also registered through dependency injection.
- Loading branch information
Showing
9 changed files
with
194 additions
and
321 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { Contracts } from "@arkecosystem/core-kernel"; | ||
|
||
export const addressesIndexer = (index: Contracts.State.WalletIndex, wallet: Contracts.State.Wallet) => { | ||
if (wallet.address) { | ||
index.set(wallet.address, wallet); | ||
} | ||
}; | ||
|
||
export const publicKeysIndexer = (index: Contracts.State.WalletIndex, wallet: Contracts.State.Wallet) => { | ||
if (wallet.publicKey) { | ||
index.set(wallet.publicKey, wallet); | ||
} | ||
}; | ||
|
||
export const usernamesIndexer = (index: Contracts.State.WalletIndex, wallet: Contracts.State.Wallet) => { | ||
if (wallet.isDelegate()) { | ||
index.set(wallet.getAttribute("delegate.username"), wallet); | ||
} | ||
}; | ||
|
||
export const resignationsIndexer = (index: Contracts.State.WalletIndex, wallet: Contracts.State.Wallet) => { | ||
if (wallet.isDelegate() && wallet.hasAttribute("delegate.resigned")) { | ||
index.set(wallet.getAttribute("delegate.username"), wallet); | ||
} | ||
}; | ||
|
||
export const locksIndexer = (index: Contracts.State.WalletIndex, wallet: Contracts.State.Wallet) => { | ||
if (wallet.hasAttribute("htlc.locks")) { | ||
const locks: object = wallet.getAttribute("htlc.locks"); | ||
|
||
for (const lockId of Object.keys(locks)) { | ||
index.set(lockId, wallet); | ||
} | ||
} | ||
}; | ||
|
||
export const ipfsIndexer = (index: Contracts.State.WalletIndex, wallet: Contracts.State.Wallet) => { | ||
if (wallet.hasAttribute("ipfs.hashes")) { | ||
const hashes: object = wallet.getAttribute("ipfs.hashes"); | ||
|
||
for (const hash of Object.keys(hashes)) { | ||
index.set(hash, wallet); | ||
} | ||
} | ||
}; |
Oops, something went wrong.