@polkadot/types#GenericAccountId TypeScript Examples

The following examples show how to use @polkadot/types#GenericAccountId. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.ts    From subsocial-js with GNU General Public License v3.0 6 votes vote down vote up
// ---------------------------------------------------------------------
  // Is boolean

  async isAccountFollower (myAddress: AnyAccountId, followedAddress: AnyAccountId): Promise<boolean> {
    const followedAccountId = asAccountId(followedAddress)
    const myAccountId = asAccountId(myAddress)
    const queryParams = new Tuple(registry, [ GenericAccountId, GenericAccountId ], [ myAccountId, followedAccountId ]);
    const isFollow = await this.queryPallet({ pallet: 'profileFollows', storage: 'accountFollowedByAccount' }, queryParams) as bool
    return isFollow.valueOf()
  }
Example #2
Source File: common.ts    From subsocial-js with GNU General Public License v3.0 6 votes vote down vote up
export function asAccountId (id: AnyAccountId): GenericAccountId | undefined {
  try {
    if (id instanceof GenericAccountId) {
      return id
    } else if (nonEmptyStr(id)) {
      return new GenericAccountId(registry, id)
    }
    return undefined
  } catch {
    return undefined
  }
}
Example #3
Source File: index.ts    From subsocial-js with GNU General Public License v3.0 5 votes vote down vote up
// TODO maybe pallet: 'posts' | 'spaces
  private async isBooleanByAccount (params: StorageItem, accountId: AnyAccountId, subjectId: SubstrateId): Promise<boolean> {
    const { storage, pallet } = params
    const queryParams = new Tuple(registry, [ GenericAccountId, 'u64' ], [ asAccountId(accountId), subjectId ]);
    const isBoolean = await this.queryPallet({ pallet, storage }, queryParams) as bool
    return isBoolean.valueOf()
  }
Example #4
Source File: index.ts    From subsocial-js with GNU General Public License v3.0 5 votes vote down vote up
private async getReactionIdsByAccount (accountId: AnyAccountId, structIds: AnyPostId[]): Promise<ReactionId[]> {
    const queryParams = structIds.map(id => new Tuple(registry, [ GenericAccountId, 'u64' ], [ asAccountId(accountId), id ]));
    return this.queryPalletMulti({ pallet: 'reactions', storage: 'postReactionIdByAccount' }, queryParams)
  }