@ -18,17 +18,17 @@ import (
"time"
ethereum_rpc "github.com/ethereum/go-ethereum/rpc"
"github.com/harmony-one /go-sdk/pkg/account"
"github.com/harmony-one /go-sdk/pkg/address"
"github.com/harmony-one /go-sdk/pkg/common"
"github.com/harmony-one /go-sdk/pkg/console/jsre"
"github.com/harmony-one /go-sdk/pkg/console/jsre/deps"
"github.com/harmony-one /go-sdk/pkg/console/prompt"
"github.com/harmony-one /go-sdk/pkg/console/web3ext"
"github.com/harmony-one /go-sdk/pkg/rpc"
"github.com/harmony-one /go-sdk/pkg/store"
"github.com/harmony-one /go-sdk/pkg/transaction"
"github.com/harmony-one/harmony /accounts"
"github.com/woop-chain /go-sdk/pkg/account"
"github.com/woop-chain /go-sdk/pkg/address"
"github.com/woop-chain /go-sdk/pkg/common"
"github.com/woop-chain /go-sdk/pkg/console/jsre"
"github.com/woop-chain /go-sdk/pkg/console/jsre/deps"
"github.com/woop-chain /go-sdk/pkg/console/prompt"
"github.com/woop-chain /go-sdk/pkg/console/web3ext"
"github.com/woop-chain /go-sdk/pkg/rpc"
"github.com/woop-chain /go-sdk/pkg/store"
"github.com/woop-chain /go-sdk/pkg/transaction"
"github.com/woop-chain/woop /accounts"
"github.com/dop251/goja"
"github.com/mattn/go-colorable"
@ -58,9 +58,9 @@ type Config struct {
Prompter prompt . UserPrompter // Input prompter to allow interactive user feedback (defaults to TerminalPrompter)
Printer io . Writer // Output writer to serialize any display strings to (defaults to os.Stdout)
Preload [ ] string // Absolute paths to JavaScript files to preload
NodeUrl string // Hmy Node url
ShardId int // Hmy Shard ID
Net string // Hmy Network
NodeUrl string // Wiki Node url
ShardId int // Wiki Shard ID
Net string // Wiki Network
}
// Console is a JavaScript interpreted runtime environment. It is a fully fledged
@ -74,9 +74,9 @@ type Console struct {
histPath string // Absolute path to the console scrollback history
history [ ] string // Scroll history maintained by the console
printer io . Writer // Output writer to serialize any display strings to
nodeUrl string // Hmy Node url
shardId int // Hmy Shard ID
net string // Hmy Network
nodeUrl string // Wiki Node url
shardId int // Wiki Shard ID
net string // Wiki Network
}
// New initializes a JavaScript interpreted runtime environment and sets defaults
@ -243,14 +243,14 @@ func (c *Console) initPersonal(vm *goja.Runtime, bridge *bridge) {
if personal == nil || c . prompter == nil {
return
}
personal . Set ( "getListAccounts" , jsre . MakeCallback ( vm , bridge . Hmy GetListAccounts) )
personal . Set ( "signTransaction" , jsre . MakeCallback ( vm , bridge . callbackProtected ( bridge . Hmy SignTransaction) ) )
personal . Set ( "sendTransaction" , jsre . MakeCallback ( vm , bridge . callbackProtected ( bridge . Hmy SendTransaction) ) )
personal . Set ( "lockAccount" , jsre . MakeCallback ( vm , bridge . callbackProtected ( bridge . Hmy LockAccount) ) )
personal . Set ( "importRawKey" , jsre . MakeCallback ( vm , bridge . Hmy ImportRawKey) )
personal . Set ( "unlockAccount" , jsre . MakeCallback ( vm , bridge . callbackProtected ( bridge . Hmy UnlockAccount) ) )
personal . Set ( "newAccount" , jsre . MakeCallback ( vm , bridge . callbackProtected ( bridge . Hmy NewAccount) ) )
personal . Set ( "sign" , jsre . MakeCallback ( vm , bridge . callbackProtected ( bridge . Hmy Sign) ) )
personal . Set ( "getListAccounts" , jsre . MakeCallback ( vm , bridge . Wiki GetListAccounts) )
personal . Set ( "signTransaction" , jsre . MakeCallback ( vm , bridge . callbackProtected ( bridge . Wiki SignTransaction) ) )
personal . Set ( "sendTransaction" , jsre . MakeCallback ( vm , bridge . callbackProtected ( bridge . Wiki SendTransaction) ) )
personal . Set ( "lockAccount" , jsre . MakeCallback ( vm , bridge . callbackProtected ( bridge . Wiki LockAccount) ) )
personal . Set ( "importRawKey" , jsre . MakeCallback ( vm , bridge . Wiki ImportRawKey) )
personal . Set ( "unlockAccount" , jsre . MakeCallback ( vm , bridge . callbackProtected ( bridge . Wiki UnlockAccount) ) )
personal . Set ( "newAccount" , jsre . MakeCallback ( vm , bridge . callbackProtected ( bridge . Wiki NewAccount) ) )
personal . Set ( "sign" , jsre . MakeCallback ( vm , bridge . callbackProtected ( bridge . Wiki Sign) ) )
_ , err := vm . RunString ( ` Object.defineProperty(personal, "listAccounts", { get: personal.getListAccounts}); ` )
if err != nil {
@ -264,8 +264,8 @@ func (c *Console) initEth(vm *goja.Runtime, bridge *bridge) {
return
}
eth . Set ( "sendTransaction" , jsre . MakeCallback ( vm , bridge . callbackProtected ( bridge . Hmy SendTransaction) ) )
eth . Set ( "signTransaction" , jsre . MakeCallback ( vm , bridge . callbackProtected ( bridge . Hmy SignTransaction) ) )
eth . Set ( "sendTransaction" , jsre . MakeCallback ( vm , bridge . callbackProtected ( bridge . Wiki SendTransaction) ) )
eth . Set ( "signTransaction" , jsre . MakeCallback ( vm , bridge . callbackProtected ( bridge . Wiki SignTransaction) ) )
}
func ( c * Console ) clearHistory ( ) {
@ -319,7 +319,7 @@ func (c *Console) AutoCompleteInput(line string, pos int) (string, []string, str
// Welcome show summary of current Geth instance and some metadata about the
// console's available modules.
func ( c * Console ) Welcome ( ) {
message := "Welcome to the Hmy JavaScript console!\n\n"
message := "Welcome to the Wiki JavaScript console!\n\n"
// Print some generic Geth metadata
if res , err := c . jsre . Run ( `
@ -327,7 +327,7 @@ func (c *Console) Welcome() {
try {
message += "coinbase: " + eth . coinbase + "\n" ;
} catch ( err ) { }
message += "at shard: " + hmy . shardID + "\n" ;
message += "at shard: " + wiki . shardID + "\n" ;
message += "at block: " + eth . blockNumber + " (" + new Date ( 1000 * eth . getBlock ( eth . blockNumber ) . timestamp ) + ")\n" ;
try {
message += " datadir: " + admin . datadir + "\n" ;
@ -531,7 +531,7 @@ func (b *bridge) callbackProtected(protectedFunc func(call jsre.Call) (goja.Valu
}
}
func ( b * bridge ) Hmy GetListAccounts( call jsre . Call ) ( goja . Value , error ) {
func ( b * bridge ) Wiki GetListAccounts( call jsre . Call ) ( goja . Value , error ) {
var accounts = [ ] string { }
for _ , name := range store . LocalAccounts ( ) {
@ -545,7 +545,7 @@ func (b *bridge) HmyGetListAccounts(call jsre.Call) (goja.Value, error) {
return call . VM . ToValue ( accounts ) , nil
}
func ( b * bridge ) Hmy SignTransaction( call jsre . Call ) ( goja . Value , error ) {
func ( b * bridge ) Wiki SignTransaction( call jsre . Call ) ( goja . Value , error ) {
txObj := call . Arguments [ 0 ] . ToObject ( call . VM )
password := call . Arguments [ 1 ] . String ( )
@ -628,7 +628,7 @@ func (b *bridge) HmySignTransaction(call jsre.Call) (goja.Value, error) {
} ) , nil
}
func ( b * bridge ) Hmy SendTransaction( call jsre . Call ) ( goja . Value , error ) {
func ( b * bridge ) Wiki SendTransaction( call jsre . Call ) ( goja . Value , error ) {
txObj := call . Arguments [ 0 ] . ToObject ( call . VM )
password := ""
if len ( call . Arguments ) > 1 {
@ -698,7 +698,7 @@ func (b *bridge) HmySendTransaction(call jsre.Call) (goja.Value, error) {
return call . VM . ToValue ( * ctrlr . TransactionHash ( ) ) , nil
}
func ( b * bridge ) Hmy LockAccount( call jsre . Call ) ( goja . Value , error ) {
func ( b * bridge ) Wiki LockAccount( call jsre . Call ) ( goja . Value , error ) {
address := call . Arguments [ 0 ] . String ( )
_ , _ , err := store . LockKeystore ( address )
@ -709,7 +709,7 @@ func (b *bridge) HmyLockAccount(call jsre.Call) (goja.Value, error) {
return goja . Null ( ) , nil
}
func ( b * bridge ) Hmy ImportRawKey( call jsre . Call ) ( goja . Value , error ) {
func ( b * bridge ) Wiki ImportRawKey( call jsre . Call ) ( goja . Value , error ) {
privateKey := call . Arguments [ 0 ] . String ( )
password := call . Arguments [ 1 ] . String ( )
@ -721,7 +721,7 @@ func (b *bridge) HmyImportRawKey(call jsre.Call) (goja.Value, error) {
return call . VM . ToValue ( name ) , nil
}
func ( b * bridge ) Hmy UnlockAccount( call jsre . Call ) ( goja . Value , error ) {
func ( b * bridge ) Wiki UnlockAccount( call jsre . Call ) ( goja . Value , error ) {
if len ( call . Arguments ) < 3 {
return nil , errors . New ( "arguments < 3" )
}
@ -737,11 +737,11 @@ func (b *bridge) HmyUnlockAccount(call jsre.Call) (goja.Value, error) {
return goja . Null ( ) , nil
}
func ( b * bridge ) Hmy NewAccount( call jsre . Call ) ( goja . Value , error ) {
func ( b * bridge ) Wiki NewAccount( call jsre . Call ) ( goja . Value , error ) {
return goja . Null ( ) , nil
}
func ( b * bridge ) Hmy Sign( call jsre . Call ) ( goja . Value , error ) {
func ( b * bridge ) Wiki Sign( call jsre . Call ) ( goja . Value , error ) {
dataToSign := call . Arguments [ 0 ] . String ( )
addressStr := call . Arguments [ 1 ] . String ( )
password := call . Arguments [ 2 ] . String ( )