Skip to content

Commit

Permalink
fix: nfts1155 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eruizgar91 committed Apr 11, 2024
1 parent 560cc02 commit 4fe860a
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 46 deletions.
4 changes: 0 additions & 4 deletions config/nevermined.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ configBase.accounts = []
if (process.env.PROVIDER_KEYFILE) {
const str = fs.readFileSync(process.env.PROVIDER_KEYFILE).toString()
configBase.accounts = [ethers.Wallet.fromEncryptedJsonSync(str, process.env.PROVIDER_PASSWORD)]
// const ethersWallet = [ethers.Wallet.fromEncryptedJsonSync(str, process.env.PROVIDER_PASSWORD)]
// ethersWallet.map((wallet) => {
// configBase.accounts.push(NvmAccount.fromAccount(privateKeyToAccount(wallet.privateKey)))
// })
}

const config = configBase
Expand Down
56 changes: 30 additions & 26 deletions integration/subscriptions.integration.spec.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,39 @@
import request from 'supertest'
import { INestApplication } from '@nestjs/common'
import { Reflector } from '@nestjs/core'
import { JwtModule } from '@nestjs/jwt'
import { PassportModule } from '@nestjs/passport'
import { Test, TestingModule } from '@nestjs/testing'
import { ConfigModule } from '../src/shared/config/config.module'
import { NeverminedModule } from '../src/shared/nevermined/nvm.module'
import { SubscriptionsController } from '../src/subscriptions/subscriptions.controller'
import { SubscriptionsService } from '../src/subscriptions/subscriptions.service'
import {
AssetAttributes,
ContractHandler,
DDO,
didPrefixed,
generateId,
Nevermined,
NFTAttributes,
Nevermined,
NvmAccount,
NvmAppMetadata,
SubscriptionCreditsNFTApi,
SubscriptionNFTApi,
didPrefixed,
generateId,
} from '@nevermined-io/sdk'
import * as jose from 'jose'
import request from 'supertest'
import { AuthService } from '../src/auth/auth.service.mock'
import { JwtAuthGuard } from '../src/common/guards/auth/jwt-auth.guard'
import { Reflector } from '@nestjs/core'
import { JwtStrategy } from '../src/common/strategies/jwt.strategy'
import { AuthService } from '../src/auth/auth.service.mock'
import { PassportModule } from '@nestjs/passport'
import { JwtModule } from '@nestjs/jwt'
import * as jose from 'jose'
import { ConfigModule } from '../src/shared/config/config.module'
import { NeverminedModule } from '../src/shared/nevermined/nvm.module'
import { SubscriptionsController } from '../src/subscriptions/subscriptions.controller'
import { SubscriptionsService } from '../src/subscriptions/subscriptions.service'

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import { config } from './config'
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import { getMetadata } from './utils'
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import NFT721SubscriptionUpgradeableABI from './resources/NFT721SubscriptionUpgradeable.json'
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import NFT1155SubscriptionUpgradeableABI from './resources/NFT1155SubscriptionUpgradeable.json'
import { NeverminedService } from '../src/shared/nevermined/nvm.service'
import { ConfigService } from '../src/shared/config/config.service'
import { NeverminedService } from '../src/shared/nevermined/nvm.service'
import { getMetadata } from './utils'

