bnb-chain / greenfield-js-sdk

JS SDK for Greenfield
https://docs.bnbchain.org/greenfield-js-sdk/
GNU General Public License v3.0
28 stars 16 forks source link

Problems with offchain Auth #479

Closed AndrewChupin closed 9 months ago

AndrewChupin commented 9 months ago

During offchain auth I get an error, deployment on localhost:8082:

    const providers = await gf.client.sp.getStorageProviders()
                            const provider = window.ethereum

                            const { code, body, message }  = await gf.client.offchainauth.genOffChainAuthKeyPairAndUpload(
                                {
                                    sps: providers
                                        .map((item) => {
                                            return {
                                                address: item.operatorAddress,
                                                endpoint: item.endpoint,
                                                name: item.description.moniker,
                                            }
                                        }),
                                    chainId: net.chain?.id || 0,
                                    expirationMs: 7 * 24 * 60 * 60 * 1000,
                                    domain: window.location.origin,
                                    address: address,
                                },
                                provider
                            )

                            if (code !== 0) {
                                console.log('gen offchainauth key pair error', message);
                                return;
                            }

Failed to execute 'compile' on 'WebAssembly': Incorrect response MIME type. Expected 'application/wasm'.

rrr523 commented 9 months ago

It looks like there was an error loading the zk wasm file

Is that how you use it:

const client = Client.create(GRPC_URL, String(GREEN_CHAIN_ID), {
  zkCryptoUrl:
    'https://unpkg.com/@bnb-chain/greenfield-zk-crypto@0.0.3/dist/node/zk-crypto.wasm',
});

doc: https://docs.bnbchain.org/greenfield-js-sdk/client/greenfield-client/

AndrewChupin commented 9 months ago

Yeah, it works thanks