Skip to content

Commit

Permalink
wip: feat(cw): 1st decoded decrypted namada tx
Browse files Browse the repository at this point in the history
  • Loading branch information
egasimus committed Mar 7, 2024
1 parent e94fca1 commit 7e63aa8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
30 changes: 23 additions & 7 deletions packages/cw/namada/namada-gov.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,16 @@ export class Vote {
}
}

const voteValueSchema = schemaEnum([
['Yay', Schema.Unit],
['Nay', Schema.Unit],
['Abstain', Schema.Unit],
])

const voteSchema = Schema.Struct({
validator: addressSchema,
delegator: addressSchema,
data: Schema.Enum({
Yay: Schema.Unit,
Nay: Schema.Unit,
Abstain: Schema.Unit
}),
data: voteValueSchema,
})

const proposalStatusSchema = Schema.Enum({
Expand Down Expand Up @@ -220,8 +222,22 @@ export class InitProposal extends fromBorshStruct({}) {
}
}

export class VoteProposal extends fromBorshStruct({}) {
export class VoteProposal extends fromBorshStruct({
id: Schema.u64,
vote: voteValueSchema,
voter: addressSchema,
delegations: Schema.Vec(addressSchema)
}) {
declare id: bigint
declare vote
declare voter
declare delegations
print (console) {
throw new Error('print VoteProposal: not implemented')
console
.log(Core.bold(' Decoded VoteProposal:'))
.log(' ID: ', Core.bold(this.id))
.log(' Vote: ', Core.bold(JSON.stringify(this.vote)))
.log(' Voter: ', Core.bold(JSON.stringify(this.voter)))
.log(' Delegations:', Core.bold(JSON.stringify(this.delegations)))
}
}
2 changes: 1 addition & 1 deletion packages/cw/namada/namada-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function fromBorshStruct (fields) {
Core.assignCamelCase(this, data, Object.keys(fields))
}
}
print (console) {
print (console: Core.Console) {
throw new Core.Error(`print ${this.constructor.name}: not implemented`)
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/cw/namada/namada.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ class NamadaCLI extends CLI {
this.log()
tx.print(this.log)
if (tx instanceof NamadaDecryptedTransaction) {
this.log.log()
tx.decodeInner().print(this.log)
}
//this.log
Expand Down

0 comments on commit 7e63aa8

Please sign in to comment.