Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion aurora/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"borsh": "^0.7.0",
"chai": "^4.2.0",
"dotenv": "^16.3.1",
"eth-object": "https://github.com/aurora-is-near/eth-object#a84d1420fdde87a768b96c6a3b3d0ee435998f72",
"eth-object": "https://github.com/aurora-is-near/eth-object#378b8dbf44a71f7049666cea5a16ab88d45aed06",
"ethereumjs-util": "^7.1.5",
"ethers": "^6.6.0",
"ethers-utils": "^2.1.11",
Expand Down
22 changes: 3 additions & 19 deletions aurora/scripts/UnlockProof.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async function getProofOfData(contractAddress, slotKey, blockNumber, web3) {
return await web3.eth.getProof(contractAddress, [slotKey], blockNumber);
}

async function getWithdrawalsRoot(blockNumber, ethRpcEndpointURL) {
async function getBlockData(blockNumber, ethRpcEndpointURL) {
const response = await fetch(ethRpcEndpointURL, {
method: 'POST',
headers: {
Expand All @@ -39,23 +39,7 @@ async function getWithdrawalsRoot(blockNumber, ethRpcEndpointURL) {
id: 0
})
});
return (await response.json())["result"]["withdrawalsRoot"];
}

async function getBlockData(blockNumber, web3, ethRpcEndpointURL) {
let block = await web3.eth.getBlock(blockNumber);
block.difficulty = web3.utils.toHex(block.difficulty);
block.number = web3.utils.toHex(parseInt(block.number));
block.nonce = "0x" + parseInt(block.nonce).toString(16).padStart(16, '0');
block.baseFeePerGas = web3.utils.toHex(parseInt(block.baseFeePerGas));
block.gasLimit = web3.utils.toHex(parseInt(block.gasLimit));
block.gasUsed = web3.utils.toHex(parseInt(block.gasUsed));
block.size = web3.utils.toHex(parseInt(block.size));
block.timestamp = web3.utils.toHex(parseInt(block.timestamp));
block.totalDifficulty = web3.utils.toHex(block.totalDifficulty);
block.withdrawalsRoot = await getWithdrawalsRoot(blockNumber, ethRpcEndpointURL);

return block;
return (await response.json())["result"];
}

async function generateUnlockProof(getProofResponse, block, web3){
Expand Down Expand Up @@ -94,7 +78,7 @@ async function getUnlockProof(contractAddress, data, blockNumber, ethRpcEndpoint
let processHash = processedHash(data.token, data.recipient, data.nonce, data.amount);
let slotKeyOfProcessedHash = getProcessedHashSlotKey(processHash);
let responseData = await getProofOfData(contractAddress, slotKeyOfProcessedHash, blockNumber, web3);
let block = await getBlockData(blockNumber, web3, ethRpcEndpointURL);
let block = await getBlockData(blockNumber, ethRpcEndpointURL);
let unlockProof = await generateUnlockProof(responseData, block, web3);

let borshSer = borsh.serialize(
Expand Down
Loading