@moonbeam-network/xcm-builder 1.0.0-dev.268 → 1.0.0-dev.269

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.mjs CHANGED
@@ -92,7 +92,6 @@ var BaseConfig = class {
92
92
  // src/types/substrate/SubstrateQueryConfig.ts
93
93
  var SubstrateQueryConfig = class _SubstrateQueryConfig extends BaseConfig {
94
94
  args;
95
- queryType;
96
95
  transform;
97
96
  static is(obj) {
98
97
  return obj instanceof _SubstrateQueryConfig;
@@ -100,12 +99,10 @@ var SubstrateQueryConfig = class _SubstrateQueryConfig extends BaseConfig {
100
99
  constructor({
101
100
  args = [],
102
101
  transform,
103
- queryType = "query",
104
102
  ...other
105
103
  }) {
106
104
  super({ ...other });
107
105
  this.args = args;
108
- this.queryType = queryType;
109
106
  this.transform = transform;
110
107
  }
111
108
  };
@@ -119,11 +116,11 @@ function AssetMinBuilder() {
119
116
  };
120
117
  }
121
118
  function assetRegistry() {
122
- const pallet8 = "assetRegistry";
119
+ const pallet6 = "assetRegistry";
123
120
  return {
124
121
  assetMetadatas: () => ({
125
122
  build: ({ asset }) => new SubstrateQueryConfig({
126
- module: pallet8,
123
+ module: pallet6,
127
124
  func: "assetMetadatas",
128
125
  args: [asset],
129
126
  // biome-ignore lint/suspicious/noExplicitAny: not sure how to fix this
@@ -132,7 +129,7 @@ function assetRegistry() {
132
129
  }),
133
130
  currencyMetadatas: () => ({
134
131
  build: ({ asset }) => new SubstrateQueryConfig({
135
- module: pallet8,
132
+ module: pallet6,
136
133
  func: "currencyMetadatas",
137
134
  args: [asset],
138
135
  // biome-ignore lint/suspicious/noExplicitAny: not sure how to fix this
@@ -141,7 +138,7 @@ function assetRegistry() {
141
138
  }),
142
139
  metadata: () => ({
143
140
  build: ({ asset }) => new SubstrateQueryConfig({
144
- module: pallet8,
141
+ module: pallet6,
145
142
  func: "metadata",
146
143
  args: [asset],
147
144
  // biome-ignore lint/suspicious/noExplicitAny: not sure how to fix this
@@ -205,8 +202,8 @@ import { encodeFunctionData } from "viem";
205
202
  var ContractConfig = class _ContractConfig extends BaseConfig {
206
203
  address;
207
204
  abi;
205
+ // biome-ignore lint/suspicious/noExplicitAny: not sure how to fix this
208
206
  args;
209
- value;
210
207
  static is(obj) {
211
208
  return obj instanceof _ContractConfig;
212
209
  }
@@ -214,14 +211,12 @@ var ContractConfig = class _ContractConfig extends BaseConfig {
214
211
  address,
215
212
  abi,
216
213
  args,
217
- value,
218
214
  ...other
219
215
  }) {
220
216
  super({ ...other });
221
217
  this.address = address;
222
218
  this.abi = abi;
223
219
  this.args = args;
224
- this.value = value;
225
220
  }
226
221
  encodeFunctionData() {
227
222
  return encodeFunctionData({
@@ -3074,902 +3069,55 @@ function xTransfer() {
3074
3069
  interior: {
3075
3070
  X2: [
3076
3071
  {
3077
- Parachain: destination.parachainId
3078
- },
3079
- {
3080
- PalletInstance: asset.getAssetPalletInstance()
3081
- }
3082
- ]
3083
- }
3084
- }
3085
- },
3086
- fun: {
3087
- Fungible: asset.amount || 1n
3088
- }
3089
- },
3090
- {
3091
- parents: 1,
3092
- interior: {
3093
- X2: [
3094
- {
3095
- Parachain: destination.parachainId
3096
- },
3097
- getExtrinsicAccount(destinationAddress)
3098
- ]
3099
- }
3100
- },
3101
- {
3102
- refTime: 5e9,
3103
- proofSize: 0
3104
- }
3105
- ]
3106
- })
3107
- })
3108
- };
3109
- }
3110
- };
3111
- }
3112
-
3113
- // src/extrinsic/ExtrinsicBuilder.ts
3114
- function ExtrinsicBuilder() {
3115
- return {
3116
- eqBalances,
3117
- xTokens,
3118
- xTransfer,
3119
- polkadotXcm,
3120
- xcmPallet
3121
- };
3122
- }
3123
-
3124
- // src/fee/gateway/gateway.ts
3125
- import { EvmChain, EvmParachain as EvmParachain2 } from "@moonbeam-network/xcm-types";
3126
-
3127
- // src/mrl/providers/snowbridge/contract/Gateway/GatewayAbi.ts
3128
- var GATEWAY_ABI = [
3129
- {
3130
- inputs: [
3131
- { internalType: "address", name: "beefyClient", type: "address" },
3132
- { internalType: "address", name: "agentExecutor", type: "address" },
3133
- { internalType: "ParaID", name: "bridgeHubParaID", type: "uint32" },
3134
- { internalType: "bytes32", name: "bridgeHubAgentID", type: "bytes32" },
3135
- { internalType: "uint8", name: "foreignTokenDecimals", type: "uint8" },
3136
- { internalType: "uint128", name: "maxDestinationFee", type: "uint128" }
3137
- ],
3138
- stateMutability: "nonpayable",
3139
- type: "constructor"
3140
- },
3141
- { inputs: [], name: "AgentAlreadyCreated", type: "error" },
3142
- { inputs: [], name: "AgentDoesNotExist", type: "error" },
3143
- { inputs: [], name: "CantSetMiddlewareToSameAddress", type: "error" },
3144
- { inputs: [], name: "CantSetMiddlewareToZeroAddress", type: "error" },
3145
- { inputs: [], name: "ChannelAlreadyCreated", type: "error" },
3146
- { inputs: [], name: "ChannelDoesNotExist", type: "error" },
3147
- { inputs: [], name: "Disabled", type: "error" },
3148
- {
3149
- inputs: [
3150
- { internalType: "uint256", name: "epoch", type: "uint256" },
3151
- { internalType: "uint256", name: "eraIndex", type: "uint256" },
3152
- { internalType: "address", name: "tokenAddress", type: "address" },
3153
- { internalType: "uint256", name: "totalPointsToken", type: "uint256" },
3154
- { internalType: "uint256", name: "totalTokensInflated", type: "uint256" },
3155
- { internalType: "bytes32", name: "rewardsRoot", type: "bytes32" },
3156
- { internalType: "bytes", name: "errorBytes", type: "bytes" }
3157
- ],
3158
- name: "EUnableToProcessRewardsB",
3159
- type: "error"
3160
- },
3161
- {
3162
- inputs: [
3163
- { internalType: "uint256", name: "epoch", type: "uint256" },
3164
- { internalType: "uint256", name: "eraIndex", type: "uint256" },
3165
- { internalType: "address", name: "tokenAddress", type: "address" },
3166
- { internalType: "uint256", name: "totalPointsToken", type: "uint256" },
3167
- { internalType: "uint256", name: "totalTokensInflated", type: "uint256" },
3168
- { internalType: "bytes32", name: "rewardsRoot", type: "bytes32" },
3169
- { internalType: "string", name: "errorString", type: "string" }
3170
- ],
3171
- name: "EUnableToProcessRewardsS",
3172
- type: "error"
3173
- },
3174
- { inputs: [], name: "FeePaymentToLow", type: "error" },
3175
- { inputs: [], name: "InvalidAgentExecutionPayload", type: "error" },
3176
- { inputs: [], name: "InvalidChannelUpdate", type: "error" },
3177
- { inputs: [], name: "InvalidCodeHash", type: "error" },
3178
- { inputs: [], name: "InvalidConstructorParams", type: "error" },
3179
- { inputs: [], name: "InvalidContract", type: "error" },
3180
- { inputs: [], name: "InvalidNonce", type: "error" },
3181
- { inputs: [], name: "InvalidProof", type: "error" },
3182
- { inputs: [], name: "MiddlewareNotSet", type: "error" },
3183
- { inputs: [], name: "NativeTransferFailed", type: "error" },
3184
- { inputs: [], name: "NotEnoughGas", type: "error" },
3185
- { inputs: [], name: "Operators__OperatorsKeysCannotBeEmpty", type: "error" },
3186
- { inputs: [], name: "Operators__OperatorsLengthTooLong", type: "error" },
3187
- {
3188
- inputs: [
3189
- { internalType: "uint256", name: "x", type: "uint256" },
3190
- { internalType: "uint256", name: "y", type: "uint256" }
3191
- ],
3192
- name: "PRBMath_MulDiv18_Overflow",
3193
- type: "error"
3194
- },
3195
- {
3196
- inputs: [
3197
- { internalType: "uint256", name: "x", type: "uint256" },
3198
- { internalType: "uint256", name: "y", type: "uint256" },
3199
- { internalType: "uint256", name: "denominator", type: "uint256" }
3200
- ],
3201
- name: "PRBMath_MulDiv_Overflow",
3202
- type: "error"
3203
- },
3204
- {
3205
- inputs: [{ internalType: "uint256", name: "x", type: "uint256" }],
3206
- name: "PRBMath_UD60x18_Convert_Overflow",
3207
- type: "error"
3208
- },
3209
- {
3210
- inputs: [{ internalType: "UD60x18", name: "x", type: "uint256" }],
3211
- name: "PRBMath_UD60x18_Exp2_InputTooBig",
3212
- type: "error"
3213
- },
3214
- {
3215
- inputs: [{ internalType: "UD60x18", name: "x", type: "uint256" }],
3216
- name: "PRBMath_UD60x18_Log_InputTooSmall",
3217
- type: "error"
3218
- },
3219
- { inputs: [], name: "TokenNotRegistered", type: "error" },
3220
- { inputs: [], name: "Unauthorized", type: "error" },
3221
- {
3222
- anonymous: false,
3223
- inputs: [
3224
- {
3225
- indexed: false,
3226
- internalType: "bytes32",
3227
- name: "agentID",
3228
- type: "bytes32"
3229
- },
3230
- {
3231
- indexed: false,
3232
- internalType: "address",
3233
- name: "agent",
3234
- type: "address"
3235
- }
3236
- ],
3237
- name: "AgentCreated",
3238
- type: "event"
3239
- },
3240
- {
3241
- anonymous: false,
3242
- inputs: [
3243
- {
3244
- indexed: true,
3245
- internalType: "bytes32",
3246
- name: "agentID",
3247
- type: "bytes32"
3248
- },
3249
- {
3250
- indexed: true,
3251
- internalType: "address",
3252
- name: "recipient",
3253
- type: "address"
3254
- },
3255
- {
3256
- indexed: false,
3257
- internalType: "uint256",
3258
- name: "amount",
3259
- type: "uint256"
3260
- }
3261
- ],
3262
- name: "AgentFundsWithdrawn",
3263
- type: "event"
3264
- },
3265
- {
3266
- anonymous: false,
3267
- inputs: [
3268
- {
3269
- indexed: true,
3270
- internalType: "ChannelID",
3271
- name: "channelID",
3272
- type: "bytes32"
3273
- }
3274
- ],
3275
- name: "ChannelCreated",
3276
- type: "event"
3277
- },
3278
- {
3279
- anonymous: false,
3280
- inputs: [
3281
- {
3282
- indexed: true,
3283
- internalType: "ChannelID",
3284
- name: "channelID",
3285
- type: "bytes32"
3286
- }
3287
- ],
3288
- name: "ChannelUpdated",
3289
- type: "event"
3290
- },
3291
- {
3292
- anonymous: false,
3293
- inputs: [
3294
- {
3295
- indexed: true,
3296
- internalType: "bytes32",
3297
- name: "tokenID",
3298
- type: "bytes32"
3299
- },
3300
- {
3301
- indexed: false,
3302
- internalType: "address",
3303
- name: "token",
3304
- type: "address"
3305
- }
3306
- ],
3307
- name: "ForeignTokenRegistered",
3308
- type: "event"
3309
- },
3310
- {
3311
- anonymous: false,
3312
- inputs: [
3313
- {
3314
- indexed: true,
3315
- internalType: "ChannelID",
3316
- name: "channelID",
3317
- type: "bytes32"
3318
- },
3319
- { indexed: false, internalType: "uint64", name: "nonce", type: "uint64" },
3320
- {
3321
- indexed: true,
3322
- internalType: "bytes32",
3323
- name: "messageID",
3324
- type: "bytes32"
3325
- },
3326
- { indexed: false, internalType: "bool", name: "success", type: "bool" }
3327
- ],
3328
- name: "InboundMessageDispatched",
3329
- type: "event"
3330
- },
3331
- {
3332
- anonymous: false,
3333
- inputs: [
3334
- {
3335
- indexed: true,
3336
- internalType: "address",
3337
- name: "previousMiddleware",
3338
- type: "address"
3339
- },
3340
- {
3341
- indexed: true,
3342
- internalType: "address",
3343
- name: "newMiddleware",
3344
- type: "address"
3345
- }
3346
- ],
3347
- name: "MiddlewareChanged",
3348
- type: "event"
3349
- },
3350
- {
3351
- anonymous: false,
3352
- inputs: [
3353
- {
3354
- indexed: false,
3355
- internalType: "enum OperatingMode",
3356
- name: "mode",
3357
- type: "uint8"
3358
- }
3359
- ],
3360
- name: "OperatingModeChanged",
3361
- type: "event"
3362
- },
3363
- {
3364
- anonymous: false,
3365
- inputs: [
3366
- {
3367
- indexed: true,
3368
- internalType: "uint256",
3369
- name: "validatorsCount",
3370
- type: "uint256"
3371
- },
3372
- { indexed: false, internalType: "bytes", name: "payload", type: "bytes" }
3373
- ],
3374
- name: "OperatorsDataCreated",
3375
- type: "event"
3376
- },
3377
- {
3378
- anonymous: false,
3379
- inputs: [
3380
- {
3381
- indexed: true,
3382
- internalType: "ChannelID",
3383
- name: "channelID",
3384
- type: "bytes32"
3385
- },
3386
- { indexed: false, internalType: "uint64", name: "nonce", type: "uint64" },
3387
- {
3388
- indexed: true,
3389
- internalType: "bytes32",
3390
- name: "messageID",
3391
- type: "bytes32"
3392
- },
3393
- { indexed: false, internalType: "bytes", name: "payload", type: "bytes" }
3394
- ],
3395
- name: "OutboundMessageAccepted",
3396
- type: "event"
3397
- },
3398
- {
3399
- anonymous: false,
3400
- inputs: [
3401
- {
3402
- indexed: true,
3403
- internalType: "address",
3404
- name: "previousOwner",
3405
- type: "address"
3406
- },
3407
- {
3408
- indexed: true,
3409
- internalType: "address",
3410
- name: "newOwner",
3411
- type: "address"
3412
- }
3413
- ],
3414
- name: "OwnershipTransferred",
3415
- type: "event"
3416
- },
3417
- {
3418
- anonymous: false,
3419
- inputs: [],
3420
- name: "PricingParametersChanged",
3421
- type: "event"
3422
- },
3423
- {
3424
- anonymous: false,
3425
- inputs: [
3426
- {
3427
- indexed: false,
3428
- internalType: "address",
3429
- name: "token",
3430
- type: "address"
3431
- }
3432
- ],
3433
- name: "TokenRegistrationSent",
3434
- type: "event"
3435
- },
3436
- {
3437
- anonymous: false,
3438
- inputs: [
3439
- {
3440
- indexed: true,
3441
- internalType: "address",
3442
- name: "token",
3443
- type: "address"
3444
- },
3445
- {
3446
- indexed: true,
3447
- internalType: "address",
3448
- name: "sender",
3449
- type: "address"
3450
- },
3451
- {
3452
- indexed: true,
3453
- internalType: "ParaID",
3454
- name: "destinationChain",
3455
- type: "uint32"
3456
- },
3457
- {
3458
- components: [
3459
- { internalType: "enum Kind", name: "kind", type: "uint8" },
3460
- { internalType: "bytes", name: "data", type: "bytes" }
3461
- ],
3462
- indexed: false,
3463
- internalType: "struct MultiAddress",
3464
- name: "destinationAddress",
3465
- type: "tuple"
3466
- },
3467
- {
3468
- indexed: false,
3469
- internalType: "uint128",
3470
- name: "amount",
3471
- type: "uint128"
3472
- }
3473
- ],
3474
- name: "TokenSent",
3475
- type: "event"
3476
- },
3477
- {
3478
- anonymous: false,
3479
- inputs: [],
3480
- name: "TokenTransferFeesChanged",
3481
- type: "event"
3482
- },
3483
- {
3484
- anonymous: false,
3485
- inputs: [
3486
- {
3487
- indexed: true,
3488
- internalType: "bytes32",
3489
- name: "operatorKey",
3490
- type: "bytes32"
3491
- },
3492
- {
3493
- indexed: false,
3494
- internalType: "uint256",
3495
- name: "slashFranction",
3496
- type: "uint256"
3497
- },
3498
- {
3499
- indexed: true,
3500
- internalType: "uint256",
3501
- name: "epoch",
3502
- type: "uint256"
3503
- },
3504
- { indexed: false, internalType: "bytes", name: "error", type: "bytes" }
3505
- ],
3506
- name: "UnableToProcessIndividualSlashB",
3507
- type: "event"
3508
- },
3509
- {
3510
- anonymous: false,
3511
- inputs: [
3512
- {
3513
- indexed: true,
3514
- internalType: "bytes32",
3515
- name: "operatorKey",
3516
- type: "bytes32"
3517
- },
3518
- {
3519
- indexed: false,
3520
- internalType: "uint256",
3521
- name: "slashFranction",
3522
- type: "uint256"
3523
- },
3524
- {
3525
- indexed: true,
3526
- internalType: "uint256",
3527
- name: "epoch",
3528
- type: "uint256"
3529
- },
3530
- { indexed: false, internalType: "string", name: "error", type: "string" }
3531
- ],
3532
- name: "UnableToProcessIndividualSlashS",
3533
- type: "event"
3534
- },
3535
- {
3536
- anonymous: false,
3537
- inputs: [
3538
- { indexed: false, internalType: "bytes", name: "error", type: "bytes" }
3539
- ],
3540
- name: "UnableToProcessRewardsMessageB",
3541
- type: "event"
3542
- },
3543
- {
3544
- anonymous: false,
3545
- inputs: [
3546
- { indexed: false, internalType: "string", name: "error", type: "string" }
3547
- ],
3548
- name: "UnableToProcessRewardsMessageS",
3549
- type: "event"
3550
- },
3551
- {
3552
- anonymous: false,
3553
- inputs: [
3554
- { indexed: false, internalType: "bytes", name: "error", type: "bytes" }
3555
- ],
3556
- name: "UnableToProcessSlashMessageB",
3557
- type: "event"
3558
- },
3559
- {
3560
- anonymous: false,
3561
- inputs: [
3562
- { indexed: false, internalType: "string", name: "error", type: "string" }
3563
- ],
3564
- name: "UnableToProcessSlashMessageS",
3565
- type: "event"
3566
- },
3567
- {
3568
- anonymous: false,
3569
- inputs: [
3570
- {
3571
- indexed: true,
3572
- internalType: "address",
3573
- name: "implementation",
3574
- type: "address"
3575
- }
3576
- ],
3577
- name: "Upgraded",
3578
- type: "event"
3579
- },
3580
- {
3581
- inputs: [],
3582
- name: "AGENT_EXECUTOR",
3583
- outputs: [{ internalType: "address", name: "", type: "address" }],
3584
- stateMutability: "view",
3585
- type: "function"
3586
- },
3587
- {
3588
- inputs: [],
3589
- name: "BEEFY_CLIENT",
3590
- outputs: [{ internalType: "address", name: "", type: "address" }],
3591
- stateMutability: "view",
3592
- type: "function"
3593
- },
3594
- {
3595
- inputs: [{ internalType: "bytes", name: "data", type: "bytes" }],
3596
- name: "agentExecute",
3597
- outputs: [],
3598
- stateMutability: "nonpayable",
3599
- type: "function"
3600
- },
3601
- {
3602
- inputs: [{ internalType: "bytes32", name: "agentID", type: "bytes32" }],
3603
- name: "agentOf",
3604
- outputs: [{ internalType: "address", name: "", type: "address" }],
3605
- stateMutability: "view",
3606
- type: "function"
3607
- },
3608
- {
3609
- inputs: [{ internalType: "ChannelID", name: "channelID", type: "bytes32" }],
3610
- name: "channelNoncesOf",
3611
- outputs: [
3612
- { internalType: "uint64", name: "", type: "uint64" },
3613
- { internalType: "uint64", name: "", type: "uint64" }
3614
- ],
3615
- stateMutability: "view",
3616
- type: "function"
3617
- },
3618
- {
3619
- inputs: [{ internalType: "ChannelID", name: "channelID", type: "bytes32" }],
3620
- name: "channelOperatingModeOf",
3621
- outputs: [{ internalType: "enum OperatingMode", name: "", type: "uint8" }],
3622
- stateMutability: "view",
3623
- type: "function"
3624
- },
3625
- {
3626
- inputs: [{ internalType: "bytes", name: "data", type: "bytes" }],
3627
- name: "createAgent",
3628
- outputs: [],
3629
- stateMutability: "nonpayable",
3630
- type: "function"
3631
- },
3632
- {
3633
- inputs: [{ internalType: "bytes", name: "data", type: "bytes" }],
3634
- name: "createChannel",
3635
- outputs: [],
3636
- stateMutability: "nonpayable",
3637
- type: "function"
3638
- },
3639
- {
3640
- inputs: [],
3641
- name: "implementation",
3642
- outputs: [{ internalType: "address", name: "", type: "address" }],
3643
- stateMutability: "view",
3644
- type: "function"
3645
- },
3646
- {
3647
- inputs: [{ internalType: "bytes", name: "data", type: "bytes" }],
3648
- name: "initialize",
3649
- outputs: [],
3650
- stateMutability: "nonpayable",
3651
- type: "function"
3652
- },
3653
- {
3654
- inputs: [{ internalType: "address", name: "token", type: "address" }],
3655
- name: "isTokenRegistered",
3656
- outputs: [{ internalType: "bool", name: "", type: "bool" }],
3657
- stateMutability: "view",
3658
- type: "function"
3659
- },
3660
- {
3661
- inputs: [{ internalType: "bytes", name: "data", type: "bytes" }],
3662
- name: "mintForeignToken",
3663
- outputs: [],
3664
- stateMutability: "nonpayable",
3665
- type: "function"
3666
- },
3667
- {
3668
- inputs: [],
3669
- name: "operatingMode",
3670
- outputs: [{ internalType: "enum OperatingMode", name: "", type: "uint8" }],
3671
- stateMutability: "view",
3672
- type: "function"
3673
- },
3674
- {
3675
- inputs: [],
3676
- name: "pricingParameters",
3677
- outputs: [
3678
- { internalType: "UD60x18", name: "", type: "uint256" },
3679
- { internalType: "uint128", name: "", type: "uint128" }
3680
- ],
3681
- stateMutability: "view",
3682
- type: "function"
3683
- },
3684
- {
3685
- inputs: [{ internalType: "address", name: "token", type: "address" }],
3686
- name: "queryForeignTokenID",
3687
- outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
3688
- stateMutability: "view",
3689
- type: "function"
3690
- },
3691
- {
3692
- inputs: [],
3693
- name: "quoteRegisterTokenFee",
3694
- outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
3695
- stateMutability: "view",
3696
- type: "function"
3697
- },
3698
- {
3699
- inputs: [
3700
- { internalType: "address", name: "token", type: "address" },
3701
- { internalType: "ParaID", name: "destinationChain", type: "uint32" },
3702
- { internalType: "uint128", name: "destinationFee", type: "uint128" }
3703
- ],
3704
- name: "quoteSendTokenFee",
3705
- outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
3706
- stateMutability: "view",
3707
- type: "function"
3708
- },
3709
- {
3710
- inputs: [{ internalType: "bytes", name: "data", type: "bytes" }],
3711
- name: "registerForeignToken",
3712
- outputs: [],
3713
- stateMutability: "nonpayable",
3714
- type: "function"
3715
- },
3716
- {
3717
- inputs: [{ internalType: "address", name: "token", type: "address" }],
3718
- name: "registerToken",
3719
- outputs: [],
3720
- stateMutability: "payable",
3721
- type: "function"
3722
- },
3723
- {
3724
- inputs: [{ internalType: "bytes", name: "data", type: "bytes" }],
3725
- name: "reportSlashes",
3726
- outputs: [],
3727
- stateMutability: "nonpayable",
3728
- type: "function"
3729
- },
3730
- {
3731
- inputs: [],
3732
- name: "s_middleware",
3733
- outputs: [{ internalType: "address", name: "", type: "address" }],
3734
- stateMutability: "view",
3735
- type: "function"
3736
- },
3737
- {
3738
- inputs: [
3739
- { internalType: "bytes32[]", name: "data", type: "bytes32[]" },
3740
- { internalType: "uint48", name: "epoch", type: "uint48" }
3741
- ],
3742
- name: "sendOperatorsData",
3743
- outputs: [],
3744
- stateMutability: "nonpayable",
3745
- type: "function"
3746
- },
3747
- {
3748
- inputs: [{ internalType: "bytes", name: "data", type: "bytes" }],
3749
- name: "sendRewards",
3750
- outputs: [],
3751
- stateMutability: "nonpayable",
3752
- type: "function"
3753
- },
3754
- {
3755
- inputs: [
3756
- { internalType: "address", name: "token", type: "address" },
3757
- { internalType: "ParaID", name: "destinationChain", type: "uint32" },
3758
- {
3759
- components: [
3760
- { internalType: "enum Kind", name: "kind", type: "uint8" },
3761
- { internalType: "bytes", name: "data", type: "bytes" }
3762
- ],
3763
- internalType: "struct MultiAddress",
3764
- name: "destinationAddress",
3765
- type: "tuple"
3766
- },
3767
- { internalType: "uint128", name: "destinationFee", type: "uint128" },
3768
- { internalType: "uint128", name: "amount", type: "uint128" }
3769
- ],
3770
- name: "sendToken",
3771
- outputs: [],
3772
- stateMutability: "payable",
3773
- type: "function"
3774
- },
3775
- {
3776
- inputs: [{ internalType: "address", name: "middleware", type: "address" }],
3777
- name: "setMiddleware",
3778
- outputs: [],
3779
- stateMutability: "nonpayable",
3780
- type: "function"
3781
- },
3782
- {
3783
- inputs: [{ internalType: "bytes", name: "data", type: "bytes" }],
3784
- name: "setOperatingMode",
3785
- outputs: [],
3786
- stateMutability: "nonpayable",
3787
- type: "function"
3788
- },
3789
- {
3790
- inputs: [{ internalType: "bytes", name: "data", type: "bytes" }],
3791
- name: "setPricingParameters",
3792
- outputs: [],
3793
- stateMutability: "nonpayable",
3794
- type: "function"
3795
- },
3796
- {
3797
- inputs: [{ internalType: "bytes", name: "data", type: "bytes" }],
3798
- name: "setTokenTransferFees",
3799
- outputs: [],
3800
- stateMutability: "nonpayable",
3801
- type: "function"
3802
- },
3803
- {
3804
- inputs: [
3805
- {
3806
- components: [
3807
- { internalType: "ChannelID", name: "channelID", type: "bytes32" },
3808
- { internalType: "uint64", name: "nonce", type: "uint64" },
3809
- { internalType: "enum Command", name: "command", type: "uint8" },
3810
- { internalType: "bytes", name: "params", type: "bytes" },
3811
- { internalType: "uint64", name: "maxDispatchGas", type: "uint64" },
3812
- { internalType: "uint256", name: "maxFeePerGas", type: "uint256" },
3813
- { internalType: "uint256", name: "reward", type: "uint256" },
3814
- { internalType: "bytes32", name: "id", type: "bytes32" }
3815
- ],
3816
- internalType: "struct InboundMessage",
3817
- name: "message",
3818
- type: "tuple"
3819
- },
3820
- { internalType: "bytes32[]", name: "leafProof", type: "bytes32[]" },
3821
- {
3822
- components: [
3823
- {
3824
- components: [
3825
- { internalType: "uint8", name: "version", type: "uint8" },
3826
- { internalType: "uint32", name: "parentNumber", type: "uint32" },
3827
- { internalType: "bytes32", name: "parentHash", type: "bytes32" },
3828
- {
3829
- internalType: "uint64",
3830
- name: "nextAuthoritySetID",
3831
- type: "uint64"
3832
- },
3833
- {
3834
- internalType: "uint32",
3835
- name: "nextAuthoritySetLen",
3836
- type: "uint32"
3837
- },
3838
- {
3839
- internalType: "bytes32",
3840
- name: "nextAuthoritySetRoot",
3841
- type: "bytes32"
3842
- }
3843
- ],
3844
- internalType: "struct Verification.MMRLeafPartial",
3845
- name: "leafPartial",
3846
- type: "tuple"
3847
- },
3848
- { internalType: "bytes32[]", name: "leafProof", type: "bytes32[]" },
3849
- {
3850
- internalType: "bytes32",
3851
- name: "parachainHeadsRoot",
3852
- type: "bytes32"
3853
- },
3854
- { internalType: "uint256", name: "leafProofOrder", type: "uint256" }
3855
- ],
3856
- internalType: "struct Verification.Proof",
3857
- name: "headerProof",
3858
- type: "tuple"
3859
- }
3860
- ],
3861
- name: "submitV1",
3862
- outputs: [],
3863
- stateMutability: "nonpayable",
3864
- type: "function"
3865
- },
3866
- {
3867
- inputs: [{ internalType: "bytes32", name: "tokenID", type: "bytes32" }],
3868
- name: "tokenAddressOf",
3869
- outputs: [{ internalType: "address", name: "", type: "address" }],
3870
- stateMutability: "view",
3871
- type: "function"
3872
- },
3873
- {
3874
- inputs: [{ internalType: "bytes", name: "data", type: "bytes" }],
3875
- name: "transferNativeFromAgent",
3876
- outputs: [],
3877
- stateMutability: "nonpayable",
3878
- type: "function"
3879
- },
3880
- {
3881
- inputs: [{ internalType: "bytes", name: "data", type: "bytes" }],
3882
- name: "transferNativeToken",
3883
- outputs: [],
3884
- stateMutability: "nonpayable",
3885
- type: "function"
3886
- },
3887
- {
3888
- inputs: [{ internalType: "address", name: "newOwner", type: "address" }],
3889
- name: "transferOwnership",
3890
- outputs: [],
3891
- stateMutability: "nonpayable",
3892
- type: "function"
3893
- },
3894
- {
3895
- inputs: [{ internalType: "bytes", name: "data", type: "bytes" }],
3896
- name: "updateChannel",
3897
- outputs: [],
3898
- stateMutability: "nonpayable",
3899
- type: "function"
3900
- },
3901
- {
3902
- inputs: [{ internalType: "bytes", name: "data", type: "bytes" }],
3903
- name: "upgrade",
3904
- outputs: [],
3905
- stateMutability: "nonpayable",
3906
- type: "function"
3907
- }
3908
- ];
3909
-
3910
- // src/fee/gateway/gateway.ts
3911
- function gateway() {
3912
- return {
3913
- quoteSendTokenFee() {
3914
- return {
3915
- build: ({ asset, destination, source }) => {
3916
- if (!asset.address) {
3917
- throw new Error(`Asset ${asset.key} has no address`);
3918
- }
3919
- if (!EvmChain.is(source) || !source.contracts?.Gateway) {
3920
- throw new Error(
3921
- "Source must be an EVMChain with the Gateway contract address configured for getting the quote send token fee for Gateway module"
3922
- );
3923
- }
3924
- if (!EvmParachain2.isAnyParachain(destination)) {
3925
- throw new Error(
3926
- "Destination must be a Parachain or EvmParachain for getting the quote send token fee for Gateway module"
3927
- );
3928
- }
3929
- return new ContractConfig({
3930
- address: source.contracts.Gateway,
3931
- abi: GATEWAY_ABI,
3932
- args: [asset.address, destination.parachainId, 0n],
3933
- func: "quoteSendTokenFee",
3934
- module: "Gateway"
3935
- });
3936
- }
3072
+ Parachain: destination.parachainId
3073
+ },
3074
+ {
3075
+ PalletInstance: asset.getAssetPalletInstance()
3076
+ }
3077
+ ]
3078
+ }
3079
+ }
3080
+ },
3081
+ fun: {
3082
+ Fungible: asset.amount || 1n
3083
+ }
3084
+ },
3085
+ {
3086
+ parents: 1,
3087
+ interior: {
3088
+ X2: [
3089
+ {
3090
+ Parachain: destination.parachainId
3091
+ },
3092
+ getExtrinsicAccount(destinationAddress)
3093
+ ]
3094
+ }
3095
+ },
3096
+ {
3097
+ refTime: 5e9,
3098
+ proofSize: 0
3099
+ }
3100
+ ]
3101
+ })
3102
+ })
3937
3103
  };
