Skip to content

Commit

Permalink
feat: iWallet
Browse files Browse the repository at this point in the history
  • Loading branch information
AbigailDeng authored and AbigailDeng committed Oct 30, 2023
1 parent d30bc3f commit 3f0293c
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 15 deletions.
4 changes: 2 additions & 2 deletions types/chain/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Contract } from 'types/contract';
import { RequestManager } from 'types/util/requestManage';
import * as Bip39 from 'bip39';
import { IWallet } from '../wallet';
import { IWalletInfo } from '../wallet';
import { IExtractArgumentsIntoObjectResult, TExtractArg } from './chainMethod';
export interface IError {
Error: {
Expand Down Expand Up @@ -164,7 +164,7 @@ declare class Chain {
): IExtractArgumentsIntoObjectResult;
public contractAt(
address: string,
wallet: IWallet,
wallet: IWalletInfo,
args: { [k in string]: any }
): Contract | Promise<Contract>;
public getMerklePath(
Expand Down
4 changes: 2 additions & 2 deletions types/contract/contractMethod.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Chain from '../chain';
import { IWallet } from '../wallet';
import { IWalletInfo } from '../wallet';
import * as protobuf from '@aelfqueen/protobufjs';
import { ITransaction } from '../util/proto';
import { Contract } from '.';
Expand All @@ -24,7 +24,7 @@ declare class ContractMethod {
chain: Chain,
method: protobuf.Method,
contractAddress: string,
walletInstance: IWallet
walletInstance: IWalletInfo
);
public packInput(input?: any): Buffer | null;
public unpackPackedInput(
Expand Down
6 changes: 3 additions & 3 deletions types/contract/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Chain from '../chain';
import { IFileDescriptorSet } from '@aelfqueen/protobufjs/ext/descriptor';
import * as protobuf from '@aelfqueen/protobufjs/light';
import { IWallet } from '../wallet';
import { IWalletInfo } from '../wallet';
import { GenericFunction } from '../util/utils';
export class Contract {
constructor(chain: Chain, services: Array<protobuf.Service>, address: string);
Expand All @@ -15,11 +15,11 @@ declare class ContractFactory implements IContractFactory {
constructor(
chain: Chain,
fileDescriptorSet: IFileDescriptorSet,
wallet: IWallet
wallet: IWalletInfo
);
public static bindMethodsToContract(
contract: Contract,
wallet: IWallet
wallet: IWalletInfo
): void;

public at(address: string, callback: GenericFunction): Contract;
Expand Down
4 changes: 2 additions & 2 deletions types/util/keyStore.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IWallet } from '../wallet';
import { IWalletInfo } from '../wallet';

interface IOptions {
dklen: number;
Expand All @@ -14,7 +14,7 @@ interface IKdfparams {
p: number;
salt: string;
}
type TWalletInfo = IWallet & {
type TWalletInfo = IWalletInfo & {
nickName?: string;
};
interface ICipherparams {
Expand Down
27 changes: 21 additions & 6 deletions types/wallet/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ interface ISignature {
}
type TSignTransaction = ISignature & TRawTx;

export interface IWallet {
export interface IWalletInfo {
BIP44Path: string;
address: string;
childWallet: IWallet | string;
childWallet: IWalletInfo | string;
keyPair: ec.KeyPair;
mnemonic: string;
privateKey: string;
}

export declare class Wallet {
interface IWallet {
ellipticEc: ec;
hdkey: HDNode;
bip39: typeof Bip39;
Expand All @@ -28,9 +28,24 @@ export declare class Wallet {
AESDescrypt(input: string, password: string): string;
getSignature(bytesToBeSign: string, keyPair: ec.KeyPair): Buffer;
getAddressFromPubKey(pubKey: curve.base.BasePoint): string;
createNewWallet(BIP44Path?: string): IWallet;
getWalletByMnemonic(mnemonic: string, BIP44Path: string): IWallet;
getWalletByPrivateKey(privateKey: string): IWallet;
createNewWallet(BIP44Path?: string): IWalletInfo;
getWalletByMnemonic(mnemonic: string, BIP44Path: string): IWalletInfo;
getWalletByPrivateKey(privateKey: string): IWalletInfo;
signTransaction(rawTxn: ITransaction, keyPair: ec.KeyPair): TSignTransaction;
sign(hexString: string, keyPair: ec.KeyPair): Buffer;
}
export declare class Wallet implements IWallet{
ellipticEc: ec;
hdkey: HDNode;
bip39: typeof Bip39;
keyStore: typeof KeyStore;
AESEncrypt(input: string, password: string): string;
AESDescrypt(input: string, password: string): string;
getSignature(bytesToBeSign: string, keyPair: ec.KeyPair): Buffer;
getAddressFromPubKey(pubKey: curve.base.BasePoint): string;
createNewWallet(BIP44Path?: string): IWalletInfo;
getWalletByMnemonic(mnemonic: string, BIP44Path: string): IWalletInfo;
getWalletByPrivateKey(privateKey: string): IWalletInfo;
signTransaction(rawTxn: ITransaction, keyPair: ec.KeyPair): TSignTransaction;
sign(hexString: string, keyPair: ec.KeyPair): Buffer;
}
Expand Down

0 comments on commit 3f0293c

Please sign in to comment.