Skip to content

Commit

Permalink
ci: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aaitor committed Jun 5, 2024
1 parent 7380c80 commit 0ca1201
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 22 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"ncli": "./dist/src/index.js"
},
"dependencies": {
"@nevermined-io/sdk": "3.0.9",
"@nevermined-io/sdk": "3.0.11",
"log4js": "^6.9.1",
"chalk": "^4.1.2",
"cross-fetch": "~3.1.5",
Expand Down
2 changes: 1 addition & 1 deletion resources/networks.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
"appBase": {
"envDescription": "The Base production environment where users can interact with Nevermined protocol.",
"envUrl": "https://base.nevermined.app/",
"envName": "base",
"envName": "Base",
"isProduction": true,
"nvm": {
"chainId": 8453,
Expand Down
1 change: 1 addition & 0 deletions src/commands/agreements/showAgreement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const showAgreement = async (
agreementId
)

logger.debug(chalk.dim(`Agreement Data: ${JSON.stringify(agreementData)}`))
const { accessConsumer, accessProvider } =
await nvmApp.sdk.keeper.templates.accessTemplate.getAgreementData(agreementId)

Expand Down
11 changes: 10 additions & 1 deletion src/commands/nfts/claimNft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ export const claimNft = async (
)
)

if (agreementData.conditionIds.length === 0) {
logger.error(`Unable to load Agreement with Id ${agreementId}: No conditions found`)
return {
status: StatusCodes.ERROR,
errorMessage: `Unable to load Agreement with Id ${agreementId}: No conditions found`
}
}

await nvmApp.sdk.keeper.conditionStoreManager.getCondition(
agreementData.conditionIds[0]
)
Expand Down Expand Up @@ -113,7 +121,8 @@ export const claimNft = async (
agreementId,
sellerAddress,
buyerAddress,
argv.amount
argv.amount,
ddo.id
)
}

Expand Down
42 changes: 25 additions & 17 deletions src/commands/nfts/mintNft.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NvmAccount, NvmApp, zeroX } from '@nevermined-io/sdk'
import { NvmAccount, NvmApp, isValidAddress, zeroX } from '@nevermined-io/sdk'
import {
StatusCodes,
printNftTokenBanner,
Expand All @@ -8,7 +8,6 @@ import { ExecutionOutput } from '../../models/ExecutionOutput'
import chalk from 'chalk'
import { Logger } from 'log4js'
import { ConfigEntry } from '../../models/ConfigDefinition'
import { FunctionFragment, ethers } from 'ethers'

export const mintNft = async (
nvmApp: NvmApp,
Expand Down Expand Up @@ -43,7 +42,7 @@ export const mintNft = async (
)

let receiver
if (ethers.isAddress(argv.receiver)) receiver = argv.receiver
if (isValidAddress(argv.receiver)) receiver = argv.receiver
else receiver = minterAccount.getId()

if (nftType === 721) {
Expand All @@ -56,23 +55,32 @@ export const mintNft = async (
await printNftTokenBanner(nft.getContract)
}

// We check the number of parameters expected by the mint function to adapt the parameters
const mintAbiDefinition = nft.nftContract.contract.interface.fragments
.filter((item: FunctionFragment) => item.name === 'mint')
.map((entry: { inputs: any }) => entry.inputs)

if (mintAbiDefinition.length == 3) {
logger.debug(`Minting using the To address + tokenId + tokenURI`)
await nft.mintWithURL(
receiver,
zeroX(ddo.shortId()),
uri || register.url,
minterAccount
)

if (uri && uri.length > 0) {
logger.debug(`Minting using uri: ${uri}`)
await nft.mintWithURL(receiver, zeroX(ddo.shortId()), uri, minterAccount)
} else {
logger.debug(`Minting using the tokenId`)
await nft.mint(zeroX(ddo.shortId()), minterAccount)
}

// getInputsOfFunctionFormatted(viemAbi, 'approve')
// We check the number of parameters expected by the mint function to adapt the parameters
// const mintAbiDefinition = nft.nftContract.contract.interface.fragments
// .filter((item: FunctionFragment) => item.name === 'mint')
// .map((entry: { inputs: any }) => entry.inputs)

// if (mintAbiDefinition.length == 3) {
// logger.debug(`Minting using the To address + tokenId + tokenURI`)
// await nft.mintWithURL(
// receiver,
// zeroX(ddo.shortId()),
// uri || register.url,
// minterAccount
// )
// } else {
// logger.debug(`Minting using the tokenId`)
// await nft.mint(zeroX(ddo.shortId()), minterAccount)
// }

logger.info(
chalk.dim(
Expand Down
3 changes: 1 addition & 2 deletions test/integration/NFTs721.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ describe('NFTs (ERC-721) e2e Testing', () => {
let did = ''
let orderAgreementId = ''
let nftAddress = ''
const metadataUri = 'http://nevermined.io/xxx'

beforeAll(async () => {
try {
Expand Down Expand Up @@ -77,7 +76,7 @@ describe('NFTs (ERC-721) e2e Testing', () => {
})

test('It mints a NFT (ERC-721)', async () => {
const mintCommand = `${baseCommands.nfts721.mint} "${did}" --nftAddress ${nftAddress} --uri ${metadataUri} --accountIndex 0 `
const mintCommand = `${baseCommands.nfts721.mint} "${did}" --nftAddress ${nftAddress} --accountIndex 0 `
console.debug(`COMMAND: ${mintCommand}`)

const stdout = execCommand(mintCommand, execOpts)
Expand Down

0 comments on commit 0ca1201

Please sign in to comment.