Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support chopsticks with archive unstable body #602

Merged
merged 13 commits into from
Dec 20, 2024
2 changes: 1 addition & 1 deletion packages/ui/.env.staging
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VITE_CHAIN_ID="kusama"
VITE_NETWORK_NAME="kusama"
VITE_WS_PROVIDER="ws://localhost:8000"
VITE_GRAPHQL_HTTP_PROVIDER="http://localhost:4350/graphql"
VITE_GRAPHQL_HTTP_PROVIDER="http://localhost:4000/graphql"
34 changes: 15 additions & 19 deletions packages/ui/cypress/tests/multisig-creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,14 @@ 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.create_pure')
})
})

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

verifySignatories()

// 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:')
// })
// there should be a pending remark
multisigPage
.transactionList()
.should('be.visible')
.within(() => {
multisigPage.pendingTransactionItem().should('have.length', 1)
multisigPage.pendingTransactionCallName().should('contain.text', 'System.remark')
})
})
})

Expand Down
15 changes: 11 additions & 4 deletions packages/ui/src/hooks/usePendingTx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type AggGroupedByDate = { [index: string]: CallDataInfoFromChain[] }
const opaqueMetadata = Tuple(compact, Bin(Infinity)).dec

const getExtDecoderAt = async (api: ApiType, client: PolkadotClient, blockHash?: string) => {
const rawMetadata = await (blockHash
const rawMetadata = await (blockHash && !import.meta.env.DEV
? client
._request<{
result: HexString
Expand Down Expand Up @@ -108,16 +108,23 @@ const getCallDataFromChainPromise = (
) =>
pendingTxData.map(async (pendingTx) => {
const blockNumber = pendingTx.info.when.height
const blockHash = (
await client._request('archive_unstable_hashByHeight', [blockNumber])
)?.[0] as HexString | undefined
const blockHashes = await client._request('archive_unstable_hashByHeight', [blockNumber])
const blockHash = (Array.isArray(blockHashes) ? blockHashes?.[0] : blockHashes) as
| HexString
| undefined

console.log('pendingTx', pendingTx)
console.log('blockNumber', blockNumber)
console.log('blockHashes', blockHashes)
console.log('blockHash', blockHash)
Tbaut marked this conversation as resolved.
Show resolved Hide resolved

if (!blockHash) {
console.log('no hash found for height', blockNumber)
return
}

const body: HexString[] = await client._request('archive_unstable_body', [blockHash])
console.log('body', body)
Tbaut marked this conversation as resolved.
Show resolved Hide resolved

let date: Date | undefined

Expand Down
Loading