-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into ism-integrartion
- Loading branch information
Showing
4 changed files
with
106 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*.*.*' | ||
|
||
jobs: | ||
artifact: | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
name: artifact | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: software-mansion/setup-scarb@v1 | ||
- name: Build contracts | ||
run: scarb build | ||
- name: Archive contracts | ||
run: | | ||
mkdir -p filtered_artifacts | ||
find ./target/dev -type f -name '*.contract_class.json' -exec cp {} filtered_artifacts/ \; | ||
- name: Generate checksums | ||
run: | | ||
cd filtered_artifacts | ||
for file in *; do | ||
sha256sum "$file" > "$file.sha256" | ||
md5sum "$file" > "$file.md5" | ||
done | ||
- name: Build artifact zip | ||
run: | | ||
cd filtered_artifacts | ||
zip -r ../hyperlane-starknet-${{ github.ref_name }}.zip . | ||
cd .. | ||
sha256sum hyperlane-starknet-${{ github.ref_name }}.zip > hyperlane-starknet-${{ github.ref_name }}.CHECKSUM | ||
md5sum hyperlane-starknet-${{ github.ref_name }}.zip > hyperlane-starknet-${{ github.ref_name }}.CHECKSUM.MD5 | ||
- name: Find zip files | ||
run: | | ||
find ./filtered_artifacts -type f -name '*.zip' -exec echo "::set-output name=zip_files::{}" \; | ||
id: find_zip_files | ||
|
||
- name: Release Artifact | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: | | ||
hyperlane-starknet-${{ github.ref_name }}.zip | ||
hyperlane-starknet-${{ github.ref_name }}.CHECKSUM | ||
hyperlane-starknet-${{ github.ref_name }}.CHECKSUM.MD5 | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: tests | ||
on: | ||
push: | ||
pull_request: | ||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: software-mansion/setup-scarb@v1 | ||
- uses: foundry-rs/setup-snfoundry@v3 | ||
- run: scarb fmt --check | ||
- run: scarb build | ||
- run: snforge test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,21 @@ | ||
use core::integer::u128_byte_reverse; | ||
|
||
/// Reverse the endianness of an u256 | ||
pub fn reverse_endianness(value: u256) -> u256 { | ||
let new_low = u128_byte_reverse(value.high); | ||
let new_high = u128_byte_reverse(value.low); | ||
u256 { low: new_low, high: new_high } | ||
} | ||
|
||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::reverse_endianness; | ||
#[test] | ||
fn test_reverse_endianness() { | ||
let big_endian_number: u256 = u256 { high: 0x12345678, low: 0 }; | ||
let expected_result: u256 = u256 { high: 0, low: 0x78563412000000000000000000000000 }; | ||
assert( | ||
reverse_endianness(big_endian_number) == expected_result, 'Failed to realise reverse' | ||
); | ||
} | ||
} |