@rabbitio/ui-kit 1.0.0-beta.28 → 1.0.0-beta.29

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rabbitio/ui-kit",
3
- "version": "1.0.0-beta.28",
3
+ "version": "1.0.0-beta.29",
4
4
  "description": "Rabbit.io react.js components kit",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -619,4 +619,29 @@ export class PublicSwapService {
619
619
  improveAndRethrow(e, "isAddressValidForAsset");
620
620
  }
621
621
  }
622
+
623
+ /**
624
+ * Retrieves token by contract address.
625
+ *
626
+ * @param addressString {string}
627
+ * @return {Promise<Coin|null>}
628
+ */
629
+ async getTokenByContractAddress(addressString) {
630
+ try {
631
+ if (!addressString) return null;
632
+ const addressLowerCase = addressString.toLowerCase();
633
+ const allCoins =
634
+ await this._swapProvider.getAllSupportedCurrencies();
635
+ if (allCoins.result) {
636
+ return allCoins.coins.find(
637
+ (coin) =>
638
+ coin.tokenAddress &&
639
+ coin.tokenAddress.toLowerCase() === addressLowerCase
640
+ );
641
+ }
642
+ } catch (e) {
643
+ Logger.logError(e, "getTokenByContractAddress");
644
+ }
645
+ return null;
646
+ }
622
647
  }