@leofcoin/standards 0.2.13 → 0.2.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/exports/token.js CHANGED
@@ -114,6 +114,8 @@ class Token extends Roles {
114
114
  burn(from, amount) {
115
115
  if (!this.hasRole(msg.sender, 'BURN') && msg.sender !== from)
116
116
  throw new Error('not the owner or burn role required');
117
+ if (this.#balances[from] < amount)
118
+ throw new Error('amount exceeds balance');
117
119
  const total = this.#totalSupply - amount;
118
120
  if (total >= 0) {
119
121
  this.#totalSupply = total;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/standards",
3
- "version": "0.2.13",
3
+ "version": "0.2.15",
4
4
  "description": "Contract standards",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,3 +1,9 @@
1
1
  export interface IToken {
2
-
2
+ mint?(to: string, amount: bigint): void
3
+ burn?(from: string, amount: bigint): void
4
+ transfer?(from: string, to: string, amount: bigint): void
5
+ balance?(): bigint
6
+ balanceOf?(address: string): bigint
7
+ setApproval?(operator: string, amount: bigint): void
8
+ approved?(owner: string, operator: string, amount: bigint): boolean
3
9
  }
package/src/token.ts CHANGED
@@ -136,6 +136,8 @@ export default class Token extends Roles {
136
136
 
137
137
  burn(from: address, amount: bigint) {
138
138
  if (!this.hasRole(msg.sender, 'BURN') && msg.sender !== from) throw new Error('not the owner or burn role required')
139
+ if (this.#balances[from] < amount) throw new Error('amount exceeds balance')
140
+
139
141
  const total = this.#totalSupply - amount
140
142
  if (total >= 0) {
141
143
  this.#totalSupply = total