Skip to content

Commit

Permalink
Fix linter (#583)
Browse files Browse the repository at this point in the history
  • Loading branch information
gregLibert authored May 2, 2024
1 parent 6901400 commit d88d7fd
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 */
}
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
)
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 d88d7fd

@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.79% 791/1939
🔴 Branches 17.73% 86/485
🔴 Functions 30.95% 117/378
🔴 Lines 40.55% 777/1916

Test suite run success

47 tests passing in 7 suites.

Report generated by 🧪jest coverage report action from d88d7fd

Please sign in to comment.