Skip to content

Commit 7f58890

Browse files
committed
disable special addres
1 parent c3b21e5 commit 7f58890

File tree

6 files changed

+13
-27
lines changed

6 files changed

+13
-27
lines changed

api/coreservice.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ type (
8282
// CoreService provides api interface for user to interact with blockchain data
8383
CoreService interface {
8484
// Account returns the metadata of an account
85-
Account(addr address.Address) (*iotextypes.AccountMeta, *iotextypes.BlockIdentifier, error)
85+
Account(string) (*iotextypes.AccountMeta, *iotextypes.BlockIdentifier, error)
8686
// ChainMeta returns blockchain metadata
8787
ChainMeta() (*iotextypes.ChainMeta, string, error)
8888
// ServerMeta gets the server metadata
@@ -306,14 +306,17 @@ func newCoreService(
306306
}
307307

308308
// Account returns the metadata of an account
309-
func (core *coreService) Account(addr address.Address) (*iotextypes.AccountMeta, *iotextypes.BlockIdentifier, error) {
309+
func (core *coreService) Account(addrStr string) (*iotextypes.AccountMeta, *iotextypes.BlockIdentifier, error) {
310310
ctx, span := tracer.NewSpan(context.Background(), "coreService.Account")
311311
defer span.End()
312-
addrStr := addr.String()
313312
if addrStr == address.RewardingPoolAddr || addrStr == address.StakingBucketPoolAddr {
314313
return core.getProtocolAccount(ctx, addrStr)
315314
}
316315
span.AddEvent("accountutil.AccountStateWithHeight")
316+
addr, err := address.FromString(addrStr)
317+
if err != nil {
318+
return nil, nil, status.Error(codes.FailedPrecondition, err.Error())
319+
}
317320
ctx = genesis.WithGenesisContext(ctx, core.bc.Genesis())
318321
state, tipHeight, err := accountutil.AccountStateWithHeight(ctx, core.sf, addr)
319322
if err != nil {
@@ -1068,7 +1071,6 @@ func (core *coreService) ActionsByAddress(addr address.Address, start uint64, co
10681071
if count > core.cfg.RangeQueryLimit {
10691072
return nil, status.Error(codes.InvalidArgument, "range exceeds the limit")
10701073
}
1071-
10721074
actions, err := core.indexer.GetActionsByAddress(hash.BytesToHash160(addr.Bytes()), start, count)
10731075
if err != nil {
10741076
if errors.Cause(err) == db.ErrBucketNotExist || errors.Cause(err) == db.ErrNotExist {

api/grpcserver.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,7 @@ func (svr *gRPCHandler) SuggestGasPrice(ctx context.Context, in *iotexapi.Sugges
159159
func (svr *gRPCHandler) GetAccount(ctx context.Context, in *iotexapi.GetAccountRequest) (*iotexapi.GetAccountResponse, error) {
160160
span := tracer.SpanFromContext(ctx)
161161
defer span.End()
162-
addr, err := address.FromString(in.Address)
163-
if err != nil {
164-
return nil, err
165-
}
166-
accountMeta, blockIdentifier, err := svr.coreService.Account(addr)
162+
accountMeta, blockIdentifier, err := svr.coreService.Account(in.Address)
167163
if err != nil {
168164
return nil, err
169165
}

api/web3server.go

+2-10
Original file line numberDiff line numberDiff line change
@@ -408,11 +408,7 @@ func (svr *web3Handler) getBalance(in *gjson.Result) (interface{}, error) {
408408
if !addr.Exists() {
409409
return nil, errInvalidFormat
410410
}
411-
ioAddr, err := ethAddrToIoAddr(addr.String())
412-
if err != nil {
413-
return nil, err
414-
}
415-
accountMeta, _, err := svr.coreService.Account(ioAddr)
411+
accountMeta, _, err := svr.coreService.Account(addr.String())
416412
if err != nil {
417413
return nil, err
418414
}
@@ -607,11 +603,7 @@ func (svr *web3Handler) getCode(in *gjson.Result) (interface{}, error) {
607603
if !addr.Exists() {
608604
return nil, errInvalidFormat
609605
}
610-
ioAddr, err := ethAddrToIoAddr(addr.String())
611-
if err != nil {
612-
return nil, err
613-
}
614-
accountMeta, _, err := svr.coreService.Account(ioAddr)
606+
accountMeta, _, err := svr.coreService.Account(addr.String())
615607
if err != nil {
616608
return nil, err
617609
}

api/web3server_utils.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,7 @@ func (svr *web3Handler) checkContractAddr(to string) (bool, error) {
193193
if to == "" {
194194
return true, nil
195195
}
196-
ioAddr, err := address.FromString(to)
197-
if err != nil {
198-
return false, err
199-
}
200-
accountMeta, _, err := svr.coreService.Account(ioAddr)
196+
accountMeta, _, err := svr.coreService.Account(to)
201197
if err != nil {
202198
return false, err
203199
}

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ require (
2424
github.com/iotexproject/go-fsm v1.0.0
2525
github.com/iotexproject/go-p2p v0.3.7-0.20240327085559-423bb9cc8f5f
2626
github.com/iotexproject/go-pkgs v0.1.13
27-
github.com/iotexproject/iotex-address v0.2.8
27+
github.com/iotexproject/iotex-address v0.2.9-0.20241020230354-523f3f51b5f9
2828
github.com/iotexproject/iotex-antenna-go/v2 v2.5.1
2929
github.com/iotexproject/iotex-election v0.3.5-0.20210611041425-20ddf674363d
3030
github.com/iotexproject/iotex-proto v0.6.4

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -1178,8 +1178,8 @@ github.com/iotexproject/go-pkgs v0.1.13 h1:bK48DVenkfYkC4TRoqL77RLFRBE1MUfscCW49
11781178
github.com/iotexproject/go-pkgs v0.1.13/go.mod h1:t5X9kQ1VL5H+L+DC5GmohXnFKlcxaTcRnIBBuydcsTQ=
11791179
github.com/iotexproject/iotex-address v0.2.4/go.mod h1:K78yPSMB4K7gF/iQ7djT1amph0RBrP3rSkFfH7gNG70=
11801180
github.com/iotexproject/iotex-address v0.2.7/go.mod h1:K78yPSMB4K7gF/iQ7djT1amph0RBrP3rSkFfH7gNG70=
1181-
github.com/iotexproject/iotex-address v0.2.8 h1:jaTR5pZe/ljiYW4OqHl9NKPs0h1o91Gi6FILOTaBCXw=
1182-
github.com/iotexproject/iotex-address v0.2.8/go.mod h1:K78yPSMB4K7gF/iQ7djT1amph0RBrP3rSkFfH7gNG70=
1181+
github.com/iotexproject/iotex-address v0.2.9-0.20241020230354-523f3f51b5f9 h1:WeEbCkm4t2I3RxsRZXzHUkDGE1VlGvDUIMR3S3nJFLw=
1182+
github.com/iotexproject/iotex-address v0.2.9-0.20241020230354-523f3f51b5f9/go.mod h1:LEpPNy+jJbMKaQ6XLEPBUkoyyllHgW9js1YdixMQL9k=
11831183
github.com/iotexproject/iotex-antenna-go/v2 v2.5.1-0.20210604061028-2c2056a5bfdb/go.mod h1:NqFzRL8RtA3xfXGpYbs0IY71HDiD6Dh2hD9iYngKLIU=
11841184
github.com/iotexproject/iotex-antenna-go/v2 v2.5.1 h1:Z7X0qXxc/4hSSE3koBaFRpLAdiD6MlCxKbn7iAdI+xQ=
11851185
github.com/iotexproject/iotex-antenna-go/v2 v2.5.1/go.mod h1:8pDZcM45M0gY6jm3PoM20rzoD2Z0vg3Hg64RS4c3qx0=

0 commit comments

Comments
 (0)