klaytn / caver-js

Official caver-js repository
GNU Lesser General Public License v3.0
114 stars 75 forks source link

Property 'keyring' does not exist on type 'IWallet'. #582

Closed narendracode closed 2 years ago

narendracode commented 2 years ago

Environment

import Caver from 'caver-js';
const caver = new Caver('...');
const keyring = caver.wallet.keyring.generate()

typescript build error : "Property 'keyring' does not exist on type 'IWallet'."

I find some of the implementation methods are missing in IWallet interface as mentioned in doc here(mentioned here in doc

https://github.com/klaytn/caver-js/blob/master/index.js

function Caver(..) {
    ...
    this.wallet = new KeyringContainer()
}

https://github.com/klaytn/caver-js/blob/master/types/index.d.ts

export default class Caver {
    ...
    wallet: IWallet
    ...
}

Solutions : 1.Either IWallet should have all those methods

export class IWallet {
    generate(num: number): string[]
    sign(address: string, transaction: Transaction): Promise<Transaction>
    signAsFeePayer(address: string, transaction: FeeDelegatedTransaction): Promise<FeeDelegatedTransaction>
    isExisted(address: string): boolean
    remove(address: string): boolean
    ... // methods to be added here
}

or 2. wallet type requires to be updated as KeyringContainer in Caver class. https://github.com/klaytn/caver-js/blob/master/types/index.d.ts

Looking forward to your update on this issue and I can create PR accordingly.

jimni1222 commented 2 years ago

Hi, Please use latest rc version. I fixed type in there. Please reopen if there is still an issue.