Open jormal opened 5 years ago
In issue #45, it fixed that unit conversions for balances. but, for values are still not working.
{ transaction(hash:"0x1234...") { value (unit:ether) } }
I think it also do conversion using web3.utils.fromWei().
web3.utils.fromWei()
I don't know is it right. but, I think it can be conversion by following this.
In, src/core/services/eth-service/index.ts
src/core/services/eth-service/index.ts
... export interface EthService { ... fetchValue(tx: EthqlTransaction): Promise<string>; ... } ...
In, src/core/services/eth-service/impl/web3-eth-service.ts
src/core/services/eth-service/impl/web3-eth-service.ts
... export class Web3EthService implements EthService { ... public async fetchValue(tx: EthqlTransaction): Promise<string> { return tx && tx.value; } ... } ...
In, src/core/model/index.ts
src/core/model/index.ts
... export class EthqlTransaction { ... public readonly value: string; ... constructor(tx: Transaction, logs?: Log[]) { ... this.value = value; ... } } ...
In, src/core/resolvers/transaction.ts
src/core/resolvers/transaction.ts
... async function value(obj: EthqlTransaction, { unit } /* args */, { services }: EthqlContext): Promise<string> { const val = await services.ethService.fetchValue(obj); return unit ? Web3.utils.fromWei(val, unit) : val; } ...
I'm Newbie and I don't know if I'm right.
In issue #45, it fixed that unit conversions for balances. but, for values are still not working.
I think it also do conversion using
web3.utils.fromWei()
.I don't know is it right. but, I think it can be conversion by following this.
In,
src/core/services/eth-service/index.ts
In,
src/core/services/eth-service/impl/web3-eth-service.ts
In,
src/core/model/index.ts
In,
src/core/resolvers/transaction.ts
I'm Newbie and I don't know if I'm right.