Skip to content

Commit

Permalink
Fix: rotateAuthAccount failed when called twice (#154)
Browse files Browse the repository at this point in the history
When `giveOwnership` and `addOwnedAccount` are executed in the same
transaction
`rotateAuthAccount` will be called twice.
However, during the second call, since authAcctPath is the same, it will
cause `acct.linkAccount` to return `nil` as a result.

Personal opinion, it would be better to change `HybridCustody` overall
to CapCons coding style.

---------

Co-authored-by: Giovanni Sanchez <[email protected]>
  • Loading branch information
btspoony and sisyphusSmiling authored Sep 27, 2023
1 parent 0ddf6b8 commit 84ab4b8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
with:
go-version: 1.18
- name: Install Flow CLI
run: bash -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" -- v1.3.4
run: bash -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" -- v1.4.4
- name: Run tests
run: sh ./test.sh
- name: Normalize coverage report filepaths
Expand Down
5 changes: 4 additions & 1 deletion contracts/HybridCustody.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,10 @@ pub contract HybridCustody {
// NOTE: This path cannot be sufficiently randomly generated, an app calling this function could build a
// capability to this path before it is made, thus maintaining ownership despite making it look like they
// gave it away. Until capability controllers, this method should not be fully trusted.
let authAcctPath = "HybridCustodyRelinquished".concat(HybridCustody.account.address.toString()).concat(getCurrentBlock().height.toString())
let authAcctPath = "HybridCustodyRelinquished_"
.concat(HybridCustody.account.address.toString())
.concat(getCurrentBlock().height.toString())
.concat(unsafeRandom().toString()) // ensure that the path is different from the previous one
let acctCap = acct.linkAccount(PrivatePath(identifier: authAcctPath)!)!

self.acct = acctCap
Expand Down

0 comments on commit 84ab4b8

Please sign in to comment.