git.delta.rocks / unique-network / refs/commits / 032022202689

difftreelog

feat use mixins for sudo/scheduler helpers

Daniel Shiposha2022-09-23parent: #f13330a.patch.diff
in: master

5 files changed

modifiedtests/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;
modifiedtests/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 {
modifiedtests/src/util/playgrounds/types.tsdiffbeforeafterboth
after · tests/src/util/playgrounds/types.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// SPDX-License-Identifier: Apache-2.034import {IKeyringPair} from '@polkadot/types/types';5import {UniqueHelper} from './unique';67export interface IEvent {8  section: string;9  method: string;10  index: [number, number] | string;11  data: any[];12  phase: {applyExtrinsic: number} | 'Initialization',13}1415export interface ITransactionResult {16  status: 'Fail' | 'Success';17  result: {18      dispatchError: any,19      events: {20        phase: any, // {ApplyExtrinsic: number} | 'Initialization',21        event: IEvent;22      }[];23  },24  moduleError?: string;25}2627export interface ISubscribeBlockEventsData {28  number: number;29  hash: string;30  timestamp: number; 31  events: IEvent[];32}3334export interface ILogger {35  log: (msg: any, level?: string) => void;36  level: {37    ERROR: 'ERROR';38    WARNING: 'WARNING';39    INFO: 'INFO';40    [key: string]: string;41  }42}4344export interface IUniqueHelperLog {45  executedAt: number;46  executionTime: number;47  type: 'extrinsic' | 'rpc';48  status: 'Fail' | 'Success';49  call: string;50  params: any[];51  moduleError?: string;52  dispatchError?: any;53  events?: any;54}5556export interface IApiListeners {57  connected?: (...args: any[]) => any;58  disconnected?: (...args: any[]) => any;59  error?: (...args: any[]) => any;60  ready?: (...args: any[]) => any; 61  decorated?: (...args: any[]) => any;62}6364export interface ICrossAccountId {65  Substrate?: TSubstrateAccount;66  Ethereum?: TEthereumAccount;67}6869export interface ICrossAccountIdLower {70  substrate?: TSubstrateAccount;71  ethereum?: TEthereumAccount;72}7374export interface ICollectionLimits {75  accountTokenOwnershipLimit?: number | null;76  sponsoredDataSize?: number | null;77  sponsoredDataRateLimit?: {blocks: number} | {sponsoringDisabled: null} | null;78  tokenLimit?: number | null;79  sponsorTransferTimeout?: number | null;80  sponsorApproveTimeout?: number | null;81  ownerCanTransfer?: boolean | null;82  ownerCanDestroy?: boolean | null;83  transfersEnabled?: boolean | null;84}8586export interface INestingPermissions {87  tokenOwner?: boolean;88  collectionAdmin?: boolean;89  restricted?: number[] | null;90}9192export interface ICollectionPermissions {93  access?: 'Normal' | 'AllowList';94  mintMode?: boolean;95  nesting?: INestingPermissions;96}9798export interface IProperty {99  key: string;100  value?: string;101}102103export interface ITokenPropertyPermission {104  key: string;105  permission: {106    mutable?: boolean;107    tokenOwner?: boolean;108    collectionAdmin?: boolean;109  }110}111112export interface IToken {113  collectionId: number;114  tokenId: number;115}116117export interface IBlock {118  extrinsics: IExtrinsic[]119  header: {120    parentHash: string,121    number: number,122  };123}124125export interface IExtrinsic {126  isSigned: boolean,127  method: {128    method: string,129    section: string,130    args: any[]131  }132}133134export interface ICollectionCreationOptions {135  name?: string | number[];136  description?: string | number[];137  tokenPrefix?: string | number[];138  mode?: {139    nft?: null;140    refungible?: null;141    fungible?: number;142  }143  permissions?: ICollectionPermissions;144  properties?: IProperty[];145  tokenPropertyPermissions?: ITokenPropertyPermission[];146  limits?: ICollectionLimits;147  pendingSponsor?: TSubstrateAccount;148}149150export interface IChainProperties {151  ss58Format: number;152  tokenDecimals: number[];153  tokenSymbol: string[]154}155156export interface ISubstrateBalance {157  free: bigint,158  reserved: bigint,159  miscFrozen: bigint,160  feeFrozen: bigint161}162163export interface IStakingInfo {164  block: bigint,165  amount: bigint,166}167168export interface ISchedulerOptions {169  priority?: number,170  periodic?: {171    period: number,172    repetitions: number,173  },174}175176export interface IForeignAssetMetadata {177  name?: number | Uint8Array,178  symbol?: string,179  decimals?: number,180  minimalBalance?: bigint,181}182183export interface MoonbeamAssetInfo {184  location: any,185  metadata: {186    name: string,187    symbol: string,188    decimals: number,189    isFrozen: boolean,190    minimalBalance: bigint,191  },192  existentialDeposit: bigint,193  isSufficient: boolean,194  unitsPerSecond: bigint,195  numAssetsWeightHint: number,196}197198export interface AcalaAssetMetadata {199  name: string,200  symbol: string,201  decimals: number,202  minimalBalance: bigint,203}204205export interface DemocracyStandardAccountVote {206  balance: bigint,207  vote: {208    aye: boolean,209    conviction: number,210  },211}212213export type TSubstrateAccount = string;214export type TEthereumAccount = string;215export type TApiAllowedListeners = 'connected' | 'disconnected' | 'error' | 'ready' | 'decorated';216export type TUniqueNetworks = 'opal' | 'quartz' | 'unique';217export type TSiblingNetworkds = 'moonbeam' | 'moonriver' | 'acala' | 'karura' | 'westmint';218export type TRelayNetworks = 'rococo' | 'westend';219export type TNetworks = TUniqueNetworks | TSiblingNetworkds | TRelayNetworks;220export type TSigner = IKeyringPair; // | 'string'
modifiedtests/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() {
modifiedtests/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());
   }
 }