@leofcoin/contracts 0.1.20 → 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/.size-log.json +17 -0
- package/package.json +4 -4
- package/src/native-token.ts +4 -0
- package/src/validators.ts +3 -1
- package/test/native-token.js +6 -3
- package/tsconfig.json +1 -0
package/.size-log.json
CHANGED
|
@@ -654,6 +654,23 @@
|
|
|
654
654
|
"development": 6,
|
|
655
655
|
"total": 8
|
|
656
656
|
}
|
|
657
|
+
},
|
|
658
|
+
{
|
|
659
|
+
"version": "0.1.20",
|
|
660
|
+
"timestamp": "2026-07-29T13:42:42.696Z",
|
|
661
|
+
"size": {
|
|
662
|
+
"bytes": 30783,
|
|
663
|
+
"formatted": "30.06 KB"
|
|
664
|
+
},
|
|
665
|
+
"nodeModules": {
|
|
666
|
+
"bytes": 0,
|
|
667
|
+
"formatted": "0 Bytes"
|
|
668
|
+
},
|
|
669
|
+
"dependencies": {
|
|
670
|
+
"production": 2,
|
|
671
|
+
"development": 6,
|
|
672
|
+
"total": 8
|
|
673
|
+
}
|
|
657
674
|
}
|
|
658
675
|
]
|
|
659
676
|
}
|
package/package.json
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leofcoin/contracts",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.22",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./factory": "./exports/factory.js",
|
|
8
|
-
"./name-
|
|
8
|
+
"./name-service": "./exports/name-service.js",
|
|
9
|
+
"./name-token": "./exports/name-service.js",
|
|
9
10
|
"./power-token": "./exports/power-token.js",
|
|
10
11
|
"./native-token": "./exports/native-token.js",
|
|
11
12
|
"./validators": "./exports/validators.js"
|
|
12
13
|
},
|
|
13
14
|
"scripts": {
|
|
14
15
|
"build": "rollup -c",
|
|
15
|
-
"postbuild": "node scripts/track-size.js",
|
|
16
16
|
"test": "node --test test/**/*.js",
|
|
17
17
|
"size": "node scripts/track-size.js"
|
|
18
18
|
},
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
21
|
-
"url": "
|
|
21
|
+
"url": "https://github.com/leofcoin/monorepo"
|
|
22
22
|
},
|
|
23
23
|
"keywords": [],
|
|
24
24
|
"author": "",
|
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/src/validators.ts
CHANGED
|
@@ -159,7 +159,9 @@ export default class Validators extends Roles {
|
|
|
159
159
|
// only return 128 best participating max
|
|
160
160
|
.splice(0, _peers.length > 128 ? 128 : _peers.length)
|
|
161
161
|
|
|
162
|
-
|
|
162
|
+
if (peers.length === 0) return
|
|
163
|
+
|
|
164
|
+
const luckyNumber = peers.length === 1 ? [0] : lottery(1, peers.length - 1)
|
|
163
165
|
|
|
164
166
|
let nextValidator = peers[luckyNumber[0]][0]
|
|
165
167
|
// redraw when the validator is the same
|
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), {
|