Erc3643 functions - #1992
Conversation
There was a problem hiding this comment.
Pull request overview
Adds ERC-3643-style management functions to the Polymesh fungible-asset precompile surface, backed by new runtime support for freezing individual investor accounts.
Changes:
- Extends the Solidity IFungibleAsset interface with ERC-3643 events and calls (
setName,setSymbol,pause,unpause,setAddressFrozen). - Implements the new calls in the precompile interface (including event emission).
- Adds runtime storage/extrinsic support for per-account freezing, plus benchmarking and weights.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| precompiles/src/interfaces/FungibleAssetStub.sol | Extends the Solidity interface/stub with ERC-3643 events and function signatures. |
| pallets/precompiles/src/interface/mod.rs | Wires the new ERC-3643 dispatch paths and introduces shared constants/errors. |
| pallets/precompiles/src/interface/erc3643.rs | Implements pause/unpause, name/symbol update, and address freeze precompile logic + events. |
| pallets/precompiles/src/interface/erc20.rs | Uses shared DECIMALS constant for ERC-20 decimals() return. |
| pallets/asset/src/lib.rs | Adds FrozenAccounts storage, set_address_frozen extrinsic, and enforces frozen-account transfer blocking. |
| pallets/asset/src/benchmarking.rs | Adds benchmark for the new set_address_frozen extrinsic. |
| pallets/weights/src/pallet_asset.rs | Adds weight function for set_address_frozen. |
Suppressed comments (1)
pallets/precompiles/src/interface/erc3643.rs:149
- Same issue as above:
UpdatedTokenInformationusesstring indexedfields, so the indexed values must bekeccak256(bytes(..)). The currentFixedBytes::try_from(..).unwrap_or_default()will emit zero topics for typical asset names/symbols.
IFungibleAsset::UpdatedTokenInformation {
newName: FixedBytes::try_from(asset_name.0.as_slice()).unwrap_or_default(),
newSymbol: FixedBytes::try_from(ticker.as_ref()).unwrap_or_default(),
newDecimals: DECIMALS,
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| event UpdatedTokenInformation( | ||
| string indexed newName, | ||
| string indexed newSymbol, | ||
| uint8 newDecimals, | ||
| string newVersion, | ||
| address indexed newOnchainID | ||
| ); |
There was a problem hiding this comment.
Lets not use this event from ERC-3643 for now. The version and onchainID don't make sense for use. Maybe we will add our own events later.
| /// Set the status of `account` for `asset_id` to `freeze`. | ||
| #[pallet::call_index(39)] | ||
| #[pallet::weight(<T as Config>::WeightInfo::set_address_frozen())] | ||
| pub fn set_address_frozen( | ||
| origin: OriginFor<T>, | ||
| asset_id: AssetId, | ||
| freeze: bool, | ||
| account: AccountId32, | ||
| ) -> DispatchResult { | ||
| Self::base_set_address_frozen(origin, asset_id, freeze, account) | ||
| } |
There was a problem hiding this comment.
I think we should implement this freeze feature for both accounts and portfolios (so take an AssetHolder target here). Also need to make sure that the freeze blocks same DID transfers (portfolio moves and transfer_funds).
There was a problem hiding this comment.
The precompile can be limited to account for now. I am not sure if we want to commit to supporting Portfolios long-term (since accounts are more commonly used).
changelog
new features
set_symbol, set_name, unpause, pause;