@moonbeam-network/xcm-builder 1.0.0-dev.282 → 1.0.0-dev.284

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 CHANGED
@@ -494,7 +494,7 @@ declare class SubstrateCallConfig {
494
494
  }
495
495
 
496
496
  type FeeConfigBuilder = ConfigBuilder<SubstrateCallConfig | ContractConfig, FeeConfigBuilderParams>;
497
- type BridgeFeeConfigBuilder = ConfigBuilder<SubstrateQueryConfig | ContractConfig, BridgeFeeConfigBuilderParams>;
497
+ type ProtocolFeeConfigBuilder = ConfigBuilder<SubstrateQueryConfig | ContractConfig, ProtocolFeeConfigBuilderParams>;
498
498
  interface FeeConfigBuilderParams {
499
499
  address: string;
500
500
  api: ApiPromise;
@@ -504,13 +504,7 @@ interface FeeConfigBuilderParams {
504
504
  feeAsset: ChainAsset;
505
505
  source: AnyChain;
506
506
  }
507
- interface BridgeFeeConfigBuilderParams {
508
- asset: ChainAsset;
509
- feeAsset: ChainAsset;
510
- address: string;
511
- balance?: AssetAmount;
512
- destination: AnyChain;
513
- source: AnyChain;
507
+ interface ProtocolFeeConfigBuilderParams extends Omit<FeeConfigBuilderParams, 'api'> {
514
508
  bridgeChainFee: AssetAmount;
515
509
  }
516
510
  interface XcmPaymentFeeProps {
@@ -527,11 +521,14 @@ interface MoonbeamRuntimeXcmConfigAssetType extends Enum {
527
521
  type GetVersionedAssetId = (params: FeeConfigBuilderParams) => Promise<object> | object;
528
522
 
529
523
  declare function gateway(): {
530
- quoteSendTokenFee(): BridgeFeeConfigBuilder;
524
+ quoteSendTokenFee(): ProtocolFeeConfigBuilder;
531
525
  };
532
526
 
533
527
  declare function outboundQueueApi(): {
534
- calculateFee: () => BridgeFeeConfigBuilder;
528
+ calculateFee: () => {
529
+ mintForeignToken: () => ProtocolFeeConfigBuilder;
530
+ agentExecute: () => ProtocolFeeConfigBuilder;
531
+ };
535
532
  };
536
533
 
537
534
  declare function xcmPaymentApi(): {
@@ -1934,4 +1931,4 @@ declare function MrlBuilder(): {
1934
1931
 
1935
1932
  declare const BATCH_CONTRACT_ADDRESS = "0x0000000000000000000000000000000000000808";
1936
1933
 
1937
- export { type AssetAddressFormat, AssetMinBuilder, type AssetMinConfigBuilder, type AssetMinConfigBuilderParams, type AssetMultilocation, BATCH_CONTRACT_ABI, BATCH_CONTRACT_ADDRESS, BalanceBuilder, type BalanceBuilderParams, type BalanceConfigBuilder, type BridgeFeeConfigBuilder, type BridgeFeeConfigBuilderParams, type BuilderParams, type ConfigBuilder, ContractBuilder, ContractConfig, type ContractConfigBuilder, type ContractConfigConstructorParams, type DestinationMultilocation, ERC20_ABI, type EquilibriumSystemBalanceData, type EventMonitoringConfig, type EvmFunctionArgs, EvmQueryConfig, type EvmQueryConfigParams, type EvmQueryFunctions, ExtrinsicBuilder, ExtrinsicConfig, type ExtrinsicConfigBuilder, type ExtrinsicConfigConstructorParams, FeeBuilder, type FeeConfigBuilder, type FeeConfigBuilderParams, GATEWAY_ABI, type GetVersionedAssetId, MonitoringBuilder, type MonitoringBuilderConfig, type MoonbeamRuntimeXcmConfigAssetType, MrlBuilder, type MrlBuilderParams, type MrlConfigBuilder, type MrlExecuteBuilderParams, type MrlExecuteConfigBuilder, type MrlTransferConfig, type PalletBalancesAccountDataOld, type Parents, Protocols, Provider, type QueryConfigConstructorParams, SnowbridgeConfig, type SnowbridgeConfigConstructorParams, type SnowbridgeFunctionArgs, type SnowbridgeFunctions, SubstrateCallConfig, type SubstrateCallConfigConstructorParams, SubstrateQueryConfig, type TokensPalletAccountData, type Transact, TransferType, WormholeConfig, type WormholeConfigConstructorParams, type WormholeFunctionArgs, type WormholeTransferFunctions, type XcmPaymentFeeProps, XcmVersion, calculateSystemAccountBalance, evm, snowbridge, substrate, wormhole, wormholeFactory };
1934
+ export { type AssetAddressFormat, AssetMinBuilder, type AssetMinConfigBuilder, type AssetMinConfigBuilderParams, type AssetMultilocation, BATCH_CONTRACT_ABI, BATCH_CONTRACT_ADDRESS, BalanceBuilder, type BalanceBuilderParams, type BalanceConfigBuilder, type BuilderParams, type ConfigBuilder, ContractBuilder, ContractConfig, type ContractConfigBuilder, type ContractConfigConstructorParams, type DestinationMultilocation, ERC20_ABI, type EquilibriumSystemBalanceData, type EventMonitoringConfig, type EvmFunctionArgs, EvmQueryConfig, type EvmQueryConfigParams, type EvmQueryFunctions, ExtrinsicBuilder, ExtrinsicConfig, type ExtrinsicConfigBuilder, type ExtrinsicConfigConstructorParams, FeeBuilder, type FeeConfigBuilder, type FeeConfigBuilderParams, GATEWAY_ABI, type GetVersionedAssetId, MonitoringBuilder, type MonitoringBuilderConfig, type MoonbeamRuntimeXcmConfigAssetType, MrlBuilder, type MrlBuilderParams, type MrlConfigBuilder, type MrlExecuteBuilderParams, type MrlExecuteConfigBuilder, type MrlTransferConfig, type PalletBalancesAccountDataOld, type Parents, type ProtocolFeeConfigBuilder, type ProtocolFeeConfigBuilderParams, Protocols, Provider, type QueryConfigConstructorParams, SnowbridgeConfig, type SnowbridgeConfigConstructorParams, type SnowbridgeFunctionArgs, type SnowbridgeFunctions, SubstrateCallConfig, type SubstrateCallConfigConstructorParams, SubstrateQueryConfig, type TokensPalletAccountData, type Transact, TransferType, WormholeConfig, type WormholeConfigConstructorParams, type WormholeFunctionArgs, type WormholeTransferFunctions, type XcmPaymentFeeProps, XcmVersion, calculateSystemAccountBalance, evm, snowbridge, substrate, wormhole, wormholeFactory };
package/build/index.mjs CHANGED
@@ -3946,8 +3946,8 @@ function gateway() {
3946
3946
  // src/fee/outboundQueueApi/outboundQueueApi.ts
3947
3947
  function outboundQueueApi() {
3948
3948
  return {
3949
- calculateFee: () => {
3950
- return {
3949
+ calculateFee: () => ({
3950
+ mintForeignToken: () => ({
3951
3951
  build: ({ address, balance, feeAsset }) => {
3952
3952
  const args = [
3953
3953
  {
@@ -3967,8 +3967,34 @@ function outboundQueueApi() {
3967
3967
  transform: async (data) => data.local.toBigInt() + data.remote.toBigInt()
3968
3968
  });
3969
3969
  }
3970
- };
3971
- }
3970
+ }),
3971
+ agentExecute: () => ({
3972
+ build: ({ address, balance, destination }) => {
3973
+ const assetInDestination = balance ? destination.getChainAsset(balance) : void 0;
3974
+ const args = [
3975
+ {
3976
+ AgentExecute: {
3977
+ agentId: "0x0000000000000000000000000000000000000000000000000000000000000000",
3978
+ // actual value is not important
3979
+ TokenTransfer: {
3980
+ tokenId: assetInDestination?.address,
3981
+ recipient: address,
3982
+ amount: balance?.amount
3983
+ }
3984
+ }
3985
+ },
3986
+ null
3987
+ ];
3988
+ return new SubstrateQueryConfig({
3989
+ module: "outboundQueueApi",
3990
+ func: "calculateFee",
3991
+ args,
3992
+ queryType: "call",
3993
+ transform: async (data) => data.local.toBigInt() + data.remote.toBigInt()
3994
+ });
3995
+ }
3996
+ })
3997
+ })
3972
3998
  };
3973
3999
  }
3974
4000
 
@@ -4816,25 +4842,20 @@ function polkadotXcm2() {
4816
4842
  const func = "transferAssetsUsingTypeAndThen";
4817
4843
  const provider = "snowbridge" /* Snowbridge */;
4818
4844
  return {
4819
- // TODO mjm rename ? nativeEth?
4820
4845
  canonicalEth: () => ({
4821
4846
  provider,
4822
- build: ({
4823
- asset,
4824
- destination,
4825
- destinationAddress,
4826
- bridgeChainFee
4827
- }) => {
4847
+ build: ({ asset, destination, destinationAddress, protocolFee }) => {
4828
4848
  if (!EvmChain2.is(destination)) {
4829
4849
  throw new Error(
4830
4850
  "Destination must be an EVM chain for globalConsensus function"
4831
4851
  );
4832
4852
  }
4833
- if (!bridgeChainFee) {
4853
+ if (!protocolFee) {
4834
4854
  throw new Error(
4835
4855
  "Bridge chain fee is required for the polkadotXcm.canonicalEth function"
4836
4856
  );
4837
4857
  }
4858
+ const protocolFeeAmount = protocolFee.amount * 110n / 100n;
4838
4859
  return new ExtrinsicConfig({
4839
4860
  module: pallet7,
4840
4861
  func,
@@ -4853,7 +4874,7 @@ function polkadotXcm2() {
4853
4874
  parents: 1,
4854
4875
  interior: "Here"
4855
4876
  },
4856
- fun: { Fungible: bridgeChainFee.amount }
4877
+ fun: { Fungible: protocolFeeAmount }
4857
4878
  },
4858
4879
  {
4859
4880
  id: {