Class: Paleth::Personal

Inherits:
Object
  • Object
show all
Includes:
Liar
Defined in:
lib/paleth/personal.rb

Overview

Wrapper for the `personal` management API

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Liar

#make_promise

Constructor Details

#initialize(core) ⇒ Personal

Returns a new instance of Personal.


10
11
12
# File 'lib/paleth/personal.rb', line 10

def initialize(core)
  @core = core
end

Instance Attribute Details

#coreObject (readonly)

Returns the value of attribute core


8
9
10
# File 'lib/paleth/personal.rb', line 8

def core
  @core
end

Instance Method Details

#accountsObject

Returns the list of accounts as a Promis.


15
16
17
# File 'lib/paleth/personal.rb', line 15

def accounts
  make_promise(@core.web3.JS[:personal], 'getListAccounts')
end

#sign(message, account, password = nil) ⇒ Object

Sign the hex encoded message with the requested address (optionnaly unlocking the account with password) Returns a Promise resolving to the requested data


29
30
31
32
# File 'lib/paleth/personal.rb', line 29

def sign(message, , password = nil)
  args = [message, , password].compact
  make_promise(@core.web3.JS[:personal], 'sign', *args)
end

#unlock_account!(address, passphrase = nil, duration = nil) ⇒ Object

Returns a Promise. Unlock the account with the provided address using the provided passphrase for duration seconds.


21
22
23
24
# File 'lib/paleth/personal.rb', line 21

def unlock_account!(address, passphrase = nil, duration = nil)
  args = [address, passphrase, duration].compact
  make_promise(@core.web3.JS[:personal], 'unlockAccount', *args)
end