js-deprecated icon indicating copy to clipboard operation
js-deprecated copied to clipboard

Error in actions.placeBid

Open dtome123 opened this issue 3 years ago • 26 comments

There a bug when I call actions.placeBid function, it is "Bidder Pot Token Must be a new account". Then I read source code and everything is normal. Why did that happen? image (error) image (code)

dtome123 avatar Jan 22 '22 05:01 dtome123

since this https://github.com/metaplex-foundation/metaplex-program-library/pull/101

  const bidderPotToken = await AuctionProgram.findProgramAddress([
    Buffer.from(AuctionProgram.PREFIX),
    new PublicKey(bidderPotKey).toBuffer(),
    Buffer.from("bidder_pot_token"),
  ]);

exromany avatar Jan 25 '22 19:01 exromany

Need to port this fix over https://github.com/metaplex-foundation/metaplex/pull/1557

aheckmann avatar Jan 25 '22 20:01 aheckmann

I try like sugget of exromany then it pass old bug but it have new bug image

dtome123 avatar Jan 26 '22 06:01 dtome123

because simulation fails. you can use connection.sendRawTransaction with skipPreflight to skip simulation

connection.sendRawTransaction(tx.serialize(), {
  skipPreflight: true,
});

exromany avatar Jan 26 '22 15:01 exromany

because simulation fails. you can use connection.sendRawTransaction with skipPreflight to skip simulation

connection.sendRawTransaction(tx.serialize(), {
  skipPreflight: true,
});

But after executing, it is still an error transaction so it's not better than. Do you think error from logic code somewhere like smart contract? Because if I use old code in JDK, error is "Bidder Pot Token must be a new account". Then I use your code, it pass but new error is "instruction requires an initialized account". Is there a conflict here? Thank for your help

dtome123 avatar Jan 27 '22 02:01 dtome123

The issue is that the revoke instruction is sent after the accountclose instruction, which leads to an uninitializedaccount error.

basvanberckel avatar Feb 01 '22 15:02 basvanberckel

@basvanberckel @dtome123 I am facing this same issue, any idea on how to fix this ?

AmmarKhalid123 avatar Feb 02 '22 15:02 AmmarKhalid123

I believe this is already enough to fix this error: https://github.com/metaplex-foundation/js/pull/172

basvanberckel avatar Feb 02 '22 15:02 basvanberckel

Yes this seems correct. I hope it gets accepted soon enough

AmmarKhalid123 avatar Feb 02 '22 15:02 AmmarKhalid123

@basvanberckel Is there any way I can use your forked repo to test this solution, and continue on my work until your PR is committed? I have run npm install git+https://github.com/Beemup/metaplex-js-sdk.git but unable to import from @metaplex/js, maybe because "lib" folder is missing in the node_modules/@metaplex/js/, which was there when I installed usingnpm install @metaplex/js.

AmmarKhalid123 avatar Feb 02 '22 16:02 AmmarKhalid123

What does your import/require statement look like in your app code? You shouldn't need to import from /lib, just from '@metaplex/js'

basvanberckel avatar Feb 02 '22 16:02 basvanberckel

import { Connection, actions } from '@metaplex/js';

AmmarKhalid123 avatar Feb 02 '22 16:02 AmmarKhalid123

import { Connection, actions } from '@metaplex/js';

On this import, I'm getting error: Module not found: Can't resolve '@metaplex/js' in 'D:\Office\SolMarketplace\solmarket\src' . Am I doing something wrong? @basvanberckel

AmmarKhalid123 avatar Feb 02 '22 16:02 AmmarKhalid123

Yeah, my bad, you can't directly install from this repo as the artifacts aren't included. Clone the repo, build it and install that as a dependency to your own project:

cd your/project/dir
git clone https://github.com/beemup/metaplex-js-sdk -b placebid-transfer-bug
cd metaplex-js-sdk
npm install
npm run build
cd ..
npm install ./metaplex-js-sdk

basvanberckel avatar Feb 02 '22 17:02 basvanberckel

@basvanberckel I'm still getting the same error btw :( Have you tested out this solution on your end?

AmmarKhalid123 avatar Feb 02 '22 17:02 AmmarKhalid123

@basvanberckel I'm still getting the same error btw :( Have you tested out this solution on your end?

Just to clarify, imports are working fine, but I'm getting the initial error of "Bidder pot token must be a new account" on actions.placeBid @basvanberckel

AmmarKhalid123 avatar Feb 02 '22 17:02 AmmarKhalid123

I have my own implementation of placebid that fixes both these errors, the fix linked in this thread above together with my pull request should resolve both. I am not able to write a full test for this right now, there should be a unit test if this needs to be verified in the future.

basvanberckel avatar Feb 02 '22 17:02 basvanberckel

the fix linked in this thread above together with my pull request should resolve both.

Are you talking about this fix?

because simulation fails. you can use connection.sendRawTransaction with skipPreflight to skip simulation

connection.sendRawTransaction(tx.serialize(), {
  skipPreflight: true,
});

AmmarKhalid123 avatar Feb 02 '22 18:02 AmmarKhalid123

The bidder token address should be generated like in https://github.com/metaplex-foundation/metaplex/pull/1557

That will resolve the initial error of this issue.

The transaction order should be changed like in my PR, that will resolve the UninitializedAccount error. It is also an option to remove the revoke instruction entirely, like in https://github.com/metaplex-foundation/metaplex/pull/1557

basvanberckel avatar Feb 02 '22 18:02 basvanberckel

I've updated the pr to fix both errors. @AmmarKhalid123 Would you be able to verify this works in your setup?

basvanberckel avatar Feb 02 '22 19:02 basvanberckel

I've updated the pr to fix both errors. @AmmarKhalid123 Would you be able to verify this works in your setup?

I will check right away and let you know

AmmarKhalid123 avatar Feb 02 '22 19:02 AmmarKhalid123

I've updated the pr to fix both errors. @AmmarKhalid123 Would you be able to verify this works in your setup?

Works like a charm.

AmmarKhalid123 avatar Feb 02 '22 20:02 AmmarKhalid123

@basvanberckel forgot, there was an import of AuctionProgram I remember missing, placeBid.ts file. I got it when tried to build the project, otherwise works great.

AmmarKhalid123 avatar Feb 02 '22 20:02 AmmarKhalid123

Ah yes, thanks. Fixed that now

basvanberckel avatar Feb 03 '22 08:02 basvanberckel

Can also confirm that @basvanberckel fix works.

tengu-br avatar Feb 18 '22 17:02 tengu-br

@AmmarKhalid123 @basvanberckel @tengu-br i am also facing the same problem of bidder pot, i made the changes you have added in the pr but the issue of bidder pot token must be new is still there am i missing something

nurav97 avatar Apr 26 '22 10:04 nurav97