ApeWorX / ape-ledger

Ledger Nano S and X account plugin for the Ape Framework
https://www.apeworx.io/
Apache License 2.0
6 stars 7 forks source link

fix: bug preventing transactions from working #17

Closed antazoey closed 2 years ago

antazoey commented 2 years ago

What I did

How I did it

Build our own RLP serializable classes.

How to verify it

from ape import accounts, project
from ape.logging import logger

def main():
    logger.info("Starting simulation...")

    funder = accounts.test_accounts[5]

    try:
        account = accounts.load("main")
    except IndexError:
        logger.error("Ledger plugin has likely failed to load :(")
        return

    logger.info("Funding main account...")
    funder.transfer(account, "900 ETH")
    logger.success("Funding complete!")
    assert account.balance

    logger.info("Deploying smart contract using Static txn...")
    account.deploy(project.Fund, type=0)
    logger.success("Smart contract deployed!")

    logger.info("Deploying smart contract using Dynamic txn...")
    account.deploy(project.Fund, gas_limit=30029122)
    logger.success("Smart contract deployed!")

    logger.info("Returning funds to funder statically...")
    account.transfer(funder, "400 ETH", type=0)
    logger.success("Refunding complete!")
    assert account.balance

    logger.info("Returning funds to funder statically...")
    account.transfer(funder, "400 ETH")
    logger.success("Refunding complete!")
    assert account.balance

    logger.success("Simulation complete!")

Checklist

fubuloubu commented 2 years ago

tried it with fantom and got:

eth_account/_utils/signing.py:95, in extract_chain_id(raw_v)
     94     else:
---> 95         raise ValueError("v %r is invalid, must be one of: 0, 1, 27, 28, 35+")
     96 else:

ValueError: v %r is invalid, must be one of: 0, 1, 27, 28, 35+
antazoey commented 2 years ago

I am close to having something that works great for both dynamic and static! Hopefully by EOD

antazoey commented 2 years ago

@fubuloubu Are you good with merging this? I want to get these changes in the pydantic PR.

We can test Fantom support more when ape-fantom is ready. If v still bugs out, we can create a new issue then

fubuloubu commented 2 years ago

@fubuloubu Are you good with merging this? I want to get these changes in the pydantic PR.

We can test Fantom support more when ape-fantom is ready. If v still bugs out, we can create a new issue then

Did you want this to work with latest ape main?

$ ape ledger list
WARNING: 'AccountContainer - LedgerAccount' from 'ape_ledger' is not fully implemented. Remaining abstract methods: 'accounts'.