trident_assistant 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8dc10e88acd41b1155e43177a48f310d7c7e56ea7a316cf79f24a039c73eb1fa
4
+ data.tar.gz: 2a2764a29a51a7b4f0806fa54c1eb00430133b235b322ae528a199110bbcf274
5
+ SHA512:
6
+ metadata.gz: 78e76d0f250fc3447e546d3886e1bc7d5643d49f06cbd375de5d02fd39df718a10c4e1261923322bfe502778ead6f194e2cf392670228b073c45bc834a26827f
7
+ data.tar.gz: 72677e15222934ad2eaae5c96bf56d2d0c413a25e67bb34ba7f9d82db72b9640e6f102552683c80654ae33100a6e93698e1e48cbfa4c46979fd1f064973f4016
data/.rubocop.yml ADDED
@@ -0,0 +1,132 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+ NewCops: enable
4
+
5
+ Style/StringLiterals:
6
+ Enabled: true
7
+ EnforcedStyle: double_quotes
8
+
9
+ Style/StringLiteralsInInterpolation:
10
+ Enabled: true
11
+ EnforcedStyle: double_quotes
12
+
13
+ Layout/LineLength:
14
+ Max: 120
15
+
16
+ Metrics/BlockLength:
17
+ Enabled: false
18
+ Metrics/ClassLength:
19
+ Enabled: false
20
+ Metrics/MethodLength:
21
+ Enabled: false
22
+ Metrics/AbcSize:
23
+ Enabled: false
24
+ Metrics/PerceivedComplexity:
25
+ Enabled: false
26
+ Metrics/CyclomaticComplexity:
27
+ Enabled: false
28
+
29
+ Gemspec/DateAssignment: # new in 1.10
30
+ Enabled: true
31
+ Gemspec/RequireMFA: # new in 1.23
32
+ Enabled: true
33
+ Layout/LineEndStringConcatenationIndentation: # new in 1.18
34
+ Enabled: true
35
+ Layout/SpaceBeforeBrackets: # new in 1.7
36
+ Enabled: true
37
+ Lint/AmbiguousAssignment: # new in 1.7
38
+ Enabled: true
39
+ Lint/AmbiguousOperatorPrecedence: # new in 1.21
40
+ Enabled: true
41
+ Lint/AmbiguousRange: # new in 1.19
42
+ Enabled: true
43
+ Lint/DeprecatedConstants: # new in 1.8
44
+ Enabled: true
45
+ Lint/DuplicateBranch: # new in 1.3
46
+ Enabled: true
47
+ Lint/DuplicateRegexpCharacterClassElement: # new in 1.1
48
+ Enabled: true
49
+ Lint/EmptyBlock: # new in 1.1
50
+ Enabled: true
51
+ Lint/EmptyClass: # new in 1.3
52
+ Enabled: true
53
+ Lint/EmptyInPattern: # new in 1.16
54
+ Enabled: true
55
+ Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21
56
+ Enabled: true
57
+ Lint/LambdaWithoutLiteralBlock: # new in 1.8
58
+ Enabled: true
59
+ Lint/NoReturnInBeginEndBlocks: # new in 1.2
60
+ Enabled: true
61
+ Lint/NumberedParameterAssignment: # new in 1.9
62
+ Enabled: true
63
+ Lint/OrAssignmentToConstant: # new in 1.9
64
+ Enabled: true
65
+ Lint/RedundantDirGlobSort: # new in 1.8
66
+ Enabled: true
67
+ Lint/RequireRelativeSelfPath: # new in 1.22
68
+ Enabled: true
69
+ Lint/SymbolConversion: # new in 1.9
70
+ Enabled: true
71
+ Lint/ToEnumArguments: # new in 1.1
72
+ Enabled: true
73
+ Lint/TripleQuotes: # new in 1.9
74
+ Enabled: true
75
+ Lint/UnexpectedBlockArity: # new in 1.5
76
+ Enabled: true
77
+ Lint/UnmodifiedReduceAccumulator: # new in 1.1
78
+ Enabled: true
79
+ Lint/UselessRuby2Keywords: # new in 1.23
80
+ Enabled: true
81
+ Naming/BlockForwarding: # new in 1.24
82
+ Enabled: true
83
+ Security/IoMethods: # new in 1.22
84
+ Enabled: true
85
+ Style/ArgumentsForwarding: # new in 1.1
86
+ Enabled: true
87
+ Style/CollectionCompact: # new in 1.2
88
+ Enabled: true
89
+ Style/DocumentDynamicEvalDefinition: # new in 1.1
90
+ Enabled: true
91
+ Style/EndlessMethod: # new in 1.8
92
+ Enabled: true
93
+ Style/FileRead: # new in 1.24
94
+ Enabled: true
95
+ Style/FileWrite: # new in 1.24
96
+ Enabled: true
97
+ Style/HashConversion: # new in 1.10
98
+ Enabled: true
99
+ Style/HashExcept: # new in 1.7
100
+ Enabled: true
101
+ Style/IfWithBooleanLiteralBranches: # new in 1.9
102
+ Enabled: true
103
+ Style/InPatternThen: # new in 1.16
104
+ Enabled: true
105
+ Style/MapToHash: # new in 1.24
106
+ Enabled: true
107
+ Style/MultilineInPatternThen: # new in 1.16
108
+ Enabled: true
109
+ Style/NegatedIfElseCondition: # new in 1.2
110
+ Enabled: true
111
+ Style/NestedFileDirname: # new in 1.26
112
+ Enabled: true
113
+ Style/NilLambda: # new in 1.3
114
+ Enabled: true
115
+ Style/NumberedParameters: # new in 1.22
116
+ Enabled: true
117
+ Style/NumberedParametersLimit: # new in 1.22
118
+ Enabled: true
119
+ Style/OpenStructUse: # new in 1.23
120
+ Enabled: true
121
+ Style/QuotedSymbols: # new in 1.16
122
+ Enabled: true
123
+ Style/RedundantArgument: # new in 1.4
124
+ Enabled: true
125
+ Style/RedundantSelfAssignmentBranch: # new in 1.19
126
+ Enabled: true
127
+ Style/SelectByRegexp: # new in 1.22
128
+ Enabled: true
129
+ Style/StringChars: # new in 1.12
130
+ Enabled: true
131
+ Style/SwapValues: # new in 1.1
132
+ Enabled: true
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-03-18
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at an.lee.work@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in trident_assistant.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "minitest", "~> 5.0"
11
+
12
+ gem "rubocop", "~> 1.21"
data/Gemfile.lock ADDED
@@ -0,0 +1,106 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ trident_assistant (0.1.0)
5
+ mixin_bot (~> 0.8)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activesupport (7.0.2.3)
11
+ concurrent-ruby (~> 1.0, >= 1.0.2)
12
+ i18n (>= 1.6, < 2)
13
+ minitest (>= 5.1)
14
+ tzinfo (~> 2.0)
15
+ addressable (2.8.0)
16
+ public_suffix (>= 2.0.2, < 5.0)
17
+ ast (2.4.2)
18
+ awesome_print (1.9.2)
19
+ bcrypt (3.1.17)
20
+ cli-ui (1.5.1)
21
+ concurrent-ruby (1.1.10)
22
+ domain_name (0.5.20190701)
23
+ unf (>= 0.0.5, < 1.0.0)
24
+ eventmachine (1.2.7)
25
+ faye-websocket (0.11.1)
26
+ eventmachine (>= 0.12.0)
27
+ websocket-driver (>= 0.5.1)
28
+ ffi (1.15.5)
29
+ ffi-compiler (1.0.1)
30
+ ffi (>= 1.0.0)
31
+ rake
32
+ hamster (3.0.0)
33
+ concurrent-ruby (~> 1.0)
34
+ http (4.4.1)
35
+ addressable (~> 2.3)
36
+ http-cookie (~> 1.0)
37
+ http-form_data (~> 2.2)
38
+ http-parser (~> 1.2.0)
39
+ http-cookie (1.0.4)
40
+ domain_name (~> 0.5)
41
+ http-form_data (2.3.0)
42
+ http-parser (1.2.3)
43
+ ffi-compiler (>= 1.0, < 2.0)
44
+ i18n (1.10.0)
45
+ concurrent-ruby (~> 1.0)
46
+ jose (1.1.3)
47
+ hamster
48
+ minitest (5.15.0)
49
+ mixin_bot (0.8.4)
50
+ activesupport (>= 5)
51
+ awesome_print (~> 1.8)
52
+ bcrypt (~> 3.1)
53
+ cli-ui (~> 1.3)
54
+ faye-websocket (>= 0.11)
55
+ http (~> 4.1)
56
+ jose (~> 1.1)
57
+ msgpack (~> 1.3)
58
+ rbnacl (~> 7.1)
59
+ sha3 (~> 1.0)
60
+ thor (~> 1.0)
61
+ msgpack (1.5.1)
62
+ parallel (1.22.1)
63
+ parser (3.1.1.0)
64
+ ast (~> 2.4.1)
65
+ public_suffix (4.0.6)
66
+ rainbow (3.1.1)
67
+ rake (13.0.6)
68
+ rbnacl (7.1.1)
69
+ ffi
70
+ regexp_parser (2.2.1)
71
+ rexml (3.2.5)
72
+ rubocop (1.26.1)
73
+ parallel (~> 1.10)
74
+ parser (>= 3.1.0.0)
75
+ rainbow (>= 2.2.2, < 4.0)
76
+ regexp_parser (>= 1.8, < 3.0)
77
+ rexml
78
+ rubocop-ast (>= 1.16.0, < 2.0)
79
+ ruby-progressbar (~> 1.7)
80
+ unicode-display_width (>= 1.4.0, < 3.0)
81
+ rubocop-ast (1.16.0)
82
+ parser (>= 3.1.1.0)
83
+ ruby-progressbar (1.11.0)
84
+ sha3 (1.0.4)
85
+ thor (1.2.1)
86
+ tzinfo (2.0.4)
87
+ concurrent-ruby (~> 1.0)
88
+ unf (0.1.4)
89
+ unf_ext
90
+ unf_ext (0.0.8.1)
91
+ unicode-display_width (2.1.0)
92
+ websocket-driver (0.7.5)
93
+ websocket-extensions (>= 0.1.0)
94
+ websocket-extensions (0.1.5)
95
+
96
+ PLATFORMS
97
+ x86_64-linux
98
+
99
+ DEPENDENCIES
100
+ minitest (~> 5.0)
101
+ rake (~> 13.0)
102
+ rubocop (~> 1.21)
103
+ trident_assistant!
104
+
105
+ BUNDLED WITH
106
+ 2.2.30
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 an-lee
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # TridentAssistant
2
+
3
+ A CLI tool to play with [Trident NFT Marketplace](https://thetrident.one)
4
+
5
+ ## Installation
6
+
7
+ $ gem install trident_assistant
8
+
9
+ ## Usage
10
+
11
+ $ ta
12
+
13
+ ```
14
+ Commands:
15
+ ta collectible # commands for collectible
16
+ ta collection # commands for collection
17
+ ta help [COMMAND] # Describe available commands or one specific command
18
+ ta metadata # commands for metadata
19
+ ta nfo # commands for nfo
20
+ ta order # commands for order
21
+ ta version # Display TridentAssistant version
22
+
23
+ Options:
24
+ -p, [--pretty], [--no-pretty] # Print output in pretty
25
+ # Default: true
26
+ -e, [--environment=ENVIRONMENT] # prod | test | dev
27
+ # Default: prod
28
+ -E, [--endpoint=ENDPOINT] # Specify an endpoint
29
+ ```
30
+
31
+ ## Development
32
+
33
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
34
+
35
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
36
+
37
+ ## Contributing
38
+
39
+ Bug reports and pull requests are welcome on GitHub at https://github.com/TheTridentOne/trident_assistant. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/trident_assistant/blob/master/CODE_OF_CONDUCT.md).
40
+
41
+ ## License
42
+
43
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
44
+
45
+ ## Code of Conduct
46
+
47
+ Everyone interacting in the TridentAssistant project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/trident_assistant/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/*_test.rb"]
10
+ end
11
+
12
+ require "rubocop/rake_task"
13
+
14
+ RuboCop::RakeTask.new
15
+
16
+ task default: %i[test rubocop]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "trident_assistant"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/ta ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "../lib/trident_assistant"
5
+
6
+ TridentAssistant::CLI::Command.start(ARGV)
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TridentAssistant
4
+ class API
5
+ # api for collectible
6
+ module Collectible
7
+ EXCHANGE_ASSET_ID = "965e5c6e-434c-3fa9-b780-c50f43cd955c"
8
+ MINIMUM_AMOUNT = 0.000_000_01
9
+
10
+ def deposit(collection, token)
11
+ token_id = MixinBot::Utils::Nfo.new(collection: collection, token: token).unique_token_id
12
+ collectible = mixin_bot.collectibles(state: :unspent)["data"].find(&->(c) { c["token_id"] == token_id })
13
+ raise "Unauthorized" if collectible.blank?
14
+
15
+ nfo = MixinBot::Utils::Nfo.new(extra: "deposit".unpack1("H*")).encode.hex
16
+ _transfer_nft(
17
+ collectible,
18
+ nfo,
19
+ receivers: TridentAssistant::Utils::TRIDENT_MTG[:members],
20
+ threshold: TridentAssistant::Utils::TRIDENT_MTG[:threshold]
21
+ )
22
+ end
23
+
24
+ def withdraw(collection, token)
25
+ token_id = MixinBot::Utils::Nfo.new(collection: collection, token: token).unique_token_id
26
+ mixin_bot.create_multisig_transaction(
27
+ keystore[:pin],
28
+ asset_id: EXCHANGE_ASSET_ID,
29
+ amount: MINIMUM_AMOUNT,
30
+ receivers: TridentAssistant::Utils::TRIDENT_MTG[:members],
31
+ threshold: TridentAssistant::Utils::TRIDENT_MTG[:threshold],
32
+ memo: TridentAssistant::Utils::Memo.new(type: "W", token_id: token_id).encode,
33
+ trace_id: SecureRandom.uuid
34
+ )
35
+ end
36
+
37
+ def airdrop(collection, token, **kwargs)
38
+ token_id = MixinBot::Utils::Nfo.new(collection: collection, token: token).unique_token_id
39
+ collectible = mixin_bot.collectibles(state: :unspent)["data"].find(&->(c) { c["token_id"] == token_id })
40
+ collectible ||= mixin_bot.collectibles(state: :signed)["data"].find(&->(c) { c["token_id"] == token_id })
41
+ raise "Cannot find collectible in wallet" if collectible.blank?
42
+
43
+ memo =
44
+ TridentAssistant::Utils::Memo.new(
45
+ type: "AD",
46
+ receiver_id: kwargs[:receiver_id],
47
+ start_at: kwargs[:start_at]
48
+ ).encode
49
+ nfo = MixinBot::Utils::Nfo.new(extra: memo.unpack1("H*")).encode.hex
50
+
51
+ _transfer_nft(
52
+ collectible,
53
+ nfo,
54
+ receivers: TridentAssistant::Utils::TRIDENT_MTG[:members],
55
+ threshold: TridentAssistant::Utils::TRIDENT_MTG[:threshold]
56
+ )
57
+ end
58
+
59
+ private
60
+
61
+ def _transfer_nft(collectible, nfo, **kwargs)
62
+ tx =
63
+ if collectible["state"] == "signed"
64
+ collectible["signed_tx"]
65
+ else
66
+ raw = mixin_bot.build_collectible_transaction(
67
+ collectible: collectible,
68
+ receivers: kwargs[:receivers],
69
+ receivers_threshold: kwargs[:threshold],
70
+ nfo: nfo
71
+ )
72
+ mixin_bot.sign_raw_transaction raw
73
+ end
74
+
75
+ request = mixin_bot.create_sign_collectible_request tx
76
+ sign = mixin_bot.sign_collectible_request request["request_id"], keystore[:pin]
77
+ mixin_bot.send_raw_transaction sign["raw_transaction"]
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TridentAssistant
4
+ class API
5
+ # api for collection
6
+ module Collection
7
+ def collection(id)
8
+ client.get(
9
+ "api/collections/#{id}",
10
+ headers: {
11
+ Authorization: "Bearer #{mixin_bot.access_token("GET", "/me")}"
12
+ }
13
+ )
14
+ end
15
+
16
+ def collections
17
+ client.get(
18
+ "api/collections",
19
+ headers: {
20
+ Authorization: "Bearer #{mixin_bot.access_token("GET", "/me")}"
21
+ }
22
+ )
23
+ end
24
+
25
+ def create_collection(**kwargs)
26
+ kwargs = kwargs.with_indifferent_access
27
+ client
28
+ .post(
29
+ "api/collections",
30
+ headers: {
31
+ Authorization: "Bearer #{mixin_bot.access_token("GET", "/me")}"
32
+ },
33
+ json: {
34
+ name: kwargs[:name],
35
+ description: kwargs[:description],
36
+ external_url: kwargs[:external_url],
37
+ split: kwargs[:split].to_f.round(2),
38
+ icon_base64: kwargs[:icon_base64],
39
+ icon_url: kwargs[:icon_url]
40
+ }
41
+ )
42
+ end
43
+
44
+ def update_collection(id, **kwargs)
45
+ kwargs = kwargs.with_indifferent_access
46
+ client
47
+ .put(
48
+ "api/collections/#{id}",
49
+ headers: {
50
+ Authorization: "Bearer #{mixin_bot.access_token("GET", "/me")}"
51
+ },
52
+ json: {
53
+ description: kwargs[:description],
54
+ external_url: kwargs[:external_url],
55
+ icon_base64: kwargs[:icon_base64]
56
+ }.compact
57
+ )
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TridentAssistant
4
+ class API
5
+ # api for metadata
6
+ module Metadata
7
+ def metadata(metahash)
8
+ client.get "api/collectibles/#{metahash}"
9
+ end
10
+
11
+ def upload_metadata(metadata:, metahash:)
12
+ client
13
+ .post(
14
+ "api/collectibles",
15
+ headers: {
16
+ Authorization: "Bearer #{mixin_bot.access_token("GET", "/me")}"
17
+ },
18
+ json: {
19
+ metadata: metadata,
20
+ metahash: metahash
21
+ }
22
+ )
23
+ end
24
+ end
25
+ end
26
+ end