Skip to content

Commit

Permalink
Merge pull request #1918 from vae520283995/master
Browse files Browse the repository at this point in the history
Update StructuredDataEncoder.java
  • Loading branch information
gtebrean committed Aug 30, 2023
2 parents 61b3285 + 151d6aa commit 1616b95
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ private byte[] convertToEncodedItem(String baseType, Object data) {
rawValue.length);
}
} else if (baseType.equals("string")) {
hashBytes = ((String) data).getBytes();
hashBytes = Numeric.hexStringToByteArray(sha3String((String) data));
} else if (baseType.equals("bytes")) {
hashBytes = Numeric.hexStringToByteArray((String) data);
hashBytes = sha3(Numeric.hexStringToByteArray((String) data));
} else {
byte[] b = convertArgToBytes((String) data);
BigInteger bi = new BigInteger(1, b);
Expand Down
4 changes: 2 additions & 2 deletions crypto/src/test/java/org/web3j/crypto/StructuredDataTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,12 @@ public void testValidStructureWithArrays() throws IOException {
(HashMap<String, Object>) dataEncoder.jsonMessageObject.getMessage());

String expectedMessageStructHash =
"0xc1c7d7b7dab9a65b30a6e951923b2d54536778329712e2239ed8a3f2f5f2329f";
"0x14f510c172a64b76f1105338b2e0b09dccfa4aef922131716d58d7fd94e097e8";

assertEquals(expectedMessageStructHash, Numeric.toHexString(dataHash));

assertEquals(
"0x935426a6009a3798ee87cd16ebeb9cea26b29d2d3762ac0951166d032f55d522",
"0xa31e6ec120743db6e47cf44cd6b116cc4383ff4875cf823308938f8ba4566cc0",
Numeric.toHexString(dataEncoder.hashStructuredData()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
-25
],
"ids": [
1,
2
"23ee3e3",
"3e2e23"
]
},
"to": [
Expand All @@ -36,9 +36,9 @@
-300
],
"ids": [
0,
3,
7
"2ed2d2",
"21ew2e",
"ewewe2"
]
}
]
Expand Down Expand Up @@ -92,7 +92,7 @@
},
{
"name": "ids",
"type": "uint16[]"
"type": "string[]"
}
]
}
Expand Down

0 comments on commit 1616b95

Please sign in to comment.