|
| 1 | +import { execa } from 'execa'; |
| 2 | + |
| 3 | +const agops = '/usr/src/agoric-sdk/packages/agoric-cli/bin/agops'; |
| 4 | + |
| 5 | +const createVault = async (containerName, agoricNet, commandTimeout, userKey, wantMinted, giveCollateral) => { |
| 6 | + console.log('Starting the vault creation process...'); |
| 7 | + |
| 8 | + if (!containerName || !agoricNet || !commandTimeout || !userKey || !wantMinted || !giveCollateral) { |
| 9 | + console.error('Error: Missing one or more required parameters:', { |
| 10 | + containerName, |
| 11 | + agoricNet, |
| 12 | + commandTimeout, |
| 13 | + userKey, |
| 14 | + wantMinted, |
| 15 | + giveCollateral, |
| 16 | + }); |
| 17 | + process.exit(1); |
| 18 | + } |
| 19 | + |
| 20 | + const createVaultCommand = `${agops} vaults open --wantMinted \"${wantMinted}\" --giveCollateral \"${giveCollateral}\" > /tmp/want-ist.json`; |
| 21 | + const executeCreateVaultCommand = `docker exec ${containerName} /bin/bash -c "env AGORIC_NET=${agoricNet} timeout ${commandTimeout} ${createVaultCommand}"`; |
| 22 | + |
| 23 | + try { |
| 24 | + console.log(`Executing: ${executeCreateVaultCommand}`); |
| 25 | + const { stdout: createVaultOutput } = await execa.command(executeCreateVaultCommand); |
| 26 | + console.log('Vault creation output:', createVaultOutput); |
| 27 | + |
| 28 | + console.log('Executing broadcast command...'); |
| 29 | + const broadcastCommand = `timeout ${commandTimeout} ${agops} perf satisfaction --executeOffer /tmp/want-ist.json --from ${userKey} --keyring-backend=test`; |
| 30 | + const executeBroadcastCommand = `docker exec ${containerName} bash -c "env AGORIC_NET=${agoricNet} ${broadcastCommand}"`; |
| 31 | + |
| 32 | + const { stdout: broadcastOutput } = await execa.command(executeBroadcastCommand); |
| 33 | + console.log('Broadcast output:', broadcastOutput); |
| 34 | + } catch (error) { |
| 35 | + console.error('Error during vault creation:', error); |
| 36 | + process.exit(1); |
| 37 | + } |
| 38 | +}; |
| 39 | + |
| 40 | +const containerName = process.env.INPUT_CONTAINERNAME; |
| 41 | +const agoricNet = process.env.INPUT_AGORICNET; |
| 42 | +const commandTimeout = process.env.INPUT_COMMANDTIMEOUT; |
| 43 | +const userKey = process.env.INPUT_USERKEY; |
| 44 | +const wantMinted = process.env.INPUT_WANTMINTED; |
| 45 | +const giveCollateral = process.env.INPUT_GIVECOLLATERAL; |
| 46 | + |
| 47 | +createVault(containerName, agoricNet, commandTimeout, userKey, wantMinted, giveCollateral); |
0 commit comments