@moonbeam-network/mrl 1.0.0-dev.273 → 1.0.0-dev.274
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 +19 -9
- 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,
|
|
@@ -17510,7 +17520,7 @@ async function getProtocolFee({
|
|
|
17510
17520
|
`Error getting bridge fee: expected bigint from contract call, but received ${typeof amount}. `
|
|
17511
17521
|
);
|
|
17512
17522
|
}
|
|
17513
|
-
return AssetAmount2.fromChainAsset(
|
|
17523
|
+
return AssetAmount2.fromChainAsset(feeAsset, {
|
|
17514
17524
|
amount
|
|
17515
17525
|
});
|
|
17516
17526
|
}
|