Class: MVM::Bridge

Inherits:
Object
  • Object
show all
Defined in:
lib/mvm/bridge.rb

Overview

Bridge client for MVM cross-chain operations.

The Bridge facilitates communication between Mixin Network and MVM, enabling cross-chain transfers and user registration.

Usage

bridge = MVM.bridge
info = bridge.info
 = bridge.user(public_key)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBridge

Initializes a new Bridge instance.

Creates an HTTP client connected to the MVM bridge service.



26
27
28
# File 'lib/mvm/bridge.rb', line 26

def initialize
  @client = MVM::Client.new 'bridge.mvm.dev'
end

Instance Attribute Details

#clientMVM::Client (readonly)

Returns the HTTP client for bridge operations.

Returns:

  • (MVM::Client)

    the HTTP client for bridge operations



19
20
21
# File 'lib/mvm/bridge.rb', line 19

def client
  @client
end

Instance Method Details

#infoHash

Retrieves bridge service information.

Returns general information about the bridge service including supported features, version, and status.

Examples:

bridge = MVM.bridge
info = bridge.info
puts info

Returns:

  • (Hash)

    bridge information



43
44
45
# File 'lib/mvm/bridge.rb', line 43

def info
  client.get '/'
end

#user(public_key) ⇒ Hash

Retrieves or creates user information on the bridge.

Registers a user’s public key with the bridge service, enabling them to perform cross-chain operations.

Examples:

bridge = MVM.bridge
user = bridge.user('0x1234...')
puts user['contract']

Parameters:

  • public_key (String)

    the user’s public key

Returns:

  • (Hash)

    user information including bridge address



61
62
63
64
65
66
67
68
69
# File 'lib/mvm/bridge.rb', line 61

def user(public_key)
  path = '/users'

  payload = {
    public_key:
  }

  client.post path, **payload
end