Skip to content

Commit

Permalink
fix: rotateAuthAccount failed
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.
  • Loading branch information
btspoony committed Aug 26, 2023
1 parent dd77f1b commit 0f8e7fe
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion contracts/HybridCustody.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,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((pathsToUnlink.length + 1).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 0f8e7fe

Please sign in to comment.