@lombard.finance/sdk 2.2.0 → 2.4.0

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.
Files changed (51) hide show
  1. package/README.md +38 -37
  2. package/dist/index.cjs +1 -1
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.js +2994 -721
  5. package/dist/index.js.map +1 -1
  6. package/package.json +7 -7
  7. package/src/common/const.ts +0 -4
  8. package/src/common/types/internalTypes.ts +2 -2
  9. package/src/common/types/types.ts +20 -15
  10. package/src/common/utils/convertSatoshi.ts +11 -7
  11. package/src/index.ts +2 -0
  12. package/src/sdk/apiConfig.ts +9 -5
  13. package/src/sdk/generateDepositBtcAddress/generateDepositBtcAddress.stories.tsx +1 -1
  14. package/src/sdk/generateDepositBtcAddress/generateDepositBtcAddress.ts +3 -3
  15. package/src/sdk/getDepositBtcAddress/getDepositBtcAddress.stories.tsx +1 -3
  16. package/src/sdk/getDepositBtcAddress/getDepositBtcAddress.ts +4 -4
  17. package/src/sdk/getDepositsByAddress/getDepositsByAddress.stories.tsx +1 -1
  18. package/src/sdk/getDepositsByAddress/getDepositsByAddress.ts +4 -3
  19. package/src/sdk/getLBTCExchangeRate/getLBTCExchangeRate.stories.tsx +3 -3
  20. package/src/sdk/getNetworkFeeSignature/getNetworkFeeSignature.stories.tsx +1 -1
  21. package/src/sdk/getPointsByAddress/getPointsByAddress.stories.tsx +49 -0
  22. package/src/sdk/getPointsByAddress/getPointsByAddress.ts +163 -0
  23. package/src/sdk/getPointsByAddress/index.ts +6 -0
  24. package/src/sdk/getUnstakesByAddress/getUnstakesByAddress.stories.tsx +49 -0
  25. package/src/sdk/getUnstakesByAddress/getUnstakesByAddress.ts +133 -0
  26. package/src/sdk/getUnstakesByAddress/index.ts +1 -0
  27. package/src/sdk/getUserStakeAndBakeSignature/getUserStakeAndBakeSignature.stories.tsx +1 -1
  28. package/src/sdk/index.ts +3 -1
  29. package/src/sdk/internalTypes.ts +3 -0
  30. package/src/sdk/setReferral/setReferral.ts +6 -5
  31. package/src/sdk/storeNetworkFeeSignature/storeNetworkFeeSignature.stories.tsx +1 -1
  32. package/src/sdk/storeStakeAndBakeSignature/storeStakeAndBakeSignature.stories.tsx +1 -1
  33. package/src/sdk/utils/getChainIdByName.ts +12 -6
  34. package/src/sdk/utils/getChainNameById.ts +25 -15
  35. package/src/web3Sdk/approveLBTC/approveLBTC.stories.tsx +1 -1
  36. package/src/web3Sdk/approveLBTC/approveLBTC.ts +1 -1
  37. package/src/web3Sdk/basculeAddressConfig.ts +7 -8
  38. package/src/web3Sdk/claimLBTC/claimLBTC.stories.tsx +1 -1
  39. package/src/web3Sdk/getBasculeDepositStatus/getBasculeDepositStatus.stories.tsx +5 -2
  40. package/src/web3Sdk/getLBTCTotalSupply/getLBTCTotalSupply.stories.tsx +1 -2
  41. package/src/web3Sdk/lbtcAddressConfig.ts +10 -9
  42. package/src/web3Sdk/signLbtcDestionationAddr/index.ts +1 -1
  43. package/src/web3Sdk/signLbtcDestionationAddr/{signLbtcDestionationAddr.ts → signLbtcDestinationAddr.ts} +4 -4
  44. package/src/web3Sdk/signLbtcDestionationAddr/signLbtcDestionationAddr.stories.tsx +3 -3
  45. package/src/web3Sdk/signNetworkFee/signNetworkFee.stories.tsx +1 -1
  46. package/src/web3Sdk/signStakeAndBake/utils.ts +4 -2
  47. package/src/web3Sdk/unstakeLBTC/unstakeLBTC.stories.tsx +1 -1
  48. package/src/web3Sdk/unstakeLBTC/unstakeLBTC.ts +2 -2
  49. package/src/web3Sdk/utils/chainIdToEnv.ts +4 -3
  50. package/src/web3Sdk/utils/getLbtcTokenContract.ts +5 -2
  51. package/src/btcSdk/utils/getOutputScript.ts +0 -67
@@ -1,67 +0,0 @@
1
- import * as ecc from '@bitcoin-js/tiny-secp256k1-asmjs';
2
- import {
3
- address as addressUtils,
4
- initEccLib,
5
- networks,
6
- payments,
7
- } from 'bitcoinjs-lib';
8
- import { OEnv, TEnv } from '../../common/types/types';
9
-
10
- initEccLib(ecc);
11
-
12
- type AddressType = 'p2tr' | 'p2wpkh' | 'p2wsh';
13
-
14
- /**
15
- * Get output script from address.
16
- *
17
- * @param address - The address.
18
- * @param networkMode - The network mode.
19
- *
20
- * @returns The output script.
21
- */
22
- export function getOutputScript(
23
- address: string,
24
- env: TEnv = OEnv.prod,
25
- ): string {
26
- const addressType = getAddressType(address);
27
-
28
- const payment = payments[addressType]({
29
- address,
30
- network: env === OEnv.prod ? networks.bitcoin : networks.testnet,
31
- });
32
-
33
- const paymentOutputScript = payment.output?.toString('hex');
34
-
35
- if (!paymentOutputScript) {
36
- throw new Error('Output script is not found.');
37
- }
38
-
39
- return `0x${paymentOutputScript}`;
40
- }
41
-
42
- function getAddressType(address: string): AddressType {
43
- const result = addressUtils.fromBech32(address);
44
-
45
- const isP2TR = result.version === 1 && result.data.length === 32;
46
- if (isP2TR) {
47
- return 'p2tr';
48
- }
49
-
50
- const isP2WPKH = result.version === 0 && result.data.length === 20;
51
- if (isP2WPKH) {
52
- return 'p2wpkh';
53
- }
54
-
55
- if (isP2WSHAddressType(address)) {
56
- return 'p2wsh';
57
- }
58
-
59
- throw new Error('Address type is not supported.');
60
- }
61
-
62
- function isP2WSHAddressType(address: string): boolean {
63
- return (
64
- (address.startsWith('bc1') || address.startsWith('tb1')) &&
65
- address.length === 62
66
- );
67
- }