@palliora.org/chainsdk 0.2.0 → 0.3.0
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/index.cjs +306 -114
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +414 -225
- package/dist/index.d.ts +414 -225
- package/dist/index.js +281 -89
- package/dist/index.js.map +1 -1
- package/package.json +3 -1
package/dist/index.cjs
CHANGED
|
@@ -230,7 +230,7 @@ var API_TYPES = {
|
|
|
230
230
|
pk_bytes: "Vec<u8>",
|
|
231
231
|
tau_params: "Vec<u8>"
|
|
232
232
|
},
|
|
233
|
-
|
|
233
|
+
ThresholdParams: {
|
|
234
234
|
_enum: {
|
|
235
235
|
SilentThreshold: "SilentThresholdParams"
|
|
236
236
|
}
|
|
@@ -241,24 +241,61 @@ var API_TYPES = {
|
|
|
241
241
|
Aes256GcmParams: {
|
|
242
242
|
nonce: "[u8; 12]"
|
|
243
243
|
},
|
|
244
|
-
|
|
244
|
+
SymmetricParams: {
|
|
245
245
|
_enum: {
|
|
246
246
|
ChaCha20Poly1305: "ChaCha20Poly1305Params",
|
|
247
247
|
Aes256Gcm: "Aes256GcmParams"
|
|
248
248
|
}
|
|
249
249
|
},
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
250
|
+
KdfParams: {
|
|
251
|
+
_enum: {
|
|
252
|
+
HkdfSha256: "Null",
|
|
253
|
+
HkdfSha512: "Null"
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
Secp256k1Params: {
|
|
257
|
+
recipient_public_key: "Vec<u8>",
|
|
258
|
+
ephemeral_public_key: "Option<Vec<u8>>",
|
|
259
|
+
compressed: "bool",
|
|
260
|
+
kdf: "KdfParams",
|
|
261
|
+
salt: "Option<Vec<u8>>",
|
|
262
|
+
info: "Option<Vec<u8>>"
|
|
263
|
+
},
|
|
264
|
+
Ed25519Params: {
|
|
265
|
+
recipient_public_key: "Vec<u8>",
|
|
266
|
+
ephemeral_public_key: "Option<Vec<u8>>",
|
|
267
|
+
kdf: "KdfParams",
|
|
268
|
+
salt: "Option<Vec<u8>>",
|
|
269
|
+
info: "Option<Vec<u8>>"
|
|
270
|
+
},
|
|
271
|
+
AsymmetricParams: {
|
|
272
|
+
_enum: {
|
|
273
|
+
Secp256k1: "Secp256k1Params",
|
|
274
|
+
Ed25519: "Ed25519Params"
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
ThresholdHybridParams: {
|
|
278
|
+
threshold_params: "ThresholdParams",
|
|
279
|
+
symmetric_params: "SymmetricParams"
|
|
280
|
+
},
|
|
281
|
+
AsymmetricHybridParams: {
|
|
282
|
+
asymmetric_params: "AsymmetricParams",
|
|
283
|
+
symmetric_params: "SymmetricParams"
|
|
253
284
|
},
|
|
254
285
|
CipherSuite: {
|
|
255
286
|
_enum: {
|
|
256
287
|
Plaintext: "Null",
|
|
257
|
-
|
|
288
|
+
ThresholdHybrid: "ThresholdHybridParams",
|
|
289
|
+
AsymmetricHybrid: "AsymmetricHybridParams"
|
|
258
290
|
}
|
|
259
291
|
},
|
|
260
292
|
ConfidentialityLevel: {
|
|
261
|
-
_enum:
|
|
293
|
+
_enum: {
|
|
294
|
+
Trusted: "u32",
|
|
295
|
+
TEE: "Null",
|
|
296
|
+
FHE: "Null",
|
|
297
|
+
SMPC: "Null"
|
|
298
|
+
}
|
|
262
299
|
},
|
|
263
300
|
NativeExecuteDA: {
|
|
264
301
|
_enum: ["Inference"]
|
|
@@ -284,6 +321,7 @@ var API_TYPES = {
|
|
|
284
321
|
},
|
|
285
322
|
DAInput: {
|
|
286
323
|
_enum: {
|
|
324
|
+
Null: "Null",
|
|
287
325
|
Inline: "DAInputInline",
|
|
288
326
|
ChainTransaction: "DAInputChainTransaction",
|
|
289
327
|
Ipfs: "DAInputIpfs",
|
|
@@ -294,16 +332,16 @@ var API_TYPES = {
|
|
|
294
332
|
},
|
|
295
333
|
ContractType: {
|
|
296
334
|
_enum: {
|
|
297
|
-
Dormant: "
|
|
298
|
-
Active: "
|
|
335
|
+
Dormant: "Null",
|
|
336
|
+
Active: "Null"
|
|
299
337
|
}
|
|
300
338
|
},
|
|
301
339
|
StoreType: {
|
|
302
340
|
_enum: {
|
|
303
|
-
Dataset: "
|
|
304
|
-
Model: "
|
|
305
|
-
Agent: "
|
|
306
|
-
Other: "
|
|
341
|
+
Dataset: "Null",
|
|
342
|
+
Model: "Null",
|
|
343
|
+
Agent: "Null",
|
|
344
|
+
Other: "Null"
|
|
307
345
|
}
|
|
308
346
|
},
|
|
309
347
|
ComputeMetadata: {
|
|
@@ -929,18 +967,55 @@ var createGuardianGroup = async (account, selectedGuardians) => {
|
|
|
929
967
|
);
|
|
930
968
|
const result = await signAndSend(tx, account);
|
|
931
969
|
debugLog("Guardian group created:", result);
|
|
970
|
+
return result;
|
|
932
971
|
} catch (error) {
|
|
933
972
|
console.error("Error creating guardian group:", error);
|
|
934
973
|
throw new Error(`Failed to create guardian group: ${error instanceof Error ? error.message : error}`);
|
|
935
974
|
}
|
|
936
975
|
};
|
|
976
|
+
var createGuardianGroupAndWatch = async (account, guardians, maxBlocks = 20) => {
|
|
977
|
+
assert(guardians.length === 3, "Exactly 3 guardians are required");
|
|
978
|
+
assert(account, "Failed to load account");
|
|
979
|
+
const api2 = await getApi();
|
|
980
|
+
assert(api2, "Failed to initialize API");
|
|
981
|
+
debugLog(`Submitting guardian group creation...`);
|
|
982
|
+
const creationResult = await createGuardianGroup(account, guardians);
|
|
983
|
+
const startBlock = (_nullishCoalesce(_optionalChain([creationResult, 'optionalAccess', _45 => _45.blockNumber]), () => ( 0))) + 1;
|
|
984
|
+
debugLog(`Group creation tx confirmed at block ${startBlock - 1}. Listening for DaccGuardianGroup event from block ${startBlock}...`);
|
|
985
|
+
const match = await scanForBlockEvent(
|
|
986
|
+
api2,
|
|
987
|
+
{
|
|
988
|
+
predicate: async (block2, event, phase) => {
|
|
989
|
+
if (event.section.toLowerCase() !== "dataavailability" || event.method.toLowerCase() !== "daccguardiangroup") return false;
|
|
990
|
+
if (!phase.isApplyExtrinsic) return false;
|
|
991
|
+
const ext2 = block2.block.extrinsics[phase.asApplyExtrinsic.toNumber()];
|
|
992
|
+
return _optionalChain([ext2, 'optionalAccess', _46 => _46.method, 'optionalAccess', _47 => _47.section, 'optionalAccess', _48 => _48.toLowerCase, 'call', _49 => _49()]) === "dataavailability" && _optionalChain([ext2, 'optionalAccess', _50 => _50.method, 'optionalAccess', _51 => _51.method, 'optionalAccess', _52 => _52.toLowerCase, 'call', _53 => _53()]) === "daccguardiangroupinfo";
|
|
993
|
+
}
|
|
994
|
+
},
|
|
995
|
+
startBlock,
|
|
996
|
+
maxBlocks
|
|
997
|
+
);
|
|
998
|
+
assert(match.extrinsicIndex !== null, "DaccGuardianGroup event was not emitted by an extrinsic");
|
|
999
|
+
debugLog(`DaccGuardianGroup event found at block ${match.blockNumber}, extrinsic index ${match.extrinsicIndex}. Decoding args...`);
|
|
1000
|
+
const block = await match.block();
|
|
1001
|
+
const ext = block.block.extrinsics[match.extrinsicIndex];
|
|
1002
|
+
const [group_id, group_pk, tau_params, agg_key] = ext.method.args;
|
|
1003
|
+
debugLog(`Guardian group parameters decoded: group_id=${group_id.toHex()}`);
|
|
1004
|
+
return {
|
|
1005
|
+
groupId: group_id.toHex(),
|
|
1006
|
+
groupPk: group_pk.toHex(),
|
|
1007
|
+
tauParams: tau_params.toHex(),
|
|
1008
|
+
aggKey: agg_key.toHex(),
|
|
1009
|
+
guardians
|
|
1010
|
+
};
|
|
1011
|
+
};
|
|
937
1012
|
|
|
938
1013
|
// src/guardian/join.ts
|
|
939
1014
|
async function joinGuardian(account, prefs) {
|
|
940
1015
|
const api2 = await getApi();
|
|
941
1016
|
assert(api2, "API not initialized");
|
|
942
1017
|
assert(account, "Account not initialized");
|
|
943
|
-
const computeOpts = _optionalChain([prefs, 'access',
|
|
1018
|
+
const computeOpts = _optionalChain([prefs, 'access', _54 => _54.compute, 'optionalAccess', _55 => _55.split, 'call', _56 => _56(","), 'access', _57 => _57.map, 'call', _58 => _58((s) => s.trim()), 'access', _59 => _59.filter, 'call', _60 => _60((s) => s.length > 0)]) || void 0;
|
|
944
1019
|
const feeThreshold = typeof prefs.fee === "bigint" ? prefs.fee : BigInt(prefs.fee || "0");
|
|
945
1020
|
const guardianPrefs = {
|
|
946
1021
|
pubKey: account.publicKey,
|
|
@@ -948,11 +1023,11 @@ async function joinGuardian(account, prefs) {
|
|
|
948
1023
|
verifier: prefs.verifier,
|
|
949
1024
|
compute: prefs.compute ? true : false,
|
|
950
1025
|
computePrefs: {
|
|
951
|
-
trusted: _optionalChain([computeOpts, 'optionalAccess',
|
|
952
|
-
tee: _optionalChain([computeOpts, 'optionalAccess',
|
|
953
|
-
mpc: _optionalChain([computeOpts, 'optionalAccess',
|
|
954
|
-
fhe: _optionalChain([computeOpts, 'optionalAccess',
|
|
955
|
-
zkp: _optionalChain([computeOpts, 'optionalAccess',
|
|
1026
|
+
trusted: _optionalChain([computeOpts, 'optionalAccess', _61 => _61.includes, 'call', _62 => _62("trusted")]) || false,
|
|
1027
|
+
tee: _optionalChain([computeOpts, 'optionalAccess', _63 => _63.includes, 'call', _64 => _64("tee")]) || false,
|
|
1028
|
+
mpc: _optionalChain([computeOpts, 'optionalAccess', _65 => _65.includes, 'call', _66 => _66("mpc")]) || false,
|
|
1029
|
+
fhe: _optionalChain([computeOpts, 'optionalAccess', _67 => _67.includes, 'call', _68 => _68("fhe")]) || false,
|
|
1030
|
+
zkp: _optionalChain([computeOpts, 'optionalAccess', _69 => _69.includes, 'call', _70 => _70("zkp")]) || false
|
|
956
1031
|
},
|
|
957
1032
|
feeThreshold
|
|
958
1033
|
};
|
|
@@ -980,7 +1055,7 @@ var signAndSend = async (request, account, opts = DEFAULT_COMPUTE_PAYLOAD) => {
|
|
|
980
1055
|
});
|
|
981
1056
|
});
|
|
982
1057
|
if (tx_result.isError) {
|
|
983
|
-
throw new Error(`Transaction failed with error: ${tx_result.
|
|
1058
|
+
throw new Error(`Transaction failed with error: ${tx_result.dispatchError}`);
|
|
984
1059
|
}
|
|
985
1060
|
if (tx_result.dispatchError) {
|
|
986
1061
|
throw new Error(
|
|
@@ -991,8 +1066,8 @@ var signAndSend = async (request, account, opts = DEFAULT_COMPUTE_PAYLOAD) => {
|
|
|
991
1066
|
`Transaction ${tx_result.txHash.toHex()} included in timepoint ${tx_result.blockNumber}-${tx_result.txIndex}`
|
|
992
1067
|
);
|
|
993
1068
|
return {
|
|
994
|
-
blockNumber: _optionalChain([tx_result, '
|
|
995
|
-
index:
|
|
1069
|
+
blockNumber: _nullishCoalesce(_optionalChain([tx_result, 'access', _71 => _71.blockNumber, 'optionalAccess', _72 => _72.toNumber, 'call', _73 => _73()]), () => ( 0)),
|
|
1070
|
+
index: _nullishCoalesce(tx_result.txIndex, () => ( 0)),
|
|
996
1071
|
hash: tx_result.txHash.toHex(),
|
|
997
1072
|
tx_result
|
|
998
1073
|
};
|
|
@@ -1010,14 +1085,14 @@ var getGuardianAddress = async () => {
|
|
|
1010
1085
|
const api2 = await getApi();
|
|
1011
1086
|
if (!api2) throw new Error("API not initialized");
|
|
1012
1087
|
assert(
|
|
1013
|
-
_util.isFunction.call(void 0, _optionalChain([api2, 'access',
|
|
1014
|
-
`api.query.guardian.
|
|
1088
|
+
_util.isFunction.call(void 0, _optionalChain([api2, 'access', _74 => _74.query, 'access', _75 => _75["guardian"], 'optionalAccess', _76 => _76["workerByKey"]])),
|
|
1089
|
+
`api.query.guardian.workerByKey does not exist`
|
|
1015
1090
|
);
|
|
1016
1091
|
const list = await getGuardianList();
|
|
1017
1092
|
const addresses = await Promise.all(
|
|
1018
1093
|
list.map(async (item) => {
|
|
1019
|
-
const peerid = _bs582.default.decode(item).slice(
|
|
1020
|
-
return (await api2.query["guardian"]["
|
|
1094
|
+
const peerid = _bs582.default.decode(item).slice(6, 38);
|
|
1095
|
+
return (await api2.query["guardian"]["workerByKey"](peerid)).toString();
|
|
1021
1096
|
})
|
|
1022
1097
|
);
|
|
1023
1098
|
return list.map((peerid, index) => ({ peerid, address: addresses[index] }));
|
|
@@ -1030,7 +1105,7 @@ var getGuardianNwParams = async () => {
|
|
|
1030
1105
|
const section = "guardian";
|
|
1031
1106
|
const method = "guardianNwParams";
|
|
1032
1107
|
assert(
|
|
1033
|
-
_util.isFunction.call(void 0, _optionalChain([rpc, 'access',
|
|
1108
|
+
_util.isFunction.call(void 0, _optionalChain([rpc, 'access', _77 => _77[section], 'optionalAccess', _78 => _78[method]])),
|
|
1034
1109
|
`api.rpc.${section}.guardianNwParams does not exist`
|
|
1035
1110
|
);
|
|
1036
1111
|
const guardianNwParams = await rpc[section][method]();
|
|
@@ -1044,6 +1119,149 @@ var getGuardianNwParams = async () => {
|
|
|
1044
1119
|
throw error;
|
|
1045
1120
|
}
|
|
1046
1121
|
};
|
|
1122
|
+
async function fetchAndDecodeExtrinsic(blockHeight, extrinsicIndex) {
|
|
1123
|
+
const api2 = await getApi();
|
|
1124
|
+
if (!api2) throw new Error("API not initialized");
|
|
1125
|
+
const blockHash = await api2.rpc.chain.getBlockHash(blockHeight);
|
|
1126
|
+
const signedBlock = await api2.rpc.chain.getBlock(blockHash);
|
|
1127
|
+
const extrinsics = signedBlock.block.extrinsics;
|
|
1128
|
+
if (extrinsicIndex >= extrinsics.length) {
|
|
1129
|
+
throw new Error(
|
|
1130
|
+
`extrinsic index ${extrinsicIndex} out of range \u2014 block ${blockHeight} has ${extrinsics.length} extrinsics`
|
|
1131
|
+
);
|
|
1132
|
+
}
|
|
1133
|
+
const raw = extrinsics[extrinsicIndex];
|
|
1134
|
+
const decoded = raw.toHuman();
|
|
1135
|
+
return { raw, decoded };
|
|
1136
|
+
}
|
|
1137
|
+
var scanForBlockEvent = (api2, filter, startBlock, maxBlocks = 20) => {
|
|
1138
|
+
const hasPredicate = "predicate" in filter;
|
|
1139
|
+
let blocksScanned = 0;
|
|
1140
|
+
let done = false;
|
|
1141
|
+
return new Promise((resolve, reject) => {
|
|
1142
|
+
const unsubPromise = api2.rpc.chain.subscribeNewHeads(
|
|
1143
|
+
async (header) => {
|
|
1144
|
+
if (done) return;
|
|
1145
|
+
const currentBlock = header.number.toNumber();
|
|
1146
|
+
if (startBlock !== void 0 && currentBlock < startBlock) return;
|
|
1147
|
+
blocksScanned++;
|
|
1148
|
+
if (maxBlocks > 0 && blocksScanned > maxBlocks) {
|
|
1149
|
+
done = true;
|
|
1150
|
+
unsubPromise.then((unsub) => unsub());
|
|
1151
|
+
reject(new Error(`No matching event found within ${maxBlocks} blocks`));
|
|
1152
|
+
return;
|
|
1153
|
+
}
|
|
1154
|
+
try {
|
|
1155
|
+
const blockHash = await api2.rpc.chain.getBlockHash(currentBlock);
|
|
1156
|
+
const eventsResult = await api2.query.system.events.at(blockHash);
|
|
1157
|
+
const events = eventsResult;
|
|
1158
|
+
const blockData = await (hasPredicate ? api2.rpc.chain.getBlock(blockHash) : Promise.resolve(null));
|
|
1159
|
+
for (const record of events) {
|
|
1160
|
+
const { event, phase } = record;
|
|
1161
|
+
const matched = hasPredicate ? await filter.predicate(blockData, event, phase) : event.section.toLowerCase() === filter.section.toLowerCase() && event.method.toLowerCase() === filter.method.toLowerCase();
|
|
1162
|
+
if (!matched) continue;
|
|
1163
|
+
done = true;
|
|
1164
|
+
unsubPromise.then((unsub) => unsub());
|
|
1165
|
+
resolve({
|
|
1166
|
+
blockHash: blockHash.toHex(),
|
|
1167
|
+
blockNumber: currentBlock,
|
|
1168
|
+
extrinsicIndex: phase.isApplyExtrinsic ? phase.asApplyExtrinsic.toNumber() : null,
|
|
1169
|
+
block: blockData ? () => Promise.resolve(blockData) : () => api2.rpc.chain.getBlock(blockHash),
|
|
1170
|
+
events
|
|
1171
|
+
});
|
|
1172
|
+
return;
|
|
1173
|
+
}
|
|
1174
|
+
} catch (err) {
|
|
1175
|
+
debugLog(`scanForBlockEvent: error scanning block ${currentBlock}: ${err}`);
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
);
|
|
1179
|
+
});
|
|
1180
|
+
};
|
|
1181
|
+
async function watchForSubmissionReceipt(requestId, timeoutMs = 10 * 60 * 1e3) {
|
|
1182
|
+
const api2 = await getApi();
|
|
1183
|
+
if (!api2) throw new Error("API not initialized");
|
|
1184
|
+
return new Promise((resolve, reject) => {
|
|
1185
|
+
let unsubFn;
|
|
1186
|
+
let settled = false;
|
|
1187
|
+
const cleanup = (settleFn) => {
|
|
1188
|
+
if (settled) return;
|
|
1189
|
+
settled = true;
|
|
1190
|
+
_optionalChain([unsubFn, 'optionalCall', _79 => _79()]);
|
|
1191
|
+
settleFn();
|
|
1192
|
+
};
|
|
1193
|
+
const timer = setTimeout(
|
|
1194
|
+
() => cleanup(() => reject(new Error(`receipt watch timed out for requestId=${requestId}`))),
|
|
1195
|
+
timeoutMs
|
|
1196
|
+
);
|
|
1197
|
+
api2.rpc.chain.subscribeNewHeads(async (header) => {
|
|
1198
|
+
if (settled) return;
|
|
1199
|
+
try {
|
|
1200
|
+
const blockNumber = header.number.toNumber();
|
|
1201
|
+
const blockHash = header.hash;
|
|
1202
|
+
const signedBlock = await api2.rpc.chain.getBlock(blockHash);
|
|
1203
|
+
const extrinsics = signedBlock.block.extrinsics;
|
|
1204
|
+
for (let i = 0; i < extrinsics.length; i++) {
|
|
1205
|
+
const ext = extrinsics[i];
|
|
1206
|
+
const decoded = ext.toHuman();
|
|
1207
|
+
const method = _optionalChain([decoded, 'optionalAccess', _80 => _80.method]);
|
|
1208
|
+
if (String(_nullishCoalesce(_optionalChain([method, 'optionalAccess', _81 => _81.section]), () => ( ""))).toLowerCase() === "compute" && String(_nullishCoalesce(_optionalChain([method, 'optionalAccess', _82 => _82.method]), () => ( ""))).toLowerCase() === "result") {
|
|
1209
|
+
const args = _optionalChain([method, 'optionalAccess', _83 => _83.args]);
|
|
1210
|
+
const onChainId = String(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([args, 'optionalAccess', _84 => _84.request_id]), () => ( _optionalChain([args, 'optionalAccess', _85 => _85.requestId]))), () => ( _optionalChain([args, 'optionalAccess', _86 => _86[0]]))), () => ( "")));
|
|
1211
|
+
if (onChainId === requestId) {
|
|
1212
|
+
clearTimeout(timer);
|
|
1213
|
+
cleanup(
|
|
1214
|
+
() => resolve({
|
|
1215
|
+
extrinsicHash: ext.hash.toHex(),
|
|
1216
|
+
blockHeight: blockNumber,
|
|
1217
|
+
extrinsicIndex: i
|
|
1218
|
+
})
|
|
1219
|
+
);
|
|
1220
|
+
return;
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
} catch (err) {
|
|
1225
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1226
|
+
console.warn(`[watchReceipt] block check failed requestId=${requestId}: ${msg}`);
|
|
1227
|
+
}
|
|
1228
|
+
}).then((fn) => {
|
|
1229
|
+
if (settled) {
|
|
1230
|
+
fn();
|
|
1231
|
+
} else {
|
|
1232
|
+
unsubFn = fn;
|
|
1233
|
+
}
|
|
1234
|
+
}).catch((err) => {
|
|
1235
|
+
clearTimeout(timer);
|
|
1236
|
+
cleanup(() => reject(err));
|
|
1237
|
+
});
|
|
1238
|
+
});
|
|
1239
|
+
}
|
|
1240
|
+
async function getAgreementCreatedRequestId(blockHeight, extrinsicIndex) {
|
|
1241
|
+
const api2 = await getApi();
|
|
1242
|
+
if (!api2) throw new Error("API not initialized");
|
|
1243
|
+
const blockHash = await api2.rpc.chain.getBlockHash(blockHeight);
|
|
1244
|
+
const apiAt = await api2.at(blockHash);
|
|
1245
|
+
const allEvents = await apiAt.query.system.events();
|
|
1246
|
+
for (const record of allEvents) {
|
|
1247
|
+
const { phase, event } = record;
|
|
1248
|
+
if (!phase.isApplyExtrinsic || phase.asApplyExtrinsic.toNumber() !== extrinsicIndex) {
|
|
1249
|
+
continue;
|
|
1250
|
+
}
|
|
1251
|
+
if (String(_nullishCoalesce(event.section, () => ( ""))).toLowerCase() !== "compute" || String(_nullishCoalesce(event.method, () => ( ""))).toLowerCase() !== "agreementcreated") {
|
|
1252
|
+
continue;
|
|
1253
|
+
}
|
|
1254
|
+
const dataHuman = event.data.toHuman();
|
|
1255
|
+
if (Array.isArray(dataHuman)) {
|
|
1256
|
+
const first = dataHuman[0];
|
|
1257
|
+
if (first != null) return String(first);
|
|
1258
|
+
} else if (dataHuman !== null && typeof dataHuman === "object") {
|
|
1259
|
+
const id = _nullishCoalesce(_nullishCoalesce(dataHuman["requestId"], () => ( dataHuman["request_id"])), () => ( dataHuman["id"]));
|
|
1260
|
+
if (id != null) return String(id);
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
return null;
|
|
1264
|
+
}
|
|
1047
1265
|
|
|
1048
1266
|
// src/chain/onchainfs.ts
|
|
1049
1267
|
var getBlock2 = async (api2, blockNumber) => {
|
|
@@ -1082,12 +1300,10 @@ var MCryptFs = class _MCryptFs {
|
|
|
1082
1300
|
this._metaRef = metadataRef;
|
|
1083
1301
|
this._metadata = metadata;
|
|
1084
1302
|
this._init = true;
|
|
1303
|
+
this._chunkRefs = [];
|
|
1085
1304
|
}
|
|
1086
1305
|
static dummyInstance(mcryptApi) {
|
|
1087
|
-
return new _MCryptFs(mcryptApi, null,
|
|
1088
|
-
name: "on-chain-file-name.txt",
|
|
1089
|
-
description: "File uploaded using mcrypt-onchain-fs"
|
|
1090
|
-
});
|
|
1306
|
+
return new _MCryptFs(mcryptApi, null, null);
|
|
1091
1307
|
}
|
|
1092
1308
|
isValid() {
|
|
1093
1309
|
if (!this._metaRef) {
|
|
@@ -1151,8 +1367,8 @@ var MCryptFsWriter = class {
|
|
|
1151
1367
|
request.signAndSend(this._account, { app_id: 1 }, (result) => {
|
|
1152
1368
|
if (result.isInBlock || result.isFinalized || result.isError) {
|
|
1153
1369
|
resolve({
|
|
1154
|
-
blockNumber: _optionalChain([result, 'access',
|
|
1155
|
-
index: result.txIndex
|
|
1370
|
+
blockNumber: _nullishCoalesce(_optionalChain([result, 'access', _87 => _87.blockNumber, 'optionalAccess', _88 => _88.toNumber, 'call', _89 => _89()]), () => ( 0)),
|
|
1371
|
+
index: _nullishCoalesce(result.txIndex, () => ( 0))
|
|
1156
1372
|
});
|
|
1157
1373
|
}
|
|
1158
1374
|
});
|
|
@@ -1174,7 +1390,7 @@ var MCryptFsWriter = class {
|
|
|
1174
1390
|
ciphertext: uint8ArrayToBase64(Uint8Array.from(ciphertext)),
|
|
1175
1391
|
td_params,
|
|
1176
1392
|
group_pk: this._guardianInfo.groupPk,
|
|
1177
|
-
tau_params: this._guardianInfo.
|
|
1393
|
+
tau_params: this._guardianInfo.tauParams,
|
|
1178
1394
|
chosen_guardians: this._guardianInfo.guardians,
|
|
1179
1395
|
blobRef: [blobRef.blockNumber, blobRef.extrinsicIndex]
|
|
1180
1396
|
});
|
|
@@ -1217,7 +1433,7 @@ var MCryptFsWriter = class {
|
|
|
1217
1433
|
const metadataRef = await this.writeMetadata();
|
|
1218
1434
|
return await FileFromMetadataRef(this._api, [
|
|
1219
1435
|
metadataRef.blockNumber,
|
|
1220
|
-
metadataRef.index
|
|
1436
|
+
_nullishCoalesce(metadataRef.index, () => ( 0))
|
|
1221
1437
|
]);
|
|
1222
1438
|
}
|
|
1223
1439
|
};
|
|
@@ -1229,6 +1445,9 @@ var MCryptFsReader = class {
|
|
|
1229
1445
|
}
|
|
1230
1446
|
async downloadFile() {
|
|
1231
1447
|
const chunks = [];
|
|
1448
|
+
if (!this._onChainFile._metadata) {
|
|
1449
|
+
throw new Error("Metadata not loaded");
|
|
1450
|
+
}
|
|
1232
1451
|
let _blockNumber = this._onChainFile._metadata.startRef[0];
|
|
1233
1452
|
let _extIndex = this._onChainFile._metadata.startRef[1];
|
|
1234
1453
|
while (_blockNumber !== 0) {
|
|
@@ -1260,21 +1479,13 @@ var FileFromMetadataRef = async (mcryptApi, metadataRef) => {
|
|
|
1260
1479
|
};
|
|
1261
1480
|
|
|
1262
1481
|
// src/compute/agreement.ts
|
|
1263
|
-
|
|
1264
1482
|
async function createAgreement(contract, account) {
|
|
1265
1483
|
const api2 = await getApi();
|
|
1266
1484
|
if (!api2) throw new Error("Api not initialized");
|
|
1267
|
-
const
|
|
1268
|
-
const agreement = guardians.map((g) => _bs582.default.decode(g.peerid).subarray(6));
|
|
1269
|
-
const txContract = {
|
|
1270
|
-
...contract,
|
|
1271
|
-
guardians: guardians.map((g) => g.address)
|
|
1272
|
-
};
|
|
1273
|
-
const tx = api2.tx.compute.agreement(txContract);
|
|
1485
|
+
const tx = api2.tx["compute"]["agreement"](contract);
|
|
1274
1486
|
const opts = {
|
|
1275
1487
|
compute: {
|
|
1276
1488
|
da_type: 1,
|
|
1277
|
-
agreement,
|
|
1278
1489
|
verification: 0,
|
|
1279
1490
|
compute: contract.contract_type === "Active" ? 1 : 0
|
|
1280
1491
|
}
|
|
@@ -1285,28 +1496,27 @@ async function createAgreement(contract, account) {
|
|
|
1285
1496
|
opts
|
|
1286
1497
|
);
|
|
1287
1498
|
if (!tx_result.isError) {
|
|
1288
|
-
const agreementCreatedEvent = tx_result.events.find(
|
|
1289
|
-
|
|
1290
|
-
|
|
1499
|
+
const agreementCreatedEvent = tx_result.events.find(
|
|
1500
|
+
(event) => {
|
|
1501
|
+
return event.event.section === "compute" && event.event.method === "AgreementCreated";
|
|
1502
|
+
}
|
|
1503
|
+
);
|
|
1291
1504
|
if (agreementCreatedEvent) {
|
|
1292
|
-
debugLog(
|
|
1293
|
-
"Agreement data:",
|
|
1294
|
-
agreementCreatedEvent.event.data.toString()
|
|
1295
|
-
);
|
|
1505
|
+
debugLog("Agreement data:", agreementCreatedEvent.event.data.toString());
|
|
1296
1506
|
return {
|
|
1297
1507
|
blockNumber,
|
|
1298
|
-
index,
|
|
1508
|
+
index: _nullishCoalesce(index, () => ( 0)),
|
|
1299
1509
|
hash,
|
|
1300
|
-
agreementId: _nullishCoalesce(_optionalChain([agreementCreatedEvent, 'access',
|
|
1510
|
+
agreementId: _nullishCoalesce(_optionalChain([agreementCreatedEvent, 'access', _90 => _90.event, 'access', _91 => _91.data, 'access', _92 => _92[0], 'optionalAccess', _93 => _93.toHex, 'optionalCall', _94 => _94()]), () => ( agreementCreatedEvent.event.data.toString()))
|
|
1301
1511
|
};
|
|
1302
1512
|
} else {
|
|
1303
1513
|
debugLog("AgreementCreated event not found");
|
|
1304
1514
|
}
|
|
1305
1515
|
}
|
|
1306
|
-
return { blockNumber, index, hash };
|
|
1516
|
+
return { blockNumber, index: _nullishCoalesce(index, () => ( 0)), hash };
|
|
1307
1517
|
}
|
|
1308
1518
|
async function createSimpleAgreement() {
|
|
1309
|
-
const guardianIds = (await getGuardianAddress()).slice(0, 3);
|
|
1519
|
+
const guardianIds = (await getGuardianAddress()).slice(0, 3).map((g) => g.address);
|
|
1310
1520
|
assert(guardianIds.length === 3, "Not enough guardians to create agreement");
|
|
1311
1521
|
const contract = {
|
|
1312
1522
|
contract_type: "Dormant",
|
|
@@ -1315,9 +1525,9 @@ async function createSimpleAgreement() {
|
|
|
1315
1525
|
compute: {
|
|
1316
1526
|
cipher: "Plaintext",
|
|
1317
1527
|
computer_indices: [0, 1, 2],
|
|
1318
|
-
fees:
|
|
1528
|
+
fees: toAtomicPaliAmount("0.01"),
|
|
1319
1529
|
deadline: 0,
|
|
1320
|
-
confidentiality: { Trusted:
|
|
1530
|
+
confidentiality: { Trusted: 0 },
|
|
1321
1531
|
fee_function: null,
|
|
1322
1532
|
input: null,
|
|
1323
1533
|
program: { NativeData: "DaFalse" },
|
|
@@ -1332,9 +1542,7 @@ async function createSimpleAgreement() {
|
|
|
1332
1542
|
}
|
|
1333
1543
|
|
|
1334
1544
|
// src/compute/data.ts
|
|
1335
|
-
async function dataContract(params) {
|
|
1336
|
-
const keyring2 = await getKeyring();
|
|
1337
|
-
const account = keyring2.getPairs()[0];
|
|
1545
|
+
async function dataContract(params, account) {
|
|
1338
1546
|
const plaintextCipher = "Plaintext";
|
|
1339
1547
|
const atomicFees = toAtomicPaliAmount(_nullishCoalesce(params.fees, () => ( "0")));
|
|
1340
1548
|
const computeStep = {
|
|
@@ -1342,11 +1550,7 @@ async function dataContract(params) {
|
|
|
1342
1550
|
computer_indices: params.guardians.map((_, i) => i),
|
|
1343
1551
|
fees: atomicFees,
|
|
1344
1552
|
deadline: _nullishCoalesce(params.deadline, () => ( 0)),
|
|
1345
|
-
confidentiality: {
|
|
1346
|
-
Trusted: {
|
|
1347
|
-
trust_index: _nullishCoalesce(params.trustIndex, () => ( 0))
|
|
1348
|
-
}
|
|
1349
|
-
},
|
|
1553
|
+
confidentiality: { Trusted: _nullishCoalesce(params.trustIndex, () => ( 0)) },
|
|
1350
1554
|
fee_function: null,
|
|
1351
1555
|
input: {
|
|
1352
1556
|
Url: {
|
|
@@ -1369,9 +1573,7 @@ async function dataContract(params) {
|
|
|
1369
1573
|
}
|
|
1370
1574
|
|
|
1371
1575
|
// src/compute/inference.ts
|
|
1372
|
-
async function inferenceCompute(params) {
|
|
1373
|
-
const keyring2 = await getKeyring();
|
|
1374
|
-
const account = keyring2.getPairs()[0];
|
|
1576
|
+
async function inferenceCompute(params, account) {
|
|
1375
1577
|
const inputData = typeof params.input === "string" ? Array.from(new TextEncoder().encode(params.input)) : Array.from(params.input);
|
|
1376
1578
|
const atomicFees = toAtomicPaliAmount(_nullishCoalesce(params.fees, () => ( "0")));
|
|
1377
1579
|
const plaintextCipher = "Plaintext";
|
|
@@ -1380,7 +1582,7 @@ async function inferenceCompute(params) {
|
|
|
1380
1582
|
computer_indices: params.guardians.map((_, i) => i),
|
|
1381
1583
|
fees: atomicFees,
|
|
1382
1584
|
deadline: _nullishCoalesce(params.deadline, () => ( 0)),
|
|
1383
|
-
confidentiality: { Trusted:
|
|
1585
|
+
confidentiality: { Trusted: 0 },
|
|
1384
1586
|
fee_function: null,
|
|
1385
1587
|
input: { Inline: { data: inputData } },
|
|
1386
1588
|
program: { NativeExecute: "Inference" }
|
|
@@ -1406,10 +1608,10 @@ async function getGuardianParticipants() {
|
|
|
1406
1608
|
const currentIndex = await api2.query.guardian.currentIndex();
|
|
1407
1609
|
const peerid = await api2.rpc.system.localPeerId();
|
|
1408
1610
|
const _peerid = _bs582.default.decode((peerid || "").toString());
|
|
1409
|
-
const account = await api2.query.guardian.
|
|
1611
|
+
const account = await api2.query.guardian.workerByKey(_peerid.slice(6, 38));
|
|
1410
1612
|
const nextIndex = currentIndex ? Number(currentIndex) + 1 : 1;
|
|
1411
|
-
const guardiansList = _optionalChain([guardians, 'optionalAccess',
|
|
1412
|
-
const nextGuardiansList = _optionalChain([nextGuardians, 'optionalAccess',
|
|
1613
|
+
const guardiansList = _optionalChain([guardians, 'optionalAccess', _95 => _95.toJSON, 'call', _96 => _96()]) || [];
|
|
1614
|
+
const nextGuardiansList = _optionalChain([nextGuardians, 'optionalAccess', _97 => _97.toJSON, 'call', _98 => _98()]) || [];
|
|
1413
1615
|
const buildDetails = async (list) => {
|
|
1414
1616
|
return Promise.all(
|
|
1415
1617
|
list.map(async (guardian) => {
|
|
@@ -1418,21 +1620,21 @@ async function getGuardianParticipants() {
|
|
|
1418
1620
|
const bonded = await api2.query.staking.bonded(guardian);
|
|
1419
1621
|
const payee = await api2.query.staking.payee(guardian);
|
|
1420
1622
|
const stakersOverview = await api2.query.staking.erasStakersOverview(
|
|
1421
|
-
_optionalChain([currentEra, 'optionalAccess',
|
|
1623
|
+
_optionalChain([currentEra, 'optionalAccess', _99 => _99.toPrimitive, 'call', _100 => _100()]),
|
|
1422
1624
|
guardian
|
|
1423
1625
|
);
|
|
1424
1626
|
const guardianErasPrefs = await api2.query.staking.erasGuardianPrefs(
|
|
1425
|
-
_optionalChain([currentEra, 'optionalAccess',
|
|
1627
|
+
_optionalChain([currentEra, 'optionalAccess', _101 => _101.toPrimitive, 'call', _102 => _102()]),
|
|
1426
1628
|
guardian
|
|
1427
1629
|
);
|
|
1428
1630
|
return {
|
|
1429
1631
|
guardian,
|
|
1430
|
-
rewardDestination: _optionalChain([payee, 'optionalAccess',
|
|
1431
|
-
currentPreferences: _optionalChain([guardianErasPrefs, 'optionalAccess',
|
|
1432
|
-
upcomingPreferences: _optionalChain([guardianPrefs, 'optionalAccess',
|
|
1433
|
-
stash: _optionalChain([bonded, 'optionalAccess',
|
|
1434
|
-
currentStakeOverview: _optionalChain([stakersOverview, 'optionalAccess',
|
|
1435
|
-
upcomingStakeOverview: _optionalChain([ledger, 'optionalAccess',
|
|
1632
|
+
rewardDestination: _optionalChain([payee, 'optionalAccess', _103 => _103.toHuman]) ? payee.toHuman() : null,
|
|
1633
|
+
currentPreferences: _optionalChain([guardianErasPrefs, 'optionalAccess', _104 => _104.toHuman]) ? guardianErasPrefs.toHuman() : null,
|
|
1634
|
+
upcomingPreferences: _optionalChain([guardianPrefs, 'optionalAccess', _105 => _105.toHuman]) ? guardianPrefs.toHuman() : null,
|
|
1635
|
+
stash: _optionalChain([bonded, 'optionalAccess', _106 => _106.toHuman]) ? bonded.toHuman() : null,
|
|
1636
|
+
currentStakeOverview: _optionalChain([stakersOverview, 'optionalAccess', _107 => _107.toHuman]) ? stakersOverview.toHuman() : null,
|
|
1637
|
+
upcomingStakeOverview: _optionalChain([ledger, 'optionalAccess', _108 => _108.toHuman]) ? ledger.toHuman() : null
|
|
1436
1638
|
};
|
|
1437
1639
|
})
|
|
1438
1640
|
);
|
|
@@ -1441,12 +1643,12 @@ async function getGuardianParticipants() {
|
|
|
1441
1643
|
const upcomingGuardians = await buildDetails(nextGuardiansList);
|
|
1442
1644
|
return {
|
|
1443
1645
|
nwState: {
|
|
1444
|
-
localPeerId: _optionalChain([peerid, 'optionalAccess',
|
|
1445
|
-
worker: _optionalChain([account, 'optionalAccess',
|
|
1446
|
-
currentEra: _optionalChain([currentEra, 'optionalAccess',
|
|
1447
|
-
guardians: JSON.stringify(_optionalChain([guardians, 'optionalAccess',
|
|
1448
|
-
nextGuardians: JSON.stringify(_optionalChain([nextGuardians, 'optionalAccess',
|
|
1449
|
-
currentIndex: _optionalChain([currentIndex, 'optionalAccess',
|
|
1646
|
+
localPeerId: _optionalChain([peerid, 'optionalAccess', _109 => _109.toString, 'call', _110 => _110()]),
|
|
1647
|
+
worker: _optionalChain([account, 'optionalAccess', _111 => _111.toHuman]) ? account.toHuman() : null,
|
|
1648
|
+
currentEra: _optionalChain([currentEra, 'optionalAccess', _112 => _112.toHuman]) ? currentEra.toHuman() : null,
|
|
1649
|
+
guardians: JSON.stringify(_optionalChain([guardians, 'optionalAccess', _113 => _113.toHuman]) ? guardians.toHuman() : null, null, 2),
|
|
1650
|
+
nextGuardians: JSON.stringify(_optionalChain([nextGuardians, 'optionalAccess', _114 => _114.toHuman]) ? nextGuardians.toHuman() : null, null, 2),
|
|
1651
|
+
currentIndex: _optionalChain([currentIndex, 'optionalAccess', _115 => _115.toHuman]) ? currentIndex.toHuman() : null,
|
|
1450
1652
|
nextIndex
|
|
1451
1653
|
},
|
|
1452
1654
|
currentGuardians,
|
|
@@ -1458,9 +1660,7 @@ async function getGuardianParticipants() {
|
|
|
1458
1660
|
}
|
|
1459
1661
|
|
|
1460
1662
|
// src/compute/simple.ts
|
|
1461
|
-
async function simpleCompute(params) {
|
|
1462
|
-
const keyring2 = await getKeyring();
|
|
1463
|
-
const account = keyring2.getPairs()[0];
|
|
1663
|
+
async function simpleCompute(params, account) {
|
|
1464
1664
|
const plaintextCipher = "Plaintext";
|
|
1465
1665
|
const atomicFees = toAtomicPaliAmount(_nullishCoalesce(params.fees, () => ( "0")));
|
|
1466
1666
|
const computeStep = {
|
|
@@ -1468,18 +1668,9 @@ async function simpleCompute(params) {
|
|
|
1468
1668
|
computer_indices: params.guardians.map((_, i) => i),
|
|
1469
1669
|
fees: atomicFees,
|
|
1470
1670
|
deadline: _nullishCoalesce(params.deadline, () => ( 0)),
|
|
1471
|
-
confidentiality: {
|
|
1472
|
-
Trusted: {
|
|
1473
|
-
trust_index: _nullishCoalesce(params.trustIndex, () => ( 0))
|
|
1474
|
-
}
|
|
1475
|
-
},
|
|
1671
|
+
confidentiality: { Trusted: _nullishCoalesce(params.trustIndex, () => ( 0)) },
|
|
1476
1672
|
fee_function: null,
|
|
1477
|
-
input:
|
|
1478
|
-
ChainTransaction: {
|
|
1479
|
-
block_number: params.inputBlockNumber,
|
|
1480
|
-
extrinsic_index: params.inputExtrinsicIndex
|
|
1481
|
-
}
|
|
1482
|
-
},
|
|
1673
|
+
input: null,
|
|
1483
1674
|
program: {
|
|
1484
1675
|
Url: {
|
|
1485
1676
|
url: Array.from(new TextEncoder().encode(params.programUrl))
|
|
@@ -1551,11 +1742,7 @@ async function registerDataAgreement(account, params) {
|
|
|
1551
1742
|
computer_indices: params.guardians.map((_, i) => i),
|
|
1552
1743
|
fees: params.fees,
|
|
1553
1744
|
deadline: _nullishCoalesce(params.deadline, () => ( 0)),
|
|
1554
|
-
confidentiality: {
|
|
1555
|
-
Trusted: {
|
|
1556
|
-
trust_index: _nullishCoalesce(params.trustIndex, () => ( 0))
|
|
1557
|
-
}
|
|
1558
|
-
},
|
|
1745
|
+
confidentiality: { Trusted: _nullishCoalesce(params.trustIndex, () => ( 0)) },
|
|
1559
1746
|
fee_function: null,
|
|
1560
1747
|
input: {
|
|
1561
1748
|
ChainTransaction: {
|
|
@@ -1657,15 +1844,15 @@ async function submitTEDataWithCipher(account, data, chosenGuardians, tau_params
|
|
|
1657
1844
|
return {
|
|
1658
1845
|
ref,
|
|
1659
1846
|
cipher: {
|
|
1660
|
-
|
|
1661
|
-
|
|
1847
|
+
ThresholdHybrid: {
|
|
1848
|
+
threshold_params: {
|
|
1662
1849
|
SilentThreshold: {
|
|
1663
1850
|
td_params: Array.from(hexToUint8Array(encryptedKey)),
|
|
1664
1851
|
pk_bytes: Array.from(hexToUint8Array(group_pk)),
|
|
1665
1852
|
tau_params: Array.from(hexToUint8Array(tau_params))
|
|
1666
1853
|
}
|
|
1667
1854
|
},
|
|
1668
|
-
|
|
1855
|
+
symmetric_params: {
|
|
1669
1856
|
ChaCha20Poly1305: { nonce: Array.from(nonce) }
|
|
1670
1857
|
}
|
|
1671
1858
|
}
|
|
@@ -1830,9 +2017,9 @@ async function removeStake(account) {
|
|
|
1830
2017
|
const api2 = await getApi();
|
|
1831
2018
|
assert(api2, "API not initialized");
|
|
1832
2019
|
assert(account, "Account not initialized");
|
|
1833
|
-
const stakeAmount = await _asyncOptionalChain([(await api2.query.staking.ledger(account.address)), 'optionalAccess', async
|
|
1834
|
-
debugLog("Removing entire stake amount:", formatPaliAmount(_optionalChain([stakeAmount, 'optionalAccess',
|
|
1835
|
-
const unstakeTx = api2.tx.staking.unbond(_optionalChain([stakeAmount, 'optionalAccess',
|
|
2020
|
+
const stakeAmount = await _asyncOptionalChain([(await api2.query.staking.ledger(account.address)), 'optionalAccess', async _116 => _116.toPrimitive, 'call', async _117 => _117()]);
|
|
2021
|
+
debugLog("Removing entire stake amount:", formatPaliAmount(_optionalChain([stakeAmount, 'optionalAccess', _118 => _118.active]) || 0n));
|
|
2022
|
+
const unstakeTx = api2.tx.staking.unbond(_optionalChain([stakeAmount, 'optionalAccess', _119 => _119.active]) || 0n);
|
|
1836
2023
|
const hash = await signAndSend(unstakeTx, account);
|
|
1837
2024
|
debugLog(`Unstake transaction sent with hash: ${hash.hash}`);
|
|
1838
2025
|
}
|
|
@@ -1901,7 +2088,7 @@ async function rotateAndSetKeys(account) {
|
|
|
1901
2088
|
_assert2.default.call(void 0, api2, "API not initialized");
|
|
1902
2089
|
debugLog(`Rotating session keys for ${account.meta.name} on ${provider.endpoint}`);
|
|
1903
2090
|
const newKeys = await api2.rpc.author.rotateKeys();
|
|
1904
|
-
debugLog(`${account.meta.name} rotated keys on ${provider.endpoint}:`, _nullishCoalesce(_optionalChain([newKeys, 'optionalAccess',
|
|
2091
|
+
debugLog(`${account.meta.name} rotated keys on ${provider.endpoint}:`, _nullishCoalesce(_optionalChain([newKeys, 'optionalAccess', _120 => _120.toHex, 'optionalCall', _121 => _121()]), () => ( newKeys)));
|
|
1905
2092
|
const setKeysTx = api2.tx.session.setKeys(newKeys, []);
|
|
1906
2093
|
const hash = await signAndSend(setKeysTx, account);
|
|
1907
2094
|
debugLog(`Rotate session transaction sent with hash: ${hash.hash}`);
|
|
@@ -1910,7 +2097,7 @@ async function setWorker(account) {
|
|
|
1910
2097
|
const api2 = await getApi();
|
|
1911
2098
|
_assert2.default.call(void 0, api2, "API not initialized");
|
|
1912
2099
|
const peerid = _bs582.default.decode((await api2.rpc.system.localPeerId()).toString());
|
|
1913
|
-
const setWorkerTx = api2.tx.guardian.setWorker(peerid.slice(
|
|
2100
|
+
const setWorkerTx = api2.tx.guardian.setWorker(peerid.slice(6, 38));
|
|
1914
2101
|
const hash = await signAndSend(setWorkerTx, account);
|
|
1915
2102
|
debugLog(`Set worker id transaction sent with hash: ${hash.hash}`);
|
|
1916
2103
|
}
|
|
@@ -2007,5 +2194,10 @@ async function setWorker(account) {
|
|
|
2007
2194
|
|
|
2008
2195
|
|
|
2009
2196
|
|
|
2010
|
-
|
|
2197
|
+
|
|
2198
|
+
|
|
2199
|
+
|
|
2200
|
+
|
|
2201
|
+
|
|
2202
|
+
exports.API_EXTENSIONS = API_EXTENSIONS; exports.API_RPC = API_RPC; exports.API_TYPES = API_TYPES; exports.AccountSourceType = AccountSourceType; exports.ApiPromise = _api2.ApiPromise; exports.CryptoType = CryptoType; exports.DEBUG = DEBUG; exports.DEFAULT_COMPUTE_PAYLOAD = DEFAULT_COMPUTE_PAYLOAD; exports.DEFAULT_EMPTY_PAYLOAD = DEFAULT_EMPTY_PAYLOAD; exports.FileFromMetadataRef = FileFromMetadataRef; exports.HttpProvider = _api2.HttpProvider; exports.MCryptFs = MCryptFs; exports.MCryptFsReader = MCryptFsReader; exports.MCryptFsWriter = MCryptFsWriter; exports.PALI_DECIMALS = PALI_DECIMALS; exports.PALI_SYMBOL = PALI_SYMBOL; exports.PALLIORA_RPC_URL = PALLIORA_RPC_URL; exports.PALLIORA_WS = PALLIORA_WS; exports.TX_WAIT_FINALIZATION = TX_WAIT_FINALIZATION; exports.WsProvider = _api2.WsProvider; exports.addStake = addStake; exports.base64ToUint8Array = base64ToUint8Array; exports.clearTokenCache = clearTokenCache; exports.configure = configure; exports.createAccount = createAccount; exports.createAgreement = createAgreement; exports.createGuardianGroup = createGuardianGroup; exports.createGuardianGroupAndWatch = createGuardianGroupAndWatch; exports.createSimpleAgreement = createSimpleAgreement; exports.dataContract = dataContract; exports.debugLog = debugLog; exports.decodeAggregateKey = decodeAggregateKey; exports.decodeField = decodeField; exports.decodePowersOfTau = decodePowersOfTau; exports.decrypt = decrypt; exports.ecncryptTest = encrypt; exports.encodeCiphertext = encodeCiphertext; exports.encrypt = encrypt2; exports.fetchAndDecodeExtrinsic = fetchAndDecodeExtrinsic; exports.fetchTokenProperties = fetchTokenProperties; exports.formatBalanceWithTokenProperties = formatBalanceWithTokenProperties; exports.formatPaliAmount = formatPaliAmount; exports.fromAtomicPaliAmount = fromAtomicPaliAmount; exports.fundAccount = fundAccount; exports.gen_shared_key = gen_shared_key; exports.gen_stretched_key = gen_stretched_key; exports.generateRandomBytes = generateRandomBytes; exports.getAgreementCreatedRequestId = getAgreementCreatedRequestId; exports.getApi = getApi; exports.getCachedTokenProperties = getCachedTokenProperties; exports.getEncKeyring = getEncKeyring; exports.getFileMetadataCall = getFileMetadataCall; exports.getGuardianAddress = getGuardianAddress; exports.getGuardianList = getGuardianList; exports.getGuardianNwParams = getGuardianNwParams; exports.getGuardianParticipants = getGuardianParticipants; exports.getKeyring = getKeyring; exports.hexToUint8Array = hexToUint8Array; exports.inferenceCompute = inferenceCompute; exports.joinGuardian = joinGuardian; exports.joinIdleStaker = joinIdleStaker; exports.joinValidator = joinValidator; exports.newStake = newStake; exports.pairFromPrivateKeyHex = pairFromPrivateKeyHex; exports.payoutStake = payoutStake; exports.provider = provider; exports.reduceStake = reduceStake; exports.registerDataAgreement = registerDataAgreement; exports.removeStake = removeStake; exports.rotateAndSetKeys = rotateAndSetKeys; exports.runAgent = runAgent; exports.scanForBlockEvent = scanForBlockEvent; exports.setIdentity = setIdentity; exports.setWorker = setWorker; exports.signAndSend = signAndSend; exports.simpleCompute = simpleCompute; exports.submitData = submitData; exports.submitTEData = submitTEData; exports.submitTEDataWithCipher = submitTEDataWithCipher; exports.testCrypt = testCrypt; exports.toAtomicPaliAmount = toAtomicPaliAmount; exports.tokenToBigint = tokenToBigint; exports.transfer = transfer; exports.uint8ArrayToBase64 = uint8ArrayToBase64; exports.uploadData = uploadData; exports.uploadDataLegacy = uploadDataLegacy; exports.utilCrypto = utilCrypto; exports.wasmCrypto = wasmCrypto; exports.watchForSubmissionReceipt = watchForSubmissionReceipt; exports.withdrawStake = withdrawStake; exports.writeMetadata = writeMetadata;
|
|
2011
2203
|
//# sourceMappingURL=index.cjs.map
|