@polkadot/types#bool TypeScript Examples
The following examples show how to use
@polkadot/types#bool.
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 createVideo(
memberId: MemberId,
channelId: ChannelId,
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 creationParameters = new VideoCreationParameters(this.api.registry, {
meta: videoMetadata,
assets: videoAssets,
enable_comments: new bool(this.api.registry, false),
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.createVideo(contentActor, channelId, creationParameters)
const { block, getEventData } = await this.sendExtrinsic(tx, cb)
const videoId = getEventData('content', 'VideoCreated')[2]
return {
videoId: videoId.toString(),
block,
assetsIds: extractVideoResultAssetsIds(inputAssets, getEventData),
}
}
Example #2
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 #3
Source File: index.ts From subsocial-js with GNU General Public License v3.0 | 6 votes |
// ---------------------------------------------------------------------
// 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 #4
Source File: utils.ts From subsocial-js with GNU General Public License v3.0 | 6 votes |
export class OptionBool<T extends boolean> extends Option<bool> {
constructor (value?: T) {
const boolOrNull = typeof value === 'boolean' ? value : new Null(registry)
super(registry, 'bool', boolOrNull)
}
}
Example #5
Source File: index.ts From subsocial-js with GNU General Public License v3.0 | 5 votes |
// 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 #6
Source File: oracle.ts From interbtc-api with Apache License 2.0 | 5 votes |
async getRawValuesUpdated(key: InterbtcPrimitivesOracleKey): Promise<boolean> {
const isSet = await this.api.query.oracle.rawValuesUpdated<Option<Bool>>(key);
return isSet.unwrap().isTrue;
}