Skip to content

Commit

Permalink
fix batch bridge fee calculation, adding base fee for each NFT
Browse files Browse the repository at this point in the history
  • Loading branch information
sisyphusSmiling committed Oct 26, 2024
1 parent e122272 commit 8c3c54e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ transaction(nftIdentifier: String, ids: [UInt256]) {
// Set a cap on the withdrawable bridge fee
var approxFee = FlowEVMBridgeUtils.calculateBridgeFee(
bytes: 200_000 // 200 kB as upper bound on movable storage used in a single transaction
)
) + (FlowEVMBridgeConfig.baseFee * UFix64(ids.length))
// Issue and store bridge-dedicated Provider Capability in storage if necessary
if signer.storage.type(at: FlowEVMBridgeConfig.providerCapabilityStoragePath) == nil {
let providerCap = signer.capabilities.storage.issue<auth(FungibleToken.Withdraw) &{FungibleToken.Provider}>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ transaction(nftIdentifier: String, ids: [UInt256], recipient: Address) {
// Set a cap on the withdrawable bridge fee
var approxFee = FlowEVMBridgeUtils.calculateBridgeFee(
bytes: 200_000 // 200 kB as upper bound on movable storage used in a single transaction
)
) + (FlowEVMBridgeConfig.baseFee * UFix64(ids.length))
// Issue and store bridge-dedicated Provider Capability in storage if necessary
if signer.storage.type(at: FlowEVMBridgeConfig.providerCapabilityStoragePath) == nil {
let providerCap = signer.capabilities.storage.issue<auth(FungibleToken.Withdraw) &{FungibleToken.Provider}>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ transaction(nftIdentifier: String, ids: [UInt64], recipient: String) {
// Withdraw the requested NFT & set a cap on the withdrawable bridge fee
var approxFee = FlowEVMBridgeUtils.calculateBridgeFee(
bytes: 200_000 // 200 kB as upper bound on movable storage used in a single transaction
)
) + (FlowEVMBridgeConfig.baseFee * UFix64(ids.length))
// Determine if the NFT requires onboarding - this impacts the fee required
self.requiresOnboarding = FlowEVMBridge.typeRequiresOnboarding(self.nftType)
?? panic("Bridge does not support this asset type")
Expand Down
3 changes: 2 additions & 1 deletion cadence/transactions/bridge/nft/batch_bridge_nft_to_evm.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,15 @@ transaction(nftIdentifier: String, ids: [UInt64]) {
// Withdraw the requested NFT & set a cap on the withdrawable bridge fee
var approxFee = FlowEVMBridgeUtils.calculateBridgeFee(
bytes: 200_000 // 200 kB as upper bound on movable storage used in a single transaction
)
) + (FlowEVMBridgeConfig.baseFee * UFix64(ids.length))
// Determine if the NFT requires onboarding - this impacts the fee required
self.requiresOnboarding = FlowEVMBridge.typeRequiresOnboarding(self.nftType)
?? panic("Bridge does not support this asset type")
// Add the onboarding fee if onboarding is necessary
if self.requiresOnboarding {
approxFee = approxFee + FlowEVMBridgeConfig.onboardFee
}
log(approxFee)

/* --- Configure a ScopedFTProvider --- */
//
Expand Down

0 comments on commit 8c3c54e

Please sign in to comment.