Skip to content

Commit

Permalink
metatx works locally
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsmkl committed Jan 17, 2023
1 parent 0e90a3e commit 56bf183
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
4 changes: 4 additions & 0 deletions contracts/registry/DIDRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import '../token/erc1155/NFT1155Upgradeable.sol';
import '../token/erc721/NFT721Upgradeable.sol';
import '../royalties/StandardRoyalties.sol';

import 'hardhat/console.sol';

/**
* @title DID Registry
* @author Nevermined
Expand Down Expand Up @@ -207,6 +209,8 @@ contract DIDRegistry is DIDFactory {
public
onlyValidAttributes(_nftMetadata)
{
console.log("what happen");
console.log(_msgSender());
registerDID(_didSeed, _checksum, _providers, _url, _activityId, _immutableUrl);
enableAndMintDidNft(
hashDID(_didSeed, _msgSender()),
Expand Down
6 changes: 5 additions & 1 deletion contracts/registry/DIDRegistryLibrary.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.0;
// Code is Apache-2.0 and docs are CC-BY-4.0

import '../interfaces/IRoyaltyScheme.sol';

import 'hardhat/console.sol';
/**
* @title DID Registry Library
* @author Nevermined
Expand Down Expand Up @@ -81,6 +81,10 @@ library DIDRegistryLibrary {
}

_self.didRegisters[_did].owner = didOwner;
console.log("DID");
console.log(uint256(_did));
console.log("owner");
console.log(didOwner);
_self.didRegisters[_did].creator = creator;
_self.didRegisters[_did].lastChecksum = _checksum;
_self.didRegisters[_did].url = _url;
Expand Down
17 changes: 6 additions & 11 deletions test/OpenGSN.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ describe('using ethers with OpenGSN', () => {
[owner, constants.address.zero, constants.address.zero, nvmConfig.address, constants.address.zero]
)
nft = await deployContract('NFT1155Upgradeable', deployer, {}, [owner, didRegistry.address, '', '', ''])
nft.connect(await deploymentProvider.getSigner(owner)).setNvmConfigAddress(nvmConfig.address)

const config = await {
paymasterAddress: paymasterAddress,
Expand Down Expand Up @@ -79,35 +80,29 @@ describe('using ethers with OpenGSN', () => {
console.log('Registering DID')

await didRegistry['registerMintableDID(bytes32,address,bytes32,address[],string,uint256,uint256,bytes32,string,string)'](
didSeed, nft.address, checksum, [], value, 20, 0, constants.activities.GENERATED, nftMetadataURL, '', { from: account })

didSeed, nft.address, checksum, [], value, 20, 0, constants.activities.GENERATED, nftMetadataURL, '', { from: account, gasLimit: 5000000 })
const didEntry = await didRegistry.getDIDRegister(did)
console.log(`DID Owner ${didEntry.owner}`)

assert.strictEqual(account, didEntry.owner)

const nftAttr = await nft.getNFTAttributes(did)
assert.strictEqual(nftMetadataURL, nftAttr.nftURI)

/*
// TODO: Review error:
// paymaster rejected in local view call to 'relayCall()' : invalid forwarder for recipient
console.log(`Minting`)
await nft['mint(uint256,uint256)'](did, 20, { from: account })
await nft['mint(uint256,uint256)'](did, 20, { from: account, gasLimit: 1000000 })

console.log(`Balance`)
let balance = await nft.balanceOf(account, did)
assert.strictEqual(20, balance.toNumber())

console.log(`Burn`)
await nft['burn(uint256,uint256)'](did, 5, { from: account })
await nft['burn(uint256,uint256)'](did, 5, { from: account, gasLimit: 1000000 })

balance = await nft.balanceOf(account, did)
assert.strictEqual(15, balance.toNumber())

const _nftURI = await nft.uri(did)
assert.strictEqual(nftMetadataURL, _nftURI) */
assert.strictEqual(nftMetadataURL, _nftURI)
})
})
})

0 comments on commit 56bf183

Please sign in to comment.