Skip to content

Commit

Permalink
patch: remove crypto dependency to use provider on browser (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
luizstacio authored Mar 4, 2022
1 parent 7ea01cd commit d9ca47b
Showing 1 changed file with 4 additions and 5 deletions.
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

0 comments on commit d9ca47b

Please sign in to comment.