Skip to content

Commit

Permalink
Merge pull request #17 from infinity-swap/CPROD-1375-add-sns-token-logo
Browse files Browse the repository at this point in the history
  • Loading branch information
blutooth authored Dec 15, 2022
2 parents f85e576 + c33326f commit cefd867
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/popular-cats-appear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@infinityswapofficial/token-lists': patch
---

Updated sns token info to include logo
10 changes: 8 additions & 2 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
run: yarn install --frozen-lockfile && yarn test:ci

release:
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
if: ${{ github.event_name == 'push' }}
runs-on: ubuntu-latest
needs: tests
steps:
Expand All @@ -34,7 +34,13 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 16.x
registry-url: 'https://registry.npmjs.org'
- name: Creating .npmrc
run: |
cat << EOF > "$HOME/.npmrc"
//registry.npmjs.org/:_authToken=$NPM_TOKEN
EOF
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Install Dependencies
run: yarn install --frozen-lockfile
- name: Create Release Pull Request or Publish to npm
Expand Down
6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
"name": "@infinityswapofficial/token-lists",
"version": "0.1.1",
"description": "InfinitySwap Token Lists specification",
"author": {
"name": "InfinitySwap",
"email": "support@infinityswap.one",
"url": "https://infinityswap.one"
},
"author": "InfinitySwap <support@infinityswap.one> (https://infinityswap.one)",
"type": "module",
"source": "src/index.ts",
"exports": {
Expand Down
9 changes: 7 additions & 2 deletions src/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface TokenProperties {
tags?: string[];
index_canister?: string;
canisterInfo?: CanisterInfo;
logo?: string;
}

export type JsonnableToken = TokenProperties;
Expand Down Expand Up @@ -57,6 +58,7 @@ export class Token {
indexCanister?: Principal;
tags?: string[];
canisterInfo?: CanisterInfo;
logo?: string;

constructor(props: TokenProperties) {
this.id = Principal.fromText(props.id);
Expand All @@ -70,6 +72,7 @@ export class Token {
this.indexCanister = props.index_canister
? Principal.fromText(props.index_canister)
: undefined;
this.logo = props.logo;
}

get wasmHash() {
Expand Down Expand Up @@ -113,7 +116,8 @@ export class Token {
standard: this.standard,
tags: this.tags,
index_canister: this.indexCanister?.toText(),
canisterInfo: this.canisterInfo
canisterInfo: this.canisterInfo,
logo: this.logo
};
}
}
Expand Down Expand Up @@ -184,7 +188,8 @@ export class TokenList {
agent
});

const [, snsTokenMeta] = await snsWrapper.metadata({});
const [snsMeta, snsTokenMeta] = await snsWrapper.metadata({});
tokenMeta.logo = snsMeta.logo[0];
snsTokenMeta.forEach(([key, val]) => {
if (key.includes('decimals') && 'Nat' in val) {
tokenMeta.decimals = Number(val.Nat);
Expand Down

0 comments on commit cefd867

Please sign in to comment.