Skip to content

Commit e230a34

Browse files
committed
update contract getter
1 parent 3461f50 commit e230a34

File tree

4 files changed

+40
-2175
lines changed

4 files changed

+40
-2175
lines changed

lib/go/contracts/contracts.go

+29
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,35 @@ func FlowExecutionParameters(env templates.Environment) []byte {
188188
func FlowServiceAccount(env templates.Environment) []byte {
189189
code := assets.MustAssetString(flowServiceAccountFilename)
190190

191+
if env.FlowExecutionParametersAddress == "" {
192+
193+
// Remove the import of FlowExecutionParameters
194+
code = strings.ReplaceAll(
195+
code,
196+
"import FlowExecutionParameters from \"FlowExecutionParameters\"",
197+
"//import FlowExecutionParameters from \"FlowExecutionParameters\"",
198+
)
199+
200+
// Replace the metering getter functions
201+
code = strings.ReplaceAll(
202+
code,
203+
"return FlowExecutionParameters.getExecutionEffortWeights()",
204+
"return self.account.storage.copy<{UInt64: UInt64}>(from: /storage/executionEffortWeights) ?? panic(\"execution effort weights not set yet\")",
205+
)
206+
207+
code = strings.ReplaceAll(
208+
code,
209+
"return FlowExecutionParameters.getExecutionMemoryWeights()",
210+
"return self.account.storage.copy<{UInt64: UInt64}>(from: /storage/executionMemoryWeights) ?? panic(\"execution memory weights not set yet\")",
211+
)
212+
213+
code = strings.ReplaceAll(
214+
code,
215+
"return FlowExecutionParameters.getExecutionMemoryLimit()",
216+
"return self.account.storage.copy<UInt64>(from: /storage/executionMemoryLimit) ?? panic(\"execution memory limit not set yet\")",
217+
)
218+
}
219+
191220
code = templates.ReplaceAddresses(code, env)
192221

193222
return []byte(code)

lib/go/contracts/go.mod

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ toolchain go1.22.4
66

77
require (
88
github.com/kevinburke/go-bindata v3.24.0+incompatible
9-
github.com/onflow/flow-core-contracts/lib/go/templates v0.15.2-0.20240215153337-0be5cb4b4bc9
9+
github.com/onflow/flow-core-contracts/lib/go/templates v1.4.1-0.20250121150329-3add9787ef8b
1010
github.com/onflow/flow-ft/lib/go/contracts v1.0.1
1111
github.com/onflow/flow-nft/lib/go/contracts v1.2.2
1212
github.com/stretchr/testify v1.9.0
@@ -37,9 +37,9 @@ require (
3737
github.com/onflow/atree v0.8.0-rc.6 // indirect
3838
github.com/onflow/cadence v1.0.0-preview.51 // indirect
3939
github.com/onflow/crypto v0.25.1 // indirect
40-
github.com/onflow/flow-ft/lib/go/templates v0.7.1-0.20240213220156-959b70719876 // indirect
40+
github.com/onflow/flow-ft/lib/go/templates v1.0.1 // indirect
4141
github.com/onflow/flow-go-sdk v1.0.0-preview.54 // indirect
42-
github.com/onflow/flow-nft/lib/go/templates v0.0.0-20240213205729-48f42d9896f8 // indirect
42+
github.com/onflow/flow-nft/lib/go/templates v1.2.1 // indirect
4343
github.com/onflow/flow/protobuf/go/flow v0.4.3 // indirect
4444
github.com/onflow/go-ethereum v1.13.4 // indirect
4545
github.com/pelletier/go-toml v1.2.0 // indirect

0 commit comments

Comments
 (0)