steem-ruby 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 25b2e7d4eb5445c89b02aac685677e49a0c551c8
4
- data.tar.gz: 9b5f21517af8ea96a85c751d0a470463cff09ea7
2
+ SHA256:
3
+ metadata.gz: 57f84dd9185bb2ad616730cb370450ff56816706a8ad5b26d452bf3a7921cd68
4
+ data.tar.gz: 59934f9af8d4e20da692c06b9d8b55b71c54aaead980bec892c400ef100cc77c
5
5
  SHA512:
6
- metadata.gz: d960cab6d69f53dc73366084c85bb98ca4534829f225306125ca517b4adb391d108483836be355659d32143058daa19b7fa2685bfa4dd2a8b192677cb786e272
7
- data.tar.gz: ba077e084d71823040fb8470aa5793439356f8d7002da3763b60a4c4939d3655ff78a41ae920a98a8b15709a035b1c0ef9f39a296207675f296213201f2fbb6c
6
+ metadata.gz: f909db06bc8e7db70da6180d385e0527e6153134b2535e275e6864f9c21511506bb93ae685fee51187024819dd9ad243939efa88213f29af8b51d28c6826290b
7
+ data.tar.gz: 1b9d47fbb3775b639c53fc767f4a71a7d19578ca848f9f196ce1fd53ffe09d2b4eabc90ce70404a9deb523b448d0e2c70ceff53f2058b708e1b9d6be7dd983a2
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- steem-ruby (0.9.2)
4
+ steem-ruby (0.9.3)
5
5
  bitcoin-ruby (~> 0.0, >= 0.0.18)
6
6
  ffi (~> 1.9, >= 1.9.23)
7
7
  hashie (~> 3.5, >= 3.5.7)
@@ -21,7 +21,7 @@ GEM
21
21
  docile (1.3.1)
22
22
  ffi (1.9.25)
23
23
  hashdiff (0.3.7)
24
- hashie (3.5.7)
24
+ hashie (3.6.0)
25
25
  json (2.1.0)
26
26
  little-plugger (1.1.4)
27
27
  logging (2.2.2)
@@ -70,4 +70,4 @@ DEPENDENCIES
70
70
  yard (~> 0.9, >= 0.9.12)
71
71
 
72
72
  BUNDLED WITH
73
- 1.16.1
73
+ 1.16.5
@@ -70,9 +70,24 @@ module Steem
70
70
  end
71
71
  end
72
72
 
73
- # Override this if you want to use your own client.
73
+ # Override this if you want to just use your own client. Otherwise, inject
74
+ # the default using:
75
+ #
76
+ # Steem::Api.register default_rpc_client_class: MyClient
74
77
  def self.default_rpc_client_class
75
- DEFAULT_RPC_CLIENT_CLASS
78
+ if !!@injected_dependencies && !!@injected_dependencies[:default_rpc_client_class]
79
+ @injected_dependencies[:default_rpc_client_class]
80
+ else
81
+ DEFAULT_RPC_CLIENT_CLASS
82
+ end
83
+ end
84
+
85
+ # Used for dependency injection. Currently, the only key supported is:
86
+ #
87
+ # `default_rpc_client_class`
88
+ def self.register(register)
89
+ @injected_dependencies ||= {}
90
+ @injected_dependencies = @injected_dependencies.merge register
76
91
  end
77
92
 
78
93
  def initialize(options = {})
@@ -31,6 +31,7 @@ module Steem
31
31
  # For details on what to pass to these methods, check out the {https://developers.steem.io/apidefinitions/broadcast-ops Steem Developer Portal Broadcast Operations} page.
32
32
  class Broadcast
33
33
  extend Retriable
34
+ extend Utils
34
35
 
35
36
  DEFAULT_MAX_ACCEPTED_PAYOUT = Type::Amount.new(amount: '1000000000', precision: 3, nai: '@@000000013')
36
37
 
@@ -509,6 +510,68 @@ module Steem
509
510
  process(options.merge(ops: ops), &block)
510
511
  end
511
512
 
