Skip to content

Commit 37e6403

Browse files
committed
fix: build
1 parent 415b02e commit 37e6403

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

packages/ui/cypress/tests/setIdentity.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ describe('Set an identity', () => {
8282
sendTxModal.buttonSend().should('not.exist')
8383
sendTxModal.buttonSending().should('be.visible')
8484
// expected https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Frococo-rpc.polkadot.io#/extrinsics/decode/0x1f0102000412ad770206045069201514711dc2456908b0af226442d475d12a5334e9c4513e001901000564696973056c6565670000000000000000
85-
cy.wrap(txRequests[0].payload.method).should(
85+
cy.wrap(txRequests[0].payload).should(
8686
'eq',
8787
'0x1f0102000412ad770206045069201514711dc2456908b0af226442d475d12a5334e9c4513e001901000564696973056c6565670000000000000000'
8888
)
Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,34 @@
11
import { encodesubstrateAddress } from './encodeSubstrateAddress'
22
import { InjectedPolkadotAccount } from 'polkadot-api/pjs-signer'
33

4-
export const encodeAccounts = (
5-
accounts: InjectedPolkadotAccount[] | string[],
4+
export function encodeAccounts(accounts: string[], ss58Format: number): string[]
5+
export function encodeAccounts(
6+
accounts: InjectedPolkadotAccount[],
67
ss58Format: number
7-
) => {
8-
return accounts
8+
): InjectedPolkadotAccount[]
9+
export function encodeAccounts(accounts: unknown[], ss58Format: number): unknown[] {
10+
if (!accounts || accounts.length === 0) return []
11+
12+
if (typeof accounts[0] === 'string') {
13+
return (accounts as string[])
14+
.map((account) => encodesubstrateAddress(account, ss58Format))
15+
.filter(Boolean) as string[]
16+
}
17+
18+
return (accounts as InjectedPolkadotAccount[])
919
.map((account) => {
10-
const addressToEncode = typeof account === 'string' ? account : account.address
20+
const addressToEncode = account.address
1121

1222
const encodedAddress = encodesubstrateAddress(addressToEncode, ss58Format)
1323

14-
if (typeof account === 'string') {
15-
return encodedAddress
24+
if (!encodedAddress) {
25+
return null
1626
}
1727

18-
return encodedAddress
19-
? {
20-
...account,
21-
address: encodedAddress
22-
}
23-
: null
28+
return {
29+
...account,
30+
address: encodedAddress
31+
} as InjectedPolkadotAccount
2432
})
25-
.filter((acc) => !!acc) as InjectedPolkadotAccount[]
33+
.filter(Boolean) as InjectedPolkadotAccount[]
2634
}

0 commit comments

Comments
 (0)