Skip to content

Commit

Permalink
feat: remove unnecessary async in method signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
r-marques committed Oct 4, 2023
1 parent 0c53780 commit 4b4d1e4
Show file tree
Hide file tree
Showing 88 changed files with 325 additions and 356 deletions.
5 changes: 4 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_"
}]
}],
"require-await":"error"
},
"ignorePatterns": ["test/resources/proxy-poc/*.js"]
}

// TODO: check https://dev.to/qpwo/most-useful-eslint-rules-for-networking-code-asyncawaitpromises-1mg4
5 changes: 2 additions & 3 deletions integration/nevermined/Assets.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ describe('Assets', () => {
assert.equal(metadata.attributes.curation.numVotes, 1 + 2)
})

it('new rating must be between 0 and 1', async () => {
it('new rating must be between 0 and 1', () => {
// Trying to add a vote with a rating out of range

nevermined.assets
Expand All @@ -322,7 +322,6 @@ describe('Assets', () => {
console.debug(`It should fail with error: ${err}`)
assert.isDefined(err)
})

})
})

Expand Down Expand Up @@ -596,7 +595,7 @@ describe('Assets', () => {
assert.equal(resolvedDDO._nvm.versions.length, 1)
})

it('dont resolve from the DIDRegistry', async () => {
it('do not resolve from the DIDRegistry', () => {
rejects(nevermined.assets.resolve(offchainDID, DIDResolvePolicy.MetadataAPIFirst))
})
})
Expand Down
2 changes: 1 addition & 1 deletion integration/nevermined/ContractEvent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('ContractEvent', () => {
executeTransaction = () => nevermined.keeper.dispenser.requestTokens(1, account.getId())
})

