Skip to content

Commit

Permalink
Remove bip39 devDependency in favour of libauth
Browse files Browse the repository at this point in the history
  • Loading branch information
rkalis committed Oct 29, 2024
1 parent fd68987 commit e9e1bab
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 11 deletions.
4 changes: 2 additions & 2 deletions examples/common-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import {
deriveHdPath,
secp256k1,
encodeCashAddress,
deriveSeedFromBip39Mnemonic,
} from '@bitauth/libauth';
import bip39 from 'bip39';

// This is duplicated from common.ts because it is not possible to import from a .ts file in p2pkh.js

// Generate entropy from BIP39 mnemonic phrase and initialise a root HD-wallet node
const seed = await bip39.mnemonicToSeed('CashScript Examples');
const seed = deriveSeedFromBip39Mnemonic('CashScript Examples');
const rootNode = deriveHdPrivateNodeFromSeed(seed, { assumeValidity: true, throwErrors: true });
const baseDerivationPath = "m/44'/145'/0'/0";

Expand Down
4 changes: 2 additions & 2 deletions examples/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import {
deriveHdPath,
secp256k1,
encodeCashAddress,
deriveSeedFromBip39Mnemonic,
} from '@bitauth/libauth';
import bip39 from 'bip39';
import { PriceOracle } from './PriceOracle.js';

// Generate entropy from BIP39 mnemonic phrase and initialise a root HD-wallet node
const seed = await bip39.mnemonicToSeed('CashScript Examples');
const seed = deriveSeedFromBip39Mnemonic('CashScript Examples');
const rootNode = deriveHdPrivateNodeFromSeed(seed, { assumeValidity: true, throwErrors: true });
const baseDerivationPath = "m/44'/145'/0'/0";

Expand Down
1 change: 0 additions & 1 deletion examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"dependencies": {
"@bitauth/libauth": "^3.0.0",
"@types/node": "^12.7.8",
"bip39": "^3.0.4",
"cashc": "^0.10.1",
"cashscript": "^0.10.1",
"eslint": "^8.56.0",
Expand Down
1 change: 0 additions & 1 deletion packages/cashscript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
"@jest/globals": "^29.4.1",
"@psf/bch-js": "^4.15.0",
"@types/pako": "^2.0.3",
"bip39": "^3.0.4",
"eslint": "^8.54.0",
"jest": "^29.4.1",
"typescript": "^5.5.4"
Expand Down
5 changes: 2 additions & 3 deletions packages/cashscript/test/fixture/vars.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import {
deriveHdPath,
deriveHdPrivateNodeFromSeed,
deriveSeedFromBip39Mnemonic,
encodeCashAddress,
secp256k1,
} from '@bitauth/libauth';
import { hash160 } from '@cashscript/utils';
import bip39 from 'bip39';
import { PriceOracle } from './PriceOracle.js';
import { Network } from '../../src/interfaces.js';

export const network = Network.CHIPNET;

const seed = await bip39.mnemonicToSeed('CashScript Tests');

const seed = deriveSeedFromBip39Mnemonic('CashScript Tests');
const rootNode = deriveHdPrivateNodeFromSeed(seed, { assumeValidity: true, throwErrors: true });
const baseDerivationPath = "m/44'/145'/0'/0";

Expand Down
4 changes: 2 additions & 2 deletions website/docs/sdk/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ import { hash160 } from '@cashscript/utils';
import {
deriveHdPrivateNodeFromSeed,
deriveHdPath,
deriveSeedFromBip39Mnemonic,
secp256k1,
encodeCashAddress,
} from '@bitauth/libauth';
import bip39 from 'bip39';
import { PriceOracle } from './PriceOracle.js';

// Generate entropy from BIP39 mnemonic phrase and initialise a root HD-wallet node
const seed = await bip39.mnemonicToSeed('CashScript Examples');
const seed = deriveSeedFromBip39Mnemonic('CashScript Examples');
const rootNode = deriveHdPrivateNodeFromSeed(seed, true);
const baseDerivationPath = "m/44'/145'/0'/0";

Expand Down

0 comments on commit e9e1bab

Please sign in to comment.