Skip to content

Commit

Permalink
Merge pull request #549 from nevermined-io/feat/burn_batch
Browse files Browse the repository at this point in the history
feat: adding burnBatchFromHolders
  • Loading branch information
aaitor authored Nov 15, 2024
2 parents dbc50d5 + d0877b0 commit c41b20d
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 3 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ 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.5.9](https://github.com/nevermined-io/contracts/compare/v3.5.7...v3.5.9)

> 15 November 2024
- Deployment v3.5.7 in all environments [`#546`](https://github.com/nevermined-io/contracts/pull/546)
- fix: gas optimization branch [`#543`](https://github.com/nevermined-io/contracts/pull/543)
- feat: peaq mainnet config [`#545`](https://github.com/nevermined-io/contracts/pull/545)
- feat: deployment on Peaq Agung [`#544`](https://github.com/nevermined-io/contracts/pull/544)
- feat: deployments [`ff1c8f5`](https://github.com/nevermined-io/contracts/commit/ff1c8f58bd30c22efcc2ebfd5a110d523322d9de)
- chore: deployment (v3.5.7) of arbitrum one and sepolia networks [`ecb1953`](https://github.com/nevermined-io/contracts/commit/ecb1953f5e21598219b13e8258ef7eacd8cbe12e)
- feat: optimism deployment [`a75f332`](https://github.com/nevermined-io/contracts/commit/a75f3322b999bfd9babdfad6a5168d85690a5517)

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

> 11 March 2024
Expand Down
12 changes: 12 additions & 0 deletions contracts/token/erc1155/NFT1155SubscriptionUpgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,16 @@ contract NFT1155SubscriptionUpgradeable is NFT1155Upgradeable {
burn(from, ids[i], amounts[i], i);
}
}

function burnBatchFromHolders(
address[] memory from,
uint256[] memory ids,
uint256[] memory amounts
) external {
require(ids.length == amounts.length, 'burnBatch: lengths do not match');
require(ids.length == from.length, 'burnBatch: lengths do not match');
for (uint i = 0; i < ids.length; i++) {
burn(from[i], ids[i], amounts[i]);
}
}
}
12 changes: 12 additions & 0 deletions contracts/token/erc1155/NFT1155SubscriptionWithoutBlocks.sol
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,16 @@ contract NFT1155SubscriptionWithoutBlocks is NFT1155Upgradeable {
burn(from, ids[i], amounts[i]);
}
}

function burnBatchFromHolders(
address[] memory from,
uint256[] memory ids,
uint256[] memory amounts
) external {
require(ids.length == amounts.length, 'burnBatch: lengths do not match');
require(ids.length == from.length, 'burnBatch: lengths do not match');
for (uint i = 0; i < ids.length; i++) {
burn(from[i], ids[i], amounts[i]);
}
}
}
2 changes: 1 addition & 1 deletion hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module.exports = {
settings: {
optimizer: {
enabled: true,
runs: 10
runs: 10000
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nevermined-io/contracts",
"version": "3.5.8",
"version": "3.5.9",
"description": "Nevermined implementation of Nevermined in Solidity",
"bugs": {
"url": "https://github.com/nevermined-io/contracts/issues"
Expand Down
2 changes: 1 addition & 1 deletion test/unit/token/NFT1155SubscriptionWithoutBlocks.Test.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ contract('NFT1155 Subscription', (accounts) => {
assert.strictEqual(balances[0], 23)
assert.strictEqual(balances[1], 15)

await nft.burnBatch(account2, [tokenId3, tokenId4], [22, 14], { from: minter })
await nft.burnBatchFromHolders([account2, account2], [tokenId3, tokenId4], [22, 14], { from: minter })
balance = new BigNumber(await nft.balanceOf(account2, tokenId3))
balance2 = new BigNumber(await nft.balanceOf(account2, tokenId4))
assert.strictEqual(balance.toNumber(), 1)
Expand Down

0 comments on commit c41b20d

Please sign in to comment.