1 | 'use strict'
|
2 | const CONFIG = require('./config');
|
3 | const TYPE = require('./type');
|
4 | const CODE = require('./code');
|
5 |
|
6 | const ABI = require('./core/abi');
|
7 | const Code = require('./model/code');
|
8 | const Method = require("./model/method");
|
9 | const Contract = require('./model/contract');
|
10 | const Request = require('./model/request');
|
11 | const Parameter = require('./model/parameter');
|
12 | const SignedTransaction = require('./model/signedTransaction');
|
13 | const SignedRequest = require('./model/signedRequest');
|
14 | const SignedData = require('./model/signedData');
|
15 |
|
16 | const ArithmeticOperator = require('./smartMethod/arithmeticOperator');
|
17 | const BasicOperator = require('./smartMethod/basicOperator');
|
18 | const CastOperator = require('./smartMethod/castOperator');
|
19 | const ChainOperator = require('./smartMethod/chainOperator');
|
20 | const ComparisonOperator = require('./smartMethod/comparisonOperator');
|
21 | const ReadOperator = require('./smartMethod/readOperator');
|
22 | const UtilOperator = require('./smartMethod/utilOperator');
|
23 | const WriteOperator = require('./smartMethod/writeOperator');
|
24 | const EthereumOperator = require('./smartMethod/ethereumOperator');
|
25 |
|
26 | const Factory = require('./rpc/factory');
|
27 | const Sender = require('./rpc/sender');
|
28 | const Node = require('./rpc/node');
|
29 |
|
30 | const Enc = require('./util/enc');
|
31 | const Clock = require('./util/clock');
|
32 | const Hasher = require('./util/hasher');
|
33 | const Signer = require('./util/signer');
|
34 | const Account = require('./util/account');
|
35 | const Math = require('./util/math');
|
36 | const Etc = require('./util/etc');
|
37 | const Common = require("./core/common");
|
38 | const {network} = require("locutus/php");
|
39 |
|
40 | module.exports = class Saseul {
|
41 |
|
42 | |
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 | constructor(option = {
|
54 | network_name: null,
|
55 | system_nonce: null,
|
56 | default_peers: [],
|
57 | genesis_address: null,
|
58 | manager_addresses: [],
|
59 | abi: null
|
60 | }) {
|
61 | try {
|
62 | if(!!option.abi && typeof option.abi !== 'object') throw 'abi must be an object.';
|
63 | if(!!option.default_peers && !Array.isArray(option.default_peers)) throw 'default_peers must be an array.';
|
64 | if(!!option.abi) this.Core.ABI = new ABI(option.abi);
|
65 | if(!!option.network_name) this.CONFIG.NETWORK = option.network_name;
|
66 | if(!!option.system_nonce) this.CONFIG._system_nonce = option.system_nonce;
|
67 | if(!!option.genesis_address) this.CONFIG._genesis_address = option.genesis_address;
|
68 | if(option.default_peers && option.default_peers?.length > 0) this.Rpc.Node = new Node(option.default_peers);
|
69 | if(option.manager_addresses && option.manager_addresses?.length > 0) this.CONFIG._manager_addresses = option.manager_addresses;
|
70 | } catch (e) {
|
71 | throw e;
|
72 | }
|
73 | }
|
74 |
|
75 | CONFIG = CONFIG;
|
76 | TYPE = TYPE;
|
77 | CODE = CODE;
|
78 |
|
79 | Core = {
|
80 | ABI: new ABI(),
|
81 | Common: Common
|
82 | }
|
83 | Model = {
|
84 | Code: Code,
|
85 | Method: Method,
|
86 | Contract: Contract,
|
87 | Request: Request,
|
88 | Parameter: Parameter,
|
89 | SignedData: SignedData,
|
90 | SignedRequest: SignedRequest,
|
91 | SignedTransaction: SignedTransaction,
|
92 | }
|
93 | SmartMethod = {
|
94 | ArithmeticOperator: ArithmeticOperator,
|
95 | BasicOperator: BasicOperator,
|
96 | CastOperator: CastOperator,
|
97 | ChainOperator: ChainOperator,
|
98 | ComparisonOperator: ComparisonOperator,
|
99 | ReadOperator: ReadOperator,
|
100 | UtilOperator: UtilOperator,
|
101 | WriteOperator: WriteOperator,
|
102 | EthereumOperator: EthereumOperator,
|
103 | }
|
104 | Rpc = {
|
105 | Factory: Factory,
|
106 | Sender: Sender,
|
107 | Node: Node,
|
108 | Code: Code,
|
109 | }
|
110 | Util = {
|
111 | Enc: Enc,
|
112 | Clock: Clock,
|
113 | Hasher: Hasher,
|
114 | Signer: Signer,
|
115 | Account: Account,
|
116 | Math: Math,
|
117 | Etc: Etc,
|
118 | }
|
119 | } |
\ | No newline at end of file |