@@ -64,9 +64,9 @@ export function buildConfidentialFungible(opts: ConfidentialFungibleOptions): Co
64
64
addPremint ( c , allOpts . premint ) ;
65
65
}
66
66
67
- // if (allOpts.mintable) {
68
- // addMintable (c);
69
- // }
67
+ if ( allOpts . mintable ) {
68
+ addWrappable ( c ) ;
69
+ }
70
70
71
71
if ( allOpts . votes ) {
72
72
const clockMode = allOpts . votes === true ? clockModeDefault : allOpts . votes ;
@@ -95,6 +95,7 @@ function addBase(c: ContractBuilder, name: string, symbol: string, tokenURI: str
95
95
} ) ;
96
96
c . addOverride ( ConfidentialFungibleToken , functions . _update ) ;
97
97
c . addOverride ( ConfidentialFungibleToken , functions . confidentialTotalSupply ) ;
98
+ c . addOverride ( ConfidentialFungibleToken , functions . decimals ) ;
98
99
}
99
100
100
101
export const premintPattern = / ^ ( \d * ) (?: \. ( \d + ) ) ? (?: e ( \d + ) ) ? $ / ;
@@ -159,9 +160,25 @@ function checkPotentialPremintOverflow(baseUnits: bigint, decimalPlace: number)
159
160
}
160
161
}
161
162
162
- // function addMintable(c: ContractBuilder) { // TODO change to wrappable
163
- // c.addFunctionCode('_mint(to, amount);', functions.mint);
164
- // }
163
+ function addWrappable ( c : ContractBuilder ) {
164
+ const underlyingArg = 'underlying' ;
165
+
166
+ c . addImportOnly ( {
167
+ name : 'IERC20' ,
168
+ path : '@openzeppelin/contracts/interfaces/IERC20.sol' ,
169
+ } ) ;
170
+ c . addConstructorArgument ( {
171
+ type : 'IERC20' ,
172
+ name : underlyingArg ,
173
+ } ) ;
174
+
175
+ const ConfidentialFungibleTokenERC20Wrapper = {
176
+ name : 'ConfidentialFungibleTokenERC20Wrapper' ,
177
+ path : '@openzeppelin/confidential-contracts/token/extensions/ConfidentialFungibleTokenERC20Wrapper.sol' ,
178
+ } ;
179
+ c . addParent ( ConfidentialFungibleTokenERC20Wrapper , [ { lit : underlyingArg } ] ) ;
180
+ c . addOverride ( ConfidentialFungibleTokenERC20Wrapper , functions . decimals ) ;
181
+ }
165
182
166
183
function addVotes ( c : ContractBuilder , name : string , clockMode : ClockMode ) {
167
184
const EIP712 = {
@@ -207,5 +224,11 @@ export const functions = defineFunctions({
207
224
args : [
208
225
{ name : 'handle' , type : 'bytes32' } ,
209
226
] ,
210
- }
227
+ } ,
228
+ decimals : {
229
+ kind : 'public' as const ,
230
+ mutability : 'view' ,
231
+ args : [ ] ,
232
+ returns : [ 'uint8' ] ,
233
+ } ,
211
234
} ) ;
0 commit comments