From 7d464157624c7fdb1277f9a57683747932ad74a9 Mon Sep 17 00:00:00 2001 From: Patrycja Zawadka Date: Tue, 26 Oct 2021 18:27:55 +0200 Subject: [PATCH 01/12] Generate tendermint types --- chain/tendermint.ts | 713 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 713 insertions(+) create mode 100644 chain/tendermint.ts diff --git a/chain/tendermint.ts b/chain/tendermint.ts new file mode 100644 index 0000000..7880770 --- /dev/null +++ b/chain/tendermint.ts @@ -0,0 +1,713 @@ +import '../common/eager_offset' +import { Bytes } from '../common/collections' + +export namespace tendermint { + export type Hash = Bytes + + export enum SignedMsgType { + SIGNED_MSG_TYPE_UNKNOWN= 0, + SIGNED_MSG_TYPE_PREVOTE= 1, + SIGNED_MSG_TYPE_PRECOMMIT= 2, + SIGNED_MSG_TYPE_PROPOSAL= 3, + } + + export enum BlockIDFlag { + BLOCK_ID_FLAG_UNKNOWN= 0, + BLOCK_ID_FLAG_ABSENT= 1, + BLOCK_ID_FLAG_COMMIT= 2, + BLOCK_ID_FLAG_NIL= 3, + } + + export class EventList { + public newblock: EventDataNewBlock + public transaction: Array + public vote: EventDataVote + public roundstate: EventDataRoundState + public newround: EventDataNewRound + public completeproposal: EventDataCompleteProposal + public validatorsetupdates: EventDataValidatorSetUpdates + public eventdatastring: EventDataString + public blocksyncstatus: EventDataBlockSyncStatus + public statesyncstatus: EventDataStateSyncStatus + + constructor( + newblock: EventDataNewBlock, + transaction: Array, + vote: EventDataVote, + roundstate: EventDataRoundState, + newround: EventDataNewRound, + completeproposal: EventDataCompleteProposal, + validatorsetupdates: EventDataValidatorSetUpdates, + eventdatastring: EventDataString, + blocksyncstatus: EventDataBlockSyncStatus, + statesyncstatus: EventDataStateSyncStatus, + ) { + this.newblock = newblock; + this.transaction = transaction; + this.vote = vote; + this.roundstate = roundstate; + this.newround = newround; + this.completeproposal = completeproposal; + this.validatorsetupdates = validatorsetupdates; + this.eventdatastring = eventdatastring; + this.blocksyncstatus = blocksyncstatus; + this.statesyncstatus = statesyncstatus; + } + } + + export class EventDataNewBlock { + public block: Block + public block_id: BlockID + public result_begin_block: ResponseBeginBlock + public result_end_block: ResponseEndBlock + + constructor( + block: Block, + block_id: BlockID, + result_begin_block: ResponseBeginBlock, + result_end_block: ResponseEndBlock, + ) { + this.block = block; + this.block_id = block_id; + this.result_begin_block = result_begin_block; + this.result_end_block = result_end_block; + } + } + + export class ResponseBeginBlock { + public events: Array + + constructor( + events: Array, + ) { + this.events = events; + } + } + + export class ResponseEndBlock { + public validator_updates: Array + public consensus_param_updates: ConsensusParams + public events: Array + + constructor( + validator_updates: Array, + consensus_param_updates: ConsensusParams, + events: Array, + ) { + this.validator_updates = validator_updates; + this.consensus_param_updates = consensus_param_updates; + this.events = events; + } + } + + export class ConsensusParams { + public block: Block + public evidence: Evidence + public validator: Validator + public version: Version + + constructor( + block: Block, + evidence: Evidence, + validator: Validator, + version: Version, + ) { + this.block = block; + this.evidence = evidence; + this.validator = validator; + this.version = version; + } + } + + export class Version { + public app_version: u64 + + constructor( + app_version: u64, + ) { + this.app_version = app_version; + } + } + + export class Block { + public header: Header + public data: Data + public evidence: EvidenceList + public last_commit: Commit + + constructor( + header: Header, + data: Data, + evidence: EvidenceList, + last_commit: Commit, + ) { + this.header = header; + this.data = data; + this.evidence = evidence; + this.last_commit = last_commit; + } + } + + export class Commit { + public height: u64 + public round: i32 + public block_id: BlockID + public signatures: Array + + constructor( + height: u64, + round: i32, + block_id: BlockID, + signatures: Array, + ) { + this.height = height; + this.round = round; + this.block_id = block_id; + this.signatures = signatures; + } + } + + export class CommitSig { + public block_id_flag: BlockIDFlag + public validator_address: Address + public timestamp: Timestamp + public signature: Bytes + + constructor( + block_id_flag: BlockIDFlag, + validator_address: Address, + timestamp: Timestamp, + signature: Bytes, + ) { + this.block_id_flag = block_id_flag; + this.validator_address = validator_address; + this.timestamp = timestamp; + this.signature = signature; + } + } + + export class EventDataNewBlockHeader { + public header: Header + public num_txs: i64 + public result_begin_block: ResponseBeginBlock + public result_end_block: ResponseEndBlock + + constructor( + header: Header, + num_txs: i64, + result_begin_block: ResponseBeginBlock, + result_end_block: ResponseEndBlock, + ) { + this.header = header; + this.num_txs = num_txs; + this.result_begin_block = result_begin_block; + this.result_end_block = result_end_block; + } + } + + export class Header { + public version: Consensus + public chain_id: string + public height: u64 + public time: Timestamp + public last_block_id: BlockID + public last_commit_hash: Hash + public data_hash: Hash + public validators_hash: Hash + public next_validators_hash: Hash + public consensus_hash: Hash + public app_hash: Hash + public last_results_hash: Hash + public evidence_hash: Hash + public proposer_address: Address + + constructor( + version: Consensus, + chain_id: string, + height: u64, + time: Timestamp, + last_block_id: BlockID, + last_commit_hash: Hash, + data_hash: Hash, + validators_hash: Hash, + next_validators_hash: Hash, + consensus_hash: Hash, + app_hash: Hash, + last_results_hash: Hash, + evidence_hash: Hash, + proposer_address: Address, + ) { + this.version = version; + this.chain_id = chain_id; + this.height = height; + this.time = time; + this.last_block_id = last_block_id; + this.last_commit_hash = last_commit_hash; + this.data_hash = data_hash; + this.validators_hash = validators_hash; + this.next_validators_hash = next_validators_hash; + this.consensus_hash = consensus_hash; + this.app_hash = app_hash; + this.last_results_hash = last_results_hash; + this.evidence_hash = evidence_hash; + this.proposer_address = proposer_address; + } + } + + export class Consensus { + public block: u64 + public app: u64 + + constructor( + block: u64, + app: u64, + ) { + this.block = block; + this.app = app; + } + } + + export class BlockID { + public hash: Hash + public part_set_header: PartSetHeader + + constructor( + hash: Hash, + part_set_header: PartSetHeader, + ) { + this.hash = hash; + this.part_set_header = part_set_header; + } + } + + export class PartSetHeader { + public total: u32 + public hash: Hash + + constructor( + total: u32, + hash: Hash, + ) { + this.total = total; + this.hash = hash; + } + } + + export class Data { + public txs: Array + + constructor( + txs: Array, + ) { + this.txs = txs; + } + } + + export class Evidence { + public duplicate_vote_evidence: DuplicateVoteEvidence + public light_client_attack_evidence: LightClientAttackEvidence + + constructor( + duplicate_vote_evidence: DuplicateVoteEvidence, + light_client_attack_evidence: LightClientAttackEvidence, + ) { + this.duplicate_vote_evidence = duplicate_vote_evidence; + this.light_client_attack_evidence = light_client_attack_evidence; + } + } + + export class DuplicateVoteEvidence { + public vote_a: EventDataVote + public vote_b: EventDataVote + public total_voting_power: i64 + public validator_power: i64 + public timestamp: Timestamp + + constructor( + vote_a: EventDataVote, + vote_b: EventDataVote, + total_voting_power: i64, + validator_power: i64, + timestamp: Timestamp, + ) { + this.vote_a = vote_a; + this.vote_b = vote_b; + this.total_voting_power = total_voting_power; + this.validator_power = validator_power; + this.timestamp = timestamp; + } + } + + export class EventDataTx { + public TxResult: TxResult + + constructor( + TxResult: TxResult, + ) { + this.TxResult = TxResult; + } + } + + export class EventDataVote { + public eventvotetype: SignedMsgType + public height: u64 + public round: i32 + public block_id: BlockID + public timestamp: Timestamp + public validator_address: Address + public validator_index: i32 + public signature: Bytes + + constructor( + eventvotetype: SignedMsgType, + height: u64, + round: i32, + block_id: BlockID, + timestamp: Timestamp, + validator_address: Address, + validator_index: i32, + signature: Bytes, + ) { + this.eventvotetype = eventvotetype; + this.height = height; + this.round = round; + this.block_id = block_id; + this.timestamp = timestamp; + this.validator_address = validator_address; + this.validator_index = validator_index; + this.signature = signature; + } + } + + export class LightClientAttackEvidence { + public conflicting_block: LightBlock + public common_height: i64 + public byzantine_validators: Array + public total_voting_power: i64 + public timestamp: Timestamp + + constructor( + conflicting_block: LightBlock, + common_height: i64, + byzantine_validators: Array, + total_voting_power: i64, + timestamp: Timestamp, + ) { + this.conflicting_block = conflicting_block; + this.common_height = common_height; + this.byzantine_validators = byzantine_validators; + this.total_voting_power = total_voting_power; + this.timestamp = timestamp; + } + } + + export class LightBlock { + public signed_header: SignedHeader + public validator_set: ValidatorSet + + constructor( + signed_header: SignedHeader, + validator_set: ValidatorSet, + ) { + this.signed_header = signed_header; + this.validator_set = validator_set; + } + } + + export class ValidatorSet { + public validators: Array + public proposer: Validator + public total_voting_power: i64 + + constructor( + validators: Array, + proposer: Validator, + total_voting_power: i64, + ) { + this.validators = validators; + this.proposer = proposer; + this.total_voting_power = total_voting_power; + } + } + + export class SignedHeader { + public header: Header + public commit: Commit + + constructor( + header: Header, + commit: Commit, + ) { + this.header = header; + this.commit = commit; + } + } + + export class EvidenceList { + public evidence: Array + + constructor( + evidence: Array, + ) { + this.evidence = evidence; + } + } + + export class Validator { + public address: Bytes + public pub_key: PublicKey + public voting_power: i64 + public proposer_priority: i64 + + constructor( + address: Bytes, + pub_key: PublicKey, + voting_power: i64, + proposer_priority: i64, + ) { + this.address = address; + this.pub_key = pub_key; + this.voting_power = voting_power; + this.proposer_priority = proposer_priority; + } + } + + export class PublicKey { + public ed25519: Bytes + public secp256k1: Bytes + public sr25519: Bytes + + constructor( + ed25519: Bytes, + secp256k1: Bytes, + sr25519: Bytes, + ) { + this.ed25519 = ed25519; + this.secp256k1 = secp256k1; + this.sr25519 = sr25519; + } + } + + export class TxResult { + public height: u64 + public index: u32 + public tx: Bytes + public result: ResponseDeliverTx + + constructor( + height: u64, + index: u32, + tx: Bytes, + result: ResponseDeliverTx, + ) { + this.height = height; + this.index = index; + this.tx = tx; + this.result = result; + } + } + + export class ResponseDeliverTx { + public code: u32 + public data: Bytes + public log: string + public info: string + public gas_wanted: i64 + public gas_used: i64 + public events: Array + public codespace: string + + constructor( + code: u32, + data: Bytes, + log: string, + info: string, + gas_wanted: i64, + gas_used: i64, + events: Array, + codespace: string, + ) { + this.code = code; + this.data = data; + this.log = log; + this.info = info; + this.gas_wanted = gas_wanted; + this.gas_used = gas_used; + this.events = events; + this.codespace = codespace; + } + } + + export class Event { + public eventtype: string + public attributes: Array + + constructor( + eventtype: string, + attributes: Array, + ) { + this.eventtype = eventtype; + this.attributes = attributes; + } + } + + export class EventAttribute { + public key: string + public value: string + public index: bool + + constructor( + key: string, + value: string, + index: bool, + ) { + this.key = key; + this.value = value; + this.index = index; + } + } + + export class EventDataRoundState { + public height: u64 + public round: i32 + public step: string + + constructor( + height: u64, + round: i32, + step: string, + ) { + this.height = height; + this.round = round; + this.step = step; + } + } + + export class EventDataNewRound { + public height: u64 + public round: i32 + public step: string + public proposer: ValidatorInfo + + constructor( + height: u64, + round: i32, + step: string, + proposer: ValidatorInfo, + ) { + this.height = height; + this.round = round; + this.step = step; + this.proposer = proposer; + } + } + + export class ValidatorInfo { + public address: Address + public index: i32 + + constructor( + address: Address, + index: i32, + ) { + this.address = address; + this.index = index; + } + } + + export class Address { + public address: Bytes + + constructor( + address: Bytes, + ) { + this.address = address; + } + } + + export class EventDataCompleteProposal { + public height: u64 + public round: i32 + public step: string + public block_id: BlockID + + constructor( + height: u64, + round: i32, + step: string, + block_id: BlockID, + ) { + this.height = height; + this.round = round; + this.step = step; + this.block_id = block_id; + } + } + + export class EventDataValidatorSetUpdates { + public validator_updates: Array + + constructor( + validator_updates: Array, + ) { + this.validator_updates = validator_updates; + } + } + + export class EventDataString { + public eventdatastring: string + + constructor( + eventdatastring: string, + ) { + this.eventdatastring = eventdatastring; + } + } + + export class EventDataBlockSyncStatus { + public complete: bool + public height: u64 + + constructor( + complete: bool, + height: u64, + ) { + this.complete = complete; + this.height = height; + } + } + + export class EventDataStateSyncStatus { + public complete: bool + public height: u64 + + constructor( + complete: bool, + height: u64, + ) { + this.complete = complete; + this.height = height; + } + } + + export class Timestamp { + public seconds: i64 + public nanos: i32 + + constructor( + seconds: i64, + nanos: i32, + ) { + this.seconds = seconds; + this.nanos = nanos; + } + } + + export class fig { + + constructor( + ) { + } + } + +} From b622ab9e0a520c13a82a904de9dfd0a75c7f7cb6 Mon Sep 17 00:00:00 2001 From: Patrycja Zawadka Date: Fri, 17 Dec 2021 16:19:54 +0100 Subject: [PATCH 02/12] Update tendermint types --- .gitignore | 3 + chain/near.ts | 2 - chain/tendermint.ts | 1175 ++++++++++++++++++------------------------- global/global.ts | 133 ++++- index.ts | 2 + test/test.js | 3 + 6 files changed, 643 insertions(+), 675 deletions(-) diff --git a/.gitignore b/.gitignore index ad46b30..2c99343 100644 --- a/.gitignore +++ b/.gitignore @@ -59,3 +59,6 @@ typings/ # next.js build output .next + +index.wasm +package-lock.json \ No newline at end of file diff --git a/chain/near.ts b/chain/near.ts index ae08232..fe3f898 100644 --- a/chain/near.ts +++ b/chain/near.ts @@ -299,13 +299,11 @@ export namespace near { @operator('<') lt(other: MerklePathItem): boolean { abort("Less than operator isn't supported in MerklePathItem") - return false } @operator('>') gt(other: MerklePathItem): boolean { abort("Greater than operator isn't supported in MerklePathItem") - return false } toString(): string { diff --git a/chain/tendermint.ts b/chain/tendermint.ts index 7880770..d338a14 100644 --- a/chain/tendermint.ts +++ b/chain/tendermint.ts @@ -1,713 +1,544 @@ import '../common/eager_offset' -import { Bytes } from '../common/collections' - +import { Bytes } from "../common/collections" +import { Address, BigInt } from '../common/numbers' export namespace tendermint { - export type Hash = Bytes + export type Hash = Bytes; export enum SignedMsgType { - SIGNED_MSG_TYPE_UNKNOWN= 0, - SIGNED_MSG_TYPE_PREVOTE= 1, - SIGNED_MSG_TYPE_PRECOMMIT= 2, - SIGNED_MSG_TYPE_PROPOSAL= 3, + SIGNED_MSG_TYPE_UNKNOWN = 0, + SIGNED_MSG_TYPE_PREVOTE = 1, + SIGNED_MSG_TYPE_PRECOMMIT = 2, + SIGNED_MSG_TYPE_PROPOSAL = 3, } - + export enum BlockIDFlag { - BLOCK_ID_FLAG_UNKNOWN= 0, - BLOCK_ID_FLAG_ABSENT= 1, - BLOCK_ID_FLAG_COMMIT= 2, - BLOCK_ID_FLAG_NIL= 3, + BLOCK_ID_FLAG_UNKNOWN = 0, + BLOCK_ID_FLAG_ABSENT = 1, + BLOCK_ID_FLAG_COMMIT = 2, + BLOCK_ID_FLAG_NIL = 3, } - + export class EventList { - public newblock: EventDataNewBlock - public transaction: Array - public vote: EventDataVote - public roundstate: EventDataRoundState - public newround: EventDataNewRound - public completeproposal: EventDataCompleteProposal - public validatorsetupdates: EventDataValidatorSetUpdates - public eventdatastring: EventDataString - public blocksyncstatus: EventDataBlockSyncStatus - public statesyncstatus: EventDataStateSyncStatus - - constructor( - newblock: EventDataNewBlock, - transaction: Array, - vote: EventDataVote, - roundstate: EventDataRoundState, - newround: EventDataNewRound, - completeproposal: EventDataCompleteProposal, - validatorsetupdates: EventDataValidatorSetUpdates, - eventdatastring: EventDataString, - blocksyncstatus: EventDataBlockSyncStatus, - statesyncstatus: EventDataStateSyncStatus, - ) { - this.newblock = newblock; - this.transaction = transaction; - this.vote = vote; - this.roundstate = roundstate; - this.newround = newround; - this.completeproposal = completeproposal; - this.validatorsetupdates = validatorsetupdates; - this.eventdatastring = eventdatastring; - this.blocksyncstatus = blocksyncstatus; - this.statesyncstatus = statesyncstatus; - } - } - - export class EventDataNewBlock { - public block: Block - public block_id: BlockID - public result_begin_block: ResponseBeginBlock - public result_end_block: ResponseEndBlock - - constructor( - block: Block, - block_id: BlockID, - result_begin_block: ResponseBeginBlock, - result_end_block: ResponseEndBlock, - ) { - this.block = block; - this.block_id = block_id; - this.result_begin_block = result_begin_block; - this.result_end_block = result_end_block; - } - } - + public newblock: EventBlock; + public transaction: Array; + public validatorsetupdates: EventValidatorSetUpdates; + + constructor( + newblock: EventBlock, + transaction: Array, + validatorsetupdates: EventValidatorSetUpdates + ) { + this.newblock = newblock; + this.transaction = transaction; + this.validatorsetupdates = validatorsetupdates; + } + } + + export class EventBlock { + public block: Block; + public block_id: BlockID; + public result_begin_block: ResponseBeginBlock; + public result_end_block: ResponseEndBlock; + + constructor( + block: Block, + block_id: BlockID, + result_begin_block: ResponseBeginBlock, + result_end_block: ResponseEndBlock + ) { + this.block = block; + this.block_id = block_id; + this.result_begin_block = result_begin_block; + this.result_end_block = result_end_block; + } + } + export class ResponseBeginBlock { - public events: Array - - constructor( - events: Array, - ) { - this.events = events; - } + public events: Array; + + constructor(events: Array) { + this.events = events; + } } - + export class ResponseEndBlock { - public validator_updates: Array - public consensus_param_updates: ConsensusParams - public events: Array - - constructor( - validator_updates: Array, - consensus_param_updates: ConsensusParams, - events: Array, - ) { - this.validator_updates = validator_updates; - this.consensus_param_updates = consensus_param_updates; - this.events = events; - } - } - + public validator_updates: Array; + public consensus_param_updates: ConsensusParams; + public events: Array; + + constructor( + validator_updates: Array, + consensus_param_updates: ConsensusParams, + events: Array + ) { + this.validator_updates = validator_updates; + this.consensus_param_updates = consensus_param_updates; + this.events = events; + } + } + export class ConsensusParams { - public block: Block - public evidence: Evidence - public validator: Validator - public version: Version - - constructor( - block: Block, - evidence: Evidence, - validator: Validator, - version: Version, - ) { - this.block = block; - this.evidence = evidence; - this.validator = validator; - this.version = version; - } - } - + public block: Block; + public evidence: Evidence; + public validator: Validator; + public version: Version; + + constructor( + block: Block, + evidence: Evidence, + validator: Validator, + version: Version + ) { + this.block = block; + this.evidence = evidence; + this.validator = validator; + this.version = version; + } + } + export class Version { - public app_version: u64 - - constructor( - app_version: u64, - ) { - this.app_version = app_version; - } + public app_version: u64; + + constructor(app_version: u64) { + this.app_version = app_version; + } } - + export class Block { - public header: Header - public data: Data - public evidence: EvidenceList - public last_commit: Commit - - constructor( - header: Header, - data: Data, - evidence: EvidenceList, - last_commit: Commit, - ) { - this.header = header; - this.data = data; - this.evidence = evidence; - this.last_commit = last_commit; - } - } - + public header: Header; + public data: Data; + public evidence: EvidenceList; + public last_commit: Commit; + + constructor( + header: Header, + data: Data, + evidence: EvidenceList, + last_commit: Commit + ) { + this.header = header; + this.data = data; + this.evidence = evidence; + this.last_commit = last_commit; + } + } + export class Commit { - public height: u64 - public round: i32 - public block_id: BlockID - public signatures: Array - - constructor( - height: u64, - round: i32, - block_id: BlockID, - signatures: Array, - ) { - this.height = height; - this.round = round; - this.block_id = block_id; - this.signatures = signatures; - } - } - + public height: u64; + public round: i32; + public block_id: BlockID; + public signatures: Array; + + constructor( + height: u64, + round: i32, + block_id: BlockID, + signatures: Array + ) { + this.height = height; + this.round = round; + this.block_id = block_id; + this.signatures = signatures; + } + } + export class CommitSig { - public block_id_flag: BlockIDFlag - public validator_address: Address - public timestamp: Timestamp - public signature: Bytes - - constructor( - block_id_flag: BlockIDFlag, - validator_address: Address, - timestamp: Timestamp, - signature: Bytes, - ) { - this.block_id_flag = block_id_flag; - this.validator_address = validator_address; - this.timestamp = timestamp; - this.signature = signature; - } - } - - export class EventDataNewBlockHeader { - public header: Header - public num_txs: i64 - public result_begin_block: ResponseBeginBlock - public result_end_block: ResponseEndBlock - - constructor( - header: Header, - num_txs: i64, - result_begin_block: ResponseBeginBlock, - result_end_block: ResponseEndBlock, - ) { - this.header = header; - this.num_txs = num_txs; - this.result_begin_block = result_begin_block; - this.result_end_block = result_end_block; - } - } - + public block_id_flag: BlockIDFlag; + public validator_address: Address; + public timestamp: Timestamp; + public signature: Bytes; + + constructor( + block_id_flag: BlockIDFlag, + validator_address: Address, + timestamp: Timestamp, + signature: Bytes + ) { + this.block_id_flag = block_id_flag; + this.validator_address = validator_address; + this.timestamp = timestamp; + this.signature = signature; + } + } + + export class EventBlockHeader { + public header: Header; + public num_txs: i64; + public result_begin_block: ResponseBeginBlock; + public result_end_block: ResponseEndBlock; + + constructor( + header: Header, + num_txs: i64, + result_begin_block: ResponseBeginBlock, + result_end_block: ResponseEndBlock + ) { + this.header = header; + this.num_txs = num_txs; + this.result_begin_block = result_begin_block; + this.result_end_block = result_end_block; + } + } + export class Header { - public version: Consensus - public chain_id: string - public height: u64 - public time: Timestamp - public last_block_id: BlockID - public last_commit_hash: Hash - public data_hash: Hash - public validators_hash: Hash - public next_validators_hash: Hash - public consensus_hash: Hash - public app_hash: Hash - public last_results_hash: Hash - public evidence_hash: Hash - public proposer_address: Address - - constructor( - version: Consensus, - chain_id: string, - height: u64, - time: Timestamp, - last_block_id: BlockID, - last_commit_hash: Hash, - data_hash: Hash, - validators_hash: Hash, - next_validators_hash: Hash, - consensus_hash: Hash, - app_hash: Hash, - last_results_hash: Hash, - evidence_hash: Hash, - proposer_address: Address, - ) { - this.version = version; - this.chain_id = chain_id; - this.height = height; - this.time = time; - this.last_block_id = last_block_id; - this.last_commit_hash = last_commit_hash; - this.data_hash = data_hash; - this.validators_hash = validators_hash; - this.next_validators_hash = next_validators_hash; - this.consensus_hash = consensus_hash; - this.app_hash = app_hash; - this.last_results_hash = last_results_hash; - this.evidence_hash = evidence_hash; - this.proposer_address = proposer_address; - } - } - + public version: Consensus; + public chain_id: string; + public height: u64; + public time: Timestamp; + public last_block_id: BlockID; + public last_commit_hash: Hash; + public data_hash: Hash; + public validators_hash: Hash; + public next_validators_hash: Hash; + public consensus_hash: Hash; + public app_hash: Hash; + public last_results_hash: Hash; + public evidence_hash: Hash; + public proposer_address: Address; + + constructor( + version: Consensus, + chain_id: string, + height: u64, + time: Timestamp, + last_block_id: BlockID, + last_commit_hash: Hash, + data_hash: Hash, + validators_hash: Hash, + next_validators_hash: Hash, + consensus_hash: Hash, + app_hash: Hash, + last_results_hash: Hash, + evidence_hash: Hash, + proposer_address: Address + ) { + this.version = version; + this.chain_id = chain_id; + this.height = height; + this.time = time; + this.last_block_id = last_block_id; + this.last_commit_hash = last_commit_hash; + this.data_hash = data_hash; + this.validators_hash = validators_hash; + this.next_validators_hash = next_validators_hash; + this.consensus_hash = consensus_hash; + this.app_hash = app_hash; + this.last_results_hash = last_results_hash; + this.evidence_hash = evidence_hash; + this.proposer_address = proposer_address; + } + } + export class Consensus { - public block: u64 - public app: u64 - - constructor( - block: u64, - app: u64, - ) { - this.block = block; - this.app = app; - } - } - + public block: u64; + public app: u64; + + constructor(block: u64, app: u64) { + this.block = block; + this.app = app; + } + } + export class BlockID { - public hash: Hash - public part_set_header: PartSetHeader - - constructor( - hash: Hash, - part_set_header: PartSetHeader, - ) { - this.hash = hash; - this.part_set_header = part_set_header; - } - } - + public hash: Hash; + public part_set_header: PartSetHeader; + + constructor(hash: Hash, part_set_header: PartSetHeader) { + this.hash = hash; + this.part_set_header = part_set_header; + } + } + export class PartSetHeader { - public total: u32 - public hash: Hash - - constructor( - total: u32, - hash: Hash, - ) { - this.total = total; - this.hash = hash; - } - } - + public total: u32; + public hash: Hash; + + constructor(total: u32, hash: Hash) { + this.total = total; + this.hash = hash; + } + } + export class Data { - public txs: Array - - constructor( - txs: Array, - ) { - this.txs = txs; - } + public txs: Array; + + constructor(txs: Array) { + this.txs = txs; + } } - + export class Evidence { - public duplicate_vote_evidence: DuplicateVoteEvidence - public light_client_attack_evidence: LightClientAttackEvidence - - constructor( - duplicate_vote_evidence: DuplicateVoteEvidence, - light_client_attack_evidence: LightClientAttackEvidence, - ) { - this.duplicate_vote_evidence = duplicate_vote_evidence; - this.light_client_attack_evidence = light_client_attack_evidence; - } - } - + public duplicate_vote_evidence: DuplicateVoteEvidence; + public light_client_attack_evidence: LightClientAttackEvidence; + + constructor( + duplicate_vote_evidence: DuplicateVoteEvidence, + light_client_attack_evidence: LightClientAttackEvidence + ) { + this.duplicate_vote_evidence = duplicate_vote_evidence; + this.light_client_attack_evidence = light_client_attack_evidence; + } + } + export class DuplicateVoteEvidence { - public vote_a: EventDataVote - public vote_b: EventDataVote - public total_voting_power: i64 - public validator_power: i64 - public timestamp: Timestamp - - constructor( - vote_a: EventDataVote, - vote_b: EventDataVote, - total_voting_power: i64, - validator_power: i64, - timestamp: Timestamp, - ) { - this.vote_a = vote_a; - this.vote_b = vote_b; - this.total_voting_power = total_voting_power; - this.validator_power = validator_power; - this.timestamp = timestamp; - } - } - - export class EventDataTx { - public TxResult: TxResult - - constructor( - TxResult: TxResult, - ) { - this.TxResult = TxResult; - } - } - - export class EventDataVote { - public eventvotetype: SignedMsgType - public height: u64 - public round: i32 - public block_id: BlockID - public timestamp: Timestamp - public validator_address: Address - public validator_index: i32 - public signature: Bytes - - constructor( - eventvotetype: SignedMsgType, - height: u64, - round: i32, - block_id: BlockID, - timestamp: Timestamp, - validator_address: Address, - validator_index: i32, - signature: Bytes, - ) { - this.eventvotetype = eventvotetype; - this.height = height; - this.round = round; - this.block_id = block_id; - this.timestamp = timestamp; - this.validator_address = validator_address; - this.validator_index = validator_index; - this.signature = signature; - } - } - + public vote_a: EventVote; + public vote_b: EventVote; + public total_voting_power: i64; + public validator_power: i64; + public timestamp: Timestamp; + + constructor( + vote_a: EventVote, + vote_b: EventVote, + total_voting_power: i64, + validator_power: i64, + timestamp: Timestamp + ) { + this.vote_a = vote_a; + this.vote_b = vote_b; + this.total_voting_power = total_voting_power; + this.validator_power = validator_power; + this.timestamp = timestamp; + } + } + + export class EventTx { + public TxResult: TxResult; + + constructor(TxResult: TxResult) { + this.TxResult = TxResult; + } + } + + export class EventVote { + public eventvotetype: SignedMsgType; + public height: u64; + public round: i32; + public block_id: BlockID; + public timestamp: Timestamp; + public validator_address: Address; + public validator_index: i32; + public signature: Bytes; + + constructor( + eventvotetype: SignedMsgType, + height: u64, + round: i32, + block_id: BlockID, + timestamp: Timestamp, + validator_address: Address, + validator_index: i32, + signature: Bytes + ) { + this.eventvotetype = eventvotetype; + this.height = height; + this.round = round; + this.block_id = block_id; + this.timestamp = timestamp; + this.validator_address = validator_address; + this.validator_index = validator_index; + this.signature = signature; + } + } + export class LightClientAttackEvidence { - public conflicting_block: LightBlock - public common_height: i64 - public byzantine_validators: Array - public total_voting_power: i64 - public timestamp: Timestamp - - constructor( - conflicting_block: LightBlock, - common_height: i64, - byzantine_validators: Array, - total_voting_power: i64, - timestamp: Timestamp, - ) { - this.conflicting_block = conflicting_block; - this.common_height = common_height; - this.byzantine_validators = byzantine_validators; - this.total_voting_power = total_voting_power; - this.timestamp = timestamp; - } - } - + public conflicting_block: LightBlock; + public common_height: i64; + public byzantine_validators: Array; + public total_voting_power: i64; + public timestamp: Timestamp; + + constructor( + conflicting_block: LightBlock, + common_height: i64, + byzantine_validators: Array, + total_voting_power: i64, + timestamp: Timestamp + ) { + this.conflicting_block = conflicting_block; + this.common_height = common_height; + this.byzantine_validators = byzantine_validators; + this.total_voting_power = total_voting_power; + this.timestamp = timestamp; + } + } + export class LightBlock { - public signed_header: SignedHeader - public validator_set: ValidatorSet - - constructor( - signed_header: SignedHeader, - validator_set: ValidatorSet, - ) { - this.signed_header = signed_header; - this.validator_set = validator_set; - } - } - + public signed_header: SignedHeader; + public validator_set: ValidatorSet; + + constructor(signed_header: SignedHeader, validator_set: ValidatorSet) { + this.signed_header = signed_header; + this.validator_set = validator_set; + } + } + export class ValidatorSet { - public validators: Array - public proposer: Validator - public total_voting_power: i64 - - constructor( - validators: Array, - proposer: Validator, - total_voting_power: i64, - ) { - this.validators = validators; - this.proposer = proposer; - this.total_voting_power = total_voting_power; - } - } - + public validators: Array; + public proposer: Validator; + public total_voting_power: i64; + + constructor( + validators: Array, + proposer: Validator, + total_voting_power: i64 + ) { + this.validators = validators; + this.proposer = proposer; + this.total_voting_power = total_voting_power; + } + } + export class SignedHeader { - public header: Header - public commit: Commit - - constructor( - header: Header, - commit: Commit, - ) { - this.header = header; - this.commit = commit; - } - } - + public header: Header; + public commit: Commit; + + constructor(header: Header, commit: Commit) { + this.header = header; + this.commit = commit; + } + } + export class EvidenceList { - public evidence: Array - - constructor( - evidence: Array, - ) { - this.evidence = evidence; - } + public evidence: Array; + + constructor(evidence: Array) { + this.evidence = evidence; + } } - + export class Validator { - public address: Bytes - public pub_key: PublicKey - public voting_power: i64 - public proposer_priority: i64 - - constructor( - address: Bytes, - pub_key: PublicKey, - voting_power: i64, - proposer_priority: i64, - ) { - this.address = address; - this.pub_key = pub_key; - this.voting_power = voting_power; - this.proposer_priority = proposer_priority; - } - } - + public address: Bytes; + public pub_key: PublicKey; + public voting_power: i64; + public proposer_priority: i64; + + constructor( + address: Bytes, + pub_key: PublicKey, + voting_power: i64, + proposer_priority: i64 + ) { + this.address = address; + this.pub_key = pub_key; + this.voting_power = voting_power; + this.proposer_priority = proposer_priority; + } + } + export class PublicKey { - public ed25519: Bytes - public secp256k1: Bytes - public sr25519: Bytes - - constructor( - ed25519: Bytes, - secp256k1: Bytes, - sr25519: Bytes, - ) { - this.ed25519 = ed25519; - this.secp256k1 = secp256k1; - this.sr25519 = sr25519; - } - } - + public ed25519: Bytes; + public secp256k1: Bytes; + public sr25519: Bytes; + + constructor(ed25519: Bytes, secp256k1: Bytes, sr25519: Bytes) { + this.ed25519 = ed25519; + this.secp256k1 = secp256k1; + this.sr25519 = sr25519; + } + } + export class TxResult { - public height: u64 - public index: u32 - public tx: Bytes - public result: ResponseDeliverTx - - constructor( - height: u64, - index: u32, - tx: Bytes, - result: ResponseDeliverTx, - ) { - this.height = height; - this.index = index; - this.tx = tx; - this.result = result; - } - } - + public height: u64; + public index: u32; + public tx: Bytes; + public result: ResponseDeliverTx; + + constructor(height: u64, index: u32, tx: Bytes, result: ResponseDeliverTx) { + this.height = height; + this.index = index; + this.tx = tx; + this.result = result; + } + } + export class ResponseDeliverTx { - public code: u32 - public data: Bytes - public log: string - public info: string - public gas_wanted: i64 - public gas_used: i64 - public events: Array - public codespace: string - - constructor( - code: u32, - data: Bytes, - log: string, - info: string, - gas_wanted: i64, - gas_used: i64, - events: Array, - codespace: string, - ) { - this.code = code; - this.data = data; - this.log = log; - this.info = info; - this.gas_wanted = gas_wanted; - this.gas_used = gas_used; - this.events = events; - this.codespace = codespace; - } - } - + public code: u32; + public data: Bytes; + public log: string; + public info: string; + public gas_wanted: i64; + public gas_used: i64; + public events: Array; + public codespace: string; + + constructor( + code: u32, + data: Bytes, + log: string, + info: string, + gas_wanted: i64, + gas_used: i64, + events: Array, + codespace: string + ) { + this.code = code; + this.data = data; + this.log = log; + this.info = info; + this.gas_wanted = gas_wanted; + this.gas_used = gas_used; + this.events = events; + this.codespace = codespace; + } + } + export class Event { - public eventtype: string - public attributes: Array - - constructor( - eventtype: string, - attributes: Array, - ) { - this.eventtype = eventtype; - this.attributes = attributes; - } - } - + public eventtype: string; + public attributes: Array; + + constructor(eventtype: string, attributes: Array) { + this.eventtype = eventtype; + this.attributes = attributes; + } + } + export class EventAttribute { - public key: string - public value: string - public index: bool - - constructor( - key: string, - value: string, - index: bool, - ) { - this.key = key; - this.value = value; - this.index = index; - } - } - - export class EventDataRoundState { - public height: u64 - public round: i32 - public step: string - - constructor( - height: u64, - round: i32, - step: string, - ) { - this.height = height; - this.round = round; - this.step = step; - } - } - - export class EventDataNewRound { - public height: u64 - public round: i32 - public step: string - public proposer: ValidatorInfo - - constructor( - height: u64, - round: i32, - step: string, - proposer: ValidatorInfo, - ) { - this.height = height; - this.round = round; - this.step = step; - this.proposer = proposer; - } - } - - export class ValidatorInfo { - public address: Address - public index: i32 - - constructor( - address: Address, - index: i32, - ) { - this.address = address; - this.index = index; - } - } - - export class Address { - public address: Bytes - - constructor( - address: Bytes, - ) { - this.address = address; - } - } - - export class EventDataCompleteProposal { - public height: u64 - public round: i32 - public step: string - public block_id: BlockID - - constructor( - height: u64, - round: i32, - step: string, - block_id: BlockID, - ) { - this.height = height; - this.round = round; - this.step = step; - this.block_id = block_id; - } - } - - export class EventDataValidatorSetUpdates { - public validator_updates: Array - - constructor( - validator_updates: Array, - ) { - this.validator_updates = validator_updates; - } - } - - export class EventDataString { - public eventdatastring: string - - constructor( - eventdatastring: string, - ) { - this.eventdatastring = eventdatastring; - } - } - - export class EventDataBlockSyncStatus { - public complete: bool - public height: u64 - - constructor( - complete: bool, - height: u64, - ) { - this.complete = complete; - this.height = height; - } - } - - export class EventDataStateSyncStatus { - public complete: bool - public height: u64 - - constructor( - complete: bool, - height: u64, - ) { - this.complete = complete; - this.height = height; - } - } - + public key: string; + public value: string; + public index: bool; + + constructor(key: string, value: string, index: bool) { + this.key = key; + this.value = value; + this.index = index; + } + } + + // export class Address { + // public address: Bytes; + + // constructor(address: Bytes) { + // this.address = address; + // } + // } + + export class EventValidatorSetUpdates { + public validator_updates: Array; + + constructor(validator_updates: Array) { + this.validator_updates = validator_updates; + } + } + export class Timestamp { - public seconds: i64 - public nanos: i32 - - constructor( - seconds: i64, - nanos: i32, - ) { - this.seconds = seconds; - this.nanos = nanos; - } - } - + public seconds: i64; + public nanos: i32; + + constructor(seconds: i64, nanos: i32) { + this.seconds = seconds; + this.nanos = nanos; + } + } + export class fig { - - constructor( - ) { - } + constructor() {} + } + + export class EventData { + constructor( + public event: Event, + public block: EventList, + ) {} } - } diff --git a/global/global.ts b/global/global.ts index ddb5885..d63e4c1 100644 --- a/global/global.ts +++ b/global/global.ts @@ -1,8 +1,9 @@ import { BigDecimal } from '../common/numbers' -import { TypedMapEntry, Entity, TypedMap, Result, Wrapped } from '../common/collections' +import { Bytes, TypedMapEntry, Entity, TypedMap, Result, Wrapped } from '../common/collections' import { JSONValue, Value } from '../common/value' import { ethereum } from '../chain/ethereum' import { near } from '../chain/near' +import { tendermint } from '../chain/tendermint' export enum TypeId { String = 0, @@ -92,6 +93,50 @@ export enum TypeId { NearChunkHeader = 84, NearBlock = 85, NearReceiptWithOutcome = 86, + TendermintArrayEventTx = 87, +TendermintArrayEvent = 88, +TendermintArrayValidator = 89, +TendermintArrayCommitSig = 90, +TendermintArrayBytes = 91, +TendermintArrayEvidence = 92, +TendermintArrayEventAttribute = 93, +TendermintBlockIDFlagEnum = 94, +TendermintSignedMsgTypeEnum = 95, +TendermintEventList = 96, +TendermintEventBlock = 97, +TendermintResponseBeginBlock = 98, +TendermintResponseEndBlock = 99, +TendermintConsensusParams = 100, +TendermintVersion = 101, +TendermintBlock = 102, +TendermintCommit = 103, +TendermintCommitSig = 104, +TendermintEventBlockHeader = 105, +TendermintHeader = 106, +TendermintConsensus = 107, +TendermintBlockID = 108, +TendermintPartSetHeader = 109, +TendermintData = 110, +TendermintEvidence = 111, +TendermintDuplicateVoteEvidence = 112, +TendermintEventTx = 113, +TendermintEventVote = 114, +TendermintLightClientAttackEvidence = 115, +TendermintLightBlock = 116, +TendermintValidatorSet = 117, +TendermintSignedHeader = 118, +TendermintEvidenceList = 119, +TendermintValidator = 120, +TendermintPublicKey = 121, +TendermintTxResult = 122, +TendermintResponseDeliverTx = 123, +TendermintEvent = 124, +TendermintEventAttribute = 125, +TendermintAddress = 126, +TendermintEventValidatorSetUpdates = 127, +TendermintTimestamp = 128, +Tendermintfig = 129, +TendermintEventData = 130, } export function id_of_type(typeId: TypeId): usize { @@ -271,6 +316,92 @@ export function id_of_type(typeId: TypeId): usize { return idof() case TypeId.NearReceiptWithOutcome: return idof() + case TypeId.TendermintArrayEventTx: + return idof>() + case TypeId.TendermintArrayEvent: + return idof>() + case TypeId.TendermintArrayValidator: + return idof>() + case TypeId.TendermintArrayCommitSig: + return idof>() + case TypeId.TendermintArrayBytes: + return idof>() + case TypeId.TendermintArrayEvidence: + return idof>() + case TypeId.TendermintArrayEventAttribute: + return idof>() + case TypeId.TendermintBlockIDFlagEnum: + return idof>() + case TypeId.TendermintSignedMsgTypeEnum: + return idof>() + case TypeId.TendermintEventList: + return idof>() + case TypeId.TendermintEventBlock: + return idof>() + case TypeId.TendermintResponseBeginBlock: + return idof() + case TypeId.TendermintResponseEndBlock: + return idof() + case TypeId.TendermintConsensusParams : + return idof() + case TypeId.TendermintVersion : + return idof() + case TypeId.TendermintBlock : + return idof() + case TypeId.TendermintCommit : + return idof() + case TypeId.TendermintCommitSig : + return idof() + case TypeId.TendermintEventBlockHeader : + return idof() + case TypeId.TendermintHeader : + return idof() + case TypeId.TendermintConsensus : + return idof() + case TypeId.TendermintBlockID : + return idof() + case TypeId.TendermintPartSetHeader : + return idof() + case TypeId.TendermintData : + return idof() + case TypeId.TendermintEvidence : + return idof() + case TypeId.TendermintDuplicateVoteEvidence : + return idof() + case TypeId.TendermintEventTx : + return idof() + case TypeId.TendermintEventVote : + return idof() + case TypeId.TendermintLightClientAttackEvidence : + return idof() + case TypeId.TendermintLightBlock : + return idof() + case TypeId.TendermintValidatorSet : + return idof() + case TypeId.TendermintSignedHeader : + return idof() + case TypeId.TendermintEvidenceList : + return idof() + case TypeId.TendermintValidator : + return idof() + case TypeId.TendermintPublicKey : + return idof() + case TypeId.TendermintTxResult : + return idof() + case TypeId.TendermintResponseDeliverTx : + return idof() + case TypeId.TendermintEvent : + return idof() + case TypeId.TendermintEventAttribute: + return idof() + case TypeId.TendermintEventValidatorSetUpdates: + return idof() + case TypeId.TendermintTimestamp: + return idof() + case TypeId.Tendermintfig: + return idof() + case TypeId.TendermintEventData: + return idof() default: return 0 } diff --git a/index.ts b/index.ts index 18df20b..6c96ce0 100644 --- a/index.ts +++ b/index.ts @@ -4,6 +4,8 @@ import './common/eager_offset' export * from './chain/ethereum' // NEAR support export * from './chain/near' +// Tendermint support +export * from './chain/tendermint' // Regular re-exports export * from './common/numbers' export * from './common/collections' diff --git a/test/test.js b/test/test.js index f71151c..94d7b0d 100644 --- a/test/test.js +++ b/test/test.js @@ -28,6 +28,7 @@ fs.copyFileSync('common/conversion.ts', 'test/temp_lib/common/conversion.ts') fs.copyFileSync('common/value.ts', 'test/temp_lib/common/value.ts') fs.copyFileSync('chain/ethereum.ts', 'test/temp_lib/chain/ethereum.ts') fs.copyFileSync('chain/near.ts', 'test/temp_lib/chain/near.ts') +fs.copyFileSync('chain/tendermint.ts', 'test/temp_lib/chain/tendermint.ts') fs.copyFileSync('index.ts', 'test/temp_lib/index.ts') let output_path = 'test/temp_out/test.wasm' @@ -58,6 +59,7 @@ try { fs.rmdirSync('test/temp_lib/common') fs.unlinkSync('test/temp_lib/chain/ethereum.ts') fs.unlinkSync('test/temp_lib/chain/near.ts') + fs.unlinkSync('test/temp_lib/chain/tendermint.ts') fs.rmdirSync('test/temp_lib/chain') fs.rmdirSync('test/temp_lib') fs.unlinkSync('test/temp_out/test.wasm') @@ -76,6 +78,7 @@ try { fs.rmdirSync('test/temp_lib/common') fs.unlinkSync('test/temp_lib/chain/ethereum.ts') fs.unlinkSync('test/temp_lib/chain/near.ts') + fs.unlinkSync('test/temp_lib/chain/tendermint.ts') fs.rmdirSync('test/temp_lib/chain') fs.rmdirSync('test/temp_lib') fs.unlinkSync('test/temp_out/test.wasm') From c4a8cca4c7b5235c97196db59fed909973214e20 Mon Sep 17 00:00:00 2001 From: Patrycja Zawadka Date: Fri, 7 Jan 2022 17:06:00 +0100 Subject: [PATCH 03/12] Apply changes from review --- .gitignore | 3 --- chain/near.ts | 2 ++ chain/tendermint.ts | 8 -------- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 2c99343..ad46b30 100644 --- a/.gitignore +++ b/.gitignore @@ -59,6 +59,3 @@ typings/ # next.js build output .next - -index.wasm -package-lock.json \ No newline at end of file diff --git a/chain/near.ts b/chain/near.ts index fe3f898..ae08232 100644 --- a/chain/near.ts +++ b/chain/near.ts @@ -299,11 +299,13 @@ export namespace near { @operator('<') lt(other: MerklePathItem): boolean { abort("Less than operator isn't supported in MerklePathItem") + return false } @operator('>') gt(other: MerklePathItem): boolean { abort("Greater than operator isn't supported in MerklePathItem") + return false } toString(): string { diff --git a/chain/tendermint.ts b/chain/tendermint.ts index d338a14..0fb767f 100644 --- a/chain/tendermint.ts +++ b/chain/tendermint.ts @@ -505,14 +505,6 @@ export namespace tendermint { } } - // export class Address { - // public address: Bytes; - - // constructor(address: Bytes) { - // this.address = address; - // } - // } - export class EventValidatorSetUpdates { public validator_updates: Array; From 2fc21ba64e52332df6f03db071dfaf6f47f2cb78 Mon Sep 17 00:00:00 2001 From: Patrycja Zawadka Date: Mon, 10 Jan 2022 15:38:11 +0100 Subject: [PATCH 04/12] Fix formatting --- chain/tendermint.ts | 1065 ++++++++++++++++++++++--------------------- global/global.ts | 86 ++-- 2 files changed, 576 insertions(+), 575 deletions(-) diff --git a/chain/tendermint.ts b/chain/tendermint.ts index 0fb767f..340d7a9 100644 --- a/chain/tendermint.ts +++ b/chain/tendermint.ts @@ -1,536 +1,537 @@ import '../common/eager_offset' import { Bytes } from "../common/collections" -import { Address, BigInt } from '../common/numbers' +import { Address } from '../common/numbers' + export namespace tendermint { - export type Hash = Bytes; - - export enum SignedMsgType { - SIGNED_MSG_TYPE_UNKNOWN = 0, - SIGNED_MSG_TYPE_PREVOTE = 1, - SIGNED_MSG_TYPE_PRECOMMIT = 2, - SIGNED_MSG_TYPE_PROPOSAL = 3, - } - - export enum BlockIDFlag { - BLOCK_ID_FLAG_UNKNOWN = 0, - BLOCK_ID_FLAG_ABSENT = 1, - BLOCK_ID_FLAG_COMMIT = 2, - BLOCK_ID_FLAG_NIL = 3, - } - - export class EventList { - public newblock: EventBlock; - public transaction: Array; - public validatorsetupdates: EventValidatorSetUpdates; - - constructor( - newblock: EventBlock, - transaction: Array, - validatorsetupdates: EventValidatorSetUpdates - ) { - this.newblock = newblock; - this.transaction = transaction; - this.validatorsetupdates = validatorsetupdates; - } - } - - export class EventBlock { - public block: Block; - public block_id: BlockID; - public result_begin_block: ResponseBeginBlock; - public result_end_block: ResponseEndBlock; - - constructor( - block: Block, - block_id: BlockID, - result_begin_block: ResponseBeginBlock, - result_end_block: ResponseEndBlock - ) { - this.block = block; - this.block_id = block_id; - this.result_begin_block = result_begin_block; - this.result_end_block = result_end_block; - } - } - - export class ResponseBeginBlock { - public events: Array; - - constructor(events: Array) { - this.events = events; - } - } - - export class ResponseEndBlock { - public validator_updates: Array; - public consensus_param_updates: ConsensusParams; - public events: Array; - - constructor( - validator_updates: Array, - consensus_param_updates: ConsensusParams, - events: Array - ) { - this.validator_updates = validator_updates; - this.consensus_param_updates = consensus_param_updates; - this.events = events; - } - } - - export class ConsensusParams { - public block: Block; - public evidence: Evidence; - public validator: Validator; - public version: Version; - - constructor( - block: Block, - evidence: Evidence, - validator: Validator, - version: Version - ) { - this.block = block; - this.evidence = evidence; - this.validator = validator; - this.version = version; - } - } - - export class Version { - public app_version: u64; - - constructor(app_version: u64) { - this.app_version = app_version; - } - } - - export class Block { - public header: Header; - public data: Data; - public evidence: EvidenceList; - public last_commit: Commit; - - constructor( - header: Header, - data: Data, - evidence: EvidenceList, - last_commit: Commit - ) { - this.header = header; - this.data = data; - this.evidence = evidence; - this.last_commit = last_commit; - } - } - - export class Commit { - public height: u64; - public round: i32; - public block_id: BlockID; - public signatures: Array; - - constructor( - height: u64, - round: i32, - block_id: BlockID, - signatures: Array - ) { - this.height = height; - this.round = round; - this.block_id = block_id; - this.signatures = signatures; - } - } - - export class CommitSig { - public block_id_flag: BlockIDFlag; - public validator_address: Address; - public timestamp: Timestamp; - public signature: Bytes; - - constructor( - block_id_flag: BlockIDFlag, - validator_address: Address, - timestamp: Timestamp, - signature: Bytes - ) { - this.block_id_flag = block_id_flag; - this.validator_address = validator_address; - this.timestamp = timestamp; - this.signature = signature; - } - } - - export class EventBlockHeader { - public header: Header; - public num_txs: i64; - public result_begin_block: ResponseBeginBlock; - public result_end_block: ResponseEndBlock; - - constructor( - header: Header, - num_txs: i64, - result_begin_block: ResponseBeginBlock, - result_end_block: ResponseEndBlock - ) { - this.header = header; - this.num_txs = num_txs; - this.result_begin_block = result_begin_block; - this.result_end_block = result_end_block; - } - } - - export class Header { - public version: Consensus; - public chain_id: string; - public height: u64; - public time: Timestamp; - public last_block_id: BlockID; - public last_commit_hash: Hash; - public data_hash: Hash; - public validators_hash: Hash; - public next_validators_hash: Hash; - public consensus_hash: Hash; - public app_hash: Hash; - public last_results_hash: Hash; - public evidence_hash: Hash; - public proposer_address: Address; - - constructor( - version: Consensus, - chain_id: string, - height: u64, - time: Timestamp, - last_block_id: BlockID, - last_commit_hash: Hash, - data_hash: Hash, - validators_hash: Hash, - next_validators_hash: Hash, - consensus_hash: Hash, - app_hash: Hash, - last_results_hash: Hash, - evidence_hash: Hash, - proposer_address: Address - ) { - this.version = version; - this.chain_id = chain_id; - this.height = height; - this.time = time; - this.last_block_id = last_block_id; - this.last_commit_hash = last_commit_hash; - this.data_hash = data_hash; - this.validators_hash = validators_hash; - this.next_validators_hash = next_validators_hash; - this.consensus_hash = consensus_hash; - this.app_hash = app_hash; - this.last_results_hash = last_results_hash; - this.evidence_hash = evidence_hash; - this.proposer_address = proposer_address; - } - } - - export class Consensus { - public block: u64; - public app: u64; - - constructor(block: u64, app: u64) { - this.block = block; - this.app = app; - } - } - - export class BlockID { - public hash: Hash; - public part_set_header: PartSetHeader; - - constructor(hash: Hash, part_set_header: PartSetHeader) { - this.hash = hash; - this.part_set_header = part_set_header; - } - } - - export class PartSetHeader { - public total: u32; - public hash: Hash; - - constructor(total: u32, hash: Hash) { - this.total = total; - this.hash = hash; - } - } - - export class Data { - public txs: Array; - - constructor(txs: Array) { - this.txs = txs; - } - } - - export class Evidence { - public duplicate_vote_evidence: DuplicateVoteEvidence; - public light_client_attack_evidence: LightClientAttackEvidence; - - constructor( - duplicate_vote_evidence: DuplicateVoteEvidence, - light_client_attack_evidence: LightClientAttackEvidence - ) { - this.duplicate_vote_evidence = duplicate_vote_evidence; - this.light_client_attack_evidence = light_client_attack_evidence; - } - } - - export class DuplicateVoteEvidence { - public vote_a: EventVote; - public vote_b: EventVote; - public total_voting_power: i64; - public validator_power: i64; - public timestamp: Timestamp; - - constructor( - vote_a: EventVote, - vote_b: EventVote, - total_voting_power: i64, - validator_power: i64, - timestamp: Timestamp - ) { - this.vote_a = vote_a; - this.vote_b = vote_b; - this.total_voting_power = total_voting_power; - this.validator_power = validator_power; - this.timestamp = timestamp; - } - } - - export class EventTx { - public TxResult: TxResult; - - constructor(TxResult: TxResult) { - this.TxResult = TxResult; - } - } - - export class EventVote { - public eventvotetype: SignedMsgType; - public height: u64; - public round: i32; - public block_id: BlockID; - public timestamp: Timestamp; - public validator_address: Address; - public validator_index: i32; - public signature: Bytes; - - constructor( - eventvotetype: SignedMsgType, - height: u64, - round: i32, - block_id: BlockID, - timestamp: Timestamp, - validator_address: Address, - validator_index: i32, - signature: Bytes - ) { - this.eventvotetype = eventvotetype; - this.height = height; - this.round = round; - this.block_id = block_id; - this.timestamp = timestamp; - this.validator_address = validator_address; - this.validator_index = validator_index; - this.signature = signature; - } - } - - export class LightClientAttackEvidence { - public conflicting_block: LightBlock; - public common_height: i64; - public byzantine_validators: Array; - public total_voting_power: i64; - public timestamp: Timestamp; - - constructor( - conflicting_block: LightBlock, - common_height: i64, - byzantine_validators: Array, - total_voting_power: i64, - timestamp: Timestamp - ) { - this.conflicting_block = conflicting_block; - this.common_height = common_height; - this.byzantine_validators = byzantine_validators; - this.total_voting_power = total_voting_power; - this.timestamp = timestamp; - } - } - - export class LightBlock { - public signed_header: SignedHeader; - public validator_set: ValidatorSet; - - constructor(signed_header: SignedHeader, validator_set: ValidatorSet) { - this.signed_header = signed_header; - this.validator_set = validator_set; - } - } - - export class ValidatorSet { - public validators: Array; - public proposer: Validator; - public total_voting_power: i64; - - constructor( - validators: Array, - proposer: Validator, - total_voting_power: i64 - ) { - this.validators = validators; - this.proposer = proposer; - this.total_voting_power = total_voting_power; - } - } - - export class SignedHeader { - public header: Header; - public commit: Commit; - - constructor(header: Header, commit: Commit) { - this.header = header; - this.commit = commit; - } - } - - export class EvidenceList { - public evidence: Array; - - constructor(evidence: Array) { - this.evidence = evidence; - } - } - - export class Validator { - public address: Bytes; - public pub_key: PublicKey; - public voting_power: i64; - public proposer_priority: i64; - - constructor( - address: Bytes, - pub_key: PublicKey, - voting_power: i64, - proposer_priority: i64 - ) { - this.address = address; - this.pub_key = pub_key; - this.voting_power = voting_power; - this.proposer_priority = proposer_priority; - } - } - - export class PublicKey { - public ed25519: Bytes; - public secp256k1: Bytes; - public sr25519: Bytes; - - constructor(ed25519: Bytes, secp256k1: Bytes, sr25519: Bytes) { - this.ed25519 = ed25519; - this.secp256k1 = secp256k1; - this.sr25519 = sr25519; - } - } - - export class TxResult { - public height: u64; - public index: u32; - public tx: Bytes; - public result: ResponseDeliverTx; - - constructor(height: u64, index: u32, tx: Bytes, result: ResponseDeliverTx) { - this.height = height; - this.index = index; - this.tx = tx; - this.result = result; - } - } - - export class ResponseDeliverTx { - public code: u32; - public data: Bytes; - public log: string; - public info: string; - public gas_wanted: i64; - public gas_used: i64; - public events: Array; - public codespace: string; - - constructor( - code: u32, - data: Bytes, - log: string, - info: string, - gas_wanted: i64, - gas_used: i64, - events: Array, - codespace: string - ) { - this.code = code; - this.data = data; - this.log = log; - this.info = info; - this.gas_wanted = gas_wanted; - this.gas_used = gas_used; - this.events = events; - this.codespace = codespace; - } - } - - export class Event { - public eventtype: string; - public attributes: Array; - - constructor(eventtype: string, attributes: Array) { - this.eventtype = eventtype; - this.attributes = attributes; - } - } - - export class EventAttribute { - public key: string; - public value: string; - public index: bool; - - constructor(key: string, value: string, index: bool) { - this.key = key; - this.value = value; - this.index = index; - } - } - - export class EventValidatorSetUpdates { - public validator_updates: Array; - - constructor(validator_updates: Array) { - this.validator_updates = validator_updates; - } - } - - export class Timestamp { - public seconds: i64; - public nanos: i32; - - constructor(seconds: i64, nanos: i32) { - this.seconds = seconds; - this.nanos = nanos; - } - } - - export class fig { - constructor() {} - } - - export class EventData { - constructor( - public event: Event, - public block: EventList, - ) {} - } + export type Hash = Bytes; + + export enum SignedMsgType { + SIGNED_MSG_TYPE_UNKNOWN = 0, + SIGNED_MSG_TYPE_PREVOTE = 1, + SIGNED_MSG_TYPE_PRECOMMIT = 2, + SIGNED_MSG_TYPE_PROPOSAL = 3, + } + + export enum BlockIDFlag { + BLOCK_ID_FLAG_UNKNOWN = 0, + BLOCK_ID_FLAG_ABSENT = 1, + BLOCK_ID_FLAG_COMMIT = 2, + BLOCK_ID_FLAG_NIL = 3, + } + + export class EventList { + public newblock: EventBlock; + public transaction: Array; + public validatorsetupdates: EventValidatorSetUpdates; + + constructor( + newblock: EventBlock, + transaction: Array, + validatorsetupdates: EventValidatorSetUpdates + ) { + this.newblock = newblock; + this.transaction = transaction; + this.validatorsetupdates = validatorsetupdates; + } + } + + export class EventBlock { + public block: Block; + public block_id: BlockID; + public result_begin_block: ResponseBeginBlock; + public result_end_block: ResponseEndBlock; + + constructor( + block: Block, + block_id: BlockID, + result_begin_block: ResponseBeginBlock, + result_end_block: ResponseEndBlock + ) { + this.block = block; + this.block_id = block_id; + this.result_begin_block = result_begin_block; + this.result_end_block = result_end_block; + } + } + + export class ResponseBeginBlock { + public events: Array; + + constructor(events: Array) { + this.events = events; + } + } + + export class ResponseEndBlock { + public validator_updates: Array; + public consensus_param_updates: ConsensusParams; + public events: Array; + + constructor( + validator_updates: Array, + consensus_param_updates: ConsensusParams, + events: Array + ) { + this.validator_updates = validator_updates; + this.consensus_param_updates = consensus_param_updates; + this.events = events; + } + } + + export class ConsensusParams { + public block: Block; + public evidence: Evidence; + public validator: Validator; + public version: Version; + + constructor( + block: Block, + evidence: Evidence, + validator: Validator, + version: Version + ) { + this.block = block; + this.evidence = evidence; + this.validator = validator; + this.version = version; + } + } + + export class Version { + public app_version: u64; + + constructor(app_version: u64) { + this.app_version = app_version; + } + } + + export class Block { + public header: Header; + public data: Data; + public evidence: EvidenceList; + public last_commit: Commit; + + constructor( + header: Header, + data: Data, + evidence: EvidenceList, + last_commit: Commit + ) { + this.header = header; + this.data = data; + this.evidence = evidence; + this.last_commit = last_commit; + } + } + + export class Commit { + public height: u64; + public round: i32; + public block_id: BlockID; + public signatures: Array; + + constructor( + height: u64, + round: i32, + block_id: BlockID, + signatures: Array + ) { + this.height = height; + this.round = round; + this.block_id = block_id; + this.signatures = signatures; + } + } + + export class CommitSig { + public block_id_flag: BlockIDFlag; + public validator_address: Address; + public timestamp: Timestamp; + public signature: Bytes; + + constructor( + block_id_flag: BlockIDFlag, + validator_address: Address, + timestamp: Timestamp, + signature: Bytes + ) { + this.block_id_flag = block_id_flag; + this.validator_address = validator_address; + this.timestamp = timestamp; + this.signature = signature; + } + } + + export class EventBlockHeader { + public header: Header; + public num_txs: i64; + public result_begin_block: ResponseBeginBlock; + public result_end_block: ResponseEndBlock; + + constructor( + header: Header, + num_txs: i64, + result_begin_block: ResponseBeginBlock, + result_end_block: ResponseEndBlock + ) { + this.header = header; + this.num_txs = num_txs; + this.result_begin_block = result_begin_block; + this.result_end_block = result_end_block; + } + } + + export class Header { + public version: Consensus; + public chain_id: string; + public height: u64; + public time: Timestamp; + public last_block_id: BlockID; + public last_commit_hash: Hash; + public data_hash: Hash; + public validators_hash: Hash; + public next_validators_hash: Hash; + public consensus_hash: Hash; + public app_hash: Hash; + public last_results_hash: Hash; + public evidence_hash: Hash; + public proposer_address: Address; + + constructor( + version: Consensus, + chain_id: string, + height: u64, + time: Timestamp, + last_block_id: BlockID, + last_commit_hash: Hash, + data_hash: Hash, + validators_hash: Hash, + next_validators_hash: Hash, + consensus_hash: Hash, + app_hash: Hash, + last_results_hash: Hash, + evidence_hash: Hash, + proposer_address: Address + ) { + this.version = version; + this.chain_id = chain_id; + this.height = height; + this.time = time; + this.last_block_id = last_block_id; + this.last_commit_hash = last_commit_hash; + this.data_hash = data_hash; + this.validators_hash = validators_hash; + this.next_validators_hash = next_validators_hash; + this.consensus_hash = consensus_hash; + this.app_hash = app_hash; + this.last_results_hash = last_results_hash; + this.evidence_hash = evidence_hash; + this.proposer_address = proposer_address; + } + } + + export class Consensus { + public block: u64; + public app: u64; + + constructor(block: u64, app: u64) { + this.block = block; + this.app = app; + } + } + + export class BlockID { + public hash: Hash; + public part_set_header: PartSetHeader; + + constructor(hash: Hash, part_set_header: PartSetHeader) { + this.hash = hash; + this.part_set_header = part_set_header; + } + } + + export class PartSetHeader { + public total: u32; + public hash: Hash; + + constructor(total: u32, hash: Hash) { + this.total = total; + this.hash = hash; + } + } + + export class Data { + public txs: Array; + + constructor(txs: Array) { + this.txs = txs; + } + } + + export class Evidence { + public duplicate_vote_evidence: DuplicateVoteEvidence; + public light_client_attack_evidence: LightClientAttackEvidence; + + constructor( + duplicate_vote_evidence: DuplicateVoteEvidence, + light_client_attack_evidence: LightClientAttackEvidence + ) { + this.duplicate_vote_evidence = duplicate_vote_evidence; + this.light_client_attack_evidence = light_client_attack_evidence; + } + } + + export class DuplicateVoteEvidence { + public vote_a: EventVote; + public vote_b: EventVote; + public total_voting_power: i64; + public validator_power: i64; + public timestamp: Timestamp; + + constructor( + vote_a: EventVote, + vote_b: EventVote, + total_voting_power: i64, + validator_power: i64, + timestamp: Timestamp + ) { + this.vote_a = vote_a; + this.vote_b = vote_b; + this.total_voting_power = total_voting_power; + this.validator_power = validator_power; + this.timestamp = timestamp; + } + } + + export class EventTx { + public TxResult: TxResult; + + constructor(TxResult: TxResult) { + this.TxResult = TxResult; + } + } + + export class EventVote { + public eventvotetype: SignedMsgType; + public height: u64; + public round: i32; + public block_id: BlockID; + public timestamp: Timestamp; + public validator_address: Address; + public validator_index: i32; + public signature: Bytes; + + constructor( + eventvotetype: SignedMsgType, + height: u64, + round: i32, + block_id: BlockID, + timestamp: Timestamp, + validator_address: Address, + validator_index: i32, + signature: Bytes + ) { + this.eventvotetype = eventvotetype; + this.height = height; + this.round = round; + this.block_id = block_id; + this.timestamp = timestamp; + this.validator_address = validator_address; + this.validator_index = validator_index; + this.signature = signature; + } + } + + export class LightClientAttackEvidence { + public conflicting_block: LightBlock; + public common_height: i64; + public byzantine_validators: Array; + public total_voting_power: i64; + public timestamp: Timestamp; + + constructor( + conflicting_block: LightBlock, + common_height: i64, + byzantine_validators: Array, + total_voting_power: i64, + timestamp: Timestamp + ) { + this.conflicting_block = conflicting_block; + this.common_height = common_height; + this.byzantine_validators = byzantine_validators; + this.total_voting_power = total_voting_power; + this.timestamp = timestamp; + } + } + + export class LightBlock { + public signed_header: SignedHeader; + public validator_set: ValidatorSet; + + constructor(signed_header: SignedHeader, validator_set: ValidatorSet) { + this.signed_header = signed_header; + this.validator_set = validator_set; + } + } + + export class ValidatorSet { + public validators: Array; + public proposer: Validator; + public total_voting_power: i64; + + constructor( + validators: Array, + proposer: Validator, + total_voting_power: i64 + ) { + this.validators = validators; + this.proposer = proposer; + this.total_voting_power = total_voting_power; + } + } + + export class SignedHeader { + public header: Header; + public commit: Commit; + + constructor(header: Header, commit: Commit) { + this.header = header; + this.commit = commit; + } + } + + export class EvidenceList { + public evidence: Array; + + constructor(evidence: Array) { + this.evidence = evidence; + } + } + + export class Validator { + public address: Bytes; + public pub_key: PublicKey; + public voting_power: i64; + public proposer_priority: i64; + + constructor( + address: Bytes, + pub_key: PublicKey, + voting_power: i64, + proposer_priority: i64 + ) { + this.address = address; + this.pub_key = pub_key; + this.voting_power = voting_power; + this.proposer_priority = proposer_priority; + } + } + + export class PublicKey { + public ed25519: Bytes; + public secp256k1: Bytes; + public sr25519: Bytes; + + constructor(ed25519: Bytes, secp256k1: Bytes, sr25519: Bytes) { + this.ed25519 = ed25519; + this.secp256k1 = secp256k1; + this.sr25519 = sr25519; + } + } + + export class TxResult { + public height: u64; + public index: u32; + public tx: Bytes; + public result: ResponseDeliverTx; + + constructor(height: u64, index: u32, tx: Bytes, result: ResponseDeliverTx) { + this.height = height; + this.index = index; + this.tx = tx; + this.result = result; + } + } + + export class ResponseDeliverTx { + public code: u32; + public data: Bytes; + public log: string; + public info: string; + public gas_wanted: i64; + public gas_used: i64; + public events: Array; + public codespace: string; + + constructor( + code: u32, + data: Bytes, + log: string, + info: string, + gas_wanted: i64, + gas_used: i64, + events: Array, + codespace: string + ) { + this.code = code; + this.data = data; + this.log = log; + this.info = info; + this.gas_wanted = gas_wanted; + this.gas_used = gas_used; + this.events = events; + this.codespace = codespace; + } + } + + export class Event { + public eventtype: string; + public attributes: Array; + + constructor(eventtype: string, attributes: Array) { + this.eventtype = eventtype; + this.attributes = attributes; + } + } + + export class EventAttribute { + public key: string; + public value: string; + public index: bool; + + constructor(key: string, value: string, index: bool) { + this.key = key; + this.value = value; + this.index = index; + } + } + + export class EventValidatorSetUpdates { + public validator_updates: Array; + + constructor(validator_updates: Array) { + this.validator_updates = validator_updates; + } + } + + export class Timestamp { + public seconds: i64; + public nanos: i32; + + constructor(seconds: i64, nanos: i32) { + this.seconds = seconds; + this.nanos = nanos; + } + } + + export class fig { + constructor() {} + } + + export class EventData { + constructor( + public event: Event, + public block: EventList, + ) {} + } } diff --git a/global/global.ts b/global/global.ts index 260af78..4c47cb3 100644 --- a/global/global.ts +++ b/global/global.ts @@ -94,49 +94,49 @@ export enum TypeId { NearBlock = 85, NearReceiptWithOutcome = 86, TendermintArrayEventTx = 87, -TendermintArrayEvent = 88, -TendermintArrayValidator = 89, -TendermintArrayCommitSig = 90, -TendermintArrayBytes = 91, -TendermintArrayEvidence = 92, -TendermintArrayEventAttribute = 93, -TendermintBlockIDFlagEnum = 94, -TendermintSignedMsgTypeEnum = 95, -TendermintEventList = 96, -TendermintEventBlock = 97, -TendermintResponseBeginBlock = 98, -TendermintResponseEndBlock = 99, -TendermintConsensusParams = 100, -TendermintVersion = 101, -TendermintBlock = 102, -TendermintCommit = 103, -TendermintCommitSig = 104, -TendermintEventBlockHeader = 105, -TendermintHeader = 106, -TendermintConsensus = 107, -TendermintBlockID = 108, -TendermintPartSetHeader = 109, -TendermintData = 110, -TendermintEvidence = 111, -TendermintDuplicateVoteEvidence = 112, -TendermintEventTx = 113, -TendermintEventVote = 114, -TendermintLightClientAttackEvidence = 115, -TendermintLightBlock = 116, -TendermintValidatorSet = 117, -TendermintSignedHeader = 118, -TendermintEvidenceList = 119, -TendermintValidator = 120, -TendermintPublicKey = 121, -TendermintTxResult = 122, -TendermintResponseDeliverTx = 123, -TendermintEvent = 124, -TendermintEventAttribute = 125, -TendermintAddress = 126, -TendermintEventValidatorSetUpdates = 127, -TendermintTimestamp = 128, -Tendermintfig = 129, -TendermintEventData = 130, + TendermintArrayEvent = 88, + TendermintArrayValidator = 89, + TendermintArrayCommitSig = 90, + TendermintArrayBytes = 91, + TendermintArrayEvidence = 92, + TendermintArrayEventAttribute = 93, + TendermintBlockIDFlagEnum = 94, + TendermintSignedMsgTypeEnum = 95, + TendermintEventList = 96, + TendermintEventBlock = 97, + TendermintResponseBeginBlock = 98, + TendermintResponseEndBlock = 99, + TendermintConsensusParams = 100, + TendermintVersion = 101, + TendermintBlock = 102, + TendermintCommit = 103, + TendermintCommitSig = 104, + TendermintEventBlockHeader = 105, + TendermintHeader = 106, + TendermintConsensus = 107, + TendermintBlockID = 108, + TendermintPartSetHeader = 109, + TendermintData = 110, + TendermintEvidence = 111, + TendermintDuplicateVoteEvidence = 112, + TendermintEventTx = 113, + TendermintEventVote = 114, + TendermintLightClientAttackEvidence = 115, + TendermintLightBlock = 116, + TendermintValidatorSet = 117, + TendermintSignedHeader = 118, + TendermintEvidenceList = 119, + TendermintValidator = 120, + TendermintPublicKey = 121, + TendermintTxResult = 122, + TendermintResponseDeliverTx = 123, + TendermintEvent = 124, + TendermintEventAttribute = 125, + TendermintAddress = 126, + TendermintEventValidatorSetUpdates = 127, + TendermintTimestamp = 128, + Tendermintfig = 129, + TendermintEventData = 130, } export function id_of_type(typeId: TypeId): usize { From add7bcd107392d4230c6044bf4baa5ff98183572 Mon Sep 17 00:00:00 2001 From: Patrycja Zawadka Date: Fri, 14 Jan 2022 18:12:26 +0100 Subject: [PATCH 05/12] Update Tendermint typescript definitions --- chain/tendermint.ts | 1174 +++++++++++++++++++++++-------------------- global/global.ts | 69 ++- 2 files changed, 675 insertions(+), 568 deletions(-) diff --git a/chain/tendermint.ts b/chain/tendermint.ts index 340d7a9..f67db28 100644 --- a/chain/tendermint.ts +++ b/chain/tendermint.ts @@ -1,537 +1,647 @@ import '../common/eager_offset' import { Bytes } from "../common/collections" -import { Address } from '../common/numbers' export namespace tendermint { - export type Hash = Bytes; - - export enum SignedMsgType { - SIGNED_MSG_TYPE_UNKNOWN = 0, - SIGNED_MSG_TYPE_PREVOTE = 1, - SIGNED_MSG_TYPE_PRECOMMIT = 2, - SIGNED_MSG_TYPE_PROPOSAL = 3, - } - - export enum BlockIDFlag { - BLOCK_ID_FLAG_UNKNOWN = 0, - BLOCK_ID_FLAG_ABSENT = 1, - BLOCK_ID_FLAG_COMMIT = 2, - BLOCK_ID_FLAG_NIL = 3, - } - - export class EventList { - public newblock: EventBlock; - public transaction: Array; - public validatorsetupdates: EventValidatorSetUpdates; - - constructor( - newblock: EventBlock, - transaction: Array, - validatorsetupdates: EventValidatorSetUpdates - ) { - this.newblock = newblock; - this.transaction = transaction; - this.validatorsetupdates = validatorsetupdates; - } - } - - export class EventBlock { - public block: Block; - public block_id: BlockID; - public result_begin_block: ResponseBeginBlock; - public result_end_block: ResponseEndBlock; - - constructor( - block: Block, - block_id: BlockID, - result_begin_block: ResponseBeginBlock, - result_end_block: ResponseEndBlock - ) { - this.block = block; - this.block_id = block_id; - this.result_begin_block = result_begin_block; - this.result_end_block = result_end_block; - } - } - - export class ResponseBeginBlock { - public events: Array; - - constructor(events: Array) { - this.events = events; - } - } - - export class ResponseEndBlock { - public validator_updates: Array; - public consensus_param_updates: ConsensusParams; - public events: Array; - - constructor( - validator_updates: Array, - consensus_param_updates: ConsensusParams, - events: Array - ) { - this.validator_updates = validator_updates; - this.consensus_param_updates = consensus_param_updates; - this.events = events; - } - } - - export class ConsensusParams { - public block: Block; - public evidence: Evidence; - public validator: Validator; - public version: Version; - - constructor( - block: Block, - evidence: Evidence, - validator: Validator, - version: Version - ) { - this.block = block; - this.evidence = evidence; - this.validator = validator; - this.version = version; - } - } - - export class Version { - public app_version: u64; - - constructor(app_version: u64) { - this.app_version = app_version; - } - } - - export class Block { - public header: Header; - public data: Data; - public evidence: EvidenceList; - public last_commit: Commit; - - constructor( - header: Header, - data: Data, - evidence: EvidenceList, - last_commit: Commit - ) { - this.header = header; - this.data = data; - this.evidence = evidence; - this.last_commit = last_commit; - } - } - - export class Commit { - public height: u64; - public round: i32; - public block_id: BlockID; - public signatures: Array; - - constructor( - height: u64, - round: i32, - block_id: BlockID, - signatures: Array - ) { - this.height = height; - this.round = round; - this.block_id = block_id; - this.signatures = signatures; - } - } - - export class CommitSig { - public block_id_flag: BlockIDFlag; - public validator_address: Address; - public timestamp: Timestamp; - public signature: Bytes; - - constructor( - block_id_flag: BlockIDFlag, - validator_address: Address, - timestamp: Timestamp, - signature: Bytes - ) { - this.block_id_flag = block_id_flag; - this.validator_address = validator_address; - this.timestamp = timestamp; - this.signature = signature; - } - } - - export class EventBlockHeader { - public header: Header; - public num_txs: i64; - public result_begin_block: ResponseBeginBlock; - public result_end_block: ResponseEndBlock; - - constructor( - header: Header, - num_txs: i64, - result_begin_block: ResponseBeginBlock, - result_end_block: ResponseEndBlock - ) { - this.header = header; - this.num_txs = num_txs; - this.result_begin_block = result_begin_block; - this.result_end_block = result_end_block; - } - } - - export class Header { - public version: Consensus; - public chain_id: string; - public height: u64; - public time: Timestamp; - public last_block_id: BlockID; - public last_commit_hash: Hash; - public data_hash: Hash; - public validators_hash: Hash; - public next_validators_hash: Hash; - public consensus_hash: Hash; - public app_hash: Hash; - public last_results_hash: Hash; - public evidence_hash: Hash; - public proposer_address: Address; - - constructor( - version: Consensus, - chain_id: string, - height: u64, - time: Timestamp, - last_block_id: BlockID, - last_commit_hash: Hash, - data_hash: Hash, - validators_hash: Hash, - next_validators_hash: Hash, - consensus_hash: Hash, - app_hash: Hash, - last_results_hash: Hash, - evidence_hash: Hash, - proposer_address: Address - ) { - this.version = version; - this.chain_id = chain_id; - this.height = height; - this.time = time; - this.last_block_id = last_block_id; - this.last_commit_hash = last_commit_hash; - this.data_hash = data_hash; - this.validators_hash = validators_hash; - this.next_validators_hash = next_validators_hash; - this.consensus_hash = consensus_hash; - this.app_hash = app_hash; - this.last_results_hash = last_results_hash; - this.evidence_hash = evidence_hash; - this.proposer_address = proposer_address; - } - } - - export class Consensus { - public block: u64; - public app: u64; - - constructor(block: u64, app: u64) { - this.block = block; - this.app = app; - } - } - - export class BlockID { - public hash: Hash; - public part_set_header: PartSetHeader; - - constructor(hash: Hash, part_set_header: PartSetHeader) { - this.hash = hash; - this.part_set_header = part_set_header; - } - } - - export class PartSetHeader { - public total: u32; - public hash: Hash; - - constructor(total: u32, hash: Hash) { - this.total = total; - this.hash = hash; - } - } - - export class Data { - public txs: Array; - - constructor(txs: Array) { - this.txs = txs; - } - } - - export class Evidence { - public duplicate_vote_evidence: DuplicateVoteEvidence; - public light_client_attack_evidence: LightClientAttackEvidence; - - constructor( - duplicate_vote_evidence: DuplicateVoteEvidence, - light_client_attack_evidence: LightClientAttackEvidence - ) { - this.duplicate_vote_evidence = duplicate_vote_evidence; - this.light_client_attack_evidence = light_client_attack_evidence; - } - } - - export class DuplicateVoteEvidence { - public vote_a: EventVote; - public vote_b: EventVote; - public total_voting_power: i64; - public validator_power: i64; - public timestamp: Timestamp; - - constructor( - vote_a: EventVote, - vote_b: EventVote, - total_voting_power: i64, - validator_power: i64, - timestamp: Timestamp - ) { - this.vote_a = vote_a; - this.vote_b = vote_b; - this.total_voting_power = total_voting_power; - this.validator_power = validator_power; - this.timestamp = timestamp; - } - } - - export class EventTx { - public TxResult: TxResult; - - constructor(TxResult: TxResult) { - this.TxResult = TxResult; - } - } - - export class EventVote { - public eventvotetype: SignedMsgType; - public height: u64; - public round: i32; - public block_id: BlockID; - public timestamp: Timestamp; - public validator_address: Address; - public validator_index: i32; - public signature: Bytes; - - constructor( - eventvotetype: SignedMsgType, - height: u64, - round: i32, - block_id: BlockID, - timestamp: Timestamp, - validator_address: Address, - validator_index: i32, - signature: Bytes - ) { - this.eventvotetype = eventvotetype; - this.height = height; - this.round = round; - this.block_id = block_id; - this.timestamp = timestamp; - this.validator_address = validator_address; - this.validator_index = validator_index; - this.signature = signature; - } - } - - export class LightClientAttackEvidence { - public conflicting_block: LightBlock; - public common_height: i64; - public byzantine_validators: Array; - public total_voting_power: i64; - public timestamp: Timestamp; - - constructor( - conflicting_block: LightBlock, - common_height: i64, - byzantine_validators: Array, - total_voting_power: i64, - timestamp: Timestamp - ) { - this.conflicting_block = conflicting_block; - this.common_height = common_height; - this.byzantine_validators = byzantine_validators; - this.total_voting_power = total_voting_power; - this.timestamp = timestamp; - } - } - - export class LightBlock { - public signed_header: SignedHeader; - public validator_set: ValidatorSet; - - constructor(signed_header: SignedHeader, validator_set: ValidatorSet) { - this.signed_header = signed_header; - this.validator_set = validator_set; - } - } - - export class ValidatorSet { - public validators: Array; - public proposer: Validator; - public total_voting_power: i64; - - constructor( - validators: Array, - proposer: Validator, - total_voting_power: i64 - ) { - this.validators = validators; - this.proposer = proposer; - this.total_voting_power = total_voting_power; - } - } - - export class SignedHeader { - public header: Header; - public commit: Commit; - - constructor(header: Header, commit: Commit) { - this.header = header; - this.commit = commit; - } - } - - export class EvidenceList { - public evidence: Array; - - constructor(evidence: Array) { - this.evidence = evidence; - } - } - - export class Validator { - public address: Bytes; - public pub_key: PublicKey; - public voting_power: i64; - public proposer_priority: i64; - - constructor( - address: Bytes, - pub_key: PublicKey, - voting_power: i64, - proposer_priority: i64 - ) { - this.address = address; - this.pub_key = pub_key; - this.voting_power = voting_power; - this.proposer_priority = proposer_priority; - } - } - - export class PublicKey { - public ed25519: Bytes; - public secp256k1: Bytes; - public sr25519: Bytes; - - constructor(ed25519: Bytes, secp256k1: Bytes, sr25519: Bytes) { - this.ed25519 = ed25519; - this.secp256k1 = secp256k1; - this.sr25519 = sr25519; - } - } - - export class TxResult { - public height: u64; - public index: u32; - public tx: Bytes; - public result: ResponseDeliverTx; - - constructor(height: u64, index: u32, tx: Bytes, result: ResponseDeliverTx) { - this.height = height; - this.index = index; - this.tx = tx; - this.result = result; - } - } - - export class ResponseDeliverTx { - public code: u32; - public data: Bytes; - public log: string; - public info: string; - public gas_wanted: i64; - public gas_used: i64; - public events: Array; - public codespace: string; - - constructor( - code: u32, - data: Bytes, - log: string, - info: string, - gas_wanted: i64, - gas_used: i64, - events: Array, - codespace: string - ) { - this.code = code; - this.data = data; - this.log = log; - this.info = info; - this.gas_wanted = gas_wanted; - this.gas_used = gas_used; - this.events = events; - this.codespace = codespace; - } - } - - export class Event { - public eventtype: string; - public attributes: Array; - - constructor(eventtype: string, attributes: Array) { - this.eventtype = eventtype; - this.attributes = attributes; - } - } - - export class EventAttribute { - public key: string; - public value: string; - public index: bool; - - constructor(key: string, value: string, index: bool) { - this.key = key; - this.value = value; - this.index = index; - } - } - - export class EventValidatorSetUpdates { - public validator_updates: Array; - - constructor(validator_updates: Array) { - this.validator_updates = validator_updates; - } - } - - export class Timestamp { - public seconds: i64; - public nanos: i32; - - constructor(seconds: i64, nanos: i32) { - this.seconds = seconds; - this.nanos = nanos; - } - } - - export class fig { - constructor() {} - } - - export class EventData { - constructor( - public event: Event, - public block: EventList, - ) {} - } + export type Hash = Bytes + + export enum SignedMsgType { + SIGNED_MSG_TYPE_UNKNOWN= 0, + SIGNED_MSG_TYPE_PREVOTE= 1, + SIGNED_MSG_TYPE_PRECOMMIT= 2, + SIGNED_MSG_TYPE_PROPOSAL= 32, + } + + export enum BlockIDFlag { + BLOCK_ID_FLAG_UNKNOWN= 0, + BLOCK_ID_FLAG_ABSENT= 1, + BLOCK_ID_FLAG_COMMIT= 2, + BLOCK_ID_FLAG_NIL= 3, + } + + export class Block { + public header: Header + public data: Data + public evidence: EvidenceList + public last_commit: Commit + + constructor( + header: Header, + data: Data, + evidence: EvidenceList, + last_commit: Commit, + ) { + this.header = header; + this.data = data; + this.evidence = evidence; + this.last_commit = last_commit; + } + } + + export class BlockID { + public hash: Bytes + public part_set_header: PartSetHeader + + constructor( + hash: Bytes, + part_set_header: PartSetHeader, + ) { + this.hash = hash; + this.part_set_header = part_set_header; + } + } + + export class BlockParams { + public max_bytes: i64 + public max_gas: i64 + + constructor( + max_bytes: i64, + max_gas: i64, + ) { + this.max_bytes = max_bytes; + this.max_gas = max_gas; + } + } + + export class Commit { + public height: i64 + public round: i32 + public block_id: BlockID + public signatures: Array + + constructor( + height: i64, + round: i32, + block_id: BlockID, + signatures: Array, + ) { + this.height = height; + this.round = round; + this.block_id = block_id; + this.signatures = signatures; + } + } + + export class CommitSig { + public block_id_flag: BlockIDFlag + public validator_address: Bytes + public timestamp: Timestamp + public signature: Bytes + + constructor( + block_id_flag: BlockIDFlag, + validator_address: Bytes, + timestamp: Timestamp, + signature: Bytes, + ) { + this.block_id_flag = block_id_flag; + this.validator_address = validator_address; + this.timestamp = timestamp; + this.signature = signature; + } + } + + export class Consensus { + public block: u64 + public app: u64 + + constructor( + block: u64, + app: u64, + ) { + this.block = block; + this.app = app; + } + } + + export class ConsensusParams { + public block: BlockParams + public evidence: EvidenceParams + public validator: ValidatorParams + public version: VersionParams + + constructor( + block: BlockParams, + evidence: EvidenceParams, + validator: ValidatorParams, + version: VersionParams, + ) { + this.block = block; + this.evidence = evidence; + this.validator = validator; + this.version = version; + } + } + + export class Data { + public txs: Array + + constructor( + txs: Array, + ) { + this.txs = txs; + } + } + + export class Duration { + public seconds: i64 + public nanos: i32 + + constructor( + seconds: i64, + nanos: i32, + ) { + this.seconds = seconds; + this.nanos = nanos; + } + } + + export class DuplicateVoteEvidence { + public vote_a: EventVote + public vote_b: EventVote + public total_voting_power: i64 + public validator_power: i64 + public timestamp: Timestamp + + constructor( + vote_a: EventVote, + vote_b: EventVote, + total_voting_power: i64, + validator_power: i64, + timestamp: Timestamp, + ) { + this.vote_a = vote_a; + this.vote_b = vote_b; + this.total_voting_power = total_voting_power; + this.validator_power = validator_power; + this.timestamp = timestamp; + } + } + + export class Event { + public type: string + public attributes: Array + + constructor( + type: string, + attributes: Array, + ) { + this.type = type; + this.attributes = attributes; + } + } + + export class EventAttribute { + public key: Bytes + public value: Bytes + public index: bool + + constructor( + key: Bytes, + value: Bytes, + index: bool, + ) { + this.key = key; + this.value = value; + this.index = index; + } + } + + export class EventBlock { + public block: Block + public block_id: BlockID + public result_begin_block: ResponseBeginBlock + public result_end_block: ResponseEndBlock + + constructor( + block: Block, + block_id: BlockID, + result_begin_block: ResponseBeginBlock, + result_end_block: ResponseEndBlock, + ) { + this.block = block; + this.block_id = block_id; + this.result_begin_block = result_begin_block; + this.result_end_block = result_end_block; + } + } + + export class EventData { + public event: Event + public block: EventList + + constructor( + event: Event, + block: EventList, + ) { + this.event = event; + this.block = block; + } + } + + export class EventList { + public new_block: EventBlock + public transaction: Array + public validator_set_updates: EventValidatorSetUpdates + + constructor( + new_block: EventBlock, + transaction: Array, + validator_set_updates: EventValidatorSetUpdates, + ) { + this.new_block = new_block; + this.transaction = transaction; + this.validator_set_updates = validator_set_updates; + } + } + + export class EventTx { + public tx_result: TxResult + + constructor( + tx_result: TxResult, + ) { + this.tx_result = tx_result; + } + } + + export class EventValidatorSetUpdates { + public validator_updates: Array + + constructor( + validator_updates: Array, + ) { + this.validator_updates = validator_updates; + } + } + + export class EventVote { + public event_vote_type: SignedMsgType + public height: u64 + public round: i32 + public block_id: BlockID + public timestamp: Timestamp + public validator_address: Bytes + public validator_index: i32 + public signature: Bytes + + constructor( + event_vote_type: SignedMsgType, + height: u64, + round: i32, + block_id: BlockID, + timestamp: Timestamp, + validator_address: Bytes, + validator_index: i32, + signature: Bytes, + ) { + this.event_vote_type = event_vote_type; + this.height = height; + this.round = round; + this.block_id = block_id; + this.timestamp = timestamp; + this.validator_address = validator_address; + this.validator_index = validator_index; + this.signature = signature; + } + } + + export class Evidence { + public duplicate_vote_evidence: DuplicateVoteEvidence + public light_client_attack_evidence: LightClientAttackEvidence + + constructor( + duplicate_vote_evidence: DuplicateVoteEvidence, + light_client_attack_evidence: LightClientAttackEvidence, + ) { + this.duplicate_vote_evidence = duplicate_vote_evidence; + this.light_client_attack_evidence = light_client_attack_evidence; + } + } + + export class EvidenceList { + public evidence: Array + + constructor( + evidence: Array, + ) { + this.evidence = evidence; + } + } + + export class EvidenceParams { + public max_age_num_blocks: i64 + public max_age_duration: Duration + public max_bytes: i64 + + constructor( + max_age_num_blocks: i64, + max_age_duration: Duration, + max_bytes: i64, + ) { + this.max_age_num_blocks = max_age_num_blocks; + this.max_age_duration = max_age_duration; + this.max_bytes = max_bytes; + } + } + + export class fig { + + constructor( + ) { + } + } + + export class Header { + public version: Consensus + public chain_id: string + public height: u64 + public time: Timestamp + public last_block_id: BlockID + public last_commit_hash: Hash + public data_hash: Hash + public validators_hash: Hash + public next_validators_hash: Hash + public consensus_hash: Hash + public app_hash: Hash + public last_results_hash: Hash + public eidence_hash: Hash + public proposer_address: Bytes + + constructor( + version: Consensus, + chain_id: string, + height: u64, + time: Timestamp, + last_block_id: BlockID, + last_commit_hash: Hash, + data_hash: Hash, + validators_hash: Hash, + next_validators_hash: Hash, + consensus_hash: Hash, + app_hash: Hash, + last_results_hash: Hash, + eidence_hash: Hash, + proposer_address: Bytes, + ) { + this.version = version; + this.chain_id = chain_id; + this.height = height; + this.time = time; + this.last_block_id = last_block_id; + this.last_commit_hash = last_commit_hash; + this.data_hash = data_hash; + this.validators_hash = validators_hash; + this.next_validators_hash = next_validators_hash; + this.consensus_hash = consensus_hash; + this.app_hash = app_hash; + this.last_results_hash = last_results_hash; + this.eidence_hash = eidence_hash; + this.proposer_address = proposer_address; + } + } + + export class LightBlock { + public signed_header: SignedHeader + public validator_set: ValidatorSet + + constructor( + signed_header: SignedHeader, + validator_set: ValidatorSet, + ) { + this.signed_header = signed_header; + this.validator_set = validator_set; + } + } + + export class LightClientAttackEvidence { + public conflicting_block: LightBlock + public common_height: i64 + public byzantine_validators: Array + public total_voting_power: i64 + public timestamp: Timestamp + + constructor( + conflicting_block: LightBlock, + common_height: i64, + byzantine_validators: Array, + total_voting_power: i64, + timestamp: Timestamp, + ) { + this.conflicting_block = conflicting_block; + this.common_height = common_height; + this.byzantine_validators = byzantine_validators; + this.total_voting_power = total_voting_power; + this.timestamp = timestamp; + } + } + + export class PublicKey { + public ed25519: Bytes + public secp256k1: Bytes + + constructor( + ed25519: Bytes, + secp256k1: Bytes, + ) { + this.ed25519 = ed25519; + this.secp256k1 = secp256k1; + } + } + + export class PartSetHeader { + public total: u32 + public hash: Hash + + constructor( + total: u32, + hash: Hash, + ) { + this.total = total; + this.hash = hash; + } + } + + export class ResponseBeginBlock { + public events: Array + + constructor( + events: Array, + ) { + this.events = events; + } + } + + export class ResponseEndBlock { + public validator_updates: Array + public consensus_param_updates: ConsensusParams + public events: Array + + constructor( + validator_updates: Array, + consensus_param_updates: ConsensusParams, + events: Array, + ) { + this.validator_updates = validator_updates; + this.consensus_param_updates = consensus_param_updates; + this.events = events; + } + } + + export class ResponseDeliverTx { + public code: u32 + public data: Bytes + public log: string + public info: string + public gas_wanted: i64 + public gas_used: i64 + public events: Array + public codespace: string + + constructor( + code: u32, + data: Bytes, + log: string, + info: string, + gas_wanted: i64, + gas_used: i64, + events: Array, + codespace: string, + ) { + this.code = code; + this.data = data; + this.log = log; + this.info = info; + this.gas_wanted = gas_wanted; + this.gas_used = gas_used; + this.events = events; + this.codespace = codespace; + } + } + + export class Reward { + public amount: string + public validator: string + + constructor( + amount: string, + validator: string, + ) { + this.amount = amount; + this.validator = validator; + } + } + + export class SignedHeader { + public header: Header + public commit: Commit + + constructor( + header: Header, + commit: Commit, + ) { + this.header = header; + this.commit = commit; + } + } + + export class Timestamp { + public seconds: i64 + public nanos: i32 + + constructor( + seconds: i64, + nanos: i32, + ) { + this.seconds = seconds; + this.nanos = nanos; + } + } + + export class Validator { + public address: Bytes + public pub_key: PublicKey + public voting_power: i64 + public proposer_priority: i64 + + constructor( + address: Bytes, + pub_key: PublicKey, + voting_power: i64, + proposer_priority: i64, + ) { + this.address = address; + this.pub_key = pub_key; + this.voting_power = voting_power; + this.proposer_priority = proposer_priority; + } + } + + export class ValidatorUpdate { + public pub_key: PublicKey + public power: i64 + + constructor( + pub_key: PublicKey, + power: i64, + ) { + this.pub_key = pub_key; + this.power = power; + } + } + + export class ValidatorParams { + public pub_key_types: Array + + constructor( + pub_key_types: Array, + ) { + this.pub_key_types = pub_key_types; + } + } + + export class VersionParams { + public app_version: u64 + + constructor( + app_version: u64, + ) { + this.app_version = app_version; + } + } + + export class ValidatorSet { + public validators: Array + public proposer: Validator + public total_voting_power: i64 + + constructor( + validators: Array, + proposer: Validator, + total_voting_power: i64, + ) { + this.validators = validators; + this.proposer = proposer; + this.total_voting_power = total_voting_power; + } + } + + export class TxResult { + public height: u64 + public index: u32 + public tx: Bytes + public result: ResponseDeliverTx + + constructor( + height: u64, + index: u32, + tx: Bytes, + result: ResponseDeliverTx, + ) { + this.height = height; + this.index = index; + this.tx = tx; + this.result = result; + } + } } diff --git a/global/global.ts b/global/global.ts index 4c47cb3..c544a09 100644 --- a/global/global.ts +++ b/global/global.ts @@ -132,11 +132,10 @@ export enum TypeId { TendermintResponseDeliverTx = 123, TendermintEvent = 124, TendermintEventAttribute = 125, - TendermintAddress = 126, - TendermintEventValidatorSetUpdates = 127, - TendermintTimestamp = 128, - Tendermintfig = 129, - TendermintEventData = 130, + TendermintEventValidatorSetUpdates = 126, + TendermintTimestamp = 127, + Tendermintfig = 128, + TendermintEventData = 129, } export function id_of_type(typeId: TypeId): usize { @@ -331,66 +330,64 @@ export function id_of_type(typeId: TypeId): usize { case TypeId.TendermintArrayEventAttribute: return idof>() case TypeId.TendermintBlockIDFlagEnum: - return idof>() + return idof() case TypeId.TendermintSignedMsgTypeEnum: - return idof>() + return idof() case TypeId.TendermintEventList: - return idof>() + return idof() case TypeId.TendermintEventBlock: - return idof>() + return idof() case TypeId.TendermintResponseBeginBlock: return idof() case TypeId.TendermintResponseEndBlock: return idof() - case TypeId.TendermintConsensusParams : + case TypeId.TendermintConsensusParams: return idof() - case TypeId.TendermintVersion : - return idof() - case TypeId.TendermintBlock : + case TypeId.TendermintVersion: + return idof() + case TypeId.TendermintBlock: return idof() - case TypeId.TendermintCommit : + case TypeId.TendermintCommit: return idof() - case TypeId.TendermintCommitSig : + case TypeId.TendermintCommitSig: return idof() - case TypeId.TendermintEventBlockHeader : - return idof() - case TypeId.TendermintHeader : + case TypeId.TendermintHeader: return idof() - case TypeId.TendermintConsensus : + case TypeId.TendermintConsensus: return idof() - case TypeId.TendermintBlockID : + case TypeId.TendermintBlockID: return idof() - case TypeId.TendermintPartSetHeader : + case TypeId.TendermintPartSetHeader: return idof() - case TypeId.TendermintData : + case TypeId.TendermintData: return idof() - case TypeId.TendermintEvidence : + case TypeId.TendermintEvidence: return idof() - case TypeId.TendermintDuplicateVoteEvidence : + case TypeId.TendermintDuplicateVoteEvidence: return idof() - case TypeId.TendermintEventTx : + case TypeId.TendermintEventTx: return idof() - case TypeId.TendermintEventVote : + case TypeId.TendermintEventVote: return idof() - case TypeId.TendermintLightClientAttackEvidence : + case TypeId.TendermintLightClientAttackEvidence: return idof() - case TypeId.TendermintLightBlock : + case TypeId.TendermintLightBlock: return idof() - case TypeId.TendermintValidatorSet : + case TypeId.TendermintValidatorSet: return idof() - case TypeId.TendermintSignedHeader : + case TypeId.TendermintSignedHeader: return idof() - case TypeId.TendermintEvidenceList : + case TypeId.TendermintEvidenceList: return idof() - case TypeId.TendermintValidator : + case TypeId.TendermintValidator: return idof() - case TypeId.TendermintPublicKey : + case TypeId.TendermintPublicKey: return idof() - case TypeId.TendermintTxResult : + case TypeId.TendermintTxResult: return idof() - case TypeId.TendermintResponseDeliverTx : + case TypeId.TendermintResponseDeliverTx: return idof() - case TypeId.TendermintEvent : + case TypeId.TendermintEvent: return idof() case TypeId.TendermintEventAttribute: return idof() From 78fd86913b334649732d0dbd291fef85f2103bfb Mon Sep 17 00:00:00 2001 From: Patrycja Zawadka Date: Tue, 18 Jan 2022 02:44:23 +0100 Subject: [PATCH 06/12] Update Tendermint ids --- chain/tendermint.ts | 133 +++++++++++++++++++++----------------------- global/global.ts | 112 +++++++++++++++++++++---------------- 2 files changed, 125 insertions(+), 120 deletions(-) diff --git a/chain/tendermint.ts b/chain/tendermint.ts index f67db28..91b887d 100644 --- a/chain/tendermint.ts +++ b/chain/tendermint.ts @@ -2,8 +2,6 @@ import '../common/eager_offset' import { Bytes } from "../common/collections" export namespace tendermint { - export type Hash = Bytes - export enum SignedMsgType { SIGNED_MSG_TYPE_UNKNOWN= 0, SIGNED_MSG_TYPE_PREVOTE= 1, @@ -179,26 +177,26 @@ export namespace tendermint { } export class Event { - public type: string + public event_type: string public attributes: Array constructor( - type: string, + event_type: string, attributes: Array, ) { - this.type = type; + this.event_type = event_type; this.attributes = attributes; } } export class EventAttribute { - public key: Bytes - public value: Bytes + public key: string + public value: string public index: bool constructor( - key: Bytes, - value: Bytes, + key: string, + value: string, index: bool, ) { this.key = key; @@ -345,27 +343,20 @@ export namespace tendermint { } } - export class fig { - - constructor( - ) { - } - } - export class Header { public version: Consensus public chain_id: string public height: u64 public time: Timestamp public last_block_id: BlockID - public last_commit_hash: Hash - public data_hash: Hash - public validators_hash: Hash - public next_validators_hash: Hash - public consensus_hash: Hash - public app_hash: Hash - public last_results_hash: Hash - public eidence_hash: Hash + public last_commit_hash: Bytes + public data_hash: Bytes + public validators_hash: Bytes + public next_validators_hash: Bytes + public consensus_hash: Bytes + public app_hash: Bytes + public last_results_hash: Bytes + public evidence_hash: Bytes public proposer_address: Bytes constructor( @@ -374,14 +365,14 @@ export namespace tendermint { height: u64, time: Timestamp, last_block_id: BlockID, - last_commit_hash: Hash, - data_hash: Hash, - validators_hash: Hash, - next_validators_hash: Hash, - consensus_hash: Hash, - app_hash: Hash, - last_results_hash: Hash, - eidence_hash: Hash, + last_commit_hash: Bytes, + data_hash: Bytes, + validators_hash: Bytes, + next_validators_hash: Bytes, + consensus_hash: Bytes, + app_hash: Bytes, + last_results_hash: Bytes, + evidence_hash: Bytes, proposer_address: Bytes, ) { this.version = version; @@ -396,7 +387,7 @@ export namespace tendermint { this.consensus_hash = consensus_hash; this.app_hash = app_hash; this.last_results_hash = last_results_hash; - this.eidence_hash = eidence_hash; + this.evidence_hash = evidence_hash; this.proposer_address = proposer_address; } } @@ -451,11 +442,11 @@ export namespace tendermint { export class PartSetHeader { public total: u32 - public hash: Hash + public hash: Bytes constructor( total: u32, - hash: Hash, + hash: Bytes, ) { this.total = total; this.hash = hash; @@ -558,6 +549,25 @@ export namespace tendermint { } } + export class TxResult { + public height: u64 + public index: u32 + public tx: Bytes + public result: ResponseDeliverTx + + constructor( + height: u64, + index: u32, + tx: Bytes, + result: ResponseDeliverTx, + ) { + this.height = height; + this.index = index; + this.tx = tx; + this.result = result; + } + } + export class Validator { public address: Bytes public pub_key: PublicKey @@ -577,19 +587,6 @@ export namespace tendermint { } } - export class ValidatorUpdate { - public pub_key: PublicKey - public power: i64 - - constructor( - pub_key: PublicKey, - power: i64, - ) { - this.pub_key = pub_key; - this.power = power; - } - } - export class ValidatorParams { public pub_key_types: Array @@ -600,16 +597,6 @@ export namespace tendermint { } } - export class VersionParams { - public app_version: u64 - - constructor( - app_version: u64, - ) { - this.app_version = app_version; - } - } - export class ValidatorSet { public validators: Array public proposer: Validator @@ -626,22 +613,26 @@ export namespace tendermint { } } - export class TxResult { - public height: u64 - public index: u32 - public tx: Bytes - public result: ResponseDeliverTx + export class ValidatorUpdate { + public pub_key: PublicKey + public power: i64 constructor( - height: u64, - index: u32, - tx: Bytes, - result: ResponseDeliverTx, + pub_key: PublicKey, + power: i64, ) { - this.height = height; - this.index = index; - this.tx = tx; - this.result = result; + this.pub_key = pub_key; + this.power = power; + } + } + + export class VersionParams { + public app_version: u64 + + constructor( + app_version: u64, + ) { + this.app_version = app_version; } } } diff --git a/global/global.ts b/global/global.ts index c544a09..e7db446 100644 --- a/global/global.ts +++ b/global/global.ts @@ -95,47 +95,51 @@ export enum TypeId { NearReceiptWithOutcome = 86, TendermintArrayEventTx = 87, TendermintArrayEvent = 88, - TendermintArrayValidator = 89, - TendermintArrayCommitSig = 90, - TendermintArrayBytes = 91, - TendermintArrayEvidence = 92, - TendermintArrayEventAttribute = 93, - TendermintBlockIDFlagEnum = 94, - TendermintSignedMsgTypeEnum = 95, - TendermintEventList = 96, - TendermintEventBlock = 97, - TendermintResponseBeginBlock = 98, - TendermintResponseEndBlock = 99, - TendermintConsensusParams = 100, - TendermintVersion = 101, - TendermintBlock = 102, - TendermintCommit = 103, - TendermintCommitSig = 104, - TendermintEventBlockHeader = 105, - TendermintHeader = 106, - TendermintConsensus = 107, - TendermintBlockID = 108, - TendermintPartSetHeader = 109, - TendermintData = 110, - TendermintEvidence = 111, - TendermintDuplicateVoteEvidence = 112, - TendermintEventTx = 113, - TendermintEventVote = 114, - TendermintLightClientAttackEvidence = 115, - TendermintLightBlock = 116, - TendermintValidatorSet = 117, - TendermintSignedHeader = 118, - TendermintEvidenceList = 119, - TendermintValidator = 120, - TendermintPublicKey = 121, - TendermintTxResult = 122, - TendermintResponseDeliverTx = 123, - TendermintEvent = 124, - TendermintEventAttribute = 125, - TendermintEventValidatorSetUpdates = 126, - TendermintTimestamp = 127, - Tendermintfig = 128, - TendermintEventData = 129, + TendermintArrayCommitSig = 89, + TendermintArrayBytes = 90, + TendermintArrayEvidence = 91, + TendermintArrayEventAttribute = 92, + TendermintBlockIDFlagEnum = 93, + TendermintSignedMsgTypeEnum = 94, + TendermintEventList = 95, + TendermintEventBlock = 96, + TendermintResponseBeginBlock = 97, + TendermintResponseEndBlock = 98, + TendermintValidatorUpdate = 99, + TendermintArrayValidatorUpdate = 100, + TendermintConsensusParams = 101, + TendermintBlockParams = 102, + TendermintEvidenceParams = 103, + TendermintValidatorParams = 104, + TendermintVersionParams = 105, + TendermintBlock = 106, + TendermintCommit = 107, + TendermintCommitSig = 108, + TendermintHeader = 109, + TendermintConsensus = 110, + TendermintBlockID = 111, + TendermintPartSetHeader = 112, + TendermintData = 113, + TendermintEvidence = 114, + TendermintDuplicateVoteEvidence = 115, + TendermintEventTx = 116, + TendermintEventVote = 117, + TendermintLightClientAttackEvidence = 118, + TendermintLightBlock = 119, + TendermintValidatorSet = 120, + TendermintSignedHeader = 121, + TendermintEvidenceList = 122, + TendermintValidator = 123, + TendermintArrayValidator = 124, + TendermintPublicKey = 125, + TendermintTxResult = 126, + TendermintResponseDeliverTx = 127, + TendermintEvent = 128, + TendermintEventAttribute = 129, + TendermintEventValidatorSetUpdates = 130, + TendermintDuration = 131, + TendermintTimestamp = 132, + TendermintEventData = 133, } export function id_of_type(typeId: TypeId): usize { @@ -319,8 +323,6 @@ export function id_of_type(typeId: TypeId): usize { return idof>() case TypeId.TendermintArrayEvent: return idof>() - case TypeId.TendermintArrayValidator: - return idof>() case TypeId.TendermintArrayCommitSig: return idof>() case TypeId.TendermintArrayBytes: @@ -330,9 +332,9 @@ export function id_of_type(typeId: TypeId): usize { case TypeId.TendermintArrayEventAttribute: return idof>() case TypeId.TendermintBlockIDFlagEnum: - return idof() + return idof>() case TypeId.TendermintSignedMsgTypeEnum: - return idof() + return idof>() case TypeId.TendermintEventList: return idof() case TypeId.TendermintEventBlock: @@ -341,10 +343,20 @@ export function id_of_type(typeId: TypeId): usize { return idof() case TypeId.TendermintResponseEndBlock: return idof() + case TypeId.TendermintValidatorUpdate: + return idof() + case TypeId.TendermintArrayValidatorUpdate: + return idof>() case TypeId.TendermintConsensusParams: return idof() - case TypeId.TendermintVersion: - return idof() + case TypeId.TendermintBlockParams: + return idof() + case TypeId.TendermintEvidenceParams: + return idof() + case TypeId.TendermintValidatorParams: + return idof() + case TypeId.TendermintVersionParams: + return idof() case TypeId.TendermintBlock: return idof() case TypeId.TendermintCommit: @@ -381,6 +393,8 @@ export function id_of_type(typeId: TypeId): usize { return idof() case TypeId.TendermintValidator: return idof() + case TypeId.TendermintArrayValidator: + return idof>() case TypeId.TendermintPublicKey: return idof() case TypeId.TendermintTxResult: @@ -393,10 +407,10 @@ export function id_of_type(typeId: TypeId): usize { return idof() case TypeId.TendermintEventValidatorSetUpdates: return idof() + case TypeId.TendermintDuration: + return idof() case TypeId.TendermintTimestamp: return idof() - case TypeId.Tendermintfig: - return idof() case TypeId.TendermintEventData: return idof() default: From 20aba73afbcc0811e3b9a37933483d48a131cd51 Mon Sep 17 00:00:00 2001 From: Patrycja Zawadka Date: Wed, 19 Jan 2022 21:23:11 +0100 Subject: [PATCH 07/12] Update tendermint --- chain/tendermint.ts | 1199 ++++++++++++++++++++----------------------- 1 file changed, 565 insertions(+), 634 deletions(-) diff --git a/chain/tendermint.ts b/chain/tendermint.ts index 91b887d..24b8de5 100644 --- a/chain/tendermint.ts +++ b/chain/tendermint.ts @@ -1,638 +1,569 @@ import '../common/eager_offset' -import { Bytes } from "../common/collections" +import { Bytes } from '../common/collections' export namespace tendermint { - export enum SignedMsgType { - SIGNED_MSG_TYPE_UNKNOWN= 0, - SIGNED_MSG_TYPE_PREVOTE= 1, - SIGNED_MSG_TYPE_PRECOMMIT= 2, - SIGNED_MSG_TYPE_PROPOSAL= 32, - } - - export enum BlockIDFlag { - BLOCK_ID_FLAG_UNKNOWN= 0, - BLOCK_ID_FLAG_ABSENT= 1, - BLOCK_ID_FLAG_COMMIT= 2, - BLOCK_ID_FLAG_NIL= 3, - } - - export class Block { - public header: Header - public data: Data - public evidence: EvidenceList - public last_commit: Commit - - constructor( - header: Header, - data: Data, - evidence: EvidenceList, - last_commit: Commit, - ) { - this.header = header; - this.data = data; - this.evidence = evidence; - this.last_commit = last_commit; - } - } - - export class BlockID { - public hash: Bytes - public part_set_header: PartSetHeader - - constructor( - hash: Bytes, - part_set_header: PartSetHeader, - ) { - this.hash = hash; - this.part_set_header = part_set_header; - } - } - - export class BlockParams { - public max_bytes: i64 - public max_gas: i64 - - constructor( - max_bytes: i64, - max_gas: i64, - ) { - this.max_bytes = max_bytes; - this.max_gas = max_gas; - } - } - - export class Commit { - public height: i64 - public round: i32 - public block_id: BlockID - public signatures: Array - - constructor( - height: i64, - round: i32, - block_id: BlockID, - signatures: Array, - ) { - this.height = height; - this.round = round; - this.block_id = block_id; - this.signatures = signatures; - } - } - - export class CommitSig { - public block_id_flag: BlockIDFlag - public validator_address: Bytes - public timestamp: Timestamp - public signature: Bytes - - constructor( - block_id_flag: BlockIDFlag, - validator_address: Bytes, - timestamp: Timestamp, - signature: Bytes, - ) { - this.block_id_flag = block_id_flag; - this.validator_address = validator_address; - this.timestamp = timestamp; - this.signature = signature; - } - } - - export class Consensus { - public block: u64 - public app: u64 - - constructor( - block: u64, - app: u64, - ) { - this.block = block; - this.app = app; - } - } - - export class ConsensusParams { - public block: BlockParams - public evidence: EvidenceParams - public validator: ValidatorParams - public version: VersionParams - - constructor( - block: BlockParams, - evidence: EvidenceParams, - validator: ValidatorParams, - version: VersionParams, - ) { - this.block = block; - this.evidence = evidence; - this.validator = validator; - this.version = version; - } - } - - export class Data { - public txs: Array - - constructor( - txs: Array, - ) { - this.txs = txs; - } - } - - export class Duration { - public seconds: i64 - public nanos: i32 - - constructor( - seconds: i64, - nanos: i32, - ) { - this.seconds = seconds; - this.nanos = nanos; - } - } - - export class DuplicateVoteEvidence { - public vote_a: EventVote - public vote_b: EventVote - public total_voting_power: i64 - public validator_power: i64 - public timestamp: Timestamp - - constructor( - vote_a: EventVote, - vote_b: EventVote, - total_voting_power: i64, - validator_power: i64, - timestamp: Timestamp, - ) { - this.vote_a = vote_a; - this.vote_b = vote_b; - this.total_voting_power = total_voting_power; - this.validator_power = validator_power; - this.timestamp = timestamp; - } - } - - export class Event { - public event_type: string - public attributes: Array - - constructor( - event_type: string, - attributes: Array, - ) { - this.event_type = event_type; - this.attributes = attributes; - } - } - - export class EventAttribute { - public key: string - public value: string - public index: bool - - constructor( - key: string, - value: string, - index: bool, - ) { - this.key = key; - this.value = value; - this.index = index; - } - } - - export class EventBlock { - public block: Block - public block_id: BlockID - public result_begin_block: ResponseBeginBlock - public result_end_block: ResponseEndBlock - - constructor( - block: Block, - block_id: BlockID, - result_begin_block: ResponseBeginBlock, - result_end_block: ResponseEndBlock, - ) { - this.block = block; - this.block_id = block_id; - this.result_begin_block = result_begin_block; - this.result_end_block = result_end_block; - } - } - - export class EventData { - public event: Event - public block: EventList - - constructor( - event: Event, - block: EventList, - ) { - this.event = event; - this.block = block; - } - } - - export class EventList { - public new_block: EventBlock - public transaction: Array - public validator_set_updates: EventValidatorSetUpdates - - constructor( - new_block: EventBlock, - transaction: Array, - validator_set_updates: EventValidatorSetUpdates, - ) { - this.new_block = new_block; - this.transaction = transaction; - this.validator_set_updates = validator_set_updates; - } - } - - export class EventTx { - public tx_result: TxResult - - constructor( - tx_result: TxResult, - ) { - this.tx_result = tx_result; - } - } - - export class EventValidatorSetUpdates { - public validator_updates: Array - - constructor( - validator_updates: Array, - ) { - this.validator_updates = validator_updates; - } - } - - export class EventVote { - public event_vote_type: SignedMsgType - public height: u64 - public round: i32 - public block_id: BlockID - public timestamp: Timestamp - public validator_address: Bytes - public validator_index: i32 - public signature: Bytes - - constructor( - event_vote_type: SignedMsgType, - height: u64, - round: i32, - block_id: BlockID, - timestamp: Timestamp, - validator_address: Bytes, - validator_index: i32, - signature: Bytes, - ) { - this.event_vote_type = event_vote_type; - this.height = height; - this.round = round; - this.block_id = block_id; - this.timestamp = timestamp; - this.validator_address = validator_address; - this.validator_index = validator_index; - this.signature = signature; - } - } - - export class Evidence { - public duplicate_vote_evidence: DuplicateVoteEvidence - public light_client_attack_evidence: LightClientAttackEvidence - - constructor( - duplicate_vote_evidence: DuplicateVoteEvidence, - light_client_attack_evidence: LightClientAttackEvidence, - ) { - this.duplicate_vote_evidence = duplicate_vote_evidence; - this.light_client_attack_evidence = light_client_attack_evidence; - } - } - - export class EvidenceList { - public evidence: Array - - constructor( - evidence: Array, - ) { - this.evidence = evidence; - } - } - - export class EvidenceParams { - public max_age_num_blocks: i64 - public max_age_duration: Duration - public max_bytes: i64 - - constructor( - max_age_num_blocks: i64, - max_age_duration: Duration, - max_bytes: i64, - ) { - this.max_age_num_blocks = max_age_num_blocks; - this.max_age_duration = max_age_duration; - this.max_bytes = max_bytes; - } - } - - export class Header { - public version: Consensus - public chain_id: string - public height: u64 - public time: Timestamp - public last_block_id: BlockID - public last_commit_hash: Bytes - public data_hash: Bytes - public validators_hash: Bytes - public next_validators_hash: Bytes - public consensus_hash: Bytes - public app_hash: Bytes - public last_results_hash: Bytes - public evidence_hash: Bytes - public proposer_address: Bytes - - constructor( - version: Consensus, - chain_id: string, - height: u64, - time: Timestamp, - last_block_id: BlockID, - last_commit_hash: Bytes, - data_hash: Bytes, - validators_hash: Bytes, - next_validators_hash: Bytes, - consensus_hash: Bytes, - app_hash: Bytes, - last_results_hash: Bytes, - evidence_hash: Bytes, - proposer_address: Bytes, - ) { - this.version = version; - this.chain_id = chain_id; - this.height = height; - this.time = time; - this.last_block_id = last_block_id; - this.last_commit_hash = last_commit_hash; - this.data_hash = data_hash; - this.validators_hash = validators_hash; - this.next_validators_hash = next_validators_hash; - this.consensus_hash = consensus_hash; - this.app_hash = app_hash; - this.last_results_hash = last_results_hash; - this.evidence_hash = evidence_hash; - this.proposer_address = proposer_address; - } - } - - export class LightBlock { - public signed_header: SignedHeader - public validator_set: ValidatorSet - - constructor( - signed_header: SignedHeader, - validator_set: ValidatorSet, - ) { - this.signed_header = signed_header; - this.validator_set = validator_set; - } - } - - export class LightClientAttackEvidence { - public conflicting_block: LightBlock - public common_height: i64 - public byzantine_validators: Array - public total_voting_power: i64 - public timestamp: Timestamp - - constructor( - conflicting_block: LightBlock, - common_height: i64, - byzantine_validators: Array, - total_voting_power: i64, - timestamp: Timestamp, - ) { - this.conflicting_block = conflicting_block; - this.common_height = common_height; - this.byzantine_validators = byzantine_validators; - this.total_voting_power = total_voting_power; - this.timestamp = timestamp; - } - } - - export class PublicKey { - public ed25519: Bytes - public secp256k1: Bytes - - constructor( - ed25519: Bytes, - secp256k1: Bytes, - ) { - this.ed25519 = ed25519; - this.secp256k1 = secp256k1; - } - } - - export class PartSetHeader { - public total: u32 - public hash: Bytes - - constructor( - total: u32, - hash: Bytes, - ) { - this.total = total; - this.hash = hash; - } - } - - export class ResponseBeginBlock { - public events: Array - - constructor( - events: Array, - ) { - this.events = events; - } - } - - export class ResponseEndBlock { - public validator_updates: Array - public consensus_param_updates: ConsensusParams - public events: Array - - constructor( - validator_updates: Array, - consensus_param_updates: ConsensusParams, - events: Array, - ) { - this.validator_updates = validator_updates; - this.consensus_param_updates = consensus_param_updates; - this.events = events; - } - } - - export class ResponseDeliverTx { - public code: u32 - public data: Bytes - public log: string - public info: string - public gas_wanted: i64 - public gas_used: i64 - public events: Array - public codespace: string - - constructor( - code: u32, - data: Bytes, - log: string, - info: string, - gas_wanted: i64, - gas_used: i64, - events: Array, - codespace: string, - ) { - this.code = code; - this.data = data; - this.log = log; - this.info = info; - this.gas_wanted = gas_wanted; - this.gas_used = gas_used; - this.events = events; - this.codespace = codespace; - } - } - - export class Reward { - public amount: string - public validator: string - - constructor( - amount: string, - validator: string, - ) { - this.amount = amount; - this.validator = validator; - } - } - - export class SignedHeader { - public header: Header - public commit: Commit - - constructor( - header: Header, - commit: Commit, - ) { - this.header = header; - this.commit = commit; - } - } - - export class Timestamp { - public seconds: i64 - public nanos: i32 - - constructor( - seconds: i64, - nanos: i32, - ) { - this.seconds = seconds; - this.nanos = nanos; - } - } - - export class TxResult { - public height: u64 - public index: u32 - public tx: Bytes - public result: ResponseDeliverTx - - constructor( - height: u64, - index: u32, - tx: Bytes, - result: ResponseDeliverTx, - ) { - this.height = height; - this.index = index; - this.tx = tx; - this.result = result; - } - } - - export class Validator { - public address: Bytes - public pub_key: PublicKey - public voting_power: i64 - public proposer_priority: i64 - - constructor( - address: Bytes, - pub_key: PublicKey, - voting_power: i64, - proposer_priority: i64, - ) { - this.address = address; - this.pub_key = pub_key; - this.voting_power = voting_power; - this.proposer_priority = proposer_priority; - } - } - - export class ValidatorParams { - public pub_key_types: Array - - constructor( - pub_key_types: Array, - ) { - this.pub_key_types = pub_key_types; - } - } - - export class ValidatorSet { - public validators: Array - public proposer: Validator - public total_voting_power: i64 - - constructor( - validators: Array, - proposer: Validator, - total_voting_power: i64, - ) { - this.validators = validators; - this.proposer = proposer; - this.total_voting_power = total_voting_power; - } - } - - export class ValidatorUpdate { - public pub_key: PublicKey - public power: i64 - - constructor( - pub_key: PublicKey, - power: i64, - ) { - this.pub_key = pub_key; - this.power = power; - } - } - - export class VersionParams { - public app_version: u64 - - constructor( - app_version: u64, - ) { - this.app_version = app_version; - } - } + export enum SignedMsgType { + SIGNED_MSG_TYPE_UNKNOWN = 0, + SIGNED_MSG_TYPE_PREVOTE = 1, + SIGNED_MSG_TYPE_PRECOMMIT = 2, + SIGNED_MSG_TYPE_PROPOSAL = 32, + } + + export enum BlockIDFlag { + BLOCK_ID_FLAG_UNKNOWN = 0, + BLOCK_ID_FLAG_ABSENT = 1, + BLOCK_ID_FLAG_COMMIT = 2, + BLOCK_ID_FLAG_NIL = 3, + } + + export class Block { + public header: Header + public data: Data + public evidence: EvidenceList + public last_commit: Commit + + constructor(header: Header, data: Data, evidence: EvidenceList, last_commit: Commit) { + this.header = header + this.data = data + this.evidence = evidence + this.last_commit = last_commit + } + } + + export class BlockID { + public hash: Bytes + public part_set_header: PartSetHeader + + constructor(hash: Bytes, part_set_header: PartSetHeader) { + this.hash = hash + this.part_set_header = part_set_header + } + } + + export class BlockParams { + public max_bytes: i64 + public max_gas: i64 + + constructor(max_bytes: i64, max_gas: i64) { + this.max_bytes = max_bytes + this.max_gas = max_gas + } + } + + export class Commit { + public height: i64 + public round: i32 + public block_id: BlockID + public signatures: Array + + constructor( + height: i64, + round: i32, + block_id: BlockID, + signatures: Array, + ) { + this.height = height + this.round = round + this.block_id = block_id + this.signatures = signatures + } + } + + export class CommitSig { + public block_id_flag: BlockIDFlag + public validator_address: Bytes + public timestamp: Timestamp + public signature: Bytes + + constructor( + block_id_flag: BlockIDFlag, + validator_address: Bytes, + timestamp: Timestamp, + signature: Bytes, + ) { + this.block_id_flag = block_id_flag + this.validator_address = validator_address + this.timestamp = timestamp + this.signature = signature + } + } + + export class Consensus { + public block: u64 + public app: u64 + + constructor(block: u64, app: u64) { + this.block = block + this.app = app + } + } + + export class ConsensusParams { + public block: BlockParams + public evidence: EvidenceParams + public validator: ValidatorParams + public version: VersionParams + + constructor( + block: BlockParams, + evidence: EvidenceParams, + validator: ValidatorParams, + version: VersionParams, + ) { + this.block = block + this.evidence = evidence + this.validator = validator + this.version = version + } + } + + export class Data { + public txs: Array + + constructor(txs: Array) { + this.txs = txs + } + } + + export class Duration { + public seconds: i64 + public nanos: i32 + + constructor(seconds: i64, nanos: i32) { + this.seconds = seconds + this.nanos = nanos + } + } + + export class DuplicateVoteEvidence { + public vote_a: EventVote + public vote_b: EventVote + public total_voting_power: i64 + public validator_power: i64 + public timestamp: Timestamp + + constructor( + vote_a: EventVote, + vote_b: EventVote, + total_voting_power: i64, + validator_power: i64, + timestamp: Timestamp, + ) { + this.vote_a = vote_a + this.vote_b = vote_b + this.total_voting_power = total_voting_power + this.validator_power = validator_power + this.timestamp = timestamp + } + } + + export class Event { + public event_type: string + public attributes: Array + + constructor(event_type: string, attributes: Array) { + this.event_type = event_type + this.attributes = attributes + } + } + + export class EventAttribute { + public key: string + public value: string + public index: bool + + constructor(key: string, value: string, index: bool) { + this.key = key + this.value = value + this.index = index + } + } + + export class EventBlock { + public block: Block + public block_id: BlockID + public result_begin_block: ResponseBeginBlock + public result_end_block: ResponseEndBlock + + constructor( + block: Block, + block_id: BlockID, + result_begin_block: ResponseBeginBlock, + result_end_block: ResponseEndBlock, + ) { + this.block = block + this.block_id = block_id + this.result_begin_block = result_begin_block + this.result_end_block = result_end_block + } + } + + export class EventData { + public event: Event + public block: EventList + + constructor(event: Event, block: EventList) { + this.event = event + this.block = block + } + } + + export class EventList { + public new_block: EventBlock + public transaction: Array + public validator_set_updates: EventValidatorSetUpdates + + constructor( + new_block: EventBlock, + transaction: Array, + validator_set_updates: EventValidatorSetUpdates, + ) { + this.new_block = new_block + this.transaction = transaction + this.validator_set_updates = validator_set_updates + } + } + + export class EventTx { + public tx_result: TxResult + + constructor(tx_result: TxResult) { + this.tx_result = tx_result + } + } + + export class EventValidatorSetUpdates { + public validator_updates: Array + + constructor(validator_updates: Array) { + this.validator_updates = validator_updates + } + } + + export class EventVote { + public event_vote_type: SignedMsgType + public height: u64 + public round: i32 + public block_id: BlockID + public timestamp: Timestamp + public validator_address: Bytes + public validator_index: i32 + public signature: Bytes + + constructor( + event_vote_type: SignedMsgType, + height: u64, + round: i32, + block_id: BlockID, + timestamp: Timestamp, + validator_address: Bytes, + validator_index: i32, + signature: Bytes, + ) { + this.event_vote_type = event_vote_type + this.height = height + this.round = round + this.block_id = block_id + this.timestamp = timestamp + this.validator_address = validator_address + this.validator_index = validator_index + this.signature = signature + } + } + + export class Evidence { + public duplicate_vote_evidence: DuplicateVoteEvidence + public light_client_attack_evidence: LightClientAttackEvidence + + constructor( + duplicate_vote_evidence: DuplicateVoteEvidence, + light_client_attack_evidence: LightClientAttackEvidence, + ) { + this.duplicate_vote_evidence = duplicate_vote_evidence + this.light_client_attack_evidence = light_client_attack_evidence + } + } + + export class EvidenceList { + public evidence: Array + + constructor(evidence: Array) { + this.evidence = evidence + } + } + + export class EvidenceParams { + public max_age_num_blocks: i64 + public max_age_duration: Duration + public max_bytes: i64 + + constructor(max_age_num_blocks: i64, max_age_duration: Duration, max_bytes: i64) { + this.max_age_num_blocks = max_age_num_blocks + this.max_age_duration = max_age_duration + this.max_bytes = max_bytes + } + } + + export class Header { + public version: Consensus + public chain_id: string + public height: u64 + public time: Timestamp + public last_block_id: BlockID + public last_commit_hash: Bytes + public data_hash: Bytes + public validators_hash: Bytes + public next_validators_hash: Bytes + public consensus_hash: Bytes + public app_hash: Bytes + public last_results_hash: Bytes + public evidence_hash: Bytes + public proposer_address: Bytes + + constructor( + version: Consensus, + chain_id: string, + height: u64, + time: Timestamp, + last_block_id: BlockID, + last_commit_hash: Bytes, + data_hash: Bytes, + validators_hash: Bytes, + next_validators_hash: Bytes, + consensus_hash: Bytes, + app_hash: Bytes, + last_results_hash: Bytes, + evidence_hash: Bytes, + proposer_address: Bytes, + ) { + this.version = version + this.chain_id = chain_id + this.height = height + this.time = time + this.last_block_id = last_block_id + this.last_commit_hash = last_commit_hash + this.data_hash = data_hash + this.validators_hash = validators_hash + this.next_validators_hash = next_validators_hash + this.consensus_hash = consensus_hash + this.app_hash = app_hash + this.last_results_hash = last_results_hash + this.evidence_hash = evidence_hash + this.proposer_address = proposer_address + } + } + + export class LightBlock { + public signed_header: SignedHeader + public validator_set: ValidatorSet + + constructor(signed_header: SignedHeader, validator_set: ValidatorSet) { + this.signed_header = signed_header + this.validator_set = validator_set + } + } + + export class LightClientAttackEvidence { + public conflicting_block: LightBlock + public common_height: i64 + public byzantine_validators: Array + public total_voting_power: i64 + public timestamp: Timestamp + + constructor( + conflicting_block: LightBlock, + common_height: i64, + byzantine_validators: Array, + total_voting_power: i64, + timestamp: Timestamp, + ) { + this.conflicting_block = conflicting_block + this.common_height = common_height + this.byzantine_validators = byzantine_validators + this.total_voting_power = total_voting_power + this.timestamp = timestamp + } + } + + export class PublicKey { + public ed25519: Bytes + public secp256k1: Bytes + + constructor(ed25519: Bytes, secp256k1: Bytes) { + this.ed25519 = ed25519 + this.secp256k1 = secp256k1 + } + } + + export class PartSetHeader { + public total: u32 + public hash: Bytes + + constructor(total: u32, hash: Bytes) { + this.total = total + this.hash = hash + } + } + + export class ResponseBeginBlock { + public events: Array + + constructor(events: Array) { + this.events = events + } + } + + export class ResponseEndBlock { + public validator_updates: Array + public consensus_param_updates: ConsensusParams + public events: Array + + constructor( + validator_updates: Array, + consensus_param_updates: ConsensusParams, + events: Array, + ) { + this.validator_updates = validator_updates + this.consensus_param_updates = consensus_param_updates + this.events = events + } + } + + export class ResponseDeliverTx { + public code: u32 + public data: Bytes + public log: string + public info: string + public gas_wanted: i64 + public gas_used: i64 + public events: Array + public codespace: string + + constructor( + code: u32, + data: Bytes, + log: string, + info: string, + gas_wanted: i64, + gas_used: i64, + events: Array, + codespace: string, + ) { + this.code = code + this.data = data + this.log = log + this.info = info + this.gas_wanted = gas_wanted + this.gas_used = gas_used + this.events = events + this.codespace = codespace + } + } + + export class Reward { + public amount: string + public validator: string + + constructor(amount: string, validator: string) { + this.amount = amount + this.validator = validator + } + } + + export class SignedHeader { + public header: Header + public commit: Commit + + constructor(header: Header, commit: Commit) { + this.header = header + this.commit = commit + } + } + + export class Timestamp { + public seconds: i64 + public nanos: i32 + + constructor(seconds: i64, nanos: i32) { + this.seconds = seconds + this.nanos = nanos + } + } + + export class TxResult { + public height: u64 + public index: u32 + public tx: Bytes + public result: ResponseDeliverTx + + constructor(height: u64, index: u32, tx: Bytes, result: ResponseDeliverTx) { + this.height = height + this.index = index + this.tx = tx + this.result = result + } + } + + export class Validator { + public address: Bytes + public pub_key: PublicKey + public voting_power: i64 + public proposer_priority: i64 + + constructor( + address: Bytes, + pub_key: PublicKey, + voting_power: i64, + proposer_priority: i64, + ) { + this.address = address + this.pub_key = pub_key + this.voting_power = voting_power + this.proposer_priority = proposer_priority + } + } + + export class ValidatorParams { + public pub_key_types: Array + + constructor(pub_key_types: Array) { + this.pub_key_types = pub_key_types + } + } + + export class ValidatorSet { + public validators: Array + public proposer: Validator + public total_voting_power: i64 + + constructor( + validators: Array, + proposer: Validator, + total_voting_power: i64, + ) { + this.validators = validators + this.proposer = proposer + this.total_voting_power = total_voting_power + } + } + + export class ValidatorUpdate { + public address: Bytes + public pub_key: PublicKey + public power: i64 + + constructor(address: Bytes, pub_key: PublicKey, power: i64) { + this.address = address + this.pub_key = pub_key + this.power = power + } + } + + export class VersionParams { + public app_version: u64 + + constructor(app_version: u64) { + this.app_version = app_version + } + } } From 753ba7d780cea6defb7b78fbaec4b6b6b273b7f6 Mon Sep 17 00:00:00 2001 From: Patrycja Zawadka Date: Thu, 20 Jan 2022 16:42:52 +0100 Subject: [PATCH 08/12] Move responses to the top --- chain/tendermint.ts | 72 ++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/chain/tendermint.ts b/chain/tendermint.ts index 24b8de5..c6e9653 100644 --- a/chain/tendermint.ts +++ b/chain/tendermint.ts @@ -16,6 +16,42 @@ export namespace tendermint { BLOCK_ID_FLAG_NIL = 3, } + export class EventData { + public event: Event + public block: EventList + + constructor(event: Event, block: EventList) { + this.event = event + this.block = block + } + } + + export class EventList { + public new_block: EventBlock + public transaction: Array + public validator_set_updates: EventValidatorSetUpdates + + constructor( + new_block: EventBlock, + transaction: Array, + validator_set_updates: EventValidatorSetUpdates, + ) { + this.new_block = new_block + this.transaction = transaction + this.validator_set_updates = validator_set_updates + } + } + + export class Reward { + public amount: string + public validator: string + + constructor(amount: string, validator: string) { + this.amount = amount + this.validator = validator + } + } + export class Block { public header: Header public data: Data @@ -198,32 +234,6 @@ export namespace tendermint { } } - export class EventData { - public event: Event - public block: EventList - - constructor(event: Event, block: EventList) { - this.event = event - this.block = block - } - } - - export class EventList { - public new_block: EventBlock - public transaction: Array - public validator_set_updates: EventValidatorSetUpdates - - constructor( - new_block: EventBlock, - transaction: Array, - validator_set_updates: EventValidatorSetUpdates, - ) { - this.new_block = new_block - this.transaction = transaction - this.validator_set_updates = validator_set_updates - } - } - export class EventTx { public tx_result: TxResult @@ -460,16 +470,6 @@ export namespace tendermint { } } - export class Reward { - public amount: string - public validator: string - - constructor(amount: string, validator: string) { - this.amount = amount - this.validator = validator - } - } - export class SignedHeader { public header: Header public commit: Commit From 9cec0f74d0b39c8c5a17da2987e0107a48065cfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Pie=C5=84kowski?= Date: Tue, 25 Jan 2022 22:01:44 +0100 Subject: [PATCH 09/12] Use camel case in Tendermint definitions --- chain/tendermint.ts | 558 +++++++++++++++++++++++++------------------- 1 file changed, 316 insertions(+), 242 deletions(-) diff --git a/chain/tendermint.ts b/chain/tendermint.ts index c6e9653..1a15712 100644 --- a/chain/tendermint.ts +++ b/chain/tendermint.ts @@ -2,6 +2,7 @@ import '../common/eager_offset' import { Bytes } from '../common/collections' export namespace tendermint { + export enum SignedMsgType { SIGNED_MSG_TYPE_UNKNOWN = 0, SIGNED_MSG_TYPE_PREVOTE = 1, @@ -18,27 +19,30 @@ export namespace tendermint { export class EventData { public event: Event - public block: EventList + public blockHeader: Header - constructor(event: Event, block: EventList) { - this.event = event - this.block = block + constructor( + event: Event, + blockHeader: Header, + ) { + this.event = event; + this.blockHeader = blockHeader; } } export class EventList { - public new_block: EventBlock + public newBlock: EventBlock public transaction: Array - public validator_set_updates: EventValidatorSetUpdates + public validatorSetUpdates: EventValidatorSetUpdates constructor( - new_block: EventBlock, + newBlock: EventBlock, transaction: Array, - validator_set_updates: EventValidatorSetUpdates, + validatorSetUpdates: EventValidatorSetUpdates, ) { - this.new_block = new_block - this.transaction = transaction - this.validator_set_updates = validator_set_updates + this.newBlock = newBlock; + this.transaction = transaction; + this.validatorSetUpdates = validatorSetUpdates; } } @@ -46,9 +50,12 @@ export namespace tendermint { public amount: string public validator: string - constructor(amount: string, validator: string) { - this.amount = amount - this.validator = validator + constructor( + amount: string, + validator: string, + ) { + this.amount = amount; + this.validator = validator; } } @@ -56,71 +63,82 @@ export namespace tendermint { public header: Header public data: Data public evidence: EvidenceList - public last_commit: Commit + public lastCommit: Commit - constructor(header: Header, data: Data, evidence: EvidenceList, last_commit: Commit) { - this.header = header - this.data = data - this.evidence = evidence - this.last_commit = last_commit + constructor( + header: Header, + data: Data, + evidence: EvidenceList, + lastCommit: Commit, + ) { + this.header = header; + this.data = data; + this.evidence = evidence; + this.lastCommit = lastCommit; } } export class BlockID { public hash: Bytes - public part_set_header: PartSetHeader + public partSetHeader: PartSetHeader - constructor(hash: Bytes, part_set_header: PartSetHeader) { - this.hash = hash - this.part_set_header = part_set_header + constructor( + hash: Bytes, + partSetHeader: PartSetHeader, + ) { + this.hash = hash; + this.partSetHeader = partSetHeader; } } export class BlockParams { - public max_bytes: i64 - public max_gas: i64 + public maxBytes: i64 + public maxGas: i64 - constructor(max_bytes: i64, max_gas: i64) { - this.max_bytes = max_bytes - this.max_gas = max_gas + constructor( + maxBytes: i64, + maxGas: i64, + ) { + this.maxBytes = maxBytes; + this.maxGas = maxGas; } } export class Commit { public height: i64 public round: i32 - public block_id: BlockID + public blockId: BlockID public signatures: Array constructor( height: i64, round: i32, - block_id: BlockID, + blockId: BlockID, signatures: Array, ) { - this.height = height - this.round = round - this.block_id = block_id - this.signatures = signatures + this.height = height; + this.round = round; + this.blockId = blockId; + this.signatures = signatures; } } export class CommitSig { - public block_id_flag: BlockIDFlag - public validator_address: Bytes + public blockIdFlag: BlockIDFlag + public validatorAddress: Bytes public timestamp: Timestamp public signature: Bytes constructor( - block_id_flag: BlockIDFlag, - validator_address: Bytes, + blockIdFlag: BlockIDFlag, + validatorAddress: Bytes, timestamp: Timestamp, signature: Bytes, ) { - this.block_id_flag = block_id_flag - this.validator_address = validator_address - this.timestamp = timestamp - this.signature = signature + this.blockIdFlag = blockIdFlag; + this.validatorAddress = validatorAddress; + this.timestamp = timestamp; + this.signature = signature; } } @@ -128,9 +146,12 @@ export namespace tendermint { public block: u64 public app: u64 - constructor(block: u64, app: u64) { - this.block = block - this.app = app + constructor( + block: u64, + app: u64, + ) { + this.block = block; + this.app = app; } } @@ -146,18 +167,20 @@ export namespace tendermint { validator: ValidatorParams, version: VersionParams, ) { - this.block = block - this.evidence = evidence - this.validator = validator - this.version = version + this.block = block; + this.evidence = evidence; + this.validator = validator; + this.version = version; } } export class Data { public txs: Array - constructor(txs: Array) { - this.txs = txs + constructor( + txs: Array, + ) { + this.txs = txs; } } @@ -165,41 +188,47 @@ export namespace tendermint { public seconds: i64 public nanos: i32 - constructor(seconds: i64, nanos: i32) { - this.seconds = seconds - this.nanos = nanos + constructor( + seconds: i64, + nanos: i32, + ) { + this.seconds = seconds; + this.nanos = nanos; } } export class DuplicateVoteEvidence { - public vote_a: EventVote - public vote_b: EventVote - public total_voting_power: i64 - public validator_power: i64 + public voteA: EventVote + public voteB: EventVote + public totalVotingPower: i64 + public validatorPower: i64 public timestamp: Timestamp constructor( - vote_a: EventVote, - vote_b: EventVote, - total_voting_power: i64, - validator_power: i64, + voteA: EventVote, + voteB: EventVote, + totalVotingPower: i64, + validatorPower: i64, timestamp: Timestamp, ) { - this.vote_a = vote_a - this.vote_b = vote_b - this.total_voting_power = total_voting_power - this.validator_power = validator_power - this.timestamp = timestamp + this.voteA = voteA; + this.voteB = voteB; + this.totalVotingPower = totalVotingPower; + this.validatorPower = validatorPower; + this.timestamp = timestamp; } } export class Event { - public event_type: string + public eventType: string public attributes: Array - constructor(event_type: string, attributes: Array) { - this.event_type = event_type - this.attributes = attributes + constructor( + eventType: string, + attributes: Array, + ) { + this.eventType = eventType; + this.attributes = attributes; } } @@ -208,190 +237,207 @@ export namespace tendermint { public value: string public index: bool - constructor(key: string, value: string, index: bool) { - this.key = key - this.value = value - this.index = index + constructor( + key: string, + value: string, + index: bool, + ) { + this.key = key; + this.value = value; + this.index = index; } } export class EventBlock { public block: Block - public block_id: BlockID - public result_begin_block: ResponseBeginBlock - public result_end_block: ResponseEndBlock + public blockId: BlockID + public resultBeginBlock: ResponseBeginBlock + public resultEndBlock: ResponseEndBlock constructor( block: Block, - block_id: BlockID, - result_begin_block: ResponseBeginBlock, - result_end_block: ResponseEndBlock, + blockId: BlockID, + resultBeginBlock: ResponseBeginBlock, + resultEndBlock: ResponseEndBlock, ) { - this.block = block - this.block_id = block_id - this.result_begin_block = result_begin_block - this.result_end_block = result_end_block + this.block = block; + this.blockId = blockId; + this.resultBeginBlock = resultBeginBlock; + this.resultEndBlock = resultEndBlock; } } export class EventTx { - public tx_result: TxResult + public txResult: TxResult - constructor(tx_result: TxResult) { - this.tx_result = tx_result + constructor( + txResult: TxResult, + ) { + this.txResult = txResult; } } export class EventValidatorSetUpdates { - public validator_updates: Array + public validatorUpdates: Array - constructor(validator_updates: Array) { - this.validator_updates = validator_updates + constructor( + validatorUpdates: Array, + ) { + this.validatorUpdates = validatorUpdates; } } export class EventVote { - public event_vote_type: SignedMsgType + public eventVoteType: SignedMsgType public height: u64 public round: i32 - public block_id: BlockID + public blockId: BlockID public timestamp: Timestamp - public validator_address: Bytes - public validator_index: i32 + public validatorAddress: Bytes + public validatorIndex: i32 public signature: Bytes constructor( - event_vote_type: SignedMsgType, + eventVoteType: SignedMsgType, height: u64, round: i32, - block_id: BlockID, + blockId: BlockID, timestamp: Timestamp, - validator_address: Bytes, - validator_index: i32, + validatorAddress: Bytes, + validatorIndex: i32, signature: Bytes, ) { - this.event_vote_type = event_vote_type - this.height = height - this.round = round - this.block_id = block_id - this.timestamp = timestamp - this.validator_address = validator_address - this.validator_index = validator_index - this.signature = signature + this.eventVoteType = eventVoteType; + this.height = height; + this.round = round; + this.blockId = blockId; + this.timestamp = timestamp; + this.validatorAddress = validatorAddress; + this.validatorIndex = validatorIndex; + this.signature = signature; } } export class Evidence { - public duplicate_vote_evidence: DuplicateVoteEvidence - public light_client_attack_evidence: LightClientAttackEvidence + public duplicateVoteEvidence: DuplicateVoteEvidence + public lightClientAttackEvidence: LightClientAttackEvidence constructor( - duplicate_vote_evidence: DuplicateVoteEvidence, - light_client_attack_evidence: LightClientAttackEvidence, + duplicateVoteEvidence: DuplicateVoteEvidence, + lightClientAttackEvidence: LightClientAttackEvidence, ) { - this.duplicate_vote_evidence = duplicate_vote_evidence - this.light_client_attack_evidence = light_client_attack_evidence + this.duplicateVoteEvidence = duplicateVoteEvidence; + this.lightClientAttackEvidence = lightClientAttackEvidence; } } export class EvidenceList { public evidence: Array - constructor(evidence: Array) { - this.evidence = evidence + constructor( + evidence: Array, + ) { + this.evidence = evidence; } } export class EvidenceParams { - public max_age_num_blocks: i64 - public max_age_duration: Duration - public max_bytes: i64 + public maxAgeNumBlocks: i64 + public maxAgeDuration: Duration + public maxBytes: i64 - constructor(max_age_num_blocks: i64, max_age_duration: Duration, max_bytes: i64) { - this.max_age_num_blocks = max_age_num_blocks - this.max_age_duration = max_age_duration - this.max_bytes = max_bytes + constructor( + maxAgeNumBlocks: i64, + maxAgeDuration: Duration, + maxBytes: i64, + ) { + this.maxAgeNumBlocks = maxAgeNumBlocks; + this.maxAgeDuration = maxAgeDuration; + this.maxBytes = maxBytes; } } export class Header { public version: Consensus - public chain_id: string + public chainId: string public height: u64 public time: Timestamp - public last_block_id: BlockID - public last_commit_hash: Bytes - public data_hash: Bytes - public validators_hash: Bytes - public next_validators_hash: Bytes - public consensus_hash: Bytes - public app_hash: Bytes - public last_results_hash: Bytes - public evidence_hash: Bytes - public proposer_address: Bytes + public lastBlockId: BlockID + public lastCommitHash: Bytes + public dataHash: Bytes + public validatorsHash: Bytes + public nextValidatorsHash: Bytes + public consensusHash: Bytes + public appHash: Bytes + public lastResultsHash: Bytes + public evidenceHash: Bytes + public proposerAddress: Bytes constructor( version: Consensus, - chain_id: string, + chainId: string, height: u64, time: Timestamp, - last_block_id: BlockID, - last_commit_hash: Bytes, - data_hash: Bytes, - validators_hash: Bytes, - next_validators_hash: Bytes, - consensus_hash: Bytes, - app_hash: Bytes, - last_results_hash: Bytes, - evidence_hash: Bytes, - proposer_address: Bytes, - ) { - this.version = version - this.chain_id = chain_id - this.height = height - this.time = time - this.last_block_id = last_block_id - this.last_commit_hash = last_commit_hash - this.data_hash = data_hash - this.validators_hash = validators_hash - this.next_validators_hash = next_validators_hash - this.consensus_hash = consensus_hash - this.app_hash = app_hash - this.last_results_hash = last_results_hash - this.evidence_hash = evidence_hash - this.proposer_address = proposer_address + lastBlockId: BlockID, + lastCommitHash: Bytes, + dataHash: Bytes, + validatorsHash: Bytes, + nextValidatorsHash: Bytes, + consensusHash: Bytes, + appHash: Bytes, + lastResultsHash: Bytes, + evidenceHash: Bytes, + proposerAddress: Bytes, + ) { + this.version = version; + this.chainId = chainId; + this.height = height; + this.time = time; + this.lastBlockId = lastBlockId; + this.lastCommitHash = lastCommitHash; + this.dataHash = dataHash; + this.validatorsHash = validatorsHash; + this.nextValidatorsHash = nextValidatorsHash; + this.consensusHash = consensusHash; + this.appHash = appHash; + this.lastResultsHash = lastResultsHash; + this.evidenceHash = evidenceHash; + this.proposerAddress = proposerAddress; } } export class LightBlock { - public signed_header: SignedHeader - public validator_set: ValidatorSet + public signedHeader: SignedHeader + public validatorSet: ValidatorSet - constructor(signed_header: SignedHeader, validator_set: ValidatorSet) { - this.signed_header = signed_header - this.validator_set = validator_set + constructor( + signedHeader: SignedHeader, + validatorSet: ValidatorSet, + ) { + this.signedHeader = signedHeader; + this.validatorSet = validatorSet; } } export class LightClientAttackEvidence { - public conflicting_block: LightBlock - public common_height: i64 - public byzantine_validators: Array - public total_voting_power: i64 + public conflictingBlock: LightBlock + public commonHeight: i64 + public byzantineValidators: Array + public totalVotingPower: i64 public timestamp: Timestamp constructor( - conflicting_block: LightBlock, - common_height: i64, - byzantine_validators: Array, - total_voting_power: i64, + conflictingBlock: LightBlock, + commonHeight: i64, + byzantineValidators: Array, + totalVotingPower: i64, timestamp: Timestamp, ) { - this.conflicting_block = conflicting_block - this.common_height = common_height - this.byzantine_validators = byzantine_validators - this.total_voting_power = total_voting_power - this.timestamp = timestamp + this.conflictingBlock = conflictingBlock; + this.commonHeight = commonHeight; + this.byzantineValidators = byzantineValidators; + this.totalVotingPower = totalVotingPower; + this.timestamp = timestamp; } } @@ -399,9 +445,12 @@ export namespace tendermint { public ed25519: Bytes public secp256k1: Bytes - constructor(ed25519: Bytes, secp256k1: Bytes) { - this.ed25519 = ed25519 - this.secp256k1 = secp256k1 + constructor( + ed25519: Bytes, + secp256k1: Bytes, + ) { + this.ed25519 = ed25519; + this.secp256k1 = secp256k1; } } @@ -409,33 +458,38 @@ export namespace tendermint { public total: u32 public hash: Bytes - constructor(total: u32, hash: Bytes) { - this.total = total - this.hash = hash + constructor( + total: u32, + hash: Bytes, + ) { + this.total = total; + this.hash = hash; } } export class ResponseBeginBlock { public events: Array - constructor(events: Array) { - this.events = events + constructor( + events: Array, + ) { + this.events = events; } } export class ResponseEndBlock { - public validator_updates: Array - public consensus_param_updates: ConsensusParams + public validatorUpdates: Array + public consensusParamUpdates: ConsensusParams public events: Array constructor( - validator_updates: Array, - consensus_param_updates: ConsensusParams, + validatorUpdates: Array, + consensusParamUpdates: ConsensusParams, events: Array, ) { - this.validator_updates = validator_updates - this.consensus_param_updates = consensus_param_updates - this.events = events + this.validatorUpdates = validatorUpdates; + this.consensusParamUpdates = consensusParamUpdates; + this.events = events; } } @@ -444,8 +498,8 @@ export namespace tendermint { public data: Bytes public log: string public info: string - public gas_wanted: i64 - public gas_used: i64 + public gasWanted: i64 + public gasUsed: i64 public events: Array public codespace: string @@ -454,19 +508,19 @@ export namespace tendermint { data: Bytes, log: string, info: string, - gas_wanted: i64, - gas_used: i64, + gasWanted: i64, + gasUsed: i64, events: Array, codespace: string, ) { - this.code = code - this.data = data - this.log = log - this.info = info - this.gas_wanted = gas_wanted - this.gas_used = gas_used - this.events = events - this.codespace = codespace + this.code = code; + this.data = data; + this.log = log; + this.info = info; + this.gasWanted = gasWanted; + this.gasUsed = gasUsed; + this.events = events; + this.codespace = codespace; } } @@ -474,9 +528,12 @@ export namespace tendermint { public header: Header public commit: Commit - constructor(header: Header, commit: Commit) { - this.header = header - this.commit = commit + constructor( + header: Header, + commit: Commit, + ) { + this.header = header; + this.commit = commit; } } @@ -484,9 +541,12 @@ export namespace tendermint { public seconds: i64 public nanos: i32 - constructor(seconds: i64, nanos: i32) { - this.seconds = seconds - this.nanos = nanos + constructor( + seconds: i64, + nanos: i32, + ) { + this.seconds = seconds; + this.nanos = nanos; } } @@ -496,74 +556,88 @@ export namespace tendermint { public tx: Bytes public result: ResponseDeliverTx - constructor(height: u64, index: u32, tx: Bytes, result: ResponseDeliverTx) { - this.height = height - this.index = index - this.tx = tx - this.result = result + constructor( + height: u64, + index: u32, + tx: Bytes, + result: ResponseDeliverTx, + ) { + this.height = height; + this.index = index; + this.tx = tx; + this.result = result; } } export class Validator { public address: Bytes - public pub_key: PublicKey - public voting_power: i64 - public proposer_priority: i64 + public pubKey: PublicKey + public votingPower: i64 + public proposerPriority: i64 constructor( address: Bytes, - pub_key: PublicKey, - voting_power: i64, - proposer_priority: i64, + pubKey: PublicKey, + votingPower: i64, + proposerPriority: i64, ) { - this.address = address - this.pub_key = pub_key - this.voting_power = voting_power - this.proposer_priority = proposer_priority + this.address = address; + this.pubKey = pubKey; + this.votingPower = votingPower; + this.proposerPriority = proposerPriority; } } export class ValidatorParams { - public pub_key_types: Array + public pubKeyTypes: Array - constructor(pub_key_types: Array) { - this.pub_key_types = pub_key_types + constructor( + pubKeyTypes: Array, + ) { + this.pubKeyTypes = pubKeyTypes; } } export class ValidatorSet { public validators: Array public proposer: Validator - public total_voting_power: i64 + public totalVotingPower: i64 constructor( validators: Array, proposer: Validator, - total_voting_power: i64, + totalVotingPower: i64, ) { - this.validators = validators - this.proposer = proposer - this.total_voting_power = total_voting_power + this.validators = validators; + this.proposer = proposer; + this.totalVotingPower = totalVotingPower; } } export class ValidatorUpdate { public address: Bytes - public pub_key: PublicKey + public pubKey: PublicKey public power: i64 - constructor(address: Bytes, pub_key: PublicKey, power: i64) { - this.address = address - this.pub_key = pub_key - this.power = power + constructor( + address: Bytes, + pubKey: PublicKey, + power: i64, + ) { + this.address = address; + this.pubKey = pubKey; + this.power = power; } } export class VersionParams { - public app_version: u64 + public appVersion: u64 - constructor(app_version: u64) { - this.app_version = app_version + constructor( + appVersion: u64, + ) { + this.appVersion = appVersion; } } + } From f6bec1b06c2e56113331da73dfe7266b6ba8f8e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Pie=C5=84kowski?= Date: Fri, 28 Jan 2022 15:59:01 +0100 Subject: [PATCH 10/12] Update the `EventData` type --- chain/tendermint.ts | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/chain/tendermint.ts b/chain/tendermint.ts index 1a15712..9fa2cd2 100644 --- a/chain/tendermint.ts +++ b/chain/tendermint.ts @@ -17,19 +17,6 @@ export namespace tendermint { BLOCK_ID_FLAG_NIL = 3, } - export class EventData { - public event: Event - public blockHeader: Header - - constructor( - event: Event, - blockHeader: Header, - ) { - this.event = event; - this.blockHeader = blockHeader; - } - } - export class EventList { public newBlock: EventBlock public transaction: Array @@ -46,16 +33,16 @@ export namespace tendermint { } } - export class Reward { - public amount: string - public validator: string + export class EventData { + public event: Event + public block: EventBlock constructor( - amount: string, - validator: string, + event: Event, + block: EventBlock, ) { - this.amount = amount; - this.validator = validator; + this.event = event; + this.block = block; } } From e22f9f9932f001f91df0c8d83ce7be27e6b8d748 Mon Sep 17 00:00:00 2001 From: Mark Preston Date: Wed, 2 Feb 2022 13:42:53 +0000 Subject: [PATCH 11/12] fixes linting errors --- chain/tendermint.ts | 358 +++++++++++++++++--------------------------- global/global.ts | 9 +- 2 files changed, 149 insertions(+), 218 deletions(-) diff --git a/chain/tendermint.ts b/chain/tendermint.ts index 9fa2cd2..faf6ca5 100644 --- a/chain/tendermint.ts +++ b/chain/tendermint.ts @@ -2,7 +2,6 @@ import '../common/eager_offset' import { Bytes } from '../common/collections' export namespace tendermint { - export enum SignedMsgType { SIGNED_MSG_TYPE_UNKNOWN = 0, SIGNED_MSG_TYPE_PREVOTE = 1, @@ -27,9 +26,9 @@ export namespace tendermint { transaction: Array, validatorSetUpdates: EventValidatorSetUpdates, ) { - this.newBlock = newBlock; - this.transaction = transaction; - this.validatorSetUpdates = validatorSetUpdates; + this.newBlock = newBlock + this.transaction = transaction + this.validatorSetUpdates = validatorSetUpdates } } @@ -37,12 +36,9 @@ export namespace tendermint { public event: Event public block: EventBlock - constructor( - event: Event, - block: EventBlock, - ) { - this.event = event; - this.block = block; + constructor(event: Event, block: EventBlock) { + this.event = event + this.block = block } } @@ -52,16 +48,11 @@ export namespace tendermint { public evidence: EvidenceList public lastCommit: Commit - constructor( - header: Header, - data: Data, - evidence: EvidenceList, - lastCommit: Commit, - ) { - this.header = header; - this.data = data; - this.evidence = evidence; - this.lastCommit = lastCommit; + constructor(header: Header, data: Data, evidence: EvidenceList, lastCommit: Commit) { + this.header = header + this.data = data + this.evidence = evidence + this.lastCommit = lastCommit } } @@ -69,12 +60,9 @@ export namespace tendermint { public hash: Bytes public partSetHeader: PartSetHeader - constructor( - hash: Bytes, - partSetHeader: PartSetHeader, - ) { - this.hash = hash; - this.partSetHeader = partSetHeader; + constructor(hash: Bytes, partSetHeader: PartSetHeader) { + this.hash = hash + this.partSetHeader = partSetHeader } } @@ -82,12 +70,9 @@ export namespace tendermint { public maxBytes: i64 public maxGas: i64 - constructor( - maxBytes: i64, - maxGas: i64, - ) { - this.maxBytes = maxBytes; - this.maxGas = maxGas; + constructor(maxBytes: i64, maxGas: i64) { + this.maxBytes = maxBytes + this.maxGas = maxGas } } @@ -97,16 +82,11 @@ export namespace tendermint { public blockId: BlockID public signatures: Array - constructor( - height: i64, - round: i32, - blockId: BlockID, - signatures: Array, - ) { - this.height = height; - this.round = round; - this.blockId = blockId; - this.signatures = signatures; + constructor(height: i64, round: i32, blockId: BlockID, signatures: Array) { + this.height = height + this.round = round + this.blockId = blockId + this.signatures = signatures } } @@ -122,10 +102,10 @@ export namespace tendermint { timestamp: Timestamp, signature: Bytes, ) { - this.blockIdFlag = blockIdFlag; - this.validatorAddress = validatorAddress; - this.timestamp = timestamp; - this.signature = signature; + this.blockIdFlag = blockIdFlag + this.validatorAddress = validatorAddress + this.timestamp = timestamp + this.signature = signature } } @@ -133,12 +113,9 @@ export namespace tendermint { public block: u64 public app: u64 - constructor( - block: u64, - app: u64, - ) { - this.block = block; - this.app = app; + constructor(block: u64, app: u64) { + this.block = block + this.app = app } } @@ -154,20 +131,18 @@ export namespace tendermint { validator: ValidatorParams, version: VersionParams, ) { - this.block = block; - this.evidence = evidence; - this.validator = validator; - this.version = version; + this.block = block + this.evidence = evidence + this.validator = validator + this.version = version } } export class Data { public txs: Array - constructor( - txs: Array, - ) { - this.txs = txs; + constructor(txs: Array) { + this.txs = txs } } @@ -175,12 +150,9 @@ export namespace tendermint { public seconds: i64 public nanos: i32 - constructor( - seconds: i64, - nanos: i32, - ) { - this.seconds = seconds; - this.nanos = nanos; + constructor(seconds: i64, nanos: i32) { + this.seconds = seconds + this.nanos = nanos } } @@ -198,11 +170,11 @@ export namespace tendermint { validatorPower: i64, timestamp: Timestamp, ) { - this.voteA = voteA; - this.voteB = voteB; - this.totalVotingPower = totalVotingPower; - this.validatorPower = validatorPower; - this.timestamp = timestamp; + this.voteA = voteA + this.voteB = voteB + this.totalVotingPower = totalVotingPower + this.validatorPower = validatorPower + this.timestamp = timestamp } } @@ -210,12 +182,9 @@ export namespace tendermint { public eventType: string public attributes: Array - constructor( - eventType: string, - attributes: Array, - ) { - this.eventType = eventType; - this.attributes = attributes; + constructor(eventType: string, attributes: Array) { + this.eventType = eventType + this.attributes = attributes } } @@ -224,14 +193,10 @@ export namespace tendermint { public value: string public index: bool - constructor( - key: string, - value: string, - index: bool, - ) { - this.key = key; - this.value = value; - this.index = index; + constructor(key: string, value: string, index: bool) { + this.key = key + this.value = value + this.index = index } } @@ -247,30 +212,26 @@ export namespace tendermint { resultBeginBlock: ResponseBeginBlock, resultEndBlock: ResponseEndBlock, ) { - this.block = block; - this.blockId = blockId; - this.resultBeginBlock = resultBeginBlock; - this.resultEndBlock = resultEndBlock; + this.block = block + this.blockId = blockId + this.resultBeginBlock = resultBeginBlock + this.resultEndBlock = resultEndBlock } } export class EventTx { public txResult: TxResult - constructor( - txResult: TxResult, - ) { - this.txResult = txResult; + constructor(txResult: TxResult) { + this.txResult = txResult } } export class EventValidatorSetUpdates { public validatorUpdates: Array - constructor( - validatorUpdates: Array, - ) { - this.validatorUpdates = validatorUpdates; + constructor(validatorUpdates: Array) { + this.validatorUpdates = validatorUpdates } } @@ -294,14 +255,14 @@ export namespace tendermint { validatorIndex: i32, signature: Bytes, ) { - this.eventVoteType = eventVoteType; - this.height = height; - this.round = round; - this.blockId = blockId; - this.timestamp = timestamp; - this.validatorAddress = validatorAddress; - this.validatorIndex = validatorIndex; - this.signature = signature; + this.eventVoteType = eventVoteType + this.height = height + this.round = round + this.blockId = blockId + this.timestamp = timestamp + this.validatorAddress = validatorAddress + this.validatorIndex = validatorIndex + this.signature = signature } } @@ -313,18 +274,16 @@ export namespace tendermint { duplicateVoteEvidence: DuplicateVoteEvidence, lightClientAttackEvidence: LightClientAttackEvidence, ) { - this.duplicateVoteEvidence = duplicateVoteEvidence; - this.lightClientAttackEvidence = lightClientAttackEvidence; + this.duplicateVoteEvidence = duplicateVoteEvidence + this.lightClientAttackEvidence = lightClientAttackEvidence } } export class EvidenceList { public evidence: Array - constructor( - evidence: Array, - ) { - this.evidence = evidence; + constructor(evidence: Array) { + this.evidence = evidence } } @@ -333,14 +292,10 @@ export namespace tendermint { public maxAgeDuration: Duration public maxBytes: i64 - constructor( - maxAgeNumBlocks: i64, - maxAgeDuration: Duration, - maxBytes: i64, - ) { - this.maxAgeNumBlocks = maxAgeNumBlocks; - this.maxAgeDuration = maxAgeDuration; - this.maxBytes = maxBytes; + constructor(maxAgeNumBlocks: i64, maxAgeDuration: Duration, maxBytes: i64) { + this.maxAgeNumBlocks = maxAgeNumBlocks + this.maxAgeDuration = maxAgeDuration + this.maxBytes = maxBytes } } @@ -376,20 +331,20 @@ export namespace tendermint { evidenceHash: Bytes, proposerAddress: Bytes, ) { - this.version = version; - this.chainId = chainId; - this.height = height; - this.time = time; - this.lastBlockId = lastBlockId; - this.lastCommitHash = lastCommitHash; - this.dataHash = dataHash; - this.validatorsHash = validatorsHash; - this.nextValidatorsHash = nextValidatorsHash; - this.consensusHash = consensusHash; - this.appHash = appHash; - this.lastResultsHash = lastResultsHash; - this.evidenceHash = evidenceHash; - this.proposerAddress = proposerAddress; + this.version = version + this.chainId = chainId + this.height = height + this.time = time + this.lastBlockId = lastBlockId + this.lastCommitHash = lastCommitHash + this.dataHash = dataHash + this.validatorsHash = validatorsHash + this.nextValidatorsHash = nextValidatorsHash + this.consensusHash = consensusHash + this.appHash = appHash + this.lastResultsHash = lastResultsHash + this.evidenceHash = evidenceHash + this.proposerAddress = proposerAddress } } @@ -397,12 +352,9 @@ export namespace tendermint { public signedHeader: SignedHeader public validatorSet: ValidatorSet - constructor( - signedHeader: SignedHeader, - validatorSet: ValidatorSet, - ) { - this.signedHeader = signedHeader; - this.validatorSet = validatorSet; + constructor(signedHeader: SignedHeader, validatorSet: ValidatorSet) { + this.signedHeader = signedHeader + this.validatorSet = validatorSet } } @@ -420,11 +372,11 @@ export namespace tendermint { totalVotingPower: i64, timestamp: Timestamp, ) { - this.conflictingBlock = conflictingBlock; - this.commonHeight = commonHeight; - this.byzantineValidators = byzantineValidators; - this.totalVotingPower = totalVotingPower; - this.timestamp = timestamp; + this.conflictingBlock = conflictingBlock + this.commonHeight = commonHeight + this.byzantineValidators = byzantineValidators + this.totalVotingPower = totalVotingPower + this.timestamp = timestamp } } @@ -432,12 +384,9 @@ export namespace tendermint { public ed25519: Bytes public secp256k1: Bytes - constructor( - ed25519: Bytes, - secp256k1: Bytes, - ) { - this.ed25519 = ed25519; - this.secp256k1 = secp256k1; + constructor(ed25519: Bytes, secp256k1: Bytes) { + this.ed25519 = ed25519 + this.secp256k1 = secp256k1 } } @@ -445,22 +394,17 @@ export namespace tendermint { public total: u32 public hash: Bytes - constructor( - total: u32, - hash: Bytes, - ) { - this.total = total; - this.hash = hash; + constructor(total: u32, hash: Bytes) { + this.total = total + this.hash = hash } } export class ResponseBeginBlock { public events: Array - constructor( - events: Array, - ) { - this.events = events; + constructor(events: Array) { + this.events = events } } @@ -474,9 +418,9 @@ export namespace tendermint { consensusParamUpdates: ConsensusParams, events: Array, ) { - this.validatorUpdates = validatorUpdates; - this.consensusParamUpdates = consensusParamUpdates; - this.events = events; + this.validatorUpdates = validatorUpdates + this.consensusParamUpdates = consensusParamUpdates + this.events = events } } @@ -500,14 +444,14 @@ export namespace tendermint { events: Array, codespace: string, ) { - this.code = code; - this.data = data; - this.log = log; - this.info = info; - this.gasWanted = gasWanted; - this.gasUsed = gasUsed; - this.events = events; - this.codespace = codespace; + this.code = code + this.data = data + this.log = log + this.info = info + this.gasWanted = gasWanted + this.gasUsed = gasUsed + this.events = events + this.codespace = codespace } } @@ -515,12 +459,9 @@ export namespace tendermint { public header: Header public commit: Commit - constructor( - header: Header, - commit: Commit, - ) { - this.header = header; - this.commit = commit; + constructor(header: Header, commit: Commit) { + this.header = header + this.commit = commit } } @@ -528,12 +469,9 @@ export namespace tendermint { public seconds: i64 public nanos: i32 - constructor( - seconds: i64, - nanos: i32, - ) { - this.seconds = seconds; - this.nanos = nanos; + constructor(seconds: i64, nanos: i32) { + this.seconds = seconds + this.nanos = nanos } } @@ -543,16 +481,11 @@ export namespace tendermint { public tx: Bytes public result: ResponseDeliverTx - constructor( - height: u64, - index: u32, - tx: Bytes, - result: ResponseDeliverTx, - ) { - this.height = height; - this.index = index; - this.tx = tx; - this.result = result; + constructor(height: u64, index: u32, tx: Bytes, result: ResponseDeliverTx) { + this.height = height + this.index = index + this.tx = tx + this.result = result } } @@ -568,20 +501,18 @@ export namespace tendermint { votingPower: i64, proposerPriority: i64, ) { - this.address = address; - this.pubKey = pubKey; - this.votingPower = votingPower; - this.proposerPriority = proposerPriority; + this.address = address + this.pubKey = pubKey + this.votingPower = votingPower + this.proposerPriority = proposerPriority } } export class ValidatorParams { public pubKeyTypes: Array - constructor( - pubKeyTypes: Array, - ) { - this.pubKeyTypes = pubKeyTypes; + constructor(pubKeyTypes: Array) { + this.pubKeyTypes = pubKeyTypes } } @@ -595,9 +526,9 @@ export namespace tendermint { proposer: Validator, totalVotingPower: i64, ) { - this.validators = validators; - this.proposer = proposer; - this.totalVotingPower = totalVotingPower; + this.validators = validators + this.proposer = proposer + this.totalVotingPower = totalVotingPower } } @@ -606,25 +537,18 @@ export namespace tendermint { public pubKey: PublicKey public power: i64 - constructor( - address: Bytes, - pubKey: PublicKey, - power: i64, - ) { - this.address = address; - this.pubKey = pubKey; - this.power = power; + constructor(address: Bytes, pubKey: PublicKey, power: i64) { + this.address = address + this.pubKey = pubKey + this.power = power } } export class VersionParams { public appVersion: u64 - constructor( - appVersion: u64, - ) { - this.appVersion = appVersion; + constructor(appVersion: u64) { + this.appVersion = appVersion } } - } diff --git a/global/global.ts b/global/global.ts index e7db446..2c92773 100644 --- a/global/global.ts +++ b/global/global.ts @@ -1,5 +1,12 @@ import { BigDecimal } from '../common/numbers' -import { Bytes, TypedMapEntry, Entity, TypedMap, Result, Wrapped } from '../common/collections' +import { + Bytes, + TypedMapEntry, + Entity, + TypedMap, + Result, + Wrapped, +} from '../common/collections' import { JSONValue, Value } from '../common/value' import { ethereum } from '../chain/ethereum' import { near } from '../chain/near' From 56d24ad92c1069294edb29d185b9a5dbd653efbb Mon Sep 17 00:00:00 2001 From: Mark Preston Date: Wed, 2 Feb 2022 14:18:00 +0000 Subject: [PATCH 12/12] fixes broken tendermint tests --- test/test.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test.js b/test/test.js index 60e538c..916b05c 100644 --- a/test/test.js +++ b/test/test.js @@ -31,6 +31,7 @@ async function main() { fs.copyFileSync('common/value.ts', 'test/temp_lib/common/value.ts') fs.copyFileSync('chain/ethereum.ts', 'test/temp_lib/chain/ethereum.ts') fs.copyFileSync('chain/near.ts', 'test/temp_lib/chain/near.ts') + fs.copyFileSync('chain/tendermint.ts', 'test/temp_lib/chain/tendermint.ts') fs.copyFileSync('index.ts', 'test/temp_lib/index.ts') try { @@ -63,6 +64,7 @@ async function main() { fs.rmdirSync('test/temp_lib/common') fs.unlinkSync('test/temp_lib/chain/ethereum.ts') fs.unlinkSync('test/temp_lib/chain/near.ts') + fs.unlinkSync('test/temp_lib/chain/tendermint.ts') fs.rmdirSync('test/temp_lib/chain') fs.unlinkSync('test/temp_lib/index.ts') fs.rmdirSync('test/temp_lib')