From d23122c958be16efeb6f7004a239503049bcfab9 Mon Sep 17 00:00:00 2001 From: dudleyneedham Date: Thu, 28 May 2020 13:25:02 +0200 Subject: [PATCH] refactor: change the qrcode to be uniform when encoding --- src/utils/PublicIdentity/Encoding.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/utils/PublicIdentity/Encoding.ts b/src/utils/PublicIdentity/Encoding.ts index b45e2ad1..febffd21 100644 --- a/src/utils/PublicIdentity/Encoding.ts +++ b/src/utils/PublicIdentity/Encoding.ts @@ -1,25 +1,23 @@ import { IPublicIdentity, IDelegationNode } from '@kiltprotocol/sdk-js' -const encodePublicIdentity = (publicIdentity: IPublicIdentity): string[] => [ - publicIdentity.address, - publicIdentity.boxPublicKeyAsHex, - ...(publicIdentity.serviceAddress ? [publicIdentity.serviceAddress] : []), -] - export type IAttesterWithDelegation = { publicIdentity: IPublicIdentity delegationId: IDelegationNode['id'] } +const encodePublicIdentity = (publicIdentity: IPublicIdentity): string[] => [ + publicIdentity.address, + publicIdentity.boxPublicKeyAsHex, + publicIdentity.serviceAddress || '', +] + const encodePublicIdentityWithDelegation = ( publicIdentityWithDelegation: IAttesterWithDelegation ): string[] => [ - publicIdentityWithDelegation.delegationId, publicIdentityWithDelegation.publicIdentity.address, publicIdentityWithDelegation.publicIdentity.boxPublicKeyAsHex, - ...(publicIdentityWithDelegation.publicIdentity.serviceAddress - ? [publicIdentityWithDelegation.publicIdentity.serviceAddress] - : []), + publicIdentityWithDelegation.publicIdentity.serviceAddress || '', + publicIdentityWithDelegation.delegationId, ] export { encodePublicIdentity, encodePublicIdentityWithDelegation }