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

Add xDAI compatibility #212

Merged
merged 7 commits into from
Oct 8, 2020
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
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ NODE_URL=wss://mainnet.infura.io/ws/v3/<your-api-key>
# https://github.com/gnosis/dex-contracts/blob/master/networks.json
STABLE_COIN_CONTRACT_ADDRESS=0x6F400810b62df8E13fded51bE75fF5393eaa841F

# xDAO Gnosis Protocol
# https://github.com/gnosis/dex-contracts/blob/master/networks.json
STABLE_COIN_CONTRACT_ADDRESS=0x25B06305CC4ec6AfCF3E7c0b673da1EF8ae26313

# Rinkeby Gnosis Protocol
# https://github.com/gnosis/dex-contracts/blob/master/networks.json
#STABLE_COIN_CONTRACT_ADDRESS=0xC576eA7bd102F7E476368a5E98FA455d1Ea34dE2
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@
"typescript": "^3.7.2",
"typescript-transform-paths": "^1.1.13"
}
}
}
2 changes: 0 additions & 2 deletions src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ const WEB_BASE_URL = process.env.WEB_BASE_URL
assert(WEB_BASE_URL, 'WEB_BASE_URL is required')
const port = parseInt(process.env.API_PORT || '3000')

assert(process.env.TCR_CONTRACT_ADDRESS, 'TCR_CONTRACT_ADDRESS env var is required')

moment.tz.setDefault('Etc/GMT')

logUnhandledErrors()
Expand Down
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ export const TOKEN_OVERRIDES = {
forceAddressDisplay: true, // name and symbol are ignored when `forceAddressDisplay` is set
},
},
100: {},
}
2 changes: 1 addition & 1 deletion src/helpers/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import { TCR_CONTRACT_ADDRESS } from 'config'

export const batchExchangeContract = createBatchExchangeContract(web3)
export const erc20Contract = createErc20Contract(web3)
export const tcrContract = createTcrContract(web3, TCR_CONTRACT_ADDRESS)
export const tcrContract = TCR_CONTRACT_ADDRESS ? createTcrContract(web3, TCR_CONTRACT_ADDRESS) : undefined
11 changes: 6 additions & 5 deletions src/services/DfusionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const log = new Logger('service:dfusion')
export interface Params {
batchExchangeContract: BatchExchangeContract
erc20Contract: Erc20Contract
tcrContract: TcrContract
tcrContract?: TcrContract
tokenIdsFilter?: string[]
web3: Web3
}
Expand Down Expand Up @@ -96,7 +96,7 @@ export interface AboutDto {
contractsVersion: string
dexJsVersion: string
batchExchangeAddress: string
tcrContractAddress: string
tcrContractAddress?: string
tcrListId: number
}

Expand All @@ -120,7 +120,7 @@ export class DfusionRepoImpl implements DfusionService {
private _erc20Contract: Erc20Contract
private _tokenIdsFilter?: string[]

private _tcrContract: TcrContract
private _tcrContract?: TcrContract
private _networkId: number
private _batchTime: BigNumber
private _cache: NodeCache
Expand Down Expand Up @@ -208,6 +208,7 @@ export class DfusionRepoImpl implements DfusionService {
public watchOrderPlacement(params: WatchOrderPlacementParams) {
const OrderPlacement = this._contract.events.OrderPlacement
const subscriptions: Map<string, ContractEventEmitter<OrderPlacement>> = new Map()

if (this._tokenIdsFilter) {
const tokenListDescription = this._tokenIdsFilter.join(', ')
subscriptions.set(
Expand Down Expand Up @@ -315,7 +316,7 @@ export class DfusionRepoImpl implements DfusionService {
dexJsVersion,
version: packageJson.version,
batchExchangeAddress: this._contract.options.address,
tcrContractAddress: this._tcrContract.options.address,
tcrContractAddress: this._tcrContract?.options.address,
tcrListId: TCR_LIST_ID,
}
}
Expand Down Expand Up @@ -403,7 +404,7 @@ export class DfusionRepoImpl implements DfusionService {
return cachedAddresses
}

const tcrList = await this._tcrContract.methods
const tcrList = await this._tcrContract?.methods
.getTokens(TCR_LIST_ID)
.call()
.catch(() => [])
Expand Down
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,9 @@
"@ethersproject/signing-key" "^5.0.0"

"@gnosis.pm/dex-contracts@^0.2.0":
version "0.2.0"
resolved "https://registry.yarnpkg.com/@gnosis.pm/dex-contracts/-/dex-contracts-0.2.0.tgz#1649e2efdb818158db79569e9375d6bf9405c63f"
integrity sha512-9zMT7XaveDJ5L52o0RNRcFL0Vf2nOpX1lGsWimIZCZBnCL1HyvKHvX4W4mfcItkScNVNgvJ9EWSNVXQjS+pK5g==
version "0.2.15"
resolved "https://registry.yarnpkg.com/@gnosis.pm/dex-contracts/-/dex-contracts-0.2.15.tgz#254314c6f8dff33a022a3d2b67035b08f0782c94"
integrity sha512-rvGuiHfl12F70qBiJimUv/uGdn5+Dfao2xAbhiQh9/wJBt5A5nVYONnZ13JFfIoOrSJTRT1n61SEhLfLOlG6dw==
dependencies:
bn.js "^5.1.1"

Expand Down Expand Up @@ -1298,9 +1298,9 @@ bn.js@^4.11.9:
integrity sha512-E6QoYqCKZfgatHTdHzs1RRKP7ip4vvm+EyRUeE2RF0NblwVvb0p6jSVeNTOFxPn26QXN2o6SMfNxKp6kU8zQaw==

bn.js@^5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.1.1.tgz#48efc4031a9c4041b9c99c6941d903463ab62eb5"
integrity sha512-IUTD/REb78Z2eodka1QZyyEk66pciRcP6Sroka0aI3tG/iwIdYLrBD62RsubR7vqdt3WyX8p4jxeatzmRSphtA==
version "5.1.3"
resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.1.3.tgz#beca005408f642ebebea80b042b4d18d2ac0ee6b"
integrity sha512-GkTiFpjFtUzU9CbMeJ5iazkCzGL3jrhzerzZIuqLABjbwRaFt33I9tUdSNryIptM+RxDet6OKm2WnLXzW51KsQ==

body-parser@1.19.0, body-parser@^1.16.0:
version "1.19.0"
Expand Down