golemfactory / yagna

An open platform and marketplace for distributed computations
GNU General Public License v3.0
405 stars 61 forks source link

Endpoint for returning wallet balance (and status) #3345

Closed nieznanysprawiciel closed 1 month ago

nieznanysprawiciel commented 1 month ago

Endpoint returns the same structure as yagna payment status CLI command

yagna payment status --network polygon

Status for account: 0xf98bb0842a7e744beedd291c98e7cd2c9b27f300
Payment Driver status: OK

┌────────────────────┬────────────────┬────────────┬─────────────┬────────────────────────────┬────────────────────────────┬────────────────┐
│  platform          │  total amount  │  reserved  │  amount     │  incoming                  │  outgoing                  │  gas           │
├────────────────────┼────────────────┼────────────┼─────────────┼────────────────────────────┼────────────────────────────┼────────────────┤
│  driver: erc20     │  22.4449 GLM   │  0 GLM     │  accepted   │  0.086760639607644453 GLM  │  0.000197094797101683 GLM  │  0.2212 MATIC  │
│  network: polygon  │                │            │  confirmed  │  0.086760639607644453 GLM  │  0.000197094797101683 GLM  │                │
│  token: GLM        │                │            │  requested  │  0.086760639607644453 GLM  │  0.000197094797101683 GLM  │                │
└────────────────────┴────────────────┴────────────┴─────────────┴────────────────────────────┴────────────────────────────┴────────────────┘

curl -H "Authorization: Bearer secret-secret-secret" "http://localhost:7465/payment-api/v1/account/status?network=polygon" | jq

{
  "amount": "22.444979322042006358",
  "reserved": "0",
  "outgoing": {
    "requested": {
      "totalAmount": "0.000197094797101683",
      "agreementsCount": 3
    },
    "accepted": {
      "totalAmount": "0.000197094797101683",
      "agreementsCount": 3
    },
    "confirmed": {
      "totalAmount": "0.000197094797101683",
      "agreementsCount": 3
    }
  },
  "incoming": {
    "requested": {
      "totalAmount": "0.086760639607644453",
      "agreementsCount": 4
    },
    "accepted": {
      "totalAmount": "0.086760639607644453",
      "agreementsCount": 4
    },
    "confirmed": {
      "totalAmount": "0.086760639607644453",
      "agreementsCount": 4
    }
  },
  "driver": "erc20",
  "network": "polygon",
  "token": "GLM",
  "gas": {
    "currency_short_name": "MATIC",
    "currency_long_name": "Polygon",
    "balance": "0.221277145100550748"
  },
  "block_number": 0,
  "block_datetime": "1970-01-01T00:00:00Z"
}