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
before · 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';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'
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());
   }
 }