@tech-bureau/mijin-catapult-tools 0.0.6

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.
Files changed (60) hide show
  1. package/.env/dev.ts +23 -0
  2. package/.env/prod.ts +23 -0
  3. package/.github/workflows/main.yml +37 -0
  4. package/.prettierrc.json +5 -0
  5. package/LICENSE +21 -0
  6. package/README.md +646 -0
  7. package/bin/mijin-catapult-tools.js +3 -0
  8. package/dist/main.js +2 -0
  9. package/jest.config.js +8 -0
  10. package/package.json +55 -0
  11. package/src/__tests__/service/AccountServices.spec.ts +63 -0
  12. package/src/__tests__/service/CertificateServices.spec.ts +20 -0
  13. package/src/__tests__/service/MessageServices.spec.ts +48 -0
  14. package/src/__tests__/service/MosaicServices.spec.ts +61 -0
  15. package/src/cli.ts +18 -0
  16. package/src/commands/account/account.ts +16 -0
  17. package/src/commands/account/accountGenerate.ts +19 -0
  18. package/src/commands/account/accountInfo.ts +16 -0
  19. package/src/commands/mosaic/mosaic.ts +16 -0
  20. package/src/commands/mosaic/mosaicCreate.ts +20 -0
  21. package/src/commands/mosaic/mosaicInfo.ts +13 -0
  22. package/src/commands/transaction/transaction.ts +18 -0
  23. package/src/commands/transaction/transactionStatus.ts +13 -0
  24. package/src/commands/transaction/transfer.ts +16 -0
  25. package/src/commands/votingkey/votingkey.ts +18 -0
  26. package/src/commands/votingkey/votingkeyCreate.ts +15 -0
  27. package/src/commands/votingkey/votingkeyInfo.ts +13 -0
  28. package/src/commands/votingkey/votingkeyUpdate.ts +15 -0
  29. package/src/infrastructure/account/accountGenerate.ts +183 -0
  30. package/src/infrastructure/account/accountInfo.ts +154 -0
  31. package/src/infrastructure/mosaic/mosaicCreate.ts +149 -0
  32. package/src/infrastructure/mosaic/mosaicInfo.ts +40 -0
  33. package/src/infrastructure/transaction/transactionStatus.ts +57 -0
  34. package/src/infrastructure/transaction/transfer.ts +168 -0
  35. package/src/infrastructure/voting/votingCreate.ts +88 -0
  36. package/src/infrastructure/voting/votingInfo.ts +44 -0
  37. package/src/infrastructure/voting/votingUpdate.ts +94 -0
  38. package/src/service/AccountServices.ts +68 -0
  39. package/src/service/CertificateServices.ts +165 -0
  40. package/src/service/CmdServices.ts +17 -0
  41. package/src/service/Logger.ts +26 -0
  42. package/src/service/MessageServices.ts +17 -0
  43. package/src/service/MosaicServices.ts +62 -0
  44. package/src/service/RepositoryFactory.ts +107 -0
  45. package/src/service/TransactionServices.ts +268 -0
  46. package/src/service/VotingServices.ts +184 -0
  47. package/src/types/AccountInfo.ts +19 -0
  48. package/src/types/AccountType.ts +9 -0
  49. package/src/types/ConfigFile.ts +24 -0
  50. package/src/types/Environment.ts +5 -0
  51. package/src/types/IAccountOption.ts +16 -0
  52. package/src/types/ILinkOption.ts +3 -0
  53. package/src/types/IMosaicOption.ts +18 -0
  54. package/src/types/ITransactionOption.ts +5 -0
  55. package/src/types/ITransferOption.ts +9 -0
  56. package/src/types/IVotingOption.ts +21 -0
  57. package/src/types/index.ts +9 -0
  58. package/src/utils.ts +38 -0
  59. package/tsconfig.json +24 -0
  60. package/webpack.config.js +24 -0
