Skip to content

Commit 11ce6a2

Browse files
authored
Add optional decimals to Solidity ERC20/Stablecoin/RWA, Confidential ERC7984, and Stellar Fungible/Stablecoin (#812)
1 parent d0bc91f commit 11ce6a2

62 files changed

Lines changed: 780 additions & 73 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@openzeppelin/wizard-confidential': patch
3+
---
4+
5+
Add optional `decimals` to `erc7984`, which overrides `decimals()` when set to a non-default value. Defaults to 6 as before, with a maximum of 10 since confidential token amounts are represented as uint64. Incompatible with `wrappable`, which derives its decimals from the underlying token (capped at 6).

.changeset/decimals-schemas-mcp.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@openzeppelin/wizard-common': patch
3+
'@openzeppelin/contracts-mcp': patch
4+
'@openzeppelin/contracts-cli': patch
5+
---
6+
7+
Add `decimals` to the AI schemas, MCP tools, and CLI for Solidity `erc20`, `stablecoin`, `realWorldAsset`, Confidential `erc7984`, and Stellar `fungible`, `stablecoin`.

.changeset/decimals-solidity.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@openzeppelin/wizard': patch
3+
---
4+
5+
Add optional `decimals` to `erc20`, `stablecoin`, and `realWorldAsset`, which overrides `decimals()` when set to a non-default value. Defaults to 18 as before.

.changeset/decimals-stellar.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@openzeppelin/wizard-stellar': patch
3+
---
4+
5+
Add optional `decimals` to `fungible` and `stablecoin`, which sets the token's metadata decimals. Defaults to 7 as before.

packages/cli/src/cli.test.ts.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Generated by [AVA](https://avajs.dev).
4343
--symbol <string> The short symbol for the token␊
4444
4545
Options:␊
46+
--decimals <string> The number of decimals used to represent token amounts. Defaults to 18.␊
4647
--burnable Whether token holders will be able to destroy their tokens␊
4748
--pausable Whether privileged accounts will be able to pause specifically marked functionality. Useful for emergency response.␊
4849
--premint <string> The number of tokens to premint for the deployer.␊
@@ -120,6 +121,7 @@ Generated by [AVA](https://avajs.dev).
120121
--symbol <string> The short symbol for the token␊
121122
122123
Options:␊
124+
--decimals <string> The number of decimals used to represent token amounts. Defaults to 18.␊
123125
--burnable Whether token holders will be able to destroy their tokens␊
124126
--pausable Whether privileged accounts will be able to pause specifically marked functionality. Useful for emergency response.␊
125127
--premint <string> The number of tokens to premint for the deployer.␊
@@ -150,6 +152,7 @@ Generated by [AVA](https://avajs.dev).
150152
--symbol <string> The short symbol for the token␊
151153
152154
Options:␊
155+
--decimals <string> The number of decimals used to represent token amounts. Defaults to 18.␊
153156
--burnable Whether token holders will be able to destroy their tokens␊
154157
--pausable Whether privileged accounts will be able to pause specifically marked functionality. Useful for emergency response.␊
155158
--premint <string> The number of tokens to premint for the deployer.␊
@@ -449,6 +452,7 @@ Generated by [AVA](https://avajs.dev).
449452
--symbol <string> The short symbol for the token␊
450453
451454
Options:␊
455+
--decimals <string> The number of decimals used to represent token amounts. Defaults to 7.␊
452456
--burnable Whether token holders will be able to destroy their tokens␊
453457
--votes Whether to enable vote checkpoints and delegation for governance.␊
454458
--pausable Whether privileged accounts will be able to pause specifically marked functionality. Useful for emergency response.␊
@@ -495,6 +499,7 @@ Generated by [AVA](https://avajs.dev).
495499
--symbol <string> The short symbol for the token␊
496500
497501
Options:␊
502+
--decimals <string> The number of decimals used to represent token amounts. Defaults to 7.␊
498503
--burnable Whether token holders will be able to destroy their tokens␊
499504
--votes Whether to enable vote checkpoints and delegation for governance.␊
500505
--pausable Whether privileged accounts will be able to pause specifically marked functionality. Useful for emergency response.␊
@@ -596,8 +601,9 @@ Generated by [AVA](https://avajs.dev).
596601
--networkConfig <zama-ethereum> Specify the provider and network configuration to use for FHEVM contracts.␊
597602
598603
Options:␊
604+
--decimals <string> The number of decimals used to represent token amounts. Defaults to 6, with a maximum of 10, since confidential token amounts are represented as uint64 and higher decimals would make the maximum total supply too limited. Incompatible with wrappable, which derives its decimals from the underlying token (capped at 6).␊
599605
--premint <string> The number of tokens to premint for the deployer. Cannot be used with wrappable, since preminted tokens would not be backed by the underlying token.␊
600-
--wrappable Whether to allow wrapping an ERC20 token into a confidential fungible token. Cannot be used with premint, since preminted tokens would not be backed by the underlying token.␊
606+
--wrappable Whether to allow wrapping an ERC20 token into a confidential fungible token. Derives its decimals from the underlying token (capped at 6), so it cannot be used with custom decimals. Cannot be used with premint, since preminted tokens would not be backed by the underlying token.␊
601607
--votes <blocknumber|timestamp> Whether to keep track of historical balances for voting in on-chain governance. Voting durations must be expressed as block numbers or timestamps.␊
602608
--info.securityContact <string> Email where people can contact you to report security issues. Will only be visible if contract source code is verified.␊
603609
--info.license <string> The license used by the contract, default is "MIT"␊

packages/cli/src/cli.test.ts.snap

121 Bytes
Binary file not shown.

packages/common/src/ai/descriptions/confidential.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ export const confidentialPrompts = {
99
export const confidentialERC7984Descriptions = {
1010
contractURI:
1111
'The metadata URI for the token. Should follow the schema defined in [ERC-7572](https://eips.ethereum.org/EIPS/eip-7572).',
12+
decimals:
13+
'The number of decimals used to represent token amounts. Defaults to 6, with a maximum of 10, since confidential token amounts are represented as uint64 and higher decimals would make the maximum total supply too limited. Incompatible with wrappable, which derives its decimals from the underlying token (capped at 6).',
1214
premint:
1315
'The number of tokens to premint for the deployer. Cannot be used with wrappable, since preminted tokens would not be backed by the underlying token.',
1416
networkConfig: 'Specify the provider and network configuration to use for FHEVM contracts.',
1517
wrappable:
16-
'Whether to allow wrapping an ERC20 token into a confidential fungible token. Cannot be used with premint, since preminted tokens would not be backed by the underlying token.',
18+
'Whether to allow wrapping an ERC20 token into a confidential fungible token. Derives its decimals from the underlying token (capped at 6), so it cannot be used with custom decimals. Cannot be used with premint, since preminted tokens would not be backed by the underlying token.',
1719
votes:
1820
'Whether to keep track of historical balances for voting in on-chain governance. Voting durations must be expressed as block numbers or timestamps.',
1921
};

packages/common/src/ai/descriptions/solidity.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const solidityCommonDescriptions = {
2323
};
2424

2525
export const solidityERC20Descriptions = {
26+
decimals: 'The number of decimals used to represent token amounts. Defaults to 18.',
2627
premint: 'The number of tokens to premint for the deployer.',
2728
permit:
2829
'Whether without paying gas, token holders will be able to allow third parties to transfer from their account.',

packages/common/src/ai/descriptions/stellar.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const stellarCommonDescriptions = {
1818
};
1919

2020
export const stellarFungibleDescriptions = {
21+
decimals: 'The number of decimals used to represent token amounts. Defaults to 7.',
2122
premint: 'The number of tokens to premint for the deployer.',
2223
votes: 'Whether to enable vote checkpoints and delegation for governance.',
2324
};
@@ -32,6 +33,7 @@ export const stellarNonFungibleDescriptions = {
3233

3334
export const stellarStablecoinDescriptions = {
3435
limitations: 'Whether to restrict certain users from transferring tokens, either via allowing or blocking them.',
36+
decimals: 'The number of decimals used to represent token amounts. Defaults to 7.',
3537
premint: 'The number of tokens to premint for the deployer.',
3638
votes: 'Whether to enable vote checkpoints and delegation for governance.',
3739
};

packages/common/src/ai/schemas/confidential.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const confidentialERC7984Schema = {
1515
name: z.string().describe(commonDescriptions.name),
1616
symbol: z.string().describe(commonDescriptions.symbol),
1717
contractURI: z.string().describe(confidentialERC7984Descriptions.contractURI),
18+
decimals: z.string().optional().describe(confidentialERC7984Descriptions.decimals),
1819
premint: z.string().optional().describe(confidentialERC7984Descriptions.premint),
1920
networkConfig: z.literal('zama-ethereum').describe(confidentialERC7984Descriptions.networkConfig),
2021
wrappable: z.boolean().optional().describe(confidentialERC7984Descriptions.wrappable),

0 commit comments

Comments
 (0)