-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ag-trade): get local node info using cosmos-fetch endo plugin
- Loading branch information
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
STATE=$(shell endo where state) | ||
PET=$(STATE)/pet-store | ||
|
||
where: | ||
@echo state: $(STATE) | ||
|
||
node-info: $(PET)/local | ||
endo eval "E(local.lcd).getJSON('/node_info').then(i => i.node_info)" local | ||
|
||
$(PET)/local: src/net-local.js $(PET)/cosmos-fetch | ||
endo make src/net-local.js -n local -p cosmos-fetch | ||
|
||
$(PET)/cosmos-fetch: src/cosmosFetch.js | ||
@echo ++ install cosmos fetch plugin | ||
endo make --UNSAFE src/cosmosFetch.js -n cosmos-fetch | ||
|
||
clean: | ||
endo reset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* Usage: | ||
* $ endo make --UNSAFE src/cosmosFetch.js -n cosmos-fetch | ||
* Object [Alleged: CosmosFetch] {} | ||
* $ endo make test/net-local.js -n local -p cosmos-fetch | ||
* { lcd: Object [Alleged: LCD] {}, rpc: Object [Alleged: RpcClient] {} } | ||
*/ | ||
import { E } from '@endo/far'; | ||
|
||
const loc = { | ||
lcd: 'http://localhost:1317', | ||
rpc: 'http://localhost:26657', | ||
}; | ||
|
||
export const make = async net => { | ||
const [lcd, rpc] = await Promise.all([ | ||
E(net).makeLCDClient(loc.lcd), | ||
E(net).makeRPCClient(loc.rpc), | ||
]); | ||
|
||
return harden({ lcd, rpc }); | ||
}; |