@cryptorubic/web3 1.1.0-alpha-stellar.40 → 1.1.0-alpha-stellar.41
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
|
@@ -70,30 +70,33 @@ class StellarAdapter extends abstract_adapter_1.AbstractAdapter {
|
|
|
70
70
|
if (web3_pure_1.Web3Pure.isNativeAddress(core_1.BLOCKCHAIN_NAME.STELLAR, tokenAddress)) {
|
|
71
71
|
return core_1.nativeTokensList[core_1.BLOCKCHAIN_NAME.STELLAR];
|
|
72
72
|
}
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
.
|
|
81
|
-
.
|
|
82
|
-
.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
73
|
+
const [code, issuer] = tokenAddress.toUpperCase().split('-');
|
|
74
|
+
try {
|
|
75
|
+
const fetchedTokens = await this.horizonClient.assets().forIssuer(issuer).limit(50).call();
|
|
76
|
+
const fetchedToken = fetchedTokens.records.find((fetchedToken) => (0, core_1.compareAddresses)(fetchedToken.asset_code, code) &&
|
|
77
|
+
(0, core_1.compareAddresses)(fetchedToken.asset_issuer, issuer) &&
|
|
78
|
+
parseFloat(fetchedToken.balances.authorized) > 0);
|
|
79
|
+
if (fetchedToken && 'toml' in fetchedToken._links) {
|
|
80
|
+
const { href } = fetchedToken._links.toml;
|
|
81
|
+
const tomlTokens = await stellar_sdk_1.StellarToml.Resolver.resolve(new URL(href).hostname, { allowHttp: true });
|
|
82
|
+
if (tomlTokens.CURRENCIES) {
|
|
83
|
+
const tomlToken = tomlTokens.CURRENCIES.find((currency) => (0, core_1.compareAddresses)(fetchedToken.asset_code, currency.code) &&
|
|
84
|
+
(0, core_1.compareAddresses)(fetchedToken.asset_issuer, currency.issuer));
|
|
85
|
+
return new core_1.Token({
|
|
86
|
+
name: tomlToken.name || tomlToken.code,
|
|
87
|
+
symbol: tomlToken.code,
|
|
88
|
+
decimals: tomlToken.display_decimals || this.CLASSIC_TOKEN_DECIMALS,
|
|
89
|
+
blockchain: core_1.BLOCKCHAIN_NAME.STELLAR,
|
|
90
|
+
address: `${tomlToken.code}-${tomlToken.issuer}`
|
|
91
|
+
});
|
|
92
|
+
}
|
|
86
93
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
decimals,
|
|
94
|
-
name,
|
|
95
|
-
symbol
|
|
96
|
-
});
|
|
94
|
+
throw new Error('Token not found');
|
|
95
|
+
}
|
|
96
|
+
catch (err) {
|
|
97
|
+
console.error(err);
|
|
98
|
+
throw err;
|
|
99
|
+
}
|
|
97
100
|
}
|
|
98
101
|
async checkEnoughBalance(token, walletAddress) {
|
|
99
102
|
const userBalance = await this.getBalance(walletAddress, token.address);
|