Skip to content

Commit b2fee7d

Browse files
Imod7filvecchiatoTarikGul
authored
fix: add xcmVersion in DryRunCall (#1649)
* fix: add xcmVersion in DryRunCall * update code to get the latest metadata version * updating tests (attempt) * Fv domi fix dryrun (#1662) * wip:tests * Fix metadata issue * fix tests for TxDryRun * running tests for dryrun * cleanup --------- Co-authored-by: tarikgul <[email protected]> * Fix test results --------- Co-authored-by: Filippo <[email protected]> Co-authored-by: tarikgul <[email protected]>
1 parent 9c86b9b commit b2fee7d

File tree

15 files changed

+69744
-41
lines changed

15 files changed

+69744
-41
lines changed

src/controllers/transaction/TransactionDryRunController.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { BadRequest } from 'http-errors';
2020
import { TransactionDryRunService } from '../../services';
2121
import { IPostRequestHandler, ITx } from '../../types/requests';
2222
import AbstractController from '../AbstractController';
23+
2324
/**
2425
* Dry run a transaction.
2526
*
@@ -60,7 +61,7 @@ export default class TransactionDryRunController extends AbstractController<Tran
6061
}
6162

6263
private dryRunTransaction: IPostRequestHandler<ITx> = async (
63-
{ body: { tx, at, senderAddress } },
64+
{ body: { tx, at, senderAddress, xcmVersion } },
6465
res,
6566
): Promise<void> => {
6667
if (!tx) {
@@ -71,8 +72,11 @@ export default class TransactionDryRunController extends AbstractController<Tran
7172
throw new BadRequest('Missing field `senderAddress` on request body.');
7273
}
7374

74-
const hash = at ? await this.getHashFromAt(at) : undefined;
75+
const hash = await this.getHashFromAt(at);
7576

76-
TransactionDryRunController.sanitizedSend(res, await this.service.dryRuntExtrinsic(senderAddress, tx, hash));
77+
TransactionDryRunController.sanitizedSend(
78+
res,
79+
await this.service.dryRuntExtrinsic(senderAddress, tx, hash, xcmVersion),
80+
);
7781
};
7882
}

src/services/runtime/RuntimeMetadataService.spec.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,15 @@
1616

1717
import { sanitizeNumbers } from '../../sanitize/sanitizeNumbers';
1818
import { blockHash789629, defaultMockApi } from '../test-helpers/mock';
19-
import response789629 from '../test-helpers/responses/runtime/metadata789629.json';
19+
import response from '../test-helpers/responses/runtime/responseV15.json';
2020
import { RuntimeMetadataService } from './RuntimeMetadataService';
2121

2222
const runtimeMetadataService = new RuntimeMetadataService(defaultMockApi);
2323

2424
describe('RuntimeMetadataService', () => {
2525
describe('fetchMetadata', () => {
2626
it('works when ApiPromise works (block 789629)', async () => {
27-
expect(sanitizeNumbers(await runtimeMetadataService.fetchMetadata(blockHash789629))).toStrictEqual(
28-
response789629,
29-
);
27+
expect(sanitizeNumbers(await runtimeMetadataService.fetchMetadata(blockHash789629))).toStrictEqual(response);
3028
});
3129
});
3230
});

src/services/runtime/RuntimeMetadataService.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

1717
import { ApiDecoration } from '@polkadot/api/types';
18-
import { Metadata } from '@polkadot/types';
19-
import type { Option } from '@polkadot/types/codec';
18+
import { Metadata, Option } from '@polkadot/types';
2019
import type { BlockHash, OpaqueMetadata } from '@polkadot/types/interfaces';
2120
import { InternalServerError } from 'http-errors';
2221

@@ -68,7 +67,6 @@ export class RuntimeMetadataService extends AbstractService {
6867
async fetchMetadataVersions(hash: BlockHash): Promise<string[]> {
6968
const { api } = this;
7069
const apiAt = await api.at(hash);
71-
7270
const availableVersions = (await apiAt.call.metadata.metadataVersions()).toHuman() as string[];
7371

7472
return availableVersions;

0 commit comments

Comments
 (0)