From 89c4191e5511e8cb700617e380d3f4593aee615f Mon Sep 17 00:00:00 2001 From: Jasmine/kimjimin Date: Tue, 13 Apr 2021 14:10:32 +0900 Subject: [PATCH] Call redefined constructor to set wallet to instance --- index.js | 4 +++- test/createTest.js | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 3ffd5879..27786f7a 100644 --- a/index.js +++ b/index.js @@ -109,7 +109,9 @@ function Caver(provider, net) { } Contract.create = function() { - return BaseContract.create.apply(this, arguments) + // With `caver.contract`, `caver.wallet` must be set in the `contarct._wallet`, + // so the Contract constructor defined above must be called here. + return new Contract(...arguments) } Contract.setProvider = function() { diff --git a/test/createTest.js b/test/createTest.js index 23eba184..3a87d3b3 100644 --- a/test/createTest.js +++ b/test/createTest.js @@ -51,6 +51,7 @@ describe('caver.contract', () => { ] const created = caver.contract.create(abi) expect(created.constructor.name).to.equal('Contract') + expect(created._wallet).not.to.be.undefined }) }) @@ -58,16 +59,19 @@ describe('caver.kct', () => { it('CAVERJS-UNIT-KCT-219: caver.kct.kip7.create method creates a KIP7 instance.', () => { const created = caver.kct.kip7.create() expect(created.constructor.name).to.equal('KIP7') + expect(created._wallet).not.to.be.undefined }) it('CAVERJS-UNIT-KCT-220: caver.kct.kip17.create method creates a KIP17 instance.', () => { const created = caver.kct.kip17.create() expect(created.constructor.name).to.equal('KIP17') + expect(created._wallet).not.to.be.undefined }) it('CAVERJS-UNIT-KCT-221: caver.kct.kip37.create method creates a KIP37 instance.', () => { const created = caver.kct.kip37.create() expect(created.constructor.name).to.equal('KIP37') + expect(created._wallet).not.to.be.undefined }) })