wowok 1.0.3
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/dist/community.d.ts +8 -0
- package/dist/community.js +96 -0
- package/dist/config.d.ts +19 -0
- package/dist/config.js +27 -0
- package/dist/demand.js +176 -0
- package/dist/guard.js +267 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/machine.js +259 -0
- package/dist/passport.js +89 -0
- package/dist/permission.js +217 -0
- package/dist/progress.js +143 -0
- package/dist/protocol.js +177 -0
- package/dist/repository.js +206 -0
- package/dist/reward.js +192 -0
- package/dist/service.js +698 -0
- package/dist/util.js +131 -0
- package/dist/vote.js +273 -0
- package/package.json +24 -0
- package/src/demand.ts +173 -0
- package/src/guard.ts +283 -0
- package/src/index.ts +0 -0
- package/src/machine.ts +257 -0
- package/src/passport.ts +110 -0
- package/src/permission.ts +224 -0
- package/src/progress.ts +139 -0
- package/src/protocol.ts +189 -0
- package/src/repository.ts +213 -0
- package/src/reward.ts +184 -0
- package/src/service.ts +686 -0
- package/src/util.ts +134 -0
- package/src/vote.ts +251 -0
- package/tsconfig.json +110 -0
package/dist/progress.js
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hold = exports.next = exports.progress_unhold = exports.progress_set_context_repository = exports.progress_bind_task = exports.progress_set_namedOperator = exports.destroy = exports.launch_as_child = exports.launch = exports.progress = exports.MAX_NAMED_OPERATOR_COUNT = void 0;
|
|
4
|
+
const bcs_1 = require("@mysten/bcs");
|
|
5
|
+
const protocol_1 = require("./protocol");
|
|
6
|
+
exports.MAX_NAMED_OPERATOR_COUNT = 64;
|
|
7
|
+
function progress(txb, machine, permission, passport) {
|
|
8
|
+
if (passport) {
|
|
9
|
+
return txb.moveCall({
|
|
10
|
+
target: protocol_1.PROTOCOL.ProgressFn('new_with_passport'),
|
|
11
|
+
arguments: [passport, machine, permission],
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
return txb.moveCall({
|
|
16
|
+
target: protocol_1.PROTOCOL.ProgressFn('new'),
|
|
17
|
+
arguments: [machine, permission],
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.progress = progress;
|
|
22
|
+
function launch(txb, progress) {
|
|
23
|
+
return txb.moveCall({
|
|
24
|
+
target: protocol_1.PROTOCOL.ProgressFn('create'),
|
|
25
|
+
arguments: [progress],
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
exports.launch = launch;
|
|
29
|
+
function launch_as_child(txb, progress, parent, parent_next) {
|
|
30
|
+
return txb.moveCall({
|
|
31
|
+
target: protocol_1.PROTOCOL.ProgressFn('create_as_child'),
|
|
32
|
+
arguments: [progress, parent, txb.pure(parent_next.next_node_name), txb.pure((0, protocol_1.name_data)(parent_next.forward))],
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
exports.launch_as_child = launch_as_child;
|
|
36
|
+
function destroy(txb, progress) {
|
|
37
|
+
return txb.moveCall({
|
|
38
|
+
target: protocol_1.PROTOCOL.ProgressFn('destroy'),
|
|
39
|
+
arguments: [progress],
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
exports.destroy = destroy;
|
|
43
|
+
function progress_set_namedOperator(txb, machine, permission, progress, name, addresses, passport) {
|
|
44
|
+
if (addresses.length == 0 || name.length == 0 || addresses.length > exports.MAX_NAMED_OPERATOR_COUNT)
|
|
45
|
+
return undefined;
|
|
46
|
+
if (passport) {
|
|
47
|
+
txb.moveCall({
|
|
48
|
+
target: protocol_1.PROTOCOL.ProgressFn('namedOperator_set_with_passport'),
|
|
49
|
+
arguments: [passport, progress, txb.pure((0, protocol_1.name_data)(name)), txb.pure(addresses, 'vector<address>'),
|
|
50
|
+
machine, permission],
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
txb.moveCall({
|
|
55
|
+
target: protocol_1.PROTOCOL.ProgressFn('namedOperator_set'),
|
|
56
|
+
arguments: [progress, txb.pure((0, protocol_1.name_data)(name)), txb.pure(addresses, 'vector<address>'),
|
|
57
|
+
machine, permission],
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.progress_set_namedOperator = progress_set_namedOperator;
|
|
62
|
+
function progress_bind_task(txb, machine, permission, progress, task_address, passport) {
|
|
63
|
+
if (passport) {
|
|
64
|
+
txb.moveCall({
|
|
65
|
+
target: protocol_1.PROTOCOL.ProgressFn('task_set_with_passport'),
|
|
66
|
+
arguments: [passport, progress, txb.pure(task_address, bcs_1.BCS.ADDRESS), machine, permission],
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
txb.moveCall({
|
|
71
|
+
target: protocol_1.PROTOCOL.ProgressFn('task_set'),
|
|
72
|
+
arguments: [progress, txb.pure(task_address, bcs_1.BCS.ADDRESS), machine, permission],
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.progress_bind_task = progress_bind_task;
|
|
77
|
+
function progress_set_context_repository(txb, machine, permission, progress, repository, passport) {
|
|
78
|
+
if (passport) {
|
|
79
|
+
if (repository) {
|
|
80
|
+
txb.moveCall({
|
|
81
|
+
target: protocol_1.PROTOCOL.ProgressFn('context_repository_set_with_passport'),
|
|
82
|
+
arguments: [passport, progress, repository, machine, permission],
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
txb.moveCall({
|
|
87
|
+
target: protocol_1.PROTOCOL.ProgressFn('context_repository_none_with_passport'),
|
|
88
|
+
arguments: [passport, progress, machine, permission],
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
if (repository) {
|
|
94
|
+
txb.moveCall({
|
|
95
|
+
target: protocol_1.PROTOCOL.ProgressFn('context_repository_set'),
|
|
96
|
+
arguments: [progress, repository, machine, permission],
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
txb.moveCall({
|
|
101
|
+
target: protocol_1.PROTOCOL.ProgressFn('context_repository_none'),
|
|
102
|
+
arguments: [progress, machine, permission],
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
exports.progress_set_context_repository = progress_set_context_repository;
|
|
108
|
+
function progress_unhold(txb, machine, permission, progress, next) {
|
|
109
|
+
txb.moveCall({
|
|
110
|
+
target: protocol_1.PROTOCOL.ProgressFn('unhold'),
|
|
111
|
+
arguments: [progress, machine, txb.pure(next.next_node_name), txb.pure((0, protocol_1.name_data)(next.forward)), permission],
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
exports.progress_unhold = progress_unhold;
|
|
115
|
+
function next(txb, machine, permission, progress, next, deliverables_address, passport) {
|
|
116
|
+
let diliverable = txb.pure([], bcs_1.BCS.U8);
|
|
117
|
+
if (deliverables_address) {
|
|
118
|
+
diliverable = txb.pure(deliverables_address, bcs_1.BCS.ADDRESS);
|
|
119
|
+
}
|
|
120
|
+
if (passport) {
|
|
121
|
+
txb.moveCall({
|
|
122
|
+
target: protocol_1.PROTOCOL.ProgressFn('run_with_passport'),
|
|
123
|
+
arguments: [passport, progress, machine, txb.pure(next.next_node_name),
|
|
124
|
+
txb.pure((0, protocol_1.name_data)(next.forward)), diliverable, permission],
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
txb.moveCall({
|
|
129
|
+
target: protocol_1.PROTOCOL.ProgressFn('run'),
|
|
130
|
+
arguments: [progress, machine, txb.pure(next.next_node_name),
|
|
131
|
+
txb.pure((0, protocol_1.name_data)(next.forward)), diliverable, permission],
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
exports.next = next;
|
|
136
|
+
function hold(txb, machine, permission, progress, next, hold) {
|
|
137
|
+
txb.moveCall({
|
|
138
|
+
target: protocol_1.PROTOCOL.ProgressFn('hold'),
|
|
139
|
+
arguments: [progress, machine, txb.pure(next.next_node_name),
|
|
140
|
+
txb.pure((0, protocol_1.name_data)(next.forward)), txb.pure(hold, bcs_1.BCS.BOOL), permission],
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
exports.hold = hold;
|
package/dist/protocol.js
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OBJECTS_TYPE = exports.OBJECTS_TYPE_PREFIX = exports.PROTOCOL = exports.Protocol = exports.ENTRYPOINT = exports.Data_Type = exports.CLOCK_OBJECT = exports.TXB_OBJECT = exports.MODULES = exports.name_data = exports.endpoint_data = exports.description_data = exports.MAX_ENDPOINT_LENGTH = exports.MAX_NAME_LENGTH = exports.MAX_DESCRIPTION_LENGTH = void 0;
|
|
4
|
+
const client_1 = require("@mysten/sui.js/client");
|
|
5
|
+
const ed25519_1 = require("@mysten/sui.js/keypairs/ed25519");
|
|
6
|
+
const bcs_1 = require("@mysten/bcs");
|
|
7
|
+
const transactions_1 = require("@mysten/sui.js/transactions");
|
|
8
|
+
const util_1 = require("./util");
|
|
9
|
+
exports.MAX_DESCRIPTION_LENGTH = 1024;
|
|
10
|
+
exports.MAX_NAME_LENGTH = 64;
|
|
11
|
+
exports.MAX_ENDPOINT_LENGTH = 1024;
|
|
12
|
+
function description_data(description) {
|
|
13
|
+
return description.substring(0, exports.MAX_DESCRIPTION_LENGTH);
|
|
14
|
+
}
|
|
15
|
+
exports.description_data = description_data;
|
|
16
|
+
function endpoint_data(endpoint) {
|
|
17
|
+
return endpoint.substring(0, exports.MAX_ENDPOINT_LENGTH);
|
|
18
|
+
}
|
|
19
|
+
exports.endpoint_data = endpoint_data;
|
|
20
|
+
function name_data(name) {
|
|
21
|
+
return name.substring(0, exports.MAX_NAME_LENGTH);
|
|
22
|
+
}
|
|
23
|
+
exports.name_data = name_data;
|
|
24
|
+
var MODULES;
|
|
25
|
+
(function (MODULES) {
|
|
26
|
+
MODULES["machine"] = "machine";
|
|
27
|
+
MODULES["node"] = "node";
|
|
28
|
+
MODULES["progress"] = "progress";
|
|
29
|
+
MODULES["community"] = "community";
|
|
30
|
+
MODULES["repository"] = "repository";
|
|
31
|
+
MODULES["permission"] = "permission";
|
|
32
|
+
MODULES["passport"] = "passport";
|
|
33
|
+
MODULES["guard"] = "guard";
|
|
34
|
+
MODULES["vote"] = "vote";
|
|
35
|
+
MODULES["demand"] = "demand";
|
|
36
|
+
MODULES["order"] = "order";
|
|
37
|
+
MODULES["reward"] = "reward";
|
|
38
|
+
MODULES["service"] = "service";
|
|
39
|
+
MODULES["wowok"] = "wowok";
|
|
40
|
+
})(MODULES || (exports.MODULES = MODULES = {}));
|
|
41
|
+
function TXB_OBJECT(txb, arg) {
|
|
42
|
+
if (typeof arg == 'string')
|
|
43
|
+
return txb.object(arg);
|
|
44
|
+
return arg;
|
|
45
|
+
}
|
|
46
|
+
exports.TXB_OBJECT = TXB_OBJECT;
|
|
47
|
+
exports.CLOCK_OBJECT = transactions_1.Inputs.SharedObjectRef({
|
|
48
|
+
objectId: "0x6",
|
|
49
|
+
mutable: false,
|
|
50
|
+
initialSharedVersion: 1,
|
|
51
|
+
});
|
|
52
|
+
var Data_Type;
|
|
53
|
+
(function (Data_Type) {
|
|
54
|
+
Data_Type[Data_Type["TYPE_DYNAMIC_QUERY"] = 1] = "TYPE_DYNAMIC_QUERY";
|
|
55
|
+
Data_Type[Data_Type["TYPE_LOGIC_OPERATOR_U128_GREATER"] = 11] = "TYPE_LOGIC_OPERATOR_U128_GREATER";
|
|
56
|
+
Data_Type[Data_Type["TYPE_LOGIC_OPERATOR_U128_GREATER_EQUAL"] = 12] = "TYPE_LOGIC_OPERATOR_U128_GREATER_EQUAL";
|
|
57
|
+
Data_Type[Data_Type["TYPE_LOGIC_OPERATOR_U128_LESSER"] = 13] = "TYPE_LOGIC_OPERATOR_U128_LESSER";
|
|
58
|
+
Data_Type[Data_Type["TYPE_LOGIC_OPERATOR_U128_LESSER_EQUAL"] = 14] = "TYPE_LOGIC_OPERATOR_U128_LESSER_EQUAL";
|
|
59
|
+
Data_Type[Data_Type["TYPE_LOGIC_OPERATOR_U128_EQUAL"] = 15] = "TYPE_LOGIC_OPERATOR_U128_EQUAL";
|
|
60
|
+
Data_Type[Data_Type["TYPE_LOGIC_OPERATOR_EQUAL"] = 16] = "TYPE_LOGIC_OPERATOR_EQUAL";
|
|
61
|
+
Data_Type[Data_Type["TYPE_LOGIC_OPERATOR_HAS_SUBSTRING"] = 17] = "TYPE_LOGIC_OPERATOR_HAS_SUBSTRING";
|
|
62
|
+
Data_Type[Data_Type["TYPE_LOGIC_ALWAYS_TRUE"] = 18] = "TYPE_LOGIC_ALWAYS_TRUE";
|
|
63
|
+
// TYPE_LOGIC_OPERATOR_VECU8_CONTAINS = 18, // SUB VEC<U8>
|
|
64
|
+
Data_Type[Data_Type["TYPE_CONTEXT_SIGNER"] = 60] = "TYPE_CONTEXT_SIGNER";
|
|
65
|
+
Data_Type[Data_Type["TYPE_CONTEXT_CURRENT_PROGRESS"] = 61] = "TYPE_CONTEXT_CURRENT_PROGRESS";
|
|
66
|
+
Data_Type[Data_Type["TYPE_CONTEXT_CURRENT_CLOCK"] = 62] = "TYPE_CONTEXT_CURRENT_CLOCK";
|
|
67
|
+
Data_Type[Data_Type["TYPE_STATIC_bool"] = 100] = "TYPE_STATIC_bool";
|
|
68
|
+
Data_Type[Data_Type["TYPE_STATIC_address"] = 101] = "TYPE_STATIC_address";
|
|
69
|
+
Data_Type[Data_Type["TYPE_STATIC_u64"] = 102] = "TYPE_STATIC_u64";
|
|
70
|
+
Data_Type[Data_Type["TYPE_STATIC_u8"] = 103] = "TYPE_STATIC_u8";
|
|
71
|
+
Data_Type[Data_Type["TYPE_STATIC_u128"] = 104] = "TYPE_STATIC_u128";
|
|
72
|
+
Data_Type[Data_Type["TYPE_STATIC_vec_u8"] = 105] = "TYPE_STATIC_vec_u8";
|
|
73
|
+
Data_Type[Data_Type["TYPE_STATIC_vec_address"] = 106] = "TYPE_STATIC_vec_address";
|
|
74
|
+
Data_Type[Data_Type["TYPE_STATIC_vec_bool"] = 107] = "TYPE_STATIC_vec_bool";
|
|
75
|
+
Data_Type[Data_Type["TYPE_STATIC_vec_vec_u8"] = 108] = "TYPE_STATIC_vec_vec_u8";
|
|
76
|
+
Data_Type[Data_Type["TYPE_STATIC_vec_u64"] = 109] = "TYPE_STATIC_vec_u64";
|
|
77
|
+
Data_Type[Data_Type["TYPE_STATIC_vec_u128"] = 110] = "TYPE_STATIC_vec_u128";
|
|
78
|
+
Data_Type[Data_Type["TYPE_STATIC_option_address"] = 111] = "TYPE_STATIC_option_address";
|
|
79
|
+
Data_Type[Data_Type["TYPE_STATIC_option_bool"] = 112] = "TYPE_STATIC_option_bool";
|
|
80
|
+
Data_Type[Data_Type["TYPE_STATIC_option_u8"] = 113] = "TYPE_STATIC_option_u8";
|
|
81
|
+
Data_Type[Data_Type["TYPE_STATIC_option_u64"] = 114] = "TYPE_STATIC_option_u64";
|
|
82
|
+
Data_Type[Data_Type["TYPE_STATIC_option_u128"] = 115] = "TYPE_STATIC_option_u128";
|
|
83
|
+
Data_Type[Data_Type["TYPE_STATIC_by_value_specified"] = 126] = "TYPE_STATIC_by_value_specified";
|
|
84
|
+
Data_Type[Data_Type["TYPE_STATIC_error"] = 127] = "TYPE_STATIC_error";
|
|
85
|
+
})(Data_Type || (exports.Data_Type = Data_Type = {}));
|
|
86
|
+
var ENTRYPOINT;
|
|
87
|
+
(function (ENTRYPOINT) {
|
|
88
|
+
ENTRYPOINT["mainnet"] = "mainnet";
|
|
89
|
+
ENTRYPOINT["testnet"] = "testnet";
|
|
90
|
+
ENTRYPOINT["devnet"] = "devnet";
|
|
91
|
+
ENTRYPOINT["localnet"] = "localnet";
|
|
92
|
+
})(ENTRYPOINT || (exports.ENTRYPOINT = ENTRYPOINT = {}));
|
|
93
|
+
class Protocol {
|
|
94
|
+
network = '';
|
|
95
|
+
package = '';
|
|
96
|
+
signer = '';
|
|
97
|
+
everyone_guard = '';
|
|
98
|
+
constructor(network = ENTRYPOINT.localnet, signer = "0xe386bb9e01b3528b75f3751ad8a1e418b207ad979fea364087deef5250a73d3f") {
|
|
99
|
+
this.network = network;
|
|
100
|
+
this.signer = signer;
|
|
101
|
+
switch (network) {
|
|
102
|
+
case ENTRYPOINT.localnet:
|
|
103
|
+
this.package = "0x74df733df2395d0c3a34c6d086d2e1f130603b8aa16962e53781cb0fa9c6958c";
|
|
104
|
+
this.everyone_guard = "0xb1a2e3d0cf13c3fcb491f126af8422f7d098147659d8a58a52511cfbb783a6e8";
|
|
105
|
+
break;
|
|
106
|
+
case ENTRYPOINT.devnet:
|
|
107
|
+
break;
|
|
108
|
+
case ENTRYPOINT.testnet:
|
|
109
|
+
this.package = "0x038b0be329e4fd227d846b850aeb1822f9629c62c14d85ffcd22d856c843923f";
|
|
110
|
+
this.everyone_guard = "0xdfe42468bfc7d7988fa1707978ef9376178dcefbe938d140a1bfd97abe755998";
|
|
111
|
+
break;
|
|
112
|
+
case ENTRYPOINT.mainnet:
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
;
|
|
116
|
+
}
|
|
117
|
+
Package() { return this.package; }
|
|
118
|
+
EveryoneGuard() { return this.everyone_guard; }
|
|
119
|
+
NetworkUrl() {
|
|
120
|
+
switch (this.network) {
|
|
121
|
+
case ENTRYPOINT.localnet:
|
|
122
|
+
return "http://127.0.0.1:9000";
|
|
123
|
+
case ENTRYPOINT.devnet:
|
|
124
|
+
return "https://fullnode.devnet.sui.io:443";
|
|
125
|
+
case ENTRYPOINT.testnet:
|
|
126
|
+
return "https://fullnode.testnet.sui.io:443";
|
|
127
|
+
case ENTRYPOINT.mainnet:
|
|
128
|
+
return "https://fullnode.mainnet.sui.io:443";
|
|
129
|
+
}
|
|
130
|
+
;
|
|
131
|
+
return "";
|
|
132
|
+
}
|
|
133
|
+
;
|
|
134
|
+
MachineFn = (fn) => { return `${this.package}::${MODULES.machine}::${fn}`; };
|
|
135
|
+
NodeFn = (fn) => { return `${this.package}::${MODULES.node}::${fn}`; };
|
|
136
|
+
ProgressFn = (fn) => { return `${this.package}::${MODULES.progress}::${fn}`; };
|
|
137
|
+
CommunityFn = (fn) => { return `${this.package}::${MODULES.community}::${fn}`; };
|
|
138
|
+
RepositoryFn = (fn) => { return `${this.package}::${MODULES.repository}::${fn}`; };
|
|
139
|
+
PermissionFn = (fn) => { return `${this.package}::${MODULES.permission}::${fn}`; };
|
|
140
|
+
PassportFn = (fn) => { return `${this.package}::${MODULES.passport}::${fn}`; };
|
|
141
|
+
GuardFn = (fn) => { return `${this.package}::${MODULES.guard}::${fn}`; };
|
|
142
|
+
VoteFn = (fn) => { return `${this.package}::${MODULES.vote}::${fn}`; };
|
|
143
|
+
DemandFn = (fn) => { return `${this.package}::${MODULES.demand}::${fn}`; };
|
|
144
|
+
OrderFn = (fn) => { return `${this.package}::${MODULES.order}::${fn}`; };
|
|
145
|
+
RewardFn = (fn) => { return `${this.package}::${MODULES.reward}::${fn}`; };
|
|
146
|
+
ServiceFn = (fn) => { return `${this.package}::${MODULES.service}::${fn}`; };
|
|
147
|
+
WowokFn = (fn) => { return `${this.package}::${MODULES.wowok}::${fn}`; };
|
|
148
|
+
Query = async (objects, options = { showContent: true }) => {
|
|
149
|
+
const client = new client_1.SuiClient({ url: exports.PROTOCOL.NetworkUrl() });
|
|
150
|
+
const ids = objects.map((value) => value.objectid);
|
|
151
|
+
const res = await client.call('sui_multiGetObjects', [ids, options]);
|
|
152
|
+
let ret = [];
|
|
153
|
+
for (let i = 0; i < res.length; i++) {
|
|
154
|
+
objects.forEach((object) => {
|
|
155
|
+
object.callback(res[i], object, options);
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
return res;
|
|
159
|
+
};
|
|
160
|
+
Sign_Excute = async (exes, priv_key, param, options = { showObjectChanges: true }) => {
|
|
161
|
+
const client = new client_1.SuiClient({ url: exports.PROTOCOL.NetworkUrl() });
|
|
162
|
+
const txb = new transactions_1.TransactionBlock();
|
|
163
|
+
exes(txb, param);
|
|
164
|
+
const privkey = (0, bcs_1.fromHEX)(priv_key);
|
|
165
|
+
const keypair = ed25519_1.Ed25519Keypair.fromSecretKey(privkey);
|
|
166
|
+
const response = await client.signAndExecuteTransactionBlock({
|
|
167
|
+
transactionBlock: txb,
|
|
168
|
+
signer: keypair,
|
|
169
|
+
options
|
|
170
|
+
});
|
|
171
|
+
return response;
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
exports.Protocol = Protocol;
|
|
175
|
+
exports.PROTOCOL = new Protocol();
|
|
176
|
+
exports.OBJECTS_TYPE_PREFIX = Object.keys(MODULES).map((key) => { return exports.PROTOCOL.Package() + '::' + key + '::'; });
|
|
177
|
+
exports.OBJECTS_TYPE = Object.keys(MODULES).map((key) => { let i = exports.PROTOCOL.Package() + '::' + key + '::'; return i + (0, util_1.capitalize)(key); });
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.change_permission = exports.repository_set_policy_permission = exports.repository_set_policy_description = exports.repository_set_policy_mode = exports.repository_set_description = exports.repository_remove_policies = exports.repository_add_policies = exports.remove = exports.add_data = exports.destroy = exports.launch = exports.repository = exports.Repository_Policy_Mode = exports.MAX_POLICY_COUNT = void 0;
|
|
4
|
+
const bcs_1 = require("@mysten/bcs");
|
|
5
|
+
const protocol_1 = require("./protocol");
|
|
6
|
+
exports.MAX_POLICY_COUNT = 128;
|
|
7
|
+
var Repository_Policy_Mode;
|
|
8
|
+
(function (Repository_Policy_Mode) {
|
|
9
|
+
Repository_Policy_Mode[Repository_Policy_Mode["POLICY_MODE_FREE"] = 0] = "POLICY_MODE_FREE";
|
|
10
|
+
Repository_Policy_Mode[Repository_Policy_Mode["POLICY_MODE_STRICT"] = 1] = "POLICY_MODE_STRICT";
|
|
11
|
+
})(Repository_Policy_Mode || (exports.Repository_Policy_Mode = Repository_Policy_Mode = {}));
|
|
12
|
+
function repository(txb, permission, description, policy_mode, passport) {
|
|
13
|
+
if (passport) {
|
|
14
|
+
return txb.moveCall({
|
|
15
|
+
target: protocol_1.PROTOCOL.RepositoryFn('new_with_passport'),
|
|
16
|
+
arguments: [passport, txb.pure((0, protocol_1.description_data)(description)), txb.pure(policy_mode, bcs_1.BCS.U8), permission],
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
return txb.moveCall({
|
|
21
|
+
target: protocol_1.PROTOCOL.RepositoryFn('new'),
|
|
22
|
+
arguments: [txb.pure((0, protocol_1.description_data)(description)), txb.pure(policy_mode, bcs_1.BCS.U8), permission],
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.repository = repository;
|
|
27
|
+
function launch(txb, repository) {
|
|
28
|
+
return txb.moveCall({
|
|
29
|
+
target: protocol_1.PROTOCOL.RepositoryFn('create'),
|
|
30
|
+
arguments: [repository],
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
exports.launch = launch;
|
|
34
|
+
function destroy(txb, repository) {
|
|
35
|
+
return txb.moveCall({
|
|
36
|
+
target: protocol_1.PROTOCOL.RepositoryFn('destroy'),
|
|
37
|
+
arguments: [repository],
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
exports.destroy = destroy;
|
|
41
|
+
function add_data(txb, repository, permission, data) {
|
|
42
|
+
if (data?.value_type) {
|
|
43
|
+
data.data.forEach((d) => txb.moveCall({
|
|
44
|
+
target: protocol_1.PROTOCOL.RepositoryFn('add'),
|
|
45
|
+
arguments: [repository,
|
|
46
|
+
txb.pure(d.address, bcs_1.BCS.ADDRESS),
|
|
47
|
+
txb.pure((0, protocol_1.name_data)(data.name)),
|
|
48
|
+
txb.pure(data.value_type, bcs_1.BCS.U8),
|
|
49
|
+
txb.pure(d.value, 'vector<u8>'),
|
|
50
|
+
permission,
|
|
51
|
+
],
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
data.data.forEach((d) => txb.moveCall({
|
|
56
|
+
target: protocol_1.PROTOCOL.RepositoryFn('add_typed_data'),
|
|
57
|
+
arguments: [repository,
|
|
58
|
+
txb.pure(d.address, bcs_1.BCS.ADDRESS),
|
|
59
|
+
txb.pure((0, protocol_1.name_data)(data.name)),
|
|
60
|
+
txb.pure(d.value, 'vector<u8>'),
|
|
61
|
+
permission,
|
|
62
|
+
],
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.add_data = add_data;
|
|
67
|
+
function remove(txb, repository, permission, address, name) {
|
|
68
|
+
txb.moveCall({
|
|
69
|
+
target: protocol_1.PROTOCOL.RepositoryFn('remove'),
|
|
70
|
+
arguments: [repository,
|
|
71
|
+
txb.pure(address, bcs_1.BCS.ADDRESS),
|
|
72
|
+
txb.pure((0, protocol_1.name_data)(name)),
|
|
73
|
+
permission,
|
|
74
|
+
],
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
exports.remove = remove;
|
|
78
|
+
// add or modify the old
|
|
79
|
+
function repository_add_policies(txb, repository, permission, policies, passport) {
|
|
80
|
+
policies.forEach((policy) => {
|
|
81
|
+
let permission_index = policy?.permission ? txb.pure(policy.permission, bcs_1.BCS.U64) : txb.pure([0], bcs_1.BCS.U8);
|
|
82
|
+
if (passport) {
|
|
83
|
+
txb.moveCall({
|
|
84
|
+
target: protocol_1.PROTOCOL.RepositoryFn('policy_add_with_passport'),
|
|
85
|
+
arguments: [passport, repository,
|
|
86
|
+
txb.pure((0, protocol_1.name_data)(policy.name)),
|
|
87
|
+
txb.pure((0, protocol_1.description_data)(policy.description)),
|
|
88
|
+
permission_index, txb.pure(policy.value_type, bcs_1.BCS.U8)]
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
txb.moveCall({
|
|
93
|
+
target: protocol_1.PROTOCOL.RepositoryFn('policy_add'),
|
|
94
|
+
arguments: [repository,
|
|
95
|
+
txb.pure((0, protocol_1.name_data)(policy.name)),
|
|
96
|
+
txb.pure((0, protocol_1.description_data)(policy.description)),
|
|
97
|
+
permission_index, txb.pure(policy.value_type, bcs_1.BCS.U8)]
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
exports.repository_add_policies = repository_add_policies;
|
|
103
|
+
function repository_remove_policies(txb, repository, permission, policy_names, removeall, passport) {
|
|
104
|
+
if (passport) {
|
|
105
|
+
if (removeall) {
|
|
106
|
+
txb.moveCall({
|
|
107
|
+
target: protocol_1.PROTOCOL.RepositoryFn('policy_remove_all_with_passport'),
|
|
108
|
+
arguments: [passport, repository, permission]
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
policy_names.forEach((name) => {
|
|
113
|
+
txb.moveCall({
|
|
114
|
+
target: protocol_1.PROTOCOL.RepositoryFn('policy_remove_with_passport'),
|
|
115
|
+
arguments: [passport, repository, txb.pure((0, protocol_1.name_data)(name)), permission]
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
if (removeall) {
|
|
122
|
+
txb.moveCall({
|
|
123
|
+
target: protocol_1.PROTOCOL.RepositoryFn('policy_remove_all'),
|
|
124
|
+
arguments: [repository, permission]
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
policy_names.forEach((name) => {
|
|
129
|
+
txb.moveCall({
|
|
130
|
+
target: protocol_1.PROTOCOL.RepositoryFn('policy_remove'),
|
|
131
|
+
arguments: [repository, txb.pure((0, protocol_1.name_data)(name)), permission]
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
exports.repository_remove_policies = repository_remove_policies;
|
|
138
|
+
// PermissionIndex.repository_description_set
|
|
139
|
+
function repository_set_description(txb, repository, permission, description, passport) {
|
|
140
|
+
if (passport) {
|
|
141
|
+
txb.moveCall({
|
|
142
|
+
target: protocol_1.PROTOCOL.RepositoryFn('description_set_with_passport'),
|
|
143
|
+
arguments: [passport, repository, txb.pure((0, protocol_1.description_data)(description)), permission]
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
txb.moveCall({
|
|
148
|
+
target: protocol_1.PROTOCOL.RepositoryFn('description_set'),
|
|
149
|
+
arguments: [repository, txb.pure((0, protocol_1.description_data)(description)), permission]
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
exports.repository_set_description = repository_set_description;
|
|
154
|
+
function repository_set_policy_mode(txb, repository, permission, policy_mode, passport) {
|
|
155
|
+
if (passport) {
|
|
156
|
+
txb.moveCall({
|
|
157
|
+
target: protocol_1.PROTOCOL.RepositoryFn('policy_mode_set_with_passport'),
|
|
158
|
+
arguments: [passport, repository, txb.pure(policy_mode), permission]
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
txb.moveCall({
|
|
163
|
+
target: protocol_1.PROTOCOL.RepositoryFn('policy_mode_set'),
|
|
164
|
+
arguments: [repository, txb.pure(policy_mode), permission]
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
exports.repository_set_policy_mode = repository_set_policy_mode;
|
|
169
|
+
function repository_set_policy_description(txb, repository, permission, description, passport) {
|
|
170
|
+
if (passport) {
|
|
171
|
+
txb.moveCall({
|
|
172
|
+
target: protocol_1.PROTOCOL.RepositoryFn('description_set_with_passport'),
|
|
173
|
+
arguments: [passport, repository, txb.pure((0, protocol_1.description_data)(description)), permission]
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
txb.moveCall({
|
|
178
|
+
target: protocol_1.PROTOCOL.RepositoryFn('description_set'),
|
|
179
|
+
arguments: [repository, txb.pure((0, protocol_1.description_data)(description)), permission]
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
exports.repository_set_policy_description = repository_set_policy_description;
|
|
184
|
+
function repository_set_policy_permission(txb, repository, permission, permission_index, passport) {
|
|
185
|
+
if (passport) {
|
|
186
|
+
txb.moveCall({
|
|
187
|
+
target: protocol_1.PROTOCOL.RepositoryFn('policy_mode_set_with_passport'),
|
|
188
|
+
arguments: [passport, repository, txb.pure(permission_index, bcs_1.BCS.U64), permission]
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
txb.moveCall({
|
|
193
|
+
target: protocol_1.PROTOCOL.RepositoryFn('policy_mode_set'),
|
|
194
|
+
arguments: [repository, txb.pure(permission_index, bcs_1.BCS.U64), permission]
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
exports.repository_set_policy_permission = repository_set_policy_permission;
|
|
199
|
+
function change_permission(txb, repository, old_permission, new_permission) {
|
|
200
|
+
txb.moveCall({
|
|
201
|
+
target: protocol_1.PROTOCOL.RepositoryFn('permission_set'),
|
|
202
|
+
arguments: [repository, old_permission, new_permission],
|
|
203
|
+
typeArguments: []
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
exports.change_permission = change_permission;
|