Skip to content

Illia malachyn/embed scripts to rosetta - #66

Merged
franklywatson merged 4 commits into
onflow:mainfrom
The-K-R-O-K:illia-malachyn/embed-scripts-to-rosetta
Sep 12, 2024
Merged

Illia malachyn/embed scripts to rosetta#66
franklywatson merged 4 commits into
onflow:mainfrom
The-K-R-O-K:illia-malachyn/embed-scripts-to-rosetta

Conversation

@illia-malachyn

@illia-malachyn illia-malachyn commented Sep 9, 2024

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Introduced a function to compute transaction fees based on user-defined parameters.
    • Added a function to retrieve the public key from a user's FlowColdStorageProxy vault.
    • Enabled account creation with multiple public keys for enhanced security and flexibility.
  • Chores

    • Updated configuration settings in JSON files to reflect new spork versioning and root block adjustments.
    • Transitioned from constant string definitions to embedded scripts for improved maintainability and readability.

@illia-malachyn
illia-malachyn requested a review from a team as a code owner September 9, 2024 13:12
@coderabbitai

coderabbitai Bot commented Sep 9, 2024

Copy link
Copy Markdown

Warning

Rate limit exceeded

@illia-malachyn has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 1 minutes and 28 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between a53348d and 0e9da46.

Walkthrough

This pull request introduces several new functionalities to the Flow blockchain ecosystem. It includes a smart contract function for computing transaction fees based on specified efforts, a function for retrieving public keys from user vaults, and a transaction for creating accounts with multiple public keys. Additionally, it updates the Go script to utilize embedded Cadence scripts, enhancing maintainability. Configuration files are also modified to reflect new spork identifiers and root block values.

Changes

File Path Change Summary
script/cadence/scripts/compute-fees.cdc Added a function to compute transaction fees based on inclusion and execution efforts.
script/cadence/scripts/get-proxy-public-key.cdc Added a function to retrieve the public key from a user's FlowColdStorageProxy vault.
script/cadence/transactions/create-account.cdc Introduced a transaction for creating accounts with specified public keys.
script/script.go Replaced constant string definitions with embedded Cadence scripts for improved maintainability.
testnet-clone.json, testnet.json Updated spork identifier and root block values in configuration files.

Possibly related PRs

🐇 In the meadow, changes sprout,
New functions dance, without a doubt.
Public keys and fees, all in a row,
With scripts embedded, watch them glow!
Hopping forward, we celebrate,
A brighter Flow, oh isn’t it great? 🌼


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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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.

@illia-malachyn
illia-malachyn force-pushed the illia-malachyn/embed-scripts-to-rosetta branch from bf7e5c4 to f5b3065 Compare September 9, 2024 13:13

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Outside diff range, codebase verification and nitpick comments (7)
script/script.go (7)

87-88: Incorrect file path in go:embed directive.

The go:embed directive specifies the path cadence/transactions/proxy-contract-update.cdc, but the actual file is located at script/cadence/transactions/proxy-contract-update.cdc. Please update the path in the directive to ensure the file is correctly embedded.

  • Update the path in the go:embed directive to script/cadence/transactions/proxy-contract-update.cdc.
Analysis chain

Embed directive correctly applied to SetContract.

The go:embed directive has been correctly applied to the SetContract variable. Please verify that the path to the cadence/transactions/proxy-contract-update.cdc file is correct and that the file exists.

Run the following script to verify the file existence:

#!/bin/bash
# Description:

</details>

<details>
<summary>Scripts executed</summary>

The following scripts were executed for the analysis:



---

Script:

