@moonbeam-network/mrl 3.0.0 → 3.0.1

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 CHANGED
@@ -1 +1,135 @@
1
- // TODO:
1
+ The Moonbeam MRL SDK enables developers to easily transfer liquidity into and across the Polkadot ecosystem from other ecosystems like Ethereum. With the SDK, you don't need to worry about setting up the different contract calls and extrinsics involved in the process of moving assets between the chains and ecosystems. It is an extension of the XCM SDK as it uses the same config and utils.
2
+
3
+ The MRL SDK offers helper functions that provide a very simple interface to execute transfers from parachains or contract calls from EVM chains. In addition, the MRL config package allows any external project to add their information in a standard way, allowing immediate support by the MRL SDK.
4
+
5
+ # Documentation
6
+
7
+ You can find the documentation at [https://moonbeam-foundation.github.io/xcm-sdk/latest/](https://moonbeam-foundation.github.io/xcm-sdk/latest/reference/mrl/).
8
+
9
+ # Installation
10
+
11
+ ```bash
12
+ npm i @moonbeam-network/mrl
13
+ ```
14
+
15
+ :warning: You need to have peer dependencies of SDK installed as well.
16
+
17
+ ```bash
18
+ npm install @polkadot/api @polkadot/util-crypto
19
+ ```
20
+
21
+ # Usage
22
+
23
+ The following sections contain basic examples of how to work with the MRL SDK to build transfer data to transfer an asset from one chain to another and how to submit the transfer. For a detailed overview on how to use it, please refer to the [XCM SDK docs](https://moonbeam-foundation.github.io/xcm-sdk/latest/example-usage/mrl).
24
+
25
+ ## Build MRL Transfer Data
26
+
27
+ ```js
28
+ import { Mrl } from '@moonbeam-network/mrl';
29
+
30
+ const fromEvm = async () => {
31
+ const transferData = await Mrl()
32
+ .setSource(INSERT_SOURCE_CHAIN)
33
+ .setDestination(INSERT_DESTINATION_CHAIN)
34
+ .setAsset(INSERT_ASSET)
35
+ .setIsAutomatic(INSERT_IF_IS_AUTOMATIC)
36
+ .setAddresses({
37
+ sourceAddress: INSERT_SOURCE_ADDRESS,
38
+ destinationAddress: INSERT_DESTINATION_ADDRESS,
39
+ });
40
+ };
41
+
42
+ fromEvm();
43
+ ```
44
+
45
+ ## Transfer
46
+
47
+ ```js
48
+ ...
49
+
50
+ const hash = await transferData.transfer(INSERT_TRANSFER_AMOUNT, INSERT_IF_IS_AUTOMATIC, { INSERT_SIGNERS });
51
+
52
+ ```
53
+
54
+ # Examples
55
+
56
+ - [mrl](https://github.com/moonbeam-foundation/xcm-sdk/blob/main/examples/mrl-simple)
57
+
58
+ ```bash
59
+ git clone git@github.com:moonbeam-foundation/xcm-sdk.git
60
+ cd xcm-sdk
61
+ pnpm install
62
+ cd examples/mrl-simple
63
+
64
+ # edit index.ts by adding your accounts
65
+
66
+ pnpm run start
67
+ ```
68
+
69
+ # Contributing
70
+
71
+ First fork the repository and clone it.
72
+
73
+ ```bash
74
+ git clone git@github.com:YOUR_GITHUB_USERNAME/xcm-sdk.git
75
+ pnpm install
76
+ ```
77
+
78
+ Optionally, you can install the `pre-commit` hook to run the linter and tests before committing:
79
+
80
+ ```bash
81
+ pnpm lefthook install
82
+ ```
83
+
84
+ # Tests
85
+
86
+ ## Unit tests
87
+
88
+ ```bash
89
+ pnpm run test
90
+ ```
91
+
92
+ ## Acceptance tests
93
+
94
+ ```bash
95
+ pnpm run test:acc
96
+ ```
97
+
98
+ # Release
99
+
100
+ To create a dev version go to GitHub actions and run `publish dev versions` workflow.
101
+
102
+ To create a release version run:
103
+
104
+ ```bash
105
+ pnpm run changeset
106
+ ```
107
+
108
+ # Testing the change in the SDK locally
109
+
110
+ Build the project:
111
+
112
+ ```bash
113
+ pnpm run build
114
+ ```
115
+
116
+ Link the SDK:
117
+
118
+ ```bash
119
+ pnpm run clean && pnpm run build && pnpm run link
120
+ ```
121
+
122
+ In your project where you would like to test the changes:
123
+
124
+ ```bash
125
+ pnpm link @moonbeam-network/xcm-types @moonbeam-network/xcm-utils @moonbeam-network/xcm-builder @moonbeam-network/xcm-config @moonbeam-network/xcm-sdk @moonbeam-network/mrl
126
+ ```
127
+
128
+ If you need you can link other packages too.
129
+
130
+ After testing is done, unlink the SDK:
131
+
132
+ ```bash
133
+ pnpm unlink @moonbeam-network/xcm-types @moonbeam-network/xcm-utils @moonbeam-network/xcm-builder @moonbeam-network/xcm-config @moonbeam-network/xcm-sdk @moonbeam-network/mrl
134
+ ```
135
+
package/build/index.mjs CHANGED
@@ -5,7 +5,11 @@ var __export = (target, all) => {
5
5
  };
6
6
 
7
7
  // src/mrl.ts
8
- import { ConfigService, mrlRoutesMap } from "@moonbeam-network/xcm-config";
8
+ import {
9
+ ConfigService,
10
+ MrlAssetRoute,
11
+ mrlRoutesMap
12
+ } from "@moonbeam-network/xcm-config";
9
13
 
10
14
  // src/getTransferData/getExecuteTransferData.ts
11
15
  import { MrlBuilder } from "@moonbeam-network/xcm-builder";
@@ -11722,6 +11726,9 @@ function Mrl(options) {
11722
11726
  source,
11723
11727
  destination
11724
11728
  });
11729
+ if (!(route instanceof MrlAssetRoute)) {
11730
+ throw new Error("Route must be an MrlAssetRoute");
11731
+ }
11725
11732
  return {
11726
11733
  setIsAutomatic(isAutomatic) {
11727
11734
  return {