Skip to content
This repository was archived by the owner on Jun 18, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
any-changes-founds: ${{ steps.any-changes-found.outputs.changes-found }}
test-rust: ${{ steps.rust-changes.outputs.changes-found }}
steps:
- uses: actions/checkout@v2.4.0
- uses: actions/checkout@v3.0.2
with:
# This ensures that the tip of the PR is checked out instead of the merge between the base ref and the tip
# On `push` this value will be empty and will "do-the-right-thing"
Expand Down Expand Up @@ -49,7 +49,7 @@ jobs:
needs: prepare
# if: ${{ needs.prepare.outputs.any-changes-founds == 'true' }}
steps:
- uses: actions/checkout@v2.4.0
- uses: actions/checkout@v3.0.2
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: ./.github/actions/build-setup
Expand All @@ -68,7 +68,7 @@ jobs:
needs: prepare
# if: ${{ needs.prepare.outputs.test-rust == 'true' }}
steps:
- uses: actions/checkout@v2.4.0
- uses: actions/checkout@v3.0.2
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0 #get all the history!!!
Expand All @@ -88,7 +88,7 @@ jobs:
needs: prepare
# if: ${{ needs.prepare.outputs.test-rust == 'true' }}
steps:
- uses: actions/checkout@v2.4.0
- uses: actions/checkout@v3.0.2
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: ./.github/actions/build-setup
Expand Down Expand Up @@ -119,7 +119,7 @@ jobs:
# needs: prepare
# if: ${{ needs.prepare.outputs.test-rust == 'true' }}
# steps:
# - uses: actions/checkout@v2.4.0
# - uses: actions/checkout@v3.0.2
# with:
# ref: ${{ github.event.pull_request.head.sha }}
# - uses: ./.github/actions/build-setup
Expand All @@ -142,7 +142,7 @@ jobs:
# env:
# CRITERION_HOME: /tmp/benches
# steps:
# - uses: actions/checkout@v2.4.0
# - uses: actions/checkout@v3.0.2
# with:
# ref: ${{ github.event.pull_request.head.sha }}
# - uses: actions/[email protected]
Expand Down Expand Up @@ -173,7 +173,7 @@ jobs:
needs:
- prepare
steps:
- uses: actions/checkout@v2.4.0
- uses: actions/checkout@v3.0.2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Use Node.js 14
Expand Down Expand Up @@ -211,7 +211,7 @@ jobs:
needs:
- prepare
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3.0.2
- name: Set up Ruby 2.6
uses: actions/setup-ruby@v1
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
env:
AUDIT_SUMMARY_FILE: /tmp/summary
steps:
- uses: actions/checkout@v2.4.0
- uses: actions/checkout@v3.0.2
with:
ref: ${{ matrix.target-branch }}
- uses: ./.github/actions/build-setup
Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:
matrix:
target-branch: [main]
steps:
- uses: actions/checkout@v2.4.0
- uses: actions/checkout@v3.0.2
with:
ref: ${{ matrix.target-branch }}
- uses: ./.github/actions/build-setup
Expand Down
28 changes: 11 additions & 17 deletions language/move-core/types/src/account_address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl AccountAddress {

let hex_len = literal.len() - 2;

// If the string is too short, pad it because it needs to be exactly the right number of bytes
// If the string is too short, pad it
if hex_len < Self::LENGTH * 2 {
let mut hex_str = String::with_capacity(Self::LENGTH * 2);
for _ in 0..Self::LENGTH * 2 - hex_len {
Expand All @@ -92,7 +92,7 @@ impl AccountAddress {
}

pub fn to_hex(&self) -> String {
self.short_str_lossless()
format!("{:x}", self)
}

pub fn from_bytes<T: AsRef<[u8]>>(bytes: T) -> Result<Self, AccountAddressParseError> {
Expand Down Expand Up @@ -206,23 +206,23 @@ impl From<&AccountAddress> for [u8; AccountAddress::LENGTH] {

impl From<&AccountAddress> for String {
fn from(addr: &AccountAddress) -> String {
addr.to_hex_literal()
::hex::encode(addr.as_ref())
}
}

impl TryFrom<String> for AccountAddress {
type Error = AccountAddressParseError;

fn try_from(s: String) -> Result<AccountAddress, AccountAddressParseError> {
AccountAddress::from_str(&s)
Self::from_hex(s)
}
}

impl FromStr for AccountAddress {
type Err = AccountAddressParseError;

fn from_str(s: &str) -> Result<Self, AccountAddressParseError> {
Self::from_hex_literal(s)
Self::from_hex(s)
}
}

Expand All @@ -233,7 +233,7 @@ impl<'de> Deserialize<'de> for AccountAddress {
{
if deserializer.is_human_readable() {
let s = <String>::deserialize(deserializer)?;
AccountAddress::from_hex_literal(&s).map_err(D::Error::custom)
AccountAddress::from_hex(s).map_err(D::Error::custom)
} else {
// In order to preserve the Serde data model and help analysis tools,
// make sure to wrap our value in a container with the same name
Expand All @@ -254,7 +254,7 @@ impl Serialize for AccountAddress {
S: Serializer,
{
if serializer.is_human_readable() {
self.to_hex_literal().serialize(serializer)
self.to_hex().serialize(serializer)
} else {
// See comment in deserialize.
serializer.serialize_newtype_struct("AccountAddress", &self.0)
Expand Down Expand Up @@ -346,16 +346,8 @@ mod tests {
assert_eq!(address_from_literal, address);
assert_eq!(hex_literal, address.to_hex_literal());

// Check other variations of 0x1
assert_eq!(AccountAddress::from_str("0x01").unwrap(), address);
assert_eq!(
AccountAddress::from_str("0x00000000000000000000000000000001").unwrap(),
address
);

// Missing '0x' should fail
// Missing '0x'
AccountAddress::from_hex_literal(hex).unwrap_err();

// Too long
AccountAddress::from_hex_literal("0x100000000000000000000000000000001").unwrap_err();
}
Expand Down Expand Up @@ -384,12 +376,14 @@ mod tests {
#[test]
fn test_serde_json() {
let hex = "ca843279e3427144cead5e4d5999a3d0";
let json_hex = "\"0xca843279e3427144cead5e4d5999a3d0\"";
let json_hex = "\"ca843279e3427144cead5e4d5999a3d0\"";

let address = AccountAddress::from_hex(hex).unwrap();

let json = serde_json::to_string(&address).unwrap();
let json_address: AccountAddress = serde_json::from_str(json_hex).unwrap();

assert_eq!(json, json_hex);
assert_eq!(address, json_address);
}

Expand Down

This file was deleted.

This file was deleted.