Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
reductionista committed Feb 15, 2022
1 parent 201ab1f commit c27ce1c
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,21 @@ export default class AbstractCommand extends TerraCommand {
}
}

// create and sign transaction, without executing
abstractPrepare = async () => {
const operations = {
[TERRA_OPERATIONS.DEPLOY]: this.opts.prepareDeploy()
[TERRA_OPERATIONS.EXECUTE]: this.opts.prepareCall()
}
return await operations[this.opts.action](address, {
[this.opts.function]: this.params,
})
}

const address = this.args[0]
return operations[this.opts.action](this.params, address)
}

execute = async () => {
const operations = {
[TERRA_OPERATIONS.DEPLOY]: this.abstractDeploy,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,34 @@ import { TerraCommand } from '@chainlink/gauntlet-terra'
import { MultisigTerraCommand } from '../contracts/multisig'

type COMMANDS = {
custom:any[]
custom: any[]
}

export default (commands:COMMANDS, slug:string) => {
const slugs:string[] = slug.split(':')
if (slugs.length < 3) {
return null
}
const op:string = slugs.pop()!
const command:any = commands.custom[slugs.join()]
if (!!command) return undefined
export default (commands: COMMANDS, slug: string) => {
const slugs: string[] = slug.split(':')
if (slugs.length < 3) {
return null
}
const op: string = slugs.pop()!
const command: any = commands.custom[slugs.join()]
if (!!command) return undefined

switch(op) {
case 'multisig':
case 'propose':
case 'vote':
case 'execute':
case 'approve': // vote yes, then execute if threshold is reached
return class Command extends MultisigTerraCommand {
static id = slugs.join()
multisigOp = () => { return op }
commandType = () => { return command }
}
default:
return undefined
}
switch (op) {
case 'multisig':
case 'propose':
case 'vote':
case 'execute':
case 'approve': // vote yes, then execute if threshold is reached
return class Command extends MultisigTerraCommand {
static id = slugs.join()
multisigOp = () => {
return op
}
commandType = () => {
return command
}
}
default:
return undefined
}
}

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CreateGroup } from './group'
import { CreateWallet } from './wallet'
import {MultisigTerraCommand} from './multisig'
import { MultisigTerraCommand } from './multisig'

export default [CreateGroup, CreateWallet]
export { MultisigTerraCommand }
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { logger, prompt } from '@chainlink/gauntlet-core/dist/utils'
import { Result } from '@chainlink/gauntlet-core'
import { TerraCommand, TransactionResponse } from '@chainlink/gauntlet-terra'
import { CATEGORIES } from '../../../lib/constants'
import { CONTRACT_LIST, Contract, getContract } from '../../../lib/contracts'
import { CONTRACT_LIST, Contract, getContract, TERRA_OPERATIONS } from '../../../lib/contracts'

type StringGetter = () => string

Expand All @@ -21,7 +21,7 @@ abstract class MultisigTerraCommand extends TerraCommand {
commandType:any
multisigOp:StringGetter

command:TerraCommand
command:AbstractCommand
multisigAddress:string
multisigContract: Promise<Contract>

Expand All @@ -37,14 +37,22 @@ abstract class MultisigTerraCommand extends TerraCommand {
}

execute = async (): Promise<Result<TransactionResponse>> => {
if ( MultisigTerraCommand.id[1] == 'deploy' )
this.command.run()
const tx =

switch ( this.command.opts.action) {
case(TERRA_OPERATIONS.deploy):
tx = this.command.prepare_deploy()
} else if () {
this.command.prepare_call()
}

const contract = getContract()

return {
responses: [
{
tx: new TransactionResponse,
contract: ''
tx: tx
contract: contract
}
]
} as Result<TransactionResponse>
Expand Down
6 changes: 3 additions & 3 deletions packages-ts/gauntlet-terra/src/commands/internal/terra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default abstract class TerraCommand extends WriteCommand<TransactionRespo
}

async deploy(codeId, instantiateMsg, migrationContract = undefined) {
const instantiateTx = await this.prepareDeploy(codeId, instantiateMsg, migrationContract = undefined)
const instantiateTx = await this.prepareDeploy(codeId, instantiateMsg, (migrationContract = undefined))
logger.loading(`Deploying contract...`)
const res = await this.provider.tx.broadcast(instantiateTx)

Expand All @@ -122,7 +122,7 @@ export default abstract class TerraCommand extends WriteCommand<TransactionRespo
const tx = await this.prepareUpload(wasm, contractName)
logger.loading(`Uploading ${contractName} contract code...`)
const res = await this.provider.tx.broadcast(tx)

return this.wrapResponse(res)
}
}
}

0 comments on commit c27ce1c

Please sign in to comment.