Skip to content

Commit bb31105

Browse files
authored
feat: Enables records bound to chainmaker to be correctly redirected to the browser via block. (#9)
1 parent 8ec35b3 commit bb31105

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

go.mod

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,16 @@ require (
1616
github.com/beorn7/perks v1.0.1 // indirect
1717
github.com/btcsuite/btcd v0.21.0-beta // indirect
1818
github.com/cespare/xxhash/v2 v2.1.1 // indirect
19-
github.com/fatih/color v1.9.0 // indirect
2019
github.com/fsnotify/fsnotify v1.5.1 // indirect
2120
github.com/go-sql-driver/mysql v1.5.0 // indirect
2221
github.com/gogo/protobuf v1.3.2 // indirect
2322
github.com/golang/protobuf v1.5.2 // indirect
2423
github.com/google/uuid v1.1.5 // indirect
2524
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
2625
github.com/hashicorp/hcl v1.0.0 // indirect
27-
github.com/hokaccha/go-prettyjson v0.0.0-20201222001619-a42f9ac2ec8e // indirect
2826
github.com/json-iterator/go v1.1.11 // indirect
2927
github.com/lestrrat-go/strftime v1.0.3 // indirect
3028
github.com/magiconair/properties v1.8.5 // indirect
31-
github.com/mattn/go-colorable v0.1.6 // indirect
32-
github.com/mattn/go-isatty v0.0.12 // indirect
3329
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
3430
github.com/miekg/pkcs11 v1.0.3 // indirect
3531
github.com/mitchellh/mapstructure v1.4.2 // indirect

go.sum

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ github.com/ethereum/go-ethereum v1.10.4/go.mod h1:nEE0TP5MtxGzOMd7egIrbPJMQBnhVU
207207
github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239 h1:Ghm4eQYC0nEPnSJdVkTrXpu9KtoVCSo1hg7mtI7G9KU=
208208
github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239/go.mod h1:Gdwt2ce0yfBxPvZrHkprdPPTTS3N5rwmLE8T22KBXlw=
209209
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
210-
github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s=
211210
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
212211
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
213212
github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
@@ -376,7 +375,6 @@ github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2p
376375
github.com/hashicorp/memberlist v0.2.2/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE=
377376
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
378377
github.com/hashicorp/serf v0.9.5/go.mod h1:UWDWwZeL5cuWDJdl0C6wrvrUwEqtQ4ZKBKKENpqIUyk=
379-
github.com/hokaccha/go-prettyjson v0.0.0-20201222001619-a42f9ac2ec8e h1:1vxUQ6PL1sROZtmO5IBbWKpq2y0CxjeZJl50rnen5js=
380378
github.com/hokaccha/go-prettyjson v0.0.0-20201222001619-a42f9ac2ec8e/go.mod h1:pFlLw2CfqZiIBOx6BuCeRLCrfxBJipTY0nIOF/VbGcI=
381379
github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA=
382380
github.com/holiman/uint256 v1.2.0/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw=
@@ -466,7 +464,6 @@ github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPK
466464
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
467465
github.com/mattn/go-colorable v0.1.0/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
468466
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
469-
github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE=
470467
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
471468
github.com/mattn/go-ieproxy v0.0.0-20190610004146-91bb50d98149/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc=
472469
github.com/mattn/go-ieproxy v0.0.0-20190702010315-6dee0af9227d/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc=
@@ -476,7 +473,6 @@ github.com/mattn/go-isatty v0.0.5-0.20180830101745-3fb116b82035/go.mod h1:M+lRXT
476473
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
477474
github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84=
478475
github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
479-
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
480476
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
481477
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
482478
github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=

object/chain.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ type ChainmakerInfo struct {
4646
}
4747

4848
type ChainmakerTxInfo struct {
49-
TxId string `json:"tx_id"`
50-
Block string `json:"block"`
51-
Result string `json:"result"`
49+
TxId string `json:"tx_id"`
50+
Block string `json:"block"`
51+
BlockHash string `json:"block_hash"`
52+
Result string `json:"result"`
5253
}
5354

5455
func InvokeContract(chainmakerInfo ChainmakerInfo) (ChainmakerTxInfo, error) {
@@ -92,7 +93,14 @@ func InvokeContract(chainmakerInfo ChainmakerInfo) (ChainmakerTxInfo, error) {
9293
return ChainmakerTxInfo{}, fmt.Errorf("query contract error: %v", err)
9394
}
9495

95-
return ChainmakerTxInfo{TxId: txId, Block: strconv.FormatUint(transactionInfo.GetBlockHeight(), 10)}, nil
96+
blockInfo, err := client.GetBlockByHeight(transactionInfo.GetBlockHeight(), true)
97+
if err != nil {
98+
return ChainmakerTxInfo{}, err
99+
}
100+
101+
block := strconv.FormatUint(transactionInfo.GetBlockHeight(), 10)
102+
blockHash := blockInfo.GetBlock().GetBlockHashStr()
103+
return ChainmakerTxInfo{TxId: txId, Block: block, BlockHash: blockHash}, nil
96104
}
97105

98106
func QueryContract(chainmakerInfo ChainmakerInfo) (ChainmakerTxInfo, error) {

0 commit comments

Comments
 (0)