@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/dist/index.cjs +1 -65
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +680 -2881
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/sdk/apiConfig.ts +1 -1
- package/src/sdk/generateDepositBtcAddress/generateDepositBtcAddress.stories.tsx +1 -1
- package/src/sdk/generateDepositBtcAddress/generateDepositBtcAddress.ts +4 -4
- package/src/sdk/getDepositBtcAddress/getDepositBtcAddress.stories.tsx +1 -1
- package/src/sdk/getDepositBtcAddress/getDepositBtcAddress.ts +8 -8
- package/src/sdk/getLBTCExchangeRate/index.ts +1 -1
- package/src/sdk/getNetworkFeeSignature/getNetworkFeeSignature.ts +3 -3
- package/src/sdk/internalTypes.ts +2 -0
- package/src/sdk/utils/getChainNameById.ts +6 -0
- package/src/web3Sdk/const.ts +2 -0
- package/src/web3Sdk/signNetworkFee/signNetworkFee.stories.tsx +3 -4
- package/src/web3Sdk/signNetworkFee/signNetworkFee.ts +9 -3
- package/dist/style.css +0 -1
package/package.json
CHANGED
package/src/sdk/apiConfig.ts
CHANGED
|
@@ -40,7 +40,7 @@ export interface IGenerateDepositBtcAddressParams extends IEnvParam {
|
|
|
40
40
|
/**
|
|
41
41
|
* The referral ID.
|
|
42
42
|
*/
|
|
43
|
-
|
|
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
|
-
|
|
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
|
-
|
|
71
|
+
partner_id: partnerId,
|
|
72
72
|
nonce: 0,
|
|
73
73
|
captcha: captchaToken,
|
|
74
74
|
};
|
|
@@ -7,7 +7,7 @@ import { getChainNameById } from '../utils/getChainNameById';
|
|
|
7
7
|
|
|
8
8
|
const ADDRESS_URL = 'api/v1/address';
|
|
9
9
|
|
|
10
|
-
type
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
57
|
+
partnerId,
|
|
58
58
|
}: IGetDepositBtcAddressParams): Promise<string> {
|
|
59
59
|
const addresses = await getDepositBtcAddresses({
|
|
60
60
|
address,
|
|
61
61
|
chainId,
|
|
62
62
|
env,
|
|
63
|
-
|
|
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
|
-
|
|
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
|
-
|
|
120
|
+
partnerId,
|
|
121
121
|
};
|
|
122
122
|
|
|
123
123
|
const { data } = await axios.get<IDepositAddressesResponse>(ADDRESS_URL, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './getLBTCExchangeRate
|
|
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);
|
package/src/sdk/internalTypes.ts
CHANGED
|
@@ -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
|
}
|
|
@@ -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:
|
|
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:
|
|
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({
|
|
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}
|