-
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.
- Loading branch information
1 parent
fc8aeba
commit 8ba0cda
Showing
4 changed files
with
117 additions
and
79 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: 'Change ATOM Price' | ||
description: 'This action updates the ATOM price on the specified Agoric network.' | ||
|
||
inputs: | ||
amount: | ||
description: 'The new price to set for ATOM.' | ||
required: true | ||
agoricNet: | ||
description: 'The Agoric network configuration where the price change will apply.' | ||
required: true | ||
containerName: | ||
description: 'The name of the Docker container in which the commands are executed.' | ||
required: true | ||
|
||
runs: | ||
using: 'node20' | ||
main: 'changePrice.mjs' |
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 |
---|---|---|
@@ -1,77 +1,41 @@ | ||
import { execa, $ } from 'execa'; | ||
import { execa } from 'execa'; | ||
|
||
async function setAtomPrice() { | ||
const agops = '/usr/src/agoric-sdk/packages/agoric-cli/bin/agops'; | ||
const setAtomPrice = async (amount, containerName, agoricNet) => { | ||
try { | ||
console.log('Changing Price...'); | ||
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); | ||
console.log(`Initiating price change to ${amount} for ATOM...`); | ||
|
||
const env = { | ||
AGORIC_NET: agoricNet, | ||
}; | ||
|
||
const { stdout } = await execa( | ||
'docker', | ||
[ | ||
'exec', | ||
containerName, | ||
agops, | ||
'oracle', | ||
'setPrice', | ||
'--keys', | ||
'gov1,gov2', | ||
'--pair', | ||
'ATOM.USD', | ||
'--price', | ||
amount, | ||
'--keyring-backend', | ||
'test', | ||
], | ||
{ env }, | ||
); | ||
console.log('Standard output:', stdout); | ||
} catch (error) { | ||
console.error('Error:', error); | ||
} | ||
} | ||
}; | ||
|
||
setAtomPrice(); | ||
const amount = process.env.PRICE; | ||
const containerName = process.env.INPUT_CONTAINERNAME; | ||
const agoricNet = process.env.INPUT_AGORICNET; | ||
|
||
// 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); | ||
setAtomPrice(amount, containerName, agoricNet); |
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,50 @@ | ||
import { execa } from 'execa'; | ||
|
||
const agops = '/usr/src/agoric-sdk/packages/agoric-cli/bin/agops'; | ||
|
||
const amount = process.env.AMOUNT; | ||
const containerName = process.env.CONTAINER_NAME; | ||
const agoricNet = process.env.AGORIC_NET; | ||
|
||
if (!amount || !containerName || !agoricNet) { | ||
console.error('Error: Missing one or more required parameters:'); | ||
if (!amount) console.error('Missing amount'); | ||
if (!containerName) console.error('Missing containerName'); | ||
if (!agoricNet) console.error('Missing agoricNet'); | ||
process.exit(1); | ||
} | ||
|
||
const setAtomPrice = async (amount, containerName, agoricNet) => { | ||
try { | ||
console.log(`Initiating price change to ${amount} for ATOM...`); | ||
|
||
const env = { | ||
AGORIC_NET: agoricNet, | ||
}; | ||
|
||
const { stdout } = await execa( | ||
'docker', | ||
[ | ||
'exec', | ||
containerName, | ||
agops, | ||
'oracle', | ||
'setPrice', | ||
'--keys', | ||
'gov1,gov2', | ||
'--pair', | ||
'ATOM.USD', | ||
'--price', | ||
amount, | ||
'--keyring-backend', | ||
'test', | ||
], | ||
{ env }, | ||
); | ||
console.log('Standard output:', stdout); | ||
} catch (error) { | ||
console.error('Error:', error); | ||
} | ||
}; | ||
|
||
setAtomPrice(amount, containerName, agoricNet); |
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