describe('SubscriptionsController', () => {
let app: INestApplication
Expand Down Expand Up @@ -193,10 +188,13 @@ describe('SubscriptionsController', () => {
subscriberAddress = subscriber.getId()
ownerAddress = publisher.getId()

// deploy contract
const contractABI = await ContractHandler.getABIArtifact(
'NFT721SubscriptionUpgradeable',
'./integration/resources/',
)
const subscriptionNFT = await SubscriptionNFTApi.deployInstance(
config,
NFT721SubscriptionUpgradeableABI,
contractABI,
publisher,
[
publisher.getId(),
Expand All @@ -205,8 +203,10 @@ describe('SubscriptionsController', () => {
'',
'',
0,
nevermined.keeper.nvmConfig.address,
],
)

await nevermined.contracts.loadNft721Api(subscriptionNFT)
await subscriptionNFT.grantOperatorRole(
nevermined.keeper.conditions.transferNft721Condition.address,
Expand Down Expand Up @@ -383,20 +383,24 @@ describe('SubscriptionsController', () => {
subscriberAddress = subscriber.getId()
ownerAddress = publisher.getId()

// deploy contract
const contractABI = await ContractHandler.getABIArtifact(
'NFT1155SubscriptionUpgradeable',
'./integration/resources/',
)
const subscriptionNFT = await SubscriptionCreditsNFTApi.deployInstance(
config,
NFT1155SubscriptionUpgradeableABI,
contractABI,
publisher,
[
publisher.getId(),
nevermined.keeper.didRegistry.address,
'Credits NFT',
'Credits Subscription NFT',
'CRED',
'',
nevermined.keeper.nvmConfig.address,
],
)

await nevermined.contracts.loadNft1155Api(subscriptionNFT)
await subscriptionNFT.grantOperatorRole(
nevermined.keeper.conditions.transferNftCondition.address,
Expand Down
5 changes: 0 additions & 5 deletions src/access/access.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,6 @@ export class AccessController {
const agreementData = await nevermined.keeper.agreementStoreManager.getAgreement(
transferData.agreementId,
)
// const templateId: string = await nevermined.keeper.agreementStoreManager.call(
// 'getAgreementTemplate',
// [zeroX(transferData.agreementId)],
// )
if (agreementData.templateId.toLowerCase() === ZeroAddress) {
throw new NotFoundException(`Agreement ${transferData.agreementId} not found on-chain`)
}
Expand Down Expand Up @@ -233,7 +229,6 @@ export class AccessController {
`[${did.getDid()}] Fulfilling transfer NFT with agreement ${transferData.agreementId}`,
)

//await plugin.process(params, from, { zeroDevSigner: this.nvmService.zerodevSigner })
await plugin.process(params, this.nvmService.nodeAccount)
Logger.debug(`NFT Transferred to ${transferData.nftReceiver}`)
} catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const bootstrap = async () => {

SwaggerModule.setup('api/v1/docs', app, document)

await app.listen(PORT || 3000)
await app.listen(PORT || 8030)
Logger.log({
message: `server version ${packageJson.version} started!`,
port: PORT,
Expand Down
2 changes: 1 addition & 1 deletion src/shared/config/config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const DOTENV_SCHEMA = Joi.object({
// Used to calculate expiry time of subscriptions in milliseconds
NETWORK_AVERAGE_BLOCK_TIME: Joi.number().default(2100),
server: Joi.object({
port: Joi.number().default(3000),
port: Joi.number().default(8030),
}),
security: Joi.object({
enableHttpsRedirect: Joi.bool().default(false),
Expand Down
4 changes: 2 additions & 2 deletions src/shared/nevermined/nvm.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ export class NeverminedService {
this.nodeAccount = await NvmAccount.fromZeroDevSigner(this.zerodevSigner)
this.providerAddress = this.zerodevSigner.address
} else {
const provider = await accountFromCredentialsData(
this.nodeAccount = await accountFromCredentialsData(
this.config.cryptoConfig().provider_key as string,
this.config.cryptoConfig().provider_password as string,
)
this.providerAddress = provider.getAccountSigner()
this.providerAddress = this.nodeAccount.getId()
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/subscriptions/subscriptions.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export class SubscriptionsService {
)

Logger.debug(
`DIDRegistry: ${await this.nvmService.nevermined.keeper.didRegistry.contract.getAddress()}`,
`DIDRegistry: ${await this.nvmService.nevermined.keeper.didRegistry.contract.address}`,
)

// get the owner of the DID
Expand Down
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1803,9 +1803,9 @@
"@types/estree" "*"

"@types/eslint@*":
version "8.56.7"
resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-8.56.7.tgz#c33b5b5a9cfb66881beb7b5be6c34aa3e81d3366"
integrity sha512-SjDvI/x3zsZnOkYZ3lCt9lOZWZLB2jIlNKz+LBgCtDurK0JZcwucxYHn1w2BJkD34dgX9Tjnak0txtq4WTggEA==
version "8.56.8"
resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-8.56.8.tgz#e927fdc742a98fc3195a9d047631e6ab95029b50"
integrity sha512-LdDdQVDzDXf3ijhhMnE27C5vc0QEknD8GiMR/Hi+fVbdZNfAfCy2j69m0LjUd2MAy0+kIgnOtd5ndTmDk/VWCA==
dependencies:
"@types/estree" "*"
"@types/json-schema" "*"
Expand Down Expand Up @@ -8648,9 +8648,9 @@ [email protected]:
integrity sha512-jQG0cRgJNMZ7aCoiFofnoojeSaa/+KgWaDlfgs8QN+BXoGMpxeMVY5OEnjq4OlNvF3yjftO8c9GRAgcHlO+u7A==

swagger-ui-dist@>=5.0.0:
version "5.15.0"
resolved "https://registry.yarnpkg.com/swagger-ui-dist/-/swagger-ui-dist-5.15.0.tgz#b67856839d4cb8a31d7b0dc8792a9ee3d1123042"
integrity sha512-1zd4cNaUayXCWFSdBGNB+CYGISbe7M4FSgPqOjrgqKi1oEZfXzrOrjIHa0jHf5uSDN0X/mXmhFgKR9Jrr+fvqQ==
version "5.15.1"
resolved "https://registry.yarnpkg.com/swagger-ui-dist/-/swagger-ui-dist-5.15.1.tgz#99fbb54c01feb6635e218fa12061f0edae634a00"
integrity sha512-Et/WY0NFdKj8sUBOyEx5P3VybsvGl7bo/y9JvgQ22TkH1a/KscQ0ZiQST2YeJ3cwCrIjYTbHbt165fkku0y1Ig==

swagger-ui-express@^5.0.0:
version "5.0.0"
Expand Down

0 comments on commit 4fe860a

Please sign in to comment.