Skip to content

Commit

Permalink
Merge branch 'main' into fix/subscription-operator-setup
Browse files Browse the repository at this point in the history
  • Loading branch information
aaitor authored Sep 14, 2023
2 parents 4d2918a + a19adbd commit 90fa497
Show file tree
Hide file tree
Showing 9 changed files with 2,552 additions and 177 deletions.
1,238 changes: 1,113 additions & 125 deletions .openzeppelin/polygon-mumbai.json

Large diffs are not rendered by default.

1,422 changes: 1,400 additions & 22 deletions .openzeppelin/unknown-80001.json.public

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [v3.3.0](https://github.com/nevermined-io/contracts/compare/v3.2.4...v3.3.0)

> 18 August 2023
- fix: expiration block is not part of the hash values [`#497`](https://github.com/nevermined-io/contracts/pull/497)
- committing deploy [`#496`](https://github.com/nevermined-io/contracts/pull/496)
- fix: resolving problem with wrong nft type [`#494`](https://github.com/nevermined-io/contracts/pull/494)
- test: fixing integration tests [`7ffed44`](https://github.com/nevermined-io/contracts/commit/7ffed44a0c143b4ccd89580a44b49f3ff43a1b07)
- test: fixing test [`94fe23e`](https://github.com/nevermined-io/contracts/commit/94fe23ef889491e72b03b0f949b76e19a1c0d782)
- fix: adding expirationBlock to fulfillForDeleaget on Transfer cond. [`7b77052`](https://github.com/nevermined-io/contracts/commit/7b770523b33f66f4ec2d9282f568f3e03faf7144)

#### [v3.2.4](https://github.com/nevermined-io/contracts/compare/v3.2.3...v3.2.4)

> 11 August 2023
Expand Down
23 changes: 9 additions & 14 deletions contracts/conditions/NFTs/TransferNFTCondition.sol
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ contract TransferNFTCondition is Condition, ITransferNFT, ReentrancyGuardUpgrade
view
returns (bytes32)
{
return hashValues(_did, _nftHolder, _nftReceiver, _nftAmount, _lockCondition, address(erc1155), true, 0);
return hashValues(_did, _nftHolder, _nftReceiver, _nftAmount, _lockCondition, address(erc1155), true);
}

/**
Expand All @@ -143,7 +143,6 @@ contract TransferNFTCondition is Condition, ITransferNFT, ReentrancyGuardUpgrade
* @param _lockCondition lock condition identifier
* @param _nftContractAddress NFT contract to use
* @param _transfer Indicates if the NFT will be transferred (true) or minted (false)
* @param _expirationBlock Block in which the token expires. If zero means no expiration
* @return bytes32 hash of all these values
*/
function hashValues(
Expand All @@ -153,14 +152,13 @@ contract TransferNFTCondition is Condition, ITransferNFT, ReentrancyGuardUpgrade
uint256 _nftAmount,
bytes32 _lockCondition,
address _nftContractAddress,
bool _transfer,
uint256 _expirationBlock
bool _transfer
)
public
pure
returns (bytes32)
{
return keccak256(abi.encode(_did, _nftHolder, _nftReceiver, _nftAmount, _lockCondition, _nftContractAddress, _transfer, _expirationBlock));
return keccak256(abi.encode(_did, _nftHolder, _nftReceiver, _nftAmount, _lockCondition, _nftContractAddress, _transfer));
}

function fulfill(
Expand All @@ -185,8 +183,7 @@ contract TransferNFTCondition is Condition, ITransferNFT, ReentrancyGuardUpgrade
* @param _nftAmount amount of NFTs to transfer
* @param _lockPaymentCondition lock payment condition identifier
* @param _nftContractAddress the NFT contract to use
* @param _transfer if yes it does a transfer if false it mints the NFT
* @param _expirationBlock Block in which the token expires. If zero means no expiration
* @param _transfer if yes it does a transfer if false it mints the NFT
* @return the encoded parameters
*/
function encodeParams(
Expand All @@ -196,10 +193,9 @@ contract TransferNFTCondition is Condition, ITransferNFT, ReentrancyGuardUpgrade
uint256 _nftAmount,
bytes32 _lockPaymentCondition,
address _nftContractAddress,
bool _transfer,
uint256 _expirationBlock
bool _transfer
) external pure returns (bytes memory) {
return abi.encode(_did, _nftHolder, _nftReceiver, _nftAmount, _lockPaymentCondition, _nftContractAddress, _transfer, _expirationBlock);
return abi.encode(_did, _nftHolder, _nftReceiver, _nftAmount, _lockPaymentCondition, _nftContractAddress, _transfer);
}

/**
Expand All @@ -226,11 +222,10 @@ contract TransferNFTCondition is Condition, ITransferNFT, ReentrancyGuardUpgrade
bytes32 _lockPaymentCondition;
address _nftContractAddress;
bool _transfer;
uint256 _expirationBlock;
(_did, _nftHolder, _nftReceiver, _nftAmount, _lockPaymentCondition, _nftContractAddress, _transfer, _expirationBlock) = abi.decode(_params, (bytes32, address, address, uint256, bytes32, address, bool, uint256));
(_did, _nftHolder, _nftReceiver, _nftAmount, _lockPaymentCondition, _nftContractAddress, _transfer) = abi.decode(_params, (bytes32, address, address, uint256, bytes32, address, bool));

require(hasRole(PROXY_ROLE, _msgSender()), 'Proxy role required');
fulfillInternal(_account, _agreementId, _did, _nftReceiver, _nftAmount, _lockPaymentCondition, _nftContractAddress, _transfer, _expirationBlock);
fulfillInternal(_account, _agreementId, _did, _nftReceiver, _nftAmount, _lockPaymentCondition, _nftContractAddress, _transfer, 0);
}

/**
Expand Down Expand Up @@ -311,7 +306,7 @@ contract TransferNFTCondition is Condition, ITransferNFT, ReentrancyGuardUpgrade
{
bytes32 _id = generateId(
_agreementId,
hashValues(_did, _account, _nftReceiver, _nftAmount, _lockPaymentCondition, _nftContractAddress, _transfer, _expirationBlock)
hashValues(_did, _account, _nftReceiver, _nftAmount, _lockPaymentCondition, _nftContractAddress, _transfer)
);

require(
Expand Down
1 change: 1 addition & 0 deletions contracts/token/erc1155/NFT1155SubscriptionUpgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ contract NFT1155SubscriptionUpgradeable is NFT1155Upgradeable {
* @dev See {NFT1155Upgradeableable-balanceOf}.
*/
function balanceOf(address account, uint256 tokenId) public view virtual override returns (uint256) {

bytes32 _key = _getTokenKey(account, tokenId);
uint256 _balance;
for (uint index = 0; index < _tokens[_key].length; index++) {
Expand Down
6 changes: 3 additions & 3 deletions test/int/nft/NFTSalesWithAccessProofAgreement.Test.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ contract('NFT Sales with Access Proof Template integration test', (accounts) =>
const conditionIdLockPayment = await lockPaymentCondition.hashValues(did, escrowCondition.address, token.address, amounts, receivers)
const fullIdLockPayment = await lockPaymentCondition.generateId(agreementId, conditionIdLockPayment)

const conditionIdTransferNFT = await transferCondition.hashValues(
did, artist, receiver, numberNFTs, fullIdLockPayment, nft.address, true, 0
)
const conditionIdTransferNFT = await transferCondition.methods['hashValues(bytes32,address,address,uint256,bytes32,address,bool)'](
did, artist, receiver, numberNFTs, fullIdLockPayment, nft.address, true)

const fullIdTransferNFT = await transferCondition.generateId(agreementId, conditionIdTransferNFT)

const conditionIdAccess = await accessProofCondition.hashValues(origHash, buyerPub, providerPub)
Expand Down
3 changes: 2 additions & 1 deletion test/int/nft/NFTWithEther_e2e.Test.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ contract('End to End NFT Scenarios (with Ether)', (accounts) => {
const agreementId = await agreementStoreManager.agreementId(initAgreementId, _from)
const conditionIdLockPayment = await lockPaymentCondition.hashValues(did, escrowCondition.address, constants.address.zero, _amounts.map(a => String(a)), _receivers)
const fullIdLockPayment = await lockPaymentCondition.generateId(agreementId, conditionIdLockPayment)
const conditionIdTransferNFT = await transferCondition.hashValues(did, _seller, _buyer, _numberNFTs, fullIdLockPayment, nft.address, true, 0)
const conditionIdTransferNFT = await transferCondition.methods['hashValues(bytes32,address,address,uint256,bytes32,address,bool)'](
did, _seller, _buyer, _numberNFTs, fullIdLockPayment, nft.address, true)
const fullIdTransferNFT = await transferCondition.generateId(agreementId, conditionIdTransferNFT)

const conditionIdEscrow = await escrowCondition.hashValues(did, _amounts.map(a => String(a)), _receivers, _buyer, escrowCondition.address, constants.address.zero, fullIdLockPayment, fullIdTransferNFT)
Expand Down
5 changes: 3 additions & 2 deletions test/int/nft/NFT_e2e.Test.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,15 @@ contract('End to End NFT Scenarios', (accounts) => {
const agreementId = await agreementStoreManager.agreementId(initAgreementId, _from)
const conditionIdLockPayment = await lockPaymentCondition.hashValues(did, escrowCondition.address, token.address, _amounts, _receivers)
const fullIdLockPayment = await lockPaymentCondition.generateId(agreementId, conditionIdLockPayment)
const conditionIdTransferNFT = await transferCondition.hashValues(did, _seller, _buyer, _numberNFTs, fullIdLockPayment, nft.address, true, 0)
const conditionIdTransferNFT = await transferCondition.methods['hashValues(bytes32,address,address,uint256,bytes32,address,bool)'](
did, _seller, _buyer, _numberNFTs, fullIdLockPayment, nft.address, true)
const fullIdTransferNFT = await transferCondition.generateId(agreementId, conditionIdTransferNFT)

const conditionIdEscrow = await escrowCondition.hashValues(did, _amounts, _receivers, _buyer, escrowCondition.address, token.address, fullIdLockPayment, fullIdTransferNFT)
const fullIdEscrow = await escrowCondition.generateId(agreementId, conditionIdEscrow)

const lockParams = await lockPaymentCondition.encodeParams(did, escrowCondition.address, token.address, _amounts, _receivers)
const transferParams = await transferCondition.encodeParams(did, _seller, _buyer, _numberNFTs, fullIdLockPayment, nft.address, true, 0)
const transferParams = await transferCondition.encodeParams(did, _seller, _buyer, _numberNFTs, fullIdLockPayment, nft.address, true)
const escrowParams = await escrowCondition.encodeParams(did, _amounts, _receivers, _buyer, escrowCondition.address, token.address, fullIdLockPayment, [fullIdTransferNFT])

const nftSalesAgreement = {
Expand Down
20 changes: 10 additions & 10 deletions test/unit/conditions/TransferNFTCondition.Test.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ contract('TransferNFT Condition', (accounts) => {
(await conditionStoreManager.getConditionState(conditionIdPayment)).toNumber(),
constants.condition.state.fulfilled)

const hashValues = await transferCondition.methods['hashValues(bytes32,address,address,uint256,bytes32,address,bool,uint256)'](
did, seller, rewardAddress, numberNFTs, conditionIdPayment, nft.address, true, 0)
const hashValues = await transferCondition.methods['hashValues(bytes32,address,address,uint256,bytes32,address,bool)'](
did, seller, rewardAddress, numberNFTs, conditionIdPayment, nft.address, true)

const conditionId = await transferCondition.generateId(agreementId, hashValues)

Expand Down Expand Up @@ -301,8 +301,8 @@ contract('TransferNFT Condition', (accounts) => {
(await conditionStoreManager.getConditionState(conditionIdPayment)).toNumber(),
constants.condition.state.fulfilled)

const hashValues = await transferCondition.methods['hashValues(bytes32,address,address,uint256,bytes32,address,bool,uint256)'](
did, seller, rewardAddress, numberNFTs, conditionIdPayment, nft.address, false, expiration
const hashValues = await transferCondition.methods['hashValues(bytes32,address,address,uint256,bytes32,address,bool)'](
did, seller, rewardAddress, numberNFTs, conditionIdPayment, nft.address, false
)

const conditionId = await transferCondition.generateId(agreementId, hashValues)
Expand Down Expand Up @@ -363,8 +363,8 @@ contract('TransferNFT Condition', (accounts) => {
(await conditionStoreManager.getConditionState(conditionIdPayment)).toNumber(),
constants.condition.state.fulfilled)

const hashValues = await transferCondition.methods['hashValues(bytes32,address,address,uint256,bytes32,address,bool,uint256)'](
did, other, rewardAddress, numberNFTs, conditionIdPayment, nft.address, true, 0)
const hashValues = await transferCondition.methods['hashValues(bytes32,address,address,uint256,bytes32,address,bool)'](
did, other, rewardAddress, numberNFTs, conditionIdPayment, nft.address, true)

const conditionId = await transferCondition.generateId(agreementId, hashValues)

Expand Down Expand Up @@ -417,8 +417,8 @@ contract('TransferNFT Condition', (accounts) => {
(await conditionStoreManager.getConditionState(conditionIdPayment)).toNumber(),
constants.condition.state.fulfilled)

const hashValues = await transferCondition.methods['hashValues(bytes32,address,address,uint256,bytes32,address,bool,uint256)'](
did, seller, rewardAddress, numberNFTs, conditionIdPayment, nft.address, true, 0)
const hashValues = await transferCondition.methods['hashValues(bytes32,address,address,uint256,bytes32,address,bool)'](
did, seller, rewardAddress, numberNFTs, conditionIdPayment, nft.address, true)

const conditionId = await transferCondition.generateId(agreementId, hashValues)

Expand Down Expand Up @@ -478,8 +478,8 @@ contract('TransferNFT Condition', (accounts) => {
(await conditionStoreManager.getConditionState(conditionIdPayment)).toNumber(),
constants.condition.state.fulfilled)

const hashValues = await transferCondition.methods['hashValues(bytes32,address,address,uint256,bytes32,address,bool,uint256)'](
did, seller, rewardAddress, numberNFTs, conditionIdPayment, nft.address, true, 0)
const hashValues = await transferCondition.methods['hashValues(bytes32,address,address,uint256,bytes32,address,bool)'](
did, seller, rewardAddress, numberNFTs, conditionIdPayment, nft.address, true)

const conditionId = await transferCondition.generateId(agreementId, hashValues)

Expand Down

0 comments on commit 90fa497

Please sign in to comment.