fix: getProxyTypeInstance to derive proxy type name from addProxy call arguments (#12053)

This commit is contained in:
Arjun Porwal 2025-12-09 20:13:11 +05:30 committed by GitHub
parent 1b3ed93c15
commit b7cdd0e991
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -148,8 +148,12 @@ function NewProxy ({ index, onChangeAccount, onChangeType, onRemove, proxiedAcco
}
function getProxyTypeInstance (api: ApiPromise, index = 0): KitchensinkRuntimeProxyType {
// This is not perfect, but should work for `{Kusama, Node, Polkadot}RuntimeProxyType`
const proxyNames = api.registry.lookup.names.filter((name) => name.endsWith('RuntimeProxyType'));
// This is not perfect, but should work for most chains coz thier type ends with ProxyType`
// const proxyNames = api.registry.lookup.names.filter((name) => name.endsWith('ProxyType'));
// Better: derive the type name directly from the args of the addProxy call.
// This works consistently across Polkadot SDK chains.
const proxyNames = [api.tx.proxy.addProxy.meta.args[1].type.toString()];
// fallback to previous version (may be Substrate default), when not found
return api.createType<KitchensinkRuntimeProxyType>(proxyNames.length ? proxyNames[0] : 'ProxyType', index);