Skip to content

Commit 1f31074

Browse files
committed
Use confidential votes
1 parent bc70870 commit 1f31074

File tree

1 file changed

+15
-72
lines changed

1 file changed

+15
-72
lines changed

packages/core/zama/src/erc20.ts

Lines changed: 15 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ export function buildERC20(opts: ERC20Options): ContractBuilder {
6666
// addMintable(c);
6767
// }
6868

69-
// if (allOpts.votes) {
70-
// const clockMode = allOpts.votes === true ? clockModeDefault : allOpts.votes;
71-
// addVotes(c, clockMode);
72-
// }
69+
if (allOpts.votes) {
70+
const clockMode = allOpts.votes === true ? clockModeDefault : allOpts.votes;
71+
addVotes(c, clockMode);
72+
}
7373

7474
setInfo(c, info);
7575

@@ -84,7 +84,6 @@ function addBase(c: ContractBuilder, name: string, symbol: string) {
8484
c.addParent(ERC20, [name, symbol]);
8585

8686
c.addOverride(ERC20, functions._update);
87-
c.addOverride(ERC20, functions._approve); // allows override from stablecoin
8887
}
8988

9089
export const premintPattern = /^(\d*)(?:\.(\d+))?(?:e(\d+))?$/;
@@ -147,35 +146,19 @@ function checkPotentialPremintOverflow(baseUnits: bigint, decimalPlace: number)
147146
}
148147
}
149148

150-
function addMintable(c: ContractBuilder) { // TODO change to wrappable
151-
c.addFunctionCode('_mint(to, amount);', functions.mint);
152-
}
149+
// function addMintable(c: ContractBuilder) { // TODO change to wrappable
150+
// c.addFunctionCode('_mint(to, amount);', functions.mint);
151+
// }
153152

154153
function addVotes(c: ContractBuilder, clockMode: ClockMode) {
155-
// TODO: Is Permit required?
156-
// if (!c.parents.some(p => p.contract.name === 'ERC20Permit')) {
157-
// throw new Error('Missing ERC20Permit requirement for ERC20Votes');
158-
// }
159-
160-
const ERC20Votes = {
161-
name: 'ERC20Votes',
162-
path: '@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol',
154+
const ConfidentialFungibleTokenVotes = {
155+
name: 'ConfidentialFungibleTokenVotes',
156+
path: '@openzeppelin/confidential-contracts/token/extensions/ConfidentialFungibleTokenVotes.sol',
163157
};
164-
c.addParent(ERC20Votes);
165-
c.addOverride(ERC20Votes, functions._update);
166-
167-
c.addImportOnly({
168-
name: 'Nonces',
169-
path: '@openzeppelin/contracts/utils/Nonces.sol',
170-
});
171-
c.addOverride(
172-
{
173-
name: 'Nonces',
174-
},
175-
functions.nonces,
176-
);
177-
178-
setClockMode(c, ERC20Votes, clockMode);
158+
c.addParent(ConfidentialFungibleTokenVotes);
159+
c.addOverride(ConfidentialFungibleTokenVotes, functions._update);
160+
161+
setClockMode(c, ConfidentialFungibleTokenVotes, clockMode);
179162
}
180163

181164
export const functions = defineFunctions({
@@ -184,48 +167,8 @@ export const functions = defineFunctions({
184167
args: [
185168
{ name: 'from', type: 'address' },
186169
{ name: 'to', type: 'address' },
187-
{ name: 'value', type: 'uint256' },
188-
],
189-
},
190-
191-
_approve: {
192-
kind: 'internal' as const,
193-
args: [
194-
{ name: 'owner', type: 'address' },
195-
{ name: 'spender', type: 'address' },
196-
{ name: 'value', type: 'uint256' },
197-
{ name: 'emitEvent', type: 'bool' },
198-
],
199-
},
200-
201-
mint: {
202-
kind: 'public' as const,
203-
args: [
204-
{ name: 'to', type: 'address' },
205-
{ name: 'amount', type: 'uint256' },
170+
{ name: 'amount', type: 'euint64' },
206171
],
207172
},
208173

209-
pause: {
210-
kind: 'public' as const,
211-
args: [],
212-
},
213-
214-
unpause: {
215-
kind: 'public' as const,
216-
args: [],
217-
},
218-
219-
snapshot: {
220-
kind: 'public' as const,
221-
args: [],
222-
},
223-
224-
nonces: {
225-
kind: 'public' as const,
226-
args: [{ name: 'owner', type: 'address' }],
227-
returns: ['uint256'],
228-
mutability: 'view' as const,
229-
},
230-
231174
});

0 commit comments

Comments
 (0)