@leofcoin/standards 0.2.11 → 0.2.13
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 -5
- package/package.json +1 -1
- package/src/lock.ts +2 -2
- package/src/staking.ts +2 -2
- package/src/token.ts +4 -4
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,8 @@ 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
117
|
const total = this.#totalSupply - amount;
|
|
118
118
|
if (total >= 0) {
|
|
119
119
|
this.#totalSupply = total;
|
|
@@ -137,12 +137,12 @@ class Token extends Roles {
|
|
|
137
137
|
if (!this.#balances[address])
|
|
138
138
|
this.#balances[address] = BigInt(0);
|
|
139
139
|
const previousBalance = this.#balances[address];
|
|
140
|
-
this.#balances[address] = this.#balances[address]
|
|
140
|
+
this.#balances[address] = this.#balances[address] += amount;
|
|
141
141
|
this.#updateHolders(address, previousBalance);
|
|
142
142
|
}
|
|
143
143
|
#decreaseBalance(address, amount) {
|
|
144
144
|
const previousBalance = this.#balances[address];
|
|
145
|
-
this.#balances[address] = this.#balances[address]
|
|
145
|
+
this.#balances[address] = this.#balances[address] -= amount;
|
|
146
146
|
this.#updateHolders(address, previousBalance);
|
|
147
147
|
}
|
|
148
148
|
balance() {
|
package/package.json
CHANGED
package/src/lock.ts
CHANGED
|
@@ -129,13 +129,13 @@ export default class Lock extends PublicVoting implements IVoting {
|
|
|
129
129
|
if (!this.#balances[address]) this.#balances[address] = BigInt(0)
|
|
130
130
|
const previousBalance = this.#balances[address]
|
|
131
131
|
|
|
132
|
-
this.#balances[address] = this.#balances[address]
|
|
132
|
+
this.#balances[address] = this.#balances[address] += amount
|
|
133
133
|
this.#updateHolders(address, previousBalance)
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
#decreaseBalance(address: address, amount: bigint) {
|
|
137
137
|
const previousBalance = this.#balances[address]
|
|
138
|
-
this.#balances[address] = this.#balances[address]
|
|
138
|
+
this.#balances[address] = this.#balances[address] -= amount
|
|
139
139
|
this.#updateHolders(address, previousBalance)
|
|
140
140
|
}
|
|
141
141
|
|
package/src/staking.ts
CHANGED
|
@@ -128,13 +128,13 @@ export default class Staking extends Roles {
|
|
|
128
128
|
if (!this.#balances[address]) this.#balances[address] = BigInt(0)
|
|
129
129
|
const previousBalance = this.#balances[address]
|
|
130
130
|
|
|
131
|
-
this.#balances[address] = this.#balances[address]
|
|
131
|
+
this.#balances[address] = this.#balances[address] += amount
|
|
132
132
|
this.#updateHolders(address, previousBalance)
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
#decreaseBalance(address: address, amount: bigint) {
|
|
136
136
|
const previousBalance = this.#balances[address]
|
|
137
|
-
this.#balances[address] = this.#balances[address]
|
|
137
|
+
this.#balances[address] = this.#balances[address] -= amount
|
|
138
138
|
this.#updateHolders(address, previousBalance)
|
|
139
139
|
}
|
|
140
140
|
|
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,7 @@ 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
139
|
const total = this.#totalSupply - amount
|
|
140
140
|
if (total >= 0) {
|
|
141
141
|
this.#totalSupply = total
|
|
@@ -158,13 +158,13 @@ export default class Token extends Roles {
|
|
|
158
158
|
if (!this.#balances[address]) this.#balances[address] = BigInt(0)
|
|
159
159
|
const previousBalance = this.#balances[address]
|
|
160
160
|
|
|
161
|
-
this.#balances[address] = this.#balances[address]
|
|
161
|
+
this.#balances[address] = this.#balances[address] += amount
|
|
162
162
|
this.#updateHolders(address, previousBalance)
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
#decreaseBalance(address: address, amount: bigint) {
|
|
166
166
|
const previousBalance = this.#balances[address]
|
|
167
|
-
this.#balances[address] = this.#balances[address]
|
|
167
|
+
this.#balances[address] = this.#balances[address] -= amount
|
|
168
168
|
this.#updateHolders(address, previousBalance)
|
|
169
169
|
}
|
|
170
170
|
|