@leofcoin/standards 0.3.1 → 0.3.2
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/index.d.ts +1 -0
- package/exports/interfaces.d.ts +47 -0
- package/exports/interfaces.js +1 -0
- package/exports/meta.d.ts +1 -1
- package/exports/roles.d.ts +1 -1
- package/exports/token-receiver.d.ts +2 -2
- package/exports/token.d.ts +1 -1
- package/exports/types.d.ts +26 -0
- package/exports/types.js +1 -0
- package/exports/voting/private-voting.d.ts +2 -2
- package/exports/voting/public-voting.d.ts +3 -3
- package/package.json +82 -23
- package/rollup.config.js +15 -2
- package/src/index.ts +1 -1
- package/src/{voting/types.ts → interfaces.ts} +15 -1
- package/src/meta.ts +1 -1
- package/src/roles.ts +1 -1
- package/src/token-receiver.ts +1 -1
- package/src/token.ts +1 -1
- package/src/voting/private-voting.ts +1 -1
- package/src/voting/public-voting.ts +1 -1
- package/src/types.ts +0 -15
package/exports/index.d.ts
CHANGED
|
@@ -4,4 +4,5 @@ export { default as Token } from './token.js';
|
|
|
4
4
|
export { default as TokenReceiver } from './token-receiver.js';
|
|
5
5
|
export { default as PublicVoting } from './voting/public-voting.js';
|
|
6
6
|
export { default as PrivateVoting } from './voting/private-voting.js';
|
|
7
|
+
export type * from './interfaces.js';
|
|
7
8
|
export * from './helpers.js';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export interface MetaState {
|
|
2
|
+
creator: address;
|
|
3
|
+
createdAt: bigint;
|
|
4
|
+
}
|
|
5
|
+
export declare interface RolesState extends MetaState {
|
|
6
|
+
roles: {
|
|
7
|
+
[index: string]: address[];
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export declare interface TokenState extends RolesState {
|
|
11
|
+
holders: bigint;
|
|
12
|
+
balances: {
|
|
13
|
+
[address: address]: bigint;
|
|
14
|
+
};
|
|
15
|
+
approvals: {
|
|
16
|
+
[owner: address]: {
|
|
17
|
+
[operator: address]: bigint;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
totalSupply: bigint;
|
|
21
|
+
}
|
|
22
|
+
export interface VotingState extends MetaState {
|
|
23
|
+
votes: {
|
|
24
|
+
[id: string]: Vote;
|
|
25
|
+
};
|
|
26
|
+
votingDisabled: boolean;
|
|
27
|
+
votingDuration: number;
|
|
28
|
+
}
|
|
29
|
+
export interface PrivateVotingState extends VotingState {
|
|
30
|
+
voters: address[];
|
|
31
|
+
}
|
|
32
|
+
export type VoteResult = 0 | 0.5 | 1;
|
|
33
|
+
export type Vote = {
|
|
34
|
+
title: string;
|
|
35
|
+
method: string;
|
|
36
|
+
args: any[];
|
|
37
|
+
description: string;
|
|
38
|
+
endTime: EpochTimeStamp;
|
|
39
|
+
results?: {
|
|
40
|
+
[address: string]: VoteResult;
|
|
41
|
+
};
|
|
42
|
+
finished?: boolean;
|
|
43
|
+
enoughVotes?: boolean;
|
|
44
|
+
};
|
|
45
|
+
export interface VoteView extends Vote {
|
|
46
|
+
id: string;
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/exports/meta.d.ts
CHANGED
package/exports/roles.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IPublicVoting } from './voting/interfaces/i-public-voting.js';
|
|
2
2
|
import PublicVoting from './voting/public-voting.js';
|
|
3
|
-
import { VotingState } from './
|
|
3
|
+
import { VotingState } from './interfaces.js';
|
|
4
4
|
export interface TokenReceiverState extends VotingState {
|
|
5
5
|
tokenToReceive: address;
|
|
6
6
|
tokenReceiver: address;
|
|
@@ -19,7 +19,7 @@ export default class TokenReceiver extends PublicVoting implements IPublicVoting
|
|
|
19
19
|
tokenAmountToReceive: bigint;
|
|
20
20
|
voteType: "burn" | "transfer";
|
|
21
21
|
votes: {
|
|
22
|
-
[id: string]: import("./
|
|
22
|
+
[id: string]: import("./interfaces.js").Vote;
|
|
23
23
|
};
|
|
24
24
|
votingDisabled: boolean;
|
|
25
25
|
votingDuration: number;
|
package/exports/token.d.ts
CHANGED
package/exports/types.d.ts
CHANGED
|
@@ -19,3 +19,29 @@ export declare interface TokenState extends RolesState {
|
|
|
19
19
|
};
|
|
20
20
|
totalSupply: bigint;
|
|
21
21
|
}
|
|
22
|
+
export interface VotingState extends MetaState {
|
|
23
|
+
votes: {
|
|
24
|
+
[id: string]: Vote;
|
|
25
|
+
};
|
|
26
|
+
votingDisabled: boolean;
|
|
27
|
+
votingDuration: number;
|
|
28
|
+
}
|
|
29
|
+
export interface PrivateVotingState extends VotingState {
|
|
30
|
+
voters: address[];
|
|
31
|
+
}
|
|
32
|
+
export type VoteResult = 0 | 0.5 | 1;
|
|
33
|
+
export type Vote = {
|
|
34
|
+
title: string;
|
|
35
|
+
method: string;
|
|
36
|
+
args: any[];
|
|
37
|
+
description: string;
|
|
38
|
+
endTime: EpochTimeStamp;
|
|
39
|
+
results?: {
|
|
40
|
+
[address: string]: VoteResult;
|
|
41
|
+
};
|
|
42
|
+
finished?: boolean;
|
|
43
|
+
enoughVotes?: boolean;
|
|
44
|
+
};
|
|
45
|
+
export interface VoteView extends Vote {
|
|
46
|
+
id: string;
|
|
47
|
+
}
|
package/exports/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import Meta from '../meta.js';
|
|
2
|
-
import { PrivateVotingState, VoteResult, VoteView } from '
|
|
2
|
+
import { PrivateVotingState, VoteResult, VoteView } from '../interfaces.js';
|
|
3
3
|
export default class PrivateVoting extends Meta {
|
|
4
4
|
#private;
|
|
5
5
|
constructor(state: PrivateVotingState);
|
|
6
6
|
get votes(): {
|
|
7
|
-
[id: string]: import("
|
|
7
|
+
[id: string]: import("../interfaces.js").Vote;
|
|
8
8
|
};
|
|
9
9
|
get voters(): {
|
|
10
10
|
[n: number]: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Meta from '../meta.js';
|
|
2
|
-
import { VotingState, VoteResult } from '
|
|
2
|
+
import { VotingState, VoteResult } from '../interfaces.js';
|
|
3
3
|
/**
|
|
4
4
|
* allows everybody that has a balance greater or equal to tokenAmountToReceive to vote
|
|
5
5
|
*/
|
|
@@ -7,7 +7,7 @@ export default class PublicVoting extends Meta {
|
|
|
7
7
|
#private;
|
|
8
8
|
constructor(state: VotingState);
|
|
9
9
|
get votes(): {
|
|
10
|
-
[id: string]: import("
|
|
10
|
+
[id: string]: import("../interfaces.js").Vote;
|
|
11
11
|
};
|
|
12
12
|
get votingDuration(): number;
|
|
13
13
|
get votingDisabled(): boolean;
|
|
@@ -16,7 +16,7 @@ export default class PublicVoting extends Meta {
|
|
|
16
16
|
*/
|
|
17
17
|
get state(): {
|
|
18
18
|
votes: {
|
|
19
|
-
[id: string]: import("
|
|
19
|
+
[id: string]: import("../interfaces.js").Vote;
|
|
20
20
|
};
|
|
21
21
|
votingDisabled: boolean;
|
|
22
22
|
votingDuration: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leofcoin/standards",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Contract standards",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -8,40 +8,98 @@
|
|
|
8
8
|
"import": "./exports/index.js",
|
|
9
9
|
"types": "./exports/index.d.ts"
|
|
10
10
|
},
|
|
11
|
-
"./
|
|
12
|
-
"import": "./exports/
|
|
13
|
-
"types": "./exports/
|
|
11
|
+
"./helpers": {
|
|
12
|
+
"import": "./exports/helpers.js",
|
|
13
|
+
"types": "./exports/helpers.d.ts"
|
|
14
14
|
},
|
|
15
|
-
"./
|
|
16
|
-
"import": "./exports/
|
|
17
|
-
"types": "./exports/
|
|
15
|
+
"./helpers.js": {
|
|
16
|
+
"import": "./exports/helpers.js",
|
|
17
|
+
"types": "./exports/helpers.d.ts"
|
|
18
18
|
},
|
|
19
|
-
"./public-voting": {
|
|
20
|
-
"import": "./exports/public-voting.js",
|
|
21
|
-
"types": "./exports/public-voting.d.ts"
|
|
19
|
+
"./i-public-voting": {
|
|
20
|
+
"import": "./exports/i-public-voting.js",
|
|
21
|
+
"types": "./exports/voting/interfaces/i-public-voting.d.ts"
|
|
22
|
+
},
|
|
23
|
+
"./i-public-voting.js": {
|
|
24
|
+
"import": "./exports/i-public-voting.js",
|
|
25
|
+
"types": "./exports/voting/interfaces/i-public-voting.d.ts"
|
|
26
|
+
},
|
|
27
|
+
"./index.js": {
|
|
28
|
+
"import": "./exports/index.js",
|
|
29
|
+
"types": "./exports/index.d.ts"
|
|
30
|
+
},
|
|
31
|
+
"./interfaces": {
|
|
32
|
+
"import": "./exports/interfaces.js",
|
|
33
|
+
"types": "./exports/interfaces.d.ts"
|
|
34
|
+
},
|
|
35
|
+
"./interfaces.js": {
|
|
36
|
+
"import": "./exports/interfaces.js",
|
|
37
|
+
"types": "./exports/interfaces.d.ts"
|
|
38
|
+
},
|
|
39
|
+
"./meta": {
|
|
40
|
+
"import": "./exports/meta.js",
|
|
41
|
+
"types": "./exports/meta.d.ts"
|
|
42
|
+
},
|
|
43
|
+
"./meta.js": {
|
|
44
|
+
"import": "./exports/meta.js",
|
|
45
|
+
"types": "./exports/meta.d.ts"
|
|
22
46
|
},
|
|
23
47
|
"./private-voting": {
|
|
24
48
|
"import": "./exports/private-voting.js",
|
|
25
|
-
"types": "./exports/private-voting.d.ts"
|
|
49
|
+
"types": "./exports/voting/private-voting.d.ts"
|
|
50
|
+
},
|
|
51
|
+
"./private-voting.js": {
|
|
52
|
+
"import": "./exports/private-voting.js",
|
|
53
|
+
"types": "./exports/voting/private-voting.d.ts"
|
|
54
|
+
},
|
|
55
|
+
"./public-voting": {
|
|
56
|
+
"import": "./exports/public-voting.js",
|
|
57
|
+
"types": "./exports/voting/interfaces/public-voting.d.ts"
|
|
58
|
+
},
|
|
59
|
+
"./public-voting.js": {
|
|
60
|
+
"import": "./exports/public-voting.js",
|
|
61
|
+
"types": "./exports/voting/interfaces/public-voting.d.ts"
|
|
62
|
+
},
|
|
63
|
+
"./roles": {
|
|
64
|
+
"import": "./exports/roles.js",
|
|
65
|
+
"types": "./exports/roles.d.ts"
|
|
66
|
+
},
|
|
67
|
+
"./roles.js": {
|
|
68
|
+
"import": "./exports/roles.js",
|
|
69
|
+
"types": "./exports/roles.d.ts"
|
|
26
70
|
},
|
|
27
71
|
"./token-receiver": {
|
|
28
72
|
"import": "./exports/token-receiver.js",
|
|
29
73
|
"types": "./exports/token-receiver.d.ts"
|
|
30
74
|
},
|
|
31
|
-
"./
|
|
32
|
-
"import": "./exports/
|
|
33
|
-
"types": "./exports/
|
|
75
|
+
"./token-receiver.js": {
|
|
76
|
+
"import": "./exports/token-receiver.js",
|
|
77
|
+
"types": "./exports/token-receiver.d.ts"
|
|
34
78
|
},
|
|
35
|
-
"./
|
|
36
|
-
"import": "./exports/
|
|
37
|
-
"types": "./exports/
|
|
79
|
+
"./token": {
|
|
80
|
+
"import": "./exports/token.js",
|
|
81
|
+
"types": "./exports/token.d.ts"
|
|
82
|
+
},
|
|
83
|
+
"./token.js": {
|
|
84
|
+
"import": "./exports/token.js",
|
|
85
|
+
"types": "./exports/token.d.ts"
|
|
86
|
+
},
|
|
87
|
+
"./types": {
|
|
88
|
+
"import": "./exports/types.js",
|
|
89
|
+
"types": "./exports/voting/types.d.ts"
|
|
90
|
+
},
|
|
91
|
+
"./types.js": {
|
|
92
|
+
"import": "./exports/types.js",
|
|
93
|
+
"types": "./exports/voting/types.d.ts"
|
|
94
|
+
},
|
|
95
|
+
"./voting": {
|
|
96
|
+
"import": "./exports/voting.js",
|
|
97
|
+
"types": "./exports/voting.d.ts"
|
|
38
98
|
},
|
|
39
|
-
"./
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"./private-voting.js": "./exports/private-voting.js",
|
|
44
|
-
"./helpers.js": "./exports/helpers.js"
|
|
99
|
+
"./voting.js": {
|
|
100
|
+
"import": "./exports/voting.js",
|
|
101
|
+
"types": "./exports/voting.d.ts"
|
|
102
|
+
}
|
|
45
103
|
},
|
|
46
104
|
"scripts": {
|
|
47
105
|
"build": "rollup -c",
|
|
@@ -62,6 +120,7 @@
|
|
|
62
120
|
"@leofcoin/global-types": "^1.0.2",
|
|
63
121
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
64
122
|
"rollup": "^4.54.0",
|
|
123
|
+
"rollup-plugin-auto-exports": "^1.1.1",
|
|
65
124
|
"tslib": "^2.8.1"
|
|
66
125
|
}
|
|
67
126
|
}
|
package/rollup.config.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import typescript from '@rollup/plugin-typescript'
|
|
2
2
|
import { execSync } from 'child_process'
|
|
3
|
+
import autoExports from 'rollup-plugin-auto-exports'
|
|
3
4
|
|
|
4
5
|
// const templates = (await readdir('./src/templates')).map(path => join('./src/templates', path))
|
|
5
6
|
const clean = () => {
|
|
@@ -17,12 +18,24 @@ export default [
|
|
|
17
18
|
'src/voting/interfaces/i-public-voting.ts',
|
|
18
19
|
'src/voting/private-voting.ts',
|
|
19
20
|
'src/helpers.ts',
|
|
20
|
-
'src/token-receiver.ts'
|
|
21
|
+
'src/token-receiver.ts',
|
|
22
|
+
'src/interfaces.ts'
|
|
21
23
|
],
|
|
22
24
|
output: {
|
|
23
25
|
dir: './exports',
|
|
24
26
|
format: 'es'
|
|
25
27
|
},
|
|
26
|
-
plugins: [
|
|
28
|
+
plugins: [
|
|
29
|
+
typescript(),
|
|
30
|
+
autoExports({
|
|
31
|
+
exportsDir: 'exports',
|
|
32
|
+
defaultExports: {
|
|
33
|
+
'.': {
|
|
34
|
+
import: 'exports/index.js',
|
|
35
|
+
types: 'exports/index.d.ts'
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
]
|
|
27
40
|
}
|
|
28
41
|
]
|
package/src/index.ts
CHANGED
|
@@ -4,5 +4,5 @@ export { default as Token } from './token.js'
|
|
|
4
4
|
export { default as TokenReceiver } from './token-receiver.js'
|
|
5
5
|
export { default as PublicVoting } from './voting/public-voting.js'
|
|
6
6
|
export { default as PrivateVoting } from './voting/private-voting.js'
|
|
7
|
-
|
|
7
|
+
export type * from './interfaces.js'
|
|
8
8
|
export * from './helpers.js'
|
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
export interface MetaState {
|
|
2
|
+
creator: address
|
|
3
|
+
createdAt: bigint
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export declare interface RolesState extends MetaState {
|
|
7
|
+
roles: { [index: string]: address[] }
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export declare interface TokenState extends RolesState {
|
|
11
|
+
holders: bigint
|
|
12
|
+
balances: { [address: address]: bigint }
|
|
13
|
+
approvals: { [owner: address]: { [operator: address]: bigint } }
|
|
14
|
+
totalSupply: bigint
|
|
15
|
+
}
|
|
2
16
|
|
|
3
17
|
export interface VotingState extends MetaState {
|
|
4
18
|
votes: {
|
package/src/meta.ts
CHANGED
package/src/roles.ts
CHANGED
package/src/token-receiver.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IPublicVoting } from './voting/interfaces/i-public-voting.js'
|
|
2
2
|
import PublicVoting from './voting/public-voting.js'
|
|
3
|
-
import { VotingState } from './
|
|
3
|
+
import { VotingState } from './interfaces.js'
|
|
4
4
|
|
|
5
5
|
export interface TokenReceiverState extends VotingState {
|
|
6
6
|
tokenToReceive: address
|
package/src/token.ts
CHANGED
package/src/types.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export interface MetaState {
|
|
2
|
-
creator: address
|
|
3
|
-
createdAt: bigint
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export declare interface RolesState extends MetaState {
|
|
7
|
-
roles: { [index: string]: address[] }
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export declare interface TokenState extends RolesState {
|
|
11
|
-
holders: bigint
|
|
12
|
-
balances: { [address: address]: bigint }
|
|
13
|
-
approvals: { [owner: address]: { [operator: address]: bigint } }
|
|
14
|
-
totalSupply: bigint
|
|
15
|
-
}
|