Skip to content
This repository was archived by the owner on Nov 5, 2024. It is now read-only.

Use view functions in FlowManager #228

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
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
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