Class: MixinBot::API
- Inherits:
-
Object
- Object
- MixinBot::API
- Includes:
- Address, App, Asset, Attachment, Auth, Blaze, Conversation, EncryptedMessage, Inscription, LegacyCollectible, LegacyMultisig, LegacyOutput, LegacyPayment, LegacySnapshot, LegacyTransaction, LegacyTransfer, Me, Message, Multisig, Output, Payment, Pin, Rpc, Snapshot, Tip, Transaction, Transfer, User, Withdraw
- Defined in:
- lib/mixin_bot/api.rb,
lib/mixin_bot/api/me.rb,
lib/mixin_bot/api/app.rb,
lib/mixin_bot/api/pin.rb,
lib/mixin_bot/api/rpc.rb,
lib/mixin_bot/api/tip.rb,
lib/mixin_bot/api/auth.rb,
lib/mixin_bot/api/user.rb,
lib/mixin_bot/api/asset.rb,
lib/mixin_bot/api/blaze.rb,
lib/mixin_bot/api/output.rb,
lib/mixin_bot/api/address.rb,
lib/mixin_bot/api/message.rb,
lib/mixin_bot/api/payment.rb,
lib/mixin_bot/api/multisig.rb,
lib/mixin_bot/api/snapshot.rb,
lib/mixin_bot/api/transfer.rb,
lib/mixin_bot/api/withdraw.rb,
lib/mixin_bot/api/attachment.rb,
lib/mixin_bot/api/inscription.rb,
lib/mixin_bot/api/transaction.rb,
lib/mixin_bot/api/conversation.rb,
lib/mixin_bot/api/legacy_output.rb,
lib/mixin_bot/api/legacy_payment.rb,
lib/mixin_bot/api/legacy_multisig.rb,
lib/mixin_bot/api/legacy_snapshot.rb,
lib/mixin_bot/api/legacy_transfer.rb,
lib/mixin_bot/api/encrypted_message.rb,
lib/mixin_bot/api/legacy_collectible.rb,
lib/mixin_bot/api/legacy_transaction.rb
Defined Under Namespace
Modules: Address, App, Asset, Attachment, Auth, Blaze, Conversation, EncryptedMessage, Inscription, LegacyCollectible, LegacyMultisig, LegacyOutput, LegacyPayment, LegacySnapshot, LegacyTransaction, LegacyTransfer, Me, Message, Multisig, Output, Payment, Pin, Rpc, Snapshot, Tip, Transaction, Transfer, User, Withdraw
Constant Summary collapse
- COLLECTIBLE_TRANSACTION_ARGUMENTS =
collectible =
type: 'non_fungible_output', user_id: '', output_id: '', token_id: '', transaction_hash: '', output_index: '', amount: 1, senders: [], sender_threshold: 1, receivers: [], receivers_threshold: 1, state: 'unspent'
%i[collectible nfo receivers receivers_threshold].freeze
Constants included from Transaction
Transaction::EXTRA_SIZE_STORAGE_CAPACITY, Transaction::EXTRA_STORAGE_PRICE_STEP, Transaction::INSCRIBE_TRANSACTION_ARGUMENTS, Transaction::OCCUPY_INSCRIPTION_TRANSACTION_ARGUMENTS, Transaction::OUTPUT_TYPE_SCRIPT, Transaction::OUTPUT_TYPE_WITHDRAW_SUBMIT, Transaction::SAFE_RAW_TRANSACTION_ARGUMENTS, Transaction::SAFE_TX_VERSION, Transaction::SIGN_SAFE_TRANSACTION_ARGUMENTS, Transaction::XIN_ASSET_ID
Constants included from Tip
Constants included from LegacyTransfer
LegacyTransfer::TRANSFER_ARGUMENTS
Constants included from LegacyTransaction
LegacyTransaction::LEGACY_TX_VERSION, LegacyTransaction::MAINNET_TRANSACTION_ARGUMENTS, LegacyTransaction::MULTISIG_TRANSACTION_ARGUMENTS, LegacyTransaction::RAW_TRANSACTION_ARGUMENTS
Constants included from LegacyMultisig
LegacyMultisig::MULTISIG_REQUEST_ACTIONS
Constants included from LegacyCollectible
LegacyCollectible::COLLECTABLE_REQUEST_ACTIONS, LegacyCollectible::NFT_ASSET_MIXIN_ID
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #access_token(method, uri, body, **kwargs) ⇒ Object
- #build_collectible_transaction(**kwargs) ⇒ Object
- #client_id ⇒ Object
- #decode_raw_transaction(raw) ⇒ Object
-
#decode_raw_transaction_native(raw) ⇒ Object
Use a mixin software to implement transaction build.
- #encode_raw_transaction(txn) ⇒ Object
-
#encode_raw_transaction_native(json) ⇒ Object
Use a mixin software to implement transaction build.
- #generate_trace_from_hash(hash, output_index = 0) ⇒ Object
-
#initialize(**kwargs) ⇒ API
constructor
A new instance of API.
- #nft_memo(collection, token_id, meta) ⇒ Object
- #utils ⇒ Object
Methods included from Withdraw
#create_withdraw_address, #delete_withdraw_address, #get_withdraw_address, #withdrawals
Methods included from User
#create_safe_user, #create_user, #fetch_users, #migrate_to_safe, #safe_register, #search_user, #user
Methods included from Transfer
#build_utxos, #create_safe_transfer
Methods included from Transaction
#build_inscribe_transaction, #build_object_transaction, #build_occupy_transaction, #build_safe_transaction, #create_safe_keys, #create_safe_transaction_request, #generate_safe_keys, #safe_transaction, #send_safe_transaction, #sign_safe_transaction
Methods included from Tip
Methods included from Snapshot
#create_safe_snapshot_notification, #safe_snapshots
Methods included from Rpc
#get_snapshot, #get_transaction, #get_utxo, #list_mint_distributions, #list_mint_works, #list_snapshots, #rpc_proxy, #send_raw_transaction
Methods included from Pin
#decrypt_pin, #encrypt_pin, #generate_shared_key_with_server, #prepare_tip_key, #update_pin, #verify_pin
Methods included from Payment
Methods included from Output
#build_threshold_script, #safe_output, #safe_outputs
Methods included from Multisig
#create_safe_multisig_request, #safe_multisig_request, #sign_safe_multisig_request, #unlock_safe_multisig_request
Methods included from Message
#acknowledge_message_receipt, #app_button_group, #app_card, #base_message_params, #list_pending_message, #plain_audio, #plain_contact, #plain_data, #plain_image, #plain_post, #plain_sticker, #plain_text, #plain_video, #recall_message, #recall_message_params, #send_app_button_group_message, #send_app_card_message, #send_contact_message, #send_file_message, #send_image_message, #send_message, #send_plain_messages, #send_post_message, #send_text_message, #write_ws_message, #ws_message
Methods included from Me
#friends, #me, #safe_me, #update_me
Methods included from LegacyTransfer
#create_legacy_transfer, #legacy_transfer
Methods included from LegacyTransaction
#build_raw_transaction, #create_mainnet_transaction, #create_multisig_transaction, #transactions
Methods included from LegacySnapshot
#network_snapshot, #network_snapshots, #snapshots
Methods included from LegacyPayment
Methods included from LegacyOutput
#build_output, #create_output, #legacy_outputs
Methods included from LegacyMultisig
#create_multisig_payment, #create_multisig_request, #create_sign_multisig_request, #create_unlock_multisig_request, #sign_multisig_request, #unlock_multisig_request, #verify_multisig
Methods included from LegacyCollectible
#create_collectible_request, #create_sign_collectible_request, #create_unlock_collectible_request, #legacy_collectible, #legacy_collectibles, #legacy_collection, #sign_collectible_request, #unlock_collectible_request
Methods included from Inscription
#collectible, #collectibles, #collection, #collection_collectibles, #create_collectible_transfer
Methods included from EncryptedMessage
#base_encrypted_message_params, #decrypt_message, #encrypt_message, #encrypted_audio, #encrypted_contact, #encrypted_data, #encrypted_image, #encrypted_post, #encrypted_sticker, #encrypted_text, #encrypted_video, #send_encrypted_audio_message, #send_encrypted_contact_message, #send_encrypted_data_message, #send_encrypted_image_message, #send_encrypted_message, #send_encrypted_messages, #send_encrypted_post_message, #send_encrypted_sticker_message, #send_encrypted_text_message, #send_encrypted_video_message
Methods included from Conversation
#add_conversation_participants, #conversation, #conversation_by_user_id, #create_contact_conversation, #create_conversation, #create_group_conversation, #exit_conversation, #remove_conversation_participants, #rotate_conversation, #unique_uuid, #update_conversation_participants_role, #update_group_conversation_announcement, #update_group_conversation_name
Methods included from Blaze
Methods included from Auth
#authorization_data, #authorize_code, #oauth_token, #request_oauth
Methods included from Attachment
#attachment, #create_attachment, #upload_attachment
Methods included from Asset
Methods included from App
#add_favorite_app, #favorite_apps, #remove_favorite_app
Methods included from Address
Constructor Details
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
37 38 39 |
# File 'lib/mixin_bot/api.rb', line 37 def client @client end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
37 38 39 |
# File 'lib/mixin_bot/api.rb', line 37 def config @config end |
Instance Method Details
#access_token(method, uri, body, **kwargs) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/mixin_bot/api.rb', line 58 def access_token(method, uri, body, **kwargs) utils.access_token( method, uri, body, exp_in: kwargs.delete(:exp_in) || 600, scp: kwargs.delete(:scp) || 'FULL', app_id: config.app_id, session_id: config.session_id, private_key: config.session_private_key ) end |
#build_collectible_transaction(**kwargs) ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/mixin_bot/api/legacy_collectible.rb', line 116 def build_collectible_transaction(**kwargs) raise ArgumentError, "#{COLLECTIBLE_TRANSACTION_ARGUMENTS.join(', ')} are needed for build collectible transaction" unless COLLECTIBLE_TRANSACTION_ARGUMENTS.all? { |param| kwargs.keys.include? param } kwargs = kwargs.with_indifferent_access collectible = kwargs['collectible'] raise 'collectible is spent' if collectible['state'] == 'spent' build_raw_transaction( utxos: [collectible], senders: collectible['receivers'], senders_threshold: collectible['receivers_threshold'], receivers: kwargs['receivers'], receivers_threshold: kwargs['receivers_threshold'], extra: [kwargs['nfo']].pack('H*'), amount: 1, asset_mixin_id: NFT_ASSET_MIXIN_ID, hint: kwargs['hint'] ) end |
#client_id ⇒ Object
54 55 56 |
# File 'lib/mixin_bot/api.rb', line 54 def client_id config.app_id end |
#decode_raw_transaction(raw) ⇒ Object
75 76 77 |
# File 'lib/mixin_bot/api.rb', line 75 def decode_raw_transaction(raw) utils.decode_raw_transaction raw end |
#decode_raw_transaction_native(raw) ⇒ Object
Use a mixin software to implement transaction build
95 96 97 98 99 100 101 102 103 |
# File 'lib/mixin_bot/api.rb', line 95 def decode_raw_transaction_native(raw) ensure_mixin_command_exist command = format("mixin decoderawtransaction --raw '%<arg>s'", arg: raw) output, error = Open3.capture3(command) raise error unless error.empty? JSON.parse output.chomp end |
#encode_raw_transaction(txn) ⇒ Object
71 72 73 |
# File 'lib/mixin_bot/api.rb', line 71 def encode_raw_transaction(txn) utils.encode_raw_transaction txn end |
#encode_raw_transaction_native(json) ⇒ Object
Use a mixin software to implement transaction build
84 85 86 87 88 89 90 91 92 |
# File 'lib/mixin_bot/api.rb', line 84 def encode_raw_transaction_native(json) ensure_mixin_command_exist command = format("mixin signrawtransaction --raw '%<arg>s'", arg: json) output, error = Open3.capture3(command) raise error unless error.empty? output.chomp end |
#generate_trace_from_hash(hash, output_index = 0) ⇒ Object
79 80 81 |
# File 'lib/mixin_bot/api.rb', line 79 def generate_trace_from_hash(hash, output_index = 0) utils.generate_trace_from_hash hash, output_index end |