thirdweb 5.93.9 → 5.93.11
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/cjs/contract/deployment/utils/create-2-factory.js +0 -4
- package/dist/cjs/contract/deployment/utils/create-2-factory.js.map +1 -1
- package/dist/cjs/pay/buyWithCrypto/getQuote.js +0 -2
- package/dist/cjs/pay/buyWithCrypto/getQuote.js.map +1 -1
- package/dist/cjs/pay/buyWithCrypto/getTransfer.js +0 -1
- package/dist/cjs/pay/buyWithCrypto/getTransfer.js.map +1 -1
- package/dist/cjs/react/core/hooks/contract/useWaitForReceipt.js +1 -1
- package/dist/cjs/react/core/hooks/contract/useWaitForReceipt.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js +4 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.js +0 -8
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.js +38 -13
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/WalletTransactionHistory.js +36 -15
- package/dist/cjs/react/web/ui/ConnectWallet/screens/WalletTransactionHistory.js.map +1 -1
- package/dist/cjs/transaction/transaction-store.js +25 -0
- package/dist/cjs/transaction/transaction-store.js.map +1 -1
- package/dist/cjs/utils/domains.js +3 -0
- package/dist/cjs/utils/domains.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/cjs/wallets/smart/lib/userop.js +12 -0
- package/dist/cjs/wallets/smart/lib/userop.js.map +1 -1
- package/dist/esm/contract/deployment/utils/create-2-factory.js +0 -4
- package/dist/esm/contract/deployment/utils/create-2-factory.js.map +1 -1
- package/dist/esm/pay/buyWithCrypto/getQuote.js +0 -2
- package/dist/esm/pay/buyWithCrypto/getQuote.js.map +1 -1
- package/dist/esm/pay/buyWithCrypto/getTransfer.js +0 -1
- package/dist/esm/pay/buyWithCrypto/getTransfer.js.map +1 -1
- package/dist/esm/react/core/hooks/contract/useWaitForReceipt.js +1 -1
- package/dist/esm/react/core/hooks/contract/useWaitForReceipt.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js +4 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.js +0 -8
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.js +39 -14
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/WalletTransactionHistory.js +37 -16
- package/dist/esm/react/web/ui/ConnectWallet/screens/WalletTransactionHistory.js.map +1 -1
- package/dist/esm/transaction/transaction-store.js +24 -0
- package/dist/esm/transaction/transaction-store.js.map +1 -1
- package/dist/esm/utils/domains.js +3 -0
- package/dist/esm/utils/domains.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/esm/wallets/smart/lib/userop.js +12 -0
- package/dist/esm/wallets/smart/lib/userop.js.map +1 -1
- package/dist/types/pay/buyWithCrypto/getQuote.d.ts.map +1 -1
- package/dist/types/pay/buyWithCrypto/getTransfer.d.ts.map +1 -1
- package/dist/types/react/core/hooks/contract/useWaitForReceipt.d.ts +5 -1
- package/dist/types/react/core/hooks/contract/useWaitForReceipt.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/WalletTransactionHistory.d.ts.map +1 -1
- package/dist/types/transaction/transaction-store.d.ts +14 -0
- package/dist/types/transaction/transaction-store.d.ts.map +1 -1
- package/dist/types/utils/domains.d.ts +6 -0
- package/dist/types/utils/domains.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/dist/types/wallets/smart/lib/userop.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/bridge/Buy.test.ts +1 -1
- package/src/bridge/Sell.test.ts +1 -1
- package/src/contract/deployment/utils/create-2-factory.ts +0 -4
- package/src/pay/buyWithCrypto/getQuote.ts +0 -2
- package/src/pay/buyWithCrypto/getTransfer.ts +0 -1
- package/src/react/core/hooks/contract/useWaitForReceipt.ts +5 -2
- package/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx +1 -1
- package/src/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.tsx +4 -1
- package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.tsx +0 -29
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.tsx +52 -13
- package/src/react/web/ui/ConnectWallet/screens/WalletTransactionHistory.tsx +51 -17
- package/src/transaction/transaction-store.ts +50 -0
- package/src/utils/domain.test.ts +1 -0
- package/src/utils/domains.ts +8 -1
- package/src/version.ts +1 -1
- package/src/wallets/smart/lib/userop.ts +18 -0
- package/src/wallets/smart/smart-wallet-integration-v07.test.ts +21 -0
@@ -1,4 +1,5 @@
|
|
1
1
|
import { CheckCircledIcon } from "@radix-ui/react-icons";
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
2
3
|
import { useState } from "react";
|
3
4
|
import type { Chain } from "../../../../../../../chains/types.js";
|
4
5
|
import { getCachedChain } from "../../../../../../../chains/utils.js";
|
@@ -78,6 +79,48 @@ export function TransferConfirmationScreen(
|
|
78
79
|
| { id: "done" }
|
79
80
|
>({ id: "idle" });
|
80
81
|
|
82
|
+
const transferQuery = useQuery({
|
83
|
+
queryKey: [
|
84
|
+
"transfer",
|
85
|
+
isNativeToken(token) ? NATIVE_TOKEN_ADDRESS : token.address,
|
86
|
+
tokenAmount,
|
87
|
+
receiverAddress,
|
88
|
+
payer.account.address,
|
89
|
+
payOptions?.purchaseData,
|
90
|
+
],
|
91
|
+
queryFn: async () => {
|
92
|
+
const transferResponse = await getBuyWithCryptoTransfer({
|
93
|
+
client,
|
94
|
+
fromAddress: payer.account.address,
|
95
|
+
toAddress: receiverAddress,
|
96
|
+
chainId: chain.id,
|
97
|
+
tokenAddress: isNativeToken(token)
|
98
|
+
? NATIVE_TOKEN_ADDRESS
|
99
|
+
: token.address,
|
100
|
+
amount: tokenAmount,
|
101
|
+
purchaseData: payOptions?.purchaseData,
|
102
|
+
});
|
103
|
+
return transferResponse;
|
104
|
+
},
|
105
|
+
refetchInterval: 30 * 1000,
|
106
|
+
});
|
107
|
+
|
108
|
+
if (transferQuery.isLoading) {
|
109
|
+
return (
|
110
|
+
<Container p="lg">
|
111
|
+
<ModalHeader title={title} onBack={onBack} />
|
112
|
+
<Container flex="column" center="both" style={{ minHeight: "300px" }}>
|
113
|
+
<Spacer y="xl" />
|
114
|
+
<Spinner size="xl" color="secondaryText" />
|
115
|
+
<Spacer y="xl" />
|
116
|
+
</Container>
|
117
|
+
</Container>
|
118
|
+
);
|
119
|
+
}
|
120
|
+
|
121
|
+
const transferFromAmountWithFees =
|
122
|
+
transferQuery.data?.paymentToken.amount || tokenAmount;
|
123
|
+
|
81
124
|
return (
|
82
125
|
<Container p="lg">
|
83
126
|
<ModalHeader title={title} onBack={onBack} />
|
@@ -109,7 +152,7 @@ export function TransferConfirmationScreen(
|
|
109
152
|
fromChain={chain}
|
110
153
|
toToken={token}
|
111
154
|
toChain={chain}
|
112
|
-
fromAmount={tokenAmount}
|
155
|
+
fromAmount={transactionMode ? tokenAmount : transferFromAmountWithFees}
|
113
156
|
toAmount={tokenAmount}
|
114
157
|
/>
|
115
158
|
|
@@ -230,7 +273,9 @@ export function TransferConfirmationScreen(
|
|
230
273
|
token,
|
231
274
|
chain,
|
232
275
|
tokenMetadata,
|
233
|
-
tokenAmount
|
276
|
+
tokenAmount: transactionMode
|
277
|
+
? tokenAmount
|
278
|
+
: transferFromAmountWithFees,
|
234
279
|
fromAddress: payer.account.address,
|
235
280
|
toAddress: receiverAddress,
|
236
281
|
transaction: txResult,
|
@@ -240,17 +285,11 @@ export function TransferConfirmationScreen(
|
|
240
285
|
setStep("execute");
|
241
286
|
setStatus({ id: "idle" });
|
242
287
|
} else {
|
243
|
-
const transferResponse =
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
tokenAddress: isNativeToken(token)
|
249
|
-
? NATIVE_TOKEN_ADDRESS
|
250
|
-
: token.address,
|
251
|
-
amount: tokenAmount,
|
252
|
-
purchaseData: payOptions?.purchaseData,
|
253
|
-
});
|
288
|
+
const transferResponse = transferQuery.data;
|
289
|
+
|
290
|
+
if (!transferResponse) {
|
291
|
+
throw new Error("Transfer data not found");
|
292
|
+
}
|
254
293
|
|
255
294
|
if (transferResponse.approvalData) {
|
256
295
|
// check allowance
|
@@ -1,12 +1,17 @@
|
|
1
1
|
"use client";
|
2
2
|
import styled from "@emotion/styled";
|
3
3
|
import { CheckIcon, CrossCircledIcon } from "@radix-ui/react-icons";
|
4
|
+
import { useQuery } from "@tanstack/react-query";
|
4
5
|
import { useSyncExternalStore } from "react";
|
6
|
+
import { ethereum } from "../../../../../chains/chain-definitions/ethereum.js";
|
5
7
|
import { getCachedChain } from "../../../../../chains/utils.js";
|
6
8
|
import type { ThirdwebClient } from "../../../../../client/client.js";
|
7
|
-
import {
|
9
|
+
import {
|
10
|
+
type StoredTransaction,
|
11
|
+
getPastTransactions,
|
12
|
+
getTransactionStore,
|
13
|
+
} from "../../../../../transaction/transaction-store.js";
|
8
14
|
import { shortenHex } from "../../../../../utils/address.js";
|
9
|
-
import type { Hex } from "../../../../../utils/encoding/hex.js";
|
10
15
|
import { formatExplorerTxUrl } from "../../../../../utils/url.js";
|
11
16
|
import { useCustomTheme } from "../../../../core/design-system/CustomThemeProvider.js";
|
12
17
|
import { iconSize, spacing } from "../../../../core/design-system/index.js";
|
@@ -38,8 +43,20 @@ export function WalletTransactionHistory(props: {
|
|
38
43
|
transactionStore.subscribe,
|
39
44
|
transactionStore.getValue,
|
40
45
|
);
|
41
|
-
const
|
42
|
-
|
46
|
+
const historicalTxQuery = useQuery({
|
47
|
+
queryKey: ["transactions", props.address, activeChain],
|
48
|
+
queryFn: () =>
|
49
|
+
getPastTransactions({
|
50
|
+
walletAddress: props.address,
|
51
|
+
chain: activeChain || ethereum,
|
52
|
+
client: props.client,
|
53
|
+
}),
|
54
|
+
enabled: !!activeChain,
|
55
|
+
});
|
56
|
+
const transactions = [
|
57
|
+
...[...reverseChronologicalTransactions].reverse(),
|
58
|
+
...(historicalTxQuery.data || []),
|
59
|
+
];
|
43
60
|
return (
|
44
61
|
<Container
|
45
62
|
scrollY
|
@@ -52,7 +69,22 @@ export function WalletTransactionHistory(props: {
|
|
52
69
|
}}
|
53
70
|
>
|
54
71
|
<Container flex="column" gap="xs" expand>
|
55
|
-
{
|
72
|
+
{historicalTxQuery.isLoading && (
|
73
|
+
<Container
|
74
|
+
flex="column"
|
75
|
+
gap="md"
|
76
|
+
center="both"
|
77
|
+
color="secondaryText"
|
78
|
+
style={{
|
79
|
+
flex: "1",
|
80
|
+
minHeight: "250px",
|
81
|
+
}}
|
82
|
+
>
|
83
|
+
<Spinner color={"secondaryText"} size={"md"} />
|
84
|
+
<Text>Loading recent transactions...</Text>
|
85
|
+
</Container>
|
86
|
+
)}
|
87
|
+
{!historicalTxQuery.isLoading && transactions.length === 0 ? (
|
56
88
|
<Container
|
57
89
|
flex="column"
|
58
90
|
gap="md"
|
@@ -79,8 +111,7 @@ export function WalletTransactionHistory(props: {
|
|
79
111
|
key={tx.transactionHash}
|
80
112
|
explorerUrl={chainExplorers.explorers[0]?.url}
|
81
113
|
client={props.client}
|
82
|
-
|
83
|
-
chainId={tx.chainId}
|
114
|
+
tx={tx}
|
84
115
|
/>
|
85
116
|
);
|
86
117
|
})}
|
@@ -92,21 +123,24 @@ export function WalletTransactionHistory(props: {
|
|
92
123
|
}
|
93
124
|
|
94
125
|
function TransactionButton(props: {
|
95
|
-
|
126
|
+
tx: StoredTransaction;
|
96
127
|
client: ThirdwebClient;
|
97
|
-
chainId: number;
|
98
128
|
explorerUrl?: string;
|
99
129
|
}) {
|
100
130
|
const {
|
101
|
-
data:
|
131
|
+
data: fetchedReceipt,
|
102
132
|
isLoading,
|
103
133
|
error,
|
104
134
|
} = useWaitForReceipt({
|
105
|
-
transactionHash: props.
|
106
|
-
chain: getCachedChain(props.chainId),
|
135
|
+
transactionHash: props.tx.transactionHash,
|
136
|
+
chain: getCachedChain(props.tx.chainId),
|
107
137
|
client: props.client,
|
138
|
+
queryOptions: {
|
139
|
+
enabled: props.tx.receipt === undefined,
|
140
|
+
},
|
108
141
|
});
|
109
|
-
const chainIconQuery = useChainIconUrl(getCachedChain(props.chainId));
|
142
|
+
const chainIconQuery = useChainIconUrl(getCachedChain(props.tx.chainId));
|
143
|
+
const receipt = props.tx.receipt ?? fetchedReceipt;
|
110
144
|
|
111
145
|
const content = (
|
112
146
|
<TxButton
|
@@ -148,8 +182,8 @@ function TransactionButton(props: {
|
|
148
182
|
>
|
149
183
|
<Text size="sm" color="primaryText">
|
150
184
|
{receipt?.to
|
151
|
-
? `Interacted with ${shortenHex(receipt
|
152
|
-
: `Hash: ${shortenHex(props.
|
185
|
+
? `Interacted with ${shortenHex(receipt?.to, 4)}`
|
186
|
+
: `Hash: ${shortenHex(props.tx.transactionHash, 4)}`}
|
153
187
|
</Text>
|
154
188
|
</Container>
|
155
189
|
|
@@ -165,7 +199,7 @@ function TransactionButton(props: {
|
|
165
199
|
}}
|
166
200
|
>
|
167
201
|
<ChainName
|
168
|
-
chain={getCachedChain(props.chainId)}
|
202
|
+
chain={getCachedChain(props.tx.chainId)}
|
169
203
|
size="xs"
|
170
204
|
client={props.client}
|
171
205
|
/>
|
@@ -193,7 +227,7 @@ function TransactionButton(props: {
|
|
193
227
|
if (props.explorerUrl) {
|
194
228
|
return (
|
195
229
|
<a
|
196
|
-
href={formatExplorerTxUrl(props.explorerUrl, props.
|
230
|
+
href={formatExplorerTxUrl(props.explorerUrl, props.tx.transactionHash)}
|
197
231
|
target="_blank"
|
198
232
|
rel="noreferrer"
|
199
233
|
>
|
@@ -1,9 +1,17 @@
|
|
1
|
+
import type { Chain } from "../chains/types.js";
|
2
|
+
import type { ThirdwebClient } from "../client/client.js";
|
1
3
|
import { type Store, createStore } from "../reactive/store.js";
|
4
|
+
import { getThirdwebDomains } from "../utils/domains.js";
|
2
5
|
import type { Hex } from "../utils/encoding/hex.js";
|
6
|
+
import { getClientFetch } from "../utils/fetch.js";
|
3
7
|
|
4
8
|
export type StoredTransaction = {
|
5
9
|
transactionHash: Hex;
|
6
10
|
chainId: number;
|
11
|
+
receipt?: {
|
12
|
+
status: "success" | "failed";
|
13
|
+
to: string;
|
14
|
+
};
|
7
15
|
};
|
8
16
|
|
9
17
|
const transactionsByAddress = new Map<string, Store<StoredTransaction[]>>();
|
@@ -33,6 +41,7 @@ export function getTransactionStore(
|
|
33
41
|
|
34
42
|
const newStore = createStore<StoredTransaction[]>([]);
|
35
43
|
transactionsByAddress.set(address, newStore);
|
44
|
+
|
36
45
|
return newStore;
|
37
46
|
}
|
38
47
|
|
@@ -54,3 +63,44 @@ export function addTransactionToStore(options: {
|
|
54
63
|
|
55
64
|
transactionsByAddress.set(address, tranasctionStore);
|
56
65
|
}
|
66
|
+
|
67
|
+
/**
|
68
|
+
* @internal for now
|
69
|
+
*/
|
70
|
+
export async function getPastTransactions(options: {
|
71
|
+
walletAddress: string;
|
72
|
+
chain: Chain;
|
73
|
+
client: ThirdwebClient;
|
74
|
+
}): Promise<StoredTransaction[]> {
|
75
|
+
const { walletAddress, chain, client } = options;
|
76
|
+
const oneMonthsAgoInSeconds = Math.floor(
|
77
|
+
(Date.now() - 1 * 30 * 24 * 60 * 60 * 1000) / 1000,
|
78
|
+
);
|
79
|
+
const url = new URL(
|
80
|
+
`https://${getThirdwebDomains().insight}/v1/wallets/${walletAddress}/transactions`,
|
81
|
+
);
|
82
|
+
url.searchParams.set("limit", "10");
|
83
|
+
url.searchParams.set("chain", chain.id.toString());
|
84
|
+
url.searchParams.set(
|
85
|
+
"filter_block_timestamp_gte",
|
86
|
+
oneMonthsAgoInSeconds.toString(),
|
87
|
+
);
|
88
|
+
const clientFetch = getClientFetch(client);
|
89
|
+
const result = await clientFetch(url.toString());
|
90
|
+
const json = (await result.json()) as {
|
91
|
+
data: {
|
92
|
+
chain_id: number;
|
93
|
+
hash: string;
|
94
|
+
status: number;
|
95
|
+
to_address: string;
|
96
|
+
}[];
|
97
|
+
};
|
98
|
+
return json.data.map((tx) => ({
|
99
|
+
transactionHash: tx.hash as Hex,
|
100
|
+
chainId: tx.chain_id,
|
101
|
+
receipt: {
|
102
|
+
status: tx.status === 1 ? "success" : "failed",
|
103
|
+
to: tx.to_address,
|
104
|
+
},
|
105
|
+
}));
|
106
|
+
}
|
package/src/utils/domain.test.ts
CHANGED
package/src/utils/domains.ts
CHANGED
@@ -34,6 +34,11 @@ type DomainOverrides = {
|
|
34
34
|
* @default "c.thirdweb.com"
|
35
35
|
*/
|
36
36
|
analytics?: string;
|
37
|
+
/**
|
38
|
+
* The base URL for the insight server.
|
39
|
+
* @default "insight.thirdweb.com"
|
40
|
+
*/
|
41
|
+
insight?: string;
|
37
42
|
};
|
38
43
|
|
39
44
|
export const DEFAULT_RPC_URL = "rpc.thirdweb.com";
|
@@ -43,7 +48,7 @@ const DEFAULT_PAY_URL = "pay.thirdweb.com";
|
|
43
48
|
const DEFAULT_STORAGE_URL = "storage.thirdweb.com";
|
44
49
|
const DEFAULT_BUNDLER_URL = "bundler.thirdweb.com";
|
45
50
|
const DEFAULT_ANALYTICS_URL = "c.thirdweb.com";
|
46
|
-
|
51
|
+
const DEFAULT_INSIGHT_URL = "insight.thirdweb.com";
|
47
52
|
let domains: { [k in keyof DomainOverrides]-?: string } = {
|
48
53
|
rpc: DEFAULT_RPC_URL,
|
49
54
|
inAppWallet: DEFAULT_IN_APP_WALLET_URL,
|
@@ -52,6 +57,7 @@ let domains: { [k in keyof DomainOverrides]-?: string } = {
|
|
52
57
|
storage: DEFAULT_STORAGE_URL,
|
53
58
|
bundler: DEFAULT_BUNDLER_URL,
|
54
59
|
analytics: DEFAULT_ANALYTICS_URL,
|
60
|
+
insight: DEFAULT_INSIGHT_URL,
|
55
61
|
};
|
56
62
|
|
57
63
|
/**
|
@@ -66,6 +72,7 @@ export const setThirdwebDomains = (DomainOverrides: DomainOverrides) => {
|
|
66
72
|
storage: DomainOverrides.storage ?? DEFAULT_STORAGE_URL,
|
67
73
|
bundler: DomainOverrides.bundler ?? DEFAULT_BUNDLER_URL,
|
68
74
|
analytics: DomainOverrides.analytics ?? DEFAULT_ANALYTICS_URL,
|
75
|
+
insight: DomainOverrides.insight ?? DEFAULT_INSIGHT_URL,
|
69
76
|
};
|
70
77
|
};
|
71
78
|
|
package/src/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = "5.93.
|
1
|
+
export const version = "5.93.11";
|
@@ -23,6 +23,7 @@ import { keccak256 } from "../../../utils/hashing/keccak256.js";
|
|
23
23
|
import { stringify } from "../../../utils/json.js";
|
24
24
|
import { resolvePromisedValue } from "../../../utils/promise/resolve-promised-value.js";
|
25
25
|
import type { Account } from "../../interfaces/wallet.js";
|
26
|
+
import { getEntrypointFromFactory } from "../index.js";
|
26
27
|
import type {
|
27
28
|
BundlerOptions,
|
28
29
|
PaymasterResult,
|
@@ -749,6 +750,23 @@ export async function createAndSignUserOp(options: {
|
|
749
750
|
waitForDeployment?: boolean;
|
750
751
|
isDeployedOverride?: boolean;
|
751
752
|
}) {
|
753
|
+
// if factory is passed, but no entrypoint, try to resolve entrypoint from factory
|
754
|
+
if (
|
755
|
+
options.smartWalletOptions.factoryAddress &&
|
756
|
+
!options.smartWalletOptions.overrides?.entrypointAddress
|
757
|
+
) {
|
758
|
+
const entrypointAddress = await getEntrypointFromFactory(
|
759
|
+
options.smartWalletOptions.factoryAddress,
|
760
|
+
options.client,
|
761
|
+
options.smartWalletOptions.chain,
|
762
|
+
);
|
763
|
+
if (entrypointAddress) {
|
764
|
+
options.smartWalletOptions.overrides = {
|
765
|
+
...options.smartWalletOptions.overrides,
|
766
|
+
entrypointAddress,
|
767
|
+
};
|
768
|
+
}
|
769
|
+
}
|
752
770
|
const unsignedUserOp = await prepareUserOp({
|
753
771
|
transactions: options.transactions,
|
754
772
|
adminAccount: options.adminAccount,
|
@@ -33,6 +33,7 @@ import {
|
|
33
33
|
confirmContractDeployment,
|
34
34
|
deploySmartAccount,
|
35
35
|
} from "./lib/signing.js";
|
36
|
+
import { createAndSignUserOp } from "./lib/userop.js";
|
36
37
|
import { smartWallet } from "./smart-wallet.js";
|
37
38
|
|
38
39
|
let wallet: Wallet;
|
@@ -363,5 +364,25 @@ describe.runIf(process.env.TW_SECRET_KEY).sequential(
|
|
363
364
|
isDeployed = await isContractDeployed(newSmartAccountContract);
|
364
365
|
expect(isDeployed).toEqual(true);
|
365
366
|
});
|
367
|
+
|
368
|
+
it("can prep a 0.7 userop", async () => {
|
369
|
+
const tx = prepareTransaction({
|
370
|
+
client,
|
371
|
+
chain,
|
372
|
+
to: smartAccount.address,
|
373
|
+
value: 0n,
|
374
|
+
});
|
375
|
+
const uo = await createAndSignUserOp({
|
376
|
+
transactions: [tx],
|
377
|
+
adminAccount: personalAccount,
|
378
|
+
client: TEST_CLIENT,
|
379
|
+
smartWalletOptions: {
|
380
|
+
chain,
|
381
|
+
sponsorGas: true,
|
382
|
+
factoryAddress: DEFAULT_ACCOUNT_FACTORY_V0_7,
|
383
|
+
},
|
384
|
+
});
|
385
|
+
expect(uo.callData.length).toBeGreaterThan(0);
|
386
|
+
});
|
366
387
|
},
|
367
388
|
);
|