@hot-labs/kit 1.2.0-alpha.1 → 1.2.0-alpha.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.
Files changed (250) hide show
  1. package/build/HotConnector.d.ts +104 -0
  2. package/build/HotConnector.js +306 -0
  3. package/build/HotConnector.js.map +1 -0
  4. package/build/OmniConnector.d.ts +85 -0
  5. package/build/OmniConnector.js +121 -0
  6. package/build/OmniConnector.js.map +1 -0
  7. package/build/OmniWallet.d.ts +42 -0
  8. package/build/OmniWallet.js +61 -0
  9. package/build/OmniWallet.js.map +1 -0
  10. package/build/activity.d.ts +18 -0
  11. package/build/activity.js +87 -0
  12. package/build/activity.js.map +1 -0
  13. package/build/core/Intents.d.ts +90 -0
  14. package/build/core/Intents.js +398 -0
  15. package/build/core/Intents.js.map +1 -0
  16. package/build/core/api.d.ts +32 -0
  17. package/build/core/api.js +75 -0
  18. package/build/core/api.js.map +1 -0
  19. package/build/core/bridge.d.ts +3 -0
  20. package/build/core/bridge.js +36 -0
  21. package/build/core/bridge.js.map +1 -0
  22. package/build/core/chains.d.ts +115 -0
  23. package/build/core/chains.js +381 -0
  24. package/build/core/chains.js.map +1 -0
  25. package/build/core/defaultTokens.d.ts +17 -0
  26. package/build/core/defaultTokens.js +1079 -0
  27. package/build/core/defaultTokens.js.map +1 -0
  28. package/build/core/events.d.ts +42 -0
  29. package/build/core/events.js +64 -0
  30. package/build/core/events.js.map +1 -0
  31. package/build/core/index.d.ts +10 -0
  32. package/build/core/index.js +11 -0
  33. package/build/core/index.js.map +1 -0
  34. package/build/core/nearRpc.d.ts +24 -0
  35. package/build/core/nearRpc.js +167 -0
  36. package/build/core/nearRpc.js.map +1 -0
  37. package/build/core/recipient.d.ts +10 -0
  38. package/build/core/recipient.js +40 -0
  39. package/build/core/recipient.js.map +1 -0
  40. package/build/core/token.d.ts +36 -0
  41. package/build/core/token.js +103 -0
  42. package/build/core/token.js.map +1 -0
  43. package/build/core/tokens.d.ts +14 -0
  44. package/build/core/tokens.js +59 -0
  45. package/build/core/tokens.js.map +1 -0
  46. package/build/core/types.d.ts +43 -0
  47. package/build/core/types.js +2 -0
  48. package/build/core/types.js.map +1 -0
  49. package/build/core/utils.d.ts +24 -0
  50. package/build/core/utils.js +150 -0
  51. package/build/core/utils.js.map +1 -0
  52. package/build/cosmos/connector.d.ts +36 -0
  53. package/build/cosmos/connector.js +215 -0
  54. package/build/cosmos/connector.js.map +1 -0
  55. package/build/cosmos/helpers.d.ts +2 -0
  56. package/build/cosmos/helpers.js +29 -0
  57. package/build/cosmos/helpers.js.map +1 -0
  58. package/build/cosmos/index.d.ts +6 -0
  59. package/build/cosmos/index.js +5 -0
  60. package/build/cosmos/index.js.map +1 -0
  61. package/build/cosmos/wallet.d.ts +28 -0
  62. package/build/cosmos/wallet.js +56 -0
  63. package/build/cosmos/wallet.js.map +1 -0
  64. package/build/defaults.d.ts +1 -0
  65. package/build/defaults.js +7 -0
  66. package/build/defaults.js.map +1 -0
  67. package/build/evm/abi.d.ts +17 -0
  68. package/build/evm/abi.js +38 -0
  69. package/build/evm/abi.js.map +1 -0
  70. package/build/evm/connector.d.ts +28 -0
  71. package/build/evm/connector.js +114 -0
  72. package/build/evm/connector.js.map +1 -0
  73. package/build/evm/index.d.ts +6 -0
  74. package/build/evm/index.js +5 -0
  75. package/build/evm/index.js.map +1 -0
  76. package/build/evm/injected.d.ts +1 -0
  77. package/build/evm/injected.js +33 -0
  78. package/build/evm/injected.js.map +1 -0
  79. package/build/evm/wallet.d.ts +41 -0
  80. package/build/evm/wallet.js +128 -0
  81. package/build/evm/wallet.js.map +1 -0
  82. package/build/exchange.d.ts +65 -0
  83. package/build/exchange.js +390 -0
  84. package/build/exchange.js.map +1 -0
  85. package/build/hot-wallet/google.d.ts +25 -0
  86. package/build/hot-wallet/google.js +112 -0
  87. package/build/hot-wallet/google.js.map +1 -0
  88. package/build/hot-wallet/iframe.d.ts +36 -0
  89. package/build/hot-wallet/iframe.js +140 -0
  90. package/build/hot-wallet/iframe.js.map +1 -0
  91. package/build/hot-wallet/index.d.ts +5 -0
  92. package/build/hot-wallet/index.js +4 -0
  93. package/build/hot-wallet/index.js.map +1 -0
  94. package/build/hot-wallet/proxy.d.ts +8 -0
  95. package/build/hot-wallet/proxy.js +45 -0
  96. package/build/hot-wallet/proxy.js.map +1 -0
  97. package/build/index.d.ts +5 -0
  98. package/build/index.js +6 -0
  99. package/build/index.js.map +1 -0
  100. package/build/near/connector.d.ts +18 -0
  101. package/build/near/connector.js +58 -0
  102. package/build/near/connector.js.map +1 -0
  103. package/build/near/index.d.ts +7 -0
  104. package/build/near/index.js +5 -0
  105. package/build/near/index.js.map +1 -0
  106. package/build/near/wallet.d.ts +55 -0
  107. package/build/near/wallet.js +195 -0
  108. package/build/near/wallet.js.map +1 -0
  109. package/build/solana/connector.d.ts +30 -0
  110. package/build/solana/connector.js +138 -0
  111. package/build/solana/connector.js.map +1 -0
  112. package/build/solana/index.d.ts +6 -0
  113. package/build/solana/index.js +5 -0
  114. package/build/solana/index.js.map +1 -0
  115. package/build/solana/injected/account.d.ts +11 -0
  116. package/build/solana/injected/account.js +41 -0
  117. package/build/solana/injected/account.js.map +1 -0
  118. package/build/solana/injected/index.d.ts +1 -0
  119. package/build/solana/injected/index.js +82 -0
  120. package/build/solana/injected/index.js.map +1 -0
  121. package/build/solana/injected/register.d.ts +2 -0
  122. package/build/solana/injected/register.js +41 -0
  123. package/build/solana/injected/register.js.map +1 -0
  124. package/build/solana/injected/solana-wallet.d.ts +34 -0
  125. package/build/solana/injected/solana-wallet.js +223 -0
  126. package/build/solana/injected/solana-wallet.js.map +1 -0
  127. package/build/solana/injected/utils.d.ts +32 -0
  128. package/build/solana/injected/utils.js +36 -0
  129. package/build/solana/injected/utils.js.map +1 -0
  130. package/build/solana/protocol.d.ts +25 -0
  131. package/build/solana/protocol.js +56 -0
  132. package/build/solana/protocol.js.map +1 -0
  133. package/build/solana/wallet.d.ts +42 -0
  134. package/build/solana/wallet.js +190 -0
  135. package/build/solana/wallet.js.map +1 -0
  136. package/build/solana/wallets.d.ts +102 -0
  137. package/build/solana/wallets.js +150 -0
  138. package/build/solana/wallets.js.map +1 -0
  139. package/build/stellar/connector.d.ts +31 -0
  140. package/build/stellar/connector.js +67 -0
  141. package/build/stellar/connector.js.map +1 -0
  142. package/build/stellar/freigher.d.ts +46 -0
  143. package/build/stellar/freigher.js +110 -0
  144. package/build/stellar/freigher.js.map +1 -0
  145. package/build/stellar/hotWallet.d.ts +33 -0
  146. package/build/stellar/hotWallet.js +28 -0
  147. package/build/stellar/hotWallet.js.map +1 -0
  148. package/build/stellar/index.d.ts +6 -0
  149. package/build/stellar/index.js +5 -0
  150. package/build/stellar/index.js.map +1 -0
  151. package/build/stellar/wallet.d.ts +65 -0
  152. package/build/stellar/wallet.js +216 -0
  153. package/build/stellar/wallet.js.map +1 -0
  154. package/build/storage.d.ts +10 -0
  155. package/build/storage.js +12 -0
  156. package/build/storage.js.map +1 -0
  157. package/build/ton/connector.d.ts +25 -0
  158. package/build/ton/connector.js +114 -0
  159. package/build/ton/connector.js.map +1 -0
  160. package/build/ton/index.d.ts +7 -0
  161. package/build/ton/index.js +5 -0
  162. package/build/ton/index.js.map +1 -0
  163. package/build/ton/injected.d.ts +1 -0
  164. package/build/ton/injected.js +49 -0
  165. package/build/ton/injected.js.map +1 -0
  166. package/build/ton/utils.d.ts +45 -0
  167. package/build/ton/utils.js +63 -0
  168. package/build/ton/utils.js.map +1 -0
  169. package/build/ton/wallet.d.ts +55 -0
  170. package/build/ton/wallet.js +139 -0
  171. package/build/ton/wallet.js.map +1 -0
  172. package/build/ui/Popup.d.ts +12 -0
  173. package/build/ui/Popup.js +39 -0
  174. package/build/ui/Popup.js.map +1 -0
  175. package/build/ui/connect/AuthPopup.d.ts +2 -0
  176. package/build/ui/connect/AuthPopup.js +48 -0
  177. package/build/ui/connect/AuthPopup.js.map +1 -0
  178. package/build/ui/connect/ConnectWallet.d.ts +9 -0
  179. package/build/ui/connect/ConnectWallet.js +22 -0
  180. package/build/ui/connect/ConnectWallet.js.map +1 -0
  181. package/build/ui/connect/LogoutPopup.d.ts +10 -0
  182. package/build/ui/connect/LogoutPopup.js +8 -0
  183. package/build/ui/connect/LogoutPopup.js.map +1 -0
  184. package/build/ui/connect/WCPopup.d.ts +13 -0
  185. package/build/ui/connect/WCPopup.js +81 -0
  186. package/build/ui/connect/WCPopup.js.map +1 -0
  187. package/build/ui/connect/WCRequest.d.ts +9 -0
  188. package/build/ui/connect/WCRequest.js +13 -0
  189. package/build/ui/connect/WCRequest.js.map +1 -0
  190. package/build/ui/connect/WalletPicker.d.ts +11 -0
  191. package/build/ui/connect/WalletPicker.js +48 -0
  192. package/build/ui/connect/WalletPicker.js.map +1 -0
  193. package/build/ui/icons/arrow-right.d.ts +1 -0
  194. package/build/ui/icons/arrow-right.js +5 -0
  195. package/build/ui/icons/arrow-right.js.map +1 -0
  196. package/build/ui/icons/close.d.ts +1 -0
  197. package/build/ui/icons/close.js +5 -0
  198. package/build/ui/icons/close.js.map +1 -0
  199. package/build/ui/icons/exchange.d.ts +6 -0
  200. package/build/ui/icons/exchange.js +6 -0
  201. package/build/ui/icons/exchange.js.map +1 -0
  202. package/build/ui/icons/logout.d.ts +1 -0
  203. package/build/ui/icons/logout.js +3 -0
  204. package/build/ui/icons/logout.js.map +1 -0
  205. package/build/ui/icons/pending.d.ts +1 -0
  206. package/build/ui/icons/pending.js +5 -0
  207. package/build/ui/icons/pending.js.map +1 -0
  208. package/build/ui/icons/qr.d.ts +1 -0
  209. package/build/ui/icons/qr.js +5 -0
  210. package/build/ui/icons/qr.js.map +1 -0
  211. package/build/ui/icons/search.d.ts +1 -0
  212. package/build/ui/icons/search.js +5 -0
  213. package/build/ui/icons/search.js.map +1 -0
  214. package/build/ui/icons/switch.d.ts +1 -0
  215. package/build/ui/icons/switch.js +5 -0
  216. package/build/ui/icons/switch.js.map +1 -0
  217. package/build/ui/icons/wallet.d.ts +1 -0
  218. package/build/ui/icons/wallet.js +5 -0
  219. package/build/ui/icons/wallet.js.map +1 -0
  220. package/build/ui/payment/Bridge.d.ts +29 -0
  221. package/build/ui/payment/Bridge.js +358 -0
  222. package/build/ui/payment/Bridge.js.map +1 -0
  223. package/build/ui/payment/DepositQR.d.ts +9 -0
  224. package/build/ui/payment/DepositQR.js +56 -0
  225. package/build/ui/payment/DepositQR.js.map +1 -0
  226. package/build/ui/payment/Payment.d.ts +16 -0
  227. package/build/ui/payment/Payment.js +50 -0
  228. package/build/ui/payment/Payment.js.map +1 -0
  229. package/build/ui/payment/Profile.d.ts +8 -0
  230. package/build/ui/payment/Profile.js +110 -0
  231. package/build/ui/payment/Profile.js.map +1 -0
  232. package/build/ui/payment/SelectRecipient.d.ts +14 -0
  233. package/build/ui/payment/SelectRecipient.js +68 -0
  234. package/build/ui/payment/SelectRecipient.js.map +1 -0
  235. package/build/ui/payment/SelectSender.d.ts +13 -0
  236. package/build/ui/payment/SelectSender.js +23 -0
  237. package/build/ui/payment/SelectSender.js.map +1 -0
  238. package/build/ui/payment/SelectToken.d.ts +13 -0
  239. package/build/ui/payment/SelectToken.js +92 -0
  240. package/build/ui/payment/SelectToken.js.map +1 -0
  241. package/build/ui/payment/TokenCard.d.ts +23 -0
  242. package/build/ui/payment/TokenCard.js +63 -0
  243. package/build/ui/payment/TokenCard.js.map +1 -0
  244. package/build/ui/router.d.ts +37 -0
  245. package/build/ui/router.js +56 -0
  246. package/build/ui/router.js.map +1 -0
  247. package/build/ui/styles.d.ts +13 -0
  248. package/build/ui/styles.js +288 -0
  249. package/build/ui/styles.js.map +1 -0
  250. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallets.js","sourceRoot":"","sources":["../../src/solana/wallets.ts"],"names":[],"mappings":"AAEA,IAAI,OAAO,GAAwB,SAAS,CAAC;AAC7C,MAAM,oBAAoB,GAAG,IAAI,GAAG,EAAU,CAAC;AAC/C,SAAS,mBAAmB,CAAC,MAAc;IAC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,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QAC9B,OAAO,CAAC,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAC1D,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAC7B,MAAM,IAAI,GAAG,CAAC,GAAG,SAAuC,EAAQ,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC;IACxI,IAAI,CAAC;QACH,MAAM,CAAC,cAAc,CAAE,MAAmC,CAAC,SAAS,EAAE,SAAS,EAAE;YAC/E,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC;SAC/B,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,2CAA2C,CAAC,CAAC;QAC3D,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,IAAI,CAAC,GAAG,SAAS,CAAC,CAAC;IACnB,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { WalletType } from "../core/chains";
