Skip to content

Commit

Permalink
Merge pull request tinymanorg#365 from tinymanorg/fix/build-script
Browse files Browse the repository at this point in the history
Updates origin for icon URLs and fixes build script to match asset ids correctly
  • Loading branch information
edizcelik authored Feb 28, 2022
2 parents f8c6870 + 64a7f6c commit fac53a2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ If you think you have met all the criteria and your PR has not been accepted, yo

You can use all ASA icons here in your projects dynamically. Each time the main branch is updated, the icons will be moved to the server. The following URLs can be used to access a project's icon.

- `https://asa-icons.s3.eu-central-1.amazonaws.com/` **`asset_id`** `/icon.png`
- `https://asa-icons.s3.eu-central-1.amazonaws.com/` **`asset_id`** `/icon.svg`
- `https://asa-list.tinyman.org/` **`asset_id`** `/icon.png`
- `https://asa-list.tinyman.org/` **`asset_id`** `/icon.svg`

For example, we want to access the icon of USDc. USDc's asset ID is 31566704. It can be accessed via this URL.

https://asa-icons.s3.eu-central-1.amazonaws.com/31566704/icon.png
https://asa-list.tinyman.org/31566704/icon.png
21 changes: 10 additions & 11 deletions build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ const __filename = fileURLToPath(import.meta.url);

const algoIconsFolderName = "ALGO";

const ASSET_LOGO_BASE_URL = "https://asa-icons.s3.eu-central-1.amazonaws.com";
const ASSET_ID_MATCHER = /\d+/;
const ASSET_LOGO_BASE_URL = "https://asa-list.tinyman.org";
const currentDirname = path.dirname(__filename);
const buildDirectory = path.join(currentDirname, "build");
const ASSET_ICON_MAP = new Map();
Expand Down Expand Up @@ -64,17 +63,17 @@ try {
* @returns Directory name that includes only asset ids
*/
function createTargetDirectoryName(source) {
let sourceDirName = source;

if (sourceDirName.match(ASSET_ID_MATCHER)) {
sourceDirName = sourceDirName.match(ASSET_ID_MATCHER)[0];
} else if (
sourceDirName.toLowerCase() === algoIconsFolderName.toLowerCase()
) {
sourceDirName = "0";
// If there is a match, the last capturing group will always be the asset id
const idMatchResult = source.match(/(.*)-(\d+)/);
let targetDirName = source;

if (idMatchResult?.length) {
targetDirName = idMatchResult[idMatchResult.length - 1];
} else if (source.toLowerCase() === algoIconsFolderName.toLowerCase()) {
targetDirName = "0";
}

return sourceDirName;
return targetDirName;
}

function copyDirectorySync(source, target, targetDirName) {
Expand Down

0 comments on commit fac53a2

Please sign in to comment.