@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.
@@ -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
@@ -1,4 +1,4 @@
1
- import { MetaState } from './types.js';
1
+ import { MetaState } from './interfaces.js';
2
2
  export default class Meta {
3
3
  #private;
4
4
  constructor(state?: MetaState);
@@ -1,5 +1,5 @@
1
1
  import Meta from './meta.js';
2
- import { RolesState } from './types.js';
2
+ import { RolesState } from './interfaces.js';
3
3
  export default class Roles extends Meta {
4
4
  #private;
5
5
  constructor(state?: RolesState);
@@ -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 './voting/types.js';
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("./voting/types.js").Vote;
22
+ [id: string]: import("./interfaces.js").Vote;
23
23
  };
24
24
  votingDisabled: boolean;
25
25
  votingDuration: number;
@@ -1,5 +1,5 @@
1
1
  import Roles from './roles.js';
2
- import { TokenState } from './types.js';
2
+ import { TokenState } from './interfaces.js';
3
3
  export default class Token extends Roles {
4
4
  #private;
5
5
  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,10 @@
1
1
  import Meta from '../meta.js';
2
- import { PrivateVotingState, VoteResult, VoteView } from './types.js';
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("./types.js").Vote;
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 './types.js';
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("./types.js").Vote;
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("./types.js").Vote;
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.1",
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
- "./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
@@ -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
- 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,4 @@
1
- import { MetaState } from './types.js'
1
+ import { MetaState } from './interfaces.js'
2
2
 
3
3
  export default class Meta {
4
4
  #creator: address
package/src/roles.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Meta from './meta.js'
2
- import { RolesState } from './types.js'
2
+ import { RolesState } from './interfaces.js'
3
3
 
4
4
  export default class Roles extends Meta {
5
5
  /**
@@ -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 './voting/types.js'
3
+ import { VotingState } from './interfaces.js'
4
4
 
5
5
  export interface TokenReceiverState extends VotingState {
6
6
  tokenToReceive: address
package/src/token.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { restoreApprovals, restoreBalances } from './helpers.js'
2
2
  import Roles from './roles.js'
3
- import { TokenState } from './types.js'
3
+ import { TokenState } from './interfaces.js'
4
4
 
5
5
  export default class Token extends Roles {
6
6
  /**
@@ -4,7 +4,7 @@ import {
4
4
  VoteResult,
5
5
  VoteView,
6
6
  VotingState
7
- } from './types.js'
7
+ } from '../interfaces.js'
8
8
 
9
9
  export default class PrivateVoting extends Meta {
10
10
  #voters: PrivateVotingState['voters']
@@ -1,5 +1,5 @@
1
1
  import Meta from '../meta.js'
2
- import { VotingState, VoteResult } from './types.js'
2
+ import { VotingState, VoteResult } from '../interfaces.js'
3
3
 
4
4
  /**
5
5
  * 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
- }