```shell
#!/bin/bash
# Check for the existence of the file `proxy-contract-update.cdc` in the `cadence/transactions` directory.
fd 'proxy-contract-update.cdc' --glob 'cadence/transactions'

Length of output: 166


Script:

#!/bin/bash
# Search for the file `proxy-contract-update.cdc` across the entire repository.
fd 'proxy-contract-update.cdc'

Length of output: 84


20-21: Incorrect path in go:embed directive for BasicTransfer.

The go:embed directive specifies the path as cadence/transactions/basic-transfer.cdc, but the actual path is script/cadence/transactions/basic-transfer.cdc. Please update the path in the directive to ensure the file is correctly embedded.

  • Update the path in the go:embed directive to script/cadence/transactions/basic-transfer.cdc.
Analysis chain

Embed directive correctly applied to BasicTransfer.

The go:embed directive has been correctly applied to the BasicTransfer variable. Please verify that the path to the cadence/transactions/basic-transfer.cdc file is correct and that the file exists.

Run the following script to verify the file existence:

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of the embedded file.

# Test: Check if the file exists. Expect: File exists.
fd 'basic-transfer.cdc' 'cadence/transactions'

Length of output: 152


Script:

#!/bin/bash
# Description: Search for the basic-transfer.cdc file across the entire repository.

# Test: Locate the file. Expect: File path is returned if it exists.
fd 'basic-transfer.cdc'

Length of output: 70


37-38: Incorrect file path in go:embed directive.

The create-proxy-account.cdc file exists in the repository at script/cadence/transactions/create-proxy-account.cdc. Please update the go:embed directive to use the correct path.

  • Update the path in the go:embed directive to script/cadence/transactions/create-proxy-account.cdc.
Analysis chain

Embed directive correctly applied to CreateProxyAccount.

The go:embed directive has been correctly applied to the CreateProxyAccount variable. Please verify that the path to the cadence/transactions/create-proxy-account.cdc file is correct and that the file exists.

Run the following script to verify the file existence:

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of the embedded file.

# Test: Check if the file exists. Expect: File exists.
fd 'create-proxy-account.cdc' 'cadence/transactions'

Length of output: 158


Script:

#!/bin/bash
# Description: Search for the 'create-proxy-account.cdc' file across the entire repository.

# Test: Locate the file. Expect: File path is returned if it exists.
fd 'create-proxy-account.cdc'

Length of output: 82


50-51: Update the embed path for GetBalances.

The get-balances.cdc file exists at script/cadence/scripts/get-balances.cdc. Please update the go:embed directive to use this correct path to ensure proper embedding.

  • Update the path in the go:embed directive to script/cadence/scripts/get-balances.cdc.
Analysis chain

Embed directive correctly applied to GetBalances.

The go:embed directive has been correctly applied to the GetBalances variable. Please verify that the path to the cadence/scripts/get-balances.cdc file is correct and that the file exists.

Run the following script to verify the file existence:

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of the embedded file.

# Test: Check if the file exists. Expect: File exists.
fd 'get-balances.cdc' 'cadence/scripts'

Length of output: 140


Script:

#!/bin/bash
# Description: Search for the get-balances.cdc file across the entire repository.

# Test: Check if the file exists anywhere in the repository. Expect: File exists.
fd 'get-balances.cdc'

Length of output: 61


25-26: Correct the path in the go:embed directive.

The file compute-fees.cdc exists at script/cadence/scripts/compute-fees.cdc. Please update the path in the go:embed directive to reflect this location:

  • Change cadence/scripts/compute-fees.cdc to script/cadence/scripts/compute-fees.cdc in the go:embed directive.
Analysis chain

Embed directive correctly applied to ComputeFees.

The go:embed directive has been correctly applied to the ComputeFees variable. Please verify that the path to the cadence/scripts/compute-fees.cdc file is correct and that the file exists.

Run the following script to verify the file existence:

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of the embedded file.

# Test: Check if the file exists. Expect: File exists.
fd 'compute-fees.cdc' 'cadence/scripts'

Length of output: 140


Script:

#!/bin/bash
# Description: Search for the compute-fees.cdc file across the entire repository.

# Test: Search for the file. Expect: File found.
fd 'compute-fees.cdc'

Length of output: 61


31-32: Incorrect path in go:embed directive for CreateAccount.

The create-account.cdc file exists at script/cadence/transactions/create-account.cdc, but the go:embed directive specifies the path as cadence/transactions/create-account.cdc. Please update the path in the directive to include the script/ prefix to ensure it functions correctly.

  • Update the path in the go:embed directive to script/cadence/transactions/create-account.cdc.
Analysis chain

Embed directive correctly applied to CreateAccount.

The go:embed directive has been correctly applied to the CreateAccount variable. Please verify that the path to the cadence/transactions/create-account.cdc file is correct and that the file exists.

Run the following script to verify the file existence:

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of the embedded file.

# Test: Check if the file exists. Expect: File exists.
fd 'create-account.cdc' 'cadence/transactions'

Length of output: 152


Script:

#!/bin/bash
# Description: Search for the create-account.cdc file across the entire repository.

# Test: Check if the file exists anywhere in the repository. Expect: File exists.
fd 'create-account.cdc'

Length of output: 70


66-67: Correct the path in the go:embed directive.

The file get-proxy-nonce.cdc exists at script/cadence/scripts/get-proxy-nonce.cdc. Please update the go:embed directive to use this correct path to ensure the file is embedded properly.

  • Incorrect path: cadence/scripts/get-proxy-nonce.cdc
  • Correct path: script/cadence/scripts/get-proxy-nonce.cdc
Analysis chain

Embed directive correctly applied to GetProxyNonce.

The go:embed directive has been correctly applied to the GetProxyNonce variable. Please verify that the path to the cadence/scripts/get-proxy-nonce.cdc file is correct and that the file exists.

Run the following script to verify the file existence:

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of the embedded file.

# Test: Check if the file exists. Expect: File exists.
fd 'get-proxy-nonce.cdc' 'cadence/scripts'

Length of output: 143


Script:

#!/bin/bash
# Description: Search for the get-proxy-nonce.cdc file across the entire repository.

# Test: Check if the file exists anywhere in the repository.
fd 'get-proxy-nonce.cdc'

Length of output: 67

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 41d1988 and a53348d.

Files selected for processing (6)
  • script/cadence/scripts/compute-fees.cdc (1 hunks)
  • script/cadence/scripts/get-proxy-public-key.cdc (1 hunks)
  • script/cadence/transactions/create-account.cdc (1 hunks)
  • script/script.go (2 hunks)
  • testnet-clone.json (1 hunks)
  • testnet.json (1 hunks)
Additional comments not posted (8)
script/cadence/scripts/compute-fees.cdc (1)

1-5: Well-structured and clear function implementation.

The function main is well-implemented with clear usage of named parameters, enhancing readability and reducing potential errors. The import statement is correctly placed and used.

testnet-clone.json (2)

27-27: Root block updated correctly.

The "root_block" value has been updated from 185185854 to 211176670. Please verify the correctness of this value with the blockchain state.

Run the following script to verify the root block value:


21-27: Spork identifier updated correctly.

The spork identifier has been updated from "50" to "51". Please ensure that this change is reflected across all relevant configuration files and systems.

Run the following script to verify the spork usage:

Verification successful

Spork identifier updated correctly across the codebase.

The spork identifier "50" is not present in the codebase, confirming that the update to "51" has been successfully applied across all files. No further action is required.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all configuration files reflect the new spork identifier.

# Test: Search for the old spork identifier. Expect: No occurrences.
rg --type json -A 5 $'\"50\"'

Length of output: 28


Script:

#!/bin/bash
# Description: Verify all files reflect the new spork identifier.

# Test: Search for the old spork identifier across all file types. Expect: No occurrences.
rg -A 5 '"50"'

Length of output: 16

testnet.json (2)

29-29: Root block updated correctly.

The "root_block" value has been updated from 185185854 to 211176670. Please verify the correctness of this value with the blockchain state.

Run the following script to verify the root block value:

Verification successful

Root block value updated successfully.

The new "root_block" value (211176670) is correctly present in the testnet.json file, confirming the update was applied as intended. No further issues were found.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of the "root_block" value.

# Test: Search for the old root block value. Expect: No occurrences.
rg --type json -A 5 $'185185854'

Length of output: 31


Script:

#!/bin/bash
# Description: Verify the presence of the new "root_block" value.

# Test: Search for the new root block value. Expect: At least one occurrence.
rg --type json -A 5 $'211176670'

Length of output: 354


23-29: Spork identifier updated correctly.

The spork identifier has been updated from "50" to "51". Please ensure that this change is reflected across all relevant configuration files and systems.

Run the following script to verify the spork usage:

Verification successful

Spork identifier update verified successfully.

The old spork identifier "50" is no longer present, and the new spork identifier "51" is correctly reflected in the relevant configuration files, such as testnet.json and testnet-clone.json. The update appears to be consistent and complete.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all configuration files reflect the new spork identifier.

# Test: Search for the old spork identifier. Expect: No occurrences.
rg --type json -A 5 $'\"50\"'

Length of output: 28


Script:

#!/bin/bash
# Description: Verify all configuration files reflect the new spork identifier.

# Test: Search for the old spork identifier. Expect: No occurrences.
rg --type json -A 5 $'\"50\"'

# Test: Search for the new spork identifier. Expect: Occurrences in relevant files.
rg --type json -A 5 $'\"51\"'

Length of output: 585

script/script.go (3)

75-76: Embed directive correctly applied to GetProxyPublicKey.

The go:embed directive has been correctly applied to the GetProxyPublicKey variable. Please verify that the path to the cadence/scripts/get-proxy-public-key.cdc file is correct and that the file exists.

Run the following script to verify the file existence:

Verification successful

File get-proxy-public-key.cdc exists and path is correct.

The file get-proxy-public-key.cdc was found at the path script/cadence/scripts/get-proxy-public-key.cdc, confirming that the go:embed directive is correctly referencing the file. No further action is needed.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of the embedded file.

# Test: Check if the file exists. Expect: File exists.
fd 'get-proxy-public-key.cdc' 'cadence/scripts'

Length of output: 148


Script:

#!/bin/bash
# Description: Search for the file `get-proxy-public-key.cdc` across the entire repository.

# Test: Check if the file exists anywhere in the repository.
fd 'get-proxy-public-key.cdc'

Length of output: 77


56-57: Embed directive correctly applied to GetBalancesBasic.

The go:embed directive has been correctly applied to the GetBalancesBasic variable. Please verify that the path to the cadence/scripts/get-balances-basic.cdc file is correct and that the file exists.

Run the following script to verify the file existence:

Verification successful

File get-balances-basic.cdc successfully located.

The file get-balances-basic.cdc has been found at script/cadence/scripts/get-balances-basic.cdc, confirming that the go:embed directive is correctly referencing an existing file. No further action is needed.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of the embedded file.

# Test: Check if the file exists. Expect: File exists.
fd 'get-balances-basic.cdc' 'cadence/scripts'

Length of output: 146


Script:

#!/bin/bash
# Description: Search for the 'get-balances-basic.cdc' file in the entire repository.

# Test: Check if the file exists anywhere in the repository.
fd 'get-balances-basic.cdc'

Length of output: 73


81-82: Embed directive correctly applied to ProxyTransfer.

The go:embed directive has been correctly applied to the ProxyTransfer variable. Please verify that the path to the cadence/transactions/proxy-transfer.cdc file is correct and that the file exists.

Run the following script to verify the file existence:

Verification successful

Embed directive correctly references existing file.

The proxy-transfer.cdc file exists at the specified path, and the go:embed directive is correctly applied. No further action is needed regarding the file path.

  • File path: script/cadence/transactions/proxy-transfer.cdc
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of the embedded file.

# Test: Check if the file exists. Expect: File exists.
fd 'proxy-transfer.cdc' 'cadence/transactions'

Length of output: 152


Script:

#!/bin/bash
# Description: Verify the existence of the directory and the embedded file.

# Test 1: Check if the 'cadence' directory exists.
fd --type d 'cadence'

# Test 2: Check if the 'proxy-transfer.cdc' file exists anywhere in the repository.
fd 'proxy-transfer.cdc'

Length of output: 108

Comment thread script/cadence/scripts/get-proxy-public-key.cdc
Comment thread script/cadence/transactions/create-account.cdc
Comment thread testnet-clone.json
"address": "access.devnet.nodes.onflow.org:9000"
}
],
"root_block": 185185854,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Be sure to double-check that these values are correct. Thanks for the cleanup!!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@franklywatson
franklywatson merged commit 77ba663 into onflow:main Sep 12, 2024
@franklywatson
franklywatson deleted the illia-malachyn/embed-scripts-to-rosetta branch September 12, 2024 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants