From 027bf623f21463318a237bc830f130c9a9246a9e Mon Sep 17 00:00:00 2001
From: RodrigoAD <15104916+RodrigoAD@users.noreply.github.com>
Date: Thu, 10 Feb 2022 17:27:14 +0100
Subject: [PATCH] commands export data
raw tx on inspection command
---
.../src/commands/abstract/executionWrapper.ts | 15 +++++++++++++--
.../src/commands/abstract/index.ts | 6 ++++++
.../src/commands/abstract/inspectionWrapper.ts | 4 ++++
.../src/commands/contracts/link/deploy.ts | 4 ++++
.../src/commands/contracts/link/transfer.ts | 4 ++++
.../src/commands/tooling/upload.ts | 4 ++++
.../gauntlet-terra/src/commands/internal/terra.ts | 1 +
7 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/packages-ts/gauntlet-terra-contracts/src/commands/abstract/executionWrapper.ts b/packages-ts/gauntlet-terra-contracts/src/commands/abstract/executionWrapper.ts
index 0325c322..65d70930 100644
--- a/packages-ts/gauntlet-terra-contracts/src/commands/abstract/executionWrapper.ts
+++ b/packages-ts/gauntlet-terra-contracts/src/commands/abstract/executionWrapper.ts
@@ -1,6 +1,7 @@
import AbstractCommand, { makeAbstractCommand } from '.'
import { Result } from '@chainlink/gauntlet-core'
import { TerraCommand, TransactionResponse } from '@chainlink/gauntlet-terra'
+import { MsgExecuteContract } from '@terra-money/terra.js'
export interface AbstractInstruction {
instruction: {
@@ -25,7 +26,7 @@ export const instructionToCommand = (instruction: AbstractInstruction)
super(flags, args)
}
- execute = async (): Promise> => {
+ buildCommand = async (): Promise => {
const commandInput = await instruction.makeInput(this.flags, this.args)
if (!instruction.validateInput(commandInput)) {
throw new Error(`Invalid input params: ${JSON.stringify(commandInput)}`)
@@ -33,7 +34,17 @@ export const instructionToCommand = (instruction: AbstractInstruction)
const input = await instruction.makeContractInput(commandInput)
const abstractCommand = await makeAbstractCommand(id, this.flags, this.args, input)
await abstractCommand.invokeMiddlewares(abstractCommand, abstractCommand.middlewares)
- return abstractCommand.execute()
+ return abstractCommand
+ }
+
+ makeRawTransaction = async (): Promise => {
+ const command = await this.buildCommand()
+ return command.makeRawTransaction()
+ }
+
+ execute = async (): Promise> => {
+ const command = await this.buildCommand()
+ return command.execute()
}
}
}
diff --git a/packages-ts/gauntlet-terra-contracts/src/commands/abstract/index.ts b/packages-ts/gauntlet-terra-contracts/src/commands/abstract/index.ts
index df11a0ca..810fb016 100644
--- a/packages-ts/gauntlet-terra-contracts/src/commands/abstract/index.ts
+++ b/packages-ts/gauntlet-terra-contracts/src/commands/abstract/index.ts
@@ -1,4 +1,5 @@
import { Result } from '@chainlink/gauntlet-core'
+import { MsgExecuteContract } from '@terra-money/terra.js'
import { logger, prompt } from '@chainlink/gauntlet-core/dist/utils'
import { TransactionResponse, TerraCommand } from '@chainlink/gauntlet-terra'
import { Contract, CONTRACT_LIST, getContract, TerraABI, TERRA_OPERATIONS } from '../../lib/contracts'
@@ -125,6 +126,11 @@ export default class AbstractCommand extends TerraCommand {
this.contracts = [this.opts.contract.id]
}
+ makeRawTransaction = async (): Promise => {
+ const address = this.args[0]
+ return new MsgExecuteContract(this.wallet.key.accAddress, address, this.params)
+ }
+
abstractDeploy: AbstractExecute = async (params: any) => {
logger.loading(`Deploying contract ${this.opts.contract.id}`)
const codeId = this.codeIds[this.opts.contract.id]
diff --git a/packages-ts/gauntlet-terra-contracts/src/commands/abstract/inspectionWrapper.ts b/packages-ts/gauntlet-terra-contracts/src/commands/abstract/inspectionWrapper.ts
index af08a195..c58578da 100644
--- a/packages-ts/gauntlet-terra-contracts/src/commands/abstract/inspectionWrapper.ts
+++ b/packages-ts/gauntlet-terra-contracts/src/commands/abstract/inspectionWrapper.ts
@@ -47,6 +47,10 @@ export const instructionToInspectCommand = (
super(flags, args)
}
+ makeRawTransaction = () => {
+ throw new Error('Inspection command does not involve any transaction')
+ }
+
execute = async (): Promise> => {
const input = await inspectInstruction.makeInput(this.flags, this.args)
const commands = await Promise.all(
diff --git a/packages-ts/gauntlet-terra-contracts/src/commands/contracts/link/deploy.ts b/packages-ts/gauntlet-terra-contracts/src/commands/contracts/link/deploy.ts
index c644a4e9..33fd1b45 100644
--- a/packages-ts/gauntlet-terra-contracts/src/commands/contracts/link/deploy.ts
+++ b/packages-ts/gauntlet-terra-contracts/src/commands/contracts/link/deploy.ts
@@ -19,6 +19,10 @@ export default class DeployLink extends TerraCommand {
super(flags, args)
}
+ makeRawTransaction = async () => {
+ throw new Error('Deploy LINK command: makeRawTransaction method not implemented')
+ }
+
execute = async () => {
await prompt(`Begin deploying LINK Token?`)
const deploy = await this.deploy(CW20_BASE_CODE_IDs[this.flags.network], {
diff --git a/packages-ts/gauntlet-terra-contracts/src/commands/contracts/link/transfer.ts b/packages-ts/gauntlet-terra-contracts/src/commands/contracts/link/transfer.ts
index 367a1ea2..fd2732f6 100644
--- a/packages-ts/gauntlet-terra-contracts/src/commands/contracts/link/transfer.ts
+++ b/packages-ts/gauntlet-terra-contracts/src/commands/contracts/link/transfer.ts
@@ -17,6 +17,10 @@ export default class TransferLink extends TerraCommand {
super(flags, args)
}
+ makeRawTransaction = async () => {
+ throw new Error('Transfer LINK command: makeRawTransaction method not implemented')
+ }
+
execute = async () => {
const decimals = this.flags.decimals || 18
const link = this.flags.link || process.env.LINK
diff --git a/packages-ts/gauntlet-terra-contracts/src/commands/tooling/upload.ts b/packages-ts/gauntlet-terra-contracts/src/commands/tooling/upload.ts
index 2ce9d6bb..a9c4df07 100644
--- a/packages-ts/gauntlet-terra-contracts/src/commands/tooling/upload.ts
+++ b/packages-ts/gauntlet-terra-contracts/src/commands/tooling/upload.ts
@@ -22,6 +22,10 @@ export default class UploadContractCode extends TerraCommand {
super(flags, args)
}
+ makeRawTransaction = async () => {
+ throw new Error('Upload command: makeRawTransaction method not implemented')
+ }
+
getCodeId(response): number | undefined {
return Number(this.parseResponseValue(response, 'store_code', 'code_id'))
}
diff --git a/packages-ts/gauntlet-terra/src/commands/internal/terra.ts b/packages-ts/gauntlet-terra/src/commands/internal/terra.ts
index 2eb61655..0b2ef097 100644
--- a/packages-ts/gauntlet-terra/src/commands/internal/terra.ts
+++ b/packages-ts/gauntlet-terra/src/commands/internal/terra.ts
@@ -23,6 +23,7 @@ export default abstract class TerraCommand extends WriteCommand Promise>
+ abstract makeRawTransaction: () => Promise
constructor(flags, args) {
super(flags, args)