Skip to content

Commit

Permalink
add ended flag and burn remaining token function
Browse files Browse the repository at this point in the history
  • Loading branch information
jollyjoker992 committed Jan 9, 2024
1 parent c67485f commit 642db0b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
21 changes: 21 additions & 0 deletions contracts/FeralFileFungibleTokenAirdropV1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,27 @@ contract FeralFileFungibleTokenAirdropV1 is ERC1155, Authorizable {
// Airdropped addresses
mapping(address => bool) public airdroppedAddresses;

// Airdrop ended flag
bool private _ended;

constructor(uint256 tokenID_, string memory tokenURI_) ERC1155(tokenURI_) {
tokenID = tokenID_;
}

// @notice check if the airdrop is ended
function isEnded() external view returns (bool) {
return _ended;
}

// @notice end the airdrop
function end() external onlyOwner {
require(_ended == false, "FeralFileTokenAirdrop: airdrop ended");
_ended = true;
}

/// @notice Mint tokens to the contract itself
function mint(uint256 amount_) external onlyAuthorized {
require(_ended == false, "FeralFileTokenAirdrop: airdrop ended");
require(amount_ > 0, "FeralFileTokenAirdrop: amount is zero");
_mint(address(this), tokenID, amount_, "");
}
Expand All @@ -29,6 +44,7 @@ contract FeralFileFungibleTokenAirdropV1 is ERC1155, Authorizable {
address[] calldata to_,
uint256 amount_
) external onlyAuthorized {
require(_ended == false, "FeralFileTokenAirdrop: airdrop ended");
require(amount_ > 0, "FeralFileTokenAirdrop: amount is zero");

uint256[] memory _tokenIDs = new uint256[](1);
Expand All @@ -55,6 +71,11 @@ contract FeralFileFungibleTokenAirdropV1 is ERC1155, Authorizable {
}
}

// @notice burn remaining tokens
function burnRemaining() external onlyOwner {
_burn(address(this), tokenID, balanceOf(address(this), tokenID));
}

function onERC1155Received(
address,
address,
Expand Down
5 changes: 5 additions & 0 deletions test/feralfile_fungible_token_airdrop_v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ contract("FeralFileFungibleTokenAirdropV1", async (accounts) => {
assert.equal(await this.contracts[0].version(), "v1");
assert.equal(await this.contracts[0].uri(TOKEN_ID), TOKEN_URI);
assert.equal(await this.contracts[0].tokenID(), TOKEN_ID);
assert.equal(await this.contracts[0].isEnded(), false);
});

it("test mint", async () => {
Expand Down Expand Up @@ -137,4 +138,8 @@ contract("FeralFileFungibleTokenAirdropV1", async (accounts) => {
assert.equal(e.reason, "FeralFileTokenAirdrop: already airdropped");
}
});

it("test end airdrop", async () => {}); // TODO

it("test burn remaining", async () => {}); // TODO
});

0 comments on commit 642db0b

Please sign in to comment.