Skip to content
This repository has been archived by the owner on Nov 28, 2023. It is now read-only.

Commit

Permalink
Merge pull request #3 from ionvv/main
Browse files Browse the repository at this point in the history
getTokens method
  • Loading branch information
michavie authored Nov 22, 2023
2 parents ef00c84 + 4fe7f01 commit a9de166
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Api/Endpoints/TokenEndpoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ public function getById(string $tokenId, array $params = []): TokenDetailed
);
}

public function getTokens(array $params = []): Collection
{
return TokenDetailed::fromApiResponse(
$this->client->request('GET', "/tokens", [
'query' => $params,
]),
isCollection: true,
);
}

public function getAccounts(string $tokenId, array $params = []): Collection
{
return TokenAccount::fromApiResponse(
Expand Down
3 changes: 3 additions & 0 deletions src/Entities/TokenDetailed.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public function __construct(
public string $supply,
public ?string $minted = null,
public ?string $burnt = null,
public ?string $type = null,
public ?float $price = null,
public ?float $marketCap = null,
) {
}

Expand Down
9 changes: 9 additions & 0 deletions tests/Api/TokensTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@
assertMatchesResponseSnapshot($actual);
});

it('getTokens - gets tokens', function () {
$client = createMockedHttpClientWithResponse('tokens/tokens.json');

$actual = (new TokenEndpoints($client))
->getTokens();

assertMatchesResponseSnapshot($actual);
});

