0.0.4 • Published 2 years ago

@jmgayosso/hashed-polkadot-api v0.0.4

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Hashed Polkadot API

This client api is used to interact with gatedMarketplace pallet, this allow do quickly connection, queries and calls to TX to this pallet.

To install the hashed polkadot api api run the following command:

npm i --save @jmgayosso/hashed-polkadot-api or yarn add --save @jmgayosso/hashed-polkadot-api

To connect to hashed chain we can use an instanfe of PolkadotApi that handles the conection and provide methods to sign tx, requestUsers from polkadotJS and sign and verify messages.

import { PolkadotApi } from '@jmgayosso/hashed-polkadot-api'

const polkadotApi = new PolkadotApi('wss://n1.hashed.systems')
await polkadotApi.connect()

PolkadotApi is requeried to create an instace of MarketplaceApi, this class provide all methods to interact with gatedMarketplace pallet.

import { PolkadotApi, MarketplaceApi } from '@jmgayosso/hashed-polkadot-api'

const polkadotApi = new PolkadotApi('wss://n1.hashed.systems')
await polkadotApi.connect()

const marketplaceApi = new MarketplaceApi(polkadotApi)

Once created an instance of MarketplaceApi the followings methods can be accessed.

MarketplaceApi

await marketplaceApi.getMarketplaceById({
  marketId: '0xa54035afb49b42cdacbe27c830dd1b66078069886e80cdd8bab3d139caa0489e'
})
await marketplaceApi.getAuthoritiesByMarketplace({
  marketId: '0xa54035afb49b42cdacbe27c830dd1b66078069886e80cdd8bab3d139caa0489e'
})
await marketplaceApi.getAllMarketplaces({
  startKey,
  pageSize
})
await marketplaceApi.getMyMarketplaces({
   accountId
})
await marketplaceApi.getParticipantsByMarket({
  marketId: '0xa54035afb49b42cdacbe27c830dd1b66078069886e80cdd8bab3d139caa0489e'
})
  • applyFor: This function call apply extrinsic
await marketplaceApi.applyFor({
  marketId,
  user,
  fields,
  custodianFields
})
await marketplaceApi.reapplyFor({
    marketId,
    user,
    fields,
    custodianFields
})
await marketplaceApi.createMarketplace({
  admin,
  user,
  label
})
await marketplaceApi.enrollApplicant({
  marketId,
  user,
  accountOrApplication,
  approved,
  feedback
})
await marketplaceApi.getApplicationStatusByAccount({
  marketId,
  account
})
await marketplaceApi.getMarketplacesByAuthority({
  accountId,
  marketplaceId
})