@xchainjs/xchain-doge 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -13,7 +13,7 @@ yarn add @xchainjs/xchain-doge
13
13
  Following peer dependencies have to be installed into your project. These are not included in `@xchainjs/xchain-doge`.
14
14
 
15
15
  ```
16
- yarn add @xchainjs/xchain-client @xchainjs/xchain-crypto @xchainjs/xchain-util axios bitcoinjs-lib coininfo wif
16
+ yarn add @xchainjs/xchain-client @xchainjs/xchain-crypto @xchainjs/xchain-util axios bitcoinjs-lib wif
17
17
  ```
18
18
 
19
19
  ## Documentation
package/lib/index.esm.js CHANGED
@@ -1,11 +1,13 @@
1
+ import * as ecc from '@bitcoin-js/tiny-secp256k1-asmjs';
1
2
  import { ExplorerProvider, Network, FeeOption, checkFeeBounds } from '@xchainjs/xchain-client';
2
3
  import { getSeed } from '@xchainjs/xchain-crypto';
3
4
  import * as Dogecoin from 'bitcoinjs-lib';
4
- import { Client as Client$1 } from '@xchainjs/xchain-utxo';
5
+ import { ECPairFactory } from 'ecpair';
6
+ import { HDKey } from '@scure/bip32';
7
+ import { toBitcoinJS, Client as Client$1 } from '@xchainjs/xchain-utxo';
5
8
  import accumulative from 'coinselect/accumulative';
6
9
  import { AssetType } from '@xchainjs/xchain-util';
7
10
  import { SochainProvider, SochainNetwork, BlockcypherProvider, BlockcypherNetwork, BitgoProvider } from '@xchainjs/xchain-utxo-providers';
8
- import coininfo from 'coininfo';
9
11
  import AppBtc from '@ledgerhq/hw-app-btc';
10
12
 
11
13
  /******************************************************************************
@@ -145,18 +147,11 @@ function inputBytes() {
145
147
  const dogeNetwork = (network) => {
146
148
  switch (network) {
147
149
  case Network.Mainnet:
148
- return coininfo.dogecoin.main.toBitcoinJS();
150
+ return toBitcoinJS('dogecoin', 'main');
149
151
  case Network.Stagenet:
150
- return coininfo.dogecoin.main.toBitcoinJS();
152
+ return toBitcoinJS('dogecoin', 'main');
151
153
  case Network.Testnet: {
152
- // Latest coininfo on NPM doesn't contain dogetest config information
153
- const bip32 = {
154
- private: 0x04358394,
155
- public: 0x043587cf,
156
- };
157
- const test = coininfo.dogecoin.test;
158
- test.versions.bip32 = bip32;
159
- return test.toBitcoinJS();
154
+ return toBitcoinJS('dogecoin', 'test');
160
155
  }
161
156
  }
162
157
  };
@@ -405,6 +400,7 @@ class Client extends Client$1 {
405
400
  }
406
401
  }
407
402
 
403
+ const ECPair = ECPairFactory(ecc);
408
404
  /**
409
405
  * Custom Doge client extended to support keystore functionality
410
406
  */
