godprotocol 1.0.841 → 1.0.842
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/Index.js +15 -17
- package/Loader_sequence/main.js +447 -292
- package/Loader_sequence/repository.js +27 -43
- package/Objects/Account.js +262 -237
- package/Objects/Block.js +78 -76
- package/Objects/Blockweb.js +36 -40
- package/Objects/Chain.js +164 -157
- package/Objects/Explorer.js +36 -39
- package/Objects/Filesystem.js +99 -82
- package/Objects/Frame.js +43 -48
- package/Objects/Manager.js +115 -108
- package/Objects/Opcodes.js +44 -44
- package/Objects/Oracle.js +93 -129
- package/Objects/Virtual_machine.js +145 -145
- package/framer.js +42 -35
- package/opcodes/add.js +9 -25
- package/opcodes/indices.js +15 -14
- package/opcodes/jmp.js +7 -12
- package/opcodes/std.js +7 -13
- package/opcodes.js +41 -58
- package/package.json +2 -3
- package/utils/create_server.js +71 -106
- package/utils/functions.js +31 -43
- package/utils/hash.js +10 -11
- package/utils/privacy.js +10 -15
- package/utils/services.js +32 -33
|
@@ -1,49 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
class Repository {
|
|
2
|
+
constructor(main) {
|
|
3
|
+
this.main = main;
|
|
4
|
+
this.oracle = this.main.account.manager.oracle;
|
|
5
|
+
this.gds = this.oracle.gds;
|
|
6
|
+
this.programs = this.gds.folder("programs");
|
|
7
|
+
this.codes = this.gds.folder("codes");
|
|
8
|
+
}
|
|
2
9
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
|
-
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
11
|
-
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
12
|
-
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
13
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
14
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
15
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
16
|
-
var Repository = /*#__PURE__*/_createClass(function Repository(main) {
|
|
17
|
-
var _this = this;
|
|
18
|
-
_classCallCheck(this, Repository);
|
|
19
|
-
_defineProperty(this, "add_program", function (config) {
|
|
20
|
-
var codes = config.codes.filter(function (line) {
|
|
21
|
-
return !!line.trim();
|
|
22
|
-
});
|
|
23
|
-
var code_hash = _this.oracle.hash(codes);
|
|
24
|
-
var code_exist = _this.codes.readone({
|
|
25
|
-
hash: code_hash
|
|
26
|
-
});
|
|
27
|
-
var code = _this.codes.write({
|
|
10
|
+
add_program = (config) => {
|
|
11
|
+
let codes = config.codes.filter((line) => !!line.trim());
|
|
12
|
+
let code_hash = this.oracle.hash(codes);
|
|
13
|
+
let code_exist = this.codes.readone({ hash: code_hash });
|
|
14
|
+
|
|
15
|
+
let code = this.codes.write({
|
|
28
16
|
body: codes,
|
|
29
17
|
hash: code_hash,
|
|
30
|
-
_id: code_exist && code_exist._id
|
|
18
|
+
_id: code_exist && code_exist._id,
|
|
31
19
|
});
|
|
32
20
|
config.codes = code._id;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
21
|
+
|
|
22
|
+
let program_hash = this.oracle.hash(JSON.stringify(config));
|
|
23
|
+
let program_exist = this.programs.readone({ hash: program_hash });
|
|
24
|
+
|
|
25
|
+
this.programs.write({
|
|
26
|
+
...config,
|
|
38
27
|
hash: program_hash,
|
|
39
|
-
_id: program_exist && program_exist._id
|
|
40
|
-
})
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
this.programs = this.gds.folder("programs");
|
|
46
|
-
this.codes = this.gds.folder("codes");
|
|
47
|
-
});
|
|
48
|
-
var _default = Repository;
|
|
49
|
-
exports["default"] = _default;
|
|
28
|
+
_id: program_exist && program_exist._id,
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default Repository;
|
package/Objects/Account.js
CHANGED
|
@@ -1,257 +1,282 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
handlers
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
1
|
+
import Loader_sequence from "../Loader_sequence/main";
|
|
2
|
+
import validate_signature from "../utils/privacy";
|
|
3
|
+
import { post_request } from "../utils/services";
|
|
4
|
+
import Filesystem from "./Filesystem";
|
|
5
|
+
import Virtual_machine from "./Virtual_machine";
|
|
6
|
+
|
|
7
|
+
class Account extends Filesystem {
|
|
8
|
+
constructor(name, meta = {}) {
|
|
9
|
+
super();
|
|
10
|
+
|
|
11
|
+
meta = meta || {};
|
|
12
|
+
|
|
13
|
+
this.name = name;
|
|
14
|
+
this.private = meta.private;
|
|
15
|
+
this.manager = meta.manager;
|
|
16
|
+
this.account = this;
|
|
17
|
+
this.stdin = new Array();
|
|
18
|
+
this.stdout = new Array();
|
|
19
|
+
|
|
20
|
+
if (!this.manager) throw new Error("Manager instance missing.");
|
|
21
|
+
|
|
22
|
+
this.name_hash();
|
|
23
|
+
this.physical_address = `${this.base_address}/${this.name}`;
|
|
24
|
+
this.set_paths(this);
|
|
25
|
+
|
|
26
|
+
this.assembler = new Loader_sequence(this);
|
|
27
|
+
|
|
28
|
+
this.chain = this.account_chain(this);
|
|
29
|
+
this.vm = new Virtual_machine(this.chain);
|
|
30
|
+
|
|
31
|
+
this.mine_buffer = {};
|
|
32
|
+
this.privileges = new Object();
|
|
33
|
+
|
|
34
|
+
this.events = new Object();
|
|
35
|
+
|
|
36
|
+
console.log(`Account Instance: ${this.name}`);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
on = (event, handler) => {
|
|
40
|
+
let handlers = this.events[event];
|
|
41
|
+
if (!handlers) {
|
|
42
|
+
handlers = new Array();
|
|
43
|
+
this.events[event] = handlers;
|
|
44
|
+
}
|
|
45
|
+
handlers.push(handler);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
emit = (event, data) => {
|
|
49
|
+
let handlers = this.events[event];
|
|
50
|
+
Array.isArray(handlers) &&
|
|
51
|
+
handlers.map((handle) => this.run_callback(handle, data));
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
propagate = (data, endpoint) => {
|
|
55
|
+
if (data.is_propagated) return;
|
|
56
|
+
|
|
57
|
+
let servers = this.privileges[endpoint];
|
|
58
|
+
|
|
59
|
+
if (data.exclusive) {
|
|
60
|
+
if (typeof data.exclusive === "boolean") return;
|
|
61
|
+
else if (Array.isArray(data.exclusive)) {
|
|
62
|
+
servers =
|
|
63
|
+
servers &&
|
|
64
|
+
servers.filter((serv) => {
|
|
57
65
|
return data.exclusive.includes(serv.domain);
|
|
58
66
|
});
|
|
59
|
-
}
|
|
60
67
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
data.is_propagated = true;
|
|
71
|
+
data = JSON.stringify(data);
|
|
72
|
+
|
|
73
|
+
if (servers && servers.length) {
|
|
74
|
+
servers.map((serv) => {
|
|
75
|
+
post_request({
|
|
76
|
+
options: {
|
|
77
|
+
...serv,
|
|
78
|
+
path: `/${endpoint}`,
|
|
79
|
+
},
|
|
80
|
+
data,
|
|
71
81
|
});
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
_defineProperty(_assertThisInitialized(_this), "add_server", function (_ref) {
|
|
75
|
-
var server = _ref.server,
|
|
76
|
-
privileges = _ref.privileges;
|
|
77
|
-
if (!Array.isArray(privileges) && privileges) privileges = ["load", "parse", "run", "create_account"];
|
|
78
|
-
privileges.map(function (privilege) {
|
|
79
|
-
var priv = _this.privileges[privilege];
|
|
80
|
-
if (!priv) {
|
|
81
|
-
priv = [];
|
|
82
|
-
_this.privileges[privilege] = priv;
|
|
83
|
-
}
|
|
84
|
-
if (!priv.find(function (serv) {
|
|
85
|
-
return serv.domain === server.domain;
|
|
86
|
-
})) priv.push(server);
|
|
87
82
|
});
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
_defineProperty(_assertThisInitialized(_this), "buff", function (block, pid) {
|
|
101
|
-
var buffer = _this.mine_buffer[pid];
|
|
102
|
-
if (!buffer) return;
|
|
103
|
-
buffer.blocks.push(block.stringify());
|
|
104
|
-
});
|
|
105
|
-
_defineProperty(_assertThisInitialized(_this), "flush_buffer", function (pid, payload) {
|
|
106
|
-
var buff = _this.mine_buffer[pid];
|
|
107
|
-
if (!buff) return;
|
|
108
|
-
buff.callback && _this.run_callback(buff.callback, payload || buff.blocks);
|
|
109
|
-
delete _this.mine_buffer[pid];
|
|
110
|
-
});
|
|
111
|
-
_defineProperty(_assertThisInitialized(_this), "load", function (payload) {
|
|
112
|
-
var program = payload.program,
|
|
113
|
-
callback = payload.callback;
|
|
114
|
-
var instructions = program.instructions,
|
|
115
|
-
assemble = program.assemble;
|
|
116
|
-
_this.propagate(payload, "load");
|
|
117
|
-
if (assemble) {
|
|
118
|
-
_this.assembler.spawn().run(instructions, {
|
|
119
|
-
cb: callback
|
|
120
|
-
});
|
|
121
|
-
} else {
|
|
122
|
-
var pid = _this.manage_buffer(callback);
|
|
123
|
-
_this.manager.push({
|
|
124
|
-
sequence: instructions,
|
|
125
|
-
account: _assertThisInitialized(_this),
|
|
126
|
-
pid: pid
|
|
127
|
-
});
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
add_server = ({ server, privileges }) => {
|
|
87
|
+
if (!Array.isArray(privileges) && privileges)
|
|
88
|
+
privileges = ["load", "parse", "run", "create_account"];
|
|
89
|
+
|
|
90
|
+
privileges.map((privilege) => {
|
|
91
|
+
let priv = this.privileges[privilege];
|
|
92
|
+
if (!priv) {
|
|
93
|
+
priv = [];
|
|
94
|
+
this.privileges[privilege] = priv;
|
|
128
95
|
}
|
|
96
|
+
if (!priv.find((serv) => serv.domain === server.domain))
|
|
97
|
+
priv.push(server);
|
|
129
98
|
});
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
get_account = (name) => {
|
|
102
|
+
return this.manager.get_account(name) || this;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
manage_buffer = (callback) => {
|
|
106
|
+
let call_session = `${Date.now()}-${Math.random()}`;
|
|
107
|
+
this.mine_buffer[call_session] = { blocks: [], callback };
|
|
108
|
+
|
|
109
|
+
return call_session;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
buff = (block, pid) => {
|
|
113
|
+
let buffer = this.mine_buffer[pid];
|
|
114
|
+
if (!buffer) return;
|
|
115
|
+
|
|
116
|
+
buffer.blocks.push(block.stringify());
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
flush_buffer = (pid, payload) => {
|
|
120
|
+
let buff = this.mine_buffer[pid];
|
|
121
|
+
if (!buff) return;
|
|
122
|
+
|
|
123
|
+
buff.callback && this.run_callback(buff.callback, payload || buff.blocks);
|
|
124
|
+
delete this.mine_buffer[pid];
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
load = (payload) => {
|
|
128
|
+
let { program, callback } = payload;
|
|
129
|
+
let { instructions, assemble } = program;
|
|
130
|
+
|
|
131
|
+
this.propagate(payload, "load");
|
|
132
|
+
|
|
133
|
+
if (assemble) {
|
|
134
|
+
this.assembler.spawn().run(instructions, { cb: callback });
|
|
135
|
+
} else {
|
|
136
|
+
let pid = this.manage_buffer(callback);
|
|
137
|
+
|
|
138
|
+
this.manager.push({ sequence: instructions, account: this, pid });
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
parse = (program) => {
|
|
143
|
+
let { payload, callback, signature } = program;
|
|
144
|
+
|
|
145
|
+
this.propagate(program, "parse");
|
|
146
|
+
|
|
147
|
+
this.manager.oracle.fetch({ ...payload, signature }, (result) =>
|
|
148
|
+
this.run_callback(callback, result)
|
|
149
|
+
);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
run = (request) => {
|
|
153
|
+
let { payload, callback } = request;
|
|
154
|
+
|
|
155
|
+
let { physical_address, query, history } = payload;
|
|
156
|
+
|
|
157
|
+
history = Math.abs(Number(history)) || 0;
|
|
158
|
+
|
|
159
|
+
this.propagate(request, "run");
|
|
160
|
+
|
|
161
|
+
let pid = this.manage_buffer(callback);
|
|
162
|
+
|
|
163
|
+
let context = physical_address
|
|
164
|
+
? this.manager.web.get(physical_address)
|
|
165
|
+
: this.vm.get_context();
|
|
166
|
+
|
|
167
|
+
if (!context) {
|
|
168
|
+
if (physical_address)
|
|
169
|
+
context = this.manager.web.split_set(physical_address);
|
|
170
|
+
else return this.flush_buffer(pid);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
let blk = query ? context.explore(query) : context.get_latest_block();
|
|
174
|
+
|
|
175
|
+
if (!query) {
|
|
176
|
+
let index = context.height;
|
|
177
|
+
index -= 2;
|
|
178
|
+
|
|
179
|
+
if (blk && blk.metadata.program) {
|
|
180
|
+
if (history) {
|
|
181
|
+
history--;
|
|
182
|
+
blk = null;
|
|
183
|
+
}
|
|
153
184
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
185
|
+
|
|
186
|
+
while (!blk && index >= 0) {
|
|
187
|
+
index--;
|
|
188
|
+
blk = context.get_block(index);
|
|
189
|
+
|
|
158
190
|
if (blk && blk.metadata.program) {
|
|
159
191
|
if (history) {
|
|
160
192
|
history--;
|
|
161
193
|
blk = null;
|
|
162
194
|
}
|
|
163
195
|
}
|
|
164
|
-
while (!blk && index >= 0) {
|
|
165
|
-
index--;
|
|
166
|
-
blk = context.get_block(index);
|
|
167
|
-
if (blk && blk.metadata.program) {
|
|
168
|
-
if (history) {
|
|
169
|
-
history--;
|
|
170
|
-
blk = null;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
196
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (blk && blk.metadata && blk.metadata.program) {
|
|
200
|
+
let program = this.read(blk.metadata.program);
|
|
201
|
+
|
|
202
|
+
this.vm.contexts.push(context);
|
|
203
|
+
program.push("pop");
|
|
204
|
+
|
|
205
|
+
Array.isArray(program) &&
|
|
206
|
+
program.length &&
|
|
207
|
+
this.manager.push({
|
|
180
208
|
sequence: program,
|
|
181
|
-
account:
|
|
182
|
-
pid
|
|
209
|
+
account: this,
|
|
210
|
+
pid,
|
|
183
211
|
});
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
212
|
+
} else this.flush_buffer(pid);
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
run_callback = (callback, payload) => {
|
|
216
|
+
setTimeout(() => {
|
|
217
|
+
if (!callback) return;
|
|
218
|
+
|
|
219
|
+
if (typeof callback === "function") return callback(payload);
|
|
220
|
+
|
|
221
|
+
callback.payload &&
|
|
222
|
+
callback.payload.physical_address &&
|
|
223
|
+
this.vm.stdin(payload, () => this.run(callback));
|
|
224
|
+
}, 0);
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
flush_stdout = (block) => {
|
|
228
|
+
if (
|
|
229
|
+
block.chain.physical_address === `${this.physical_address}/Opcodes/stdout`
|
|
230
|
+
)
|
|
231
|
+
return;
|
|
232
|
+
|
|
233
|
+
for (let s = 0; s < this.stdout.length; s++) {
|
|
234
|
+
let out = this.stdout[s];
|
|
235
|
+
if (out.pid === this.vm.track.pid) {
|
|
236
|
+
block.metadata.stdout.push(out.data);
|
|
237
|
+
this.stdout[s] = null;
|
|
203
238
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
239
|
+
}
|
|
240
|
+
this.stdout = this.stdout.filter((out) => !!out);
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
validate = (payload, signature, callback) => {
|
|
244
|
+
if (!this.private) return true;
|
|
245
|
+
|
|
246
|
+
let valid = validate_signature(
|
|
247
|
+
this.name,
|
|
248
|
+
JSON.stringify(payload),
|
|
249
|
+
signature
|
|
250
|
+
);
|
|
251
|
+
if (!valid && callback)
|
|
252
|
+
this.run_callback(callback, {
|
|
253
|
+
private: this.private,
|
|
213
254
|
error: true,
|
|
214
|
-
error_message: "Invalid signature"
|
|
255
|
+
error_message: "Invalid signature",
|
|
215
256
|
});
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
_this.name_hash();
|
|
243
|
-
_this.physical_address = "".concat(_this.base_address, "/").concat(_this.name);
|
|
244
|
-
_this.set_paths(_assertThisInitialized(_this));
|
|
245
|
-
_this.assembler = new _main["default"](_assertThisInitialized(_this));
|
|
246
|
-
_this.chain = _this.account_chain(_assertThisInitialized(_this));
|
|
247
|
-
_this.vm = new _Virtual_machine["default"](_this.chain);
|
|
248
|
-
_this.mine_buffer = {};
|
|
249
|
-
_this.privileges = new Object();
|
|
250
|
-
_this.events = new Object();
|
|
251
|
-
console.log("Account Instance: ".concat(_this.name));
|
|
252
|
-
return _this;
|
|
253
|
-
}
|
|
254
|
-
return _createClass(Account);
|
|
255
|
-
}(_Filesystem2["default"]);
|
|
256
|
-
var _default = Account;
|
|
257
|
-
exports["default"] = _default;
|
|
257
|
+
|
|
258
|
+
return valid;
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
stringify = (str) => {
|
|
262
|
+
let obj = {};
|
|
263
|
+
|
|
264
|
+
obj.name = this.name;
|
|
265
|
+
obj.hash = this.hash;
|
|
266
|
+
obj.path = this.path;
|
|
267
|
+
obj.private = this.private;
|
|
268
|
+
obj.chain = this.chain.stringify();
|
|
269
|
+
obj.physical_address = this.physical_address;
|
|
270
|
+
|
|
271
|
+
return str ? JSON.stringify(obj) : obj;
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
create_account = (payload) => {
|
|
275
|
+
this.propagate(payload, "create_account");
|
|
276
|
+
let { name, meta } = payload;
|
|
277
|
+
|
|
278
|
+
return this.manager.add_account(name, meta);
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export default Account;
|