Skip to content

Commit da65807

Browse files
joshuahannanclaude
andcommitted
Add NodeOperator entitlement to StakingProxy privileged functions
Replaces access(all) on state-modifying functions in NodeStakerProxyHolder with access(NodeOperator) entitlement, following Cadence security best practices. Updates all dependent transactions to borrow with the entitlement, tightens the public capability to expose only NodeStakerProxyHolderPublic, and fixes a pre-existing typo in remove_staking_proxy.cdc. Closes #578 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 22471b4 commit da65807

File tree

14 files changed

+55
-51
lines changed

14 files changed

+55
-51
lines changed

contracts/StakingProxy.cdc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
access(all) contract StakingProxy {
99

10+
/// Entitlement that grants access to the node operator's privileged functions
11+
access(all) entitlement NodeOperator
12+
1013
/// path to store the node operator resource
1114
/// in the node operators account for staking helper
1215
access(all) let NodeOperatorCapabilityStoragePath: StoragePath
@@ -100,15 +103,15 @@ access(all) contract StakingProxy {
100103

101104
/// Node operator calls this to add info about a node they
102105
/// want to accept tokens for
103-
access(all) fun addNodeInfo(nodeInfo: NodeInfo) {
106+
access(NodeOperator) fun addNodeInfo(nodeInfo: NodeInfo) {
104107
pre {
105108
self.nodeInfo[nodeInfo.id] == nil
106109
}
107110
self.nodeInfo[nodeInfo.id] = nodeInfo
108111
}
109112

110113
/// Remove node info if it isn't in use any more
111-
access(all) fun removeNodeInfo(nodeID: String): NodeInfo {
114+
access(NodeOperator) fun removeNodeInfo(nodeID: String): NodeInfo {
112115
return self.nodeInfo.remove(key: nodeID)!
113116
}
114117

@@ -130,7 +133,7 @@ access(all) contract StakingProxy {
130133

131134
/// The node operator can call the removeStakingProxy function
132135
/// to remove a staking proxy if it is no longer needed
133-
access(all) fun removeStakingProxy(nodeID: String): {NodeStakerProxy} {
136+
access(NodeOperator) fun removeStakingProxy(nodeID: String): {NodeStakerProxy} {
134137
pre {
135138
self.stakingProxies[nodeID] != nil
136139
}
@@ -140,7 +143,7 @@ access(all) contract StakingProxy {
140143

141144
/// Borrow a "reference" to the staking proxy so staking operations
142145
/// can be performed with it
143-
access(all) fun borrowStakingProxy(nodeID: String): {NodeStakerProxy}? {
146+
access(NodeOperator) fun borrowStakingProxy(nodeID: String): {NodeStakerProxy}? {
144147
return self.stakingProxies[nodeID]
145148
}
146149
}

lib/go/contracts/internal/assets/assets.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)