feat: Add chain ID to contract (#29)
This commit is contained in:
parent
a9b06fde83
commit
4c1b47dae1
|
@ -7,7 +7,7 @@ import json_serialization
|
|||
import tables
|
||||
import strformat
|
||||
import statusgo_backend/core
|
||||
import ./types/[transaction, setting, rpc_response]
|
||||
import ./types/[transaction, setting, rpc_response, network_type, network]
|
||||
import utils
|
||||
import statusgo_backend/wallet
|
||||
import stew/byteutils
|
||||
|
@ -159,7 +159,8 @@ proc contenthash*(ensAddr: string): string =
|
|||
|
||||
proc getPrice*(): Stuint[256] =
|
||||
let
|
||||
contract = contracts.getContract("ens-usernames")
|
||||
network = status_settings.getCurrentNetwork().toNetwork()
|
||||
contract = contracts.findContract(network.chainId, "ens-usernames")
|
||||
payload = %* [{
|
||||
"to": $contract.address,
|
||||
"data": contract.methods["getPrice"].encodeAbi()
|
||||
|
@ -176,7 +177,8 @@ proc getPrice*(): Stuint[256] =
|
|||
proc releaseEstimateGas*(username: string, address: string, success: var bool): int =
|
||||
let
|
||||
label = fromHex(FixedBytes[32], label(username))
|
||||
ensUsernamesContract = contracts.getContract("ens-usernames")
|
||||
network = status_settings.getCurrentNetwork().toNetwork()
|
||||
ensUsernamesContract = contracts.findContract(network.chainId, "ens-usernames")
|
||||
release = Release(label: label)
|
||||
|
||||
var tx = transactions.buildTokenTransaction(parseAddress(address), ensUsernamesContract.address, "", "")
|
||||
|
@ -190,7 +192,8 @@ proc releaseEstimateGas*(username: string, address: string, success: var bool):
|
|||
proc release*(username: string, address: string, gas, gasPrice, password: string, success: var bool): string =
|
||||
let
|
||||
label = fromHex(FixedBytes[32], label(username))
|
||||
ensUsernamesContract = contracts.getContract("ens-usernames")
|
||||
network = status_settings.getCurrentNetwork().toNetwork()
|
||||
ensUsernamesContract = contracts.findContract(network.chainId, "ens-usernames")
|
||||
release = Release(label: label)
|
||||
|
||||
var tx = transactions.buildTokenTransaction(parseAddress(address), ensUsernamesContract.address, "", "")
|
||||
|
@ -205,7 +208,8 @@ proc getExpirationTime*(username: string, success: var bool): int =
|
|||
let
|
||||
label = fromHex(FixedBytes[32], label(username))
|
||||
expTime = ExpirationTime(label: label)
|
||||
ensUsernamesContract = contracts.getContract("ens-usernames")
|
||||
network = status_settings.getCurrentNetwork().toNetwork()
|
||||
ensUsernamesContract = contracts.findContract(network.chainId, "ens-usernames")
|
||||
|
||||
var tx = transactions.buildTransaction(parseAddress("0x0000000000000000000000000000000000000000"), 0.u256)
|
||||
tx.to = ensUsernamesContract.address.some
|
||||
|
@ -230,8 +234,9 @@ proc registerUsernameEstimateGas*(username: string, address: string, pubKey: str
|
|||
coordinates = extractCoordinates(pubkey)
|
||||
x = fromHex(FixedBytes[32], coordinates.x)
|
||||
y = fromHex(FixedBytes[32], coordinates.y)
|
||||
ensUsernamesContract = contracts.getContract("ens-usernames")
|
||||
sntContract = contracts.getSntContract()
|
||||
network = status_settings.getCurrentNetwork().toNetwork()
|
||||
ensUsernamesContract = contracts.findContract(network.chainId, "ens-usernames")
|
||||
sntContract = contracts.findErc20Contract(network.chainId, network.sntSymbol())
|
||||
price = getPrice()
|
||||
|
||||
let
|
||||
|
@ -252,8 +257,9 @@ proc registerUsername*(username, pubKey, address, gas, gasPrice: string, isEIP15
|
|||
coordinates = extractCoordinates(pubkey)
|
||||
x = fromHex(FixedBytes[32], coordinates.x)
|
||||
y = fromHex(FixedBytes[32], coordinates.y)
|
||||
ensUsernamesContract = contracts.getContract("ens-usernames")
|
||||
sntContract = contracts.getSntContract()
|
||||
network = status_settings.getCurrentNetwork().toNetwork()
|
||||
ensUsernamesContract = contracts.findContract(network.chainId, "ens-usernames")
|
||||
sntContract = contracts.findErc20Contract(network.chainId, network.sntSymbol)
|
||||
price = getPrice()
|
||||
|
||||
let
|
||||
|
@ -275,7 +281,8 @@ proc setPubKeyEstimateGas*(username: string, address: string, pubKey: string, su
|
|||
label = fromHex(FixedBytes[32], "0x" & hash)
|
||||
x = fromHex(FixedBytes[32], "0x" & pubkey[4..67])
|
||||
y = fromHex(FixedBytes[32], "0x" & pubkey[68..131])
|
||||
resolverContract = contracts.getContract("ens-resolver")
|
||||
network = status_settings.getCurrentNetwork().toNetwork()
|
||||
resolverContract = contracts.findContract(network.chainId, "ens-resolver")
|
||||
setPubkey = SetPubkey(label: label, x: x, y: y)
|
||||
resolverAddress = resolver(hash)
|
||||
|
||||
|
@ -296,7 +303,8 @@ proc setPubKey*(username, pubKey, address, gas, gasPrice: string, isEIP1559Enabl
|
|||
label = fromHex(FixedBytes[32], "0x" & hash)
|
||||
x = fromHex(FixedBytes[32], "0x" & pubkey[4..67])
|
||||
y = fromHex(FixedBytes[32], "0x" & pubkey[68..131])
|
||||
resolverContract = contracts.getContract("ens-resolver")
|
||||
network = status_settings.getCurrentNetwork().toNetwork()
|
||||
resolverContract = contracts.findContract(network.chainId, "ens-resolver")
|
||||
setPubkey = SetPubkey(label: label, x: x, y: y)
|
||||
resolverAddress = resolver(hash)
|
||||
|
||||
|
@ -310,7 +318,8 @@ proc setPubKey*(username, pubKey, address, gas, gasPrice: string, isEIP1559Enabl
|
|||
raise
|
||||
|
||||
proc statusRegistrarAddress*():string =
|
||||
result = $contracts.getContract("ens-usernames").address
|
||||
let network = status_settings.getCurrentNetwork().toNetwork()
|
||||
result = $contracts.findContract(network.chainId, "ens-usernames").address
|
||||
|
||||
|
||||
type
|
||||
|
|
|
@ -5,7 +5,7 @@ import
|
|||
web3/ethtypes, stew/byteutils, nimcrypto, json_serialization, chronicles
|
||||
|
||||
import
|
||||
../types/[network_type], ../statusgo_backend/settings, ../statusgo_backend/coder, transactions, methods, ../utils
|
||||
../types/network, ../statusgo_backend/settings, ../statusgo_backend/coder, transactions, methods, ../utils
|
||||
|
||||
export
|
||||
GetPackData, PackData, BuyToken, ApproveAndCall, Transfer, BalanceOf, Register, SetPubkey,
|
||||
|
@ -53,7 +53,7 @@ const ERC721_ENUMERABLE_METHODS = @[
|
|||
type
|
||||
Contract* = ref object of RootObj
|
||||
name*: string
|
||||
network*: NetworkType
|
||||
chainId*: int
|
||||
address*: Address
|
||||
methods* {.dontSerialize.}: Table[string, Method]
|
||||
|
||||
|
@ -62,20 +62,19 @@ type
|
|||
decimals*: int
|
||||
hasIcon* {.dontSerialize.}: bool
|
||||
color*: string
|
||||
chainId*: int
|
||||
|
||||
Erc721Contract* = ref object of Contract
|
||||
symbol*: string
|
||||
hasIcon*: bool
|
||||
|
||||
proc newErc20Contract*(name: string, network: NetworkType, address: Address, symbol: string, decimals: int, hasIcon: bool): Erc20Contract =
|
||||
Erc20Contract(name: name, network: network, address: address, methods: ERC20_METHODS.toTable, symbol: symbol, decimals: decimals, hasIcon: hasIcon)
|
||||
proc newErc20Contract*(name: string, chainId: int, address: Address, symbol: string, decimals: int, hasIcon: bool): Erc20Contract =
|
||||
Erc20Contract(name: name, chainId: chainId, address: address, methods: ERC20_METHODS.toTable, symbol: symbol, decimals: decimals, hasIcon: hasIcon)
|
||||
|
||||
proc newErc20Contract*(network: NetworkType, address: Address): Erc20Contract =
|
||||
Erc20Contract(name: "", network: network, address: address, methods: ERC20_METHODS.toTable, symbol: "", decimals: 0, hasIcon: false)
|
||||
proc newErc20Contract*(chainId: int, address: Address): Erc20Contract =
|
||||
Erc20Contract(name: "", chainId: chainId, address: address, methods: ERC20_METHODS.toTable, symbol: "", decimals: 0, hasIcon: false)
|
||||
|
||||
proc newErc721Contract(name: string, network: NetworkType, address: Address, symbol: string, hasIcon: bool, addlMethods: seq[tuple[name: string, meth: Method]] = @[]): Erc721Contract =
|
||||
Erc721Contract(name: name, network: network, address: address, symbol: symbol, hasIcon: hasIcon, methods: ERC721_ENUMERABLE_METHODS.concat(addlMethods).toTable)
|
||||
proc newErc721Contract(name: string, chainId: int, address: Address, symbol: string, hasIcon: bool, addlMethods: seq[tuple[name: string, meth: Method]] = @[]): Erc721Contract =
|
||||
Erc721Contract(name: name, chainId: chainId, address: address, symbol: symbol, hasIcon: hasIcon, methods: ERC721_ENUMERABLE_METHODS.concat(addlMethods).toTable)
|
||||
|
||||
|
||||
var
|
||||
|
@ -87,122 +86,122 @@ proc allContracts(): seq[Contract] =
|
|||
else:
|
||||
contracts = @[
|
||||
# Mainnet contracts
|
||||
newErc20Contract("Status Network Token", NetworkType.Mainnet, parseAddress("0x744d70fdbe2ba4cf95131626614a1763df805b9e"), "SNT", 18, true),
|
||||
newErc20Contract("Dai Stablecoin", NetworkType.Mainnet, parseAddress("0x6b175474e89094c44da98b954eedeac495271d0f"), "DAI", 18, true),
|
||||
newErc20Contract("Sai Stablecoin v1.0", NetworkType.Mainnet, parseAddress("0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359"), "SAI", 18, true),
|
||||
newErc20Contract("MKR", NetworkType.Mainnet, parseAddress("0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2"), "MKR", 18, true),
|
||||
newErc20Contract("EOS", NetworkType.Mainnet, parseAddress("0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0"), "EOS", 18, true),
|
||||
newErc20Contract("OMGToken", NetworkType.Mainnet, parseAddress("0xd26114cd6ee289accf82350c8d8487fedb8a0c07"), "OMG", 18, true),
|
||||
newErc20Contract("Populous Platform", NetworkType.Mainnet, parseAddress("0xd4fa1460f537bb9085d22c7bccb5dd450ef28e3a"), "PPT", 8, true),
|
||||
newErc20Contract("Reputation", NetworkType.Mainnet, parseAddress("0x1985365e9f78359a9b6ad760e32412f4a445e862"), "REP", 18, true),
|
||||
newErc20Contract("PowerLedger", NetworkType.Mainnet, parseAddress("0x595832f8fc6bf59c85c527fec3740a1b7a361269"), "POWR", 6, true),
|
||||
newErc20Contract("TenX Pay Token", NetworkType.Mainnet, parseAddress("0xb97048628db6b661d4c2aa833e95dbe1a905b280"), "PAY", 18, true),
|
||||
newErc20Contract("Veros", NetworkType.Mainnet, parseAddress("0x92e78dae1315067a8819efd6dca432de9dcde2e9"), "VRS", 6, false),
|
||||
newErc20Contract("Golem Network Token", NetworkType.Mainnet, parseAddress("0xa74476443119a942de498590fe1f2454d7d4ac0d"), "GNT", 18, true),
|
||||
newErc20Contract("Salt", NetworkType.Mainnet, parseAddress("0x4156d3342d5c385a87d264f90653733592000581"), "SALT", 8, true),
|
||||
newErc20Contract("BNB", NetworkType.Mainnet, parseAddress("0xb8c77482e45f1f44de1745f52c74426c631bdd52"), "BNB", 18, true),
|
||||
newErc20Contract("Basic Attention Token", NetworkType.Mainnet, parseAddress("0x0d8775f648430679a709e98d2b0cb6250d2887ef"), "BAT", 18, true),
|
||||
newErc20Contract("Kyber Network Crystal", NetworkType.Mainnet, parseAddress("0xdd974d5c2e2928dea5f71b9825b8b646686bd200"), "KNC", 18, true),
|
||||
newErc20Contract("BTU Protocol", NetworkType.Mainnet, parseAddress("0xb683D83a532e2Cb7DFa5275eED3698436371cc9f"), "BTU", 18, true),
|
||||
newErc20Contract("Digix DAO", NetworkType.Mainnet, parseAddress("0xe0b7927c4af23765cb51314a0e0521a9645f0e2a"), "DGD", 9, true),
|
||||
newErc20Contract("Aeternity", NetworkType.Mainnet, parseAddress("0x5ca9a71b1d01849c0a95490cc00559717fcf0d1d"), "AE", 18, true),
|
||||
newErc20Contract("Tronix", NetworkType.Mainnet, parseAddress("0xf230b790e05390fc8295f4d3f60332c93bed42e2"), "TRX", 6, true),
|
||||
newErc20Contract("Ethos", NetworkType.Mainnet, parseAddress("0x5af2be193a6abca9c8817001f45744777db30756"), "ETHOS", 8, true),
|
||||
newErc20Contract("Raiden Token", NetworkType.Mainnet, parseAddress("0x255aa6df07540cb5d3d297f0d0d4d84cb52bc8e6"), "RDN", 18, true),
|
||||
newErc20Contract("SingularDTV", NetworkType.Mainnet, parseAddress("0xaec2e87e0a235266d9c5adc9deb4b2e29b54d009"), "SNGLS", 0, true),
|
||||
newErc20Contract("Gnosis Token", NetworkType.Mainnet, parseAddress("0x6810e776880c02933d47db1b9fc05908e5386b96"), "GNO", 18, true),
|
||||
newErc20Contract("StorjToken", NetworkType.Mainnet, parseAddress("0xb64ef51c888972c908cfacf59b47c1afbc0ab8ac"), "STORJ", 8, true),
|
||||
newErc20Contract("AdEx", NetworkType.Mainnet, parseAddress("0x4470bb87d77b963a013db939be332f927f2b992e"), "ADX", 4, false),
|
||||
newErc20Contract("FunFair", NetworkType.Mainnet, parseAddress("0x419d0d8bdd9af5e606ae2232ed285aff190e711b"), "FUN", 8, true),
|
||||
newErc20Contract("Civic", NetworkType.Mainnet, parseAddress("0x41e5560054824ea6b0732e656e3ad64e20e94e45"), "CVC", 8, true),
|
||||
newErc20Contract("ICONOMI", NetworkType.Mainnet, parseAddress("0x888666ca69e0f178ded6d75b5726cee99a87d698"), "ICN", 18, true),
|
||||
newErc20Contract("Walton Token", NetworkType.Mainnet, parseAddress("0xb7cb1c96db6b22b0d3d9536e0108d062bd488f74"), "WTC", 18, true),
|
||||
newErc20Contract("Bytom", NetworkType.Mainnet, parseAddress("0xcb97e65f07da24d46bcdd078ebebd7c6e6e3d750"), "BTM", 8, true),
|
||||
newErc20Contract("0x Protocol Token", NetworkType.Mainnet, parseAddress("0xe41d2489571d322189246dafa5ebde1f4699f498"), "ZRX", 18, true),
|
||||
newErc20Contract("Bancor Network Token", NetworkType.Mainnet, parseAddress("0x1f573d6fb3f13d689ff844b4ce37794d79a7ff1c"), "BNT", 18, true),
|
||||
newErc20Contract("Metal", NetworkType.Mainnet, parseAddress("0xf433089366899d83a9f26a773d59ec7ecf30355e"), "MTL", 8, false),
|
||||
newErc20Contract("PayPie", NetworkType.Mainnet, parseAddress("0xc42209accc14029c1012fb5680d95fbd6036e2a0"), "PPP", 18, true),
|
||||
newErc20Contract("ChainLink Token", NetworkType.Mainnet, parseAddress("0x514910771af9ca656af840dff83e8264ecf986ca"), "LINK", 18, true),
|
||||
newErc20Contract("Kin", NetworkType.Mainnet, parseAddress("0x818fc6c2ec5986bc6e2cbf00939d90556ab12ce5"), "KIN", 18, true),
|
||||
newErc20Contract("Aragon Network Token", NetworkType.Mainnet, parseAddress("0x960b236a07cf122663c4303350609a66a7b288c0"), "ANT", 18, true),
|
||||
newErc20Contract("MobileGo Token", NetworkType.Mainnet, parseAddress("0x40395044ac3c0c57051906da938b54bd6557f212"), "MGO", 8, true),
|
||||
newErc20Contract("Monaco", NetworkType.Mainnet, parseAddress("0xb63b606ac810a52cca15e44bb630fd42d8d1d83d"), "MCO", 8, true),
|
||||
newErc20Contract("loopring", NetworkType.Mainnet, parseAddress("0xef68e7c694f40c8202821edf525de3782458639f"), "LRC", 18, true),
|
||||
newErc20Contract("Zeus Shield Coin", NetworkType.Mainnet, parseAddress("0x7a41e0517a5eca4fdbc7fbeba4d4c47b9ff6dc63"), "ZSC", 18, true),
|
||||
newErc20Contract("Streamr DATAcoin", NetworkType.Mainnet, parseAddress("0x0cf0ee63788a0849fe5297f3407f701e122cc023"), "DATA", 18, true),
|
||||
newErc20Contract("Ripio Credit Network Token", NetworkType.Mainnet, parseAddress("0xf970b8e36e23f7fc3fd752eea86f8be8d83375a6"), "RCN", 18, true),
|
||||
newErc20Contract("WINGS", NetworkType.Mainnet, parseAddress("0x667088b212ce3d06a1b553a7221e1fd19000d9af"), "WINGS", 18, true),
|
||||
newErc20Contract("Edgeless", NetworkType.Mainnet, parseAddress("0x08711d3b02c8758f2fb3ab4e80228418a7f8e39c"), "EDG", 0, true),
|
||||
newErc20Contract("Melon Token", NetworkType.Mainnet, parseAddress("0xbeb9ef514a379b997e0798fdcc901ee474b6d9a1"), "MLN", 18, true),
|
||||
newErc20Contract("Moeda Loyalty Points", NetworkType.Mainnet, parseAddress("0x51db5ad35c671a87207d88fc11d593ac0c8415bd"), "MDA", 18, true),
|
||||
newErc20Contract("PILLAR", NetworkType.Mainnet, parseAddress("0xe3818504c1b32bf1557b16c238b2e01fd3149c17"), "PLR", 18, true),
|
||||
newErc20Contract("QRL", NetworkType.Mainnet, parseAddress("0x697beac28b09e122c4332d163985e8a73121b97f"), "QRL", 8, true),
|
||||
newErc20Contract("Modum Token", NetworkType.Mainnet, parseAddress("0x957c30ab0426e0c93cd8241e2c60392d08c6ac8e"), "MOD", 0, true),
|
||||
newErc20Contract("Token-as-a-Service", NetworkType.Mainnet, parseAddress("0xe7775a6e9bcf904eb39da2b68c5efb4f9360e08c"), "TAAS", 6, true),
|
||||
newErc20Contract("GRID Token", NetworkType.Mainnet, parseAddress("0x12b19d3e2ccc14da04fae33e63652ce469b3f2fd"), "GRID", 12, true),
|
||||
newErc20Contract("SANtiment network token", NetworkType.Mainnet, parseAddress("0x7c5a0ce9267ed19b22f8cae653f198e3e8daf098"), "SAN", 18, true),
|
||||
newErc20Contract("SONM Token", NetworkType.Mainnet, parseAddress("0x983f6d60db79ea8ca4eb9968c6aff8cfa04b3c63"), "SNM", 18, true),
|
||||
newErc20Contract("Request Token", NetworkType.Mainnet, parseAddress("0x8f8221afbb33998d8584a2b05749ba73c37a938a"), "REQ", 18, true),
|
||||
newErc20Contract("Substratum", NetworkType.Mainnet, parseAddress("0x12480e24eb5bec1a9d4369cab6a80cad3c0a377a"), "SUB", 2, true),
|
||||
newErc20Contract("Decentraland MANA", NetworkType.Mainnet, parseAddress("0x0f5d2fb29fb7d3cfee444a200298f468908cc942"), "MANA", 18, true),
|
||||
newErc20Contract("AirSwap Token", NetworkType.Mainnet, parseAddress("0x27054b13b1b798b345b591a4d22e6562d47ea75a"), "AST", 4, true),
|
||||
newErc20Contract("R token", NetworkType.Mainnet, parseAddress("0x48f775efbe4f5ece6e0df2f7b5932df56823b990"), "R", 0, true),
|
||||
newErc20Contract("FirstBlood Token", NetworkType.Mainnet, parseAddress("0xaf30d2a7e90d7dc361c8c4585e9bb7d2f6f15bc7"), "1ST", 18, true),
|
||||
newErc20Contract("Cofoundit", NetworkType.Mainnet, parseAddress("0x12fef5e57bf45873cd9b62e9dbd7bfb99e32d73e"), "CFI", 18, true),
|
||||
newErc20Contract("Enigma", NetworkType.Mainnet, parseAddress("0xf0ee6b27b759c9893ce4f094b49ad28fd15a23e4"), "ENG", 8, true),
|
||||
newErc20Contract("Amber Token", NetworkType.Mainnet, parseAddress("0x4dc3643dbc642b72c158e7f3d2ff232df61cb6ce"), "AMB", 18, true),
|
||||
newErc20Contract("XPlay Token", NetworkType.Mainnet, parseAddress("0x90528aeb3a2b736b780fd1b6c478bb7e1d643170"), "XPA", 18, true),
|
||||
newErc20Contract("Open Trading Network", NetworkType.Mainnet, parseAddress("0x881ef48211982d01e2cb7092c915e647cd40d85c"), "OTN", 18, true),
|
||||
newErc20Contract("Trustcoin", NetworkType.Mainnet, parseAddress("0xcb94be6f13a1182e4a4b6140cb7bf2025d28e41b"), "TRST", 6, true),
|
||||
newErc20Contract("Monolith TKN", NetworkType.Mainnet, parseAddress("0xaaaf91d9b90df800df4f55c205fd6989c977e73a"), "TKN", 8, true),
|
||||
newErc20Contract("RHOC", NetworkType.Mainnet, parseAddress("0x168296bb09e24a88805cb9c33356536b980d3fc5"), "RHOC", 8, true),
|
||||
newErc20Contract("Target Coin", NetworkType.Mainnet, parseAddress("0xac3da587eac229c9896d919abc235ca4fd7f72c1"), "TGT", 1, false),
|
||||
newErc20Contract("Everex", NetworkType.Mainnet, parseAddress("0xf3db5fa2c66b7af3eb0c0b782510816cbe4813b8"), "EVX", 4, true),
|
||||
newErc20Contract("ICOS", NetworkType.Mainnet, parseAddress("0x014b50466590340d41307cc54dcee990c8d58aa8"), "ICOS", 6, true),
|
||||
newErc20Contract("district0x Network Token", NetworkType.Mainnet, parseAddress("0x0abdace70d3790235af448c88547603b945604ea"), "DNT", 18, true),
|
||||
newErc20Contract("Dentacoin", NetworkType.Mainnet, parseAddress("0x08d32b0da63e2c3bcf8019c9c5d849d7a9d791e6"), "٨", 0, false),
|
||||
newErc20Contract("Eidoo Token", NetworkType.Mainnet, parseAddress("0xced4e93198734ddaff8492d525bd258d49eb388e"), "EDO", 18, true),
|
||||
newErc20Contract("BitDice", NetworkType.Mainnet, parseAddress("0x29d75277ac7f0335b2165d0895e8725cbf658d73"), "CSNO", 8, false),
|
||||
newErc20Contract("Cobinhood Token", NetworkType.Mainnet, parseAddress("0xb2f7eb1f2c37645be61d73953035360e768d81e6"), "COB", 18, true),
|
||||
newErc20Contract("Enjin Coin", NetworkType.Mainnet, parseAddress("0xf629cbd94d3791c9250152bd8dfbdf380e2a3b9c"), "ENJ", 18, false),
|
||||
newErc20Contract("AVENTUS", NetworkType.Mainnet, parseAddress("0x0d88ed6e74bbfd96b831231638b66c05571e824f"), "AVT", 18, false),
|
||||
newErc20Contract("Chronobank TIME", NetworkType.Mainnet, parseAddress("0x6531f133e6deebe7f2dce5a0441aa7ef330b4e53"), "TIME", 8, false),
|
||||
newErc20Contract("Cindicator Token", NetworkType.Mainnet, parseAddress("0xd4c435f5b09f855c3317c8524cb1f586e42795fa"), "CND", 18, true),
|
||||
newErc20Contract("Stox", NetworkType.Mainnet, parseAddress("0x006bea43baa3f7a6f765f14f10a1a1b08334ef45"), "STX", 18, true),
|
||||
newErc20Contract("Xaurum", NetworkType.Mainnet, parseAddress("0x4df812f6064def1e5e029f1ca858777cc98d2d81"), "XAUR", 8, true),
|
||||
newErc20Contract("Vibe", NetworkType.Mainnet, parseAddress("0x2c974b2d0ba1716e644c1fc59982a89ddd2ff724"), "VIB", 18, true),
|
||||
newErc20Contract("PRG", NetworkType.Mainnet, parseAddress("0x7728dfef5abd468669eb7f9b48a7f70a501ed29d"), "PRG", 6, false),
|
||||
newErc20Contract("Delphy Token", NetworkType.Mainnet, parseAddress("0x6c2adc2073994fb2ccc5032cc2906fa221e9b391"), "DPY", 18, true),
|
||||
newErc20Contract("CoinDash Token", NetworkType.Mainnet, parseAddress("0x2fe6ab85ebbf7776fee46d191ee4cea322cecf51"), "CDT", 18, true),
|
||||
newErc20Contract("Tierion Network Token", NetworkType.Mainnet, parseAddress("0x08f5a9235b08173b7569f83645d2c7fb55e8ccd8"), "TNT", 8, true),
|
||||
newErc20Contract("DomRaiderToken", NetworkType.Mainnet, parseAddress("0x9af4f26941677c706cfecf6d3379ff01bb85d5ab"), "DRT", 8, true),
|
||||
newErc20Contract("SPANK", NetworkType.Mainnet, parseAddress("0x42d6622dece394b54999fbd73d108123806f6a18"), "SPANK", 18, true),
|
||||
newErc20Contract("Berlin Coin", NetworkType.Mainnet, parseAddress("0x80046305aaab08f6033b56a360c184391165dc2d"), "BRLN", 18, true),
|
||||
newErc20Contract("USD//C", NetworkType.Mainnet, parseAddress("0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"), "USDC", 6, true),
|
||||
newErc20Contract("Livepeer Token", NetworkType.Mainnet, parseAddress("0x58b6a8a3302369daec383334672404ee733ab239"), "LPT", 18, true),
|
||||
newErc20Contract("Simple Token", NetworkType.Mainnet, parseAddress("0x2c4e8f2d746113d0696ce89b35f0d8bf88e0aeca"), "ST", 18, true),
|
||||
newErc20Contract("Wrapped BTC", NetworkType.Mainnet, parseAddress("0x2260fac5e5542a773aa44fbcfedf7c193bc2c599"), "WBTC", 8, true),
|
||||
newErc20Contract("Bloom Token", NetworkType.Mainnet, parseAddress("0x107c4504cd79c5d2696ea0030a8dd4e92601b82e"), "BLT", 18, true),
|
||||
newErc20Contract("Unisocks", NetworkType.Mainnet, parseAddress("0x23b608675a2b2fb1890d3abbd85c5775c51691d5"), "SOCKS", 18, true),
|
||||
newErc20Contract("Hermez Network Token", NetworkType.Mainnet, parseAddress("0xEEF9f339514298C6A857EfCfC1A762aF84438dEE"), "HEZ", 18, true),
|
||||
Contract(name: "stickers", network: NetworkType.Mainnet, address: parseAddress("0x0577215622f43a39f4bc9640806dfea9b10d2a36"),
|
||||
newErc20Contract("Status Network Token", Mainnet, parseAddress("0x744d70fdbe2ba4cf95131626614a1763df805b9e"), "SNT", 18, true),
|
||||
newErc20Contract("Dai Stablecoin", Mainnet, parseAddress("0x6b175474e89094c44da98b954eedeac495271d0f"), "DAI", 18, true),
|
||||
newErc20Contract("Sai Stablecoin v1.0", Mainnet, parseAddress("0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359"), "SAI", 18, true),
|
||||
newErc20Contract("MKR", Mainnet, parseAddress("0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2"), "MKR", 18, true),
|
||||
newErc20Contract("EOS", Mainnet, parseAddress("0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0"), "EOS", 18, true),
|
||||
newErc20Contract("OMGToken", Mainnet, parseAddress("0xd26114cd6ee289accf82350c8d8487fedb8a0c07"), "OMG", 18, true),
|
||||
newErc20Contract("Populous Platform", Mainnet, parseAddress("0xd4fa1460f537bb9085d22c7bccb5dd450ef28e3a"), "PPT", 8, true),
|
||||
newErc20Contract("Reputation", Mainnet, parseAddress("0x1985365e9f78359a9b6ad760e32412f4a445e862"), "REP", 18, true),
|
||||
newErc20Contract("PowerLedger", Mainnet, parseAddress("0x595832f8fc6bf59c85c527fec3740a1b7a361269"), "POWR", 6, true),
|
||||
newErc20Contract("TenX Pay Token", Mainnet, parseAddress("0xb97048628db6b661d4c2aa833e95dbe1a905b280"), "PAY", 18, true),
|
||||
newErc20Contract("Veros", Mainnet, parseAddress("0x92e78dae1315067a8819efd6dca432de9dcde2e9"), "VRS", 6, false),
|
||||
newErc20Contract("Golem Network Token", Mainnet, parseAddress("0xa74476443119a942de498590fe1f2454d7d4ac0d"), "GNT", 18, true),
|
||||
newErc20Contract("Salt", Mainnet, parseAddress("0x4156d3342d5c385a87d264f90653733592000581"), "SALT", 8, true),
|
||||
newErc20Contract("BNB", Mainnet, parseAddress("0xb8c77482e45f1f44de1745f52c74426c631bdd52"), "BNB", 18, true),
|
||||
newErc20Contract("Basic Attention Token", Mainnet, parseAddress("0x0d8775f648430679a709e98d2b0cb6250d2887ef"), "BAT", 18, true),
|
||||
newErc20Contract("Kyber Network Crystal", Mainnet, parseAddress("0xdd974d5c2e2928dea5f71b9825b8b646686bd200"), "KNC", 18, true),
|
||||
newErc20Contract("BTU Protocol", Mainnet, parseAddress("0xb683D83a532e2Cb7DFa5275eED3698436371cc9f"), "BTU", 18, true),
|
||||
newErc20Contract("Digix DAO", Mainnet, parseAddress("0xe0b7927c4af23765cb51314a0e0521a9645f0e2a"), "DGD", 9, true),
|
||||
newErc20Contract("Aeternity", Mainnet, parseAddress("0x5ca9a71b1d01849c0a95490cc00559717fcf0d1d"), "AE", 18, true),
|
||||
newErc20Contract("Tronix", Mainnet, parseAddress("0xf230b790e05390fc8295f4d3f60332c93bed42e2"), "TRX", 6, true),
|
||||
newErc20Contract("Ethos", Mainnet, parseAddress("0x5af2be193a6abca9c8817001f45744777db30756"), "ETHOS", 8, true),
|
||||
newErc20Contract("Raiden Token", Mainnet, parseAddress("0x255aa6df07540cb5d3d297f0d0d4d84cb52bc8e6"), "RDN", 18, true),
|
||||
newErc20Contract("SingularDTV", Mainnet, parseAddress("0xaec2e87e0a235266d9c5adc9deb4b2e29b54d009"), "SNGLS", 0, true),
|
||||
newErc20Contract("Gnosis Token", Mainnet, parseAddress("0x6810e776880c02933d47db1b9fc05908e5386b96"), "GNO", 18, true),
|
||||
newErc20Contract("StorjToken", Mainnet, parseAddress("0xb64ef51c888972c908cfacf59b47c1afbc0ab8ac"), "STORJ", 8, true),
|
||||
newErc20Contract("AdEx", Mainnet, parseAddress("0x4470bb87d77b963a013db939be332f927f2b992e"), "ADX", 4, false),
|
||||
newErc20Contract("FunFair", Mainnet, parseAddress("0x419d0d8bdd9af5e606ae2232ed285aff190e711b"), "FUN", 8, true),
|
||||
newErc20Contract("Civic", Mainnet, parseAddress("0x41e5560054824ea6b0732e656e3ad64e20e94e45"), "CVC", 8, true),
|
||||
newErc20Contract("ICONOMI", Mainnet, parseAddress("0x888666ca69e0f178ded6d75b5726cee99a87d698"), "ICN", 18, true),
|
||||
newErc20Contract("Walton Token", Mainnet, parseAddress("0xb7cb1c96db6b22b0d3d9536e0108d062bd488f74"), "WTC", 18, true),
|
||||
newErc20Contract("Bytom", Mainnet, parseAddress("0xcb97e65f07da24d46bcdd078ebebd7c6e6e3d750"), "BTM", 8, true),
|
||||
newErc20Contract("0x Protocol Token", Mainnet, parseAddress("0xe41d2489571d322189246dafa5ebde1f4699f498"), "ZRX", 18, true),
|
||||
newErc20Contract("Bancor Network Token", Mainnet, parseAddress("0x1f573d6fb3f13d689ff844b4ce37794d79a7ff1c"), "BNT", 18, true),
|
||||
newErc20Contract("Metal", Mainnet, parseAddress("0xf433089366899d83a9f26a773d59ec7ecf30355e"), "MTL", 8, false),
|
||||
newErc20Contract("PayPie", Mainnet, parseAddress("0xc42209accc14029c1012fb5680d95fbd6036e2a0"), "PPP", 18, true),
|
||||
newErc20Contract("ChainLink Token", Mainnet, parseAddress("0x514910771af9ca656af840dff83e8264ecf986ca"), "LINK", 18, true),
|
||||
newErc20Contract("Kin", Mainnet, parseAddress("0x818fc6c2ec5986bc6e2cbf00939d90556ab12ce5"), "KIN", 18, true),
|
||||
newErc20Contract("Aragon Network Token", Mainnet, parseAddress("0x960b236a07cf122663c4303350609a66a7b288c0"), "ANT", 18, true),
|
||||
newErc20Contract("MobileGo Token", Mainnet, parseAddress("0x40395044ac3c0c57051906da938b54bd6557f212"), "MGO", 8, true),
|
||||
newErc20Contract("Monaco", Mainnet, parseAddress("0xb63b606ac810a52cca15e44bb630fd42d8d1d83d"), "MCO", 8, true),
|
||||
newErc20Contract("loopring", Mainnet, parseAddress("0xef68e7c694f40c8202821edf525de3782458639f"), "LRC", 18, true),
|
||||
newErc20Contract("Zeus Shield Coin", Mainnet, parseAddress("0x7a41e0517a5eca4fdbc7fbeba4d4c47b9ff6dc63"), "ZSC", 18, true),
|
||||
newErc20Contract("Streamr DATAcoin", Mainnet, parseAddress("0x0cf0ee63788a0849fe5297f3407f701e122cc023"), "DATA", 18, true),
|
||||
newErc20Contract("Ripio Credit Network Token", Mainnet, parseAddress("0xf970b8e36e23f7fc3fd752eea86f8be8d83375a6"), "RCN", 18, true),
|
||||
newErc20Contract("WINGS", Mainnet, parseAddress("0x667088b212ce3d06a1b553a7221e1fd19000d9af"), "WINGS", 18, true),
|
||||
newErc20Contract("Edgeless", Mainnet, parseAddress("0x08711d3b02c8758f2fb3ab4e80228418a7f8e39c"), "EDG", 0, true),
|
||||
newErc20Contract("Melon Token", Mainnet, parseAddress("0xbeb9ef514a379b997e0798fdcc901ee474b6d9a1"), "MLN", 18, true),
|
||||
newErc20Contract("Moeda Loyalty Points", Mainnet, parseAddress("0x51db5ad35c671a87207d88fc11d593ac0c8415bd"), "MDA", 18, true),
|
||||
newErc20Contract("PILLAR", Mainnet, parseAddress("0xe3818504c1b32bf1557b16c238b2e01fd3149c17"), "PLR", 18, true),
|
||||
newErc20Contract("QRL", Mainnet, parseAddress("0x697beac28b09e122c4332d163985e8a73121b97f"), "QRL", 8, true),
|
||||
newErc20Contract("Modum Token", Mainnet, parseAddress("0x957c30ab0426e0c93cd8241e2c60392d08c6ac8e"), "MOD", 0, true),
|
||||
newErc20Contract("Token-as-a-Service", Mainnet, parseAddress("0xe7775a6e9bcf904eb39da2b68c5efb4f9360e08c"), "TAAS", 6, true),
|
||||
newErc20Contract("GRID Token", Mainnet, parseAddress("0x12b19d3e2ccc14da04fae33e63652ce469b3f2fd"), "GRID", 12, true),
|
||||
newErc20Contract("SANtiment network token", Mainnet, parseAddress("0x7c5a0ce9267ed19b22f8cae653f198e3e8daf098"), "SAN", 18, true),
|
||||
newErc20Contract("SONM Token", Mainnet, parseAddress("0x983f6d60db79ea8ca4eb9968c6aff8cfa04b3c63"), "SNM", 18, true),
|
||||
newErc20Contract("Request Token", Mainnet, parseAddress("0x8f8221afbb33998d8584a2b05749ba73c37a938a"), "REQ", 18, true),
|
||||
newErc20Contract("Substratum", Mainnet, parseAddress("0x12480e24eb5bec1a9d4369cab6a80cad3c0a377a"), "SUB", 2, true),
|
||||
newErc20Contract("Decentraland MANA", Mainnet, parseAddress("0x0f5d2fb29fb7d3cfee444a200298f468908cc942"), "MANA", 18, true),
|
||||
newErc20Contract("AirSwap Token", Mainnet, parseAddress("0x27054b13b1b798b345b591a4d22e6562d47ea75a"), "AST", 4, true),
|
||||
newErc20Contract("R token", Mainnet, parseAddress("0x48f775efbe4f5ece6e0df2f7b5932df56823b990"), "R", 0, true),
|
||||
newErc20Contract("FirstBlood Token", Mainnet, parseAddress("0xaf30d2a7e90d7dc361c8c4585e9bb7d2f6f15bc7"), "1ST", 18, true),
|
||||
newErc20Contract("Cofoundit", Mainnet, parseAddress("0x12fef5e57bf45873cd9b62e9dbd7bfb99e32d73e"), "CFI", 18, true),
|
||||
newErc20Contract("Enigma", Mainnet, parseAddress("0xf0ee6b27b759c9893ce4f094b49ad28fd15a23e4"), "ENG", 8, true),
|
||||
newErc20Contract("Amber Token", Mainnet, parseAddress("0x4dc3643dbc642b72c158e7f3d2ff232df61cb6ce"), "AMB", 18, true),
|
||||
newErc20Contract("XPlay Token", Mainnet, parseAddress("0x90528aeb3a2b736b780fd1b6c478bb7e1d643170"), "XPA", 18, true),
|
||||
newErc20Contract("Open Trading Network", Mainnet, parseAddress("0x881ef48211982d01e2cb7092c915e647cd40d85c"), "OTN", 18, true),
|
||||
newErc20Contract("Trustcoin", Mainnet, parseAddress("0xcb94be6f13a1182e4a4b6140cb7bf2025d28e41b"), "TRST", 6, true),
|
||||
newErc20Contract("Monolith TKN", Mainnet, parseAddress("0xaaaf91d9b90df800df4f55c205fd6989c977e73a"), "TKN", 8, true),
|
||||
newErc20Contract("RHOC", Mainnet, parseAddress("0x168296bb09e24a88805cb9c33356536b980d3fc5"), "RHOC", 8, true),
|
||||
newErc20Contract("Target Coin", Mainnet, parseAddress("0xac3da587eac229c9896d919abc235ca4fd7f72c1"), "TGT", 1, false),
|
||||
newErc20Contract("Everex", Mainnet, parseAddress("0xf3db5fa2c66b7af3eb0c0b782510816cbe4813b8"), "EVX", 4, true),
|
||||
newErc20Contract("ICOS", Mainnet, parseAddress("0x014b50466590340d41307cc54dcee990c8d58aa8"), "ICOS", 6, true),
|
||||
newErc20Contract("district0x Network Token", Mainnet, parseAddress("0x0abdace70d3790235af448c88547603b945604ea"), "DNT", 18, true),
|
||||
newErc20Contract("Dentacoin", Mainnet, parseAddress("0x08d32b0da63e2c3bcf8019c9c5d849d7a9d791e6"), "٨", 0, false),
|
||||
newErc20Contract("Eidoo Token", Mainnet, parseAddress("0xced4e93198734ddaff8492d525bd258d49eb388e"), "EDO", 18, true),
|
||||
newErc20Contract("BitDice", Mainnet, parseAddress("0x29d75277ac7f0335b2165d0895e8725cbf658d73"), "CSNO", 8, false),
|
||||
newErc20Contract("Cobinhood Token", Mainnet, parseAddress("0xb2f7eb1f2c37645be61d73953035360e768d81e6"), "COB", 18, true),
|
||||
newErc20Contract("Enjin Coin", Mainnet, parseAddress("0xf629cbd94d3791c9250152bd8dfbdf380e2a3b9c"), "ENJ", 18, false),
|
||||
newErc20Contract("AVENTUS", Mainnet, parseAddress("0x0d88ed6e74bbfd96b831231638b66c05571e824f"), "AVT", 18, false),
|
||||
newErc20Contract("Chronobank TIME", Mainnet, parseAddress("0x6531f133e6deebe7f2dce5a0441aa7ef330b4e53"), "TIME", 8, false),
|
||||
newErc20Contract("Cindicator Token", Mainnet, parseAddress("0xd4c435f5b09f855c3317c8524cb1f586e42795fa"), "CND", 18, true),
|
||||
newErc20Contract("Stox", Mainnet, parseAddress("0x006bea43baa3f7a6f765f14f10a1a1b08334ef45"), "STX", 18, true),
|
||||
newErc20Contract("Xaurum", Mainnet, parseAddress("0x4df812f6064def1e5e029f1ca858777cc98d2d81"), "XAUR", 8, true),
|
||||
newErc20Contract("Vibe", Mainnet, parseAddress("0x2c974b2d0ba1716e644c1fc59982a89ddd2ff724"), "VIB", 18, true),
|
||||
newErc20Contract("PRG", Mainnet, parseAddress("0x7728dfef5abd468669eb7f9b48a7f70a501ed29d"), "PRG", 6, false),
|
||||
newErc20Contract("Delphy Token", Mainnet, parseAddress("0x6c2adc2073994fb2ccc5032cc2906fa221e9b391"), "DPY", 18, true),
|
||||
newErc20Contract("CoinDash Token", Mainnet, parseAddress("0x2fe6ab85ebbf7776fee46d191ee4cea322cecf51"), "CDT", 18, true),
|
||||
newErc20Contract("Tierion Network Token", Mainnet, parseAddress("0x08f5a9235b08173b7569f83645d2c7fb55e8ccd8"), "TNT", 8, true),
|
||||
newErc20Contract("DomRaiderToken", Mainnet, parseAddress("0x9af4f26941677c706cfecf6d3379ff01bb85d5ab"), "DRT", 8, true),
|
||||
newErc20Contract("SPANK", Mainnet, parseAddress("0x42d6622dece394b54999fbd73d108123806f6a18"), "SPANK", 18, true),
|
||||
newErc20Contract("Berlin Coin", Mainnet, parseAddress("0x80046305aaab08f6033b56a360c184391165dc2d"), "BRLN", 18, true),
|
||||
newErc20Contract("USD//C", Mainnet, parseAddress("0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"), "USDC", 6, true),
|
||||
newErc20Contract("Livepeer Token", Mainnet, parseAddress("0x58b6a8a3302369daec383334672404ee733ab239"), "LPT", 18, true),
|
||||
newErc20Contract("Simple Token", Mainnet, parseAddress("0x2c4e8f2d746113d0696ce89b35f0d8bf88e0aeca"), "ST", 18, true),
|
||||
newErc20Contract("Wrapped BTC", Mainnet, parseAddress("0x2260fac5e5542a773aa44fbcfedf7c193bc2c599"), "WBTC", 8, true),
|
||||
newErc20Contract("Bloom Token", Mainnet, parseAddress("0x107c4504cd79c5d2696ea0030a8dd4e92601b82e"), "BLT", 18, true),
|
||||
newErc20Contract("Unisocks", Mainnet, parseAddress("0x23b608675a2b2fb1890d3abbd85c5775c51691d5"), "SOCKS", 18, true),
|
||||
newErc20Contract("Hermez Network Token", Mainnet, parseAddress("0xEEF9f339514298C6A857EfCfC1A762aF84438dEE"), "HEZ", 18, true),
|
||||
Contract(name: "stickers", chainId: Mainnet, address: parseAddress("0x0577215622f43a39f4bc9640806dfea9b10d2a36"),
|
||||
methods: [
|
||||
("packCount", Method(signature: "packCount()")),
|
||||
("getPackData", Method(signature: "getPackData(uint256)"))
|
||||
].toTable
|
||||
),
|
||||
Contract(name: "sticker-market", network: NetworkType.Mainnet, address: parseAddress("0x12824271339304d3a9f7e096e62a2a7e73b4a7e7"),
|
||||
Contract(name: "sticker-market", chainId: Mainnet, address: parseAddress("0x12824271339304d3a9f7e096e62a2a7e73b4a7e7"),
|
||||
methods: [
|
||||
("buyToken", Method(signature: "buyToken(uint256,address,uint256)"))
|
||||
].toTable
|
||||
),
|
||||
newErc721Contract("sticker-pack", NetworkType.Mainnet, parseAddress("0x110101156e8F0743948B2A61aFcf3994A8Fb172e"), "PACK", false, @[("tokenPackId", Method(signature: "tokenPackId(uint256)"))]),
|
||||
newErc721Contract("sticker-pack", Mainnet, parseAddress("0x110101156e8F0743948B2A61aFcf3994A8Fb172e"), "PACK", false, @[("tokenPackId", Method(signature: "tokenPackId(uint256)"))]),
|
||||
# Strikers seems dead. Their website doesn't work anymore
|
||||
newErc721Contract("strikers", NetworkType.Mainnet, parseAddress("0xdcaad9fd9a74144d226dbf94ce6162ca9f09ed7e"), "STRK", true),
|
||||
newErc721Contract("ethermon", NetworkType.Mainnet, parseAddress("0xb2c0782ae4a299f7358758b2d15da9bf29e1dd99"), "EMONA", true),
|
||||
newErc721Contract("kudos", NetworkType.Mainnet, parseAddress("0x2aea4add166ebf38b63d09a75de1a7b94aa24163"), "KDO", true),
|
||||
newErc721Contract("crypto-kitties", NetworkType.Mainnet, parseAddress("0x06012c8cf97bead5deae237070f9587f8e7a266d"), "CK", true),
|
||||
Contract(name: "ens-usernames", network: NetworkType.Mainnet, address: parseAddress("0xDB5ac1a559b02E12F29fC0eC0e37Be8E046DEF49"),
|
||||
newErc721Contract("strikers", Mainnet, parseAddress("0xdcaad9fd9a74144d226dbf94ce6162ca9f09ed7e"), "STRK", true),
|
||||
newErc721Contract("ethermon", Mainnet, parseAddress("0xb2c0782ae4a299f7358758b2d15da9bf29e1dd99"), "EMONA", true),
|
||||
newErc721Contract("kudos", Mainnet, parseAddress("0x2aea4add166ebf38b63d09a75de1a7b94aa24163"), "KDO", true),
|
||||
newErc721Contract("crypto-kitties", Mainnet, parseAddress("0x06012c8cf97bead5deae237070f9587f8e7a266d"), "CK", true),
|
||||
Contract(name: "ens-usernames", chainId: Mainnet, address: parseAddress("0xDB5ac1a559b02E12F29fC0eC0e37Be8E046DEF49"),
|
||||
methods: [
|
||||
("register", Method(signature: "register(bytes32,address,bytes32,bytes32)")),
|
||||
("getPrice", Method(signature: "getPrice()")),
|
||||
|
@ -210,34 +209,34 @@ proc allContracts(): seq[Contract] =
|
|||
("release", Method(signature: "release(bytes32)"))
|
||||
].toTable
|
||||
),
|
||||
Contract(name: "ens-resolver", network: NetworkType.Mainnet, address: parseAddress("0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41"),
|
||||
Contract(name: "ens-resolver", chainId: Mainnet, address: parseAddress("0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41"),
|
||||
methods: [
|
||||
("setPubkey", Method(signature: "setPubkey(bytes32,bytes32,bytes32)"))
|
||||
].toTable
|
||||
),
|
||||
|
||||
# Testnet (Ropsten) contracts
|
||||
newErc20Contract("Status Test Token", NetworkType.Testnet, parseAddress("0xc55cf4b03948d7ebc8b9e8bad92643703811d162"), "STT", 18, true),
|
||||
newErc20Contract("Handy Test Token", NetworkType.Testnet, parseAddress("0xdee43a267e8726efd60c2e7d5b81552dcd4fa35c"), "HND", 0, false),
|
||||
newErc20Contract("Lucky Test Token", NetworkType.Testnet, parseAddress("0x703d7dc0bc8e314d65436adf985dda51e09ad43b"), "LXS", 2, false),
|
||||
newErc20Contract("Adi Test Token", NetworkType.Testnet, parseAddress("0xe639e24346d646e927f323558e6e0031bfc93581"), "ADI", 7, false),
|
||||
newErc20Contract("Wagner Test Token", NetworkType.Testnet, parseAddress("0x2e7cd05f437eb256f363417fd8f920e2efa77540"), "WGN", 10, false),
|
||||
newErc20Contract("Modest Test Token", NetworkType.Testnet, parseAddress("0x57cc9b83730e6d22b224e9dc3e370967b44a2de0"), "MDS", 18, false),
|
||||
Contract(name: "tribute-to-talk", network: NetworkType.Testnet, address: parseAddress("0xC61aa0287247a0398589a66fCD6146EC0F295432")),
|
||||
Contract(name: "stickers", network: NetworkType.Testnet, address: parseAddress("0x8cc272396be7583c65bee82cd7b743c69a87287d"),
|
||||
newErc20Contract("Status Test Token", Ropsten, parseAddress("0xc55cf4b03948d7ebc8b9e8bad92643703811d162"), "STT", 18, true),
|
||||
newErc20Contract("Handy Test Token", Ropsten, parseAddress("0xdee43a267e8726efd60c2e7d5b81552dcd4fa35c"), "HND", 0, false),
|
||||
newErc20Contract("Lucky Test Token", Ropsten, parseAddress("0x703d7dc0bc8e314d65436adf985dda51e09ad43b"), "LXS", 2, false),
|
||||
newErc20Contract("Adi Test Token", Ropsten, parseAddress("0xe639e24346d646e927f323558e6e0031bfc93581"), "ADI", 7, false),
|
||||
newErc20Contract("Wagner Test Token", Ropsten, parseAddress("0x2e7cd05f437eb256f363417fd8f920e2efa77540"), "WGN", 10, false),
|
||||
newErc20Contract("Modest Test Token", Ropsten, parseAddress("0x57cc9b83730e6d22b224e9dc3e370967b44a2de0"), "MDS", 18, false),
|
||||
Contract(name: "tribute-to-talk", chainId: Ropsten, address: parseAddress("0xC61aa0287247a0398589a66fCD6146EC0F295432")),
|
||||
Contract(name: "stickers", chainId: Ropsten, address: parseAddress("0x8cc272396be7583c65bee82cd7b743c69a87287d"),
|
||||
methods: [
|
||||
("packCount", Method(signature: "packCount()")),
|
||||
("getPackData", Method(signature: "getPackData(uint256)"))
|
||||
].toTable
|
||||
),
|
||||
Contract(name: "sticker-market", network: NetworkType.Testnet, address: parseAddress("0x6CC7274aF9cE9572d22DFD8545Fb8c9C9Bcb48AD"),
|
||||
Contract(name: "sticker-market", chainId: Ropsten, address: parseAddress("0x6CC7274aF9cE9572d22DFD8545Fb8c9C9Bcb48AD"),
|
||||
methods: [
|
||||
("buyToken", Method(signature: "buyToken(uint256,address,uint256)"))
|
||||
].toTable
|
||||
),
|
||||
newErc721Contract("sticker-pack", NetworkType.Testnet, parseAddress("0xf852198d0385c4b871e0b91804ecd47c6ba97351"), "PACK", false, @[("tokenPackId", Method(signature: "tokenPackId(uint256)"))]),
|
||||
newErc721Contract("kudos", NetworkType.Testnet, parseAddress("0xcd520707fc68d153283d518b29ada466f9091ea8"), "KDO", true),
|
||||
Contract(name: "ens-usernames", network: NetworkType.Testnet, address: parseAddress("0xdaae165beb8c06e0b7613168138ebba774aff071"),
|
||||
newErc721Contract("sticker-pack", Ropsten, parseAddress("0xf852198d0385c4b871e0b91804ecd47c6ba97351"), "PACK", false, @[("tokenPackId", Method(signature: "tokenPackId(uint256)"))]),
|
||||
newErc721Contract("kudos", Ropsten, parseAddress("0xcd520707fc68d153283d518b29ada466f9091ea8"), "KDO", true),
|
||||
Contract(name: "ens-usernames", chainId: Ropsten, address: parseAddress("0xdaae165beb8c06e0b7613168138ebba774aff071"),
|
||||
methods: [
|
||||
("register", Method(signature: "register(bytes32,address,bytes32,bytes32)")),
|
||||
("getPrice", Method(signature: "getPrice()")),
|
||||
|
@ -245,76 +244,56 @@ proc allContracts(): seq[Contract] =
|
|||
("release", Method(signature: "release(bytes32)"))
|
||||
].toTable
|
||||
),
|
||||
Contract(name: "ens-resolver", network: NetworkType.Testnet, address: parseAddress("0x42D63ae25990889E35F215bC95884039Ba354115"),
|
||||
Contract(name: "ens-resolver", chainId: Ropsten, address: parseAddress("0x42D63ae25990889E35F215bC95884039Ba354115"),
|
||||
methods: [
|
||||
("setPubkey", Method(signature: "setPubkey(bytes32,bytes32,bytes32)"))
|
||||
].toTable
|
||||
),
|
||||
|
||||
# Rinkeby contracts
|
||||
newErc20Contract("Moksha Coin", NetworkType.Rinkeby, parseAddress("0x6ba7dc8dd10880ab83041e60c4ede52bb607864b"), "MOKSHA", 18, false),
|
||||
newErc20Contract("WIBB", NetworkType.Rinkeby, parseAddress("0x7d4ccf6af2f0fdad48ee7958bcc28bdef7b732c7"), "WIBB", 18, false),
|
||||
newErc20Contract("Status Test Token", NetworkType.Rinkeby, parseAddress("0x43d5adc3b49130a575ae6e4b00dfa4bc55c71621"), "STT", 18, false),
|
||||
newErc20Contract("Moksha Coin", Rinkeby, parseAddress("0x6ba7dc8dd10880ab83041e60c4ede52bb607864b"), "MOKSHA", 18, false),
|
||||
newErc20Contract("WIBB", Rinkeby, parseAddress("0x7d4ccf6af2f0fdad48ee7958bcc28bdef7b732c7"), "WIBB", 18, false),
|
||||
newErc20Contract("Status Test Token", Rinkeby, parseAddress("0x43d5adc3b49130a575ae6e4b00dfa4bc55c71621"), "STT", 18, false),
|
||||
|
||||
# xDai contracts
|
||||
newErc20Contract("buffiDai", NetworkType.XDai, parseAddress("0x3e50bf6703fc132a94e4baff068db2055655f11b"), "BUFF", 18, false),
|
||||
newErc20Contract("buffiDai", XDai, parseAddress("0x3e50bf6703fc132a94e4baff068db2055655f11b"), "BUFF", 18, false),
|
||||
|
||||
newErc20Contract("Uniswap", NetworkType.Mainnet, parseAddress("0x1f9840a85d5af5bf1d1762f925bdaddc4201f984"), "UNI", 18, true),
|
||||
newErc20Contract("Compound", NetworkType.Mainnet, parseAddress("0xc00e94cb662c3520282e6f5717214004a7f26888"), "COMP", 18, true),
|
||||
newErc20Contract("Balancer", NetworkType.Mainnet, parseAddress("0xba100000625a3754423978a60c9317c58a424e3d"), "BAL", 18, true),
|
||||
newErc20Contract("Akropolis", NetworkType.Mainnet, parseAddress("0x8ab7404063ec4dbcfd4598215992dc3f8ec853d7"), "AKRO", 18, true),
|
||||
newErc20Contract("Orchid", NetworkType.Mainnet, parseAddress("0x4575f41308EC1483f3d399aa9a2826d74Da13Deb"), "OXT", 18, false),
|
||||
newErc20Contract("Uniswap", Mainnet, parseAddress("0x1f9840a85d5af5bf1d1762f925bdaddc4201f984"), "UNI", 18, true),
|
||||
newErc20Contract("Compound", Mainnet, parseAddress("0xc00e94cb662c3520282e6f5717214004a7f26888"), "COMP", 18, true),
|
||||
newErc20Contract("Balancer", Mainnet, parseAddress("0xba100000625a3754423978a60c9317c58a424e3d"), "BAL", 18, true),
|
||||
newErc20Contract("Akropolis", Mainnet, parseAddress("0x8ab7404063ec4dbcfd4598215992dc3f8ec853d7"), "AKRO", 18, true),
|
||||
newErc20Contract("Orchid", Mainnet, parseAddress("0x4575f41308EC1483f3d399aa9a2826d74Da13Deb"), "OXT", 18, false),
|
||||
]
|
||||
contractsInited = true
|
||||
result = contracts
|
||||
|
||||
proc getContract(network: NetworkType, name: string): Contract =
|
||||
let found = allContracts().filter(contract => contract.name == name and contract.network == network)
|
||||
result = if found.len > 0: found[0] else: nil
|
||||
|
||||
proc getContract*(name: string): Contract =
|
||||
let network = settings.getCurrentNetwork()
|
||||
getContract(network, name)
|
||||
|
||||
proc getErc20ContractBySymbol*(contracts: seq[Erc20Contract], symbol: string): Erc20Contract =
|
||||
let found = contracts.filter(contract => contract.symbol.toLower == symbol.toLower)
|
||||
result = if found.len > 0: found[0] else: nil
|
||||
|
||||
proc getErc20ContractByAddress*(contracts: seq[Erc20Contract], address: Address): Erc20Contract =
|
||||
proc findByAddress*(contracts: seq[Erc20Contract], address: Address): Erc20Contract =
|
||||
let found = contracts.filter(contract => contract.address == address)
|
||||
result = if found.len > 0: found[0] else: nil
|
||||
|
||||
proc getErc20Contract*(symbol: string): Erc20Contract =
|
||||
let network = settings.getCurrentNetwork()
|
||||
result = allContracts().filter(contract => contract.network == network and contract of Erc20Contract).map(contract => Erc20Contract(contract)).getErc20ContractBySymbol(symbol)
|
||||
proc findBySymbol*(contracts: seq[Erc20Contract], symbol: string): Erc20Contract =
|
||||
let found = contracts.filter(contract => contract.symbol.toLower == symbol.toLower)
|
||||
result = if found.len > 0: found[0] else: nil
|
||||
|
||||
proc getErc20Contract*(address: Address): Erc20Contract =
|
||||
let network = settings.getCurrentNetwork()
|
||||
result = allContracts().filter(contract => contract.network == network and contract of Erc20Contract).map(contract => Erc20Contract(contract)).getErc20ContractByAddress(address)
|
||||
proc findContract*(chainId: int, name: string): Contract =
|
||||
let found = allContracts().filter(contract => contract.name == name and contract.chainId == chainId)
|
||||
result = if found.len > 0: found[0] else: nil
|
||||
|
||||
proc getErc20Contracts*(): seq[Erc20Contract] =
|
||||
let network = settings.getCurrentNetwork()
|
||||
result = allContracts().filter(contract => contract of Erc20Contract and contract.network == network).map(contract => Erc20Contract(contract))
|
||||
proc allErc20Contracts*(): seq[Erc20Contract] =
|
||||
result = allContracts().map(contract => Erc20Contract(contract))
|
||||
|
||||
proc getErc721Contract(network: NetworkType, name: string): Erc721Contract =
|
||||
let found = allContracts().filter(contract => contract of Erc721Contract and Erc721Contract(contract).name.toLower == name.toLower and contract.network == network)
|
||||
result = if found.len > 0: Erc721Contract(found[0]) else: nil
|
||||
proc allErc20ContractsByChainId*(chainId: int): seq[Erc20Contract] =
|
||||
result = allContracts().filter(contract => contract of Erc20Contract and contract.chainId == chainId).map(contract => Erc20Contract(contract))
|
||||
|
||||
proc getErc721Contract*(name: string): Erc721Contract =
|
||||
let network = settings.getCurrentNetwork()
|
||||
getErc721Contract(network, name)
|
||||
proc findErc20Contract*(chainId: int, symbol: string): Erc20Contract =
|
||||
return allErc20ContractsByChainId(chainId).findBySymbol(symbol)
|
||||
|
||||
proc getErc721Contracts*(): seq[Erc721Contract] =
|
||||
let network = settings.getCurrentNetwork()
|
||||
result = allContracts().filter(contract => contract of Erc721Contract and contract.network == network).map(contract => Erc721Contract(contract))
|
||||
proc findErc20Contract*(chainId: int, address: Address): Erc20Contract =
|
||||
return allErc20ContractsByChainId(chainId).findByAddress(address)
|
||||
|
||||
proc getSntContract*(): Erc20Contract =
|
||||
if settings.getCurrentNetwork() == NetworkType.Mainnet:
|
||||
result = getErc20Contract("snt")
|
||||
else:
|
||||
result = getErc20Contract("stt")
|
||||
if result == nil:
|
||||
# TODO: xDai network does not have an SNT contract listed. We will need to handle
|
||||
# having no SNT contract in other places in the code (ie anywhere that
|
||||
# getSntContract() is called)
|
||||
raise newException(ValueError, "A status contract could not be found for the current network")
|
||||
proc allErc721ContractsByChainId*(chainId: int): seq[Erc721Contract] =
|
||||
result = allContracts().filter(contract => contract of Erc721Contract and contract.chainId == chainId).map(contract => Erc721Contract(contract))
|
||||
|
||||
proc findErc721Contract*(chainId: int, name: string): Erc721Contract =
|
||||
let found = allErc721ContractsByChainId(chainId).filter(contract => contract.name.toLower == name.toLower)
|
||||
result = if found.len > 0: found[0] else: nil
|
|
@ -13,14 +13,17 @@ import # vendor libs
|
|||
from nimcrypto import fromHex
|
||||
|
||||
import # status-desktop libs
|
||||
./eth/transactions as transactions, types/[sticker, setting, rpc_response],
|
||||
eth/contracts, ./statusgo_backend/settings, ./statusgo_backend/edn_helpers, utils
|
||||
../types/[sticker, setting, rpc_response, network_type],
|
||||
../statusgo_backend/[edn_helpers, settings],
|
||||
../utils,
|
||||
./transactions as transactions,
|
||||
./contracts
|
||||
|
||||
# Retrieves number of sticker packs owned by user
|
||||
# See https://notes.status.im/Q-sQmQbpTOOWCQcYiXtf5g#Read-Sticker-Packs-owned-by-a-user
|
||||
# for more details
|
||||
proc getBalance*(address: Address): int =
|
||||
let contract = contracts.getContract("sticker-pack")
|
||||
proc getBalance*(chainId: int, address: Address): int =
|
||||
let contract = contracts.findContract(chainId, "sticker-pack")
|
||||
if contract == nil: return 0
|
||||
|
||||
let
|
||||
|
@ -39,8 +42,8 @@ proc getBalance*(address: Address): int =
|
|||
result = parseHexInt(response.result)
|
||||
|
||||
# Gets number of sticker packs
|
||||
proc getPackCount*(): int =
|
||||
let contract = contracts.getContract("stickers")
|
||||
proc getPackCount*(chainId: int): int =
|
||||
let contract = contracts.findContract(chainId, "stickers")
|
||||
if contract == nil: return 0
|
||||
|
||||
let payload = %* [{
|
||||
|
@ -57,12 +60,12 @@ proc getPackCount*(): int =
|
|||
result = parseHexInt(response.result)
|
||||
|
||||
# Gets sticker pack data
|
||||
proc getPackData*(id: Stuint[256], running: var Atomic[bool]): StickerPack =
|
||||
proc getPackData*(chainId: int, id: Stuint[256], running: var Atomic[bool]): StickerPack =
|
||||
let secureSSLContext = newContext()
|
||||
let client = newHttpClient(sslContext = secureSSLContext)
|
||||
try:
|
||||
let
|
||||
contract = contracts.getContract("stickers")
|
||||
contract = contracts.findContract(chainId, "stickers")
|
||||
contractMethod = contract.methods["getPackData"]
|
||||
getPackData = GetPackData(packId: id)
|
||||
payload = %* [{
|
||||
|
@ -99,9 +102,9 @@ proc getPackData*(id: Stuint[256], running: var Atomic[bool]): StickerPack =
|
|||
finally:
|
||||
client.close()
|
||||
|
||||
proc tokenOfOwnerByIndex*(address: Address, idx: Stuint[256]): int =
|
||||
proc tokenOfOwnerByIndex*(chainId: int, address: Address, idx: Stuint[256]): int =
|
||||
let
|
||||
contract = contracts.getContract("sticker-pack")
|
||||
contract = contracts.findContract(chainId, "sticker-pack")
|
||||
tokenOfOwnerByIndex = TokenOfOwnerByIndex(address: address, index: idx)
|
||||
payload = %* [{
|
||||
"to": $contract.address,
|
||||
|
@ -115,9 +118,9 @@ proc tokenOfOwnerByIndex*(address: Address, idx: Stuint[256]): int =
|
|||
return 0
|
||||
result = parseHexInt(response.result)
|
||||
|
||||
proc getPackIdFromTokenId*(tokenId: Stuint[256]): int =
|
||||
proc getPackIdFromTokenId*(chainId: int, tokenId: Stuint[256]): int =
|
||||
let
|
||||
contract = contracts.getContract("sticker-pack")
|
||||
contract = contracts.findContract(chainId, "sticker-pack")
|
||||
tokenPackId = TokenPackId(tokenId: tokenId)
|
||||
payload = %* [{
|
||||
"to": $contract.address,
|
||||
|
@ -168,16 +171,16 @@ proc getRecentStickers*(): seq[Sticker] =
|
|||
# inserting recent stickers at the front of the list
|
||||
result.insert(Sticker(hash: $hash, packId: packId), 0)
|
||||
|
||||
proc getAvailableStickerPacks*(running: var Atomic[bool]): Table[int, StickerPack] =
|
||||
proc getAvailableStickerPacks*(chainId: int, running: var Atomic[bool]): Table[int, StickerPack] =
|
||||
var availableStickerPacks = initTable[int, StickerPack]()
|
||||
try:
|
||||
let numPacks = getPackCount()
|
||||
let numPacks = getPackCount(chainId)
|
||||
for i in 0..<numPacks:
|
||||
if not running.load():
|
||||
trace "Sticker pack task interrupted, exiting sticker pack loading"
|
||||
break
|
||||
try:
|
||||
let stickerPack = getPackData(i.u256, running)
|
||||
let stickerPack = getPackData(chainId, i.u256, running)
|
||||
availableStickerPacks[stickerPack.id] = stickerPack
|
||||
except:
|
||||
continue
|
|
@ -6,72 +6,68 @@ import
|
|||
web3/[ethtypes, conversions], json_serialization
|
||||
|
||||
import
|
||||
./statusgo_backend/settings, ./statusgo_backend/core, ./statusgo_backend/wallet, eth/contracts,
|
||||
types/[setting, network_type, rpc_response]
|
||||
from utils import parseAddress
|
||||
|
||||
import statusgo_backend/tokens as statusgo_backend_tokens
|
||||
../statusgo_backend/[core, wallet, settings],
|
||||
../statusgo_backend/tokens as statusgo_backend_tokens,
|
||||
../types/[setting, network, rpc_response],
|
||||
./contracts
|
||||
from ../utils import parseAddress
|
||||
|
||||
var
|
||||
customTokens {.threadvar.}: seq[Erc20Contract]
|
||||
|
||||
proc visibleTokensSNTDefault(): JsonNode =
|
||||
let currentNetwork = getCurrentNetwork()
|
||||
let SNT = if currentNetwork == NetworkType.Mainnet: "SNT" else: "STT"
|
||||
proc visibleTokensSNTDefault(network: Network): JsonNode =
|
||||
let symbol = network.sntSymbol()
|
||||
let response = getSetting[string](Setting.VisibleTokens, "{}").parseJSON
|
||||
|
||||
if not response.hasKey($currentNetwork):
|
||||
if not response.hasKey($network.chainId):
|
||||
# Set STT/SNT visible by default
|
||||
response[$currentNetwork] = %* [SNT]
|
||||
response[$network.chainId] = %* [symbol]
|
||||
|
||||
return response
|
||||
|
||||
proc convertStringSeqToERC20ContractSeq*(stringSeq: seq[string]): seq[Erc20Contract] =
|
||||
proc convertStringSeqToERC20ContractSeq*(network: Network, stringSeq: seq[string]): seq[Erc20Contract] =
|
||||
result = @[]
|
||||
for v in stringSeq:
|
||||
let t = getErc20Contract(v)
|
||||
let t = findErc20Contract(network.chainId, v)
|
||||
if t != nil: result.add t
|
||||
let ct = customTokens.getErc20ContractBySymbol(v)
|
||||
let ct = customTokens.findBySymbol(v)
|
||||
if ct != nil: result.add ct
|
||||
|
||||
proc toggleAsset*(symbol: string): seq[Erc20Contract] =
|
||||
let currentNetwork = getCurrentNetwork()
|
||||
let visibleTokens = visibleTokensSNTDefault()
|
||||
var visibleTokenList = visibleTokens[$currentNetwork].to(seq[string])
|
||||
proc toggleAsset*(network: Network, symbol: string): seq[Erc20Contract] =
|
||||
let visibleTokens = visibleTokensSNTDefault(network)
|
||||
var visibleTokenList = visibleTokens[$network.chainId].to(seq[string])
|
||||
let symbolIdx = visibleTokenList.find(symbol)
|
||||
if symbolIdx > -1:
|
||||
visibleTokenList.del(symbolIdx)
|
||||
else:
|
||||
visibleTokenList.add symbol
|
||||
visibleTokens[$currentNetwork] = newJArray()
|
||||
visibleTokens[$currentNetwork] = %* visibleTokenList
|
||||
let saved = saveSetting(Setting.VisibleTokens, $visibleTokens)
|
||||
visibleTokens[$network.chainId] = newJArray()
|
||||
visibleTokens[$network.chainId] = %* visibleTokenList
|
||||
let saved = saveSetting(Setting.VisibleTokens, $visibleTokens)
|
||||
|
||||
convertStringSeqToERC20ContractSeq(visibleTokenList)
|
||||
convertStringSeqToERC20ContractSeq(network, visibleTokenList)
|
||||
|
||||
proc hideAsset*(symbol: string) =
|
||||
let currentNetwork = getCurrentNetwork()
|
||||
let visibleTokens = visibleTokensSNTDefault()
|
||||
var visibleTokenList = visibleTokens[$currentNetwork].to(seq[string])
|
||||
proc hideAsset*(network: Network, symbol: string) =
|
||||
let visibleTokens = visibleTokensSNTDefault(network)
|
||||
var visibleTokenList = visibleTokens[$network.chainId].to(seq[string])
|
||||
var symbolIdx = visibleTokenList.find(symbol)
|
||||
if symbolIdx > -1:
|
||||
visibleTokenList.del(symbolIdx)
|
||||
visibleTokens[$currentNetwork] = newJArray()
|
||||
visibleTokens[$currentNetwork] = %* visibleTokenList
|
||||
visibleTokens[$network.chainId] = newJArray()
|
||||
visibleTokens[$network.chainId] = %* visibleTokenList
|
||||
discard saveSetting(Setting.VisibleTokens, $visibleTokens)
|
||||
|
||||
proc getVisibleTokens*(): seq[Erc20Contract] =
|
||||
let currentNetwork = getCurrentNetwork()
|
||||
let visibleTokens = visibleTokensSNTDefault()
|
||||
var visibleTokenList = visibleTokens[$currentNetwork].to(seq[string])
|
||||
proc getVisibleTokens*(network: Network): seq[Erc20Contract] =
|
||||
let visibleTokens = visibleTokensSNTDefault(network)
|
||||
var visibleTokenList = visibleTokens[$network.chainId].to(seq[string])
|
||||
let customTokens = statusgo_backend_tokens.getCustomTokens()
|
||||
|
||||
result = convertStringSeqToERC20ContractSeq(visibleTokenList)
|
||||
result = convertStringSeqToERC20ContractSeq(network, visibleTokenList)
|
||||
|
||||
proc getToken*(tokenAddress: string): Erc20Contract =
|
||||
getErc20Contracts().concat(statusgo_backend_tokens.getCustomTokens()).getErc20ContractByAddress(tokenAddress.parseAddress)
|
||||
proc getToken*(network: Network, tokenAddress: string): Erc20Contract =
|
||||
allErc20ContractsByChainId(network.chainId).concat(statusgo_backend_tokens.getCustomTokens()).findByAddress(tokenAddress.parseAddress)
|
||||
|
||||
proc getTokenBalance*(tokenAddress: string, account: string): string =
|
||||
proc getTokenBalance*(network: Network, tokenAddress: string, account: string): string =
|
||||
var postfixedAccount: string = account
|
||||
postfixedAccount.removePrefix("0x")
|
||||
let payload = %* [{
|
||||
|
@ -82,8 +78,8 @@ proc getTokenBalance*(tokenAddress: string, account: string): string =
|
|||
|
||||
var decimals = 18
|
||||
let address = parseAddress(tokenAddress)
|
||||
let t = getErc20Contract(address)
|
||||
let ct = statusgo_backend_tokens.getCustomTokens().getErc20ContractByAddress(address)
|
||||
let t = findErc20Contract(network.chainId, address)
|
||||
let ct = statusgo_backend_tokens.getCustomTokens().findByAddress(address)
|
||||
if t != nil:
|
||||
decimals = t.decimals
|
||||
elif ct != nil:
|
||||
|
@ -91,13 +87,12 @@ proc getTokenBalance*(tokenAddress: string, account: string): string =
|
|||
|
||||
result = $hex2Token(balance, decimals)
|
||||
|
||||
proc getSNTAddress*(): string =
|
||||
let snt = contracts.getSntContract()
|
||||
result = $snt.address
|
||||
proc getSNTAddress*(network: Network): string =
|
||||
let contract = findErc20Contract(network.chainId, network.sntSymbol)
|
||||
return $contract.address
|
||||
|
||||
proc getSNTBalance*(account: string): string =
|
||||
let snt = contracts.getSntContract()
|
||||
result = getTokenBalance($snt.address, account)
|
||||
proc getSNTBalance*(network: Network, account: string): string =
|
||||
result = getTokenBalance(network, getSNTAddress(network), account)
|
||||
|
||||
proc getTokenString*(contract: Contract, methodName: string): string =
|
||||
let payload = %* [{
|
|
@ -5,7 +5,7 @@ import json_serialization
|
|||
|
||||
from ./core import callPrivateRPC
|
||||
from ../types/rpc_response import RpcResponseTyped, RpcException
|
||||
from ../wallet2/network import Network, toPayload
|
||||
from ../types/network import Network, toPayload
|
||||
|
||||
logScope:
|
||||
topics = "wallet"
|
||||
|
|
|
@ -6,10 +6,12 @@ import # project deps
|
|||
|
||||
import # local deps
|
||||
utils as status_utils,
|
||||
statusgo_backend/settings as status_settings,
|
||||
eth/contracts as status_contracts,
|
||||
stickers_backend as status_stickers, transactions,
|
||||
eth/stickers as status_stickers,
|
||||
transactions,
|
||||
statusgo_backend/wallet, ../eventemitter
|
||||
import ./types/[sticker, transaction, rpc_response]
|
||||
import ./types/[sticker, transaction, rpc_response, network_type, network]
|
||||
from utils as statusgo_backend_utils import eth2Wei, gwei2Wei, toUInt64, parseAddress
|
||||
|
||||
logScope:
|
||||
|
@ -44,9 +46,10 @@ proc init*(self: StickersModel) =
|
|||
self.addStickerToRecent(evArgs.sticker, evArgs.save)
|
||||
|
||||
proc buildTransaction(packId: Uint256, address: Address, price: Uint256, approveAndCall: var ApproveAndCall[100], sntContract: var Erc20Contract, gas = "", gasPrice = "", isEIP1559Enabled = false, maxPriorityFeePerGas = "", maxFeePerGas = ""): TransactionData =
|
||||
sntContract = status_contracts.getSntContract()
|
||||
let network = status_settings.getCurrentNetwork().toNetwork()
|
||||
sntContract = status_contracts.findErc20Contract(network.chainId, network.sntSymbol())
|
||||
let
|
||||
stickerMktContract = status_contracts.getContract("sticker-market")
|
||||
stickerMktContract = status_contracts.findContract(network.chainId, "sticker-market")
|
||||
buyToken = BuyToken(packId: packId, address: address, price: price)
|
||||
buyTxAbiEncoded = stickerMktContract.methods["buyToken"].encodeAbi(buyToken)
|
||||
approveAndCall = ApproveAndCall[100](to: stickerMktContract.address, value: price, data: DynamicBytes[100].fromHex(buyTxAbiEncoded))
|
||||
|
@ -55,7 +58,8 @@ proc buildTransaction(packId: Uint256, address: Address, price: Uint256, approve
|
|||
proc estimateGas*(packId: int, address: string, price: string, success: var bool): int =
|
||||
var
|
||||
approveAndCall: ApproveAndCall[100]
|
||||
sntContract = status_contracts.getSntContract()
|
||||
network = status_settings.getCurrentNetwork().toNetwork()
|
||||
sntContract = status_contracts.findErc20Contract(network.chainId, network.sntSymbol())
|
||||
tx = buildTransaction(
|
||||
packId.u256,
|
||||
parseAddress(address),
|
||||
|
@ -90,14 +94,16 @@ proc buyPack*(self: StickersModel, packId: int, address, price, gas, gasPrice: s
|
|||
trackPendingTransaction(result, address, $sntContract.address, PendingTransactionType.BuyStickerPack, $packId)
|
||||
|
||||
proc getStickerMarketAddress*(self: StickersModel): Address =
|
||||
result = status_contracts.getContract("sticker-market").address
|
||||
let network = status_settings.getCurrentNetwork().toNetwork()
|
||||
result = status_contracts.findContract(network.chainId, "sticker-market").address
|
||||
|
||||
proc getPurchasedStickerPacks*(self: StickersModel, address: Address): seq[int] =
|
||||
try:
|
||||
let
|
||||
balance = status_stickers.getBalance(address)
|
||||
tokenIds = toSeq[0..<balance].mapIt(status_stickers.tokenOfOwnerByIndex(address, it.u256))
|
||||
purchasedPackIds = tokenIds.mapIt(status_stickers.getPackIdFromTokenId(it.u256))
|
||||
network = status_settings.getCurrentNetwork().toNetwork()
|
||||
balance = status_stickers.getBalance(network.chainId, address)
|
||||
tokenIds = toSeq[0..<balance].mapIt(status_stickers.tokenOfOwnerByIndex(network.chainId, address, it.u256))
|
||||
purchasedPackIds = tokenIds.mapIt(status_stickers.getPackIdFromTokenId(network.chainId, it.u256))
|
||||
self.purchasedStickerPacks = self.purchasedStickerPacks.concat(purchasedPackIds)
|
||||
result = self.purchasedStickerPacks
|
||||
except RpcException:
|
||||
|
@ -111,7 +117,9 @@ proc getInstalledStickerPacks*(self: StickersModel): Table[int, StickerPack] =
|
|||
self.installedStickerPacks = status_stickers.getInstalledStickerPacks()
|
||||
result = self.installedStickerPacks
|
||||
|
||||
proc getAvailableStickerPacks*(running: var Atomic[bool]): Table[int, StickerPack] = status_stickers.getAvailableStickerPacks(running)
|
||||
proc getAvailableStickerPacks*(running: var Atomic[bool]): Table[int, StickerPack] =
|
||||
let network = status_settings.getCurrentNetwork().toNetwork()
|
||||
return status_stickers.getAvailableStickerPacks(network.chainId, running)
|
||||
|
||||
proc getRecentStickers*(self: StickersModel): seq[Sticker] =
|
||||
result = status_stickers.getRecentStickers()
|
||||
|
@ -146,4 +154,5 @@ proc decodeContentHash*(value: string): string =
|
|||
result = status_utils.decodeContentHash(value)
|
||||
|
||||
proc getPackIdFromTokenId*(tokenId: Stuint[256]): int =
|
||||
result = status_stickers.getPackIdFromTokenId(tokenId)
|
||||
let network = status_settings.getCurrentNetwork().toNetwork()
|
||||
result = status_stickers.getPackIdFromTokenId(network.chainId, tokenId)
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import statusgo_backend/settings as status_settings
|
||||
import statusgo_backend/tokens as statusgo_backend_tokens
|
||||
import tokens_backend as status_tokens
|
||||
import eth/tokens as status_tokens
|
||||
import eth/contracts
|
||||
import ./types/network_type
|
||||
import ../eventemitter
|
||||
|
||||
type
|
||||
|
@ -12,7 +14,8 @@ proc newTokensModel*(events: EventEmitter): TokensModel =
|
|||
result.events = events
|
||||
|
||||
proc getSNTAddress*(): string =
|
||||
result = status_tokens.getSNTAddress()
|
||||
let network = status_settings.getCurrentNetwork().toNetwork()
|
||||
result = status_tokens.getSNTAddress(network)
|
||||
|
||||
proc getCustomTokens*(self: TokensModel, useCached: bool = true): seq[Erc20Contract] =
|
||||
result = statusgo_backend_tokens.getCustomTokens(useCached)
|
||||
|
@ -21,7 +24,8 @@ proc removeCustomToken*(self: TokensModel, address: string) =
|
|||
statusgo_backend_tokens.removeCustomToken(address)
|
||||
|
||||
proc getSNTBalance*(account: string): string =
|
||||
result = status_tokens.getSNTBalance(account)
|
||||
let network = status_settings.getCurrentNetwork().toNetwork()
|
||||
result = status_tokens.getSNTBalance(network, account)
|
||||
|
||||
proc tokenDecimals*(contract: Contract): int =
|
||||
result = status_tokens.tokenDecimals(contract)
|
||||
|
@ -33,12 +37,14 @@ proc tokensymbol*(contract: Contract): string =
|
|||
result = status_tokens.tokensymbol(contract)
|
||||
|
||||
proc getTokenBalance*(tokenAddress: string, account: string): string =
|
||||
result = status_tokens.getTokenBalance(tokenAddress, account)
|
||||
let network = status_settings.getCurrentNetwork().toNetwork()
|
||||
result = status_tokens.getTokenBalance(network, tokenAddress, account)
|
||||
|
||||
proc getToken*(self: TokensModel, tokenAddress: string): Erc20Contract =
|
||||
result = status_tokens.getToken(tokenAddress)
|
||||
let network = status_settings.getCurrentNetwork().toNetwork()
|
||||
result = status_tokens.getToken(network, tokenAddress)
|
||||
|
||||
export newErc20Contract
|
||||
export getErc20Contracts
|
||||
export allErc20ContractsByChainId
|
||||
export Erc20Contract
|
||||
export getErc20ContractByAddress
|
||||
export findByAddress
|
||||
|
|
|
@ -11,7 +11,7 @@ import ../statusgo_backend/tokens as status_tokens
|
|||
import ../eth/contracts as status_contracts
|
||||
import web3/conversions
|
||||
from ../utils import parseAddress, wei2Eth
|
||||
import setting, network_type
|
||||
import setting, network
|
||||
|
||||
include message_command_parameters
|
||||
include message_reaction
|
||||
|
@ -156,10 +156,10 @@ proc toMessage*(jsonMsg: JsonNode): Message =
|
|||
|
||||
if message.contentType == ContentType.Transaction:
|
||||
let
|
||||
allContracts = getErc20Contracts().concat(getCustomTokens())
|
||||
ethereum = newErc20Contract("Ethereum", NetworkType.Mainnet, parseAddress(constants.ZERO_ADDRESS), "ETH", 18, true)
|
||||
allContracts = allErc20Contracts().concat(getCustomTokens())
|
||||
ethereum = newErc20Contract("Ethereum", Mainnet, parseAddress(constants.ZERO_ADDRESS), "ETH", 18, true)
|
||||
tokenAddress = jsonMsg["commandParameters"]["contract"].getStr
|
||||
tokenContract = if tokenAddress == "": ethereum else: allContracts.getErc20ContractByAddress(parseAddress(tokenAddress))
|
||||
tokenContract = if tokenAddress == "": ethereum else: allContracts.findByAddress(parseAddress(tokenAddress))
|
||||
tokenContractStr = if tokenContract == nil: "{}" else: $(Json.encode(tokenContract))
|
||||
var weiStr = if tokenContract == nil: "0" else: wei2Eth(jsonMsg["commandParameters"]["value"].getStr, tokenContract.decimals)
|
||||
weiStr.trimZeros()
|
||||
|
|
|
@ -2,8 +2,18 @@ from json import JsonNode, `%*`, parseJson
|
|||
from strformat import fmt
|
||||
import json_serialization
|
||||
|
||||
const Mainnet = 1
|
||||
const Ropsten = 3
|
||||
const Rinkeby = 4
|
||||
const Goerli = 5
|
||||
const Optimism = 10
|
||||
const Poa = 99
|
||||
const XDai = 100
|
||||
|
||||
export Mainnet, Ropsten, Rinkeby, Goerli, Optimism, Poa, XDai
|
||||
|
||||
type Network* = ref object
|
||||
chainID* {.serializedFieldName("chainId").}: int
|
||||
chainId* {.serializedFieldName("chainId").}: int
|
||||
nativeCurrencyDecimals* {.serializedFieldName("nativeCurrencyDecimals").}: int
|
||||
layer* {.serializedFieldName("layer").}: int
|
||||
chainName* {.serializedFieldName("chainName").}: string
|
||||
|
@ -16,7 +26,13 @@ type Network* = ref object
|
|||
enabled* {.serializedFieldName("enabled").}: bool
|
||||
|
||||
proc `$`*(self: Network): string =
|
||||
return fmt"Network(chainID:{self.chainID}, name:{self.chainName}, rpcURL:{self.rpcURL}, isTest:{self.isTest}, enabled:{self.enabled})"
|
||||
return fmt"Network(chainId:{self.chainId}, name:{self.chainName}, rpcURL:{self.rpcURL}, isTest:{self.isTest}, enabled:{self.enabled})"
|
||||
|
||||
proc toPayload*(self: Network): JsonNode =
|
||||
return %* [Json.encode(self).parseJson]
|
||||
return %* [Json.encode(self).parseJson]
|
||||
|
||||
proc sntSymbol*(self: Network): string =
|
||||
if self.chainId == Mainnet:
|
||||
return "SNT"
|
||||
else:
|
||||
return "STT"
|
|
@ -4,6 +4,10 @@ include node_config
|
|||
include network_details
|
||||
include upstream_config
|
||||
|
||||
import ../statusgo_backend/network as status_network
|
||||
|
||||
import ./network
|
||||
|
||||
type
|
||||
NetworkType* {.pure.} = enum
|
||||
Mainnet = "mainnet_rpc",
|
||||
|
@ -12,4 +16,22 @@ type
|
|||
Goerli = "goerli_rpc",
|
||||
XDai = "xdai_rpc",
|
||||
Poa = "poa_rpc",
|
||||
Other = "other"
|
||||
Other = "other"
|
||||
|
||||
proc toChainId*(self: NetworkType): int =
|
||||
case self:
|
||||
of NetworkType.Mainnet: result = Mainnet
|
||||
of NetworkType.Testnet: result = Ropsten
|
||||
of NetworkType.Rinkeby: result = Rinkeby
|
||||
of NetworkType.Goerli: result = Goerli
|
||||
of NetworkType.XDai: result = XDai
|
||||
of NetworkType.Poa: result = 99
|
||||
of NetworkType.Other: result = -1
|
||||
|
||||
proc toNetwork*(self: NetworkType): Network =
|
||||
for network in status_network.getNetworks():
|
||||
if self.toChainId() == network.chainId:
|
||||
return network
|
||||
|
||||
# Will be removed, this is used in case of legacy chain Id
|
||||
return Network(chainId: self.toChainId())
|
|
@ -4,12 +4,12 @@ from web3/ethtypes import Address, Quantity
|
|||
from web3/conversions import `$`
|
||||
from statusgo_backend/core import getBlockByNumber
|
||||
import statusgo_backend/accounts as status_accounts
|
||||
import tokens_backend as status_tokens
|
||||
import statusgo_backend/tokens as statusgo_backend_tokens
|
||||
import statusgo_backend/settings as status_settings
|
||||
import statusgo_backend/wallet as status_wallet
|
||||
import statusgo_backend/accounts/constants as constants
|
||||
import eth/[eth, contracts]
|
||||
import eth/tokens as status_tokens
|
||||
from statusgo_backend/core import getBlockByNumber
|
||||
from utils as statusgo_backend_utils import eth2Wei, gwei2Wei, wei2Gwei, first, toUInt64, parseAddress
|
||||
import wallet/[balance_manager, collectibles]
|
||||
|
@ -17,7 +17,7 @@ import wallet/account as wallet_account
|
|||
import transactions
|
||||
import ../eventemitter
|
||||
import options
|
||||
import ./types/[account, transaction, network_type, setting, gas_prediction, rpc_response]
|
||||
import ./types/[account, transaction, network, network_type, setting, gas_prediction, rpc_response]
|
||||
export wallet_account, collectibles
|
||||
export Transaction
|
||||
|
||||
|
@ -69,14 +69,16 @@ proc delete*(self: WalletModel) =
|
|||
discard
|
||||
|
||||
proc buildTokenTransaction(source, to, assetAddress: Address, value: float, transfer: var Transfer, contract: var Erc20Contract, gas = "", gasPrice = "", isEIP1559Enabled: bool = false, maxPriorityFeePerGas = "", maxFeePerGas = ""): TransactionData =
|
||||
contract = getErc20Contract(assetAddress)
|
||||
let network = status_settings.getCurrentNetwork().toNetwork()
|
||||
contract = findErc20Contract(network.chainId, assetAddress)
|
||||
if contract == nil:
|
||||
raise newException(ValueError, fmt"Could not find ERC-20 contract with address '{assetAddress}' for the current network")
|
||||
transfer = Transfer(to: to, value: eth2Wei(value, contract.decimals))
|
||||
transactions.buildTokenTransaction(source, assetAddress, gas, gasPrice, isEIP1559Enabled, maxPriorityFeePerGas, maxFeePerGas)
|
||||
|
||||
proc getKnownTokenContract*(self: WalletModel, address: Address): Erc20Contract =
|
||||
getErc20Contracts().concat(statusgo_backend_tokens.getCustomTokens()).getErc20ContractByAddress(address)
|
||||
let network = status_settings.getCurrentNetwork().toNetwork()
|
||||
allErc20ContractsByChainId(network.chainId).concat(statusgo_backend_tokens.getCustomTokens()).findByAddress(address)
|
||||
|
||||
proc estimateGas*(self: WalletModel, source, to, value, data: string, success: var bool): string =
|
||||
var tx = transactions.buildTransaction(
|
||||
|
@ -180,9 +182,10 @@ proc getDefaultCurrency*(self: WalletModel): string =
|
|||
# TODO: This needs to be removed or refactored so that test tokens are shown
|
||||
# when on testnet https://github.com/status-im/nim-status-client/issues/613.
|
||||
proc getStatusToken*(self: WalletModel): string =
|
||||
let network = status_settings.getCurrentNetwork().toNetwork()
|
||||
var
|
||||
token = Asset()
|
||||
erc20Contract = getSntContract()
|
||||
erc20Contract = findErc20Contract(network.chainId, network.sntSymbol())
|
||||
token.name = erc20Contract.name
|
||||
token.symbol = erc20Contract.symbol
|
||||
token.address = $erc20Contract.address
|
||||
|
@ -256,7 +259,8 @@ proc feeHistory*(self: WalletModel, n:int):seq[Uint256] =
|
|||
raise newException(StatusGoException, "Error obtaining fee history")
|
||||
|
||||
proc initAccounts*(self: WalletModel) =
|
||||
self.tokens = status_tokens.getVisibleTokens()
|
||||
let network = status_settings.getCurrentNetwork().toNetwork()
|
||||
self.tokens = status_tokens.getVisibleTokens(network)
|
||||
let accounts = status_wallet.getWalletAccounts()
|
||||
for account in accounts:
|
||||
var acc = WalletAccount(account)
|
||||
|
@ -369,15 +373,17 @@ proc deleteAccount*(self: WalletModel, address: string): string =
|
|||
self.accounts = self.accounts.filter(acc => acc.address.toLowerAscii != address.toLowerAscii)
|
||||
|
||||
proc toggleAsset*(self: WalletModel, symbol: string) =
|
||||
self.tokens = status_tokens.toggleAsset(symbol)
|
||||
let network = status_settings.getCurrentNetwork().toNetwork()
|
||||
self.tokens = status_tokens.toggleAsset(network, symbol)
|
||||
for account in self.accounts:
|
||||
account.assetList = self.generateAccountConfiguredAssets(account.address)
|
||||
updateBalance(account, self.getDefaultCurrency())
|
||||
self.events.emit("assetChanged", Args())
|
||||
|
||||
proc hideAsset*(self: WalletModel, symbol: string) =
|
||||
status_tokens.hideAsset(symbol)
|
||||
self.tokens = status_tokens.getVisibleTokens()
|
||||
let network = status_settings.getCurrentNetwork().toNetwork()
|
||||
status_tokens.hideAsset(network, symbol)
|
||||
self.tokens = status_tokens.getVisibleTokens(network)
|
||||
for account in self.accounts:
|
||||
account.assetList = self.generateAccountConfiguredAssets(account.address)
|
||||
updateBalance(account, self.getDefaultCurrency())
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import strformat, strutils, stint, httpclient, json, chronicles, net
|
||||
import ../statusgo_backend/wallet as status_wallet
|
||||
import ../tokens_backend as status_tokens
|
||||
import ../types/[rpc_response]
|
||||
import ../statusgo_backend/settings as status_settings
|
||||
import ../eth/tokens as status_tokens
|
||||
import ../types/[rpc_response, network_type]
|
||||
import ../utils/cache
|
||||
import account
|
||||
import options
|
||||
|
@ -48,7 +49,8 @@ proc getBalance*(symbol: string, accountAddress: string, tokenAddress: string, r
|
|||
let ethBalance = getEthBalance(accountAddress)
|
||||
return ethBalance
|
||||
|
||||
result = $status_tokens.getTokenBalance(tokenAddress, accountAddress)
|
||||
let network = status_settings.getCurrentNetwork().toNetwork()
|
||||
result = $status_tokens.getTokenBalance(network, tokenAddress, accountAddress)
|
||||
balanceManager.tokenBalances.cacheValue(cacheKey, result)
|
||||
|
||||
proc convertValue*(balance: string, fromCurrency: string, toCurrency: string): float =
|
||||
|
|
|
@ -6,9 +6,12 @@ import # vendor libs
|
|||
stint
|
||||
|
||||
import # status-desktop libs
|
||||
../statusgo_backend/core as status, ../eth/contracts as contracts,
|
||||
../statusgo_backend/core as status,
|
||||
../statusgo_backend/settings as status_settings,
|
||||
../eth/contracts as contracts,
|
||||
../stickers as status_stickers,
|
||||
../utils as status_utils,
|
||||
../types/network_type,
|
||||
web3/[conversions, ethtypes], ../utils, account
|
||||
|
||||
const CRYPTOKITTY* = "cryptokitty"
|
||||
|
@ -140,9 +143,10 @@ proc getCryptoKitties*(address: string): string =
|
|||
|
||||
proc getEthermons*(address: Address): string =
|
||||
try:
|
||||
let network = status_settings.getCurrentNetwork().toNetwork()
|
||||
var ethermons: seq[Collectible]
|
||||
ethermons = @[]
|
||||
let contract = getErc721Contract("ethermon")
|
||||
let contract = findErc721Contract(network.chainId, "ethermon")
|
||||
if contract == nil: return $(%*ethermons)
|
||||
|
||||
let tokens = tokensOfOwnerByIndex(contract, address)
|
||||
|
@ -180,9 +184,10 @@ proc getEthermons*(address: string): string =
|
|||
|
||||
proc getKudos*(address: Address): string =
|
||||
try:
|
||||
let network = status_settings.getCurrentNetwork().toNetwork()
|
||||
var kudos: seq[Collectible]
|
||||
kudos = @[]
|
||||
let contract = getErc721Contract("kudos")
|
||||
let contract = findErc721Contract(network.chainId, "kudos")
|
||||
if contract == nil: return $(%*kudos)
|
||||
|
||||
let tokens = tokensOfOwnerByIndex(contract, address)
|
||||
|
@ -221,9 +226,10 @@ proc getKudos*(address: string): string =
|
|||
|
||||
proc getStickers*(address: Address, running: var Atomic[bool]): string =
|
||||
try:
|
||||
let network = status_settings.getCurrentNetwork().toNetwork()
|
||||
var stickers: seq[Collectible]
|
||||
stickers = @[]
|
||||
let contract = getErc721Contract("sticker-pack")
|
||||
let contract = findErc721Contract(network.chainId, "sticker-pack")
|
||||
if contract == nil: return
|
||||
|
||||
let tokensIds = tokensOfOwnerByIndex(contract, address)
|
||||
|
|
|
@ -2,14 +2,14 @@ import json, strformat, options, chronicles, sugar, sequtils, strutils
|
|||
|
||||
import statusgo_backend/accounts as status_accounts
|
||||
import statusgo_backend/accounts/constants as constants
|
||||
import tokens_backend as status_tokens
|
||||
import statusgo_backend/wallet as status_wallet
|
||||
import statusgo_backend/network as status_network
|
||||
import statusgo_backend/settings as status_settings
|
||||
import eth/[contracts]
|
||||
import wallet2/[balance_manager, network]
|
||||
import eth/contracts
|
||||
import wallet2/balance_manager
|
||||
import eth/tokens as tokens_backend
|
||||
import wallet2/account as wallet_account
|
||||
import ./types/[account, transaction, network_type, setting, gas_prediction, rpc_response]
|
||||
import ./types/[account, transaction, network, network_type, setting, gas_prediction, rpc_response]
|
||||
import ../eventemitter
|
||||
from web3/ethtypes import Address
|
||||
from web3/conversions import `$`
|
||||
|
@ -48,13 +48,13 @@ proc setup(self: StatusWalletController, events: EventEmitter) =
|
|||
proc delete*(self: StatusWalletController) =
|
||||
discard
|
||||
|
||||
proc newStatusWalletController*(events: EventEmitter):
|
||||
StatusWalletController =
|
||||
proc newStatusWalletController*(events: EventEmitter): StatusWalletController =
|
||||
result = StatusWalletController()
|
||||
result.setup(events)
|
||||
|
||||
proc initTokens(self: StatusWalletController) =
|
||||
self.tokens = status_tokens.getVisibleTokens()
|
||||
let network = status_settings.getCurrentNetwork().toNetwork()
|
||||
self.tokens = tokens_backend.getVisibleTokens(network)
|
||||
|
||||
proc initNetworks(self: StatusWalletController) =
|
||||
self.networks = status_network.getNetworks()
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import strformat, strutils, stint, httpclient, json, chronicles, net
|
||||
import ../statusgo_backend/wallet as status_wallet
|
||||
import ../tokens_backend as status_tokens
|
||||
import ../types/[rpc_response]
|
||||
import ../statusgo_backend/settings as status_settings
|
||||
import ../eth/tokens as status_tokens
|
||||
import ../types/[rpc_response, network_type]
|
||||
import ../utils/cache
|
||||
import account
|
||||
import options
|
||||
|
@ -48,7 +49,8 @@ proc getBalance*(symbol: string, accountAddress: string, tokenAddress: string, r
|
|||
let ethBalance = getEthBalance(accountAddress)
|
||||
return ethBalance
|
||||
|
||||
result = $status_tokens.getTokenBalance(tokenAddress, accountAddress)
|
||||
let network = status_settings.getCurrentNetwork().toNetwork()
|
||||
result = $status_tokens.getTokenBalance(network, tokenAddress, accountAddress)
|
||||
balanceManager.tokenBalances.cacheValue(cacheKey, result)
|
||||
|
||||
proc convertValue*(balance: string, fromCurrency: string, toCurrency: string): float =
|
||||
|
|
Loading…
Reference in New Issue