@lombard.finance/sdk 2.0.16 → 2.1.0
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/README.md +105 -6
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +362 -673
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/common/types/types.ts +2 -9
- package/src/provider/Provider.ts +1 -0
- package/src/provider/rpcUrlConfig.ts +3 -3
- package/src/sdk/generateDepositBtcAddress/generateDepositBtcAddress.ts +6 -0
- package/src/sdk/getDepositsByAddress/getDepositsByAddress.ts +2 -0
- package/src/sdk/getUserStakeAndBakeSignature/getUserStakeAndBakeSignature.stories.tsx +1 -1
- package/src/sdk/internalTypes.ts +5 -5
- package/src/sdk/storeStakeAndBakeSignature/storeStakeAndBakeSignature.stories.tsx +27 -95
- package/src/sdk/storeStakeAndBakeSignature/storeStakeAndBakeSignature.ts +1 -1
- package/src/sdk/utils/getChainIdByName.ts +5 -0
- package/src/sdk/utils/getChainNameById.ts +1 -1
- package/src/web3Sdk/basculeAddressConfig.ts +70 -0
- package/src/web3Sdk/claimLBTC/claimLBTC.ts +0 -1
- package/src/web3Sdk/getBasculeDepositStatus/getBasculeDepositStatus.stories.tsx +3 -3
- package/src/web3Sdk/getBasculeDepositStatus/getBasculeDepositStatus.ts +12 -15
- package/src/web3Sdk/index.ts +2 -1
- package/src/web3Sdk/lbtcAddressConfig.ts +4 -4
- package/src/web3Sdk/signStakeAndBake/contracts.ts +29 -1
- package/src/web3Sdk/signStakeAndBake/signStakeAndBake.stories.tsx +25 -100
- package/src/web3Sdk/lbtcOFTAdapterAddressConfig.ts +0 -47
|
@@ -1,31 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { useState } from 'react';
|
|
4
|
-
import { OChainId } from '../../common/types/types';
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
|
|
5
3
|
import { Button } from '../../stories/components/Button';
|
|
6
4
|
import { CodeBlock } from '../../stories/components/CodeBlock';
|
|
7
5
|
import { useConnect } from '../../stories/hooks/useConnect';
|
|
8
6
|
import useQuery from '../../stories/hooks/useQuery';
|
|
9
7
|
import { fromCamelCase } from '../../stories/utils/fromCamelCase';
|
|
10
|
-
import {
|
|
11
|
-
getStakeAndBakeVaults,
|
|
12
|
-
SUPPORTED_STAKE_AND_BAKE_CHAINS,
|
|
13
|
-
} from './contracts';
|
|
14
|
-
import { signStakeAndBake } from './signStakeAndBake';
|
|
8
|
+
import { signStakeAndBake, ISignStakeAndBakeParams } from './signStakeAndBake';
|
|
15
9
|
|
|
16
10
|
const { name } = signStakeAndBake;
|
|
17
11
|
const nameWithWhitespaces = fromCamelCase(name);
|
|
18
12
|
|
|
19
|
-
const EXPIRY_OPTIONS = {
|
|
20
|
-
'10 seconds': 10,
|
|
21
|
-
'1 minute': 60,
|
|
22
|
-
'1 hour': 3600,
|
|
23
|
-
'1 day': 86400,
|
|
24
|
-
'1 year': 31536000,
|
|
25
|
-
} as const;
|
|
26
|
-
|
|
27
|
-
type ExpiryOption = keyof typeof EXPIRY_OPTIONS;
|
|
28
|
-
|
|
29
13
|
const meta = {
|
|
30
14
|
title: 'Web3SDK/signStakeAndBake',
|
|
31
15
|
component: StoryView,
|
|
@@ -34,13 +18,22 @@ const meta = {
|
|
|
34
18
|
|
|
35
19
|
export default meta;
|
|
36
20
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
21
|
+
type Story = StoryObj<typeof meta>;
|
|
22
|
+
|
|
23
|
+
export const WithParams: Story = {
|
|
24
|
+
args: {
|
|
25
|
+
value: '20000',
|
|
26
|
+
expiry: 3600,
|
|
27
|
+
vaultKey: 'veda',
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
type SignStakeAndBakeParams = Pick<
|
|
32
|
+
ISignStakeAndBakeParams,
|
|
33
|
+
'value' | 'expiry' | 'vaultKey'
|
|
34
|
+
>;
|
|
43
35
|
|
|
36
|
+
export function StoryView(props: SignStakeAndBakeParams) {
|
|
44
37
|
const {
|
|
45
38
|
data: connectData,
|
|
46
39
|
error: connectError,
|
|
@@ -53,24 +46,18 @@ export function StoryView() {
|
|
|
53
46
|
return;
|
|
54
47
|
}
|
|
55
48
|
|
|
56
|
-
const expiry =
|
|
57
|
-
Math.floor(Date.now() / 1000) + EXPIRY_OPTIONS[selectedExpiry];
|
|
58
|
-
|
|
59
49
|
return signStakeAndBake({
|
|
60
50
|
provider: connectData.provider,
|
|
61
51
|
address: connectData.account,
|
|
62
|
-
chainId:
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
52
|
+
chainId: connectData.chainId,
|
|
53
|
+
|
|
54
|
+
value: props.value,
|
|
55
|
+
expiry: props.expiry,
|
|
56
|
+
vaultKey: props.vaultKey,
|
|
66
57
|
});
|
|
67
58
|
};
|
|
68
59
|
|
|
69
|
-
const { data, error, isLoading, refetch } = useQuery(
|
|
70
|
-
request,
|
|
71
|
-
[selectedExpiry, selectedChain, selectedVaultKey],
|
|
72
|
-
false,
|
|
73
|
-
);
|
|
60
|
+
const { data, error, isLoading, refetch } = useQuery(request, [], false);
|
|
74
61
|
|
|
75
62
|
const formattedConnectData = connectData && {
|
|
76
63
|
account: connectData.account,
|
|
@@ -96,71 +83,9 @@ export function StoryView() {
|
|
|
96
83
|
<CodeBlock text={connectError || formattedConnectData} />
|
|
97
84
|
</div>
|
|
98
85
|
|
|
99
|
-
<div className="mb-4">
|
|
100
|
-
<FormControl fullWidth>
|
|
101
|
-
<InputLabel id="chain-select-label">Chain</InputLabel>
|
|
102
|
-
<Select
|
|
103
|
-
labelId="chain-select-label"
|
|
104
|
-
value={selectedChain}
|
|
105
|
-
label="Chain"
|
|
106
|
-
onChange={e => {
|
|
107
|
-
const newChainId = Number(e.target.value) as typeof selectedChain;
|
|
108
|
-
setSelectedChain(newChainId);
|
|
109
|
-
// Reset vault selection to first vault of new chain
|
|
110
|
-
const newVaults = getStakeAndBakeVaults(newChainId);
|
|
111
|
-
setSelectedVaultKey(newVaults[0].key);
|
|
112
|
-
}}
|
|
113
|
-
>
|
|
114
|
-
{SUPPORTED_STAKE_AND_BAKE_CHAINS.map(chainId => (
|
|
115
|
-
<MenuItem key={chainId} value={chainId}>
|
|
116
|
-
{chainId}
|
|
117
|
-
</MenuItem>
|
|
118
|
-
))}
|
|
119
|
-
</Select>
|
|
120
|
-
</FormControl>
|
|
121
|
-
</div>
|
|
122
|
-
|
|
123
|
-
<div className="mb-4">
|
|
124
|
-
<FormControl fullWidth>
|
|
125
|
-
<InputLabel id="vault-select-label">Vault</InputLabel>
|
|
126
|
-
<Select
|
|
127
|
-
labelId="vault-select-label"
|
|
128
|
-
value={selectedVaultKey}
|
|
129
|
-
label="Vault"
|
|
130
|
-
onChange={e => setSelectedVaultKey(e.target.value)}
|
|
131
|
-
>
|
|
132
|
-
{vaults.map(vault => (
|
|
133
|
-
<MenuItem key={vault.key} value={vault.key}>
|
|
134
|
-
{vault.name}
|
|
135
|
-
</MenuItem>
|
|
136
|
-
))}
|
|
137
|
-
</Select>
|
|
138
|
-
</FormControl>
|
|
139
|
-
</div>
|
|
140
|
-
|
|
141
|
-
<div className="mb-4">
|
|
142
|
-
<FormControl fullWidth>
|
|
143
|
-
<InputLabel id="expiry-select-label">Expiry Time</InputLabel>
|
|
144
|
-
<Select
|
|
145
|
-
labelId="expiry-select-label"
|
|
146
|
-
value={selectedExpiry}
|
|
147
|
-
label="Expiry Time"
|
|
148
|
-
onChange={e => setSelectedExpiry(e.target.value as ExpiryOption)}
|
|
149
|
-
>
|
|
150
|
-
{Object.keys(EXPIRY_OPTIONS).map(option => (
|
|
151
|
-
<MenuItem key={option} value={option}>
|
|
152
|
-
{option}
|
|
153
|
-
</MenuItem>
|
|
154
|
-
))}
|
|
155
|
-
</Select>
|
|
156
|
-
</FormControl>
|
|
157
|
-
</div>
|
|
158
|
-
|
|
159
86
|
<Button
|
|
160
87
|
onClick={refetch}
|
|
161
|
-
disabled={
|
|
162
|
-
isLoading || !connectData || connectData.chainId !== selectedChain
|
|
163
|
-
}
|
|
88
|
+
disabled={isLoading || !connectData}
|
|
164
89
|
isLoading={isLoading}
|
|
165
90
|
>
|
|
166
91
|
{nameWithWhitespaces}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { defaultEnv } from '../common/const';
|
|
2
|
-
import { OChainId, OEnv, TOFTChainId, TEnv } from '../common/types/types';
|
|
3
|
-
|
|
4
|
-
type TToChainId = Partial<Record<TOFTChainId, string>>;
|
|
5
|
-
|
|
6
|
-
type LbtcOFTAdapterConfig = Partial<Record<TOFTChainId, TToChainId>>;
|
|
7
|
-
|
|
8
|
-
const stageConfig: LbtcOFTAdapterConfig = {
|
|
9
|
-
[OChainId.sepolia]: {
|
|
10
|
-
[OChainId.berachainBartioTestnet]:
|
|
11
|
-
'0xe3748bF0Ec0A76767539eE28610B3367e35fe2C2',
|
|
12
|
-
},
|
|
13
|
-
[OChainId.berachainBartioTestnet]: {
|
|
14
|
-
[OChainId.sepolia]: '0x1977013acaf27856ac8048C42EE2ed0134d53895',
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const testnetConfig: LbtcOFTAdapterConfig = {
|
|
19
|
-
...stageConfig,
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const prodConfig: LbtcOFTAdapterConfig = {
|
|
23
|
-
...stageConfig,
|
|
24
|
-
[OChainId.corn]: {
|
|
25
|
-
[OChainId.ethereum]: '0xfc7B20D9B59A8A466f4fC3d34aA69a7D98e71d7A',
|
|
26
|
-
},
|
|
27
|
-
[OChainId.ethereum]: {
|
|
28
|
-
[OChainId.corn]: '0x6bc15d7930839ec18a57f6f7df72ae1b439d077f',
|
|
29
|
-
[OChainId.swell]: '0x37E92d760a15231e652a2C502182a6b44c7510c0',
|
|
30
|
-
},
|
|
31
|
-
[OChainId.swell]: {
|
|
32
|
-
[OChainId.ethereum]: '0x7B3784AD646C10A8Ddf42b47a4f4bd9aFD351E54',
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export function getLbtcOFTAdapterAddressConfig(
|
|
37
|
-
env: TEnv = defaultEnv,
|
|
38
|
-
): LbtcOFTAdapterConfig {
|
|
39
|
-
switch (env) {
|
|
40
|
-
case OEnv.prod:
|
|
41
|
-
return prodConfig;
|
|
42
|
-
case OEnv.testnet:
|
|
43
|
-
return testnetConfig;
|
|
44
|
-
default:
|
|
45
|
-
return stageConfig;
|
|
46
|
-
}
|
|
47
|
-
}
|