@lombard.finance/sdk 2.4.2 → 2.4.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lombard.finance/sdk",
3
- "version": "2.4.2",
3
+ "version": "2.4.4",
4
4
  "exports": {
5
5
  ".": {
6
6
  "import": "./dist/index.js",
@@ -2,14 +2,16 @@ import { OChainId } from '../common/types/types';
2
2
 
3
3
  export type TRpcUrlConfig = Record<number, string>;
4
4
 
5
+ export const RPC_URL = 'https://bff.prod.lombard.finance/multi-rpc/proxy';
6
+
5
7
  export const rpcUrlConfig: TRpcUrlConfig = {
6
- [OChainId.ethereum]: 'https://rpc.ankr.com/eth',
7
- [OChainId.holesky]: 'https://rpc.ankr.com/eth_holesky',
8
- [OChainId.sepolia]: 'https://rpc.ankr.com/eth_sepolia',
9
- [OChainId.base]: 'https://rpc.ankr.com/base',
10
- [OChainId.baseSepoliaTestnet]: 'https://rpc.ankr.com/base_sepolia',
8
+ [OChainId.ethereum]: `${RPC_URL}/eth`,
9
+ [OChainId.holesky]: `${RPC_URL}/eth_holesky`,
10
+ [OChainId.sepolia]: `${RPC_URL}/eth_sepolia`,
11
+ [OChainId.base]: `${RPC_URL}/base`,
12
+ [OChainId.baseSepoliaTestnet]: `${RPC_URL}/base_sepolia`,
11
13
  [OChainId.binanceSmartChain]: 'https://bsc-dataseed.bnbchain.org',
12
14
  [OChainId.binanceSmartChainTestnet]:
13
15
  'https://bsc-testnet-dataseed.bnbchain.org',
14
- [OChainId.corn]: 'https://rpc.ankr.com/corn_maizenet',
16
+ [OChainId.corn]: `${RPC_URL}/corn_maizenet`,
15
17
  };
@@ -1,9 +1,15 @@
1
+ import {
2
+ BasculeDepositStatus,
3
+ getBasculeDepositStatus,
4
+ } from '../getBasculeDepositStatus';
1
5
  import { IEnvParam } from '../../common/types/internalTypes';
2
6
  import { getErrorMessage } from '../../common/utils/getErrorMessage';
3
7
  import { IWeb3SendResult, Provider } from '../../provider';
4
8
  import { IProviderBasedParams } from '../types';
5
9
  import { getGasMultiplier } from '../utils/getGasMultiplier';
6
10
  import { getLbtcTokenContract } from '../utils/getLbtcTokenContract';
11
+ import { throwBasculeDepositStatusError } from '../getBasculeDepositStatus/utils/throwBasculeDepositStatusError';
12
+ import { BASCULE_SUPPORTED_CHAINS } from '../getBasculeDepositStatus/utils/const';
7
13
 
8
14
  const INSUFFICIENT_FUNDS_PARTIAL_ERROR = 'insufficient funds';
9
15
 
@@ -38,6 +44,18 @@ export async function claimLBTC({
38
44
  }: IClaimLBTCParams): Promise<IWeb3SendResult> {
39
45
  const provider = new Provider(providerParams);
40
46
 
47
+ if (BASCULE_SUPPORTED_CHAINS.includes(provider.chainId)) {
48
+ const status = await getBasculeDepositStatus({
49
+ env,
50
+ rawPayload: data,
51
+ ...providerParams,
52
+ });
53
+
54
+ if (status !== BasculeDepositStatus.REPORTED) {
55
+ throwBasculeDepositStatusError(status);
56
+ }
57
+ }
58
+
41
59
  const tokenContract = getLbtcTokenContract(provider, env);
42
60
 
43
61
  const tx = tokenContract.methods.mint(hexify(data), hexify(proofSignature));
@@ -20,7 +20,7 @@ export interface ICheckBasculeDepositStatusParams
20
20
  extends IProviderBasedParams,
21
21
  IEnvParam {
22
22
  /**
23
- * rawPayload of the transaction.
23
+ * raw_payload of the transaction.
24
24
  */
25
25
  rawPayload?: string;
26
26
  }
@@ -0,0 +1,7 @@
1
+ import { OChainId } from '../../../common/types/types';
2
+
3
+ export const BASCULE_SUPPORTED_CHAINS: number[] = [
4
+ OChainId.ethereum,
5
+ OChainId.base,
6
+ OChainId.binanceSmartChain,
7
+ ];
@@ -0,0 +1,21 @@
1
+ import { BasculeDepositStatus } from '../getBasculeDepositStatus';
2
+
3
+ export function throwBasculeDepositStatusError(status: BasculeDepositStatus) {
4
+ let errorMessage = '';
5
+
6
+ switch (status) {
7
+ case BasculeDepositStatus.UNREPORTED:
8
+ errorMessage = 'Checking Minting Status, try again in 30 seconds.';
9
+ break;
10
+
11
+ case BasculeDepositStatus.WITHDRAWN:
12
+ errorMessage =
13
+ 'Funds have been withdrawn. Minting is currently disabled.';
14
+ break;
15
+
16
+ default:
17
+ errorMessage = 'Unknown Error';
18
+ }
19
+
20
+ throw new Error(errorMessage, { cause: true });
21
+ }