@@ -53,21 +53,23 @@ pub contract FlowStakingCollection {
53
53
pub struct MachineAccountInfo {
54
54
pub let nodeID : String
55
55
pub let role : UInt8
56
- pub let address : Address
57
56
// Capability to the FLOW Vault to allow the owner
58
57
// to withdraw or deposit to their machine account if needed
59
58
access (contract) let machineAccountVaultProvider : Capability <&FlowToken .Vault >
60
59
61
- init (nodeID : String , role : UInt8 , machineAccountAddress : Address , machineAccountVaultProvider : Capability <&FlowToken .Vault >) {
60
+ init (nodeID : String , role : UInt8 , machineAccountVaultProvider : Capability <&FlowToken .Vault >) {
62
61
pre {
63
62
machineAccountVaultProvider.check (): " Invalid Flow Token Vault Provider"
64
- machineAccountVaultProvider.borrow ()! .owner! .address == machineAccountAddress: " Vault provider must be stored in the machine account address provided"
65
63
}
66
64
self .nodeID = nodeID
67
65
self .role = role
68
- self .address = machineAccountAddress
69
66
self .machineAccountVaultProvider = machineAccountVaultProvider
70
67
}
68
+
69
+ // Gets the address of the machine account
70
+ pub fun getAddress (): Address {
71
+ return self .machineAccountVaultProvider.borrow ()! .owner! .address
72
+ }
71
73
}
72
74
73
75
/// Public interface that users can publish for their staking collection
@@ -424,7 +426,7 @@ pub contract FlowStakingCollection {
424
426
425
427
// Get the vault capability and create the machineAccountInfo struct
426
428
let machineAccountVaultProvider = machineAcct.link< &FlowToken.Vault> (/ private / machineAccountPrivateVault, target: / storage/ flowTokenVault)!
427
- let machineAccountInfo = MachineAccountInfo (nodeID : nodeInfo.id, role : nodeInfo.role, machineAccountAddress : machineAcct.address, machineAccountVaultProvider : machineAccountVaultProvider)
429
+ let machineAccountInfo = MachineAccountInfo (nodeID : nodeInfo.id, role : nodeInfo.role, machineAccountVaultProvider : machineAccountVaultProvider)
428
430
429
431
// If they are a collector node, create a QC Voter object and store it in the account
430
432
if nodeInfo.role == FlowEpoch.NodeRole.Collector.rawValue {
@@ -436,7 +438,7 @@ pub contract FlowStakingCollection {
436
438
// set this node's machine account
437
439
self .machineAccounts[nodeInfo.id] = machineAccountInfo
438
440
439
- emit MachineAccountCreated (nodeID : nodeInfo.id, role : FlowEpoch.NodeRole.Collector.rawValue, address : machineAcct .address)
441
+ emit MachineAccountCreated (nodeID : nodeInfo.id, role : FlowEpoch.NodeRole.Collector.rawValue, address : machineAccountVaultProvider. borrow () ! .owner ! .address)
440
442
441
443
return machineAcct
442
444
@@ -450,7 +452,7 @@ pub contract FlowStakingCollection {
450
452
// set this node's machine account
451
453
self .machineAccounts[nodeInfo.id] = machineAccountInfo
452
454
453
- emit MachineAccountCreated (nodeID : nodeInfo.id, role : FlowEpoch.NodeRole.Consensus.rawValue, address : machineAcct .address)
455
+ emit MachineAccountCreated (nodeID : nodeInfo.id, role : FlowEpoch.NodeRole.Consensus.rawValue, address : machineAccountVaultProvider. borrow () ! .owner ! .address)
454
456
455
457
return machineAcct
456
458
}
@@ -498,7 +500,7 @@ pub contract FlowStakingCollection {
498
500
}
499
501
500
502
// Create the new Machine account info object and store it
501
- let machineAccountInfo = MachineAccountInfo (nodeID : nodeID, role : nodeInfo.role, machineAccountAddress : machineAccount.address, machineAccountVaultProvider : machineAccountVaultProvider)
503
+ let machineAccountInfo = MachineAccountInfo (nodeID : nodeID, role : nodeInfo.role, machineAccountVaultProvider : machineAccountVaultProvider)
502
504
self .machineAccounts[nodeID] = machineAccountInfo
503
505
}
504
506
@@ -837,7 +839,7 @@ pub contract FlowStakingCollection {
837
839
let unlockedVault = self .unlockedVault! .borrow ()!
838
840
var availableBalance : UFix64 = 0 .0
839
841
if FlowStorageFees.storageMegaBytesPerReservedFLOW ! = (0 .0 as UFix64) {
840
- availableBalance = FlowStorageFees.defaultTokenAvailableBalance (machineAccountInfo.address)
842
+ availableBalance = FlowStorageFees.defaultTokenAvailableBalance (machineAccountInfo.machineAccountVaultProvider. borrow () ! .owner ! . address)
841
843
} else {
842
844
availableBalance = vaultRef.balance
843
845
}
0 commit comments