mirror of
https://github.com/alexgo-io/alex-sdk.git
synced 2026-01-12 22:12:16 +08:00
feat: add getAddressFrom
This commit is contained in:
@@ -76,6 +76,14 @@ Get the corresponding currency for a given address.
|
||||
function getCurrencyFrom(address: string): Currency | undefined;
|
||||
```
|
||||
|
||||
### getAddressFrom
|
||||
|
||||
Get the corresponding currency for a given address.
|
||||
|
||||
```javascript
|
||||
function getAddressFrom(currency: Exclude<Currency, Currency.STX>): string;
|
||||
```
|
||||
|
||||
### isAlexSwapTransaction
|
||||
|
||||
Check if a transaction is a swap transaction from Alex
|
||||
|
||||
@@ -7,6 +7,7 @@ import { runSpot, TxToBroadCast } from './helpers/SwapHelper';
|
||||
import {
|
||||
fetchBalanceForAccount,
|
||||
findCurrencyByNativeAddress,
|
||||
getCurrencyNativeAddress,
|
||||
} from './utils/currencyUtils';
|
||||
import { fetchLatestPrices } from './utils/currencyPrice';
|
||||
import { assignConfig, AssignConfigParams, configs } from './config';
|
||||
@@ -72,6 +73,10 @@ export class AlexSDK {
|
||||
return findCurrencyByNativeAddress(address);
|
||||
}
|
||||
|
||||
getAddressFrom(currency: Exclude<Currency, Currency.STX>): string {
|
||||
return getCurrencyNativeAddress(currency);
|
||||
}
|
||||
|
||||
getLatestPrices(): Promise<
|
||||
Partial<{
|
||||
[currency in Currency]: number;
|
||||
|
||||
@@ -11,7 +11,7 @@ export function getCurrencyNativeScale(currency: Currency) {
|
||||
|
||||
export function getCurrencyNativeAddress(currency: Currency) {
|
||||
if (currency === Currency.STX) {
|
||||
throw new Error('STX is not a token');
|
||||
throw new Error('STX does not have an address');
|
||||
}
|
||||
return configs.NATIVE_TOKEN_MAPPING[currency].assetIdentifier;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user