@lifi/sdk 3.8.11 → 3.9.0-beta.1
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/package.json +3 -2
- package/src/_cjs/core/EVM/EVM.js +2 -2
- package/src/_cjs/core/EVM/EVM.js.map +1 -1
- package/src/_cjs/core/EVM/EVMStepExecutor.js +24 -22
- package/src/_cjs/core/EVM/EVMStepExecutor.js.map +1 -1
- package/src/_cjs/core/EVM/publicClient.js +8 -0
- package/src/_cjs/core/EVM/publicClient.js.map +1 -1
- package/src/_cjs/core/EVM/{getENSAddress.js → resolveENSAddress.js} +4 -4
- package/src/_cjs/core/EVM/resolveENSAddress.js.map +1 -0
- package/src/_cjs/core/EVM/resolveEVMAddress.js +11 -0
- package/src/_cjs/core/EVM/resolveEVMAddress.js.map +1 -0
- package/src/_cjs/core/EVM/uns/constants.js +78 -0
- package/src/_cjs/core/EVM/uns/constants.js.map +1 -0
- package/src/_cjs/core/EVM/uns/resolveUNSAddress.js +82 -0
- package/src/_cjs/core/EVM/uns/resolveUNSAddress.js.map +1 -0
- package/src/_cjs/core/Solana/Solana.js +2 -2
- package/src/_cjs/core/Solana/Solana.js.map +1 -1
- package/src/_cjs/core/Solana/resolveSolanaAddress.js +8 -0
- package/src/_cjs/core/Solana/resolveSolanaAddress.js.map +1 -0
- package/src/_cjs/core/Sui/Sui.js +2 -2
- package/src/_cjs/core/Sui/Sui.js.map +1 -1
- package/src/_cjs/core/Sui/resolveSuiAddress.js +8 -0
- package/src/_cjs/core/Sui/resolveSuiAddress.js.map +1 -0
- package/src/_cjs/core/UTXO/UTXO.js +2 -3
- package/src/_cjs/core/UTXO/UTXO.js.map +1 -1
- package/src/_cjs/core/UTXO/UTXOStepExecutor.js +25 -1
- package/src/_cjs/core/UTXO/UTXOStepExecutor.js.map +1 -1
- package/src/_cjs/core/UTXO/resolveUTXOAddress.js +7 -0
- package/src/_cjs/core/UTXO/resolveUTXOAddress.js.map +1 -0
- package/src/_cjs/core/UTXO/utils.js +3 -0
- package/src/_cjs/core/UTXO/utils.js.map +1 -1
- package/src/_cjs/core/prepareRestart.js +1 -1
- package/src/_cjs/core/prepareRestart.js.map +1 -1
- package/src/_cjs/core/waitForDestinationChainTransaction.js +3 -2
- package/src/_cjs/core/waitForDestinationChainTransaction.js.map +1 -1
- package/src/_cjs/index.js.map +1 -1
- package/src/_cjs/version.js +1 -1
- package/src/_cjs/version.js.map +1 -1
- package/src/_esm/core/EVM/EVM.js +2 -2
- package/src/_esm/core/EVM/EVM.js.map +1 -1
- package/src/_esm/core/EVM/EVMStepExecutor.js +28 -24
- package/src/_esm/core/EVM/EVMStepExecutor.js.map +1 -1
- package/src/_esm/core/EVM/publicClient.js +9 -0
- package/src/_esm/core/EVM/publicClient.js.map +1 -1
- package/src/_esm/core/EVM/{getENSAddress.js → resolveENSAddress.js} +2 -2
- package/src/_esm/core/EVM/resolveENSAddress.js.map +1 -0
- package/src/_esm/core/EVM/resolveEVMAddress.js +8 -0
- package/src/_esm/core/EVM/resolveEVMAddress.js.map +1 -0
- package/src/_esm/core/EVM/uns/constants.js +74 -0
- package/src/_esm/core/EVM/uns/constants.js.map +1 -0
- package/src/_esm/core/EVM/uns/resolveUNSAddress.js +80 -0
- package/src/_esm/core/EVM/uns/resolveUNSAddress.js.map +1 -0
- package/src/_esm/core/Solana/Solana.js +2 -2
- package/src/_esm/core/Solana/Solana.js.map +1 -1
- package/src/_esm/core/Solana/resolveSolanaAddress.js +5 -0
- package/src/_esm/core/Solana/resolveSolanaAddress.js.map +1 -0
- package/src/_esm/core/Sui/Sui.js +2 -2
- package/src/_esm/core/Sui/Sui.js.map +1 -1
- package/src/_esm/core/Sui/resolveSuiAddress.js +5 -0
- package/src/_esm/core/Sui/resolveSuiAddress.js.map +1 -0
- package/src/_esm/core/UTXO/UTXO.js +2 -4
- package/src/_esm/core/UTXO/UTXO.js.map +1 -1
- package/src/_esm/core/UTXO/UTXOStepExecutor.js +35 -4
- package/src/_esm/core/UTXO/UTXOStepExecutor.js.map +1 -1
- package/src/_esm/core/UTXO/resolveUTXOAddress.js +5 -0
- package/src/_esm/core/UTXO/resolveUTXOAddress.js.map +1 -0
- package/src/_esm/core/UTXO/utils.js +2 -0
- package/src/_esm/core/UTXO/utils.js.map +1 -1
- package/src/_esm/core/prepareRestart.js +1 -1
- package/src/_esm/core/prepareRestart.js.map +1 -1
- package/src/_esm/core/waitForDestinationChainTransaction.js +5 -2
- package/src/_esm/core/waitForDestinationChainTransaction.js.map +1 -1
- package/src/_esm/index.js.map +1 -1
- package/src/_esm/version.js +1 -1
- package/src/_esm/version.js.map +1 -1
- package/src/_types/core/EVM/EVMStepExecutor.d.ts +3 -5
- package/src/_types/core/EVM/EVMStepExecutor.d.ts.map +1 -1
- package/src/_types/core/EVM/publicClient.d.ts.map +1 -1
- package/src/_types/core/EVM/resolveENSAddress.d.ts +2 -0
- package/src/_types/core/EVM/resolveENSAddress.d.ts.map +1 -0
- package/src/_types/core/EVM/resolveEVMAddress.d.ts +3 -0
- package/src/_types/core/EVM/resolveEVMAddress.d.ts.map +1 -0
- package/src/_types/core/EVM/uns/constants.d.ts +51 -0
- package/src/_types/core/EVM/uns/constants.d.ts.map +1 -0
- package/src/_types/core/EVM/uns/resolveUNSAddress.d.ts +3 -0
- package/src/_types/core/EVM/uns/resolveUNSAddress.d.ts.map +1 -0
- package/src/_types/core/Solana/resolveSolanaAddress.d.ts +2 -0
- package/src/_types/core/Solana/resolveSolanaAddress.d.ts.map +1 -0
- package/src/_types/core/Sui/resolveSuiAddress.d.ts +2 -0
- package/src/_types/core/Sui/resolveSuiAddress.d.ts.map +1 -0
- package/src/_types/core/UTXO/UTXO.d.ts.map +1 -1
- package/src/_types/core/UTXO/UTXOStepExecutor.d.ts.map +1 -1
- package/src/_types/core/UTXO/resolveUTXOAddress.d.ts +2 -0
- package/src/_types/core/UTXO/resolveUTXOAddress.d.ts.map +1 -0
- package/src/_types/core/UTXO/utils.d.ts +1 -0
- package/src/_types/core/UTXO/utils.d.ts.map +1 -1
- package/src/_types/core/prepareRestart.d.ts.map +1 -1
- package/src/_types/core/types.d.ts +4 -3
- package/src/_types/core/types.d.ts.map +1 -1
- package/src/_types/core/waitForDestinationChainTransaction.d.ts.map +1 -1
- package/src/_types/index.d.ts +1 -1
- package/src/_types/index.d.ts.map +1 -1
- package/src/_types/version.d.ts +1 -1
- package/src/_types/version.d.ts.map +1 -1
- package/src/core/EVM/EVM.ts +2 -2
- package/src/core/EVM/EVMStepExecutor.ts +35 -37
- package/src/core/EVM/publicClient.ts +13 -1
- package/src/core/EVM/{getENSAddress.ts → resolveENSAddress.ts} +1 -1
- package/src/core/EVM/resolveEVMAddress.ts +15 -0
- package/src/core/EVM/uns/constants.ts +81 -0
- package/src/core/EVM/uns/resolveUNSAddress.ts +123 -0
- package/src/core/Solana/Solana.ts +2 -2
- package/src/core/Solana/resolveSolanaAddress.ts +7 -0
- package/src/core/Sui/Sui.ts +2 -2
- package/src/core/Sui/resolveSuiAddress.ts +7 -0
- package/src/core/UTXO/UTXO.ts +2 -4
- package/src/core/UTXO/UTXOStepExecutor.ts +48 -4
- package/src/core/UTXO/resolveUTXOAddress.ts +6 -0
- package/src/core/UTXO/utils.ts +4 -0
- package/src/core/prepareRestart.ts +2 -1
- package/src/core/types.ts +9 -2
- package/src/core/waitForDestinationChainTransaction.ts +6 -2
- package/src/index.ts +5 -1
- package/src/version.ts +1 -1
- package/src/_cjs/core/EVM/getENSAddress.js.map +0 -1
- package/src/_esm/core/EVM/getENSAddress.js.map +0 -1
- package/src/_types/core/EVM/getENSAddress.d.ts +0 -2
- package/src/_types/core/EVM/getENSAddress.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../core/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,OAAO,EACP,OAAO,EACP,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,SAAS,E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B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,KAAK,CAAA;IACf,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAA;CACrB;AAED,MAAM,MAAM,qBAAqB,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"waitForDestinationChainTransaction.d.ts","sourceRoot":"","sources":["../../core/waitForDestinationChainTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EAGd,MAAM,aAAa,CAAA;AAGpB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAG3D,wBAAsB,kCAAkC,CACtD,IAAI,EAAE,gBAAgB,EACtB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,aAAa,EACxB,OAAO,EAAE,aAAa,EACtB,aAAa,EAAE,aAAa,EAC5B,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,gBAAgB,CAAC,
|
|
1
|
+
{"version":3,"file":"waitForDestinationChainTransaction.d.ts","sourceRoot":"","sources":["../../core/waitForDestinationChainTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EAGd,MAAM,aAAa,CAAA;AAGpB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAG3D,wBAAsB,kCAAkC,CACtD,IAAI,EAAE,gBAAgB,EACtB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,aAAa,EACxB,OAAO,EAAE,aAAa,EACtB,aAAa,EAAE,aAAa,EAC5B,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,gBAAgB,CAAC,CAkF3B"}
|
package/src/_types/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export { isBatchingSupported } from './core/EVM/isBatchingSupported.js';
|
|
|
7
7
|
export { getNativePermit } from './core/EVM/permits/getNativePermit.js';
|
|
8
8
|
export { revokeTokenApproval, setTokenAllowance, } from './core/EVM/setAllowance.js';
|
|
9
9
|
export { isGaslessStep, isRelayerStep, } from './core/EVM/typeguards.js';
|
|
10
|
-
export type { EVMProvider, EVMProviderOptions } from './core/EVM/types.js';
|
|
10
|
+
export type { EVMProvider, EVMProviderOptions, WalletCallReceipt, } from './core/EVM/types.js';
|
|
11
11
|
export { isEVM } from './core/EVM/types.js';
|
|
12
12
|
export { convertExtendedChain, isExtendedChain, } from './core/EVM/utils.js';
|
|
13
13
|
export { executeRoute, getActiveRoute, getActiveRoutes, resumeRoute, stopRouteExecution, updateRouteExecution, } from './core/execution.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAEA,cAAc,aAAa,CAAA;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAA;AACrE,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AACvC,OAAO,EACL,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAA;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAA;AACvE,OAAO,EACL,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EACL,aAAa,EACb,aAAa,GACd,MAAM,0BAA0B,CAAA;AACjC,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAEA,cAAc,aAAa,CAAA;AAC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mB,CAAA;AAC1B,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,uBAAuB,GACxB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAA;AAC3E,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAA"}
|
package/src/_types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI,cAAc,CAAA;AAC/B,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI,cAAc,CAAA;AAC/B,eAAO,MAAM,OAAO,iBAAiB,CAAA"}
|
package/src/core/EVM/EVM.ts
CHANGED
|
@@ -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:
|
|
19
|
+
resolveAddress: resolveEVMAddress,
|
|
20
20
|
getBalance: getEVMBalance,
|
|
21
21
|
getWalletClient: _options.getWalletClient,
|
|
22
22
|
async getStepExecutor(
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
sendTransaction,
|
|
16
16
|
signTypedData,
|
|
17
17
|
} from 'viem/actions'
|
|
18
|
-
import { getAction } from 'viem/utils'
|
|
18
|
+
import { getAction, isHex } from 'viem/utils'
|
|
19
19
|
import { config } from '../../config.js'
|
|
20
20
|
import { LiFiErrorCode } from '../../errors/constants.js'
|
|
21
21
|
import { TransactionError } from '../../errors/errors.js'
|
|
@@ -126,30 +126,26 @@ export class EVMStepExecutor extends BaseStepExecutor {
|
|
|
126
126
|
process,
|
|
127
127
|
fromChain,
|
|
128
128
|
toChain,
|
|
129
|
-
txType,
|
|
130
|
-
txHash,
|
|
131
129
|
isBridgeExecution,
|
|
132
130
|
}: {
|
|
133
131
|
step: LiFiStepExtended
|
|
134
132
|
process: Process
|
|
135
133
|
fromChain: ExtendedChain
|
|
136
134
|
toChain: ExtendedChain
|
|
137
|
-
txType: TransactionMethodType
|
|
138
|
-
txHash: Hash
|
|
139
135
|
isBridgeExecution: boolean
|
|
140
136
|
}) => {
|
|
141
137
|
let transactionReceipt: TransactionReceipt | WalletCallReceipt | undefined
|
|
142
138
|
|
|
143
|
-
switch (txType) {
|
|
139
|
+
switch (process.txType) {
|
|
144
140
|
case 'batched':
|
|
145
141
|
transactionReceipt = await waitForBatchTransactionReceipt(
|
|
146
142
|
this.client,
|
|
147
|
-
|
|
143
|
+
process.taskId as Hash
|
|
148
144
|
)
|
|
149
145
|
break
|
|
150
146
|
case 'relayed':
|
|
151
147
|
transactionReceipt = await waitForRelayedTransactionReceipt(
|
|
152
|
-
|
|
148
|
+
process.taskId as Hash,
|
|
153
149
|
step
|
|
154
150
|
)
|
|
155
151
|
break
|
|
@@ -157,7 +153,7 @@ export class EVMStepExecutor extends BaseStepExecutor {
|
|
|
157
153
|
transactionReceipt = await waitForTransactionReceipt({
|
|
158
154
|
client: this.client,
|
|
159
155
|
chainId: fromChain.id,
|
|
160
|
-
txHash,
|
|
156
|
+
txHash: process.txHash as Hash,
|
|
161
157
|
onReplaced: (response) => {
|
|
162
158
|
this.statusManager.updateProcess(step, process.type, 'PENDING', {
|
|
163
159
|
txHash: response.transaction.hash,
|
|
@@ -171,17 +167,24 @@ export class EVMStepExecutor extends BaseStepExecutor {
|
|
|
171
167
|
// This might happen if the transaction was replaced.
|
|
172
168
|
if (
|
|
173
169
|
transactionReceipt?.transactionHash &&
|
|
174
|
-
transactionReceipt.transactionHash !== txHash
|
|
170
|
+
transactionReceipt.transactionHash !== process.txHash
|
|
175
171
|
) {
|
|
172
|
+
// Validate if transaction hash is a valid hex string that can be used on-chain
|
|
173
|
+
// Some custom integrations may return non-hex identifiers to support custom status tracking
|
|
174
|
+
const txHash = isHex(transactionReceipt.transactionHash, { strict: true })
|
|
175
|
+
? transactionReceipt.transactionHash
|
|
176
|
+
: undefined
|
|
176
177
|
process = this.statusManager.updateProcess(
|
|
177
178
|
step,
|
|
178
179
|
process.type,
|
|
179
180
|
'PENDING',
|
|
180
181
|
{
|
|
181
|
-
txHash:
|
|
182
|
+
txHash: txHash,
|
|
182
183
|
txLink:
|
|
183
184
|
(transactionReceipt as WalletCallReceipt).transactionLink ||
|
|
184
|
-
|
|
185
|
+
(txHash
|
|
186
|
+
? `${fromChain.metamask.blockExplorerUrls[0]}tx/${txHash}`
|
|
187
|
+
: undefined),
|
|
185
188
|
}
|
|
186
189
|
)
|
|
187
190
|
}
|
|
@@ -307,6 +310,8 @@ export class EVMStepExecutor extends BaseStepExecutor {
|
|
|
307
310
|
const checkForAllowance =
|
|
308
311
|
// No existing swap/bridge transaction is pending
|
|
309
312
|
!existingProcess?.txHash &&
|
|
313
|
+
// No existing swap/bridge batch/order is pending
|
|
314
|
+
!existingProcess?.taskId &&
|
|
310
315
|
// Token is not native (address is not zero)
|
|
311
316
|
!isFromNativeToken &&
|
|
312
317
|
// Approval address is required for allowance checks, but may be null in special cases (e.g. direct transfers)
|
|
@@ -346,38 +351,31 @@ export class EVMStepExecutor extends BaseStepExecutor {
|
|
|
346
351
|
}
|
|
347
352
|
|
|
348
353
|
let process = this.statusManager.findProcess(step, currentProcessType)
|
|
354
|
+
try {
|
|
355
|
+
if (process?.status === 'DONE') {
|
|
356
|
+
await waitForDestinationChainTransaction(
|
|
357
|
+
step,
|
|
358
|
+
process,
|
|
359
|
+
fromChain,
|
|
360
|
+
toChain,
|
|
361
|
+
this.statusManager
|
|
362
|
+
)
|
|
349
363
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
step,
|
|
353
|
-
process,
|
|
354
|
-
fromChain,
|
|
355
|
-
toChain,
|
|
356
|
-
this.statusManager
|
|
357
|
-
)
|
|
358
|
-
|
|
359
|
-
return step
|
|
360
|
-
}
|
|
364
|
+
return step
|
|
365
|
+
}
|
|
361
366
|
|
|
362
|
-
|
|
363
|
-
if (process?.txHash) {
|
|
367
|
+
if (process?.txHash || process?.taskId) {
|
|
364
368
|
// Make sure that the chain is still correct
|
|
365
369
|
const updatedClient = await this.checkClient(step, process)
|
|
366
370
|
if (!updatedClient) {
|
|
367
371
|
return step
|
|
368
372
|
}
|
|
369
373
|
|
|
370
|
-
// Wait for exiting transaction
|
|
371
|
-
const txHash = process.txHash as Hash
|
|
372
|
-
const txType = process.txType as TransactionMethodType
|
|
373
|
-
|
|
374
374
|
await this.waitForTransaction({
|
|
375
375
|
step,
|
|
376
376
|
process,
|
|
377
377
|
fromChain,
|
|
378
378
|
toChain,
|
|
379
|
-
txType,
|
|
380
|
-
txHash,
|
|
381
379
|
isBridgeExecution,
|
|
382
380
|
})
|
|
383
381
|
|
|
@@ -488,7 +486,8 @@ export class EVMStepExecutor extends BaseStepExecutor {
|
|
|
488
486
|
return step
|
|
489
487
|
}
|
|
490
488
|
|
|
491
|
-
let txHash: Hash
|
|
489
|
+
let txHash: Hash | undefined
|
|
490
|
+
let taskId: Hash | undefined
|
|
492
491
|
let txType: TransactionMethodType = 'standard'
|
|
493
492
|
let txLink: string | undefined
|
|
494
493
|
|
|
@@ -510,7 +509,7 @@ export class EVMStepExecutor extends BaseStepExecutor {
|
|
|
510
509
|
account: this.client.account!,
|
|
511
510
|
calls,
|
|
512
511
|
})
|
|
513
|
-
|
|
512
|
+
taskId = id as Hash
|
|
514
513
|
txType = 'batched'
|
|
515
514
|
} else if (isRelayerTransaction) {
|
|
516
515
|
const relayerTypedData = step.typedData?.find(
|
|
@@ -561,7 +560,7 @@ export class EVMStepExecutor extends BaseStepExecutor {
|
|
|
561
560
|
...stepBase,
|
|
562
561
|
typedData: signedTypedData,
|
|
563
562
|
})
|
|
564
|
-
|
|
563
|
+
taskId = relayedTransaction.taskId as Hash
|
|
565
564
|
txType = 'relayed'
|
|
566
565
|
txLink = relayedTransaction.txLink
|
|
567
566
|
} else {
|
|
@@ -663,9 +662,10 @@ export class EVMStepExecutor extends BaseStepExecutor {
|
|
|
663
662
|
// When atomic batch or relayer are supported, txHash represents the batch hash or taskId rather than an individual transaction hash
|
|
664
663
|
{
|
|
665
664
|
txHash,
|
|
665
|
+
taskId,
|
|
666
666
|
txType,
|
|
667
667
|
txLink:
|
|
668
|
-
txType === 'standard'
|
|
668
|
+
txType === 'standard' && txHash
|
|
669
669
|
? `${fromChain.metamask.blockExplorerUrls[0]}tx/${txHash}`
|
|
670
670
|
: txLink,
|
|
671
671
|
}
|
|
@@ -676,8 +676,6 @@ export class EVMStepExecutor extends BaseStepExecutor {
|
|
|
676
676
|
process,
|
|
677
677
|
fromChain,
|
|
678
678
|
toChain,
|
|
679
|
-
txHash,
|
|
680
|
-
txType,
|
|
681
679
|
isBridgeExecution,
|
|
682
680
|
})
|
|
683
681
|
|
|
@@ -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
|
|
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:
|
|
16
|
+
resolveAddress: resolveSolanaAddress,
|
|
17
17
|
getBalance: getSolanaBalance,
|
|
18
18
|
async getStepExecutor(
|
|
19
19
|
options: StepExecutorOptions
|
package/src/core/Sui/Sui.ts
CHANGED
|
@@ -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 {
|
|
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:
|
|
16
|
+
resolveAddress: resolveSuiAddress,
|
|
17
17
|
getBalance: getSuiBalance,
|
|
18
18
|
async getStepExecutor(
|
|
19
19
|
options: StepExecutorOptions
|
package/src/core/UTXO/UTXO.ts
CHANGED
|
@@ -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
|
-
|
|
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
|