Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set_authority() implemented #73

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions spl/token/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def revoke(
def set_authority(
self,
account: PublicKey,
current_authority: PublicKey,
current_authority: Union[Account, PublicKey],
authority_type: spl_token.AuthorityType,
new_authority: Optional[PublicKey] = None,
multi_signers: Optional[List[Account]] = None,
Expand All @@ -395,7 +395,27 @@ def set_authority(
:param multi_signers: (optional) Signing accounts if `owner` is a multiSig.
:param opts: (optional) Transaction options.
"""
raise NotImplementedError("set_authority not implemented")
if isinstance(current_authority, Account):
current_authority_pubkey = current_authority.public_key()
signers = [current_authority]
else:
current_authority_pubkey = current_authority
signers = multi_signers if multi_signers else []

txn = Transaction().add(
spl_token.set_authority(
spl_token.SetAuthorityParams(
program_id=self.program_id,
account=account,
authority=authority_type,
current_authority=current_authority_pubkey,
signers=[signer.public_key() for signer in signers],
new_authority=new_authority,
)
)
)

return self._conn.send_transaction(txn, self.payer, *signers, opts=opts)

def mint_to(
self,
Expand Down