@moonbeam-network/xcm-utils 4.2.2 → 4.2.4
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/README.md +24 -8
- package/build/index.d.mts +45 -0
- package/build/index.d.ts +2 -2
- package/build/index.mjs +21531 -48
- package/build/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,20 +1,36 @@
|
|
|
1
|
-
|
|
1
|
+
# @moonbeam-network/xcm-utils
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Shared utility functions used across all other packages in the Moonbeam XCM SDK.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Package Information
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
**NPM Package:** [https://www.npmjs.com/package/@moonbeam-network/xcm-utils](https://www.npmjs.com/package/@moonbeam-network/xcm-utils)
|
|
8
|
+
|
|
9
|
+
**Package Level:** Foundation (lowest level)
|
|
10
|
+
This package provides core utility functions and has no dependencies on other packages in the monorepo.
|
|
11
|
+
|
|
12
|
+
## Documentation
|
|
13
|
+
|
|
14
|
+
### v4 (current)
|
|
15
|
+
|
|
16
|
+
#### Usage
|
|
8
17
|
|
|
9
18
|
- [XCM SDK](https://moonbeam-foundation.github.io/xcm-sdk/latest/example-usage/xcm)
|
|
10
19
|
- [MRL SDK](https://moonbeam-foundation.github.io/xcm-sdk/latest/example-usage/mrl)
|
|
11
20
|
|
|
12
|
-
|
|
21
|
+
#### References
|
|
13
22
|
|
|
14
23
|
- [XCM SDK](https://moonbeam-foundation.github.io/xcm-sdk/latest/reference/xcm)
|
|
15
24
|
- [MRL SDK](https://moonbeam-foundation.github.io/xcm-sdk/latest/reference/mrl)
|
|
16
25
|
|
|
17
|
-
|
|
26
|
+
### v3 (previous)
|
|
27
|
+
|
|
28
|
+
#### Usage
|
|
29
|
+
|
|
30
|
+
- [XCM SDK](https://moonbeam-foundation.github.io/xcm-sdk/v3/example-usage/xcm)
|
|
31
|
+
- [MRL SDK](https://moonbeam-foundation.github.io/xcm-sdk/v3/example-usage/mrl)
|
|
32
|
+
|
|
33
|
+
#### References
|
|
18
34
|
|
|
19
|
-
- [
|
|
20
|
-
- [
|
|
35
|
+
- [XCM SDK](https://moonbeam-foundation.github.io/xcm-sdk/v3/reference/xcm)
|
|
36
|
+
- [MRL SDK](https://moonbeam-foundation.github.io/xcm-sdk/v3/reference/mrl)
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { RoundingMode } from 'big.js';
|
|
2
|
+
import { ApiPromise } from '@polkadot/api';
|
|
3
|
+
|
|
4
|
+
declare function isHexString(asset: unknown): boolean;
|
|
5
|
+
declare function isEthAddress(address: string): boolean;
|
|
6
|
+
|
|
7
|
+
declare function formatAssetIdToERC20(id: string): string;
|
|
8
|
+
declare function convertAddressTo32Bytes(address: string): string;
|
|
9
|
+
|
|
10
|
+
declare function toDecimal(number: bigint | number | string, decimals: number, maxDecimal?: number, roundType?: RoundingMode): string;
|
|
11
|
+
declare function toBigInt(amount: bigint | string | number, decimals: number): bigint;
|
|
12
|
+
declare function convertDecimals(number: string | bigint, decimals: number, targetDecimals: number): bigint;
|
|
13
|
+
declare function hasDecimalOverflow(fl: number | string, maxDecimal: number): boolean;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* reference: https://github.com/Moonsong-Labs/xcm-tools/blob/main/scripts/calculate-sovereign-account.ts
|
|
17
|
+
*/
|
|
18
|
+
declare function getSovereignAccountAddresses(paraId: number): {
|
|
19
|
+
generic: string;
|
|
20
|
+
moonbeam: string;
|
|
21
|
+
relay: string;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* reference: https://github.com/Moonsong-Labs/xcm-tools/blob/main/scripts/calculate-multilocation-derivative-account.ts
|
|
25
|
+
*/
|
|
26
|
+
declare function getMultilocationDerivedAddresses({ paraId, address, parents, }: {
|
|
27
|
+
paraId?: number;
|
|
28
|
+
address: string;
|
|
29
|
+
parents?: 0 | 1 | 2;
|
|
30
|
+
}): {
|
|
31
|
+
address20: `0x${string}`;
|
|
32
|
+
address32: `0x${string}`;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
declare enum MRLTypes {
|
|
36
|
+
XcmVersionedMultiLocation = "XcmVersionedMultiLocation",
|
|
37
|
+
XcmVersionedLocation = "XcmVersionedLocation",
|
|
38
|
+
XcmRoutingUserAction = "XcmRoutingUserAction",
|
|
39
|
+
VersionedUserAction = "VersionedUserAction"
|
|
40
|
+
}
|
|
41
|
+
declare function getPolkadotApi(ws: string | string[]): Promise<ApiPromise>;
|
|
42
|
+
|
|
43
|
+
declare function getPolkadotAppsUrl(ws: string): string;
|
|
44
|
+
|
|
45
|
+
export { MRLTypes, convertAddressTo32Bytes, convertDecimals, formatAssetIdToERC20, getMultilocationDerivedAddresses, getPolkadotApi, getPolkadotAppsUrl, getSovereignAccountAddresses, hasDecimalOverflow, isEthAddress, isHexString, toBigInt, toDecimal };
|
package/build/index.d.ts
CHANGED
|
@@ -23,10 +23,10 @@ declare function getSovereignAccountAddresses(paraId: number): {
|
|
|
23
23
|
/**
|
|
24
24
|
* reference: https://github.com/Moonsong-Labs/xcm-tools/blob/main/scripts/calculate-multilocation-derivative-account.ts
|
|
25
25
|
*/
|
|
26
|
-
declare function getMultilocationDerivedAddresses({ paraId, address,
|
|
26
|
+
declare function getMultilocationDerivedAddresses({ paraId, address, parents, }: {
|
|
27
27
|
paraId?: number;
|
|
28
28
|
address: string;
|
|
29
|
-
|
|
29
|
+
parents?: 0 | 1 | 2;
|
|
30
30
|
}): {
|
|
31
31
|
address20: `0x${string}`;
|
|
32
32
|
address32: `0x${string}`;
|