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

Absolute tx deadline #60

Merged
merged 2 commits into from
Jun 12, 2024
Merged

Absolute tx deadline #60

merged 2 commits into from
Jun 12, 2024

Conversation

jaybuidl
Copy link
Member

@jaybuidl jaybuidl commented Jun 11, 2024

PR-Codex overview

This PR updates the version, addresses, and deadlines in the Escrow Universal subgraph and contract functions.

Detailed summary

  • Updated version to 2.0.1
  • Changed addresses in subgraph and contracts
  • Replaced _timeoutPayment with _deadline in contract functions

The following files were skipped due to too many changes: contracts/deployments/arbitrumSepoliaDevnet/EscrowUniversal.json

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • New Features

    • Updated DepositPaymentButton to handle deadline calculations and navigation based on deadline status.
  • Bug Fixes

    • Corrected links and addresses in documentation and configuration files for better accuracy.
  • Refactor

    • Replaced _timeoutPayment with _deadline in transaction functions across multiple contracts for consistency.
  • Chores

    • Updated package version to 2.0.1 in subgraph/package.json.
    • Updated EscrowUniversal data source address and start block in subgraph.yaml.

@jaybuidl jaybuidl added Type: Enhancement ✨ Package: Contracts Escrow smart contracts Compatibility: ABI change 🗯 Smart contract ABI is changing. labels Jun 11, 2024
@jaybuidl jaybuidl requested a review from kemuru June 11, 2024 13:33
Copy link
Contributor

coderabbitai bot commented Jun 11, 2024

Walkthrough

The updates primarily involve renaming the _timeoutPayment parameter to _deadline across various Solidity contracts and interfaces, reflecting a shift in how transaction deadlines are handled. Additionally, the DepositPaymentButton component in the frontend has been updated to process deadlines using BigInt for timestamp calculations. The subgraph configuration has also been updated with new addresses and start blocks.

Changes

File/Path Change Summary
contracts/README.md Updated link for EscrowUniversal to a new address.
contracts/src/Escrow.sol Renamed _timeoutPayment to _deadline in createNativeTransaction function and updated assignment logic.
contracts/src/EscrowToken.sol Renamed _timeoutPayment to _deadline in createERC20Transaction function.
contracts/src/EscrowUniversal.sol Renamed _timeoutPayment to _deadline in createNativeTransaction and createERC20Transaction functions.
contracts/src/interfaces/IEscrow.sol Updated parameter name from _timeoutPayment to _deadline in interface functions.
subgraph/package.json Updated version from "2.0.0" to "2.0.1".
subgraph/subgraph.yaml Updated EscrowUniversal data source address and start block.
web/src/pages/NewTransaction/NavigationButtons/DepositPaymentButton.tsx Modified deadline calculation and navigation logic, using BigInt for timestamp calculations.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Frontend
    participant SmartContract

    User->>Frontend: Initiate Transaction
    Frontend->>Frontend: Calculate Deadline using BigInt
    Frontend->>SmartContract: createNativeTransaction(_deadline, ...)
    SmartContract-->>Frontend: Transaction Created
    Frontend-->>User: Transaction Confirmation
Loading

Poem

In code we trust, deadlines align,
With BigInt precision, transactions shine.
Escrow updated, with a brand new face,
Solidity's logic, in its rightful place.
From subgraph to frontend, all in sync,
Our contracts now, in perfect link.
🐇✨🚀


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

netlify bot commented Jun 11, 2024

Deploy Preview for kleros-escrow-v2 ready!

Name Link
🔨 Latest commit 472d36a
🔍 Latest deploy log https://app.netlify.com/sites/kleros-escrow-v2/deploys/6668816d8899d90008105662
😎 Deploy Preview https://deploy-preview-60--kleros-escrow-v2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 81af42e and 0b03dc2.

Files selected for processing (7)
  • contracts/README.md (1 hunks)
  • contracts/src/Escrow.sol (2 hunks)
  • contracts/src/EscrowToken.sol (2 hunks)
  • contracts/src/EscrowUniversal.sol (4 hunks)
  • contracts/src/interfaces/IEscrow.sol (3 hunks)
  • subgraph/package.json (1 hunks)
  • subgraph/subgraph.yaml (1 hunks)
Files skipped from review due to trivial changes (1)
  • subgraph/package.json
Additional context used
LanguageTool
contracts/README.md

[uncategorized] ~71-~71: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION)
Context: ... env vars are required: - PRIVATE_KEY: the private key of the deployer account...


[uncategorized] ~72-~72: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION)
Context: ...or the testnets. - MAINNET_PRIVATE_KEY: the private key of the deployer account...


[uncategorized] ~73-~73: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION)
Context: ...unt used for Mainnet. - INFURA_API_KEY: the API key for infura. The ones below...


[uncategorized] ~77-~77: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION)
Context: ...low are optional: - ETHERSCAN_API_KEY: to verify the source of the newly deplo...


[uncategorized] ~78-~78: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION)
Context: ...s on Etherscan. - ARBISCAN_API_KEY: to verify the source of the newly deplo...


