-
Notifications
You must be signed in to change notification settings - Fork 540
[SDK] Engine search transactions and batch transaction support #7190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
joaquim-verges
merged 1 commit into
main
from
_Engine_Add_search_transactions_and_batch_transaction_support
May 29, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
--- | ||
"thirdweb": minor | ||
--- | ||
|
||
Enhanced Engine functionality with server wallet management, search transactions and batch transaction support: | ||
|
||
- Added `Engine.createServerWallet()` to create a new server wallet with a custom label | ||
|
||
```ts | ||
import { Engine } from "thirdweb"; | ||
|
||
const serverWallet = await Engine.createServerWallet({ | ||
client, | ||
label: "My Server Wallet", | ||
}); | ||
console.log(serverWallet.address); | ||
console.log(serverWallet.smartAccountAddress); | ||
``` | ||
|
||
- Added `Engine.getServerWallets()` to list all existing server wallets | ||
|
||
```ts | ||
import { Engine } from "thirdweb"; | ||
|
||
const serverWallets = await Engine.getServerWallets({ | ||
client, | ||
}); | ||
console.log(serverWallets); | ||
``` | ||
|
||
- Added `Engine.searchTransactions()` to search for transactions by various filters (id, chainId, from address, etc.) | ||
|
||
```ts | ||
// Search by transaction IDs | ||
const transactions = await Engine.searchTransactions({ | ||
client, | ||
filters: [ | ||
{ | ||
field: "id", | ||
values: ["1", "2", "3"], | ||
}, | ||
], | ||
}); | ||
|
||
// Search by chain ID and sender address | ||
const transactions = await Engine.searchTransactions({ | ||
client, | ||
filters: [ | ||
{ | ||
filters: [ | ||
{ | ||
field: "from", | ||
values: ["0x1234567890123456789012345678901234567890"], | ||
}, | ||
{ | ||
field: "chainId", | ||
values: ["8453"], | ||
}, | ||
], | ||
operation: "AND", | ||
}, | ||
], | ||
pageSize: 100, | ||
page: 0, | ||
}); | ||
``` | ||
|
||
- Added `serverWallet.enqueueBatchTransaction()` to enqueue multiple transactions in a single batch | ||
|
||
```ts | ||
// Prepare multiple transactions | ||
const transaction1 = claimTo({ | ||
contract, | ||
to: firstRecipient, | ||
quantity: 1n, | ||
}); | ||
const transaction2 = claimTo({ | ||
contract, | ||
to: secondRecipient, | ||
quantity: 1n, | ||
}); | ||
|
||
// Enqueue as a batch | ||
const { transactionId } = await serverWallet.enqueueBatchTransaction({ | ||
transactions: [transaction1, transaction2], | ||
}); | ||
|
||
// Wait for batch completion | ||
const { transactionHash } = await Engine.waitForTransactionHash({ | ||
client, | ||
transactionId, | ||
}); | ||
``` | ||
|
||
- Improved server wallet transaction handling with better error reporting |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@thirdweb-dev/engine": patch | ||
--- | ||
|
||
Updated to latest API |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { createAccount } from "@thirdweb-dev/engine"; | ||
import { stringify } from "viem"; | ||
import type { ThirdwebClient } from "../client/client.js"; | ||
import { getThirdwebBaseUrl } from "../utils/domains.js"; | ||
import { getClientFetch } from "../utils/fetch.js"; | ||
|
||
export type CreateServerWalletArgs = { | ||
client: ThirdwebClient; | ||
label: string; | ||
}; | ||
|
||
/** | ||
* Create a server wallet. | ||
* @param params - The parameters for the server wallet. | ||
* @param params.client - The thirdweb client to use. | ||
* @param params.label - The label for the server wallet. | ||
* @returns The server wallet signer address and the predicted smart account address. | ||
* @engine | ||
* @example | ||
* ```ts | ||
* import { Engine } from "thirdweb"; | ||
* | ||
* const serverWallet = await Engine.createServerWallet({ | ||
* client, | ||
* label: "My Server Wallet", | ||
* }); | ||
* console.log(serverWallet.address); | ||
* console.log(serverWallet.smartAccountAddress); | ||
* ``` | ||
*/ | ||
export async function createServerWallet(params: CreateServerWalletArgs) { | ||
const { client, label } = params; | ||
const result = await createAccount({ | ||
baseUrl: getThirdwebBaseUrl("engineCloud"), | ||
bodySerializer: stringify, | ||
fetch: getClientFetch(client), | ||
body: { | ||
label, | ||
}, | ||
}); | ||
|
||
if (result.error) { | ||
throw new Error( | ||
`Error creating server wallet with label ${label}: ${stringify( | ||
result.error, | ||
)}`, | ||
); | ||
} | ||
|
||
const data = result.data?.result; | ||
|
||
if (!data) { | ||
throw new Error(`No server wallet created with label ${label}`); | ||
} | ||
|
||
return data; | ||
} | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.