Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Commit

Permalink
Merge pull request #452 from jimni1222/setWallet
Browse files Browse the repository at this point in the history
Call redefined constructor to set wallet to instance
  • Loading branch information
jimni1222 authored Apr 13, 2021
2 parents e0386b6 + 89c4191 commit a47c626
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
4 changes: 4 additions & 0 deletions test/createTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,27 @@ describe('caver.contract', () => {
]
const created = caver.contract.create(abi)
expect(created.constructor.name).to.equal('Contract')
expect(created._wallet).not.to.be.undefined
})
})

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
})
})

Expand Down

0 comments on commit a47c626

Please sign in to comment.