@lombard.finance/sdk 2.0.2 → 2.0.5

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.0.2",
3
+ "version": "2.0.5",
4
4
  "exports": {
5
5
  ".": {
6
6
  "import": "./dist/index.js",
@@ -33,3 +33,14 @@ export type TOFTChainId =
33
33
  export interface IEIP1193Provider {
34
34
  request: (args: any) => Promise<any>;
35
35
  }
36
+
37
+ export const getEthNetworkByEnv = (env: TEnv) =>
38
+ env === OEnv.prod ? OChainId.ethereum : OChainId.holesky;
39
+
40
+ export const getBscNetworkByEnv = (env: TEnv) =>
41
+ env === OEnv.prod
42
+ ? OChainId.binanceSmartChain
43
+ : OChainId.binanceSmartChainTestnet;
44
+
45
+ export const getBaseNetworkByEnv = (env: TEnv) =>
46
+ env === OEnv.prod ? OChainId.base : OChainId.baseTestnet;
@@ -9,4 +9,6 @@ export const rpcUrlConfig: TRpcUrlConfig = {
9
9
  [OChainId.base]: 'https://rpc.ankr.com/base',
10
10
  [OChainId.baseTestnet]: 'https://rpc.ankr.com/base_sepolia',
11
11
  [OChainId.binanceSmartChain]: 'https://rpc.ankr.com/bsc',
12
+ [OChainId.binanceSmartChainTestnet]:
13
+ 'https://rpc.ankr.com/bsc_testnet_chapel',
12
14
  };
@@ -3,22 +3,18 @@ import { OEnv, TEnv } from '../common/types/types';
3
3
 
4
4
  interface IApiConfig {
5
5
  baseApiUrl: string;
6
- claimerApiUrl: string;
7
6
  }
8
7
 
9
8
  const stageConfig: IApiConfig = {
10
9
  baseApiUrl: 'https://staging.prod.lombard.finance',
11
- claimerApiUrl: 'https://claimer.staging.lombard.finance',
12
10
  };
13
11
 
14
12
  const testnetConfig: IApiConfig = {
15
13
  baseApiUrl: 'https://gastald-testnet.prod.lombard.finance',
16
- claimerApiUrl: 'https://claimer.staging.lombard.finance',
17
14
  };
18
15
 
19
16
  const prodConfig: IApiConfig = {
20
17
  baseApiUrl: 'https://mainnet.prod.lombard.finance',
21
- claimerApiUrl: '',
22
18
  };
23
19
 
24
20
  export const getApiConfig = (env: TEnv = defaultEnv): IApiConfig => {
@@ -117,7 +117,7 @@ export async function getDepositBtcAddresses({
117
117
  limit: 1,
118
118
  offset: 0,
119
119
  asc: false,
120
- partnerId,
120
+ referralId: partnerId,
121
121
  };
122
122
 
123
123
  const { data } = await axios.get<IDepositAddressesResponse>(ADDRESS_URL, {
@@ -4,7 +4,7 @@ import { IEnvParam } from '../../common/types/internalTypes';
4
4
  import { TChainId, TEnv } from '../../common/types/types';
5
5
  import { fromSatoshi } from '../../common/utils/convertSatoshi';
6
6
  import { getApiConfig } from '../apiConfig';
7
- import { getCainIdByName } from '../utils/getCainIdByName';
7
+ import { getChainIdByName } from '../utils/getChainIdByName';
8
8
 
9
9
  type Address = string;
10
10
  type Seconds = number;
@@ -115,7 +115,7 @@ function mapResponse(env?: TEnv) {
115
115
  blockTime: data.block_time ? Number(data.block_time) : undefined,
116
116
  value: new BigNumber(fromSatoshi(data.value)),
117
117
  address: data.address,
118
- chainId: getCainIdByName(data.to_chain, env),
118
+ chainId: getChainIdByName(data.to_chain, env),
119
119
  claimedTxId: data.claim_tx,
120
120
  rawPayload: data.raw_payload,
121
121
  signature: data.proof,
@@ -55,11 +55,11 @@ export async function getNetworkFeeSignature({
55
55
  chainId,
56
56
  env,
57
57
  }: IGetNetworkFeeSignatureParams): Promise<IGetNetworkFeeSignatureMappedResponse> {
58
- const { claimerApiUrl } = getApiConfig(env);
58
+ const { baseApiUrl } = getApiConfig(env);
59
59
 
60
60
  try {
61
61
  const { data } = await axios.get<IGetNetworkFeeSignatureResponse>(
62
- `${claimerApiUrl}/claimer/v1/mintwithfee/get-user-signature`,
62
+ `${baseApiUrl}/api/v1/claimer/get-user-signature`,
63
63
  {
64
64
  params: {
65
65
  user_destination_address: address,
package/src/sdk/index.ts CHANGED
@@ -5,4 +5,5 @@ export * from './getDepositsByAddress';
5
5
  export * from './getLBTCExchangeRate';
6
6
  export * from './getNetworkFeeSignature';
7
7
  export * from './storeNetworkFeeSignature';
8
-
8
+ export * from './utils/getChainIdByName';
9
+ export * from './utils/getChainNameById';
@@ -2,6 +2,11 @@ export const OChainName = {
2
2
  eth: 'DESTINATION_BLOCKCHAIN_ETHEREUM',
3
3
  base: 'DESTINATION_BLOCKCHAIN_BASE',
4
4
  bsc: 'DESTINATION_BLOCKCHAIN_BSC',
5
+ mantle: 'DESTINATION_BLOCKCHAIN_MANTLE',
6
+ linea: 'DESTINATION_BLOCKCHAIN_LINEA',
7
+ zcircuit: 'DESTINATION_BLOCKCHAIN_ZIRCUIT',
8
+ scroll: 'DESTINATION_BLOCKCHAIN_SCROLL',
9
+ xlayer: 'DESTINATION_BLOCKCHAIN_XLAYER',
5
10
  } as const;
6
11
 
7
12
  export type TChainName = (typeof OChainName)[keyof typeof OChainName];
@@ -1,7 +1,7 @@
1
1
  import axios from 'axios';
2
- import { getApiConfig } from '../apiConfig';
3
2
  import { IEnvParam } from '../../common/types/internalTypes';
4
3
  import { getErrorMessage } from '../../common/utils/getErrorMessage';
4
+ import { getApiConfig } from '../apiConfig';
5
5
 
6
6
  export type IStoreNetworkFeeSignatureStatus = 'success';
7
7
 
@@ -38,11 +38,11 @@ export async function storeNetworkFeeSignature({
38
38
  address,
39
39
  env,
40
40
  }: IStoreNetworkFeeSignatureParams): Promise<IStoreNetworkFeeSignatureStatus> {
41
- const { claimerApiUrl } = getApiConfig(env);
41
+ const { baseApiUrl } = getApiConfig(env);
42
42
 
43
43
  try {
44
44
  const { data } = await axios.post<IStoreNetworkFeeSignatureResponse>(
45
- `${claimerApiUrl}/claimer/v1/mintwithfee/save-user-signature`,
45
+ `${baseApiUrl}/api/v1/claimer/save-user-signature`,
46
46
  null,
47
47
  {
48
48
  params: {
@@ -0,0 +1,32 @@
1
+ import { defaultEnv } from '../../common/const';
2
+ import {
3
+ getBaseNetworkByEnv,
4
+ getBscNetworkByEnv,
5
+ getEthNetworkByEnv,
6
+ OChainId,
7
+ TChainId,
8
+ TEnv,
9
+ } from '../../common/types/types';
10
+ import { OChainName, TChainName } from '../internalTypes';
11
+
12
+ /**
13
+ * @param chainId the chain ID
14
+ *
15
+ * @returns the chain name
16
+ */
17
+ export function getChainIdByName(
18
+ chain: string,
19
+ env: TEnv = defaultEnv,
20
+ ): TChainId {
21
+ switch (chain as TChainName) {
22
+ case OChainName.eth:
23
+ return getEthNetworkByEnv(env);
24
+ case OChainName.base:
25
+ return getBaseNetworkByEnv(env);
26
+ case OChainName.bsc:
27
+ return getBscNetworkByEnv(env);
28
+
29
+ default:
30
+ return OChainId.ethereum;
31
+ }
32
+ }
@@ -8,9 +8,9 @@ import { OChainName, TChainName } from '../internalTypes';
8
8
  */
9
9
  export function getChainNameById(chainId: TChainId): TChainName {
10
10
  switch (chainId) {
11
+ case OChainId.ethereum:
11
12
  case OChainId.holesky:
12
13
  case OChainId.sepolia:
13
- case OChainId.ethereum:
14
14
  return OChainName.eth;
15
15
  case OChainId.base:
16
16
  case OChainId.baseTestnet:
@@ -48,6 +48,7 @@ export async function claimLBTC({
48
48
  tokenContract.options.address,
49
49
  {
50
50
  data: tx.encodeABI(),
51
+ // TODO: add getGasOptions from the app for bsc here
51
52
  estimate: true,
52
53
  estimateFee: true,
53
54
  gasLimitMultiplier: getGasMultiplier(provider.chainId),
@@ -1,21 +0,0 @@
1
- import { defaultEnv } from '../../common/const';
2
- import { OChainId, OEnv, TChainId, TEnv } from '../../common/types/types';
3
- import { TChainName } from '../internalTypes';
4
-
5
- /**
6
- * @param chainId the chain ID
7
- *
8
- * @returns the chain name
9
- */
10
- export function getCainIdByName(
11
- chain: string,
12
- env: TEnv = defaultEnv,
13
- ): TChainId {
14
- switch (chain as TChainName) {
15
- case 'DESTINATION_BLOCKCHAIN_ETHEREUM':
16
- return env === OEnv.prod ? OChainId.ethereum : OChainId.sepolia;
17
-
18
- default:
19
- return OChainId.ethereum;
20
- }
21
- }