-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1818 from onflow/cf/fix-init-tx
Simplify and fix the `init` Counter transaction
- Loading branch information
Showing
5 changed files
with
92 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 8 additions & 7 deletions
15
internal/super/generator/templates/transaction_counter.cdc.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
import "{{ .ContractName }}" | ||
|
||
transaction { | ||
prepare(signer: auth(BorrowValue) &Account) { | ||
// Borrow a reference to the {{ .ContractName }} contract's public capability | ||
let counterRef = signer.borrow<&{{ .ContractName }}>(from: /storage/counter) | ||
?? panic("Could not borrow reference to the counter") | ||
|
||
// Call the increment function on the Counter contract | ||
counterRef.increment() | ||
prepare(acct: &Account) { | ||
// Authorizes the transaction | ||
} | ||
|
||
execute { | ||
log("Counter incremented successfully") | ||
// Increment the counter | ||
Counter.increment() | ||
|
||
// Retrieve the new count and log it | ||
let newCount = Counter.getCount() | ||
log("New count after incrementing: ".concat(newCount.toString())) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters