-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use zx for creating vaults
- Loading branch information
1 parent
5ce73f8
commit b007646
Showing
5 changed files
with
348 additions
and
103 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { execa, $ } from 'execa'; | ||
|
||
async function setAtomPrice() { | ||
try { | ||
const { stdout } = await execa('docker', [ | ||
'exec', | ||
'agd', | ||
'/usr/src/agoric-sdk/packages/agoric-cli/bin/agops', | ||
'oracle', | ||
'setPrice', | ||
'--keys', | ||
'gov1,gov2', | ||
'--pair', | ||
'ATOM.USD', | ||
'--price', | ||
'12.34', | ||
'--keyring-backend', | ||
'test', | ||
]); | ||
console.log('Output:', stdout); | ||
} catch (error) { | ||
console.error('Error:', error); | ||
} | ||
} | ||
|
||
setAtomPrice(); | ||
|
||
const createVault = async (containerName, agoricNet, commandTimeout, userKey, wantMinted, giveCollateral) => { | ||
console.log('Starting the vault creation process...'); | ||
const agops = '/usr/src/agoric-sdk/packages/agoric-cli/bin/agops'; | ||
|
||
let res = await $`docker ps`; | ||
console.log('test.........', res); | ||
|
||
res = await $`ls /usr/`; | ||
console.log('usr.........', res); | ||
|
||
res = await $`ls /usr/src`; | ||
console.log('src.........', res); | ||
|
||
// res = await $`find / -type d -name "agoric-sdk" 2>/dev/null`; | ||
// console.log('sdk dir.........', res); | ||
|
||
const createVaultCommand = `${agops} vaults open --wantMinted \"${wantMinted}\" --giveCollateral \"${giveCollateral}\" > /tmp/want-ist.json`; | ||
const executeCreateVaultCommand = `docker exec ${containerName} /bin/bash -c "env AGORIC_NET=${agoricNet} timeout ${commandTimeout} ${createVaultCommand}"`; | ||
try { | ||
if (!containerName || !agoricNet || !commandTimeout || !userKey || !wantMinted || !giveCollateral) { | ||
console.error('Missing required parameters.'); | ||
process.exit(1); | ||
} | ||
|
||
// Improved logging for debugging | ||
console.log(`Command to execute: ${executeCreateVaultCommand}`); | ||
|
||
await $`${executeCreateVaultCommand}`; | ||
console.log('Executing broadcast command...'); | ||
const broadcastCommand = `timeout ${commandTimeout} ${agops} perf satisfaction --executeOffer /tmp/want-ist.json --from ${userKey} --keyring-backend=test`; | ||
const executeBroadcastCommand = `docker exec ${containerName} AGORIC_NET=${agoricNet} ${broadcastCommand}`; | ||
|
||
await $`${executeBroadcastCommand}`; | ||
console.log('Offer broadcast successfully.'); | ||
} catch (error) { | ||
console.error('Error during vault creation:', error); | ||
process.exit(1); | ||
} | ||
}; | ||
|
||
const containerName = process.env.INPUT_CONTAINERNAME; | ||
const agoricNet = process.env.INPUT_AGORICNET; | ||
const commandTimeout = process.env.INPUT_COMMANDTIMEOUT; | ||
const userKey = process.env.INPUT_USERKEY; | ||
const wantMinted = process.env.INPUT_WANTMINTED; | ||
const giveCollateral = process.env.INPUT_GIVECOLLATERAL; | ||
|
||
console.log('ARGS:', { containerName, agoricNet, commandTimeout, userKey, wantMinted, giveCollateral }); | ||
createVault(containerName, agoricNet, commandTimeout, userKey, wantMinted, giveCollateral); |
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
Oops, something went wrong.