@moonbeam-network/mrl 1.0.0-dev.164 → 1.0.0-dev.165
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 +135 -1
- package/build/index.d.ts +2 -1
- package/build/index.mjs +21 -14
- package/build/index.mjs.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1 +1,135 @@
|
|
|
1
|
-
|
|
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.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SourceChainTransferData, EvmSigner } from '@moonbeam-network/xcm-sdk';
|
|
2
2
|
import * as _moonbeam_network_xcm_types from '@moonbeam-network/xcm-types';
|
|
3
|
-
import { AssetAmount, AnyChain, EvmChain,
|
|
3
|
+
import { AssetAmount, EvmParachain, AnyChain, EvmChain, Ecosystem, AnyAsset } from '@moonbeam-network/xcm-types';
|
|
4
4
|
import { Signer } from '@polkadot/api/types';
|
|
5
5
|
import { IKeyringPair, ISubmittableResult } from '@polkadot/types/types';
|
|
6
6
|
import { TokenTransfer } from '@wormhole-foundation/sdk-connect';
|
|
@@ -31,6 +31,7 @@ interface SourceTransferData extends SourceChainTransferData {
|
|
|
31
31
|
interface DestinationTransferData extends ChainTransferData {
|
|
32
32
|
}
|
|
33
33
|
type MoonChainTransferData = Omit<ChainTransferData, 'min'> & {
|
|
34
|
+
chain: EvmParachain;
|
|
34
35
|
address: string;
|
|
35
36
|
feeBalance: AssetAmount;
|
|
36
37
|
};
|
package/build/index.mjs
CHANGED
|
@@ -5,7 +5,11 @@ var __export = (target, all) => {
|
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
// src/mrl.ts
|
|
8
|
-
import {
|
|
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";
|
|
@@ -16,19 +20,19 @@ import {
|
|
|
16
20
|
wormholeFactory
|
|
17
21
|
} from "@moonbeam-network/xcm-builder";
|
|
18
22
|
|
|
19
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@
|
|
23
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@1.4.5_bufferutil@4.0.8_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-tokenbridge/dist/esm/index.js
|
|
20
24
|
import { registerProtocol as registerProtocol2 } from "@wormhole-foundation/sdk-connect";
|
|
21
25
|
import { _platform as _platform2 } from "@wormhole-foundation/sdk-evm";
|
|
22
26
|
|
|
23
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@
|
|
27
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@1.4.5_bufferutil@4.0.8_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-tokenbridge/dist/esm/tokenBridge.js
|
|
24
28
|
import { ErrNotWrapped, UniversalAddress, isNative, keccak256 as keccak2562, nativeChainIds as nativeChainIds2, serialize as serialize2, toChain, toChainId, toNative } from "@wormhole-foundation/sdk-connect";
|
|
25
29
|
import { EvmAddress as EvmAddress2, EvmPlatform as EvmPlatform2, EvmUnsignedTransaction as EvmUnsignedTransaction2, EvmZeroAddress, addChainId as addChainId2, addFrom as addFrom2, unusedArbiterFee, unusedNonce } from "@wormhole-foundation/sdk-evm";
|
|
26
30
|
|
|
27
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-core@
|
|
31
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-core@1.4.5_bufferutil@4.0.8_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-core/dist/esm/index.js
|
|
28
32
|
import { registerProtocol } from "@wormhole-foundation/sdk-connect";
|
|
29
33
|
import { _platform } from "@wormhole-foundation/sdk-evm";
|
|
30
34
|
|
|
31
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-core@
|
|
35
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-core@1.4.5_bufferutil@4.0.8_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-core/dist/esm/core.js
|
|
32
36
|
import { nativeChainIds, createVAA, isWormholeMessageId, encoding, serialize } from "@wormhole-foundation/sdk-connect";
|
|
33
37
|
import { EvmAddress, EvmPlatform, EvmUnsignedTransaction, addChainId, addFrom } from "@wormhole-foundation/sdk-evm";
|
|
34
38
|
var EvmWormholeCore = class _EvmWormholeCore {
|
|
@@ -142,7 +146,7 @@ var EvmWormholeCore = class _EvmWormholeCore {
|
|
|
142
146
|
}
|
|
143
147
|
};
|
|
144
148
|
|
|
145
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-core@
|
|
149
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-core@1.4.5_bufferutil@4.0.8_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-core/dist/esm/ethers-contracts/index.js
|
|
146
150
|
var ethers_contracts_exports = {};
|
|
147
151
|
__export(ethers_contracts_exports, {
|
|
148
152
|
Implementation__factory: () => Implementation__factory
|
|
@@ -7289,7 +7293,7 @@ var ContractFactory = class _ContractFactory {
|
|
|
7289
7293
|
}
|
|
7290
7294
|
};
|
|
7291
7295
|
|
|
7292
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-core@
|
|
7296
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-core@1.4.5_bufferutil@4.0.8_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-core/dist/esm/ethers-contracts/factories/Implementation__factory.js
|
|
7293
7297
|
var _abi = [
|
|
7294
7298
|
{
|
|
7295
7299
|
anonymous: false,
|
|
@@ -8359,10 +8363,10 @@ var Implementation__factory = class extends ContractFactory {
|
|
|
8359
8363
|
}
|
|
8360
8364
|
};
|
|
8361
8365
|
|
|
8362
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-core@
|
|
8366
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-core@1.4.5_bufferutil@4.0.8_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-core/dist/esm/index.js
|
|
8363
8367
|
registerProtocol(_platform, "WormholeCore", EvmWormholeCore);
|
|
8364
8368
|
|
|
8365
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@
|
|
8369
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@1.4.5_bufferutil@4.0.8_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-tokenbridge/dist/esm/tokenBridge.js
|
|
8366
8370
|
var EvmTokenBridge = class _EvmTokenBridge {
|
|
8367
8371
|
network;
|
|
8368
8372
|
chain;
|
|
@@ -8491,7 +8495,7 @@ var EvmTokenBridge = class _EvmTokenBridge {
|
|
|
8491
8495
|
}
|
|
8492
8496
|
};
|
|
8493
8497
|
|
|
8494
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@
|
|
8498
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@1.4.5_bufferutil@4.0.8_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-tokenbridge/dist/esm/automaticTokenBridge.js
|
|
8495
8499
|
import { isNative as isNative2, serialize as serialize3, toNative as toNative2, nativeChainIds as nativeChainIds3, toChainId as toChainId2 } from "@wormhole-foundation/sdk-connect";
|
|
8496
8500
|
import { EvmAddress as EvmAddress3, EvmPlatform as EvmPlatform3, EvmUnsignedTransaction as EvmUnsignedTransaction3, addChainId as addChainId3, addFrom as addFrom3 } from "@wormhole-foundation/sdk-evm";
|
|
8497
8501
|
var EvmAutomaticTokenBridge = class _EvmAutomaticTokenBridge {
|
|
@@ -8593,14 +8597,14 @@ var EvmAutomaticTokenBridge = class _EvmAutomaticTokenBridge {
|
|
|
8593
8597
|
}
|
|
8594
8598
|
};
|
|
8595
8599
|
|
|
8596
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@
|
|
8600
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@1.4.5_bufferutil@4.0.8_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-tokenbridge/dist/esm/ethers-contracts/index.js
|
|
8597
8601
|
var ethers_contracts_exports2 = {};
|
|
8598
8602
|
__export(ethers_contracts_exports2, {
|
|
8599
8603
|
Bridge__factory: () => Bridge__factory,
|
|
8600
8604
|
TokenBridgeRelayer__factory: () => TokenBridgeRelayer__factory
|
|
8601
8605
|
});
|
|
8602
8606
|
|
|
8603
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@
|
|
8607
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@1.4.5_bufferutil@4.0.8_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-tokenbridge/dist/esm/ethers-contracts/factories/Bridge__factory.js
|
|
8604
8608
|
var _abi2 = [
|
|
8605
8609
|
{
|
|
8606
8610
|
anonymous: false,
|
|
@@ -9840,7 +9844,7 @@ var Bridge__factory = class extends ContractFactory {
|
|
|
9840
9844
|
}
|
|
9841
9845
|
};
|
|
9842
9846
|
|
|
9843
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@
|
|
9847
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@1.4.5_bufferutil@4.0.8_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-tokenbridge/dist/esm/ethers-contracts/factories/TokenBridgeRelayer__factory.js
|
|
9844
9848
|
var _abi3 = [
|
|
9845
9849
|
{
|
|
9846
9850
|
inputs: [
|
|
@@ -10911,7 +10915,7 @@ var TokenBridgeRelayer__factory = class extends ContractFactory {
|
|
|
10911
10915
|
}
|
|
10912
10916
|
};
|
|
10913
10917
|
|
|
10914
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@
|
|
10918
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@1.4.5_bufferutil@4.0.8_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-tokenbridge/dist/esm/index.js
|
|
10915
10919
|
registerProtocol2(_platform2, "TokenBridge", EvmTokenBridge);
|
|
10916
10920
|
registerProtocol2(_platform2, "AutomaticTokenBridge", EvmAutomaticTokenBridge);
|
|
10917
10921
|
|
|
@@ -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 {
|