it('should get a ContractEvent instance', async () => {
it('should get a ContractEvent instance', () => {
assert.instanceOf(nevermined.keeper.token.events, ContractEvent)
})

Expand Down
2 changes: 1 addition & 1 deletion integration/nevermined/MetaTx.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe.skip('MetaTx test with nfts', () => {
await nevermined.keeper.nftUpgradeable.grantOperatorRole(artist.getId(), nftContractOwner)
})

describe('with default token', async () => {
describe('with default token', () => {
before(async () => {
const metadata = getMetadata(Math.random())
metadata.userId = payload.sub
Expand Down
8 changes: 4 additions & 4 deletions integration/nevermined/NFT.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('Nfts operations', () => {
payload = decodeJwt(config.marketplaceAuthToken)
})

describe('with default token', async () => {
describe('with default token', () => {
before(async () => {
const metadata = getMetadata()
metadata.userId = payload.sub
Expand All @@ -47,7 +47,7 @@ describe('Nfts operations', () => {
ddo = await nevermined.nfts1155.create(nftAttributes, artist)
})

it('nft contract address is correct', async () => {
it('nft contract address is correct', () => {
assert.equal(
nevermined.assets.getNftContractAddress(ddo),
nevermined.keeper.nftUpgradeable.address,
Expand Down Expand Up @@ -84,7 +84,7 @@ describe('Nfts operations', () => {
})
})

describe('with custom token', async () => {
describe('with custom token', () => {
before(async () => {
const metadata = getMetadata()
metadata.userId = payload.sub
Expand Down Expand Up @@ -121,7 +121,7 @@ describe('Nfts operations', () => {
})
})

describe('with ether', async () => {
describe('with ether', () => {
before(async () => {
const metadata = getMetadata()
metadata.userId = payload.sub
Expand Down
8 changes: 4 additions & 4 deletions integration/nevermined/NFT721.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { TokenUtils } from '../../src/nevermined'
import { ethers } from 'ethers'
import { ContractHandler, Nft721Contract, TransferNFT721Condition } from '../../src/keeper'

describe('Nfts721 operations', async () => {
describe('Nfts721 operations', () => {
let nevermined: Nevermined
let transferNft721Condition: TransferNFT721Condition

Expand Down Expand Up @@ -64,7 +64,7 @@ describe('Nfts721 operations', async () => {
;({ token } = nevermined.utils)
})

describe('with default token', async () => {
describe('with default token', () => {
before(async () => {
const metadata = getMetadata()
metadata.userId = payload.sub
Expand Down Expand Up @@ -121,7 +121,7 @@ describe('Nfts721 operations', async () => {
})
})

describe('with custom token', async () => {
describe('with custom token', () => {
before(async () => {
const metadata = getMetadata()
metadata.userId = payload.sub
Expand Down Expand Up @@ -166,7 +166,7 @@ describe('Nfts721 operations', async () => {
})
})

describe('with ether', async () => {
describe('with ether', () => {
before(async () => {
const metadata = getMetadata()
metadata.userId = payload.sub
Expand Down
10 changes: 5 additions & 5 deletions integration/nevermined/NFTTemplatesWithEther.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { ZeroAddress, parseEther } from '../../src/utils'
import { getRoyaltyAttributes, RoyaltyAttributes, RoyaltyKind } from '../../src/nevermined'
import { EventLog } from 'ethers'

describe('NFTTemplates With Ether E2E', async () => {
describe('NFTTemplates With Ether E2E', () => {
let artist: Account
let collector1: Account
let collector2: Account
Expand Down Expand Up @@ -124,7 +124,7 @@ describe('NFTTemplates With Ether E2E', async () => {
console.debug(`NETWORK FEE = ${fee}`)
})

describe('Full flow', async () => {
describe('Full flow', () => {
before(async () => {
// initial balances
initialBalances = {
Expand Down Expand Up @@ -182,7 +182,7 @@ describe('NFTTemplates With Ether E2E', async () => {
ddo = await nevermined.nfts1155.create(nftAttributes, artist)
})

describe('As an artist I want to register a new artwork', async () => {
describe('As an artist I want to register a new artwork', () => {
it('I want to register a new artwork and tokenize (via NFT). I want to get 10% royalties', async () => {
await nftUpgradeable.setApprovalForAll(transferNftCondition.address, true, artist)

Expand All @@ -191,7 +191,7 @@ describe('NFTTemplates With Ether E2E', async () => {
})
})

describe('As a collector I want to buy some art', async () => {
describe('As a collector I want to buy some art', () => {
it('I am setting an agreement for buying a NFT', async () => {
conditionIdLockPayment = await lockPaymentCondition.generateIdWithSeed(
agreementId,
Expand Down Expand Up @@ -345,7 +345,7 @@ describe('NFTTemplates With Ether E2E', async () => {
})
})

describe('As an artist I want to give exclusive access to the collectors owning a specific NFT', async () => {
describe('As an artist I want to give exclusive access to the collectors owning a specific NFT', () => {
it('The collector sets up the NFT access agreement', async () => {
// Collector1: Create NFT access agreement
conditionIdNFTHolder = await nftHolderCondition.generateIdWithSeed(
Expand Down
2 changes: 1 addition & 1 deletion integration/nevermined/SecondaryMarket.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ describe('Secondary Markets', () => {
ddo.setNFTRewardsFromService('nft-sales', assetPrice2, collector1.getId())
})

it('As collector1 I create and store an off-chain service agreement', async () => {
it('As collector1 I create and store an off-chain service agreement', () => {
const nftSalesServiceAgreementTemplate = nftSalesTemplate.getServiceAgreementTemplate()
const nftSalesTemplateConditions = nftSalesTemplate.getServiceAgreementTemplateConditions()

Expand Down
4 changes: 2 additions & 2 deletions src/ddo/DDO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ export class DDO {
* @param publicKey - Public key to be used on personal sign.
* @returns Proof object.
*/
public async generateProof(publicKey: string): Promise<Proof> {
public generateProof(publicKey: string): Proof {
const checksum = {}
this.service.forEach((svc) => {
checksum[svc.index] = this.checksum(
Expand Down Expand Up @@ -392,7 +392,7 @@ export class DDO {
* @param seed the seed
* @returns the string represeing the DID seed
*/
public async generateDidSeed(seed) {
public generateDidSeed(seed): string {
return zeroX(this.checksum(JSON.stringify(seed)))
}

Expand Down
4 changes: 2 additions & 2 deletions src/ddo/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -743,9 +743,9 @@ export interface ServicePlugin<T extends Service> {
// Process agreement for provider
process(params: ValidationParams, from: Account, txparams?: TxParameters): Promise<void>
// Check if service can be granted without agreement
accept(params: ValidationParams): Promise<boolean>
accept(params: ValidationParams): boolean
// It registers the usage of a service
track(params: ValidationParams, from: Account, txparams?: TxParameters): Promise<boolean>
track(params: ValidationParams, from: Account, txparams?: TxParameters): boolean
}

export interface ServiceAgreementTemplateParameter {
Expand Down
4 changes: 2 additions & 2 deletions src/events/ContractEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class ContractEvent extends NeverminedEvent {
return instance
}

public async getEventData(options: EventOptions): EventResult {
public getEventData(options: EventOptions): EventResult {
if (!this.eventExists(options.eventName)) {
throw new KeeperError(
`Event "${options.eventName}" not found on contract "${this.contract.contractName}"`,
Expand Down Expand Up @@ -50,7 +50,7 @@ export class ContractEvent extends NeverminedEvent {
}
}

public async getBlockNumber(): Promise<number> {
public getBlockNumber(): Promise<number> {
return this.web3.getBlockNumber()
}

Expand Down
2 changes: 1 addition & 1 deletion src/events/SubgraphEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class SubgraphEvent extends NeverminedEvent {
}
}

public async getPastEvents(options: EventOptions): EventResult {
public getPastEvents(options: EventOptions): EventResult {
return this.getEventData(options)
}

Expand Down
2 changes: 1 addition & 1 deletion src/keeper/Keeper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class Keeper extends Instantiable {
* Returns Keeper instance.
* @returns {@link Keeper}
*/
public static async getInstance(config: InstantiableConfig): Promise<Keeper> {
public static getInstance(config: InstantiableConfig): Keeper {
const keeper = new Keeper()
keeper.setInstanceConfig(config)
return keeper
Expand Down
Loading

0 comments on commit 4b4d1e4

Please sign in to comment.