thirdweb 5.97.2 → 5.97.3
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/verification/constructor-params.js +1 -1
- package/dist/cjs/contract/verification/constructor-params.js.map +1 -1
- package/dist/cjs/engine/get-status.js +110 -0
- package/dist/cjs/engine/get-status.js.map +1 -0
- package/dist/cjs/engine/index.js +9 -0
- package/dist/cjs/engine/index.js.map +1 -0
- package/dist/cjs/engine/server-wallet.js +214 -0
- package/dist/cjs/engine/server-wallet.js.map +1 -0
- package/dist/cjs/exports/engine.js +5 -0
- package/dist/cjs/exports/engine.js.map +1 -0
- package/dist/cjs/exports/thirdweb.js +6 -2
- package/dist/cjs/exports/thirdweb.js.map +1 -1
- package/dist/cjs/extensions/prebuilts/get-required-transactions.js +5 -5
- package/dist/cjs/extensions/prebuilts/get-required-transactions.js.map +1 -1
- package/dist/cjs/react/web/ui/prebuilt/NFT/utils.js +1 -0
- package/dist/cjs/react/web/ui/prebuilt/NFT/utils.js.map +1 -1
- package/dist/cjs/react/web/wallets/in-app/InAppWalletConnectUI.js +1 -1
- package/dist/cjs/react/web/wallets/in-app/InAppWalletConnectUI.js.map +1 -1
- package/dist/cjs/storage/upload/mobile.js +1 -1
- package/dist/cjs/storage/upload/mobile.js.map +1 -1
- package/dist/cjs/utils/domains.js +3 -0
- package/dist/cjs/utils/domains.js.map +1 -1
- package/dist/cjs/utils/fetch.js +7 -3
- package/dist/cjs/utils/fetch.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/wallets/engine/index.js +1 -0
- package/dist/cjs/wallets/engine/index.js.map +1 -1
- package/dist/cjs/wallets/smart/lib/calls.js +2 -2
- package/dist/cjs/wallets/smart/lib/calls.js.map +1 -1
- package/dist/cjs/wallets/smart/lib/paymaster.js +2 -2
- package/dist/cjs/wallets/smart/lib/paymaster.js.map +1 -1
- package/dist/esm/contract/verification/constructor-params.js +1 -1
- package/dist/esm/contract/verification/constructor-params.js.map +1 -1
- package/dist/esm/engine/get-status.js +106 -0
- package/dist/esm/engine/get-status.js.map +1 -0
- package/dist/esm/engine/index.js +3 -0
- package/dist/esm/engine/index.js.map +1 -0
- package/dist/esm/engine/server-wallet.js +211 -0
- package/dist/esm/engine/server-wallet.js.map +1 -0
- package/dist/esm/exports/engine.js +2 -0
- package/dist/esm/exports/engine.js.map +1 -0
- package/dist/esm/exports/thirdweb.js +4 -0
- package/dist/esm/exports/thirdweb.js.map +1 -1
- package/dist/esm/extensions/prebuilts/get-required-transactions.js +5 -5
- package/dist/esm/extensions/prebuilts/get-required-transactions.js.map +1 -1
- package/dist/esm/react/web/ui/prebuilt/NFT/utils.js +1 -0
- package/dist/esm/react/web/ui/prebuilt/NFT/utils.js.map +1 -1
- package/dist/esm/react/web/wallets/in-app/InAppWalletConnectUI.js +1 -1
- package/dist/esm/react/web/wallets/in-app/InAppWalletConnectUI.js.map +1 -1
- package/dist/esm/storage/upload/mobile.js +1 -1
- package/dist/esm/storage/upload/mobile.js.map +1 -1
- package/dist/esm/utils/domains.js +3 -0
- package/dist/esm/utils/domains.js.map +1 -1
- package/dist/esm/utils/fetch.js +7 -3
- package/dist/esm/utils/fetch.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/wallets/engine/index.js +1 -0
- package/dist/esm/wallets/engine/index.js.map +1 -1
- package/dist/esm/wallets/smart/lib/calls.js +2 -2
- package/dist/esm/wallets/smart/lib/calls.js.map +1 -1
- package/dist/esm/wallets/smart/lib/paymaster.js +2 -2
- package/dist/esm/wallets/smart/lib/paymaster.js.map +1 -1
- package/dist/types/engine/get-status.d.ts +81 -0
- package/dist/types/engine/get-status.d.ts.map +1 -0
- package/dist/types/engine/index.d.ts +3 -0
- package/dist/types/engine/index.d.ts.map +1 -0
- package/dist/types/engine/server-wallet.d.ts +95 -0
- package/dist/types/engine/server-wallet.d.ts.map +1 -0
- package/dist/types/exports/engine.d.ts +2 -0
- package/dist/types/exports/engine.d.ts.map +1 -0
- package/dist/types/exports/thirdweb.d.ts +4 -0
- package/dist/types/exports/thirdweb.d.ts.map +1 -1
- package/dist/types/react/native/ui/prebuilt/Account/balance.d.ts +1 -1
- package/dist/types/react/native/ui/prebuilt/Wallet/name.d.ts +1 -1
- package/dist/types/react/web/ui/prebuilt/Account/balance.d.ts +1 -1
- package/dist/types/react/web/ui/prebuilt/Chain/name.d.ts +1 -1
- package/dist/types/react/web/ui/prebuilt/NFT/utils.d.ts.map +1 -1
- package/dist/types/react/web/ui/prebuilt/Token/name.d.ts +1 -1
- package/dist/types/react/web/ui/prebuilt/Token/symbol.d.ts +1 -1
- package/dist/types/react/web/ui/prebuilt/Wallet/name.d.ts +1 -1
- package/dist/types/utils/domains.d.ts +6 -0
- package/dist/types/utils/domains.d.ts.map +1 -1
- package/dist/types/utils/fetch.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/wallets/engine/index.d.ts +1 -0
- package/dist/types/wallets/engine/index.d.ts.map +1 -1
- package/package.json +7 -1
- package/src/contract/verification/constructor-params.ts +1 -1
- package/src/engine/get-status.ts +180 -0
- package/src/engine/index.ts +11 -0
- package/src/engine/server-wallet.test.ts +196 -0
- package/src/engine/server-wallet.ts +284 -0
- package/src/exports/engine.ts +1 -0
- package/src/exports/thirdweb.ts +5 -0
- package/src/extensions/prebuilts/get-required-transactions.ts +5 -5
- package/src/react/native/ui/prebuilt/Account/balance.tsx +1 -1
- package/src/react/native/ui/prebuilt/Wallet/name.tsx +1 -1
- package/src/react/web/ui/prebuilt/Account/balance.tsx +1 -1
- package/src/react/web/ui/prebuilt/Chain/name.tsx +1 -1
- package/src/react/web/ui/prebuilt/NFT/utils.ts +1 -0
- package/src/react/web/ui/prebuilt/Token/name.tsx +1 -1
- package/src/react/web/ui/prebuilt/Token/symbol.tsx +1 -1
- package/src/react/web/ui/prebuilt/Wallet/name.tsx +1 -1
- package/src/react/web/wallets/in-app/InAppWalletConnectUI.tsx +1 -1
- package/src/storage/upload/mobile.ts +1 -1
- package/src/utils/domain.test.ts +1 -0
- package/src/utils/domains.ts +9 -0
- package/src/utils/fetch.ts +11 -3
- package/src/version.ts +1 -1
- package/src/wallets/engine/index.ts +1 -0
- package/src/wallets/smart/lib/calls.ts +2 -2
- package/src/wallets/smart/lib/paymaster.ts +2 -2
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../../../src/react/web/ui/prebuilt/NFT/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,sCAAsC,CAAC;AAEhE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD;;GAEG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../../../src/react/web/ui/prebuilt/NFT/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,sCAAsC,CAAC;AAEhE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD;;GAEG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,CAoCxE"}
|
@@ -39,7 +39,7 @@ export interface TokenNameProps extends Omit<React.HTMLAttributes<HTMLSpanElemen
|
|
39
39
|
* If not passed, the component will return `null`.
|
40
40
|
*
|
41
41
|
* You can/should pass a descriptive text/component to this prop, indicating that the
|
42
|
-
* name was not fetched
|
42
|
+
* name was not fetched successfully
|
43
43
|
* @example
|
44
44
|
* ```tsx
|
45
45
|
* <TokenName fallbackComponent={"Failed to load"}
|
@@ -39,7 +39,7 @@ export interface TokenSymbolProps extends Omit<React.HTMLAttributes<HTMLSpanElem
|
|
39
39
|
* If not passed, the component will return `null`.
|
40
40
|
*
|
41
41
|
* You can/should pass a descriptive text/component to this prop, indicating that the
|
42
|
-
* symbol was not fetched
|
42
|
+
* symbol was not fetched successfully
|
43
43
|
* @example
|
44
44
|
* ```tsx
|
45
45
|
* <TokenSymbol fallbackComponent={"Failed to load"}
|
@@ -22,7 +22,7 @@ export interface WalletNameProps extends Omit<React.HTMLAttributes<HTMLSpanEleme
|
|
22
22
|
* If not passed, the component will return `null`.
|
23
23
|
*
|
24
24
|
* You can/should pass a descriptive text/component to this prop, indicating that the
|
25
|
-
* name was not fetched
|
25
|
+
* name was not fetched successfully
|
26
26
|
* @example
|
27
27
|
* ```tsx
|
28
28
|
* <WalletName fallbackComponent={<span>Failed to load</span>}
|
@@ -39,6 +39,11 @@ type DomainOverrides = {
|
|
39
39
|
* @default "insight.thirdweb.com"
|
40
40
|
*/
|
41
41
|
insight?: string;
|
42
|
+
/**
|
43
|
+
* The base URL for the engine cloud server.
|
44
|
+
* @default "engine.thirdweb.com"
|
45
|
+
*/
|
46
|
+
engineCloud?: string;
|
42
47
|
};
|
43
48
|
export declare const DEFAULT_RPC_URL = "rpc.thirdweb.com";
|
44
49
|
export declare const setThirdwebDomains: (DomainOverrides: DomainOverrides) => void;
|
@@ -54,6 +59,7 @@ export declare const getThirdwebDomains: () => {
|
|
54
59
|
bundler: string;
|
55
60
|
analytics: string;
|
56
61
|
insight: string;
|
62
|
+
engineCloud: string;
|
57
63
|
};
|
58
64
|
/**
|
59
65
|
* @internal
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"domains.d.ts","sourceRoot":"","sources":["../../../src/utils/domains.ts"],"names":[],"mappings":"AAAA,KAAK,eAAe,GAAG;IACrB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;
|
1
|
+
{"version":3,"file":"domains.d.ts","sourceRoot":"","sources":["../../../src/utils/domains.ts"],"names":[],"mappings":"AAAA,KAAK,eAAe,GAAG;IACrB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,eAAe,qBAAqB,CAAC;AAsBlD,eAAO,MAAM,kBAAkB,GAAI,iBAAiB,eAAe,SAYlE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB;SAlFvB,MAAM;YAKH,MAAM;iBAKD,MAAM;SAKd,MAAM;aAKF,MAAM;aAKN,MAAM;eAKJ,MAAM;aAKR,MAAM;iBAKF,MAAM;CA4CrB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAAI,SAAS,MAAM,eAAe,WAMhE,CAAC;AAIF,eAAO,MAAM,aAAa,GAAI,KAAK,MAAM,GAAG,IAAI,SAE/C,CAAC;AAEF,eAAO,MAAM,aAAa,qBAEzB,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../src/utils/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAY1C;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,EAAE,SAAS,CAAC,EAAE,SAAS,SAKnE,MAAM,GAAG,OAAO,SACd,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,GAAG;IAAE,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAAE,KACjE,OAAO,CAAC,QAAQ,CAAC,
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../src/utils/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAY1C;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,EAAE,SAAS,CAAC,EAAE,SAAS,SAKnE,MAAM,GAAG,OAAO,SACd,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,GAAG;IAAE,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAAE,KACjE,OAAO,CAAC,QAAQ,CAAC,CAwFrB;AAWD,eAAO,MAAM,qBAAqB,iBAA4B,CAAC;AAE/D;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAyBlD;AAwCD;;GAEG;AACH,wBAAgB,kBAAkB,uBA0BjC"}
|
package/dist/types/version.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export declare const version = "5.97.
|
1
|
+
export declare const version = "5.97.3";
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
@@ -37,6 +37,7 @@ export type EngineAccountOptions = {
|
|
37
37
|
};
|
38
38
|
/**
|
39
39
|
* Creates an account that uses your engine backend wallet for sending transactions and signing messages.
|
40
|
+
* @deprecated This for v2 dedicated engine instances, for v3 and engine cloud use Engine.serverWallet()
|
40
41
|
*
|
41
42
|
* @param options - The options for the engine account.
|
42
43
|
* @returns An account that uses your engine backend wallet.
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/wallets/engine/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAInD,OAAO,KAAK,EAAE,OAAO,EAAyB,MAAM,yBAAyB,CAAC;AAE9E;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE;QACV;;WAEG;QACH,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB;;WAEG;QACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;QAC/B;;WAEG;QACH,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;IACF;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC;CACf,CAAC;AAEF
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/wallets/engine/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAInD,OAAO,KAAK,EAAE,OAAO,EAAyB,MAAM,yBAAyB,CAAC;AAE9E;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE;QACV;;WAEG;QACH,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB;;WAEG;QACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;QAC/B;;WAEG;QACH,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;IACF;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC;CACf,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAyJpE"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "thirdweb",
|
3
|
-
"version": "5.97.
|
3
|
+
"version": "5.97.3",
|
4
4
|
"repository": {
|
5
5
|
"type": "git",
|
6
6
|
"url": "git+https://github.com/thirdweb-dev/js.git#main"
|
@@ -138,6 +138,11 @@
|
|
138
138
|
"import": "./dist/esm/exports/insight.js",
|
139
139
|
"default": "./dist/cjs/exports/insight.js"
|
140
140
|
},
|
141
|
+
"./engine": {
|
142
|
+
"types": "./dist/types/exports/engine.d.ts",
|
143
|
+
"import": "./dist/esm/exports/engine.js",
|
144
|
+
"default": "./dist/cjs/exports/engine.js"
|
145
|
+
},
|
141
146
|
"./package.json": "./package.json"
|
142
147
|
},
|
143
148
|
"typesVersions": {
|
@@ -245,6 +250,7 @@
|
|
245
250
|
"toml": "3.0.0",
|
246
251
|
"uqr": "0.1.2",
|
247
252
|
"viem": "2.28.1",
|
253
|
+
"@thirdweb-dev/engine": "3.0.0",
|
248
254
|
"@thirdweb-dev/insight": "1.0.0"
|
249
255
|
},
|
250
256
|
"peerDependencies": {
|
@@ -86,7 +86,7 @@ export async function fetchConstructorParams(
|
|
86
86
|
),
|
87
87
|
];
|
88
88
|
|
89
|
-
// regex finds the LAST
|
89
|
+
// regex finds the LAST occurrence of solc metadata bytes, result always in same position
|
90
90
|
// TODO: we currently don't handle error string embedded in the bytecode, need to strip ascii (upgradeableProxy) in patterns[2]
|
91
91
|
// https://etherscan.io/address/0xee6a57ec80ea46401049e92587e52f5ec1c24785#code
|
92
92
|
if (matches?.[0]?.[2]) {
|
@@ -0,0 +1,180 @@
|
|
1
|
+
import { searchTransactions } from "@thirdweb-dev/engine";
|
2
|
+
import type { Chain } from "../chains/types.js";
|
3
|
+
import { getCachedChain } from "../chains/utils.js";
|
4
|
+
import type { ThirdwebClient } from "../client/client.js";
|
5
|
+
import type { WaitForReceiptOptions } from "../transaction/actions/wait-for-tx-receipt.js";
|
6
|
+
import { getThirdwebBaseUrl } from "../utils/domains.js";
|
7
|
+
import type { Hex } from "../utils/encoding/hex.js";
|
8
|
+
import { getClientFetch } from "../utils/fetch.js";
|
9
|
+
import { stringify } from "../utils/json.js";
|
10
|
+
import type { Prettify } from "../utils/type-utils.js";
|
11
|
+
|
12
|
+
export type RevertData = {
|
13
|
+
errorName: string;
|
14
|
+
errorArgs: Record<string, unknown>;
|
15
|
+
};
|
16
|
+
|
17
|
+
type ExecutionResult4337Serialized =
|
18
|
+
| {
|
19
|
+
status: "QUEUED";
|
20
|
+
}
|
21
|
+
| {
|
22
|
+
status: "FAILED";
|
23
|
+
error: string;
|
24
|
+
}
|
25
|
+
| {
|
26
|
+
status: "SUBMITTED";
|
27
|
+
monitoringStatus: "WILL_MONITOR" | "CANNOT_MONITOR";
|
28
|
+
userOpHash: string;
|
29
|
+
}
|
30
|
+
| ({
|
31
|
+
status: "CONFIRMED";
|
32
|
+
userOpHash: Hex;
|
33
|
+
transactionHash: Hex;
|
34
|
+
actualGasCost: string;
|
35
|
+
actualGasUsed: string;
|
36
|
+
nonce: string;
|
37
|
+
} & (
|
38
|
+
| {
|
39
|
+
onchainStatus: "SUCCESS";
|
40
|
+
}
|
41
|
+
| {
|
42
|
+
onchainStatus: "REVERTED";
|
43
|
+
revertData?: RevertData;
|
44
|
+
}
|
45
|
+
));
|
46
|
+
|
47
|
+
export type ExecutionResult = Prettify<
|
48
|
+
ExecutionResult4337Serialized & {
|
49
|
+
chain: Chain;
|
50
|
+
from: string | undefined;
|
51
|
+
id: string;
|
52
|
+
}
|
53
|
+
>;
|
54
|
+
|
55
|
+
/**
|
56
|
+
* Get the execution status of a transaction.
|
57
|
+
* @param args - The arguments for the transaction.
|
58
|
+
* @param args.client - The thirdweb client to use.
|
59
|
+
* @param args.transactionId - The id of the transaction to get the status of.
|
60
|
+
* @engine
|
61
|
+
* @example
|
62
|
+
* ```ts
|
63
|
+
* import { Engine } from "thirdweb";
|
64
|
+
*
|
65
|
+
* const executionResult = await Engine.getTransactionStatus({
|
66
|
+
* client,
|
67
|
+
* transactionId,
|
68
|
+
* });
|
69
|
+
* console.log(executionResult.status);
|
70
|
+
* ```
|
71
|
+
*/
|
72
|
+
export async function getTransactionStatus(args: {
|
73
|
+
client: ThirdwebClient;
|
74
|
+
transactionId: string;
|
75
|
+
}): Promise<ExecutionResult> {
|
76
|
+
const { client, transactionId } = args;
|
77
|
+
const searchResult = await searchTransactions({
|
78
|
+
baseUrl: getThirdwebBaseUrl("engineCloud"),
|
79
|
+
fetch: getClientFetch(client),
|
80
|
+
body: {
|
81
|
+
filters: [
|
82
|
+
{
|
83
|
+
field: "id",
|
84
|
+
values: [transactionId],
|
85
|
+
operation: "OR",
|
86
|
+
},
|
87
|
+
],
|
88
|
+
},
|
89
|
+
});
|
90
|
+
|
91
|
+
if (searchResult.error) {
|
92
|
+
throw new Error(
|
93
|
+
`Error searching for transaction ${transactionId}: ${stringify(
|
94
|
+
searchResult.error,
|
95
|
+
)}`,
|
96
|
+
);
|
97
|
+
}
|
98
|
+
|
99
|
+
const data = searchResult.data?.result?.transactions?.[0];
|
100
|
+
|
101
|
+
if (!data) {
|
102
|
+
throw new Error(`Transaction ${transactionId} not found`);
|
103
|
+
}
|
104
|
+
|
105
|
+
const executionResult = data.executionResult as ExecutionResult4337Serialized;
|
106
|
+
return {
|
107
|
+
...executionResult,
|
108
|
+
chain: getCachedChain(Number(data.chainId)),
|
109
|
+
from: data.from ?? undefined,
|
110
|
+
id: data.id,
|
111
|
+
};
|
112
|
+
}
|
113
|
+
|
114
|
+
/**
|
115
|
+
* Wait for a transaction to be submitted onchain and return the transaction hash.
|
116
|
+
* @param args - The arguments for the transaction.
|
117
|
+
* @param args.client - The thirdweb client to use.
|
118
|
+
* @param args.transactionId - The id of the transaction to wait for.
|
119
|
+
* @param args.timeoutInSeconds - The timeout in seconds.
|
120
|
+
* @engine
|
121
|
+
* @example
|
122
|
+
* ```ts
|
123
|
+
* import { Engine } from "thirdweb";
|
124
|
+
*
|
125
|
+
* const { transactionHash } = await Engine.waitForTransactionHash({
|
126
|
+
* client,
|
127
|
+
* transactionId, // the transaction id returned from enqueueTransaction
|
128
|
+
* });
|
129
|
+
* ```
|
130
|
+
*/
|
131
|
+
export async function waitForTransactionHash(args: {
|
132
|
+
client: ThirdwebClient;
|
133
|
+
transactionId: string;
|
134
|
+
timeoutInSeconds?: number;
|
135
|
+
}): Promise<WaitForReceiptOptions> {
|
136
|
+
const startTime = Date.now();
|
137
|
+
const TIMEOUT_IN_MS = args.timeoutInSeconds
|
138
|
+
? args.timeoutInSeconds * 1000
|
139
|
+
: 5 * 60 * 1000; // 5 minutes in milliseconds
|
140
|
+
|
141
|
+
while (Date.now() - startTime < TIMEOUT_IN_MS) {
|
142
|
+
const executionResult = await getTransactionStatus(args);
|
143
|
+
const status = executionResult.status;
|
144
|
+
|
145
|
+
switch (status) {
|
146
|
+
case "FAILED": {
|
147
|
+
throw new Error(
|
148
|
+
`Transaction failed: ${executionResult.error || "Unknown error"}`,
|
149
|
+
);
|
150
|
+
}
|
151
|
+
case "CONFIRMED": {
|
152
|
+
const onchainStatus =
|
153
|
+
executionResult && "onchainStatus" in executionResult
|
154
|
+
? executionResult.onchainStatus
|
155
|
+
: null;
|
156
|
+
if (onchainStatus === "REVERTED") {
|
157
|
+
const revertData =
|
158
|
+
"revertData" in executionResult
|
159
|
+
? executionResult.revertData
|
160
|
+
: undefined;
|
161
|
+
throw new Error(
|
162
|
+
`Transaction reverted: ${revertData?.errorName || ""} ${revertData?.errorArgs ? stringify(revertData.errorArgs) : ""}`,
|
163
|
+
);
|
164
|
+
}
|
165
|
+
return {
|
166
|
+
transactionHash: executionResult.transactionHash as Hex,
|
167
|
+
client: args.client,
|
168
|
+
chain: executionResult.chain,
|
169
|
+
};
|
170
|
+
}
|
171
|
+
default: {
|
172
|
+
// wait for the transaction to be confirmed
|
173
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
174
|
+
}
|
175
|
+
}
|
176
|
+
}
|
177
|
+
throw new Error(
|
178
|
+
`Transaction timed out after ${TIMEOUT_IN_MS / 1000} seconds`,
|
179
|
+
);
|
180
|
+
}
|
@@ -0,0 +1,196 @@
|
|
1
|
+
import { beforeAll, describe, expect, it } from "vitest";
|
2
|
+
import { TEST_CLIENT } from "../../test/src/test-clients.js";
|
3
|
+
import { TEST_ACCOUNT_B } from "../../test/src/test-wallets.js";
|
4
|
+
import { typedData } from "../../test/src/typed-data.js";
|
5
|
+
import { arbitrumSepolia } from "../chains/chain-definitions/arbitrum-sepolia.js";
|
6
|
+
import { sepolia } from "../chains/chain-definitions/sepolia.js";
|
7
|
+
import { getContract } from "../contract/contract.js";
|
8
|
+
import { setContractURI } from "../extensions/common/__generated__/IContractMetadata/write/setContractURI.js";
|
9
|
+
import { claimTo } from "../extensions/erc1155/drops/write/claimTo.js";
|
10
|
+
import { getAllActiveSigners } from "../extensions/erc4337/__generated__/IAccountPermissions/read/getAllActiveSigners.js";
|
11
|
+
import { sendTransaction } from "../transaction/actions/send-transaction.js";
|
12
|
+
import { setThirdwebDomains } from "../utils/domains.js";
|
13
|
+
import {
|
14
|
+
DEFAULT_ACCOUNT_FACTORY_V0_6,
|
15
|
+
ENTRYPOINT_ADDRESS_v0_6,
|
16
|
+
} from "../wallets/smart/lib/constants.js";
|
17
|
+
import { smartWallet } from "../wallets/smart/smart-wallet.js";
|
18
|
+
import { generateAccount } from "../wallets/utils/generateAccount.js";
|
19
|
+
import * as Engine from "./index.js";
|
20
|
+
|
21
|
+
describe.runIf(
|
22
|
+
process.env.TW_SECRET_KEY &&
|
23
|
+
process.env.VAULT_TOKEN &&
|
24
|
+
process.env.ENGINE_CLOUD_WALLET_ADDRESS &&
|
25
|
+
process.env.ENGINE_CLOUD_WALLET_ADDRESS_EOA,
|
26
|
+
)(
|
27
|
+
"Engine Cloud",
|
28
|
+
{
|
29
|
+
retry: 0,
|
30
|
+
},
|
31
|
+
() => {
|
32
|
+
let serverWallet: Engine.ServerWallet;
|
33
|
+
|
34
|
+
beforeAll(async () => {
|
35
|
+
setThirdwebDomains({
|
36
|
+
rpc: "rpc.thirdweb-dev.com",
|
37
|
+
storage: "storage.thirdweb-dev.com",
|
38
|
+
bundler: "bundler.thirdweb-dev.com",
|
39
|
+
engineCloud: "engine.thirdweb-dev.com",
|
40
|
+
});
|
41
|
+
serverWallet = Engine.serverWallet({
|
42
|
+
client: TEST_CLIENT,
|
43
|
+
vaultAccessToken: process.env.VAULT_TOKEN as string,
|
44
|
+
address: process.env.ENGINE_CLOUD_WALLET_ADDRESS as string,
|
45
|
+
chain: arbitrumSepolia,
|
46
|
+
});
|
47
|
+
});
|
48
|
+
|
49
|
+
it("should sign a message", async () => {
|
50
|
+
const signature = await serverWallet.signMessage({
|
51
|
+
message: "hello",
|
52
|
+
});
|
53
|
+
expect(signature).toBeDefined();
|
54
|
+
});
|
55
|
+
|
56
|
+
it("should sign typed data", async () => {
|
57
|
+
const signature = await serverWallet.signTypedData({
|
58
|
+
...typedData.basic,
|
59
|
+
});
|
60
|
+
expect(signature).toBeDefined();
|
61
|
+
});
|
62
|
+
|
63
|
+
it("should send a tx with regular API", async () => {
|
64
|
+
const tx = await sendTransaction({
|
65
|
+
account: serverWallet,
|
66
|
+
transaction: {
|
67
|
+
client: TEST_CLIENT,
|
68
|
+
chain: arbitrumSepolia,
|
69
|
+
to: TEST_ACCOUNT_B.address,
|
70
|
+
value: 0n,
|
71
|
+
},
|
72
|
+
});
|
73
|
+
expect(tx).toBeDefined();
|
74
|
+
});
|
75
|
+
|
76
|
+
it("should enqueue a tx", async () => {
|
77
|
+
const nftContract = getContract({
|
78
|
+
client: TEST_CLIENT,
|
79
|
+
chain: sepolia,
|
80
|
+
address: "0xe2cb0eb5147b42095c2FfA6F7ec953bb0bE347D8",
|
81
|
+
});
|
82
|
+
const claimTx = claimTo({
|
83
|
+
contract: nftContract,
|
84
|
+
to: TEST_ACCOUNT_B.address,
|
85
|
+
tokenId: 0n,
|
86
|
+
quantity: 1n,
|
87
|
+
});
|
88
|
+
const result = await serverWallet.enqueueTransaction({
|
89
|
+
transaction: claimTx,
|
90
|
+
});
|
91
|
+
expect(result.transactionId).toBeDefined();
|
92
|
+
const txHash = await Engine.waitForTransactionHash({
|
93
|
+
client: TEST_CLIENT,
|
94
|
+
transactionId: result.transactionId,
|
95
|
+
});
|
96
|
+
expect(txHash.transactionHash).toBeDefined();
|
97
|
+
});
|
98
|
+
|
99
|
+
it("should send a extension tx", async () => {
|
100
|
+
const nftContract = getContract({
|
101
|
+
client: TEST_CLIENT,
|
102
|
+
chain: sepolia,
|
103
|
+
address: "0xe2cb0eb5147b42095c2FfA6F7ec953bb0bE347D8",
|
104
|
+
});
|
105
|
+
const claimTx = claimTo({
|
106
|
+
contract: nftContract,
|
107
|
+
to: TEST_ACCOUNT_B.address,
|
108
|
+
tokenId: 0n,
|
109
|
+
quantity: 1n,
|
110
|
+
});
|
111
|
+
const tx = await sendTransaction({
|
112
|
+
account: serverWallet,
|
113
|
+
transaction: claimTx,
|
114
|
+
});
|
115
|
+
expect(tx).toBeDefined();
|
116
|
+
});
|
117
|
+
|
118
|
+
it("should get revert reason", async () => {
|
119
|
+
const nftContract = getContract({
|
120
|
+
client: TEST_CLIENT,
|
121
|
+
chain: sepolia,
|
122
|
+
address: "0xe2cb0eb5147b42095c2FfA6F7ec953bb0bE347D8",
|
123
|
+
});
|
124
|
+
const transaction = setContractURI({
|
125
|
+
contract: nftContract,
|
126
|
+
uri: "https://example.com",
|
127
|
+
overrides: {
|
128
|
+
gas: 1000000n, // skip simulation
|
129
|
+
},
|
130
|
+
});
|
131
|
+
await expect(
|
132
|
+
sendTransaction({
|
133
|
+
account: serverWallet,
|
134
|
+
transaction,
|
135
|
+
}),
|
136
|
+
).rejects.toThrow();
|
137
|
+
});
|
138
|
+
|
139
|
+
it("should send a session key tx", async () => {
|
140
|
+
const sessionKeyAccountAddress = process.env
|
141
|
+
.ENGINE_CLOUD_WALLET_ADDRESS_EOA as string;
|
142
|
+
const personalAccount = await generateAccount({
|
143
|
+
client: TEST_CLIENT,
|
144
|
+
});
|
145
|
+
const smart = smartWallet({
|
146
|
+
chain: sepolia,
|
147
|
+
sponsorGas: true,
|
148
|
+
sessionKey: {
|
149
|
+
address: sessionKeyAccountAddress,
|
150
|
+
permissions: {
|
151
|
+
approvedTargets: "*",
|
152
|
+
},
|
153
|
+
},
|
154
|
+
});
|
155
|
+
const smartAccount = await smart.connect({
|
156
|
+
client: TEST_CLIENT,
|
157
|
+
personalAccount,
|
158
|
+
});
|
159
|
+
expect(smartAccount.address).toBeDefined();
|
160
|
+
|
161
|
+
const signers = await getAllActiveSigners({
|
162
|
+
contract: getContract({
|
163
|
+
client: TEST_CLIENT,
|
164
|
+
chain: sepolia,
|
165
|
+
address: smartAccount.address,
|
166
|
+
}),
|
167
|
+
});
|
168
|
+
expect(signers.map((s) => s.signer)).toContain(sessionKeyAccountAddress);
|
169
|
+
|
170
|
+
const serverWallet = Engine.serverWallet({
|
171
|
+
client: TEST_CLIENT,
|
172
|
+
vaultAccessToken: process.env.VAULT_TOKEN as string,
|
173
|
+
address: sessionKeyAccountAddress,
|
174
|
+
chain: sepolia,
|
175
|
+
executionOptions: {
|
176
|
+
type: "ERC4337",
|
177
|
+
signerAddress: sessionKeyAccountAddress,
|
178
|
+
smartAccountAddress: smartAccount.address,
|
179
|
+
factoryAddress: DEFAULT_ACCOUNT_FACTORY_V0_6,
|
180
|
+
entrypointAddress: ENTRYPOINT_ADDRESS_v0_6,
|
181
|
+
},
|
182
|
+
});
|
183
|
+
|
184
|
+
const tx = await sendTransaction({
|
185
|
+
account: serverWallet,
|
186
|
+
transaction: {
|
187
|
+
client: TEST_CLIENT,
|
188
|
+
chain: sepolia,
|
189
|
+
to: TEST_ACCOUNT_B.address,
|
190
|
+
value: 0n,
|
191
|
+
},
|
192
|
+
});
|
193
|
+
expect(tx).toBeDefined();
|
194
|
+
});
|
195
|
+
},
|
196
|
+
);
|