513
+ # Create a claimed account.
514
+ # options = {
515
+ # wif: wif,
516
+ # params: {
517
+ # creator: creator_account_name,
518
+ # new_account_name: new_account_name,
519
+ # owner: {
520
+ # weight_threshold: 1,
521
+ # account_auths: [],
522
+ # key_auths: [[owner_public_key, 1]],
523
+ # },
524
+ # active: {
525
+ # weight_threshold: 1,
526
+ # account_auths: [],
527
+ # key_auths: [[active_public_key, 1]],
528
+ # },
529
+ # posting: {
530
+ # weight_threshold: 1,
531
+ # account_auths: [],
532
+ # key_auths: [[posting_public_key, 1]],
533
+ # },
534
+ # memo_key: memo_public_key,
535
+ # json_metadata: '{}'
536
+ # }
537
+ # }
538
+ #
539
+ # Steem::Broadcast.create_claimed_account(options)
540
+ #
541
+ # @param options [Hash] options
542
+ # @option options [String] :wif Active wif
543
+ # @option options [Hash] :params
544
+ # * :creator (String)
545
+ # * :new_account_name (String)
546
+ # * :owner (Hash)
547
+ # * :active (Hash)
548
+ # * :posting (Hash)
549
+ # * :memo_key (String)
550
+ # * :metadata (Hash) Metadata of the account, becomes `json_metadata`.
551
+ # * :json_metadata (String) String version of `metadata` (use one or the other).
552
+ # * :extensions (Array) (optional)
553
+ # @option options [Boolean] :pretend Just validate, do not broadcast.
554
+ # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_create_claimed_account
555
+ def self.create_claimed_account(options, &block)
556
+ required_fields = %i(creator new_account_name owner active posting memo_key json_metadata)
557
+ params = options[:params]
558
+
559
+ if !!params[:metadata] && !!params[:json_metadata]
560
+ raise Steem::ArgumentError, 'Assign either metadata or json_metadata, not both.'
561
+ end
562
+
563
+ metadata = params.delete(:metadata) || {}
564
+ metadata ||= (JSON[params[:json_metadata]] || nil) || {}
565
+ params[:json_metadata] = metadata.to_json
566
+
567
+ check_required_fields(params, *required_fields)
568
+
569
+ params[:extensions] ||= []
570
+ ops = [[:account_create, params]]
571
+
572
+ process(options.merge(ops: ops), &block)
573
+ end
574
+
512
575
  # Update an account.
513
576
  # options = {
514
577
  # wif: wif,
@@ -611,6 +674,65 @@ module Steem
611
674
  process(options.merge(ops: ops), &block)
612
675
  end
613
676
 
677
+ # Extensible replacement for #witness_update that supports additional
678
+ # properties added since HF20 and beyond.
679
+ #
680
+ # options = {
681
+ # wif: wif,
682
+ # params: {
683
+ # owner: witness_account_name,
684
+ # props: {
685
+ # account_creation_fee: '0.000 STEEM',
686
+ # maximum_block_size: 131072,
687
+ # sbd_interest_rate: 1000,
688
+ # account_subsidy_budget: 50000,
689
+ # account_subsidy_decay: 330782,
690
+ # sbd_exchange_rate: '1.000 STEEM',
691
+ # url: "https://steemit.com",
692
+ # new_signing_key: 'STM8LoQjQqJHvotqBo7HjnqmUbFW9oJ2theyqonzUd9DdJ7YYHsvD'
693
+ # }
694
+ # }
695
+ # }
696
+ #
697
+ # Steem::Broadcast.witness_set_properties(options)
698
+ #
699
+ # @param options [Hash] options
700
+ # @option options [String] :wif Active wif
701
+ # @option options [Hash] :params
702
+ # * :owner (String)
703
+ # * :props (String)
704
+ # @option options [Boolean] :pretend Just validate, do not broadcast.
705
+ # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_witness_set_properties
706
+ # @see https://github.com/steemit/steem/blob/master/doc/witness_parameters.md
707
+ def self.witness_set_properties(options, &block)
708
+ required_fields = %i(owner props)
709
+ params = options[:params]
710
+ check_required_fields(params, *required_fields)
711
+
712
+ if !!(account_creation_fee = params[:props][:account_creation_fee] rescue nil)
713
+ params[:props][:account_creation_fee] = normalize_amount(options.merge amount: account_creation_fee, serialize: true)
714
+ end
715
+
716
+ if !!(sbd_exchange_rate = params[:props][:sbd_exchange_rate] rescue nil)
717
+ params[:props][:sbd_exchange_rate] = normalize_amount(options.merge amount: sbd_exchange_rate, serialize: true)
718
+ end
719
+
720
+ %i(account_creation_fee sbd_exchange_rate url new_signing_key).each do |key|
721
+ next unless !!params[:props][key]
722
+
723
+ val = params[:props][key]
724
+
725
+ params[:props][key] = hexlify val unless val =~ /^[0-9A-F]+$/i
726
+ end
727
+
728
+ params[:props] = params[:props].to_a
729
+
730
+ params[:extensions] ||= []
731
+ ops = [[:witness_set_properties, params]]
732
+
733
+ process(options.merge(ops: ops), &block)
734
+ end
735
+
614
736
  # All accounts with a VFS (Vesting Fund Shares) can vote for or against any
