Skip to content

Commit

Permalink
style(eslint): bulk auto-fixable issues resolved project-wide - 2023-…
Browse files Browse the repository at this point in the history
…09-20

1. the eslint auto-fixer diff
2. the cspell auto-fixer spelling error fixes in documentation only

E.g., no actual code changes at all, runtime behavior should be
equivalent to how it was before this commit.

[skip ci]

Fixes #2710

Depends on #2727

Signed-off-by: Peter Somogyvari <[email protected]>
  • Loading branch information
petermetz committed Oct 16, 2023
1 parent 84c5b34 commit 1d3968d
Show file tree
Hide file tree
Showing 232 changed files with 1,319 additions and 1,317 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ describe("Config files check tests", () => {
usersettingYaml.logLevel === "trace",
).toBe(true);

const ipRegex = /^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
const ipRegex =
/^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
expect(
usersettingYaml.applicationHostInfo.hostName.replace("http://", ""),
).toMatch(ipRegex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,10 @@ describe("Ledger operation tests", () => {
let options = createOptionObj(path, "POST", postData);

// Get current balances on accounts before sending request
let srcBalanceBeforeTransaction = await getCurrentBalanceOnAccount(
srcAccount,
);
let destBalanceBeforeTransaction = await getCurrentBalanceOnAccount(
destAccount,
);
let srcBalanceBeforeTransaction =
await getCurrentBalanceOnAccount(srcAccount);
let destBalanceBeforeTransaction =
await getCurrentBalanceOnAccount(destAccount);
logger.debug(`Balances before transaction:\nsource account:${srcBalanceBeforeTransaction}
\ndestination account: ${destBalanceBeforeTransaction}`);

Expand All @@ -308,12 +306,10 @@ describe("Ledger operation tests", () => {
expect(foo).toBeDefined();

// Check balances after transaction
let srcBalanceAfterTransaction = await getCurrentBalanceOnAccount(
srcAccount,
);
let destBalanceAfterTransaction = await getCurrentBalanceOnAccount(
destAccount,
);
let srcBalanceAfterTransaction =
await getCurrentBalanceOnAccount(srcAccount);
let destBalanceAfterTransaction =
await getCurrentBalanceOnAccount(destAccount);

// Check if differences from before and after transaction are correct

Expand All @@ -338,9 +334,8 @@ describe("Ledger operation tests", () => {

// Get current balances on accounts before sending request
srcBalanceBeforeTransaction = await getCurrentBalanceOnAccount(srcAccount);
destBalanceBeforeTransaction = await getCurrentBalanceOnAccount(
destAccount,
);
destBalanceBeforeTransaction =
await getCurrentBalanceOnAccount(destAccount);
logger.debug(`Balances before transaction:\nsource account:${srcBalanceBeforeTransaction}
destination account: ${destBalanceBeforeTransaction}`);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ export class CarbonAccountingApp {
const xdaiAccount = await this.ledgers.xdai.createEthTestAccount();

const sshConfig = await this.ledgers.fabric.getSshConfig();
const connectionProfile = await this.ledgers.fabric.getConnectionProfileOrg1();
const connectionProfile =
await this.ledgers.fabric.getConnectionProfileOrg1();
const enrollAdminOut = await this.ledgers.fabric.enrollAdmin();
const adminWallet = enrollAdminOut[1];
const [userIdentity] = await this.ledgers.fabric.enrollUser(adminWallet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export class EmissionsChaincode {
getEmissionsData: this.getEmissionsData,
getAllEmissionsData: this.getAllEmissionsData,
getAllEmissionsDataByDateRange: this.getAllEmissionsDataByDateRange,
getAllEmissionsDataByDateRangeAndParty: this
.getAllEmissionsDataByDateRangeAndParty,
getAllEmissionsDataByDateRangeAndParty:
this.getAllEmissionsDataByDateRangeAndParty,
};
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async Init(stub: ChaincodeStub): Promise<ChaincodeResponse> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ export function getCO2EmissionFactor(
// calculate emissions using percent_of_renewables if found
if (factor.percent_of_renewables.length !== 0) {
emissionsUOM = "g";
const co2EquivalentEmissionsUOM = factor.co2_equivalent_emissions_uom.split(
"/",
);
const co2EquivalentEmissionsUOM =
factor.co2_equivalent_emissions_uom.split("/");
if (co2EquivalentEmissionsUOM.length === 0) {
console.error("co2_equivalent_emissions_uom not found in factor");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ export class EmissionsRecordContract {
md5: string,
): Promise<Uint8Array> {
// get emissions factors from eGRID database; convert energy use to emissions factor UOM; calculate energy use
const lookup = await this.utilityLookupState.getUtilityLookupItem(
utilityId,
);
const factor = await this.utilityEmissionsFactorState.getEmissionsFactorByLookupItem(
lookup.item,
thruDate,
);
const lookup =
await this.utilityLookupState.getUtilityLookupItem(utilityId);
const factor =
await this.utilityEmissionsFactorState.getEmissionsFactorByLookupItem(
lookup.item,
thruDate,
);
const co2Emission = getCO2EmissionFactor(
factor.factor,
Number(energyUseAmount),
Expand Down Expand Up @@ -128,11 +128,12 @@ export class EmissionsRecordContract {
partyId: string,
): Promise<Uint8Array> {
const partyIdsha256 = SHA256(partyId).toString();
const records = await this.emissionsState.getAllEmissionsDataByDateRangeAndParty(
fromDate,
thruDate,
partyIdsha256,
);
const records =
await this.emissionsState.getAllEmissionsDataByDateRangeAndParty(
fromDate,
thruDate,
partyIdsha256,
);
return Buffer.from(JSON.stringify(records));
}
async importUtilityFactor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ export class UtilityEmissionsFactor extends State {
}
}

export class UtilityEmissionsFactorState extends WorldState<
UtilityEmissionsFactorInterface
> {
export class UtilityEmissionsFactorState extends WorldState<UtilityEmissionsFactorInterface> {
constructor(stub: ChaincodeStub) {
super(stub);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ export class UtilityLookupItem extends State {
}
}

export class UtilityLookupItemState extends WorldState<
UtilityLookupItemInterface
> {
export class UtilityLookupItemState extends WorldState<UtilityLookupItemInterface> {
constructor(stub: ChaincodeStub) {
super(stub);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ export interface ICarbonAccountingPluginOptions {
}

export class CarbonAccountingPlugin
implements ICactusPlugin, IPluginWebService {
implements ICactusPlugin, IPluginWebService
{
public static readonly CLASS_NAME = "CarbonAccountingPlugin";

private readonly log: Logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class GetAllowanceEndpoint implements IWebServiceEndpoint {
};
}

public get oasPath(): typeof OAS.paths["/api/v1/plugins/@hyperledger/cactus-example-carbon-accounting-backend/dao-token/get-allowance"] {
public get oasPath(): (typeof OAS.paths)["/api/v1/plugins/@hyperledger/cactus-example-carbon-accounting-backend/dao-token/get-allowance"] {
return OAS.paths[
"/api/v1/plugins/@hyperledger/cactus-example-carbon-accounting-backend/dao-token/get-allowance"
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class EnrollAdminV1Endpoint implements IWebServiceEndpoint {
};
}

public get oasPath(): typeof OAS.paths["/api/v1/utilityemissionchannel/registerEnroll/admin"] {
public get oasPath(): (typeof OAS.paths)["/api/v1/utilityemissionchannel/registerEnroll/admin"] {
return OAS.paths["/api/v1/utilityemissionchannel/registerEnroll/admin"];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ chai.use(chaiAsPromised);
chai.use(sinonChai);

class TestContext extends Context {
public stub: sinon.SinonStubbedInstance<
ChaincodeStub
> = sinon.createStubInstance(ChaincodeStub);
public clientIdentity: sinon.SinonStubbedInstance<
ClientIdentity
> = sinon.createStubInstance(ClientIdentity);
public stub: sinon.SinonStubbedInstance<ChaincodeStub> =
sinon.createStubInstance(ChaincodeStub);
public clientIdentity: sinon.SinonStubbedInstance<ClientIdentity> =
sinon.createStubInstance(ClientIdentity);
public logging = {
getLogger: sinon
.stub()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ export async function launchApp(
const configService = new ConfigService();
const exampleConfig = await configService.newExampleConfig();
exampleConfig.configFile = "";
exampleConfig.authorizationConfigJson = (JSON.stringify(
exampleConfig.authorizationConfigJson = JSON.stringify(
exampleConfig.authorizationConfigJson,
) as unknown) as IAuthorizationConfig;
) as unknown as IAuthorizationConfig;
exampleConfig.authorizationProtocol = AuthorizationProtocol.NONE;

const convictConfig = await configService.newExampleConfigConvict(
exampleConfig,
);
const convictConfig =
await configService.newExampleConfigConvict(exampleConfig);

env = await configService.newExampleConfigEnv(convictConfig.getProperties());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ export class CbdcBridgingApp {
await this.infrastructure.start();
this.onShutdown(() => this.infrastructure.stop());

const fabricPlugin = await this.infrastructure.createFabricLedgerConnector();
const fabricPlugin =
await this.infrastructure.createFabricLedgerConnector();
const besuPlugin = await this.infrastructure.createBesuLedgerConnector();
const clientIpfsPlugin = await this.infrastructure.createIPFSConnector();
const serverIpfsPlugin = await this.infrastructure.createIPFSConnector();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ export class CbdcBridgingAppDummyInfrastructure {
publishAllPorts: true,
imageName: DEFAULT_FABRIC_2_AIO_IMAGE_NAME,
imageVersion: DEFAULT_FABRIC_2_AIO_IMAGE_VERSION,
envVars: new Map([["FABRIC_VERSION", DEFAULT_FABRIC_2_AIO_FABRIC_VERSION]]),
envVars: new Map([
["FABRIC_VERSION", DEFAULT_FABRIC_2_AIO_FABRIC_VERSION],
]),
logLevel: level || "DEBUG",
});

Expand Down Expand Up @@ -166,9 +168,7 @@ export class CbdcBridgingAppDummyInfrastructure {
}
}

public async createFabricLedgerConnector(): Promise<
PluginLedgerConnectorFabric
> {
public async createFabricLedgerConnector(): Promise<PluginLedgerConnectorFabric> {
const connectionProfileOrg1 = await this.fabric.getConnectionProfileOrg1();
const enrollAdminOutOrg1 = await this.fabric.enrollAdminV2({
organization: "org1",
Expand Down Expand Up @@ -646,8 +646,8 @@ export class CbdcBridgingAppDummyInfrastructure {
public async deployBesuContracts(besuApiClient: BesuApi): Promise<void> {
const fnTag = `${this.className}#deployBesuContracts()`;

const deployCbdcContractResponse = await besuApiClient.deployContractSolBytecodeV1(
{
const deployCbdcContractResponse =
await besuApiClient.deployContractSolBytecodeV1({
keychainId: CryptoMaterial.keychains.keychain2.id,
contractName: CBDCcontractJson.contractName,
contractAbi: CBDCcontractJson.abi,
Expand All @@ -659,15 +659,14 @@ export class CbdcBridgingAppDummyInfrastructure {
},
bytecode: CBDCcontractJson.bytecode,
gas: 10000000,
} as DeployContractSolidityBytecodeV1Request,
);
} as DeployContractSolidityBytecodeV1Request);

if (deployCbdcContractResponse == undefined) {
throw new Error(`${fnTag}, error when deploying CBDC smart contract`);
}

const deployAssetReferenceContractResponse = await besuApiClient.deployContractSolBytecodeV1(
{
const deployAssetReferenceContractResponse =
await besuApiClient.deployContractSolBytecodeV1({
keychainId: CryptoMaterial.keychains.keychain2.id,
contractName: AssetReferenceContractJson.contractName,
contractAbi: AssetReferenceContractJson.abi,
Expand All @@ -681,8 +680,7 @@ export class CbdcBridgingAppDummyInfrastructure {
},
bytecode: AssetReferenceContractJson.bytecode,
gas: 10000000,
} as DeployContractSolidityBytecodeV1Request,
);
} as DeployContractSolidityBytecodeV1Request);

if (deployAssetReferenceContractResponse == undefined) {
throw new Error(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ export class BesuOdapGateway extends PluginOdapGateway {

if (this.besuApi != undefined) {
const amount = sessionData.assetProfile.keyInformationLink[0].toString();
const userEthAddress = sessionData.assetProfile.keyInformationLink[2].toString();
const userEthAddress =
sessionData.assetProfile.keyInformationLink[2].toString();

const besuCreateRes = await this.besuApi.invokeContractV1({
contractName: this.besuContractName,
Expand Down Expand Up @@ -458,7 +459,8 @@ export class BesuOdapGateway extends PluginOdapGateway {

if (this.besuApi != undefined) {
const amount = sessionData.assetProfile.keyInformationLink[0].toString();
const userEthAddress = sessionData.assetProfile.keyInformationLink[2].toString();
const userEthAddress =
sessionData.assetProfile.keyInformationLink[2].toString();

const assetCreateResponse = await this.besuApi.invokeContractV1({
contractName: this.besuContractName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,10 @@ export class FabricOdapGateway extends PluginOdapGateway {

if (this.fabricApi != undefined) {
const amount = sessionData.assetProfile.keyInformationLink[0].toString();
const fabricClientID = sessionData.assetProfile.keyInformationLink[1].toString();
const userEthAddress = sessionData.assetProfile.keyInformationLink[2].toString();
const fabricClientID =
sessionData.assetProfile.keyInformationLink[1].toString();
const userEthAddress =
sessionData.assetProfile.keyInformationLink[2].toString();

const response = await this.fabricApi.runTransactionV1({
contractName: this.fabricContractName,
Expand All @@ -296,16 +298,15 @@ export class FabricOdapGateway extends PluginOdapGateway {
signingCredential: this.fabricSigningCredential,
} as FabricRunTransactionRequest);

const receiptCreateRes = await this.fabricApi.getTransactionReceiptByTxIDV1(
{
const receiptCreateRes =
await this.fabricApi.getTransactionReceiptByTxIDV1({
signingCredential: this.fabricSigningCredential,
channelName: this.fabricChannelName,
contractName: "qscc",
invocationType: FabricContractInvocationType.Call,
methodName: "GetBlockByTxID",
params: [this.fabricChannelName, response.data.transactionId],
} as FabricRunTransactionRequest,
);
} as FabricRunTransactionRequest);

this.log.warn(receiptCreateRes.data);
fabricCreateAssetProof = JSON.stringify(receiptCreateRes.data);
Expand Down Expand Up @@ -368,16 +369,15 @@ export class FabricOdapGateway extends PluginOdapGateway {
params: [assetId],
} as FabricRunTransactionRequest);

const receiptDeleteRes = await this.fabricApi.getTransactionReceiptByTxIDV1(
{
const receiptDeleteRes =
await this.fabricApi.getTransactionReceiptByTxIDV1({
signingCredential: this.fabricSigningCredential,
channelName: this.fabricChannelName,
contractName: "qscc",
invocationType: FabricContractInvocationType.Call,
methodName: "GetBlockByTxID",
params: [this.fabricChannelName, deleteRes.data.transactionId],
} as FabricRunTransactionRequest,
);
} as FabricRunTransactionRequest);

this.log.warn(receiptDeleteRes.data);
fabricDeleteAssetProof = JSON.stringify(receiptDeleteRes.data);
Expand Down Expand Up @@ -445,7 +445,8 @@ export class FabricOdapGateway extends PluginOdapGateway {

if (this.fabricApi != undefined) {
const amount = sessionData.assetProfile.keyInformationLink[0].toString();
const userEthAddress = sessionData.assetProfile.keyInformationLink[2].toString();
const userEthAddress =
sessionData.assetProfile.keyInformationLink[2].toString();

const response = await this.fabricApi.runTransactionV1({
contractName: this.fabricContractName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export interface IServerHelperOptions {
}

export class ServerHelper extends ServerGatewayHelper {

public static readonly CLASS_NAME: string = "ServerHelper";

constructor(readonly opts: IServerHelperOptions) {
Expand Down Expand Up @@ -120,7 +119,8 @@ export class ServerHelper extends ServerGatewayHelper {

sessionData.clientSignatureInitializationRequestMessage = request.signature;

sessionData.initializationRequestMessageProcessedTimeStamp = Date.now().toString();
sessionData.initializationRequestMessageProcessedTimeStamp =
Date.now().toString();

odap.sessions.set(request.sessionID, sessionData);

Expand Down
Loading

0 comments on commit 1d3968d

Please sign in to comment.