Module: Mpp::Methods::Tempo::Defaults

Extended by:
T::Sig
Defined in:
lib/mpp/methods/tempo/defaults.rb

Constant Summary collapse

CHAIN_ID =

Mainnet

4217
RPC_URL =
"https://rpc.tempo.xyz"
PATH_USD =
"0x20c0000000000000000000000000000000000000"
USDC =
"0x20C000000000000000000000b9537d11c60E8b50"
PATH_USD_DECIMALS =
6
TESTNET_CHAIN_ID =

Testnet (Moderato)

42_431
TESTNET_RPC_URL =
"https://rpc.moderato.tempo.xyz"
DEFAULT_FEE_PAYER_URL =

Testnet only - fee payer service sponsors gas on testnet

"https://sponsor.moderato.tempo.xyz"
DEFAULT_CURRENCIES =

Chain ID -> default currency mapping

T.let({
  CHAIN_ID => USDC,
  TESTNET_CHAIN_ID => PATH_USD
}.freeze, T::Hash[T.untyped, T.untyped])
CHAIN_RPC_URLS =

Chain ID -> default RPC URL mapping

T.let({
  CHAIN_ID => RPC_URL,
  TESTNET_CHAIN_ID => TESTNET_RPC_URL
}.freeze, T::Hash[T.untyped, T.untyped])
ESCROW_CONTRACTS =

Chain ID -> escrow contract address mapping

T.let({
  CHAIN_ID => "0x33b901018174DDabE4841042ab76ba85D4e24f25",
  TESTNET_CHAIN_ID => "0xe1c4d3dce17bc111181ddf716f75bae49e61a336"
}.freeze, T::Hash[T.untyped, T.untyped])

Class Method Summary collapse

Class Method Details

.default_currency_for_chain(chain_id) ⇒ Object



54
55
56
57
58
# File 'lib/mpp/methods/tempo/defaults.rb', line 54

def default_currency_for_chain(chain_id)
  return PATH_USD if chain_id.nil?

  DEFAULT_CURRENCIES.fetch(chain_id, PATH_USD)
end

.escrow_contract_for_chain(chain_id) ⇒ Object



67
68
69
70
71
72
73
# File 'lib/mpp/methods/tempo/defaults.rb', line 67

def escrow_contract_for_chain(chain_id)
  addr = ESCROW_CONTRACTS[chain_id]
  return addr if addr

  Kernel.raise ArgumentError,
    "Unknown chain_id #{chain_id}. Known chains: #{ESCROW_CONTRACTS.keys}. Pass escrow_contract explicitly."
end

.resolve_currency(chain_id: nil, testnet: false) ⇒ Object



61
62
63
64
# File 'lib/mpp/methods/tempo/defaults.rb', line 61

def resolve_currency(chain_id: nil, testnet: false)
  id = chain_id || (testnet ? TESTNET_CHAIN_ID : CHAIN_ID)
  DEFAULT_CURRENCIES.fetch(id, PATH_USD)
end

.rpc_url_for_chain(chain_id) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/mpp/methods/tempo/defaults.rb', line 45

def rpc_url_for_chain(chain_id)
  url = CHAIN_RPC_URLS[chain_id]
  return url if url

  Kernel.raise ArgumentError,
    "Unknown chain_id #{chain_id}. Known chains: #{CHAIN_RPC_URLS.keys}. Pass rpc_url explicitly."
end