Skip to content

Commit

Permalink
Fix linter
Browse files Browse the repository at this point in the history
  • Loading branch information
gregLibert committed Apr 30, 2024
1 parent 4821931 commit 46c1cfb
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion packages/massa-web3/src/experimental/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ export class Account {
throw new Error('Password is required for V0 keystore')
}
const passwordSeal = new PasswordSeal(password, salt, nonce)

/* eslint-disable @typescript-eslint/naming-convention */
// It is mandatory to follow the Massa standard.
return {
Address: this.address.toString(),
Version: this.version,
Expand All @@ -124,12 +127,16 @@ export class Account {
.then((a) => Array.from(a)),
PublicKey: Array.from(this.publicKey.toBytes()),
} as AccountV0KeyStore
/* eslint-enable @typescript-eslint/naming-convention */
}

Check warning on line 131 in packages/massa-web3/src/experimental/account.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

Check warning on line 131 in packages/massa-web3/src/experimental/account.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

Check warning on line 131 in packages/massa-web3/src/experimental/account.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
case Version.V1: {
if (!password) {
throw new Error('Password is required for V1 keystore')
}
const passwordSeal = new PasswordSeal(password, salt, nonce)

/* eslint-disable @typescript-eslint/naming-convention */
// It is mandatory to follow the Massa standard.
return {
Address: this.address.toString(),
Version: this.version,
Expand All @@ -141,6 +148,7 @@ export class Account {
.then((a) => Array.from(a)),
PublicKey: Array.from(this.publicKey.toBytes()),
} as AccountV1KeyStore
/* eslint-enable @typescript-eslint/naming-convention */
}
default:
throw new Error(`unsupported version`)
Expand Down Expand Up @@ -180,6 +188,9 @@ export class Account {
const privateKeyBytes = await passwordSeal.unseal(keystore.CipheredData)
const privateKey = PrivateKey.fromBytes(privateKeyBytes, Version.V0)
const publicKey = PublicKey.fromBytes(
// TODO: The PublicKey class should be refactored to ensure consistency between the fromBytes and toBytes methods,
// similar to what was done for the address class.
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
new Uint8Array(keystore.PublicKey).subarray(1),
Version.V0

Check warning on line 195 in packages/massa-web3/src/experimental/account.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 195 in packages/massa-web3/src/experimental/account.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 195 in packages/massa-web3/src/experimental/account.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
)
Expand All @@ -206,6 +217,9 @@ export class Account {
const version = numberVersion as Version
const privateKey = PrivateKey.fromBytes(bytes, version)
const publicKey = PublicKey.fromBytes(
// TODO: The PublicKey class should be refactored to ensure consistency between the fromBytes and toBytes methods,
// similar to what was done for the address class.
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
new Uint8Array(keystore.PublicKey).subarray(1),
Version.V0
)
Expand Down Expand Up @@ -243,7 +257,8 @@ export class Account {
}
}

// keys are uppercased to match the yaml keystore file format
/* eslint-disable @typescript-eslint/naming-convention */
// It is mandatory to follow the Massa standard.
export type AccountKeyStoreBase = {
Address: string
Nickname: string
Expand All @@ -255,4 +270,5 @@ export type AccountKeyStoreBase = {

export type AccountV0KeyStore = AccountKeyStoreBase & { Version: Version.V0 }
export type AccountV1KeyStore = AccountKeyStoreBase & { Version: Version.V1 }
/* eslint-enable @typescript-eslint/naming-convention */
export type AccountKeyStore = AccountV0KeyStore | AccountV1KeyStore

1 comment on commit 46c1cfb

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage report for experimental massa-web3

St.
Category Percentage Covered / Total
🔴 Statements 40.41% 780/1930
🔴 Branches 17.96% 88/490
🔴 Functions 30.95% 117/378
🔴 Lines 40.17% 766/1907

Test suite run success

47 tests passing in 7 suites.

Report generated by 🧪jest coverage report action from 46c1cfb

Please sign in to comment.