@lombard.finance/sdk 0.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 +32 -0
- package/dist/index.js +12574 -0
- package/dist/index.js.map +1 -0
- package/package.json +55 -0
- package/src/btcSdk/utils/getOutputScript.ts +54 -0
- package/src/common/const.ts +3 -0
- package/src/common/types/internalTypes.ts +8 -0
- package/src/common/types/types.ts +13 -0
- package/src/common/utils/convertSatoshi.ts +21 -0
- package/src/common/utils/getErrorMessage.ts +35 -0
- package/src/common/utils/isValidChain.ts +5 -0
- package/src/index.ts +5 -0
- package/src/provider/Provider.ts +174 -0
- package/src/provider/ReadProvider.ts +120 -0
- package/src/provider/index.ts +2 -0
- package/src/provider/rpcUrlConfig.ts +8 -0
- package/src/provider/types.ts +58 -0
- package/src/provider/utils/getMaxPriorityFeePerGas.ts +25 -0
- package/src/sdk/apiConfig.ts +20 -0
- package/src/sdk/generateDepositBtcAddress/generateDepositBtcAddress.stories.tsx +52 -0
- package/src/sdk/generateDepositBtcAddress/generateDepositBtcAddress.ts +64 -0
- package/src/sdk/generateDepositBtcAddress/index.ts +1 -0
- package/src/sdk/getDepositBtcAddress/getDepositBtcAddress.stories.tsx +53 -0
- package/src/sdk/getDepositBtcAddress/getDepositBtcAddress.ts +101 -0
- package/src/sdk/getDepositBtcAddress/index.ts +1 -0
- package/src/sdk/getDepositsByAddress/getDepositsByAddress.stories.tsx +49 -0
- package/src/sdk/getDepositsByAddress/getDepositsByAddress.ts +146 -0
- package/src/sdk/getDepositsByAddress/index.ts +1 -0
- package/src/sdk/index.ts +3 -0
- package/src/sdk/internalTypes.ts +5 -0
- package/src/sdk/utils/getCainIdByName.ts +21 -0
- package/src/sdk/utils/getChainNameById.ts +17 -0
- package/src/stories/components/Button/Button.tsx +43 -0
- package/src/stories/components/Button/index.ts +1 -0
- package/src/stories/components/CodeBlock/CodeBlock.tsx +24 -0
- package/src/stories/components/CodeBlock/CodeBlockStyles.css +3 -0
- package/src/stories/components/CodeBlock/index.ts +1 -0
- package/src/stories/components/Spinner/Spinner.tsx +25 -0
- package/src/stories/components/Spinner/index.ts +1 -0
- package/src/stories/const.ts +1 -0
- package/src/stories/hooks/useConnect.ts +47 -0
- package/src/stories/hooks/useQuery.ts +56 -0
- package/src/stories/utils/connectInjectedWallet.ts +12 -0
- package/src/stories/utils/fromCamelCase.ts +16 -0
- package/src/stories/utils/getMetaTitle.ts +7 -0
- package/src/stories/utils/getWalletInfo.ts +31 -0
- package/src/vite-env.d.ts +1 -0
- package/src/web3Sdk/abi/IERC20.json +222 -0
- package/src/web3Sdk/abi/LBTC.json +1400 -0
- package/src/web3Sdk/abi/index.ts +4 -0
- package/src/web3Sdk/approveLBTC/approveLBTC.stories.tsx +77 -0
- package/src/web3Sdk/approveLBTC/approveLBTC.ts +48 -0
- package/src/web3Sdk/approveLBTC/index.ts +1 -0
- package/src/web3Sdk/claimLBTC/claimLBTC.stories.tsx +77 -0
- package/src/web3Sdk/claimLBTC/claimLBTC.ts +62 -0
- package/src/web3Sdk/claimLBTC/index.ts +1 -0
- package/src/web3Sdk/index.ts +4 -0
- package/src/web3Sdk/internalTypes.ts +19 -0
- package/src/web3Sdk/lbtcAddressConfig.ts +16 -0
- package/src/web3Sdk/signLbtcDestionationAddr/index.ts +1 -0
- package/src/web3Sdk/signLbtcDestionationAddr/signLbtcDestionationAddr.stories.tsx +97 -0
- package/src/web3Sdk/signLbtcDestionationAddr/signLbtcDestionationAddr.ts +25 -0
- package/src/web3Sdk/unstakeLBTC/index.ts +1 -0
- package/src/web3Sdk/unstakeLBTC/unstakeLBTC.stories.tsx +77 -0
- package/src/web3Sdk/unstakeLBTC/unstakeLBTC.ts +51 -0
- package/src/web3Sdk/utils/getGasMultiplier.ts +19 -0
- package/src/web3Sdk/utils/getLbtcTokenContract.ts +28 -0
- package/src/web3Sdk/utils/getTokenABI.ts +12 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type TEip1559Provider = any;
|
|
2
|
+
|
|
3
|
+
export async function connectInjectedWallet(): Promise<TEip1559Provider> {
|
|
4
|
+
const { ethereum } = window as any;
|
|
5
|
+
if (!ethereum) {
|
|
6
|
+
throw new Error('Ethereum object not found');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
await ethereum.enable();
|
|
10
|
+
|
|
11
|
+
return ethereum;
|
|
12
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a camelCase string to readable string with spaces.
|
|
3
|
+
*
|
|
4
|
+
* @param value - CamelCase string.
|
|
5
|
+
*
|
|
6
|
+
* @returns Readable string with spaces.
|
|
7
|
+
*/
|
|
8
|
+
export function fromCamelCase(value: string): string {
|
|
9
|
+
return (
|
|
10
|
+
value
|
|
11
|
+
// Insert a space before all caps
|
|
12
|
+
.replace(/([A-Z])/g, ' $1')
|
|
13
|
+
// Uppercase the first character
|
|
14
|
+
.replace(/^./, str => str.toUpperCase())
|
|
15
|
+
);
|
|
16
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import Web3, { FMT_BYTES, FMT_NUMBER } from 'web3';
|
|
2
|
+
|
|
3
|
+
interface IGetWalletInfo {
|
|
4
|
+
account: string;
|
|
5
|
+
chainId: number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Retrieves wallet information.
|
|
10
|
+
*
|
|
11
|
+
* @param web3 - The Web3 instance.
|
|
12
|
+
* @returns A promise that resolves to an object containing the account and chainId.
|
|
13
|
+
* @throws An error if no account is found.
|
|
14
|
+
*/
|
|
15
|
+
export async function getWalletInfo(web3: Web3): Promise<IGetWalletInfo> {
|
|
16
|
+
const [account] = await web3.eth.getAccounts();
|
|
17
|
+
|
|
18
|
+
if (!account) {
|
|
19
|
+
throw new Error('No account found');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const chainId = await web3.eth.getChainId({
|
|
23
|
+
bytes: FMT_BYTES.HEX,
|
|
24
|
+
number: FMT_NUMBER.NUMBER,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
account,
|
|
29
|
+
chainId,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"constant": true,
|
|
4
|
+
"inputs": [],
|
|
5
|
+
"name": "name",
|
|
6
|
+
"outputs": [
|
|
7
|
+
{
|
|
8
|
+
"name": "",
|
|
9
|
+
"type": "string"
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"payable": false,
|
|
13
|
+
"stateMutability": "view",
|
|
14
|
+
"type": "function"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"constant": false,
|
|
18
|
+
"inputs": [
|
|
19
|
+
{
|
|
20
|
+
"name": "_spender",
|
|
21
|
+
"type": "address"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "_value",
|
|
25
|
+
"type": "uint256"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"name": "approve",
|
|
29
|
+
"outputs": [
|
|
30
|
+
{
|
|
31
|
+
"name": "",
|
|
32
|
+
"type": "bool"
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
"payable": false,
|
|
36
|
+
"stateMutability": "nonpayable",
|
|
37
|
+
"type": "function"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"constant": true,
|
|
41
|
+
"inputs": [],
|
|
42
|
+
"name": "totalSupply",
|
|
43
|
+
"outputs": [
|
|
44
|
+
{
|
|
45
|
+
"name": "",
|
|
46
|
+
"type": "uint256"
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"payable": false,
|
|
50
|
+
"stateMutability": "view",
|
|
51
|
+
"type": "function"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"constant": false,
|
|
55
|
+
"inputs": [
|
|
56
|
+
{
|
|
57
|
+
"name": "_from",
|
|
58
|
+
"type": "address"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"name": "_to",
|
|
62
|
+
"type": "address"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"name": "_value",
|
|
66
|
+
"type": "uint256"
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
"name": "transferFrom",
|
|
70
|
+
"outputs": [
|
|
71
|
+
{
|
|
72
|
+
"name": "",
|
|
73
|
+
"type": "bool"
|
|
74
|
+
}
|
|
75
|
+
],
|
|
76
|
+
"payable": false,
|
|
77
|
+
"stateMutability": "nonpayable",
|
|
78
|
+
"type": "function"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"constant": true,
|
|
82
|
+
"inputs": [],
|
|
83
|
+
"name": "decimals",
|
|
84
|
+
"outputs": [
|
|
85
|
+
{
|
|
86
|
+
"name": "",
|
|
87
|
+
"type": "uint8"
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
"payable": false,
|
|
91
|
+
"stateMutability": "view",
|
|
92
|
+
"type": "function"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"constant": true,
|
|
96
|
+
"inputs": [
|
|
97
|
+
{
|
|
98
|
+
"name": "_owner",
|
|
99
|
+
"type": "address"
|
|
100
|
+
}
|
|
101
|
+
],
|
|
102
|
+
"name": "balanceOf",
|
|
103
|
+
"outputs": [
|
|
104
|
+
{
|
|
105
|
+
"name": "balance",
|
|
106
|
+
"type": "uint256"
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
"payable": false,
|
|
110
|
+
"stateMutability": "view",
|
|
111
|
+
"type": "function"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"constant": true,
|
|
115
|
+
"inputs": [],
|
|
116
|
+
"name": "symbol",
|
|
117
|
+
"outputs": [
|
|
118
|
+
{
|
|
119
|
+
"name": "",
|
|
120
|
+
"type": "string"
|
|
121
|
+
}
|
|
122
|
+
],
|
|
123
|
+
"payable": false,
|
|
124
|
+
"stateMutability": "view",
|
|
125
|
+
"type": "function"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"constant": false,
|
|
129
|
+
"inputs": [
|
|
130
|
+
{
|
|
131
|
+
"name": "_to",
|
|
132
|
+
"type": "address"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"name": "_value",
|
|
136
|
+
"type": "uint256"
|
|
137
|
+
}
|
|
138
|
+
],
|
|
139
|
+
"name": "transfer",
|
|
140
|
+
"outputs": [
|
|
141
|
+
{
|
|
142
|
+
"name": "",
|
|
143
|
+
"type": "bool"
|
|
144
|
+
}
|
|
145
|
+
],
|
|
146
|
+
"payable": false,
|
|
147
|
+
"stateMutability": "nonpayable",
|
|
148
|
+
"type": "function"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"constant": true,
|
|
152
|
+
"inputs": [
|
|
153
|
+
{
|
|
154
|
+
"name": "_owner",
|
|
155
|
+
"type": "address"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"name": "_spender",
|
|
159
|
+
"type": "address"
|
|
160
|
+
}
|
|
161
|
+
],
|
|
162
|
+
"name": "allowance",
|
|
163
|
+
"outputs": [
|
|
164
|
+
{
|
|
165
|
+
"name": "",
|
|
166
|
+
"type": "uint256"
|
|
167
|
+
}
|
|
168
|
+
],
|
|
169
|
+
"payable": false,
|
|
170
|
+
"stateMutability": "view",
|
|
171
|
+
"type": "function"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"payable": true,
|
|
175
|
+
"stateMutability": "payable",
|
|
176
|
+
"type": "fallback"
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
"anonymous": false,
|
|
180
|
+
"inputs": [
|
|
181
|
+
{
|
|
182
|
+
"indexed": true,
|
|
183
|
+
"name": "owner",
|
|
184
|
+
"type": "address"
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
"indexed": true,
|
|
188
|
+
"name": "spender",
|
|
189
|
+
"type": "address"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"indexed": false,
|
|
193
|
+
"name": "value",
|
|
194
|
+
"type": "uint256"
|
|
195
|
+
}
|
|
196
|
+
],
|
|
197
|
+
"name": "Approval",
|
|
198
|
+
"type": "event"
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
"anonymous": false,
|
|
202
|
+
"inputs": [
|
|
203
|
+
{
|
|
204
|
+
"indexed": true,
|
|
205
|
+
"name": "from",
|
|
206
|
+
"type": "address"
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
"indexed": true,
|
|
210
|
+
"name": "to",
|
|
211
|
+
"type": "address"
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
"indexed": false,
|
|
215
|
+
"name": "value",
|
|
216
|
+
"type": "uint256"
|
|
217
|
+
}
|
|
218
|
+
],
|
|
219
|
+
"name": "Transfer",
|
|
220
|
+
"type": "event"
|
|
221
|
+
}
|
|
222
|
+
]
|