Skip to content
This repository has been archived by the owner on Nov 24, 2022. It is now read-only.

Commit

Permalink
Merge pull request #265 from KILTprotocol/demo-qrcode-uniform-encoding
Browse files Browse the repository at this point in the history
refactor: change the qrcode to be uniform when encoding
  • Loading branch information
Dudleyneedham authored May 28, 2020
2 parents 7c4485f + d23122c commit 5627a7b
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/utils/PublicIdentity/Encoding.ts
Original file line number Diff line number Diff line change
@@ -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 }

0 comments on commit 5627a7b

Please sign in to comment.