-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsecondary_registrar.js
59 lines (50 loc) · 1.57 KB
/
secondary_registrar.js
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
var contracts = require('./contract_interface')
function SecondaryRegistrar(web3Provider) {
this.secReg = contracts.makeSecReg(web3Provider)
this.listBuyNowName = function(name, priceInETH) {
var price = Number(priceInETH) * 100000000
return this.secReg.listName(
name,
price,
{from:web3.eth.accounts[0], gas:3000000}
)
}
this.getBuyNowListingCount = function() {
return this.secReg.getCount.call()
}
this.getAuctionListingCount = function() {
return this.secReg.getAuctionCount.call()
}
this.getAuctionListings = function(st, ed, callback) {
var output = []
var cnt = 0
for (var i = st; i < ed; i++) {
this.secReg.getAuctionRecord.call(i).then(function(result) {
output.push(result)
cnt = cnt + 1
if (cnt == (ed - st)) {
callback(output)
}
})
}
}
this.getBestBidder = function(name) {
return this.secReg.getBestBidder.call(name)
}
this.getListings = function(st, ed, callback) {
var output = []
var cnt = 0
for (var i = st; i < ed; i++) {
this.secReg.getRecord.call(i).then(function(result) {
output.push(result)
cnt = cnt + 1
if (cnt == (ed - st)) {
callback(output)
}
})
}
}
this.buy = this.secReg.buy
this.address = this.secReg.address
}
module.exports = SecondaryRegistrar