aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Yin <[email protected]>2020-09-08 00:42:35 -0400
committerGitHub <[email protected]>2020-09-08 00:42:35 -0400
commit22e5802155d7ee4314898e3a75144aa90def8df8 (patch)
treec0bc18693cc0aa3ca551053697f3b521a748140c
parent891eb16f79fbc8552ede10d786bf70927f78367a (diff)
parent13718f05008268dd887257d87a4116b37afb1eeb (diff)
Merge pull request #14 from ava-labs/TS_ava_to_avax
change /ava API to /avax
-rw-r--r--plugin/evm/service.go11
-rw-r--r--plugin/evm/vm.go10
2 files changed, 11 insertions, 10 deletions
diff --git a/plugin/evm/service.go b/plugin/evm/service.go
index 29ef35d..dbd6d46 100644
--- a/plugin/evm/service.go
+++ b/plugin/evm/service.go
@@ -44,7 +44,8 @@ type SnowmanAPI struct{ vm *VM }
// NetAPI offers network related API methods
type NetAPI struct{ vm *VM }
-type AvaAPI struct{ vm *VM }
+// AvaxAPI offers Avalanche network related API methods
+type AvaxAPI struct{ vm *VM }
// NewNetAPI creates a new net API instance.
func NewNetAPI(vm *VM) *NetAPI { return &NetAPI{vm} }
@@ -144,7 +145,7 @@ type ExportKeyReply struct {
}
// ExportKey returns a private key from the provided user
-func (service *AvaAPI) ExportKey(r *http.Request, args *ExportKeyArgs, reply *ExportKeyReply) error {
+func (service *AvaxAPI) ExportKey(r *http.Request, args *ExportKeyArgs, reply *ExportKeyReply) error {
service.vm.ctx.Log.Info("Platform: ExportKey called")
db, err := service.vm.ctx.Keystore.GetDatabase(args.Username, args.Password)
if err != nil {
@@ -168,7 +169,7 @@ type ImportKeyArgs struct {
}
// ImportKey adds a private key to the provided user
-func (service *AvaAPI) ImportKey(r *http.Request, args *ImportKeyArgs, reply *api.JsonAddress) error {
+func (service *AvaxAPI) ImportKey(r *http.Request, args *ImportKeyArgs, reply *api.JsonAddress) error {
service.vm.ctx.Log.Info("Platform: ImportKey called for user '%s'", args.Username)
if service.vm.ctx.Keystore == nil {
return fmt.Errorf("oh no")
@@ -223,7 +224,7 @@ type ImportAVAXArgs struct {
// ImportAVAX issues a transaction to import AVAX from the X-chain. The AVAX
// must have already been exported from the X-Chain.
-func (service *AvaAPI) ImportAVAX(_ *http.Request, args *ImportAVAXArgs, response *api.JsonTxID) error {
+func (service *AvaxAPI) ImportAVAX(_ *http.Request, args *ImportAVAXArgs, response *api.JsonTxID) error {
service.vm.ctx.Log.Info("Platform: ImportAVAX called")
chainID, err := service.vm.ctx.BCLookup.Lookup(args.SourceChain)
@@ -271,7 +272,7 @@ type ExportAVAXArgs struct {
// ExportAVAX exports AVAX from the P-Chain to the X-Chain
// It must be imported on the X-Chain to complete the transfer
-func (service *AvaAPI) ExportAVAX(_ *http.Request, args *ExportAVAXArgs, response *api.JsonTxID) error {
+func (service *AvaxAPI) ExportAVAX(_ *http.Request, args *ExportAVAXArgs, response *api.JsonTxID) error {
service.vm.ctx.Log.Info("Platform: ExportAVAX called")
if args.Amount == 0 {
diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go
index e1fdc33..b0073da 100644
--- a/plugin/evm/vm.go
+++ b/plugin/evm/vm.go
@@ -519,9 +519,9 @@ func (vm *VM) CreateHandlers() map[string]*commonEng.HTTPHandler {
handler.RegisterName("admin", &admin.Performance{})
return map[string]*commonEng.HTTPHandler{
- "/rpc": &commonEng.HTTPHandler{LockOptions: commonEng.NoLock, Handler: handler},
- "/ava": newHandler("ava", &AvaAPI{vm}),
- "/ws": &commonEng.HTTPHandler{LockOptions: commonEng.NoLock, Handler: handler.WebsocketHandler([]string{"*"})},
+ "/rpc": {LockOptions: commonEng.NoLock, Handler: handler},
+ "/avax": newHandler("avax", &AvaxAPI{vm}),
+ "/ws": {LockOptions: commonEng.NoLock, Handler: handler.WebsocketHandler([]string{"*"})},
}
}
@@ -530,8 +530,8 @@ func (vm *VM) CreateStaticHandlers() map[string]*commonEng.HTTPHandler {
handler := rpc.NewServer()
handler.RegisterName("static", &StaticService{})
return map[string]*commonEng.HTTPHandler{
- "/rpc": &commonEng.HTTPHandler{LockOptions: commonEng.NoLock, Handler: handler},
- "/ws": &commonEng.HTTPHandler{LockOptions: commonEng.NoLock, Handler: handler.WebsocketHandler([]string{"*"})},
+ "/rpc": {LockOptions: commonEng.NoLock, Handler: handler},
+ "/ws": {LockOptions: commonEng.NoLock, Handler: handler.WebsocketHandler([]string{"*"})},
}
}