Skip to content

Commit

Permalink
feat(ag-trade): get local node info using cosmos-fetch endo plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
dckc committed Jan 16, 2024
1 parent ae4a847 commit a2ee99b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/ag-trade/Makefile
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
22 changes: 22 additions & 0 deletions packages/ag-trade/src/net-local.js
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 });
};

0 comments on commit a2ee99b

Please sign in to comment.