Skip to content

Commit

Permalink
feat(ethereum): use triple equal signs
Browse files Browse the repository at this point in the history
  • Loading branch information
denizenging committed Oct 8, 2023
1 parent 76cbb07 commit ebadcc3
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions pkg/ethereum/src/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,29 @@ export const execute = async (
): Promise<PluginResult> => {
const web3 = new Web3(ctx.fetchConnect()[0]);

if (kind == EthereumRequestKind.EthereumNonce) {
if (kind === EthereumRequestKind.EthereumNonce) {
const address = ctx.fetch('address') as string;
const nonce = await web3.eth.getTransactionCount(address);
return ctx.pass(nonce.toString());
}

if (kind == EthereumRequestKind.EthereumGasPrice) {
if (kind === EthereumRequestKind.EthereumGasPrice) {
const gasPrice = await web3.eth.getGasPrice();
return ctx.pass(gasPrice.toString());
}

if (kind == EthereumRequestKind.EthereumBalance) {
if (kind === EthereumRequestKind.EthereumBalance) {
// TODO: different statement for string and array
const address = ctx.fetch('address');
if (Array.isArray(address)) {
const balances = await Promise.all(
address.map((addr) => web3.eth.getBalance(addr as string))
);
return ctx.pass(balances.map((b) => b.toString()));
} else {
return ctx.pass((await web3.eth.getBalance(address as string)).toString());
}
return ctx.pass((await web3.eth.getBalance(address as string)).toString());
}
// if (kind == EthereumRequestKind.EthereumBytes) {
// if (kind === EthereumRequestKind.EthereumBytes) {
// const tag = ctx.fetch('transaction_id') as string;
// const receipt = await web3.eth.getTransactionReceipt(
// tag.startsWith('0x') ? tag : '0x' + tag
Expand Down

0 comments on commit ebadcc3

Please sign in to comment.