/// Claim the caller's GTC neurons (on behalf of the caller) and return the
/// IDs of these neurons
Claim the caller's GTC neurons (on behalf of the caller) and return the
IDs of these neurons
Claim the caller ' s GTC neurons ( on behalf of the caller ) and return the IDs of these neurons
pub async fn claim_neurons(
        &mut self,
        caller: &PrincipalId,
        public_key_hex: String,
    ) -> Result<Vec<NeuronId>, String> {
        self.assert_claim_neurons_can_be_called()?;
        let public_key = decode_hex_public_key(&public_key_hex)?;
        validate_public_key_against_caller(&public_key, caller)?;
        let address = public_key_to_gtc_address(&public_key);
        let account = self.get_account_mut(&address)?;
        account.authenticated_principal_id = Some(*caller);
        if account.has_donated {
            return Err("Account has previously donated its funds".to_string());
        }
        if account.has_forwarded {
            return Err("Account has previously forwarded its funds".to_string());
        }
        if account.has_claimed {
            return Ok(account.neuron_ids.clone());
        }
        GovernanceCanister::claim_gtc_neurons(caller, account.neuron_ids.clone()).await?;
        account.has_claimed = true;
        Ok(account.neuron_ids.clone())
    }
pub async fn claim_neurons ( & mut self , caller : & PrincipalId , public_key_hex : String , ) -> Result < Vec < NeuronId > , String > { self . assert_claim_neurons_can_be_called ( ) ? ; let public_key = decode_hex_public_key ( & public_key_hex ) ? ; validate_public_key_against_caller ( & public_key , caller ) ? ; let address = public_key_to_gtc_address ( & public_key ) ; let account = self . get_account_mut ( & address ) ? ; account . authenticated_principal_id = Some ( * caller ) ; if account . has_donated { return Err ( " " . to_string ( ) ) ; } if account . has_forwarded { return Err ( " " . to_string ( ) ) ; } if account . has_claimed { return Ok ( account . neuron_ids . clone ( ) ) ; } GovernanceCanister :: claim_gtc_neurons ( caller , account . neuron_ids . clone ( ) ) . await ? ; account . has_claimed = true ; Ok ( account . neuron_ids . clone ( ) ) }
Claim the caller's GTC neurons (on behalf of the caller) and return the
IDs of these neurons
Claim the caller ' s GTC neurons ( on behalf of the caller ) and return the IDs of these neurons
&mut self
caller
&PrincipalId
public_key_hex
String