|
1 | 1 | import fs from 'fs/promises'; |
2 | 2 | import { IExec, utils } from 'iexec'; |
3 | | -import { HOST } from '../config/config.js'; |
4 | 3 |
|
5 | | -export const getIExec = (privateKey: string): IExec => { |
6 | | - const ethProvider = utils.getSignerFromPrivateKey(HOST, privateKey); |
| 4 | +export const getIExec = ( |
| 5 | + privateKey: string, |
| 6 | + host: string = 'bellecour' |
| 7 | +): IExec => { |
| 8 | + const ethProvider = utils.getSignerFromPrivateKey(host, privateKey, { providers: {}, allowExperimentalNetworks: true }); |
7 | 9 | return new IExec({ |
8 | 10 | ethProvider, |
9 | 11 | }); |
10 | 12 | }; |
11 | 13 |
|
12 | | -export const getDockerImageChecksum = async ( |
13 | | - namespace: string, |
14 | | - repository: string, |
15 | | - tag: string |
16 | | -): Promise<string> => { |
17 | | - try { |
18 | | - const manifest = await fetch( |
19 | | - `https://hub.docker.com/v2/namespaces/${namespace}/repositories/${repository}/tags/${tag}` |
20 | | - ).then((res) => res.json()); |
21 | | - const digest = manifest.digest as string; |
22 | | - if (digest) { |
23 | | - return digest.replace('sha256:', '0x'); |
24 | | - } |
25 | | - } catch (err) { |
26 | | - throw Error( |
27 | | - `Error inspecting image ${namespace}/${repository}:${tag}: ${err}` |
28 | | - ); |
29 | | - } |
30 | | -}; |
31 | | - |
32 | | -/** |
33 | | - * read the scone fingerprint from previously generated `.scone-fingerprint` |
34 | | - */ |
35 | | -export const loadSconeFingerprint = async (): Promise<string> => { |
36 | | - try { |
37 | | - const fingerprint = await fs.readFile('.scone-fingerprint', 'utf8'); |
38 | | - return fingerprint.trim(); |
39 | | - } catch (err) { |
40 | | - throw Error(`Error reading .scone-fingerprint: ${err}`); |
41 | | - } |
42 | | -}; |
43 | | - |
44 | 14 | const APP_ADDRESS_FILE = '.app-address'; |
45 | 15 | /** |
46 | 16 | * save the app address in `.app-address` file for next usages |
|
0 commit comments