Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core-api): include business asset in wallet transformer #3205

Merged
merged 3 commits into from Nov 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions packages/core-api/src/handlers/wallets/transformer.ts
@@ -1,10 +1,25 @@
import { app } from "@arkecosystem/core-container";
import { State } from "@arkecosystem/core-interfaces";
import { Interfaces, Utils } from "@arkecosystem/crypto";

export const transformWallet = (wallet: State.IWallet) => {
const username: string = wallet.getAttribute("delegate.username");
const multiSignature: Interfaces.IMultiSignatureAsset = wallet.getAttribute("multiSignature");

// TODO: cleanup V3
let business: any;
if (app.has("core-magistrate-transactions")) {
business = wallet.getAttribute("business");

if (business) {
business = {
...business.businessAsset,
businessId: business.businessId,
resigned: business.resigned,
};
}
}

return {
address: wallet.address,
publicKey: wallet.publicKey,
Expand All @@ -19,5 +34,6 @@ export const transformWallet = (wallet: State.IWallet) => {
isResigned: !!wallet.getAttribute("delegate.resigned"),
vote: wallet.getAttribute("vote"),
multiSignature,
business,
};
};
Expand Up @@ -229,6 +229,7 @@ export class WalletsBusinessRepository implements Database.IWalletsBusinessRepos
.map(wallet => {
const business: any = wallet.getAttribute("business");
return {
address: wallet.address,
businessId: business.businessId,
...business.businessAsset,
};
Expand Down