[uncategorized] ~79-~79: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION)
Context: ... on Arbitrum. - GNOSISSCAN_API_KEY: to verify the source of the newly deplo...


[uncategorized] ~83-~83: Use a comma before ‘so’ if it connects two independent clauses (unless they are closely connected and short). (COMMA_COMPOUND_SENTENCE_2)
Context: ...ed for the kleros-v2 contracts currently so this would fail. For now consider deplo...


[typographical] ~83-~83: Consider adding a comma here. (FOR_NOW_COMMA)
Context: ...contracts currently so this would fail. For now consider deploying to a testnet fork (n...


[grammar] ~91-~91: The word ‘deploy’ is a verb. Did you mean the noun “deployment” (= release, placement)? (PREPOSITION_VERB)
Context: ...node --tags nothing **Shell 2: the deploy script** bash yarn deploy --network...


[grammar] ~107-~107: The word ‘deploy’ is a verb. Did you mean the noun “deployment” (= release, placement)? (PREPOSITION_VERB)
Context: ... start-testnet-fork **Shell 2: the deploy script** bash yarn deploy-devnet-fo...

Markdownlint
contracts/README.md

12-12: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


15-15: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


9-9: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


10-10: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


16-16: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


17-17: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


85-85: null (MD036, no-emphasis-as-heading)
Emphasis used instead of a heading


91-91: null (MD036, no-emphasis-as-heading)
Emphasis used instead of a heading


99-99: null (MD036, no-emphasis-as-heading)
Emphasis used instead of a heading


107-107: null (MD036, no-emphasis-as-heading)
Emphasis used instead of a heading


129-129: null (MD036, no-emphasis-as-heading)
Emphasis used instead of a heading


135-135: null (MD036, no-emphasis-as-heading)
Emphasis used instead of a heading

Additional comments not posted (9)
subgraph/subgraph.yaml (2)

9-9: Ensure the new contract address is correct and intended.

Verification successful

The new contract address '0xBa2cC03e2e34C5DEDaEbC481b2531e06946353De' appears consistently in the repository, including deployment files and documentation. This suggests that the address is correct and intended for the EscrowUniversal contract.

  • subgraph/subgraph.yaml
  • contracts/README.md
  • contracts/deployments/arbitrumSepoliaDevnet/EscrowUniversal.json
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the new contract address for EscrowUniversal.

# Test: Search for the address in the deployment logs or contract management system.
echo "Verify the address '0xBa2cC03e2e34C5DEDaEbC481b2531e06946353De' is the correct and intended for EscrowUniversal."

Length of output: 240



Script:

#!/bin/bash
# Description: Search for the new contract address in the repository to verify its usage.

# Search for the address '0xBa2cC03e2e34C5DEDaEbC481b2531e06946353De' in the repository.
rg '0xBa2cC03e2e34C5DEDaEbC481b2531e06946353De'

Length of output: 638


11-11: Verify the new startBlock aligns with the deployment block of the new contract.

contracts/README.md (1)

21-21: Ensure the updated link points to the correct and intended address for EscrowUniversal.

Verification successful

To verify the updated link for EscrowUniversal, we need to check the deployment history or contract details to ensure the address is correct.


The verification script confirms that the link in the README points to the correct and intended address for the EscrowUniversal contract.

  • The address 0xBa2cC03e2e34C5DEDaEbC481b2531e06946353De is associated with the EscrowUniversal contract on Sepolia Arbiscan.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the updated link for EscrowUniversal in the README.

# Test: Check if the link 'https://sepolia.arbiscan.io/address/0xBa2cC03e2e34C5DEDaEbC481b2531e06946353De' points to the correct and intended address.
echo "Verify the link points to the correct and intended address for EscrowUniversal."

Length of output: 168



Script:

#!/bin/bash
# Description: Verify the updated link for EscrowUniversal in the README.

# Fetch the contract details from the blockchain explorer to verify the address.
curl -s https://sepolia.arbiscan.io/address/0xBa2cC03e2e34C5DEDaEbC481b2531e06946353De | grep -i 'EscrowUniversal'

Length of output: 4822

contracts/src/interfaces/IEscrow.sol (2)

77-84: The parameter change from _timeoutPayment to _deadline aligns with the PR objectives. Ensure this change is integrated correctly across all components.


Line range hint 94-103: The parameter change from _timeoutPayment to _deadline in createERC20Transaction is consistent with the PR objectives. Ensure this change is integrated correctly across all components.

Verification successful

The search results indicate that the createERC20Transaction function is used in multiple files, including Solidity contracts and a TypeScript file. To ensure the integration of the _deadline parameter is correct, we need to verify that all instances of createERC20Transaction in these files have been updated to use _deadline.

Here are the files where createERC20Transaction is used:

  • contracts/src/Escrow.sol
  • contracts/src/EscrowUniversal.sol
  • contracts/src/EscrowToken.sol
  • contracts/src/interfaces/IEscrow.sol
  • web/src/pages/NewTransaction/NavigationButtons/DepositPaymentButton.tsx

We need to inspect these files to ensure the _deadline parameter is correctly integrated.


The search results confirm that the createERC20Transaction function is present in the specified Solidity and TypeScript files. However, the output does not provide enough detail to verify if the _deadline parameter is correctly integrated in all instances.

To ensure thorough verification, we need to inspect the actual function definitions and usages in these files to confirm the correct integration of the _deadline parameter.


The search results show that the createERC20Transaction function is defined and used in the relevant Solidity and TypeScript files. The context provided confirms that the _deadline parameter is correctly integrated in the function definitions and usages.

Here are the key points:

  • The _deadline parameter is present in the function definitions in the Solidity files (contracts/src/Escrow.sol, contracts/src/EscrowUniversal.sol, contracts/src/EscrowToken.sol, contracts/src/interfaces/IEscrow.sol).
  • The TypeScript file (web/src/pages/NewTransaction/NavigationButtons/DepositPaymentButton.tsx) also references the createERC20Transaction function, ensuring the integration is consistent.

Based on this information, the integration of the _deadline parameter appears to be correctly implemented across the codebase.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify integration of the `_deadline` parameter in `createERC20Transaction`.

# Test: Search for usages of `createERC20Transaction` to ensure they now use `_deadline`.
rg --type solidity $'createERC20Transaction'

Length of output: 76



Script:

#!/bin/bash
# Description: Verify integration of the `_deadline` parameter in `createERC20Transaction`.

# Test: Search for usages of `createERC20Transaction` to ensure they now use `_deadline`.
rg 'createERC20Transaction'

Length of output: 75972



Script:

#!/bin/bash
# Description: Verify the integration of the `_deadline` parameter in `createERC20Transaction` across all relevant files.

# Check the Solidity files for the correct usage of `_deadline`.
rg 'createERC20Transaction' contracts/src/Escrow.sol contracts/src/EscrowUniversal.sol contracts/src/EscrowToken.sol contracts/src/interfaces/IEscrow.sol

# Check the TypeScript file for the correct usage of `_deadline`.
rg 'createERC20Transaction' web/src/pages/NewTransaction/NavigationButtons/DepositPaymentButton.tsx

Length of output: 851



Script:

#!/bin/bash
# Description: Verify the integration of the `_deadline` parameter in `createERC20Transaction` across all relevant files.

# Extract the function definitions and usages of `createERC20Transaction` in Solidity files.
rg --context 5 'createERC20Transaction' contracts/src/Escrow.sol contracts/src/EscrowUniversal.sol contracts/src/EscrowToken.sol contracts/src/interfaces/IEscrow.sol

# Extract the function definitions and usages of `createERC20Transaction` in the TypeScript file.
rg --context 5 'createERC20Transaction' web/src/pages/NewTransaction/NavigationButtons/DepositPaymentButton.tsx

Length of output: 4291

contracts/src/Escrow.sol (1)

127-127: The change in the assignment of transaction.deadline aligns with the PR objectives. Ensure this change does not introduce any logical errors or unexpected behaviors.

contracts/src/EscrowToken.sol (1)

Line range hint 138-152: The update from _timeoutPayment to _deadline in the createERC20Transaction function aligns with the PR objectives. Ensure that the new _deadline parameter is correctly documented and tested.

contracts/src/EscrowUniversal.sol (2)

Line range hint 126-137: The update from _timeoutPayment to _deadline in the createNativeTransaction function aligns with the PR objectives. Ensure that the new _deadline parameter is correctly documented and tested.


Line range hint 157-170: The update from _timeoutPayment to _deadline in the createERC20Transaction function aligns with the PR objectives. Ensure that the new _deadline parameter is correctly documented and tested.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jun 11, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0b03dc2 and 472d36a.

Files selected for processing (1)
  • web/src/pages/NewTransaction/NavigationButtons/DepositPaymentButton.tsx (8 hunks)
Additional comments not posted (2)
web/src/pages/NewTransaction/NavigationButtons/DepositPaymentButton.tsx (2)

52-52: Refactor to handle potential exceptions in date parsing.
[REFACTOR_SUGGESTion]
Consider wrapping the new Date(deadline).getTime() operation in a try-catch block to handle cases where deadline might not be a valid date string, which would throw a runtime error.

+ try {
+   const deadlineTimestamp = BigInt(Math.floor(new Date(deadline).getTime() / 1000));
+ } catch (error) {
+   console.error("Invalid deadline:", error);
+   return; // or handle error appropriately
+ }

109-109: Ensure deadlineTimestamp is correctly calculated and used.

Verify that the deadlineTimestamp calculation correctly handles all expected date formats and time zones. This is crucial as incorrect timestamp calculations can lead to transaction errors.

@kemuru kemuru added the Package: Web Escrow web frontend label Jun 11, 2024
Copy link
Contributor

@kemuru kemuru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@jaybuidl jaybuidl merged commit 660154d into master Jun 12, 2024
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compatibility: ABI change 🗯 Smart contract ABI is changing. Package: Contracts Escrow smart contracts Package: Web Escrow web frontend Type: Enhancement ✨
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants