Skip to content

Commit

Permalink
fix(getTransactionHash): add fee and version to calculation (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-ziv authored Mar 22, 2022
1 parent faf2857 commit 938ffe0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/__tests__/utils/blockchain/starknet.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import utils from '../../../utils';
describe('starknet', () => {
describe('getTransactionHash', () => {
it('should calc tx hash', () => {
const from_address = '0xcf98f0a8edc6a730e1ca6b64a2528c6be031cb12';
const from_address = '0xc3511006C04EF1d78af4C8E0e74Ec18A6E64Ff9e';
const to_address =
'1384622289134235426972866085149619554404298343372540338336104355150443775597';
'3256441166037631918262930812410838598500200462657642943867372734773841898370';
const selector =
'1285101517810983806491589552491143496277809242732141897358598292095611420389';
const nonce = '55';
const nonce = '9052';
const payload = [
'17466514784613283928575916580398045172482824287888203092305238190565527099',
'52145000000000',
'2466233808699993860276959899635844440352648432893721200040352181857144501229',
'12213000000000',
'0'
];

Expand All @@ -26,7 +26,7 @@ describe('starknet', () => {
ChainType.GOERLI.id,
nonce
)
).toEqual('0x35ab0e4de971ac0736844ef36a05796dc41490c165373923c423f4b995983e8');
).toEqual('0x6660a4a84d5c6665be0e97b863433afe3ce7ea6521f5f90e0693b3b772cda55');
});
});
});
2 changes: 2 additions & 0 deletions src/utils/blockchain/starknet.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@ export const getTransactionHash = (
const {l2IdPrefix} = byChainId(chainId);
return hash.computeHashOnElements([
txHashPrefix,
0, // version
toAddress,
selector,
calldataHash,
0, // max_fee
l2IdPrefix,
...additionalData
]);
Expand Down

0 comments on commit 938ffe0

Please sign in to comment.