Skip to content

Commit

Permalink
Papi migration (#559)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbaut authored Dec 2, 2024
1 parent c98f2bf commit 5de4ac0
Show file tree
Hide file tree
Showing 117 changed files with 56,187 additions and 4,040 deletions.
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
/packages/ui/src/gql/**/*
/packages/ui/src/interfaces/**/*
/packages/ui/types-and-hooks.tsx
/packages/ui/build/**/*
/packages/ui/build/**/*
.papi
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"lint:fix": "yarn workspaces foreach run lint:fix",
"formatAll": "prettier --write .",
"start:chopsticks-test-build-and-launch-all": "concurrently --kill-others 'npm run start:chopsticks' 'npm run ui:start-with-chopsticks' 'npm run docker:down && npm run docker:db && npm run build:indexer && npm run indexer:start:chopsticks-local' 'npm run start:graphql-server'",
"start:chopsticks": "npx --yes @acala-network/chopsticks@0.10.0-2 --config chopsticks-config.yml",
"start:chopsticks": "npx --yes @acala-network/chopsticks@1.0.1 --config chopsticks-config.yml",
"start:graphql-server": "cd squid && npm run start:graphql-server",
"indexer:start:chopsticks-ci": "cd squid && npm run start:chopsticks-ci",
"indexer:start:chopsticks-local": "cd squid && npm run start:chopsticks-local",
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"plugin:react-hooks/recommended",
"plugin:react/recommended",
"prettier",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/eslint-recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
Expand Down Expand Up @@ -38,7 +38,7 @@
"react/jsx-tag-spacing": "error",
"prettier/prettier": "error",
"react-hooks/exhaustive-deps": "error",
"react/react-in-jsx-scope": "off",
"react/react-in-jsx-scope": "off"

},
"overrides": [
Expand Down
3 changes: 3 additions & 0 deletions packages/ui/.papi/descriptors/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
!.gitignore
!package.json
24 changes: 24 additions & 0 deletions packages/ui/.papi/descriptors/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"version": "0.1.0-autogenerated.8448668932732983882",
"name": "@polkadot-api/descriptors",
"files": [
"dist"
],
"exports": {
".": {
"types": "./dist/index.d.ts",
"module": "./dist/index.mjs",
"import": "./dist/index.mjs",
"require": "./dist/index.js"
},
"./package.json": "./package.json"
},
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"browser": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"sideEffects": false,
"peerDependencies": {
"polkadot-api": "*"
}
}
Binary file added packages/ui/.papi/metadata/acala.scale
Binary file not shown.
Binary file added packages/ui/.papi/metadata/bifrostDot.scale
Binary file not shown.
Binary file added packages/ui/.papi/metadata/dot.scale
Binary file not shown.
Binary file added packages/ui/.papi/metadata/dotAssetHub.scale
Binary file not shown.
Binary file added packages/ui/.papi/metadata/dotPpl.scale
Binary file not shown.
Binary file added packages/ui/.papi/metadata/hydration.scale
Binary file not shown.
Binary file added packages/ui/.papi/metadata/khala.scale
Binary file not shown.
Binary file added packages/ui/.papi/metadata/ksm-asset-hub.scale
Binary file not shown.
Binary file added packages/ui/.papi/metadata/ksm.scale
Binary file not shown.
Binary file added packages/ui/.papi/metadata/ksmAssetHub.scale
Binary file not shown.
Binary file added packages/ui/.papi/metadata/ksmPpl.scale
Binary file not shown.
Binary file added packages/ui/.papi/metadata/pasPpl.scale
Binary file not shown.
Binary file added packages/ui/.papi/metadata/paseo.scale
Binary file not shown.
Binary file added packages/ui/.papi/metadata/phala.scale
Binary file not shown.
Binary file added packages/ui/.papi/metadata/rhala.scale
Binary file not shown.
Binary file added packages/ui/.papi/metadata/rococo.scale
Binary file not shown.
Binary file added packages/ui/.papi/metadata/rococoAssetHub.scale
Binary file not shown.
Binary file added packages/ui/.papi/metadata/rococoPpl.scale
Binary file not shown.
Binary file added packages/ui/.papi/metadata/wesPpl.scale
Binary file not shown.
74 changes: 74 additions & 0 deletions packages/ui/.papi/polkadot-api.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"version": 0,
"descriptorPath": ".papi/descriptors",
"entries": {
"dot": {
"chain": "polkadot",
"metadata": ".papi/metadata/dot.scale"
},
"ksm": {
"chain": "ksmcc3",
"metadata": ".papi/metadata/ksm.scale"
},
"ksmAssetHub": {
"chain": "ksmcc3_asset_hub",
"metadata": ".papi/metadata/ksmAssetHub.scale"
},
"ksmPpl": {
"chain": "ksmcc3_people",
"metadata": ".papi/metadata/ksmPpl.scale"
},
"dotPpl": {
"chain": "polkadot_people",
"metadata": ".papi/metadata/dotPpl.scale"
},
"dotAssetHub": {
"chain": "polkadot_asset_hub",
"metadata": ".papi/metadata/dotAssetHub.scale"
},
"rococo": {
"chain": "rococo_v2_2",
"metadata": ".papi/metadata/rococo.scale"
},
"rococoAssetHub": {
"chain": "rococo_v2_2_asset_hub",
"metadata": ".papi/metadata/rococoAssetHub.scale"
},
"rococoPpl": {
"chain": "rococo_v2_2_people",
"metadata": ".papi/metadata/rococoPpl.scale"
},
"bifrostDot": {
"wsUrl": "wss://eu.bifrost-polkadot-rpc.liebi.com/ws",
"metadata": ".papi/metadata/bifrostDot.scale"
},
"hydration": {
"wsUrl": "wss://rpc.helikon.io/hydradx",
"metadata": ".papi/metadata/hydration.scale"
},
"khala": {
"wsUrl": "wss://khala-api.phala.network/ws",
"metadata": ".papi/metadata/khala.scale"
},
"phala": {
"wsUrl": "wss://api.phala.network/ws",
"metadata": ".papi/metadata/phala.scale"
},
"paseo": {
"wsUrl": "wss://rpc.ibp.network/paseo",
"metadata": ".papi/metadata/paseo.scale"
},
"acala": {
"wsUrl": "wss://acala-rpc.dwellir.com",
"metadata": ".papi/metadata/acala.scale"
},
"pasPpl": {
"wsUrl": "wss://people-paseo.rpc.amforc.com",
"metadata": ".papi/metadata/pasPpl.scale"
},
"wesPpl": {
"wsUrl": "wss://westend-people-rpc.polkadot.io",
"metadata": ".papi/metadata/wesPpl.scale"
}
}
}
2 changes: 1 addition & 1 deletion packages/ui/cypress/fixtures/testAccounts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { InjectedAccount } from '@polkadot/extension-inject/types'
import { InjectedAccount } from 'polkadot-api/pjs-signer'

