diff --git a/.envrc b/.envrc index a3693d2..a93d020 100644 --- a/.envrc +++ b/.envrc @@ -1,3 +1,4 @@ +# shellcheck shell=bash if ! has nix_direnv_version || ! nix_direnv_version 3.0.6; then URL=https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.6/direnvrc HASH=sha256-RYcUJaRMf8oF5LznDrlCXbkOQrywm0HDv1VjYGaJGdM= diff --git a/.github/workflows/pr-assessment.yaml b/.github/workflows/pr-assessment.yaml index 71c5461..18e484f 100644 --- a/.github/workflows/pr-assessment.yaml +++ b/.github/workflows/pr-assessment.yaml @@ -3,7 +3,6 @@ on: pull_request: types: - closed - jobs: assess-pr-size-on-merge: uses: rainlanguage/github-chore/.github/workflows/pr-assessment.yml@main diff --git a/.github/workflows/rainix-rs.yaml b/.github/workflows/rainix-rs.yaml new file mode 100644 index 0000000..4805435 --- /dev/null +++ b/.github/workflows/rainix-rs.yaml @@ -0,0 +1,9 @@ +name: rainix-rs +on: [push] +jobs: + static: + uses: rainlanguage/rainix/.github/workflows/rainix-rs-static.yaml@main + test: + uses: rainlanguage/rainix/.github/workflows/rainix-rs-test.yaml@main + wasm: + uses: rainlanguage/rainix/.github/workflows/rainix-rs-wasm.yaml@main diff --git a/.github/workflows/rainix.yaml b/.github/workflows/rainix.yaml deleted file mode 100644 index 14cf3d3..0000000 --- a/.github/workflows/rainix.yaml +++ /dev/null @@ -1,47 +0,0 @@ -name: Rainix CI -on: [push] - -concurrency: - group: ${{ github.ref }}-rainix - cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} - -jobs: - standard-tests: - strategy: - matrix: - os: [ubuntu-latest, macos-latest] - task: [rainix-rs-test, rainix-rs-artifacts] - include: - # We don't need to do rust static analysis on multiple platforms - - os: ubuntu-latest - task: rainix-rs-static - fail-fast: false - runs-on: ${{ matrix.os }} - env: - TEST_POLYGON_RPC: ${{ secrets.CI_DEPLOY_POLYGON_RPC_URL }} - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - fetch-depth: 0 - - - uses: nixbuild/nix-quick-install-action@v30 - with: - nix_conf: | - keep-env-derivations = true - keep-outputs = true - - name: Restore and save Nix store - uses: nix-community/cache-nix-action@v6 - with: - # restore and save a cache using this key - primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }} - # if there's no cache hit, restore a cache by this prefix - restore-prefixes-first-match: nix-${{ runner.os }}- - gc-max-store-size-linux: 5G - - - run: nix develop -c rainix-rs-prelude - - name: Run ${{ matrix.task }} - run: nix develop -c ${{ matrix.task }} - - - name: Build for wasm target - run: nix develop -c cargo build --target wasm32-unknown-unknown diff --git a/.vscode/settings.json b/.vscode/settings.json index 3905ae4..9119366 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,3 @@ { - "editor.rulers": [80] -} \ No newline at end of file + "editor.rulers": [80] +} diff --git a/README.md b/README.md index 65e4ad9..678795f 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,22 @@ ## Crate for Safe Typecasting between Ethers and Alloy types + Currently supporting type conversion for: -- `ethers::types::H160` to `alloy_primitives::Address` + +- `ethers::types::H160` to `alloy_primitives::Address` - `alloy_primitives::Address` to `ethers::types::H160` -- `ethers::types::U256` to `alloy_primitives::U256` -- `alloy_primitives::U256` to `ethers::types::U256` -- `ethers::types::Bytes` to `alloy_primitives::Bytes` -- `alloy_primitives::Bytes` to `ethers::types::Bytes` +- `ethers::types::U256` to `alloy_primitives::U256` +- `alloy_primitives::U256` to `ethers::types::U256` +- `ethers::types::Bytes` to `alloy_primitives::Bytes` +- `alloy_primitives::Bytes` to `ethers::types::Bytes` ## Example + ```sh let ethers_address: ethers::types::H160 = ethers::types::H160::random(); let alloy_address: alloy_primitives::Address = ethers_address_to_alloy(ethers_address); ``` + ```sh let ethers_u256: ethers::types::U256 = ethers::types::U256::from_dec_str("126731272983"); let alloy_u256: alloy_primitives::U256 = ethers_u256_to_alloy(ethers_u256); -``` \ No newline at end of file +``` diff --git a/flake.lock b/flake.lock index 09614c3..5d4a9cb 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,21 @@ { "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1767039857, + "narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=", + "owner": "NixOS", + "repo": "flake-compat", + "rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "flake-compat", + "type": "github" + } + }, "flake-utils": { "inputs": { "systems": "systems" @@ -75,11 +91,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1741023058, - "narHash": "sha256-LSd/8CBlpDLjci5ANFJjP0w+dGdY/mqKsyUfhjGwnfs=", + "lastModified": 1778486972, + "narHash": "sha256-iuy/TbK9AbghEld2VSFuxyAF30LkOGUUdtrvixLfE7M=", "owner": "shazow", "repo": "foundry.nix", - "rev": "66becfe20b7e688b8f2e5774609c4436cf202ba0", + "rev": "db117ae95a77b9ead24137c3ccb28896ae4fa4ec", "type": "github" }, "original": { @@ -88,6 +104,48 @@ "type": "github" } }, + "git-hooks-nix": { + "inputs": { + "flake-compat": "flake-compat", + "gitignore": "gitignore", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1778507602, + "narHash": "sha256-kTwur1wV+01SdqskVMSo6JMEpg71ps3HpbFY2GsflKs=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "61ab0e80d9c7ab14c256b5b453d8b3fb0189ba0a", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "rainix", + "git-hooks-nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1666753130, @@ -104,11 +162,27 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1747828570, - "narHash": "sha256-tv8R4Z/69GC8zogsb5TNDRj5tkhMeHpyYIzRl1cJigo=", + "lastModified": 1770073757, + "narHash": "sha256-Vy+G+F+3E/Tl+GMNgiHl9Pah2DgShmIUBJXmbiQPHbI=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "47472570b1e607482890801aeaf29bfb749884f6", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1778656924, + "narHash": "sha256-lKVrom9wOmpC3i7m+uBoGaBdW0PfH3QbLRG1XmuC6YA=", "owner": "nixos", "repo": "nixpkgs", - "rev": "040a62f13f40879a05578a66dd4ae0d284c55a5b", + "rev": "4ba039de0909446943c07e2b42bd2f0f4507072e", "type": "github" }, "original": { @@ -117,7 +191,7 @@ "type": "github" } }, - "nixpkgs_3": { + "nixpkgs_4": { "locked": { "lastModified": 1744536153, "narHash": "sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38=", @@ -133,13 +207,13 @@ "type": "github" } }, - "nixpkgs_4": { + "nixpkgs_5": { "locked": { - "lastModified": 1731531548, - "narHash": "sha256-sz8/v17enkYmfpgeeuyzniGJU0QQBfmAjlemAUYhfy8=", + "lastModified": 1777641297, + "narHash": "sha256-WNGcmeOZ8Tr9dq6ztCspYbzWFswr2mPebM9LpsfGxPk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "24f0d4acd634792badd6470134c387a3b039dace", + "rev": "c6d65881c5624c9cae5ea6cedef24699b0c0a4c0", "type": "github" }, "original": { @@ -153,20 +227,21 @@ "inputs": { "flake-utils": "flake-utils_2", "foundry": "foundry", - "nixpkgs": "nixpkgs_2", + "git-hooks-nix": "git-hooks-nix", + "nixpkgs": "nixpkgs_3", "rust-overlay": "rust-overlay", "solc": "solc" }, "locked": { - "lastModified": 1748346550, - "narHash": "sha256-Rlaj/hHHACo0blFKane6/arqIXWUCGe/sCNgqX8VfZ8=", - "owner": "rainprotocol", + "lastModified": 1780287289, + "narHash": "sha256-eZ74zj6VwotSmT1kXImwA2yX0el0pZthcgNjg7j/AyQ=", + "owner": "rainlanguage", "repo": "rainix", - "rev": "a1a5c321f356cb5006d16dd2d1a2242c183b7e96", + "rev": "f22d4dcaca61717e33eac65e7b09b9a82f604c1f", "type": "github" }, "original": { - "owner": "rainprotocol", + "owner": "rainlanguage", "repo": "rainix", "type": "github" } @@ -179,14 +254,14 @@ }, "rust-overlay": { "inputs": { - "nixpkgs": "nixpkgs_3" + "nixpkgs": "nixpkgs_4" }, "locked": { - "lastModified": 1747795013, - "narHash": "sha256-c7i0xJ+xFhgjO9SWHYu5dF/7lq63RPDvwKAdjc6VCE4=", + "lastModified": 1778642276, + "narHash": "sha256-bhk4lawR4ZnFhPtamB5WkCyvfgyZmsEUbWfT/3FRxFY=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "6b1cf12374361859242a562e1933a7930649131a", + "rev": "77265d2dc1e61b2abfd3b1d6609dbb66fe75e0a5", "type": "github" }, "original": { @@ -198,15 +273,15 @@ "solc": { "inputs": { "flake-utils": "flake-utils_4", - "nixpkgs": "nixpkgs_4", + "nixpkgs": "nixpkgs_5", "solc-macos-amd64-list-json": "solc-macos-amd64-list-json" }, "locked": { - "lastModified": 1742758229, - "narHash": "sha256-FrU9rhab/0vOjjeFoQF+Ej43zRLv3enUIYjgLrH3Gd8=", + "lastModified": 1777817996, + "narHash": "sha256-iI71iUhD7THLibl3w1JcQEhHmTwZMxChi70RTe33BAo=", "owner": "hellwolf", "repo": "solc.nix", - "rev": "6885b61bac89da19a6e3c70b89fdd592e2cef884", + "rev": "e3cf898cb804d5c0e5474b378a300fe8942e67d6", "type": "github" }, "original": { @@ -218,13 +293,13 @@ "solc-macos-amd64-list-json": { "flake": false, "locked": { - "narHash": "sha256-U5ckttxwKO13gIKggel6iybG5oTDbSidPR5nH3Gs+kY=", + "narHash": "sha256-zzwwHA2qPotv7yp8mK7+y9BZhm7ytuFeCJVvKBBdBn4=", "type": "file", - "url": "https://github.com/ethereum/solc-bin/raw/30a3695/macosx-amd64/list.json" + "url": "https://github.com/argotorg/solc-bin/raw/902dfaf/macosx-amd64/list.json" }, "original": { "type": "file", - "url": "https://github.com/ethereum/solc-bin/raw/30a3695/macosx-amd64/list.json" + "url": "https://github.com/argotorg/solc-bin/raw/902dfaf/macosx-amd64/list.json" } }, "systems": { diff --git a/flake.nix b/flake.nix index 92f7c3a..cfe58fd 100644 --- a/flake.nix +++ b/flake.nix @@ -2,11 +2,12 @@ description = "Flake for development workflows."; inputs = { - rainix.url = "github:rainprotocol/rainix"; + rainix.url = "github:rainlanguage/rainix"; flake-utils.url = "github:numtide/flake-utils"; }; - outputs = { self, flake-utils, rainix }: + outputs = + { flake-utils, rainix, ... }: flake-utils.lib.eachDefaultSystem (system: { packages = rainix.packages.${system}; devShells = rainix.devShells.${system};