Skip to content

Commit

Permalink
chore(test): Unskip failing tx test (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbaut authored Oct 24, 2024
1 parent f84fe74 commit 610b31b
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { waitForAuthRequest } from '../utils/waitForAuthRequests'

const Alice = {
address: '5Fsaew2ZtsgpaCUWDmBnz8Jn8i49dvJFQUaJ5TZ6NGC1EBeS',
addressWithPrefix0: '14osoGHdkexJ1jV2BQEo8H8vzL3oLDrPUyJnEkYSvMDXQcu7',
name: 'Alice',
type: 'sr25519',
mnemonic: 'blame only east lunar valve mother link pill expect eight quote table'
Expand Down Expand Up @@ -106,15 +105,15 @@ describe('test cypress-polkadot-wallet plugin', () => {
cy.getTxRequests().then((req) => {
const txRequests = Object.values(req)
cy.wrap(txRequests.length).should('eq', 1)
cy.wrap(txRequests[0].payload.address).should('eq', Alice.addressWithPrefix0)
cy.wrap(txRequests[0].payload.address).should('eq', Alice.address)
cy.approveTx(txRequests[0].id)
cy.get('#tx-hash').should('not.be.empty')
cy.get('#tx-events', { timeout: 20000 }).should('contain', 'ExtrinsicSuccess')
cy.get('#tx-error').should('be.empty')
})
})

it.skip('should sign a transaction and get an error', () => {
it('should sign a transaction and get an error', () => {
cy.visit(TESTING_LANDING_PAGE)
cy.initWallet([Alice], EXAMPLE_DAPP_NAME)
cy.get('#connect-accounts-papi').click()
Expand All @@ -129,7 +128,7 @@ describe('test cypress-polkadot-wallet plugin', () => {
cy.getTxRequests().then((req) => {
const txRequests = Object.values(req)
cy.wrap(txRequests.length).should('eq', 1)
cy.wrap(txRequests[0].payload.address).should('eq', Alice.addressWithPrefix0)
cy.wrap(txRequests[0].payload.address).should('eq', Alice.address)
cy.approveTx(txRequests[0].id)
// the tx hash will be present, but the chain will reject the
// tx eventually
Expand Down
2 changes: 1 addition & 1 deletion packages/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@polkadot-api/descriptors": "portal:.papi/descriptors",
"@polkadot/api": "^14.1.1",
"@polkadot/extension-dapp": "^0.54.1",
"polkadot-api": "^1.6.2"
"polkadot-api": "^1.6.4"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^8.11.0",
Expand Down
35 changes: 5 additions & 30 deletions packages/example/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ import './style.css'
import { web3Accounts, web3Enable, web3FromSource } from '@polkadot/extension-dapp'
import { ApiPromise, WsProvider } from '@polkadot/api'
import { InjectedAccountWithMeta } from '@polkadot/extension-inject/types'
// `dot` is the name we gave to `npx papi add`
import { MultiAddress, pas } from '@polkadot-api/descriptors'
import { createClient } from 'polkadot-api'
// import from "polkadot-api/ws-provider/node"
// if you are running in a NodeJS environment
import { getWsProvider } from 'polkadot-api/ws-provider/web'
import { withPolkadotSdkCompat } from 'polkadot-api/polkadot-sdk-compat'
import {
Expand All @@ -22,19 +19,8 @@ const EXAMPLE_DAPP_NAME = 'example-dapp'
let injectedAccountsPjs: InjectedAccountWithMeta[] = []
let injectedAccountsPapi: InjectedPolkadotAccount[] = []

const getPapi = () => {
// Connect to the polkadot relay chain.
const client = createClient(
// Polkadot-SDK Nodes have issues, we recommend adding this enhancer
// see Requirements page for more info
withPolkadotSdkCompat(getWsProvider(PASEO_WS_PROVIDER))
)

// With the `client`, you can get information such as subscribing to the last
// block to get the latest hash:
const pasApi = client.getTypedApi(pas)
return pasApi
}
const client = createClient(withPolkadotSdkCompat(getWsProvider(PASEO_WS_PROVIDER)))
const papi = client.getTypedApi(pas)

document
.querySelector<HTMLButtonElement>('#connect-accounts-papi')!
Expand Down Expand Up @@ -88,9 +74,8 @@ document

document.querySelector<HTMLButtonElement>('#send-tx-pjs')!.addEventListener('click', async () => {
const provider = new WsProvider(PASEO_WS_PROVIDER)
const api = await ApiPromise.create({ provider })
const pjsApi = await ApiPromise.create({ provider })

// Initialise the provider to connect to the local node
const account = injectedAccountsPjs[0]

if (injectedAccountsPjs.length === 0) {
Expand All @@ -100,7 +85,7 @@ document.querySelector<HTMLButtonElement>('#send-tx-pjs')!.addEventListener('cli

const amount = document.querySelector<HTMLInputElement>('#amount-input')?.value

const transferExtrinsic = api.tx.balances.transferKeepAlive(account.address, amount)
const transferExtrinsic = pjsApi.tx.balances.transferKeepAlive(account.address, amount)
const injector = await web3FromSource(account.meta.source)

transferExtrinsic
Expand All @@ -122,9 +107,6 @@ document.querySelector<HTMLButtonElement>('#send-tx-pjs')!.addEventListener('cli
})

document.querySelector<HTMLButtonElement>('#send-tx-papi')!.addEventListener('click', async () => {
const api = await getPapi()

// Initialise the provider to connect to the local node
const account = injectedAccountsPapi[0]

if (injectedAccountsPapi.length === 0) {
Expand All @@ -134,7 +116,7 @@ document.querySelector<HTMLButtonElement>('#send-tx-papi')!.addEventListener('cl

const amount = document.querySelector<HTMLInputElement>('#amount-input')?.value

const transferExtrinsic = api.tx.Balances.transfer_keep_alive({
const transferExtrinsic = papi.tx.Balances.transfer_keep_alive({
dest: MultiAddress.Id(account.address),
value: amount ? BigInt(amount) : 0n
})
Expand All @@ -156,10 +138,3 @@ document.querySelector<HTMLButtonElement>('#send-tx-papi')!.addEventListener('cl
}
})
})

// { "type": "Balances", "value": { "type": "Withdraw", "value": { "who": "12bzRJfh7arnnfPPUZHeJUaE62QLEwhK48QnH9LXeK2m1iZU", "amount": "153060938" } } }
// { "type": "Balances", "value": { "type": "Deposit", "value": { "who": "12bzRJfh7arnnfPPUZHeJUaE62QLEwhK48QnH9LXeK2m1iZU", "amount": "0" } } }
// { "type": "Balances", "value": { "type": "Deposit", "value": { "who": "13UVJyLnbVp9RBZYFwFGyDvVd1y27Tt8tkntv6Q7JVPhFsTB", "amount": "122448750" } } }
// { "type": "Balances", "value": { "type": "Deposit", "value": { "who": "14Q6d7nBEnmvThE5o8sFdXJbxLAJzb9vPw2w4utdWwPrWosa", "amount": "30612188" } } }
// { "type": "TransactionPayment", "value": { "type": "TransactionFeePaid", "value": { "who": "12bzRJfh7arnnfPPUZHeJUaE62QLEwhK48QnH9LXeK2m1iZU", "actual_fee": "153060938", "tip": "0" } } }
// { "type": "System", "value": { "type": "ExtrinsicSuccess", "value": { "dispatch_info": { "weight": { "ref_time": "259771000", "proof_size": "3593" }, "class": { "type": "Normal" }, "pays_fee": { "type": "Yes" } } } } }
139 changes: 77 additions & 62 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ __metadata:
languageName: node
linkType: hard

"@noble/hashes@npm:^1.4.0":
"@noble/hashes@npm:^1.4.0, @noble/hashes@npm:^1.5.0":
version: 1.5.0
resolution: "@noble/hashes@npm:1.5.0"
checksum: 1b46539695fbfe4477c0822d90c881a04d4fa2921c08c552375b444a48cac9930cb1ee68de0a3c7859e676554d0f3771999716606dc4d8f826e414c11692cdd9
Expand Down Expand Up @@ -745,17 +745,17 @@ __metadata:
languageName: node
linkType: hard

"@polkadot-api/cli@npm:0.9.10":
version: 0.9.10
resolution: "@polkadot-api/cli@npm:0.9.10"
"@polkadot-api/cli@npm:0.9.12":
version: 0.9.12
resolution: "@polkadot-api/cli@npm:0.9.12"
dependencies:
"@commander-js/extra-typings": "npm:^12.1.0"
"@polkadot-api/codegen": "npm:0.12.5"
"@polkadot-api/ink-contracts": "npm:0.1.0"
"@polkadot-api/codegen": "npm:0.12.6"
"@polkadot-api/ink-contracts": "npm:0.1.1"
"@polkadot-api/json-rpc-provider": "npm:0.0.4"
"@polkadot-api/known-chains": "npm:0.5.4"
"@polkadot-api/metadata-compatibility": "npm:0.1.9"
"@polkadot-api/observable-client": "npm:0.5.11"
"@polkadot-api/known-chains": "npm:0.5.5"
"@polkadot-api/metadata-compatibility": "npm:0.1.10"
"@polkadot-api/observable-client": "npm:0.5.13"
"@polkadot-api/polkadot-sdk-compat": "npm:2.3.1"
"@polkadot-api/sm-provider": "npm:0.1.3"
"@polkadot-api/smoldot": "npm:0.3.3"
Expand All @@ -778,20 +778,20 @@ __metadata:
bin:
papi: dist/main.js
polkadot-api: dist/main.js
checksum: 2ed474c277949946fc067975e2476a00ec38e44b395f5d0e526ac63042d356d7ba207c77bf69db946b94d1a746d9658f85a9061568c2120eafade3ed69e4a85b
checksum: 25782ca0fb36171d611c2360e2f7e9ac732dc27b23af9bba2f2485594100c12c2cc252b33ac2b352537887219e2d4f5a13bce53a8f95783fecc232ae6d910434
languageName: node
linkType: hard

"@polkadot-api/codegen@npm:0.12.5":
version: 0.12.5
resolution: "@polkadot-api/codegen@npm:0.12.5"
"@polkadot-api/codegen@npm:0.12.6":
version: 0.12.6
resolution: "@polkadot-api/codegen@npm:0.12.6"
dependencies:
"@polkadot-api/ink-contracts": "npm:0.1.0"
"@polkadot-api/metadata-builders": "npm:0.8.2"
"@polkadot-api/metadata-compatibility": "npm:0.1.9"
"@polkadot-api/ink-contracts": "npm:0.1.1"
"@polkadot-api/metadata-builders": "npm:0.9.0"
"@polkadot-api/metadata-compatibility": "npm:0.1.10"
"@polkadot-api/substrate-bindings": "npm:0.9.2"
"@polkadot-api/utils": "npm:0.1.2"
checksum: cc8e6a4f255e5838730b08cbb0fc72cc7398fe774930bd68f5ad39fa3d80e78084f113e2fc09454a4e551db816220ef5bdd6746609a139fdd02a952d44b8f560
checksum: 6748d994a4cf97eb8853d9ae12ade6590727683023d6b6934157e629c4c99f1f49ec9a5f5340c62e652c6a812e326ed72942ea5e0aea2bc437701f4448c7ab06
languageName: node
linkType: hard

Expand All @@ -803,15 +803,15 @@ __metadata:
languageName: node
linkType: soft

"@polkadot-api/ink-contracts@npm:0.1.0":
version: 0.1.0
resolution: "@polkadot-api/ink-contracts@npm:0.1.0"
"@polkadot-api/ink-contracts@npm:0.1.1":
version: 0.1.1
resolution: "@polkadot-api/ink-contracts@npm:0.1.1"
dependencies:
"@polkadot-api/metadata-builders": "npm:0.8.2"
"@polkadot-api/metadata-builders": "npm:0.9.0"
"@polkadot-api/substrate-bindings": "npm:0.9.2"
"@polkadot-api/utils": "npm:0.1.2"
scale-ts: "npm:^1.6.0"
checksum: e7e22767db5427d50a2b2ca1dc8602416684f3402c925a7bd4b845c4b90ee32b1e81a348779a3b8d299c23faf3d2c69f22a07b179c293df3178957eca3636bac
checksum: a4963763d562cd147dafaa2975d76c358fbef59e6e22e5c97c83bfd3841df28c87c89e41b79593df54c02cc868639f1edf99e2bb080d0b4c701bfac30b5147a7
languageName: node
linkType: hard

Expand Down Expand Up @@ -843,10 +843,10 @@ __metadata:
languageName: node
linkType: hard

"@polkadot-api/known-chains@npm:0.5.4":
version: 0.5.4
resolution: "@polkadot-api/known-chains@npm:0.5.4"
checksum: 1f74015139d6cc1f3019d0960e7d8ef00ffa211e1b97a804e8444cd488656e067cf04601e2070788f44a50d1ab46022b8e686893f5de76a910f14e8d540d119b
"@polkadot-api/known-chains@npm:0.5.5":
version: 0.5.5
resolution: "@polkadot-api/known-chains@npm:0.5.5"
checksum: 89ea415b162504f90af3b42a12179256671455691f41e7f927152faa4007e791343fd28af47b80cabdaadca6147206d6db7a24f88ea897dd9e08c4fb1b95a609
languageName: node
linkType: hard

Expand All @@ -869,37 +869,37 @@ __metadata:
languageName: node
linkType: hard

"@polkadot-api/metadata-builders@npm:0.8.2":
version: 0.8.2
resolution: "@polkadot-api/metadata-builders@npm:0.8.2"
"@polkadot-api/metadata-builders@npm:0.9.0":
version: 0.9.0
resolution: "@polkadot-api/metadata-builders@npm:0.9.0"
dependencies:
"@polkadot-api/substrate-bindings": "npm:0.9.2"
"@polkadot-api/utils": "npm:0.1.2"
checksum: 038b7d5ffce244a806dc85f28ac53bc05721bb4e2c67fce4d8268de816694895320831483460341effc945254d5faf2483e3277c408f7e9c3353f1318c7c65ca
checksum: 26f714bea541cbb4e534707561d0b1d1d2322cba6a49b0cb18deac8923fa21b3a172b163380778655cf44c184713656daae3c6d98c1bbc8baca6d6c924d30125
languageName: node
linkType: hard

"@polkadot-api/metadata-compatibility@npm:0.1.9":
version: 0.1.9
resolution: "@polkadot-api/metadata-compatibility@npm:0.1.9"
"@polkadot-api/metadata-compatibility@npm:0.1.10":
version: 0.1.10
resolution: "@polkadot-api/metadata-compatibility@npm:0.1.10"
dependencies:
"@polkadot-api/metadata-builders": "npm:0.8.2"
"@polkadot-api/metadata-builders": "npm:0.9.0"
"@polkadot-api/substrate-bindings": "npm:0.9.2"
checksum: 593a7de6e05306e4fb42d9ab28baa7e9f6ae6f99b633098d3104e7d192910591e918089b16b95a6b1785223c5a74f3f49c814dd4e582d9ee9af683df39f5a658
checksum: ede884bc58ce1aee49ab290eb6ec03889cfdde4bc4b5f68efb48d425a226cbf6e3ee98068bc2b685da56bf3adae448214a478faec2034b5fd93476a80ad4e7a7
languageName: node
linkType: hard

"@polkadot-api/observable-client@npm:0.5.11":
version: 0.5.11
resolution: "@polkadot-api/observable-client@npm:0.5.11"
"@polkadot-api/observable-client@npm:0.5.13":
version: 0.5.13
resolution: "@polkadot-api/observable-client@npm:0.5.13"
dependencies:
"@polkadot-api/metadata-builders": "npm:0.8.2"
"@polkadot-api/metadata-builders": "npm:0.9.0"
"@polkadot-api/substrate-bindings": "npm:0.9.2"
"@polkadot-api/utils": "npm:0.1.2"
peerDependencies:
"@polkadot-api/substrate-client": 0.2.2
rxjs: ">=7.8.0"
checksum: a1d7374ab73b801de4ea81f17eac716078c23921e481ca78708747a27fd057568ac36b3d5bc50e0f4b12831779c59e8527fa9509fd199ade37c2b961cdf1370d
checksum: aa97d9a4c91445b5ba5a0348c700c8f837c5642cdcc75107b63aa3778a25868fa2cc026103a59077e542bced21b6f5a1f1e72b53b12943400ba7af00fbe331c3
languageName: node
linkType: hard

Expand All @@ -917,15 +917,16 @@ __metadata:
languageName: node
linkType: hard

"@polkadot-api/pjs-signer@npm:0.5.0":
version: 0.5.0
resolution: "@polkadot-api/pjs-signer@npm:0.5.0"
"@polkadot-api/pjs-signer@npm:0.5.1":
version: 0.5.1
resolution: "@polkadot-api/pjs-signer@npm:0.5.1"
dependencies:
"@polkadot-api/metadata-builders": "npm:0.8.2"
"@polkadot-api/metadata-builders": "npm:0.9.0"
"@polkadot-api/polkadot-signer": "npm:0.1.6"
"@polkadot-api/signers-common": "npm:0.1.0"
"@polkadot-api/substrate-bindings": "npm:0.9.2"
"@polkadot-api/utils": "npm:0.1.2"
checksum: 1eb6fb00253f601bbe45774373c90c489dfc1776e5a5e8be844194ff048a3f3040ca818d017fa33e2e31174d541eab2af915ae60c6d58ba0a1d78f52a90e6934
checksum: 0673b24bd998e4fbf4f8122015c58ea74682191303ec96e6e33b6580c2a9e768e8405a0ea88351a3bdd3511d9ca6e8508c894f5c32032377d79cbaffecfa2253
languageName: node
linkType: hard

Expand All @@ -945,14 +946,28 @@ __metadata:
languageName: node
linkType: hard

"@polkadot-api/signer@npm:0.1.8":
version: 0.1.8
resolution: "@polkadot-api/signer@npm:0.1.8"
"@polkadot-api/signer@npm:0.1.9":
version: 0.1.9
resolution: "@polkadot-api/signer@npm:0.1.9"
dependencies:
"@noble/hashes": "npm:^1.5.0"
"@polkadot-api/polkadot-signer": "npm:0.1.6"
"@polkadot-api/signers-common": "npm:0.1.0"
"@polkadot-api/substrate-bindings": "npm:0.9.2"
"@polkadot-api/utils": "npm:0.1.2"
checksum: 31e3428a316f035f6bf5db2d420b405828cc384aa562cd78d66df7c9e3dc8c780ec3726280b79f71a41b87f83dc4911dc00983e81b8d2633c3a418fc629c650f
languageName: node
linkType: hard

"@polkadot-api/signers-common@npm:0.1.0":
version: 0.1.0
resolution: "@polkadot-api/signers-common@npm:0.1.0"
dependencies:
"@polkadot-api/metadata-builders": "npm:0.9.0"
"@polkadot-api/polkadot-signer": "npm:0.1.6"
"@polkadot-api/substrate-bindings": "npm:0.9.2"
"@polkadot-api/utils": "npm:0.1.2"
checksum: ae200b1169ee581611e80070ffdb9108e7bb25eac8a79aa17b50c86f3028c9dfbfd7159777b888f9dffbdee98c373be047d7241ec5074e257f531fafa824c8ae
checksum: 953183756f08c44c37b81dedbdb6a66b39b6e5d040f2a0a01e5445104b90e9419daa66392043e3d5fb3931881fa3bbae36eb070d38181aec7e8baf84c4d2eca3
languageName: node
linkType: hard

Expand Down Expand Up @@ -3234,7 +3249,7 @@ __metadata:
eslint-config-prettier: "npm:^9.1.0"
eslint-plugin-cypress: "npm:^4.0.0"
eslint-plugin-prettier: "npm:^5.2.1"
polkadot-api: "npm:^1.6.2"
polkadot-api: "npm:^1.6.4"
prettier: "npm:^3.3.3"
typescript: "npm:^5.6.3"
vite: "npm:^5.4.9"
Expand Down Expand Up @@ -5083,22 +5098,22 @@ __metadata:
languageName: node
linkType: hard

"polkadot-api@npm:^1.6.2":
version: 1.6.2
resolution: "polkadot-api@npm:1.6.2"
"polkadot-api@npm:^1.6.4":
version: 1.6.4
resolution: "polkadot-api@npm:1.6.4"
dependencies:
"@polkadot-api/cli": "npm:0.9.10"
"@polkadot-api/ink-contracts": "npm:0.1.0"
"@polkadot-api/cli": "npm:0.9.12"
"@polkadot-api/ink-contracts": "npm:0.1.1"
"@polkadot-api/json-rpc-provider": "npm:0.0.4"
"@polkadot-api/known-chains": "npm:0.5.4"
"@polkadot-api/known-chains": "npm:0.5.5"
"@polkadot-api/logs-provider": "npm:0.0.6"
"@polkadot-api/metadata-builders": "npm:0.8.2"
"@polkadot-api/metadata-compatibility": "npm:0.1.9"
"@polkadot-api/observable-client": "npm:0.5.11"
"@polkadot-api/pjs-signer": "npm:0.5.0"
"@polkadot-api/metadata-builders": "npm:0.9.0"
"@polkadot-api/metadata-compatibility": "npm:0.1.10"
"@polkadot-api/observable-client": "npm:0.5.13"
"@polkadot-api/pjs-signer": "npm:0.5.1"
"@polkadot-api/polkadot-sdk-compat": "npm:2.3.1"
"@polkadot-api/polkadot-signer": "npm:0.1.6"
"@polkadot-api/signer": "npm:0.1.8"
"@polkadot-api/signer": "npm:0.1.9"
"@polkadot-api/sm-provider": "npm:0.1.3"
"@polkadot-api/smoldot": "npm:0.3.3"
"@polkadot-api/substrate-bindings": "npm:0.9.2"
Expand All @@ -5110,7 +5125,7 @@ __metadata:
bin:
papi: bin/cli.mjs
polkadot-api: bin/cli.mjs
checksum: 005680ed2ff742eee7eae2b9d5daf35818190072cbb63718da8c5cb27aabf94cb1484369b1a562b547c398e07dbcee46ab4c32fd45c3cc0b4734c6523ca457af
checksum: 432c0a8bd4a0ceb0e64ae7203c41b09611caabbbe72db7cc73e6d74e5f441a8a135309903262678949ef6edcdcd83ee4dbe29418af01be50a1faf6345d2d7573
languageName: node
linkType: hard

Expand Down

0 comments on commit 610b31b

Please sign in to comment.