@moonbeam-network/xcm-builder 1.0.0-dev.280 → 1.0.0-dev.282
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.d.ts +12 -2
- package/build/index.mjs +209 -20
- package/build/index.mjs.map +1 -1
- package/package.json +3 -3
package/build/index.d.ts
CHANGED
|
@@ -417,7 +417,7 @@ declare function eqBalances(): {
|
|
|
417
417
|
transferXcm: () => ExtrinsicConfigBuilder;
|
|
418
418
|
};
|
|
419
419
|
|
|
420
|
-
declare function polkadotXcm$
|
|
420
|
+
declare function polkadotXcm$2(): {
|
|
421
421
|
limitedReserveTransferAssets: () => {
|
|
422
422
|
here: () => ExtrinsicConfigBuilder;
|
|
423
423
|
X1: () => ExtrinsicConfigBuilder;
|
|
@@ -478,7 +478,7 @@ declare function ExtrinsicBuilder(): {
|
|
|
478
478
|
eqBalances: typeof eqBalances;
|
|
479
479
|
xTokens: typeof xTokens;
|
|
480
480
|
xTransfer: typeof xTransfer;
|
|
481
|
-
polkadotXcm: typeof polkadotXcm$
|
|
481
|
+
polkadotXcm: typeof polkadotXcm$2;
|
|
482
482
|
xcmPallet: typeof xcmPallet$1;
|
|
483
483
|
};
|
|
484
484
|
|
|
@@ -511,6 +511,7 @@ interface BridgeFeeConfigBuilderParams {
|
|
|
511
511
|
balance?: AssetAmount;
|
|
512
512
|
destination: AnyChain;
|
|
513
513
|
source: AnyChain;
|
|
514
|
+
bridgeChainFee: AssetAmount;
|
|
514
515
|
}
|
|
515
516
|
interface XcmPaymentFeeProps {
|
|
516
517
|
isAssetReserveChain: boolean;
|
|
@@ -607,6 +608,7 @@ interface SnowbridgeFunctionArgs {
|
|
|
607
608
|
destinationParaId: number;
|
|
608
609
|
amount: bigint;
|
|
609
610
|
bridgeFeeAmount: bigint;
|
|
611
|
+
bridgeChainFee: bigint;
|
|
610
612
|
requiresApproval: boolean;
|
|
611
613
|
}
|
|
612
614
|
interface SnowbridgeConfigConstructorParams {
|
|
@@ -1739,6 +1741,7 @@ type MrlExecuteConfigBuilder = ConfigBuilder<ContractConfig, MrlExecuteBuilderPa
|
|
|
1739
1741
|
interface MrlBuilderParams extends BuilderParams<AnyChain> {
|
|
1740
1742
|
isAutomatic: boolean;
|
|
1741
1743
|
protocolFee?: AssetAmount;
|
|
1744
|
+
bridgeChainFee?: AssetAmount;
|
|
1742
1745
|
moonApi: ApiPromise;
|
|
1743
1746
|
moonAsset: ChainAsset;
|
|
1744
1747
|
bridgeChain: AnyParachain;
|
|
@@ -1770,6 +1773,12 @@ declare function ethereumTokenTransfers(): {
|
|
|
1770
1773
|
transferNativeToken: () => MrlConfigBuilder;
|
|
1771
1774
|
};
|
|
1772
1775
|
|
|
1776
|
+
declare function polkadotXcm$1(): {
|
|
1777
|
+
transferAssetsUsingTypeAndThen: () => {
|
|
1778
|
+
canonicalEth: () => MrlConfigBuilder;
|
|
1779
|
+
};
|
|
1780
|
+
};
|
|
1781
|
+
|
|
1773
1782
|
declare function xcmPallet(): {
|
|
1774
1783
|
transferAssets: () => {
|
|
1775
1784
|
globalConsensus: () => MrlConfigBuilder;
|
|
@@ -1780,6 +1789,7 @@ declare function xcmPallet(): {
|
|
|
1780
1789
|
declare function extrinsic$1(): {
|
|
1781
1790
|
ethereumTokenTransfers: typeof ethereumTokenTransfers;
|
|
1782
1791
|
xcmPallet: typeof xcmPallet;
|
|
1792
|
+
polkadotXcm: typeof polkadotXcm$1;
|
|
1783
1793
|
};
|
|
1784
1794
|
|
|
1785
1795
|
declare function snowbridge(): {
|
package/build/index.mjs
CHANGED
|
@@ -119,11 +119,11 @@ function AssetMinBuilder() {
|
|
|
119
119
|
};
|
|
120
120
|
}
|
|
121
121
|
function assetRegistry() {
|
|
122
|
-
const
|
|
122
|
+
const pallet9 = "assetRegistry";
|
|
123
123
|
return {
|
|
124
124
|
assetMetadatas: () => ({
|
|
125
125
|
build: ({ asset }) => new SubstrateQueryConfig({
|
|
126
|
-
module:
|
|
126
|
+
module: pallet9,
|
|
127
127
|
func: "assetMetadatas",
|
|
128
128
|
args: [asset],
|
|
129
129
|
// biome-ignore lint/suspicious/noExplicitAny: not sure how to fix this
|
|
@@ -132,7 +132,7 @@ function assetRegistry() {
|
|
|
132
132
|
}),
|
|
133
133
|
currencyMetadatas: () => ({
|
|
134
134
|
build: ({ asset }) => new SubstrateQueryConfig({
|
|
135
|
-
module:
|
|
135
|
+
module: pallet9,
|
|
136
136
|
func: "currencyMetadatas",
|
|
137
137
|
args: [asset],
|
|
138
138
|
// biome-ignore lint/suspicious/noExplicitAny: not sure how to fix this
|
|
@@ -141,7 +141,7 @@ function assetRegistry() {
|
|
|
141
141
|
}),
|
|
142
142
|
metadata: () => ({
|
|
143
143
|
build: ({ asset }) => new SubstrateQueryConfig({
|
|
144
|
-
module:
|
|
144
|
+
module: pallet9,
|
|
145
145
|
func: "metadata",
|
|
146
146
|
args: [asset],
|
|
147
147
|
// biome-ignore lint/suspicious/noExplicitAny: not sure how to fix this
|
|
@@ -3912,7 +3912,7 @@ function gateway() {
|
|
|
3912
3912
|
return {
|
|
3913
3913
|
quoteSendTokenFee() {
|
|
3914
3914
|
return {
|
|
3915
|
-
build: ({ asset, destination, source }) => {
|
|
3915
|
+
build: ({ asset, destination, source, bridgeChainFee }) => {
|
|
3916
3916
|
if (!asset.address) {
|
|
3917
3917
|
throw new Error(`Asset ${asset.key} has no address`);
|
|
3918
3918
|
}
|
|
@@ -3929,7 +3929,11 @@ function gateway() {
|
|
|
3929
3929
|
return new ContractConfig({
|
|
3930
3930
|
address: source.contracts.Gateway,
|
|
3931
3931
|
abi: GATEWAY_ABI,
|
|
3932
|
-
args: [
|
|
3932
|
+
args: [
|
|
3933
|
+
asset.address,
|
|
3934
|
+
destination.parachainId,
|
|
3935
|
+
bridgeChainFee.amount
|
|
3936
|
+
],
|
|
3933
3937
|
func: "quoteSendTokenFee",
|
|
3934
3938
|
module: "Gateway"
|
|
3935
3939
|
});
|
|
@@ -4715,27 +4719,49 @@ function Gateway() {
|
|
|
4715
4719
|
return {
|
|
4716
4720
|
sendToken: () => ({
|
|
4717
4721
|
provider,
|
|
4718
|
-
build: ({
|
|
4722
|
+
build: ({
|
|
4723
|
+
asset,
|
|
4724
|
+
destinationAddress,
|
|
4725
|
+
protocolFee,
|
|
4726
|
+
destination,
|
|
4727
|
+
bridgeChainFee
|
|
4728
|
+
}) => callSendToken(
|
|
4729
|
+
asset,
|
|
4730
|
+
protocolFee,
|
|
4731
|
+
destination,
|
|
4732
|
+
destinationAddress,
|
|
4733
|
+
bridgeChainFee
|
|
4734
|
+
)
|
|
4719
4735
|
}),
|
|
4720
4736
|
approveAndSendToken: () => ({
|
|
4721
4737
|
provider,
|
|
4722
|
-
build: ({
|
|
4738
|
+
build: ({
|
|
4739
|
+
asset,
|
|
4740
|
+
destinationAddress,
|
|
4741
|
+
protocolFee,
|
|
4742
|
+
destination,
|
|
4743
|
+
bridgeChainFee
|
|
4744
|
+
}) => {
|
|
4723
4745
|
const requiresApproval = protocolFee && !protocolFee.isSame(asset);
|
|
4724
4746
|
return callSendToken(
|
|
4725
4747
|
asset,
|
|
4726
4748
|
protocolFee,
|
|
4727
4749
|
destination,
|
|
4728
4750
|
destinationAddress,
|
|
4751
|
+
bridgeChainFee,
|
|
4729
4752
|
requiresApproval
|
|
4730
4753
|
);
|
|
4731
4754
|
}
|
|
4732
4755
|
})
|
|
4733
4756
|
};
|
|
4734
4757
|
}
|
|
4735
|
-
function callSendToken(asset, protocolFee, destination, destinationAddress, requiresApproval = false) {
|
|
4758
|
+
function callSendToken(asset, protocolFee, destination, destinationAddress, bridgeChainFee, requiresApproval = false) {
|
|
4736
4759
|
if (!protocolFee) {
|
|
4737
4760
|
throw new Error("Protocol fee is required for Gateway module");
|
|
4738
4761
|
}
|
|
4762
|
+
if (!bridgeChainFee) {
|
|
4763
|
+
throw new Error("Bridge chain fee is required for Gateway module");
|
|
4764
|
+
}
|
|
4739
4765
|
if (!EvmParachain4.isAnyParachain(destination)) {
|
|
4740
4766
|
throw new Error(
|
|
4741
4767
|
"Destination must be a Parachain or EvmParachain for sending token with Gateway module"
|
|
@@ -4748,6 +4774,7 @@ function callSendToken(asset, protocolFee, destination, destinationAddress, requ
|
|
|
4748
4774
|
destinationParaId: destination.parachainId,
|
|
4749
4775
|
amount: asset.amount,
|
|
4750
4776
|
bridgeFeeAmount: protocolFee.amount,
|
|
4777
|
+
bridgeChainFee: bridgeChainFee.amount,
|
|
4751
4778
|
requiresApproval
|
|
4752
4779
|
},
|
|
4753
4780
|
func: "sendToken"
|
|
@@ -4780,8 +4807,170 @@ function ethereumTokenTransfers() {
|
|
|
4780
4807
|
};
|
|
4781
4808
|
}
|
|
4782
4809
|
|
|
4783
|
-
// src/mrl/providers/snowbridge/extrinsic/
|
|
4810
|
+
// src/mrl/providers/snowbridge/extrinsic/polkadotXcm/polkadotXcm.ts
|
|
4784
4811
|
import { EvmChain as EvmChain2 } from "@moonbeam-network/xcm-types";
|
|
4812
|
+
var pallet7 = "polkadotXcm";
|
|
4813
|
+
function polkadotXcm2() {
|
|
4814
|
+
return {
|
|
4815
|
+
transferAssetsUsingTypeAndThen: () => {
|
|
4816
|
+
const func = "transferAssetsUsingTypeAndThen";
|
|
4817
|
+
const provider = "snowbridge" /* Snowbridge */;
|
|
4818
|
+
return {
|
|
4819
|
+
// TODO mjm rename ? nativeEth?
|
|
4820
|
+
canonicalEth: () => ({
|
|
4821
|
+
provider,
|
|
4822
|
+
build: ({
|
|
4823
|
+
asset,
|
|
4824
|
+
destination,
|
|
4825
|
+
destinationAddress,
|
|
4826
|
+
bridgeChainFee
|
|
4827
|
+
}) => {
|
|
4828
|
+
if (!EvmChain2.is(destination)) {
|
|
4829
|
+
throw new Error(
|
|
4830
|
+
"Destination must be an EVM chain for globalConsensus function"
|
|
4831
|
+
);
|
|
4832
|
+
}
|
|
4833
|
+
if (!bridgeChainFee) {
|
|
4834
|
+
throw new Error(
|
|
4835
|
+
"Bridge chain fee is required for the polkadotXcm.canonicalEth function"
|
|
4836
|
+
);
|
|
4837
|
+
}
|
|
4838
|
+
return new ExtrinsicConfig({
|
|
4839
|
+
module: pallet7,
|
|
4840
|
+
func,
|
|
4841
|
+
getArgs: (extrinsicFunction) => {
|
|
4842
|
+
const version = getExtrinsicArgumentVersion(extrinsicFunction);
|
|
4843
|
+
const dest = {
|
|
4844
|
+
[version]: {
|
|
4845
|
+
parents: 1,
|
|
4846
|
+
interior: "Here"
|
|
4847
|
+
}
|
|
4848
|
+
};
|
|
4849
|
+
const assets3 = {
|
|
4850
|
+
[version]: [
|
|
4851
|
+
{
|
|
4852
|
+
id: {
|
|
4853
|
+
parents: 1,
|
|
4854
|
+
interior: "Here"
|
|
4855
|
+
},
|
|
4856
|
+
fun: { Fungible: bridgeChainFee.amount }
|
|
4857
|
+
},
|
|
4858
|
+
{
|
|
4859
|
+
id: {
|
|
4860
|
+
parents: 2,
|
|
4861
|
+
interior: {
|
|
4862
|
+
X1: [
|
|
4863
|
+
{
|
|
4864
|
+
GlobalConsensus: {
|
|
4865
|
+
Ethereum: { chainId: destination.id }
|
|
4866
|
+
}
|
|
4867
|
+
}
|
|
4868
|
+
]
|
|
4869
|
+
}
|
|
4870
|
+
},
|
|
4871
|
+
fun: { Fungible: asset.amount }
|
|
4872
|
+
}
|
|
4873
|
+
]
|
|
4874
|
+
};
|
|
4875
|
+
const assetsTransferType = 2 /* DestinationReserve */;
|
|
4876
|
+
const remoteFeesId = {
|
|
4877
|
+
[version]: {
|
|
4878
|
+
parents: 1,
|
|
4879
|
+
interior: "Here"
|
|
4880
|
+
}
|
|
4881
|
+
};
|
|
4882
|
+
const feesTransferType = 2 /* DestinationReserve */;
|
|
4883
|
+
const customXcmOnDest = {
|
|
4884
|
+
[version]: [
|
|
4885
|
+
{
|
|
4886
|
+
InitiateReserveWithdraw: {
|
|
4887
|
+
assets: {
|
|
4888
|
+
Definite: [
|
|
4889
|
+
{
|
|
4890
|
+
id: {
|
|
4891
|
+
parents: 1,
|
|
4892
|
+
interior: {
|
|
4893
|
+
X1: [
|
|
4894
|
+
{
|
|
4895
|
+
GlobalConsensus: {
|
|
4896
|
+
Ethereum: { chainId: destination.id }
|
|
4897
|
+
}
|
|
4898
|
+
}
|
|
4899
|
+
]
|
|
4900
|
+
}
|
|
4901
|
+
},
|
|
4902
|
+
fun: { Fungible: asset.amount }
|
|
4903
|
+
}
|
|
4904
|
+
]
|
|
4905
|
+
},
|
|
4906
|
+
reserve: {
|
|
4907
|
+
parents: 1,
|
|
4908
|
+
interior: {
|
|
4909
|
+
X1: [
|
|
4910
|
+
{
|
|
4911
|
+
GlobalConsensus: {
|
|
4912
|
+
Ethereum: { chainId: destination.id }
|
|
4913
|
+
}
|
|
4914
|
+
}
|
|
4915
|
+
]
|
|
4916
|
+
}
|
|
4917
|
+
},
|
|
4918
|
+
xcm: [
|
|
4919
|
+
{
|
|
4920
|
+
DepositAsset: {
|
|
4921
|
+
assets: {
|
|
4922
|
+
Definite: [
|
|
4923
|
+
{
|
|
4924
|
+
id: {
|
|
4925
|
+
parents: 0,
|
|
4926
|
+
interior: "Here"
|
|
4927
|
+
},
|
|
4928
|
+
fun: { Fungible: asset.amount }
|
|
4929
|
+
}
|
|
4930
|
+
]
|
|
4931
|
+
},
|
|
4932
|
+
beneficiary: {
|
|
4933
|
+
parents: 0,
|
|
4934
|
+
interior: {
|
|
4935
|
+
X1: [
|
|
4936
|
+
{
|
|
4937
|
+
AccountKey20: {
|
|
4938
|
+
network: {
|
|
4939
|
+
Ethereum: { chainId: destination.id }
|
|
4940
|
+
},
|
|
4941
|
+
key: destinationAddress
|
|
4942
|
+
}
|
|
4943
|
+
}
|
|
4944
|
+
]
|
|
4945
|
+
}
|
|
4946
|
+
}
|
|
4947
|
+
}
|
|
4948
|
+
}
|
|
4949
|
+
]
|
|
4950
|
+
}
|
|
4951
|
+
}
|
|
4952
|
+
]
|
|
4953
|
+
};
|
|
4954
|
+
return [
|
|
4955
|
+
dest,
|
|
4956
|
+
assets3,
|
|
4957
|
+
assetsTransferType,
|
|
4958
|
+
remoteFeesId,
|
|
4959
|
+
feesTransferType,
|
|
4960
|
+
customXcmOnDest,
|
|
4961
|
+
"Unlimited"
|
|
4962
|
+
];
|
|
4963
|
+
}
|
|
4964
|
+
});
|
|
4965
|
+
}
|
|
4966
|
+
})
|
|
4967
|
+
};
|
|
4968
|
+
}
|
|
4969
|
+
};
|
|
4970
|
+
}
|
|
4971
|
+
|
|
4972
|
+
// src/mrl/providers/snowbridge/extrinsic/xcmPallet/xcmPallet.ts
|
|
4973
|
+
import { EvmChain as EvmChain3 } from "@moonbeam-network/xcm-types";
|
|
4785
4974
|
|
|
4786
4975
|
// src/mrl/providers/snowbridge/extrinsic/xcmPallet/xcmPallet.utils.ts
|
|
4787
4976
|
function getGlobalConsensusArgs({
|
|
@@ -4834,7 +5023,7 @@ function getGlobalConsensusArgs({
|
|
|
4834
5023
|
}
|
|
4835
5024
|
|
|
4836
5025
|
// src/mrl/providers/snowbridge/extrinsic/xcmPallet/xcmPallet.ts
|
|
4837
|
-
var
|
|
5026
|
+
var pallet8 = "xcmPallet";
|
|
4838
5027
|
function xcmPallet2() {
|
|
4839
5028
|
return {
|
|
4840
5029
|
transferAssets: () => {
|
|
@@ -4844,13 +5033,13 @@ function xcmPallet2() {
|
|
|
4844
5033
|
globalConsensus: () => ({
|
|
4845
5034
|
provider,
|
|
4846
5035
|
build: ({ asset, destination, destinationAddress }) => {
|
|
4847
|
-
if (!
|
|
5036
|
+
if (!EvmChain3.is(destination)) {
|
|
4848
5037
|
throw new Error(
|
|
4849
5038
|
"Destination must be an EVM chain for globalConsensus function"
|
|
4850
5039
|
);
|
|
4851
5040
|
}
|
|
4852
5041
|
return new ExtrinsicConfig({
|
|
4853
|
-
module:
|
|
5042
|
+
module: pallet8,
|
|
4854
5043
|
func,
|
|
4855
5044
|
getArgs: (extrinsicFunction) => {
|
|
4856
5045
|
const assets3 = [
|
|
@@ -4883,14 +5072,14 @@ function xcmPallet2() {
|
|
|
4883
5072
|
globalConsensusErc20: () => ({
|
|
4884
5073
|
provider,
|
|
4885
5074
|
build: ({ asset, destination, destinationAddress }) => {
|
|
4886
|
-
if (!
|
|
5075
|
+
if (!EvmChain3.is(destination)) {
|
|
4887
5076
|
throw new Error(
|
|
4888
5077
|
"Destination must be an EVM chain for globalConsensusErc20 function"
|
|
4889
5078
|
);
|
|
4890
5079
|
}
|
|
4891
5080
|
const assetInDestination = destination.getChainAsset(asset);
|
|
4892
5081
|
return new ExtrinsicConfig({
|
|
4893
|
-
module:
|
|
5082
|
+
module: pallet8,
|
|
4894
5083
|
func,
|
|
4895
5084
|
getArgs: (extrinsicFunction) => {
|
|
4896
5085
|
const assets3 = [
|
|
@@ -4935,7 +5124,7 @@ function xcmPallet2() {
|
|
|
4935
5124
|
|
|
4936
5125
|
// src/mrl/providers/snowbridge/extrinsic/index.ts
|
|
4937
5126
|
function extrinsic() {
|
|
4938
|
-
return { ethereumTokenTransfers, xcmPallet: xcmPallet2 };
|
|
5127
|
+
return { ethereumTokenTransfers, xcmPallet: xcmPallet2, polkadotXcm: polkadotXcm2 };
|
|
4939
5128
|
}
|
|
4940
5129
|
|
|
4941
5130
|
// src/mrl/providers/snowbridge/index.ts
|
|
@@ -4962,7 +5151,7 @@ import {
|
|
|
4962
5151
|
import { getMultilocationDerivedAddresses } from "@moonbeam-network/xcm-utils";
|
|
4963
5152
|
var BUY_EXECUTION_FEE = 100000000000000000n;
|
|
4964
5153
|
var CROSS_CHAIN_FEE = 100000000000000000n;
|
|
4965
|
-
function
|
|
5154
|
+
function polkadotXcm3() {
|
|
4966
5155
|
const provider = "wormhole" /* Wormhole */;
|
|
4967
5156
|
return {
|
|
4968
5157
|
send: () => ({
|
|
@@ -5915,7 +6104,7 @@ var WormholeConfig = class _WormholeConfig {
|
|
|
5915
6104
|
};
|
|
5916
6105
|
|
|
5917
6106
|
// src/mrl/providers/wormhole/wormhole/wormhole.ts
|
|
5918
|
-
import { EvmChain as
|
|
6107
|
+
import { EvmChain as EvmChain4, EvmParachain as EvmParachain7, Parachain as Parachain3 } from "@moonbeam-network/xcm-types";
|
|
5919
6108
|
import { getMultilocationDerivedAddresses as getMultilocationDerivedAddresses3 } from "@moonbeam-network/xcm-utils";
|
|
5920
6109
|
import { evmToAddress as evmToAddress4 } from "@polkadot/util-crypto/address";
|
|
5921
6110
|
import { Wormhole as Wormhole2 } from "@wormhole-foundation/sdk-connect";
|
|
@@ -5956,7 +6145,7 @@ function wormhole() {
|
|
|
5956
6145
|
}) => {
|
|
5957
6146
|
const isSourceParachain = Parachain3.is(source);
|
|
5958
6147
|
const isDestinationMoonChain = destination.isEqual(moonChain);
|
|
5959
|
-
const isDestinationEvmChain =
|
|
6148
|
+
const isDestinationEvmChain = EvmChain4.is(destination);
|
|
5960
6149
|
const isNativeAsset = asset.isSame(
|
|
5961
6150
|
isDestinationEvmChain ? moonChain.nativeAsset : source.nativeAsset
|
|
5962
6151
|
);
|
|
@@ -7610,7 +7799,7 @@ function ethereumXcm() {
|
|
|
7610
7799
|
|
|
7611
7800
|
// src/mrl/providers/wormhole/extrinsic/index.ts
|
|
7612
7801
|
function extrinsic2() {
|
|
7613
|
-
return { ethereumXcm, polkadotXcm:
|
|
7802
|
+
return { ethereumXcm, polkadotXcm: polkadotXcm3 };
|
|
7614
7803
|
}
|
|
7615
7804
|
|
|
7616
7805
|
// src/mrl/providers/wormhole/index.ts
|