@lifi/sdk 3.8.11 → 3.9.0-beta.0

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.
Files changed (104) hide show
  1. package/package.json +3 -2
  2. package/src/_cjs/core/EVM/EVM.js +2 -2
  3. package/src/_cjs/core/EVM/EVM.js.map +1 -1
  4. package/src/_cjs/core/EVM/publicClient.js +8 -0
  5. package/src/_cjs/core/EVM/publicClient.js.map +1 -1
  6. package/src/_cjs/core/EVM/{getENSAddress.js → resolveENSAddress.js} +4 -4
  7. package/src/_cjs/core/EVM/resolveENSAddress.js.map +1 -0
  8. package/src/_cjs/core/EVM/resolveEVMAddress.js +11 -0
  9. package/src/_cjs/core/EVM/resolveEVMAddress.js.map +1 -0
  10. package/src/_cjs/core/EVM/uns/constants.js +78 -0
  11. package/src/_cjs/core/EVM/uns/constants.js.map +1 -0
  12. package/src/_cjs/core/EVM/uns/resolveUNSAddress.js +82 -0
  13. package/src/_cjs/core/EVM/uns/resolveUNSAddress.js.map +1 -0
  14. package/src/_cjs/core/Solana/Solana.js +2 -2
  15. package/src/_cjs/core/Solana/Solana.js.map +1 -1
  16. package/src/_cjs/core/Solana/resolveSolanaAddress.js +8 -0
  17. package/src/_cjs/core/Solana/resolveSolanaAddress.js.map +1 -0
  18. package/src/_cjs/core/Sui/Sui.js +2 -2
  19. package/src/_cjs/core/Sui/Sui.js.map +1 -1
  20. package/src/_cjs/core/Sui/resolveSuiAddress.js +8 -0
  21. package/src/_cjs/core/Sui/resolveSuiAddress.js.map +1 -0
  22. package/src/_cjs/core/UTXO/UTXO.js +2 -3
  23. package/src/_cjs/core/UTXO/UTXO.js.map +1 -1
  24. package/src/_cjs/core/UTXO/UTXOStepExecutor.js +25 -1
  25. package/src/_cjs/core/UTXO/UTXOStepExecutor.js.map +1 -1
  26. package/src/_cjs/core/UTXO/resolveUTXOAddress.js +7 -0
  27. package/src/_cjs/core/UTXO/resolveUTXOAddress.js.map +1 -0
  28. package/src/_cjs/core/UTXO/utils.js +3 -0
  29. package/src/_cjs/core/UTXO/utils.js.map +1 -1
  30. package/src/_cjs/version.js +1 -1
  31. package/src/_cjs/version.js.map +1 -1
  32. package/src/_esm/core/EVM/EVM.js +2 -2
  33. package/src/_esm/core/EVM/EVM.js.map +1 -1
  34. package/src/_esm/core/EVM/publicClient.js +9 -0
  35. package/src/_esm/core/EVM/publicClient.js.map +1 -1
  36. package/src/_esm/core/EVM/{getENSAddress.js → resolveENSAddress.js} +2 -2
  37. package/src/_esm/core/EVM/resolveENSAddress.js.map +1 -0
  38. package/src/_esm/core/EVM/resolveEVMAddress.js +8 -0
  39. package/src/_esm/core/EVM/resolveEVMAddress.js.map +1 -0
  40. package/src/_esm/core/EVM/uns/constants.js +74 -0
  41. package/src/_esm/core/EVM/uns/constants.js.map +1 -0
  42. package/src/_esm/core/EVM/uns/resolveUNSAddress.js +80 -0
  43. package/src/_esm/core/EVM/uns/resolveUNSAddress.js.map +1 -0
  44. package/src/_esm/core/Solana/Solana.js +2 -2
  45. package/src/_esm/core/Solana/Solana.js.map +1 -1
  46. package/src/_esm/core/Solana/resolveSolanaAddress.js +5 -0
  47. package/src/_esm/core/Solana/resolveSolanaAddress.js.map +1 -0
  48. package/src/_esm/core/Sui/Sui.js +2 -2
  49. package/src/_esm/core/Sui/Sui.js.map +1 -1
  50. package/src/_esm/core/Sui/resolveSuiAddress.js +5 -0
  51. package/src/_esm/core/Sui/resolveSuiAddress.js.map +1 -0
  52. package/src/_esm/core/UTXO/UTXO.js +2 -4
  53. package/src/_esm/core/UTXO/UTXO.js.map +1 -1
  54. package/src/_esm/core/UTXO/UTXOStepExecutor.js +35 -4
  55. package/src/_esm/core/UTXO/UTXOStepExecutor.js.map +1 -1
  56. package/src/_esm/core/UTXO/resolveUTXOAddress.js +5 -0
  57. package/src/_esm/core/UTXO/resolveUTXOAddress.js.map +1 -0
  58. package/src/_esm/core/UTXO/utils.js +2 -0
  59. package/src/_esm/core/UTXO/utils.js.map +1 -1
  60. package/src/_esm/version.js +1 -1
  61. package/src/_esm/version.js.map +1 -1
  62. package/src/_types/core/EVM/publicClient.d.ts.map +1 -1
  63. package/src/_types/core/EVM/resolveENSAddress.d.ts +2 -0
  64. package/src/_types/core/EVM/resolveENSAddress.d.ts.map +1 -0
  65. package/src/_types/core/EVM/resolveEVMAddress.d.ts +3 -0
  66. package/src/_types/core/EVM/resolveEVMAddress.d.ts.map +1 -0
  67. package/src/_types/core/EVM/uns/constants.d.ts +51 -0
  68. package/src/_types/core/EVM/uns/constants.d.ts.map +1 -0
  69. package/src/_types/core/EVM/uns/resolveUNSAddress.d.ts +3 -0
  70. package/src/_types/core/EVM/uns/resolveUNSAddress.d.ts.map +1 -0
  71. package/src/_types/core/Solana/resolveSolanaAddress.d.ts +2 -0
  72. package/src/_types/core/Solana/resolveSolanaAddress.d.ts.map +1 -0
  73. package/src/_types/core/Sui/resolveSuiAddress.d.ts +2 -0
  74. package/src/_types/core/Sui/resolveSuiAddress.d.ts.map +1 -0
  75. package/src/_types/core/UTXO/UTXO.d.ts.map +1 -1
  76. package/src/_types/core/UTXO/UTXOStepExecutor.d.ts.map +1 -1
  77. package/src/_types/core/UTXO/resolveUTXOAddress.d.ts +2 -0
  78. package/src/_types/core/UTXO/resolveUTXOAddress.d.ts.map +1 -0
  79. package/src/_types/core/UTXO/utils.d.ts +1 -0
  80. package/src/_types/core/UTXO/utils.d.ts.map +1 -1
  81. package/src/_types/core/types.d.ts +2 -2
  82. package/src/_types/core/types.d.ts.map +1 -1
  83. package/src/_types/version.d.ts +1 -1
  84. package/src/_types/version.d.ts.map +1 -1
  85. package/src/core/EVM/EVM.ts +2 -2
  86. package/src/core/EVM/publicClient.ts +13 -1
  87. package/src/core/EVM/{getENSAddress.ts → resolveENSAddress.ts} +1 -1
  88. package/src/core/EVM/resolveEVMAddress.ts +15 -0
  89. package/src/core/EVM/uns/constants.ts +81 -0
  90. package/src/core/EVM/uns/resolveUNSAddress.ts +123 -0
  91. package/src/core/Solana/Solana.ts +2 -2
  92. package/src/core/Solana/resolveSolanaAddress.ts +7 -0
  93. package/src/core/Sui/Sui.ts +2 -2
  94. package/src/core/Sui/resolveSuiAddress.ts +7 -0
  95. package/src/core/UTXO/UTXO.ts +2 -4
  96. package/src/core/UTXO/UTXOStepExecutor.ts +48 -4
  97. package/src/core/UTXO/resolveUTXOAddress.ts +6 -0
  98. package/src/core/UTXO/utils.ts +4 -0
  99. package/src/core/types.ts +7 -1
  100. package/src/version.ts +1 -1
  101. package/src/_cjs/core/EVM/getENSAddress.js.map +0 -1
  102. package/src/_esm/core/EVM/getENSAddress.js.map +0 -1
  103. package/src/_types/core/EVM/getENSAddress.d.ts +0 -2
  104. package/src/_types/core/EVM/getENSAddress.d.ts.map +0 -1
