diff --git a/package-lock.json b/package-lock.json index b0fc819..30b8ca8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,13 +1,16 @@ { "name": "@eximchain/dappbot-types", - "version": "1.7.13", + "version": "1.7.14", "lockfileVersion": 1, "requires": true, "dependencies": { "@eximchain/api-types": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@eximchain/api-types/-/api-types-1.0.1.tgz", - "integrity": "sha512-QO56ZAORrxUjSClT+460GQJapn2TyDB5FG+RnaZ35hOsjGhr5IrQjcEyWduer+0Iqzaq7wX21y1k911MhHJGEg==" + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@eximchain/api-types/-/api-types-1.0.4.tgz", + "integrity": "sha512-heYWxU8FkOEx+L7vhm3faJXgJ/vCd2rIq4o3rIqxsvR2trYAvjz9zeo7KP4TMCaMm5UJ17YgEzM+OZDFGWvzWw==", + "requires": { + "ts-xor": "^1.0.8" + } }, "@types/minimatch": { "version": "3.0.3", diff --git a/package.json b/package.json index c2f178f..8b7014f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@eximchain/dappbot-types", - "version": "1.7.13", + "version": "1.7.14", "description": "Typescript bindings to interact with the DappBot API", "main": "build/index.js", "types": "spec/index.ts", @@ -28,9 +28,9 @@ }, "homepage": "https://eximchain.github.io/dappbot-types", "dependencies": { + "@eximchain/api-types": "^1.0.4", "@types/stripe": "^6.32.13", - "ts-xor": "^1.0.8", - "@eximchain/api-types": "^1.0.1" + "ts-xor": "^1.0.8" }, "peerDependencies": { "@types/stripe": "6.31.25" diff --git a/spec/dapp/chains.ts b/spec/dapp/chains.ts deleted file mode 100644 index 81ef359..0000000 --- a/spec/dapp/chains.ts +++ /dev/null @@ -1,128 +0,0 @@ -export enum Names { - Eximchain = 'Eximchain', - EximGamma = 'EximGamma', - Ethereum = 'Ethereum', - Ropsten = 'Ropsten', - Kovan = 'Kovan', - Rinkeby = 'Rinkeby', - Goerli = 'Goerli' -} - -export interface Details { - id: number - genesisHash: string - web3Url: string - name: Names - displayName: string -} - -export function isName(val: string): val is Names { - return Object.values(Names).includes(val as Names); -} - -export function detailsByName(): { [key: string]: Details } { - return { - [Names.Eximchain]: Eximchain(), - [Names.EximGamma]: EximGamma(), - [Names.Ethereum]: Ethereum(), - [Names.Goerli]: Goerli(), - [Names.Kovan]: Kovan(), - [Names.Rinkeby]: Rinkeby(), - [Names.Ropsten]: Ropsten() - } -} - -export function allDetails(): Details[] { - return Object.values(detailsByName()); -} - -export function detailsFromName(name: string): Details | null { - let details = detailsByName()[name]; - return details ? details : null; -} - -export function detailsFromUrl(url:string): Details | null { - let detail = allDetails().find(each => each.web3Url === url); - return detail ? detail : null; -} - -export function detailsById(): { [key: number] : Details[] } { - return allDetails().reduce((result, chain) => { - if (result[chain.id]) { - result[chain.id].push(chain); - } else { - result[chain.id] = [chain]; - } - return result; - }, {} as { [key:number] : Details[] }) -} - -export function Eximchain(): Details { - return { - id: 1, - genesisHash: '0x722138a9f3635c65747a8e2eeac7e7963846fb952b8931da257395fd7656c3dd', - web3Url: "https://tx-executor-stress-test.eximchain.com", - name: Names.Eximchain, - displayName: 'Eximchain (Main Net)' - } -} - -export function EximGamma(): Details { - return { - id: 1, - genesisHash: '0x6a2d1d7602dbebc139cf9598607bf012d30da83954aab5f731d7550feb283bdc', - web3Url: 'https://gamma-tx-executor-us-east.eximchain-dev.com', - name: Names.EximGamma, - displayName: 'Eximchain (Test Net)' - } -} - -export function Ethereum(): Details { - return { - id: 1, - genesisHash: '0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3', - web3Url: "https://mainnet.infura.io/v3/45c2433b314e4ad09674978a2b9cce43", - name: Names.Ethereum, - displayName: 'Ethereum (Main Net)' - } -} - -export function Ropsten(): Details { - return { - id: 3, - genesisHash: '0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d', - web3Url: "https://ropsten.infura.io/v3/f084d60882a94d76bfb3b587af30e8e6", - name: Names.Ropsten, - displayName: 'Ethereum (Ropsten)' - } -} - -export function Kovan(): Details { - return { - id: 42, - genesisHash: '0xa3c565fc15c7478862d50ccd6561e3c06b24cc509bf388941c25ea985ce32cb9', - web3Url: "https://kovan.infura.io/v3/c58eda7787d342c7b41f8a3f38893def", - name: Names.Kovan, - displayName: 'Ethereum (Kovan)' - } -} - -export function Rinkeby(): Details { - return { - id: 4, - genesisHash: '0x6341fd3daf94b748c72ced5a5b26028f2474f5f00d824504e4fa37a75767e177', - name: Names.Rinkeby, - web3Url: "https://rinkeby.infura.io/v3/70a3fea548984fffbe86de56093b8044", - displayName: 'Ethereum (Rinkeby)' - } -} - -export function Goerli(): Details { - return { - id: 5, - genesisHash: '0xbf7e331f7f7c1dd2e05159666b3bf8bc7a8a3a9eb1d518969eab529dd9b88c1a', - name: Names.Goerli, - web3Url: 'https://goerli.infura.io/v3/55454709df7f4e54a660ceb5ad5a844c', - displayName: 'Ethereum (Görli)' - } -} \ No newline at end of file diff --git a/spec/dapp/dapp.ts b/spec/dapp/dapp.ts index dcb1a8a..1589b7f 100644 --- a/spec/dapp/dapp.ts +++ b/spec/dapp/dapp.ts @@ -1,5 +1,5 @@ import { keysAreStrings, isString, isObject } from '@eximchain/api-types/spec/validators'; -import * as Chains from './chains'; +import * as Chains from '@eximchain/api-types/spec/chains'; // This line makes Chain part of the Dapp // namespace, supporting calls like: diff --git a/spec/dapp/index.ts b/spec/dapp/index.ts index 4cdb271..b7dfb30 100644 --- a/spec/dapp/index.ts +++ b/spec/dapp/index.ts @@ -4,7 +4,7 @@ // then a consumer would have to do it in order // to get a convenient namespace. import * as Dapp from './dapp'; -import * as ChainTypes from './chains'; +import * as ChainTypes from '@eximchain/api-types/spec/chains'; // This line directly surfaces all of its non-default // exports from right here, so that users can just