@@ -826,48 +826,6 @@ func (s *Substrate) OptOutOfV3Billing(identity Identity, nodeID uint32) (hash ty
826826 return callResponse .Hash , nil
827827}
828828
829- // AddTwinAdmin adds an account to the list of twin admins allowed to deploy on opted-out nodes.
830- // Requires council (restricted) origin.
831- func (s * Substrate ) AddTwinAdmin (identity Identity , account AccountID ) (hash types.Hash , err error ) {
832- cl , meta , err := s .GetClient ()
833- if err != nil {
834- return hash , err
835- }
836-
837- c , err := types .NewCall (meta , "TfgridModule.add_twin_admin" , account )
838- if err != nil {
839- return hash , errors .Wrap (err , "failed to create call" )
840- }
841-
842- callResponse , err := s .Call (cl , meta , identity , c )
843- if err != nil {
844- return hash , errors .Wrap (err , "failed to add twin admin" )
845- }
846-
847- return callResponse .Hash , nil
848- }
849-
850- // RemoveTwinAdmin removes an account from the list of twin admins allowed to deploy on opted-out nodes.
851- // Requires council (restricted) origin.
852- func (s * Substrate ) RemoveTwinAdmin (identity Identity , account AccountID ) (hash types.Hash , err error ) {
853- cl , meta , err := s .GetClient ()
854- if err != nil {
855- return hash , err
856- }
857-
858- c , err := types .NewCall (meta , "TfgridModule.remove_twin_admin" , account )
859- if err != nil {
860- return hash , errors .Wrap (err , "failed to create call" )
861- }
862-
863- callResponse , err := s .Call (cl , meta , identity , c )
864- if err != nil {
865- return hash , errors .Wrap (err , "failed to remove twin admin" )
866- }
867-
868- return callResponse .Hash , nil
869- }
870-
871829// GetAllowedTwinAdmins returns the list of accounts allowed to deploy on opted-out nodes.
872830// Returns an empty slice if no admins have been configured.
873831func (s * Substrate ) GetAllowedTwinAdmins () ([]AccountID , error ) {
@@ -899,28 +857,48 @@ func (s *Substrate) GetAllowedTwinAdmins() ([]AccountID, error) {
899857}
900858
901859// IsNodeOptedOutOfV3Billing returns true if the node has opted out of v3 billing.
860+ // Deprecated: use GetNodeV3BillingOptOutTimestamp to also retrieve the opt-out time.
902861func (s * Substrate ) IsNodeOptedOutOfV3Billing (nodeID uint32 ) (bool , error ) {
903- cl , meta , err := s .GetClient ( )
862+ ts , err := s .GetNodeV3BillingOptOutTimestamp ( nodeID )
904863 if err != nil {
905864 return false , err
906865 }
866+ return ts != nil , nil
867+ }
868+
869+ // GetNodeV3BillingOptOutTimestamp returns the Unix timestamp (seconds) at which the node
870+ // opted out of v3 billing, or nil if the node has not opted out.
871+ func (s * Substrate ) GetNodeV3BillingOptOutTimestamp (nodeID uint32 ) (* uint64 , error ) {
872+ cl , meta , err := s .GetClient ()
873+ if err != nil {
874+ return nil , err
875+ }
907876
908877 bytes , err := Encode (nodeID )
909878 if err != nil {
910- return false , errors .Wrap (err , "substrate: encoding error building query arguments" )
879+ return nil , errors .Wrap (err , "substrate: encoding error building query arguments" )
911880 }
912881
913882 key , err := types .CreateStorageKey (meta , "TfgridModule" , "NodeV3BillingOptOut" , bytes )
914883 if err != nil {
915- return false , errors .Wrap (err , "failed to create substrate query key" )
884+ return nil , errors .Wrap (err , "failed to create substrate query key" )
916885 }
917886
918887 raw , err := cl .RPC .State .GetStorageRawLatest (key )
919888 if err != nil {
920- return false , errors .Wrap (err , "failed to lookup node v3 billing opt-out" )
889+ return nil , errors .Wrap (err , "failed to lookup node v3 billing opt-out" )
890+ }
891+
892+ if len (* raw ) == 0 {
893+ return nil , nil
894+ }
895+
896+ var ts uint64
897+ if err := Decode (* raw , & ts ); err != nil {
898+ return nil , errors .Wrap (err , "failed to decode node v3 billing opt-out timestamp" )
921899 }
922900
923- return len ( * raw ) > 0 , nil
901+ return & ts , nil
924902}
925903
926904// SetNodeCertificate sets the node certificate type
0 commit comments