godprotocol 1.1.0 → 1.1.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.
- package/Datatypes/arr.js +11 -0
- package/Datatypes/bool.js +11 -0
- package/Datatypes/callable.js +11 -0
- package/Datatypes/functions/storage.js +5 -0
- package/Datatypes/num.js +11 -0
- package/Datatypes/str.js +11 -0
- package/Datatypes/twa.js +11 -0
- package/Datatypes/voi.js +11 -0
- package/Index.js +36 -2
- package/Objects/Account.js +35 -322
- package/Objects/Block.js +7 -80
- package/Objects/Blockweb.js +19 -26
- package/Objects/Callable.js +40 -0
- package/Objects/Chain.js +20 -244
- package/Objects/GDS/Arena_classic/.config +1 -0
- package/Objects/GDS/Arena_classic/Accounts/lola/.config +1 -0
- package/Objects/Manager.js +28 -294
- package/Objects/Oracle.js +67 -84
- package/Objects/Repository.js +67 -0
- package/Objects/Trinity.js +24 -0
- package/Objects/Virtual_machine.js +16 -206
- package/callables/functions/assign.js +6 -0
- package/callables/functions/display.js +3 -0
- package/callables/register.js +22 -0
- package/package.json +24 -43
- package/utils/create_server.js +35 -88
- package/utils/functions.js +0 -70
- package/utils/server.cert +23 -0
- package/utils/server.key +28 -0
- package/utils/services.js +61 -21
- package/utils/vm_utils.js +53 -275
- package/Executables/callables.js +0 -131
- package/Executables/executables.js +0 -230
- package/Executables/functions/adminstrator/adm_register.js +0 -29
- package/Executables/functions/adminstrator/native_components.js +0 -10
- package/Executables/functions/adminstrator/query_selectors.js +0 -10
- package/Executables/functions/adminstrator/render.js +0 -24
- package/Executables/functions/array_register.js +0 -161
- package/Executables/functions/assign.js +0 -19
- package/Executables/functions/display.js +0 -55
- package/Executables/functions/folder.js +0 -95
- package/Executables/functions/folder_register.js +0 -87
- package/Executables/functions/importcheck.js +0 -13
- package/Executables/functions/indices.js +0 -56
- package/Executables/functions/len.js +0 -22
- package/Executables/functions/methods/array.js +0 -272
- package/Executables/functions/methods/string.js +0 -197
- package/Executables/functions/methods/twain.js +0 -148
- package/Executables/functions/op.js +0 -15
- package/Executables/functions/price_register.js +0 -30
- package/Executables/functions/pricing.js +0 -26
- package/Executables/functions/servers/account.js +0 -81
- package/Executables/functions/servers/account_register.js +0 -56
- package/Executables/functions/servers/block.js +0 -21
- package/Executables/functions/servers/block_register.js +0 -18
- package/Executables/functions/servers/chain.js +0 -42
- package/Executables/functions/servers/chain_register.js +0 -28
- package/Executables/functions/set_error_catch.js +0 -34
- package/Executables/functions/string_register.js +0 -130
- package/Executables/functions/twain_register.js +0 -56
- package/Executables/functions/typecast.js +0 -43
- package/Executables/functions/utils.js +0 -9
- package/Executables/stack.js +0 -53
- package/Loader_sequence/main.js +0 -805
- package/Loader_sequence/repository.js +0 -33
- package/Objects/Explorer.js +0 -40
- package/Objects/Fee.js +0 -33
- package/Objects/Filesystem.js +0 -216
- package/Objects/Frame.js +0 -54
- package/Objects/Opcodes.js +0 -87
- package/Objects/Protocol.js +0 -5
- package/Trinity.js +0 -20
- package/callables.js +0 -172
- package/framer.js +0 -124
- package/opcodes/add.js +0 -15
- package/opcodes/indices.js +0 -82
- package/opcodes/jmp.js +0 -16
- package/opcodes/std.js +0 -12
- package/opcodes.js +0 -96
- package/readme.md +0 -133
- package/starter_scripts/constants.seq +0 -11
- package/tsconfig.json +0 -8
- package/types/Account.d.ts +0 -73
- package/types/Block.d.ts +0 -22
- package/types/Blockweb.d.ts +0 -14
- package/types/Chain.d.ts +0 -35
- package/types/Explorer.d.ts +0 -9
- package/types/Filesystem.d.ts +0 -23
- package/types/Frame.d.ts +0 -14
- package/types/Manager.d.ts +0 -21
- package/types/Opcodes.d.ts +0 -11
- package/types/Oracle.d.ts +0 -17
- package/types/Virtual_machine.d.ts +0 -20
- package/types/index.d.ts +0 -4
- package/utils/hash.js +0 -13
- package/utils/logger.js +0 -79
- package/utils/privacy.js +0 -22
- package/utils/type_coersion.js +0 -3
package/framer.js
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import Frame from "./Objects/Frame";
|
|
2
|
-
|
|
3
|
-
let obj = {
|
|
4
|
-
Opcodes: {
|
|
5
|
-
add: null,
|
|
6
|
-
equal: null,
|
|
7
|
-
multiply: null,
|
|
8
|
-
subtract: null,
|
|
9
|
-
divide: null,
|
|
10
|
-
exp: null,
|
|
11
|
-
equal: null,
|
|
12
|
-
|
|
13
|
-
send: null,
|
|
14
|
-
readonly: null,
|
|
15
|
-
socket_send: null,
|
|
16
|
-
|
|
17
|
-
jmp: null,
|
|
18
|
-
|
|
19
|
-
stdout: null,
|
|
20
|
-
stdin: null,
|
|
21
|
-
|
|
22
|
-
run: null,
|
|
23
|
-
load: null,
|
|
24
|
-
parse: null,
|
|
25
|
-
create_account: null,
|
|
26
|
-
},
|
|
27
|
-
Datatypes: {
|
|
28
|
-
Number: null,
|
|
29
|
-
String: null,
|
|
30
|
-
Twain: null,
|
|
31
|
-
Array: null,
|
|
32
|
-
Void: null,
|
|
33
|
-
Boolean: null,
|
|
34
|
-
},
|
|
35
|
-
Objects: {
|
|
36
|
-
Blockchain: {
|
|
37
|
-
Chain: null,
|
|
38
|
-
Block: null,
|
|
39
|
-
},
|
|
40
|
-
Folder: {
|
|
41
|
-
active_file: null,
|
|
42
|
-
folder: null,
|
|
43
|
-
file: null,
|
|
44
|
-
},
|
|
45
|
-
File: {
|
|
46
|
-
row: null,
|
|
47
|
-
parse: null,
|
|
48
|
-
column: null,
|
|
49
|
-
write: null,
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
CONSTANTS:{
|
|
53
|
-
overload: {
|
|
54
|
-
__add__: {__type:'twain', value: {type:'string', static_value:'__add__'}},
|
|
55
|
-
__multiply__: {__type:'twain', value: {type:'string', static_value:'__multiply__'}},
|
|
56
|
-
__subtract__: {__type:'twain', value: {type:'string', static_value:'__subtract__'}},
|
|
57
|
-
__divide__: {__type:'twain', value: {type:'string', static_value:'__divide__'}},
|
|
58
|
-
__exp__: {__type:'twain', value: {type:'string', static_value:'__exp__'}},
|
|
59
|
-
__equal__: {__type:'twain', value: {type:'string', static_value:'__equal__'}},
|
|
60
|
-
// __not_equal__: {__type:'twain', value: {type:'string', static_value:'__not_equal__'}},
|
|
61
|
-
__lt__: {__type:'twain', value: {type:'string', static_value:'__lt__'}},
|
|
62
|
-
__lte__: {__type:'twain', value: {type:'string', static_value:'__lte__'}},
|
|
63
|
-
__gt__: {__type:'twain', value: {type:'string', static_value:'__gt__'}},
|
|
64
|
-
__gte__: {__type:'twain', value: {type:'string', static_value:'__gte__'}},
|
|
65
|
-
},
|
|
66
|
-
types: {
|
|
67
|
-
instance: {__type: 'twain', value: {type:'string', __address__:`Accounts/initiator/CONSTANTS/types/instance`, static_value: 'instance'}},
|
|
68
|
-
function: {__type:'string', value: {type:'string', __address__:`Accounts/initiator/CONSTANTS/types/function`, static_value: 'function'}},
|
|
69
|
-
boolean: {__type:'string',value: {type:'string', __address__:`Accounts/initiator/CONSTANTS/types/boolean`, static_value: 'boolean'}},
|
|
70
|
-
array: {__type:'string',value: {type:'string', __address__:`Accounts/initiator/CONSTANTS/types/array`, static_value: 'array'}},
|
|
71
|
-
twain: {__type:'string',value: {type:'string', __address__:`Accounts/initiator/CONSTANTS/types/twain`, static_value: 'twain'}},
|
|
72
|
-
number: { __type:'string', value: {type:'string', __address__:`Accounts/initiator/CONSTANTS/types/number`, static_value: 'number'}},
|
|
73
|
-
string: {__type:'string', value: {type:'string', __address__:`Accounts/initiator/CONSTANTS/types/string`, static_value: 'string'}},
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
const framer = (initiator, cb) => {
|
|
79
|
-
let frame = new Frame(obj);
|
|
80
|
-
frame.account = initiator;
|
|
81
|
-
let start = Date.now();
|
|
82
|
-
|
|
83
|
-
let callback = (blks) => {
|
|
84
|
-
console.log(
|
|
85
|
-
`Account:${initiator.name} is ready in ${Date.now() - start}ms.`
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
initiator.initiated = true
|
|
89
|
-
|
|
90
|
-
cb&&cb(blks)
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/* Quick due diligence */
|
|
94
|
-
let oracle = initiator.manager.oracle,
|
|
95
|
-
obj_hash = oracle.hash(obj),
|
|
96
|
-
globals = oracle.gds.folder('globals'),
|
|
97
|
-
quick_hashes = globals.readone({title:'quick_hashes'});
|
|
98
|
-
|
|
99
|
-
if(!quick_hashes){
|
|
100
|
-
quick_hashes = {title:"quick_hashes"}
|
|
101
|
-
let res = globals.write(quick_hashes)
|
|
102
|
-
quick_hashes._id = res._id
|
|
103
|
-
quick_hashes.created = res.created
|
|
104
|
-
}
|
|
105
|
-
if(quick_hashes.frame === obj_hash){
|
|
106
|
-
setTimeout(() => {
|
|
107
|
-
callback([])
|
|
108
|
-
}, 0);
|
|
109
|
-
}else {
|
|
110
|
-
frame.to_instruction();
|
|
111
|
-
let instructions = frame.flatten_instructions();
|
|
112
|
-
|
|
113
|
-
initiator.load({
|
|
114
|
-
program: { instructions },
|
|
115
|
-
callback,
|
|
116
|
-
});
|
|
117
|
-
globals.update({_id:quick_hashes._id}, {frame: obj_hash})
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
export default framer;
|
|
124
|
-
export { obj };
|
package/opcodes/add.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
let ops = [
|
|
2
|
-
{ name: "add", sign: "+" },
|
|
3
|
-
{ name: "multiply", sign: "*" },
|
|
4
|
-
{ name: "subtract", sign: "-" },
|
|
5
|
-
{ name: "divide", sign: "/" },
|
|
6
|
-
{ name: "exp", sign: "**" },
|
|
7
|
-
{ name: "equal", sign: "==", jmp:true},
|
|
8
|
-
{ name: "not_equal", sign: "!=", jmp:true},
|
|
9
|
-
{ name: "gt", sign: ">",jmp:true },
|
|
10
|
-
{ name: "lt", sign: "<", jmp:true },
|
|
11
|
-
{ name: "lte", sign: "<=" , jmp:true},
|
|
12
|
-
{ name: "gte", sign: ">=", jmp:true },
|
|
13
|
-
];
|
|
14
|
-
|
|
15
|
-
export { ops };
|
package/opcodes/indices.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
const getter = (args) => {
|
|
2
|
-
let base = args.op0;
|
|
3
|
-
|
|
4
|
-
// console.log(args, 'getter.args')
|
|
5
|
-
if(!base)return base === ''?null: base
|
|
6
|
-
|
|
7
|
-
if (typeof base === "number") return base;
|
|
8
|
-
|
|
9
|
-
if (typeof base === "string") return base[args.op1];
|
|
10
|
-
|
|
11
|
-
if (Array.isArray(base)) return base.slice(args.op1)[0];
|
|
12
|
-
|
|
13
|
-
return base[args.op1];
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const setter = (args, vm) => {
|
|
17
|
-
let base = args.op0;
|
|
18
|
-
|
|
19
|
-
if (typeof base === "number") return base;
|
|
20
|
-
|
|
21
|
-
if(vm.is_readonly(args))return;
|
|
22
|
-
|
|
23
|
-
if (typeof base === "string") {
|
|
24
|
-
if (args.op1 ===0 && base.length <= 1){
|
|
25
|
-
base = `${args.op2}${base}`
|
|
26
|
-
} else if (args.op1 ===-1){
|
|
27
|
-
base = `${base}${args.op2}`
|
|
28
|
-
} else base = `${base.slice(0, args.op1)}${args.op2}${base.slice(args.op1)}`;
|
|
29
|
-
} else {
|
|
30
|
-
if (Array.isArray(base)) {
|
|
31
|
-
if (args.op1<0|| args.op1 == null || args.op1 >= base.length) base.push(args.op2);
|
|
32
|
-
else base[args.op1] = args.op2;
|
|
33
|
-
} else base[args.op1] = args.op2;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return base;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const del = (args, vm)=>{
|
|
40
|
-
let base = args.op0
|
|
41
|
-
|
|
42
|
-
if (typeof base === 'number')return;
|
|
43
|
-
|
|
44
|
-
if(vm.is_readonly(args))return;
|
|
45
|
-
|
|
46
|
-
if (typeof base === 'string'){
|
|
47
|
-
if (args.op1 === 0){
|
|
48
|
-
base = base.slice(1)
|
|
49
|
-
}else if (args === -1){
|
|
50
|
-
base = base.slice(0, -1)
|
|
51
|
-
}else {
|
|
52
|
-
base = `${base.slice(0, args.op1)}${base.slice(args.op1+1)}`
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
if (Array.isArray(base)){
|
|
57
|
-
base.splice(args.op1, 1)
|
|
58
|
-
}else delete base[args.op1]
|
|
59
|
-
}
|
|
60
|
-
return base;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const slice = (args, vm)=>{
|
|
64
|
-
let obj = args.op0
|
|
65
|
-
let indexes = args.op1
|
|
66
|
-
if (!Array.isArray(indexes))return vm.stderr(`Indexes must be an array`)
|
|
67
|
-
|
|
68
|
-
let res;
|
|
69
|
-
|
|
70
|
-
if (typeof obj === 'number' ||!obj)return null;
|
|
71
|
-
|
|
72
|
-
if (typeof obj === 'object' && !Array.isArray(obj)){
|
|
73
|
-
res = {}
|
|
74
|
-
indexes.map(i=>{
|
|
75
|
-
res[i] = obj[i]
|
|
76
|
-
})
|
|
77
|
-
}else res = obj.slice(indexes[0], indexes[1])
|
|
78
|
-
|
|
79
|
-
return res;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export { setter, getter , del, slice};
|
package/opcodes/jmp.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const jmp = (args, vm, meta) => {
|
|
2
|
-
meta = meta || {};
|
|
3
|
-
let { flag, inverse } = meta;
|
|
4
|
-
|
|
5
|
-
let condition;
|
|
6
|
-
if (flag) condition = vm.flags[flag];
|
|
7
|
-
if (inverse) condition = !!!condition;
|
|
8
|
-
|
|
9
|
-
if ((condition || !flag) && typeof args.op0 === "number") {
|
|
10
|
-
vm.track.pointer = args.op0;
|
|
11
|
-
|
|
12
|
-
vm.pop_context()
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export { jmp };
|
package/opcodes/std.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
const stdout = (args, vm) => {
|
|
2
|
-
if (!args) return;
|
|
3
|
-
|
|
4
|
-
args&& args.op0&& vm.account.stdout.push({ data: args, pid: vm.track.pid });
|
|
5
|
-
|
|
6
|
-
let logs = []
|
|
7
|
-
for (let v in args) logs.push(args[v].static_value == null ? null :args[v].static_value);
|
|
8
|
-
|
|
9
|
-
console.log(...logs)
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export { stdout };
|
package/opcodes.js
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
// import { socket_send } from "./Socket";
|
|
2
|
-
import callables from "./callables";
|
|
3
|
-
import { ops } from "./opcodes/add";
|
|
4
|
-
import { del, getter, setter, slice } from "./opcodes/indices";
|
|
5
|
-
import { jmp } from "./opcodes/jmp";
|
|
6
|
-
import { stdout } from "./opcodes/std";
|
|
7
|
-
import { post_request } from "./utils/services";
|
|
8
|
-
|
|
9
|
-
const opcodes = (account) => {
|
|
10
|
-
callables(account)
|
|
11
|
-
|
|
12
|
-
let set = account.vm.set;
|
|
13
|
-
|
|
14
|
-
ops.map((op) => {
|
|
15
|
-
if(op.jmp){
|
|
16
|
-
let flag = op.name
|
|
17
|
-
account.vm.flags[flag] = false
|
|
18
|
-
|
|
19
|
-
set(`jmp_${flag}`, (args, vm) => jmp(args, vm, { flag }));
|
|
20
|
-
set(`jmp_not_${flag}`, (args, vm) =>
|
|
21
|
-
jmp(args, vm, { flag, inverse: true })
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
set(op.name, (args) => {
|
|
26
|
-
if (!args) return;
|
|
27
|
-
try {
|
|
28
|
-
let {op0, op1}=args;
|
|
29
|
-
|
|
30
|
-
let type0 = op0.type
|
|
31
|
-
let type1 = op1.type
|
|
32
|
-
|
|
33
|
-
let val0 = op0.static_value;
|
|
34
|
-
let val1 = op1.static_value;
|
|
35
|
-
|
|
36
|
-
if(op.name ==='divide' && val1 === 0){
|
|
37
|
-
return account.vm.stderr({name:'Zero_division_error', message: 'Do not divide by zero'})
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
let result = eval(`val0 ${op.sign} val1`);
|
|
41
|
-
|
|
42
|
-
if (op.jmp) {
|
|
43
|
-
result = !!result;
|
|
44
|
-
account.vm.flags[op.name] = result;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return result;
|
|
48
|
-
} catch (e) {
|
|
49
|
-
console.log("opcodes: ", e.message);
|
|
50
|
-
console.log(e)
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
Object.keys(account.vm.flags).map((flag) => {
|
|
56
|
-
set(`jmp_${flag}`, (args, vm) => jmp(args, vm, { flag }));
|
|
57
|
-
set(`jmp_not_${flag}`, (args, vm) =>
|
|
58
|
-
jmp(args, vm, { flag, inverse: true })
|
|
59
|
-
);
|
|
60
|
-
});
|
|
61
|
-
set("jmp", jmp);
|
|
62
|
-
|
|
63
|
-
// Indices
|
|
64
|
-
set("setter", setter);
|
|
65
|
-
set("getter", getter);
|
|
66
|
-
set("del", del);
|
|
67
|
-
set("slice", slice);
|
|
68
|
-
|
|
69
|
-
set("send", (data) => post_request(data, account.vm.stdin));
|
|
70
|
-
// set("socket_send", socket_send);
|
|
71
|
-
|
|
72
|
-
set("stdout", stdout);
|
|
73
|
-
set("stdin",args=>account. vm.stdin(args&&args.op0));
|
|
74
|
-
|
|
75
|
-
/* Aliases */
|
|
76
|
-
set('quit', account.vm.quit)
|
|
77
|
-
set('exit', account.vm.quit)
|
|
78
|
-
|
|
79
|
-
set('ret', arg=>account.vm.quit(arg, 'ret'))
|
|
80
|
-
|
|
81
|
-
set('exec', account.vm.exec)
|
|
82
|
-
|
|
83
|
-
set('config', account.vm.set_config)
|
|
84
|
-
|
|
85
|
-
set("add_server", (args) => account.add_server(args && args.op0));
|
|
86
|
-
|
|
87
|
-
["run", "load", "parse"].map((op) =>
|
|
88
|
-
set(op, (arg) => arg && arg.op0 && account.manager.endpoint(op, arg && arg.op0))
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
set("add_account", (arg) =>
|
|
92
|
-
account. manager.add_account({ ...arg.op0, string: true })
|
|
93
|
-
);
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
export default opcodes;
|
package/readme.md
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
# God Protocol
|
|
2
|
-
|
|
3
|
-
### A data mediator
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
npm install godprotocol --save
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
### Brief Description
|
|
12
|
-
|
|
13
|
-
This package is developing a framework for the Web 4.0
|
|
14
|
-
It is to help provide multiple compute instances for servers and also data flexibility and transactions.
|
|
15
|
-
|
|
16
|
-
You can get overall comprehension in just 4 method calls.
|
|
17
|
-
|
|
18
|
-
## Create an Account
|
|
19
|
-
|
|
20
|
-
Accounts comes with their own VM, thereby providing concurrency on processes being executed.
|
|
21
|
-
|
|
22
|
-
```js
|
|
23
|
-
import start from "godprotocol";
|
|
24
|
-
|
|
25
|
-
// Create an initial account
|
|
26
|
-
let initiator = start(`name`, { private: true || false });
|
|
27
|
-
// if private is set to `true`, communication to the account instance must be validated by sigining with the private key.
|
|
28
|
-
// N.B your keypairs are generated offline.
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
| `Parameters` | Type | Description |
|
|
32
|
-
| ------------ | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
33
|
-
| `name` | string | Account names can be any valid variable string. Such as a Public Key |
|
|
34
|
-
| `private` | object:boolean | default `false`, if set to true, then any payloads sent to the account must be signed using the private key belonging to the account `name` |
|
|
35
|
-
|
|
36
|
-
## Load Instructions
|
|
37
|
-
|
|
38
|
-
The load method is the second in the pipeline,
|
|
39
|
-
It is used to set your programs into the network web,
|
|
40
|
-
where its data can continue to be accessed, and subsequent
|
|
41
|
-
calls can be made on the loaded program.
|
|
42
|
-
|
|
43
|
-
### Usage
|
|
44
|
-
|
|
45
|
-
```js
|
|
46
|
-
initiator.load(
|
|
47
|
-
{
|
|
48
|
-
instructions: ["link Account/initiator/Datatypes/Number", "write 7", "pop"],
|
|
49
|
-
account: `public_key`,
|
|
50
|
-
},
|
|
51
|
-
cb
|
|
52
|
-
);
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
Type `method`
|
|
56
|
-
|
|
57
|
-
| `Parameters` | Type | Destructure | Description |
|
|
58
|
-
| ------------ | -------- | -------------- | -------------------------------------------------------------------------------------------------------------------- |
|
|
59
|
-
| `program` | object | `instructions` | An array of opcode-operands generated by the [`Loader Sequence`](https://godprotocol-web.vercel.app/loader_sequence) |
|
|
60
|
-
| | | `account` | Account instance to load and execute the program in. |
|
|
61
|
-
| `cb` | function | | A function that is called with the blocks mined during the execution. |
|
|
62
|
-
|
|
63
|
-
## Run Program
|
|
64
|
-
|
|
65
|
-
The run is technically the second in the pipeline.
|
|
66
|
-
|
|
67
|
-
### Usage
|
|
68
|
-
|
|
69
|
-
```js
|
|
70
|
-
initiator.run(
|
|
71
|
-
{
|
|
72
|
-
physical_address: "Account/initiator/Datatypes/Number", // This points to a chain
|
|
73
|
-
query: { blocks: 0 }, // Basically saying, index 0 block in physical_address chain, run again its instructions.
|
|
74
|
-
account: `public_key`,
|
|
75
|
-
},
|
|
76
|
-
cb
|
|
77
|
-
);
|
|
78
|
-
// N.B If query is missing, then VM starts execution from the block-index-0
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
Type `method`
|
|
82
|
-
|
|
83
|
-
| `Parameters` | Type | Destructure | Description |
|
|
84
|
-
| ------------ | -------- | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
85
|
-
| `payload` | object | `physical_address` | [`Physical Addresses`](https://godprotocol-web.vercel.app/physical_address) are logical namespace locations of tokens. They are derived from the high-level representation of the program's instructions. |
|
|
86
|
-
| | object | `query` | A valid blockweb explorer query, you can read the explorer documentation [here](https://godprotocol-web.vercel.app/explorer) |
|
|
87
|
-
| | string | `account` | Account instance to execute the instructions in. |
|
|
88
|
-
| `cb` | function | | A function that is called with the blocks mined during the execution. |
|
|
89
|
-
|
|
90
|
-
## Parse Result
|
|
91
|
-
|
|
92
|
-
The parse is technically the third of the pipeline. It takes like parameters as the `run` method.
|
|
93
|
-
|
|
94
|
-
### Usage
|
|
95
|
-
|
|
96
|
-
It is used to retrieve blocks and chains, and also extract their properties.
|
|
97
|
-
|
|
98
|
-
```js
|
|
99
|
-
initiator.parse(
|
|
100
|
-
{
|
|
101
|
-
physical_address: "Account/initiator/Datatypes/Number", // This points to a chain
|
|
102
|
-
query: { blocks: 0 }, // Basically saying, index 0 block in physical_address chain, retrieve it.
|
|
103
|
-
account: `public_key`,
|
|
104
|
-
},
|
|
105
|
-
cb
|
|
106
|
-
);
|
|
107
|
-
// N.B If query isn't provided, then you parse the chain.
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
Type `method`
|
|
111
|
-
|
|
112
|
-
| `Parameters` | Type | Destructure | Description |
|
|
113
|
-
| ------------ | -------- | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
114
|
-
| `payload` | object | `physical_address` | [`Physical Addresses`](https://godprotocol-web.vercel.app/physical_address) are logical namespace locations of tokens. They are derived from the high-level representation of the program's instructions. |
|
|
115
|
-
| | object | `query` | A valid blockweb explorer query, you can read the explorer documentation [here](https://godprotocol-web.vercel.app/explorer) |
|
|
116
|
-
| | string | `account` | Account instance to execute the instructions in. |
|
|
117
|
-
| `cb` | function | | A function that is called with the blocks mined during the execution. |
|
|
118
|
-
|
|
119
|
-
See the [package source](https://github.com/godprotocol4/GodProtocol) for more details.
|
|
120
|
-
|
|
121
|
-
[npm-url]: https://npmjs.org/package/godprotocol
|
|
122
|
-
[downloads-url]: https://npmjs.org/package/godprotocol
|
|
123
|
-
|
|
124
|
-
## References
|
|
125
|
-
|
|
126
|
-
The main website for communicating updates and tutorials about the platform.
|
|
127
|
-
[https://godprotocol-web.vercel.app](https://godprotocol-web.vercel.app)
|
|
128
|
-
Physical Address - Token logical address from an High-level construct. Find everything else to know about it in the links below.
|
|
129
|
-
[https://godprotocol-web.vercel.app/physical_address](https://godprotocol-web.vercel.app/physical_address)
|
|
130
|
-
Explorer - Every blockchain technology has an explorer, learn more about ours.
|
|
131
|
-
[https://godprotocol-web.vercel.app/explorer](https://godprotocol-web.vercel.app/explorer)
|
|
132
|
-
Loader Sequence - Instruction bits, the lowest granular layer where a user can outline the execution flow.
|
|
133
|
-
[https://godprotocol-web.vercel.app/loader_sequence](https://godprotocol-web.vercel.app/loader_sequence)
|
package/tsconfig.json
DELETED
package/types/Account.d.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import Loader_sequence from "../Loader_sequence/main";
|
|
2
|
-
import Filesystem from "./Filesystem";
|
|
3
|
-
import Virtual_machine from "./Virtual_machine";
|
|
4
|
-
|
|
5
|
-
interface Meta {
|
|
6
|
-
private?: boolean;
|
|
7
|
-
manager?: any;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
interface Program {
|
|
11
|
-
instructions: string[];
|
|
12
|
-
account: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
interface LoadPayload {
|
|
16
|
-
program: Program;
|
|
17
|
-
signature: string;
|
|
18
|
-
callback?: (data: any) => void;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
interface ParsePayload {
|
|
22
|
-
payload: any;
|
|
23
|
-
signature: string;
|
|
24
|
-
callback?: (data: any) => void;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
interface RunRequest {
|
|
28
|
-
payload: any;
|
|
29
|
-
signature: string;
|
|
30
|
-
callback?: (data: any) => void;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
interface AccountPayload {
|
|
34
|
-
name: string;
|
|
35
|
-
meta?: Meta;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
interface EndpointPayload {
|
|
39
|
-
[key: string]: any;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
declare class Account extends Filesystem {
|
|
43
|
-
name: string;
|
|
44
|
-
private: boolean;
|
|
45
|
-
manager: any;
|
|
46
|
-
account: Account;
|
|
47
|
-
physical_address: string;
|
|
48
|
-
compiler: Loader_sequence;
|
|
49
|
-
chain: any;
|
|
50
|
-
vm: Virtual_machine;
|
|
51
|
-
mine_buffer: Record<string, any>;
|
|
52
|
-
|
|
53
|
-
constructor(name: string, meta?: Meta);
|
|
54
|
-
|
|
55
|
-
get_account(name: string): Account;
|
|
56
|
-
manage_buffer(callback?: (data: any) => void): string;
|
|
57
|
-
buff(block: any, pid: string): void;
|
|
58
|
-
flush_buffer(pid: string): void;
|
|
59
|
-
load(payload: LoadPayload): void;
|
|
60
|
-
parse(payload: ParsePayload): void;
|
|
61
|
-
run(request: RunRequest): void;
|
|
62
|
-
run_callback(callback: any, payload: any): void;
|
|
63
|
-
validate(
|
|
64
|
-
payload: any,
|
|
65
|
-
signature: string,
|
|
66
|
-
callback?: (data: any) => void
|
|
67
|
-
): boolean;
|
|
68
|
-
stringify(str?: boolean): string | object;
|
|
69
|
-
create_account(payload: AccountPayload): Account;
|
|
70
|
-
endpoint(endpoint: string, payload: EndpointPayload): void;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export default Account;
|
package/types/Block.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import Chain from "./Chain"; // Adjust the import according to your project structure
|
|
2
|
-
|
|
3
|
-
declare class Block {
|
|
4
|
-
chain: Chain;
|
|
5
|
-
data: any;
|
|
6
|
-
metadata: Record<string, any>;
|
|
7
|
-
children: Block[];
|
|
8
|
-
index: number;
|
|
9
|
-
previous_hash?: string;
|
|
10
|
-
hash?: string;
|
|
11
|
-
cursor?: any;
|
|
12
|
-
datapath?: string;
|
|
13
|
-
timelapse?: any;
|
|
14
|
-
|
|
15
|
-
constructor(chain: Chain);
|
|
16
|
-
|
|
17
|
-
generate_hash(): void;
|
|
18
|
-
store(no_curs?: boolean): void;
|
|
19
|
-
stringify(str?: boolean): string | object;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export default Block;
|
package/types/Blockweb.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import Chain from "./Chain";
|
|
2
|
-
|
|
3
|
-
declare class Blockweb {
|
|
4
|
-
mgr: any;
|
|
5
|
-
physical_addresses: Record<string, string>;
|
|
6
|
-
chains: Record<string, Chain>;
|
|
7
|
-
|
|
8
|
-
constructor(mgr: any);
|
|
9
|
-
|
|
10
|
-
get(addr: string): Chain | undefined;
|
|
11
|
-
set(parent: any, name: string): Chain;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export default Blockweb;
|
package/types/Chain.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import Block from "./Block";
|
|
2
|
-
import Explorer from "./Explorer";
|
|
3
|
-
|
|
4
|
-
declare class Chain extends Explorer {
|
|
5
|
-
parent: any;
|
|
6
|
-
account: any;
|
|
7
|
-
name: string;
|
|
8
|
-
physical_address: string;
|
|
9
|
-
pending_children: Block[];
|
|
10
|
-
connections: Block[];
|
|
11
|
-
blocks: Block[];
|
|
12
|
-
txs: any[];
|
|
13
|
-
height: number;
|
|
14
|
-
cursor: number;
|
|
15
|
-
cursors: number[];
|
|
16
|
-
buffs: any[];
|
|
17
|
-
start_time?: number;
|
|
18
|
-
hash: string;
|
|
19
|
-
|
|
20
|
-
constructor(parent: any, name?: string);
|
|
21
|
-
|
|
22
|
-
append_buffer(): void;
|
|
23
|
-
set_cursor(cursor: number): void;
|
|
24
|
-
get_buffer(): any;
|
|
25
|
-
generate_hash(): void;
|
|
26
|
-
get_block(index: number): Block | undefined;
|
|
27
|
-
add_tx(instruction: any): void;
|
|
28
|
-
mine(vm: any, no_curs?: boolean): Block;
|
|
29
|
-
add_block(block: Block): void;
|
|
30
|
-
get_latest_block(): Block | undefined;
|
|
31
|
-
stringify(str?: boolean): string | Record<string, any>;
|
|
32
|
-
add_chain(name: string): Chain;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export default Chain;
|
package/types/Explorer.d.ts
DELETED
package/types/Filesystem.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
declare class Filesystem {
|
|
2
|
-
base_address: string;
|
|
3
|
-
physical_address: string;
|
|
4
|
-
name: string;
|
|
5
|
-
hash: string;
|
|
6
|
-
account: any;
|
|
7
|
-
manager: any;
|
|
8
|
-
|
|
9
|
-
constructor();
|
|
10
|
-
|
|
11
|
-
parse_path(path: string): any;
|
|
12
|
-
read(datapath: string): any;
|
|
13
|
-
save(content: any, chain: any, just_obj?: boolean): string | object;
|
|
14
|
-
data_addr(type: string): string;
|
|
15
|
-
get_type(chain: any): string;
|
|
16
|
-
write(arg: any, context: any): void;
|
|
17
|
-
name_hash(): void;
|
|
18
|
-
set_paths(chain: any): void;
|
|
19
|
-
add_chain(name: string, parent: any): any;
|
|
20
|
-
account_chain(account: any): any;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export default Filesystem;
|