bnb-chain / greenfield-js-sdk

JS SDK for Greenfield

Home Page:https://docs.bnbchain.org/greenfield-js-sdk/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Create bucket with signer does not work

doge-malone opened this issue · comments

SDK version:

  • reproducible on ^0.2.3, 0.2.4-alpha.12, 0.2.4-alpha.19

Environment:

  • OS (e.g. from /etc/os-release):
  • Install tools:
  • Others:

What happened:
Issue using the greenfield JS SDK on our dapp where client.bucket.createBucket fails after signing msg using metamask with the following error:

GET https://gnfd-testnet-sp1.nodereal.io/greenfield/admin/v1/get-approval?action=CreateBucket 400
index.tsx:93 Uncaught (in promise) {code: -1, message: 'bad signature', statusCode: 400}

Method works with a private key, but does not work for offChainAuth.

What you expected to happen:
After signing, a new bucket should be created.

Have you tried the latest version: yes

How to reproduce it (as minimally and precisely as possible):

Our code is a copy of the NextJS example in the SDK codebase. Just run the NextJS code or the following:

      `const createBucketTx = await client.bucket.createBucket(
        {
          bucketName: createBucketInfo.bucketName,
          creator: address,
          visibility: "VISIBILITY_TYPE_PUBLIC_READ",
          chargedReadQuota: "0",
          spInfo: {
            primarySpAddress: spInfo.primarySpAddress,
          },
          signType: "offChainAuth",
          domain: window.location.origin,
          seedString: offChainData.seedString,
        }
      );`

Logs (paste a small part showing an error (< 10 lines) or link a pastebin, gist, etc. containing more of the log file):
GET https://gnfd-testnet-sp1.nodereal.io/greenfield/admin/v1/get-approval?action=CreateBucket 400
index.tsx:93 Uncaught (in promise) {code: -1, message: 'bad signature', statusCode: 400}

Config (you can paste only the changes you've made): N/A

node command runtime flags:

Anything else we need to know: Please help as we're building something cool for hackvolution. Thanks.

commented

@doge-malone

The alpha version is used to iterate over the next version, and the next version is BREAKING CHANGE for testnet.

If you need it now, use 0.2.3.

Reference code on main branch: https://github.com/bnb-chain/greenfield-js-sdk/blob/main/examples/nextjs/src/components/bucket/create/index.tsx#L34-L44. alpha branch and alpha version corresponding development branch of the internal chain.

NOTICE: As I said above, we will reset testnet chain and release 0.2.4 in two days. Then you can run your current code.

Now gnfd chain and SDK are working hard on iteration, thanks for using 😄 .

Since the issue was labeled with needs more info, but no response in 3 days. This issue will be closed. If you have any questions, you can comment and reply.