Skip to content

SDK Server type revamp + wallet account creation helper#1225

Open
ethankonk wants to merge 5 commits intomainfrom
ethan/sdk-server-types
Open

SDK Server type revamp + wallet account creation helper#1225
ethankonk wants to merge 5 commits intomainfrom
ethan/sdk-server-types

Conversation

@ethankonk
Copy link
Contributor

Summary & Motivation

  • @turnkey/sdk-server has been using its own generated types for the sdk client for a while, we've recently introduced a types package with readable generated types which we are switching @turnkey/sdk-server over to.
  • Also added generateWalletAccountsFromAddressFormat helper to sdk-server
    • This helper takes in an array of address formats as well as an array of the current wallet accounts within the wallet and handles conflicting/duplicate path formats returning an array of v1WalletAccountParams for easy wallet account generation.

How I Tested These Changes

  • locally

Did you add a changeset?

  • yes

@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 27, 2026

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit ce3d616:

Sandbox Source
@turnkey/example-react-components Configuration

@ethankonk ethankonk force-pushed the ethan/sdk-server-types branch 2 times, most recently from b7cb610 to 7769ccd Compare March 9, 2026 16:01
@ethankonk ethankonk force-pushed the ethan/sdk-server-types branch from 5d51533 to 2f4d42d Compare March 13, 2026 17:07
@andrewkmin andrewkmin requested a review from Copilot March 18, 2026 15:46
to: string;
caip2: string;
caip2:
| "eip155:1"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we define this set as its own type? can help us DRY things up a bit. and if/when we do so, it might be useful to also add the plain english EVM network (e.g. mainnet, sepolia, etc)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unfortunately a flaw with how the EthSendRawTransactionIntent proto is defined

https://github.com/tkhq/mono/blob/98d7b8abac3896dbc0ad9bf258862c6cd8286769/proto/immutable/activity/v1/activity.proto#L3987

Could try making an internal type for this case specifically though

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates @turnkey/sdk-server from its local generated API types to the shared @turnkey/sdk-types package, and adds a helper to generate wallet account creation params from address formats while avoiding path/index conflicts.

Changes:

  • Switch @turnkey/sdk-server SDK client + public exports to use @turnkey/sdk-types instead of src/__generated__/sdk_api_types.ts (which is removed).
  • Update @turnkey/sdk-types codegen to emit string literal unions for Swagger enum fields (instead of plain string).
  • Add generateWalletAccountsFromAddressFormat, createWalletAccountFromAddressFormat, and addressFormatConfig to sdk-server.

Reviewed changes

Copilot reviewed 12 out of 16 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
pnpm-lock.yaml Adds workspace link for @turnkey/sdk-types dependency.
packages/sdk-types/src/generated/types.ts Regenerates types with enum-backed string literal unions (e.g., request type, CAIP-2 values).
packages/sdk-types/scripts/codegen.js Updates swagger-to-TS mapping for string enums to emit "A" | "B" unions.
packages/sdk-server/src/turnkey-helpers.ts Migrates helper types to @turnkey/sdk-types and adds wallet account generation helpers/config.
packages/sdk-server/src/index.ts Swaps SDK API type imports to @turnkey/sdk-types and exports new helpers.
packages/sdk-server/src/types/base.ts Replaces local HTTP-generated types with @turnkey/sdk-types (e.g., activity/user/email customization).
packages/sdk-server/src/generated/sdk_api_types.ts Removes sdk-server’s locally generated API types file.
packages/sdk-server/src/generated/sdk-client-base.ts Updates client base to reference @turnkey/sdk-types and internal base types.
packages/sdk-server/scripts/codegen.js Stops generating sdk_api_types.ts; updates generated client imports to use @turnkey/sdk-types.
packages/sdk-server/package.json Adds @turnkey/sdk-types dependency.
packages/sdk-react/src/components/auth/Auth.tsx Casts customAccounts to v1WalletAccountParams[] for server calls after type migration.
packages/react-wallet-kit/src/providers/client/Provider.tsx Casts caip2 to the narrowed union type when constructing EthTransaction.
packages/core/src/types/method-types/shared.ts Narrows caip2 fields to specific supported CAIP-2 literal unions for ETH/Solana types.
.changeset/tall-olives-wonder.md Declares @turnkey/sdk-types release for enum typing changes.
.changeset/metal-planets-tan.md Declares @turnkey/sdk-server patch for the new wallet account helper.
.changeset/huge-sloths-dream.md Declares @turnkey/sdk-server major for switching to @turnkey/sdk-types.
Files not reviewed (4)
  • packages/sdk-server/src/generated/sdk-client-base.ts: Language not supported
  • packages/sdk-server/src/generated/sdk_api_types.ts: Language not supported
  • packages/sdk-types/src/generated/types.ts: Language not supported
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +27 to 28
TurnkeyRequestError,
} from "./__types__/base";
Comment on lines +18 to +22
curve: "CURVE_SECP256K1",
pathFormat: "PATH_FORMAT_BIP32",
path: `m/44'/60'/${pathIndex}'/0/0`,
addressFormat: "ADDRESS_FORMAT_ETHEREUM",
};
} as v1WalletAccount;
Comment on lines +441 to 443
export const DEFAULT_XRP_ACCOUNTS: v1WalletAccountParams[] = [
defaultXrpAccountAtIndex(0),
];
Comment on lines +596 to +607
const walletAccount = addressFormatConfig[addressFormat]?.defaultAccounts;
if (!walletAccount) {
throw new Error(`Unsupported address format: ${addressFormat}`);
}

if (walletAccount[0]) {
return walletAccount[0];
}

throw new Error(
`No default accounts defined for address format: ${addressFormat}`,
);
*
* ```ts
* // Example usage:
* import { addressFormatConfig } from "@turnkey/sdk-core";
Comment on lines +2 to +5
"@turnkey/sdk-types": minor
---

Fixed nested enums in types, now generates the enum values rather than generating them as strings
"@turnkey/sdk-server": patch
---

Added the `generateWalletAccountsFromAddressFormat` helper which takes in an array of address formats as well as an array of the current wallet accounts within the wallet and returns a list of path format deduped `WalletAccountParams`
Copy link
Collaborator

@andrewkmin andrewkmin Mar 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

returns a list of path format deduped WalletAccountParams

can we generalize this and say

deduped `WalletAccountParams`

?

export type EmailCustomization = TurnkeyApiTypes["v1EmailCustomizationParams"];
/** @internal */
export type TActivityStatus = v1ActivityStatus;
/** @internal */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tiny nit: can we add a newline above just to keep spacing consistent?

alternatively, we can keep one /** @internal */, and have everything under it be implicitly internal (can have it apply to this whole section of exports)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately the JS docs only apply to the type below it 😞

export type TActivityResponse = v1ActivityResponse;

/** @internal */
export type TSignedRequest = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see some of these exports in packages/core/src as well; any plans to dedupe? perhaps by exporting from sdk-types?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call out, can definitely move some these there

@ethankonk ethankonk force-pushed the ethan/sdk-server-types branch from 1f0493c to 583c8cb Compare March 19, 2026 16:20
@ethankonk ethankonk force-pushed the ethan/sdk-server-types branch from d1ed73a to ce3d616 Compare March 20, 2026 16:29
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

Successfully merging this pull request may close these issues.

3 participants