mirror of
https://github.com/alexgo-io/alex-sdk.git
synced 2026-05-04 21:39:31 +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;
|
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
|
### isAlexSwapTransaction
|
||||||
|
|
||||||
Check if a transaction is a swap transaction from Alex
|
Check if a transaction is a swap transaction from Alex
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { runSpot, TxToBroadCast } from './helpers/SwapHelper';
|
|||||||
import {
|
import {
|
||||||
fetchBalanceForAccount,
|
fetchBalanceForAccount,
|
||||||
findCurrencyByNativeAddress,
|
findCurrencyByNativeAddress,
|
||||||
|
getCurrencyNativeAddress,
|
||||||
} from './utils/currencyUtils';
|
} from './utils/currencyUtils';
|
||||||
import { fetchLatestPrices } from './utils/currencyPrice';
|
import { fetchLatestPrices } from './utils/currencyPrice';
|
||||||
import { assignConfig, AssignConfigParams, configs } from './config';
|
import { assignConfig, AssignConfigParams, configs } from './config';
|
||||||
@@ -72,6 +73,10 @@ export class AlexSDK {
|
|||||||
return findCurrencyByNativeAddress(address);
|
return findCurrencyByNativeAddress(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getAddressFrom(currency: Exclude<Currency, Currency.STX>): string {
|
||||||
|
return getCurrencyNativeAddress(currency);
|
||||||
|
}
|
||||||
|
|
||||||
getLatestPrices(): Promise<
|
getLatestPrices(): Promise<
|
||||||
Partial<{
|
Partial<{
|
||||||
[currency in Currency]: number;
|
[currency in Currency]: number;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export function getCurrencyNativeScale(currency: Currency) {
|
|||||||
|
|
||||||
export function getCurrencyNativeAddress(currency: Currency) {
|
export function getCurrencyNativeAddress(currency: Currency) {
|
||||||
if (currency === Currency.STX) {
|
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;
|
return configs.NATIVE_TOKEN_MAPPING[currency].assetIdentifier;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user