Skip to content

Commit

Permalink
fix: build
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbaut committed Oct 31, 2024
1 parent 415b02e commit 37e6403
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/ui/cypress/tests/setIdentity.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe('Set an identity', () => {
sendTxModal.buttonSend().should('not.exist')
sendTxModal.buttonSending().should('be.visible')
// expected https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Frococo-rpc.polkadot.io#/extrinsics/decode/0x1f0102000412ad770206045069201514711dc2456908b0af226442d475d12a5334e9c4513e001901000564696973056c6565670000000000000000
cy.wrap(txRequests[0].payload.method).should(
cy.wrap(txRequests[0].payload).should(
'eq',
'0x1f0102000412ad770206045069201514711dc2456908b0af226442d475d12a5334e9c4513e001901000564696973056c6565670000000000000000'
)
Expand Down
36 changes: 22 additions & 14 deletions packages/ui/src/utils/encodeAccounts.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
import { encodesubstrateAddress } from './encodeSubstrateAddress'
import { InjectedPolkadotAccount } from 'polkadot-api/pjs-signer'

export const encodeAccounts = (
accounts: InjectedPolkadotAccount[] | string[],
export function encodeAccounts(accounts: string[], ss58Format: number): string[]
export function encodeAccounts(
accounts: InjectedPolkadotAccount[],
ss58Format: number
) => {
return accounts
): InjectedPolkadotAccount[]
export function encodeAccounts(accounts: unknown[], ss58Format: number): unknown[] {
if (!accounts || accounts.length === 0) return []

if (typeof accounts[0] === 'string') {
return (accounts as string[])
.map((account) => encodesubstrateAddress(account, ss58Format))
.filter(Boolean) as string[]
}

return (accounts as InjectedPolkadotAccount[])
.map((account) => {
const addressToEncode = typeof account === 'string' ? account : account.address
const addressToEncode = account.address

const encodedAddress = encodesubstrateAddress(addressToEncode, ss58Format)

if (typeof account === 'string') {
return encodedAddress
if (!encodedAddress) {
return null
}

return encodedAddress
? {
...account,
address: encodedAddress
}
: null
return {
...account,
address: encodedAddress
} as InjectedPolkadotAccount
})
.filter((acc) => !!acc) as InjectedPolkadotAccount[]
.filter(Boolean) as InjectedPolkadotAccount[]
}

0 comments on commit 37e6403

Please sign in to comment.