@cityofzion/bs-neo-legacy 0.9.0 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,11 +3,9 @@ export declare const TOKENS: Record<NetworkType, Token[]>;
3
3
  export declare const LEGACY_NETWORK_BY_NETWORK_TYPE: Record<Exclude<NetworkType, 'custom'>, string>;
4
4
  export declare const NATIVE_ASSETS: {
5
5
  symbol: string;
6
- type: string;
7
6
  name: string;
8
7
  hash: string;
9
8
  decimals: number;
10
- blockchain: string;
11
9
  }[];
12
10
  export declare const DEFAULT_URL_BY_NETWORK_TYPE: Record<Exclude<NetworkType, 'custom'>, string>;
13
11
  export declare const DERIVATION_PATH = "m/44'/888'/0'/0/?";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cityofzion/bs-neo-legacy",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "author": "Coz",
@@ -9,19 +9,24 @@
9
9
  "@cityofzion/dora-ts": "0.0.11",
10
10
  "@cityofzion/neon-js": "4.8.3",
11
11
  "axios": "1.5.1",
12
- "@cityofzion/blockchain-service": "0.9.0",
12
+ "@cityofzion/blockchain-service": "0.9.1",
13
13
  "@cityofzion/bs-asteroid-sdk": "0.7.3"
14
14
  },
15
15
  "devDependencies": {
16
- "ts-node": "10.9.1",
17
- "typescript": "4.9.5",
16
+ "@types/jest": "29.5.3",
17
+ "@typescript-eslint/eslint-plugin": "^6.5.0",
18
+ "@typescript-eslint/parser": "^6.5.0",
19
+ "dotenv": "16.3.1",
20
+ "eslint": "^8.48.0",
18
21
  "jest": "29.6.2",
19
22
  "ts-jest": "29.1.1",
20
- "@types/jest": "29.5.3",
21
- "dotenv": "16.3.1"
23
+ "ts-node": "10.9.1",
24
+ "typescript": "4.9.5"
22
25
  },
23
26
  "scripts": {
24
27
  "build": "tsc --project tsconfig.build.json",
25
- "test": "jest --config jest.config.ts"
28
+ "test": "jest --config jest.config.ts",
29
+ "lint": "eslint .",
30
+ "format": "eslint --fix"
26
31
  }
27
32
  }
@@ -103,15 +103,15 @@ export class BSNeoLegacy<BSCustomName extends string = string>
103
103
  try {
104
104
  const { NativeModules } = require('react-native')
105
105
  BsReactNativeDecrypt = NativeModules.BsReactNativeDecrypt
106
+
107
+ if (!BsReactNativeDecrypt) {
108
+ throw new Error('@CityOfZion/bs-react-native-decrypt is not installed')
109
+ }
106
110
  } catch {
107
111
  const key = await wallet.decrypt(encryptedKey, password)
108
112
  return this.generateAccountFromKey(key)
109
113
  }
110
114
 
111
- if (!BsReactNativeDecrypt) {
112
- throw new Error('@CityOfZion/bs-react-native-decrypt is not installed')
113
- }
114
-
115
115
  const privateKey = await BsReactNativeDecrypt.decryptNeoLegacy(encryptedKey, password)
116
116
  return this.generateAccountFromKey(privateKey)
117
117
  }
@@ -8,7 +8,6 @@ import {
8
8
  BDSClaimable,
9
9
  TransactionTransferAsset,
10
10
  Token,
11
- NetworkType,
12
11
  Network,
13
12
  } from '@cityofzion/blockchain-service'
14
13
  import { api } from '@cityofzion/dora-ts'
@@ -124,7 +123,7 @@ export class DoraBDSNeoLegacy implements BlockchainDataService, BDSClaimable {
124
123
  if (!data || 'error' in data) throw new Error(`Token ${tokenHash} not found`)
125
124
 
126
125
  const token = {
127
- decimals: data.decimals,
126
+ decimals: Number(data.decimals),
128
127
  symbol: data.symbol,
129
128
  hash: data.scripthash,
130
129
  name: data.name,
@@ -139,16 +138,20 @@ export class DoraBDSNeoLegacy implements BlockchainDataService, BDSClaimable {
139
138
  const data = await api.NeoLegacyREST.balance(address, this.network.type)
140
139
 
141
140
  const promises = data.map<Promise<BalanceResponse>>(async balance => {
141
+ const hash = balance.asset.replace('0x', '')
142
+
142
143
  let token: Token = {
143
- hash: balance.asset,
144
+ hash,
144
145
  name: balance.asset_name,
145
146
  symbol: balance.symbol,
146
147
  decimals: 8,
147
148
  }
148
149
 
149
150
  try {
150
- token = await this.getTokenInfo(balance.asset)
151
- } catch {}
151
+ token = await this.getTokenInfo(hash)
152
+ } catch {
153
+ // Empty block
154
+ }
152
155
 
153
156
  return {
154
157
  amount: Number(balance.balance).toFixed(token.decimals),
@@ -3,7 +3,7 @@ import { DoraBDSNeoLegacy } from '../DoraBDSNeoLegacy'
3
3
  import { DEFAULT_URL_BY_NETWORK_TYPE, TOKENS } from '../constants'
4
4
 
5
5
  const gasToken = TOKENS.testnet.find(t => t.symbol === 'GAS')!
6
- let doraBDSNeoLegacy = new DoraBDSNeoLegacy(
6
+ const doraBDSNeoLegacy = new DoraBDSNeoLegacy(
7
7
  { type: 'testnet', url: DEFAULT_URL_BY_NETWORK_TYPE.testnet },
8
8
  gasToken,
9
9
  gasToken
@@ -67,7 +67,9 @@ describe('BDSNeoLegacy', () => {
67
67
  })
68
68
  )
69
69
  })
70
- } catch {}
70
+ } catch {
71
+ // Empty block
72
+ }
71
73
  }
72
74
  )
73
75
 
@@ -106,6 +108,7 @@ describe('BDSNeoLegacy', () => {
106
108
  decimals: expect.any(Number),
107
109
  },
108
110
  })
111
+ expect(balance.token.hash.startsWith('0x')).toBeFalsy()
109
112
  })
110
113
  })
111
114
 
@@ -1,5 +1,4 @@
1
1
  import { BSNeoLegacy } from '../BSNeoLegacy'
2
- import { wallet } from '@cityofzion/neon-js'
3
2
  import { generateMnemonic } from '@cityofzion/bs-asteroid-sdk'
4
3
 
5
4
  let bsNeoLegacy: BSNeoLegacy
@@ -1,18 +1,14 @@
1
1
  [
2
2
  {
3
3
  "symbol": "GAS",
4
- "type": "UtilityToken",
5
4
  "name": "GAS",
6
5
  "hash": "602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7",
7
- "decimals": 8,
8
- "blockchain": "neoLegacy"
6
+ "decimals": 8
9
7
  },
10
8
  {
11
9
  "symbol": "NEO",
12
- "type": "GoverningToken",
13
10
  "name": "NEO",
14
11
  "hash": "c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b",
15
- "decimals": 0,
16
- "blockchain": "neoLegacy"
12
+ "decimals": 0
17
13
  }
18
- ]
14
+ ]