mobius-client 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: e968b6b25b6837e3eadbb9a1996b4a372c2d8637
4
- data.tar.gz: 06cf259d883d2990cddac20515b4a1acf2a5de2e
2
+ SHA256:
3
+ metadata.gz: 37f31bfca5afe7e6d46ff5d0f8b9991a6e145d0871bb4af521922858b1e9c902
4
+ data.tar.gz: 1deea8ff27c033a34b78700bf209fb1ec49bf94f66c461e64325ac6d243b74ef
5
5
  SHA512:
6
- metadata.gz: 2e5c816f4bd5bbece1298892d92d9ae722304ccc582722c866f51de2a34b7703b18369656ef3ca8bb621e1235811fd8c032d139009248ea87d41be4b60252db0
7
- data.tar.gz: 34bf38e11f7b153d80f65954de20353fdc9a3d1dba32d0901710ee89da0abfee41a73d7f0581fd4c5aee22a03975f8925021935ef35bea3d5b187c6f8eb0966c
6
+ metadata.gz: 49fca8065b821688c16d91d62793b178ec201082f348306d69717f00e5e169b1ce8ba67a8c877442332937206a2daf8caa4c8645feb6532dc842ca606470ba46
7
+ data.tar.gz: d321ee0e241b23b661a8a2bdab59390d66344ee8343a66edb7cb7685867629b6d54c9fe756b7c25d63ab69f5fa038c192dd82e71e4f498498a1cae64b19a5dce
@@ -3,20 +3,23 @@ class Mobius::Client::Blockchain::AddCosigner
3
3
  extend Dry::Initializer
4
4
  extend ConstructorShortcut[:call]
5
5
 
6
- # @!method initialize(keypair, cosigner, weight)
6
+ # @!method initialize(keypair, cosigner, cosigner_weight:, master_weight:)
7
7
  # @param keypair [Stellar::Keypair] Account keypair
8
8
  # @param cosigner_keypair [Stellar::Keypair] Cosigner account keypair
9
- # @param weight [Integer] Cosigner weight, default: 1
9
+ # @param cosigner_weight [Integer] Cosigner weight, default: 1
10
+ # @param master_weight [Integer] Master key weight, default: 10
10
11
  # @!scope instance
11
12
  param :keypair
12
13
  param :cosigner_keypair
13
- param :weight, default: -> { 1 }
14
+ param :cosigner_weight, default: -> { 1 } # TODO: should be an option too
15
+ option :master_weight, default: -> { 10 }
14
16
 
15
- # @!method call(keypair, cosigner, weight)
17
+ # @!method call(keypair, cosigner, cosigner_weight:, master_weight:)
16
18
  # Executes an operation.
17
19
  # @param keypair [Stellar::Keypair] Account keypair
18
20
  # @param cosigner_keypair [Stellar::Keypair] Cosigner account keypair
19
- # @param weight [Integer] Cosigner weight, default: 1
21
+ # @param cosigner_weight[Integer] Cosigner weight, default: 1
22
+ # @param master_weight [Integer] Master key weight, default: 10
20
23
  # @!scope class
21
24
 
22
25
  # Executes an operation
@@ -30,22 +33,36 @@ class Mobius::Client::Blockchain::AddCosigner
30
33
 
31
34
  private
32
35
 
33
- # TODO: weight must be params
34
36
  def tx
35
- Stellar::Transaction.set_options(
37
+ Stellar::Transaction.for_account(
36
38
  account: keypair,
37
- sequence: account.next_sequence_value,
38
- signer: signer,
39
- master_weight: 10,
40
- highThreshold: 10,
41
- medThreshold: 1,
42
- lowThreshold: 1
39
+ sequence: account.next_sequence_value
40
+ ).tap do |txn|
41
+ txn.operations << add_cosigner_op
42
+ txn.operations << set_thresholds_op
43
+ txn.fee *= txn.operations.size
44
+ end
45
+ end
46
+
47
+ def add_cosigner_op
48
+ Stellar::Operation.set_options(
49
+ signer: cosigner,
50
+ master_weight: master_weight
51
+ )
52
+ end
53
+
54
+ def set_thresholds_op
55
+ Stellar::Operation.set_options(
56
+ high_threshold: master_weight,
57
+ med_threshold: cosigner_weight,
58
+ low_threshold: cosigner_weight
43
59
  )
44
60
  end
45
61
 
46
- def signer
62
+ def cosigner
47
63
  Stellar::Signer.new(
48
- key: Stellar::SignerKey.new(:signer_key_type_ed25519, cosigner_keypair.raw_public_key), weight: weight
64
+ key: Stellar::SignerKey.new(:signer_key_type_ed25519, cosigner_keypair.raw_public_key),
65
+ weight: cosigner_weight
49
66
  )
50
67
  end
51
68
 
@@ -1,5 +1,5 @@
1
1
  module Mobius
2
2
  module Client
3
- VERSION = "0.6.0".freeze
3
+ VERSION = "0.6.1".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mobius-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Viktor Sokolov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-06 00:00:00.000000000 Z
11
+ date: 2018-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -392,7 +392,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
392
392
  version: '0'
393
393
  requirements: []
394
394
  rubyforge_project:
395
- rubygems_version: 2.6.14.1
395
+ rubygems_version: 2.7.6
396
396
  signing_key:
397
397
  specification_version: 4
398
398
  summary: Mobius Ruby Client