-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
44 lines (36 loc) · 1 KB
/
index.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
const contract = require('./build/contract.json')
const { abi } = require('eth-serde')
const { format, parse } = require('eth-helpers/utils')
module.exports = class VegaTokenProxy {
constructor (addr) {
this._addr = addr
}
balanceOf (addr, tx = {}) {
return this._tx(abi.encodeMethod('balanceOf', ['address'], [addr]), tx)
}
name (tx = {}) {
return this._tx(abi.encodeMethod('name', []), tx)
}
totalSupply (tx = {}) {
return this._tx(abi.encodeMethod('totalSupply', []), tx)
}
symbol (tx = {}) {
return this._tx(abi.encodeMethod('symbol', []), tx)
}
decimals (tx = {}) {
return this._tx(abi.encodeMethod('decimals', []), tx)
}
_tx (data, tx = {}) {
return Object.assign(tx, {
to: this._addr,
data: '0x' + data.toString('hex')
})
}
static create ({ erc20Address, vestingAddress }) {
return format.bytes(abi.encodeConstructor(
parse.bytes(contract.bytecode),
['address', 'address'],
[erc20Address, vestingAddress]
))
}
}