Skip to content

Commit

Permalink
add supported assets to token info
Browse files Browse the repository at this point in the history
  • Loading branch information
buck54321 committed Jan 31, 2023
1 parent f4a0fec commit 5d2dd39
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
7 changes: 4 additions & 3 deletions client/asset/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func Register(assetID uint32, driver Driver) {
// RegisterToken should be called to register tokens. If no nets are specified
// the token will be registered for all networks. The user must invoke
// SetNetwork to enable net-based filtering of package function output.
func RegisterToken(tokenID uint32, token *dex.Token, walletDef *WalletDefinition, nets ...dex.Network) {
func RegisterToken(tokenID uint32, token *dex.Token, walletDef *WalletDefinition, supportedVersions []uint32, nets ...dex.Network) {
driversMtx.Lock()
defer driversMtx.Unlock()
if _, exists := tokens[tokenID]; exists {
Expand All @@ -94,8 +94,9 @@ func RegisterToken(tokenID uint32, token *dex.Token, walletDef *WalletDefinition
}
tokens[tokenID] = &nettedToken{
Token: &Token{
Token: token,
Definition: walletDef,
Token: token,
Definition: walletDef,
SupportedVersions: supportedVersions,
},
nets: nets,
}
Expand Down
8 changes: 4 additions & 4 deletions client/asset/eth/eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func registerToken(tokenID uint32, desc string, nets ...dex.Network) {
asset.RegisterToken(tokenID, token.Token, &asset.WalletDefinition{
Type: "token",
Description: desc,
}, nets...)
}, SupportedTokenVersions, nets...)
}

func init() {
Expand Down Expand Up @@ -138,6 +138,8 @@ var (
},
}

SupportedTokenVersions = []uint32{0} // Server versions that we can handle.

chainIDs = map[dex.Network]int64{
dex.Mainnet: 1,
dex.Testnet: 5, // Görli
Expand Down Expand Up @@ -492,11 +494,9 @@ func (w *ETHWallet) Info() *asset.WalletInfo {
// Info returns basic information about the wallet and asset.
func (w *TokenWallet) Info() *asset.WalletInfo {
var bestVer uint32
var vers []uint32
netToken := w.token.NetTokens[w.net]
if netToken != nil {
for ver := range netToken.SwapContracts {
vers = append(vers, ver)
if ver > bestVer {
bestVer = ver
}
Expand All @@ -506,7 +506,7 @@ func (w *TokenWallet) Info() *asset.WalletInfo {
return &asset.WalletInfo{
Name: w.token.Name,
Version: bestVer,
SupportedVersions: vers,
SupportedVersions: SupportedTokenVersions,
UnitInfo: w.token.UnitInfo,
MaxSwapsInTx: w.maxSwapsInTx,
MaxRedeemsInTx: w.maxRedeemsInTx,
Expand Down
3 changes: 2 additions & 1 deletion client/asset/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ type WalletDefinition struct {
// Token combines the generic dex.Token with a WalletDefinition.
type Token struct {
*dex.Token
Definition *WalletDefinition `json:"definition"`
Definition *WalletDefinition `json:"definition"`
SupportedVersions []uint32 `json:"supportedVersions"`
}

// WalletInfo is auxiliary information about an ExchangeWallet.
Expand Down
4 changes: 3 additions & 1 deletion client/webserver/site/src/js/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export interface Token {
name: string
unitInfo: UnitInfo
definition: WalletDefinition
supportedVersions: number[]
}

export interface WalletState {
Expand All @@ -189,7 +190,8 @@ export interface WalletState {

export interface WalletInfo {
name: string
version: number
version: number // deprecated
versions: number[] // new field for supported server versions
availablewallets: WalletDefinition[]
emptyidx: number
unitinfo: UnitInfo
Expand Down

0 comments on commit 5d2dd39

Please sign in to comment.