-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6216 from Agoric/6211-cli-provision
6211 cli provision
- Loading branch information
Showing
6 changed files
with
108 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// @ts-check | ||
/* global process */ | ||
import { normalizeBech32 } from '@cosmjs/encoding'; | ||
import { execSync } from 'child_process'; | ||
|
||
export const normalizeAddress = literalOrName => { | ||
try { | ||
return normalizeBech32(literalOrName); | ||
} catch (_) { | ||
// not an address so try as a key | ||
const buff = execSync(`agd keys show --address ${literalOrName}`); | ||
return normalizeBech32(buff.toString().trim()); | ||
} | ||
}; | ||
harden(normalizeAddress); | ||
|
||
/** | ||
* SECURITY: closes over process and child_process | ||
* | ||
* @param {string} swingsetArgs | ||
* @param {import('./rpc').MinimalNetworkConfig} net | ||
* @param {string} from | ||
* @param {boolean} [dryRun] | ||
*/ | ||
export const execSwingsetTransaction = ( | ||
swingsetArgs, | ||
net, | ||
from, | ||
dryRun = false, | ||
) => { | ||
const { chainName, rpcAddrs } = net; | ||
|
||
const cmd = `agd --node=${rpcAddrs[0]} --chain-id=${chainName} --from=${from} tx swingset ${swingsetArgs}`; | ||
|
||
if (dryRun) { | ||
process.stdout.write('Run this interactive command in shell:\n\n'); | ||
process.stdout.write(cmd); | ||
process.stdout.write('\n'); | ||
} else { | ||
const yesCmd = `${cmd} --yes`; | ||
console.log('Executing ', yesCmd); | ||
execSync(yesCmd); | ||
} | ||
}; | ||
harden(execSwingsetTransaction); | ||
|
||
// xxx rpc should be able to query this by HTTP without shelling out | ||
export const fetchSwingsetParams = net => { | ||
const { chainName, rpcAddrs } = net; | ||
const cmd = `agd --node=${rpcAddrs[0]} --chain-id=${chainName} query swingset params --output --json`; | ||
const buffer = execSync(cmd); | ||
return JSON.parse(buffer.toString()); | ||
}; | ||
harden(fetchSwingsetParams); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters