Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Bryant Eisenbach
    @fubuloubu
    Well, that makes an external call to self.asset
    If you trust that contract it's unlikely to do any harm i.e. if it's a token you've created
    If you're making something that let's any ERC20 token be that asset, it's worth considering the token could be compromised
    But msg.sender doesn't do anything special there, just an address variable
    But mint probably wouldn't cause harm by itself, it doesn't impact any internal state of the contract
    Alexander
    @alexangelj_twitter
    self.asset is a trusted contract I create, but in this case msg.sender could be a malicious contract right?
    Bryant Eisenbach
    @fubuloubu
    It could be, but if your token contract doesn't communicate to the initiator of your method, you have nothing to worry about
    Félix Robles
    @Findeton
    in vyper, can a payable function send money to somewhere else?
    Michael Egorov
    @michwill
    Is it possible to do something like import a as b? When I'm doing it, vyper complains about unknown interface and it wants import a as a
    Bryant Eisenbach
    @fubuloubu
    @Findeton yes, you can send from inside any function, including payable ones
    @michwill unsure, the import support is sorta new and may be a little fuzzy around the edges. If it's not working like how you expect, I would open an issue
    Michael Egorov
    @michwill
    Bryant Eisenbach
    @fubuloubu
    👍
    Félix Robles
    @Findeton
    @fubuloubu how can I check the balance of the contract's address?
    Bryant Eisenbach
    @fubuloubu
    self.balance
    Félix Robles
    @Findeton
    thanks!
    Aristotelis Triantafyllidis
    @Totoual
    Hi, is there a way around of concating lists of bytes32 other than manually adding each element in the concat() function? I mean I am not able to pass the list inside the concat function because it doesn't support it.
    I need something similar to this.
        temp: bytes32[BATCH_SIZE]
        temp_from_supplies: bytes32[BATCH_SIZE]
        for i in ragne(BATCH_SIZE):
            id: uint256 = _ids[i]
            temp[i] = convert(id, bytes32)
            supply: uint256 = _from_supplies[i]
            temp_from_supplies[i] = supply
    
    hash: bytes32 = keccak256(concat(temp, temp_from_supplies))
    Bryant Eisenbach
    @fubuloubu
    I can't see exactly what you're trying to do, but currently that is the pain we have when working with hashing types. @charles-cooper is working on the ABI encoder, which will make this significantly easier to do
    You will just have to do hash: bytes32 = keccak256(abi_encode(_ids, _from_supplies))
    It's probably our biggest missing feature at the moment
    Also will allow us to do data passing on calls like ERC721 transfer
    Aristotelis Triantafyllidis
    @Totoual
    Hmm thanks for your response. So this is not implemented yet right ? I am creating a hash of some items along with a signature that I receive and I am verifying the address.
    Bryant Eisenbach
    @fubuloubu
    Yeah, not yet. I mean, you can do what you're looking to do today, but it will be significantly easier once the ABI encoder is complete.
    It's actually kind of cool that concat(bytes32[N], bytes32[N]) works to give you a string of bytes. I don't think I've seen someone do that yet
    Aristotelis Triantafyllidis
    @Totoual
    I see thank you very much! I 'll try this one.
    Jacques Wagener
    @jacqueswww
    @Totoual so you are trying to hash 2 lists of bytes32?
    Jacques Wagener
    @jacqueswww
    Hashing a list of bytes should be simple actually... since it's just a chunk in memory that we can directly hash.
    Bryant Eisenbach
    @fubuloubu
    @jacqueswww it apparently already does that?
    who knew lol
    Aristotelis Triantafyllidis
    @Totoual
    Yes that's true I am trying to hash 2 arrays of bytes32. Actually, end it up doing something like this
     aggregate_hash: bytes32 = keccak256(concat(convert(_ids[0], bytes32), convert(_from_supplies[0], bytes32), convert(_to_supplies[0], bytes32)))
        for i in range(BATCH_SIZE):
          if not i == 0:
            aggregate_hash = keccak256(concat(aggregate_hash, convert(_ids[i], bytes32), convert(_from_supplies[i], bytes32), convert(_to_supplies[i], bytes32)))
        hash: bytes32 = keccak256(concat(convert(_from, bytes32),
                                  convert(_to, bytes32),
                                  aggregate_hash,
                                  convert(_value_eth, bytes32),
                                  convert(_nonce, bytes32)))
        return hash
    Michael Egorov
    @michwill

    I am wondering, would it be possible to do transaction-like behavior for reading and changing persisted attributes?

    E.g., currently:

    _x: uint256 = self.x
    ...
    self.x += 1
    ...
    _y: uint256 = self.x ** 2
    ...

    Creates three heavy reads and one heavy write.

    Is it possible to cache the value of self.x at first operation automatically (sload), and do the sstore only at the end of transaction? Or is that how it works?

    Bryant Eisenbach
    @fubuloubu
    yes, caching behavior is something we would want to implement as an optimization eventually
    it can be very problematic if you get it wrong, so not something to be approached lightly
    in fact, our stack underflow issues all basically stemmed from a similar optimization
    you also have re-entrancy to contend with
    basically, you would want to commit the state change before making an external call
    so, that complicates things further
    Michael Egorov
    @michwill
    I see, yeah
    Henry Gong
    @henrygong
    Hi, does anyone have a good tutorial for logs and accessing them?
    Félix Robles
    @Findeton
    @henrygong I don't know if I'm the only crazy one, but for accessing the logs/events I just use the etherscan APIs
    Michael Egorov
    @michwill

    Looks like there is a bug. If an array is declared with an imported interface, e.g.:

    tokens: ERC20[3]

    it cannot be accessed as an array:

    tokens[1] = ERC20(some_addr)
    Bryant Eisenbach
    @fubuloubu
    oh weird, does that hold for maps too?
    Michael Egorov
    @michwill
    let's see...
    Mappings also have a problem, but much earlier
    Michael Egorov
    @michwill
    xyz: map(uint256, ERC20)
    causes
    vyper.exceptions.InvalidTypeException: line 50:18 Invalid base type: ERC20
    Bryant Eisenbach
    @fubuloubu
    Yeah, that's a problem. I believe mappings should allow maps to any value for a given key of a basic type.
    Would you mind logging issues please? Thanks for finding this!
    Steve Marx
    @smarx
    x: ERC20 gives the same error. I recall a discussion here about it quite a while ago, but I can't find it now. I thought the outcome of that discussion was that it was by design. (I think the intention was to force developers to do ERC20(foo).transfer() each time to make it obvious what function was being called.)