cryptonative-ch / aqua-smartcontracts

⛓️ Aqua Smart Contracts
GNU Lesser General Public License v3.0
4 stars 5 forks source link

`getContractAddressesForChainOrThrow` throws error in aqua-sc #143

Closed adamazad closed 3 years ago

adamazad commented 3 years ago

Using aqua-sc@0.1.2,

import { getContractAddressesForChainOrThrow, ChainId } from 'aqua-sc'

const addersses = getContractAddressesForChainOrThrow(ChainId.xdai)

throws

TypeError: Cannot read property '100' of undefined
    at Object.getContractAddressesForChainOrThrow (E:\mesa\mesa-subgraph\node_modules\aqua-sc\index.js:34:25)
    at E:\mesa\mesa-subgraph\bin\prepare.ts:19:21
    at Generator.next (<anonymous>)
    at E:\mesa\mesa-subgraph\bin\prepare.ts:9:71
    at new Promise (<anonymous>)
    at __awaiter (E:\mesa\mesa-subgraph\bin\prepare.ts:5:12)
    at prepare (E:\mesa\mesa-subgraph\bin\prepare.ts:30:12)
    at Object.<anonymous> (E:\mesa\mesa-subgraph\bin\prepare.ts:46:3)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Module.m._compile (E:\mesa\mesa-subgraph\node_modules\ts-node\src\index.ts:1056:23)

For now, this works


import addresses from 'aqua-sc/addresses.json'

addresses[100] // rinkeby
addresses[4] // xdai
denciu commented 3 years ago

Typescript has a problem with compiling json import as it is right now. I'll apply this fix along with bundling script refactor.

// tsc adds ["default"] to the imported object
import addresses from './addresses.json'

// tsc is now happy
import * as addresses from './addresses.json'