UNPKG

@renegade-fi/core

Version:
44 lines 1.69 kB
import invariant from 'tiny-invariant'; /** * Creates a configuration for users who want to manage their own wallet secrets. * * This configuration differs from the standard createConfig by allowing users to maintain * custody of their wallet secrets while still enabling interaction with the relayer for * wallet operations. Instead of managing keys internally, it accepts user-provided * cryptographic materials and signing functions. */ export function createExternalKeyConfig(parameters) { const { relayerUrl, signMessage, symmetricKey, walletId, publicKey: initialPublicKey, websocketUrl, viemClient, darkPoolAddress, } = parameters; invariant(parameters.utils, 'Utils must be provided by the package if not supplied by the user.'); let currentPublicKey = initialPublicKey; return { // External keychain signMessage, symmetricKey, walletId, get publicKey() { return currentPublicKey; }, setPublicKey: (newPublicKey) => { currentPublicKey = newPublicKey; }, // BaseConfig utils: parameters.utils, renegadeKeyType: 'external', relayerUrl, getBaseUrl: (route = '') => { const formattedRoute = route.startsWith('/') ? route : `/${route}`; return `${relayerUrl}/v0${formattedRoute}`; }, getWebsocketBaseUrl: () => { return websocketUrl.replace(/\/$/, ''); }, getSymmetricKey: () => { return symmetricKey; }, viemClient, darkPoolAddress, chainId: parameters.chainId, }; } //# sourceMappingURL=createExternalKeyConfig.js.map