Skip to content

Commit

Permalink
Remove Pausable.
Browse files Browse the repository at this point in the history
It's nice, but not really necessary for the standard. Also, it wasn't actually
stopping transfers in the current implementation.
  • Loading branch information
kantp committed Mar 20, 2024
1 parent e7be4d8 commit 7877c3e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 45 deletions.
15 changes: 1 addition & 14 deletions src/Hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,10 @@ class Hooks extends SmartContract implements _Hooks {
const admin = this.admin.get();
this.admin.requireEquals(admin);

// If you want to disallow some AdminActions, you can do
// that via an assert statement like this:
//const actionPossible = action.type
// .equals(AdminAction.types.setPaused)
// .equals(Bool(false));
//actionPossible.assertTrue();
// This would check that the action is not setPaused,
// and thus disallow pausing/unpausing token transfers.

// If you want to allow any AdminAction, unconditioanlly return true.
const actionPossible = Bool(true);

// Require a signature from the admin
const adminAccountUpdate = AccountUpdate.create(admin);
adminAccountUpdate.requireSignature();

return actionPossible;
return Bool(true);
}
}

Expand Down
10 changes: 2 additions & 8 deletions src/interfaces/token/adminable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ class AdminAction extends Struct({
mint: 0,
burn: 1,
setTotalSupply: 2,
setPaused: 3,
setVerificationKey: 4,
setVerificationKey: 3,
};

public static fromType(type: number): AdminAction {
Expand All @@ -38,14 +37,9 @@ interface Burnable {
burn: (from: PublicKey, amount: UInt64) => AccountUpdate;
}

interface Pausable {
paused: State<Bool>;
setPaused: (paused: Bool) => void;
}

interface Upgradable {
setVerificationKey: (verificationKey: VerificationKey) => void;
}

export type { Mintable, Burnable, Pausable, Upgradable };
export type { Mintable, Burnable, Upgradable };
export { AdminAction };
1 change: 0 additions & 1 deletion src/interfaces/token/viewable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ interface Viewable {
getTotalSupply: () => UInt64;
getCirculatingSupply: () => UInt64;
getDecimals: () => UInt64;
getPaused: () => Bool;
getHooks: () => PublicKey;
}

Expand Down
24 changes: 2 additions & 22 deletions src/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
import errors from './errors';
import {
AdminAction,
type Pausable,
type Burnable,
type Mintable,
type Upgradable,
Expand All @@ -43,7 +42,6 @@ class Token
Mintable,
Burnable,
Viewable,
Pausable,
Transferable,
Upgradable
{
Expand All @@ -58,8 +56,6 @@ class Token

@state(UInt64) public circulatingSupply = State<UInt64>();

@state(Bool) public paused = State<Bool>();

public decimals: UInt64 = UInt64.from(Token.defaultDecimals);

public getHooksContract(): Hooks {
Expand All @@ -80,7 +76,6 @@ class Token
this.hooks.set(hooks);
this.totalSupply.set(totalSupply);
this.circulatingSupply.set(UInt64.from(0));
this.paused.set(Bool(false));
}

/**
Expand Down Expand Up @@ -147,19 +142,11 @@ class Token
}

/**
* Pausable
* Approvable
*/

@method
public setPaused(paused: Bool) {
const hooksContract = this.getHooksContract();
hooksContract.canAdmin(AdminAction.fromType(AdminAction.types.setPaused));

this.paused.set(paused);
}

@method
approveBase(updates: AccountUpdateForest) {
public approveBase(updates: AccountUpdateForest) {
this.checkZeroBalanceChange(updates);
}

Expand Down Expand Up @@ -200,13 +187,6 @@ class Token
return hooks;
}

public getPaused(): Bool {
const paused = this.paused.get();
this.paused.requireEquals(paused);

return paused;
}

public getDecimals(): UInt64 {
return this.decimals;
}
Expand Down

0 comments on commit 7877c3e

Please sign in to comment.