Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
janezpodhostnik committed May 21, 2024
1 parent 9d409fb commit cae8329
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
11 changes: 7 additions & 4 deletions contracts/DependencyAudit.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ access(all) contract DependencyAudit {
access(all) event PanicOnUnstagedDependenciesChanged(shouldPanic: Bool)

// checkDependencies is called from the FlowServiceAccount contract
access(self) fun checkDependencies(_ dependenciesAddresses: [Address], _ dependenciesNames: [String], _ authorizers: [Address]) {
access(contract) fun checkDependencies(_ dependenciesAddresses: [Address], _ dependenciesNames: [String], _ authorizers: [Address]) {
var unstagedDependencies: [Dependency] = []

var numDependencies = dependenciesAddresses.length
Expand Down Expand Up @@ -56,7 +56,7 @@ access(all) contract DependencyAudit {
j = j + 1
}

// the transactions will fail with a message that looks like this: `error: panic: Found unstaged dependencies: A.0x2ceae959ed1a7e7a.MigrationContractStaging, A.0x2ceae959ed1a7e7a.DependencyAudit`
// the transactions will fail with a message that looks like this: `error: panic: Found unstaged dependencies: A.2ceae959ed1a7e7a.MigrationContractStaging, A.2ceae959ed1a7e7a.DependencyAudit`
panic("Found unstaged dependencies: ".concat(unstagedDependenciesString))
} else {
emit UnstagedDependencies(dependencies: unstagedDependencies)
Expand Down Expand Up @@ -105,12 +105,15 @@ access(all) contract DependencyAudit {
}

access(all) fun toString(): String {
return "A.".concat(self.address.toString()).concat(".").concat(self.name)
var addressString = self.address.toString()
// remove 0x prefix
addressString = addressString.slice(from: 2, upTo: addressString.length)
return "A.".concat(addressString).concat(".").concat(self.name)
}
}

// The admin resource is saved to the storage so that the admin can be accessed by the service account
// The `excludedAddresses` will be the addresses with the system contracracts.
// The `excludedAddresses` will be the addresses with the system contracts.
init(excludedAddresses: [Address]) {
self.excludedAddresses = {}
self.panicOnUnstaged = false
Expand Down
6 changes: 3 additions & 3 deletions lib/go/contracts/internal/assets/assets.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/dependency_audit_tests.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -213,5 +213,5 @@ access(all) fun testChekDependenciesWithUnstagedEntriesPanics() {
)
Test.expect(commitResult, Test.beFailed())
// not sure how to test this:
// Test.expect(commitResult.error!.message, Test.contain("panic: Found unstaged dependencies: A.0x0000000000000008.Foo") )
// Test.expect(commitResult.error!.message, Test.contain("panic: Found unstaged dependencies: A.0000000000000008.Foo") )
}

0 comments on commit cae8329

Please sign in to comment.