The core protocol of WoopChain
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
woop/rpc/v2/legacy.go

46 lines
1.1 KiB

package v2
import (
"context"
"math/big"
"github.com/woop-chain/woop/eth/rpc"
"github.com/woop-chain/woop/wiki"
internal_common "github.com/woop-chain/woop/internal/common"
)
// PublicLegacyService provides an API to access the Woop blockchain.
// Services here are legacy methods, specific to the V1 RPC that can be deprecated in the future.
type PublicLegacyService struct {
wiki *wiki.Woop
}
// NewPublicLegacyAPI creates a new API for the RPC interface
func NewPublicLegacyAPI(wiki *wiki.Woop, namespace string) rpc.API {
if namespace == "" {
namespace = "wikiv2"
}
return rpc.API{
Namespace: namespace,
Version: "1.0",
Service: &PublicLegacyService{wiki},
Public: true,
}
}
// GetBalance returns the amount of Atto for the given address in the state of the
// given block number.
func (s *PublicLegacyService) GetBalance(
ctx context.Context, address string,
) (*big.Int, error) {
addr, err := internal_common.ParseAddr(address)
if err != nil {
return nil, err
}
balance, err := s.wiki.GetBalance(ctx, addr, rpc.BlockNumberOrHashWithNumber(rpc.LatestBlockNumber))
if err != nil {
return nil, err
}
return balance, nil
}