difftreelog
feat use mixins for sudo/scheduler helpers
in: master
5 files changed
tests/src/eth/util/playgrounds/types.tsdiffbeforeafterboth--- a/tests/src/eth/util/playgrounds/types.ts
+++ b/tests/src/eth/util/playgrounds/types.ts
@@ -1,3 +1,5 @@
+import {EthUniqueHelper} from './unique.dev';
+
export interface ContractImports {
solPath: string;
fsPath: string;
@@ -13,3 +15,5 @@
event: string,
args: { [key: string]: string }
};
+
+export type EthUniqueHelperConstructor = new (...args: any[]) => EthUniqueHelper;
tests/src/eth/util/playgrounds/unique.dev.tsdiffbeforeafterboth--- a/tests/src/eth/util/playgrounds/unique.dev.ts
+++ b/tests/src/eth/util/playgrounds/unique.dev.ts
@@ -18,7 +18,7 @@
import {DevUniqueHelper} from '../../../util/playgrounds/unique.dev';
-import {ContractImports, CompiledContract, NormalizedEvent} from './types';
+import {ContractImports, CompiledContract, NormalizedEvent, EthUniqueHelperConstructor} from './types';
// Native contracts ABI
import collectionHelpersAbi from '../../collectionHelpersAbi.json';
@@ -340,7 +340,6 @@
return '0x' + address.substring(address.length - 40);
}
}
-
export type EthUniqueHelperConstructor = new (...args: any[]) => EthUniqueHelper;
export class EthUniqueHelper extends DevUniqueHelper {
tests/src/util/playgrounds/types.tsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// SPDX-License-Identifier: Apache-2.034import {IKeyringPair} from '@polkadot/types/types';56export interface IEvent {7 section: string;8 method: string;9 index: [number, number] | string;10 data: any[];11 phase: {applyExtrinsic: number} | 'Initialization',12}1314export interface ITransactionResult {15 status: 'Fail' | 'Success';16 result: {17 dispatchError: any,18 events: {19 phase: any, // {ApplyExtrinsic: number} | 'Initialization',20 event: IEvent;21 }[];22 },23 moduleError?: string;24}2526export interface ISubscribeBlockEventsData {27 number: number;28 hash: string;29 timestamp: number; 30 events: IEvent[];31}3233export interface ILogger {34 log: (msg: any, level?: string) => void;35 level: {36 ERROR: 'ERROR';37 WARNING: 'WARNING';38 INFO: 'INFO';39 [key: string]: string;40 }41}4243export interface IUniqueHelperLog {44 executedAt: number;45 executionTime: number;46 type: 'extrinsic' | 'rpc';47 status: 'Fail' | 'Success';48 call: string;49 params: any[];50 moduleError?: string;51 dispatchError?: any;52 events?: any;53}5455export interface IApiListeners {56 connected?: (...args: any[]) => any;57 disconnected?: (...args: any[]) => any;58 error?: (...args: any[]) => any;59 ready?: (...args: any[]) => any; 60 decorated?: (...args: any[]) => any;61}6263export interface ICrossAccountId {64 Substrate?: TSubstrateAccount;65 Ethereum?: TEthereumAccount;66}6768export interface ICrossAccountIdLower {69 substrate?: TSubstrateAccount;70 ethereum?: TEthereumAccount;71}7273export interface ICollectionLimits {74 accountTokenOwnershipLimit?: number | null;75 sponsoredDataSize?: number | null;76 sponsoredDataRateLimit?: {blocks: number} | {sponsoringDisabled: null} | null;77 tokenLimit?: number | null;78 sponsorTransferTimeout?: number | null;79 sponsorApproveTimeout?: number | null;80 ownerCanTransfer?: boolean | null;81 ownerCanDestroy?: boolean | null;82 transfersEnabled?: boolean | null;83}8485export interface INestingPermissions {86 tokenOwner?: boolean;87 collectionAdmin?: boolean;88 restricted?: number[] | null;89}9091export interface ICollectionPermissions {92 access?: 'Normal' | 'AllowList';93 mintMode?: boolean;94 nesting?: INestingPermissions;95}9697export interface IProperty {98 key: string;99 value?: string;100}101102export interface ITokenPropertyPermission {103 key: string;104 permission: {105 mutable?: boolean;106 tokenOwner?: boolean;107 collectionAdmin?: boolean;108 }109}110111export interface IToken {112 collectionId: number;113 tokenId: number;114}115116export interface IBlock {117 extrinsics: IExtrinsic[]118 header: {119 parentHash: string,120 number: number,121 };122}123124export interface IExtrinsic {125 isSigned: boolean,126 method: {127 method: string,128 section: string,129 args: any[]130 }131}132133export interface ICollectionCreationOptions {134 name?: string | number[];135 description?: string | number[];136 tokenPrefix?: string | number[];137 mode?: {138 nft?: null;139 refungible?: null;140 fungible?: number;141 }142 permissions?: ICollectionPermissions;143 properties?: IProperty[];144 tokenPropertyPermissions?: ITokenPropertyPermission[];145 limits?: ICollectionLimits;146 pendingSponsor?: TSubstrateAccount;147}148149export interface IChainProperties {150 ss58Format: number;151 tokenDecimals: number[];152 tokenSymbol: string[]153}154155export interface ISubstrateBalance {156 free: bigint,157 reserved: bigint,158 miscFrozen: bigint,159 feeFrozen: bigint160}161162export interface IStakingInfo {163 block: bigint,164 amount: bigint,165}166167export interface ISchedulerOptions {168 priority?: number,169 periodic?: {170 period: number,171 repetitions: number,172 },173}174175export interface IForeignAssetMetadata {176 name?: number | Uint8Array,177 symbol?: string,178 decimals?: number,179 minimalBalance?: bigint,180}181182export interface MoonbeamAssetInfo {183 location: any,184 metadata: {185 name: string,186 symbol: string,187 decimals: number,188 isFrozen: boolean,189 minimalBalance: bigint,190 },191 existentialDeposit: bigint,192 isSufficient: boolean,193 unitsPerSecond: bigint,194 numAssetsWeightHint: number,195}196197export interface AcalaAssetMetadata {198 name: string,199 symbol: string,200 decimals: number,201 minimalBalance: bigint,202}203204export interface DemocracyStandardAccountVote {205 balance: bigint,206 vote: {207 aye: boolean,208 conviction: number,209 },210}211212export type TSubstrateAccount = string;213export type TEthereumAccount = string;214export type TApiAllowedListeners = 'connected' | 'disconnected' | 'error' | 'ready' | 'decorated';215export type TUniqueNetworks = 'opal' | 'quartz' | 'unique';216export type TSiblingNetworkds = 'moonbeam' | 'moonriver' | 'acala' | 'karura' | 'westmint';217export type TRelayNetworks = 'rococo' | 'westend';218export type TNetworks = TUniqueNetworks | TSiblingNetworkds | TRelayNetworks;219export type TSigner = IKeyringPair; // | 'string'tests/src/util/playgrounds/unique.dev.tsdiffbeforeafterboth--- a/tests/src/util/playgrounds/unique.dev.ts
+++ b/tests/src/util/playgrounds/unique.dev.ts
@@ -11,6 +11,7 @@
import {ICrossAccountId} from './types';
import {FrameSystemEventRecord} from '@polkadot/types/lookup';
import {VoidFn} from '@polkadot/api/types';
+import {FrameSystemEventRecord} from '@polkadot/types/lookup';
export class SilentLogger {
log(_msg: any, _level: any): void { }
@@ -496,13 +497,13 @@
async startCapture() {
this.stopCapture();
- this.unsubscribe = await this.helper.getApi().query.system.events(eventRecords => {
+ this.unsubscribe = (await this.helper.getApi().query.system.events((eventRecords: FrameSystemEventRecord[]) => {
const newEvents = eventRecords.filter(r => {
return r.event.section == this.eventSection && r.event.method == this.eventMethod;
});
this.events.push(...newEvents);
- });
+ })) as any;
}
stopCapture() {
tests/src/util/playgrounds/unique.tsdiffbeforeafterboth--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -2439,6 +2439,10 @@
}
class SchedulerGroup extends HelperGroup<UniqueHelper> {
+ constructor(helper: UniqueHelper) {
+ super(helper);
+ }
+
async cancelScheduled(signer: TSigner, scheduledId: string) {
return this.helper.executeExtrinsic(
signer,
@@ -2828,7 +2832,6 @@
expectSuccess?: boolean,
): Promise<ITransactionResult> {
const call = this.constructApiCall(extrinsic, params);
-
return super.executeExtrinsic(
sender,
'api.tx.sudo.sudo',
@@ -2964,10 +2967,6 @@
getSudo<T extends UniqueHelper>() {
return new UniqueBaseCollection(this.collectionId, this.helper.getSudo<T>());
- }
-
- getSudo() {
- return new UniqueCollectionBase(this.collectionId, this.helper.getSudo());
}
}