mixin_bot 0.11.2 → 0.11.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mixin_bot/version.rb +1 -1
- data/lib/mvm/registry.rb +37 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbe972f6a75908bd8c682e1a29208177cbd3766ee246bc44ac53a9416063ec3b
|
4
|
+
data.tar.gz: 783349cc919f4c0cb6fb6a4637a9768e4713a02cb91c859b24518ccf6e1e28cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdaf7d01136e90ee031b8fc974037cc84bb9ef7b492edc8ab36cbcf1c73c5c4679c8cc28e350f806ec57fc45eac1feaa8dd5beeeb28e8b560edd80c5afe1024a
|
7
|
+
data.tar.gz: b21eacbe6a3e34c0a08d1b719c46f62a83a6da4e1b70f9ec2460cb611df480efd74f4a66c8c43ea651f00bde484c251654997e75924d1a336159ea1786fd2acc
|
data/lib/mixin_bot/version.rb
CHANGED
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
|
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
|
17
|
-
|
49
|
+
def contract_from_user(user_id)
|
50
|
+
contract_from_multisig [user_id], 1
|
18
51
|
end
|
19
52
|
|
20
|
-
def
|
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
|