@lombard.finance/sdk-starknet 0.3.0-canary.0.4
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/LICENSE +21 -0
- package/README.md +128 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/index2.cjs +229 -0
- package/dist/index2.cjs.map +1 -0
- package/dist/index2.js +30378 -0
- package/dist/index2.js.map +1 -0
- package/dist/index3.cjs +2 -0
- package/dist/index3.cjs.map +1 -0
- package/dist/index3.js +2316 -0
- package/dist/index3.js.map +1 -0
- package/package.json +88 -0
- package/src/contract-functions/approve.stories.tsx +74 -0
- package/src/contract-functions/approve.ts +56 -0
- package/src/contract-functions/balance-of.stories.tsx +54 -0
- package/src/contract-functions/balance-of.ts +41 -0
- package/src/contract-functions/mint.ts +109 -0
- package/src/contract-functions/redeem.ts +107 -0
- package/src/index.ts +25 -0
- package/src/module/createStarknetModule.ts +38 -0
- package/src/services/StarknetServiceImpl.ts +83 -0
- package/src/services/index.ts +7 -0
- package/src/stories/components/Button/Button.css +10 -0
- package/src/stories/components/Button/Button.tsx +52 -0
- package/src/stories/components/Button/index.ts +1 -0
- package/src/stories/components/CodeBlock/CodeBlock.tsx +38 -0
- package/src/stories/components/CodeBlock/CodeBlockStyles.css +3 -0
- package/src/stories/components/CodeBlock/index.ts +1 -0
- package/src/stories/components/ConnectButton/connect-button.tsx +112 -0
- package/src/stories/components/ConnectButton/index.ts +1 -0
- package/src/stories/components/Spinner/Spinner.tsx +24 -0
- package/src/stories/components/Spinner/index.ts +1 -0
- package/src/stories/components/decorators/function-type.tsx +66 -0
- package/src/stories/components/decorators/index.ts +1 -0
- package/src/stories/components/decorators/starknet-context.tsx +21 -0
- package/src/stories/components/error-block.tsx +21 -0
- package/src/stories/hooks/use-connection.ts +70 -0
- package/src/stories/hooks/use-query.ts +56 -0
- package/src/tokens/abi/ERC20_ABI.ts +1122 -0
- package/src/tokens/abi/LBTC_ABI.ts +1615 -0
- package/src/tokens/abi/LBTC_BASCULE_ABI.ts +709 -0
- package/src/tokens/abi/LBTC_BRIDGE_ABI.ts +1568 -0
- package/src/tokens/lib/tokens.ts +267 -0
- package/src/utils/account.ts +81 -0
- package/src/utils/chains.ts +33 -0
- package/src/utils/common.ts +11 -0
- package/src/utils/env.ts +6 -0
- package/src/utils/err.ts +121 -0
- package/src/utils/rpc-providers.ts +25 -0
- package/src/utils/signature.ts +60 -0
- package/src/utils/span.ts +56 -0
- package/src/utils/typed-data.ts +36 -0
- package/src/utils/wallet-account.ts +9 -0
- package/src/wallet-functions/sign-message.stories.tsx +72 -0
- package/src/wallet-functions/sign-message.ts +127 -0
- package/src/wallet-functions/sign-terms-of-service.ts +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2026 Lombard Finance
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# @lombard.finance/sdk-starknet
|
|
2
|
+
|
|
3
|
+
The Lombard's Starknet SDK package provides a set of functions that allow interacting with the Lombard protocol and its features.
|
|
4
|
+
|
|
5
|
+
Read more about Lombard's mission: https://www.lombard.finance
|
|
6
|
+
|
|
7
|
+
**⚠️ THIS PACKAGE IS EXPERIMENTAL USE AT YOUR OWN RISK!**
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
### Installing per dependencies
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
npm install @noble/hashes@^1.7.2 axios@^1 bignumber.js@^9
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Installing SDK
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
npm install @lombard.finance/sdk-common@^3.3.0 @lombard.finance/sdk@^3.6.0 @lombard.finance/sdk-starknet
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
### Getting or generating the BTC deposit address
|
|
26
|
+
|
|
27
|
+
```javascript
|
|
28
|
+
import {
|
|
29
|
+
Env,
|
|
30
|
+
generateDepositBtcAddress,
|
|
31
|
+
getDepositBtcAddress,
|
|
32
|
+
} from '@lombard.finance/sdk';
|
|
33
|
+
import { signLbtcDestinationAddrStarknet } from '@lombard.finance/sdk-starknet';
|
|
34
|
+
|
|
35
|
+
let depositAddress = await getDepositBtcAddress({
|
|
36
|
+
address: walletAccount.address, // connected wallet address,
|
|
37
|
+
chainId: StarknetChainId.SN_SEPOLIA, // the chain identifier, other available options are: StarknetChainId.SN_MAIN
|
|
38
|
+
env: Env.stage, // the environment, use Env.stage for StarknetChainId.SN_SEPOLIA testing,
|
|
39
|
+
partnerId: ENV_PARTNER_ID, // your partner id
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
if (!depositAddress) {
|
|
43
|
+
// Step 1: sign destination address
|
|
44
|
+
const sig = await signLbtcDestinationAddrStarknet({
|
|
45
|
+
walletAccount: walletAccount, // connected wallet account
|
|
46
|
+
chainId: StarknetChainId.SN_SEPOLIA, // the chain identifier, other available options are: StarknetChainId.SN_MAIN
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// Step 2: generate address
|
|
50
|
+
depositAddress = await generateDepositBtcAddress({
|
|
51
|
+
address: walletAccount.address, // connected wallet address,
|
|
52
|
+
chainId: StarknetChainId.SN_SEPOLIA, // the chain identifier, other available options are: StarknetChainId.SN_MAIN
|
|
53
|
+
signature: sig.signatureHex, // the signature hex from step 1
|
|
54
|
+
pubKey: sig.pubKey, // the pubkey from step 1
|
|
55
|
+
env: Env.stage, // the environment, use Env.stage for StarknetChainId.SN_SEPOLIA testing,
|
|
56
|
+
partnerId: ENV_PARTNER_ID, // your partner id
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Deposit status
|
|
62
|
+
|
|
63
|
+
```javascript
|
|
64
|
+
import { getDepositsByAddress } from '@lombard.finance/sdk';
|
|
65
|
+
|
|
66
|
+
const deposits = await getDepositsByAddress({
|
|
67
|
+
address: walletAccount.address, // connected wallet address,
|
|
68
|
+
env: Env.stage, // the environment, use Env.stage for StarknetChainId.SN_SEPOLIA testing,
|
|
69
|
+
});
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The above results with an array of:
|
|
73
|
+
|
|
74
|
+
- `txid: string;` - The BTC transaction id,
|
|
75
|
+
- `index?: number;` - The index of the BTC transaction,
|
|
76
|
+
- `value: BigNumber;` - The deposit amount,
|
|
77
|
+
- `address: Address;` - The source address,
|
|
78
|
+
- `chainId: ChainId | SuiChain | SolanaChain | StarknetChain;` -
|
|
79
|
+
- `isClaimed?: boolean;` - A flag determining whether the particular deposit has been claimed,
|
|
80
|
+
- `claimedTxId?: string;` - The claimed transaction id,
|
|
81
|
+
- `rawPayload?: string;` - The raw deposit payload,
|
|
82
|
+
- `signature?: string;` - The deposit signature,
|
|
83
|
+
- `notarizationWaitDur?: Seconds;` - Approx. number of seconds until notarization completed,
|
|
84
|
+
- `payload?: string;` - The deposit payload,
|
|
85
|
+
- `notarizationStatus: ENotarizationStatus;` - The notarization status.
|
|
86
|
+
|
|
87
|
+
### Minting LBTC
|
|
88
|
+
|
|
89
|
+
```javascript
|
|
90
|
+
import { mint, Token } from '@lombard.finance/sdk-starknet';
|
|
91
|
+
|
|
92
|
+
const mintParams = {
|
|
93
|
+
amount: d.value, // The deposit amount
|
|
94
|
+
depositIndex: d.index, // The index of the BTC transaction
|
|
95
|
+
depositPayload: d.rawPayload, // The raw deposit payload
|
|
96
|
+
depositProofSignature: d.signature, // The deposit signature
|
|
97
|
+
depositTxId: d.txid, // The BTC transaction id
|
|
98
|
+
token: Token.LBTC, // The token identifier
|
|
99
|
+
walletAccount: walletAccount, // connected wallet account
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const txHash = await mint(mintParams);
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Checking the balance of LBTC
|
|
106
|
+
|
|
107
|
+
```javascript
|
|
108
|
+
import { balanceOf, Token, StarknetChain } from '@lombard.finance/sdk-starknet';
|
|
109
|
+
|
|
110
|
+
const tokenBalance = await balanceOf({
|
|
111
|
+
account: walletAccount, // an instance of the WalletAccount class
|
|
112
|
+
token: Token.LBTC, // the token identifier, other available tokens are: Token.ETH and Token.STRK
|
|
113
|
+
chainId: StarknetChainId.SN_SEPOLIA, // the chain identifier, other available options are: StarknetChainId.SN_MAIN
|
|
114
|
+
});
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Redeeming LBTC
|
|
118
|
+
|
|
119
|
+
```javascript
|
|
120
|
+
import { redeem, Token } from '@lombard.finance/sdk-starknet';
|
|
121
|
+
|
|
122
|
+
const txHash = await redeem({
|
|
123
|
+
amount: amount, // amount to be redeemed, e.g. `BigNumber(0.02)`
|
|
124
|
+
btcAddress: btcAddress, // the BTC destination address
|
|
125
|
+
token: Token.LBTC, // The token identifier
|
|
126
|
+
walletAccount: walletAccount, // connected wallet account
|
|
127
|
+
});
|
|
128
|
+
```
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index2.cjs");exports.SIGN_MESSAGE_TYPED_DATA=e.SIGN_MESSAGE_TYPED_DATA;exports.StarknetChain=e.StarknetChain;exports.StarknetChainId=e.StarknetChainId;exports.Token=e.Token;exports.approve=e.approve;exports.balanceOf=e.balanceOf;exports.getRpcProvider=e.getRpcProvider;exports.getTokenContract=e.getTokenContract;exports.getTokenInfo=e.getTokenInfo;exports.makeDestinationChainId=e.makeDestinationChainId;exports.mint=e.mint;exports.redeem=e.redeem;exports.signLbtcDestinationAddrStarknet=e.signLbtcDestinationAddrStarknet;exports.signMessage=e.signMessage;exports.signTermsOfService=e.signTermsOfService;exports.starknetModule=e.starknetModule;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { S as s, b as n, c as t, T as i, d as r, e as o, f as k, h as d, i as S, m as g, j as T, k as c, s as m, l as f, n as h, o as p } from "./index2.js";
|
|
2
|
+
export {
|
|
3
|
+
s as SIGN_MESSAGE_TYPED_DATA,
|
|
4
|
+
n as StarknetChain,
|
|
5
|
+
t as StarknetChainId,
|
|
6
|
+
i as Token,
|
|
7
|
+
r as approve,
|
|
8
|
+
o as balanceOf,
|
|
9
|
+
k as getRpcProvider,
|
|
10
|
+
d as getTokenContract,
|
|
11
|
+
S as getTokenInfo,
|
|
12
|
+
g as makeDestinationChainId,
|
|
13
|
+
T as mint,
|
|
14
|
+
c as redeem,
|
|
15
|
+
m as signLbtcDestinationAddrStarknet,
|
|
16
|
+
f as signMessage,
|
|
17
|
+
h as signTermsOfService,
|
|
18
|
+
p as starknetModule
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|