export interface InjectedAccountWitMnemonic extends InjectedAccount {
mnemonic: string
Expand Down
7 changes: 5 additions & 2 deletions packages/ui/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import '@chainsafe/cypress-polkadot-wallet'

const LOCALSTORAGE_ACCOUNT_NAMES_KEY = 'multix.accountNames'
const LOCALSTORAGE_WATCHED_ACCOUNTS_KEY = 'multix.watchedAccount'
const LOCALSTORAGE_EXTENSION_CONNECTION_KEY = 'multix.canConnectToExtension'
const LOCALSTORAGE_EXTENSION_CONNECTION_KEY = '@reactive-dot/wallet/injected/polkadot-js/connected'
const LOCALSTORAGE_ALLOWED_CONNECTION_KEY = 'multix.canConnectToExtension'
export const MULTIX_DAPP_NAME = 'Multix'

Cypress.Commands.add('rejectCurrentMultisigTx', rejectCurrentMultisigTxs)
Expand Down Expand Up @@ -51,8 +52,10 @@ Cypress.Commands.add(
!!accountNames &&
win.localStorage.setItem(LOCALSTORAGE_ACCOUNT_NAMES_KEY, JSON.stringify(accountNames))

!!extensionConnectionAllowed &&
if (extensionConnectionAllowed) {
win.localStorage.setItem(LOCALSTORAGE_ALLOWED_CONNECTION_KEY, 'true')
win.localStorage.setItem(LOCALSTORAGE_EXTENSION_CONNECTION_KEY, 'true')
}
}
})

