Skip to content

Commit

Permalink
Merge pull request #31 from CityOfZion/CU-86a217gdx
Browse files Browse the repository at this point in the history
CU-86a217gdx - NeoLegacy: Remove 0x from the return token of the method getBalance
  • Loading branch information
lock9 authored Jan 29, 2024
2 parents 454c79c + 62895d7 commit 18fc343
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 242 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@cityofzion/bs-neo-legacy",
"comment": "Removed 0x from the return token od the getBalance method",
"type": "patch"
}
],
"packageName": "@cityofzion/bs-neo-legacy"
}
8 changes: 5 additions & 3 deletions packages/bs-neo-legacy/src/DoraBDSNeoLegacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class DoraBDSNeoLegacy implements BlockchainDataService, BDSClaimable {
if (!data || 'error' in data) throw new Error(`Token ${tokenHash} not found`)

const token = {
decimals: data.decimals,
decimals: Number(data.decimals),
symbol: data.symbol,
hash: data.scripthash,
name: data.name,
Expand All @@ -138,15 +138,17 @@ export class DoraBDSNeoLegacy implements BlockchainDataService, BDSClaimable {
const data = await api.NeoLegacyREST.balance(address, this.network.type)

const promises = data.map<Promise<BalanceResponse>>(async balance => {
const hash = balance.asset.replace('0x', '')

let token: Token = {
hash: balance.asset,
hash,
name: balance.asset_name,
symbol: balance.symbol,
decimals: 8,
}

try {
token = await this.getTokenInfo(balance.asset)
token = await this.getTokenInfo(hash)
} catch {
// Empty block
}
Expand Down
1 change: 1 addition & 0 deletions packages/bs-neo-legacy/src/__tests__/BDSNeoLegacy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ describe('BDSNeoLegacy', () => {
decimals: expect.any(Number),
},
})
expect(balance.token.hash.startsWith("0x")).toBeFalsy()
})
})

Expand Down
10 changes: 3 additions & 7 deletions packages/bs-neo-legacy/src/assets/tokens/common.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
[
{
"symbol": "GAS",
"type": "UtilityToken",
"name": "GAS",
"hash": "602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7",
"decimals": 8,
"blockchain": "neoLegacy"
"decimals": 8
},
{
"symbol": "NEO",
"type": "GoverningToken",
"name": "NEO",
"hash": "c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b",
"decimals": 0,
"blockchain": "neoLegacy"
"decimals": 0
}
]
]
Loading

0 comments on commit 18fc343

Please sign in to comment.