Skip to content

Commit b7cdd0e

Browse files
authored
fix: getProxyTypeInstance to derive proxy type name from addProxy call arguments (#12053)
1 parent 1b3ed93 commit b7cdd0e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/page-accounts/src/modals/ProxyOverview.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,12 @@ function NewProxy ({ index, onChangeAccount, onChangeType, onRemove, proxiedAcco
148148
}
149149

150150
function getProxyTypeInstance (api: ApiPromise, index = 0): KitchensinkRuntimeProxyType {
151-
// This is not perfect, but should work for `{Kusama, Node, Polkadot}RuntimeProxyType`
152-
const proxyNames = api.registry.lookup.names.filter((name) => name.endsWith('RuntimeProxyType'));
151+
// This is not perfect, but should work for most chains coz thier type ends with ProxyType`
152+
// const proxyNames = api.registry.lookup.names.filter((name) => name.endsWith('ProxyType'));
153+
154+
// Better: derive the type name directly from the args of the addProxy call.
155+
// This works consistently across Polkadot SDK chains.
156+
const proxyNames = [api.tx.proxy.addProxy.meta.args[1].type.toString()];
153157

154158
// fallback to previous version (may be Substrate default), when not found
155159
return api.createType<KitchensinkRuntimeProxyType>(proxyNames.length ? proxyNames[0] : 'ProxyType', index);

0 commit comments

Comments
 (0)