@moonbeam-network/xcm-builder 1.0.0-dev.222 → 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
@@ -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;
@@ -2326,8 +2325,7 @@ function xcmPallet() {
2326
2325
  return [
2327
2326
  {
2328
2327
  [version]: {
2329
- parents: 1,
2330
- // TODO put 1 to force error in source, revert to 0 to fix
2328
+ parents: 0,
2331
2329
  interior: {
2332
2330
  X1: [
2333
2331
  {
@@ -3056,263 +3054,6 @@ function FeeBuilder() {
3056
3054
  };
3057
3055
  }
3058
3056
 
3059
- // src/monitoring/eventMonitoring/eventMonitoring.ts
3060
- import { u8aToHex as u8aToHex7 } from "@polkadot/util";
3061
- import { decodeAddress as decodeAddress7 } from "@polkadot/util-crypto";
3062
-
3063
- // src/monitoring/eventMonitoring/eventMonitoring.utils.ts
3064
- import { u8aToHex as u8aToHex6 } from "@polkadot/util";
3065
- import { decodeAddress as decodeAddress6 } from "@polkadot/util-crypto";
3066
- var createSourceChecker = (section, method, addressExtractor, messageIdExtractor) => (events, sourceAddress) => {
3067
- const decodedSourceAddress = u8aToHex6(decodeAddress6(sourceAddress));
3068
- const methods = Array.isArray(method) ? method : [method];
3069
- const event = events.find((event2) => {
3070
- if (event2.event.section !== section || !methods.includes(event2.event.method)) {
3071
- return false;
3072
- }
3073
- try {
3074
- const address = addressExtractor(event2);
3075
- return address === decodedSourceAddress;
3076
- } catch {
3077
- return false;
3078
- }
3079
- });
3080
- if (!event) {
3081
- return { matched: false };
3082
- }
3083
- try {
3084
- const messageId = messageIdExtractor(event, events);
3085
- return { matched: true, messageId, event };
3086
- } catch {
3087
- return { matched: true, event };
3088
- }
3089
- };
3090
- var createDestinationChecker = (section, method, matchMessageId, getIsSuccess) => (events, messageId) => {
3091
- const methods = Array.isArray(method) ? method : [method];
3092
- const event = events.find((event2) => {
3093
- if (event2.event.section !== section || !methods.includes(event2.event.method)) {
3094
- return false;
3095
- }
3096
- return matchMessageId(event2, messageId);
3097
- });
3098
- if (!event) {
3099
- return { matched: false, success: false };
3100
- }
3101
- const success = getIsSuccess(event);
3102
- return { matched: true, success, event };
3103
- };
3104
-
3105
- // src/monitoring/eventMonitoring/eventMonitoring.ts
3106
- function GetAddress() {
3107
- return {
3108
- fromXcmEvent: () => (event) => {
3109
- const eventData = event.event.data;
3110
- const interior = eventData.origin.interior.asX1[0];
3111
- if (interior.isAccountId32) {
3112
- return interior.asAccountId32.id.toHex();
3113
- } else if (interior.isAccountKey20) {
3114
- return interior.asAccountKey20.key.toString();
3115
- } else {
3116
- throw new Error("Unsupported address type");
3117
- }
3118
- },
3119
- fromXTokensEvent: () => (event) => {
3120
- const eventData = event.event.data;
3121
- return u8aToHex7(decodeAddress7(eventData.sender.toString()));
3122
- }
3123
- };
3124
- }
3125
- function GetMessageId() {
3126
- return {
3127
- fromXcmEvent: () => (event) => {
3128
- const eventData = event.event.data;
3129
- return eventData.messageId.toHex();
3130
- },
3131
- fromXcmpQueue: () => (_event, events) => {
3132
- const xcmpEvent = events?.find(
3133
- (event) => event.event.section === "xcmpQueue" && event.event.method === "XcmpMessageSent"
3134
- );
3135
- if (!xcmpEvent) {
3136
- throw new Error("XcmpMessageSent event not found");
3137
- }
3138
- const eventData = xcmpEvent.event.data;
3139
- return eventData.messageHash.toHex();
3140
- }
3141
- };
3142
- }
3143
- function MatchMessageId() {
3144
- return {
3145
- fromMessageQueueId: () => (event, messageId) => {
3146
- if (!messageId) return true;
3147
- try {
3148
- const eventData = event.event.data;
3149
- return eventData.id.toString() === messageId;
3150
- } catch {
3151
- return false;
3152
- }
3153
- },
3154
- fromXcmpQueueHash: () => (event, messageId) => {
3155
- if (!messageId) return true;
3156
- try {
3157
- const eventData = event.event.data;
3158
- return eventData.messageHash.toString() === messageId;
3159
- } catch {
3160
- return false;
3161
- }
3162
- },
3163
- fromEthereumXcmEvent: () => (event) => {
3164
- const eventData = event.event.data;
3165
- return eventData.xcmMsgHash.toHex();
3166
- },
3167
- never: () => () => true
3168
- // Always match for cases where messageId is not used
3169
- };
3170
- }
3171
- function GetIsSuccess() {
3172
- return {
3173
- fromMessageQueueProcessed: () => (event) => {
3174
- try {
3175
- const eventData = event.event.data;
3176
- return eventData.success.isTrue;
3177
- } catch {
3178
- return false;
3179
- }
3180
- },
3181
- fromXcmpQueueEvent: () => (event) => {
3182
- return event.event.method === "Success";
3183
- },
3184
- alwaysTrue: () => () => true
3185
- // Always successful for simple cases
3186
- };
3187
- }
3188
- function CheckSource() {
3189
- return {
3190
- xcmPallet: () => createSourceChecker(
3191
- "xcmPallet",
3192
- "Sent",
3193
- GetAddress().fromXcmEvent(),
3194
- GetMessageId().fromXcmEvent()
3195
- ),
3196
- polkadotXcm: () => createSourceChecker(
3197
- "polkadotXcm",
3198
- "Sent",
3199
- GetAddress().fromXcmEvent(),
3200
- GetMessageId().fromXcmEvent()
3201
- ),
3202
- polkadotXcmAndXcmpQueue: () => createSourceChecker(
3203
- "polkadotXcm",
3204
- "Sent",
3205
- GetAddress().fromXcmEvent(),
3206
- GetMessageId().fromXcmpQueue()
3207
- ),
3208
- xTokens: () => createSourceChecker(
3209
- "xTokens",
3210
- ["TransferredMultiAssets", "TransferredAssets"],
3211
- GetAddress().fromXTokensEvent(),
3212
- GetMessageId().fromXcmpQueue()
3213
- ),
3214
- bridgeMessages: () => (events) => {
3215
- const event = events.find(
3216
- (event2) => event2.event.section === "bridgeMessages" && event2.event.method === "MessageAccepted"
3217
- );
3218
- return event ? { matched: true, event } : { matched: false };
3219
- }
3220
- };
3221
- }
3222
- function CheckDestination() {
3223
- return {
3224
- messageQueue: () => createDestinationChecker(
3225
- "messageQueue",
3226
- "Processed",
3227
- MatchMessageId().fromMessageQueueId(),
3228
- GetIsSuccess().fromMessageQueueProcessed()
3229
- ),
3230
- xcmpQueue: () => (events, messageId) => {
3231
- const matchMessageId = MatchMessageId().fromXcmpQueueHash();
3232
- const successEvent = events.find((event) => {
3233
- if (event.event.section !== "xcmpQueue" || event.event.method !== "Success") {
3234
- return false;
3235
- }
3236
- return matchMessageId(event, messageId);
3237
- });
3238
- const failEvent = events.find((event) => {
3239
- if (event.event.section !== "xcmpQueue" || event.event.method !== "Fail") {
3240
- return false;
3241
- }
3242
- return matchMessageId(event, messageId);
3243
- });
3244
- if (!successEvent && !failEvent) {
3245
- return { matched: false, success: false };
3246
- }
3247
- return {
3248
- matched: true,
3249
- success: !!successEvent,
3250
- event: successEvent || failEvent
3251
- };
3252
- },
3253
- bridgeMessages: () => createDestinationChecker(
3254
- "bridgeMessages",
3255
- "MessagesReceived",
3256
- // TODO implement message matching
3257
- MatchMessageId().never(),
3258
- GetIsSuccess().alwaysTrue()
3259
- ),
3260
- ethereumXcm: () => createDestinationChecker(
3261
- "ethereumXcm",
3262
- "ExecutedFromXcm",
3263
- MatchMessageId().never(),
3264
- GetIsSuccess().alwaysTrue()
3265
- )
3266
- };
3267
- }
3268
- function monitorEvent() {
3269
- return {
3270
- xcmPallet: () => ({
3271
- messageQueue: () => ({
3272
- checkSource: CheckSource().xcmPallet(),
3273
- checkDestination: CheckDestination().messageQueue()
3274
- })
3275
- }),
3276
- polkadotXcm: () => ({
3277
- messageQueue: () => ({
3278
- checkSource: CheckSource().polkadotXcm(),
3279
- checkDestination: CheckDestination().messageQueue()
3280
- }),
3281
- mixedQueue: () => ({
3282
- checkSource: CheckSource().polkadotXcmAndXcmpQueue(),
3283
- checkDestination: CheckDestination().messageQueue()
3284
- }),
3285
- xcmpQueue: () => ({
3286
- checkSource: CheckSource().polkadotXcmAndXcmpQueue(),
3287
- checkDestination: CheckDestination().xcmpQueue()
3288
- })
3289
- }),
3290
- xTokens: () => ({
3291
- messageQueue: () => ({
3292
- checkSource: CheckSource().xTokens(),
3293
- checkDestination: CheckDestination().messageQueue()
3294
- }),
3295
- ethereumXcm: () => ({
3296
- checkSource: CheckSource().xTokens(),
3297
- checkDestination: CheckDestination().ethereumXcm()
3298
- })
3299
- }),
3300
- bridgeMessages: () => ({
3301
- bridgeMessages: () => ({
3302
- checkSource: CheckSource().bridgeMessages(),
3303
- checkDestination: CheckDestination().bridgeMessages()
3304
- })
3305
- })
3306
- };
3307
- }
3308
-
3309
- // src/monitoring/MonitoringBuilder.ts
3310
- function MonitoringBuilder() {
3311
- return {
3312
- monitorEvent
3313
- };
3314
- }
3315
-
3316
3057
  // src/mrl/providers/wormhole/contract/Batch/Batch.ts
3317
3058
  import {
3318
3059
  EvmParachain as EvmParachain2
@@ -4215,7 +3956,7 @@ function getCurrencies({ source, moonAsset, asset }) {
4215
3956
  }
4216
3957
 
4217
3958
  // src/mrl/providers/wormhole/contract/Gmp/Gmp.ts
4218
- import { u8aToHex as u8aToHex8 } from "@polkadot/util";
3959
+ import { u8aToHex as u8aToHex6 } from "@polkadot/util";
4219
3960
 
4220
3961
  // src/mrl/providers/wormhole/contract/Gmp/GmpAbi.ts
4221
3962
  var GMP_ABI = [
@@ -4241,7 +3982,7 @@ function Gmp() {
4241
3982
  return {
4242
3983
  wormholeTransferERC20: () => ({
4243
3984
  build: ({ bytes }) => {
4244
- const hex = u8aToHex8(bytes);
3985
+ const hex = u8aToHex6(bytes);
4245
3986
  return new ContractConfig({
4246
3987
  address: GMP_CONTRACT_ADDRESS,
4247
3988
  abi: GMP_ABI,
@@ -4341,7 +4082,7 @@ function wormhole() {
4341
4082
  asset.amount,
4342
4083
  whSourceAddress,
4343
4084
  whDestinationAddress,
4344
- isAutomatic,
4085
+ isAutomatic ? "AutomaticTokenBridge" : "TokenBridge",
4345
4086
  isDestinationMoonChain || isDestinationEvmChain ? void 0 : getPayload({ destination, destinationAddress, moonApi })
4346
4087
  ],
4347
4088
  func: "tokenTransfer"
@@ -5988,7 +5729,6 @@ export {
5988
5729
  ExtrinsicBuilder,
5989
5730
  ExtrinsicConfig,
5990
5731
  FeeBuilder,
5991
- MonitoringBuilder,
5992
5732
  MrlBuilder,
5993
5733
  SubstrateCallConfig,
5994
5734
  SubstrateQueryConfig,