Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patch: remove crypto dependency to use provider on browser #151

Merged
merged 1 commit into from
Mar 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions packages/providers/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { sha256 } from '@ethersproject/sha2';
import { calcRoot } from '@fuel-ts/merkle';
import type { Transaction } from '@fuel-ts/transactions';
import { InputType, OutputType, TransactionType, TransactionCoder } from '@fuel-ts/transactions';
import { createHash } from 'crypto';

const getContractRoot = (bytecode: Uint8Array): string => {
const chunkSize = 8;
Expand Down Expand Up @@ -39,10 +38,10 @@ export const getContractId = (bytecode: BytesLike, salt: string, stateRoot: stri
};

export const getCoinUtxoId = (transactionId: BytesLike, outputIndex: BigNumberish): string => {
const hasher = createHash('sha256');
hasher.update(arrayify(transactionId));
hasher.update(Uint8Array.from([BigNumber.from(outputIndex).toNumber()]));
return hexlify(hasher.digest());
const coinUtxoId = sha256(
concat([arrayify(transactionId), Uint8Array.from([BigNumber.from(outputIndex).toNumber()])])
);
return coinUtxoId;
};

export const getSignableTransaction = (transaction: Transaction): Transaction => {
Expand Down