From 1d66db1fadaca17624f28429edb7d76c428c6984 Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Wed, 10 Apr 2024 15:02:39 -0700 Subject: [PATCH] Use view functions in FlowManager (#228) --- .changeset/late-trees-ring.md | 5 +++++ cadence/contracts/FlowManager.cdc | 8 ++++---- src/generated/contracts/FlowManager.js | 8 ++++---- 3 files changed, 13 insertions(+), 8 deletions(-) create mode 100644 .changeset/late-trees-ring.md diff --git a/.changeset/late-trees-ring.md b/.changeset/late-trees-ring.md new file mode 100644 index 00000000..5633c0b9 --- /dev/null +++ b/.changeset/late-trees-ring.md @@ -0,0 +1,5 @@ +--- +"@onflow/flow-js-testing": patch +--- + +Use `view` functions in FlowManager diff --git a/cadence/contracts/FlowManager.cdc b/cadence/contracts/FlowManager.cdc index ed20691f..010de496 100644 --- a/cadence/contracts/FlowManager.cdc +++ b/cadence/contracts/FlowManager.cdc @@ -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] } @@ -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)! @@ -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 } diff --git a/src/generated/contracts/FlowManager.js b/src/generated/contracts/FlowManager.js index 919d045d..e145a72d 100644 --- a/src/generated/contracts/FlowManager.js +++ b/src/generated/contracts/FlowManager.js @@ -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] } @@ -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)! @@ -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 }