Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ST-725: fix token not displaying symbol #509

Merged
merged 2 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/codecommit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: sync to codecommit

on:
push:
tags:
- '*'
branches:
- '*'

jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.CC_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.CC_SECRET_KEY }}
aws-region: us-east-1

- name: Sync up to CodeCommit
uses: terra-money/sync-up-to-codecommit-action@v1
with:
repository_name: ${{ github.event.repository.name }}
aws_region: us-east-1
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ const AssetSelector = ({
<ArrowDropDownIcon style={{ fontSize: 20 }} className={styles.caret} />
</button>
{open && (
<AssetList list={assetList} onChange={handleSelection} value={value} />
<AssetList
list={assetList.filter(({ balance }) => !!Number(balance))}
onChange={handleSelection}
value={value}
/>
)}
</div>
)
Expand Down
28 changes: 21 additions & 7 deletions src/data/token.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export enum TokenType {
IBC = "ibc",
GAMM = "gamm",
FACTORY = "factory",
STRIDE = "stride",
}

export const useNativeDenoms = () => {
Expand All @@ -110,6 +111,11 @@ export const useNativeDenoms = () => {
} else if (denom.startsWith("gamm/")) {
tokenType = TokenType.GAMM
decimals = GAMM_TOKEN_DECIMALS
} else if (
denom.startsWith("stu") &&
(!chainID || chainID === "stride-1")
) {
tokenType = TokenType.STRIDE
}

let fixedDenom = ""
Expand All @@ -122,18 +128,21 @@ export const useNativeDenoms = () => {
fixedDenom = gammTokens.get(denom) ?? readDenom(denom)
break

case TokenType.FACTORY: {
case TokenType.FACTORY:
const factoryParts = denom.split(/[/:]/)
let tokenAddress = ""
if (factoryParts.length >= 2) {
tokenAddress = factoryParts.slice(2).join(" ")
}
fixedDenom = tokenAddress
break
}

case TokenType.STRIDE:
fixedDenom = `st${denom.replace("stu", "").toUpperCase()}`
break

default:
fixedDenom = readDenom(denom)
fixedDenom = readDenom(denom) || denom
}

let factoryIcon
Expand Down Expand Up @@ -204,6 +213,10 @@ export const useNativeDenoms = () => {
}
}

const CHAIN_ICON =
networks[chainID ?? ""]?.icon ||
"https://assets.terra.dev/icon/svg/Terra.svg"

return (
cw20.find(({ token }) => denom === token) ?? {
// default token icon
Expand All @@ -212,11 +225,12 @@ export const useNativeDenoms = () => {
name: fixedDenom,
type: tokenType,
icon:
tokenType === TokenType.IBC
(tokenType === TokenType.IBC
? "https://assets.terra.dev/icon/svg/IBC.svg"
: tokenType === TokenType.FACTORY || TokenType.GAMM
? factoryIcon
: "https://assets.terra.dev/icon/svg/Terra.svg",
: tokenType === TokenType.STRIDE
? "https://station-assets.terra.dev/img/chains/Stride.png"
: (tokenType === TokenType.FACTORY || TokenType.GAMM) &&
factoryIcon) || CHAIN_ICON,
decimals,
isNonWhitelisted: true,
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/wallet/SendPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const SendPage = () => {
() =>
Object.values(
(balances ?? []).reduce((acc, { denom, amount, chain }) => {
const data = readNativeDenom(denom)
const data = readNativeDenom(denom, chain)
// TODO: resolve ibc lun(a|c) balances better at balance fetch
// then update max / balance / messaging to translate lun(a|c)
// for now, check if token is LUNC and network isn't classic, discard if so
Expand Down
Loading