@moonbeam-network/xcm-builder 1.0.0-dev.212 → 1.0.0-dev.213

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
@@ -4,7 +4,6 @@ import { FrameSystemAccountInfo, StagingXcmV3MultiLocation } from '@polkadot/typ
4
4
  import { Struct, u128, Enum } from '@polkadot/types';
5
5
  import { Abi, PublicClient, HttpTransport } from 'viem';
6
6
  import { SubmittableExtrinsicFunction } from '@polkadot/api/types';
7
- import { EventRecord } from '@polkadot/types/interfaces';
8
7
  import { HexString } from '@polkadot/util/types';
9
8
  import { Wormhole, Network } from '@wormhole-foundation/sdk-connect';
10
9
 
@@ -371,7 +370,6 @@ declare function polkadotXcm$1(): {
371
370
  };
372
371
  transferAssets: () => {
373
372
  here: (parents?: number) => ExtrinsicConfigBuilder;
374
- X1: () => ExtrinsicConfigBuilder;
375
373
  X2: () => ExtrinsicConfigBuilder;
376
374
  X3: () => ExtrinsicConfigBuilder;
377
375
  X2AndFeeHere: () => ExtrinsicConfigBuilder;
@@ -471,51 +469,6 @@ declare function FeeBuilder(): {
471
469
  xcmPaymentApi: typeof xcmPaymentApi;
472
470
  };
473
471
 
474
- type SourceChecker = (events: EventRecord[], sourceAddress: string) => {
475
- matched: boolean;
476
- messageId?: string;
477
- event?: EventRecord;
478
- };
479
- type DestinationChecker = (events: EventRecord[], messageId?: string) => {
480
- matched: boolean;
481
- success: boolean;
482
- event?: EventRecord;
483
- };
484
- interface MonitoringConfig {
485
- checkSource: SourceChecker;
486
- checkDestination: DestinationChecker;
487
- }
488
- declare function MonitoringBuilder(): {
489
- xcmPallet: () => {
490
- messageQueue: () => {
491
- checkSource: SourceChecker;
492
- checkDestination: DestinationChecker;
493
- };
494
- };
495
- polkadotXcm: () => {
496
- messageQueue: () => {
497
- checkSource: SourceChecker;
498
- checkDestination: DestinationChecker;
499
- };
500
- xcmpQueue: () => {
501
- checkSource: SourceChecker;
502
- checkDestination: DestinationChecker;
503
- };
504
- };
505
- xTokens: () => {
506
- messageQueue: () => {
507
- checkSource: SourceChecker;
508
- checkDestination: DestinationChecker;
509
- };
510
- };
511
- bridgeMessages: () => {
512
- bridgeMessages: () => {
513
- checkSource: SourceChecker;
514
- checkDestination: DestinationChecker;
515
- };
516
- };
517
- };
518
-
519
472
  type WormholeTransferFunctions = 'tokenTransfer';
520
473
  type WormholeFunctionArgs = Parameters<Wormhole<Network>[WormholeTransferFunctions]>;
521
474
  interface WormholeConfigConstructorParams {
@@ -693,4 +646,4 @@ declare function MrlBuilder(): {
693
646
 
694
647
  declare const BATCH_CONTRACT_ADDRESS = "0x0000000000000000000000000000000000000808";
695
648
 
696
- export { AssetMinBuilder, type AssetMinConfigBuilder, type AssetMinConfigBuilderParams, BATCH_CONTRACT_ABI, BATCH_CONTRACT_ADDRESS, BalanceBuilder, type BalanceBuilderParams, type BalanceConfigBuilder, type BuilderParams, type ConfigBuilder, ContractBuilder, ContractConfig, type ContractConfigBuilder, type ContractConfigConstructorParams, type DestinationChecker, ERC20_ABI, type EquilibriumSystemBalanceData, type EvmFunctionArgs, EvmQueryConfig, type EvmQueryConfigParams, type EvmQueryFunctions, ExtrinsicBuilder, ExtrinsicConfig, type ExtrinsicConfigBuilder, type ExtrinsicConfigConstructorParams, FeeBuilder, type FeeConfigBuilder, type FeeConfigBuilderParams, type GetVersionedAssetId, MonitoringBuilder, type MonitoringConfig, type MoonbeamRuntimeXcmConfigAssetType, MrlBuilder, type MrlBuilderParams, type MrlConfigBuilder, type MrlExecuteBuilderParams, type MrlExecuteConfigBuilder, type PalletBalancesAccountDataOld, type Parents, type QueryConfigConstructorParams, type SourceChecker, SubstrateCallConfig, type SubstrateCallConfigConstructorParams, SubstrateQueryConfig, type TokensPalletAccountData, type Transact, WormholeConfig, type WormholeConfigConstructorParams, type WormholeFunctionArgs, type WormholeTransferFunctions, type XcmPaymentFeeProps, XcmVersion, calculateSystemAccountBalance, evm, substrate, wormhole, wormholeFactory };
649
+ export { AssetMinBuilder, type AssetMinConfigBuilder, type AssetMinConfigBuilderParams, BATCH_CONTRACT_ABI, BATCH_CONTRACT_ADDRESS, BalanceBuilder, type BalanceBuilderParams, type BalanceConfigBuilder, type BuilderParams, type ConfigBuilder, ContractBuilder, ContractConfig, type ContractConfigBuilder, type ContractConfigConstructorParams, ERC20_ABI, type EquilibriumSystemBalanceData, type EvmFunctionArgs, EvmQueryConfig, type EvmQueryConfigParams, type EvmQueryFunctions, ExtrinsicBuilder, ExtrinsicConfig, type ExtrinsicConfigBuilder, type ExtrinsicConfigConstructorParams, FeeBuilder, type FeeConfigBuilder, type FeeConfigBuilderParams, type GetVersionedAssetId, type MoonbeamRuntimeXcmConfigAssetType, MrlBuilder, type MrlBuilderParams, type MrlConfigBuilder, type MrlExecuteBuilderParams, type MrlExecuteConfigBuilder, type PalletBalancesAccountDataOld, type Parents, type QueryConfigConstructorParams, SubstrateCallConfig, type SubstrateCallConfigConstructorParams, SubstrateQueryConfig, type TokensPalletAccountData, type Transact, WormholeConfig, type WormholeConfigConstructorParams, type WormholeFunctionArgs, type WormholeTransferFunctions, type XcmPaymentFeeProps, XcmVersion, calculateSystemAccountBalance, evm, substrate, wormhole, wormholeFactory };
package/build/index.mjs CHANGED
@@ -83,7 +83,6 @@ function applyConcreteWrapper(versionedObject) {
83
83
  var BaseConfig = class {
84
84
  module;
85
85
  func;
86
- // TODO add section and method here or some mapping that transforms the module in section and func in method, for the event monitoring
87
86
  constructor({ module: module5, func }) {
88
87
  this.module = module5;
89
88
  this.func = func;
@@ -1723,36 +1722,6 @@ function polkadotXcm() {
1723
1722
  }
1724
1723
  })
1725
1724
  }),
1726
- X1: () => ({
1727
- build: (params) => new ExtrinsicConfig({
1728
- module: pallet2,
1729
- func,
1730
- getArgs: (extrinsicFunction) => {
1731
- const version = getExtrinsicArgumentVersion(extrinsicFunction);
1732
- return getPolkadotXcmExtrinsicArgs({
1733
- ...params,
1734
- func: extrinsicFunction,
1735
- asset: [
1736
- {
1737
- id: normalizeConcrete(version, {
1738
- parents: 0,
1739
- interior: {
1740
- X1: [
1741
- {
1742
- GeneralIndex: params.asset.getAssetId()
1743
- }
1744
- ]
1745
- }
1746
- }),
1747
- fun: {
1748
- Fungible: params.asset.amount
1749
- }
1750
- }
1751
- ]
1752
- });
1753
- }
1754
- })
1755
- }),
1756
1725
  X2: () => ({
1757
1726
  build: (params) => new ExtrinsicConfig({
1758
1727
  module: pallet2,
@@ -2239,7 +2208,6 @@ function xcmPallet() {
2239
2208
  {
2240
2209
  [version]: {
2241
2210
  parents: 0,
2242
- // TODO put 1 to force error in source, revert to 0 to fix
2243
2211
  interior: {
2244
2212
  X1: [
2245
2213
  {
@@ -2968,234 +2936,6 @@ function FeeBuilder() {
2968
2936
  };
2969
2937
  }
2970
2938
 
2971
- // src/monitoring/MonitoringBuilder.ts
2972
- import { u8aToHex as u8aToHex6 } from "@polkadot/util";
2973
- import { decodeAddress as decodeAddress6 } from "@polkadot/util-crypto";
2974
- function GetAddress() {
2975
- return {
2976
- fromXcmEvent: () => (event) => {
2977
- const eventData = event.event.data;
2978
- const interior = eventData.origin.interior.asX1[0];
2979
- if (interior.isAccountId32) {
2980
- return interior.asAccountId32.id.toHex();
2981
- } else if (interior.isAccountKey20) {
2982
- return interior.asAccountKey20.key.toString();
2983
- } else {
2984
- throw new Error("Unsupported address type");
2985
- }
2986
- },
2987
- fromXTokensEvent: () => (event) => {
2988
- const eventData = event.event.data;
2989
- return u8aToHex6(decodeAddress6(eventData.sender.toString()));
2990
- }
2991
- };
2992
- }
2993
- function GetMessageId() {
2994
- return {
2995
- fromXcmEvent: () => (event) => {
2996
- const eventData = event.event.data;
2997
- return eventData.messageId.toHex();
2998
- },
2999
- fromXcmpQueue: () => (event, events) => {
3000
- const xcmpEvent = events?.find(
3001
- (event2) => event2.event.section === "xcmpQueue" && event2.event.method === "XcmpMessageSent"
3002
- );
3003
- if (!xcmpEvent) {
3004
- throw new Error("XcmpMessageSent event not found");
3005
- }
3006
- const eventData = xcmpEvent.event.data;
3007
- return eventData.messageHash.toHex();
3008
- }
3009
- };
3010
- }
3011
- function MatchMessageId() {
3012
- return {
3013
- fromMessageQueueId: () => (event, messageId) => {
3014
- if (!messageId) return true;
3015
- try {
3016
- const eventData = event.event.data;
3017
- return eventData.id.toString() === messageId;
3018
- } catch {
3019
- return false;
3020
- }
3021
- },
3022
- fromXcmpQueueHash: () => (event, messageId) => {
3023
- if (!messageId) return true;
3024
- try {
3025
- const eventData = event.event.data;
3026
- return eventData.messageHash.toString() === messageId;
3027
- } catch {
3028
- return false;
3029
- }
3030
- },
3031
- // TODO
3032
- never: () => () => true
3033
- // Always match for cases where messageId is not used
3034
- };
3035
- }
3036
- function GetIsSuccess() {
3037
- return {
3038
- fromMessageQueueProcessed: () => (event) => {
3039
- try {
3040
- const eventData = event.event.data;
3041
- return eventData.success.isTrue;
3042
- } catch {
3043
- return false;
3044
- }
3045
- },
3046
- fromXcmpQueueEvent: () => (event) => {
3047
- return event.event.method === "Success";
3048
- },
3049
- // TODO
3050
- alwaysTrue: () => () => true
3051
- // Always successful for simple cases
3052
- };
3053
- }
3054
- var createDestinationChecker = (section, method, matchMessageId, getIsSuccess) => (events, messageId) => {
3055
- const methods = Array.isArray(method) ? method : [method];
3056
- const event = events.find((event2) => {
3057
- if (event2.event.section !== section || !methods.includes(event2.event.method)) {
3058
- return false;
3059
- }
3060
- return matchMessageId(event2, messageId);
3061
- });
3062
- if (!event) {
3063
- return { matched: false, success: false };
3064
- }
3065
- const success = getIsSuccess(event);
3066
- return { matched: true, success, event };
3067
- };
3068
- var createSourceChecker = (section, method, addressExtractor, messageIdExtractor) => (events, sourceAddress) => {
3069
- const decodedSourceAddress = u8aToHex6(decodeAddress6(sourceAddress));
3070
- const methods = Array.isArray(method) ? method : [method];
3071
- const event = events.find((event2) => {
3072
- if (event2.event.section !== section || !methods.includes(event2.event.method)) {
3073
- return false;
3074
- }
3075
- try {
3076
- const address = addressExtractor(event2);
3077
- return address === decodedSourceAddress;
3078
- } catch {
3079
- return false;
3080
- }
3081
- });
3082
- if (!event) {
3083
- return { matched: false };
3084
- }
3085
- try {
3086
- const messageId = messageIdExtractor(event, events);
3087
- return { matched: true, messageId, event };
3088
- } catch {
3089
- return { matched: true, event };
3090
- }
3091
- };
3092
- function CheckSource() {
3093
- return {
3094
- xcmPallet: () => createSourceChecker(
3095
- "xcmPallet",
3096
- "Sent",
3097
- GetAddress().fromXcmEvent(),
3098
- GetMessageId().fromXcmEvent()
3099
- ),
3100
- polkadotXcm: () => createSourceChecker(
3101
- "polkadotXcm",
3102
- "Sent",
3103
- GetAddress().fromXcmEvent(),
3104
- GetMessageId().fromXcmEvent()
3105
- ),
3106
- polkadotXcmAndXcmpQueue: () => createSourceChecker(
3107
- "polkadotXcm",
3108
- "Sent",
3109
- GetAddress().fromXcmEvent(),
3110
- GetMessageId().fromXcmpQueue()
3111
- ),
3112
- xTokens: () => createSourceChecker(
3113
- "xTokens",
3114
- ["TransferredMultiAssets", "TransferredAssets"],
3115
- GetAddress().fromXTokensEvent(),
3116
- GetMessageId().fromXcmpQueue()
3117
- ),
3118
- bridgeMessages: () => (events, sourceAddress) => {
3119
- const event = events.find(
3120
- (event2) => event2.event.section === "bridgeMessages" && event2.event.method === "MessageAccepted"
3121
- );
3122
- return event ? { matched: true, event } : { matched: false };
3123
- }
3124
- };
3125
- }
3126
- function CheckDestination() {
3127
- return {
3128
- messageQueue: () => createDestinationChecker(
3129
- "messageQueue",
3130
- "Processed",
3131
- MatchMessageId().fromMessageQueueId(),
3132
- GetIsSuccess().fromMessageQueueProcessed()
3133
- ),
3134
- xcmpQueue: () => (events, messageId) => {
3135
- const matchMessageId = MatchMessageId().fromXcmpQueueHash();
3136
- const successEvent = events.find((event) => {
3137
- if (event.event.section !== "xcmpQueue" || event.event.method !== "Success") {
3138
- return false;
3139
- }
3140
- return matchMessageId(event, messageId);
3141
- });
3142
- const failEvent = events.find((event) => {
3143
- if (event.event.section !== "xcmpQueue" || event.event.method !== "Fail") {
3144
- return false;
3145
- }
3146
- return matchMessageId(event, messageId);
3147
- });
3148
- if (!successEvent && !failEvent) {
3149
- return { matched: false, success: false };
3150
- }
3151
- return {
3152
- matched: true,
3153
- success: !!successEvent,
3154
- event: successEvent || failEvent
3155
- };
3156
- },
3157
- bridgeMessages: () => createDestinationChecker(
3158
- "bridgeMessages",
3159
- "MessagesReceived",
3160
- MatchMessageId().never(),
3161
- GetIsSuccess().alwaysTrue()
3162
- )
3163
- };
3164
- }
3165
- function MonitoringBuilder() {
3166
- return {
3167
- xcmPallet: () => ({
3168
- messageQueue: () => ({
3169
- checkSource: CheckSource().xcmPallet(),
3170
- checkDestination: CheckDestination().messageQueue()
3171
- })
3172
- }),
3173
- polkadotXcm: () => ({
3174
- messageQueue: () => ({
3175
- checkSource: CheckSource().polkadotXcm(),
3176
- checkDestination: CheckDestination().messageQueue()
3177
- }),
3178
- xcmpQueue: () => ({
3179
- checkSource: CheckSource().polkadotXcmAndXcmpQueue(),
3180
- checkDestination: CheckDestination().xcmpQueue()
3181
- })
3182
- }),
3183
- xTokens: () => ({
3184
- messageQueue: () => ({
3185
- checkSource: CheckSource().xTokens(),
3186
- checkDestination: CheckDestination().messageQueue()
3187
- })
3188
- }),
3189
- // TODO mjm call ecosystem bridge or something?
3190
- bridgeMessages: () => ({
3191
- bridgeMessages: () => ({
3192
- checkSource: CheckSource().bridgeMessages(),
3193
- checkDestination: CheckDestination().bridgeMessages()
3194
- })
3195
- })
3196
- };
3197
- }
3198
-
3199
2939
  // src/mrl/providers/wormhole/contract/Batch/Batch.ts
3200
2940
  import {
3201
2941
  EvmParachain as EvmParachain2
@@ -4098,7 +3838,7 @@ function getCurrencies({ source, moonAsset, asset }) {
4098
3838
  }
4099
3839
 
4100
3840
  // src/mrl/providers/wormhole/contract/Gmp/Gmp.ts
4101
- import { u8aToHex as u8aToHex7 } from "@polkadot/util";
3841
+ import { u8aToHex as u8aToHex6 } from "@polkadot/util";
4102
3842
 
4103
3843
  // src/mrl/providers/wormhole/contract/Gmp/GmpAbi.ts
4104
3844
  var GMP_ABI = [
@@ -4124,7 +3864,7 @@ function Gmp() {
4124
3864
  return {
4125
3865
  wormholeTransferERC20: () => ({
4126
3866
  build: ({ bytes }) => {
4127
- const hex = u8aToHex7(bytes);
3867
+ const hex = u8aToHex6(bytes);
4128
3868
  return new ContractConfig({
4129
3869
  address: GMP_CONTRACT_ADDRESS,
4130
3870
  abi: GMP_ABI,
@@ -5871,7 +5611,6 @@ export {
5871
5611
  ExtrinsicBuilder,
5872
5612
  ExtrinsicConfig,
5873
5613
  FeeBuilder,
5874
- MonitoringBuilder,
5875
5614
  MrlBuilder,
5876
5615
  SubstrateCallConfig,
5877
5616
  SubstrateQueryConfig,