edge / mobile-wallet

Mobile wallet app for managing XE & Ethereum wallets

Home Page:https://ed.ge/app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Backend endpoints for mobile calls

PJDavis1970 opened this issue · comments

Current calls made by app and timers delays.

Timer: 10 seconds
Each wallet in app will call the follow 3 endpoints

https://xe1.test.network/wallet/
<address>
https://index.test.network/transactions/
<address>
https://xe1.test.network/transactions/pending/
<address>

In an ideal world this would change to 1 endpoint polled every x seconds.

GetStatus( AddressList )

 The GetStatus endpoint would send back data for all given wallets.

That data could comprise of all data currently in

 https://xe1.test.network/wallet/<address>. 

It would also have a new field ( LastTransaction ). This field would be a timestamp of the last transaction that happened on this address.
 If the last transaction is later than my locally stored transactions timestamp I then call a

 GetTransactions( WalletAddress, timestamp)

Which would return all transactions for the given address after the timestamp and including pending transactions

Gas Rates, Exchange Rates, Etc

These are all called every 2 seconds.

https://index.test.network/gasrates
https://index.test.network/exchangerate
https://index.test.network/token/current
https://index.test.network/token/lastweek

It would make sense to have all of these in one call

Data structures used in mobile app

Structure used from https://xe1.test.network/wallet/
<address>

var address: String?
var balance: Int?
var nonce: Int?

Structure used from https://index.test.network/transactions/
<address>

var timestamp: Int
var sender: String
var recipient: String
var amount: Int
var data: XETransactionDataDataModel?
var nonce: Int
var signature: String
var hash: String
var block: XETransactionBlockDataModel?
var confirmations: Int?
var status: TransactionStatus?  ( IGNORE THIS FIELD I USE IT INTERNALLY)


XETransactionDataDataModel?

    var memo: String
    
XETransactionBlockDataModel?

    var height: Int
    var hash: String

As discussed, there is now an endpoint which returns the latest indexed block, the most recent tx for a given list of addresses, as well as a quick summary of the addresses provided including balance, nonce, and latest tx hash and block.

The endpoint is https://index.test.network/wallets/<addresses>/summary. The addresses should be comma separated, for example the following URL loads the following data:

https://index.test.network/wallets/xe_8580964CCa4577960D935e92b19fdAECcf441cc1,xe_407044EAaE711dFDbD9F04E66FA6a8D6c356DE7E/summary

{
  "latestBlock": 182635,
  "latestTx": {
    "timestamp": 1646394298526,
    "sender": "xe_407044EAaE711dFDbD9F04E66FA6a8D6c356DE7E",
    "recipient": "xe_8580964CCa4577960D935e92b19fdAECcf441cc1",
    "amount": 1000000,
    "data": {
      "memo": "test"
    },
    "nonce": 125,
    "signature": "536eb1aff94341734216a337cef299923a77a1a4d09f020b185ba63591cdc68a5c1d15e3b0b44065a858644627c61afd319628d99d5e37beebff33f2593685a600",
    "hash": "72e90abc716d3aae1ecb0b7e9333fee8de6ba30676e67119303bb7350a7d7402",
    "block": {
      "height": 176032,
      "hash": "0000027c17acd25798c8f0b309e5a7c1c8c9570d79fc6e53d4bfd0179ff233b5"
    }
  },
  "balances": [
    {
      "address": "xe_407044EAaE711dFDbD9F04E66FA6a8D6c356DE7E",
      "balance": 63555000000,
      "nonce": 126,
      "latestTx": {
        "hash": "72e90abc716d3aae1ecb0b7e9333fee8de6ba30676e67119303bb7350a7d7402",
        "block": 176032
      }
    },
    {
      "address": "xe_8580964CCa4577960D935e92b19fdAECcf441cc1",
      "balance": 590117002500,
      "nonce": 70,
      "latestTx": {
        "hash": "72e90abc716d3aae1ecb0b7e9333fee8de6ba30676e67119303bb7350a7d7402",
        "block": 176032
      }
    }
  ]
}

As discussed, this endpoint should be used for regular polling, with any wallet tx changes triggering a transaction refresh where required.