@leofcoin/contracts 0.1.21 → 0.1.22
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/package.json +1 -1
- package/src/native-token.ts +4 -0
- package/test/native-token.js +6 -3
package/package.json
CHANGED
package/src/native-token.ts
CHANGED
|
@@ -3,6 +3,10 @@ import Token, { TokenState } from '@leofcoin/standards/token.js'
|
|
|
3
3
|
export default class Leofcoin extends Token {
|
|
4
4
|
constructor(state: TokenState) {
|
|
5
5
|
super('Leofcoin', 'LFC', 18, state)
|
|
6
|
+
// The machine executes protocol fee burns as the immutable contract creator.
|
|
7
|
+
// Persist this capability in fresh genesis state; restored legacy state is
|
|
8
|
+
// intentionally left untouched and cannot activate fee burning.
|
|
9
|
+
if (!state && !this.hasRole(msg.sender, 'BURN')) this.grantRole(msg.sender, 'BURN')
|
|
6
10
|
}
|
|
7
11
|
|
|
8
12
|
burn(from: address, amount: bigint) {
|
package/test/native-token.js
CHANGED
|
@@ -53,17 +53,20 @@ describe('Leofcoin', () => {
|
|
|
53
53
|
assert.equal(token.balanceOf(otherReceiverAddress), 10000n)
|
|
54
54
|
})
|
|
55
55
|
|
|
56
|
-
it('should
|
|
57
|
-
|
|
56
|
+
it('should grant the genesis owner protocol burn authority', () => {
|
|
57
|
+
assert.equal(token.hasRole(ownerAddress, 'BURN'), true)
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
it('should burn balance and reduce total supply', async () => {
|
|
58
61
|
await token.grantRole(ownerAddress, 'MINT')
|
|
59
62
|
await token.mint(ownerAddress, 100000n)
|
|
60
63
|
await token.burn(ownerAddress, 10000n)
|
|
61
64
|
assert.equal(token.balanceOf(ownerAddress), 90000n)
|
|
65
|
+
assert.equal(token.totalSupply, 90000n)
|
|
62
66
|
})
|
|
63
67
|
|
|
64
68
|
it('should not be able to burn more than balance', async () => {
|
|
65
69
|
await token.grantRole(ownerAddress, 'MINT')
|
|
66
|
-
await token.grantRole(ownerAddress, 'BURN')
|
|
67
70
|
await token.mint(ownerAddress, 100000n)
|
|
68
71
|
|
|
69
72
|
await assert.rejects(async () => await token.burn(ownerAddress, 100001n), {
|