Skip to content

Commit 9f1a77f

Browse files
[SDK] fix: Allow resending OTP on failures (#6412)
1 parent 158a08a commit 9f1a77f

File tree

6 files changed

+20
-82
lines changed

6 files changed

+20
-82
lines changed

.changeset/silent-jobs-report.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Allow resending OTP on failures

packages/thirdweb/src/extensions/erc1155/drop1155.test.ts

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@ import { resolvePromisedValue } from "../../utils/promise/resolve-promised-value
1717
import { toEther } from "../../utils/units.js";
1818
import { generateMerkleTreeInfoERC1155 } from "../airdrop/write/merkleInfoERC1155.js";
1919
import { name } from "../common/read/name.js";
20-
import { deployERC20Contract } from "../prebuilts/deploy-erc20.js";
2120
import { deployERC1155Contract } from "../prebuilts/deploy-erc1155.js";
2221
import { balanceOf } from "./__generated__/IERC1155/read/balanceOf.js";
23-
import { totalSupply } from "./__generated__/IERC1155/read/totalSupply.js";
2422
import { nextTokenIdToMint } from "./__generated__/IERC1155Enumerable/read/nextTokenIdToMint.js";
2523
import { canClaim } from "./drops/read/canClaim.js";
2624
import { getActiveClaimCondition } from "./drops/read/getActiveClaimCondition.js";
@@ -472,63 +470,6 @@ describe.runIf(process.env.TW_SECRET_KEY)(
472470
expect(isGetNFTsSupported(selectors)).toBe(true);
473471
});
474472

475-
/**
476-
* This is to document the behavior where one can claim without paying if the claiming address
477-
* is the same as the PrimaryRecipientAddress, because of this Solidity code:
478-
* ```solidity
479-
* // CurrencyTransferLib.sol
480-
* function safeTransferERC20(address _currency, address _from, address _to, uint256 _amount) internal {
481-
* if (_from == _to) {
482-
* return;
483-
* }
484-
* ...
485-
* }
486-
* ```
487-
*/
488-
it("address that is the same with PrimaryFeeRecipient can claim without paying ERC20", async () => {
489-
const tokenAddress = await deployERC20Contract({
490-
client: TEST_CLIENT,
491-
chain: ANVIL_CHAIN,
492-
account: TEST_ACCOUNT_C,
493-
type: "TokenERC20",
494-
params: {
495-
name: "token20",
496-
contractURI: TEST_CONTRACT_URI,
497-
},
498-
});
499-
const tokenId = 5n;
500-
const setClaimTx = setClaimConditions({
501-
contract,
502-
tokenId,
503-
phases: [
504-
{
505-
maxClaimableSupply: 100n,
506-
maxClaimablePerWallet: 100n,
507-
currencyAddress: tokenAddress,
508-
price: 1000,
509-
startTime: new Date(),
510-
},
511-
],
512-
});
513-
await sendAndConfirmTransaction({
514-
transaction: setClaimTx,
515-
account: TEST_ACCOUNT_C,
516-
});
517-
518-
const transaction = claimTo({
519-
contract,
520-
tokenId,
521-
quantity: 50n,
522-
to: TEST_ACCOUNT_C.address,
523-
});
524-
await sendAndConfirmTransaction({
525-
transaction,
526-
account: TEST_ACCOUNT_C,
527-
});
528-
const supplyCount = await totalSupply({ contract, id: tokenId });
529-
expect(supplyCount).toBe(50n);
530-
});
531-
532473
it("getActiveClaimCondition should work", async () => {
533474
// Create a public allowlist claim phase
534475
const snapshot = [

packages/thirdweb/src/react/web/wallets/shared/OTPLoginUI.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ export function OTPLoginUI(props: {
276276

277277
{!isWideModal && <Line />}
278278

279-
<Container p={isWideModal ? undefined : "lg"}>
279+
<Container p={isWideModal ? undefined : "lg"} gap="xs">
280280
{accountStatus === "error" && (
281281
<Text size="sm" center color="danger">
282282
{locale.emailLoginScreen.failedToSendCode}
@@ -297,7 +297,7 @@ export function OTPLoginUI(props: {
297297
</Container>
298298
)}
299299

300-
{accountStatus === "sent" && (
300+
{accountStatus !== "sending" && (
301301
<LinkButton onClick={sendEmailOrSms} type="button">
302302
{locale.emailLoginScreen.resendCode}
303303
</LinkButton>

packages/thirdweb/src/transaction/actions/gasless/providers/engine.test.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,12 @@ describe.runIf(process.env.TW_SECRET_KEY)("prepareengineTransaction", () => {
7474
const { message, messageType, signature } = result;
7575

7676
expect(isHex(signature)).toBe(true);
77-
expect(message).toMatchInlineSnapshot(`
78-
{
79-
"data": "0xa9059cbb00000000000000000000000070997970c51812dc3a010c7d01b50e0d17dc79c80000000000000000000000000000000000000000000000056bc75e2d63100000",
80-
"from": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
81-
"gas": 64340n,
82-
"nonce": 0n,
83-
"to": "${erc20Contract.address}",
84-
"value": 0n,
85-
}
86-
`);
77+
expect(message.data).toBe(
78+
"0xa9059cbb00000000000000000000000070997970c51812dc3a010c7d01b50e0d17dc79c80000000000000000000000000000000000000000000000056bc75e2d63100000",
79+
);
80+
expect(message.from).toBe(TEST_ACCOUNT_A.address);
81+
expect(message.to).toBe(erc20Contract.address);
82+
expect(message.value).toBe(0n);
8783
expect(messageType).toMatchInlineSnapshot(`"forward"`);
8884
});
8985

packages/thirdweb/src/transaction/actions/gasless/providers/openzeppelin.test.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,12 @@ describe.runIf(process.env.TW_SECRET_KEY)(
7272
const { message, messageType, signature } = result;
7373

7474
expect(isHex(signature)).toBe(true);
75-
expect(message).toMatchInlineSnapshot(`
76-
{
77-
"data": "0xa9059cbb00000000000000000000000070997970c51812dc3a010c7d01b50e0d17dc79c80000000000000000000000000000000000000000000000056bc75e2d63100000",
78-
"from": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
79-
"gas": 64340n,
80-
"nonce": 0n,
81-
"to": "${erc20Contract.address}",
82-
"value": 0n,
83-
}
84-
`);
75+
expect(message.from).toBe(TEST_ACCOUNT_A.address);
76+
expect(message.to).toBe(erc20Contract.address);
77+
expect(message.value).toBe(0n);
78+
expect(message.data).toBe(
79+
"0xa9059cbb00000000000000000000000070997970c51812dc3a010c7d01b50e0d17dc79c80000000000000000000000000000000000000000000000056bc75e2d63100000",
80+
);
8581
expect(messageType).toMatchInlineSnapshot(`"forward"`);
8682
});
8783
},

packages/thirdweb/src/wallets/smart/smart-wallet-integration-v07.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ describe.runIf(process.env.TW_SECRET_KEY).sequential(
200200
});
201201

202202
await expect(tx).rejects.toMatchInlineSnapshot(`
203-
[TransactionError: Error - Not authorized
203+
[TransactionError: Execution Reverted: {"code":3,"message":"execution reverted: Not authorized"}
204204
205205
contract: ${contract.address}
206206
chainId: 11155111]

0 commit comments

Comments
 (0)