-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontext.ts
84 lines (74 loc) · 3.64 KB
/
context.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import fs = require("fs");
import Web3 = require("web3");
export class Context {
public blockNumber: number;
public blockTimestamp: number;
public lrcAddress: string;
public feePercentageBase: number;
public ringIndex: number;
public ERC20Contract: any;
public TradeDelegateContract: any;
public TradeHistoryContract: any;
public BrokerRegistryContract: any;
public OrderRegistryContract: any;
public BrokerInterceptorContract: any;
public FeeHolderContract: any;
public OrderBookContract: any;
public BurnRateTableContract: any;
public tradeDelegate: any;
public tradeHistory: any;
public orderBrokerRegistry: any;
public minerBrokerRegistry: any;
public orderRegistry: any;
public minerRegistry: any;
public feeHolder: any;
public orderBook: any;
public burnRateTable: any;
constructor(blockNumber: number,
blockTimestamp: number,
tradeDelegateAddress: string,
tradeHistoryAddress: string,
orderBrokerRegistryAddress: string,
orderRegistryAddress: string,
feeHolderAddress: string,
orderBookAddress: string,
burnRateTableAddress: string,
lrcAddress: string,
feePercentageBase: number,
ringIndex: number) {
this.blockNumber = blockNumber;
this.blockTimestamp = blockTimestamp;
this.lrcAddress = lrcAddress;
this.feePercentageBase = feePercentageBase;
this.ringIndex = ringIndex;
const ABIPath = "ABI/latest/";
const erc20Abi = fs.readFileSync(ABIPath + "ERC20.abi", "ascii");
const tradeDelegateAbi = fs.readFileSync(ABIPath + "ITradeDelegate.abi", "ascii");
const tradeHistoryAbi = fs.readFileSync(ABIPath + "ITradeHistory.abi", "ascii");
const brokerRegistryAbi = fs.readFileSync(ABIPath + "IBrokerRegistry.abi", "ascii");
const orderRegistryAbi = fs.readFileSync(ABIPath + "IOrderRegistry.abi", "ascii");
const brokerInterceptorAbi = fs.readFileSync(ABIPath + "IBrokerInterceptor.abi", "ascii");
const feeHolderAbi = fs.readFileSync(ABIPath + "IFeeHolder.abi", "ascii");
const orderBookAbi = fs.readFileSync(ABIPath + "IOrderBook.abi", "ascii");
const burnRateTableAbi = fs.readFileSync(ABIPath + "IBurnRateTable.abi", "ascii");
if (!web3) {
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
}
this.ERC20Contract = new web3.eth.Contract(JSON.parse(erc20Abi));
this.TradeDelegateContract = new web3.eth.Contract(JSON.parse(tradeDelegateAbi), tradeDelegateAddress);
this.TradeHistoryContract = new web3.eth.Contract(JSON.parse(tradeHistoryAbi), tradeHistoryAddress);
this.BrokerRegistryContract = new web3.eth.Contract(JSON.parse(brokerRegistryAbi), orderBrokerRegistryAddress);
this.OrderRegistryContract = new web3.eth.Contract(JSON.parse(orderRegistryAbi), orderRegistryAddress);
this.FeeHolderContract = new web3.eth.Contract(JSON.parse(feeHolderAbi), feeHolderAddress);
this.OrderBookContract = new web3.eth.Contract(JSON.parse(orderBookAbi), orderBookAddress);
this.BrokerInterceptorContract = new web3.eth.Contract(JSON.parse(brokerInterceptorAbi));
this.BurnRateTableContract = new web3.eth.Contract(JSON.parse(burnRateTableAbi), burnRateTableAddress);
this.tradeDelegate = this.TradeDelegateContract.clone();
this.tradeHistory = this.TradeHistoryContract.clone();
this.orderBrokerRegistry = this.BrokerRegistryContract.clone();
this.orderRegistry = this.OrderRegistryContract.clone();
this.feeHolder = this.FeeHolderContract.clone();
this.orderBook = this.OrderBookContract.clone();
this.burnRateTable = this.BurnRateTableContract.clone();
}
}