trident_assistant 0.1.1 → 0.1.2
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
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f692fe7b57bad948bdd511404d193da3ef7ca6de57c98be5d0e89e723f72aad6
|
4
|
+
data.tar.gz: 639c4c9112f0fb0a0abbb2b74d6f27628268b3fe7b7cae9dc4af3fc5c263bcc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c58889b81b4025b95bb1d78bab718b79f76d217c6f4bab65aa0201d6bccd62913a9c2c1a61c6b2df12ed80bb4abbfa13254d0b14b41107ad55b90e27f9dc58a
|
7
|
+
data.tar.gz: 323b6811abc920239e4abede5f2ba222458bd7737dc11486cd5dca51727fc610fd1010016d8e16bee860fbb3a161de872785372bc33d85de15e979cfd8553b11
|
@@ -56,6 +56,23 @@ module TridentAssistant
|
|
56
56
|
)
|
57
57
|
end
|
58
58
|
|
59
|
+
def transfer(collection, token, recipient, **_kwargs)
|
60
|
+
token_id = MixinBot::Utils::Nfo.new(collection: collection, token: token).unique_token_id
|
61
|
+
collectible = mixin_bot.collectibles(state: :unspent)["data"].find(&->(c) { c["token_id"] == token_id })
|
62
|
+
collectible ||= mixin_bot.collectibles(state: :signed)["data"].find(&->(c) { c["token_id"] == token_id })
|
63
|
+
raise "Cannot find collectible in wallet" if collectible.blank?
|
64
|
+
|
65
|
+
memo = "TRANSFER"
|
66
|
+
nfo = MixinBot::Utils::Nfo.new(extra: memo.unpack1("H*")).encode.hex
|
67
|
+
|
68
|
+
_transfer_nft(
|
69
|
+
collectible,
|
70
|
+
nfo,
|
71
|
+
receivers: [recipient],
|
72
|
+
threshold: 1
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
59
76
|
private
|
60
77
|
|
61
78
|
def _transfer_nft(collectible, nfo, **kwargs)
|
@@ -25,6 +25,15 @@ module TridentAssistant
|
|
25
25
|
log r["data"]
|
26
26
|
end
|
27
27
|
|
28
|
+
desc "transfer COLLECTION, TOKEN, RECIPIENT", "transfer NFT"
|
29
|
+
option :keystore, type: :string, aliases: "k", required: true, desc: "keystore or keystore.json file of Mixin bot"
|
30
|
+
def transfer(collection, token, recipient)
|
31
|
+
log api.transfer collection, token, recipient
|
32
|
+
log UI.fmt("{{v}} successfully transfer NFT")
|
33
|
+
rescue StandardError => e
|
34
|
+
log UI.fmt("{{x}} failed: #{e.inspect} #{e.backtrace.join("\n")}")
|
35
|
+
end
|
36
|
+
|
28
37
|
desc "deposit COLLECTION TOKEN", "deposit NFT"
|
29
38
|
option :keystore, type: :string, aliases: "k", required: true, desc: "keystore or keystore.json file of Mixin bot"
|
30
39
|
def deposit(collection, token)
|
@@ -21,15 +21,19 @@ module TridentAssistant
|
|
21
21
|
def bulkmint(dir)
|
22
22
|
raise "#{dir} is not a directory" unless Dir.exist?(dir)
|
23
23
|
|
24
|
-
Dir.glob("#{dir}/*.json")
|
24
|
+
files = Dir.glob("#{dir}/*.json")
|
25
|
+
minted = []
|
26
|
+
files.each do |file|
|
25
27
|
log "-" * 80
|
26
28
|
log UI.fmt("{{v}} found #{file}")
|
27
|
-
_mint
|
29
|
+
minted.push(file) if _mint(file)
|
28
30
|
rescue TridentAssistant::Utils::Metadata::InvalidFormatError, JSON::ParserError, Client::RequestError,
|
29
31
|
MixinBot::Error, RuntimeError => e
|
30
32
|
log UI.fmt("{{x}} #{file} failed: #{e.inspect}")
|
31
33
|
next
|
32
34
|
end
|
35
|
+
ensure
|
36
|
+
log UI.fmt("Found #{files.size} json file, minted #{minted.size}")
|
33
37
|
end
|
34
38
|
|
35
39
|
private
|
@@ -46,6 +50,14 @@ module TridentAssistant
|
|
46
50
|
|
47
51
|
raise "Creator ID incompatible with keystore" if metadata.creator[:id] != api.mixin_bot.client_id
|
48
52
|
|
53
|
+
# upload metadata
|
54
|
+
if data.dig("_mint", "metahash").blank?
|
55
|
+
api.upload_metadata metadata: metadata.json, metahash: metadata.metahash
|
56
|
+
data["_mint"] ||= {}
|
57
|
+
data["_mint"]["metahash"] = metadata.metahash
|
58
|
+
end
|
59
|
+
log UI.fmt("{{v}} metadata uploaded: #{options[:endpoint]}/api/collectibles/#{metadata.metahash}")
|
60
|
+
|
49
61
|
token_id = MixinBot::Utils::Nfo.new(collection: metadata.collection[:id],
|
50
62
|
token: metadata.token[:id]).unique_token_id
|
51
63
|
collectible =
|
@@ -56,23 +68,15 @@ module TridentAssistant
|
|
56
68
|
end
|
57
69
|
if collectible.present?
|
58
70
|
log UI.fmt("{{v}} already minted: #{token_id}")
|
59
|
-
return
|
71
|
+
return true
|
60
72
|
end
|
61
73
|
|
62
|
-
# upload metadata
|
63
|
-
if data.dig("_mint", "metahash").blank?
|
64
|
-
api.upload_metadata metadata: metadata.json, metahash: metadata.metahash
|
65
|
-
data["_mint"] ||= {}
|
66
|
-
data["_mint"]["metahash"] = metadata.metahash
|
67
|
-
end
|
68
|
-
log UI.fmt("{{v}} metadata uploaded: #{options[:endpoint]}/api/collectibles/#{metadata.metahash}")
|
69
|
-
|
70
74
|
# pay to NFO
|
71
75
|
trace_id = data.dig("_mint", "trace_id") || SecureRandom.uuid
|
72
76
|
memo = api.mixin_bot.nft_memo metadata.collection[:id], metadata.token[:id].to_i, metadata.metahash
|
73
77
|
|
74
78
|
data["_mint"]["trace_id"] = trace_id
|
75
|
-
|
79
|
+
loop do
|
76
80
|
payment =
|
77
81
|
begin
|
78
82
|
api.mixin_bot.create_multisig_transaction(
|
@@ -86,10 +90,10 @@ module TridentAssistant
|
|
86
90
|
threshold: TridentAssistant::Utils::NFO_MTG[:threshold]
|
87
91
|
}
|
88
92
|
)
|
89
|
-
rescue MixinBot::InsufficientPoolError => e
|
93
|
+
rescue MixinBot::InsufficientPoolError, MixinBot::HttpError => e
|
90
94
|
log UI.fmt("{{x}} #{e.inspect}")
|
91
95
|
log "Retrying to pay..."
|
92
|
-
sleep
|
96
|
+
sleep 1
|
93
97
|
nil
|
94
98
|
end
|
95
99
|
|
@@ -97,10 +101,11 @@ module TridentAssistant
|
|
97
101
|
|
98
102
|
log UI.fmt("{{v}} NFT mint payment paid: #{payment["data"]}")
|
99
103
|
data["_mint"]["token_id"] = token_id
|
104
|
+
log UI.fmt("{{v}} NFT successfully minted")
|
100
105
|
break
|
101
106
|
end
|
102
107
|
|
103
|
-
|
108
|
+
data.dig("_mint", "token_id").present?
|
104
109
|
ensure
|
105
110
|
if File.file? raw
|
106
111
|
File.write raw, data.to_json
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trident_assistant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- an-lee
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-04-
|
11
|
+
date: 2022-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mixin_bot
|