Skip to content

Conversation

@minhd-vu
Copy link
Contributor

@minhd-vu minhd-vu commented Sep 5, 2024

Motivation

  • Sometimes when using cast send or cast mktx, it would be nice to be able to provide an access list

Solution

  • Adds --access-list flag for transactions
  • --access-list provided with no value will use cast access-list to populate the access list
--access-list '[
  {
    "address": "0x528e26b25a34a4a5d0dbda1d57d318153d2ed582",
    "storageKeys": [
      "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103",
      "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc"
    ]
  },
  {
    "address": "0x1f4479ccb333fcba58e68f04e38f3ab070983b31",
    "storageKeys": []
  }
]'

@minhd-vu minhd-vu marked this pull request as ready for review September 5, 2024 22:30
}

// Parses a `AccessList` from a &str
pub fn parse_access_list(s: &str) -> Result<AccessList> {
Copy link
Member

Choose a reason for hiding this comment

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

hmm, I am wondering if we should add some additional formats for better UX here? eg fallback to comma-separated addresses list or something similar

Copy link
Member

Choose a reason for hiding this comment

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

@minhd-vu let's make access_list arg an Option<Option<String>> and if just --access-list with no value is provided, we'll use provider.create_access_list to create it through RPC

I think this would be pretty useful and would allow us to keep a way to invoke it without manually providing JSON access list

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like that idea, I'll try my best to implement it.

Copy link
Member

Choose a reason for hiding this comment

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

let me know if any questions!

@minhd-vu minhd-vu marked this pull request as draft September 10, 2024 17:21
@minhd-vu minhd-vu marked this pull request as ready for review September 11, 2024 23:01
tx.set_nonce(nonce.to());
}

if let Some(access_list) = match tx_opts.access_list {
Copy link
Member

Choose a reason for hiding this comment

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

we should do it right before estimating gas in _build

we don't yet have calldata here, so calling rpc will result in incomplete data or an error

@minhd-vu minhd-vu marked this pull request as draft September 12, 2024 16:42
@minhd-vu minhd-vu marked this pull request as ready for review September 16, 2024 04:35
@minhd-vu minhd-vu requested review from klkvr and mattsse September 16, 2024 04:35
@mattsse mattsse merged commit f141a43 into foundry-rs:master Sep 16, 2024
20 checks passed
@minhd-vu minhd-vu deleted the access-list branch September 16, 2024 13:55
rplusq pushed a commit to rplusq/foundry that referenced this pull request Sep 25, 2024
* add access list

* fix lint

* improve

* set access list even if legacy is true

* update grammar

* update comment to doc string

* call access list if no string provided

* address comments

* update docs

* update docs again

* address comments

* refactor
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