@moonbeam-network/xcm-builder 1.0.0-dev.223 → 1.0.0-dev.224

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,9 +4,8 @@ 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
- import { Wormhole, Network } from '@wormhole-foundation/sdk-connect';
8
+ import { TokenId, ChainAddress, TokenTransfer, Wormhole } from '@wormhole-foundation/sdk-connect';
10
9
 
11
10
  interface ConfigBuilder<Config, Params = BuilderParams> {
12
11
  build: (params: Params) => Config;
@@ -473,54 +472,15 @@ declare function FeeBuilder(): {
473
472
  xcmPaymentApi: typeof xcmPaymentApi;
474
473
  };
475
474
 
476
- type SourceChecker = (events: EventRecord[], sourceAddress: string) => {
477
- matched: boolean;
478
- messageId?: string;
479
- event?: EventRecord;
480
- };
481
- type DestinationChecker = (events: EventRecord[], messageId?: string) => {
482
- matched: boolean;
483
- success: boolean;
484
- event?: EventRecord;
485
- };
486
- interface MonitorEventReturn {
487
- xcmPallet: () => {
488
- messageQueue: () => EventMonitoringConfig$1;
489
- };
490
- polkadotXcm: () => {
491
- messageQueue: () => EventMonitoringConfig$1;
492
- mixedQueue: () => EventMonitoringConfig$1;
493
- xcmpQueue: () => EventMonitoringConfig$1;
494
- };
495
- xTokens: () => {
496
- messageQueue: () => EventMonitoringConfig$1;
497
- ethereumXcm: () => EventMonitoringConfig$1;
498
- };
499
- bridgeMessages: () => {
500
- bridgeMessages: () => EventMonitoringConfig$1;
501
- };
502
- }
503
- interface EventMonitoringConfig$1 {
504
- checkSource: SourceChecker;
505
- checkDestination: DestinationChecker;
506
- }
507
-
508
- declare function monitorEvent(): MonitorEventReturn;
509
-
510
- declare function MonitoringBuilder(): {
511
- monitorEvent: typeof monitorEvent;
512
- };
513
-
514
- interface MonitoringBuilderConfig {
515
- eventMonitoring: EventMonitoringConfig;
516
- }
517
- interface EventMonitoringConfig {
518
- checkSource: SourceChecker;
519
- checkDestination: DestinationChecker;
520
- }
521
-
522
475
  type WormholeTransferFunctions = 'tokenTransfer';
523
- type WormholeFunctionArgs = Parameters<Wormhole<Network>[WormholeTransferFunctions]>;
476
+ type WormholeFunctionArgs = [
477
+ TokenId,
478
+ bigint,
479
+ ChainAddress,
480
+ ChainAddress,
481
+ TokenTransfer.Protocol,
482
+ Uint8Array?
483
+ ];
524
484
  interface WormholeConfigConstructorParams {
525
485
  args: WormholeFunctionArgs;
526
486
  func: WormholeTransferFunctions;
@@ -536,7 +496,7 @@ declare function wormhole$1(): {
536
496
  tokenTransfer: () => MrlConfigBuilder;
537
497
  };
538
498
 
539
- declare function wormholeFactory(chain: AnyChain): Wormhole<"Mainnet" | "Testnet">;
499
+ declare function wormholeFactory(chain: AnyChain): Wormhole<"Testnet" | "Mainnet">;
540
500
 
541
501
  type MrlConfigBuilder = ConfigBuilder<ContractConfig | ExtrinsicConfig | WormholeConfig, MrlBuilderParams>;
542
502
  type MrlExecuteConfigBuilder = ConfigBuilder<ContractConfig, MrlExecuteBuilderParams>;
@@ -696,4 +656,4 @@ declare function MrlBuilder(): {
696
656
 
697
657
  declare const BATCH_CONTRACT_ADDRESS = "0x0000000000000000000000000000000000000808";
698
658
 
699
- 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 EventMonitoringConfig, type EvmFunctionArgs, EvmQueryConfig, type EvmQueryConfigParams, type EvmQueryFunctions, ExtrinsicBuilder, ExtrinsicConfig, type ExtrinsicConfigBuilder, type ExtrinsicConfigConstructorParams, FeeBuilder, type FeeConfigBuilder, type FeeConfigBuilderParams, type GetVersionedAssetId, MonitoringBuilder, type MonitoringBuilderConfig, 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 };
659
+ 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
@@ -3054,263 +3054,6 @@ function FeeBuilder() {
3054
3054
  };
3055
3055
  }
3056
3056
 
3057
- // src/monitoring/eventMonitoring/eventMonitoring.ts
3058
- import { u8aToHex as u8aToHex7 } from "@polkadot/util";
3059
- import { decodeAddress as decodeAddress7 } from "@polkadot/util-crypto";
3060
-
3061
- // src/monitoring/eventMonitoring/eventMonitoring.utils.ts
3062
- import { u8aToHex as u8aToHex6 } from "@polkadot/util";
3063
- import { decodeAddress as decodeAddress6 } from "@polkadot/util-crypto";
3064
- var createSourceChecker = (section, method, addressExtractor, messageIdExtractor) => (events, sourceAddress) => {
3065
- const decodedSourceAddress = u8aToHex6(decodeAddress6(sourceAddress));
3066
- const methods = Array.isArray(method) ? method : [method];
3067
- const event = events.find((event2) => {
3068
- if (event2.event.section !== section || !methods.includes(event2.event.method)) {
3069
- return false;
3070
- }
3071
- try {
3072
- const address = addressExtractor(event2);
3073
- return address === decodedSourceAddress;
3074
- } catch {
3075
- return false;
3076
- }
3077
- });
3078
- if (!event) {
3079
- return { matched: false };
3080
- }
3081
- try {
3082
- const messageId = messageIdExtractor(event, events);
3083
- return { matched: true, messageId, event };
3084
- } catch {
3085
- return { matched: true, event };
3086
- }
3087
- };
3088
- var createDestinationChecker = (section, method, matchMessageId, getIsSuccess) => (events, messageId) => {
3089
- const methods = Array.isArray(method) ? method : [method];
3090
- const event = events.find((event2) => {
3091
- if (event2.event.section !== section || !methods.includes(event2.event.method)) {
3092
- return false;
3093
- }
3094
- return matchMessageId(event2, messageId);
3095
- });
3096
- if (!event) {
3097
- return { matched: false, success: false };
3098
- }
3099
- const success = getIsSuccess(event);
3100
- return { matched: true, success, event };
3101
- };
3102
-
3103
- // src/monitoring/eventMonitoring/eventMonitoring.ts
3104
- function GetAddress() {
3105
- return {
3106
- fromXcmEvent: () => (event) => {
3107
- const eventData = event.event.data;
3108
- const interior = eventData.origin.interior.asX1[0];
3109
- if (interior.isAccountId32) {
3110
- return interior.asAccountId32.id.toHex();
3111
- } else if (interior.isAccountKey20) {
3112
- return interior.asAccountKey20.key.toString();
3113
- } else {
3114
- throw new Error("Unsupported address type");
3115
- }
3116
- },
3117
- fromXTokensEvent: () => (event) => {
3118
- const eventData = event.event.data;
3119
- return u8aToHex7(decodeAddress7(eventData.sender.toString()));
3120
- }
3121
- };
3122
- }
3123
- function GetMessageId() {
3124
- return {
3125
- fromXcmEvent: () => (event) => {
3126
- const eventData = event.event.data;
3127
- return eventData.messageId.toHex();
3128
- },
3129
- fromXcmpQueue: () => (_event, events) => {
3130
- const xcmpEvent = events?.find(
3131
- (event) => event.event.section === "xcmpQueue" && event.event.method === "XcmpMessageSent"
3132
- );
3133
- if (!xcmpEvent) {
3134
- throw new Error("XcmpMessageSent event not found");
3135
- }
3136
- const eventData = xcmpEvent.event.data;
3137
- return eventData.messageHash.toHex();
3138
- }
3139
- };
3140
- }
3141
- function MatchMessageId() {
3142
- return {
3143
- fromMessageQueueId: () => (event, messageId) => {
3144
- if (!messageId) return true;
3145
- try {
3146
- const eventData = event.event.data;
3147
- return eventData.id.toString() === messageId;
3148
- } catch {
3149
- return false;
3150
- }
3151
- },
3152
- fromXcmpQueueHash: () => (event, messageId) => {
3153
- if (!messageId) return true;
3154
- try {
3155
- const eventData = event.event.data;
3156
- return eventData.messageHash.toString() === messageId;
3157
- } catch {
3158
- return false;
3159
- }
3160
- },
3161
- fromEthereumXcmEvent: () => (event) => {
3162
- const eventData = event.event.data;
3163
- return eventData.xcmMsgHash.toHex();
3164
- },
3165
- never: () => () => true
3166
- // Always match for cases where messageId is not used
3167
- };
3168
- }
3169
- function GetIsSuccess() {
3170
- return {
3171
- fromMessageQueueProcessed: () => (event) => {
3172
- try {
3173
- const eventData = event.event.data;
3174
- return eventData.success.isTrue;
3175
- } catch {
3176
- return false;
3177
- }
3178
- },
3179
- fromXcmpQueueEvent: () => (event) => {
3180
- return event.event.method === "Success";
3181
- },
3182
- alwaysTrue: () => () => true
3183
- // Always successful for simple cases
3184
- };
3185
- }
3186
- function CheckSource() {
3187
- return {
3188
- xcmPallet: () => createSourceChecker(
3189
- "xcmPallet",
3190
- "Sent",
3191
- GetAddress().fromXcmEvent(),
3192
- GetMessageId().fromXcmEvent()
3193
- ),
3194
- polkadotXcm: () => createSourceChecker(
3195
- "polkadotXcm",
3196
- "Sent",
3197
- GetAddress().fromXcmEvent(),
3198
- GetMessageId().fromXcmEvent()
3199
- ),
3200
- polkadotXcmAndXcmpQueue: () => createSourceChecker(
3201
- "polkadotXcm",
3202
- "Sent",
3203
- GetAddress().fromXcmEvent(),
3204
- GetMessageId().fromXcmpQueue()
3205
- ),
3206
- xTokens: () => createSourceChecker(
3207
- "xTokens",
3208
- ["TransferredMultiAssets", "TransferredAssets"],
3209
- GetAddress().fromXTokensEvent(),
3210
- GetMessageId().fromXcmpQueue()
3211
- ),
3212
- bridgeMessages: () => (events) => {
3213
- const event = events.find(
3214
- (event2) => event2.event.section === "bridgeMessages" && event2.event.method === "MessageAccepted"
3215
- );
3216
- return event ? { matched: true, event } : { matched: false };
3217
- }
3218
- };
3219
- }
3220
- function CheckDestination() {
3221
- return {
3222
- messageQueue: () => createDestinationChecker(
3223
- "messageQueue",
3224
- "Processed",
3225
- MatchMessageId().fromMessageQueueId(),
3226
- GetIsSuccess().fromMessageQueueProcessed()
3227
- ),
3228
- xcmpQueue: () => (events, messageId) => {
3229
- const messageIdMatcher = MatchMessageId().fromXcmpQueueHash();
3230
- const successEvent = events.find((event) => {
3231
- if (event.event.section !== "xcmpQueue" || event.event.method !== "Success") {
3232
- return false;
3233
- }
3234
- return messageIdMatcher(event, messageId);
3235
- });
3236
- const failEvent = events.find((event) => {
3237
- if (event.event.section !== "xcmpQueue" || event.event.method !== "Fail") {
3238
- return false;
3239
- }
3240
- return messageIdMatcher(event, messageId);
3241
- });
3242
- if (!successEvent && !failEvent) {
3243
- return { matched: false, success: false };
3244
- }
3245
- return {
3246
- matched: true,
3247
- success: !!successEvent,
3248
- event: successEvent || failEvent
3249
- };
3250
- },
3251
- bridgeMessages: () => createDestinationChecker(
3252
- "bridgeMessages",
3253
- "MessagesReceived",
3254
- // TODO implement message matching
3255
- MatchMessageId().never(),
3256
- GetIsSuccess().alwaysTrue()
3257
- ),
3258
- ethereumXcm: () => createDestinationChecker(
3259
- "ethereumXcm",
3260
- "ExecutedFromXcm",
3261
- MatchMessageId().never(),
3262
- GetIsSuccess().alwaysTrue()
3263
- )
3264
- };
3265
- }
3266
- function monitorEvent() {
3267
- return {
3268
- xcmPallet: () => ({
3269
- messageQueue: () => ({
3270
- checkSource: CheckSource().xcmPallet(),
3271
- checkDestination: CheckDestination().messageQueue()
3272
- })
3273
- }),
3274
- polkadotXcm: () => ({
3275
- messageQueue: () => ({
3276
- checkSource: CheckSource().polkadotXcm(),
3277
- checkDestination: CheckDestination().messageQueue()
3278
- }),
3279
- mixedQueue: () => ({
3280
- checkSource: CheckSource().polkadotXcmAndXcmpQueue(),
3281
- checkDestination: CheckDestination().messageQueue()
3282
- }),
3283
- xcmpQueue: () => ({
3284
- checkSource: CheckSource().polkadotXcmAndXcmpQueue(),
3285
- checkDestination: CheckDestination().xcmpQueue()
3286
- })
3287
- }),
3288
- xTokens: () => ({
3289
- messageQueue: () => ({
3290
- checkSource: CheckSource().xTokens(),
3291
- checkDestination: CheckDestination().messageQueue()
3292
- }),
3293
- ethereumXcm: () => ({
3294
- checkSource: CheckSource().xTokens(),
3295
- checkDestination: CheckDestination().ethereumXcm()
3296
- })
3297
- }),
3298
- bridgeMessages: () => ({
3299
- bridgeMessages: () => ({
3300
- checkSource: CheckSource().bridgeMessages(),
3301
- checkDestination: CheckDestination().bridgeMessages()
3302
- })
3303
- })
3304
- };
3305
- }
3306
-
3307
- // src/monitoring/MonitoringBuilder.ts
3308
- function MonitoringBuilder() {
3309
- return {
3310
- monitorEvent
3311
- };
3312
- }
3313
-
3314
3057
  // src/mrl/providers/wormhole/contract/Batch/Batch.ts
3315
3058
  import {
3316
3059
  EvmParachain as EvmParachain2
@@ -4213,7 +3956,7 @@ function getCurrencies({ source, moonAsset, asset }) {
4213
3956
  }
4214
3957
 
4215
3958
  // src/mrl/providers/wormhole/contract/Gmp/Gmp.ts
4216
- import { u8aToHex as u8aToHex8 } from "@polkadot/util";
3959
+ import { u8aToHex as u8aToHex6 } from "@polkadot/util";
4217
3960
 
4218
3961
  // src/mrl/providers/wormhole/contract/Gmp/GmpAbi.ts
4219
3962
  var GMP_ABI = [
@@ -4239,7 +3982,7 @@ function Gmp() {
4239
3982
  return {
4240
3983
  wormholeTransferERC20: () => ({
4241
3984
  build: ({ bytes }) => {
4242
- const hex = u8aToHex8(bytes);
3985
+ const hex = u8aToHex6(bytes);
4243
3986
  return new ContractConfig({
4244
3987
  address: GMP_CONTRACT_ADDRESS,
4245
3988
  abi: GMP_ABI,
@@ -4339,7 +4082,7 @@ function wormhole() {
4339
4082
  asset.amount,
4340
4083
  whSourceAddress,
4341
4084
  whDestinationAddress,
4342
- isAutomatic,
4085
+ isAutomatic ? "AutomaticTokenBridge" : "TokenBridge",
4343
4086
  isDestinationMoonChain || isDestinationEvmChain ? void 0 : getPayload({ destination, destinationAddress, moonApi })
4344
4087
  ],
4345
4088
  func: "tokenTransfer"
@@ -5986,7 +5729,6 @@ export {
5986
5729
  ExtrinsicBuilder,
5987
5730
  ExtrinsicConfig,
5988
5731
  FeeBuilder,
5989
- MonitoringBuilder,
5990
5732
  MrlBuilder,
5991
5733
  SubstrateCallConfig,
5992
5734
  SubstrateQueryConfig,