@leofcoin/standards 0.2.16 → 0.3.0
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/.gitattributes +2 -2
- package/.github/workflows/test.yml +33 -0
- package/.prettierrc +8 -8
- package/CHANGELOG.md +16 -3
- package/LICENSE +21 -21
- package/README.md +25 -23
- package/exports/helpers.js +1 -1
- package/exports/i-public-voting.js +1 -0
- package/exports/index.d.ts +2 -1
- package/exports/index.js +2 -3
- package/exports/meta-D7uruGOw.js +28 -0
- package/exports/meta.d.ts +11 -0
- package/exports/private-voting.js +104 -11
- package/exports/public-voting.js +103 -4
- package/exports/roles.d.ts +5 -10
- package/exports/roles.js +7 -8
- package/exports/token-receiver.d.ts +5 -7
- package/exports/token-receiver.js +25 -14
- package/exports/token.d.ts +14 -27
- package/exports/token.js +14 -48
- package/exports/types.d.ts +21 -0
- package/exports/voting/private-voting.d.ts +108 -11
- package/exports/voting/public-voting.d.ts +45 -8
- package/exports/voting/types.d.ts +11 -7
- package/package.json +10 -18
- package/rollup.config.js +28 -28
- package/src/helpers.ts +19 -19
- package/src/index.ts +8 -7
- package/src/meta.ts +31 -0
- package/src/roles.ts +88 -89
- package/src/token-receiver.ts +196 -175
- package/src/token.ts +162 -198
- package/src/types.ts +15 -0
- package/src/voting/interfaces/i-public-voting.ts +4 -0
- package/src/voting/private-voting.ts +187 -69
- package/src/voting/public-voting.ts +134 -14
- package/src/voting/types.ts +30 -24
- package/test/helpers.js +51 -0
- package/test/public-voting.js +365 -6
- package/test/roles.js +186 -0
- package/test/token.js +211 -0
- package/tsconfig.json +16 -12
- package/.changeset/README.md +0 -8
- package/.changeset/config.json +0 -11
- package/exports/contract-creator.d.ts +0 -11
- package/exports/contract-creator.js +0 -20
- package/exports/decorators/time.d.ts +0 -1
- package/exports/interfaces/i-token.d.ts +0 -10
- package/exports/lock.d.ts +0 -37
- package/exports/staking.d.ts +0 -40
- package/exports/voting/interfaces/i-voting.d.ts +0 -6
- package/exports/voting/voting.d.ts +0 -38
- package/exports/voting-C0KVNQO3.js +0 -112
- package/exports/voting-xYjJlN2h.js +0 -112
- package/src/contract-creator.ts +0 -24
- package/src/decorators/time.ts +0 -9
- package/src/interfaces/i-token.ts +0 -10
- package/src/lock.ts +0 -167
- package/src/staking.ts +0 -166
- package/src/voting/interfaces/i-voting.ts +0 -7
- package/src/voting/voting.ts +0 -123
package/test/roles.js
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { test } from 'node:test'
|
|
2
|
+
import assert from 'node:assert/strict'
|
|
3
|
+
import Roles from './../exports/roles.js'
|
|
4
|
+
|
|
5
|
+
test('Roles - constructor initializes with provided roles', () => {
|
|
6
|
+
const state = {
|
|
7
|
+
creator: '0x1234567890123456789012345678901234567890',
|
|
8
|
+
roles: {
|
|
9
|
+
OWNER: [],
|
|
10
|
+
MINT: [],
|
|
11
|
+
BURN: []
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const roles = new Roles(state)
|
|
15
|
+
|
|
16
|
+
assert(roles.roles)
|
|
17
|
+
assert.deepEqual(roles.roles.OWNER, [])
|
|
18
|
+
assert.deepEqual(roles.roles.MINT, [])
|
|
19
|
+
assert.deepEqual(roles.roles.BURN, [])
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
test('Roles - constructor with state initializes custom roles', () => {
|
|
23
|
+
const state = {
|
|
24
|
+
creator: '0x1',
|
|
25
|
+
roles: {
|
|
26
|
+
admin: ['0x1', '0x2'],
|
|
27
|
+
user: ['0x3']
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const roles = new Roles(state)
|
|
32
|
+
|
|
33
|
+
assert.deepEqual(roles.roles.admin, ['0x1', '0x2'])
|
|
34
|
+
assert.deepEqual(roles.roles.user, ['0x3'])
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
test('Roles - constructor throws when roles is not an object', () => {
|
|
38
|
+
const state = {
|
|
39
|
+
creator: '0x1',
|
|
40
|
+
roles: 'invalid'
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
assert.throws(() => {
|
|
44
|
+
new Roles(state)
|
|
45
|
+
}, /expected roles to be an object/)
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
test('Roles - hasRole returns true for address with role', () => {
|
|
49
|
+
const state = {
|
|
50
|
+
creator: '0x1234567890123456789012345678901234567890',
|
|
51
|
+
roles: {
|
|
52
|
+
OWNER: ['0xabc'],
|
|
53
|
+
MINT: ['0xdef', '0x123'],
|
|
54
|
+
BURN: []
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const roles = new Roles(state)
|
|
58
|
+
|
|
59
|
+
assert.equal(roles.hasRole('0xabc', 'OWNER'), true)
|
|
60
|
+
assert.equal(roles.hasRole('0xdef', 'MINT'), true)
|
|
61
|
+
assert.equal(roles.hasRole('0x123', 'MINT'), true)
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
test('Roles - hasRole returns false for address without role', () => {
|
|
65
|
+
const state = {
|
|
66
|
+
creator: '0x1234567890123456789012345678901234567890',
|
|
67
|
+
roles: {
|
|
68
|
+
OWNER: ['0xabc'],
|
|
69
|
+
MINT: [],
|
|
70
|
+
BURN: []
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const roles = new Roles(state)
|
|
74
|
+
|
|
75
|
+
assert.equal(roles.hasRole('0xdef', 'OWNER'), false)
|
|
76
|
+
assert.equal(roles.hasRole('0xabc', 'MINT'), false)
|
|
77
|
+
assert.equal(roles.hasRole('0xabc', 'BURN'), false)
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
test('Roles - hasRole returns false for non-existent role', () => {
|
|
81
|
+
const state = {
|
|
82
|
+
creator: '0x1234567890123456789012345678901234567890',
|
|
83
|
+
roles: {
|
|
84
|
+
OWNER: ['0xabc'],
|
|
85
|
+
MINT: [],
|
|
86
|
+
BURN: []
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const roles = new Roles(state)
|
|
90
|
+
|
|
91
|
+
assert.equal(roles.hasRole('0xabc', 'ADMIN'), false)
|
|
92
|
+
assert.equal(roles.hasRole('0xabc', 'NON_EXISTENT'), false)
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
test('Roles - roles getter returns copy of roles', () => {
|
|
96
|
+
const state = {
|
|
97
|
+
creator: '0x1234567890123456789012345678901234567890',
|
|
98
|
+
roles: {
|
|
99
|
+
OWNER: ['0x1', '0x2'],
|
|
100
|
+
MINT: ['0x3'],
|
|
101
|
+
BURN: []
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const roles = new Roles(state)
|
|
105
|
+
const rolesObj = roles.roles
|
|
106
|
+
|
|
107
|
+
assert.deepEqual(rolesObj.OWNER, ['0x1', '0x2'])
|
|
108
|
+
assert.deepEqual(rolesObj.MINT, ['0x3'])
|
|
109
|
+
assert.deepEqual(rolesObj.BURN, [])
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
test('Roles - state getter returns complete state', () => {
|
|
113
|
+
const state = {
|
|
114
|
+
creator: '0x1234567890123456789012345678901234567890',
|
|
115
|
+
createdAt: Date.now(),
|
|
116
|
+
roles: {
|
|
117
|
+
OWNER: ['0x1'],
|
|
118
|
+
MINT: ['0x2'],
|
|
119
|
+
BURN: []
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const roles = new Roles(state)
|
|
123
|
+
const rolesState = roles.state
|
|
124
|
+
|
|
125
|
+
assert(rolesState.creator)
|
|
126
|
+
assert(rolesState.createdAt)
|
|
127
|
+
assert(rolesState.roles)
|
|
128
|
+
assert.deepEqual(rolesState.roles.OWNER, ['0x1'])
|
|
129
|
+
assert.deepEqual(rolesState.roles.MINT, ['0x2'])
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
test('Roles - hasRole with multiple addresses in same role', () => {
|
|
133
|
+
const state = {
|
|
134
|
+
creator: '0x1234567890123456789012345678901234567890',
|
|
135
|
+
roles: {
|
|
136
|
+
OWNER: [],
|
|
137
|
+
MINT: ['0xa', '0xb', '0xc', '0xd'],
|
|
138
|
+
BURN: []
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
const roles = new Roles(state)
|
|
142
|
+
|
|
143
|
+
assert.equal(roles.hasRole('0xa', 'MINT'), true)
|
|
144
|
+
assert.equal(roles.hasRole('0xb', 'MINT'), true)
|
|
145
|
+
assert.equal(roles.hasRole('0xc', 'MINT'), true)
|
|
146
|
+
assert.equal(roles.hasRole('0xd', 'MINT'), true)
|
|
147
|
+
assert.equal(roles.hasRole('0xe', 'MINT'), false)
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
test('Roles - constructor with complex role structure', () => {
|
|
151
|
+
const state = {
|
|
152
|
+
creator: '0x1234567890123456789012345678901234567890',
|
|
153
|
+
roles: {
|
|
154
|
+
OWNER: ['0x1'],
|
|
155
|
+
MINT: ['0x2', '0x3'],
|
|
156
|
+
BURN: ['0x4', '0x5', '0x6'],
|
|
157
|
+
ADMIN: ['0x7'],
|
|
158
|
+
USER: ['0x8', '0x9', '0xa']
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
const roles = new Roles(state)
|
|
162
|
+
|
|
163
|
+
assert.equal(roles.hasRole('0x1', 'OWNER'), true)
|
|
164
|
+
assert.equal(roles.hasRole('0x2', 'MINT'), true)
|
|
165
|
+
assert.equal(roles.hasRole('0x3', 'MINT'), true)
|
|
166
|
+
assert.equal(roles.hasRole('0x4', 'BURN'), true)
|
|
167
|
+
assert.equal(roles.hasRole('0x7', 'ADMIN'), true)
|
|
168
|
+
assert.equal(roles.hasRole('0x8', 'USER'), true)
|
|
169
|
+
assert.equal(roles.hasRole('0x9', 'USER'), true)
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
test('Roles - hasRole is case-sensitive', () => {
|
|
173
|
+
const state = {
|
|
174
|
+
creator: '0x1234567890123456789012345678901234567890',
|
|
175
|
+
roles: {
|
|
176
|
+
OWNER: ['0xabc'],
|
|
177
|
+
owner: ['0xdef']
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
const roles = new Roles(state)
|
|
181
|
+
|
|
182
|
+
assert.equal(roles.hasRole('0xabc', 'OWNER'), true)
|
|
183
|
+
assert.equal(roles.hasRole('0xabc', 'owner'), false)
|
|
184
|
+
assert.equal(roles.hasRole('0xdef', 'owner'), true)
|
|
185
|
+
assert.equal(roles.hasRole('0xdef', 'OWNER'), false)
|
|
186
|
+
})
|
package/test/token.js
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { test } from 'node:test'
|
|
2
|
+
import assert from 'node:assert/strict'
|
|
3
|
+
import Token from './../exports/token.js'
|
|
4
|
+
|
|
5
|
+
test('Token - constructor throws when name is undefined', () => {
|
|
6
|
+
assert.throws(() => {
|
|
7
|
+
new Token('', 'MTK', 18, {
|
|
8
|
+
creator: '0x1',
|
|
9
|
+
roles: { OWNER: [], MINT: [], BURN: [] },
|
|
10
|
+
balances: {},
|
|
11
|
+
approvals: {},
|
|
12
|
+
holders: '0',
|
|
13
|
+
totalSupply: '0'
|
|
14
|
+
})
|
|
15
|
+
}, /name undefined/)
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
test('Token - constructor throws when symbol is undefined', () => {
|
|
19
|
+
assert.throws(() => {
|
|
20
|
+
new Token('MyToken', '', 18, {
|
|
21
|
+
creator: '0x1',
|
|
22
|
+
roles: { OWNER: [], MINT: [], BURN: [] },
|
|
23
|
+
balances: {},
|
|
24
|
+
approvals: {},
|
|
25
|
+
holders: '0',
|
|
26
|
+
totalSupply: '0'
|
|
27
|
+
})
|
|
28
|
+
}, /symbol undefined/)
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
test('Token - constructor with state restores token properties', () => {
|
|
32
|
+
const state = {
|
|
33
|
+
creator: '0x1234567890123456789012345678901234567890',
|
|
34
|
+
roles: { OWNER: [], MINT: [], BURN: [] },
|
|
35
|
+
balances: { '0x1': '1000', '0x2': '500' },
|
|
36
|
+
approvals: { '0x1': { '0x2': '250' } },
|
|
37
|
+
holders: '2',
|
|
38
|
+
totalSupply: '1500'
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const token = new Token('MyToken', 'MTK', 18, state)
|
|
42
|
+
|
|
43
|
+
assert.equal(token.totalSupply, 1500n)
|
|
44
|
+
assert.equal(token.holders, 2n)
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
test('Token - constructor with zero balances state', () => {
|
|
48
|
+
const state = {
|
|
49
|
+
creator: '0x1234567890123456789012345678901234567890',
|
|
50
|
+
roles: { OWNER: [], MINT: [], BURN: [] },
|
|
51
|
+
balances: {},
|
|
52
|
+
approvals: {},
|
|
53
|
+
holders: '0',
|
|
54
|
+
totalSupply: '0'
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const token = new Token('MyToken', 'MTK', 18, state)
|
|
58
|
+
|
|
59
|
+
assert.equal(token.totalSupply, 0n)
|
|
60
|
+
assert.equal(token.holders, 0n)
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
test('Token - decimals getter returns correct value', () => {
|
|
64
|
+
const state = {
|
|
65
|
+
creator: '0x1234567890123456789012345678901234567890',
|
|
66
|
+
roles: { OWNER: [], MINT: [], BURN: [] },
|
|
67
|
+
balances: {},
|
|
68
|
+
approvals: {},
|
|
69
|
+
holders: '0',
|
|
70
|
+
totalSupply: '0'
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const token = new Token('MyToken', 'MTK', 18, state)
|
|
74
|
+
|
|
75
|
+
// Decimals default to 18 when state is provided
|
|
76
|
+
assert.equal(token.decimals, 18)
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
test('Token - balances getter returns copy of balances', () => {
|
|
80
|
+
const state = {
|
|
81
|
+
creator: '0x1234567890123456789012345678901234567890',
|
|
82
|
+
roles: { OWNER: [], MINT: [], BURN: [] },
|
|
83
|
+
balances: { '0x1': '1000', '0x2': '500' },
|
|
84
|
+
approvals: {},
|
|
85
|
+
holders: '2',
|
|
86
|
+
totalSupply: '1500'
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const token = new Token('MyToken', 'MTK', 18, state)
|
|
90
|
+
const balances = token.balances
|
|
91
|
+
|
|
92
|
+
assert.equal(balances['0x1'], 1000n)
|
|
93
|
+
assert.equal(balances['0x2'], 500n)
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
test('Token - balanceOf returns balance for specific address', () => {
|
|
97
|
+
const state = {
|
|
98
|
+
creator: '0x1234567890123456789012345678901234567890',
|
|
99
|
+
roles: { OWNER: [], MINT: [], BURN: [] },
|
|
100
|
+
balances: { '0xabc': '2500', '0xdef': '750' },
|
|
101
|
+
approvals: {},
|
|
102
|
+
holders: '2',
|
|
103
|
+
totalSupply: '3250'
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const token = new Token('MyToken', 'MTK', 18, state)
|
|
107
|
+
|
|
108
|
+
assert.equal(token.balanceOf('0xabc'), 2500n)
|
|
109
|
+
assert.equal(token.balanceOf('0xdef'), 750n)
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
test('Token - approvals getter returns approvals object', () => {
|
|
113
|
+
const state = {
|
|
114
|
+
creator: '0x1234567890123456789012345678901234567890',
|
|
115
|
+
roles: { OWNER: [], MINT: [], BURN: [] },
|
|
116
|
+
balances: {},
|
|
117
|
+
approvals: { '0x1': { '0x2': '100', '0x3': '200' } },
|
|
118
|
+
holders: '0',
|
|
119
|
+
totalSupply: '0'
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const token = new Token('MyToken', 'MTK', 18, state)
|
|
123
|
+
const approvals = token.approvals
|
|
124
|
+
|
|
125
|
+
assert.equal(approvals['0x1']['0x2'], 100n)
|
|
126
|
+
assert.equal(approvals['0x1']['0x3'], 200n)
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
test('Token - approved checks if exact amount is approved', () => {
|
|
130
|
+
const state = {
|
|
131
|
+
creator: '0x1234567890123456789012345678901234567890',
|
|
132
|
+
roles: { OWNER: [], MINT: [], BURN: [] },
|
|
133
|
+
balances: {},
|
|
134
|
+
approvals: { '0xowner': { '0xoperator': '500' } },
|
|
135
|
+
holders: '0',
|
|
136
|
+
totalSupply: '0'
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const token = new Token('MyToken', 'MTK', 18, state)
|
|
140
|
+
|
|
141
|
+
assert.equal(token.approved('0xowner', '0xoperator', 500n), true)
|
|
142
|
+
assert.equal(token.approved('0xowner', '0xoperator', 400n), false)
|
|
143
|
+
assert.equal(token.approved('0xowner', '0xoperator', 600n), false)
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
test('Token - state getter returns complete state object', () => {
|
|
147
|
+
const now = Date.now()
|
|
148
|
+
const state = {
|
|
149
|
+
creator: '0x1234567890123456789012345678901234567890',
|
|
150
|
+
createdAt: now,
|
|
151
|
+
roles: { OWNER: ['0x1'], MINT: [], BURN: [] },
|
|
152
|
+
balances: { '0x1': '1000' },
|
|
153
|
+
approvals: { '0x1': { '0x2': '250' } },
|
|
154
|
+
holders: '1',
|
|
155
|
+
totalSupply: '1000'
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const token = new Token('MyToken', 'MTK', 18, state)
|
|
159
|
+
const tokenState = token.state
|
|
160
|
+
|
|
161
|
+
// Verify state object has expected properties
|
|
162
|
+
assert(tokenState.creator)
|
|
163
|
+
assert(tokenState.createdAt)
|
|
164
|
+
assert.equal(tokenState.totalSupply, 1000n)
|
|
165
|
+
assert.equal(tokenState.holders, 1n)
|
|
166
|
+
assert(tokenState.balances)
|
|
167
|
+
assert(tokenState.approvals)
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
test('Token - constructor with multiple balances updates holders count', () => {
|
|
171
|
+
const state = {
|
|
172
|
+
creator: '0x1234567890123456789012345678901234567890',
|
|
173
|
+
roles: { OWNER: [], MINT: [], BURN: [] },
|
|
174
|
+
balances: {
|
|
175
|
+
'0x1': '1000',
|
|
176
|
+
'0x2': '500',
|
|
177
|
+
'0x3': '250',
|
|
178
|
+
'0x4': '750'
|
|
179
|
+
},
|
|
180
|
+
approvals: {},
|
|
181
|
+
holders: '4',
|
|
182
|
+
totalSupply: '2500'
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const token = new Token('MyToken', 'MTK', 18, state)
|
|
186
|
+
|
|
187
|
+
assert.equal(token.holders, 4n)
|
|
188
|
+
assert.equal(token.totalSupply, 2500n)
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
test('Token - constructor with complex approval state', () => {
|
|
192
|
+
const state = {
|
|
193
|
+
creator: '0x1234567890123456789012345678901234567890',
|
|
194
|
+
roles: { OWNER: [], MINT: [], BURN: [] },
|
|
195
|
+
balances: { '0x1': '1000', '0x2': '2000' },
|
|
196
|
+
approvals: {
|
|
197
|
+
'0x1': { '0x2': '100', '0x3': '200' },
|
|
198
|
+
'0x2': { '0x1': '500', '0x4': '300' }
|
|
199
|
+
},
|
|
200
|
+
holders: '2',
|
|
201
|
+
totalSupply: '3000'
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const token = new Token('MyToken', 'MTK', 18, state)
|
|
205
|
+
const approvals = token.approvals
|
|
206
|
+
|
|
207
|
+
assert.equal(approvals['0x1']['0x2'], 100n)
|
|
208
|
+
assert.equal(approvals['0x1']['0x3'], 200n)
|
|
209
|
+
assert.equal(approvals['0x2']['0x1'], 500n)
|
|
210
|
+
assert.equal(approvals['0x2']['0x4'], 300n)
|
|
211
|
+
})
|
package/tsconfig.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"module": "NodeNext",
|
|
4
|
-
"target": "es2022",
|
|
5
|
-
"outDir": "./exports",
|
|
6
|
-
"moduleResolution": "NodeNext",
|
|
7
|
-
"declaration": true,
|
|
8
|
-
"declarationDir": "./exports"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "NodeNext",
|
|
4
|
+
"target": "es2022",
|
|
5
|
+
"outDir": "./exports",
|
|
6
|
+
"moduleResolution": "NodeNext",
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"declarationDir": "./exports"
|
|
9
|
+
},
|
|
10
|
+
"include": [
|
|
11
|
+
"./src/*",
|
|
12
|
+
"./node_modules/@leofcoin/global-types/*",
|
|
13
|
+
"src/voting/private-voting.ts",
|
|
14
|
+
"src/voting/public-voting.ts"
|
|
15
|
+
]
|
|
16
|
+
}
|
package/.changeset/README.md
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
# Changesets
|
|
2
|
-
|
|
3
|
-
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
|
|
4
|
-
with multi-package repos, or single-package repos to help you version and publish your code. You can
|
|
5
|
-
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
|
|
6
|
-
|
|
7
|
-
We have a quick list of common questions to get you started engaging with this project in
|
|
8
|
-
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
|
package/.changeset/config.json
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json",
|
|
3
|
-
"changelog": "@changesets/cli/changelog",
|
|
4
|
-
"commit": true,
|
|
5
|
-
"fixed": [],
|
|
6
|
-
"linked": [],
|
|
7
|
-
"access": "public",
|
|
8
|
-
"baseBranch": "main",
|
|
9
|
-
"updateInternalDependencies": "patch",
|
|
10
|
-
"ignore": []
|
|
11
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/// <reference types="@leofcoin/types/global" />
|
|
2
|
-
export type ContractCreatorState = {
|
|
3
|
-
contractCreator: address;
|
|
4
|
-
};
|
|
5
|
-
export default class ContractCreator {
|
|
6
|
-
#private;
|
|
7
|
-
constructor(state: ContractCreatorState);
|
|
8
|
-
get _contractCreator(): string;
|
|
9
|
-
get state(): ContractCreatorState;
|
|
10
|
-
get _isContractCreator(): boolean;
|
|
11
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
class ContractCreator {
|
|
2
|
-
#creator;
|
|
3
|
-
constructor(state) {
|
|
4
|
-
if (state)
|
|
5
|
-
this.#creator = state.contractCreator;
|
|
6
|
-
else
|
|
7
|
-
this.#creator = msg.sender;
|
|
8
|
-
}
|
|
9
|
-
get _contractCreator() {
|
|
10
|
-
return this.#creator;
|
|
11
|
-
}
|
|
12
|
-
get state() {
|
|
13
|
-
return { contractCreator: this.#creator };
|
|
14
|
-
}
|
|
15
|
-
get _isContractCreator() {
|
|
16
|
-
return msg.sender === this.#creator;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export { ContractCreator as default };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function time(target: any, descriptor: any): void;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
interface IToken {
|
|
2
|
-
mint?(to: string, amount: bigint): void;
|
|
3
|
-
burn?(from: string, amount: bigint): void;
|
|
4
|
-
transfer?(from: string, to: string, amount: bigint): void;
|
|
5
|
-
balance?(): bigint;
|
|
6
|
-
balanceOf?(address: string): bigint;
|
|
7
|
-
setApproval?(operator: string, amount: bigint): void;
|
|
8
|
-
approved?(owner: string, operator: string, amount: bigint): boolean;
|
|
9
|
-
}
|
|
10
|
-
export { IToken };
|
package/exports/lock.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/// <reference types="@leofcoin/types/global" />
|
|
2
|
-
import { RolesState } from './roles.js';
|
|
3
|
-
import { IVoting } from './voting/interfaces/i-voting.js';
|
|
4
|
-
import PublicVoting from './voting/public-voting.js';
|
|
5
|
-
export declare interface LockState extends RolesState {
|
|
6
|
-
holders: bigint;
|
|
7
|
-
balances: {
|
|
8
|
-
[address: address]: bigint;
|
|
9
|
-
};
|
|
10
|
-
totalSupply: bigint;
|
|
11
|
-
}
|
|
12
|
-
export default class Lock extends PublicVoting implements IVoting {
|
|
13
|
-
#private;
|
|
14
|
-
constructor(name: string, symbol: string, decimals?: number, state?: LockState);
|
|
15
|
-
/**
|
|
16
|
-
* @return {Object} {holders, balances, ...}
|
|
17
|
-
*/
|
|
18
|
-
get state(): LockState;
|
|
19
|
-
get totalSupply(): bigint;
|
|
20
|
-
get name(): string;
|
|
21
|
-
get symbol(): string;
|
|
22
|
-
get holders(): LockState['holders'];
|
|
23
|
-
get balances(): LockState['balances'];
|
|
24
|
-
get approvals(): {
|
|
25
|
-
[owner: string]: {
|
|
26
|
-
[operator: string]: bigint;
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
get decimals(): number;
|
|
30
|
-
mint(to: address, amount: bigint): void;
|
|
31
|
-
burn(from: address, amount: bigint): void;
|
|
32
|
-
balance(): any;
|
|
33
|
-
balanceOf(address: address): bigint;
|
|
34
|
-
setApproval(operator: address, amount: bigint): void;
|
|
35
|
-
approved(owner: address, operator: address, amount: bigint): boolean;
|
|
36
|
-
transfer(from: address, to: address, amount: bigint): void;
|
|
37
|
-
}
|
package/exports/staking.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/// <reference types="@leofcoin/types/global" />
|
|
2
|
-
import Roles, { RolesState } from './roles.js';
|
|
3
|
-
export declare interface TokenState extends RolesState {
|
|
4
|
-
holders: bigint;
|
|
5
|
-
balances: {
|
|
6
|
-
[address: address]: bigint;
|
|
7
|
-
};
|
|
8
|
-
approvals: {
|
|
9
|
-
[owner: address]: {
|
|
10
|
-
[operator: address]: bigint;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
totalSupply: bigint;
|
|
14
|
-
}
|
|
15
|
-
export default class Staking extends Roles {
|
|
16
|
-
#private;
|
|
17
|
-
constructor(name: string, symbol: string, decimals?: number, state?: TokenState);
|
|
18
|
-
/**
|
|
19
|
-
* @return {Object} {holders, balances, ...}
|
|
20
|
-
*/
|
|
21
|
-
get state(): TokenState;
|
|
22
|
-
get totalSupply(): bigint;
|
|
23
|
-
get name(): string;
|
|
24
|
-
get symbol(): string;
|
|
25
|
-
get holders(): TokenState['holders'];
|
|
26
|
-
get balances(): TokenState['balances'];
|
|
27
|
-
get approvals(): {
|
|
28
|
-
[owner: string]: {
|
|
29
|
-
[operator: string]: bigint;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
get decimals(): number;
|
|
33
|
-
mint(to: address, amount: bigint): void;
|
|
34
|
-
burn(from: address, amount: bigint): void;
|
|
35
|
-
balance(): any;
|
|
36
|
-
balanceOf(address: address): bigint;
|
|
37
|
-
setApproval(operator: address, amount: bigint): void;
|
|
38
|
-
approved(owner: address, operator: address, amount: bigint): boolean;
|
|
39
|
-
transfer(from: address, to: address, amount: bigint): void;
|
|
40
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import ContractCreator, { ContractCreatorState } from '../contract-creator.js';
|
|
2
|
-
import { Vote, VoteResult, VotingState as _VotingState } from './types.js';
|
|
3
|
-
export declare interface VotingState extends _VotingState, ContractCreatorState {
|
|
4
|
-
}
|
|
5
|
-
export default class Voting extends ContractCreator {
|
|
6
|
-
#private;
|
|
7
|
-
constructor(state: VotingState);
|
|
8
|
-
get votes(): {
|
|
9
|
-
[x: string]: Vote;
|
|
10
|
-
};
|
|
11
|
-
get votingDuration(): number;
|
|
12
|
-
get votingDisabled(): boolean;
|
|
13
|
-
get state(): VotingState;
|
|
14
|
-
/**
|
|
15
|
-
* create vote
|
|
16
|
-
* @param {string} vote
|
|
17
|
-
* @param {string} description
|
|
18
|
-
* @param {number} endTime
|
|
19
|
-
* @param {string} method function to run when agree amount is bigger
|
|
20
|
-
*/
|
|
21
|
-
createVote(title: string, description: string, endTime: EpochTimeStamp, method: string, args?: any[]): void;
|
|
22
|
-
vote(voteId: string, vote: VoteResult): Promise<void>;
|
|
23
|
-
get votesInProgress(): {
|
|
24
|
-
id: string;
|
|
25
|
-
title: string;
|
|
26
|
-
method: string;
|
|
27
|
-
args: any[];
|
|
28
|
-
description: string;
|
|
29
|
-
endTime: number;
|
|
30
|
-
results?: {
|
|
31
|
-
[address: string]: VoteResult;
|
|
32
|
-
};
|
|
33
|
-
finished?: boolean;
|
|
34
|
-
enoughVotes?: boolean;
|
|
35
|
-
}[];
|
|
36
|
-
disableVoting(): void;
|
|
37
|
-
sync(): void;
|
|
38
|
-
}
|