@@ -2,8 +2,8 @@ import { ChainType } from '@lifi/types'
2
2
  import { isAddress } from 'viem'
3
3
  import type { StepExecutorOptions } from '../types.js'
4
4
  import { EVMStepExecutor } from './EVMStepExecutor.js'
5
- import { getENSAddress } from './getENSAddress.js'
6
5
  import { getEVMBalance } from './getEVMBalance.js'
6
+ import { resolveEVMAddress } from './resolveEVMAddress.js'
7
7
  import type { EVMProvider, EVMProviderOptions } from './types.js'
8
8
 
9
9
  export function EVM(options?: EVMProviderOptions): EVMProvider {
@@ -16,7 +16,7 @@ export function EVM(options?: EVMProviderOptions): EVMProvider {
16
16
  return _options
17
17
  },
18
18
  isAddress,
19
- resolveAddress: getENSAddress,
19
+ resolveAddress: resolveEVMAddress,
20
20
  getBalance: getEVMBalance,
21
21
  getWalletClient: _options.getWalletClient,
22
22
  async getStepExecutor(
@@ -1,10 +1,11 @@
1
1
  import { ChainId, ChainType } from '@lifi/types'
2
2
  import type { Client } from 'viem'
3
- import { createClient, fallback, http, webSocket } from 'viem'
3
+ import { type Address, createClient, fallback, http, webSocket } from 'viem'
4
4
  import { type Chain, mainnet } from 'viem/chains'
5
5
  import { config } from '../../config.js'
6
6
  import { getRpcUrls } from '../rpc.js'
7
7
  import type { EVMProvider } from './types.js'
8
+ import { UNS_PROXY_READER_ADDRESSES } from './uns/constants.js'
8
9
 
9
10
  // cached providers
10
11
  const publicClients: Record<number, Client> = {}
@@ -46,6 +47,17 @@ export const getPublicClient = async (chainId: number): Promise<Client> => {
46
47
  ...chain.contracts,
47
48
  }
48
49
  }
50
+
51
+ // Add UNS contracts for supported chains
52
+ if (chain.id === ChainId.ETH || chain.id === ChainId.POL) {
53
+ const unsProxyAddress = UNS_PROXY_READER_ADDRESSES[chain.id]
54
+
55
+ chain.contracts = {
56
+ ...chain.contracts,
57
+ unsProxyReader: { address: unsProxyAddress as Address },
58
+ }
59
+ }
60
+
49
61
  const provider = config.getProvider(ChainType.EVM) as EVMProvider | undefined
50
62
  publicClients[chainId] = createClient({
51
63
  chain: chain,
@@ -2,7 +2,7 @@ import { ChainId } from '@lifi/types'
2
2
  import { getEnsAddress, normalize } from 'viem/ens'
3
3
  import { getPublicClient } from './publicClient.js'
4
4
 
5
- export const getENSAddress = async (
5
+ export const resolveENSAddress = async (
6
6
  name: string
7
7
  ): Promise<string | undefined> => {
8
8
  try {
@@ -0,0 +1,15 @@
1
+ import type { ChainId, CoinKey } from '@lifi/types'
2
+ import { ChainType } from '@lifi/types'
3
+ import { resolveENSAddress } from './resolveENSAddress.js'
4
+ import { resolveUNSAddress } from './uns/resolveUNSAddress.js'
5
+
6
+ export async function resolveEVMAddress(
7
+ name: string,
8
+ chainId?: ChainId,
9
+ token?: CoinKey
10
+ ): Promise<string | undefined> {
11
+ return (
12
+ (await resolveENSAddress(name)) ||
13
+ (await resolveUNSAddress(name, ChainType.EVM, chainId, token))
14
+ )
15
+ }
@@ -0,0 +1,81 @@
1
+ import { ChainId, ChainType } from '@lifi/types'
2
+ import type { Address } from 'viem'
3
+
4
+ export const UNS_PROXY_READER_ADDRESSES: Record<number, Address> = {
5
+ [ChainId.ETH]: '0x578853aa776Eef10CeE6c4dd2B5862bdcE767A8B',
6
+ [ChainId.POL]: '0x91EDd8708062bd4233f4Dd0FCE15A7cb4d500091',
7
+ } as const
8
+
9
+ export const getUNSProxyAddress = (chainId: number): Address | undefined =>
10
+ UNS_PROXY_READER_ADDRESSES[chainId]
11
+
12
+ export const UNSProxyReaderABI = [
13
+ {
14
+ constant: true,
15
+ inputs: [
16
+ {
17
+ internalType: 'string[]',
18
+ name: 'keys',
19
+ type: 'string[]',
20
+ },
21
+ {
22
+ internalType: 'uint256',
23
+ name: 'tokenId',
24
+ type: 'uint256',
25
+ },
26
+ ],
27
+ name: 'getData',
28
+ outputs: [
29
+ {
30
+ internalType: 'address',
31
+ name: 'resolver',
32
+ type: 'address',
33
+ },
34
+ {
35
+ internalType: 'address',
36
+ name: 'owner',
37
+ type: 'address',
38
+ },
39
+ {
40
+ internalType: 'string[]',
41
+ name: 'values',
42
+ type: 'string[]',
43
+ },
44
+ ],
45
+ payable: false,
46
+ stateMutability: 'view',
47
+ type: 'function',
48
+ },
49
+ {
50
+ inputs: [{ internalType: 'uint256', name: 'tokenId', type: 'uint256' }],
51
+ name: 'exists',
52
+ outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
53
+ stateMutability: 'view',
54
+ type: 'function',
55
+ },
56
+ ] as const
57
+
58
+ export const CHAIN_TYPE_UNS_CHAIN_MAP: Record<ChainType, string> = {
59
+ [ChainType.EVM]: 'ETH',
60
+ [ChainType.MVM]: 'SUI',
61
+ [ChainType.SVM]: 'SOL',
62
+ [ChainType.UTXO]: 'BTC',
63
+ }
64
+
65
+ export const CHAIN_ID_UNS_CHAIN_MAP: Partial<Record<ChainId, string>> = {
66
+ [ChainId.ETH]: 'ETH',
67
+ [ChainId.BTC]: 'BTC',
68
+ [ChainId.SUI]: 'SUI',
69
+ [ChainId.SOL]: 'SOL',
70
+ [ChainId.BAS]: 'BASE',
71
+ [ChainId.POL]: 'MATIC',
72
+ [ChainId.ARB]: 'ARB1',
73
+ [ChainId.AVA]: 'AVAX',
74
+ }
75
+
76
+ export const CHAIN_TYPE_FAMILY_MAP: Record<ChainType, string> = {
77
+ [ChainType.EVM]: 'EVM',
78
+ [ChainType.UTXO]: 'BTC',
79
+ [ChainType.SVM]: 'SOL',
80
+ [ChainType.MVM]: 'SUI',
81
+ }
@@ -0,0 +1,123 @@
1
+ import { ChainId, type ChainType, type CoinKey } from '@lifi/types'
2
+ import type { Address, Client } from 'viem'
3
+ import { readContract } from 'viem/actions'
4
+ import { namehash } from 'viem/ens'
5
+ import { getAction, trim } from 'viem/utils'
6
+ import { getPublicClient } from '../publicClient.js'
7
+
8
+ import {
9
+ CHAIN_ID_UNS_CHAIN_MAP,
10
+ CHAIN_TYPE_FAMILY_MAP,
11
+ CHAIN_TYPE_UNS_CHAIN_MAP,
12
+ getUNSProxyAddress,
13
+ UNSProxyReaderABI,
14
+ } from './constants.js'
15
+
16
+ export const resolveUNSAddress = async (
17
+ name: string,
18
+ chainType: ChainType,
19
+ chain?: ChainId,
20
+ token?: CoinKey
21
+ ): Promise<string | undefined> => {
22
+ try {
23
+ const L1Client = await getPublicClient(ChainId.ETH)
24
+ const L2Client = await getPublicClient(ChainId.POL)
25
+
26
+ const nameHash = namehash(name)
27
+ const keys: string[] = []
28
+
29
+ // handle token based resolution
30
+ if (chain) {
31
+ const family = CHAIN_TYPE_FAMILY_MAP[chainType]
32
+ const unschain = CHAIN_ID_UNS_CHAIN_MAP[chain]
33
+
34
+ if (family) {
35
+ if (token) {
36
+ keys.push(`token.${family}.${unschain}.${token}.address`)
37
+ }
38
+ if (unschain) {
39
+ keys.push(`token.${family}.${unschain}.address`)
40
+ }
41
+
42
+ keys.push(`token.${family}.address`)
43
+ }
44
+ }
45
+
46
+ // fallback to chain based resolution
47
+ const unschainType = CHAIN_TYPE_UNS_CHAIN_MAP[chainType]
48
+ keys.push(`crypto.${unschainType}.address`)
49
+
50
+ for (const key of keys) {
51
+ const address =
52
+ (await getUnsAddress(L2Client, { name: nameHash, key })) ||
53
+ (await getUnsAddress(L1Client, { name: nameHash, key }))
54
+ if (address) {
55
+ return address
56
+ }
57
+ }
58
+ return undefined
59
+ } catch {
60
+ return undefined
61
+ }
62
+ }
63
+
64
+ type GetUnsAddressParameters = {
65
+ key: string
66
+ name: string
67
+ }
68
+
69
+ type GetUnsAddressReturnType = Address | undefined
70
+
71
+ async function getUnsAddress(
72
+ client: Client,
73
+ params: GetUnsAddressParameters
74
+ ): Promise<GetUnsAddressReturnType> {
75
+ const { name, key } = params
76
+
77
+ const chainId = client.chain?.id
78
+ if (!chainId) {
79
+ throw new Error('Chain ID not available')
80
+ }
81
+
82
+ const proxyAddress = getUNSProxyAddress(chainId)
83
+ if (!proxyAddress) {
84
+ throw new Error(`UNS contracts are not deployed on chain ${chainId}`)
85
+ }
86
+
87
+ const readContractAction = getAction(client, readContract, 'readContract')
88
+
89
+ const existsReadContractParameters = {
90
+ abi: UNSProxyReaderABI,
91
+ address: proxyAddress,
92
+ functionName: 'exists',
93
+ args: [BigInt(name)],
94
+ } as const
95
+
96
+ const exists = await readContractAction(existsReadContractParameters)
97
+
98
+ if (!exists) {
99
+ return undefined
100
+ }
101
+
102
+ const readContractParameters = {
103
+ abi: UNSProxyReaderABI,
104
+ address: proxyAddress,
105
+ functionName: 'getData',
106
+ args: [[key], BigInt(name)],
107
+ } as const
108
+
109
+ const res = await readContractAction(readContractParameters)
110
+ const [, , addresses] = res
111
+
112
+ const address = addresses[0]
113
+
114
+ if (
115
+ address === '0x' ||
116
+ address === '' ||
117
+ trim(address as Address) === '0x00'
118
+ ) {
119
+ return undefined
120
+ }
121
+
122
+ return address as Address
123
+ }
@@ -1,8 +1,8 @@
1
1
  import { ChainType } from '@lifi/types'
2
2
  import type { StepExecutorOptions } from '../types.js'
3
- import { getSNSAddress } from './getSNSAddress.js'
4
3
  import { getSolanaBalance } from './getSolanaBalance.js'
5
4
  import { isSVMAddress } from './isSVMAddress.js'
5
+ import { resolveSolanaAddress } from './resolveSolanaAddress.js'
6
6
  import { SolanaStepExecutor } from './SolanaStepExecutor.js'
7
7
  import type { SolanaProvider, SolanaProviderOptions } from './types.js'
8
8
 
@@ -13,7 +13,7 @@ export function Solana(options?: SolanaProviderOptions): SolanaProvider {
13
13
  return ChainType.SVM
14
14
  },
15
15
  isAddress: isSVMAddress,
16
- resolveAddress: getSNSAddress,
16
+ resolveAddress: resolveSolanaAddress,
17
17
  getBalance: getSolanaBalance,
18
18
  async getStepExecutor(
19
19
  options: StepExecutorOptions
@@ -0,0 +1,7 @@
1
+ import { getSNSAddress } from './getSNSAddress.js'
2
+
3
+ export async function resolveSolanaAddress(
4
+ name: string
5
+ ): Promise<string | undefined> {
6
+ return await getSNSAddress(name)
7
+ }
@@ -2,7 +2,7 @@ import { ChainType } from '@lifi/types'
2
2
  import { isValidSuiAddress } from '@mysten/sui/utils'
3
3
  import type { StepExecutorOptions } from '../types.js'
4
4
  import { getSuiBalance } from './getSuiBalance.js'
5
- import { getSuiNSAddress } from './getSuiNSAddress.js'
5
+ import { resolveSuiAddress } from './resolveSuiAddress.js'
6
6
  import { SuiStepExecutor } from './SuiStepExecutor.js'
7
7
  import type { SuiProvider, SuiProviderOptions } from './types.js'
8
8
 
@@ -13,7 +13,7 @@ export function Sui(options?: SuiProviderOptions): SuiProvider {
13
13
  return ChainType.MVM
14
14
  },
15
15
  isAddress: isValidSuiAddress,
16
- resolveAddress: getSuiNSAddress,
16
+ resolveAddress: resolveSuiAddress,
17
17
  getBalance: getSuiBalance,
18
18
  async getStepExecutor(
19
19
  options: StepExecutorOptions
@@ -0,0 +1,7 @@
1
+ import { getSuiNSAddress } from './getSuiNSAddress.js'
2
+
3
+ export async function resolveSuiAddress(
4
+ name: string
5
+ ): Promise<string | undefined> {
6
+ return await getSuiNSAddress(name)
7
+ }
@@ -2,6 +2,7 @@ import { isUTXOAddress } from '@bigmi/core'
2
2
  import { ChainType } from '@lifi/types'
3
3
  import type { StepExecutorOptions } from '../types.js'
4
4
  import { getUTXOBalance } from './getUTXOBalance.js'
5
+ import { resolveUTXOAddress } from './resolveUTXOAddress.js'
5
6
  import type { UTXOProvider, UTXOProviderOptions } from './types.js'
6
7
  import { UTXOStepExecutor } from './UTXOStepExecutor.js'
7
8
 
@@ -12,10 +13,7 @@ export function UTXO(options?: UTXOProviderOptions): UTXOProvider {
12
13
  return ChainType.UTXO
13
14
  },
14
15
  isAddress: isUTXOAddress,
15
- async resolveAddress(name) {
16
- // Not supported on UTXO yet
17
- return name
18
- },
16
+ resolveAddress: resolveUTXOAddress,
19
17
  getBalance: getUTXOBalance,
20
18
  async getStepExecutor(
21
19
  options: StepExecutorOptions
@@ -1,7 +1,15 @@
1
1
  import type { Client, ReplacementReason } from '@bigmi/core'
2
- import { signPsbt, waitForTransaction, withTimeout } from '@bigmi/core'
2
+ import {
3
+ AddressType,
4
+ getAddressInfo,
5
+ hexToUnit8Array,
6
+ signPsbt,
7
+ waitForTransaction,
8
+ withTimeout,
9
+ } from '@bigmi/core'
10
+ import * as ecc from '@bitcoinerlab/secp256k1'
3
11
  import { ChainId } from '@lifi/types'
4
- import { address, networks, Psbt } from 'bitcoinjs-lib'
12
+ import { address, initEccLib, networks, Psbt } from 'bitcoinjs-lib'
5
13
  import { config } from '../../config.js'
6
14
  import { LiFiErrorCode } from '../../errors/constants.js'
7
15
  import { TransactionError } from '../../errors/errors.js'
@@ -17,7 +25,7 @@ import type {
17
25
  import { waitForDestinationChainTransaction } from '../waitForDestinationChainTransaction.js'
18
26
  import { getUTXOPublicClient } from './getUTXOPublicClient.js'
19
27
  import { parseUTXOErrors } from './parseUTXOErrors.js'
20
- import { isPsbtFinalized } from './utils.js'
28
+ import { isPsbtFinalized, toXOnly } from './utils.js'
21
29
 
22
30
  export interface UTXOStepExecutorOptions extends StepExecutorOptions {
23
31
  client: Client
@@ -143,8 +151,44 @@ export class UTXOStepExecutor extends BaseStepExecutor {
143
151
 
144
152
  const psbtHex = transactionRequest.data
145
153
 
154
+ // Initialize ECC library required for Taproot operations
155
+ // https://github.com/bitcoinjs/bitcoinjs-lib?tab=readme-ov-file#using-taproot
156
+ initEccLib(ecc)
157
+
146
158
  const psbt = Psbt.fromHex(psbtHex, { network: networks.bitcoin })
147
159
 
160
+ psbt.data.inputs.forEach((input, index) => {
161
+ const accountAddress = input.witnessUtxo
162
+ ? address.fromOutputScript(
163
+ input.witnessUtxo.script,
164
+ networks.bitcoin
165
+ )
166
+ : (this.client.account?.address as string)
167
+ const addressInfo = getAddressInfo(accountAddress)
168
+ if (addressInfo.type === AddressType.p2tr) {
169
+ // Taproot (P2TR) addresses require specific PSBT fields for proper signing
170
+
171
+ // tapInternalKey: Required for Taproot key-path spending
172
+ // Most wallets / libraries usually handle this already
173
+ if (!input.tapInternalKey) {
174
+ const pubKey = this.client.account?.publicKey
175
+ if (pubKey) {
176
+ const tapInternalKey = toXOnly(hexToUnit8Array(pubKey))
177
+ psbt.updateInput(index, {
178
+ tapInternalKey,
179
+ })
180
+ }
181
+ }
182
+ // sighashType: Required by bitcoinjs-lib even though the bitcoin protocol allows defaults
183
+ // check if sighashType is default (0) or not set (undefined)
184
+ if (!input.sighashType) {
185
+ psbt.updateInput(index, {
186
+ sighashType: 1, // Default to Transaction.SIGHASH_ALL - 1
187
+ })
188
+ }
189
+ }
190
+ })
191
+
148
192
  const inputsToSign = Array.from(
149
193
  psbt.data.inputs
150
194
  .reduce((map, input, index) => {
@@ -172,7 +216,7 @@ export class UTXOStepExecutor extends BaseStepExecutor {
172
216
  const signedPsbtHex = await withTimeout(
173
217
  () =>
174
218
  signPsbt(this.client, {
175
- psbt: psbtHex,
219
+ psbt: psbt.toHex(),
176
220
  inputsToSign: inputsToSign,
177
221
  finalize: false,
178
222
  }),
@@ -0,0 +1,6 @@
1
+ export async function resolveUTXOAddress(
2
+ name: string
3
+ ): Promise<string | undefined> {
4
+ // Not supported on UTXO yet
5
+ return name
6
+ }
@@ -8,3 +8,7 @@ export function isPsbtFinalized(psbt: Psbt): boolean {
8
8
  return false
9
9
  }
10
10
  }
11
+
12
+ // helper function to convert full public key (33 bytes) to x-only compressed format (32 bytes) required after taproot update
13
+ export const toXOnly = (pubKey: Uint8Array) =>
14
+ pubKey.length === 32 ? pubKey : pubKey.subarray(1, 33)
package/src/core/types.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import type {
2
+ ChainId,
2
3
  ChainType,
4
+ CoinKey,
3
5
  FeeCost,
4
6
  GasCost,
5
7
  LiFiStep,
@@ -14,7 +16,11 @@ import type { Client } from 'viem'
14
16
  export interface SDKProvider {
15
17
  readonly type: ChainType
16
18
  isAddress(address: string): boolean
17
- resolveAddress(name: string): Promise<string | undefined>
19
+ resolveAddress(
20
+ name: string,
21
+ chainId?: ChainId,
22
+ token?: CoinKey
23
+ ): Promise<string | undefined>
18
24
  getStepExecutor(options: StepExecutorOptions): Promise<StepExecutor>
19
25
  getBalance(walletAddress: string, tokens: Token[]): Promise<TokenAmount[]>
20
26
  }
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/sdk'
2
- export const version = '3.8.11'
2
+ export const version = '3.9.0-beta.0'
@@ -1 +0,0 @@
1
- {"version":3,"file":"getENSAddress.js","sourceRoot":"","sources":["../../../core/EVM/getENSAddress.ts"],"names":[],"mappings":";;;AAAA,uCAAqC;AACrC,kCAAmD;AACnD,uDAAmD;AAE5C,MAAM,aAAa,GAAG,KAAK,EAChC,IAAY,EACiB,EAAE;IAC/B,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,IAAA,iCAAe,EAAC,eAAO,CAAC,GAAG,CAAC,CAAA;QACjD,MAAM,OAAO,GAAG,MAAM,IAAA,mBAAa,EAAC,MAAM,EAAE;YAC1C,IAAI,EAAE,IAAA,eAAS,EAAC,IAAI,CAAC;SACtB,CAAC,CAAA;QACF,OAAO,OAA6B,CAAA;IACtC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QAEX,OAAM;IACR,CAAC;AACH,CAAC,CAAA;AAbY,QAAA,aAAa,iBAazB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"getENSAddress.js","sourceRoot":"","sources":["../../../core/EVM/getENSAddress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AACrC,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAChC,IAAY,EACiB,EAAE;IAC/B,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QACjD,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC,MAAM,EAAE;YAC1C,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC;SACtB,CAAC,CAAA;QACF,OAAO,OAA6B,CAAA;IACtC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,SAAS;QACT,OAAM;IACR,CAAC;AACH,CAAC,CAAA"}
@@ -1,2 +0,0 @@
1
- export declare const getENSAddress: (name: string) => Promise<string | undefined>;
2
- //# sourceMappingURL=getENSAddress.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getENSAddress.d.ts","sourceRoot":"","sources":["../../../core/EVM/getENSAddress.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,aAAa,GACxB,MAAM,MAAM,KACX,OAAO,CAAC,MAAM,GAAG,SAAS,CAW5B,CAAA"}