Skip to content

Commit

Permalink
fix: update identity class
Browse files Browse the repository at this point in the history
  • Loading branch information
shuffledex committed Feb 17, 2020
1 parent 3c32d2d commit fbfcf23
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/api/entities/Identity.ts
Expand Up @@ -3,6 +3,8 @@ import { Entity } from './Entity';
import { serialize, unserialize } from '~/utils';
import { Context } from '~/Context';
import { Balance } from '@polymathnetwork/polkadot/types/interfaces';
import { ErrorCode } from '~/types';
import { PolymeshError } from '~/base/PolymeshError';

/**
* Properties that uniquely identify an Identity
Expand Down Expand Up @@ -48,7 +50,10 @@ export class Identity extends Entity {
const unserialized = unserialize(serialized);

if (!isUniqueIdentifiers(unserialized)) {
// throw error
throw new PolymeshError({
code: ErrorCode.InvalidUuid,
message: 'The string is not related to an Identity Unique Identifier',
});
}

return unserialized;
Expand Down Expand Up @@ -88,7 +93,7 @@ export class Identity extends Entity {
*/
public getPolyBalance = async (): Promise<Balance> => {
const { context, did } = this;
// TODO return a human readable value
// TODO MSDK-48 - Create an human readable value conversion
return context.polymeshApi.query.balances.identityBalance(did);
};
}
1 change: 1 addition & 0 deletions src/types/index.ts
Expand Up @@ -38,4 +38,5 @@ export enum ErrorCode {
TransactionRejectedByUser = 'TransactionRejectedByUser',
TransactionReverted = 'TransactionReverted',
FatalError = 'FatalError',
InvalidUuid = 'InvalidUuid',
}

0 comments on commit fbfcf23

Please sign in to comment.