@moonbeam-network/mrl 1.0.0-dev.273 → 1.0.0-dev.275
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 +22 -11
- package/build/index.mjs.map +1 -1
- package/package.json +6 -6
package/build/index.mjs
CHANGED
|
@@ -17255,6 +17255,11 @@ async function getBridgeChainGasLimit(params) {
|
|
|
17255
17255
|
});
|
|
17256
17256
|
return gasEstimation * 110n / 100n;
|
|
17257
17257
|
}
|
|
17258
|
+
function getAmountForTransferSimulation(balance, protocolFee) {
|
|
17259
|
+
return balance.copyWith({
|
|
17260
|
+
amount: balance.amount - protocolFee.amount > 0 ? balance.amount - protocolFee.amount : 0n
|
|
17261
|
+
});
|
|
17262
|
+
}
|
|
17258
17263
|
|
|
17259
17264
|
// src/getTransferData/getSourceData.ts
|
|
17260
17265
|
async function getSourceData({
|
|
@@ -17306,15 +17311,14 @@ async function getSourceData({
|
|
|
17306
17311
|
const protocolFee = await getProtocolFee({
|
|
17307
17312
|
source,
|
|
17308
17313
|
destination,
|
|
17309
|
-
|
|
17310
|
-
|
|
17311
|
-
asset: feeAsset,
|
|
17314
|
+
asset,
|
|
17315
|
+
feeAsset,
|
|
17312
17316
|
balance,
|
|
17313
17317
|
protocolFee: route.source.protocolFee,
|
|
17314
17318
|
address: destinationAddress
|
|
17315
17319
|
});
|
|
17316
17320
|
const transfer = await buildTransfer({
|
|
17317
|
-
asset:
|
|
17321
|
+
asset: getAmountForTransferSimulation(balance, protocolFee),
|
|
17318
17322
|
protocolFee,
|
|
17319
17323
|
destinationAddress,
|
|
17320
17324
|
feeAsset: feeBalance,
|
|
@@ -17380,10 +17384,15 @@ async function getFee({
|
|
|
17380
17384
|
}
|
|
17381
17385
|
if (SnowbridgeConfig.is(transfer)) {
|
|
17382
17386
|
const snowbridge = SnowbridgeService.create(chain2);
|
|
17383
|
-
|
|
17384
|
-
|
|
17385
|
-
|
|
17386
|
-
|
|
17387
|
+
try {
|
|
17388
|
+
const feeAmount = await snowbridge.getFee(sourceAddress, transfer);
|
|
17389
|
+
return AssetAmount2.fromChainAsset(chain2.getChainAsset(feeBalance), {
|
|
17390
|
+
amount: feeAmount
|
|
17391
|
+
});
|
|
17392
|
+
} catch (error) {
|
|
17393
|
+
console.error(error);
|
|
17394
|
+
return feeBalance.copyWith({ amount: 0n });
|
|
17395
|
+
}
|
|
17387
17396
|
}
|
|
17388
17397
|
if (ContractConfig2.is(transfer)) {
|
|
17389
17398
|
try {
|
|
@@ -17485,6 +17494,7 @@ async function getBridgeChainFeeBalance({
|
|
|
17485
17494
|
async function getProtocolFee({
|
|
17486
17495
|
address,
|
|
17487
17496
|
asset,
|
|
17497
|
+
feeAsset,
|
|
17488
17498
|
balance,
|
|
17489
17499
|
protocolFee,
|
|
17490
17500
|
destination,
|
|
@@ -17498,6 +17508,7 @@ async function getProtocolFee({
|
|
|
17498
17508
|
const config = protocolFee?.build({
|
|
17499
17509
|
address,
|
|
17500
17510
|
asset,
|
|
17511
|
+
feeAsset,
|
|
17501
17512
|
balance,
|
|
17502
17513
|
destination,
|
|
17503
17514
|
source
|
|
@@ -17510,18 +17521,18 @@ async function getProtocolFee({
|
|
|
17510
17521
|
`Error getting bridge fee: expected bigint from contract call, but received ${typeof amount}. `
|
|
17511
17522
|
);
|
|
17512
17523
|
}
|
|
17513
|
-
return AssetAmount2.fromChainAsset(
|
|
17524
|
+
return AssetAmount2.fromChainAsset(feeAsset, {
|
|
17514
17525
|
amount
|
|
17515
17526
|
});
|
|
17516
17527
|
}
|
|
17517
17528
|
if (SubstrateQueryConfig.is(config) && EvmParachain3.isAnyParachain(source)) {
|
|
17518
17529
|
const polkadot = await PolkadotService2.create(source);
|
|
17519
17530
|
const amount = await polkadot.query(config);
|
|
17520
|
-
return AssetAmount2.fromChainAsset(
|
|
17531
|
+
return AssetAmount2.fromChainAsset(feeAsset, {
|
|
17521
17532
|
amount
|
|
17522
17533
|
});
|
|
17523
17534
|
}
|
|
17524
|
-
return AssetAmount2.fromChainAsset(
|
|
17535
|
+
return AssetAmount2.fromChainAsset(feeAsset, {
|
|
17525
17536
|
amount: 0n
|
|
17526
17537
|
});
|
|
17527
17538
|
}
|