Browse Source

added quote props rule to prettier

Gleb Urvanov 4 years ago
parent
commit
446f83ce62

+ 1 - 0
devops/prettier-config/index.js

@@ -5,4 +5,5 @@ module.exports = {
   tabWidth: 2,
   semi: false,
   trailingComma: 'es5',
+  quoteProps: 'preserve'
 }

+ 2 - 2
tests/network-tests/src/constantinople/utils/apiWrapper.ts

@@ -38,7 +38,7 @@ export class ApiWrapper {
     expectFailure = false
   ): Promise<void> {
     return this.sender.signAndSend(
-      this.api.tx.members.buyMembership(paidTermsId, new UserInfo({ handle: name, avatar_uri: '', about: '' })),
+      this.api.tx.members.buyMembership(paidTermsId, new UserInfo({ 'handle': name, 'avatar_uri': '', 'about': '' })),
       account,
       expectFailure
     )
@@ -84,7 +84,7 @@ export class ApiWrapper {
 
   public estimateBuyMembershipFee(account: KeyringPair, paidTermsId: number, name: string): BN {
     return this.estimateTxFee(
-      this.api.tx.members.buyMembership(paidTermsId, new UserInfo({ handle: name, avatar_uri: '', about: '' }))
+      this.api.tx.members.buyMembership(paidTermsId, new UserInfo({ 'handle': name, 'avatar_uri': '', 'about': '' }))
     )
   }
 

+ 8 - 7
tests/network-tests/src/nicaea/dto/fillOpeningParameters.ts

@@ -1,4 +1,5 @@
 import BN from 'bn.js'
+import { RewardPolicy } from '@nicaea/types/working-group'
 
 export class FillOpeningParameters {
   private amountPerPayout!: BN
@@ -62,18 +63,18 @@ export class FillOpeningParameters {
 
   public getRewardPolicy() {
     return {
-      amount_per_payout: this.amountPerPayout,
-      next_payment_at_block: this.nextPaymentAtBlock,
-      payout_interval: this.payoutInterval,
+      'amount_per_payout': this.amountPerPayout,
+      'next_payment_at_block': this.nextPaymentAtBlock,
+      'payout_interval': this.payoutInterval,
     }
   }
 
   public getFillOpeningParameters() {
     return {
-      opening_id: this.openingId,
-      successful_application_id: this.successfulApplicationId,
-      reward_policy: this.getRewardPolicy(),
-      working_group: this.workingGroup,
+      'opening_id': this.openingId,
+      'successful_application_id': this.successfulApplicationId,
+      'reward_policy': this.getRewardPolicy(),
+      'working_group': this.workingGroup,
     }
   }
 }

+ 23 - 23
tests/network-tests/src/nicaea/dto/workingGroupOpening.ts

@@ -192,35 +192,35 @@ export class WorkingGroupOpening {
 
   public getCommitment() {
     return {
-      application_rationing_policy: { max_active_applicants: this.maxActiveApplicants },
-      max_review_period_length: this.maxReviewPeriodLength,
-      application_staking_policy: {
-        amount: this.applicationStakingPolicyAmount,
-        amount_mode: 'AtLeast',
-        crowded_out_unstaking_period_length: this.applicationCrowdedOutUnstakingPeriodLength,
-        review_period_expired_unstaking_period_length: this.applicationExpiredUnstakingPeriodLength,
+      'application_rationing_policy': { 'max_active_applicants': this.maxActiveApplicants },
+      'max_review_period_length': this.maxReviewPeriodLength,
+      'application_staking_policy': {
+        'amount': this.applicationStakingPolicyAmount,
+        'amount_mode': 'AtLeast',
+        'crowded_out_unstaking_period_length': this.applicationCrowdedOutUnstakingPeriodLength,
+        'review_period_expired_unstaking_period_length': this.applicationExpiredUnstakingPeriodLength,
       },
-      role_staking_policy: {
-        amount: this.roleStakingPolicyAmount,
-        amount_mode: 'AtLeast',
-        crowded_out_unstaking_period_length: this.roleCrowdedOutUnstakingPeriodLength,
-        review_period_expired_unstaking_period_length: this.roleExpiredUnstakingPeriodLength,
+      'role_staking_policy': {
+        'amount': this.roleStakingPolicyAmount,
+        'amount_mode': 'AtLeast',
+        'crowded_out_unstaking_period_length': this.roleCrowdedOutUnstakingPeriodLength,
+        'review_period_expired_unstaking_period_length': this.roleExpiredUnstakingPeriodLength,
       },
-      role_slashing_terms: {
-        Slashable: {
-          max_count: this.slashableMaxCount,
-          max_percent_pts_per_time: this.slashableMaxPercentPtsPerTime,
+      'role_slashing_terms': {
+        'Slashable': {
+          'max_count': this.slashableMaxCount,
+          'max_percent_pts_per_time': this.slashableMaxPercentPtsPerTime,
         },
       },
-      fill_opening_successful_applicant_application_stake_unstaking_period: this
+      'fill_opening_successful_applicant_application_stake_unstaking_period': this
         .successfulApplicantApplicationStakeUnstakingPeriod,
-      fill_opening_failed_applicant_application_stake_unstaking_period: this
+      'fill_opening_failed_applicant_application_stake_unstaking_period': this
         .failedApplicantApplicationStakeUnstakingPeriod,
-      fill_opening_failed_applicant_role_stake_unstaking_period: this.failedApplicantRoleStakeUnstakingPeriod,
-      terminate_application_stake_unstaking_period: this.terminateApplicationStakeUnstakingPeriod,
-      terminate_role_stake_unstaking_period: this.terminateRoleStakeUnstakingPeriod,
-      exit_role_application_stake_unstaking_period: this.exitRoleApplicationStakeUnstakingPeriod,
-      exit_role_stake_unstaking_period: this.exitRoleStakeUnstakingPeriod,
+      'fill_opening_failed_applicant_role_stake_unstaking_period': this.failedApplicantRoleStakeUnstakingPeriod,
+      'terminate_application_stake_unstaking_period': this.terminateApplicationStakeUnstakingPeriod,
+      'terminate_role_stake_unstaking_period': this.terminateRoleStakeUnstakingPeriod,
+      'exit_role_application_stake_unstaking_period': this.exitRoleApplicationStakeUnstakingPeriod,
+      'exit_role_stake_unstaking_period': this.exitRoleStakeUnstakingPeriod,
     }
   }
 }

+ 45 - 53
tests/network-tests/src/nicaea/utils/apiWrapper.ts

@@ -57,7 +57,7 @@ export class ApiWrapper {
     expectFailure = false
   ): Promise<void> {
     return this.sender.signAndSend(
-      this.api.tx.members.buyMembership(paidTermsId, new UserInfo({ handle: name, avatar_uri: '', about: '' })),
+      this.api.tx.members.buyMembership(paidTermsId, new UserInfo({ 'handle': name, 'avatar_uri': '', 'about': '' })),
       account,
       expectFailure
     )
@@ -103,7 +103,7 @@ export class ApiWrapper {
 
   public estimateBuyMembershipFee(account: KeyringPair, paidTermsId: number, name: string): BN {
     return this.estimateTxFee(
-      this.api.tx.members.buyMembership(paidTermsId, new UserInfo({ handle: name, avatar_uri: '', about: '' }))
+      this.api.tx.members.buyMembership(paidTermsId, new UserInfo({ 'handle': name, 'avatar_uri': '', 'about': '' }))
     )
   }
 
@@ -275,9 +275,9 @@ export class ApiWrapper {
   public estimateFillOpeningFee(module: WorkingGroups): BN {
     return this.estimateTxFee(
       this.api.tx[module].fillOpening(0, [0], {
-        amount_per_payout: 0,
-        next_payment_at_block: 0,
-        payout_interval: 0,
+        'amount_per_payout': 0,
+        'next_payment_at_block': 0,
+        'payout_interval': 0,
       })
     )
   }
@@ -325,6 +325,26 @@ export class ApiWrapper {
   }
 
   public estimateProposeCreateWorkingGroupLeaderOpeningFee(): BN {
+    const opening: WorkingGroupOpening = new WorkingGroupOpening()
+    opening.setActivateAtBlock(undefined)
+    opening.setMaxActiveApplicants(new BN(32))
+    opening.setMaxReviewPeriodLength(new BN(32))
+    opening.setApplicationStakingPolicyAmount(new BN(1))
+    opening.setApplicationCrowdedOutUnstakingPeriodLength(new BN(1))
+    opening.setApplicationExpiredUnstakingPeriodLength(new BN(1))
+    opening.setRoleStakingPolicyAmount(new BN(1))
+    opening.setRoleCrowdedOutUnstakingPeriodLength(new BN(1))
+    opening.setRoleExpiredUnstakingPeriodLength(new BN(1))
+    opening.setSlashableMaxCount(new BN(0))
+    opening.setSlashableMaxPercentPtsPerTime(new BN(0))
+    opening.setSuccessfulApplicantApplicationStakeUnstakingPeriod(new BN(1))
+    opening.setFailedApplicantApplicationStakeUnstakingPeriod(new BN(1))
+    opening.setFailedApplicantRoleStakeUnstakingPeriod(new BN(1))
+    opening.setTerminateApplicationStakeUnstakingPeriod(new BN(1))
+    opening.setTerminateRoleStakeUnstakingPeriod(new BN(1))
+    opening.setExitRoleApplicationStakeUnstakingPeriod(new BN(1))
+    opening.setExitRoleStakeUnstakingPeriod(new BN(1))
+
     return this.estimateTxFee(
       this.api.tx.proposalsCodex.createAddWorkingGroupLeaderOpeningProposal(
         0,
@@ -332,38 +352,10 @@ export class ApiWrapper {
         'some long description for the purpose of testing',
         0,
         {
-          activate_at: 'CurrentBlock',
-          commitment: {
-            application_rationing_policy: { max_active_applicants: '32' },
-            max_review_period_length: 32,
-            application_staking_policy: {
-              amount: 0,
-              amount_mode: 'AtLeast',
-              crowded_out_unstaking_period_length: 0,
-              review_period_expired_unstaking_period_length: 0,
-            },
-            role_staking_policy: {
-              amount: 0,
-              amount_mode: 'AtLeast',
-              crowded_out_unstaking_period_length: 0,
-              review_period_expired_unstaking_period_length: 0,
-            },
-            role_slashing_terms: {
-              Slashable: {
-                max_count: 0,
-                max_percent_pts_per_time: 0,
-              },
-            },
-            fill_opening_successful_applicant_application_stake_unstaking_period: 0,
-            fill_opening_failed_applicant_application_stake_unstaking_period: 0,
-            fill_opening_failed_applicant_role_stake_unstaking_period: 0,
-            terminate_curator_application_stake_unstaking_period: 0,
-            terminate_curator_role_stake_unstaking_period: 0,
-            exit_curator_role_application_stake_unstaking_period: 0,
-            exit_curator_role_stake_unstaking_period: 0,
-          },
-          human_readable_text: 'Opening readable text',
-          working_group: 'Storage',
+          'activate_at': opening.getActivateAt(),
+          'commitment': opening.getCommitment(),
+          'human_readable_text': 'Opening readable text',
+          'working_group': 'Storage',
         }
       )
     )
@@ -410,10 +402,10 @@ export class ApiWrapper {
         'Some testing text used for estimation purposes which is longer than text expected during the test',
         0,
         {
-          worker_id: 0,
-          rationale: 'Exceptionaly long and extraordinary descriptive rationale',
-          slash: true,
-          working_group: 'Storage',
+          'worker_id': 0,
+          'rationale': 'Exceptionaly long and extraordinary descriptive rationale',
+          'slash': true,
+          'working_group': 'Storage',
         }
       )
     )
@@ -1040,10 +1032,10 @@ export class ApiWrapper {
         description,
         proposalStake,
         {
-          activate_at: opening.getActivateAt(),
-          commitment: opening.getCommitment(),
-          human_readable_text: opening.getText(),
-          working_group: workingGroup,
+          'activate_at': opening.getActivateAt(),
+          'commitment': opening.getCommitment(),
+          'human_readable_text': opening.getText(),
+          'working_group': workingGroup,
         }
       ),
       account,
@@ -1090,10 +1082,10 @@ export class ApiWrapper {
         description,
         proposalStake,
         {
-          worker_id: leadWorkerId,
+          'worker_id': leadWorkerId,
           rationale,
           slash,
-          working_group: workingGroup,
+          'working_group': workingGroup,
         }
       ),
       account,
@@ -1281,9 +1273,9 @@ export class ApiWrapper {
   ): Promise<void> {
     return this.sender.signAndSend(
       this.api.tx[module].fillOpening(openingId, applicationId, {
-        amount_per_payout: amountPerPayout,
-        next_payment_at_block: nextPaymentBlock,
-        payout_interval: payoutInterval,
+        'amount_per_payout': amountPerPayout,
+        'next_payment_at_block': nextPaymentBlock,
+        'payout_interval': payoutInterval,
       }),
       leader,
       false
@@ -1302,9 +1294,9 @@ export class ApiWrapper {
     return this.sender.signAndSend(
       this.api.tx.sudo.sudo(
         this.api.tx[module].fillOpening(openingId, applicationId, {
-          amount_per_payout: amountPerPayout,
-          next_payment_at_block: nextPaymentBlock,
-          payout_interval: payoutInterval,
+          'amount_per_payout': amountPerPayout,
+          'next_payment_at_block': nextPaymentBlock,
+          'payout_interval': payoutInterval,
         })
       ),
       sudo,

+ 4 - 0
tests/network-tests/src/nicaea/utils/utils.ts

@@ -46,4 +46,8 @@ export class Utils {
   public static readRuntimeFromFile(path: string): string {
     return '0x' + fs.readFileSync(path).toString('hex')
   }
+
+  public static camelToSnakeCase(key: string): string {
+    return key.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`)
+  }
 }

+ 2 - 2
tests/network-tests/src/rome/utils/apiWrapper.ts

@@ -35,7 +35,7 @@ export class ApiWrapper {
     expectFailure = false
   ): Promise<void> {
     return this.sender.signAndSend(
-      this.api.tx.members.buyMembership(paidTermsId, new UserInfo({ handle: name, avatar_uri: '', about: '' })),
+      this.api.tx.members.buyMembership(paidTermsId, new UserInfo({ 'handle': name, 'avatar_uri': '', 'about': '' })),
       account,
       expectFailure
     )
@@ -81,7 +81,7 @@ export class ApiWrapper {
 
   public estimateBuyMembershipFee(account: KeyringPair, paidTermsId: number, name: string): BN {
     return this.estimateTxFee(
-      this.api.tx.members.buyMembership(paidTermsId, new UserInfo({ handle: name, avatar_uri: '', about: '' }))
+      this.api.tx.members.buyMembership(paidTermsId, new UserInfo({ 'handle': name, 'avatar_uri': '', 'about': '' }))
     )
   }