Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cadence/contracts/FlowYieldVaults.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,10 @@ access(all) contract FlowYieldVaults {
}
/// Creates a YieldVaultManager used to create and manage YieldVaults
access(all) fun createYieldVaultManager(betaRef: auth(FlowYieldVaultsClosedBeta.Beta) &FlowYieldVaultsClosedBeta.BetaBadge): @ YieldVaultManager {
pre {
FlowYieldVaultsClosedBeta.validateBeta(betaRef.getOwner(), betaRef):
"Invalid Beta Ref"
}
return <-create YieldVaultManager()
}
/// Creates a StrategyFactory resource
Expand Down
11 changes: 11 additions & 0 deletions cadence/contracts/FlowYieldVaultsClosedBeta.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ access(all) contract FlowYieldVaultsClosedBeta {
return cap
}

/// Clean up any previously issued controller before issuing a fresh capability.
access(contract) fun _cleanupExistingGrant(_ addr: Address) {
if let info = self.issuedCapIDs[addr] {
if let ctrl = self.account.capabilities.storage.getController(byCapabilityID: info.capID) {
ctrl.delete()
emit BetaRevoked(addr: addr, capID: info.capID)
}
}
}

/// Delete the recorded controller, revoking *all copies* of the capability
access(contract) fun _revokeByAddress(_ addr: Address) {
let info = self.issuedCapIDs[addr] ?? panic("No cap recorded for address")
Expand All @@ -83,6 +93,7 @@ access(all) contract FlowYieldVaultsClosedBeta {
// 2) A small in-account helper resource that performs privileged ops
access(all) resource AdminHandle {
access(Admin) fun grantBeta(addr: Address): Capability<auth(FlowYieldVaultsClosedBeta.Beta) &FlowYieldVaultsClosedBeta.BetaBadge> {
FlowYieldVaultsClosedBeta._cleanupExistingGrant(addr)
FlowYieldVaultsClosedBeta._ensureBadge(addr)
return FlowYieldVaultsClosedBeta._issueBadgeCap(addr)
}
Expand Down