Skip to content

Not able to export a suborganization wallet #597

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

Open
cmordi opened this issue Apr 14, 2025 · 3 comments
Open

Not able to export a suborganization wallet #597

cmordi opened this issue Apr 14, 2025 · 3 comments

Comments

@cmordi
Copy link

cmordi commented Apr 14, 2025

I'm looking to add functionality to derive the recovery phrase for a Solana wallet so I can display that on a UI. I implemented the export wallet functionality off the docs I saw and currently running into a

Turnkey error 3: organization mismatch: request is targeting organization (), but voters are in organization () (Details: [])

where the targeting organization is my root organization id while the voters is the sub-organization id

I've chalked this down exportWallet and the turnkeyClient not allowing sub-organization id's not being accepted. Please let me know

@t-vila
Copy link
Contributor

t-vila commented Apr 14, 2025

Hey, the parent org has only read rights over the its sub-orgs, export is a write operation. This activity will need to be initiated using the sub-org id.

@cmordi
Copy link
Author

cmordi commented Apr 14, 2025

I want to preface this by saying that I am using the free plan and im not sure if that's why this is happening.

I kind of assumed that we would need to use the sub-org id instead, but even when I initialize with the sub-org details, I still get the same error message. This is my initialization. For further breakdown, these are the snippets from the file in referencing where relevant turnkey actions are happening or are related, and maybe there is something im genuinely not understanding that you could help me point out.

The flow goes like this. I fetch the turnkey sub-organization ID details (which I've verified are correct) from the database:

    const { data: userWallet, error: walletError } = await supabase
      .from('user_wallets')
      .select('turnkey_sub_org_id, turnkey_wallet_id')
      .eq('user_id', session.user.id)
      .maybeSingle();

I then initialize my client:

    const turnkeyClient = new Turnkey({
      apiPublicKey: process.env.TURNKEY_API_PUBLIC_KEY || '',
      apiPrivateKey: process.env.TURNKEY_API_PRIVATE_KEY || '',
      apiBaseUrl: process.env.NEXT_PUBLIC_BASE_URL ,
      defaultOrganizationId: userWallet.turnkey_sub_org_id
    });

Then I get the export bundle from turnkey:

    const exportResult = await turnkeyClient.apiClient().exportWallet({
      walletId: userWallet.turnkey_wallet_id,
      targetPublicKey: targetPublicKey,
      organizationId: userWallet.turnkey_sub_org_id
    });

@cmordi
Copy link
Author

cmordi commented Apr 17, 2025

Hey @t-vila. Just wondering if you had any recommendations to solve this? We need to find a way to resolve this so that we can demo the full functionality before subscribing to the enterprise plan

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

No branches or pull requests

2 participants