anchor
anchor copied to clipboard
React Native support
Are you planning on creating a version that supports react native? Or are there any resources we can follow to make it work?
I left a comment here to get it to build https://github.com/project-serum/anchor/issues/864#issuecomment-968104501
const tx = await program.rpc.setData(
'data'
{
accounts: {
data: pda,
user: provider.wallet.publicKey,
systemProgram: anchor.web3.SystemProgram.programId,
},
signers: [],
},
);
When I call the above instruction, I get this error undefined is not a constructor (evaluating 'new a.Transaction()')
@saicharanpogul did you find any solution?
@saicharanpogul did you find any solution?
No, I just tried again with new APIs of v0.24.2 and also asked the same in Anchor's Discord and this is not the first time, I asked several times. Seems like no one from the community and even core developers are interested in React Native queries and issues!
@saicharanpogul it looks like the tx is failing at this line: https://github.com/project-serum/anchor/blob/master/ts/src/program/namespace/transaction.ts#L18-L19
@raj-khare Check if this helps you. https://stackoverflow.com/a/70964609/4687973
@saicharanpogul thanks, it worked when i removed the terser
plugin 🚀
@saicharanpogul thanks, it worked when i removed the
terser
plugin 🚀
Great, can you share here how you removed the terser plugin exactly.
@saicharanpogul
- Fork the anchor repo
- Comment/Remove this line: https://github.com/project-serum/anchor/blob/master/ts/rollup.config.ts#L33
- run
cd ts && yarn && yarn run build:browser
- copy the
dist/
folder to your own project - instead of doing
import * anchor from "@project-serum/anchor
, doimport * anchor from "./dist/index"
@saicharanpogul
- Fork the anchor repo
- Comment/Remove this line: https://github.com/project-serum/anchor/blob/master/ts/rollup.config.ts#L33
- run
cd ts && yarn && yarn run build:browser
- copy the
dist/
folder to your own project- instead of doing
import * anchor from "@project-serum/anchor
, doimport * anchor from "./dist/index"
Are you able to create instance of Wallet
and pass it AnchorProvider
?
@saicharanpogul
- Fork the anchor repo
- Comment/Remove this line: https://github.com/project-serum/anchor/blob/master/ts/rollup.config.ts#L33
- run
cd ts && yarn && yarn run build:browser
- copy the
dist/
folder to your own project- instead of doing
import * anchor from "@project-serum/anchor
, doimport * anchor from "./dist/index"
This solution worked perfect! Thanks @raj-khare. Would be awesome if support for RN is added so we don't have to do this.
@saicharanpogul you can add the wallet on the generated file and export it, like this:
@devenus98 it has moved to https://github.com/coral-xyz/anchor/tree/master/ts
Good luck...
@devenus98 it has moved to https://github.com/coral-xyz/anchor/tree/master/ts
Good luck...
which line needs commenting out now?