3938
3104
  }
3939
3105
  };
3940
3106
  }
3941
3107
 
3942
- // src/fee/outboundQueueApi/outboundQueueApi.ts
3943
- function outboundQueueApi() {
3108
+ // src/extrinsic/ExtrinsicBuilder.ts
3109
+ function ExtrinsicBuilder() {
3944
3110
  return {
3945
- calculateFee: () => {
3946
- return {
3947
- build: ({ address, asset, balance }) => {
3948
- const args = [
3949
- {
3950
- MintForeignToken: {
3951
- tokenId: asset.getAssetId(),
3952
- recipient: address,
3953
- amount: balance?.amount
3954
- }
3955
- },
3956
- null
3957
- ];
3958
- return new SubstrateQueryConfig({
3959
- module: "outboundQueueApi",
3960
- func: "calculateFee",
3961
- args,
3962
- queryType: "call",
3963
- transform: async (data) => data.local.toBigInt() + data.remote.toBigInt()
3964
- });
3965
- }
3966
- };
3967
- }
3111
+ eqBalances,
3112
+ xTokens,
3113
+ xTransfer,
3114
+ polkadotXcm,
3115
+ xcmPallet
3968
3116
  };
3969
3117
  }
3970
3118
 
3971
3119
  // src/fee/FeeBuilder.utils.ts
3972
- import { EvmParachain as EvmParachain3 } from "@moonbeam-network/xcm-types";
3120
+ import { EvmParachain as EvmParachain2 } from "@moonbeam-network/xcm-types";
3973
3121
  import { isEthAddress as isEthAddress2 } from "@moonbeam-network/xcm-utils";
3974
3122
  import { u8aToHex as u8aToHex5 } from "@polkadot/util";
3975
3123
  import { decodeAddress as decodeAddress5 } from "@polkadot/util-crypto";
@@ -3990,7 +3138,7 @@ function getWithdrawAssetInstruction(assetTypes) {
3990
3138
  };
3991
3139
  }
