@polkadot/types#BTreeSet TypeScript Examples
The following examples show how to use
@polkadot/types#BTreeSet.
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: extrinsics.ts From atlas with GNU General Public License v3.0 | 6 votes |
async createChannel(
memberId: MemberId,
inputMetadata: ChannelInputMetadata,
inputAssets: ChannelInputAssets,
cb?: ExtrinsicStatusCallbackFn
): Promise<ChannelExtrinsicResult> {
await this.ensureApi()
const [channelMetadata, channelAssets] = await parseChannelExtrinsicInput(this.api, inputMetadata, inputAssets)
const creationParameters = new ChannelCreationParameters(this.api.registry, {
meta: channelMetadata,
assets: channelAssets,
collaborators: new BTreeSet(this.api.registry, RuntimeMemberId, [memberId]),
moderators: new BTreeSet(this.api.registry, RuntimeMemberId, [memberId]),
reward_account: new Option<RuntimeAccountId>(this.api.registry, RuntimeAccountId, inputMetadata.ownerAccount),
})
const contentActor = new ContentActor(this.api.registry, {
member: memberId,
})
const tx = this.api.tx.content.createChannel(contentActor, creationParameters)
const { block, getEventData } = await this.sendExtrinsic(tx, cb)
const channelId = getEventData('content', 'ChannelCreated')[1]
return {
channelId: channelId.toString(),
block,
assetsIds: extractChannelResultAssetsIds(inputAssets, getEventData),
}
}
Example #2
Source File: extrinsics.ts From atlas with GNU General Public License v3.0 | 6 votes |
async updateChannel(
channelId: ChannelId,
memberId: MemberId,
inputMetadata: ChannelInputMetadata,
inputAssets: ChannelInputAssets,
cb?: ExtrinsicStatusCallbackFn
): Promise<ChannelExtrinsicResult> {
await this.ensureApi()
const [channelMetadata, channelAssets] = await parseChannelExtrinsicInput(this.api, inputMetadata, inputAssets)
const updateParameters = new ChannelUpdateParameters(this.api.registry, {
new_meta: channelMetadata,
assets_to_upload: channelAssets,
assets_to_remove: new BTreeSet(this.api.registry, DataObjectId, getInputDataObjectsIds(inputAssets)),
collaborators: new Option<BTreeSet<RuntimeMemberId>>(this.api.registry, BTreeSet),
reward_account: new Option<Option<RuntimeAccountId>>(this.api.registry, Option),
})
const contentActor = new ContentActor(this.api.registry, {
member: memberId,
})
const tx = this.api.tx.content.updateChannel(contentActor, channelId, updateParameters)
const { block, getEventData } = await this.sendExtrinsic(tx, cb)
return {
channelId,
block,
assetsIds: extractChannelResultAssetsIds(inputAssets, getEventData),
}
}
Example #3
Source File: extrinsics.ts From atlas with GNU General Public License v3.0 | 6 votes |
async updateVideo(
videoId: VideoId,
memberId: MemberId,
inputMetadata: VideoInputMetadata,
nftInputMetadata: NftIssuanceInputMetadata | undefined,
inputAssets: VideoInputAssets,
cb?: ExtrinsicStatusCallbackFn
): Promise<VideoExtrinsicResult> {
await this.ensureApi()
const [videoMetadata, videoAssets] = await parseVideoExtrinsicInput(this.api, inputMetadata, inputAssets)
const nftIssuanceParameters = createNftIssuanceParameters(this.api.registry, nftInputMetadata)
const updateParameters = new VideoUpdateParameters(this.api.registry, {
new_meta: videoMetadata,
assets_to_upload: videoAssets,
assets_to_remove: new BTreeSet(this.api.registry, DataObjectId, getInputDataObjectsIds(inputAssets)),
enable_comments: new Option(this.api.registry, bool),
auto_issue_nft: new Option(this.api.registry, NftIssuanceParameters, nftIssuanceParameters),
})
const contentActor = new ContentActor(this.api.registry, {
member: memberId,
})
const tx = this.api.tx.content.updateVideo(contentActor, videoId, updateParameters)
const { block, getEventData } = await this.sendExtrinsic(tx, cb)
return {
videoId,
block,
assetsIds: extractVideoResultAssetsIds(inputAssets, getEventData),
}
}
Example #4
Source File: extrinsics.ts From atlas with GNU General Public License v3.0 | 6 votes |
async deleteVideo(
videoId: VideoId,
memberId: MemberId,
cb?: ExtrinsicStatusCallbackFn
): Promise<Omit<VideoExtrinsicResult, 'assetsIds'>> {
await this.ensureApi()
const contentActor = new ContentActor(this.api.registry, {
member: memberId,
})
const tx = this.api.tx.content.deleteVideo(contentActor, videoId, new BTreeSet(this.api.registry, DataObjectId))
const { block } = await this.sendExtrinsic(tx, cb)
return {
videoId,
block,
}
}
Example #5
Source File: tohex.ts From community-repo with GNU General Public License v3.0 | 6 votes |
async function main() {
const provider = new WsProvider('ws://127.0.0.1:9944');
const api = await ApiPromise.create({ provider, types })
let wgId = [1, 2]
let set = new BTreeSet<CuratorApplicationId>(api.registry, CuratorApplicationId, []);
wgId.forEach((id) => {
set.add(new CuratorApplicationId(api.registry, id))
})
/*
Replace the integers inside the bracket in:
let wgId:number[] = [1, 2];
With the "WG ID"s of the curators you wish to hire, in ascending order.
To hire "WG ID" 18 21 and 16:
let wgId:number[] = [16, 18, 21];
*/
console.log('copy/paste the output below to hire curator applicant(s) with WG IDs:', wgId )
console.log(set.toHex())
api.disconnect()
}
Example #6
Source File: helpers.ts From atlas with GNU General Public License v3.0 | 5 votes |
createCommonAuctionParams = (registry: Registry, inputMetadata: NftAuctionInputMetadata) => {
return {
starting_price: new Balance(registry, inputMetadata.startingPrice),
buy_now_price: new Option(registry, Balance, inputMetadata.buyNowPrice),
starts_at: new Option(registry, BlockNumber, inputMetadata.startsAtBlock),
whitelist: new BTreeSet(registry, RuntimeMemberId, inputMetadata.whitelistedMembersIds || []),
}
}