Skip to content

Commit

Permalink
fix: transactions test on paseo
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbaut committed Oct 23, 2024
1 parent 6866d7a commit 4e01985
Show file tree
Hide file tree
Showing 6 changed files with 308 additions and 233 deletions.
4 changes: 2 additions & 2 deletions packages/ui/cypress/tests/transactions.cy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { testAccounts } from '../fixtures/testAccounts'
import { knownMultisigs } from '../fixtures/knownMultisigs'
import { landingPageUrl } from '../fixtures/landingData'
import { landingPageAddressUrl } from '../fixtures/landingData'
import { multisigPage } from '../support/page-objects/multisigPage'
import { notifications } from '../support/page-objects/notifications'
import { sendTxModal } from '../support/page-objects/sendTxModal'
Expand All @@ -20,7 +20,7 @@ const fillAndSubmitTransactionForm = () => {
describe('Perform transactions', () => {
beforeEach(() => {
cy.setupAndVisit({
url: landingPageUrl,
url: landingPageAddressUrl(knownMultisigs['test-simple-multisig-1'].address),
extensionConnectionAllowed: true,
injectExtensionWithAccounts: [
testAccounts['Multisig Member Account 1'],
Expand Down
31 changes: 25 additions & 6 deletions packages/ui/cypress/utils/rejectCurrentMultisigTxs.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import { InjectedAccountWitMnemonic } from '../fixtures/testAccounts'
import { PendingTx } from '../../src/hooks/usePendingTx'
import { paseo, PaseoQueries } from '@polkadot-api/descriptors'
import { Binary, createClient, Transaction, TxEvent, TypedApi } from 'polkadot-api'
import { paseo } from '@polkadot-api/descriptors'
import {
Binary,
createClient,
FixedSizeBinary,
SS58String,
Transaction,
TxEvent,
TypedApi
} from 'polkadot-api'
import { getWsProvider } from 'polkadot-api/ws-provider/web'
import { sr25519CreateDerive } from '@polkadot-labs/hdkd'
import { entropyToMiniSecret, mnemonicToEntropy } from '@polkadot-labs/hdkd-helpers'
Expand Down Expand Up @@ -34,13 +42,23 @@ const callBack = (resolve: (thenableOrResult?: unknown) => void) => ({
}
})

const getPendingMultisixTx = (multisigTxs: any, multisigInfo: MultisigInfo) => {
interface MultisigQuery {
keyArgs: [SS58String, FixedSizeBinary<32>]
value: {
when: { height: number; index: number }
deposit: bigint
depositor: SS58String
approvals: SS58String[]
}
}

const getPendingMultisixTx = (multisigTxs: MultisigQuery[], multisigInfo: MultisigInfo) => {
const curratedMultisigTxs: PendingTx[] = []

multisigTxs.forEach(({ KeyArgs, Value }: PaseoQueries['Multisig']['Multisigs']) => {
const [multisigAddress, txHash] = KeyArgs
multisigTxs.forEach(({ keyArgs, value }) => {
const [multisigAddress, txHash] = keyArgs
// this is supposed to be the multisig address that we asked the storage for
const info = Value
const info = value

// Fix for ghost proposals for https://github.com/polkadot-js/apps/issues/9103
// These 2 should be the same
Expand Down Expand Up @@ -117,6 +135,7 @@ export const rejectCurrentMultisigTxs = ({
const multisigTxs = await api.query.Multisig.Multisigs.getEntries(multisigInfo.address, {
at: 'best'
})
console.log('multisigTxs', multisigTxs)
const pendingMultisigTxs = getPendingMultisixTx(multisigTxs, multisigInfo)

if (!pendingMultisigTxs.length) {
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"vite": "^5.4.7"
},
"devDependencies": {
"@chainsafe/cypress-polkadot-wallet": "^2.2.0",
"@chainsafe/cypress-polkadot-wallet": "^2.3.0",
"@eslint/js": "^9.0.0",
"@graphql-codegen/cli": "5.0.2",
"@graphql-codegen/client-preset": "4.2.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ const AccountDisplay = ({

const [isEditing, setIsEditing] = useState(false)
const isOwnAccount = useMemo(() => ownAddressList.includes(address), [address, ownAddressList])

const { displayName, subIdentity, isLocalNameDisplayed, identity, localName, identityName } =
useAccountDisplayInfo({
address
Expand Down
48 changes: 24 additions & 24 deletions packages/ui/src/pages/Home/HeaderView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ const HeaderView = () => {
const [searchParams] = useSearchParams()
const { selectedMultiProxy, selectedHasProxy, selectedIsWatched } = useMultiProxy()

const selectedAddress = useMemo((): string => {
return String(
selectedHasProxy ? selectedMultiProxy?.proxy : selectedMultiProxy?.multisigs[0].address
)
const selectedAddress = useMemo(() => {
return selectedHasProxy ? selectedMultiProxy?.proxy : selectedMultiProxy?.multisigs[0].address
}, [selectedHasProxy, selectedMultiProxy])

return (
Expand All @@ -36,26 +34,28 @@ const HeaderView = () => {
<HiOutlineArrowLongRight size={24} />
</ButtonWithIcon>
</OverviewWrapper>
<PureHeaderStyled>
<AccountDisplayStyled
iconSize={'large'}
address={selectedAddress}
badge={selectedHasProxy ? AccountBadge.PURE : AccountBadge.MULTI}
canEdit
canCopy
/>
<BalanceStyledWrapper>
<BalanceStyled>
<BalanceHeaderStyled>Balance</BalanceHeaderStyled>
<BalanceAmountStyled data-cy="label-account-balance">
<Balance address={selectedAddress} />
</BalanceAmountStyled>
</BalanceStyled>
</BalanceStyledWrapper>
<BoxStyled>
<MultisigActionMenu withNewTransactionButton={!selectedIsWatched} />
</BoxStyled>
</PureHeaderStyled>
{selectedAddress && (
<PureHeaderStyled>
<AccountDisplayStyled
iconSize={'large'}
address={selectedAddress}
badge={selectedHasProxy ? AccountBadge.PURE : AccountBadge.MULTI}
canEdit
canCopy
/>
<BalanceStyledWrapper>
<BalanceStyled>
<BalanceHeaderStyled>Balance</BalanceHeaderStyled>
<BalanceAmountStyled data-cy="label-account-balance">
<Balance address={selectedAddress} />
</BalanceAmountStyled>
</BalanceStyled>
</BalanceStyledWrapper>
<BoxStyled>
<MultisigActionMenu withNewTransactionButton={!selectedIsWatched} />
</BoxStyled>
</PureHeaderStyled>
)}
</PureProxyWrapper>
)
}
Expand Down
Loading

0 comments on commit 4e01985

Please sign in to comment.