Skip to content

Commit

Permalink
Use view functions in FlowManager (onflow#228)
Browse files Browse the repository at this point in the history
  • Loading branch information
jribbink authored Apr 10, 2024
1 parent 6a11947 commit 1d66db1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/late-trees-ring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@onflow/flow-js-testing": patch
---

Use `view` functions in FlowManager
8 changes: 4 additions & 4 deletions cadence/contracts/FlowManager.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ access(all) contract FlowManager {
access(all) struct Mapper {
access(all) let accounts: {String: Address}

access(all) fun getAddress(_ name: String): Address? {
access(all) view fun getAddress(_ name: String): Address? {
return self.accounts[name]
}

Expand All @@ -20,7 +20,7 @@ access(all) contract FlowManager {
}
}

access(all) fun getAccountAddress(_ name: String): Address?{
access(all) view fun getAccountAddress(_ name: String): Address?{
let accountManager = self.account
.capabilities.borrow<&FlowManager.Mapper>(self.accountManagerPath)!

Expand Down Expand Up @@ -67,12 +67,12 @@ access(all) contract FlowManager {
emit FlowManager.TimestampOffsetChanged(offset: offset)
}

access(all) fun getBlockHeight(): UInt64 {
access(all) view fun getBlockHeight(): UInt64 {
var block = getCurrentBlock()
return block.height + self.blockOffset
}

access(all) fun getBlockTimestamp(): UFix64 {
access(all) view fun getBlockTimestamp(): UFix64 {
var block = getCurrentBlock()
return block.timestamp + self.timestampOffset
}
Expand Down
8 changes: 4 additions & 4 deletions src/generated/contracts/FlowManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ access(all) contract FlowManager {
access(all) struct Mapper {
access(all) let accounts: {String: Address}
access(all) fun getAddress(_ name: String): Address? {
access(all) view fun getAddress(_ name: String): Address? {
return self.accounts[name]
}
Expand All @@ -31,7 +31,7 @@ access(all) contract FlowManager {
}
}
access(all) fun getAccountAddress(_ name: String): Address?{
access(all) view fun getAccountAddress(_ name: String): Address?{
let accountManager = self.account
.capabilities.borrow<&FlowManager.Mapper>(self.accountManagerPath)!
Expand Down Expand Up @@ -78,12 +78,12 @@ access(all) contract FlowManager {
emit FlowManager.TimestampOffsetChanged(offset: offset)
}
access(all) fun getBlockHeight(): UInt64 {
access(all) view fun getBlockHeight(): UInt64 {
var block = getCurrentBlock()
return block.height + self.blockOffset
}
access(all) fun getBlockTimestamp(): UFix64 {
access(all) view fun getBlockTimestamp(): UFix64 {
var block = getCurrentBlock()
return block.timestamp + self.timestampOffset
}
Expand Down

0 comments on commit 1d66db1

Please sign in to comment.