@prosopo/scripts 0.2.14 → 0.2.16
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/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +3 -20
- package/dist/cli/index.js.map +1 -1
- package/dist/contract/deploy/dapp.js +3 -5
- package/dist/contract/deploy/dapp.js.map +1 -1
- package/dist/contract/deploy/index.js +0 -13
- package/dist/contract/deploy/index.js.map +1 -1
- package/dist/contract/deploy/protocol.js +1 -17
- package/dist/contract/deploy/protocol.js.map +1 -1
- package/dist/contract/import.js +0 -46
- package/dist/contract/import.js.map +1 -1
- package/dist/contract/index.js +0 -13
- package/dist/contract/index.js.map +1 -1
- package/dist/index.js +0 -13
- package/dist/index.js.map +1 -1
- package/dist/scripts/addCopyrightNotice.js +0 -20
- package/dist/scripts/addCopyrightNotice.js.map +1 -1
- package/dist/scripts/bytesToHex.js +0 -13
- package/dist/scripts/bytesToHex.js.map +1 -1
- package/dist/scripts/convertAccount.js +0 -14
- package/dist/scripts/convertAccount.js.map +1 -1
- package/dist/scripts/encodeDecode.js +0 -13
- package/dist/scripts/encodeDecode.js.map +1 -1
- package/dist/scripts/fluxDeploy.d.ts +1 -1
- package/dist/scripts/fluxDeploy.d.ts.map +1 -1
- package/dist/scripts/fluxDeploy.js +20 -24
- package/dist/scripts/fluxDeploy.js.map +1 -1
- package/dist/scripts/generateMnemonic.js +14 -18
- package/dist/scripts/generateMnemonic.js.map +1 -1
- package/dist/scripts/getBlock.js +0 -15
- package/dist/scripts/getBlock.js.map +1 -1
- package/dist/scripts/getContractInfoOf.js +0 -13
- package/dist/scripts/getContractInfoOf.js.map +1 -1
- package/dist/scripts/getExistentialDeposit.js +0 -16
- package/dist/scripts/getExistentialDeposit.js.map +1 -1
- package/dist/scripts/getRandomProvider.js +1 -14
- package/dist/scripts/getRandomProvider.js.map +1 -1
- package/dist/scripts/getStorage.js +0 -13
- package/dist/scripts/getStorage.js.map +1 -1
- package/dist/scripts/hash.js +0 -15
- package/dist/scripts/hash.js.map +1 -1
- package/dist/scripts/hexToBytes.js +0 -13
- package/dist/scripts/hexToBytes.js.map +1 -1
- package/dist/scripts/populateTxAndSign.js +0 -63
- package/dist/scripts/populateTxAndSign.js.map +1 -1
- package/dist/scripts/sendFunds.js +0 -13
- package/dist/scripts/sendFunds.js.map +1 -1
- package/dist/scripts/sep256k1Sign.js +10 -20
- package/dist/scripts/sep256k1Sign.js.map +1 -1
- package/dist/scripts/setVersion.js +0 -18
- package/dist/scripts/setVersion.js.map +1 -1
- package/dist/setup/dapp.js +0 -16
- package/dist/setup/dapp.js.map +1 -1
- package/dist/setup/funds.d.ts +0 -15
- package/dist/setup/funds.d.ts.map +1 -1
- package/dist/setup/funds.js +1 -23
- package/dist/setup/funds.js.map +1 -1
- package/dist/setup/index.js +0 -13
- package/dist/setup/index.js.map +1 -1
- package/dist/setup/provider.js +0 -3
- package/dist/setup/provider.js.map +1 -1
- package/dist/setup/setup.d.ts +1 -0
- package/dist/setup/setup.d.ts.map +1 -1
- package/dist/setup/setup.js +16 -27
- package/dist/setup/setup.js.map +1 -1
- package/dist/util/exec.js +2 -15
- package/dist/util/exec.js.map +1 -1
- package/dist/util/index.js +0 -13
- package/dist/util/index.js.map +1 -1
- package/dist/util/loadContractFiles.js +0 -15
- package/dist/util/loadContractFiles.js.map +1 -1
- package/dist/util/updateEnv.js +0 -9
- package/dist/util/updateEnv.js.map +1 -1
- package/env.rococo +4 -4
- package/package.json +21 -22
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare function streamToJson(stream: ReadableStream<Uint8Array>): Promise<Record<any, any>>;
|
|
2
2
|
//# sourceMappingURL=fluxDeploy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fluxDeploy.d.ts","sourceRoot":"","sources":["../../src/scripts/fluxDeploy.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"fluxDeploy.d.ts","sourceRoot":"","sources":["../../src/scripts/fluxDeploy.ts"],"names":[],"mappings":"AAqGA,wBAAsB,YAAY,CAAC,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAEhG"}
|
|
@@ -5,21 +5,27 @@ import { loadEnv } from '@prosopo/cli';
|
|
|
5
5
|
import { sign, wifToPrivateKey } from './sep256k1Sign.js';
|
|
6
6
|
import qs from 'qs';
|
|
7
7
|
const log = getLogger(`Info`, `fluxDeploy.js`);
|
|
8
|
+
export async function streamToJson(stream) {
|
|
9
|
+
return await new Response(stream).json();
|
|
10
|
+
}
|
|
8
11
|
const errorHandler = async (response) => {
|
|
9
12
|
if (!response.ok) {
|
|
10
13
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
11
14
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
if (response.body && !response.bodyUsed) {
|
|
16
|
+
const data = await streamToJson(response.body);
|
|
17
|
+
if (data.status === 'error') {
|
|
18
|
+
throw new Error(data.data.message);
|
|
19
|
+
}
|
|
20
|
+
return data;
|
|
15
21
|
}
|
|
16
|
-
return
|
|
22
|
+
return {};
|
|
17
23
|
};
|
|
18
24
|
const getLoginPhrase = async (url) => {
|
|
19
25
|
const apiURL = new URL(`${url || 'https://api.runonflux.io/'}id/loginphrase`);
|
|
20
26
|
log.info('Calling:', apiURL.href);
|
|
21
27
|
const response = await fetch(apiURL.toString());
|
|
22
|
-
return await errorHandler(response);
|
|
28
|
+
return (await errorHandler(response)).data;
|
|
23
29
|
};
|
|
24
30
|
const getFluxAppsDetails = async (zelId, signature, loginPhrase) => {
|
|
25
31
|
const apiUrl = `https://jetpackbridge.runonflux.io/api/v1/dapps.php?filter=&zelid=${zelId}&signature=${signature}&loginPhrase=${loginPhrase}`;
|
|
@@ -33,17 +39,17 @@ const getIndividualFluxAppDetails = async (dappName, zelId, signature, loginPhra
|
|
|
33
39
|
};
|
|
34
40
|
const getFluxOSURLs = async (dappName, zelId, signature, loginPhrase) => {
|
|
35
41
|
const data = await getIndividualFluxAppDetails(dappName, zelId, signature, loginPhrase);
|
|
36
|
-
// return the fluxOS urls
|
|
37
42
|
return Object.values(data.nodes).map((node) => node.fluxos);
|
|
38
43
|
};
|
|
39
44
|
const verifyLogin = async (zelid, signature, loginPhrase, url) => {
|
|
40
|
-
const apiUrl = new URL(`${url || 'api.
|
|
45
|
+
const apiUrl = new URL(`${url || 'api.runonflux.io/'}id/verifylogin`).toString();
|
|
41
46
|
const data = qs.stringify({
|
|
42
47
|
zelid,
|
|
43
48
|
signature,
|
|
44
49
|
loginPhrase,
|
|
45
50
|
});
|
|
46
51
|
log.info('Data:', data);
|
|
52
|
+
log.info('apiUrl:', apiUrl);
|
|
47
53
|
const response = await fetch(apiUrl, {
|
|
48
54
|
method: 'POST',
|
|
49
55
|
body: data,
|
|
@@ -51,8 +57,8 @@ const verifyLogin = async (zelid, signature, loginPhrase, url) => {
|
|
|
51
57
|
});
|
|
52
58
|
return await errorHandler(response);
|
|
53
59
|
};
|
|
54
|
-
const softRedeploy = async (zelid, signature, loginPhrase, url) => {
|
|
55
|
-
const apiUrl = new URL(`${url}apps/redeploy/
|
|
60
|
+
const softRedeploy = async (zelid, signature, loginPhrase, url, appName) => {
|
|
61
|
+
const apiUrl = new URL(`${url}apps/redeploy/${appName}/false/true`).toString();
|
|
56
62
|
const Zelidauth = qs.stringify({
|
|
57
63
|
zelid,
|
|
58
64
|
signature,
|
|
@@ -64,19 +70,18 @@ const softRedeploy = async (zelid, signature, loginPhrase, url) => {
|
|
|
64
70
|
Zelidauth: Zelidauth,
|
|
65
71
|
},
|
|
66
72
|
});
|
|
67
|
-
await errorHandler(response);
|
|
68
|
-
return response;
|
|
73
|
+
return await errorHandler(response);
|
|
69
74
|
};
|
|
70
75
|
const setupArgs = () => {
|
|
71
76
|
const appName = process.argv.slice(2)[0];
|
|
72
77
|
if (!appName) {
|
|
73
78
|
throw new Error('Please provide an app name');
|
|
74
79
|
}
|
|
75
|
-
const secretWIFKey = process.env.
|
|
80
|
+
const secretWIFKey = process.env.PROSOPO_ZELCORE_PRIVATE_KEY;
|
|
76
81
|
if (!secretWIFKey) {
|
|
77
82
|
throw new Error('No private key provided');
|
|
78
83
|
}
|
|
79
|
-
const zelId = process.env.
|
|
84
|
+
const zelId = process.env.PROSOPO_ZELCORE_PUBLIC_KEY;
|
|
80
85
|
if (!zelId) {
|
|
81
86
|
throw new Error('No zelId provided');
|
|
82
87
|
}
|
|
@@ -91,15 +96,12 @@ const getNodeAPIURL = (nodeUIURL) => {
|
|
|
91
96
|
return new URL(`http://${nodeUIURL.replace(port, portLogin.toString())}`);
|
|
92
97
|
};
|
|
93
98
|
const getNode = async (appName, zelId, secretKey) => {
|
|
94
|
-
// Get Flux login phrase
|
|
95
99
|
const loginPhrase = await getLoginPhrase();
|
|
96
100
|
log.info('Login Phrase:', loginPhrase);
|
|
97
101
|
const signature = base64Encode(await sign(loginPhrase, { secretKey }));
|
|
98
102
|
log.info('Signature:', signature);
|
|
99
|
-
// Get details of individual Flux app
|
|
100
103
|
const individualNodeIPs = await getFluxOSURLs(appName, zelId, signature, loginPhrase);
|
|
101
104
|
log.info('Individual Node IPs:', individualNodeIPs);
|
|
102
|
-
// Choose a node at random from individualNodeIPs
|
|
103
105
|
const node = individualNodeIPs[Math.floor(Math.random() * individualNodeIPs.length)];
|
|
104
106
|
if (!node) {
|
|
105
107
|
throw new Error('Failed to randomly select node');
|
|
@@ -111,21 +113,15 @@ const getNode = async (appName, zelId, secretKey) => {
|
|
|
111
113
|
try {
|
|
112
114
|
loadEnv();
|
|
113
115
|
const { appName, secretKey, zelId } = setupArgs();
|
|
114
|
-
// Get a Flux node
|
|
115
116
|
const nodeUIURL = await getNode(appName, zelId, secretKey);
|
|
116
|
-
// Get the admin API URL as it is different from the UI URL
|
|
117
117
|
const nodeAPIURL = getNodeAPIURL(nodeUIURL);
|
|
118
|
-
// Get a login token from the node
|
|
119
118
|
const nodeLoginPhrase = await getLoginPhrase(nodeAPIURL);
|
|
120
119
|
log.info('Node Login Phrase:', nodeLoginPhrase);
|
|
121
|
-
// Sign the login token with zelcore private key
|
|
122
120
|
const nodeSignature = base64Encode(await sign(nodeLoginPhrase, { secretKey }));
|
|
123
121
|
log.info('Node Signature:', nodeSignature);
|
|
124
|
-
// Login to the node
|
|
125
122
|
await verifyLogin(zelId, nodeSignature, nodeLoginPhrase, nodeAPIURL);
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
log.info(redployResponse.json());
|
|
123
|
+
const redeployResponse = await softRedeploy(zelId, nodeSignature, nodeLoginPhrase, nodeAPIURL, appName);
|
|
124
|
+
log.info(redeployResponse);
|
|
129
125
|
process.exit(0);
|
|
130
126
|
}
|
|
131
127
|
catch (error) {
|
|
@@ -1 +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,EAAE,MAAM,IAAI,CAAA;AAEnB,MAAM,GAAG,GAAG,SAAS,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;
|
|
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,C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UAAU,EAAE,OAAO,CAAC,CAAA;QAEvG,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA;QAC1B,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"}
|
|
@@ -1,25 +1,21 @@
|
|
|
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
1
|
import { LogLevel, getLogger } from '@prosopo/common';
|
|
15
2
|
import { generateMnemonic } from '@prosopo/contract';
|
|
16
|
-
|
|
17
|
-
|
|
3
|
+
import { loadEnv } from '@prosopo/cli';
|
|
4
|
+
import { updateEnvFile } from '../setup/index.js';
|
|
5
|
+
loadEnv();
|
|
6
|
+
const logger = getLogger(process.env.PROSOPO_LOG_LEVEL || LogLevel.enum.info, 'generateMnemonic');
|
|
7
|
+
async function mnemonic(addToEnv) {
|
|
18
8
|
const [mnemonic, address] = await generateMnemonic();
|
|
19
|
-
logger.
|
|
20
|
-
logger.
|
|
9
|
+
logger.info(`Address: ${address}`);
|
|
10
|
+
logger.info(`Mnemonic: ${mnemonic}`);
|
|
11
|
+
if (addToEnv) {
|
|
12
|
+
await updateEnvFile({
|
|
13
|
+
PROSOPO_PROVIDER_MNEMONIC: `"${mnemonic}"`,
|
|
14
|
+
PROSOPO_PROVIDER_ADDRESS: address,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
21
17
|
}
|
|
22
|
-
mnemonic()
|
|
18
|
+
mnemonic(process.argv.includes('--env'))
|
|
23
19
|
.then(() => process.exit(0))
|
|
24
20
|
.catch((e) => {
|
|
25
21
|
console.error(e);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateMnemonic.js","sourceRoot":"","sources":["../../src/scripts/generateMnemonic.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generateMnemonic.js","sourceRoot":"","sources":["../../src/scripts/generateMnemonic.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEjD,OAAO,EAAE,CAAA;AACT,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAA;AAEjG,KAAK,UAAU,QAAQ,CAAC,QAAiB;IACrC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,MAAM,gBAAgB,EAAE,CAAA;IACpD,MAAM,CAAC,IAAI,CAAC,YAAY,OAAO,EAAE,CAAC,CAAA;IAClC,MAAM,CAAC,IAAI,CAAC,aAAa,QAAQ,EAAE,CAAC,CAAA;IACpC,IAAI,QAAQ,EAAE;QACV,MAAM,aAAa,CAAC;YAChB,yBAAyB,EAAE,IAAI,QAAQ,GAAG;YAC1C,wBAAwB,EAAE,OAAO;SACpC,CAAC,CAAA;KACL;AACL,CAAC;AAED,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;KACnC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KAC3B,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;IACT,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAChB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACnB,CAAC,CAAC,CAAA"}
|
package/dist/scripts/getBlock.js
CHANGED
|
@@ -1,24 +1,9 @@
|
|
|
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
1
|
import { ApiPromise, WsProvider } from '@polkadot/api';
|
|
15
2
|
import { at } from '@prosopo/util';
|
|
16
3
|
async function run(blockNumber) {
|
|
17
|
-
// Construct
|
|
18
4
|
const provider = 'ws://localhost:9944';
|
|
19
5
|
const wsProvider = new WsProvider(provider);
|
|
20
6
|
const api = await ApiPromise.create({ provider: wsProvider });
|
|
21
|
-
// Do something
|
|
22
7
|
const blockHash = await api.rpc.chain.getBlockHash(blockNumber);
|
|
23
8
|
const block = await api.rpc.chain.getBlock(blockHash);
|
|
24
9
|
console.log(JSON.stringify(block.toJSON(), null, 2));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBlock.js","sourceRoot":"","sources":["../../src/scripts/getBlock.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getBlock.js","sourceRoot":"","sources":["../../src/scripts/getBlock.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EAAE,EAAE,EAAE,MAAM,eAAe,CAAA;AAElC,KAAK,UAAU,GAAG,CAAC,WAA4B;IAE3C,MAAM,QAAQ,GAAG,qBAAqB,CAAA;IACtC,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,QAAQ,CAAC,CAAA;IAC3C,MAAM,GAAG,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAA;IAG7D,MAAM,SAAS,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC,CAAA;IAE/D,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAA;IACrD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;AACxD,CAAC;AAED,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;KAC5B,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,16 +1,3 @@
|
|
|
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
1
|
import { ApiPromise, WsProvider } from '@polkadot/api';
|
|
15
2
|
import { get } from '@prosopo/util';
|
|
16
3
|
import { hideBin } from 'yargs/helpers';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getContractInfoOf.js","sourceRoot":"","sources":["../../src/scripts/getContractInfoOf.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getContractInfoOf.js","sourceRoot":"","sources":["../../src/scripts/getContractInfoOf.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAEtD,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAA;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,SAAS,GAAG;IACd,KAAK,EAAE,EAAE,QAAQ,EAAE,0BAA0B,EAAE;IAC/C,QAAQ,EAAE,EAAE,QAAQ,EAAE,uBAAuB,EAAE;IAC/C,MAAM,EAAE,EAAE,QAAQ,EAAE,4CAA4C,EAAE;CACrE,CAAA;AAED,KAAK,UAAU,iBAAiB,CAAC,eAAuB,EAAE,QAAgB;IACtE,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,QAAQ,C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|
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
1
|
import { ApiPromise, WsProvider } from '@polkadot/api';
|
|
15
2
|
import { oneUnit } from '@prosopo/contract';
|
|
16
3
|
async function run() {
|
|
17
|
-
// Construct
|
|
18
4
|
const provider = 'ws://localhost:9944';
|
|
19
|
-
// const provider = 'wss://shiden.public.blastapi.io'
|
|
20
5
|
const wsProvider = new WsProvider(provider);
|
|
21
6
|
const api = await ApiPromise.create({ provider: wsProvider });
|
|
22
|
-
// Do something
|
|
23
7
|
const existentialDeposit = await api.consts.balances.existentialDeposit;
|
|
24
8
|
const unit = await oneUnit(api);
|
|
25
9
|
const chainDecimals = api.registry.chainDecimals;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getExistentialDeposit.js","sourceRoot":"","sources":["../../src/scripts/getExistentialDeposit.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getExistentialDeposit.js","sourceRoot":"","sources":["../../src/scripts/getExistentialDeposit.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC3C,KAAK,UAAU,GAAG;IAEd,MAAM,QAAQ,GAAG,qBAAqB,CAAA;IAEtC,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,QAAQ,CAAC,CAAA;IAC3C,MAAM,GAAG,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAA;IAG7D,MAAM,kBAAkB,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAA;IACvE,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAA;IAC/B,MAAM,aAAa,GAAG,GAAG,CAAC,QAAQ,CAAC,aAAa,CAAA;IAChD,OAAO,CAAC,GAAG,CAAC,uBAAuB,EAAE,aAAa,CAAC,CAAA;IACnD,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAA;IACzC,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,kBAAkB,CAAC,QAAQ,EAAE,CAAC,CAAA;IAClE,OAAO,CAAC,GAAG,CAAC,+BAA+B,EAAE,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,MAAM,CAAC,CAAA;IAC7F,OAAO,CAAC,GAAG,CAAC,0BAA0B,EAAE,kBAAkB,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;IACrE,OAAO,kBAAkB,CAAA;AAC7B,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,16 +1,3 @@
|
|
|
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
1
|
import { ProviderEnvironment } from '@prosopo/env';
|
|
15
2
|
import { Tasks } from '@prosopo/provider';
|
|
16
3
|
import { defaultConfig } from '@prosopo/cli';
|
|
@@ -25,7 +12,7 @@ async function main() {
|
|
|
25
12
|
await env.isReady();
|
|
26
13
|
const tasks = new Tasks(env);
|
|
27
14
|
const [mnemonic, address] = (await generateMnemonic(env.keyring)) || ['', ''];
|
|
28
|
-
const dappContractAccount = process.env.
|
|
15
|
+
const dappContractAccount = process.env.PROSOPO_SITE_KEY || '';
|
|
29
16
|
const provider = (await tasks.contract.query.getRandomActiveProvider(address, dappContractAccount)).value
|
|
30
17
|
.unwrap()
|
|
31
18
|
.unwrap();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRandomProvider.js","sourceRoot":"","sources":["../../src/scripts/getRandomProvider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getRandomProvider.js","sourceRoot":"","sources":["../../src/scripts/getRandomProvider.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,MAAM,MAAM,QAAQ,CAAA;AAE3B,MAAM,CAAC,MAAM,EAAE,CAAA;AAEf,KAAK,UAAU,IAAI;IACf,MAAM,MAAM,GAAG,aAAa,EAAE,CAAA;IAC9B,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,cAAc,CAAC,CAAA;IACtD,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;IACnD,MAAM,GAAG,GAAG,IAAI,mBAAmB,CAAC,aAAa,EAAE,EAAE,IAAI,CAAC,CAAA;IAC1D,MAAM,GAAG,CAAC,OAAO,EAAE,CAAA;IACnB,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,CAAA;IAC5B,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;IAC7E,MAAM,mBAAmB,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,EAAE,CAAA;IAC9D,MAAM,QAAQ,GAAG,CAAC,MAAM,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,uBAAuB,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC,CAAC,KAAK;SACpG,MAAM,EAAE;SACR,MAAM,EAAE,CAAA;IACb,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IACrB,OAAO,CAAC,IAAI,EAAE,CAAA;AAClB,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACpB,OAAO,CAAC,IAAI,EAAE,CAAA;AAClB,CAAC,CAAC,CAAA"}
|
|
@@ -1,16 +1,3 @@
|
|
|
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
1
|
import { ProviderEnvironment } from '@prosopo/env';
|
|
15
2
|
import { Tasks } from '@prosopo/provider';
|
|
16
3
|
import { at } from '@prosopo/util';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getStorage.js","sourceRoot":"","sources":["../../src/scripts/getStorage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getStorage.js","sourceRoot":"","sources":["../../src/scripts/getStorage.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAE,EAAE,EAAE,MAAM,eAAe,CAAA;AAClC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD,OAAO,EAAE,CAAA;AAET,KAAK,UAAU,IAAI,CAAC,UAAkB;IAClC,MAAM,MAAM,GAAG,aAAa,EAAE,CAAA;IAC9B,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,cAAc,CAAC,CAAA;IACtD,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;IACnD,MAAM,GAAG,GAAG,IAAI,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACjD,MAAM,GAAG,CAAC,OAAO,EAAE,CAAA;IACnB,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,CAAA;IAC5B,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAA;IAC/B,MAAM,EAAE,GAAQ,GAAG,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAA;IACzC,MAAM,YAAY,GAAG,MAAM,EAAE,EAAE,CAAA;IAC/B,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC,CAAA;IACnC,OAAO,CAAC,IAAI,EAAE,CAAA;AAClB,CAAC;AAED,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACtD,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACpB,OAAO,CAAC,IAAI,EAAE,CAAA;AAClB,CAAC,CAAC,CAAA"}
|
package/dist/scripts/hash.js
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
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
1
|
import { blake2AsHex, blake2AsU8a, keccakAsHex, keccakAsU8a } from '@polkadot/util-crypto';
|
|
15
2
|
import { decodeAddress, encodeAddress } from '@polkadot/keyring';
|
|
16
3
|
import { get } from '@prosopo/util';
|
|
@@ -46,9 +33,7 @@ function main() {
|
|
|
46
33
|
result = fn(arg);
|
|
47
34
|
}
|
|
48
35
|
catch (e) {
|
|
49
|
-
// ignore
|
|
50
36
|
}
|
|
51
|
-
// https://stackoverflow.com/questions/9781218/how-to-change-node-jss-console-font-color
|
|
52
37
|
console.log(`\x1b[40m\x1b[33m${fnName.padEnd(max + 1, ' ')}:\x1b[37m ${result}`);
|
|
53
38
|
}
|
|
54
39
|
}
|
package/dist/scripts/hash.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash.js","sourceRoot":"","sources":["../../src/scripts/hash.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hash.js","sourceRoot":"","sources":["../../src/scripts/hash.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAC1F,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAA;AACnC,OAAO,EACH,OAAO,EACP,WAAW,EACX,QAAQ,EACR,KAAK,EACL,WAAW,EACX,WAAW,EACX,OAAO,EACP,UAAU,EACV,QAAQ,EACR,WAAW,GACd,MAAM,gBAAgB,CAAA;AAEvB,SAAS,IAAI;IACT,MAAM,GAAG,GAEL;QACA,GAAG,EAAE,CAAC,GAAQ,EAAE,EAAE,CAAC,GAAG;QACtB,KAAK;QACL,WAAW;QACX,QAAQ;QACR,OAAO;QACP,WAAW;QACX,WAAW;QACX,WAAW;QACX,WAAW;QACX,WAAW;QACX,WAAW;QACX,aAAa;QACb,aAAa;QACb,QAAQ;QACR,OAAO;QACP,UAAU;QACV,WAAW;QACX,SAAS,EAAE,IAAI,CAAC,KAAK;QACrB,aAAa,EAAE,IAAI,CAAC,SAAS;KAChC,CAAA;IAED,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAEpC,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAA;IAC/E,KAAK,MAAM,MAAM,IAAI,GAAG,EAAE;QACtB,MAAM,EAAE,GAAG,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QAC3B,IAAI,MAAM,GAAG,EAAE,CAAA;QACf,IAAI;YACA,MAAM,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;SACnB;QAAC,OAAO,CAAC,EAAE;SAEX;QAED,OAAO,CAAC,GAAG,CAAC,mBAAmB,MAAM,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,EAAE,GAAG,CAAC,aAAa,MAAM,EAAE,CAAC,CAAA;KACnF;AACL,CAAC;AAED,IAAI,EAAE,CAAA"}
|
|
@@ -1,16 +1,3 @@
|
|
|
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
1
|
import { at } from '@prosopo/util';
|
|
15
2
|
import { hexToU8a } from '@polkadot/util';
|
|
16
3
|
const arg = at(process.argv.slice(2), 0).trim();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hexToBytes.js","sourceRoot":"","sources":["../../src/scripts/hexToBytes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hexToBytes.js","sourceRoot":"","sources":["../../src/scripts/hexToBytes.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,EAAE,EAAE,MAAM,eAAe,CAAA;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;AAC/C,OAAO,CAAC,GAAG,CAAC,kBAAkB,GAAG,EAAE,CAAC,CAAA;AAEpC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAA"}
|
|
@@ -1,65 +1,2 @@
|
|
|
1
|
-
// Copyright 2021-2022 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
|
-
// #!/usr/bin/env node
|
|
15
|
-
// import { hexToString, hexToU8a, u8aToHex } from '@polkadot/util'
|
|
16
|
-
// import { Environment } from '../src/env'
|
|
17
|
-
// import { blake2AsU8a, encodeAddress } from '@polkadot/util-crypto'
|
|
18
|
-
// import { Option, GenericAccountId } from '@polkadot/types'
|
|
19
|
-
//
|
|
20
|
-
// require('dotenv').config()
|
|
21
1
|
export {};
|
|
22
|
-
// async function main () {
|
|
23
|
-
// const env = new Environment(undefined)
|
|
24
|
-
// await env.isReady()
|
|
25
|
-
// const contractApi = new ProsopoContractApi(env)
|
|
26
|
-
// const serviceOrigin = 'http://localhost:9229'
|
|
27
|
-
// const dappContract = '5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y'
|
|
28
|
-
// const mnemonic = '//Alice'
|
|
29
|
-
//
|
|
30
|
-
// if (mnemonic) {
|
|
31
|
-
// const signerPair = env.network.keyring.addFromMnemonic(mnemonic)
|
|
32
|
-
// const senderAddress = signerPair.address
|
|
33
|
-
// const davePair = env.network.keyring.addFromMnemonic('//Dave')
|
|
34
|
-
// console.log(davePair.address)
|
|
35
|
-
// // let emptyOption: <T extends Codec> (typeName: keyof InterfaceTypes) => Option<T>;
|
|
36
|
-
// const args = [serviceOrigin, dappContract, new Option(env.network.registry, GenericAccountId)]
|
|
37
|
-
// const method = 'dappRegister'
|
|
38
|
-
// const encodedArgs = contractApi.encodeArgs(method, args)
|
|
39
|
-
// console.log(new Option(env.network.registry, GenericAccountId).toU8a())
|
|
40
|
-
// // console.log(u8aToHex(encodedArgs));
|
|
41
|
-
// console.log(encodedArgs)
|
|
42
|
-
// const populatedTx = await env.contract?.populateTransaction.dappRegister(...encodedArgs, { gasLimit: 8705000000 })
|
|
43
|
-
// console.log(encodeAddress(populatedTx!.callParams!.dest))
|
|
44
|
-
// console.log(populatedTx!.callParams!.gasLimit.toString())
|
|
45
|
-
// console.log(u8aToHex(populatedTx!.callParams!.inputData))
|
|
46
|
-
// const payload = u8aToHex(populatedTx!.callParams!.inputData)
|
|
47
|
-
// console.log('Payload generated with no signer present in environment\n')
|
|
48
|
-
// console.log(`Payload: ${payload}`)
|
|
49
|
-
// await env.changeSigner(mnemonic)
|
|
50
|
-
// const signature = signerPair.sign(hexToU8a(payload), { withType: true })
|
|
51
|
-
// console.log(`Signature: ${u8aToHex(signature)}`)
|
|
52
|
-
// console.log(`Decoding 0x42b45efa: ${hexToString('0x42b45efa')}`)
|
|
53
|
-
// console.log(`Decoding 0x1501: ${hexToString('0x1501')}`)
|
|
54
|
-
// // decodeU8a
|
|
55
|
-
// console.log(new Option(env.network.registry, GenericAccountId, null).toU8a())
|
|
56
|
-
// process.exit(0)
|
|
57
|
-
// }
|
|
58
|
-
// }
|
|
59
|
-
//
|
|
60
|
-
// main()
|
|
61
|
-
// .catch((error) => {
|
|
62
|
-
// console.error(error)
|
|
63
|
-
// process.exit()
|
|
64
|
-
// })
|
|
65
2
|
//# sourceMappingURL=populateTxAndSign.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"populateTxAndSign.js","sourceRoot":"","sources":["../../src/scripts/populateTxAndSign.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"populateTxAndSign.js","sourceRoot":"","sources":["../../src/scripts/populateTxAndSign.ts"],"names":[],"mappings":""}
|
|
@@ -1,16 +1,3 @@
|
|
|
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
1
|
import { BN } from '@polkadot/util';
|
|
15
2
|
import { Environment } from '@prosopo/env';
|
|
16
3
|
import { at } from '@prosopo/util';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendFunds.js","sourceRoot":"","sources":["../../src/scripts/sendFunds.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,CAAC,CAAA"}
|
|
@@ -2,9 +2,9 @@ import { BN_BE_256_OPTS } from '@polkadot/util-crypto/bn';
|
|
|
2
2
|
import { at } from '@prosopo/util';
|
|
3
3
|
import { base58Decode, base64Encode, cryptoWaitReady, sha256AsU8a } from '@polkadot/util-crypto';
|
|
4
4
|
import { bnToU8a, hexToU8a, u8aConcat, u8aToHex } from '@polkadot/util';
|
|
5
|
+
import { isMain } from '@prosopo/util';
|
|
5
6
|
import { loadEnv } from '@prosopo/cli';
|
|
6
7
|
import { secp256k1 } from '@noble/curves/secp256k1';
|
|
7
|
-
import esMain from 'es-main';
|
|
8
8
|
import varuint from 'varuint-bitcoin';
|
|
9
9
|
loadEnv();
|
|
10
10
|
const MESSAGE_MAGIC = '\u0018Bitcoin Signed Message:\n';
|
|
@@ -28,37 +28,26 @@ export async function sign(message, { secretKey }) {
|
|
|
28
28
|
await cryptoWaitReady();
|
|
29
29
|
const data = hasher(message, MESSAGE_MAGIC);
|
|
30
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));
|
|
31
|
+
return u8aConcat(Buffer.alloc(1, signature.recovery + 4 + 27), bnToU8a(signature.r, BN_BE_256_OPTS), bnToU8a(signature.s, BN_BE_256_OPTS));
|
|
34
32
|
}
|
|
35
|
-
// https://bitcoin.stackexchange.com/a/61972
|
|
36
|
-
// <version><key><compression?><first 4 bytes of double sha256>
|
|
37
|
-
// 0x80..................................................................6430148d
|
|
38
|
-
// ..................................................................
|
|
39
33
|
export function wifToPrivateKey(wif) {
|
|
40
34
|
let substractLength;
|
|
41
35
|
if (wif.length === 51) {
|
|
42
|
-
|
|
43
|
-
substractLength = 8; // remove 4 bytes from WIF so 8 in hex
|
|
36
|
+
substractLength = 8;
|
|
44
37
|
}
|
|
45
38
|
else if (wif.length === 52) {
|
|
46
|
-
|
|
47
|
-
substractLength = 10; // remove 5 bytes from WIF so 10 in hex
|
|
39
|
+
substractLength = 10;
|
|
48
40
|
}
|
|
49
41
|
else {
|
|
50
42
|
throw new Error('Invalid WIF');
|
|
51
43
|
}
|
|
52
44
|
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
45
|
const secretKeyHex = `0x${secretKeyHexLong.substring(4, secretKeyHexLong.length - substractLength)}`;
|
|
56
46
|
return hexToU8a(secretKeyHex);
|
|
57
47
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
const publicKey = base58Decode(process.env.ZELCORE_PUBLIC_KEY || '');
|
|
48
|
+
if (isMain(import.meta.url)) {
|
|
49
|
+
const secretKey = wifToPrivateKey(process.env.PROSOPO_ZELCORE_PRIVATE_KEY || '');
|
|
50
|
+
const publicKey = base58Decode(process.env.PROSOPO_ZELCORE_PUBLIC_KEY || '');
|
|
62
51
|
const keypair = { secretKey, publicKey };
|
|
63
52
|
const message = at(process.argv.slice(2), 0).trim();
|
|
64
53
|
if (message.length === 0) {
|
|
@@ -68,8 +57,9 @@ if (esMain(import.meta)) {
|
|
|
68
57
|
sign(message, keypair)
|
|
69
58
|
.then((sig) => {
|
|
70
59
|
const hexSig = u8aToHex(sig);
|
|
71
|
-
console.log(`Hex
|
|
72
|
-
console.log(`
|
|
60
|
+
console.log(`Hex Signature : ${hexSig}`);
|
|
61
|
+
console.log(`Public Key: ${publicKey}`);
|
|
62
|
+
console.log(`Base64 Signature: ${base64Encode(hexSig)}`);
|
|
73
63
|
process.exit();
|
|
74
64
|
})
|
|
75
65
|
.catch((error) => {
|