Skip to content
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

eth: v1 contract #2038

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

eth: v1 contract #2038

wants to merge 1 commit into from

Commits on Nov 13, 2024

  1. eth v1 contract

    Implements the version 1 contracts for ethereum and tokens. Based
    on feedback in decred#1426, everything is now encoded in the
    "contract data". This "contract data", is the msgjson.Init.Contract
    -> msgjson.Audit.Contract -> MatchMetaData.Proof.CounterContract,
    AuditInfo.Contract -> Redemption.Spends.Contract.
    
    A few new terms are introduced to differentiate various encodings and
    data sets. The aforementioned contract data did encode a version
    and a secret hash. It now encodes a version and a "locator", which is
    a []byte whose length and content depend on the version. For
    version 0, the locator is still just the secretHash[:]. For v1,
    the locator encodes all of the immutable data that defines the
    swap. This immutable data is now collected in something called
    a "vector" (dexeth.SwapVector). For version 0, some vector data
    is stored on-chain indexed by the secret hash. For version 1, all
    vector data is encoded in the locator.
    
    I've also made an effort to standardize the use of status/step,
    and eliminated the use of ambiguous "ver" variables throughout.
    A "status" is now the collection of mutable contract data: the step,
    the init block height, and the secret. The status and vector
    collectively fully characterize the swap.
    
    client/asset/eth:
    New contractV1 and tokenContractorV1 interfaces. To avoid duplication,
    the ERC20 parts of the tokenContractors are separated into a new type
    erc20Contractor that is embedded by both versions. Getters for
    status and vector are added in place of the old method "swap".
    
    assetWallet and embedding types are updated to work with the new
    version-dependent locators and the status and vector model.
    
    dex/networks/{eth,erc20}:
    New contracts added. New methods for dealing with locators. Simnet
    entries added for eth and dextt.eth in the ContractAddresses and Tokens
    maps. txDataHandler interace is replaced with versioned package-level
    functions.
    
    server/asset/eth:
    Server is fully switched to version 1. No option to use version 0.
    Translation to new version was straightforward, with one notable
    difference that we can no longer get a block height from the
    contract once the swap is redeemed.
    buck54321 committed Nov 13, 2024
    Configuration menu
    Copy the full SHA
    f7c5296 View commit details
    Browse the repository at this point in the history