Skip to content
This repository has been archived by the owner on Jan 26, 2023. It is now read-only.

Commit

Permalink
Merge pull request #197 from mbeacom/deprecate-contract
Browse files Browse the repository at this point in the history
Add ability to stop kudos minting and cloning
  • Loading branch information
jasonrhaas committed Oct 22, 2018
2 parents 0095315 + 320187d commit f47ac98
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
21 changes: 19 additions & 2 deletions contracts/Kudos.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,23 @@ contract Kudos is ERC721Token("KudosToken", "KDO"), Ownable {

Kudo[] public kudos;
uint256 public cloneFeePercentage = 10;
bool public isMintable = true;

modifier mintable {
require(
isMintable == true,
"New kudos are no longer mintable on this contract. Please see KUDOS_CONTRACT_MAINNET at http://gitcoin.co/l/gcsettings for latest address."
);
_;
}

/// @dev mint(): Mint a new Gen0 Kudos. These are the tokens that other Kudos will be "cloned from".
/// @param _to Address to mint to.
/// @param _priceFinney Price of the Kudos in Finney.
/// @param _numClonesAllowed Maximum number of times this Kudos is allowed to be cloned.
/// @param _tokenURI A URL to the JSON file containing the metadata for the Kudos. See metadata.json for an example.
/// @return the tokenId of the Kudos that has been minted. Note that in a transaction only the tx_hash is returned.
function mint(address _to, uint256 _priceFinney, uint256 _numClonesAllowed, string _tokenURI) public payable onlyOwner returns (uint256 tokenId) {
function mint(address _to, uint256 _priceFinney, uint256 _numClonesAllowed, string _tokenURI) public payable mintable onlyOwner returns (uint256 tokenId) {
uint256 _numClonesInWild = 0;
uint256 _clonedFromId = 0;

Expand Down Expand Up @@ -55,7 +64,7 @@ contract Kudos is ERC721Token("KudosToken", "KDO"), Ownable {
/// @param _to The address to clone to.
/// @param _tokenId The token id of the Kudos to clone and transfer.
/// @param _numClonesRequested Number of clones to generate.
function clone(address _to, uint256 _tokenId, uint256 _numClonesRequested) public payable {
function clone(address _to, uint256 _tokenId, uint256 _numClonesRequested) public payable mintable {
// Grab existing Kudo blueprint
Kudo memory _kudo = kudos[_tokenId];
uint256 cloningCost = _kudo.priceFinney * 10**15 * _numClonesRequested;
Expand Down Expand Up @@ -125,6 +134,14 @@ contract Kudos is ERC721Token("KudosToken", "KDO"), Ownable {
cloneFeePercentage = _cloneFeePercentage;
}

/// @dev setMintable(): set the isMintable public variable. When set to `false`, no new
/// kudos are allowed to be minted or cloned. However, all of already
/// existing kudos will remain unchanged.
/// @param _isMintable flag for the mintable function modifier.
function setMintable(bool _isMintable) public onlyOwner {
isMintable = _isMintable;
}

/// @dev setPrice(): Update the Kudos listing price.
/// @param _tokenId The Kudos Id.
/// @param _newPriceFinney The new price of the Kudos.
Expand Down
25 changes: 25 additions & 0 deletions test/kudos.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,29 @@ contract("KudosTest", async(accounts) => {
}
})

it("should be able to stop all minting and cloning on the contract", async () => {
let instance = await Kudos.deployed();
await instance.mint(mintAddress, priceFinney, numClonesAllowed, tokenURI, {"from": accounts[0]});
let kudos_id = (await instance.getLatestId()).toNumber();
let numClones = 1;
// Make sure clonging works also
await instance.clone(accounts[1], kudos_id, numClones, {"from": accounts[1], "value": priceWeiBN});
// Turn minting off
await instance.setMintable(false, {"from": accounts[0]});
// Cloning should no longer work
try {
await instance.clone(accounts[1], kudos_id, numClones, {"from": accounts[1], "value": priceWeiBN});
assert.fail();
} catch (err) {
assert.ok(err);
}
// Minting should no longer work
try {
await instance.mint(mintAddress, priceFinney, numClonesAllowed, tokenURI, {"from": accounts[0]});
assert.fail();
} catch (err) {
assert.ok(err);
}
})

});

0 comments on commit f47ac98

Please sign in to comment.