Questions tagged [typescript]

TypeScript is a typed superset of JavaScript that transpiles to plain JavaScript. It adds optional types, classes, interfaces, and modules to JavaScript. This tag is for questions specific to TypeScript. It is not used for general JavaScript questions.

Filter by
Sorted by
Tagged with
0 votes
0 answers
7 views

generate types from chain does not work. Documentation is not clear

I dont think typegen is working as expected per documentation, by following the provided example and adapting it to my parachain. ` Found 244 errors in 5 files. Errors Files 5 src/interfaces/augment-...
rvalle's user avatar
  • 45
2 votes
1 answer
36 views

Is `createType` safe to use in polkadot-js/api

In this comment of pjs github, it says that we should never do the following: const something = api.createType('SomeType', { foo: 'bar' }); ... await api.tx.somewhere.something(something); ... and ...
Tarik Gul's user avatar
  • 1,066
1 vote
0 answers
20 views

Substrate enum to typescript(polkadot-js)

I am new to Substrate and Polkadot-JS. I am attempting to convert this enum with values to TypeScript, but I haven't been successful so far. I really appreciate any help you can provide. pub enum ...
Uncle_Sam's user avatar
0 votes
0 answers
12 views

Polkadot Typegen importing JS extension instead of TS

We are using the typegen to create types for our custom chain. Following the docs The code that is generated is kinda strange. In the augment-api.ts file it tries to import all the other generated ts ...
donkeydonkey's user avatar
1 vote
1 answer
39 views

Decode event data

I am learning to use polkadotjs api, I am trying to send a system.remarkWithEvent and then get the event that this created and decode de output to verify that the remark is there. The sending of the ...
Valentin Fernandez's user avatar
3 votes
1 answer
37 views

subscriptions with parameters in polkadot.js api

I am using React+Typescript and trying to retrieve data from a struc using a query subscription. I first tried the following in order to check that I'm retrieving the right data: api.query.rolesModule....
Kazunobu Ndong's user avatar
2 votes
1 answer
71 views

api.createType does not work?

I would like to create a type called XcmVersionedMultiLocation. It can be imported using the following code: import { XcmVersionedMultiLocation } from "@polkadot/types/lookup"; To create an ...
Michal Danco's user avatar
3 votes
0 answers
35 views

How to get runtime types in polkadotjs (typescript)

In subxt we can have Rust types directly from scale-encoded runtime metadata. Is the same possible in polkadotjs? Is there a "polkadots" which has typescript types automatically derived from ...
Hugo Trentesaux's user avatar
3 votes
1 answer
93 views

What informations consist of a signature which is generated when siging a transaction payload offline?

From the wiki (https://wiki.polkadot.network/docs/build-transaction-construction), import { createSignedTx } from "@substrate/txwrapper-polkadot"; // Example code, replace `signWithAlice` ...
drhanlondon's user avatar
0 votes
1 answer
24 views

what is the correct typescript syntax for declaring the return type of session.queuedKeys()

in this pull request, i attempt to add support for looking up the collator account associated with a given nimbus session key. the method implementation in the pr is as follows: export function ...
grenade's user avatar
  • 456
0 votes
0 answers
18 views

Where in PJS Apps are signatures added to transactions & submitted?

I have been following the path of a Ledger submitted transaction on Polkadot JS Apps, and have found that the Ledger device is generating a signature here in hw-ledger/src/bundle.ts. I am unable ...
Ross's user avatar
  • 131
1 vote
1 answer
97 views

Invalid Transaction: Transaction has a bad signature - Ledger signature into tx

I am attempting to submit a transaction using Polkadot JS API and a signature that has been signed by Ledger. Upon passing it to send I get the Invalid Transaction: Transaction has a bad signature ...
Ross's user avatar
  • 131
2 votes
1 answer
40 views

Errors on generated code from Typegen

We are following the polkadot{.js} docs on TypeScript user generated for Chain modules. We are trying to get our custom chain module types into Typescript. We can generate fine however the generated ...
donkeydonkey's user avatar
2 votes
1 answer
105 views

MultiLocation type polkadot js

I am trying to figure out correct way how to type MultiLocation type I thought that I would do import {MultiLocation} from "@polkadot/types/interfaces" const location: MultiLocation = { ...
Michal Danco's user avatar
2 votes
1 answer
96 views

How do I include a tip for transactions using Polkadot.JS/API

I am attempting to add a tip to a transaction in the following manner: const batch = await api.tx.utility.batch([...]); batch.tip = 1; It appears that tip is a read-only property and I'm receiving an ...
Paradox - ParaNodes.io's user avatar
1 vote
1 answer
87 views

Custom ChargeTransactionPayment type for extrinsics

if the type for extrinsic verification pub struct ChargeTransactionPayment<T: Config> has been changed on a chain, how do we update the polkadot.js API to use the new types? Suppose the type has ...
Emmanuel Thomas's user avatar
1 vote
0 answers
14 views

UnsubscribePromise not being returned from subscription

When I try to create a subscription from a custom pallet, it doesn't return a UnsubscribePromise (like the native ones), but returns a Promise<Codec>, even though I added a callback as the last ...
Pedro Filho's user avatar
0 votes
1 answer
158 views

How do we work with polkadot-js enums in TypeScript?

I used typegen to generate my types from definitions. Definition Person: { status: 'Status', balance: 'u128', }, Status: { _enum: ['Active',...
forgetso's user avatar
  • 1,462
0 votes
1 answer
172 views

Extracting error from system.ExtrinsicFailed

I have a call to an extrinsic (in a Typescript/RxJS client) that is failing but I want to be able to catch the error that the extrinsic is throwing and not just that it failed. const chainEvents: ...
Robert La Ferla's user avatar
0 votes
1 answer
216 views

JavaScript/TypeScript: How to pass arguments of an array individually to a function?

I want to dynamically call contract functions. The only problem with this is, that all of the functions have a different amount of variables. As of now, the function looks like this: async call(...
rajohs's user avatar
  • 491
1 vote
2 answers
299 views

Typescript errors when using @polkadot/api

I'm building a typescript project and I'm trying to do the very simplest thing as a first step with Polkadot: Connect to a node and get account information. However, when I run tsc, it totally blows ...
kael's user avatar
  • 109
3 votes
2 answers
129 views

How to decorate polkadot.js api with upcoming runtime features

There's upcoming features coming to pallet uniques. They are now merged to master of substrate repo but not yet released. We would like to be prepared for it on Singular marketplace but not 100% sure ...
Yuri's user avatar
  • 173
1 vote
2 answers
54 views

Are there any tools available for creating a mock version of a contract in JS/TS?

Currently, we use "live" versions of our contracts running on a substrate contracts node in our JavaScript tests. This makes them integration tests and difficult to include in simple GitHub ...
forgetso's user avatar
  • 1,462
1 vote
1 answer
70 views

Polkadot{js} state queryies example not working

I am trying to run one of the examples in the Polkadot{.js} documentation and it is not working for me in TypeScript. This much works const wsProvider = new WsProvider('wss://rpc.polkadot.io'); ...
Roger J Bos CFA's user avatar
2 votes
2 answers
1k views

How to prevent / remove duplicate modules and mismatched version numbers (i.e. @polkdadot/types)?

I am still learning TypeScript and I have some code that is working, but it returns a lot of messages about multiple versions of modules and conflicting packages. What is the best way to fix these ...
Roger J Bos CFA's user avatar
1 vote
1 answer
60 views

How to do a democracy pallet vote using Polkadot API in typescript

I am trying to do a democracy vote using the API. First I am getting the balance of my account: const balance = (await api.query.system.account(my_account)).data.free; const voteConfig: Vote = ...
nicolasochem's user avatar
2 votes
1 answer
214 views

How do you resolve missing type errors in the @polkadot/api v7.x.x packages?

Upgrading from: // package.json "@polkadot/api": "^6.7.2", "@polkadot/types": "^6.7.2", to: // package.json "@polkadot/api": "^7.7.1", &...
tarrball's user avatar
  • 225