2
+ import { HotConnector } from "../HotConnector";
3
+ import { ConnectorType, OmniConnector } from "../OmniConnector";
4
+ import { OmniWallet } from "../OmniWallet";
5
+ import { FreighterModule } from "./freigher";
6
+ import { HotWalletModule } from "./hotWallet";
7
+ import StellarWallet from "./wallet";
8
+ declare class StellarConnector extends OmniConnector<StellarWallet> {
9
+ icon: string;
10
+ walletTypes: WalletType[];
11
+ type: ConnectorType;
12
+ name: string;
13
+ id: string;
14
+ modules: {
15
+ hotWallet: HotWalletModule;
16
+ freighter: FreighterModule;
17
+ };
18
+ constructor(wibe3: HotConnector);
19
+ getWallet(id: string): FreighterModule | HotWalletModule | null;
20
+ createWallet(address: string): Promise<OmniWallet>;
21
+ getConnectedWallet(): Promise<{
22
+ type?: string;
23
+ id?: string;
24
+ address?: string;
25
+ publicKey?: string;
26
+ }>;
27
+ selectWallet(address: string, wallet: HotWalletModule | FreighterModule): Promise<StellarWallet>;
28
+ connect(id: string): Promise<StellarWallet>;
29
+ disconnect(): Promise<void>;
30
+ }
31
+ export default StellarConnector;
@@ -0,0 +1,67 @@
1
+ import HOT from "../hot-wallet/iframe";
2
+ import { WalletType } from "../core/chains";
3
+ import { ConnectorType, OmniConnector } from "../OmniConnector";
4
+ import { FreighterModule } from "./freigher";
5
+ import { HotWalletModule } from "./hotWallet";
6
+ import StellarWallet from "./wallet";
7
+ class StellarConnector extends OmniConnector {
8
+ icon = "https://storage.herewallet.app/upload/1469894e53ca248ac6adceb2194e6950a13a52d972beb378a20bce7815ba01a4.png";
9
+ walletTypes = [WalletType.STELLAR, WalletType.OMNI];
10
+ type = ConnectorType.WALLET;
11
+ name = "Stellar Wallet";
12
+ id = "stellar";
13
+ modules = {
14
+ hotWallet: new HotWalletModule(),
15
+ freighter: new FreighterModule(),
16
+ };
17
+ constructor(wibe3) {
18
+ super(wibe3);
19
+ this.options = Object.values(this.modules).map((module) => ({
20
+ type: "external",
21
+ name: module.productName,
22
+ icon: module.productIcon,
23
+ download: module.productUrl,
24
+ id: module.productId,
25
+ }));
26
+ this.getConnectedWallet().then(async ({ id, address }) => {
27
+ if (!id || !address)
28
+ return;
29
+ const wallet = this.getWallet(id);
30
+ const isAvailable = await wallet?.isAvailable();
31
+ if (isAvailable && wallet)
32
+ this.selectWallet(address, wallet);
33
+ });
34
+ }
35
+ getWallet(id) {
36
+ return Object.values(this.modules).find((module) => module.productId === id) || null;
37
+ }
38
+ async createWallet(address) {
39
+ return new StellarWallet(this, { address });
40
+ }
41
+ async getConnectedWallet() {
42
+ if (HOT.isInjected) {
43
+ const { address } = await this.modules.hotWallet.getAddress();
44
+ return { type: "wallet", id: this.modules.hotWallet.productId, address };
45
+ }
46
+ return await this.getStorage();
47
+ }
48
+ async selectWallet(address, wallet) {
49
+ const signMessage = async (message) => wallet.signMessage(message);
50
+ const signTransaction = async (transaction) => wallet.signTransaction(transaction.toXDR());
51
+ return this.setWallet(new StellarWallet(this, { address, signMessage, signTransaction }));
52
+ }
53
+ async connect(id) {
54
+ const wallet = this.getWallet(id);
55
+ if (!wallet)
56
+ throw new Error("Wallet not found");
57
+ const { address } = await wallet.getAddress();
58
+ this.setStorage({ type: "wallet", id, address });
59
+ return this.selectWallet(address, wallet);
60
+ }
61
+ async disconnect() {
62
+ super.disconnect();
63
+ this.removeStorage();
64
+ }
65
+ }
66
+ export default StellarConnector;
67
+ //# sourceMappingURL=connector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connector.js","sourceRoot":"","sources":["../../src/stellar/connector.ts"],"names":[],"mappings":"AAEA,OAAO,GAAG,MAAM,sBAAsB,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGhE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,aAAa,MAAM,UAAU,CAAC;AAErC,MAAM,gBAAiB,SAAQ,aAA4B;IACzD,IAAI,GAAG,4GAA4G,CAAC;IACpH,WAAW,GAAG,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;IACpD,IAAI,GAAG,aAAa,CAAC,MAAM,CAAC;IAC5B,IAAI,GAAG,gBAAgB,CAAC;IACxB,EAAE,GAAG,SAAS,CAAC;IAEf,OAAO,GAAG;QACR,SAAS,EAAE,IAAI,eAAe,EAAE;QAChC,SAAS,EAAE,IAAI,eAAe,EAAE;KACjC,CAAC;IAEF,YAAY,KAAmB;QAC7B,KAAK,CAAC,KAAK,CAAC,CAAC;QAEb,IAAI,CAAC,OAAO,GAAG,MA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+ }
9
+ export declare class FreighterModule {
10
+ productId: string;
11
+ productName: string;
12
+ productUrl: string;
13
+ productIcon: string;
14
+ runChecks(): Promise<void>;
15
+ isAvailable(): Promise<boolean>;
16
+ getAddress(params?: {
17
+ skipRequestAccess?: boolean;
18
+ }): Promise<{
19
+ address: string;
20
+ }>;
21
+ signTransaction(xdr: string, opts?: {
22
+ address?: string;
23
+ networkPassphrase?: string;
24
+ }): Promise<{
25
+ signedTxXdr: string;
26
+ signerAddress?: string;
27
+ }>;
28
+ signAuthEntry(authEntry: string, opts?: {
29
+ address?: string;
30
+ networkPassphrase?: string;
31
+ }): Promise<{
32
+ signedAuthEntry: string;
33
+ signerAddress?: string;
34
+ }>;
35
+ signMessage(message: string, opts?: {
36
+ address?: string;
37
+ networkPassphrase?: string;
38
+ }): Promise<{
39
+ signedMessage: string;
40
+ signerAddress?: string;
41
+ }>;
42
+ getNetwork(): Promise<{
43
+ network: string;
44
+ networkPassphrase: string;
45
+ }>;
46
+ }
@@ -0,0 +1,110 @@
1
+ import { isConnected, requestAccess, getAddress, signTransaction, signAuthEntry, signMessage, getNetwork } from "@stellar/freighter-api";
2
+ function parseError(e) {
3
+ return {
4
+ code: e?.error?.code || e?.code || -1,
5
+ message: e?.error?.message || e?.message || (typeof e === "string" && e) || "Unhandled error from the wallet",
6
+ ext: e?.error?.ext || e?.ext,
7
+ };
8
+ }
9
+ const FREIGHTER_ID = "freighter";
10
+ export class FreighterModule {
11
+ productId = FREIGHTER_ID;
12
+ productName = "Freighter";
13
+ productUrl = "https://freighter.app";
14
+ productIcon = "https://stellar.creit.tech/wallet-icons/freighter.png";
15
+ async runChecks() {
16
+ if (!(await this.isAvailable())) {
17
+ throw new Error("Freighter is not connected");
18
+ }
19
+ }
20
+ async isAvailable() {
21
+ if (window.stellar?.provider === "freighter" && window.stellar?.platform === "mobile")
22
+ return false;
23
+ return isConnected()
24
+ .then(({ isConnected: isConnected2, error }) => !error && isConnected2)
25
+ .catch(() => false);
26
+ }
27
+ async getAddress(params) {
28
+ return this.runChecks()
29
+ .then(async () => {
30
+ if (params?.skipRequestAccess)
31
+ return true;
32
+ return requestAccess();
33
+ })
34
+ .then(() => getAddress())
35
+ .then(({ address, error }) => {
36
+ if (error)
37
+ throw error;
38
+ if (!address)
39
+ throw {
40
+ code: -3,
41
+ message: "Getting the address is not allowed, please request access first.",
42
+ };
43
+ return { address };
44
+ })
45
+ .catch((e) => {
46
+ throw parseError(e);
47
+ });
48
+ }
49
+ async signTransaction(xdr, opts) {
50
+ return this.runChecks()
51
+ .then(async () => {
52
+ const { signedTxXdr, signerAddress, error } = await signTransaction(xdr, {
53
+ address: opts?.address,
54
+ networkPassphrase: opts?.networkPassphrase,
55
+ });
56
+ if (error)
57
+ throw error;
58
+ return { signedTxXdr, signerAddress };
59
+ })
60
+ .catch((e) => {
61
+ throw parseError(e);
62
+ });
63
+ }
64
+ async signAuthEntry(authEntry, opts) {
65
+ return this.runChecks()
66
+ .then(async () => {
67
+ const { signedAuthEntry, signerAddress, error } = await signAuthEntry(authEntry, {
68
+ address: opts?.address,
69
+ networkPassphrase: opts?.networkPassphrase,
70
+ });
71
+ if (error || !signedAuthEntry)
72
+ throw error;
73
+ return { signedAuthEntry: Buffer.from(signedAuthEntry).toString("base64"), signerAddress };
74
+ })
75
+ .catch((e) => {
76
+ throw parseError(e);
77
+ });
78
+ }
79
+ async signMessage(message, opts) {
80
+ return this.runChecks()
81
+ .then(async () => {
82
+ const { signedMessage, signerAddress, error } = await signMessage(message, {
83
+ address: opts?.address,
84
+ networkPassphrase: opts?.networkPassphrase,
85
+ });
86
+ if (error || !signedMessage)
87
+ throw error;
88
+ return {
89
+ signedMessage: typeof signedMessage === "string" ? signedMessage : Buffer.from(signedMessage).toString("base64"),
90
+ signerAddress,
91
+ };
92
+ })
93
+ .catch((e) => {
94
+ throw parseError(e);
95
+ });
96
+ }
97
+ async getNetwork() {
98
+ return this.runChecks()
99
+ .then(async () => {
100
+ const { network, networkPassphrase, error } = await getNetwork();
101
+ if (error)
102
+ throw error;
103
+ return { network, networkPassphrase };
104
+ })
105
+ .catch((e) => {
106
+ throw parseError(e);
107
+ });
108
+ }
109
+ }
110
+ //# sourceMappingURL=freigher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"freigher.js","sourceRoot":"","sources":["../../src/stellar/freigher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,eAAe,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAWzI,SAAS,UAAU,CAAC,CAAM;IACxB,OAAO;QACL,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,CAAC;QACrC,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,IAAI,CAAC,EAAE,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,IAAI,iCAAiC;QAC7G,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,EAAE,GAAG;KAC7B,CAAC;AACJ,CAAC;AAED,MAAM,YAAY,GAAG,WAAW,CAAC;AACjC,MAAM,OAAO,eAAe;IAC1B,SAAS,GAAG,YAAY,CAAC;IACzB,WAAW,GAAG,WAAW,CAAC;IAC1B,UAAU,GAAG,uBAAuB,CAAC;IACrC,WAAW,GAAG,uDAAuD,CAAC;IAEtE,KAAK,CAAC,SAAS;QACb,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IAED,KAAK,CAAC,WAAW;QACf,IAAI,MAAM,CAAC,OAAO,EAAE,QAAQ,KAAK,WAAW,IAAI,MAAM,CAAC,OAAO,EAAE,QAAQ,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;QACpG,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Aa,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;gBAChH,aAAa;aACd,CAAC;QACJ,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;YACX,MAAM,UAAU,CAAC,CAAC,CAAC,CAAC;QACtB,CAAC,CAAC,CAAC;IACP,CAAC;IAED,KAAK,CAAC,UAAU;QACd,OAAO,IAAI,CAAC,SAAS,EAAE;aACpB,IAAI,CAAC,KAAK,IAAI,EAAE;YACf,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,GAAG,MAAM,UAAU,EAAE,CAAC;YACjE,IAAI,KAAK;gBAAE,MAAM,KAAK,CAAC;YACvB,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,CAAC;QACxC,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;YACX,MAAM,UAAU,CAAC,CAAC,CAAC,CAAC;QACtB,CAAC,CAAC,CAAC;IACP,CAAC;CACF"}
@@ -0,0 +1,33 @@
1
+ export declare const HOTWALLET_ID: string;
2
+ export declare class HotWalletModule {
3
+ productId: string;
4
+ productName: string;
5
+ productUrl: string;
6
+ productIcon: string;
7
+ isAvailable(): Promise<boolean>;
8
+ getAddress(): Promise<{
9
+ address: string;
10
+ }>;
11
+ signTransaction(xdr: string, opts?: {
12
+ address?: string;
13
+ }): Promise<{
14
+ signedTxXdr: string;
15
+ signerAddress?: string;
16
+ }>;
17
+ signAuthEntry(authEntry: string, opts?: {
18
+ address?: string;
19
+ }): Promise<{
20
+ signedAuthEntry: string;
21
+ signerAddress?: string;
22
+ }>;
23
+ signMessage(message: string, opts?: {
24
+ address?: string;
25
+ }): Promise<{
26
+ signedMessage: string;
27
+ signerAddress?: string;
28
+ }>;
29
+ getNetwork(): Promise<{
30
+ network: string;
31
+ networkPassphrase: string;
32
+ }>;
33
+ }
@@ -0,0 +1,28 @@
1
+ import { Networks } from "@stellar/stellar-sdk";
2
+ import HOT from "../hot-wallet/iframe";
3
+ export const HOTWALLET_ID = "hot-wallet";
4
+ export class HotWalletModule {
5
+ productId = HOTWALLET_ID;
6
+ productName = "HOT Wallet";
7
+ productUrl = "https://hot-labs.org/wallet";
8
+ productIcon = "https://storage.herewallet.app/logo.png";
9
+ async isAvailable() {
10
+ return true;
11
+ }
12
+ async getAddress() {
13
+ return await HOT.request("stellar:getAddress", {});
14
+ }
15
+ async signTransaction(xdr, opts) {
16
+ return await HOT.request("stellar:signTransaction", { xdr, accountToSign: opts?.address });
17
+ }
18
+ async signAuthEntry(authEntry, opts) {
19
+ return await HOT.request("stellar:signAuthEntry", { authEntry, accountToSign: opts?.address });
20
+ }
21
+ async signMessage(message, opts) {
22
+ return await HOT.request("stellar:signMessage", { message, accountToSign: opts?.address });
23
+ }
24
+ async getNetwork() {
25
+ return { network: "mainnet", networkPassphrase: Networks.PUBLIC };
26
+ }
27
+ }
28
+ //# sourceMappingURL=hotWallet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hotWallet.js","sourceRoot":"","sources":["../../src/stellar/hotWallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,GAAG,MAAM,sBAAsB,CAAC;AAEvC,MAAM,CAAC,MAAM,YAAY,GAAW,YAAY,CAAC;AAEjD,MAAM,OAAO,eAAe;IAC1B,SAAS,GAAW,YAAY,CAAC;IACjC,WAAW,GAAW,YAAY,CAAC;IACnC,UAAU,GAAW,6BAA6B,CAAC;IACnD,WAAW,GAAW,yCAAyC,CAAC;IAEhE,KAAK,CAAC,WAAW;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,UAAU;QACd,OAAO,MAAM,GAAG,CAAC,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,GAAW,EAAE,IAA2B;QAC5D,OAAO,MAAM,GAAG,CAAC,OAAO,CAAC,yBAAyB,EAAE,EAAE,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IAC7F,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,SAAiB,EAAE,IAA2B;QAChE,OAAO,MAAM,GAAG,CAAC,OAAO,CAAC,uBAAuB,EAAE,EAAE,SAAS,EAAE,aAAa,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IACjG,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAAe,EAAE,IAA2B;QAC5D,OAAO,MAAM,GAAG,CAAC,OAAO,CAAC,qBAAqB,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IAC7F,CAAC;IAED,KAAK,CAAC,UAAU;QACd,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IACpE,CAAC;CACF"}
@@ -0,0 +1,6 @@
1
+ import StellarConnector from "./connector";
2
+ import StellarWallet from "./wallet";
3
+ import { HotConnector } from "../HotConnector";
4
+ export { StellarConnector, StellarWallet };
5
+ declare const _default: () => (wibe3: HotConnector) => Promise<StellarConnector>;
6
+ export default _default;
@@ -0,0 +1,5 @@
1
+ import StellarConnector from "./connector";
2
+ import StellarWallet from "./wallet";
3
+ export { StellarConnector, StellarWallet };
4
+ export default () => async (wibe3) => new StellarConnector(wibe3);
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/stellar/index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,aAAa,CAAC;AAC3C,OAAO,aAAa,MAAM,UAAU,CAAC;AAGrC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,CAAC;AAE3C,eAAe,GAAG,EAAE,CAAC,KAAK,EAAE,KAAmB,EAAE,EAAE,CAAC,IAAI,gBAAgB,CAAC,KAAK,CAAC,CAAC"}
@@ -0,0 +1,65 @@
1
+ import { Asset, Memo, Operation, Transaction, xdr } from "@stellar/stellar-base";
2
+ import { WalletType } from "../core/chains";
3
+ import { OmniWallet } from "../OmniWallet";
4
+ import { OmniConnector } from "../OmniConnector";
5
+ import { ReviewFee } from "../core/bridge";
6
+ import { Token } from "../core/token";
7
+ import { Commitment } from "../core";
8
+ interface ProtocolWallet {
9
+ signTransaction?: (transaction: Transaction) => Promise<{
10
+ signedTxXdr: string;
11
+ }>;
12
+ signMessage?: (message: string) => Promise<{
13
+ signedMessage: string;
14
+ }>;
15
+ address: string;
16
+ }
17
+ export declare const ACCOUNT_FOR_SIMULATE = "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7";
18
+ export declare enum ASSET_CONTRACT_METHOD {
19
+ GET_ALLOWANCE = "allowance",
20
+ APPROVE_ALLOWANCE = "approve",
21
+ GET_BALANCE = "balance",
22
+ TRANSFER = "transfer",
23
+ NAME = "name",
24
+ BURN = "burn"
25
+ }
26
+ declare class StellarWallet extends OmniWallet {
27
+ readonly connector: OmniConnector;
28
+ readonly wallet: ProtocolWallet;
29
+ readonly type = WalletType.STELLAR;
30
+ constructor(connector: OmniConnector, wallet: ProtocolWallet);
31
+ get rpc(): import("@hot-labs/omni-sdk").StellarBridge;
32
+ get address(): string;
33
+ get publicKey(): string;
34
+ get omniAddress(): string;
35
+ fetchBalances(): Promise<Record<string, bigint>>;
36
+ fetchBalance(chain: number, token: string): Promise<bigint>;
37
+ transferFee(token: Token): Promise<ReviewFee>;
38
+ emulateTransfer(token: string, receiver: string, amount: bigint, memo?: string): Promise<{
39
+ fee: ReviewFee;
40
+ tx: Transaction;
41
+ }>;
42
+ transfer(args: {
43
+ token: Token;
44
+ receiver: string;
45
+ amount: bigint;
46
+ comment?: string;
47
+ gasFee?: ReviewFee;
48
+ }): Promise<string>;
49
+ sendTransaction(transaction: Transaction): Promise<string>;
50
+ signMessage(message: string): Promise<{
51
+ signedMessage: string;
52
+ }>;
53
+ signIntents(intents: Record<string, any>[], options?: {
54
+ deadline?: number;
55
+ nonce?: Uint8Array;
56
+ }): Promise<Commitment>;
57
+ static isTokenActivated(address: string, token: string): Promise<any>;
58
+ changeTrustline(address: string): Promise<string | undefined>;
59
+ readonly assetsCache: Map<string, Asset>;
60
+ getAssetFromContractId(id: string): Promise<Asset>;
61
+ buildSmartContactTx(publicKey: string, contactId: string, method: string, ...args: any[]): Promise<Transaction<Memo<import("@stellar/stellar-base").MemoType>, Operation[]>>;
62
+ getTokenBalance(token: Asset | string, contract: string): Promise<bigint>;
63
+ i128ToInt(val: xdr.Int128Parts): string;
64
+ }
65
+ export default StellarWallet;
@@ -0,0 +1,216 @@
1
+ import { base64, base58, hex, base32 } from "@scure/base";
2
+ import { Address, Asset, BASE_FEE, Claimant, Contract, Memo, nativeToScVal, Networks, Operation, TimeoutInfinite, Transaction, TransactionBuilder } from "@stellar/stellar-base";
3
+ import { WalletType } from "../core/chains";
4
+ import { OmniWallet } from "../OmniWallet";
5
+ import { ReviewFee } from "../core/bridge";
6
+ import { formatter } from "../core/utils";
7
+ import { Network } from "../core/chains";
8
+ export const ACCOUNT_FOR_SIMULATE = "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7";
9
+ export var ASSET_CONTRACT_METHOD;
10
+ (function (ASSET_CONTRACT_METHOD) {
11
+ ASSET_CONTRACT_METHOD["GET_ALLOWANCE"] = "allowance";
12
+ ASSET_CONTRACT_METHOD["APPROVE_ALLOWANCE"] = "approve";
13
+ ASSET_CONTRACT_METHOD["GET_BALANCE"] = "balance";
14
+ ASSET_CONTRACT_METHOD["TRANSFER"] = "transfer";
15
+ ASSET_CONTRACT_METHOD["NAME"] = "name";
16
+ ASSET_CONTRACT_METHOD["BURN"] = "burn";
17
+ })(ASSET_CONTRACT_METHOD || (ASSET_CONTRACT_METHOD = {}));
18
+ class StellarWallet extends OmniWallet {
19
+ connector;
20
+ wallet;
21
+ type = WalletType.STELLAR;
22
+ constructor(connector, wallet) {
23
+ super(connector);
24
+ this.connector = connector;
25
+ this.wallet = wallet;
26
+ }
27
+ get rpc() {
28
+ return this.connector.wibe3.hotBridge.stellar;
29
+ }
30
+ get address() {
31
+ return this.wallet.address;
32
+ }
33
+ get publicKey() {
34
+ const payload = base32.decode(this.address);
35
+ return base58.encode(payload.slice(1, -2));
36
+ }
37
+ get omniAddress() {
38
+ const payload = base32.decode(this.address);
39
+ return hex.encode(payload.slice(1, -2));
40
+ }
41
+ async fetchBalances() {
42
+ const data = await fetch(`https://horizon.stellar.org/accounts/${this.address}`).then((res) => res.json());
43
+ const balances = data.balances?.map((ft) => {
44
+ const asset = ft.asset_type === "native" ? Asset.native() : new Asset(ft.asset_code, ft.asset_issuer);
45
+ const contractId = ft.asset_type === "native" ? "native" : asset.contractId(Networks.PUBLIC);
46
+ if (contractId === "native") {
47
+ const activatingReserve = ft.sponsor != null ? 0 : 1;
48
+ const trustlines = data.balances.filter((t) => t.asset_type !== "native" && t.sponsor == null);
49
+ const balance = BigInt(formatter.parseAmount(ft.balance, 7));
50
+ const reserved = BigInt(formatter.parseAmount(activatingReserve + 0.5 * (trustlines.length + (data.num_sponsoring || 0)), 7));
51
+ return [contractId, formatter.bigIntMax(0n, balance - BigInt(reserved))];
52
+ }
53
+ return [contractId, BigInt(formatter.parseAmount(ft.balance, 7))];
54
+ });
55
+ return Object.fromEntries(balances);
56
+ }
57
+ async fetchBalance(chain, token) {
58
+ if (chain !== Network.Stellar)
59
+ throw "Invalid chain";
60
+ const balances = await this.fetchBalances();
61
+ return balances[token] || 0n;
62
+ }
63
+ async transferFee(token) {
64
+ return new ReviewFee({ baseFee: 0n, gasLimit: 0n, chain: token.chain });
65
+ }
66
+ async emulateTransfer(token, receiver, amount, memo) {
67
+ const asset = await this.getAssetFromContractId(token);
68
+ const sendAmount = formatter.formatAmount(amount, 7);
69
+ const account = await this.connector.wibe3.hotBridge.stellar.callSoroban((s) => s.getAccount(this.address));
70
+ const baseFee = await this.connector.wibe3.hotBridge.stellar.callHorizon((h) => h.fetchBaseFee()).catch(() => +BASE_FEE);
71
+ const builder = new TransactionBuilder(account, {
72
+ memo: memo ? Memo.text(memo) : undefined,
73
+ networkPassphrase: Networks.PUBLIC,
74
+ fee: String(baseFee),
75
+ }).setTimeout(TimeoutInfinite);
76
+ if (receiver.startsWith("C")) {
77
+ const contract = new Contract(asset.contractId(Networks.PUBLIC));
78
+ const amountScVal = nativeToScVal(amount, { type: "i128" });
79
+ builder.addOperation(contract.call("transfer", //
80
+ Address.fromString(this.address).toScVal(), Address.fromString(receiver).toScVal(), amountScVal));
81
+ const tx = await this.rpc.callSoroban((s) => s.prepareTransaction(builder.build()));
82
+ const fee = BigInt(Math.floor(baseFee * tx.operations.length));
83
+ return { fee: new ReviewFee({ baseFee: fee, priorityFee: 0n, gasLimit: 1n, chain: Network.Stellar }), tx: tx };
84
+ }
85
+ let needXlm = 0;
86
+ const receiverAccount = await this.rpc.callHorizon((h) => h.loadAccount(receiver)).catch(() => null);
87
+ const claimableBalance = Operation.createClaimableBalance({ amount: amount.toString(), claimants: [new Claimant(receiver)], asset });
88
+ if (receiverAccount == null) {
89
+ if (token === "native") {
90
+ builder.addOperation(Operation.createAccount({ destination: receiver, startingBalance: Math.max(1, sendAmount).toString() }));
91
+ needXlm = Math.max(1, sendAmount);
92
+ }
93
+ else {
94
+ builder.addOperation(Operation.createAccount({ destination: receiver, startingBalance: "1" }));
95
+ builder.addOperation(claimableBalance);
96
+ needXlm = 1;
97
+ }
98
+ }
99
+ else {
100
+ const trustline = receiverAccount.balances.find((b) => {
101
+ if (b.asset_type === "native")
102
+ return false;
103
+ return b.asset_code === asset.code && b.asset_issuer === asset.issuer;
104
+ });
105
+ // Check if trustline exists for non-native assets
106
+ if (token !== "native" && !trustline) {
107
+ builder.addOperation(claimableBalance);
108
+ }
109
+ else {
110
+ builder.addOperation(Operation.payment({ destination: receiver, asset, amount: sendAmount.toString() }));
111
+ }
112
+ }
113
+ const tx = builder.build();
114
+ const fee = BigInt(Math.floor(baseFee * tx.operations.length));
115
+ const need = fee + BigInt(formatter.parseAmount(needXlm, 7));
116
+ return { fee: new ReviewFee({ baseFee: need, priorityFee: 0n, gasLimit: 1n, chain: Network.Stellar }), tx };
117
+ }
118
+ async transfer(args) {
119
+ const { tx } = await this.emulateTransfer(args.token.address, args.receiver, args.amount, args.comment);
120
+ return this.sendTransaction(tx);
121
+ }
122
+ async sendTransaction(transaction) {
123
+ if (!this.wallet.signTransaction)
124
+ throw "not impl";
125
+ const result = await this.wallet.signTransaction(transaction);
126
+ const txObject = new Transaction(result.signedTxXdr, Networks.PUBLIC);
127
+ const { hash } = await this.rpc.callHorizon((t) => t.submitTransaction(txObject));
128
+ return hash;
129
+ }
130
+ async signMessage(message) {
131
+ if (!this.wallet.signMessage)
132
+ throw "not impl";
133
+ return await this.wallet.signMessage(message);
134
+ }
135
+ async signIntents(intents, options) {
136
+ const nonce = new Uint8Array(options?.nonce || window.crypto.getRandomValues(new Uint8Array(32)));
137
+ const message = JSON.stringify({
138
+ deadline: options?.deadline ? new Date(options.deadline).toISOString() : "2100-01-01T00:00:00.000Z",
139
+ nonce: base64.encode(nonce),
140
+ verifying_contract: "intents.near",
141
+ signer_id: this.omniAddress,
142
+ intents: intents,
143
+ });
144
+ const signature = await this.signMessage(message);
145
+ return {
146
+ signature: `ed25519:${base58.encode(base64.decode(signature.signedMessage))}`,
147
+ public_key: `ed25519:${this.publicKey}`,
148
+ standard: "sep53",
149
+ payload: message,
150
+ };
151
+ }
152
+ static async isTokenActivated(address, token) {
153
+ if (address === "native")
154
+ return true;
155
+ const data = await fetch(`https://horizon.stellar.org/accounts/${address}`).then((res) => res.json());
156
+ return data.balances.some((ft) => {
157
+ if (!ft.asset_issuer)
158
+ return false;
159
+ const asset = new Asset(ft.asset_code, ft.asset_issuer).contractId(Networks.PUBLIC);
160
+ return asset.toLowerCase() === token.toLowerCase();
161
+ });
162
+ }
163
+ async changeTrustline(address) {
164
+ if (address === "native")
165
+ return;
166
+ const asset = await this.getAssetFromContractId(address);
167
+ const account = await this.rpc.callHorizon((h) => h.loadAccount(this.address));
168
+ const trustlineOp = Operation.changeTrust({ asset: asset, source: this.address });
169
+ const trustlineTx = new TransactionBuilder(account, { fee: BASE_FEE, networkPassphrase: Networks.PUBLIC }) //
170
+ .addOperation(trustlineOp)
171
+ .setTimeout(TimeoutInfinite)
172
+ .build();
173
+ return this.sendTransaction(trustlineTx);
174
+ }
175
+ assetsCache = new Map();
176
+ async getAssetFromContractId(id) {
177
+ if (id === "native")
178
+ return Asset.native();
179
+ if (this.assetsCache.has(id)) {
180
+ return Promise.resolve(this.assetsCache.get(id));
181
+ }
182
+ const tx = await this.buildSmartContactTx(ACCOUNT_FOR_SIMULATE, id, ASSET_CONTRACT_METHOD.NAME);
183
+ const result = (await this.rpc.callSoroban((s) => s.simulateTransaction(tx)));
184
+ const value = result?.result?.retval?.value();
185
+ if (!value)
186
+ throw "Asset not found";
187
+ const [code, issuer] = value.toString().split(":");
188
+ const asset = issuer ? new Asset(code, issuer) : Asset.native();
189
+ this.assetsCache.set(id, asset);
190
+ return asset;
191
+ }
192
+ async buildSmartContactTx(publicKey, contactId, method, ...args) {
193
+ const account = await this.rpc.callSoroban((s) => s.getAccount(publicKey));
194
+ const contract = new Contract(contactId);
195
+ const builtTx = new TransactionBuilder(account, { fee: BASE_FEE, networkPassphrase: Networks.PUBLIC });
196
+ if (args)
197
+ builtTx.addOperation(contract.call(method, ...args));
198
+ else
199
+ builtTx.addOperation(contract.call(method));
200
+ return builtTx.setTimeout(TimeoutInfinite).build();
201
+ }
202
+ async getTokenBalance(token, contract) {
203
+ const tx = await this.buildSmartContactTx(ACCOUNT_FOR_SIMULATE, //
204
+ typeof token === "string" ? (token === "native" ? new Asset("XLM").contractId(Networks.PUBLIC) : token) : token.contractId(Networks.PUBLIC), ASSET_CONTRACT_METHOD.GET_BALANCE, Address.fromString(contract).toScVal());
205
+ const result = (await this.rpc.callSoroban((s) => s.simulateTransaction(tx)));
206
+ if (result)
207
+ return BigInt(this.i128ToInt(result.result?.retval.value()));
208
+ return 0n;
209
+ }
210
+ i128ToInt(val) {
211
+ // @ts-expect-error TODO: fix this
212
+ return new BigNumber(val.hi()._value).plus(val.lo()._value).div(1e7).toString();
213
+ }
214
+ }
215
+ export default StellarWallet;
216
+ //# sourceMappingURL=wallet.js.map