Sha256: 7bb6825165a08a0bddc32f19779a0e2aa94edee5dcd3671d8c854119c2735c8f

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

require 'bitshares/version'

module BitShares
	autoload :WSocket,	'bitshares/wsocket'
	autoload :RPC,			'bitshares/rpc'
	autoload :API,			'bitshares/api'
	autoload :Wallet,		'bitshares/wallet'
	autoload :Asset,		'bitshares/asset'
	autoload :Account,	'bitshares/account'


	class << self

		def config autoconnect=true, &block
			@node = 'wss://node.testnet.bitshares.eu'
			@login = ''
			@pass = ''
			instance_eval(&block) if block_given?
			start if autoconnect
		end

		def node(n=nil)		n ||= @node; @node = n;		end
		def login(n=nil)	n ||= @login; @login = n; end
		def pass(n=nil)		n ||= @pass; @pass = n;		end

		def start
			WSocket.start
			RPC.new(1,'login',[@login,@pass]).send
		end

		def stop() WSocket.stop end

		def account name
			Account[name]
		end

		def balance name,*ids
			Wallet[name,*ids]
		end

		def assets *ids
			Asset[*ids]
		end

		def list_assets name, limit=1
			Asset.search name, limit
		end

		def subscribe_callback id, clear_filter=true
			RPC.new('set_subscribe_callback', [id, clear_filter]).send
		end

		def transfer that, amount, from, to
			RPC.new 'transfer',[]
		end

	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bitsharesws-0.0.4 lib/bitshares.rb