@vleap/warps-wallet-coinbase 1.0.0-beta.3 → 1.0.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -80,8 +80,10 @@ var _CoinbaseWalletProvider = class _CoinbaseWalletProvider {
80
80
  if (hasEip1559Fields) {
81
81
  const maxFee = typeof tx.maxFeePerGas === "bigint" ? tx.maxFeePerGas : BigInt(formatBigInt(tx.maxFeePerGas));
82
82
  const maxPriorityFee = typeof tx.maxPriorityFeePerGas === "bigint" ? tx.maxPriorityFeePerGas : BigInt(formatBigInt(tx.maxPriorityFeePerGas));
83
+ let safePriorityFee = maxPriorityFee <= maxFee ? maxPriorityFee : maxFee / 10n;
84
+ if (safePriorityFee > maxFee) safePriorityFee = maxFee;
85
+ if (safePriorityFee < 1n) safePriorityFee = 1n;
83
86
  formatted.maxFeePerGas = formatBigInt(maxFee);
84
- const safePriorityFee = maxPriorityFee < maxFee ? maxPriorityFee : maxFee / 10n;
85
87
  formatted.maxPriorityFeePerGas = formatBigInt(safePriorityFee);
86
88
  } else if (hasLegacyFields) {
87
89
  const gasPriceHex = formatBigInt(tx.gasPrice);
@@ -235,8 +237,10 @@ var _CoinbaseWalletProvider = class _CoinbaseWalletProvider {
235
237
  if (hasEip1559Fields) {
236
238
  const maxFee = typeof tx.maxFeePerGas === "bigint" ? tx.maxFeePerGas : BigInt(formatBigInt(tx.maxFeePerGas));
237
239
  const maxPriorityFee = typeof tx.maxPriorityFeePerGas === "bigint" ? tx.maxPriorityFeePerGas : BigInt(formatBigInt(tx.maxPriorityFeePerGas));
240
+ let safePriorityFee = maxPriorityFee <= maxFee ? maxPriorityFee : maxFee / 10n;
241
+ if (safePriorityFee > maxFee) safePriorityFee = maxFee;
242
+ if (safePriorityFee < 1n) safePriorityFee = 1n;
238
243
  formatted.maxFeePerGas = formatBigInt(maxFee);
239
- const safePriorityFee = maxPriorityFee < maxFee ? maxPriorityFee : maxFee / 10n;
240
244
  formatted.maxPriorityFeePerGas = formatBigInt(safePriorityFee);
241
245
  } else if (hasLegacyFields) {
242
246
  const gasPriceHex = formatBigInt(tx.gasPrice);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/CoinbaseWalletProvider.ts","../src/helpers.ts"],"sourcesContent":["export * from './CoinbaseWalletProvider'\nexport * from './helpers'\nexport * from './types'\n","import { CdpClient } from '@coinbase/cdp-sdk'\nimport {\n getWarpWalletAddressFromConfig,\n setWarpWalletInConfig,\n WalletProvider,\n WarpAdapterGenericTransaction,\n WarpChainInfo,\n WarpClientConfig,\n WarpWalletDetails,\n WarpWalletProvider,\n} from '@vleap/warps'\nimport { CoinbaseProviderConfig } from './types'\n\nexport class CoinbaseWalletProvider implements WalletProvider {\n static readonly PROVIDER_NAME: WarpWalletProvider = 'coinbase'\n private readonly client: CdpClient\n private cachedAccount: { id: string; address: string; publicKey?: string } | null = null\n private cachedEvmAccount: { signTransaction: (tx: unknown) => Promise<unknown> } | null = null\n\n constructor(\n private readonly config: WarpClientConfig,\n private readonly chain: WarpChainInfo,\n private readonly coinbaseConfig: CoinbaseProviderConfig\n ) {\n this.client = new CdpClient({\n apiKeyId: coinbaseConfig.apiKeyId,\n apiKeySecret: coinbaseConfig.apiKeySecret,\n walletSecret: coinbaseConfig.walletSecret,\n ...(coinbaseConfig.apiUrl && { apiUrl: coinbaseConfig.apiUrl }),\n })\n }\n\n async getAddress(): Promise<string | null> {\n try {\n return (await this.getAccount()).address\n } catch (error) {\n console.error('CoinbaseWalletProvider: Failed to get address', error)\n return null\n }\n }\n\n async getPublicKey(): Promise<string | null> {\n try {\n return (await this.getAccount()).publicKey ?? null\n } catch (error) {\n console.error('CoinbaseWalletProvider: Failed to get public key', error)\n return null\n }\n }\n\n async signTransaction(tx: WarpAdapterGenericTransaction): Promise<WarpAdapterGenericTransaction> {\n const formatBigInt = (value: bigint | string | number | undefined): string | undefined => {\n if (value === undefined || value === null) return undefined\n if (typeof value === 'bigint') return `0x${value.toString(16)}`\n if (typeof value === 'string' && value.startsWith('0x')) return value\n if (typeof value === 'string') return `0x${BigInt(value).toString(16)}`\n return `0x${BigInt(value).toString(16)}`\n }\n\n const hasEip1559Fields = tx.maxFeePerGas !== undefined && tx.maxPriorityFeePerGas !== undefined\n const hasLegacyFields = tx.gasPrice !== undefined && !hasEip1559Fields\n\n const formatted: any = {\n to: tx.to,\n value: formatBigInt(tx.value) || '0x0',\n data: tx.data || '0x',\n chainId: typeof tx.chainId === 'number' ? tx.chainId : parseInt(String(tx.chainId || this.chain.chainId)),\n }\n\n if (tx.gasLimit) {\n formatted.gas = formatBigInt(tx.gasLimit)\n }\n\n if (hasEip1559Fields) {\n const maxFee = typeof tx.maxFeePerGas === 'bigint' ? tx.maxFeePerGas : BigInt(formatBigInt(tx.maxFeePerGas)!)\n const maxPriorityFee =\n typeof tx.maxPriorityFeePerGas === 'bigint' ? tx.maxPriorityFeePerGas : BigInt(formatBigInt(tx.maxPriorityFeePerGas)!)\n formatted.maxFeePerGas = formatBigInt(maxFee)!\n const safePriorityFee = maxPriorityFee < maxFee ? maxPriorityFee : maxFee / 10n\n formatted.maxPriorityFeePerGas = formatBigInt(safePriorityFee)!\n } else if (hasLegacyFields) {\n const gasPriceHex = formatBigInt(tx.gasPrice)!\n const gasPrice = typeof tx.gasPrice === 'bigint' ? tx.gasPrice : BigInt(gasPriceHex)\n formatted.maxFeePerGas = gasPriceHex\n const priorityFee = (gasPrice * 9n) / 10n\n formatted.maxPriorityFeePerGas = formatBigInt(priorityFee > 0n ? priorityFee : 1n)!\n } else {\n const defaultMaxFee = BigInt('1000000000')\n formatted.maxFeePerGas = formatBigInt(defaultMaxFee)!\n formatted.maxPriorityFeePerGas = formatBigInt(defaultMaxFee / 10n)!\n }\n\n if (tx.nonce !== undefined) {\n formatted.nonce = typeof tx.nonce === 'number' ? `0x${tx.nonce.toString(16)}` : formatBigInt(tx.nonce)\n }\n\n try {\n const account = await this.getAccount()\n\n if (this.chain.name === 'solana') {\n const result = await this.client.solana.signTransaction({\n address: account.id,\n transaction: tx as never,\n })\n\n if ('signedTransaction' in result && result.signedTransaction) {\n return { ...(tx as Record<string, unknown>), signature: String(result.signedTransaction) }\n }\n throw new Error('Coinbase API did not return signed transaction')\n }\n\n if (!this.cachedEvmAccount) {\n const address = this.getWalletAddress()\n const evmAccount = await this.client.evm.getAccount({ address: address as `0x${string}` })\n if (!('signTransaction' in evmAccount)) {\n throw new Error('CoinbaseWalletProvider: Account object missing signTransaction method. This may be a SDK version issue.')\n }\n this.cachedEvmAccount = { signTransaction: evmAccount.signTransaction as (tx: unknown) => Promise<unknown> }\n }\n\n const formattedTx = this.formatTransactionForCoinbase(tx)\n const signedTx = await this.cachedEvmAccount.signTransaction(formattedTx)\n return { ...(tx as Record<string, unknown>), signature: signedTx }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error)\n if (errorMessage.includes('signTransaction is not a function')) {\n throw new Error('CoinbaseWalletProvider: Account object missing signTransaction method. This may be a SDK version issue.')\n }\n throw new Error(`CoinbaseWalletProvider: Failed to sign transaction: ${error}`)\n }\n }\n\n async signMessage(message: string): Promise<string> {\n try {\n const account = await this.getAccount()\n const result =\n this.chain.name === 'solana'\n ? await this.client.solana.signMessage({ address: account.id, message })\n : await this.client.evm.signMessage({ address: account.id as `0x${string}`, message })\n\n if ('signedMessage' in result && result.signedMessage) {\n return String(result.signedMessage)\n }\n\n throw new Error('Coinbase API did not return signed message')\n } catch (error) {\n throw new Error(`CoinbaseWalletProvider: Failed to sign message: ${error}`)\n }\n }\n\n async importFromMnemonic(mnemonic: string): Promise<WarpWalletDetails> {\n throw new Error(\n 'CoinbaseWalletProvider: importFromMnemonic() is not supported. Use generate() to create a new account via Coinbase API.'\n )\n }\n\n async importFromPrivateKey(privateKey: string): Promise<WarpWalletDetails> {\n try {\n const name = this.getAccountName()\n const account =\n this.chain.name === 'solana'\n ? await this.client.solana.importAccount({ privateKey, ...(name && { name }) })\n : await this.client.evm.importAccount({ privateKey: privateKey as `0x${string}`, ...(name && { name }) })\n\n const walletDetails: WarpWalletDetails = {\n provider: CoinbaseWalletProvider.PROVIDER_NAME,\n address: account.address,\n privateKey,\n }\n\n setWarpWalletInConfig(this.config, this.chain.name, walletDetails)\n\n return walletDetails\n } catch (error) {\n throw new Error(`CoinbaseWalletProvider: Failed to import account from private key: ${error}`)\n }\n }\n\n async export(): Promise<WarpWalletDetails> {\n try {\n const address = this.getWalletAddress()\n const privateKey =\n this.chain.name === 'solana'\n ? await this.client.solana.exportAccount({ address })\n : await this.client.evm.exportAccount({ address: address as `0x${string}` })\n\n return {\n provider: CoinbaseWalletProvider.PROVIDER_NAME,\n address,\n privateKey,\n }\n } catch (error) {\n throw new Error(`CoinbaseWalletProvider: Failed to export account: ${error}`)\n }\n }\n\n async generate(): Promise<WarpWalletDetails> {\n try {\n const name = this.getAccountName()\n const account =\n this.chain.name === 'solana' ? await this.client.solana.createAccount({ name }) : await this.client.evm.createAccount({ name })\n\n const walletDetails: WarpWalletDetails = {\n provider: CoinbaseWalletProvider.PROVIDER_NAME,\n address: account.address,\n }\n\n setWarpWalletInConfig(this.config, this.chain.name, walletDetails)\n\n return walletDetails\n } catch (error) {\n throw new Error(`CoinbaseWalletProvider: Failed to generate account: ${error}`)\n }\n }\n\n private getAccountName(): string | undefined {\n return this.config.user?.id ? `${this.config.user.id}-${this.chain.name}` : undefined\n }\n\n private getWalletAddress(): string {\n const address = getWarpWalletAddressFromConfig(this.config, this.chain.name)\n if (!address) throw new Error(`CoinbaseWalletProvider: Wallet address not found in config for chain ${this.chain.name}`)\n return address\n }\n\n private extractPublicKey(account: { address: string; publicKey?: unknown }): string | undefined {\n return account.publicKey as string | undefined\n }\n\n private async getAccount(): Promise<{ id: string; address: string; publicKey?: string }> {\n if (this.cachedAccount) return this.cachedAccount\n\n const address = this.getWalletAddress()\n const account =\n this.chain.name === 'solana'\n ? await this.client.solana.getAccount({ address })\n : await this.client.evm.getAccount({ address: address as `0x${string}` })\n\n const publicKey = this.extractPublicKey(account)\n this.cachedAccount = {\n id: account.address,\n address: account.address,\n ...(publicKey && { publicKey }),\n }\n\n if (this.chain.name !== 'solana' && 'signTransaction' in account) {\n this.cachedEvmAccount = { signTransaction: account.signTransaction as (tx: unknown) => Promise<unknown> }\n }\n\n return this.cachedAccount\n }\n\n private formatTransactionForCoinbase(tx: any): any {\n const formatBigInt = (value: bigint | string | number | undefined): string | undefined => {\n if (value === undefined || value === null) return undefined\n if (typeof value === 'bigint') return `0x${value.toString(16)}`\n if (typeof value === 'string' && value.startsWith('0x')) return value\n if (typeof value === 'string') return `0x${BigInt(value).toString(16)}`\n return `0x${BigInt(value).toString(16)}`\n }\n\n const hasEip1559Fields = tx.maxFeePerGas !== undefined && tx.maxPriorityFeePerGas !== undefined\n const hasLegacyFields = tx.gasPrice !== undefined && !hasEip1559Fields\n\n const formatted: any = {\n to: tx.to,\n value: formatBigInt(tx.value) || '0x0',\n data: tx.data || '0x',\n chainId: typeof tx.chainId === 'number' ? tx.chainId : parseInt(String(tx.chainId || this.chain.chainId)),\n }\n\n if (tx.gasLimit) {\n formatted.gas = formatBigInt(tx.gasLimit)\n }\n\n if (hasEip1559Fields) {\n const maxFee = typeof tx.maxFeePerGas === 'bigint' ? tx.maxFeePerGas : BigInt(formatBigInt(tx.maxFeePerGas)!)\n const maxPriorityFee =\n typeof tx.maxPriorityFeePerGas === 'bigint' ? tx.maxPriorityFeePerGas : BigInt(formatBigInt(tx.maxPriorityFeePerGas)!)\n formatted.maxFeePerGas = formatBigInt(maxFee)!\n const safePriorityFee = maxPriorityFee < maxFee ? maxPriorityFee : maxFee / 10n\n formatted.maxPriorityFeePerGas = formatBigInt(safePriorityFee)!\n } else if (hasLegacyFields) {\n const gasPriceHex = formatBigInt(tx.gasPrice)!\n const gasPrice = typeof tx.gasPrice === 'bigint' ? tx.gasPrice : BigInt(gasPriceHex)\n formatted.maxFeePerGas = gasPriceHex\n const priorityFee = (gasPrice * 9n) / 10n\n formatted.maxPriorityFeePerGas = formatBigInt(priorityFee > 0n ? priorityFee : 1n)!\n } else {\n const defaultMaxFee = BigInt('1000000000')\n formatted.maxFeePerGas = formatBigInt(defaultMaxFee)!\n formatted.maxPriorityFeePerGas = formatBigInt(defaultMaxFee / 10n)!\n }\n\n if (tx.nonce !== undefined) {\n formatted.nonce = typeof tx.nonce === 'number' ? `0x${tx.nonce.toString(16)}` : formatBigInt(tx.nonce)\n }\n\n return formatted\n }\n}\n","import { WalletProviderFactory, WarpChainInfo, WarpClientConfig } from '@vleap/warps'\nimport { CoinbaseWalletProvider } from './CoinbaseWalletProvider'\nimport { CoinbaseProviderConfig } from './types'\n\nexport const createCoinbaseWalletProvider = (\n coinbaseConfig: CoinbaseProviderConfig\n): WalletProviderFactory => {\n return (config: WarpClientConfig, chain: WarpChainInfo) =>\n new CoinbaseWalletProvider(config, chain, coinbaseConfig)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,qBAA0B;AAC1B,mBASO;AAGA,IAAM,0BAAN,MAAM,wBAAiD;AAAA,EAM5D,YACmB,QACA,OACA,gBACjB;AAHiB;AACA;AACA;AANnB,SAAQ,gBAA4E;AACpF,SAAQ,mBAAkF;AAOxF,SAAK,SAAS,IAAI,yBAAU;AAAA,MAC1B,UAAU,eAAe;AAAA,MACzB,cAAc,eAAe;AAAA,MAC7B,cAAc,eAAe;AAAA,MAC7B,GAAI,eAAe,UAAU,EAAE,QAAQ,eAAe,OAAO;AAAA,IAC/D,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,aAAqC;AACzC,QAAI;AACF,cAAQ,MAAM,KAAK,WAAW,GAAG;AAAA,IACnC,SAAS,OAAO;AACd,cAAQ,MAAM,iDAAiD,KAAK;AACpE,aAAO;AAAA,IACT;AAAA,EACF;AAAA,EAEA,MAAM,eAAuC;AAC3C,QAAI;AACF,cAAQ,MAAM,KA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sources":["../src/index.ts","../src/CoinbaseWalletProvider.ts","../src/helpers.ts"],"sourcesContent":["export * from './CoinbaseWalletProvider'\nexport * from './helpers'\nexport * from './types'\n","import { CdpClient } from '@coinbase/cdp-sdk'\nimport {\n getWarpWalletAddressFromConfig,\n setWarpWalletInConfig,\n WalletProvider,\n WarpAdapterGenericTransaction,\n WarpChainInfo,\n WarpClientConfig,\n WarpWalletDetails,\n WarpWalletProvider,\n} from '@vleap/warps'\nimport { CoinbaseProviderConfig } from './types'\n\nexport class CoinbaseWalletProvider implements WalletProvider {\n static readonly PROVIDER_NAME: WarpWalletProvider = 'coinbase'\n private readonly client: CdpClient\n private cachedAccount: { id: string; address: string; publicKey?: string } | null = null\n private cachedEvmAccount: { signTransaction: (tx: unknown) => Promise<unknown> } | null = null\n\n constructor(\n private readonly config: WarpClientConfig,\n private readonly chain: WarpChainInfo,\n private readonly coinbaseConfig: CoinbaseProviderConfig\n ) {\n this.client = new CdpClient({\n apiKeyId: coinbaseConfig.apiKeyId,\n apiKeySecret: coinbaseConfig.apiKeySecret,\n walletSecret: coinbaseConfig.walletSecret,\n ...(coinbaseConfig.apiUrl && { apiUrl: coinbaseConfig.apiUrl }),\n })\n }\n\n async getAddress(): Promise<string | null> {\n try {\n return (await this.getAccount()).address\n } catch (error) {\n console.error('CoinbaseWalletProvider: Failed to get address', error)\n return null\n }\n }\n\n async getPublicKey(): Promise<string | null> {\n try {\n return (await this.getAccount()).publicKey ?? null\n } catch (error) {\n console.error('CoinbaseWalletProvider: Failed to get public key', error)\n return null\n }\n }\n\n async signTransaction(tx: WarpAdapterGenericTransaction): Promise<WarpAdapterGenericTransaction> {\n const formatBigInt = (value: bigint | string | number | undefined): string | undefined => {\n if (value === undefined || value === null) return undefined\n if (typeof value === 'bigint') return `0x${value.toString(16)}`\n if (typeof value === 'string' && value.startsWith('0x')) return value\n if (typeof value === 'string') return `0x${BigInt(value).toString(16)}`\n return `0x${BigInt(value).toString(16)}`\n }\n\n const hasEip1559Fields = tx.maxFeePerGas !== undefined && tx.maxPriorityFeePerGas !== undefined\n const hasLegacyFields = tx.gasPrice !== undefined && !hasEip1559Fields\n\n const formatted: any = {\n to: tx.to,\n value: formatBigInt(tx.value) || '0x0',\n data: tx.data || '0x',\n chainId: typeof tx.chainId === 'number' ? tx.chainId : parseInt(String(tx.chainId || this.chain.chainId)),\n }\n\n if (tx.gasLimit) {\n formatted.gas = formatBigInt(tx.gasLimit)\n }\n\n if (hasEip1559Fields) {\n const maxFee = typeof tx.maxFeePerGas === 'bigint' ? tx.maxFeePerGas : BigInt(formatBigInt(tx.maxFeePerGas)!)\n const maxPriorityFee =\n typeof tx.maxPriorityFeePerGas === 'bigint' ? tx.maxPriorityFeePerGas : BigInt(formatBigInt(tx.maxPriorityFeePerGas)!)\n let safePriorityFee = maxPriorityFee <= maxFee ? maxPriorityFee : maxFee / 10n\n if (safePriorityFee > maxFee) safePriorityFee = maxFee\n if (safePriorityFee < 1n) safePriorityFee = 1n\n formatted.maxFeePerGas = formatBigInt(maxFee)!\n formatted.maxPriorityFeePerGas = formatBigInt(safePriorityFee)!\n } else if (hasLegacyFields) {\n const gasPriceHex = formatBigInt(tx.gasPrice)!\n const gasPrice = typeof tx.gasPrice === 'bigint' ? tx.gasPrice : BigInt(gasPriceHex)\n formatted.maxFeePerGas = gasPriceHex\n const priorityFee = (gasPrice * 9n) / 10n\n formatted.maxPriorityFeePerGas = formatBigInt(priorityFee > 0n ? priorityFee : 1n)!\n } else {\n const defaultMaxFee = BigInt('1000000000')\n formatted.maxFeePerGas = formatBigInt(defaultMaxFee)!\n formatted.maxPriorityFeePerGas = formatBigInt(defaultMaxFee / 10n)!\n }\n\n if (tx.nonce !== undefined) {\n formatted.nonce = typeof tx.nonce === 'number' ? `0x${tx.nonce.toString(16)}` : formatBigInt(tx.nonce)\n }\n\n try {\n const account = await this.getAccount()\n\n if (this.chain.name === 'solana') {\n const result = await this.client.solana.signTransaction({\n address: account.id,\n transaction: tx as never,\n })\n\n if ('signedTransaction' in result && result.signedTransaction) {\n return { ...(tx as Record<string, unknown>), signature: String(result.signedTransaction) }\n }\n throw new Error('Coinbase API did not return signed transaction')\n }\n\n if (!this.cachedEvmAccount) {\n const address = this.getWalletAddress()\n const evmAccount = await this.client.evm.getAccount({ address: address as `0x${string}` })\n if (!('signTransaction' in evmAccount)) {\n throw new Error('CoinbaseWalletProvider: Account object missing signTransaction method. This may be a SDK version issue.')\n }\n this.cachedEvmAccount = { signTransaction: evmAccount.signTransaction as (tx: unknown) => Promise<unknown> }\n }\n\n const formattedTx = this.formatTransactionForCoinbase(tx)\n const signedTx = await this.cachedEvmAccount.signTransaction(formattedTx)\n return { ...(tx as Record<string, unknown>), signature: signedTx }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error)\n if (errorMessage.includes('signTransaction is not a function')) {\n throw new Error('CoinbaseWalletProvider: Account object missing signTransaction method. This may be a SDK version issue.')\n }\n throw new Error(`CoinbaseWalletProvider: Failed to sign transaction: ${error}`)\n }\n }\n\n async signMessage(message: string): Promise<string> {\n try {\n const account = await this.getAccount()\n const result =\n this.chain.name === 'solana'\n ? await this.client.solana.signMessage({ address: account.id, message })\n : await this.client.evm.signMessage({ address: account.id as `0x${string}`, message })\n\n if ('signedMessage' in result && result.signedMessage) {\n return String(result.signedMessage)\n }\n\n throw new Error('Coinbase API did not return signed message')\n } catch (error) {\n throw new Error(`CoinbaseWalletProvider: Failed to sign message: ${error}`)\n }\n }\n\n async importFromMnemonic(mnemonic: string): Promise<WarpWalletDetails> {\n throw new Error(\n 'CoinbaseWalletProvider: importFromMnemonic() is not supported. Use generate() to create a new account via Coinbase API.'\n )\n }\n\n async importFromPrivateKey(privateKey: string): Promise<WarpWalletDetails> {\n try {\n const name = this.getAccountName()\n const account =\n this.chain.name === 'solana'\n ? await this.client.solana.importAccount({ privateKey, ...(name && { name }) })\n : await this.client.evm.importAccount({ privateKey: privateKey as `0x${string}`, ...(name && { name }) })\n\n const walletDetails: WarpWalletDetails = {\n provider: CoinbaseWalletProvider.PROVIDER_NAME,\n address: account.address,\n privateKey,\n }\n\n setWarpWalletInConfig(this.config, this.chain.name, walletDetails)\n\n return walletDetails\n } catch (error) {\n throw new Error(`CoinbaseWalletProvider: Failed to import account from private key: ${error}`)\n }\n }\n\n async export(): Promise<WarpWalletDetails> {\n try {\n const address = this.getWalletAddress()\n const privateKey =\n this.chain.name === 'solana'\n ? await this.client.solana.exportAccount({ address })\n : await this.client.evm.exportAccount({ address: address as `0x${string}` })\n\n return {\n provider: CoinbaseWalletProvider.PROVIDER_NAME,\n address,\n privateKey,\n }\n } catch (error) {\n throw new Error(`CoinbaseWalletProvider: Failed to export account: ${error}`)\n }\n }\n\n async generate(): Promise<WarpWalletDetails> {\n try {\n const name = this.getAccountName()\n const account =\n this.chain.name === 'solana' ? await this.client.solana.createAccount({ name }) : await this.client.evm.createAccount({ name })\n\n const walletDetails: WarpWalletDetails = {\n provider: CoinbaseWalletProvider.PROVIDER_NAME,\n address: account.address,\n }\n\n setWarpWalletInConfig(this.config, this.chain.name, walletDetails)\n\n return walletDetails\n } catch (error) {\n throw new Error(`CoinbaseWalletProvider: Failed to generate account: ${error}`)\n }\n }\n\n private getAccountName(): string | undefined {\n return this.config.user?.id ? `${this.config.user.id}-${this.chain.name}` : undefined\n }\n\n private getWalletAddress(): string {\n const address = getWarpWalletAddressFromConfig(this.config, this.chain.name)\n if (!address) throw new Error(`CoinbaseWalletProvider: Wallet address not found in config for chain ${this.chain.name}`)\n return address\n }\n\n private extractPublicKey(account: { address: string; publicKey?: unknown }): string | undefined {\n return account.publicKey as string | undefined\n }\n\n private async getAccount(): Promise<{ id: string; address: string; publicKey?: string }> {\n if (this.cachedAccount) return this.cachedAccount\n\n const address = this.getWalletAddress()\n const account =\n this.chain.name === 'solana'\n ? await this.client.solana.getAccount({ address })\n : await this.client.evm.getAccount({ address: address as `0x${string}` })\n\n const publicKey = this.extractPublicKey(account)\n this.cachedAccount = {\n id: account.address,\n address: account.address,\n ...(publicKey && { publicKey }),\n }\n\n if (this.chain.name !== 'solana' && 'signTransaction' in account) {\n this.cachedEvmAccount = { signTransaction: account.signTransaction as (tx: unknown) => Promise<unknown> }\n }\n\n return this.cachedAccount\n }\n\n private formatTransactionForCoinbase(tx: any): any {\n const formatBigInt = (value: bigint | string | number | undefined): string | undefined => {\n if (value === undefined || value === null) return undefined\n if (typeof value === 'bigint') return `0x${value.toString(16)}`\n if (typeof value === 'string' && value.startsWith('0x')) return value\n if (typeof value === 'string') return `0x${BigInt(value).toString(16)}`\n return `0x${BigInt(value).toString(16)}`\n }\n\n const hasEip1559Fields = tx.maxFeePerGas !== undefined && tx.maxPriorityFeePerGas !== undefined\n const hasLegacyFields = tx.gasPrice !== undefined && !hasEip1559Fields\n\n const formatted: any = {\n to: tx.to,\n value: formatBigInt(tx.value) || '0x0',\n data: tx.data || '0x',\n chainId: typeof tx.chainId === 'number' ? tx.chainId : parseInt(String(tx.chainId || this.chain.chainId)),\n }\n\n if (tx.gasLimit) {\n formatted.gas = formatBigInt(tx.gasLimit)\n }\n\n if (hasEip1559Fields) {\n const maxFee = typeof tx.maxFeePerGas === 'bigint' ? tx.maxFeePerGas : BigInt(formatBigInt(tx.maxFeePerGas)!)\n const maxPriorityFee =\n typeof tx.maxPriorityFeePerGas === 'bigint' ? tx.maxPriorityFeePerGas : BigInt(formatBigInt(tx.maxPriorityFeePerGas)!)\n let safePriorityFee = maxPriorityFee <= maxFee ? maxPriorityFee : maxFee / 10n\n if (safePriorityFee > maxFee) safePriorityFee = maxFee\n if (safePriorityFee < 1n) safePriorityFee = 1n\n formatted.maxFeePerGas = formatBigInt(maxFee)!\n formatted.maxPriorityFeePerGas = formatBigInt(safePriorityFee)!\n } else if (hasLegacyFields) {\n const gasPriceHex = formatBigInt(tx.gasPrice)!\n const gasPrice = typeof tx.gasPrice === 'bigint' ? tx.gasPrice : BigInt(gasPriceHex)\n formatted.maxFeePerGas = gasPriceHex\n const priorityFee = (gasPrice * 9n) / 10n\n formatted.maxPriorityFeePerGas = formatBigInt(priorityFee > 0n ? priorityFee : 1n)!\n } else {\n const defaultMaxFee = BigInt('1000000000')\n formatted.maxFeePerGas = formatBigInt(defaultMaxFee)!\n formatted.maxPriorityFeePerGas = formatBigInt(defaultMaxFee / 10n)!\n }\n\n if (tx.nonce !== undefined) {\n formatted.nonce = typeof tx.nonce === 'number' ? `0x${tx.nonce.toString(16)}` : formatBigInt(tx.nonce)\n }\n\n return formatted\n }\n}\n","import { WalletProviderFactory, WarpChainInfo, WarpClientConfig } from '@vleap/warps'\nimport { CoinbaseWalletProvider } from './CoinbaseWalletProvider'\nimport { CoinbaseProviderConfig } from './types'\n\nexport const createCoinbaseWalletProvider = (\n coinbaseConfig: CoinbaseProviderConfig\n): WalletProviderFactory => {\n return (config: WarpClientConfig, chain: WarpChainInfo) =>\n new CoinbaseWalletProvider(config, chain, coinbaseConfig)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,qBAA0B;AAC1B,mBASO;AAGA,IAAM,0BAAN,MAAM,wBAAiD;AAAA,EAM5D,YACmB,QACA,OACA,gBACjB;AAHiB;AACA;AACA;AANnB,SAAQ,gBAA4E;AACpF,SAAQ,mBAAkF;AAOxF,SAAK,SAAS,IAAI,yBAAU;AAAA,MAC1B,UAAU,eAAe;AAAA,MACzB,cAAc,eAAe;AAAA,MAC7B,cAAc,eAAe;AAAA,MAC7B,GAAI,eAAe,UAAU,EAAE,QAAQ,eAAe,OAAO;AAAA,IAC/D,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,aAAqC;AACzC,QAAI;AACF,cAAQ,MAAM,KAAK,WAAW,GAAG;AAAA,IACnC,SAAS,OAAO;AACd,cAAQ,MAAM,iDAAiD,KAAK;AACpE,aAAO;AAAA,IACT;AAAA,EACF;AAAA,EAEA,MAAM,eAAuC;AAC3C,QAAI;AACF,cAAQ,MAAM,KAAK,WAAW,GAAG,aAAa;AAAA,I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+B,CAC1C,mBAC0B;AAC1B,SAAO,CAAC,QAA0B,UAChC,IAAI,uBAAuB,QAAQ,OAAO,cAAc;AAC5D;","names":[]}
package/dist/index.mjs CHANGED
@@ -56,8 +56,10 @@ var _CoinbaseWalletProvider = class _CoinbaseWalletProvider {
56
56
  if (hasEip1559Fields) {
57
57
  const maxFee = typeof tx.maxFeePerGas === "bigint" ? tx.maxFeePerGas : BigInt(formatBigInt(tx.maxFeePerGas));
58
58
  const maxPriorityFee = typeof tx.maxPriorityFeePerGas === "bigint" ? tx.maxPriorityFeePerGas : BigInt(formatBigInt(tx.maxPriorityFeePerGas));
59
+ let safePriorityFee = maxPriorityFee <= maxFee ? maxPriorityFee : maxFee / 10n;
60
+ if (safePriorityFee > maxFee) safePriorityFee = maxFee;
61
+ if (safePriorityFee < 1n) safePriorityFee = 1n;
59
62
  formatted.maxFeePerGas = formatBigInt(maxFee);
60
- const safePriorityFee = maxPriorityFee < maxFee ? maxPriorityFee : maxFee / 10n;
61
63
  formatted.maxPriorityFeePerGas = formatBigInt(safePriorityFee);
62
64
  } else if (hasLegacyFields) {
63
65
  const gasPriceHex = formatBigInt(tx.gasPrice);
@@ -211,8 +213,10 @@ var _CoinbaseWalletProvider = class _CoinbaseWalletProvider {
211
213
  if (hasEip1559Fields) {
212
214
  const maxFee = typeof tx.maxFeePerGas === "bigint" ? tx.maxFeePerGas : BigInt(formatBigInt(tx.maxFeePerGas));
213
215
  const maxPriorityFee = typeof tx.maxPriorityFeePerGas === "bigint" ? tx.maxPriorityFeePerGas : BigInt(formatBigInt(tx.maxPriorityFeePerGas));
216
+ let safePriorityFee = maxPriorityFee <= maxFee ? maxPriorityFee : maxFee / 10n;
217
+ if (safePriorityFee > maxFee) safePriorityFee = maxFee;
218
+ if (safePriorityFee < 1n) safePriorityFee = 1n;
214
219
  formatted.maxFeePerGas = formatBigInt(maxFee);
215
- const safePriorityFee = maxPriorityFee < maxFee ? maxPriorityFee : maxFee / 10n;
216
220
  formatted.maxPriorityFeePerGas = formatBigInt(safePriorityFee);
217
221
  } else if (hasLegacyFields) {
218
222
  const gasPriceHex = formatBigInt(tx.gasPrice);
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/CoinbaseWalletProvider.ts","../src/helpers.ts"],"sourcesContent":["import { CdpClient } from '@coinbase/cdp-sdk'\nimport {\n getWarpWalletAddressFromConfig,\n setWarpWalletInConfig,\n WalletProvider,\n WarpAdapterGenericTransaction,\n WarpChainInfo,\n WarpClientConfig,\n WarpWalletDetails,\n WarpWalletProvider,\n} from '@vleap/warps'\nimport { CoinbaseProviderConfig } from './types'\n\nexport class CoinbaseWalletProvider implements WalletProvider {\n static readonly PROVIDER_NAME: WarpWalletProvider = 'coinbase'\n private readonly client: CdpClient\n private cachedAccount: { id: string; address: string; publicKey?: string } | null = null\n private cachedEvmAccount: { signTransaction: (tx: unknown) => Promise<unknown> } | null = null\n\n constructor(\n private readonly config: WarpClientConfig,\n private readonly chain: WarpChainInfo,\n private readonly coinbaseConfig: CoinbaseProviderConfig\n ) {\n this.client = new CdpClient({\n apiKeyId: coinbaseConfig.apiKeyId,\n apiKeySecret: coinbaseConfig.apiKeySecret,\n walletSecret: coinbaseConfig.walletSecret,\n ...(coinbaseConfig.apiUrl && { apiUrl: coinbaseConfig.apiUrl }),\n })\n }\n\n async getAddress(): Promise<string | null> {\n try {\n return (await this.getAccount()).address\n } catch (error) {\n console.error('CoinbaseWalletProvider: Failed to get address', error)\n return null\n }\n }\n\n async getPublicKey(): Promise<string | null> {\n try {\n return (await this.getAccount()).publicKey ?? null\n } catch (error) {\n console.error('CoinbaseWalletProvider: Failed to get public key', error)\n return null\n }\n }\n\n async signTransaction(tx: WarpAdapterGenericTransaction): Promise<WarpAdapterGenericTransaction> {\n const formatBigInt = (value: bigint | string | number | undefined): string | undefined => {\n if (value === undefined || value === null) return undefined\n if (typeof value === 'bigint') return `0x${value.toString(16)}`\n if (typeof value === 'string' && value.startsWith('0x')) return value\n if (typeof value === 'string') return `0x${BigInt(value).toString(16)}`\n return `0x${BigInt(value).toString(16)}`\n }\n\n const hasEip1559Fields = tx.maxFeePerGas !== undefined && tx.maxPriorityFeePerGas !== undefined\n const hasLegacyFields = tx.gasPrice !== undefined && !hasEip1559Fields\n\n const formatted: any = {\n to: tx.to,\n value: formatBigInt(tx.value) || '0x0',\n data: tx.data || '0x',\n chainId: typeof tx.chainId === 'number' ? tx.chainId : parseInt(String(tx.chainId || this.chain.chainId)),\n }\n\n if (tx.gasLimit) {\n formatted.gas = formatBigInt(tx.gasLimit)\n }\n\n if (hasEip1559Fields) {\n const maxFee = typeof tx.maxFeePerGas === 'bigint' ? tx.maxFeePerGas : BigInt(formatBigInt(tx.maxFeePerGas)!)\n const maxPriorityFee =\n typeof tx.maxPriorityFeePerGas === 'bigint' ? tx.maxPriorityFeePerGas : BigInt(formatBigInt(tx.maxPriorityFeePerGas)!)\n formatted.maxFeePerGas = formatBigInt(maxFee)!\n const safePriorityFee = maxPriorityFee < maxFee ? maxPriorityFee : maxFee / 10n\n formatted.maxPriorityFeePerGas = formatBigInt(safePriorityFee)!\n } else if (hasLegacyFields) {\n const gasPriceHex = formatBigInt(tx.gasPrice)!\n const gasPrice = typeof tx.gasPrice === 'bigint' ? tx.gasPrice : BigInt(gasPriceHex)\n formatted.maxFeePerGas = gasPriceHex\n const priorityFee = (gasPrice * 9n) / 10n\n formatted.maxPriorityFeePerGas = formatBigInt(priorityFee > 0n ? priorityFee : 1n)!\n } else {\n const defaultMaxFee = BigInt('1000000000')\n formatted.maxFeePerGas = formatBigInt(defaultMaxFee)!\n formatted.maxPriorityFeePerGas = formatBigInt(defaultMaxFee / 10n)!\n }\n\n if (tx.nonce !== undefined) {\n formatted.nonce = typeof tx.nonce === 'number' ? `0x${tx.nonce.toString(16)}` : formatBigInt(tx.nonce)\n }\n\n try {\n const account = await this.getAccount()\n\n if (this.chain.name === 'solana') {\n const result = await this.client.solana.signTransaction({\n address: account.id,\n transaction: tx as never,\n })\n\n if ('signedTransaction' in result && result.signedTransaction) {\n return { ...(tx as Record<string, unknown>), signature: String(result.signedTransaction) }\n }\n throw new Error('Coinbase API did not return signed transaction')\n }\n\n if (!this.cachedEvmAccount) {\n const address = this.getWalletAddress()\n const evmAccount = await this.client.evm.getAccount({ address: address as `0x${string}` })\n if (!('signTransaction' in evmAccount)) {\n throw new Error('CoinbaseWalletProvider: Account object missing signTransaction method. This may be a SDK version issue.')\n }\n this.cachedEvmAccount = { signTransaction: evmAccount.signTransaction as (tx: unknown) => Promise<unknown> }\n }\n\n const formattedTx = this.formatTransactionForCoinbase(tx)\n const signedTx = await this.cachedEvmAccount.signTransaction(formattedTx)\n return { ...(tx as Record<string, unknown>), signature: signedTx }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error)\n if (errorMessage.includes('signTransaction is not a function')) {\n throw new Error('CoinbaseWalletProvider: Account object missing signTransaction method. This may be a SDK version issue.')\n }\n throw new Error(`CoinbaseWalletProvider: Failed to sign transaction: ${error}`)\n }\n }\n\n async signMessage(message: string): Promise<string> {\n try {\n const account = await this.getAccount()\n const result =\n this.chain.name === 'solana'\n ? await this.client.solana.signMessage({ address: account.id, message })\n : await this.client.evm.signMessage({ address: account.id as `0x${string}`, message })\n\n if ('signedMessage' in result && result.signedMessage) {\n return String(result.signedMessage)\n }\n\n throw new Error('Coinbase API did not return signed message')\n } catch (error) {\n throw new Error(`CoinbaseWalletProvider: Failed to sign message: ${error}`)\n }\n }\n\n async importFromMnemonic(mnemonic: string): Promise<WarpWalletDetails> {\n throw new Error(\n 'CoinbaseWalletProvider: importFromMnemonic() is not supported. Use generate() to create a new account via Coinbase API.'\n )\n }\n\n async importFromPrivateKey(privateKey: string): Promise<WarpWalletDetails> {\n try {\n const name = this.getAccountName()\n const account =\n this.chain.name === 'solana'\n ? await this.client.solana.importAccount({ privateKey, ...(name && { name }) })\n : await this.client.evm.importAccount({ privateKey: privateKey as `0x${string}`, ...(name && { name }) })\n\n const walletDetails: WarpWalletDetails = {\n provider: CoinbaseWalletProvider.PROVIDER_NAME,\n address: account.address,\n privateKey,\n }\n\n setWarpWalletInConfig(this.config, this.chain.name, walletDetails)\n\n return walletDetails\n } catch (error) {\n throw new Error(`CoinbaseWalletProvider: Failed to import account from private key: ${error}`)\n }\n }\n\n async export(): Promise<WarpWalletDetails> {\n try {\n const address = this.getWalletAddress()\n const privateKey =\n this.chain.name === 'solana'\n ? await this.client.solana.exportAccount({ address })\n : await this.client.evm.exportAccount({ address: address as `0x${string}` })\n\n return {\n provider: CoinbaseWalletProvider.PROVIDER_NAME,\n address,\n privateKey,\n }\n } catch (error) {\n throw new Error(`CoinbaseWalletProvider: Failed to export account: ${error}`)\n }\n }\n\n async generate(): Promise<WarpWalletDetails> {\n try {\n const name = this.getAccountName()\n const account =\n this.chain.name === 'solana' ? await this.client.solana.createAccount({ name }) : await this.client.evm.createAccount({ name })\n\n const walletDetails: WarpWalletDetails = {\n provider: CoinbaseWalletProvider.PROVIDER_NAME,\n address: account.address,\n }\n\n setWarpWalletInConfig(this.config, this.chain.name, walletDetails)\n\n return walletDetails\n } catch (error) {\n throw new Error(`CoinbaseWalletProvider: Failed to generate account: ${error}`)\n }\n }\n\n private getAccountName(): string | undefined {\n return this.config.user?.id ? `${this.config.user.id}-${this.chain.name}` : undefined\n }\n\n private getWalletAddress(): string {\n const address = getWarpWalletAddressFromConfig(this.config, this.chain.name)\n if (!address) throw new Error(`CoinbaseWalletProvider: Wallet address not found in config for chain ${this.chain.name}`)\n return address\n }\n\n private extractPublicKey(account: { address: string; publicKey?: unknown }): string | undefined {\n return account.publicKey as string | undefined\n }\n\n private async getAccount(): Promise<{ id: string; address: string; publicKey?: string }> {\n if (this.cachedAccount) return this.cachedAccount\n\n const address = this.getWalletAddress()\n const account =\n this.chain.name === 'solana'\n ? await this.client.solana.getAccount({ address })\n : await this.client.evm.getAccount({ address: address as `0x${string}` })\n\n const publicKey = this.extractPublicKey(account)\n this.cachedAccount = {\n id: account.address,\n address: account.address,\n ...(publicKey && { publicKey }),\n }\n\n if (this.chain.name !== 'solana' && 'signTransaction' in account) {\n this.cachedEvmAccount = { signTransaction: account.signTransaction as (tx: unknown) => Promise<unknown> }\n }\n\n return this.cachedAccount\n }\n\n private formatTransactionForCoinbase(tx: any): any {\n const formatBigInt = (value: bigint | string | number | undefined): string | undefined => {\n if (value === undefined || value === null) return undefined\n if (typeof value === 'bigint') return `0x${value.toString(16)}`\n if (typeof value === 'string' && value.startsWith('0x')) return value\n if (typeof value === 'string') return `0x${BigInt(value).toString(16)}`\n return `0x${BigInt(value).toString(16)}`\n }\n\n const hasEip1559Fields = tx.maxFeePerGas !== undefined && tx.maxPriorityFeePerGas !== undefined\n const hasLegacyFields = tx.gasPrice !== undefined && !hasEip1559Fields\n\n const formatted: any = {\n to: tx.to,\n value: formatBigInt(tx.value) || '0x0',\n data: tx.data || '0x',\n chainId: typeof tx.chainId === 'number' ? tx.chainId : parseInt(String(tx.chainId || this.chain.chainId)),\n }\n\n if (tx.gasLimit) {\n formatted.gas = formatBigInt(tx.gasLimit)\n }\n\n if (hasEip1559Fields) {\n const maxFee = typeof tx.maxFeePerGas === 'bigint' ? tx.maxFeePerGas : BigInt(formatBigInt(tx.maxFeePerGas)!)\n const maxPriorityFee =\n typeof tx.maxPriorityFeePerGas === 'bigint' ? tx.maxPriorityFeePerGas : BigInt(formatBigInt(tx.maxPriorityFeePerGas)!)\n formatted.maxFeePerGas = formatBigInt(maxFee)!\n const safePriorityFee = maxPriorityFee < maxFee ? maxPriorityFee : maxFee / 10n\n formatted.maxPriorityFeePerGas = formatBigInt(safePriorityFee)!\n } else if (hasLegacyFields) {\n const gasPriceHex = formatBigInt(tx.gasPrice)!\n const gasPrice = typeof tx.gasPrice === 'bigint' ? tx.gasPrice : BigInt(gasPriceHex)\n formatted.maxFeePerGas = gasPriceHex\n const priorityFee = (gasPrice * 9n) / 10n\n formatted.maxPriorityFeePerGas = formatBigInt(priorityFee > 0n ? priorityFee : 1n)!\n } else {\n const defaultMaxFee = BigInt('1000000000')\n formatted.maxFeePerGas = formatBigInt(defaultMaxFee)!\n formatted.maxPriorityFeePerGas = formatBigInt(defaultMaxFee / 10n)!\n }\n\n if (tx.nonce !== undefined) {\n formatted.nonce = typeof tx.nonce === 'number' ? `0x${tx.nonce.toString(16)}` : formatBigInt(tx.nonce)\n }\n\n return formatted\n }\n}\n","import { WalletProviderFactory, WarpChainInfo, WarpClientConfig } from '@vleap/warps'\nimport { CoinbaseWalletProvider } from './CoinbaseWalletProvider'\nimport { CoinbaseProviderConfig } from './types'\n\nexport const createCoinbaseWalletProvider = (\n coinbaseConfig: CoinbaseProviderConfig\n): WalletProviderFactory => {\n return (config: WarpClientConfig, chain: WarpChainInfo) =>\n new CoinbaseWalletProvider(config, chain, coinbaseConfig)\n}\n"],"mappings":";AAAA,SAAS,iBAAiB;AAC1B;AAAA,EACE;AAAA,EACA;AAAA,OAOK;AAGA,IAAM,0BAAN,MAAM,wBAAiD;AAAA,EAM5D,YACmB,QACA,OACA,gBACjB;AAHiB;AACA;AACA;AANnB,SAAQ,gBAA4E;AACpF,SAAQ,mBAAkF;AAOxF,SAAK,SAAS,IAAI,UAAU;AAAA,MAC1B,UAAU,eAAe;AAAA,MACzB,cAAc,eAAe;AAAA,MAC7B,cAAc,eAAe;AAAA,MAC7B,GAAI,eAAe,UAAU,EAAE,QAAQ,eAAe,OAAO;AAAA,IAC/D,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,aAAqC;AACzC,QAAI;AACF,cAAQ,MAAM,KAAK,WAAW,GAAG;AAAA,IACnC,SAAS,OAAO;AACd,cAAQ,MAAM,iDAAiD,KAAK;AACpE,aAAO;AAAA,IACT;AAAA,EACF;AAAA,EAEA,MAAM,eAAuC;AAC3C,QAAI;AACF,cAAQ,MAAM,KAAK,WAAW,GAAG,aAAa;AAAA,IAChD,SAAS,OAAO;AACd,cAAQ,MAAM,oDAAoD,KAAK;AACvE,aAAO;AAAA,IACT;AAAA,EACF;AAAA,EAEA,MAAM,gBAA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,UAAU;AACf,gBAAU,MAAM,aAAa,GAAG,QAAQ;AAAA,IAC1C;AAEA,QAAI,kBAAkB;AACpB,YAAM,SAAS,OAAO,GAAG,iBAAiB,WAAW,GAAG,eAAe,OAAO,aAAa,GAAG,YAAY,CAAE;AAC5G,YAAM,iBACJ,OAAO,GAAG,yBAAyB,WAAW,GAAG,uBAAuB,OAAO,aAAa,GAAG,oBAAoB,CAAE;AACvH,gBAAU,eAAe,aAAa,MAAM;AAC5C,YAAM,kBAAkB,iBAAiB,SAAS,iBAAiB,SAAS;AAC5E,gBAAU,uBAAuB,aAAa,eAAe;AAAA,IAC/D,WAAW,iBAAiB;AAC1B,YAAM,cAAc,aAAa,GAAG,QAAQ;AAC5C,YAAM,WAAW,OAAO,GAAG,aAAa,WAAW,GAAG,WAAW,OAAO,WAAW;AACnF,gBAAU,eAAe;AACzB,YAAM,cAAe,WAAW,KAAM;AACtC,gBAAU,uBAAuB,aAAa,cAAc,KAAK,cAAc,EAAE;AAAA,IACnF,OAAO;AACL,YAAM,gBAAgB,OAAO,YAAY;AACzC,gBAAU,eAAe,aAAa,aAAa;AACnD,gBAAU,uBAAuB,aAAa,gBAAgB,GAAG;AAAA,IACnE;AAEA,QAAI,GAAG,UAAU,QAAW;AAC1B,gBAAU,QAAQ,OAAO,GAAG,UAAU,WAAW,KAAK,GAAG,MAAM,SAAS,EAAE,CAAC,KAAK,aAAa,GAAG,KAAK;AAAA,IACvG;AAEA,WAAO;AAAA,EACT;AACF;AA/Ra,wBACK,gBAAoC;AAD/C,IAAM,yBAAN;;;ACTA,IAAM,+BAA+B,CAC1C,mBAC0B;AAC1B,SAAO,CAAC,QAA0B,UAChC,IAAI,uBAAuB,QAAQ,OAAO,cAAc;AAC5D;","names":[]}
1
+ {"version":3,"sources":["../src/CoinbaseWalletProvider.ts","../src/helpers.ts"],"sourcesContent":["import { CdpClient } from '@coinbase/cdp-sdk'\nimport {\n getWarpWalletAddressFromConfig,\n setWarpWalletInConfig,\n WalletProvider,\n WarpAdapterGenericTransaction,\n WarpChainInfo,\n WarpClientConfig,\n WarpWalletDetails,\n WarpWalletProvider,\n} from '@vleap/warps'\nimport { CoinbaseProviderConfig } from './types'\n\nexport class CoinbaseWalletProvider implements WalletProvider {\n static readonly PROVIDER_NAME: WarpWalletProvider = 'coinbase'\n private readonly client: CdpClient\n private cachedAccount: { id: string; address: string; publicKey?: string } | null = null\n private cachedEvmAccount: { signTransaction: (tx: unknown) => Promise<unknown> } | null = null\n\n constructor(\n private readonly config: WarpClientConfig,\n private readonly chain: WarpChainInfo,\n private readonly coinbaseConfig: CoinbaseProviderConfig\n ) {\n this.client = new CdpClient({\n apiKeyId: coinbaseConfig.apiKeyId,\n apiKeySecret: coinbaseConfig.apiKeySecret,\n walletSecret: coinbaseConfig.walletSecret,\n ...(coinbaseConfig.apiUrl && { apiUrl: coinbaseConfig.apiUrl }),\n })\n }\n\n async getAddress(): Promise<string | null> {\n try {\n return (await this.getAccount()).address\n } catch (error) {\n console.error('CoinbaseWalletProvider: Failed to get address', error)\n return null\n }\n }\n\n async getPublicKey(): Promise<string | null> {\n try {\n return (await this.getAccount()).publicKey ?? null\n } catch (error) {\n console.error('CoinbaseWalletProvider: Failed to get public key', error)\n return null\n }\n }\n\n async signTransaction(tx: WarpAdapterGenericTransaction): Promise<WarpAdapterGenericTransaction> {\n const formatBigInt = (value: bigint | string | number | undefined): string | undefined => {\n if (value === undefined || value === null) return undefined\n if (typeof value === 'bigint') return `0x${value.toString(16)}`\n if (typeof value === 'string' && value.startsWith('0x')) return value\n if (typeof value === 'string') return `0x${BigInt(value).toString(16)}`\n return `0x${BigInt(value).toString(16)}`\n }\n\n const hasEip1559Fields = tx.maxFeePerGas !== undefined && tx.maxPriorityFeePerGas !== undefined\n const hasLegacyFields = tx.gasPrice !== undefined && !hasEip1559Fields\n\n const formatted: any = {\n to: tx.to,\n value: formatBigInt(tx.value) || '0x0',\n data: tx.data || '0x',\n chainId: typeof tx.chainId === 'number' ? tx.chainId : parseInt(String(tx.chainId || this.chain.chainId)),\n }\n\n if (tx.gasLimit) {\n formatted.gas = formatBigInt(tx.gasLimit)\n }\n\n if (hasEip1559Fields) {\n const maxFee = typeof tx.maxFeePerGas === 'bigint' ? tx.maxFeePerGas : BigInt(formatBigInt(tx.maxFeePerGas)!)\n const maxPriorityFee =\n typeof tx.maxPriorityFeePerGas === 'bigint' ? tx.maxPriorityFeePerGas : BigInt(formatBigInt(tx.maxPriorityFeePerGas)!)\n let safePriorityFee = maxPriorityFee <= maxFee ? maxPriorityFee : maxFee / 10n\n if (safePriorityFee > maxFee) safePriorityFee = maxFee\n if (safePriorityFee < 1n) safePriorityFee = 1n\n formatted.maxFeePerGas = formatBigInt(maxFee)!\n formatted.maxPriorityFeePerGas = formatBigInt(safePriorityFee)!\n } else if (hasLegacyFields) {\n const gasPriceHex = formatBigInt(tx.gasPrice)!\n const gasPrice = typeof tx.gasPrice === 'bigint' ? tx.gasPrice : BigInt(gasPriceHex)\n formatted.maxFeePerGas = gasPriceHex\n const priorityFee = (gasPrice * 9n) / 10n\n formatted.maxPriorityFeePerGas = formatBigInt(priorityFee > 0n ? priorityFee : 1n)!\n } else {\n const defaultMaxFee = BigInt('1000000000')\n formatted.maxFeePerGas = formatBigInt(defaultMaxFee)!\n formatted.maxPriorityFeePerGas = formatBigInt(defaultMaxFee / 10n)!\n }\n\n if (tx.nonce !== undefined) {\n formatted.nonce = typeof tx.nonce === 'number' ? `0x${tx.nonce.toString(16)}` : formatBigInt(tx.nonce)\n }\n\n try {\n const account = await this.getAccount()\n\n if (this.chain.name === 'solana') {\n const result = await this.client.solana.signTransaction({\n address: account.id,\n transaction: tx as never,\n })\n\n if ('signedTransaction' in result && result.signedTransaction) {\n return { ...(tx as Record<string, unknown>), signature: String(result.signedTransaction) }\n }\n throw new Error('Coinbase API did not return signed transaction')\n }\n\n if (!this.cachedEvmAccount) {\n const address = this.getWalletAddress()\n const evmAccount = await this.client.evm.getAccount({ address: address as `0x${string}` })\n if (!('signTransaction' in evmAccount)) {\n throw new Error('CoinbaseWalletProvider: Account object missing signTransaction method. This may be a SDK version issue.')\n }\n this.cachedEvmAccount = { signTransaction: evmAccount.signTransaction as (tx: unknown) => Promise<unknown> }\n }\n\n const formattedTx = this.formatTransactionForCoinbase(tx)\n const signedTx = await this.cachedEvmAccount.signTransaction(formattedTx)\n return { ...(tx as Record<string, unknown>), signature: signedTx }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error)\n if (errorMessage.includes('signTransaction is not a function')) {\n throw new Error('CoinbaseWalletProvider: Account object missing signTransaction method. This may be a SDK version issue.')\n }\n throw new Error(`CoinbaseWalletProvider: Failed to sign transaction: ${error}`)\n }\n }\n\n async signMessage(message: string): Promise<string> {\n try {\n const account = await this.getAccount()\n const result =\n this.chain.name === 'solana'\n ? await this.client.solana.signMessage({ address: account.id, message })\n : await this.client.evm.signMessage({ address: account.id as `0x${string}`, message })\n\n if ('signedMessage' in result && result.signedMessage) {\n return String(result.signedMessage)\n }\n\n throw new Error('Coinbase API did not return signed message')\n } catch (error) {\n throw new Error(`CoinbaseWalletProvider: Failed to sign message: ${error}`)\n }\n }\n\n async importFromMnemonic(mnemonic: string): Promise<WarpWalletDetails> {\n throw new Error(\n 'CoinbaseWalletProvider: importFromMnemonic() is not supported. Use generate() to create a new account via Coinbase API.'\n )\n }\n\n async importFromPrivateKey(privateKey: string): Promise<WarpWalletDetails> {\n try {\n const name = this.getAccountName()\n const account =\n this.chain.name === 'solana'\n ? await this.client.solana.importAccount({ privateKey, ...(name && { name }) })\n : await this.client.evm.importAccount({ privateKey: privateKey as `0x${string}`, ...(name && { name }) })\n\n const walletDetails: WarpWalletDetails = {\n provider: CoinbaseWalletProvider.PROVIDER_NAME,\n address: account.address,\n privateKey,\n }\n\n setWarpWalletInConfig(this.config, this.chain.name, walletDetails)\n\n return walletDetails\n } catch (error) {\n throw new Error(`CoinbaseWalletProvider: Failed to import account from private key: ${error}`)\n }\n }\n\n async export(): Promise<WarpWalletDetails> {\n try {\n const address = this.getWalletAddress()\n const privateKey =\n this.chain.name === 'solana'\n ? await this.client.solana.exportAccount({ address })\n : await this.client.evm.exportAccount({ address: address as `0x${string}` })\n\n return {\n provider: CoinbaseWalletProvider.PROVIDER_NAME,\n address,\n privateKey,\n }\n } catch (error) {\n throw new Error(`CoinbaseWalletProvider: Failed to export account: ${error}`)\n }\n }\n\n async generate(): Promise<WarpWalletDetails> {\n try {\n const name = this.getAccountName()\n const account =\n this.chain.name === 'solana' ? await this.client.solana.createAccount({ name }) : await this.client.evm.createAccount({ name })\n\n const walletDetails: WarpWalletDetails = {\n provider: CoinbaseWalletProvider.PROVIDER_NAME,\n address: account.address,\n }\n\n setWarpWalletInConfig(this.config, this.chain.name, walletDetails)\n\n return walletDetails\n } catch (error) {\n throw new Error(`CoinbaseWalletProvider: Failed to generate account: ${error}`)\n }\n }\n\n private getAccountName(): string | undefined {\n return this.config.user?.id ? `${this.config.user.id}-${this.chain.name}` : undefined\n }\n\n private getWalletAddress(): string {\n const address = getWarpWalletAddressFromConfig(this.config, this.chain.name)\n if (!address) throw new Error(`CoinbaseWalletProvider: Wallet address not found in config for chain ${this.chain.name}`)\n return address\n }\n\n private extractPublicKey(account: { address: string; publicKey?: unknown }): string | undefined {\n return account.publicKey as string | undefined\n }\n\n private async getAccount(): Promise<{ id: string; address: string; publicKey?: string }> {\n if (this.cachedAccount) return this.cachedAccount\n\n const address = this.getWalletAddress()\n const account =\n this.chain.name === 'solana'\n ? await this.client.solana.getAccount({ address })\n : await this.client.evm.getAccount({ address: address as `0x${string}` })\n\n const publicKey = this.extractPublicKey(account)\n this.cachedAccount = {\n id: account.address,\n address: account.address,\n ...(publicKey && { publicKey }),\n }\n\n if (this.chain.name !== 'solana' && 'signTransaction' in account) {\n this.cachedEvmAccount = { signTransaction: account.signTransaction as (tx: unknown) => Promise<unknown> }\n }\n\n return this.cachedAccount\n }\n\n private formatTransactionForCoinbase(tx: any): any {\n const formatBigInt = (value: bigint | string | number | undefined): string | undefined => {\n if (value === undefined || value === null) return undefined\n if (typeof value === 'bigint') return `0x${value.toString(16)}`\n if (typeof value === 'string' && value.startsWith('0x')) return value\n if (typeof value === 'string') return `0x${BigInt(value).toString(16)}`\n return `0x${BigInt(value).toString(16)}`\n }\n\n const hasEip1559Fields = tx.maxFeePerGas !== undefined && tx.maxPriorityFeePerGas !== undefined\n const hasLegacyFields = tx.gasPrice !== undefined && !hasEip1559Fields\n\n const formatted: any = {\n to: tx.to,\n value: formatBigInt(tx.value) || '0x0',\n data: tx.data || '0x',\n chainId: typeof tx.chainId === 'number' ? tx.chainId : parseInt(String(tx.chainId || this.chain.chainId)),\n }\n\n if (tx.gasLimit) {\n formatted.gas = formatBigInt(tx.gasLimit)\n }\n\n if (hasEip1559Fields) {\n const maxFee = typeof tx.maxFeePerGas === 'bigint' ? tx.maxFeePerGas : BigInt(formatBigInt(tx.maxFeePerGas)!)\n const maxPriorityFee =\n typeof tx.maxPriorityFeePerGas === 'bigint' ? tx.maxPriorityFeePerGas : BigInt(formatBigInt(tx.maxPriorityFeePerGas)!)\n let safePriorityFee = maxPriorityFee <= maxFee ? maxPriorityFee : maxFee / 10n\n if (safePriorityFee > maxFee) safePriorityFee = maxFee\n if (safePriorityFee < 1n) safePriorityFee = 1n\n formatted.maxFeePerGas = formatBigInt(maxFee)!\n formatted.maxPriorityFeePerGas = formatBigInt(safePriorityFee)!\n } else if (hasLegacyFields) {\n const gasPriceHex = formatBigInt(tx.gasPrice)!\n const gasPrice = typeof tx.gasPrice === 'bigint' ? tx.gasPrice : BigInt(gasPriceHex)\n formatted.maxFeePerGas = gasPriceHex\n const priorityFee = (gasPrice * 9n) / 10n\n formatted.maxPriorityFeePerGas = formatBigInt(priorityFee > 0n ? priorityFee : 1n)!\n } else {\n const defaultMaxFee = BigInt('1000000000')\n formatted.maxFeePerGas = formatBigInt(defaultMaxFee)!\n formatted.maxPriorityFeePerGas = formatBigInt(defaultMaxFee / 10n)!\n }\n\n if (tx.nonce !== undefined) {\n formatted.nonce = typeof tx.nonce === 'number' ? `0x${tx.nonce.toString(16)}` : formatBigInt(tx.nonce)\n }\n\n return formatted\n }\n}\n","import { WalletProviderFactory, WarpChainInfo, WarpClientConfig } from '@vleap/warps'\nimport { CoinbaseWalletProvider } from './CoinbaseWalletProvider'\nimport { CoinbaseProviderConfig } from './types'\n\nexport const createCoinbaseWalletProvider = (\n coinbaseConfig: CoinbaseProviderConfig\n): WalletProviderFactory => {\n return (config: WarpClientConfig, chain: WarpChainInfo) =>\n new CoinbaseWalletProvider(config, chain, coinbaseConfig)\n}\n"],"mappings":";AAAA,SAAS,iBAAiB;AAC1B;AAAA,EACE;AAAA,EACA;AAAA,OAOK;AAGA,IAAM,0BAAN,MAAM,wBAAiD;AAAA,EAM5D,YACmB,QACA,OACA,gBACjB;AAHiB;AACA;AACA;AANnB,SAAQ,gBAA4E;AACpF,SAAQ,mBAAkF;AAOxF,SAAK,SAAS,IAAI,UAAU;AAAA,MAC1B,UAAU,eAAe;AAAA,MACzB,cAAc,eAAe;AAAA,MAC7B,cAAc,eAAe;AAAA,MAC7B,GAAI,eAAe,UAAU,EAAE,QAAQ,eAAe,OAAO;AAAA,IAC/D,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,aAAqC;AACzC,QAAI;AACF,cAAQ,MAAM,KAAK,WAAW,GAAG;AAAA,IACnC,SAAS,OAAO;AACd,cAAQ,MAAM,iDAAiD,KAAK;AACpE,aAAO;AAAA,IACT;AAAA,EACF;AAAA,EAEA,MAAM,eAAuC;AAC3C,QAAI;AACF,cAAQ,MAAM,KAAK,WAAW,GAAG,aAAa;AAAA,IAChD,SAAS,OAAO;AACd,cAAQ,MAAM,oDAAoD,KAAK;AACvE,aAAO;AAAA,IACT;AAAA,EACF;AAAA,EAEA,MAAM,gBAAgB,IAA2E;AAC/F,UAAM,eAAe,CAAC,UAAoE;AACxF,UAAI,UAAU,UAAa,UAAU,KAAM,QAAO;AAClD,UAAI,OAAO,UAAU,SAAU,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4
4
  "description": "Coinbase Server Wallet v2 provider for multiple chains",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",