-
-
Notifications
You must be signed in to change notification settings - Fork 814
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
add ERC1155 contract standard #2605
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2605 +/- ##
==========================================
- Coverage 86.62% 86.59% -0.04%
==========================================
Files 91 91
Lines 9438 9438
Branches 2362 2362
==========================================
- Hits 8176 8173 -3
- Misses 775 777 +2
- Partials 487 488 +1
Continue to review full report at Codecov.
|
@sonnhfit now that |
@fubuloubu thank u. In the gaming sector. There it has great application since such games have fungible elements (like life/energy), but also non-fungible elements like weapons and other collectables that all differ from one another. |
Sure! Will add some comments. |
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.
Try these updates to use the new DynArray
type
assert _to != ZERO_ADDRESS | ||
#assert len(_ids) == len(_values) | ||
|
||
for i in range(BATCH_SIZE): |
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.
for i in range(BATCH_SIZE): | |
for i in range(min(len(_ids), BATCH_SIZE)): |
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.
Note: this is because Vyper does not allow unbounded loops, but will allow min(var, const)
expressions as it has a defined upper bound
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.
Note: this is because Vyper does not allow unbounded loops, but will allow
min(var, const)
expressions as it has a defined upper bound
oh so I think this for loop is limited by BATCH_SIZE
. I also saw your comment here #1047 . could you help me merge pull requests. or give me some suggestions. thank bro @fubuloubu
examples/tokens/ERC1155.vy
Outdated
_owner: address[BATCH_SIZE], | ||
_ids: uint256[BATCH_SIZE] |
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.
_owner: address[BATCH_SIZE], | |
_ids: uint256[BATCH_SIZE] | |
_owner: DynArray[address, BATCH_SIZE], | |
_ids: DynArray[uint256, BATCH_SIZE] |
_ids: uint256[BATCH_SIZE] | ||
) -> uint256[BATCH_SIZE]: | ||
returnValues: uint256[BATCH_SIZE] = empty(uint256[BATCH_SIZE]) | ||
for i in range(BATCH_SIZE): |
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.
for i in range(BATCH_SIZE): | |
for i in range(min(len(_owners), BATCH_SIZE)): |
examples/tokens/ERC1155.vy
Outdated
_owner: address[BATCH_SIZE], | ||
_ids: uint256[BATCH_SIZE] | ||
) -> uint256[BATCH_SIZE]: | ||
returnValues: uint256[BATCH_SIZE] = empty(uint256[BATCH_SIZE]) |
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.
returnValues: uint256[BATCH_SIZE] = empty(uint256[BATCH_SIZE]) | |
assert len(_owners) == len(_ids) | |
returnValues: DynArray[uint256, BATCH_SIZE] = empty(DynArray[uint256, BATCH_SIZE]) |
examples/tokens/ERC1155.vy
Outdated
@external | ||
def mintBatch( | ||
_to: address, | ||
_supplys: uint256[BATCH_SIZE], |
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.
_supplys: uint256[BATCH_SIZE], | |
_supplys: DynArray[uint256, BATCH_SIZE], |
examples/tokens/ERC1155.vy
Outdated
_data: Bytes[256] | ||
) -> uint256[BATCH_SIZE]: | ||
assert _to != ZERO_ADDRESS | ||
ids: uint256[BATCH_SIZE] = empty(uint256[BATCH_SIZE]) |
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.
ids: uint256[BATCH_SIZE] = empty(uint256[BATCH_SIZE]) | |
ids: DynArray[uint256, BATCH_SIZE] = empty(DynArray[uint256, BATCH_SIZE]) |
hi @fubuloubu thank u. I saw your mention at #1440 but I have some unknown issue with
this is my vyper version, clone from the master. am I missing something like import right? or something like a version issue?
|
I had a similar issue. I ended up uninstalling Vyper through pip or maybe even deleting the packages from the directory. Seem you have the right version installed already. Maybe stating the obvious, do you use a virtualenv? I've had my share of challenges with multiple python versions and virtualenvs in the past ;-) On Linux you can do 'which vyper' and it shows you were the vyper command is. On Linux it's a small python script, you might want to check what is in there. Maybe it points to a different python version, which has an older Vyper installed. |
@charles-cooper |
@sonnhfit @fubuloubu @charles-cooper This compiles for me when I define an interface
[edit] so I think there's something sideways in your path maybe, see post above? |
The vyper command has been hardcoded to use /usr/bin/python3 check with |
Yes, this should be changed to |
Shall I create an issue for this? |
Yes please! or just PR, it's not really a big change to fix |
Not sure where I can find that in the code, where the vyper file gets created and placed in that specific location, any leads? I'll PR it :) |
Might be here https://github.com/vyperlang/vyper/blob/master/vyper/__main__.py Try it locally |
exactly env error because my machine has 2 env. thank @DataBeast-IT |
This is looking pretty good! I would suggest adding a testing file to the examples tests showing the functionality of the token. Use the ERC as a guide for what should and shouldn't work! |
thank bro I will add some testing file |
hi @fubuloubu I have a question. when I write a test. I identified a generic error something like a transaction not sent. something like:
I have identified the exact code that caused the error.
during the investigation of the cause. I really want to see the values of the variables. |
Welcome to the joys of smart contract programming! There is no method to print to the console like this. We are looking to migrate to a framework that would allow you to print the transaction trace (which calls were made during your transaction), which would help isolate it a little, but in general it's still not full debug capabilities. Best bet is to trace through the code manually and use comments to disable certain lines you think mgiht be problematic as you go. |
Also, this one is a little easier to debug at first glance. Seems like you are allowing the array index
You'd need to do this for iterating via
|
The issue here is that returnValues: DynArray[uint256, BATCH_SIZE] = empty(DynArray[uint256, BATCH_SIZE])
for i in range(BATCH_SIZE):
if i > len(_owners):
break
returnValues.append(self._balanceOf[_owners[i]][_ids[i]]) |
@charles-cooper @fubuloubu many thanks. Your information is very helpful. I will write tests for some other functions. |
@sonnhfit @fubuloubu what's the status of this PR? |
Some fixes needed, however some of the newer features in the |
i think this is superseded by #2807 |
What I did
I added standard token 1155 updated version 0.3.1
How I did it
update from here
How to verify it
deploy it
Description for the changelog
add an example for token standard erc1155
Cute Animal Picture