Skip to content

Commit

Permalink
Add transferOwnership function to DeWeb SC
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-senechal committed Dec 13, 2024
1 parent 920bbc7 commit 7d02921
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions smart-contract/assembly/contracts/deweb-interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
Address,
balance,
Context,
generateEvent,
Expand Down Expand Up @@ -45,6 +46,23 @@ export function constructor(_: StaticArray<u8>): void {
_setOwner(Context.caller().toString());
}

/**
* Change the owner of the smart contract to the address passed as an argument
* @param _binaryArgs - serialized arguments containing the new owner address
* @returns void
*/
export function transferOwnership(_binaryArgs: StaticArray<u8>): void {
_onlyOwner();

const args = new Args(_binaryArgs);
const newOwner = args
.nextSerializable<Address>()
.expect('Address is missing or invalid');

_setOwner(newOwner.toString());
}


/* -------------------------------------------------------------------------- */
/* FILE INITIALIZATION */
/* -------------------------------------------------------------------------- */
Expand Down

0 comments on commit 7d02921

Please sign in to comment.