mixin_bot 0.11.2 → 0.11.3

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
2
  SHA256:
3
- metadata.gz: 630485777ae51872c9c3f5835375f63bc192918dfd354c9ac2d2346b1fcf1835
4
- data.tar.gz: fbcc1ca362beed41d977e2a9f6e0ebdf1c23fc0ee1ee373593372b221e6d0a43
3
+ metadata.gz: fbe972f6a75908bd8c682e1a29208177cbd3766ee246bc44ac53a9416063ec3b
4
+ data.tar.gz: 783349cc919f4c0cb6fb6a4637a9768e4713a02cb91c859b24518ccf6e1e28cb
5
5
  SHA512:
6
- metadata.gz: 37ee5ff2ecd52af503fa3d2ae49fc1ea730201b34ab99d9c184cab3d914bb565b245940b4df67d2801615a144f3daedb13ff4e921c597e11b0c8e4b18b017457
7
- data.tar.gz: b77cb941c1a9dac7abb840190a333eda86b8a2536a876ea81ff2471d2951ba867ded88ae6a3dfc36fb803dfbd7898f8a0bbadf43cfd01336b050f9c7ee751750
6
+ metadata.gz: bdaf7d01136e90ee031b8fc974037cc84bb9ef7b492edc8ab36cbcf1c73c5c4679c8cc28e350f806ec57fc45eac1feaa8dd5beeeb28e8b560edd80c5afe1024a
7
+ data.tar.gz: b21eacbe6a3e34c0a08d1b719c46f62a83a6da4e1b70f9ec2460cb611df480efd74f4a66c8c43ea651f00bde484c251654997e75924d1a336159ea1786fd2acc
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MixinBot
4
- VERSION = '0.11.2'
4
+ VERSION = '0.11.3'
5
5
  end
data/lib/mvm/registry.rb CHANGED
@@ -9,15 +9,48 @@ module MVM
9
9
  @registry = Eth::Contract.from_abi name: 'Registry', address: registry_address, abi: File.open(File.expand_path('./abis/registry.json', __dir__)).read
10
10
  end
11
11
 
12
- def asset(asset_id)
12
+ def pid
13
+ hex = @rpc.call(@registry, 'PID').to_s(16)
14
+ MixinBot::Utils::UUID.new(hex:hex).unpacked
15
+ end
16
+
17
+ def version
18
+ @rpc.call @registry, 'VERSION'
19
+ end
20
+
21
+ def asset_from_contract(contract)
22
+ hex = @rpc.call(@registry, 'assets', contract).to_s(16)
23
+ MixinBot::Utils::UUID.new(hex:hex).unpacked
24
+ end
25
+
26
+ def users_from_contract(contract)
27
+ bytes = @rpc.call(@registry, 'users', contract).bytes
28
+ members = []
29
+ length = bytes.shift(2).reverse.pack('C*').unpack1('S*')
30
+ length.times do
31
+ members << MixinBot::Utils::UUID.new(raw: bytes.shift(16).pack('C*')).unpacked
32
+ end
33
+ threshold = bytes.shift(2).reverse.pack('C*').unpack1('S*')
34
+ {
35
+ members: members,
36
+ threshold: threshold
37
+ }.with_indifferent_access
38
+ end
39
+
40
+ def user_from_contract(contract)
41
+ group = users_from_contract contract
42
+ group[:members].first
43
+ end
44
+
45
+ def contract_from_asset(asset_id)
13
46
  @rpc.call @registry, 'contracts', asset_id.gsub('-', '').to_i(16)
14
47
  end
15
48
 
16
- def user(user_id)
17
- multisig [user_id], 1
49
+ def contract_from_user(user_id)
50
+ contract_from_multisig [user_id], 1
18
51
  end
19
52
 
20
- def multisig(user_ids, threshold)
53
+ def contract_from_multisig(user_ids, threshold)
21
54
  bytes = []
22
55
  bytes += MixinBot::Utils.encode_int(user_ids.length)
23
56
  bytes += [user_ids.sort.join('').gsub('-', '')].pack('H*').bytes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mixin_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.2
4
+ version: 0.11.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - an-lee