@leofcoin/standards 0.3.1 → 0.3.3

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.
@@ -1,7 +1,7 @@
1
- export { default as Meta } from './meta.js';
2
- export { default as Roles } from './roles.js';
3
- export { default as Token } from './token.js';
4
- export { default as TokenReceiver } from './token-receiver.js';
5
- export { default as PublicVoting } from './voting/public-voting.js';
6
- export { default as PrivateVoting } from './voting/private-voting.js';
1
+ export { default as Meta, type MetaState } from './meta.js';
2
+ export { default as Roles, type RolesState } from './roles.js';
3
+ export { default as Token, type TokenState } from './token.js';
4
+ export { default as TokenReceiver, type TokenReceiverState } from './token-receiver.js';
5
+ export { default as PublicVoting, type VotingState, type VoteResult, type Vote, type VoteView } from './voting/public-voting.js';
6
+ export { default as PrivateVoting, type PrivateVotingState } from './voting/private-voting.js';
7
7
  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
@@ -1,4 +1,7 @@
1
- import { MetaState } from './types.js';
1
+ export interface MetaState {
2
+ creator: address;
3
+ createdAt: bigint;
4
+ }
2
5
  export default class Meta {
3
6
  #private;
4
7
  constructor(state?: MetaState);
@@ -1,5 +1,9 @@
1
- import Meta from './meta.js';
2
- import { RolesState } from './types.js';
1
+ import Meta, { MetaState } from './meta.js';
2
+ export interface RolesState extends MetaState {
3
+ roles: {
4
+ [index: string]: address[];
5
+ };
6
+ }
3
7
  export default class Roles extends Meta {
4
8
  #private;
5
9
  constructor(state?: RolesState);
@@ -1,6 +1,5 @@
1
1
  import { IPublicVoting } from './voting/interfaces/i-public-voting.js';
2
- import PublicVoting from './voting/public-voting.js';
3
- import { VotingState } from './voting/types.js';
2
+ import PublicVoting, { VotingState } from './voting/public-voting.js';
4
3
  export interface TokenReceiverState extends VotingState {
5
4
  tokenToReceive: address;
6
5
  tokenReceiver: address;
@@ -19,7 +18,7 @@ export default class TokenReceiver extends PublicVoting implements IPublicVoting
19
18
  tokenAmountToReceive: bigint;
20
19
  voteType: "burn" | "transfer";
21
20
  votes: {
22
- [id: string]: import("./voting/types.js").Vote;
21
+ [id: string]: import("./voting/public-voting.js").Vote;
23
22
  };
24
23
  votingDisabled: boolean;
25
24
  votingDuration: number;
@@ -1,5 +1,16 @@
1
- import Roles from './roles.js';
2
- import { TokenState } from './types.js';
1
+ import Roles, { RolesState } from './roles.js';
2
+ export interface TokenState extends RolesState {
3
+ holders: bigint;
4
+ balances: {
5
+ [address: address]: bigint;
6
+ };
7
+ approvals: {
8
+ [owner: address]: {
9
+ [operator: address]: bigint;
10
+ };
11
+ };
12
+ totalSupply: bigint;
13
+ }
3
14
  export default class Token extends Roles {
4
15
  #private;
5
16
  constructor(name: string, symbol: string, decimals?: number, state?: TokenState);
@@ -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
+ }
@@ -0,0 +1 @@
1
+
@@ -1,10 +1,35 @@
1
- import Meta from '../meta.js';
2
- import { PrivateVotingState, VoteResult, VoteView } from './types.js';
1
+ import Meta, { MetaState } from '../meta.js';
2
+ export interface VotingState extends MetaState {
3
+ votes: {
4
+ [id: string]: Vote;
5
+ };
6
+ votingDisabled: boolean;
7
+ votingDuration: number;
8
+ }
9
+ export interface PrivateVotingState extends VotingState {
10
+ voters: address[];
11
+ }
12
+ export type VoteResult = 0 | 0.5 | 1;
13
+ export type Vote = {
14
+ title: string;
15
+ method: string;
16
+ args: any[];
17
+ description: string;
18
+ endTime: EpochTimeStamp;
19
+ results?: {
20
+ [address: string]: VoteResult;
21
+ };
22
+ finished?: boolean;
23
+ enoughVotes?: boolean;
24
+ };
25
+ export interface VoteView extends Vote {
26
+ id: string;
27
+ }
3
28
  export default class PrivateVoting extends Meta {
4
29
  #private;
5
30
  constructor(state: PrivateVotingState);
6
31
  get votes(): {
7
- [id: string]: import("./types.js").Vote;
32
+ [id: string]: Vote;
8
33
  };
9
34
  get voters(): {
10
35
  [n: number]: string;
@@ -1,5 +1,27 @@
1
- import Meta from '../meta.js';
2
- import { VotingState, VoteResult } from './types.js';
1
+ import Meta, { MetaState } from '../meta.js';
2
+ export interface VotingState extends MetaState {
3
+ votes: {
4
+ [id: string]: Vote;
5
+ };
6
+ votingDisabled: boolean;
7
+ votingDuration: number;
8
+ }
9
+ export type VoteResult = 0 | 0.5 | 1;
10
+ export type Vote = {
11
+ title: string;
12
+ method: string;
13
+ args: any[];
14
+ description: string;
15
+ endTime: EpochTimeStamp;
16
+ results?: {
17
+ [address: string]: VoteResult;
18
+ };
19
+ finished?: boolean;
20
+ enoughVotes?: boolean;
21
+ };
22
+ export interface VoteView extends Vote {
23
+ id: string;
24
+ }
3
25
  /**
4
26
  * allows everybody that has a balance greater or equal to tokenAmountToReceive to vote
5
27
  */
@@ -7,7 +29,7 @@ export default class PublicVoting extends Meta {
7
29
  #private;
8
30
  constructor(state: VotingState);
9
31
  get votes(): {
10
- [id: string]: import("./types.js").Vote;
32
+ [id: string]: Vote;
11
33
  };
12
34
  get votingDuration(): number;
13
35
  get votingDisabled(): boolean;
@@ -16,7 +38,7 @@ export default class PublicVoting extends Meta {
16
38
  */
17
39
  get state(): {
18
40
  votes: {
19
- [id: string]: import("./types.js").Vote;
41
+ [id: string]: Vote;
20
42
  };
21
43
  votingDisabled: boolean;
22
44
  votingDuration: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/standards",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
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
- "./token": {
12
- "import": "./exports/token.js",
13
- "types": "./exports/token.d.ts"
11
+ "./helpers": {
12
+ "import": "./exports/helpers.js",
13
+ "types": "./exports/helpers.d.ts"
14
14
  },
15
- "./roles": {
16
- "import": "./exports/roles.js",
17
- "types": "./exports/roles.d.ts"
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
- "./interfaces/i-public-voting": {
32
- "import": "./exports/i-public-voting.js",
33
- "types": "./exports/i-public-voting.d.ts"
75
+ "./token-receiver.js": {
76
+ "import": "./exports/token-receiver.js",
77
+ "types": "./exports/token-receiver.d.ts"
34
78
  },
35
- "./helpers": {
36
- "import": "./exports/helpers.js",
37
- "types": "./exports/helpers.d.ts"
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
- "./token.js": "./exports/token.js",
40
- "./roles.js": "./exports/roles.js",
41
- "./public-voting.js": "./exports/public-voting.js",
42
- "./interfaces/i-public-voting.js": "./exports/i-public-voting.js",
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: [typescript()]
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
@@ -1,8 +1,19 @@
1
- export { default as Meta } from './meta.js'
2
- export { default as Roles } from './roles.js'
3
- export { default as Token } from './token.js'
4
- export { default as TokenReceiver } from './token-receiver.js'
5
- export { default as PublicVoting } from './voting/public-voting.js'
6
- export { default as PrivateVoting } from './voting/private-voting.js'
7
-
1
+ export { default as Meta, type MetaState } from './meta.js'
2
+ export { default as Roles, type RolesState } from './roles.js'
3
+ export { default as Token, type TokenState } from './token.js'
4
+ export {
5
+ default as TokenReceiver,
6
+ type TokenReceiverState
7
+ } from './token-receiver.js'
8
+ export {
9
+ default as PublicVoting,
10
+ type VotingState,
11
+ type VoteResult,
12
+ type Vote,
13
+ type VoteView
14
+ } from './voting/public-voting.js'
15
+ export {
16
+ default as PrivateVoting,
17
+ type PrivateVotingState
18
+ } from './voting/private-voting.js'
8
19
  export * from './helpers.js'
@@ -1,4 +1,18 @@
1
- import { MetaState } from '../types.js'
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
@@ -1,4 +1,7 @@
1
- import { MetaState } from './types.js'
1
+ export interface MetaState {
2
+ creator: address
3
+ createdAt: bigint
4
+ }
2
5
 
3
6
  export default class Meta {
4
7
  #creator: address
package/src/roles.ts CHANGED
@@ -1,5 +1,8 @@
1
- import Meta from './meta.js'
2
- import { RolesState } from './types.js'
1
+ import Meta, { MetaState } from './meta.js'
2
+
3
+ export interface RolesState extends MetaState {
4
+ roles: { [index: string]: address[] }
5
+ }
3
6
 
4
7
  export default class Roles extends Meta {
5
8
  /**
@@ -1,6 +1,5 @@
1
1
  import { IPublicVoting } from './voting/interfaces/i-public-voting.js'
2
- import PublicVoting from './voting/public-voting.js'
3
- import { VotingState } from './voting/types.js'
2
+ import PublicVoting, { VotingState } from './voting/public-voting.js'
4
3
 
5
4
  export interface TokenReceiverState extends VotingState {
6
5
  tokenToReceive: address
package/src/token.ts CHANGED
@@ -1,6 +1,12 @@
1
1
  import { restoreApprovals, restoreBalances } from './helpers.js'
2
- import Roles from './roles.js'
3
- import { TokenState } from './types.js'
2
+ import Roles, { RolesState } from './roles.js'
3
+
4
+ export interface TokenState extends RolesState {
5
+ holders: bigint
6
+ balances: { [address: address]: bigint }
7
+ approvals: { [owner: address]: { [operator: address]: bigint } }
8
+ totalSupply: bigint
9
+ }
4
10
 
5
11
  export default class Token extends Roles {
6
12
  /**
@@ -1,10 +1,33 @@
1
- import Meta from '../meta.js'
2
- import {
3
- PrivateVotingState,
4
- VoteResult,
5
- VoteView,
6
- VotingState
7
- } from './types.js'
1
+ import Meta, { MetaState } from '../meta.js'
2
+
3
+ export interface VotingState extends MetaState {
4
+ votes: {
5
+ [id: string]: Vote
6
+ }
7
+ votingDisabled: boolean
8
+ votingDuration: number
9
+ }
10
+
11
+ export interface PrivateVotingState extends VotingState {
12
+ voters: address[]
13
+ }
14
+
15
+ export type VoteResult = 0 | 0.5 | 1
16
+
17
+ export type Vote = {
18
+ title: string
19
+ method: string
20
+ args: any[]
21
+ description: string
22
+ endTime: EpochTimeStamp
23
+ results?: { [address: string]: VoteResult }
24
+ finished?: boolean
25
+ enoughVotes?: boolean
26
+ }
27
+
28
+ export interface VoteView extends Vote {
29
+ id: string
30
+ }
8
31
 
9
32
  export default class PrivateVoting extends Meta {
10
33
  #voters: PrivateVotingState['voters']
@@ -1,5 +1,29 @@
1
- import Meta from '../meta.js'
2
- import { VotingState, VoteResult } from './types.js'
1
+ import Meta, { MetaState } from '../meta.js'
2
+
3
+ export interface VotingState extends MetaState {
4
+ votes: {
5
+ [id: string]: Vote
6
+ }
7
+ votingDisabled: boolean
8
+ votingDuration: number
9
+ }
10
+
11
+ export type VoteResult = 0 | 0.5 | 1
12
+
13
+ export type Vote = {
14
+ title: string
15
+ method: string
16
+ args: any[]
17
+ description: string
18
+ endTime: EpochTimeStamp
19
+ results?: { [address: string]: VoteResult }
20
+ finished?: boolean
21
+ enoughVotes?: boolean
22
+ }
23
+
24
+ export interface VoteView extends Vote {
25
+ id: string
26
+ }
3
27
 
4
28
  /**
5
29
  * allows everybody that has a balance greater or equal to tokenAmountToReceive to vote
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
- }