it('getAccounts - gets the token accounts', function () {
$client = createMockedHttpClientWithResponse('tokens/accounts.json');

Expand Down
152 changes: 152 additions & 0 deletions tests/Api/responses/tokens/tokens.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
[
{
"type": "FungibleESDT",
"identifier": "HTM-f51d55",
"name": "Hatom",
"ticker": "HTM",
"owner": "erd1y5ytj48d9cd9rvgzk7zkth0gerywu2s6y0tpg23c9rrhhg50dtestnvh79",
"decimals": 18,
"isPaused": false,
"assets": {
"website": "https://hatom.com/",
"description": "HTM is the utility and governance token of Hatom, a liquidity protocol that empowers DeFi in the MultiversX blockchain",
"status": "active",
"pngUrl": "https://media.elrond.com/tokens/asset/HTM-f51d55/logo.png",
"svgUrl": "https://media.elrond.com/tokens/asset/HTM-f51d55/logo.svg",
"lockedAccounts": {
"erd1y5ytj48d9cd9rvgzk7zkth0gerywu2s6y0tpg23c9rrhhg50dtestnvh79": "Minter Account",
"erd1qqqqqqqqqqqqqpgq39rqpn2xvm0ykl2ccaa4h5zk5c9r647wdteswmap9l": "Investors Vesting",
"erd1qqqqqqqqqqqqqpgq4hl5hdvvxtm987nw5vtczgm8y89ra2hndteshlehgs": "Token Vesting"
},
"ledgerSignature": "304402200efd7cbc3a55b1eecbdd0e53c7c949ab4c39c6359f4d28eb4e3b7257a1bd4e8302204b845636199611baeef599bca3cc1472d53baa7a216046c0f0a7baab34b66e1f",
"social": {
"blog": "https://blog.hatom.com/",
"telegram": "https://t.me/HatomProtocol",
"twitter": "https://twitter.com/HatomProtocol",
"whitepaper": "https://docs.hatom.com/getting-started/learn-more-about-hatom-token/whitepaper"
}
},
"transactions": 51360,
"accounts": 38703,
"canUpgrade": true,
"canMint": false,
"canBurn": false,
"canChangeOwner": true,
"canAddSpecialRoles": true,
"canPause": false,
"canFreeze": false,
"canWipe": false,
"price": 2.21338616753827,
"marketCap": 34480730.90310609,
"supply": "100000000000000000000000000",
"circulatingSupply": "15578271613333333333333416"
},
{
"type": "FungibleESDT",
"identifier": "WEGLD-bd4d79",
"name": "WrappedEGLD",
"ticker": "WEGLD",
"owner": "erd1ss6u80ruas2phpmr82r42xnkd6rxy40g9jl69frppl4qez9w2jpsqj8x97",
"decimals": 18,
"isPaused": false,
"assets": {
"website": "https://xexchange.com",
"description": "wEGLD is an ESDT token that has the same value as EGLD, the native coin of the MultiversX blockchain.",
"status": "active",
"pngUrl": "https://media.elrond.com/tokens/asset/WEGLD-bd4d79/logo.png",
"svgUrl": "https://media.elrond.com/tokens/asset/WEGLD-bd4d79/logo.svg",
"ledgerSignature": "3044022062a68d4bdd649aebb5e4ed5c6284e211c689c3b8142e59a47b01cc9997b16dfa0220475b064836849b9c4aa9c5ff18daed91a64f847bd96aa0a26768349f2cd0c24f"
},
"transactions": 6860481,
"accounts": 131902,
"canUpgrade": true,
"canMint": true,
"canBurn": true,
"canChangeOwner": true,
"canAddSpecialRoles": true,
"canPause": true,
"canFreeze": true,
"canWipe": true,
"price": 42.62450699127219,
"marketCap": 33489009.386221197,
"supply": "785674996618222940597861",
"circulatingSupply": "785674996618222940597861"
},
{
"type": "FungibleESDT",
"identifier": "MEX-455c57",
"name": "MEX",
"ticker": "MEX",
"owner": "erd1ss6u80ruas2phpmr82r42xnkd6rxy40g9jl69frppl4qez9w2jpsqj8x97",
"decimals": 18,
"isPaused": false,
"assets": {
"website": "https://xexchange.com",
"description": "MEX is the utility token of the xExchange.",
"status": "active",
"pngUrl": "https://media.elrond.com/tokens/asset/MEX-455c57/logo.png",
"svgUrl": "https://media.elrond.com/tokens/asset/MEX-455c57/logo.svg",
"ledgerSignature": "304402207c9727bf3a0af254052154bceefe835856e4a7f6538cb6f5c3ef12422c6ab5dd02207d7a6c88777032079cd57b5b859a6e8dee4b73bb4fa699f0340f99fb70080a8d"
},
"transactions": 1813732,
"accounts": 98331,
"canUpgrade": true,
"canMint": true,
"canBurn": true,
"canChangeOwner": true,
"canAddSpecialRoles": true,
"canPause": true,
"canFreeze": true,
"canWipe": true,
"price": 0.000006427122425848906,
"marketCap": 26205346.831226137,
"supply": "4077306311426748277802457991213",
"circulatingSupply": "4077306311426748277802457991213"
},
{
"type": "FungibleESDT",
"identifier": "UTK-2f80e9",
"name": "Utrust",
"ticker": "UTK",
"owner": "erd1kc3y0d3jhmv4j42lvyq84t395s7s47tucpw97grwgaj8dqlkzumsw97k34",
"decimals": 18,
"isPaused": false,
"assets": {
"website": "https://www.xmoney.com/",
"description": "Web3 L1 Payments Technology",
"status": "active",
"pngUrl": "https://media.elrond.com/tokens/asset/UTK-2f80e9/logo.png",
"svgUrl": "https://media.elrond.com/tokens/asset/UTK-2f80e9/logo.svg",
"extraTokens": [
"UTKWEGLD-c960d1",
"METAUTKLK-e6a445",
"METAUTK-291e0e",
"SUTK-ba35f3",
"UTKWEGLDFL-082aec",
"UTKWEGLDF-5b9d50"
],
"name": "xMoney UTK",
"ledgerSignature": "304402204f2f6035dccb8c5e16698a1a8cfd0c0d4203e9a31103147e286fa1c1ea829c16022003284c1f3c8cb23b6587c5dee3187feb1e0663b15ffbffa89dbe07e7a766eff2",
"social": {
"email": "[email protected]",
"twitter": "https://twitter.com/xMoney_com",
"coinmarketcap": "https://coinmarketcap.com/currencies/utrust/",
"coingecko": "https://www.coingecko.com/en/coins/xmoney"
}
},
"transactions": 503560,
"accounts": 76944,
"canUpgrade": true,
"canMint": true,
"canBurn": true,
"canChangeOwner": true,
"canAddSpecialRoles": true,
"canPause": true,
"canFreeze": true,
"canWipe": true,
"price": 0.06741330939393897,
"marketCap": 24650908.354071133,
"supply": "365668271973122553445481020",
"circulatingSupply": "365668271973122553445481020"
}
]
Binary file not shown.
Binary file not shown.

0 comments on commit a9de166

Please sign in to comment.