@leofcoin/standards 0.2.12 → 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 +5 -3
- package/package.json +1 -1
- package/src/token.ts +4 -2
package/exports/token.js
CHANGED
|
@@ -95,7 +95,7 @@ class Token extends Roles {
|
|
|
95
95
|
}
|
|
96
96
|
mint(to, amount) {
|
|
97
97
|
if (!this.hasRole(msg.sender, 'MINT'))
|
|
98
|
-
throw new Error('
|
|
98
|
+
throw new Error('mint role required');
|
|
99
99
|
const supply = this.#totalSupply + amount;
|
|
100
100
|
if (this.#maxSupply === 0n) {
|
|
101
101
|
this.#totalSupply = supply;
|
|
@@ -112,8 +112,10 @@ class Token extends Roles {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
burn(from, amount) {
|
|
115
|
-
if (!this.hasRole(msg.sender, 'BURN')
|
|
116
|
-
throw new Error('not
|
|
115
|
+
if (!this.hasRole(msg.sender, 'BURN') && msg.sender !== from)
|
|
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
|
@@ -118,7 +118,7 @@ export default class Token extends Roles {
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
mint(to: address, amount: bigint) {
|
|
121
|
-
if (!this.hasRole(msg.sender, 'MINT')) throw new Error('
|
|
121
|
+
if (!this.hasRole(msg.sender, 'MINT')) throw new Error('mint role required')
|
|
122
122
|
|
|
123
123
|
const supply = this.#totalSupply + amount
|
|
124
124
|
if (this.#maxSupply === 0n) {
|
|
@@ -135,7 +135,9 @@ export default class Token extends Roles {
|
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
burn(from: address, amount: bigint) {
|
|
138
|
-
if (!this.hasRole(msg.sender, 'BURN')
|
|
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
|