3992
3140
  function getUniversalOriginInstruction(source) {
3993
- if (!EvmParachain3.isAnyParachain(source)) {
3141
+ if (!EvmParachain2.isAnyParachain(source)) {
3994
3142
  throw new Error("Source is not a parachain");
3995
3143
  }
3996
3144
  return {
@@ -4000,7 +3148,7 @@ function getUniversalOriginInstruction(source) {
4000
3148
  };
4001
3149
  }
4002
3150
  function getDescendOriginInstruction(source) {
4003
- if (!EvmParachain3.isAnyParachain(source)) {
3151
+ if (!EvmParachain2.isAnyParachain(source)) {
4004
3152
  throw new Error("Source is not a parachain");
4005
3153
  }
4006
3154
  return {
@@ -4389,39 +3537,35 @@ var createXcmFeeBuilder = ({
4389
3537
  getVersionedTransferAsset,
4390
3538
  options
4391
3539
  }) => ({
4392
- build: (params) => {
4393
- return new SubstrateCallConfig({
4394
- api: params.api,
4395
- call: async () => {
4396
- const [assets3, versionedFeeAssetId] = await getVersionedAssets({
4397
- getVersionedFeeAsset,
4398
- getVersionedTransferAsset,
4399
- options,
4400
- params
4401
- });
4402
- const instructions = getInstructions({
4403
- isAssetReserveChain: options.isAssetReserveChain,
4404
- assets: assets3,
4405
- versionedFeeAssetId,
4406
- address: params.address,
4407
- source: params.source,
4408
- isEcosystemBridge: options.isEcosystemBridge
4409
- });
4410
- return getFeeForXcmInstructionsAndAsset(
4411
- params.api,
4412
- instructions,
4413
- versionedFeeAssetId
4414
- );
4415
- }
4416
- });
4417
- }
3540
+ build: (params) => new SubstrateCallConfig({
3541
+ api: params.api,
3542
+ call: async () => {
3543
+ const [assets3, versionedFeeAssetId] = await getVersionedAssets({
3544
+ getVersionedFeeAsset,
3545
+ getVersionedTransferAsset,
3546
+ options,
3547
+ params
3548
+ });
3549
+ const instructions = getInstructions({
3550
+ isAssetReserveChain: options.isAssetReserveChain,
3551
+ assets: assets3,
3552
+ versionedFeeAssetId,
3553
+ address: params.address,
3554
+ source: params.source,
3555
+ isEcosystemBridge: options.isEcosystemBridge
3556
+ });
3557
+ return getFeeForXcmInstructionsAndAsset(
3558
+ params.api,
3559
+ instructions,
3560
+ versionedFeeAssetId
3561
+ );
3562
+ }
3563
+ })
4418
3564
  });
4419
3565
 
4420
3566
  // src/fee/FeeBuilder.ts
4421
3567
  function FeeBuilder() {
4422
3568
  return {
4423
- gateway,
4424
- outboundQueueApi,
4425
3569
  xcmPaymentApi
4426
3570
  };
4427
3571
  }
@@ -4683,265 +3827,9 @@ function MonitoringBuilder() {
4683
3827
  };
4684
3828
  }
4685
3829
 
4686
- // src/mrl/providers/snowbridge/contract/Gateway/Gateway.ts
4687
- import {
4688
- EvmParachain as EvmParachain4
4689
- } from "@moonbeam-network/xcm-types";
4690
-
4691
- // src/mrl/providers/snowbridge/snowbridge/SnowbridgeConfig.ts
4692
- var SnowbridgeConfig = class _SnowbridgeConfig {
4693
- args;
4694
- func;
4695
- provider = "snowbridge";
4696
- static is(obj) {
4697
- return obj instanceof _SnowbridgeConfig;
4698
- }
4699
- constructor({ args, func }) {
4700
- this.args = args;
4701
- this.func = func;
4702
- }
4703
- };
4704
-
4705
- // src/mrl/providers/snowbridge/contract/Gateway/Gateway.ts
4706
- function Gateway() {
4707
- const provider = "snowbridge";
4708
- return {
4709
- sendToken: () => ({
4710
- provider,
4711
- build: ({ asset, destinationAddress, protocolFee, destination }) => callSendToken(asset, protocolFee, destination, destinationAddress)
4712
- }),
4713
- approveAndSendToken: () => ({
4714
- provider,
4715
- build: ({ asset, destinationAddress, protocolFee, destination }) => {
4716
- const requiresApproval = protocolFee && !protocolFee.isSame(asset);
4717
- return callSendToken(
4718
- asset,
4719
- protocolFee,
4720
- destination,
4721
- destinationAddress,
4722
- requiresApproval
4723
- );
4724
- }
4725
- })
4726
- };
4727
- }
4728
- function callSendToken(asset, protocolFee, destination, destinationAddress, requiresApproval = false) {
4729
- if (!protocolFee) {
4730
- throw new Error("Protocol fee is required for Gateway module");
4731
- }
4732
- if (!EvmParachain4.isAnyParachain(destination)) {
4733
- throw new Error(
4734
- "Destination must be a Parachain or EvmParachain for sending token with Gateway module"
4735
- );
4736
- }
4737
- return new SnowbridgeConfig({
4738
- args: {
4739
- tokenAddress: asset.address,
4740
- destinationAddress,
4741
- destinationParaId: destination.parachainId,
4742
- amount: asset.amount,
4743
- bridgeFeeAmount: protocolFee.amount,
4744
- requiresApproval
4745
- },
4746
- func: "sendToken"
4747
- });
4748
- }
4749
-
4750
- // src/mrl/providers/snowbridge/contract/index.ts
4751
- function contract() {
4752
- return { Gateway };
4753
- }
4754
-
4755
- // src/mrl/providers/snowbridge/extrinsic/ethereumTokenTransfer/ethereumTokenTransfers.ts
4756
- var pallet6 = "ethereumTokenTransfers";
4757
- function ethereumTokenTransfers() {
4758
- return {
4759
- transferNativeToken: () => {
4760
- const func = "transferNativeToken";
4761
- const provider = "snowbridge";
4762
- return {
4763
- provider,
4764
- build: ({ asset, destinationAddress }) => {
4765
- return new ExtrinsicConfig({
4766
- module: pallet6,
4767
- func,
4768
- getArgs: () => [asset.amount, destinationAddress]
4769
- });
4770
- }
4771
- };
4772
- }
4773
- };
4774
- }
4775
-
4776
- // src/mrl/providers/snowbridge/extrinsic/xcmPallet/xcmPallet.ts
4777
- import { EvmChain as EvmChain2 } from "@moonbeam-network/xcm-types";
4778
-
4779
- // src/mrl/providers/snowbridge/extrinsic/xcmPallet/xcmPallet.utils.ts
4780
- function getGlobalConsensusArgs({
4781
- assets: assets3,
4782
- destination,
4783
- destinationAddress,
4784
- func
4785
- }) {
4786
- const version = getExtrinsicArgumentVersion(func);
4787
- const dest = {
4788
- [version]: {
4789
- parents: 1,
4790
- interior: {
4791
- X1: [
4792
- {
4793
- GlobalConsensus: {
4794
- Ethereum: { chainId: destination.id }
4795
- }
4796
- }
4797
- ]
4798
- }
4799
- }
4800
- };
4801
- const beneficiary = {
4802
- [version]: {
4803
- parents: 0,
4804
- interior: {
4805
- X1: [
4806
- {
4807
- AccountKey20: {
4808
- network: { Ethereum: { chainId: destination.id } },
4809
- key: destinationAddress
4810
- }
4811
- }
4812
- ]
4813
- }
4814
- }
4815
- };
4816
- const assetsArg = {
4817
- [version]: assets3
4818
- };
4819
- return [
4820
- dest,
4821
- beneficiary,
4822
- assetsArg,
4823
- 0,
4824
- // feeAssetItem
4825
- "Unlimited"
4826
- ];
4827
- }
4828
-
4829
- // src/mrl/providers/snowbridge/extrinsic/xcmPallet/xcmPallet.ts
4830
- var pallet7 = "xcmPallet";
4831
- function xcmPallet2() {
4832
- return {
4833
- transferAssets: () => {
4834
- const func = "transferAssets";
4835
- const provider = "snowbridge";
4836
- return {
4837
- globalConsensus: () => ({
4838
- provider,
4839
- build: ({ asset, destination, destinationAddress }) => {
4840
- if (!EvmChain2.is(destination)) {
4841
- throw new Error(
4842
- "Destination must be an EVM chain for globalConsensus function"
4843
- );
4844
- }
4845
- return new ExtrinsicConfig({
4846
- module: pallet7,
4847
- func,
4848
- getArgs: (extrinsicFunction) => {
4849
- const assets3 = [
4850
- {
4851
- id: {
4852
- parents: 1,
4853
- interior: {
4854
- X1: [
4855
- {
4856
- GlobalConsensus: {
4857
- Ethereum: { chainId: destination.id }
4858
- }
4859
- }
4860
- ]
4861
- }
4862
- },
4863
- fun: { Fungible: asset.amount }
4864
- }
4865
- ];
4866
- return getGlobalConsensusArgs({
4867
- assets: assets3,
4868
- destination,
4869
- destinationAddress,
4870
- func: extrinsicFunction
4871
- });
4872
- }
4873
- });
4874
- }
4875
- }),
4876
- globalConsensusErc20: () => ({
4877
- provider,
4878
- build: ({ asset, destination, destinationAddress }) => {
4879
- if (!EvmChain2.is(destination)) {
4880
- throw new Error(
4881
- "Destination must be an EVM chain for globalConsensusErc20 function"
4882
- );
4883
- }
4884
- const assetInDestination = destination.getChainAsset(asset);
4885
- return new ExtrinsicConfig({
4886
- module: pallet7,
4887
- func,
4888
- getArgs: (extrinsicFunction) => {
4889
- const assets3 = [
4890
- {
4891
- id: {
4892
- parents: 1,
4893
- interior: {
4894
- X2: [
4895
- {
4896
- GlobalConsensus: {
4897
- Ethereum: { chainId: destination.id }
4898
- }
4899
- },
4900
- {
4901
- AccountKey20: {
4902
- network: {
4903
- Ethereum: { chainId: destination.id }
4904
- },
4905
- key: assetInDestination.address
4906
- }
4907
- }
4908
- ]
4909
- }
4910
- },
4911
- fun: { Fungible: asset.amount }
4912
- }
4913
- ];
4914
- return getGlobalConsensusArgs({
4915
- assets: assets3,
4916
- destination,
4917
- destinationAddress,
4918
- func: extrinsicFunction
4919
- });
4920
- }
4921
- });
4922
- }
4923
- })
4924
- };
4925
- }
4926
- };
4927
- }
4928
-
4929
- // src/mrl/providers/snowbridge/extrinsic/index.ts
4930
- function extrinsic() {
4931
- return { ethereumTokenTransfers, xcmPallet: xcmPallet2 };
4932
- }
4933
-
4934
- // src/mrl/providers/snowbridge/index.ts
4935
- function snowbridge() {
4936
- return {
4937
- contract,
4938
- extrinsic
4939
- };
4940
- }
4941
-
4942
3830
  // src/mrl/providers/wormhole/contract/Batch/Batch.ts
4943
3831
  import {
4944
- EvmParachain as EvmParachain5
3832
+ EvmParachain as EvmParachain3
4945
3833
  } from "@moonbeam-network/xcm-types";
4946
3834
  import { getMultilocationDerivedAddresses as getMultilocationDerivedAddresses2 } from "@moonbeam-network/xcm-utils";
4947
3835
  import { evmToAddress as evmToAddress3 } from "@polkadot/util-crypto";
@@ -4953,13 +3841,12 @@ import {
4953
3841
  Parachain as Parachain2
4954
3842
  } from "@moonbeam-network/xcm-types";
4955
3843
  import { getMultilocationDerivedAddresses } from "@moonbeam-network/xcm-utils";
3844
+ import { moonriver } from "viem/chains";
4956
3845
  var BUY_EXECUTION_FEE = 100000000000000000n;
4957
3846
  var CROSS_CHAIN_FEE = 100000000000000000n;
4958
3847
  function polkadotXcm2() {
4959
- const provider = "wormhole";
4960
3848
  return {
4961
3849
  send: () => ({
4962
- provider,
4963
3850
  build: ({
4964
3851
  asset,
4965
3852
  destination,
@@ -4967,7 +3854,7 @@ function polkadotXcm2() {
4967
3854
  fee,
4968
3855
  isAutomatic,
4969
3856
  moonAsset,
4970
- bridgeChain,
3857
+ moonChain,
4971
3858
  moonApi,
4972
3859
  sendOnlyRemoteExecution,
4973
3860
  source,
@@ -4998,7 +3885,7 @@ function polkadotXcm2() {
4998
3885
  isAutomatic,
4999
3886
  moonApi,
5000
3887
  moonAsset,
5001
- bridgeChain,
3888
+ moonChain,
5002
3889
  source,
5003
3890
  sourceAddress,
5004
3891
  sourceApi
@@ -5011,7 +3898,7 @@ function polkadotXcm2() {
5011
3898
  fee,
5012
3899
  isAutomatic,
5013
3900
  moonAsset,
5014
- bridgeChain,
3901
+ moonChain,
5015
3902
  moonApi,
5016
3903
  source,
5017
3904
  sourceAddress,
@@ -5019,6 +3906,16 @@ function polkadotXcm2() {
5019
3906
  transact
5020
3907
  });
5021
3908
  const transactionsToSend = sendOnlyRemoteExecution ? [send] : [...assetTransferTxs, send];
3909
+ console.log("send", send.toHuman());
3910
+ console.log(
3911
+ "assetTransferTxs",
3912
+ assetTransferTxs.map((tx) => tx.toHuman())
3913
+ );
3914
+ console.log("transact", transact);
3915
+ console.log(
3916
+ "transactionsToSend",
3917
+ transactionsToSend.map((tx) => tx.toHuman())
3918
+ );
5022
3919
  return new ExtrinsicConfig({
5023
3920
  module: "utility",
5024
3921
  func: "batchAll",
@@ -5031,7 +3928,7 @@ function polkadotXcm2() {
5031
3928
  function buildSendExtrinsic({
5032
3929
  computedOriginAccount,
5033
3930
  moonAsset,
5034
- bridgeChain,
3931
+ moonChain,
5035
3932
  sourceApi,
5036
3933
  transact
5037
3934
  }) {
@@ -5042,9 +3939,12 @@ function buildSendExtrinsic({
5042
3939
  return sourceApi.tx.polkadotXcm.send(
5043
3940
  {
5044
3941
  [version]: normalizeX1(version, {
5045
- parents: 1,
3942
+ parents: 2,
5046
3943
  interior: {
5047
- X1: { Parachain: bridgeChain.parachainId }
3944
+ X2: [
3945
+ { GlobalConsensus: "Polkadot" },
3946
+ { Parachain: moonChain.parachainId }
3947
+ ]
5048
3948
  }
5049
3949
  })
5050
3950
  },
@@ -5127,14 +4027,36 @@ function getAssetTransferTxs({
5127
4027
  fee,
5128
4028
  moonApi,
5129
4029
  moonAsset,
5130
- bridgeChain,
4030
+ moonChain,
5131
4031
  source,
5132
4032
  sourceAddress,
5133
4033
  sourceApi
5134
4034
  }) {
5135
- const { transfer, transferMulticurrencies } = sourceApi.tx.xTokens;
4035
+ const { transferAssets } = sourceApi.tx.polkadotXcm;
5136
4036
  const transferBuilder = ExtrinsicBuilder().xTokens().transfer();
4037
+ const polkadotXcmBuilder = ExtrinsicBuilder().polkadotXcm().transferAssetsToEcosystem().X4();
5137
4038
  const transferMulticurrenciesBuilder = ExtrinsicBuilder().xTokens().transferMultiCurrencies();
4039
+ const testMoonriver = source.name === moonriver.name;
4040
+ console.log("testMoonriver", testMoonriver);
4041
+ if (testMoonriver) {
4042
+ const transferAssetsTx = transferAssets(
4043
+ ...polkadotXcmBuilder.build({
4044
+ asset,
4045
+ destination: moonChain,
4046
+ destinationAddress: computedOriginAccount,
4047
+ destinationApi: moonApi,
4048
+ fee: AssetAmount.fromChainAsset(source.getChainAsset(moonAsset), {
4049
+ amount: CROSS_CHAIN_FEE + BUY_EXECUTION_FEE
4050
+ }),
4051
+ source,
4052
+ sourceAddress,
4053
+ sourceApi
4054
+ }).getArgs(transferAssets)
4055
+ );
4056
+ console.log("transferAssetsTx", transferAssetsTx.toHuman());
4057
+ return [transferAssetsTx];
4058
+ }
4059
+ const { transfer, transferMulticurrencies } = sourceApi.tx.xTokens;
5138
4060
  if (asset.isSame(fee)) {
5139
4061
  const assetTransferTx = transfer(
5140
4062
  ...transferBuilder.build({
@@ -5143,7 +4065,7 @@ function getAssetTransferTxs({
5143
4065
  // for this we have to add a new concept in the config (Cross Chain Fee), and get the value from there
5144
4066
  amount: asset.amount + 10n * CROSS_CHAIN_FEE
5145
4067
  }),
5146
- destination: bridgeChain,
4068
+ destination: moonChain,
5147
4069
  destinationAddress: computedOriginAccount,
5148
4070
  destinationApi: moonApi,
5149
4071
  fee,
@@ -5157,7 +4079,7 @@ function getAssetTransferTxs({
5157
4079
  asset: AssetAmount.fromChainAsset(source.getChainAsset(moonAsset), {
5158
4080
  amount: CROSS_CHAIN_FEE + BUY_EXECUTION_FEE
5159
4081
  }),
5160
- destination: bridgeChain,
4082
+ destination: moonChain,
5161
4083
  destinationAddress: computedOriginAccount,
5162
4084
  destinationApi: moonApi,
5163
4085
  fee,
@@ -5171,7 +4093,7 @@ function getAssetTransferTxs({
5171
4093
  const multiCurrenciesTransferTx = transferMulticurrencies(
5172
4094
  ...transferMulticurrenciesBuilder.build({
5173
4095
  asset,
5174
- destination: bridgeChain,
4096
+ destination: moonChain,
5175
4097
  destinationAddress: computedOriginAccount,
5176
4098
  destinationApi: moonApi,
5177
4099
  fee: AssetAmount.fromChainAsset(source.getChainAsset(moonAsset), {
@@ -5727,10 +4649,8 @@ function getAbisForChain(_) {
5727
4649
  // src/mrl/providers/wormhole/contract/Batch/Batch.ts
5728
4650
  var module = "Batch";
5729
4651
  function Batch() {
5730
- const provider = "wormhole";
5731
4652
  return {
5732
4653
  transferAssetsAndMessage: () => ({
5733
- provider,
5734
4654
  build: ({
5735
4655
  asset,
5736
4656
  destination,
@@ -5738,14 +4658,14 @@ function Batch() {
5738
4658
  fee,
5739
4659
  isAutomatic,
5740
4660
  moonAsset,
5741
- bridgeChain,
4661
+ moonChain,
5742
4662
  moonApi,
5743
4663
  source,
5744
4664
  sourceAddress,
5745
4665
  sourceApi,
5746
4666
  transact
5747
4667
  }) => {
5748
- if (!EvmParachain5.is(source)) {
4668
+ if (!EvmParachain3.is(source)) {
5749
4669
  throw new Error("Source chain needs to be an EVMParachain");
5750
4670
  }
5751
4671
  if (!sourceApi) {
@@ -5771,7 +4691,7 @@ function Batch() {
5771
4691
  fee,
5772
4692
  isAutomatic,
5773
4693
  moonAsset,
5774
- bridgeChain,
4694
+ moonChain,
5775
4695
  moonApi,
5776
4696
  source,
5777
4697
  sourceAddress,
@@ -5779,7 +4699,7 @@ function Batch() {
5779
4699
  transact
5780
4700
  });
5781
4701
  const encodedXcmMessage = send.args[1].toHex();
5782
- const { destinationParachain, destinationParachainAndAddress } = getDestinationInHex(bridgeChain, computedOriginAccount);
4702
+ const { destinationParachain, destinationParachainAndAddress } = getDestinationInHex(moonChain, computedOriginAccount);
5783
4703
  const { currencies, feeItem } = getCurrencies({
5784
4704
  source,
5785
4705
  moonAsset,
@@ -5812,15 +4732,15 @@ function Batch() {
5812
4732
  })
5813
4733
  };
5814
4734
  }
5815
- function getDestinationInHex(bridgeChain, computedOriginAccount) {
4735
+ function getDestinationInHex(moonChain, computedOriginAccount) {
5816
4736
  const destinationParachain = {
5817
4737
  parents: 1,
5818
- interior: getPrecompileDestinationInterior(bridgeChain)
4738
+ interior: getPrecompileDestinationInterior(moonChain)
5819
4739
  };
5820
4740
  const destinationParachainAndAddress = {
5821
4741
  parents: 1,
5822
4742
  interior: getPrecompileDestinationInterior(
5823
- bridgeChain,
4743
+ moonChain,
5824
4744
  computedOriginAccount
5825
4745
  )
5826
4746
  };
@@ -5897,7 +4817,6 @@ var Protocols = /* @__PURE__ */ ((Protocols2) => {
5897
4817
  var WormholeConfig = class _WormholeConfig {
5898
4818
  args;
5899
4819
  func;
5900
- provider = "wormhole";
5901
4820
  static is(obj) {
5902
4821
  return obj instanceof _WormholeConfig;
5903
4822
  }
@@ -5908,20 +4827,20 @@ var WormholeConfig = class _WormholeConfig {
5908
4827
  };
5909
4828
 
5910
4829
  // src/mrl/providers/wormhole/wormhole/wormhole.ts
5911
- import { EvmChain as EvmChain3, EvmParachain as EvmParachain7, Parachain as Parachain3 } from "@moonbeam-network/xcm-types";
4830
+ import { EvmChain, EvmParachain as EvmParachain5, Parachain as Parachain3 } from "@moonbeam-network/xcm-types";
5912
4831
  import { getMultilocationDerivedAddresses as getMultilocationDerivedAddresses3 } from "@moonbeam-network/xcm-utils";
5913
4832
  import { evmToAddress as evmToAddress4 } from "@polkadot/util-crypto/address";
5914
4833
  import { Wormhole as Wormhole2 } from "@wormhole-foundation/sdk-connect";
5915
4834
 
5916
4835
  // src/mrl/providers/wormhole/wormhole/wormholeFactory.ts
5917
- import { EvmParachain as EvmParachain6 } from "@moonbeam-network/xcm-types";
4836
+ import { EvmParachain as EvmParachain4 } from "@moonbeam-network/xcm-types";
5918
4837
  import { Wormhole } from "@wormhole-foundation/sdk-connect";
5919
4838
  import { EvmPlatform } from "@wormhole-foundation/sdk-evm";
5920
4839
  function wormholeFactory(chain) {
5921
4840
  return new Wormhole(
5922
4841
  chain.isTestChain ? "Testnet" : "Mainnet",
5923
4842
  [EvmPlatform],
5924
- EvmParachain6.isAnyEvmChain(chain) && chain.wh ? {
4843
+ EvmParachain4.isAnyEvmChain(chain) && chain.wh ? {
5925
4844
  chains: {
5926
4845
  [chain.wh.name]: {
5927
4846
  rpc: chain.rpc
@@ -5933,23 +4852,21 @@ function wormholeFactory(chain) {
5933
4852
 
5934
4853
  // src/mrl/providers/wormhole/wormhole/wormhole.ts
5935
4854
  function wormhole() {
5936
- const provider = "wormhole";
5937
4855
  return {
5938
4856
  tokenTransfer: () => ({
5939
- provider,
5940
4857
  build: ({
5941
4858
  asset,
5942
4859
  destination,
5943
4860
  destinationAddress,
5944
4861
  isAutomatic,
5945
4862
  moonApi,
5946
- bridgeChain: moonChain,
4863
+ moonChain,
5947
4864
  source,
5948
4865
  sourceAddress
5949
4866
  }) => {
5950
4867
  const isSourceParachain = Parachain3.is(source);
5951
4868
  const isDestinationMoonChain = destination.isEqual(moonChain);
5952
- const isDestinationEvmChain = EvmChain3.is(destination);
4869
+ const isDestinationEvmChain = EvmChain.is(destination);
5953
4870
  const isNativeAsset = asset.isSame(
5954
4871
  isDestinationEvmChain ? moonChain.nativeAsset : source.nativeAsset
5955
4872
  );
@@ -5981,7 +4898,12 @@ function wormhole() {
5981
4898
  from: whSourceAddress,
5982
4899
  to: whDestinationAddress,
5983
4900
  protocol: isAutomatic ? "AutomaticTokenBridge" /* AutomaticTokenBridge */ : "TokenBridge" /* TokenBridge */,
5984
- payload: isDestinationMoonChain || isDestinationEvmChain ? void 0 : getPayload({ destination, destinationAddress, moonApi })
4901
+ payload: isDestinationMoonChain || isDestinationEvmChain ? void 0 : getPayload({
4902
+ destination,
4903
+ destinationAddress,
4904
+ moonApi,
4905
+ moonChain
4906
+ })
5985
4907
  },
5986
4908
  func: "tokenTransfer"
5987
4909
  });
@@ -5992,16 +4914,60 @@ function wormhole() {
5992
4914
  function getPayload({
5993
4915
  moonApi,
5994
4916
  destination,
5995
- destinationAddress
4917
+ destinationAddress,
4918
+ moonChain
4919
+ }) {
4920
+ const multilocation = getMultilocation({
4921
+ destination,
4922
+ destinationAddress,
4923
+ moonApi,
4924
+ moonChain
4925
+ });
4926
+ console.log("multilocation", multilocation.toHuman());
4927
+ const action = moonApi.createType("XcmRoutingUserAction", {
4928
+ destination: multilocation
4929
+ });
4930
+ const versioned = moonApi.createType("VersionedUserAction", {
4931
+ V1: action
4932
+ });
4933
+ return versioned.toU8a();
4934
+ }
4935
+ function getMultilocation({
4936
+ moonApi,
4937
+ destination,
4938
+ destinationAddress,
4939
+ moonChain
5996
4940
  }) {
5997
- if (!EvmParachain7.isAnyParachain(destination)) {
4941
+ if (!EvmParachain5.isAnyParachain(destination)) {
5998
4942
  throw new Error(
5999
4943
  `Destination ${destination.name} is not a Parachain or EvmParachain`
6000
4944
  );
6001
4945
  }
6002
- const isEvmDestination = EvmParachain7.is(destination);
6003
4946
  const version = getExtrinsicArgumentVersion(moonApi.tx.polkadotXcm.send);
6004
- const multilocation = moonApi.createType("XcmVersionedLocation", {
4947
+ const isDifferentEcosystem = destination.ecosystem !== moonChain.ecosystem;
4948
+ const isEvmDestination = EvmParachain5.is(destination);
4949
+ if (isDifferentEcosystem) {
4950
+ return moonApi.createType("XcmVersionedLocation", {
4951
+ [version]: {
4952
+ parents: 2,
4953
+ interior: {
4954
+ X3: [
4955
+ {
4956
+ GlobalConsensus: getGlobalConsensus(destination)
4957
+ },
4958
+ {
4959
+ Parachain: destination.parachainId
4960
+ },
4961
+ // wrong
4962
+ getExtrinsicAccount(
4963
+ isEvmDestination ? evmToAddress4(destinationAddress) : destinationAddress
4964
+ )
4965
+ ]
4966
+ }
4967
+ }
4968
+ });
4969
+ }
4970
+ return moonApi.createType("XcmVersionedLocation", {
6005
4971
  [version]: {
6006
4972
  parents: 1,
6007
4973
  interior: {
@@ -6016,13 +4982,6 @@ function getPayload({
6016
4982
  }
6017
4983
  }
6018
4984
  });
6019
- const action = moonApi.createType("XcmRoutingUserAction", {
6020
- destination: multilocation
6021
- });
6022
- const versioned = moonApi.createType("VersionedUserAction", {
6023
- V1: action
6024
- });
6025
- return versioned.toU8a();
6026
4985
  }
6027
4986
 
6028
4987
  // src/mrl/providers/wormhole/contract/TokenBridge/TokenBridgeAbi.ts
@@ -7215,28 +6174,26 @@ var TOKEN_BRIDGE_ABI = [
7215
6174
  // src/mrl/providers/wormhole/contract/TokenBridge/TokenBridge.ts
7216
6175
  var module3 = "TokenBridge";
7217
6176
  function TokenBridge() {
7218
- const provider = "wormhole";
7219
6177
  return {
7220
6178
  transferTokens: () => ({
7221
- provider,
7222
- build: ({ asset, destination, destinationAddress, bridgeChain }) => {
7223
- const wh = wormholeFactory(bridgeChain);
6179
+ build: ({ asset, destination, destinationAddress, moonChain }) => {
6180
+ const wh = wormholeFactory(moonChain);
7224
6181
  const whDestination = wh.getChain(destination.getWormholeName()).config.chainId;
7225
- const tokenAddressOnMoonChain = bridgeChain.getChainAsset(asset).address;
6182
+ const tokenAddressOnMoonChain = moonChain.getChainAsset(asset).address;
7226
6183
  if (!tokenAddressOnMoonChain) {
7227
6184
  throw new Error(
7228
- `Asset ${asset.symbol} does not have a token address on chain ${bridgeChain.name}`
6185
+ `Asset ${asset.symbol} does not have a token address on chain ${moonChain.name}`
7229
6186
  );
7230
6187
  }
7231
6188
  const destinationAddress32bytes = convertAddressTo32Bytes(
7232
6189
  destinationAddress
7233
6190
  );
7234
6191
  const tokenAmountOnMoonChain = asset.convertDecimals(
7235
- bridgeChain.getChainAsset(asset).decimals
6192
+ moonChain.getChainAsset(asset).decimals
7236
6193
  ).amount;
7237
6194
  const contractAddress = wh.getChain("Moonbeam").config.contracts.tokenBridge;
7238
6195
  if (!contractAddress) {
7239
- throw new Error(`Wormhole address not found for ${bridgeChain.name}`);
6196
+ throw new Error(`Wormhole address not found for ${moonChain.name}`);
7240
6197
  }
7241
6198
  return new ContractConfig({
7242
6199
  address: contractAddress,
@@ -7374,28 +6331,26 @@ var TOKEN_BRIDGE_RELAYER_ABI = [
7374
6331
  // src/mrl/providers/wormhole/contract/TokenBridgeRelayer/TokenBridgeRelayer.ts
7375
6332
  var module4 = "TokenBridgeRelayer";
7376
6333
  function TokenBridgeRelayer() {
7377
- const provider = "wormhole";
7378
6334
  return {
7379
6335
  transferTokensWithRelay: () => ({
7380
- provider,
7381
- build: ({ asset, destination, destinationAddress, bridgeChain }) => {
7382
- const wh = wormholeFactory(bridgeChain);
6336
+ build: ({ asset, destination, destinationAddress, moonChain }) => {
6337
+ const wh = wormholeFactory(moonChain);
7383
6338
  const whDestination = wh.getChain(destination.getWormholeName()).config.chainId;
7384
- const tokenAddressOnMoonChain = bridgeChain.getChainAsset(asset).address;
6339
+ const tokenAddressOnMoonChain = moonChain.getChainAsset(asset).address;
7385
6340
  if (!tokenAddressOnMoonChain) {
7386
6341
  throw new Error(
7387
- `Asset ${asset.symbol} does not have a token address on chain ${bridgeChain.name}`
6342
+ `Asset ${asset.symbol} does not have a token address on chain ${moonChain.name}`
7388
6343
  );
7389
6344
  }
7390
6345
  const destinationAddress32bytes = convertAddressTo32Bytes2(
7391
6346
  destinationAddress
7392
6347
  );
7393
6348
  const tokenAmountOnMoonChain = asset.convertDecimals(
7394
- bridgeChain.getChainAsset(asset).decimals
6349
+ moonChain.getChainAsset(asset).decimals
7395
6350
  ).amount;
7396
6351
  const contractAddress = wh.getChain("Moonbeam").config.contracts.tokenBridgeRelayer;
7397
6352
  if (!contractAddress) {
7398
- throw new Error(`Wormhole address not found for ${bridgeChain.name}`);
6353
+ throw new Error(`Wormhole address not found for ${moonChain.name}`);
7399
6354
  }
7400
6355
  return new ContractConfig({
7401
6356
  address: contractAddress,
@@ -7417,7 +6372,7 @@ function TokenBridgeRelayer() {
7417
6372
  }
7418
6373
 
7419
6374
  // src/mrl/providers/wormhole/contract/index.ts
7420
- function contract2() {
6375
+ function contract() {
7421
6376
  return { Batch, Gmp, TokenBridge, TokenBridgeRelayer };
7422
6377
  }
7423
6378
 
@@ -7543,38 +6498,36 @@ var BATCH_CONTRACT_ABI = [
7543
6498
 
7544
6499
  // src/mrl/providers/wormhole/extrinsic/ethereumXcm/ethereumXcm.ts
7545
6500
  function ethereumXcm() {
7546
- const provider = "wormhole";
7547
6501
  return {
7548
6502
  transact: () => ({
7549
- provider,
7550
6503
  build: (params) => {
7551
- const { asset, isAutomatic, bridgeChain, bridgeChainGasLimit } = params;
7552
- if (!bridgeChainGasLimit) {
7553
- throw new Error("bridgeChainGasLimit must be defined");
6504
+ const { asset, isAutomatic, moonChain, moonGasLimit } = params;
6505
+ if (!moonGasLimit) {
6506
+ throw new Error("moonGasLimit must be defined");
7554
6507
  }
7555
- const tokenAddressOnMoonChain = bridgeChain.getChainAsset(asset).address;
6508
+ const tokenAddressOnMoonChain = moonChain.getChainAsset(asset).address;
7556
6509
  if (!tokenAddressOnMoonChain) {
7557
6510
  throw new Error(
7558
- `Asset ${asset.symbol} does not have a token address on chain ${bridgeChain.name}`
6511
+ `Asset ${asset.symbol} does not have a token address on chain ${moonChain.name}`
7559
6512
  );
7560
6513
  }
7561
6514
  const tokenAmountOnMoonChain = asset.convertDecimals(
7562
- bridgeChain.getChainAsset(asset).decimals
6515
+ moonChain.getChainAsset(asset).decimals
7563
6516
  ).amount;
7564
- const contract3 = isAutomatic ? contract2().TokenBridgeRelayer().transferTokensWithRelay().build(params) : contract2().TokenBridge().transferTokens().build(params);
6517
+ const contract2 = isAutomatic ? contract().TokenBridgeRelayer().transferTokensWithRelay().build(params) : contract().TokenBridge().transferTokens().build(params);
7565
6518
  const approveTx = encodeFunctionData3({
7566
6519
  abi: ERC20_ABI,
7567
6520
  functionName: "approve",
7568
- args: [contract3.address, tokenAmountOnMoonChain]
6521
+ args: [contract2.address, tokenAmountOnMoonChain]
7569
6522
  });
7570
6523
  const batchAll = encodeFunctionData3({
7571
6524
  abi: BATCH_CONTRACT_ABI,
7572
6525
  functionName: "batchAll",
7573
6526
  args: [
7574
- [tokenAddressOnMoonChain, contract3.address],
6527
+ [tokenAddressOnMoonChain, contract2.address],
7575
6528
  [0n, 0n],
7576
6529
  // Value to send for each call
7577
- [approveTx, contract3.encodeFunctionData()],
6530
+ [approveTx, contract2.encodeFunctionData()],
7578
6531
  // Call data for each call
7579
6532
  []
7580
6533
  // Gas limit for each call
@@ -7586,7 +6539,7 @@ function ethereumXcm() {
7586
6539
  getArgs: () => [
7587
6540
  {
7588
6541
  V2: {
7589
- gasLimit: bridgeChainGasLimit,
6542
+ gasLimit: moonGasLimit,
7590
6543
  action: {
7591
6544
  Call: BATCH_CONTRACT_ADDRESS
7592
6545
  },
@@ -7602,15 +6555,15 @@ function ethereumXcm() {
7602
6555
  }
7603
6556
 
7604
6557
  // src/mrl/providers/wormhole/extrinsic/index.ts
7605
- function extrinsic2() {
6558
+ function extrinsic() {
7606
6559
  return { ethereumXcm, polkadotXcm: polkadotXcm2 };
7607
6560
  }
7608
6561
 
7609
6562
  // src/mrl/providers/wormhole/index.ts
7610
6563
  function wormhole2() {
7611
6564
  return {
7612
- contract: contract2,
7613
- extrinsic: extrinsic2,
6565
+ contract,
6566
+ extrinsic,
7614
6567
  wormhole
7615
6568
  };
7616
6569
  }
@@ -7618,7 +6571,6 @@ function wormhole2() {
7618
6571
  // src/mrl/MrlBuilder.ts
7619
6572
  function MrlBuilder() {
7620
6573
  return {
7621
- snowbridge,
7622
6574
  wormhole: wormhole2
7623
6575
  };
7624
6576
  }
@@ -7634,11 +6586,9 @@ export {
7634
6586
  ExtrinsicBuilder,
7635
6587
  ExtrinsicConfig,
7636
6588
  FeeBuilder,
7637
- GATEWAY_ABI,
7638
6589
  MonitoringBuilder,
7639
6590
  MrlBuilder,
7640
6591
  Protocols,
7641
- SnowbridgeConfig,
7642
6592
  SubstrateCallConfig,
7643
6593
  SubstrateQueryConfig,
7644
6594
  TransferType,
@@ -7646,7 +6596,6 @@ export {
7646
6596
  XcmVersion,
7647
6597
  calculateSystemAccountBalance,
7648
6598
  evm,
7649
- snowbridge,
7650
6599
  substrate,
7651
6600
  wormhole2 as wormhole,
7652
6601
  wormholeFactory