-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #99 from confio/12-relayer-loop
Relayer Loop
- Loading branch information
Showing
17 changed files
with
648 additions
and
200 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
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
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
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
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
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,31 @@ | ||
import { Logger } from '../../lib/logger'; | ||
|
||
// This is meant to be used around top-level command. | ||
// If you have access to a logger, please use errorBoundary | ||
export function rootBoundary<T>( | ||
command: (flags: T) => Promise<void> | ||
): (flags: T) => Promise<void> { | ||
return async function (flags: T) { | ||
try { | ||
await command(flags); | ||
} catch (e) { | ||
// TODO: should we format this somehow? | ||
console.error(e); | ||
process.exit(1); | ||
} | ||
}; | ||
} | ||
|
||
// FIXME: figure this one out better once we have loggers | ||
export async function errorBoundary( | ||
logger: Logger, | ||
command: () => Promise<void> | ||
) { | ||
try { | ||
await command(); | ||
} catch (e) { | ||
// TODO: should we format this somehow? | ||
logger.error(e); | ||
process.exit(1); | ||
} | ||
} |
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,33 @@ | ||
import { stringToPath } from '@cosmjs/crypto'; | ||
import { GasPrice } from '@cosmjs/launchpad'; | ||
import { DirectSecp256k1HdWallet } from '@cosmjs/proto-signing'; | ||
|
||
import { IbcClient, IbcClientOptions } from '../../lib/ibcclient'; | ||
import { Logger } from '../../lib/logger'; | ||
import { Chain } from '../types'; | ||
|
||
export async function signingClient( | ||
chain: Chain, | ||
mnemonic: string, | ||
logger?: Logger | ||
): Promise<IbcClient> { | ||
const hdPath = chain.hd_path ? stringToPath(chain.hd_path) : undefined; | ||
const signer = await DirectSecp256k1HdWallet.fromMnemonic( | ||
mnemonic, | ||
hdPath, | ||
chain.prefix | ||
); | ||
const { address } = (await signer.getAccounts())[0]; | ||
const options: IbcClientOptions = { | ||
prefix: chain.prefix, | ||
gasPrice: GasPrice.fromString(chain.gas_price), | ||
logger, | ||
}; | ||
const client = await IbcClient.connectWithSigner( | ||
chain.rpc[0], | ||
signer, | ||
address, | ||
options | ||
); | ||
return client; | ||
} |
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
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
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
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
Oops, something went wrong.