615
737
  # witness.
616
738
  #
@@ -1084,6 +1206,28 @@ module Steem
1084
1206
  process(options.merge(ops: ops), &block)
1085
1207
  end
1086
1208
 
1209
+ # @param options [Hash] options
1210
+ # @option options [String] :wif Active wif
1211
+ # @option options [Hash] :params
1212
+ # * :creator (String)
1213
+ # * :fee (String)
1214
+ # * :extensions (Array)
1215
+ # @option options [Boolean] :pretend Just validate, do not broadcast.
1216
+ # @see https://developers.steem.io/apidefinitions/broadcast-ops#broadcast_ops_claim_account
1217
+ def self.claim_account(options, &block)
1218
+ required_fields = %i(creator fee)
1219
+ params = options[:params]
1220
+
1221
+ check_required_fields(params, *required_fields)
1222
+
1223
+ params[:fee] = normalize_amount(options.merge amount: params[:fee])
1224
+ params[:extensions] ||= []
1225
+
1226
+ ops = [[:claim_account, params]]
1227
+
1228
+ process(options.merge(ops: ops), &block)
1229
+ end
1230
+
1087
1231
  # @param options [Hash] options
1088
1232
  # @option options [Array<Array<Hash>] :ops Operations to process.
1089
1233
  # @option options [Boolean] :pretend Just validate, do not broadcast.
@@ -1131,6 +1275,8 @@ module Steem
1131
1275
  def self.normalize_amount(options)
1132
1276
  if !!options[:app_base]
1133
1277
  Type::Amount.to_h(options[:amount])
1278
+ elsif !!options[:serialize]
1279
+ Type::Amount.to_s(options[:amount])
1134
1280
  else
1135
1281
  Type::Amount.to_s(options[:amount])
1136
1282
  end
@@ -28,9 +28,10 @@ module Steem
28
28
 
29
29
  attr_accessor :app_base, :database_api, :block_api, :expiration, :operations
30
30
  attr_writer :wif
31
- attr_reader :signed
31
+ attr_reader :signed, :testnet
32
32
 
33
33
  alias app_base? app_base
34
+ alias testnet? testnet
34
35
 
35
36
  def initialize(options = {})
36
37
  @app_base = !!options[:app_base] # default false
@@ -47,6 +48,7 @@ module Steem
47
48
 
48
49
  @wif = [options[:wif]].flatten
49
50
  @signed = false
51
+ @testnet = !!options[:testnet]
50
52
 
51
53
  if !!(trx = options[:trx])
52
54
  trx = case trx
@@ -78,11 +80,16 @@ module Steem
78
80
  @signatures = options[:signatures] || []
79
81
  @chain = options[:chain] || :steem
80
82
  @error_pipe = options[:error_pipe] || STDERR
81
- @chain_id = case @chain
83
+ @chain_id = options[:chain_id]
84
+ @chain_id ||= case @chain
82
85
  when :steem then NETWORKS_STEEM_CHAIN_ID
83
86
  when :test then NETWORKS_TEST_CHAIN_ID
84
87
  else; raise UnsupportedChainError, "Unsupported chain: #{@chain}"
85
88
  end
89
+
90
+ if testnet? && @chain_id == NETWORKS_STEEM_CHAIN_ID
91
+ raise UnsupportedChainError, "Unsupported testnet chain id: #{@chain_id}"
92
+ end
86
93
  end
87
94
 
88
95
  def inspect
@@ -13,6 +13,10 @@ module Steem
13
13
  new(amount).to_s
14
14
  end
15
15
 
16
+ def self.to_bytes(amount)
17
+ new(amount).to_bytes
18
+ end
19
+
16
20
  def initialize(value)
17
21
  super(:amount, value)
18
22
 
@@ -1,4 +1,4 @@
1
1
  module Steem
2
- VERSION = '0.9.2'
2
+ VERSION = '0.9.3'
3
3
  AGENT_ID = "steem-ruby/#{VERSION}"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: steem-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Martin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-20 00:00:00.000000000 Z
11
+ date: 2018-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -385,7 +385,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
385
385
  version: '0'
386
386
  requirements: []
387
387
  rubyforge_project:
388
- rubygems_version: 2.6.14
388
+ rubygems_version: 2.7.7
389
389
  signing_key:
390
390
  specification_version: 4
391
391
  summary: Steem Ruby Client