-
Notifications
You must be signed in to change notification settings - Fork 58
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
chore: Migrate transfer endpoints to v5 SDK #732
Conversation
examples: ["50000000000"], | ||
}); | ||
|
||
export const NumberStringSchema = Type.RegExp(/^\d+$/, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Useful for any generic non-decimal number input like tokenId or amount that must be a whole number (e.g. transferring NFTs).
fromAddress: getChecksumAddress(walletAddress), | ||
toAddress: getChecksumAddress(contractAddress), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making sure the from/to here is always backend wallet -> contract (as opposed to above when building the transaction where from/to are the sender/recipient addresses).
to: getChecksumAddress(to), | ||
tokenId: BigInt(tokenId), | ||
value: BigInt(amount), | ||
data: "0x", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd expose data
as an optional body param
to: getChecksumAddress(to), | ||
tokenId: BigInt(tokenId), | ||
value: BigInt(amount), | ||
data: "0x", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expose data here too, and all the other routes
simulateTx, | ||
extension: "erc1155", | ||
idempotencyKey, | ||
const transaction = safeTransferFrom({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
safeTransferFrom can fail if the recipient is a contract that does not implement the onReceived hook. This is generally desirable behaviour, but could fail transfers to smart accounts that do not implement this method. Most smart accounts do implement this though, including ours I think, but would be best to confirm once.
|
||
return getAddress(newWallet.result.walletAddress); | ||
} | ||
const { result } = await engine.backendWallet.import({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Importing the same wallet into Engine is fine (it will dedupe)
Maps the following routes to the v5 SDK methods:
PR-Codex overview
This PR focuses on enhancing the functionality and testing of ERC20, ERC721, and ERC1155 token transfers, along with improving schema definitions and utility functions. It introduces new test cases and refines existing code for better clarity and usability.
Detailed summary
TEST_ACCOUNT_B
totest/e2e/utils/wallets.ts
.HexSchema
insrc/server/schemas/address.ts
.amount
insdk/src/services/BackendWalletService.ts
.Address
intest/e2e/tests/setup.ts
.test/e2e/tests/write.test.ts
.data
parameter to transfer functions in ERC1155.getEngineBackendWalletB
function intest/e2e/utils/engine.ts
.thirdweb
client in multiple files.