Skip to content

Commit f8242d1

Browse files
Add default underlying token decimals customization in wrapper
1 parent 875940a commit f8242d1

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

contracts/token/extensions/ConfidentialFungibleTokenERC20Wrapper.sol

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,15 @@ abstract contract ConfidentialFungibleTokenERC20Wrapper is ConfidentialFungibleT
155155
_receivers[requestID] = to;
156156
}
157157

158+
/**
159+
* @dev Returns the default number of decimals of the underlying ERC-20 token that is being wrapped.
160+
* Used as a default fallback when {_tryGetAssetDecimals} fails to fetch decimals of the underlying
161+
* ERC-20 token.
162+
*/
163+
function _defaultUnderlyingDecimals() internal pure virtual returns (uint8) {
164+
return 18;
165+
}
166+
158167
/**
159168
* @dev Returns the maximum number that will be used for {decimals} by the wrapper.
160169
*/
@@ -169,6 +178,6 @@ abstract contract ConfidentialFungibleTokenERC20Wrapper is ConfidentialFungibleT
169178
if (success && encodedDecimals.length == 32) {
170179
return abi.decode(encodedDecimals, (uint8));
171180
}
172-
return 18;
181+
return _defaultUnderlyingDecimals();
173182
}
174183
}

0 commit comments

Comments
 (0)