mixin_bot 0.11.1 → 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 +4 -4
- data/lib/mixin_bot/version.rb +1 -1
- data/lib/mvm/bridge.rb +4 -0
- data/lib/mvm/nft.rb +8 -11
- data/lib/mvm/registry.rb +63 -0
- data/lib/mvm.rb +11 -2
- metadata +3 -2
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/bridge.rb
CHANGED
data/lib/mvm/nft.rb
CHANGED
@@ -2,18 +2,15 @@
|
|
2
2
|
|
3
3
|
module MVM
|
4
4
|
class Nft
|
5
|
-
|
6
|
-
MIRROR_ADDRESS = '0xC193486e6Bf3E8461cb8fcdF178676a5D75c066A'
|
5
|
+
attr_reader :rpc, :mirror
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
@client = Eth::Client.create RPC_URL
|
12
|
-
@mirror = Eth::Contract.from_abi name: 'Mirror', address: MIRROR_ADDRESS, abi: File.open(File.expand_path('./abis/mirror.json', __dir__)).read
|
7
|
+
def initialize(rpc_url: MVM::RPC_URL, mirror_address: MVM::MIRROR_ADDRESS)
|
8
|
+
@rpc = Eth::Client.create rpc_url
|
9
|
+
@mirror = Eth::Contract.from_abi name: 'Mirror', address: mirror_address, abi: File.open(File.expand_path('./abis/mirror.json', __dir__)).read
|
13
10
|
end
|
14
11
|
|
15
12
|
def collection_from_contract(address)
|
16
|
-
collection = @
|
13
|
+
collection = @rpc.call @mirror, 'collections', address
|
17
14
|
return if collection.zero?
|
18
15
|
|
19
16
|
MixinBot::Utils::UUID.new(hex: collection.to_fs(16)).unpacked
|
@@ -21,7 +18,7 @@ module MVM
|
|
21
18
|
|
22
19
|
def contract_from_collection(uuid)
|
23
20
|
collection = uuid.to_s.gsub('-', '').to_i(16)
|
24
|
-
contract = @
|
21
|
+
contract = @rpc.call @mirror, 'contracts', collection
|
25
22
|
address = Eth::Address.new contract
|
26
23
|
return unless address.valid?
|
27
24
|
|
@@ -33,7 +30,7 @@ module MVM
|
|
33
30
|
return if address.blank? || address.to_i(16).zero?
|
34
31
|
|
35
32
|
contract = Eth::Contract.from_abi name: 'Collectible', address: address, abi: File.open(File.expand_path('./abis/erc721.json', __dir__)).read
|
36
|
-
owner = @
|
33
|
+
owner = @rpc.call contract, 'ownerOf', token_id.to_i
|
37
34
|
address = Eth::Address.new owner
|
38
35
|
return unless address.valid?
|
39
36
|
|
@@ -45,7 +42,7 @@ module MVM
|
|
45
42
|
def token_of_owner_by_index(contract, owner, index)
|
46
43
|
contract = Eth::Contract.from_abi name: 'Collectible', address: contract, abi: File.open(File.expand_path('./abis/erc721.json', __dir__)).read
|
47
44
|
|
48
|
-
@
|
45
|
+
@rpc.call contract, 'tokenOfOwnerByIndex', owner, index
|
49
46
|
rescue IOError
|
50
47
|
nil
|
51
48
|
end
|
data/lib/mvm/registry.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MVM
|
4
|
+
class Registry
|
5
|
+
attr_reader :rpc, :registry
|
6
|
+
|
7
|
+
def initialize(rpc_url: MVM::RPC_URL, registry_address: MVM::REGISTRY_ADDRESS)
|
8
|
+
@rpc = Eth::Client.create rpc_url
|
9
|
+
@registry = Eth::Contract.from_abi name: 'Registry', address: registry_address, abi: File.open(File.expand_path('./abis/registry.json', __dir__)).read
|
10
|
+
end
|
11
|
+
|
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)
|
46
|
+
@rpc.call @registry, 'contracts', asset_id.gsub('-', '').to_i(16)
|
47
|
+
end
|
48
|
+
|
49
|
+
def contract_from_user(user_id)
|
50
|
+
contract_from_multisig [user_id], 1
|
51
|
+
end
|
52
|
+
|
53
|
+
def contract_from_multisig(user_ids, threshold)
|
54
|
+
bytes = []
|
55
|
+
bytes += MixinBot::Utils.encode_int(user_ids.length)
|
56
|
+
bytes += [user_ids.sort.join('').gsub('-', '')].pack('H*').bytes
|
57
|
+
bytes += MixinBot::Utils.encode_int(threshold)
|
58
|
+
|
59
|
+
hash = Eth::Util.bin_to_prefixed_hex(Eth::Util.keccak256(bytes.pack('C*')))
|
60
|
+
@rpc.call @registry, 'contracts', hash.to_i(16)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/lib/mvm.rb
CHANGED
@@ -7,9 +7,14 @@ require 'eth'
|
|
7
7
|
require_relative './mvm/bridge'
|
8
8
|
require_relative './mvm/client'
|
9
9
|
require_relative './mvm/nft'
|
10
|
+
require_relative './mvm/registry'
|
10
11
|
require_relative './mvm/scan'
|
11
12
|
|
12
13
|
module MVM
|
14
|
+
RPC_URL = 'https://geth.mvm.dev'
|
15
|
+
MIRROR_ADDRESS = '0xC193486e6Bf3E8461cb8fcdF178676a5D75c066A'
|
16
|
+
REGISTRY_ADDRESS = '0x3c84B6C98FBeB813e05a7A7813F0442883450B1F'
|
17
|
+
|
13
18
|
class Error < StandardError; end
|
14
19
|
class HttpError < Error; end
|
15
20
|
class ResponseError < Error; end
|
@@ -18,11 +23,15 @@ module MVM
|
|
18
23
|
@bridge ||= MVM::Bridge.new
|
19
24
|
end
|
20
25
|
|
21
|
-
def self.nft
|
22
|
-
@nft ||= MVM::Nft.new
|
26
|
+
def self.nft(**params)
|
27
|
+
@nft ||= MVM::Nft.new(**params)
|
23
28
|
end
|
24
29
|
|
25
30
|
def self.scan
|
26
31
|
@scan ||= MVM::Scan.new
|
27
32
|
end
|
33
|
+
|
34
|
+
def self.registry(**params)
|
35
|
+
@registry ||= MVM::Registry.new(**params)
|
36
|
+
end
|
28
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mixin_bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- an-lee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -326,6 +326,7 @@ files:
|
|
326
326
|
- lib/mvm/bridge.rb
|
327
327
|
- lib/mvm/client.rb
|
328
328
|
- lib/mvm/nft.rb
|
329
|
+
- lib/mvm/registry.rb
|
329
330
|
- lib/mvm/scan.rb
|
330
331
|
homepage: https://github.com/an-lee/mixin_bot
|
331
332
|
licenses:
|