Skip to content

Commit

Permalink
refactor wallets view
Browse files Browse the repository at this point in the history
  • Loading branch information
buck54321 committed Feb 27, 2025
1 parent 87f8019 commit 991cbc3
Show file tree
Hide file tree
Showing 56 changed files with 1,752 additions and 1,361 deletions.
1 change: 1 addition & 0 deletions client/asset/bch/bch.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ var (
rpcWalletDefinition,
// electrumWalletDefinition, // getinfo RPC needs backport: https://github.com/Electron-Cash/Electron-Cash/pull/2399
},
BlockchainClass: asset.BlockchainClassUTXO,
}

externalFeeRate = btc.BitcoreRateFetcher("BCH")
Expand Down
1 change: 1 addition & 0 deletions client/asset/btc/btc.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ var (
electrumWalletDefinition,
},
LegacyWalletIndex: 1,
BlockchainClass: asset.BlockchainClassUTXO,
}
)

Expand Down
1 change: 1 addition & 0 deletions client/asset/dash/dash.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ var (
ConfigOpts: configOpts,
},
},
BlockchainClass: asset.BlockchainClassUTXO,
}
)

Expand Down
1 change: 1 addition & 0 deletions client/asset/dcr/dcr.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ var (
MultiFundingOpts: multiFundingOpts,
},
},
BlockchainClass: asset.BlockchainClassUTXO,
}
swapFeeBumpKey = "swapfeebump"
splitKey = "swapsplit"
Expand Down
1 change: 1 addition & 0 deletions client/asset/dgb/dgb.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ var (
DefaultConfigPath: dexbtc.SystemConfigPath("digibyte"),
ConfigOpts: configOpts,
}},
BlockchainClass: asset.BlockchainClassUTXO,
}
)

Expand Down
1 change: 1 addition & 0 deletions client/asset/doge/doge.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ var (
DefaultConfigPath: dexbtc.SystemConfigPath("dogecoin"),
ConfigOpts: configOpts,
}},
BlockchainClass: asset.BlockchainClassUTXO,
}
)

Expand Down
5 changes: 3 additions & 2 deletions client/asset/eth/eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ var (
GuideLink: "https://github.com/decred/dcrdex/blob/master/docs/wiki/Ethereum.md",
},
},
IsAccountBased: true,
BlockchainClass: asset.BlockchainClassEVM,
}

// unlimitedAllowance is the maximum supported allowance for an erc20
Expand Down Expand Up @@ -663,7 +663,7 @@ func CreateEVMWallet(chainID int64, createWalletParams *asset.CreateWalletParams
func newWallet(assetCFG *asset.WalletConfig, logger dex.Logger, net dex.Network) (w *ETHWallet, err error) {
chainCfg, err := ChainConfig(net)
if err != nil {
return nil, fmt.Errorf("failed to locate Ethereum genesis configuration for network %s", net)
return nil, fmt.Errorf("failed to locate Ethereum genesis configuration for network %s: %v", net, err)
}
comp, err := NetworkCompatibilityData(net)
if err != nil {
Expand Down Expand Up @@ -1265,6 +1265,7 @@ func (w *ETHWallet) OpenTokenWallet(tokenCfg *asset.TokenConfig) (asset.Wallet,
Name: token.Name,
SupportedVersions: supportedAssetVersions,
UnitInfo: token.UnitInfo,
BlockchainClass: asset.BlockchainClassEVM,
},
tokenAddr: netToken.Address,
pendingTxCheckBal: new(big.Int),
Expand Down
1 change: 1 addition & 0 deletions client/asset/firo/firo.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ var (
ConfigOpts: append(btc.ElectrumConfigOpts, btc.CommonConfigOpts("FIRO", true)...),
},
},
BlockchainClass: asset.BlockchainClassUTXO,
}
)

Expand Down
17 changes: 13 additions & 4 deletions client/asset/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,17 @@ type Token struct {
SupportedAssetVersions []uint32 `json:"supportedAssetVersions"`
}

type BlockchainClass string

const (
BlockchainClassUTXO BlockchainClass = "UTXO"
BlockchainClassEVM BlockchainClass = "EVM"
)

func (c BlockchainClass) IsEVM() bool {
return c == BlockchainClassEVM
}

// WalletInfo is auxiliary information about an ExchangeWallet.
type WalletInfo struct {
// Name is the display name for the currency, e.g. "Decred"
Expand All @@ -326,10 +337,8 @@ type WalletInfo struct {
// UnitInfo is the information about unit names and conversion factors for
// the asset.
UnitInfo dex.UnitInfo `json:"unitinfo"`
// IsAccountBased should be set to true for account-based (EVM) assets, so
// that a common seed will be generated and wallets will generate the
// same address.
IsAccountBased bool
// BlockchainClass is the type of the wallet's blockchain.
BlockchainClass BlockchainClass
}

// ConfigOption is a wallet configuration option.
Expand Down
1 change: 1 addition & 0 deletions client/asset/ltc/ltc.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ var (
rpcWalletDefinition,
electrumWalletDefinition,
},
BlockchainClass: asset.BlockchainClassUTXO,
}
)

Expand Down
2 changes: 1 addition & 1 deletion client/asset/polygon/polygon.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ var (
NoAuth: true,
},
},
IsAccountBased: true,
BlockchainClass: asset.BlockchainClassEVM,
}
)

Expand Down
1 change: 1 addition & 0 deletions client/asset/zcl/zcl.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ var (
ConfigOpts: configOpts,
NoAuth: true,
}},
BlockchainClass: asset.BlockchainClassUTXO,
}
)

Expand Down
1 change: 1 addition & 0 deletions client/asset/zec/zec.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ var (
ConfigOpts: configOpts,
NoAuth: true,
}},
BlockchainClass: asset.BlockchainClassUTXO,
}

feeReservesPerLot = dexzec.TxFeesZIP317(dexbtc.RedeemP2PKHInputSize+1, 2*dexbtc.P2PKHOutputSize+1, 0, 0, 0, 0)
Expand Down
Loading

0 comments on commit 991cbc3

Please sign in to comment.