Expand Down
1 change: 1 addition & 0 deletions packages/ui/cypress/support/page-objects/landingPage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const landingPage = {
connectionDialog: () => cy.get('[data-cy=dialog-connection]'),
multixIntroHeader: () => cy.get('[data-cy=header-multix-introduction]', { timeout: 10000 }),
interactionPromptLabel: () => cy.get('[data-cy=label-interaction-prompt]'),
noMultisigFoundError: () => cy.get('[data-cy=label-no-multisig-found]', { timeout: 10000 }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('Verify extrinsics display', () => {
})
})

it('The router.sell extrinsic is displayed in plank', () => {
it('The Router.sell extrinsic is displayed in plank', () => {
multisigPage.accountHeader().within(() => {
accountDisplay.addressLabel().should('contain.text', expectedMultisigAddress.slice(0, 6))
})
Expand All @@ -28,17 +28,17 @@ describe('Verify extrinsics display', () => {
.within(() => {
multisigPage.pendingTransactionItem().should('have.length', 1)
multisigPage.pendingTransactionItem().within(() => {
multisigPage.pendingTransactionCallName().should('contain.text', 'router.sell')
multisigPage.pendingTransactionCallName().should('contain.text', 'Router.sell')
multisigPage.unknownCallIcon().should('not.exist')
multisigPage.unknownCallAlert().should('not.exist')
expander.paramExpander().click()
expander.contentExpander().should('contain', 'amount_in: 10,000,000,000,000')
expander.contentExpander().should('contain', 'min_amount_out: 72,179')
expander.contentExpander().should('contain', `amount_in: '10000000000000'`)
expander.contentExpander().should('contain', `min_amount_out: '72179'`)
})
})
})

it('A manual omnipool.sell extrinsic creation has input in plank', () => {
it.skip('A manual omnipool.sell extrinsic creation has input in plank', () => {
multisigPage.accountHeader().within(() => {
accountDisplay.addressLabel().should('contain.text', expectedMultisigAddress.slice(0, 6))
})
Expand All @@ -56,7 +56,7 @@ describe('Verify extrinsics display', () => {
sendTxModal.paramField('amount').should('not.contain', 'HDX')
})

it('A manual balances.transferKeepAlive extrinsic has input in HDX', () => {
it.skip('A manual balances.transferKeepAlive extrinsic has input in HDX', () => {
multisigPage.accountHeader().within(() => {
accountDisplay.addressLabel().should('contain.text', expectedMultisigAddress.slice(0, 6))
})
Expand Down Expand Up @@ -98,4 +98,27 @@ describe('Verify extrinsics display', () => {
})
})
})

it('A from call data balances.transferKeepAlive extrinsic is correctly displayed', () => {
const balanceTransferCallData =
'0x0703d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d0b00b04e2bde6f'
const sendingAmount = 'value: 123 HDX'
const expectedRecipient = '7NPoMQ..kZpiba'

multisigPage.accountHeader().within(() => {
accountDisplay.addressLabel().should('contain.text', expectedMultisigAddress.slice(0, 6))
})

multisigPage.newTransactionButton().click()
sendTxModal.sendTxTitle().should('be.visible')
sendTxModal.selectEasySetup().click()
sendTxModal.selectionEasySetupSetupFromCallData().click()
sendTxModal.callDataInput().click().type(balanceTransferCallData)
sendTxModal.sendTxContent().within(() => {
expander.contentExpander().should('contain', sendingAmount)
accountDisplay.addressLabel().should('contain', expectedRecipient)
accountDisplay.identicon().should('be.visible')
accountDisplay.nameLabel().should('contain', extrinsicsDisplayAccounts['Alice'].name)
})
})
})
4 changes: 2 additions & 2 deletions packages/ui/cypress/tests/login.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ describe('Connect Account', () => {
cy.wrap(requests.length).should('eq', 1)
// this request should be from the application Multix
cy.wrap(requests[0].origin).should('eq', MULTIX_DAPP_NAME)
// let's allow it for Alice

// auth is rejected
cy.rejectAuth(requests[0].id, 'Cancelled')
// the ui should then move on to connecting to the rpcs
landingPage
.noAccountFoundError()
.should(
Expand Down
33 changes: 19 additions & 14 deletions packages/ui/cypress/tests/multisig-creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,17 @@ describe('Multisig creation', () => {

verifySignatories()

// this is commented because chopsticks doesnot support archive_unstable_hashByHeight
// see https://github.com/AcalaNetwork/chopsticks/issues/852

// there should be a pending pure proxy creation
multisigPage
.transactionList()
.should('be.visible')
.within(() => {
multisigPage.pendingTransactionItem().should('have.length', 1)
multisigPage.pendingTransactionCallName().should('contain.text', 'proxy.createPure')
})
// multisigPage
// .transactionList()
// .should('be.visible')
// .within(() => {
// multisigPage.pendingTransactionItem().should('have.length', 1)
// multisigPage.pendingTransactionCallName().should('contain.text', 'proxy.createPure')
// })
})

it('Create a multisig without a pure proxy', () => {
Expand Down Expand Up @@ -170,13 +173,15 @@ describe('Multisig creation', () => {

verifySignatories()

multisigPage
.transactionList()
.should('be.visible')
.within(() => {
multisigPage.pendingTransactionItem().should('have.length', 1)
multisigPage.pendingTransactionCallName().should('contain.text', 'system.remark')
})
// this is commented because chopsticks doesnot support archive_unstable_hashByHeight
// see https://github.com/AcalaNetwork/chopsticks/issues/852
// multisigPage
// .transactionList()
// .should('be.visible')
// .within(() => {
// multisigPage.pendingTransactionItem().should('have.length', 1)
// multisigPage.pendingTransactionCallName().should('contain.text', 'remark:')
// })
})
})

Expand Down
6 changes: 3 additions & 3 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 Expand Up @@ -62,7 +62,7 @@ describe('Perform transactions', () => {
(address) => address !== testAccount1Address
)
},
WSendpoint: 'wss://paseo.rpc.amforc.com'
WSendpoint: 'wss://rpc.ibp.network/paseo'
})
multisigPage.accountHeader().within(() => {
accountDisplay.addressLabel().should('not.have.text', '')
Expand Down
3 changes: 1 addition & 2 deletions packages/ui/cypress/tests/unknown-transaction.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ describe('Unknown Transaction', () => {
txSigningModal
.callInfoContainer()
.should('be.visible')
.should('contain.text', 'system.remark')
.should('contain.text', 'remark: multix ftw')
.should('contain.text', `remark: 'multix ftw'`)
txSigningModal.approveButton().should('be.enabled')
})
})
Expand Down
8 changes: 7 additions & 1 deletion packages/ui/cypress/utils/clickOnConnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import { waitForAuthRequest } from './waitForAuthRequests'

export const clickOnConnect = () => {
topMenuItems.connectButton().click()
landingPage.accountsLoader().should('contain', 'Loading your accounts')
landingPage.connectionDialog().should('exist')
landingPage
.connectionDialog()
.within(() => cy.get('button', { includeShadowDom: true }).contains('Connect').click())
waitForAuthRequest()
landingPage
.connectionDialog()
.within(() => cy.get('#close-button', { includeShadowDom: true }).click())
}
Loading

0 comments on commit 5de4ac0

Please sign in to comment.