mirror of
https://github.com/pezkuwichain/pezkuwi-api.git
synced 2026-10-26 13:19:50 +00:00
Rebrand: polkadot → pezkuwi, substrate → bizinikiwi, kusama → dicle
This commit is contained in:
commit
d5f038faea
1383 files changed
+1088018
No files matched your search
@@ -0,0 +1,39 @@
|
||||
// Copyright 2017-2025 @pezkuwi/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiPromise } from '@pezkuwi/api';
|
||||
import type { Bounty, BountyIndex } from '@pezkuwi/types/interfaces';
|
||||
import type { Codec, CodecClass, InterfaceTypes, Registry } from '@pezkuwi/types/types';
|
||||
|
||||
import { Option, StorageKey } from '@pezkuwi/types';
|
||||
|
||||
export class BountyFactory {
|
||||
readonly #api: ApiPromise;
|
||||
readonly #registry: Registry;
|
||||
|
||||
constructor (api: ApiPromise) {
|
||||
this.#api = api;
|
||||
this.#registry = this.#api.registry;
|
||||
}
|
||||
|
||||
public storageKey = (index: number): StorageKey => {
|
||||
const key = new StorageKey(this.#registry, this.#api.query.bounties.bounties.key(this.bountyIndex(index)));
|
||||
|
||||
return key.setMeta(this.#api.query.bounties.bounties.creator.meta);
|
||||
};
|
||||
|
||||
public bountyIndex = (index: number): BountyIndex =>
|
||||
this.#registry.createType('BountyIndex', index);
|
||||
|
||||
public defaultBounty = (): Bounty =>
|
||||
this.#registry.createType('Bounty');
|
||||
|
||||
public optionOf = <T extends Codec>(value: T): Option<T> => {
|
||||
const typeName = this.#registry.getClassName(value.constructor as CodecClass<T>);
|
||||
|
||||
return new Option<T>(this.#registry, typeName as keyof InterfaceTypes, value);
|
||||
};
|
||||
|
||||
public emptyOption = <T extends Codec>(typeName: keyof InterfaceTypes): Option<T> =>
|
||||
new Option<T>(this.#registry, typeName);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright 2017-2025 @pezkuwi/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Bytes } from '@pezkuwi/types';
|
||||
import type { Registry } from '@pezkuwi/types/types';
|
||||
|
||||
export class BytesFactory {
|
||||
#registry: Registry;
|
||||
|
||||
constructor (registry: Registry) {
|
||||
this.#registry = registry;
|
||||
}
|
||||
|
||||
public bytes = (value: string): Bytes => this.#registry.createType('Bytes', value);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// Copyright 2017-2025 @pezkuwi/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiPromise, WsProvider } from '@pezkuwi/api';
|
||||
import { Metadata, TypeRegistry } from '@pezkuwi/types';
|
||||
import metaStatic from '@pezkuwi/types-support/metadata/static-bizinikiwi';
|
||||
|
||||
export function createApiWithAugmentations (): ApiPromise {
|
||||
const registry = new TypeRegistry();
|
||||
const metadata = new Metadata(registry, metaStatic);
|
||||
|
||||
registry.setMetadata(metadata);
|
||||
|
||||
const api = new ApiPromise({
|
||||
provider: new WsProvider('ws://', false),
|
||||
registry
|
||||
});
|
||||
|
||||
// eslint-disable-next-line deprecation/deprecation
|
||||
api.injectMetadata(metadata, true, registry);
|
||||
|
||||
return api;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright 2017-2025 @pezkuwi/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiPromise } from '@pezkuwi/api';
|
||||
import type { SubmittableExtrinsic } from '@pezkuwi/api-base/types';
|
||||
import type { Proposal, ProposalIndex } from '@pezkuwi/types/interfaces';
|
||||
import type { Registry } from '@pezkuwi/types/types';
|
||||
|
||||
export class ProposalFactory {
|
||||
readonly #api: ApiPromise;
|
||||
readonly #registry: Registry;
|
||||
|
||||
constructor (api: ApiPromise) {
|
||||
this.#api = api;
|
||||
this.#registry = this.#api.registry;
|
||||
}
|
||||
|
||||
public createProposal = (method: SubmittableExtrinsic<'promise'>): Proposal => {
|
||||
return this.#registry.createType('Proposal', method);
|
||||
};
|
||||
|
||||
public proposalIndex = (index: number): ProposalIndex => {
|
||||
return this.#registry.createType('ProposalIndex', index);
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user