Skip to content

Conversation

@open-junius
Copy link
Contributor

Description

Add getProxies function in precompile.

Related Issue(s)

  • Closes #[issue number]

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Other (please describe):

Breaking Change

If this PR introduces a breaking change, please provide a detailed description of the impact and the migration path for existing applications.

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have run ./scripts/fix_rust.sh to ensure my code is formatted and linted correctly
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Screenshots (if applicable)

Please include any relevant screenshots or GIFs that demonstrate the changes made.

Additional Notes

Please provide any additional information or context that may be helpful for reviewers.

@open-junius open-junius self-assigned this Nov 14, 2025
@open-junius open-junius added the skip-cargo-audit This PR fails cargo audit but needs to be merged anyway label Nov 14, 2025
Comment on lines 254 to 256
for proxy in proxies.0 {
let delegate: [u8; 32] = proxy.delegate.into();
result.push(delegate.into());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add the proxytype and the delay here
Returning a struct would be nice

Self::SudoUncheckedSetCode => Ok(14),
Self::SwapHotkey => Ok(15),
Self::SubnetLeaseBeneficiary => Ok(16),
Self::RootClaim => Err(()),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intentional? I thought we added root claim operations to proxy filter.

Comment on lines +43 to +47
struct ProxyInfo {
bytes32 delegate;
uint256 proxy_type;
uint256 delay;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More of a question for my personal knowledge, what is the difference between defining a struct inside the interface scope and out of the interface scope?

await tx.wait()
}

const proxiesAfterAdd = await await api.query.Proxy.Proxies.getValue(convertH160ToSS58(evmWallet4.address))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the double await expected here?

Comment on lines +192 to +217
impl TryInto<u8> for ProxyType {
type Error = ();

fn try_into(self) -> Result<u8, Self::Error> {
match self {
Self::Any => Ok(0),
Self::Owner => Ok(1),
Self::NonCritical => Ok(2),
Self::NonTransfer => Ok(3),
Self::Senate => Ok(4),
Self::NonFungible => Ok(5),
Self::Triumvirate => Ok(6),
Self::Governance => Ok(7),
Self::Staking => Ok(8),
Self::Registration => Ok(9),
Self::Transfer => Ok(10),
Self::SmallTransfer => Ok(11),
Self::RootWeights => Ok(12),
Self::ChildKeys => Ok(13),
Self::SudoUncheckedSetCode => Ok(14),
Self::SwapHotkey => Ok(15),
Self::SubnetLeaseBeneficiary => Ok(16),
Self::RootClaim => Err(()),
}
}
}
Copy link
Collaborator

@l0r1s l0r1s Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is more idiomatic to avoid implementing TryInto directly but implement TryFrom instead because it provides a blanket (automatic) implementation of TryInto.

So if you implement TryFrom<ProxyType> for u8 you get TryInto<u8> for ProxyType for free.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-cargo-audit This PR fails cargo audit but needs to be merged anyway

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants