@moonbeam-network/mrl 1.0.0-dev.161 → 1.0.0-dev.162
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/build/index.mjs +38 -19
- package/build/index.mjs.map +1 -1
- package/package.json +10 -7
package/build/index.mjs
CHANGED
|
@@ -11085,7 +11085,7 @@ import {
|
|
|
11085
11085
|
} from "@moonbeam-network/xcm-sdk";
|
|
11086
11086
|
import {
|
|
11087
11087
|
AssetAmount as AssetAmount3,
|
|
11088
|
-
EvmChain
|
|
11088
|
+
EvmChain,
|
|
11089
11089
|
EvmParachain as EvmParachain3
|
|
11090
11090
|
} from "@moonbeam-network/xcm-types";
|
|
11091
11091
|
import { toBigInt as toBigInt3 } from "@moonbeam-network/xcm-utils";
|
|
@@ -11094,7 +11094,10 @@ import Big2 from "big.js";
|
|
|
11094
11094
|
// src/getTransferData/getMoonChainData.ts
|
|
11095
11095
|
import { getMoonChain } from "@moonbeam-network/xcm-config";
|
|
11096
11096
|
import { getBalance, getDestinationFee } from "@moonbeam-network/xcm-sdk";
|
|
11097
|
-
import {
|
|
11097
|
+
import {
|
|
11098
|
+
EvmParachain,
|
|
11099
|
+
Parachain
|
|
11100
|
+
} from "@moonbeam-network/xcm-types";
|
|
11098
11101
|
import { getMultilocationDerivedAddresses } from "@moonbeam-network/xcm-utils";
|
|
11099
11102
|
import { evmToAddress } from "@polkadot/util-crypto";
|
|
11100
11103
|
async function getMoonChainData({
|
|
@@ -11108,44 +11111,60 @@ async function getMoonChainData({
|
|
|
11108
11111
|
);
|
|
11109
11112
|
}
|
|
11110
11113
|
const moonChain = getMoonChain(route.source.chain);
|
|
11111
|
-
const
|
|
11112
|
-
|
|
11114
|
+
const moonChainAddress = getMoonChainAddress({
|
|
11115
|
+
source: route.source.chain,
|
|
11116
|
+
destination: route.destination.chain,
|
|
11117
|
+
sourceAddress,
|
|
11118
|
+
destinationAddress
|
|
11119
|
+
});
|
|
11113
11120
|
const fee = await getDestinationFee({
|
|
11114
|
-
address,
|
|
11121
|
+
address: moonChainAddress,
|
|
11115
11122
|
asset: route.source.asset,
|
|
11116
11123
|
destination: moonChain,
|
|
11117
11124
|
fee: route.mrl.moonChain.fee.amount,
|
|
11118
11125
|
feeAsset: route.mrl.moonChain.fee.asset
|
|
11119
11126
|
});
|
|
11120
|
-
if (Parachain.is(route.source.chain) && !route.source.chain.isEqual(moonChain)) {
|
|
11121
|
-
const addressToUse = EvmParachain.is(route.source.chain) ? evmToAddress(sourceAddress) : sourceAddress;
|
|
11122
|
-
const { address20 } = getMultilocationDerivedAddresses({
|
|
11123
|
-
address: addressToUse,
|
|
11124
|
-
paraId: route.source.chain.parachainId,
|
|
11125
|
-
isParents: true
|
|
11126
|
-
});
|
|
11127
|
-
address = address20;
|
|
11128
|
-
}
|
|
11129
11127
|
const balance = await getBalance({
|
|
11130
|
-
address,
|
|
11128
|
+
address: moonChainAddress,
|
|
11131
11129
|
asset: moonChain.getChainAsset(route.mrl.moonChain.asset),
|
|
11132
11130
|
builder: route.mrl.moonChain.balance,
|
|
11133
11131
|
chain: moonChain
|
|
11134
11132
|
});
|
|
11135
11133
|
const feeBalance = await getBalance({
|
|
11136
|
-
address,
|
|
11134
|
+
address: moonChainAddress,
|
|
11137
11135
|
asset: moonChain.getChainAsset(route.mrl.moonChain.fee.asset),
|
|
11138
11136
|
builder: route.mrl.moonChain.fee.balance,
|
|
11139
11137
|
chain: moonChain
|
|
11140
11138
|
});
|
|
11141
11139
|
return {
|
|
11142
|
-
address,
|
|
11140
|
+
address: moonChainAddress,
|
|
11143
11141
|
balance,
|
|
11144
11142
|
feeBalance,
|
|
11145
11143
|
chain: moonChain,
|
|
11146
11144
|
fee
|
|
11147
11145
|
};
|
|
11148
11146
|
}
|
|
11147
|
+
function getMoonChainAddress({
|
|
11148
|
+
source,
|
|
11149
|
+
destination,
|
|
11150
|
+
sourceAddress,
|
|
11151
|
+
destinationAddress
|
|
11152
|
+
}) {
|
|
11153
|
+
const moonChain = getMoonChain(source);
|
|
11154
|
+
const isDestinationMoonChain = moonChain.isEqual(destination);
|
|
11155
|
+
const isSourceMoonChain = moonChain.isEqual(source);
|
|
11156
|
+
let moonChainAddress = isDestinationMoonChain ? destinationAddress : sourceAddress;
|
|
11157
|
+
if (Parachain.is(source) && !isSourceMoonChain) {
|
|
11158
|
+
const isSourceEvmSigner = EvmParachain.is(source) && source.isEvmSigner;
|
|
11159
|
+
const { address20: computedOriginAccount } = getMultilocationDerivedAddresses({
|
|
11160
|
+
address: isSourceEvmSigner ? evmToAddress(sourceAddress) : sourceAddress,
|
|
11161
|
+
paraId: source.parachainId,
|
|
11162
|
+
isParents: true
|
|
11163
|
+
});
|
|
11164
|
+
moonChainAddress = computedOriginAccount;
|
|
11165
|
+
}
|
|
11166
|
+
return moonChainAddress;
|
|
11167
|
+
}
|
|
11149
11168
|
|
|
11150
11169
|
// src/getTransferData/getSourceData.ts
|
|
11151
11170
|
import {
|
|
@@ -11644,7 +11663,7 @@ async function getTransferData({
|
|
|
11644
11663
|
sendOnlyRemoteExecution,
|
|
11645
11664
|
sourceAddress
|
|
11646
11665
|
});
|
|
11647
|
-
if (ContractConfig2.is(transfer) && (
|
|
11666
|
+
if (ContractConfig2.is(transfer) && (EvmChain.is(source) || EvmParachain3.is(source))) {
|
|
11648
11667
|
if (!evmSigner) {
|
|
11649
11668
|
throw new Error("EVM Signer must be provided");
|
|
11650
11669
|
}
|
|
@@ -11665,7 +11684,7 @@ async function getTransferData({
|
|
|
11665
11684
|
);
|
|
11666
11685
|
return [hash];
|
|
11667
11686
|
}
|
|
11668
|
-
if (WormholeConfig2.is(transfer) && (
|
|
11687
|
+
if (WormholeConfig2.is(transfer) && (EvmChain.is(source) || EvmParachain3.is(source))) {
|
|
11669
11688
|
if (!evmSigner) {
|
|
11670
11689
|
throw new Error("EVM Signer must be provided");
|
|
11671
11690
|
}
|