I'm reading the source here:
https://github.com/solana-labs/solana-program-library/blob/master/token/program/src/processor.rs
But my Rust is not so fluent right now.
Right around here:
match source_account.delegate {
COption::Some(ref delegate) if Self::cmp_pubkeys(authority_info.key, delegate) {...}
_ => Self::validateOwner(...stuff...&source_account.owner)
}
I see the delegate consulted.
It looks like, if the authority_info"authority_info" arg is set to owner"owner", then even if delegate isa "delegate" has been set on the account, itthe program will run the "owner is signer" assertion rather than the "delegate is signer" assertion. Meaning, that it appears that, the owner is always authorized to transfer tokens in any amount no matter what is delegated.
But, I'm kind of hoping I'm wrong here. In my case, it'd be ideal for the delegate to have exclusive rights over their delegated amount.
I don't need exclusive rights, as longAs an alternative for my delegation rights are dropped on transferuse case, or closea fallback to the "Delegate" having "exclusive rights" over the delegated amount, and I'm ableif the delegate were to detect that efficiently via a mentionbe mentioned when the total amount on the delegate account drops below the delegate amount, that may suffice.
So aA follow up "Plan B" question is, if transfer rights are not exclusive, are the delegates cleared on transferwhen their delegated amount is transferred?
Which I think is technically, no. Because I think what happens is the source account is just depleted of token quantity. So theThe delegate remains set on the account, thereand so does their delegate amount. There is just less quantity in the account for itthe delegate to potentially be granted further authority over. Possibly there is zero quantity"amount" on the account, despite the "delegate amount" being greater than zero.
Although actually, if the non delegate (i.e. the owner) is allowed to transfer a quantity over which the delegate has authority ( i.e. transfer in excess of non delegated quantity ), shouldn't that subtract from the delegate's holdings even if the delegate is not the signer?
Or is it possible for the delegate to hold authority over more tokens than what are held by the account?