Skip to content

Commit

Permalink
fix: fixing key mappings (#197)
Browse files Browse the repository at this point in the history
Signed-off-by: Mariusz Jasuwienas <[email protected]>
  • Loading branch information
arianejasuwienas committed Feb 3, 2025
1 parent 7bebfcc commit 71d92bb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
6 changes: 5 additions & 1 deletion contracts/HtsSystemContract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,11 @@ contract HtsSystemContract is IHederaTokenService {
function _getKey(uint keyType, TokenInfo memory tokenInfo) private pure returns (bool, KeyValue memory) {
for (uint256 i = 0; i < tokenInfo.token.tokenKeys.length; i++) {
if (tokenInfo.token.tokenKeys[i].keyType == keyType) {
return (true, tokenInfo.token.tokenKeys[i].key);
bool notEmpty = tokenInfo.token.tokenKeys[i].key.contractId != address(0) ||
tokenInfo.token.tokenKeys[i].key.delegatableContractId != address(0) ||
keccak256(tokenInfo.token.tokenKeys[i].key.ECDSA_secp256k1) != keccak256("") ||
keccak256(tokenInfo.token.tokenKeys[i].key.ed25519) != keccak256("");
return (notEmpty, tokenInfo.token.tokenKeys[i].key);
}
}
KeyValue memory value;
Expand Down
20 changes: 9 additions & 11 deletions src/slotmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,17 +240,15 @@ function slotMapOf(token) {
['supply_key', 0x10],
['fee_schedule_key', 0x20],
['pause_key', 0x40],
])
.map(([prop, key_type]) => {
const key = token[prop];
if (key === null) return { key_type, ed25519: '', _e_c_d_s_a_secp256k1: '' };
assert(typeof key === 'object');
assert('_type' in key && 'key' in key);
if (key._type === 'ED25519')
return { key_type, ed25519: key.key, _e_c_d_s_a_secp256k1: '' };
return { key_type, ed25519: '', _e_c_d_s_a_secp256k1: key.key };
})
.filter(key => key.ed25519 !== '' || key._e_c_d_s_a_secp256k1 !== '');
]).map(([prop, key_type]) => {
const key = token[prop];
if (key === null) return { key_type, ed25519: '', _e_c_d_s_a_secp256k1: '' };
assert(typeof key === 'object');
assert('_type' in key && 'key' in key);
if (key._type === 'ED25519')
return { key_type, ed25519: key.key, _e_c_d_s_a_secp256k1: '' };
return { key_type, ed25519: '', _e_c_d_s_a_secp256k1: key.key };
});
const customFees = /**@type {Record<string, Record<string, unknown>[]>}*/ (
token['custom_fees']
);
Expand Down

0 comments on commit 71d92bb

Please sign in to comment.