Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type 0x2::kiosk::Kiosk is not registered #17256

Closed
sudofina opened this issue Apr 20, 2024 · 6 comments
Closed

Type 0x2::kiosk::Kiosk is not registered #17256

sudofina opened this issue Apr 20, 2024 · 6 comments
Assignees

Comments

@sudofina
Copy link

Steps to Reproduce Issue

kioskClient.getKiosk(kioskId) where kioskId is 0x6ca6a0fbcd8bb6952382aa0f590c8ab9c46d102d6704e186a6cc0a1c235d524d on testnet: https://testnet.suivision.xyz/object/6ca6a0fbcd8bb6952382aa0f590c8ab9c46d102d6704e186a6cc0a1c235d524d

Expected Result

Expected getKiosk to return the kiosk data.

Actual Result

An error was returned:

"Error: Type 0x2::kiosk::Kiosk is not registered\n    at _BCS.getTypeInterface (http://localhost:3000/static/js/bundle.js:122705:13)\n    at _BCS.de (http://localhost:3000/static/js/bundle.js:122202:19)\n    at getKioskObject 

System Information

"@mysten/bcs": "0.11.1",
"@mysten/sui.js": "0.51.2",
"@mysten/kiosk": "0.8.6",
@sudofina
Copy link
Author

@EasonC13
Copy link

EasonC13 commented Apr 20, 2024

Have you specified that you want to call a testnet kiosk?

const kioskId = "0x6ca6a0fbcd8bb6952382aa0f590c8ab9c46d102d6704e186a6cc0a1c235d524d"

const kioskClient = new KioskClient({
      client,
      network: "testnet",
    });

const kiosk = await kioskClient.getKiosk(kioskId)
console.log({kiosk})

@sudofina
Copy link
Author

Yes, that's specified.

My code:

const kioskClient = new KioskClient({
      suiClient,
      network: Network.TESTNET,
});

const res = await kioskClient.getKiosk({
   id: kioskId,
   options: {
         withKioskFields: true,
         withObjects: true,
    },
});

But I found out that this error only occurs when I provide withKioskFields = true option to the getKiosk API since when withKioskFields is set to true, it will call getKioskObject which internally calls bcs.de in https://github.com/MystenLabs/sui/blob/main/sdk/bcs/src/legacy-registry.ts#L274, which has led to the error in legacy-registry.ts: https://github.com/MystenLabs/sui/blob/main/sdk/bcs/src/legacy-registry.ts#L947.

I am able to get the response back without the error if I remove withKioskFields: true from the provided option.

@sudofina
Copy link
Author

sudofina commented Apr 20, 2024

I am able to get what I want for now but I will leave this issue open as I believe this is still an issue if we want to set withKioskFields = true

@hayes-mysten
Copy link
Contributor

This may be related to the sideEffects option, which is set to false here:

"sideEffects": false,
. This option allows bundlers to remove code that isn't directly imported, reducing bundle size. The bcs type it's complaining about is registered here:

sui/sdk/kiosk/src/bcs.ts

Lines 14 to 20 in 4313fc2

bcs.registerStructType(KIOSK_TYPE, {
id: 'address',
profits: 'u64',
owner: 'address',
itemCount: 'u32',
allowExtensions: 'bool',
});
, but I suspect is being eliminated during bundling.

There is some existing work that entirely removes the bcs registry and ensures that the SDKs aren't dependent on types being registered as a side-effect of importing files. If this is a blocker, we can probably temporarily set sideEffects to true in the kiosk package, otherwise, this will be resolved in an upcoming release that should be out in the next few weeks

@hayes-mysten
Copy link
Contributor

The registry has been removed from @mysten/bcs, and the kiosk sdk has been updated to use the updated bcs APIs, so this should no-longer be an issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants