Skip to content

Commit dac16dd

Browse files
committed
add stalking code
1 parent 98c455f commit dac16dd

File tree

5 files changed

+923
-1
lines changed

5 files changed

+923
-1
lines changed

cmd/query/account.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
11
package query
22

33
import (
4+
"context"
45
"encoding/hex"
56
"encoding/json"
67
"fmt"
78
"io"
89
"math/big"
910
"net/http"
1011
"os"
12+
"strings"
13+
"time"
14+
15+
"github.com/bcdevtools/devd/v3/third_party/ethsecp256k1"
16+
sdkcodec "github.com/cosmos/cosmos-sdk/codec"
17+
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
18+
"github.com/cosmos/cosmos-sdk/x/auth/vesting/exported"
19+
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
20+
21+
sdkcodectypes "github.com/cosmos/cosmos-sdk/codec/types"
22+
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
1123

1224
sdk "github.com/cosmos/cosmos-sdk/types"
1325
"github.com/ethereum/go-ethereum/crypto"
@@ -97,6 +109,41 @@ func GetQueryAccountCommand() *cobra.Command {
97109
}
98110
}
99111
}
112+
} else if strings.HasPrefix(typeString, "/cosmos.vesting.v1beta1.") {
113+
tendermintRpcHttpClient, _ := flags.MustGetTmRpc(cmd)
114+
115+
req := authtypes.QueryAccountRequest{
116+
Address: bech32,
117+
}
118+
bz, err := req.Marshal()
119+
utils.ExitOnErr(err, "failed to marshal ABCI query account details")
120+
121+
resultABCIQuery, err := tendermintRpcHttpClient.ABCIQuery(context.Background(), "/cosmos.auth.v1beta1.Query/Account", bz)
122+
utils.ExitOnErr(err, "failed to query account details")
123+
124+
var queryAccountResponse authtypes.QueryAccountResponse
125+
err = queryAccountResponse.Unmarshal(resultABCIQuery.Response.Value)
126+
utils.ExitOnErr(err, "failed to unmarshal ABCI query account details")
127+
128+
ir := sdkcodectypes.NewInterfaceRegistry()
129+
vestingtypes.RegisterInterfaces(ir)
130+
ir.RegisterInterface(
131+
"ethermint.crypto.v1.ethsecp256k1.PubKey",
132+
(*cryptotypes.PubKey)(nil),
133+
&ethsecp256k1.PubKey{},
134+
)
135+
cdc := sdkcodec.NewProtoCodec(ir)
136+
137+
var account exported.VestingAccount
138+
err = cdc.UnpackAny(queryAccountResponse.Account, &account)
139+
utils.ExitOnErr(err, "failed to unpack account details")
140+
141+
now := time.Now()
142+
accountInfoAsMap["_vesting"] = map[string]interface{}{
143+
"vested": account.GetVestedCoins(now),
144+
"vesting": account.GetVestingCoins(now),
145+
"locked": account.LockedCoins(now),
146+
}
100147
}
101148
}
102149
}
@@ -109,6 +156,7 @@ func GetQueryAccountCommand() *cobra.Command {
109156
}
110157

111158
cmd.Flags().String(flags.FlagCosmosRest, "", flags.FlagCosmosRestDesc)
159+
cmd.Flags().String(flags.FlagTendermintRpc, "", fmt.Sprintf("(conditionally used, not always) %s", flags.FlagTmRpcDesc))
112160

113161
return cmd
114162
}

go.mod

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,35 @@ require (
1717
)
1818

