Class: EtherERC20Bridge
- Inherits:
-
ERC20
- Object
- Contract
- ERC20
- EtherERC20Bridge
show all
- Defined in:
- lib/rubysol/contracts/ether_erc20_bridge.rb
Instance Method Summary
collapse
Methods inherited from ERC20
#_burn, #_mint, #approve, #transfer, #transferFrom
Instance Method Details
#bridgeIn(to:, amount:) ⇒ Object
20
21
22
23
24
25
26
27
|
# File 'lib/rubysol/contracts/ether_erc20_bridge.rb', line 20
def bridgeIn( to:, amount: )
assert(
address(msg.sender) == @trustedSmartContract,
"Only the trusted smart contract can bridge in tokens"
)
_mint(to: to, amount: amount)
end
|
#bridgeOut(amount:) ⇒ Object
30
31
32
33
34
35
36
|
# File 'lib/rubysol/contracts/ether_erc20_bridge.rb', line 30
def bridgeOut( amount: )
_burn(from: msg.sender, amount: amount)
@pendingWithdrawals[address(msg.sender)] += amount
log InitiateWithdrawal, from: address(msg.sender), amount: amount
end
|
#constructor(name:, symbol:, trustedSmartContract:) ⇒ Object
10
11
12
13
14
15
16
17
|
# File 'lib/rubysol/contracts/ether_erc20_bridge.rb', line 10
def constructor(
name:,
symbol:,
trustedSmartContract:)
super(name: name, symbol: symbol, decimals: 18)
@trustedSmartContract = trustedSmartContract
end
|
#markWithdrawalComplete(to:, amount:) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/rubysol/contracts/ether_erc20_bridge.rb', line 39
def markWithdrawalComplete( to:, amount: )
assert(
address(msg.sender) == @trustedSmartContract,
'Only the trusted smart contract can mark withdrawals as complete'
)
assert(
@pendingWithdrawals[to] >= amount,
'Insufficient pending withdrawal'
)
@pendingWithdrawals[to] -= amount
log WithdrawalComplete, to: to, amount: amount
end
|