@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/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1013 -986
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/provider/rpcUrlConfig.ts +8 -6
- package/src/web3Sdk/claimLBTC/claimLBTC.ts +18 -0
- package/src/web3Sdk/getBasculeDepositStatus/getBasculeDepositStatus.ts +1 -1
- package/src/web3Sdk/getBasculeDepositStatus/utils/const.ts +7 -0
- package/src/web3Sdk/getBasculeDepositStatus/utils/throwBasculeDepositStatusError.ts +21 -0
package/package.json
CHANGED
|
@@ -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]:
|
|
7
|
-
[OChainId.holesky]:
|
|
8
|
-
[OChainId.sepolia]:
|
|
9
|
-
[OChainId.base]:
|
|
10
|
-
[OChainId.baseSepoliaTestnet]:
|
|
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]:
|
|
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));
|
|
@@ -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
|
+
}
|