@moonbeam-network/xcm-utils 1.0.0-dev.29 → 1.0.0-dev.290
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/LICENSE +1 -1
- package/README.md +16 -5
- package/build/index.d.ts +38 -28
- package/build/index.mjs +21644 -1
- package/build/index.mjs.map +1 -1
- package/package.json +25 -32
- package/build/index.cjs +0 -2
- package/build/index.cjs.map +0 -1
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright
|
|
1
|
+
Copyright 2024 Moonbeam Foundation
|
|
2
2
|
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
4
|
|
package/README.md
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
The Utils package contains the utility functions for the Moonbeam XCM SDK and MRL SDK.
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# Documentation for the Moonbeam XCM SDK
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## v3 (current)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
### Usage
|
|
8
8
|
|
|
9
|
-
-
|
|
9
|
+
- [XCM SDK](https://moonbeam-foundation.github.io/xcm-sdk/latest/example-usage/xcm)
|
|
10
|
+
- [MRL SDK](https://moonbeam-foundation.github.io/xcm-sdk/latest/example-usage/mrl)
|
|
11
|
+
|
|
12
|
+
### References
|
|
13
|
+
|
|
14
|
+
- [XCM SDK](https://moonbeam-foundation.github.io/xcm-sdk/latest/reference/xcm)
|
|
15
|
+
- [MRL SDK](https://moonbeam-foundation.github.io/xcm-sdk/latest/reference/mrl)
|
|
16
|
+
|
|
17
|
+
## v2 (previous)
|
|
18
|
+
|
|
19
|
+
- [usage](https://moonbeam-foundation.github.io/xcm-sdk/v2/example-usage)
|
|
20
|
+
- [references](https://moonbeam-foundation.github.io/xcm-sdk/v2/reference/interfaces)
|
package/build/index.d.ts
CHANGED
|
@@ -1,35 +1,45 @@
|
|
|
1
1
|
import { RoundingMode } from 'big.js';
|
|
2
2
|
import { ApiPromise } from '@polkadot/api';
|
|
3
3
|
|
|
4
|
-
declare function
|
|
4
|
+
declare function isHexString(asset: unknown): boolean;
|
|
5
|
+
declare function isEthAddress(address: string): boolean;
|
|
5
6
|
|
|
6
|
-
declare function
|
|
7
|
-
|
|
8
|
-
decimals: number,
|
|
9
|
-
maxDecimal?: number,
|
|
10
|
-
roundType?: RoundingMode,
|
|
11
|
-
): string;
|
|
12
|
-
declare function toBigInt(
|
|
13
|
-
amount: bigint | string | number,
|
|
14
|
-
decimals: number,
|
|
15
|
-
): bigint;
|
|
16
|
-
declare function convertDecimals(
|
|
17
|
-
number: string | bigint,
|
|
18
|
-
decimals: number,
|
|
19
|
-
targetDecimals: number,
|
|
20
|
-
): bigint;
|
|
21
|
-
declare function hasDecimalOverflow(
|
|
22
|
-
fl: number | string,
|
|
23
|
-
maxDecimal: number,
|
|
24
|
-
): boolean;
|
|
7
|
+
declare function formatAssetIdToERC20(id: string): string;
|
|
8
|
+
declare function convertAddressTo32Bytes(address: string): string;
|
|
25
9
|
|
|
26
|
-
declare function
|
|
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;
|
|
27
14
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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}`;
|
|
35
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 };
|