@lombard.finance/sdk 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lombard.finance/sdk",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "exports": {
5
5
  ".": {
6
6
  "import": "./dist/index.js",
@@ -7,7 +7,7 @@ interface IApiConfig {
7
7
  }
8
8
 
9
9
  const stageConfig: IApiConfig = {
10
- baseApiUrl: 'https://bft-dev.stage.lombard.finance',
10
+ baseApiUrl: 'https://staging.prod.lombard.finance',
11
11
  claimerApiUrl: 'https://claimer.staging.lombard.finance',
12
12
  };
13
13
 
@@ -31,7 +31,7 @@ export const WithParams: Story = {
31
31
  signature: '',
32
32
  env: defaultEnv,
33
33
  referrerCode: 'lombard',
34
- referralId: 'lombard',
34
+ partnerId: 'lombard',
35
35
  },
36
36
  };
37
37
 
@@ -40,7 +40,7 @@ export interface IGenerateDepositBtcAddressParams extends IEnvParam {
40
40
  /**
41
41
  * The referral ID.
42
42
  */
43
- referralId: string;
43
+ partnerId?: string;
44
44
  }
45
45
 
46
46
  /**
@@ -56,9 +56,9 @@ export async function generateDepositBtcAddress({
56
56
  chainId,
57
57
  signature,
58
58
  env,
59
- captchaToken,
60
59
  referrerCode,
61
- referralId,
60
+ partnerId,
61
+ captchaToken = '',
62
62
  }: IGenerateDepositBtcAddressParams): Promise<string> {
63
63
  const { baseApiUrl } = getApiConfig(env);
64
64
  const toChain = getChainNameById(chainId);
@@ -68,7 +68,7 @@ export async function generateDepositBtcAddress({
68
68
  to_address_signature: signature,
69
69
  to_chain: toChain,
70
70
  referrer_code: referrerCode,
71
- referral_id: referralId,
71
+ partner_id: partnerId,
72
72
  nonce: 0,
73
73
  captcha: captchaToken,
74
74
  };
@@ -29,7 +29,7 @@ export const WithParams: Story = {
29
29
  address: exampleEvmAddress,
30
30
  chainId: OChainId.ethereum,
31
31
  env: defaultEnv,
32
- referralId: 'lombard',
32
+ partnerId: 'lombard',
33
33
  },
34
34
  };
35
35
 
@@ -7,7 +7,7 @@ import { getChainNameById } from '../utils/getChainNameById';
7
7
 
8
8
  const ADDRESS_URL = 'api/v1/address';
9
9
 
10
- type TReferralId = 'lombard' | string;
10
+ type TPartnerId = 'lombard' | string;
11
11
 
12
12
  interface IDepositAddress {
13
13
  btc_address: string;
@@ -16,7 +16,8 @@ interface IDepositAddress {
16
16
  type: string;
17
17
  used?: boolean;
18
18
  deposit_metadata: {
19
- referral: TReferralId;
19
+ referral: TPartnerId;
20
+ partner_id: TPartnerId;
20
21
  to_address: string;
21
22
  to_blockchain: TChainName;
22
23
  };
@@ -27,7 +28,6 @@ interface IDepositAddressesResponse {
27
28
  has_more?: boolean;
28
29
  }
29
30
 
30
-
31
31
  export interface IGetDepositBtcAddressParams extends IEnvParam {
32
32
  /**
33
33
  * The destination EVM user address where LBTC will be claimed.
@@ -40,7 +40,7 @@ export interface IGetDepositBtcAddressParams extends IEnvParam {
40
40
  /**
41
41
  * The referral ID.
42
42
  */
43
- referralId: TReferralId;
43
+ partnerId: TPartnerId;
44
44
  }
45
45
 
