@lombard.finance/sdk-solana 1.2.2 → 2.0.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.
Files changed (61) hide show
  1. package/README.md +48 -15
  2. package/dist/index.cjs +1 -1
  3. package/dist/index.js +37 -31
  4. package/dist/index2.cjs +57 -54
  5. package/dist/index2.js +7608 -7206
  6. package/package.json +2 -2
  7. package/src/const/errors.ts +0 -4
  8. package/src/const/getConfig.ts +43 -20
  9. package/src/const/rpcUrls.ts +2 -2
  10. package/src/idl/asset_router.json +548 -179
  11. package/src/idl/consortium.json +24 -43
  12. package/src/idl/mailbox.json +118 -107
  13. package/src/index.ts +1 -3
  14. package/src/services/SolanaServiceImpl.test.ts +123 -0
  15. package/src/services/SolanaServiceImpl.ts +53 -17
  16. package/src/stories/components/OutputSelector/OutputSelector.tsx +1 -0
  17. package/src/types/errors.ts +2 -0
  18. package/src/utils/createDebugLogger.ts +6 -13
  19. package/src/utils/errors.ts +2 -0
  20. package/src/utils/tokenAccount.ts +3 -1
  21. package/src/utils/transactions.ts +1 -1
  22. package/src/web3Sdk/claimToken/claimBtcb.ts +37 -28
  23. package/src/web3Sdk/claimToken/claimLbtcGmp.ts +66 -8
  24. package/src/web3Sdk/claimToken/claimToken.stories.tsx +2 -2
  25. package/src/web3Sdk/claimToken/claimToken.ts +20 -16
  26. package/src/web3Sdk/claimToken/constants.ts +5 -0
  27. package/src/web3Sdk/claimToken/index.ts +1 -0
  28. package/src/web3Sdk/claimToken/shared.ts +88 -80
  29. package/src/web3Sdk/deposit/deposit.stories.tsx +240 -0
  30. package/src/web3Sdk/deposit/deposit.test.ts +327 -0
  31. package/src/web3Sdk/deposit/deposit.ts +339 -0
  32. package/src/web3Sdk/deposit/index.ts +1 -0
  33. package/src/web3Sdk/getTokenFeeConfig/getTokenFeeConfig.stories.tsx +166 -0
  34. package/src/web3Sdk/getTokenFeeConfig/getTokenFeeConfig.test.ts +224 -0
  35. package/src/web3Sdk/getTokenFeeConfig/getTokenFeeConfig.ts +154 -0
  36. package/src/web3Sdk/getTokenFeeConfig/index.ts +11 -0
  37. package/src/web3Sdk/index.ts +3 -4
  38. package/src/web3Sdk/redeem/index.ts +1 -0
  39. package/src/web3Sdk/redeem/redeem.stories.tsx +226 -0
  40. package/src/web3Sdk/redeem/redeem.test.ts +327 -0
  41. package/src/web3Sdk/redeem/redeem.ts +352 -0
  42. package/src/web3Sdk/redeemToken/redeemBtcb.ts +174 -0
  43. package/src/web3Sdk/redeemToken/redeemForBtc.stories.tsx +35 -21
  44. package/src/web3Sdk/redeemToken/redeemForBtc.test.ts +306 -0
  45. package/src/web3Sdk/redeemToken/redeemForBtc.ts +54 -215
  46. package/src/web3Sdk/redeemToken/redeemLbtc.ts +174 -0
  47. package/src/web3Sdk/redeemToken/shared.test.ts +45 -0
  48. package/src/web3Sdk/redeemToken/shared.ts +97 -0
  49. package/src/web3Sdk/claimLBTC/claimLBTC.stories.tsx +0 -189
  50. package/src/web3Sdk/claimLBTC/claimLBTC.ts +0 -225
  51. package/src/web3Sdk/claimLBTC/index.ts +0 -1
  52. package/src/web3Sdk/claimLBTC/utils/generateDepositId.ts +0 -75
  53. package/src/web3Sdk/claimLBTC/utils/index.ts +0 -2
  54. package/src/web3Sdk/claimLBTC/utils/parseTransactionLogs.ts +0 -44
  55. package/src/web3Sdk/claimLBTC/utils/payloadUtils.ts +0 -58
  56. package/src/web3Sdk/claimLBTC/utils/postMintSignatures.ts +0 -50
  57. package/src/web3Sdk/unstakeLBTC/index.ts +0 -1
  58. package/src/web3Sdk/unstakeLBTC/unstakeLBTC.stories.tsx +0 -141
  59. package/src/web3Sdk/unstakeLBTC/unstakeLBTC.ts +0 -140
  60. /package/src/web3Sdk/{claimLBTC → claimToken}/utils/__tests__/signatureUtils.test.ts +0 -0
  61. /package/src/web3Sdk/{claimLBTC → claimToken}/utils/signatureUtils.ts +0 -0
