Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add call to dependency audit contract #430

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions contracts/FlowServiceAccount.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import FungibleToken from "FungibleToken"
import FlowToken from 0xFLOWTOKENADDRESS
import FlowFees from 0xFLOWFEESADDRESS
import FlowStorageFees from 0xFLOWSTORAGEFEESADDRESS
import DependencyAudit from "DependencyAudit"

pub contract FlowServiceAccount {

Expand Down Expand Up @@ -78,7 +79,7 @@ pub contract FlowServiceAccount {
if self.transactionFee > tokenVault.balance {
feeAmount = tokenVault.balance
}

let feeVault <- tokenVault.withdraw(amount: feeAmount)
FlowFees.deposit(from: <-feeVault)
}
Expand Down Expand Up @@ -128,21 +129,21 @@ pub contract FlowServiceAccount {
return self.accountCreators.keys
}

// Gets Execution Effort Weights from the service account's storage
// Gets Execution Effort Weights from the service account's storage
pub fun getExecutionEffortWeights(): {UInt64: UInt64} {
return self.account.copy<{UInt64: UInt64}>(from: /storage/executionEffortWeights)
return self.account.copy<{UInt64: UInt64}>(from: /storage/executionEffortWeights)
?? panic("execution effort weights not set yet")
}

// Gets Execution Memory Weights from the service account's storage
// Gets Execution Memory Weights from the service account's storage
pub fun getExecutionMemoryWeights(): {UInt64: UInt64} {
return self.account.copy<{UInt64: UInt64}>(from: /storage/executionMemoryWeights)
return self.account.copy<{UInt64: UInt64}>(from: /storage/executionMemoryWeights)
?? panic("execution memory weights not set yet")
}

// Gets Execution Memory Limit from the service account's storage
pub fun getExecutionMemoryLimit(): UInt64 {
return self.account.copy<UInt64>(from: /storage/executionMemoryLimit)
return self.account.copy<UInt64>(from: /storage/executionMemoryLimit)
?? panic("execution memory limit not set yet")
}

Expand Down Expand Up @@ -191,6 +192,16 @@ pub contract FlowServiceAccount {
}
}

/// checkDependencies is called by the FVM at the end of the transaction execution
/// The `dependenciesAddresses` and `dependenciesNames` are the addresses and names of all the contracts that the transaction depends on.
/// The `authorizers` are the addresses of the accounts that authorized the transaction and the payer.
/// The FVM can call this even though it is private.
/// checkDependencies is not intended to be called by the user.
access(self) fun checkDependencies(_ dependenciesAddresses: [Address], _ dependenciesNames: [String], _ authorizers: [Address]) {
// forwad the call to the DependencyAudit, where the actual check is done.
DependencyAudit.checkDependencies(dependenciesAddresses, dependenciesNames, authorizers)
}

init() {
self.transactionFee = 0.0
self.accountCreationFee = 0.0
Expand Down
Loading