Skip to content

Commit

Permalink
fix: use runtime version to check for ethereum linking
Browse files Browse the repository at this point in the history
  • Loading branch information
rflechtner committed Mar 15, 2023
1 parent 23ee887 commit e4788d1
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions packages/did/src/DidLinks/AccountLinks.chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,13 @@ type EncodedMultiAddress =
| { AccountId32: Uint8Array }

/**
* Detects whether api decoration indicates presence of Ethereum linking enabled pallet.
* Detects whether the spec version indicates presence of Ethereum linking enabled pallet.
*
* @param api The api object.
* @returns True if Ethereum linking is supported.
*/
function isEthereumEnabled(api: ApiPromise): boolean {
const removeType = api.createType(
api.tx.didLookup.removeAccountAssociation.meta.args[0]?.type?.toString() ||
'bool'
)
const associateType = api.createType(
api.tx.didLookup.associateAccount.meta.args[0]?.type?.toString() || 'bool'
)

return 'isAccountId20' in removeType || 'isEthereum' in associateType
return api.runtimeVersion.specVersion.gten(11000)
}

/**
Expand Down

0 comments on commit e4788d1

Please sign in to comment.