@@ -0,0 +1,18 @@
1
+ export interface IMosaicCreateOption {
2
+ owner: string
3
+ url?: string
4
+ supply: string
5
+ divisibility: string
6
+ supplymutable: boolean
7
+ transferable: boolean
8
+ restrictable: boolean
9
+ revokable: boolean
10
+ readfile?: string
11
+ privatekey?: string
12
+ }
13
+
14
+ export interface IMosaicInfoOption {
15
+ url?: string
16
+ readfile?: string
17
+ mosaicrawId?: string
18
+ }
@@ -0,0 +1,5 @@
1
+ export interface ITransactionStatusOption {
2
+ url?: string
3
+ transactionhash: string
4
+ readfile?: string
5
+ }
@@ -0,0 +1,9 @@
1
+ export interface ITransferOption {
2
+ url?: string
3
+ from?: string
4
+ dest?: string
5
+ mosaic: string
6
+ amount: string
7
+ readfile?: string
8
+ message?: string
9
+ }
@@ -0,0 +1,21 @@
1
+ export interface IVotingCreateOption {
2
+ url?: string
3
+ readfile?: string
4
+ startepoch: string
5
+ endepoch: string
6
+ savedir: string
7
+ }
8
+
9
+ export interface IVotingInfoOption {
10
+ url?: string
11
+ readfile?: string
12
+ savedir: string
13
+ }
14
+
15
+ export interface IVotingUpdateOption {
16
+ url?: string
17
+ readfile?: string
18
+ startepoch: string
19
+ endepoch: string
20
+ savedir: string
21
+ }
@@ -0,0 +1,9 @@
1
+ export * from './AccountType'
2
+ export * from './AccountInfo'
3
+ export * from './IAccountOption'
4
+ export * from './ITransactionOption'
5
+ export * from './ITransferOption'
6
+ export * from './ILinkOption'
7
+ export * from './ConfigFile'
8
+ export * from './IVotingOption'
9
+ export * from './IMosaicOption'
package/src/utils.ts ADDED
@@ -0,0 +1,38 @@
1
+ import { promises as fs } from 'fs'
2
+ import { ConfigFile } from './types'
3
+
4
+ export const readConfig = async (filename: string): Promise<ConfigFile> => {
5
+ return JSON.parse(await fs.readFile(filename, 'utf-8'))
6
+ }
7
+
8
+ export const writeConfig = async (filename: string, data: string) => {
9
+ return await fs.writeFile(filename, data, 'utf-8')
10
+ }
11
+
12
+ export const writeFile = async (filename: string, data: string | Uint8Array) => {
13
+ return await fs.writeFile(filename, data, 'utf-8')
14
+ }
15
+
16
+ export const readFile = async (filename: string) => {
17
+ return await fs.readFile(filename, 'utf-8')
18
+ }
19
+
20
+ export const checkFile = async (filename: string) => {
21
+ try {
22
+ return !!(await fs.lstat(filename))
23
+ } catch (e) {
24
+ return false
25
+ }
26
+ }
27
+
28
+ export const checkDir = async (filepath: string) => {
29
+ try {
30
+ return !!(await fs.lstat(filepath))
31
+ } catch (e) {
32
+ return false
33
+ }
34
+ }
35
+
36
+ export const createDir = async (dirpath: string) => {
37
+ return await fs.mkdir(dirpath, { recursive: true })
38
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "compilerOptions": {
3
+ "allowSyntheticDefaultImports": true,
4
+ "target": "es2018",
5
+ "lib": ["dom", "es2018"],
6
+ "strict": true,
7
+ "skipLibCheck": true,
8
+ "declaration": true,
9
+ "declarationMap": true,
10
+ "pretty": true,
11
+ "newLine": "lf",
12
+ "sourceMap": true,
13
+ "paths": {
14
+ "userEnv": ["./.env/dev"]
15
+ },
16
+ "esModuleInterop": true,
17
+ "moduleResolution": "node",
18
+ "outDir": "./dist",
19
+ "rootDir": ".",
20
+ "typeRoots": ["node_modules/@types", "src/@types"]
21
+ },
22
+ "include": ["src/*", "src/__tests__/**/*.ts", "jest.config.js", "src/**/*.ts"],
23
+ "exclude": ["node_modules"]
24
+ }
@@ -0,0 +1,24 @@
1
+ const path = require('path');
2
+ const environment = process.env.NODE_ENV || 'dev';
3
+
4
+ module.exports = {
5
+ entry: './src/cli.ts',
6
+ target: 'node',
7
+ node: {
8
+ __dirname: false,
9
+ __filename: false
10
+ },
11
+ module: {
12
+ rules: [{
13
+ test: /\.ts$/,
14
+ use: ['ts-loader'],
15
+ exclude: /node_modules/
16
+ }]
17
+ },
18
+ resolve: {
19
+ extensions: ['.tsx', '.ts', '.js'],
20
+ alias: {
21
+ userEnv$: path.resolve(__dirname, `.env/${environment}.ts`),
22
+ },
23
+ }
24
+ };