@prosopo/scripts 0.2.10 → 0.2.11
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/scripts/fluxDeploy.d.ts +2 -0
- package/dist/scripts/fluxDeploy.d.ts.map +1 -0
- package/dist/scripts/fluxDeploy.js +136 -0
- package/dist/scripts/fluxDeploy.js.map +1 -0
- package/dist/scripts/getStorage.js +6 -6
- package/dist/scripts/getStorage.js.map +1 -1
- package/dist/scripts/sep256k1Sign.d.ts +4 -0
- package/dist/scripts/sep256k1Sign.d.ts.map +1 -0
- package/dist/scripts/sep256k1Sign.js +80 -0
- package/dist/scripts/sep256k1Sign.js.map +1 -0
- package/package.json +24 -21
- package/dist/scripts/getBalance.d.ts +0 -2
- package/dist/scripts/getBalance.d.ts.map +0 -1
- package/dist/scripts/getBalance.js +0 -15
- package/dist/scripts/getBalance.js.map +0 -1
- package/dist/scripts/getNetworks.d.ts +0 -2
- package/dist/scripts/getNetworks.d.ts.map +0 -1
- package/dist/scripts/getNetworks.js +0 -38
- package/dist/scripts/getNetworks.js.map +0 -1
- package/dist/scripts/getValidators.d.ts +0 -2
- package/dist/scripts/getValidators.d.ts.map +0 -1
- package/dist/scripts/getValidators.js +0 -32
- package/dist/scripts/getValidators.js.map +0 -1
- package/dist/scripts/mnemonicFromSeed.d.ts +0 -2
- package/dist/scripts/mnemonicFromSeed.d.ts.map +0 -1
- package/dist/scripts/mnemonicFromSeed.js +0 -30
- package/dist/scripts/mnemonicFromSeed.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fluxDeploy.d.ts","sourceRoot":"","sources":["../../src/scripts/fluxDeploy.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { at } from '@prosopo/util';
|
|
2
|
+
import { base64Encode } from '@polkadot/util-crypto';
|
|
3
|
+
import { getLogger } from '@prosopo/common';
|
|
4
|
+
import { loadEnv } from '@prosopo/cli';
|
|
5
|
+
import { sign, wifToPrivateKey } from './sep256k1Sign.js';
|
|
6
|
+
import axios from 'axios';
|
|
7
|
+
import qs from 'qs';
|
|
8
|
+
const log = getLogger(`Info`, `fluxDeploy.js`);
|
|
9
|
+
const errorHandler = (axiosResponse) => {
|
|
10
|
+
if (axiosResponse.data && axiosResponse.data.status === 'error') {
|
|
11
|
+
throw new Error(axiosResponse.data.data.message);
|
|
12
|
+
}
|
|
13
|
+
return axiosResponse;
|
|
14
|
+
};
|
|
15
|
+
const getLoginPhrase = async (url) => {
|
|
16
|
+
const apiURL = new URL(`${url || 'https://api.runonflux.io/'}id/loginphrase`);
|
|
17
|
+
log.info('Calling:', apiURL.href);
|
|
18
|
+
const response = await axios.get(apiURL.toString());
|
|
19
|
+
errorHandler(response);
|
|
20
|
+
return response.data.data;
|
|
21
|
+
};
|
|
22
|
+
const getFluxAppsDetails = async (zelId, signature, loginPhrase) => {
|
|
23
|
+
const apiUrl = `https://jetpackbridge.runonflux.io/api/v1/dapps.php?filter=&zelid=${zelId}&signature=${signature}&loginPhrase=${loginPhrase}`;
|
|
24
|
+
const response = await axios.get(apiUrl);
|
|
25
|
+
errorHandler(response);
|
|
26
|
+
return response.data;
|
|
27
|
+
};
|
|
28
|
+
const getIndividualFluxAppDetails = async (dappName, zelId, signature, loginPhrase) => {
|
|
29
|
+
const apiUrl = `https://jetpackbridge.runonflux.io/api/v1/dapps.php?dapp=${dappName}&zelid=${zelId}&signature=${signature}&loginPhrase=${loginPhrase}`;
|
|
30
|
+
const response = await axios.get(apiUrl);
|
|
31
|
+
errorHandler(response);
|
|
32
|
+
return response.data;
|
|
33
|
+
};
|
|
34
|
+
const getFluxOSURLs = async (dappName, zelId, signature, loginPhrase) => {
|
|
35
|
+
const data = await getIndividualFluxAppDetails(dappName, zelId, signature, loginPhrase);
|
|
36
|
+
// return the fluxOS urls
|
|
37
|
+
return Object.values(data.nodes).map((node) => node.fluxos);
|
|
38
|
+
};
|
|
39
|
+
const verifyLogin = async (zelid, signature, loginPhrase, url) => {
|
|
40
|
+
const apiUrl = new URL(`${url || 'api.runonfux.io/'}id/verifylogin`).toString();
|
|
41
|
+
const data = qs.stringify({
|
|
42
|
+
zelid,
|
|
43
|
+
signature,
|
|
44
|
+
loginPhrase,
|
|
45
|
+
});
|
|
46
|
+
log.info('Data:', data);
|
|
47
|
+
const response = await axios.post(apiUrl, data, {
|
|
48
|
+
method: 'POST',
|
|
49
|
+
headers: { 'Content-Type': `application/x-www-form-urlencoded` },
|
|
50
|
+
});
|
|
51
|
+
errorHandler(response);
|
|
52
|
+
return response;
|
|
53
|
+
};
|
|
54
|
+
const softRedeploy = async (zelid, signature, loginPhrase, url) => {
|
|
55
|
+
const apiUrl = new URL(`${url}apps/redeploy/imageServer/false/true`).toString();
|
|
56
|
+
const Zelidauth = qs.stringify({
|
|
57
|
+
zelid,
|
|
58
|
+
signature,
|
|
59
|
+
loginPhrase,
|
|
60
|
+
});
|
|
61
|
+
const response = await axios.get(apiUrl, {
|
|
62
|
+
method: 'GET',
|
|
63
|
+
headers: {
|
|
64
|
+
Zelidauth: Zelidauth,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
errorHandler(response);
|
|
68
|
+
return response;
|
|
69
|
+
};
|
|
70
|
+
const setupArgs = () => {
|
|
71
|
+
const appName = process.argv.slice(2)[0];
|
|
72
|
+
if (!appName) {
|
|
73
|
+
throw new Error('Please provide an app name');
|
|
74
|
+
}
|
|
75
|
+
const secretWIFKey = process.env.ZELCORE_PRIVATE_KEY;
|
|
76
|
+
if (!secretWIFKey) {
|
|
77
|
+
throw new Error('No private key provided');
|
|
78
|
+
}
|
|
79
|
+
const zelId = process.env.ZELCORE_PUBLIC_KEY;
|
|
80
|
+
if (!zelId) {
|
|
81
|
+
throw new Error('No zelId provided');
|
|
82
|
+
}
|
|
83
|
+
const secretKey = wifToPrivateKey(secretWIFKey);
|
|
84
|
+
return { appName, secretKey, zelId };
|
|
85
|
+
};
|
|
86
|
+
const getNodeAPIURL = (nodeUIURL) => {
|
|
87
|
+
const port = at(nodeUIURL.split(':'), 1);
|
|
88
|
+
const portLogin = Number(port) + 1;
|
|
89
|
+
const nodeAPIURL = new URL(`http://${nodeUIURL.replace(port, portLogin.toString())}`);
|
|
90
|
+
log.info('Node API URL:', nodeAPIURL);
|
|
91
|
+
return new URL(`http://${nodeUIURL.replace(port, portLogin.toString())}`);
|
|
92
|
+
};
|
|
93
|
+
const getNode = async (appName, zelId, secretKey) => {
|
|
94
|
+
// Get Flux login phrase
|
|
95
|
+
const loginPhrase = await getLoginPhrase();
|
|
96
|
+
log.info('Login Phrase:', loginPhrase);
|
|
97
|
+
const signature = base64Encode(await sign(loginPhrase, { secretKey }));
|
|
98
|
+
log.info('Signature:', signature);
|
|
99
|
+
// Get details of individual Flux app
|
|
100
|
+
const individualNodeIPs = await getFluxOSURLs(appName, zelId, signature, loginPhrase);
|
|
101
|
+
log.info('Individual Node IPs:', individualNodeIPs);
|
|
102
|
+
// Choose a node at random from individualNodeIPs
|
|
103
|
+
const node = individualNodeIPs[Math.floor(Math.random() * individualNodeIPs.length)];
|
|
104
|
+
if (!node) {
|
|
105
|
+
throw new Error('Failed to randomly select node');
|
|
106
|
+
}
|
|
107
|
+
log.info('Node:', node);
|
|
108
|
+
return node;
|
|
109
|
+
};
|
|
110
|
+
(async () => {
|
|
111
|
+
try {
|
|
112
|
+
loadEnv();
|
|
113
|
+
const { appName, secretKey, zelId } = setupArgs();
|
|
114
|
+
// Get a Flux node
|
|
115
|
+
const nodeUIURL = await getNode(appName, zelId, secretKey);
|
|
116
|
+
// Get the admin API URL as it is different from the UI URL
|
|
117
|
+
const nodeAPIURL = getNodeAPIURL(nodeUIURL);
|
|
118
|
+
// Get a login token from the node
|
|
119
|
+
const nodeLoginPhrase = await getLoginPhrase(nodeAPIURL);
|
|
120
|
+
log.info('Node Login Phrase:', nodeLoginPhrase);
|
|
121
|
+
// Sign the login token with zelcore private key
|
|
122
|
+
const nodeSignature = base64Encode(await sign(nodeLoginPhrase, { secretKey }));
|
|
123
|
+
log.info('Node Signature:', nodeSignature);
|
|
124
|
+
// Login to the node
|
|
125
|
+
await verifyLogin(zelId, nodeSignature, nodeLoginPhrase, nodeAPIURL);
|
|
126
|
+
// Soft redeploy the app
|
|
127
|
+
const redployResponse = await softRedeploy(zelId, nodeSignature, nodeLoginPhrase, nodeAPIURL);
|
|
128
|
+
log.info(redployResponse.data);
|
|
129
|
+
process.exit(0);
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
log.error('An error occurred:', error);
|
|
133
|
+
process.exit(1);
|
|
134
|
+
}
|
|
135
|
+
})();
|
|
136
|
+
//# sourceMappingURL=fluxDeploy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fluxDeploy.js","sourceRoot":"","sources":["../../src/scripts/fluxDeploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,eAAe,CAAA;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACzD,OAAO,KAAwB,MAAM,OAAO,CAAA;AAC5C,OAAO,EAAE,MAAM,IAAI,CAAA;AAEnB,MAAM,GAAG,GAAG,SAAS,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;AAoF9C,MAAM,YAAY,GAAG,CAAC,aAA4B,EAAE,EAAE;IAClD,IAAI,aAAa,CAAC,IAAI,IAAI,aAAa,CAAC,IAAI,CAAC,MAAM,KAAK,OAAO,EAAE;QAC7D,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;KACnD;IACD,OAAO,aAAa,CAAA;AACxB,CAAC,CAAA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UAAU,GAAG,aAAa,CAAC,SAAS,CAAC,CAAA;QAE3C,kCAAkC;QAClC,MAAM,eAAe,GAAG,MAAM,cAAc,CAAC,UAAU,CAAC,CAAA;QACxD,GAAG,CAAC,IAAI,CAAC,oBAAoB,EAAE,eAAe,CAAC,CAAA;QAE/C,gDAAgD;QAChD,MAAM,aAAa,GAAG,YAAY,CAAC,MAAM,IAAI,CAAC,eAAe,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,CAAA;QAC9E,GAAG,CAAC,IAAI,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAA;QAE1C,oBAAoB;QACpB,MAAM,WAAW,CAAC,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,UAAU,CAAC,CAAA;QAEpE,wBAAwB;QACxB,MAAM,eAAe,GAAG,MAAM,YAAY,CAAC,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,UAAU,CAAC,CAAA;QAE7F,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAA;QAC9B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;KAClB;IAAC,OAAO,KAAK,EAAE;QACZ,GAAG,CAAC,KAAK,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAA;QACtC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;KAClB;AACL,CAAC,CAAC,EAAE,CAAA"}
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
// limitations under the License.
|
|
14
14
|
import { ProviderEnvironment } from '@prosopo/env';
|
|
15
15
|
import { Tasks } from '@prosopo/provider';
|
|
16
|
-
import {
|
|
16
|
+
import { at } from '@prosopo/util';
|
|
17
|
+
import { defaultConfig, loadEnv } from '@prosopo/cli';
|
|
17
18
|
import { get } from '@prosopo/util';
|
|
18
19
|
import { getPairAsync } from '@prosopo/contract';
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
async function main() {
|
|
20
|
+
loadEnv();
|
|
21
|
+
async function main(storageKey) {
|
|
22
22
|
const config = defaultConfig();
|
|
23
23
|
const network = config.networks[config.defaultNetwork];
|
|
24
24
|
const pair = await getPairAsync(network, '//Alice');
|
|
@@ -26,12 +26,12 @@ async function main() {
|
|
|
26
26
|
await env.isReady();
|
|
27
27
|
const tasks = new Tasks(env);
|
|
28
28
|
const contract = tasks.contract;
|
|
29
|
-
const fn = get(contract,
|
|
29
|
+
const fn = get(contract, storageKey);
|
|
30
30
|
const dappAccounts = await fn();
|
|
31
31
|
console.log(dappAccounts.toHuman());
|
|
32
32
|
process.exit();
|
|
33
33
|
}
|
|
34
|
-
main().catch((error) => {
|
|
34
|
+
main(at(process.argv.slice(2), 0).trim()).catch((error) => {
|
|
35
35
|
console.error(error);
|
|
36
36
|
process.exit();
|
|
37
37
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getStorage.js","sourceRoot":"","sources":["../../src/scripts/getStorage.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"getStorage.js","sourceRoot":"","sources":["../../src/scripts/getStorage.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAA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
|
1
|
+
{"version":3,"file":"sep256k1Sign.d.ts","sourceRoot":"","sources":["../../src/scripts/sep256k1Sign.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAA;AA4BrD,wBAAsB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,EAAE,OAAO,CAAC,OAAO,CAAC,uBAW1E;AAMD,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAiBvD"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { BN_BE_256_OPTS } from '@polkadot/util-crypto/bn';
|
|
2
|
+
import { at } from '@prosopo/util';
|
|
3
|
+
import { base58Decode, base64Encode, cryptoWaitReady, sha256AsU8a } from '@polkadot/util-crypto';
|
|
4
|
+
import { bnToU8a, hexToU8a, u8aConcat, u8aToHex } from '@polkadot/util';
|
|
5
|
+
import { loadEnv } from '@prosopo/cli';
|
|
6
|
+
import { secp256k1 } from '@noble/curves/secp256k1';
|
|
7
|
+
import esMain from 'es-main';
|
|
8
|
+
import varuint from 'varuint-bitcoin';
|
|
9
|
+
loadEnv();
|
|
10
|
+
const MESSAGE_MAGIC = '\u0018Bitcoin Signed Message:\n';
|
|
11
|
+
function hash256(buffer) {
|
|
12
|
+
return Buffer.from(sha256AsU8a(sha256AsU8a(buffer)));
|
|
13
|
+
}
|
|
14
|
+
function hasher(message, messagePrefix) {
|
|
15
|
+
messagePrefix = messagePrefix || '\u0018Bitcoin Signed Message:\n';
|
|
16
|
+
const messagePrefixBuffer = Buffer.from(messagePrefix, 'utf8');
|
|
17
|
+
const messageBuffer = Buffer.from(message, 'utf8');
|
|
18
|
+
const messageVISize = varuint.encodingLength(messageBuffer.length);
|
|
19
|
+
const buffer = Buffer.allocUnsafe(messagePrefix.length + messageVISize + messageBuffer.length);
|
|
20
|
+
messagePrefixBuffer.copy(buffer, 0);
|
|
21
|
+
varuint.encode(messageBuffer.length, buffer, messagePrefixBuffer.length);
|
|
22
|
+
messageBuffer.copy(buffer, messagePrefixBuffer.length + messageVISize);
|
|
23
|
+
return hash256(buffer);
|
|
24
|
+
}
|
|
25
|
+
export async function sign(message, { secretKey }) {
|
|
26
|
+
if (!secretKey)
|
|
27
|
+
throw new Error('No secret key provided');
|
|
28
|
+
await cryptoWaitReady();
|
|
29
|
+
const data = hasher(message, MESSAGE_MAGIC);
|
|
30
|
+
const signature = secp256k1.sign(data, secretKey);
|
|
31
|
+
return u8aConcat(
|
|
32
|
+
// add 4 for compressed and then 27 for the 27th recovery byte
|
|
33
|
+
Buffer.alloc(1, signature.recovery + 4 + 27), bnToU8a(signature.r, BN_BE_256_OPTS), bnToU8a(signature.s, BN_BE_256_OPTS));
|
|
34
|
+
}
|
|
35
|
+
// https://bitcoin.stackexchange.com/a/61972
|
|
36
|
+
// <version><key><compression?><first 4 bytes of double sha256>
|
|
37
|
+
// 0x80..................................................................6430148d
|
|
38
|
+
// ..................................................................
|
|
39
|
+
export function wifToPrivateKey(wif) {
|
|
40
|
+
let substractLength;
|
|
41
|
+
if (wif.length === 51) {
|
|
42
|
+
// compression not included
|
|
43
|
+
substractLength = 8; // remove 4 bytes from WIF so 8 in hex
|
|
44
|
+
}
|
|
45
|
+
else if (wif.length === 52) {
|
|
46
|
+
// compression included
|
|
47
|
+
substractLength = 10; // remove 5 bytes from WIF so 10 in hex
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
throw new Error('Invalid WIF');
|
|
51
|
+
}
|
|
52
|
+
const secretKeyHexLong = u8aToHex(base58Decode(wif));
|
|
53
|
+
// remove 0x and the version byte prefix 80 from the start. Remove the Compression Byte suffix and the Checksum from
|
|
54
|
+
// the end
|
|
55
|
+
const secretKeyHex = `0x${secretKeyHexLong.substring(4, secretKeyHexLong.length - substractLength)}`;
|
|
56
|
+
return hexToU8a(secretKeyHex);
|
|
57
|
+
}
|
|
58
|
+
// if main process
|
|
59
|
+
if (esMain(import.meta)) {
|
|
60
|
+
const secretKey = wifToPrivateKey(process.env.ZELCORE_PRIVATE_KEY || '');
|
|
61
|
+
const publicKey = base58Decode(process.env.ZELCORE_PUBLIC_KEY || '');
|
|
62
|
+
const keypair = { secretKey, publicKey };
|
|
63
|
+
const message = at(process.argv.slice(2), 0).trim();
|
|
64
|
+
if (message.length === 0) {
|
|
65
|
+
console.error('No message provided');
|
|
66
|
+
process.exit();
|
|
67
|
+
}
|
|
68
|
+
sign(message, keypair)
|
|
69
|
+
.then((sig) => {
|
|
70
|
+
const hexSig = u8aToHex(sig);
|
|
71
|
+
console.log(`Hex signature : ${hexSig}`);
|
|
72
|
+
console.log(`Base64 signature: ${base64Encode(hexSig)}`);
|
|
73
|
+
process.exit();
|
|
74
|
+
})
|
|
75
|
+
.catch((error) => {
|
|
76
|
+
console.error(error);
|
|
77
|
+
process.exit();
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=sep256k1Sign.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sep256k1Sign.js","sourceRoot":"","sources":["../../src/scripts/sep256k1Sign.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAEzD,OAAO,EAAE,EAAE,EAAE,MAAM,eAAe,CAAA;AAClC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAChG,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACvE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,OAAO,MAAM,MAAM,SAAS,CAAA;AAC5B,OAAO,OAAO,MAAM,iBAAiB,CAAA;AAErC,OAAO,EAAE,CAAA;AACT,MAAM,aAAa,GAAG,iCAAiC,CAAA;AAEvD,SAAS,OAA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AAE,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;IACnD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;QACtB,OAAO,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAA;QACpC,OAAO,CAAC,IAAI,EAAE,CAAA;KACjB;IACD,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC;SACjB,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;QACV,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAA;QAC5B,OAAO,CAAC,GAAG,CAAC,qBAAqB,MAAM,EAAE,CAAC,CAAA;QAC1C,OAAO,CAAC,GAAG,CAAC,qBAAqB,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;QACxD,OAAO,CAAC,IAAI,EAAE,CAAA;IAClB,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QACb,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACpB,OAAO,CAAC,IAAI,EAAE,CAAA;IAClB,CAAC,CAAC,CAAA;CACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosopo/scripts",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.11",
|
|
4
4
|
"description": "Dev scripts for working with prosopo packages",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -26,29 +26,32 @@
|
|
|
26
26
|
"@polkadot/apps-config": "0.132.1",
|
|
27
27
|
"@polkadot/types": "10.9.1",
|
|
28
28
|
"@polkadot/util-crypto": "12.3.2",
|
|
29
|
-
"@prosopo/api": "0.2.
|
|
30
|
-
"@prosopo/cli": "0.2.
|
|
31
|
-
"@prosopo/common": "0.2.
|
|
32
|
-
"@prosopo/config": "0.2.
|
|
33
|
-
"@prosopo/contract": "0.2.
|
|
34
|
-
"@prosopo/database": "0.2.
|
|
35
|
-
"@prosopo/datasets": "0.2.
|
|
36
|
-
"@prosopo/datasets-fs": "0.2.
|
|
37
|
-
"@prosopo/env": "0.2.
|
|
38
|
-
"@prosopo/file-server": "0.2.
|
|
39
|
-
"@prosopo/procaptcha": "0.2.
|
|
40
|
-
"@prosopo/procaptcha-bundle": "0.2.
|
|
41
|
-
"@prosopo/procaptcha-react": "0.2.
|
|
42
|
-
"@prosopo/provider": "0.2.
|
|
43
|
-
"@prosopo/server": "0.2.
|
|
44
|
-
"@prosopo/types": "0.2.
|
|
45
|
-
"@prosopo/types-database": "0.2.
|
|
46
|
-
"@prosopo/types-env": "0.2.
|
|
47
|
-
"@prosopo/captcha-contract": "0.2.
|
|
48
|
-
"@prosopo/util": "0.2.
|
|
29
|
+
"@prosopo/api": "0.2.11",
|
|
30
|
+
"@prosopo/cli": "0.2.11",
|
|
31
|
+
"@prosopo/common": "0.2.11",
|
|
32
|
+
"@prosopo/config": "0.2.11",
|
|
33
|
+
"@prosopo/contract": "0.2.11",
|
|
34
|
+
"@prosopo/database": "0.2.11",
|
|
35
|
+
"@prosopo/datasets": "0.2.11",
|
|
36
|
+
"@prosopo/datasets-fs": "0.2.11",
|
|
37
|
+
"@prosopo/env": "0.2.11",
|
|
38
|
+
"@prosopo/file-server": "0.2.11",
|
|
39
|
+
"@prosopo/procaptcha": "0.2.11",
|
|
40
|
+
"@prosopo/procaptcha-bundle": "0.2.11",
|
|
41
|
+
"@prosopo/procaptcha-react": "0.2.11",
|
|
42
|
+
"@prosopo/provider": "0.2.11",
|
|
43
|
+
"@prosopo/server": "0.2.11",
|
|
44
|
+
"@prosopo/types": "0.2.11",
|
|
45
|
+
"@prosopo/types-database": "0.2.11",
|
|
46
|
+
"@prosopo/types-env": "0.2.11",
|
|
47
|
+
"@prosopo/captcha-contract": "0.2.11",
|
|
48
|
+
"@prosopo/util": "0.2.11",
|
|
49
49
|
"consola": "^3.2.3",
|
|
50
50
|
"dotenv": "^16.0.3",
|
|
51
|
+
"es-main": "^1.2.0",
|
|
51
52
|
"glob": "^10.0.0",
|
|
53
|
+
"qs": "^6.11.2",
|
|
54
|
+
"varuint-bitcoin": "^1.1.2",
|
|
52
55
|
"yargs": "^17.5.1",
|
|
53
56
|
"yargs-parser": "^21.0.1"
|
|
54
57
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getBalance.d.ts","sourceRoot":"","sources":["../../src/scripts/getBalance.ts"],"names":[],"mappings":""}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export {};
|
|
2
|
-
// Copyright 2021-2023 Prosopo (UK) Ltd.
|
|
3
|
-
//
|
|
4
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
// you may not use this file except in compliance with the License.
|
|
6
|
-
// You may obtain a copy of the License at
|
|
7
|
-
//
|
|
8
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
//
|
|
10
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
// See the License for the specific language governing permissions and
|
|
14
|
-
// limitations under the License.
|
|
15
|
-
//# sourceMappingURL=getBalance.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getBalance.js","sourceRoot":"","sources":["../../src/scripts/getBalance.ts"],"names":[],"mappings":";AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getNetworks.d.ts","sourceRoot":"","sources":["../../src/scripts/getNetworks.ts"],"names":[],"mappings":""}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
// Copyright 2021-2023 Prosopo (UK) Ltd.
|
|
2
|
-
//
|
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
// you may not use this file except in compliance with the License.
|
|
5
|
-
// You may obtain a copy of the License at
|
|
6
|
-
//
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
//
|
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
14
|
-
import { selectableNetworks } from '@polkadot/networks';
|
|
15
|
-
import { testParasRococoCommon } from '@polkadot/apps-config';
|
|
16
|
-
async function run() {
|
|
17
|
-
// // Construct
|
|
18
|
-
// const provider = 'ws://localhost:9944'
|
|
19
|
-
// // const provider = 'wss://shiden.public.blastapi.io'
|
|
20
|
-
// const wsProvider = new WsProvider(provider)
|
|
21
|
-
// const api = await ApiPromise.create({ provider: wsProvider })
|
|
22
|
-
selectableNetworks.forEach((network) => {
|
|
23
|
-
if (network.network === 'shiden')
|
|
24
|
-
console.log('Network:', network);
|
|
25
|
-
});
|
|
26
|
-
for (const testPara of testParasRococoCommon) {
|
|
27
|
-
if (testPara.info === 'rococoContracts') {
|
|
28
|
-
console.log('Test Para:', testPara);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
run()
|
|
33
|
-
.then(() => process.exit(0))
|
|
34
|
-
.catch((error) => {
|
|
35
|
-
console.error(error);
|
|
36
|
-
process.exit(-1);
|
|
37
|
-
});
|
|
38
|
-
//# sourceMappingURL=getNetworks.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getNetworks.js","sourceRoot":"","sources":["../../src/scripts/getNetworks.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,KAAK,UAAU,GAAG;IACd,eAAe;IACf,yCAAyC;IACzC,wDAAwD;IACxD,8CAA8C;IAC9C,gEAAgE;IAEhE,kBAAkB,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QACnC,IAAI,OAAO,CAAC,OAAO,KAAK,QAAQ;YAAE,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA;IACtE,CAAC,CAAC,CAAA;IACF,KAAK,MAAM,QAAQ,IAAI,qBAAqB,EAAE;QAC1C,IAAI,QAAQ,CAAC,IAAI,KAAK,iBAAiB,EAAE;YACrC,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAA;SACtC;KACJ;AACL,CAAC;AAED,GAAG,EAAE;KACA,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KAC3B,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACb,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACpB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;AACpB,CAAC,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getValidators.d.ts","sourceRoot":"","sources":["../../src/scripts/getValidators.ts"],"names":[],"mappings":""}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// Copyright 2021-2023 Prosopo (UK) Ltd.
|
|
2
|
-
//
|
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
// you may not use this file except in compliance with the License.
|
|
5
|
-
// You may obtain a copy of the License at
|
|
6
|
-
//
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
//
|
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
14
|
-
import { ApiPromise, WsProvider } from '@polkadot/api';
|
|
15
|
-
import { get } from '@prosopo/util';
|
|
16
|
-
const providers = {
|
|
17
|
-
kusama: { endpoint: 'wss://kusama-rpc.polkadot.io/' },
|
|
18
|
-
polkadot: { endpoint: 'wss://rpc.polkadot.io' },
|
|
19
|
-
};
|
|
20
|
-
async function run() {
|
|
21
|
-
// Construct
|
|
22
|
-
for (const provider in providers) {
|
|
23
|
-
const wsProvider = new WsProvider(get(providers, provider).endpoint);
|
|
24
|
-
const api = await ApiPromise.create({ provider: wsProvider });
|
|
25
|
-
// Do something
|
|
26
|
-
const validators = await api.query.staking.validators.keys();
|
|
27
|
-
console.log(`${validators.length} validators on ${provider}`);
|
|
28
|
-
}
|
|
29
|
-
process.exit();
|
|
30
|
-
}
|
|
31
|
-
run();
|
|
32
|
-
//# sourceMappingURL=getValidators.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getValidators.js","sourceRoot":"","sources":["../../src/scripts/getValidators.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAA;AAEnC,MAAM,SAAS,GAAG;IACd,MAAM,EAAE,EAAE,QAAQ,EAAE,+BAA+B,EAAE;IACrD,QAAQ,EAAE,EAAE,QAAQ,EAAE,uBAAuB,EAAE;CAClD,CAAA;AAED,KAAK,UAAU,GAAG;IACd,YAAY;IACZ,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;QAC9B,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAA;QACpE,MAAM,GAAG,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAA;QAE7D,eAAe;QACf,MAAM,UAAU,GAAG,MAAM,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,EAAE,CAAA;QAC5D,OAAO,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,MAAM,kBAAkB,QAAQ,EAAE,CAAC,CAAA;KAChE;IACD,OAAO,CAAC,IAAI,EAAE,CAAA;AAClB,CAAC;AAED,GAAG,EAAE,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mnemonicFromSeed.d.ts","sourceRoot":"","sources":["../../src/scripts/mnemonicFromSeed.ts"],"names":[],"mappings":""}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// Copyright 2021-2023 Prosopo (UK) Ltd.
|
|
2
|
-
//
|
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
// you may not use this file except in compliance with the License.
|
|
5
|
-
// You may obtain a copy of the License at
|
|
6
|
-
//
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
//
|
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
14
|
-
import { Keyring } from '@polkadot/keyring';
|
|
15
|
-
import { entropyToMnemonic } from '@polkadot/util-crypto/mnemonic/bip39';
|
|
16
|
-
import { hexToU8a } from '@polkadot/util';
|
|
17
|
-
async function mnemonic() {
|
|
18
|
-
const keyring = new Keyring({ type: 'ed25519', ss58Format: 5 });
|
|
19
|
-
const u8Entropy = hexToU8a('0x7723670fb49be71c81598c2245ae19d1f1685f032f3e98d160b648f23241f41e');
|
|
20
|
-
const mnemonic = entropyToMnemonic(u8Entropy);
|
|
21
|
-
console.log(`Mnemonic: ${mnemonic}`);
|
|
22
|
-
const account = keyring.addFromMnemonic(mnemonic);
|
|
23
|
-
console.log(`Address: ${account.address}`);
|
|
24
|
-
const account2 = keyring.addFromSeed(hexToU8a('0x7723670fb49be71c81598c2245ae19d1f1685f032f3e98d160b648f23241f41e'));
|
|
25
|
-
console.log(`Address: ${account2.address}`);
|
|
26
|
-
const ss58Format = 5;
|
|
27
|
-
}
|
|
28
|
-
mnemonic();
|
|
29
|
-
//0x7723670fb49be71c81598c2245ae19d1f1685f032f3e98d160b648f23241f41e
|
|
30
|
-
//# sourceMappingURL=mnemonicFromSeed.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mnemonicFromSeed.js","sourceRoot":"","sources":["../../src/scripts/mnemonicFromSeed.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,KAAK,UAAU,QAAQ;IACnB,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,CAAA;IAC/D,MAAM,SAAS,GAAG,QAAQ,CAAC,oEAAoE,CAAC,CAAA;IAChG,MAAM,QAAQ,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAA;IAC7C,OAAO,CAAC,GAAG,CAAC,aAAa,QAAQ,EAAE,CAAC,CAAA;IACpC,MAAM,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAA;IACjD,OAAO,CAAC,GAAG,CAAC,YAAY,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;IAC1C,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,oEAAoE,CAAC,CAAC,CAAA;IACpH,OAAO,CAAC,GAAG,CAAC,YAAY,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAA;IAC3C,MAAM,UAAU,GAAG,CAAC,CAAA;AACxB,CAAC;AAED,QAAQ,EAAE,CAAA;AAEV,oEAAoE"}
|