1 | const lodash = require('lodash');
|
2 | const ContractMethod = require('./ContractMethod');
|
3 |
|
4 | class ContractConstructor extends ContractMethod {
|
5 | constructor(fragment, bytecode, contract, conflux) {
|
6 | super(lodash.defaults(fragment, { name: 'constructor', inputs: [] }), contract, conflux);
|
7 |
|
8 | this.bytecode = bytecode;
|
9 | this.decodeOutputs = hex => hex;
|
10 | }
|
11 |
|
12 | get signature() {
|
13 | return this.bytecode;
|
14 | }
|
15 |
|
16 | set signature(hex) {
|
17 | this.bytecode = hex;
|
18 | }
|
19 |
|
20 | call(...args) {
|
21 | if (!this.bytecode) {
|
22 | throw new Error('bytecode is empty');
|
23 | }
|
24 |
|
25 | const called = super.call(...args);
|
26 | called.to = null;
|
27 | return called;
|
28 | }
|
29 | }
|
30 |
|
31 | module.exports = ContractConstructor;
|