Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/elliptic-6.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
quiet-node authored Nov 1, 2024
2 parents 896a8ec + 756469f commit 56bd8c1
Show file tree
Hide file tree
Showing 6 changed files with 283 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,25 @@
"name": "HbarAllowance",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "account",
"type": "address"
},
{
"indexed": false,
"internalType": "bool",
"name": "response",
"type": "bool"
}
],
"name": "IsAuthorizedRaw",
"type": "event"
},
{
"anonymous": false,
"inputs": [
Expand Down Expand Up @@ -218,6 +237,40 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "account",
"type": "address"
},
{
"internalType": "bytes",
"name": "messageHash",
"type": "bytes"
},
{
"internalType": "bytes",
"name": "signature",
"type": "bytes"
}
],
"name": "isAuthorizedRawPublic",
"outputs": [
{
"internalType": "int64",
"name": "responseCode",
"type": "int64"
},
{
"internalType": "bool",
"name": "response",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@ abstract contract HederaAccountService {
/// @param account The account to check the signature against
/// @param messageHash The hash of the message to check the signature against
/// @param signature The signature to check
/// @return responseCode The response code for the status of the request. SUCCESS is 22.
/// @return response True if the signature is valid, false otherwise
function isAuthorizedRaw(address account, bytes memory messageHash, bytes memory signature) internal returns (bool response) {
function isAuthorizedRaw(address account, bytes memory messageHash, bytes memory signature) internal returns (int64 responseCode, bool response) {
(bool success, bytes memory result) = HASPrecompileAddress.call(
abi.encodeWithSelector(IHederaAccountService.isAuthorizedRaw.selector,
account, messageHash, signature));
response = success ? abi.decode(result, (bool)) : false;
(responseCode, response) = success ? (HederaResponseCodes.SUCCESS, abi.decode(result, (bool))) : (HederaResponseCodes.UNKNOWN, false);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import "../../../hedera-token-service/HederaTokenService.sol";
contract CryptoAllowance is HederaAccountService, HederaTokenService {
event ResponseCode(int responseCode);
event HbarAllowance(address owner, address spender, int256 allowance);
event IsAuthorizedRaw(address account, bool response);

function hbarApprovePublic(address owner, address spender, int256 amount) public returns (int64 responseCode) {
responseCode = HederaAccountService.hbarApprove(owner, spender, amount);
Expand All @@ -26,6 +27,15 @@ contract CryptoAllowance is HederaAccountService, HederaTokenService {
emit HbarAllowance(owner, spender, allowance);
}

function isAuthorizedRawPublic(address account, bytes memory messageHash, bytes memory signature) public returns (int64 responseCode, bool response) {
(responseCode, response) = HederaAccountService.isAuthorizedRaw(account, messageHash, signature);
emit ResponseCode(responseCode);
if (responseCode != HederaResponseCodes.SUCCESS) {
revert("mehehehehe");
}
emit IsAuthorizedRaw(account, response);
}

function cryptoTransferPublic(IHederaTokenService.TransferList calldata transferList, IHederaTokenService.TokenTransferList[] calldata tokenTransferList) public returns (int responseCode) {
responseCode = HederaTokenService.cryptoTransfer(transferList, tokenTransferList);
emit ResponseCode(responseCode);
Expand Down
142 changes: 71 additions & 71 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@nomicfoundation/hardhat-foundry": "^1.1.2",
"@openzeppelin/contracts": "^5.0.2",
"@openzeppelin/contracts-upgradeable": "^5.1.0",
"hardhat": "^2.22.12",
"hardhat": "^2.22.13",
"@openzeppelin/hardhat-upgrades": "^3.5.0",
"hardhat-abi-exporter": "^2.10.1",
"husky": "^9.1.6",
Expand Down
Loading

0 comments on commit 56bd8c1

Please sign in to comment.