@leofcoin/standards 0.2.13 → 0.2.14
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 +2 -0
- package/package.json +1 -1
- package/src/token.ts +2 -0
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
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
|