1919
require (
20+
cosmossdk.io/api v0.3.1 // indirect
21+
cosmossdk.io/core v0.5.1 // indirect
22+
cosmossdk.io/depinject v1.0.0-alpha.4 // indirect
2023
cosmossdk.io/errors v1.0.1 // indirect
2124
cosmossdk.io/math v1.3.0 // indirect
25+
filippo.io/edwards25519 v1.0.0 // indirect
26+
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
27+
github.com/99designs/keyring v1.2.1 // indirect
28+
github.com/ChainSafe/go-schnorrkel v1.0.0 // indirect
2229
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect
2330
github.com/VictoriaMetrics/fastcache v1.6.0 // indirect
31+
github.com/armon/go-metrics v0.4.1 // indirect
2432
github.com/beorn7/perks v1.0.1 // indirect
33+
github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect
2534
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
2635
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect
2736
github.com/cespare/xxhash v1.1.0 // indirect
2837
github.com/cespare/xxhash/v2 v2.2.0 // indirect
38+
github.com/cockroachdb/errors v1.10.0 // indirect
39+
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
40+
github.com/cockroachdb/redact v1.1.5 // indirect
2941
github.com/cometbft/cometbft-db v0.7.0 // indirect
3042
github.com/confio/ics23/go v0.9.0 // indirect
3143
github.com/cosmos/btcutil v1.0.5 // indirect
3244
github.com/cosmos/cosmos-proto v1.0.0-beta.4 // indirect
3345
github.com/cosmos/gogoproto v1.4.10 // indirect
46+
github.com/cosmos/iavl v0.20.1 // indirect
47+
github.com/cosmos/ledger-cosmos-go v0.12.4 // indirect
48+
github.com/danieljoos/wincred v1.1.2 // indirect
3449
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
3550
github.com/deckarep/golang-set v1.8.0 // indirect
3651
github.com/decred/dcrd/crypto/blake256 v1.1.0 // indirect
@@ -39,34 +54,48 @@ require (
3954
github.com/dgraph-io/ristretto v0.1.1 // indirect
4055
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect
4156
github.com/dustin/go-humanize v1.0.1 // indirect
57+
github.com/dvsekhvalnov/jose2go v1.6.0 // indirect
4258
github.com/fsnotify/fsnotify v1.6.0 // indirect
59+
github.com/getsentry/sentry-go v0.23.0 // indirect
4360
github.com/go-kit/kit v0.12.0 // indirect
4461
github.com/go-kit/log v0.2.1 // indirect
4562
github.com/go-logfmt/logfmt v0.5.1 // indirect
4663
github.com/go-ole/go-ole v1.2.6 // indirect
4764
github.com/go-stack/stack v1.8.0 // indirect
65+
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
4866
github.com/gogo/protobuf v1.3.2 // indirect
4967
github.com/golang/glog v1.1.2 // indirect
5068
github.com/golang/protobuf v1.5.3 // indirect
5169
github.com/golang/snappy v0.0.4 // indirect
5270
github.com/google/btree v1.1.2 // indirect
5371
github.com/google/go-cmp v0.6.0 // indirect
5472
github.com/gorilla/websocket v1.5.0 // indirect
73+
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
74+
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
75+
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
5576
github.com/gtank/merlin v0.1.1 // indirect
77+
github.com/gtank/ristretto255 v0.1.2 // indirect
78+
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
5679
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
5780
github.com/hashicorp/hcl v1.0.0 // indirect
81+
github.com/hdevalence/ed25519consensus v0.1.0 // indirect
5882
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
5983
github.com/holiman/uint256 v1.2.0 // indirect
84+
github.com/huandu/skiplist v1.2.0 // indirect
6085
github.com/inconshreveable/mousetrap v1.1.0 // indirect
6186
github.com/jmhodges/levigo v1.0.0 // indirect
6287
github.com/klauspost/compress v1.16.7 // indirect
88+
github.com/kr/pretty v0.3.1 // indirect
89+
github.com/kr/text v0.2.0 // indirect
6390
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
6491
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
6592
github.com/magiconair/properties v1.8.6 // indirect
93+
github.com/mattn/go-isatty v0.0.20 // indirect
6694
github.com/mattn/go-runewidth v0.0.9 // indirect
6795
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
6896
github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 // indirect
6997
github.com/mitchellh/mapstructure v1.5.0 // indirect
98+
github.com/mtibben/percent v0.2.1 // indirect
7099
github.com/olekukonko/tablewriter v0.0.5 // indirect
71100
github.com/pelletier/go-toml v1.9.5 // indirect
72101
github.com/pelletier/go-toml/v2 v2.0.7 // indirect
@@ -79,6 +108,7 @@ require (
79108
github.com/prometheus/procfs v0.9.0 // indirect
80109
github.com/prometheus/tsdb v0.7.1 // indirect
81110
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
111+
github.com/rogpeppe/go-internal v1.11.0 // indirect
82112
github.com/sasha-s/go-deadlock v0.3.1 // indirect
83113
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
84114
github.com/shoenig/go-m1cpu v0.1.6 // indirect
@@ -91,20 +121,27 @@ require (
91121
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
92122
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect
93123
github.com/tendermint/go-amino v0.16.0 // indirect
124+
github.com/tidwall/btree v1.6.0 // indirect
94125
github.com/tklauser/go-sysconf v0.3.12 // indirect
95126
github.com/tklauser/numcpus v0.6.1 // indirect
96127
github.com/yusufpapurcu/wmi v1.2.4 // indirect
128+
github.com/zondax/hid v0.9.2 // indirect
129+
github.com/zondax/ledger-go v0.14.3 // indirect
97130
go.etcd.io/bbolt v1.3.7 // indirect
98131
golang.org/x/crypto v0.32.0 // indirect
99132
golang.org/x/net v0.21.0 // indirect
100133
golang.org/x/sys v0.29.0 // indirect
134+
golang.org/x/term v0.28.0 // indirect
101135
golang.org/x/text v0.21.0 // indirect
136+
google.golang.org/genproto v0.0.0-20240102182953-50ed04b92917 // indirect
137+
google.golang.org/genproto/googleapis/api v0.0.0-20231212172506-995d672761c0 // indirect
102138
google.golang.org/genproto/googleapis/rpc v0.0.0-20240108191215-35c7eff3a6b1 // indirect
103139
google.golang.org/grpc v1.60.1 // indirect
104140
google.golang.org/protobuf v1.32.0 // indirect
105141
gopkg.in/ini.v1 v1.67.0 // indirect
106142
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
107143
gopkg.in/yaml.v2 v2.4.0 // indirect
108144
gopkg.in/yaml.v3 v3.0.1 // indirect
145+
pgregory.net/rapid v1.1.0 // indirect
109146
sigs.k8s.io/yaml v1.4.0 // indirect
110147
)

0 commit comments

Comments
 (0)