46
46
  /**
@@ -54,13 +54,13 @@ export async function getDepositBtcAddress({
54
54
  address,
55
55
  chainId,
56
56
  env,
57
- referralId,
57
+ partnerId,
58
58
  }: IGetDepositBtcAddressParams): Promise<string> {
59
59
  const addresses = await getDepositBtcAddresses({
60
60
  address,
61
61
  chainId,
62
62
  env,
63
- referralId,
63
+ partnerId,
64
64
  });
65
65
 
66
66
  const addressData = getActualAddress(addresses);
@@ -106,7 +106,7 @@ export async function getDepositBtcAddresses({
106
106
  address,
107
107
  chainId,
108
108
  env,
109
- referralId,
109
+ partnerId,
110
110
  }: IGetDepositBtcAddressParams): Promise<IDepositAddress[]> {
111
111
  const { baseApiUrl } = getApiConfig(env);
112
112
  const toBlockchain = getChainNameById(chainId);
@@ -117,7 +117,7 @@ export async function getDepositBtcAddresses({
117
117
  limit: 1,
118
118
  offset: 0,
119
119
  asc: false,
120
- referralId,
120
+ partnerId,
121
121
  };
122
122
 
123
123
  const { data } = await axios.get<IDepositAddressesResponse>(ADDRESS_URL, {
@@ -1 +1 @@
1
- export * from './getLBTCExchangeRate.stories';
1
+ export * from './getLBTCExchangeRate';
@@ -1,8 +1,8 @@
1
1
  import axios from 'axios';
2
2
 
3
+ import { IEnvParam } from '../../common/types/internalTypes';
3
4
  import { getErrorMessage } from '../../common/utils/getErrorMessage';
4
5
  import { getApiConfig } from '../apiConfig';
5
- import { IEnvParam } from '../../common/types/internalTypes';
6
6
 
7
7
  export interface IGetNetworkFeeSignatureParams extends IEnvParam {
8
8
  /**
@@ -53,7 +53,7 @@ export interface IGetNetworkFeeSignatureMappedResponse {
53
53
  export async function getNetworkFeeSignature({
54
54
  address,
55
55
  chainId,
56
- env
56
+ env,
57
57
  }: IGetNetworkFeeSignatureParams): Promise<IGetNetworkFeeSignatureMappedResponse> {
58
58
  const { claimerApiUrl } = getApiConfig(env);
59
59
 
@@ -71,7 +71,7 @@ export async function getNetworkFeeSignature({
71
71
  return {
72
72
  expirationDate: data?.expiration_date,
73
73
  hasSignature: data?.has_signature,
74
- isDelayed: data?.is_delayed
74
+ isDelayed: data?.is_delayed,
75
75
  };
76
76
  } catch (error) {
77
77
  const errorMessage = getErrorMessage(error);
@@ -1,5 +1,7 @@
1
1
  export const OChainName = {
2
2
  eth: 'DESTINATION_BLOCKCHAIN_ETHEREUM',
3
+ base: 'DESTINATION_BLOCKCHAIN_BASE',
4
+ bsc: 'DESTINATION_BLOCKCHAIN_BSC',
3
5
  } as const;
4
6
 
5
7
  export type TChainName = (typeof OChainName)[keyof typeof OChainName];
@@ -12,6 +12,12 @@ export function getChainNameById(chainId: TChainId): TChainName {
12
12
  case OChainId.sepolia:
13
13
  case OChainId.ethereum:
14
14
  return OChainName.eth;
15
+ case OChainId.base:
16
+ case OChainId.baseTestnet:
17
+ return OChainName.base;
18
+ case OChainId.binanceSmartChain:
19
+ case OChainId.binanceSmartChainTestnet:
20
+ return OChainName.bsc;
15
21
  default:
16
22
  throw new Error(`Unknown chain ID: ${chainId}`);
17
23
  }
@@ -0,0 +1,2 @@
1
+ export const SECONDS_PER_DAY = 24 * 60 * 60;
2
+ export const MS_PER_DAY = SECONDS_PER_DAY * 1000;
@@ -1,11 +1,12 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
+ import { OEnv } from '../../common/types/types';
2
3
  import { Button } from '../../stories/components/Button';
3
4
  import { CodeBlock } from '../../stories/components/CodeBlock';
4
5
  import { useConnect } from '../../stories/hooks/useConnect';
5
6
  import useQuery from '../../stories/hooks/useQuery';
6
7
  import { fromCamelCase } from '../../stories/utils/fromCamelCase';
8
+ import { MS_PER_DAY } from '../const';
7
9
  import { ISignNetworkFeeParams, signNetworkFee } from './signNetworkFee';
8
- import { OEnv } from '../../common/types/types';
9
10
 
10
11
  const { name } = signNetworkFee;
11
12
  const nameWithWhitespaces = fromCamelCase(name);
@@ -36,8 +37,6 @@ export function StoryView(props: SignNetworkFeeProps) {
36
37
  connect,
37
38
  } = useConnect();
38
39
 
39
- console.log(props);
40
-
41
40
  const request = async () => {
42
41
  if (!connectData) {
43
42
  return;
@@ -47,7 +46,7 @@ export function StoryView(props: SignNetworkFeeProps) {
47
46
  ...connectData,
48
47
  ...props,
49
48
  fee: '1100',
50
- expiry: '1831688748',
49
+ expiry: Date.now() + MS_PER_DAY,
51
50
  address: connectData.account,
52
51
  });
53
52
  };
@@ -1,5 +1,6 @@
1
1
  import { IEnvParam } from '../../common/types/internalTypes';
2
2
  import { Provider } from '../../provider';
3
+ import { SECONDS_PER_DAY } from '../const';
3
4
  import { IProviderBasedParams } from '../types';
4
5
  import { getLbtcTokenContract } from '../utils/getLbtcTokenContract';
5
6
  import { getTypedData } from './getTypedData';
@@ -21,7 +22,7 @@ export interface ISignNetworkFeeParams
21
22
  /**
22
23
  * Expiration time
23
24
  */
24
- expiry: string;
25
+ expiry: number;
25
26
  }
26
27
 
27
28
  export interface ISignNetworkFeeResponse {
@@ -46,9 +47,9 @@ export async function signNetworkFee({
46
47
  address,
47
48
  provider,
48
49
  fee,
49
- expiry,
50
50
  chainId,
51
51
  env,
52
+ expiry = Date.now() + SECONDS_PER_DAY,
52
53
  }: ISignNetworkFeeParams): Promise<ISignNetworkFeeResponse> {
53
54
  const providerInstance = new Provider({
54
55
  provider,
@@ -59,7 +60,12 @@ export async function signNetworkFee({
59
60
  const tokenContract = getLbtcTokenContract(providerInstance, env);
60
61
  const verifyingContract = tokenContract.options.address;
61
62
  const typedData = JSON.stringify(
62
- getTypedData({ chainId, verifyingContract, fee, expiry }),
63
+ getTypedData({
64
+ chainId,
65
+ verifyingContract,
66
+ fee,
67
+ expiry: expiry.toString(),
68
+ }),
63
69
  );
64
70
 
65
71
  const signature = await providerInstance.web3?.currentProvider?.request<
package/dist/style.css DELETED
@@ -1 +0,0 @@
1
- .code-block--max-height{max-height:500px}