@@ -453,11 +449,11 @@ class ClientKeystore extends Client {
453
449
  getDogeKeys(phrase, index = 0) {
454
450
  const dogeNetwork$1 = dogeNetwork(this.network);
455
451
  const seed = getSeed(phrase);
456
- const master = Dogecoin.bip32.fromSeed(seed, dogeNetwork$1).derivePath(this.getFullDerivationPath(index));
452
+ const master = HDKey.fromMasterSeed(Uint8Array.from(seed), dogeNetwork$1.bip32).derive(this.getFullDerivationPath(index));
457
453
  if (!master.privateKey) {
458
454
  throw new Error('Could not get private key from phrase');
459
455
  }
460
- return Dogecoin.ECPair.fromPrivateKey(master.privateKey, { network: dogeNetwork$1 });
456
+ return ECPair.fromPrivateKey(Buffer.from(master.privateKey), { network: dogeNetwork$1 });
461
457
  }
462
458
  /**
463
459
  * Get the current address.
package/lib/index.js CHANGED
@@ -1,13 +1,15 @@
1
1
  'use strict';
2
2
 
3
+ var ecc = require('@bitcoin-js/tiny-secp256k1-asmjs');
3
4
  var xchainClient = require('@xchainjs/xchain-client');
4
5
  var xchainCrypto = require('@xchainjs/xchain-crypto');
5
6
  var Dogecoin = require('bitcoinjs-lib');
7
+ var ecpair = require('ecpair');
8
+ var bip32 = require('@scure/bip32');
6
9
  var xchainUtxo = require('@xchainjs/xchain-utxo');
7
10
  var accumulative = require('coinselect/accumulative');
8
11
  var xchainUtil = require('@xchainjs/xchain-util');
9
12
  var xchainUtxoProviders = require('@xchainjs/xchain-utxo-providers');
10
- var coininfo = require('coininfo');
11
13
  var AppBtc = require('@ledgerhq/hw-app-btc');
12
14
 
13
15
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -30,9 +32,9 @@ function _interopNamespace(e) {
30
32
  return Object.freeze(n);
31
33
  }
32
34
 
35
+ var ecc__namespace = /*#__PURE__*/_interopNamespace(ecc);
33
36
  var Dogecoin__namespace = /*#__PURE__*/_interopNamespace(Dogecoin);
34
37
  var accumulative__default = /*#__PURE__*/_interopDefault(accumulative);
35
- var coininfo__default = /*#__PURE__*/_interopDefault(coininfo);
36
38
  var AppBtc__default = /*#__PURE__*/_interopDefault(AppBtc);
37
39
 
38
40
  /******************************************************************************
@@ -172,18 +174,11 @@ function inputBytes() {
172
174
  const dogeNetwork = (network) => {
173
175
  switch (network) {
174
176
  case xchainClient.Network.Mainnet:
175
- return coininfo__default.default.dogecoin.main.toBitcoinJS();
177
+ return xchainUtxo.toBitcoinJS('dogecoin', 'main');
176
178
  case xchainClient.Network.Stagenet:
177
- return coininfo__default.default.dogecoin.main.toBitcoinJS();
179
+ return xchainUtxo.toBitcoinJS('dogecoin', 'main');
178
180
  case xchainClient.Network.Testnet: {
179
- // Latest coininfo on NPM doesn't contain dogetest config information
180
- const bip32 = {
181
- private: 0x04358394,
182
- public: 0x043587cf,
183
- };
184
- const test = coininfo__default.default.dogecoin.test;
185
- test.versions.bip32 = bip32;
186
- return test.toBitcoinJS();
181
+ return xchainUtxo.toBitcoinJS('dogecoin', 'test');
187
182
  }
188
183
  }
189
184
  };
@@ -432,6 +427,7 @@ class Client extends xchainUtxo.Client {
432
427
  }
433
428
  }
434
429
 
430
+ const ECPair = ecpair.ECPairFactory(ecc__namespace);
435
431
  /**
436
432
  * Custom Doge client extended to support keystore functionality
437
433
  */
@@ -480,11 +476,11 @@ class ClientKeystore extends Client {
480
476
  getDogeKeys(phrase, index = 0) {
481
477
  const dogeNetwork$1 = dogeNetwork(this.network);
482
478
  const seed = xchainCrypto.getSeed(phrase);
483
- const master = Dogecoin__namespace.bip32.fromSeed(seed, dogeNetwork$1).derivePath(this.getFullDerivationPath(index));
479
+ const master = bip32.HDKey.fromMasterSeed(Uint8Array.from(seed), dogeNetwork$1.bip32).derive(this.getFullDerivationPath(index));
484
480
  if (!master.privateKey) {
485
481
  throw new Error('Could not get private key from phrase');
486
482
  }
487
- return Dogecoin__namespace.ECPair.fromPrivateKey(master.privateKey, { network: dogeNetwork$1 });
483
+ return ECPair.fromPrivateKey(Buffer.from(master.privateKey), { network: dogeNetwork$1 });
488
484
  }
489
485
  /**
490
486
  * Get the current address.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xchainjs/xchain-doge",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "Custom Doge client and utilities used by XChain clients",
5
5
  "keywords": [
6
6
  "Xchain",
@@ -33,20 +33,23 @@
33
33
  "postversion": "git push --follow-tags"
34
34
  },
35
35
  "dependencies": {
36
- "@ledgerhq/hw-app-btc": "10.1.0",
37
- "@xchainjs/xchain-client": "2.0.0",
38
- "@xchainjs/xchain-crypto": "1.0.0",
39
- "@xchainjs/xchain-util": "2.0.0",
40
- "@xchainjs/xchain-utxo": "2.0.0",
41
- "@xchainjs/xchain-utxo-providers": "2.0.0",
42
- "bitcoinjs-lib": "5.2.0",
43
- "coininfo": "5.1.0",
44
- "coinselect": "3.1.12"
36
+ "@bitcoin-js/tiny-secp256k1-asmjs": "^2.2.3",
37
+ "@ledgerhq/hw-app-btc": "10.9.0",
38
+ "@scure/bip32": "^1.7.0",
39
+ "@xchainjs/xchain-client": "2.0.2",
40
+ "@xchainjs/xchain-crypto": "1.0.1",
41
+ "@xchainjs/xchain-util": "2.0.1",
42
+ "@xchainjs/xchain-utxo": "2.0.2",
43
+ "@xchainjs/xchain-utxo-providers": "2.0.2",
44
+ "bitcoinjs-lib": "^6.1.7",
45
+ "coinselect": "3.1.12",
46
+ "ecpair": "2.1.0"
45
47
  },
46
48
  "devDependencies": {
47
49
  "@ledgerhq/hw-transport-node-hid": "6.28.6",
50
+ "@types/bitcoinjs-lib": "^5.0.4",
48
51
  "axios": "1.8.4",
49
- "axios-mock-adapter": "1.20.0"
52
+ "axios-mock-adapter": "2.1.0"
50
53
  },
51
54
  "publishConfig": {
52
55
  "access": "public",