Skip to content

Commit

Permalink
touchups
Browse files Browse the repository at this point in the history
  • Loading branch information
buck54321 committed May 18, 2022
1 parent 1f0da0d commit 0458637
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
3 changes: 3 additions & 0 deletions client/asset/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ func Register(assetID uint32, driver Driver) {
if driver.Info().UnitInfo.Conventional.ConversionFactor == 0 {
panic(fmt.Sprint("asset: Registered driver doesn't have a conventional conversion factor set in the wallet info ", assetID))
}

fmt.Println("--Register'ing", assetID, driver.Info().UnitInfo)

drivers[assetID] = driver
}

Expand Down
1 change: 1 addition & 0 deletions client/cmd/dexc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
_ "decred.org/dcrdex/client/asset/bch" // register bch asset
_ "decred.org/dcrdex/client/asset/btc" // register btc asset
_ "decred.org/dcrdex/client/asset/dcr" // register dcr asset
_ "decred.org/dcrdex/client/asset/eth" // register eth asset
_ "decred.org/dcrdex/client/asset/ltc" // register ltc asset

"decred.org/dcrdex/client/cmd/dexc/version"
Expand Down
4 changes: 4 additions & 0 deletions client/webserver/site/src/js/forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,10 @@ function isTruthyString (s) {

function unitInfo (xc, assetID) {
const dexAsset = xc.assets[assetID]

console.log("--unitInfo.dexAsset", dexAsset)
console.log("--unitInfo.supportedAsset", app().assets[assetID])

if (dexAsset && dexAsset.unitInfo.conventional.conversionFactor > 0) return dexAsset.unitInfo
const supportedAsset = app().assets[assetID]
if (!supportedAsset) return null
Expand Down
14 changes: 6 additions & 8 deletions dex/networks/eth/contracts/ETHSwapV1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ contract ETHSwap {
// swaps is a map of contract hashes to the "swap record". The swap record
// has the following interpretation.
// if (record == bytes32(0x00)): contract is uninitiated
// else if (uint256(record) < block.number && sha256(record) != contract.secret):
// else if (uint256(record) < block.number && sha256(record) != contract.secretHash):
// contract is initiated and redeemable by the participant with the secret.
// else if (sha256(record) == contract.secret): contract has been redeemed
// else if (sha256(record) == contract.secretHash): contract has been redeemed
// else if (record == RefundRecord): contract has been refunded
// else: invalid record. Should be impossible by construction
mapping(bytes32 => bytes32) public swaps;
Expand Down Expand Up @@ -104,7 +104,6 @@ contract ETHSwap {
if (secretValidates(record, c.secretHash)) {
return State.Redeemed;
}
// Is it worth checking whether blockNum < block.number?
return State.Filled;
}

Expand All @@ -121,14 +120,14 @@ contract ETHSwap {
require(c.value > 0, "0 val");
require(c.refundTimestamp > 0, "0 refundTimestamp");

// Is this needed?
// require(msg.sender == c.initiator)

bytes32 k = contractKey(c);
bytes32 record = swaps[k];
require(record == bytes32(0), "swap not empty");

swaps[k] = bytes32(block.number);
record = bytes32(block.number);
require(!secretValidates(record, c.secretHash), "hash collision");

swaps[k] = record;

initVal += c.value * 1 gwei;
}
Expand Down Expand Up @@ -171,7 +170,6 @@ contract ETHSwap {
// To be redeemable, the record needs to represent a valid block
// number.
require(blockNum > 0 && blockNum < block.number, "unfilled swap");
// require(blockNum >> 32 == 0, "invalid swap format");

// Can't already be redeemed.
require(!secretValidates(record, r.c.secretHash), "already redeemed");
Expand Down
1 change: 1 addition & 0 deletions server/cmd/dcrdex/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
_ "decred.org/dcrdex/server/asset/bch"
_ "decred.org/dcrdex/server/asset/btc" // register btc asset
_ "decred.org/dcrdex/server/asset/dcr" // register dcr asset
_ "decred.org/dcrdex/server/asset/eth" // register eth asset
_ "decred.org/dcrdex/server/asset/ltc" // register ltc asset
dexsrv "decred.org/dcrdex/server/dex"
"github.com/decred/dcrd/dcrec/secp256k1/v4"
Expand Down

0 comments on commit 0458637

Please sign in to comment.