-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add WrapCommand, makeRawTransaction(), ProposalContext
Also: fix compiler errors, workaround for gauntlet-core bug in type declaration for findPolymorphic
- Loading branch information
1 parent
e9e2978
commit 3f8b33e
Showing
6 changed files
with
66 additions
and
39 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
31 changes: 22 additions & 9 deletions
31
packages-ts/gauntlet-terra-contracts/src/commands/abstract/polymorphic.ts
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,35 +1,48 @@ | ||
import { TerraCommand } from '@chainlink/gauntlet-terra' | ||
import { TerraCommand, TransactionResponse } from '@chainlink/gauntlet-terra' | ||
import { MultisigTerraCommand } from '../contracts/multisig' | ||
import { Result, Command } from '@chainlink/gauntlet-core' | ||
|
||
type COMMANDS = { | ||
custom: any[] | ||
class EmptyCommand extends Command { | ||
constructor() { | ||
super({help : false}, []) | ||
} | ||
} | ||
|
||
export default (commands: COMMANDS, slug: string) => { | ||
export default (commands: any[], slug: string) : Command => { | ||
const slugs: string[] = slug.split(':') | ||
if (slugs.length < 3) { | ||
return null | ||
throw Error(`Command ${slugs.join(':')} not found`) | ||
} | ||
const op: string = slugs.pop()! | ||
const command: any = commands.custom[slugs.join()] | ||
if (!!command) return undefined | ||
const command: any = commands[slugs.join()] | ||
if (!!command) throw Error(`Command ${slugs.join(':')} not found`) | ||
|
||
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 { | ||
class WrappedCommand extends MultisigTerraCommand { | ||
static id = slugs.join() | ||
|
||
constructor(flags, args) { | ||
super(flags, args) | ||
} | ||
|
||
multisigOp = () => { | ||
return op | ||
} | ||
commandType = () => { | ||
return command | ||
} | ||
} | ||
|
||
let cmd = new EmptyCommand() | ||
let wc = Object.setPrototypeOf(WrappedCommand, EmptyCommand.prototype) | ||
wc = Object.assign(wc, cmd) | ||
return wc | ||
default: | ||
return undefined | ||
throw Error(`Command ${slugs.join(':')} not found`) | ||
} | ||
} |
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
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,6 +1,10 @@ | ||
import { Tx as RawTransaction } from '@terra-money/terra.js' | ||
|
||
export type TransactionResponse = { | ||
hash: string | ||
address?: string | ||
wait: () => { success: boolean } | ||
tx?: any | ||
} | ||
|
||
export { RawTransaction } |
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,6 +1,6 @@ | ||
import TerraCommand from './commands/internal/terra' | ||
import { waitExecute } from './lib/execute' | ||
import { TransactionResponse } from './commands/types' | ||
import { RawTransaction, TransactionResponse } from './commands/types' | ||
import * as constants from './lib/constants' | ||
|
||
export { TerraCommand, waitExecute, TransactionResponse, constants } | ||
export { RawTransaction, TerraCommand, waitExecute, TransactionResponse, constants } |