-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
First pass at adding profile images. #162
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
6049504
First pass at adding profile images.
877914c
Merge branch 'main' into ballers-add-images
39b2b26
Set token name method for BLB admins.
eaa8f3c
Updating web3 dependency.
5078260
Using relative path in solidity import.
d7b6e77
Fixing web3 path.
5bac81e
Casing issue in ITerminus import.
b59cebd
Updating BLB cli.
449c832
Merge branch 'main' into ballers-add-images
c5ff6b4
Merge branch 'main' into ballers-add-images
e6df744
Updating images.
9d91e41
Changing array of images to mapping. Batching setTokenNames method. A…
24c40c9
Using cdn urls for metadata. Updating tests per PR.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Submodule web3
updated
20 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,26 +6,79 @@ import { ERC721 } from "../lib/openzeppelin-contracts/contracts/token/ERC721/ERC | |
import { ERC721Enumerable } from "../lib/openzeppelin-contracts/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; | ||
import { Base64 } from "../lib/openzeppelin-contracts/contracts/utils/Base64.sol"; | ||
import { Strings } from "../lib/openzeppelin-contracts/contracts/utils/Strings.sol"; | ||
import { ITerminus } from "../lib/web3/contracts/interfaces/ITerminus.sol"; | ||
|
||
contract BeerLeagueBallers is ERC721Enumerable { | ||
string[24] public ProfileImages = [ | ||
"https://badges.moonstream.to/blb/p0.png", | ||
"https://badges.moonstream.to/blb/p1.png", | ||
"https://badges.moonstream.to/blb/p2.png", | ||
"https://badges.moonstream.to/blb/p3.png", | ||
"https://badges.moonstream.to/blb/p4.png", | ||
"https://badges.moonstream.to/blb/p5.png", | ||
"https://badges.moonstream.to/blb/p6.png", | ||
"https://badges.moonstream.to/blb/p7.png" | ||
]; | ||
mapping(uint256 => string) public ProfileImages; | ||
uint256 public NumProfileImages; | ||
|
||
mapping(uint256 => string) public Name; | ||
mapping(uint256 => uint256) public ImageIndex; | ||
|
||
constructor() ERC721("Beer League Ballers", "BLB") { } | ||
address adminTerminus; | ||
uint256 adminPoolID; | ||
|
||
constructor(address _adminTerminus, uint256 _adminPoolID) ERC721("Beer League Ballers", "BLB") { | ||
adminTerminus = _adminTerminus; | ||
adminPoolID = _adminPoolID; | ||
|
||
ProfileImages[0] = "https://static.fullcount.xyz/Beer_League_Ballers/p0.png"; | ||
ProfileImages[1] = "https://static.fullcount.xyz/Beer_League_Ballers/p1.png"; | ||
ProfileImages[2] = "https://static.fullcount.xyz/Beer_League_Ballers/p2.png"; | ||
ProfileImages[3] = "https://static.fullcount.xyz/Beer_League_Ballers/p3.png"; | ||
ProfileImages[4] = "https://static.fullcount.xyz/Beer_League_Ballers/p4.png"; | ||
ProfileImages[5] = "https://static.fullcount.xyz/Beer_League_Ballers/p5.png"; | ||
ProfileImages[6] = "https://static.fullcount.xyz/Beer_League_Ballers/p6.png"; | ||
ProfileImages[7] = "https://static.fullcount.xyz/Beer_League_Ballers/p7.png"; | ||
NumProfileImages = 8; | ||
} | ||
|
||
function _enforceIsAdmin() internal view { | ||
ITerminus terminus = ITerminus(address(adminTerminus)); | ||
require(terminus.balanceOf(msg.sender, adminPoolID) > 0, "BeerLeagueBallers._enforceIsAdmin: not admin"); | ||
} | ||
|
||
function addProfileImage(string memory newImage) public { | ||
_enforceIsAdmin(); | ||
|
||
ProfileImages[NumProfileImages] = newImage; | ||
NumProfileImages++; | ||
} | ||
|
||
function updateProfileImage(uint256 index, string memory newImage) public { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should also probably be a batch method. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We decided not to do this. |
||
_enforceIsAdmin(); | ||
|
||
ProfileImages[index] = newImage; | ||
} | ||
|
||
function setTokenNames(uint256[] memory tokenIDList, string[] memory newNameList) public { | ||
_enforceIsAdmin(); | ||
|
||
require( | ||
tokenIDList.length == newNameList.length, | ||
"BeerLeagueBallers.setTokenNames: tokenIDList and newNameList length mismatch" | ||
); | ||
|
||
for (uint256 i = 0; i < tokenIDList.length; i++) { | ||
Name[tokenIDList[i]] = newNameList[i]; | ||
} | ||
} | ||
|
||
function setTokenImages(uint256[] memory tokenIDList, uint256[] memory imageIndexList) public { | ||
_enforceIsAdmin(); | ||
|
||
require( | ||
tokenIDList.length == imageIndexList.length, | ||
"BeerLeagueBallers.setTokenImages: tokenIDList and imageIndexList length mismatch" | ||
); | ||
|
||
for (uint256 i = 0; i < tokenIDList.length; i++) { | ||
ImageIndex[tokenIDList[i]] = imageIndexList[i]; | ||
} | ||
} | ||
|
||
function mint(string memory name, uint256 imageIndex) public returns (uint256) { | ||
require(imageIndex < ProfileImages.length, "BLB.mint: invalid image index"); | ||
require(imageIndex < NumProfileImages, "BLB.mint: invalid image index"); | ||
uint256 tokenId = totalSupply() + 1; | ||
Name[tokenId] = name; | ||
ImageIndex[tokenId] = imageIndex; | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're probably going to be adding multiple images at once, this seems like it should be a batch method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We decided not to do this.