From 843dfac927db45c9ffd7cc82082a841e292565e2 Mon Sep 17 00:00:00 2001 From: 0xa Date: Fri, 30 Apr 2021 19:30:04 +0800 Subject: [PATCH] add on chain events types for generating types of python && Fix stratum id (#2468) --- Cargo.lock | 10 +-- stratum/Cargo.toml | 8 +-- stratum/src/stratum.rs | 3 +- .../tests/staged/starcoin.yaml | 69 ++++++++++++++++++- 4 files changed, 79 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 08290c96b2..2d5fa99002 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3663,7 +3663,7 @@ dependencies = [ [[package]] name = "jsonrpc-core" version = "17.1.0" -source = "git+https://github.com/starcoinorg/jsonrpc?rev=ea1c05d445a8c9e2deef09d439674eb820489e0b#ea1c05d445a8c9e2deef09d439674eb820489e0b" +source = "git+https://github.com/starcoinorg/jsonrpc?rev=a913ce4632c1989c8fa1810823ec7c209a50d26c#a913ce4632c1989c8fa1810823ec7c209a50d26c" dependencies = [ "futures 0.3.13", "futures-executor", @@ -3699,7 +3699,7 @@ dependencies = [ [[package]] name = "jsonrpc-derive" version = "17.1.0" -source = "git+https://github.com/starcoinorg/jsonrpc?rev=ea1c05d445a8c9e2deef09d439674eb820489e0b#ea1c05d445a8c9e2deef09d439674eb820489e0b" +source = "git+https://github.com/starcoinorg/jsonrpc?rev=a913ce4632c1989c8fa1810823ec7c209a50d26c#a913ce4632c1989c8fa1810823ec7c209a50d26c" dependencies = [ "proc-macro-crate", "proc-macro2 1.0.26", @@ -3756,7 +3756,7 @@ dependencies = [ [[package]] name = "jsonrpc-pubsub" version = "17.1.0" -source = "git+https://github.com/starcoinorg/jsonrpc?rev=ea1c05d445a8c9e2deef09d439674eb820489e0b#ea1c05d445a8c9e2deef09d439674eb820489e0b" +source = "git+https://github.com/starcoinorg/jsonrpc?rev=a913ce4632c1989c8fa1810823ec7c209a50d26c#a913ce4632c1989c8fa1810823ec7c209a50d26c" dependencies = [ "futures 0.3.13", "jsonrpc-core 17.1.0", @@ -3788,7 +3788,7 @@ dependencies = [ [[package]] name = "jsonrpc-server-utils" version = "17.1.0" -source = "git+https://github.com/starcoinorg/jsonrpc?rev=ea1c05d445a8c9e2deef09d439674eb820489e0b#ea1c05d445a8c9e2deef09d439674eb820489e0b" +source = "git+https://github.com/starcoinorg/jsonrpc?rev=a913ce4632c1989c8fa1810823ec7c209a50d26c#a913ce4632c1989c8fa1810823ec7c209a50d26c" dependencies = [ "bytes 0.5.6", "futures 0.3.13", @@ -3817,7 +3817,7 @@ dependencies = [ [[package]] name = "jsonrpc-tcp-server" version = "17.1.0" -source = "git+https://github.com/starcoinorg/jsonrpc?rev=ea1c05d445a8c9e2deef09d439674eb820489e0b#ea1c05d445a8c9e2deef09d439674eb820489e0b" +source = "git+https://github.com/starcoinorg/jsonrpc?rev=a913ce4632c1989c8fa1810823ec7c209a50d26c#a913ce4632c1989c8fa1810823ec7c209a50d26c" dependencies = [ "jsonrpc-core 17.1.0", "jsonrpc-server-utils 17.1.0", diff --git a/stratum/Cargo.toml b/stratum/Cargo.toml index 190eb54eda..698a7e76f7 100644 --- a/stratum/Cargo.toml +++ b/stratum/Cargo.toml @@ -6,10 +6,10 @@ edition = "2018" [dependencies] -jsonrpc-tcp-server = { git = "https://github.com/starcoinorg/jsonrpc", rev = "ea1c05d445a8c9e2deef09d439674eb820489e0b"} -jsonrpc-derive = { git = "https://github.com/starcoinorg/jsonrpc", rev = "ea1c05d445a8c9e2deef09d439674eb820489e0b"} -jsonrpc-core = { git = "https://github.com/starcoinorg/jsonrpc", rev = "ea1c05d445a8c9e2deef09d439674eb820489e0b",features=["arbitrary_precision"]} -jsonrpc-pubsub = { git = "https://github.com/starcoinorg/jsonrpc", rev = "ea1c05d445a8c9e2deef09d439674eb820489e0b"} +jsonrpc-tcp-server = { git = "https://github.com/starcoinorg/jsonrpc", rev = "a913ce4632c1989c8fa1810823ec7c209a50d26c"} +jsonrpc-derive = { git = "https://github.com/starcoinorg/jsonrpc", rev = "a913ce4632c1989c8fa1810823ec7c209a50d26c"} +jsonrpc-core = { git = "https://github.com/starcoinorg/jsonrpc", rev = "a913ce4632c1989c8fa1810823ec7c209a50d26c",features=["arbitrary_precision"]} +jsonrpc-pubsub = { git = "https://github.com/starcoinorg/jsonrpc", rev = "a913ce4632c1989c8fa1810823ec7c209a50d26c"} serde_json = { version="1.0", features = ["arbitrary_precision"]} serde = { version = "1.0.125" } hex = { version = "0.4.3", default-features = false } diff --git a/stratum/src/stratum.rs b/stratum/src/stratum.rs index a88d3f6706..6fb11c1eca 100644 --- a/stratum/src/stratum.rs +++ b/stratum/src/stratum.rs @@ -29,7 +29,8 @@ impl Stratum { } } fn next_id(&self) -> SubscriptionId { - SubscriptionId::Number(1) + let id = self.uid.fetch_add(1, atomic::Ordering::SeqCst); + SubscriptionId::Number(id) } fn sync_current_job(&mut self) -> Result> { let service = self.miner_service.clone(); diff --git a/testsuite/generate-format/tests/staged/starcoin.yaml b/testsuite/generate-format/tests/staged/starcoin.yaml index 628e020f45..5ec83ab115 100644 --- a/testsuite/generate-format/tests/staged/starcoin.yaml +++ b/testsuite/generate-format/tests/staged/starcoin.yaml @@ -346,4 +346,71 @@ EventFilter: SEQ: TYPENAME: EventKey - limit: - OPTION: U64 \ No newline at end of file + OPTION: U64 +AcceptTokenEvent: + STRUCT: + - token_code: + TYPENAME: TokenCode +AccountAddress: + NEWTYPESTRUCT: + TUPLEARRAY: + CONTENT: U8 + SIZE: 16 +BlockRewardEvent: + STRUCT: + - block_number: U64 + - block_reward: U128 + - gas_fees: U128 + - miner: + TYPENAME: AccountAddress +BurnEvent: + STRUCT: + - amount: U128 + - token_code: + TYPENAME: TokenCode +DepositEvent: + STRUCT: + - amount: U128 + - token_code: + TYPENAME: TokenCode + - metadata: + SEQ: U8 +MintEvent: + STRUCT: + - amount: U128 + - token_code: + TYPENAME: TokenCode +NewBlockEvent: + STRUCT: + - number: U64 + - author: + TYPENAME: AccountAddress + - timestamp: U64 + - uncles: U64 +ProposalCreatedEvent: + STRUCT: + - proposal_id: U64 + - proposer: + TYPENAME: AccountAddress +TokenCode: + STRUCT: + - address: + TYPENAME: AccountAddress + - module: STR + - name: STR +VoteChangedEvent: + STRUCT: + - proposal_id: U64 + - proposer: + TYPENAME: AccountAddress + - voter: + TYPENAME: AccountAddress + - agree: BOOL + - vote: U128 +WithdrawEvent: + STRUCT: + - amount: U128 + - token_code: + TYPENAME: TokenCode + - metadata: + SEQ: U8 \ No newline at end of file