From 0621244d4c70ca2bf3b8564f49ac77139fe85906 Mon Sep 17 00:00:00 2001 From: rinchan01 Date: Mon, 2 Dec 2024 10:31:00 +0700 Subject: [PATCH 1/2] update files and apis for tokens with treasuryNft --- README.md | 6 +++--- src/adapters/blockFrostAdapter.ts | 5 ++--- src/adapters/types.ts | 8 ++++---- src/apis/marketcapApi.ts | 2 +- src/apis/tokenApi.ts | 2 +- ...f87c819f1056206e879a1cd61446a65644d6963726f555344.yaml | 2 +- ...f87c819f1056206e879a1cd615368656e4d6963726f555344.yaml | 2 +- 7 files changed, 13 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index e0bd145..77f76bb 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ socialLinks: verified: true # default true, if a token violate verification policy then switch to false # the following fields are not required -# for `big number`, it's a big number with no decimals. For example, if your token has a max supply of 50,000,000 tokens and 6 decimals, the value needs to be 50000000 × 10^6 = 50000000000000 +# for `big number`, it's a big number with no decimals. For example, if your token has a max supply of 50,000,000 tokens with 6 decimals, the value needs to be 50000000 × 10^6 = 50000000000000 # for `URIs`, currently only URI which returns a big number (no decimals) are supported maxSupply: big number # or @@ -77,10 +77,10 @@ circulatingOnChain: - https://... - assetId -treasuryNft: assetId +treasuryNft: addr... ``` -Alternatively, create an issue with above information and our team will update accordingly. The pull request will be processed faster. +Alternatively, create an issue with above information and our team will update accordingly. However, please note that the pull request will be processed faster. Our team will verify and approve in first-in-first-out order. ## Usage diff --git a/src/adapters/blockFrostAdapter.ts b/src/adapters/blockFrostAdapter.ts index 457c019..3650a5c 100644 --- a/src/adapters/blockFrostAdapter.ts +++ b/src/adapters/blockFrostAdapter.ts @@ -26,8 +26,7 @@ export class BlockFrostAdapter implements Adapter { return BigInt(assetInfo?.quantity); } - async getAmountInFirstAddressHoldingAsset(tokenId: string, nftId: string): Promise { - const addresses = await this.blockFrost.assetsAddresses(nftId); - return await this.getAmountInAddress(addresses[0]["address"], tokenId); + async getAmountInFirstAddressHoldingAsset(address: string, tokenId: string): Promise { + return await this.getAmountInAddress(address, tokenId); } } diff --git a/src/adapters/types.ts b/src/adapters/types.ts index 112c3ff..f8a4614 100644 --- a/src/adapters/types.ts +++ b/src/adapters/types.ts @@ -18,10 +18,10 @@ export type Adapter = { /** * Get the amount held in the address holding a specific asset by the asset's ID. - * After obtaining a list of addresses possessing a specific asset in blockchain's point of view ascending order, this retrieve the amount associated with the first address returned. + * After obtaining a list of addresses possessing a specific asset in ascending order from the blockchain's point of view, this retrieve the amount associated with the first address returned. * This function currently supports Shen and DJED. - * @param tokenId The token's policy ID. - * @param nftId The concatenation of token's policy ID and hex-coded token name. + * @param address The first address holding the asset returned in ascending order from the blockchain's point of view. + * @param tokenId The concatenation of token's policy ID and hex-coded token name. */ - getAmountInFirstAddressHoldingAsset(tokenId: string, nftId: string): Promise; + getAmountInFirstAddressHoldingAsset(address: string, tokenId: string): Promise; }; diff --git a/src/apis/marketcapApi.ts b/src/apis/marketcapApi.ts index f357cc6..d1ea0cc 100644 --- a/src/apis/marketcapApi.ts +++ b/src/apis/marketcapApi.ts @@ -49,7 +49,7 @@ export class MarketCapAPI { if (tokenInfo.treasuryNft) { const treasuryRaw = tokenInfo.treasuryNft; - const treasury = await this.adapter.getAmountInFirstAddressHoldingAsset(tokenId, treasuryRaw); + const treasury = await this.adapter.getAmountInFirstAddressHoldingAsset(treasuryRaw, tokenId); return { total: formatNumber(total - treasury, decimals), circulating: formatNumber(total - treasury, decimals), diff --git a/src/apis/tokenApi.ts b/src/apis/tokenApi.ts index 7fcd6f6..4f6d1d1 100644 --- a/src/apis/tokenApi.ts +++ b/src/apis/tokenApi.ts @@ -14,7 +14,7 @@ export class TokenAPI { public async getToken(tokenId: string) { try { const __dirname = import.meta.dirname; - const filePath = path.join(__dirname, `${TOKENS_DIR}/${tokenId}.yaml`); + const filePath = path.join(__dirname, `../${TOKENS_DIR}/${tokenId}.yaml`); const tokenFileData = fs.readFileSync(filePath, "utf-8"); const tokenData: TokenMetadata = { tokenId, diff --git a/src/tokens/8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd61446a65644d6963726f555344.yaml b/src/tokens/8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd61446a65644d6963726f555344.yaml index 4eb8bf3..2f14082 100644 --- a/src/tokens/8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd61446a65644d6963726f555344.yaml +++ b/src/tokens/8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd61446a65644d6963726f555344.yaml @@ -13,5 +13,5 @@ maxSupply: '1000000000000000000' decimals: 6 -treasuryNft: 8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd61446a6564537461626c65436f696e4e4654 +treasuryNft: addr1zx82ru5f7p8ewhhdvahueg2s4gxs3gxl66fkygdekkjs74sm5kjdmrpmng059yellupyvwgay2v0lz6663swmds7hp0q4vpw0l diff --git a/src/tokens/8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd615368656e4d6963726f555344.yaml b/src/tokens/8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd615368656e4d6963726f555344.yaml index 4cd3ba2..62f4f0a 100644 --- a/src/tokens/8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd615368656e4d6963726f555344.yaml +++ b/src/tokens/8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd615368656e4d6963726f555344.yaml @@ -13,5 +13,5 @@ maxSupply: '1000000000000000000' decimals: 6 -treasuryNft: 8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd61446a6564537461626c65436f696e4e4654 +treasuryNft: addr1zx82ru5f7p8ewhhdvahueg2s4gxs3gxl66fkygdekkjs74sm5kjdmrpmng059yellupyvwgay2v0lz6663swmds7hp0q4vpw0l From 48f34146481d0c737fb630f3897bb1b742fbfbfb Mon Sep 17 00:00:00 2001 From: rinchan01 Date: Mon, 2 Dec 2024 14:33:19 +0700 Subject: [PATCH 2/2] update files and apis for tokens with treasuryOnChain --- README.md | 9 ++++++--- src/adapters/blockFrostAdapter.ts | 4 ---- src/adapters/types.ts | 9 --------- src/apis/marketcapApi.ts | 8 ++++---- src/tokenSchema.ts | 2 +- ...87c819f1056206e879a1cd61446a65644d6963726f555344.yaml | 5 ++--- ...87c819f1056206e879a1cd615368656e4d6963726f555344.yaml | 5 ++--- 7 files changed, 15 insertions(+), 27 deletions(-) mode change 100644 => 100755 README.md mode change 100644 => 100755 src/adapters/blockFrostAdapter.ts mode change 100644 => 100755 src/adapters/types.ts mode change 100644 => 100755 src/apis/marketcapApi.ts mode change 100644 => 100755 src/tokenSchema.ts mode change 100644 => 100755 src/tokens/8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd61446a65644d6963726f555344.yaml mode change 100644 => 100755 src/tokens/8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd615368656e4d6963726f555344.yaml diff --git a/README.md b/README.md old mode 100644 new mode 100755 index 77f76bb..cf2db6b --- a/README.md +++ b/README.md @@ -8,21 +8,24 @@ As of latest update, we consider `circulating = maxSupply - treasury - burn` and In cases where `circulatingOnChain` is provided directly according to the asset's quantity on-chain or through external APIs, the `circulating` is the value of `circulatingOnChain`. -For tokens providing with `treasuryNft`, the `circulating` is the quantity of the address containing the assets. In default, the amount is retrieved from the oldest address from the blockchain's point of view. +For tokens providing with `treasuryOnChain`, the `circulating` is the quantity of the address containing the assets. In default, the amount is retrieved from the oldest address from the blockchain's point of view. ## How to add my token + ### Requirements + As token verification prerequisites, ensure your token has: + - A pool with at least **1000 ADA TVL**, - A post of your policy ID on Twitter or your policy ID displayed on your landing page, - A logo added in the [Cardano Token Registry](https://github.com/cardano-foundation/cardano-token-registry) or CIP-68 metadata. For tokens to be verified: + 1. Create a transaction transfer **100 ADA** to Minswap wallet receiving token verification fee below. This fee appears as the cost for lifetime maintain this repository. 2. Metadata includes: **the last 4 numbers of asset's policyId and asset's ticker** (for example, Verify 70c6 MIN). 3. Attach the transaction hash to a comment in the yaml file pull request (instructions below). - Minswap wallet receiving token verification fee: `addr1q85g6fkwzr2cf984qdmntqthl3yxnw4pst4mpgeyygdlnehqlcgwvr6c9vmajz96vnmmset3earqt5wl0keg0kw60eysdgwnej` Any token that has been verified does **not** meet the requirements in the future would still be unverified. @@ -77,7 +80,7 @@ circulatingOnChain: - https://... - assetId -treasuryNft: addr... +treasuryOnChain: addr... ``` Alternatively, create an issue with above information and our team will update accordingly. However, please note that the pull request will be processed faster. diff --git a/src/adapters/blockFrostAdapter.ts b/src/adapters/blockFrostAdapter.ts old mode 100644 new mode 100755 index 3650a5c..587e52e --- a/src/adapters/blockFrostAdapter.ts +++ b/src/adapters/blockFrostAdapter.ts @@ -25,8 +25,4 @@ export class BlockFrostAdapter implements Adapter { const assetInfo = await this.blockFrost.assetsById(assetId); return BigInt(assetInfo?.quantity); } - - async getAmountInFirstAddressHoldingAsset(address: string, tokenId: string): Promise { - return await this.getAmountInAddress(address, tokenId); - } } diff --git a/src/adapters/types.ts b/src/adapters/types.ts old mode 100644 new mode 100755 index f8a4614..36d1ba4 --- a/src/adapters/types.ts +++ b/src/adapters/types.ts @@ -15,13 +15,4 @@ export type Adapter = { * @param assetId The concatenation of token's policy ID and the hex-coded token name. */ getOnchainAmountOfAsset(assetId: string): Promise; - - /** - * Get the amount held in the address holding a specific asset by the asset's ID. - * After obtaining a list of addresses possessing a specific asset in ascending order from the blockchain's point of view, this retrieve the amount associated with the first address returned. - * This function currently supports Shen and DJED. - * @param address The first address holding the asset returned in ascending order from the blockchain's point of view. - * @param tokenId The concatenation of token's policy ID and hex-coded token name. - */ - getAmountInFirstAddressHoldingAsset(address: string, tokenId: string): Promise; }; diff --git a/src/apis/marketcapApi.ts b/src/apis/marketcapApi.ts old mode 100644 new mode 100755 index d1ea0cc..fa7d56b --- a/src/apis/marketcapApi.ts +++ b/src/apis/marketcapApi.ts @@ -40,16 +40,16 @@ export class MarketCapAPI { return nullResponse; } - if (!tokenInfo.circulatingOnChain && !tokenInfo.burn && !tokenInfo.treasury && !tokenInfo.treasuryNft) { + if (!tokenInfo.circulatingOnChain && !tokenInfo.burn && !tokenInfo.treasury && !tokenInfo.treasuryOnChain) { return { total: formatNumber(total, decimals), }; } - if (tokenInfo.treasuryNft) { - const treasuryRaw = tokenInfo.treasuryNft; + if (tokenInfo.treasuryOnChain) { + const treasuryRaw = tokenInfo.treasuryOnChain; - const treasury = await this.adapter.getAmountInFirstAddressHoldingAsset(treasuryRaw, tokenId); + const treasury = await this.adapter.getAmountInAddress(treasuryRaw, tokenId); return { total: formatNumber(total - treasury, decimals), circulating: formatNumber(total - treasury, decimals), diff --git a/src/tokenSchema.ts b/src/tokenSchema.ts old mode 100644 new mode 100755 index a701790..aa41467 --- a/src/tokenSchema.ts +++ b/src/tokenSchema.ts @@ -128,7 +128,7 @@ export const tokenSchema: JSONSchemaType = { }, nullable: true, }, - treasuryNft: { + treasuryOnChain: { type: "string", nullable: true, }, diff --git a/src/tokens/8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd61446a65644d6963726f555344.yaml b/src/tokens/8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd61446a65644d6963726f555344.yaml old mode 100644 new mode 100755 index 2f14082..b9157fe --- a/src/tokens/8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd61446a65644d6963726f555344.yaml +++ b/src/tokens/8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd61446a65644d6963726f555344.yaml @@ -9,9 +9,8 @@ socialLinks: verified: true -maxSupply: '1000000000000000000' +maxSupply: "1000000000000000000" decimals: 6 -treasuryNft: addr1zx82ru5f7p8ewhhdvahueg2s4gxs3gxl66fkygdekkjs74sm5kjdmrpmng059yellupyvwgay2v0lz6663swmds7hp0q4vpw0l - +treasuryOnChain: addr1zx82ru5f7p8ewhhdvahueg2s4gxs3gxl66fkygdekkjs74sm5kjdmrpmng059yellupyvwgay2v0lz6663swmds7hp0q4vpw0l diff --git a/src/tokens/8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd615368656e4d6963726f555344.yaml b/src/tokens/8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd615368656e4d6963726f555344.yaml old mode 100644 new mode 100755 index 62f4f0a..df48143 --- a/src/tokens/8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd615368656e4d6963726f555344.yaml +++ b/src/tokens/8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd615368656e4d6963726f555344.yaml @@ -9,9 +9,8 @@ socialLinks: verified: true -maxSupply: '1000000000000000000' +maxSupply: "1000000000000000000" decimals: 6 -treasuryNft: addr1zx82ru5f7p8ewhhdvahueg2s4gxs3gxl66fkygdekkjs74sm5kjdmrpmng059yellupyvwgay2v0lz6663swmds7hp0q4vpw0l - +treasuryOnChain: addr1zx82ru5f7p8ewhhdvahueg2s4gxs3gxl66fkygdekkjs74sm5kjdmrpmng059yellupyvwgay2v0lz6663swmds7hp0q4vpw0l