diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index bcef9e0694..521cbf0eed 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -26,7 +26,7 @@ /packages/jellyfish-transaction-builder/ @fuxingloh @ivan-zynesis @monstrobishi /packages/jellyfish-transaction-signature/ @fuxingloh @ivan-zynesis -/packages/jellyfish-wallet/ @fuxingloh @ivan-zynesis +/packages/jellyfish-wallet/ @fuxingloh @ivan-zynesis @monstrobishi /packages/jellyfish-wallet-mnemonic/ @fuxingloh @ivan-zynesis /packages/testcontainers/ @fuxingloh /packages/testing/ @fuxingloh @canonbrother diff --git a/.idea/jellyfish.iml b/.idea/jellyfish.iml index 6f3607dd53..0201ce7e00 100644 --- a/.idea/jellyfish.iml +++ b/.idea/jellyfish.iml @@ -7,8 +7,9 @@ + - \ No newline at end of file + diff --git a/packages/jellyfish-wallet/__tests__/account.mock.ts b/packages/jellyfish-wallet/__tests__/account.mock.ts index 01c70bb8c0..4f9a1b6cd6 100644 --- a/packages/jellyfish-wallet/__tests__/account.mock.ts +++ b/packages/jellyfish-wallet/__tests__/account.mock.ts @@ -1,4 +1,4 @@ -import { WalletAccount, WalletAccountProvider, WalletHdNode } from '../src' +import { WalletAccount, WalletAccountProvider, WalletEllipticPair } from '../src' import { Network, RegTest } from '@defichain/jellyfish-network' /** @@ -13,7 +13,7 @@ import { Network, RegTest } from '@defichain/jellyfish-network' * 02acf1d65943ce391c5c7a6319050c71ece26f5815f1a69445edd35b8d8dac13be */ export class TestAccount extends WalletAccount { - constructor (hdNode: WalletHdNode, readonly provider: TestAccountProvider) { + constructor (hdNode: WalletEllipticPair, readonly provider: TestAccountProvider) { super(hdNode, provider.network) } @@ -29,7 +29,7 @@ export class TestAccountProvider implements WalletAccountProvider { constructor (public readonly addresses: string[]) { } - provide (hdNode: WalletHdNode): TestAccount { + provide (hdNode: WalletEllipticPair): TestAccount { return new TestAccount(hdNode, this) } } diff --git a/packages/jellyfish-wallet/__tests__/node.mock.ts b/packages/jellyfish-wallet/__tests__/node.mock.ts index 07b9ac1914..c0cc53d1bc 100644 --- a/packages/jellyfish-wallet/__tests__/node.mock.ts +++ b/packages/jellyfish-wallet/__tests__/node.mock.ts @@ -1,11 +1,7 @@ import { WalletHdNode, WalletHdNodeProvider } from '../src' -import { - Transaction, - TransactionSegWit, - Vout -} from '@defichain/jellyfish-transaction' +import { Transaction, TransactionSegWit, Vout } from '@defichain/jellyfish-transaction' import { SignInputOption, TransactionSigner } from '@defichain/jellyfish-transaction-signature' -import { EllipticPair, Elliptic } from '@defichain/jellyfish-crypto' +import { Elliptic, EllipticPair } from '@defichain/jellyfish-crypto' /** * This is for testing only, please don't use this for anything else. diff --git a/packages/jellyfish-wallet/src/index.ts b/packages/jellyfish-wallet/src/index.ts index f004b3aa27..e88356367e 100644 --- a/packages/jellyfish-wallet/src/index.ts +++ b/packages/jellyfish-wallet/src/index.ts @@ -1,3 +1,4 @@ export * from './wallet' export * from './wallet_account' export * from './wallet_hd_node' +export * from './wallet_elliptic_pair' diff --git a/packages/jellyfish-wallet/src/wallet_account.ts b/packages/jellyfish-wallet/src/wallet_account.ts index 5d872c1c95..c8da66d014 100644 --- a/packages/jellyfish-wallet/src/wallet_account.ts +++ b/packages/jellyfish-wallet/src/wallet_account.ts @@ -1,5 +1,5 @@ -import { Script, OP_CODES, Transaction, Vout, TransactionSegWit } from '@defichain/jellyfish-transaction' -import { WalletHdNode } from './wallet_hd_node' +import { OP_CODES, Script, Transaction, TransactionSegWit, Vout } from '@defichain/jellyfish-transaction' +import { WalletEllipticPair } from './wallet_elliptic_pair' import { Bech32, HASH160 } from '@defichain/jellyfish-crypto' import { Network } from '@defichain/jellyfish-network' import { DeFiAddress } from '@defichain/jellyfish-address' @@ -11,9 +11,9 @@ import { DeFiAddress } from '@defichain/jellyfish-address' * * WalletAccount implementation uses NATIVE SEGWIT redeem script exclusively. */ -export abstract class WalletAccount implements WalletHdNode { +export abstract class WalletAccount implements WalletEllipticPair { protected constructor ( - private readonly hdNode: WalletHdNode, + private readonly walletEllipticPair: WalletEllipticPair, private readonly network: Network ) { } @@ -22,7 +22,7 @@ export abstract class WalletAccount implements WalletHdNode { * @return {Promise} Bech32 address of this account. (NATIVE SEGWIT) */ async getAddress (): Promise { - const pubKey = await this.hdNode.publicKey() + const pubKey = await this.walletEllipticPair.publicKey() return Bech32.fromPubKey(pubKey, this.network.bech32.hrp, 0x00) } @@ -30,7 +30,7 @@ export abstract class WalletAccount implements WalletHdNode { * @return {Promise