anchor icon indicating copy to clipboard operation
anchor copied to clipboard

React Native support

Open rbjamaca opened this issue 3 years ago • 12 comments

Are you planning on creating a version that supports react native? Or are there any resources we can follow to make it work?

rbjamaca avatar Nov 30 '21 05:11 rbjamaca

I left a comment here to get it to build https://github.com/project-serum/anchor/issues/864#issuecomment-968104501

safaiyeh avatar Dec 14 '21 00:12 safaiyeh

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 avatar Feb 16 '22 14:02 saicharanpogul

@saicharanpogul did you find any solution?

raj-khare avatar Apr 24 '22 16:04 raj-khare

@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 avatar Apr 24 '22 21:04 saicharanpogul

@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 avatar Apr 25 '22 15:04 raj-khare

@raj-khare Check if this helps you. https://stackoverflow.com/a/70964609/4687973

saicharanpogul avatar Apr 25 '22 16:04 saicharanpogul

@saicharanpogul thanks, it worked when i removed the terser plugin 🚀

raj-khare avatar Apr 25 '22 18:04 raj-khare

@saicharanpogul thanks, it worked when i removed the terser plugin 🚀

Great, can you share here how you removed the terser plugin exactly.

saicharanpogul avatar Apr 25 '22 18:04 saicharanpogul

@saicharanpogul

  1. Fork the anchor repo
  2. Comment/Remove this line: https://github.com/project-serum/anchor/blob/master/ts/rollup.config.ts#L33
  3. run cd ts && yarn && yarn run build:browser
  4. copy the dist/ folder to your own project
  5. instead of doing import * anchor from "@project-serum/anchor, do import * anchor from "./dist/index"

raj-khare avatar Apr 26 '22 07:04 raj-khare

@saicharanpogul

  1. Fork the anchor repo
  2. Comment/Remove this line: https://github.com/project-serum/anchor/blob/master/ts/rollup.config.ts#L33
  3. run cd ts && yarn && yarn run build:browser
  4. copy the dist/ folder to your own project
  5. instead of doing import * anchor from "@project-serum/anchor, do import * anchor from "./dist/index"

Are you able to create instance of Wallet and pass it AnchorProvider?

saicharanpogul avatar Apr 26 '22 09:04 saicharanpogul

@saicharanpogul

  1. Fork the anchor repo
  2. Comment/Remove this line: https://github.com/project-serum/anchor/blob/master/ts/rollup.config.ts#L33
  3. run cd ts && yarn && yarn run build:browser
  4. copy the dist/ folder to your own project
  5. instead of doing import * anchor from "@project-serum/anchor, do import * 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.

mordonez-me avatar May 31 '22 02:05 mordonez-me

@saicharanpogul you can add the wallet on the generated file and export it, like this:

image

mordonez-me avatar May 31 '22 17:05 mordonez-me

@devenus98 it has moved to https://github.com/coral-xyz/anchor/tree/master/ts

Good luck...

Plitskine avatar Jan 27 '23 02:01 Plitskine

@devenus98 it has moved to https://github.com/coral-xyz/anchor/tree/master/ts

Good luck...

which line needs commenting out now?

faisalKhan-99 avatar Feb 13 '23 12:02 faisalKhan-99