-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.ls
53 lines (53 loc) · 2.41 KB
/
api.ls
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
47
48
49
50
51
52
53
require! {
\./providers.ls
\mobx : { toJS }
\prelude-ls : { pairs-to-obj, obj-to-pairs }
}
action = (func)-> (config, cb)->
return cb "provider is not defined" if not config?network?api?provider?
provider = providers[config.network.api.provider]
console.error "providr not found for #{config.network.api.provider}" if not provider?
return cb "providr not found for #{config.network.api.provider}" if not provider?
func provider, config, cb
export calc-fee = action (provider, config, cb)->
switch config.fee-type
case \auto then provider.calc-fee config, cb
case \cheap then provider.calc-fee config, cb
case \custom then cb null, config.fee-custom-amount
export get-keys = action (provider, config, cb)->
if window?.override-address?
err, wallet <- provider.get-keys config
return cb err if err
wallet.address = window.override-address
return cb err, wallet
else
provider.get-keys config, cb
export get-market-history-prices = action (provider, config, cb)->
return cb "getMarketHistoryPrices method is not supported" if typeof! provider.get-market-history-prices isnt \Function
provider.get-market-history-prices config, cb
export get-balance = action (provider, config, cb)->
provider.get-balance config, cb
export get-transactions = action (provider, config, cb)->
provider.get-transactions config, cb
export get-reward-history = action (provider, config, cb)->
provider.get-reward-history config, cb
export create-transaction = action (provider, config, cb)->
provider.create-transaction config, cb
export push-tx = action (provider, config, cb)->
provider.push-tx config, cb
export get-transaction-info = action (provider, config, cb)->
return cb "method is not supported" if typeof! provider.get-transaction-info isnt \Function
provider.get-transaction-info config, cb
export is-valid-address = action (provider, config, cb)->
return cb "method is not supported" if typeof! provider.is-valid-address isnt \Function
provider.is-valid-address config, cb
#
#
#
#
export get-sync-status = action (provider, config, cb)->
return cb "method is not supported" if typeof! provider.get-sync-status isnt \Function
provider.get-sync-status cb
export get-peer-count = action (provider, config, cb)->
return cb "method is not supported" if typeof! provider.get-peer-count isnt \Function
provider.get-peer-count cb