forked from cryptobuks1/JsWallet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontracts.ls
More file actions
46 lines (46 loc) · 1.61 KB
/
Copy pathcontracts.ls
File metadata and controls
46 lines (46 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
require! {
\prelude-ls : { map, find, keys, filter }
\./velas/addresses.ls
\./math.ls : { div }
\./swaping/addresses.ls : \swapping-addresses
}
export get-contract-by-name = (store, name)->
network = store.current.network
addresses[network][name]
export get-contract-name = (store, address)->
#res = to-eth-address address
network = store.current.network
result =
addresses[network]
|> keys
|> filter (it)->
(addresses[network][it] ? "").to-lower-case! is address.to-lower-case!
result[0] ? address
export is-contract = (store, address)->
return no if not address?
network = store.current.network
addresss = "#{address}".trim!
return no if addresss is ""
found =
addresses[network]
|> keys
|> find (it)->
addresses[network][it].to-lower-case! is addresss.to-lower-case!
found? and found.length > 0
export is-swap-contract = (store, address)->
return no if not address?
network = store.current.network
addresss = "#{address}".trim!
return no if addresss is ""
found =
swapping-addresses[network]
|> keys
|> find (it)->
swapping-addresses[network][it].to-lower-case! is addresss.to-lower-case!
found? and found.length > 0
export get-home-network-fee = ({store, web3t}, address, cb)->
name = get-contract-name(store, address)
return cb null if name isnt "ForeignBridge"
err, fee <- web3t.velas.HomeBridgeNativeToErc.getHomeFee!
return cb err if err?
return cb null, (fee `div` (10^18))