@xchainjs/xchain-radix 1.1.0 → 1.1.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.
- package/lib/client.d.ts +3 -3
- package/lib/const.d.ts +1 -1
- package/lib/index.esm.js +14 -12
- package/lib/index.js +14 -12
- package/package.json +3 -3
package/lib/client.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Curve, PrivateKey } from '@radixdlt/radix-engine-toolkit';
|
|
3
3
|
import { AssetInfo, BaseXChainClient, Fees, Network, PreparedTx, TxHistoryParams, XChainClientParams } from '@xchainjs/xchain-client';
|
|
4
|
-
import { Address } from '@xchainjs/xchain-util';
|
|
4
|
+
import { Address, TokenAsset } from '@xchainjs/xchain-util';
|
|
5
5
|
import { RadixSpecificClient } from './radix-client';
|
|
6
|
-
import { Balance,
|
|
6
|
+
import { Balance, Tx, TxParams, TxsPage } from './types/radix';
|
|
7
7
|
/**
|
|
8
8
|
* Custom Radix client
|
|
9
9
|
*/
|
|
@@ -67,7 +67,7 @@ export default class Client extends BaseXChainClient {
|
|
|
67
67
|
* @param {Asset[]} assets - Assets to retrieve the balance for (optional).
|
|
68
68
|
* @returns {Promise<Balance[]>} An array containing the balance of the address.
|
|
69
69
|
*/
|
|
70
|
-
getBalance(address: Address, assets?:
|
|
70
|
+
getBalance(address: Address, assets?: TokenAsset[]): Promise<Balance[]>;
|
|
71
71
|
/**
|
|
72
72
|
* Get transaction history of a given address with pagination options.
|
|
73
73
|
* @param {TxHistoryParams} params The options to get transaction history. (optional)
|
package/lib/const.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare const RadixChain: "XRD";
|
|
|
8
8
|
export declare const MAINNET_GATEWAY_URL = "https://mainnet.radixdlt.com";
|
|
9
9
|
export declare const STOKENET_GATEWAY_URL = "https://stokenet.radixdlt.com";
|
|
10
10
|
export declare const XRD_DECIMAL = 18;
|
|
11
|
-
export declare const RADIX_ASSET_RESOURCE = "
|
|
11
|
+
export declare const RADIX_ASSET_RESOURCE = "resource_rdx1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxradxrd";
|
|
12
12
|
export declare const AssetXRD: Asset;
|
|
13
13
|
export declare const xrdRootDerivationPaths: RootDerivationPaths;
|
|
14
14
|
export declare const bech32Networks: {
|
package/lib/index.esm.js
CHANGED
|
@@ -13906,7 +13906,7 @@ const RadixChain = 'XRD';
|
|
|
13906
13906
|
const MAINNET_GATEWAY_URL = 'https://mainnet.radixdlt.com';
|
|
13907
13907
|
const STOKENET_GATEWAY_URL = 'https://stokenet.radixdlt.com';
|
|
13908
13908
|
const XRD_DECIMAL = 18;
|
|
13909
|
-
const RADIX_ASSET_RESOURCE = '
|
|
13909
|
+
const RADIX_ASSET_RESOURCE = 'resource_rdx1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxradxrd';
|
|
13910
13910
|
const AssetXRD = {
|
|
13911
13911
|
symbol: `XRD`,
|
|
13912
13912
|
ticker: 'XRD',
|
|
@@ -14011,21 +14011,22 @@ class RadixSpecificClient {
|
|
|
14011
14011
|
});
|
|
14012
14012
|
batch.forEach((item) => {
|
|
14013
14013
|
if (item.aggregation_level === 'Global') {
|
|
14014
|
-
const asset =
|
|
14015
|
-
|
|
14016
|
-
|
|
14017
|
-
|
|
14018
|
-
|
|
14019
|
-
|
|
14014
|
+
const asset = item.resource_address === RADIX_ASSET_RESOURCE
|
|
14015
|
+
? AssetXRD
|
|
14016
|
+
: {
|
|
14017
|
+
chain: RadixChain,
|
|
14018
|
+
symbol: item.resource_address,
|
|
14019
|
+
ticker: item.resource_address,
|
|
14020
|
+
type: AssetType.TOKEN,
|
|
14021
|
+
};
|
|
14020
14022
|
const divisibility = divisibilities.get(item.resource_address) || 0;
|
|
14021
14023
|
// We need to do this because item.amount can be either string or number
|
|
14022
14024
|
// depending on the type of resource
|
|
14023
14025
|
const amount = typeof item.amount === 'string' ? parseFloat(item.amount) : item.amount;
|
|
14024
|
-
|
|
14025
|
-
asset
|
|
14026
|
+
balances.push({
|
|
14027
|
+
asset,
|
|
14026
14028
|
amount: assetToBase(assetAmount(amount, divisibility)),
|
|
14027
|
-
};
|
|
14028
|
-
balances.push(balance);
|
|
14029
|
+
});
|
|
14029
14030
|
}
|
|
14030
14031
|
});
|
|
14031
14032
|
}
|
|
@@ -14455,7 +14456,8 @@ class Client extends BaseXChainClient {
|
|
|
14455
14456
|
if (!assets) {
|
|
14456
14457
|
return balances;
|
|
14457
14458
|
}
|
|
14458
|
-
const filteredBalances = balances.filter((balance) =>
|
|
14459
|
+
const filteredBalances = balances.filter((balance) => eqAsset(balance.asset, this.getAssetInfo().asset) ||
|
|
14460
|
+
assets.some((asset) => balance.asset.symbol === asset.symbol));
|
|
14459
14461
|
return filteredBalances;
|
|
14460
14462
|
});
|
|
14461
14463
|
}
|
package/lib/index.js
CHANGED
|
@@ -13918,7 +13918,7 @@ const RadixChain = 'XRD';
|
|
|
13918
13918
|
const MAINNET_GATEWAY_URL = 'https://mainnet.radixdlt.com';
|
|
13919
13919
|
const STOKENET_GATEWAY_URL = 'https://stokenet.radixdlt.com';
|
|
13920
13920
|
const XRD_DECIMAL = 18;
|
|
13921
|
-
const RADIX_ASSET_RESOURCE = '
|
|
13921
|
+
const RADIX_ASSET_RESOURCE = 'resource_rdx1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxradxrd';
|
|
13922
13922
|
const AssetXRD = {
|
|
13923
13923
|
symbol: `XRD`,
|
|
13924
13924
|
ticker: 'XRD',
|
|
@@ -14023,21 +14023,22 @@ class RadixSpecificClient {
|
|
|
14023
14023
|
});
|
|
14024
14024
|
batch.forEach((item) => {
|
|
14025
14025
|
if (item.aggregation_level === 'Global') {
|
|
14026
|
-
const asset =
|
|
14027
|
-
|
|
14028
|
-
|
|
14029
|
-
|
|
14030
|
-
|
|
14031
|
-
|
|
14026
|
+
const asset = item.resource_address === RADIX_ASSET_RESOURCE
|
|
14027
|
+
? AssetXRD
|
|
14028
|
+
: {
|
|
14029
|
+
chain: RadixChain,
|
|
14030
|
+
symbol: item.resource_address,
|
|
14031
|
+
ticker: item.resource_address,
|
|
14032
|
+
type: xchainUtil.AssetType.TOKEN,
|
|
14033
|
+
};
|
|
14032
14034
|
const divisibility = divisibilities.get(item.resource_address) || 0;
|
|
14033
14035
|
// We need to do this because item.amount can be either string or number
|
|
14034
14036
|
// depending on the type of resource
|
|
14035
14037
|
const amount = typeof item.amount === 'string' ? parseFloat(item.amount) : item.amount;
|
|
14036
|
-
|
|
14037
|
-
asset
|
|
14038
|
+
balances.push({
|
|
14039
|
+
asset,
|
|
14038
14040
|
amount: xchainUtil.assetToBase(xchainUtil.assetAmount(amount, divisibility)),
|
|
14039
|
-
};
|
|
14040
|
-
balances.push(balance);
|
|
14041
|
+
});
|
|
14041
14042
|
}
|
|
14042
14043
|
});
|
|
14043
14044
|
}
|
|
@@ -14467,7 +14468,8 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
14467
14468
|
if (!assets) {
|
|
14468
14469
|
return balances;
|
|
14469
14470
|
}
|
|
14470
|
-
const filteredBalances = balances.filter((balance) =>
|
|
14471
|
+
const filteredBalances = balances.filter((balance) => xchainUtil.eqAsset(balance.asset, this.getAssetInfo().asset) ||
|
|
14472
|
+
assets.some((asset) => balance.asset.symbol === asset.symbol));
|
|
14471
14473
|
return filteredBalances;
|
|
14472
14474
|
});
|
|
14473
14475
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xchainjs/xchain-radix",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Custom Radix client and utilities used by XChainJS clients",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"XRD",
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@radixdlt/babylon-gateway-api-sdk": "^1.4.1",
|
|
42
42
|
"@radixdlt/radix-engine-toolkit": "^1.0.3",
|
|
43
|
-
"@xchainjs/xchain-client": "1.0.
|
|
43
|
+
"@xchainjs/xchain-client": "1.0.4",
|
|
44
44
|
"@xchainjs/xchain-crypto": "0.3.4",
|
|
45
|
-
"@xchainjs/xchain-util": "1.0.
|
|
45
|
+
"@xchainjs/xchain-util": "1.0.3",
|
|
46
46
|
"bech32": "^2.0.0",
|
|
47
47
|
"bip32": "^4.0.0",
|
|
48
48
|
"bip39": "^3.1.0",
|