package/README.md CHANGED
@@ -113,31 +113,64 @@ const depositAddress = await generateDepositBtcAddress({
113
113
 
114
114
  ```
115
115
 
116
- ### Claiming LBTC
116
+ ### Claiming tokens (Asset Router)
117
117
 
118
- This operation mints the deposited amount of BTC into LBTC and transfers that
119
- to the provided recipient address.
118
+ Mints BTC.b or LBTC on Solana from a notarized deposit payload using the
119
+ Asset Router program. Replaces the previous `claimLBTC` helper.
120
120
 
121
- ```javascript
122
- const txHash = await claimLBTC(provider, {
121
+ ```typescript
122
+ import { claimToken } from '@lombard.finance/sdk-solana';
123
+
124
+ const txHash = await claimToken(provider, {
123
125
  recipientAddress: address,
124
- amount: '10000',
126
+ tokenMint: getConfig(Env.prod).btcbTokenMint, // or lbtcTokenMint
125
127
  network: 'mainnet-beta',
126
- // The signatures (obtained from `getDepositsByAddress`)
128
+ // Obtained from `getDepositsByAddress`
127
129
  proofSignature: selectedOutput.proof,
128
130
  rawPayload: selectedOutput.raw_payload,
129
131
  });
130
132
  ```
131
133
 
132
- ### Unstaking LBTC
134
+ ### Redeeming tokens for BTC (Asset Router)
133
135
 
134
- This operation burns given amount of LBTC and initiates transfer of BTC to the
135
- given BTC address.
136
+ Burns BTC.b or LBTC on Solana and sends a GMP message through the Mailbox to
137
+ trigger a BTC payout to the specified Bitcoin address.
136
138
 
137
- ```javascript
138
- const txHash = await unstakeLBTC(provider, {
139
- amount: '10000',
140
- btcAddress,
141
- network: 'mainnet-beta',
139
+ ```typescript
140
+ import { redeemForBtc } from '@lombard.finance/sdk-solana';
141
+
142
+ // BTC.b → BTC (default)
143
+ const { signature } = await redeemForBtc(provider, {
144
+ amount: '2000',
145
+ btcAddress: 'bc1q...',
146
+ network: 'devnet',
147
+ env: 'stage',
148
+ });
149
+
150
+ // LBTC → BTC (pass LBTC mint)
151
+ const { signature } = await redeemForBtc(provider, {
152
+ amount: '2000',
153
+ btcAddress: 'bc1q...',
154
+ tokenMint: 'LBTCojyVJ63rsEED2DLEGWMzSxWJyQynXE91LMLgV1J',
155
+ network: 'devnet',
156
+ env: 'stage',
142
157
  });
143
158
  ```
159
+
160
+ ### Redeeming LBTC for BTC.b (Asset Router)
161
+
162
+ Burns LBTC and sends a GMP message to route BTC.b to the recipient on Solana.
163
+
164
+ ```typescript
165
+ import { redeem } from '@lombard.finance/sdk-solana';
166
+
167
+ const txHash = await redeem(provider, {
168
+ amount: '2000',
169
+ recipient: '8yarEiDaJVik7n6wX8JCbubTbtZD3WZ67Q1ytMDA2BKA',
170
+ network: 'devnet',
171
+ env: 'dev',
172
+ });
173
+ ```
174
+
175
+ Optional overrides: `tokenMint` (source token), `toTokenAddress` (destination
176
+ token), `toLchainId` (destination chain). All default to LBTC → BTC.b on Solana.
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index2.cjs");exports.ALREADY_MINTED_TX_HASH=e.ALREADY_MINTED_TX_HASH;exports.BFF_BASE_URL_PROD=e.BFF_BASE_URL_PROD;exports.BFF_BASE_URL_STAGE=e.BFF_BASE_URL_STAGE;exports.BFF_WS_URL_PROD=e.BFF_WS_URL_PROD;exports.BFF_WS_URL_STAGE=e.BFF_WS_URL_STAGE;exports.DEFAULT_COMMITMENT=e.DEFAULT_COMMITMENT;exports.DEFAULT_NETWORK=e.DEFAULT_NETWORK;exports.INVALID_ADDRESS_ERROR=e.INVALID_ADDRESS_ERROR;exports.InjectedWallet=e.InjectedWallet;exports.RPC_URLS=e.RPC_URLS;exports.SolanaNetwork=e.SolanaNetwork;exports.WS_URLS=e.WS_URLS;exports.claimLBTC=e.claimLBTC;exports.claimToken=e.claimToken;exports.getBalance=e.getBalance;exports.getConfig=e.getConfig;exports.getConnection=e.getConnection;exports.getLBTCAddress=e.getLBTCAddress;exports.getLBTCProgramAddress=e.getLBTCProgramAddress;exports.getOftAmountCanBeSent=e.getOftAmountCanBeSent;exports.getRpcUrl=e.getRpcUrl;exports.getSolanaWalletProvider=e.getSolanaWalletProvider;exports.getUnifiedChainId=e.getUnifiedChainId;exports.isWalletAvailable=e.isWalletAvailable;exports.loadBridgeFunctions=e.loadBridgeFunctions;exports.parseOFTRecipient=e.parseOFTRecipient;exports.redeemForBtc=e.redeemForBtc;exports.signLbtcDestinationAddrSolana=e.signLbtcDestinationAddrSolana;exports.signMessage=e.signMessage;exports.signTermsOfService=e.signTermsOfService;exports.solanaModule=e.solanaModule;exports.unstakeLBTC=e.unstakeLBTC;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index2.cjs");exports.ALREADY_MINTED_TX_HASH=e.ALREADY_MINTED_TX_HASH;exports.BFF_BASE_URL_PROD=e.BFF_BASE_URL_PROD;exports.BFF_BASE_URL_STAGE=e.BFF_BASE_URL_STAGE;exports.BFF_WS_URL_PROD=e.BFF_WS_URL_PROD;exports.BFF_WS_URL_STAGE=e.BFF_WS_URL_STAGE;exports.DEFAULT_COMMITMENT=e.DEFAULT_COMMITMENT;exports.DEFAULT_NETWORK=e.DEFAULT_NETWORK;exports.INVALID_ADDRESS_ERROR=e.INVALID_ADDRESS_ERROR;exports.InjectedWallet=e.InjectedWallet;exports.RPC_URLS=e.RPC_URLS;exports.SolanaNetwork=e.SolanaNetwork;exports.WS_URLS=e.WS_URLS;exports.claimToken=e.claimToken;exports.deposit=e.deposit;exports.getBTCBAddress=e.getBTCBAddress;exports.getBalance=e.getBalance;exports.getConfig=e.getConfig;exports.getConnection=e.getConnection;exports.getLBTCAddress=e.getLBTCAddress;exports.getLBTCProgramAddress=e.getLBTCProgramAddress;exports.getMinRedeemAmountSolana=e.getMinRedeemAmountSolana;exports.getMinRedeemAmountWithFeeSolana=e.getMinRedeemAmountWithFeeSolana;exports.getMintingFeeSolana=e.getMintingFeeSolana;exports.getOftAmountCanBeSent=e.getOftAmountCanBeSent;exports.getRedeemFeeSolana=e.getRedeemFeeSolana;exports.getRpcUrl=e.getRpcUrl;exports.getSolanaWalletProvider=e.getSolanaWalletProvider;exports.getTokenFeeConfig=e.getTokenFeeConfig;exports.getUnifiedChainId=e.getUnifiedChainId;exports.isWalletAvailable=e.isWalletAvailable;exports.loadBridgeFunctions=e.loadBridgeFunctions;exports.parseOFTRecipient=e.parseOFTRecipient;exports.redeem=e.redeem;exports.redeemForBtc=e.redeemForBtc;exports.signLbtcDestinationAddrSolana=e.signLbtcDestinationAddrSolana;exports.signMessage=e.signMessage;exports.signTermsOfService=e.signTermsOfService;exports.solanaModule=e.solanaModule;
package/dist/index.js CHANGED
@@ -1,35 +1,41 @@
1
- import { A as e, x as t, y as n, z as _, D as i, E as o, F as l, I as R, G as S, R as r, S as A, W as g, H as L, J as T, K as d, k as B, c as F, d as E, L as c, M as D, N as C, O as U, Q as O, X as W, Y as m, Z as I, _ as M, $ as N, a0 as f, a1 as P, a2 as k, a3 as p } from "./index2.js";
1
+ import { A as s, x as n, y as t, z as o, D as i, E as g, F as d, I as S, G as _, R as l, S as R, W as A, H as r, J as F, K as T, L as B, k as L, c as E, d as m, M as c, N as D, O as C, Q as M, X as U, Y as O, Z as W, _ as I, $ as f, a0 as N, a1 as p, a2 as u, a3 as P, a4 as k, a5 as v, a6 as G, a7 as H, a8 as b, a9 as h } from "./index2.js";
2
2
  export {
3
- e as ALREADY_MINTED_TX_HASH,
4
- t as BFF_BASE_URL_PROD,
5
- n as BFF_BASE_URL_STAGE,
6
- _ as BFF_WS_URL_PROD,
3
+ s as ALREADY_MINTED_TX_HASH,
4
+ n as BFF_BASE_URL_PROD,
5
+ t as BFF_BASE_URL_STAGE,
6
+ o as BFF_WS_URL_PROD,
7
7
  i as BFF_WS_URL_STAGE,
8
- o as DEFAULT_COMMITMENT,
9
- l as DEFAULT_NETWORK,
10
- R as INVALID_ADDRESS_ERROR,
11
- S as InjectedWallet,
12
- r as RPC_URLS,
13
- A as SolanaNetwork,
14
- g as WS_URLS,
15
- L as claimLBTC,
16
- T as claimToken,
17
- d as getBalance,
18
- B as getConfig,
19
- F as getConnection,
20
- E as getLBTCAddress,
8
+ g as DEFAULT_COMMITMENT,
9
+ d as DEFAULT_NETWORK,
10
+ S as INVALID_ADDRESS_ERROR,
11
+ _ as InjectedWallet,
12
+ l as RPC_URLS,
13
+ R as SolanaNetwork,
14
+ A as WS_URLS,
15
+ r as claimToken,
16
+ F as deposit,
17
+ T as getBTCBAddress,
18
+ B as getBalance,
19
+ L as getConfig,
20
+ E as getConnection,
21
+ m as getLBTCAddress,
21
22
  c as getLBTCProgramAddress,
22
- D as getOftAmountCanBeSent,
23
- C as getRpcUrl,
24
- U as getSolanaWalletProvider,
25
- O as getUnifiedChainId,
26
- W as isWalletAvailable,
27
- m as loadBridgeFunctions,
28
- I as parseOFTRecipient,
29
- M as redeemForBtc,
30
- N as signLbtcDestinationAddrSolana,
31
- f as signMessage,
32
- P as signTermsOfService,
33
- k as solanaModule,
34
- p as unstakeLBTC
23
+ D as getMinRedeemAmountSolana,
24
+ C as getMinRedeemAmountWithFeeSolana,
25
+ M as getMintingFeeSolana,
26
+ U as getOftAmountCanBeSent,
27
+ O as getRedeemFeeSolana,
28
+ W as getRpcUrl,
29
+ I as getSolanaWalletProvider,
30
+ f as getTokenFeeConfig,
31
+ N as getUnifiedChainId,
32
+ p as isWalletAvailable,
33
+ u as loadBridgeFunctions,
34
+ P as parseOFTRecipient,
35
+ k as redeem,
36
+ v as redeemForBtc,
37
+ G as signLbtcDestinationAddrSolana,
38
+ H as signMessage,
39
+ b as signTermsOfService,
40
+ h as solanaModule
35
41
  };