Skip to content

Commit

Permalink
[SDK] Fix: logout on iframe (#4809)
Browse files Browse the repository at this point in the history
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on fixing account logout functionality and updating error messages related to transaction limits across various tests in the `thirdweb` package.

### Detailed summary
- Updated `logout` method in `iframe-auth.ts` to check for `AuthQuerier` before calling logout.
- Changed expected address in `deploy-published.test.ts`.
- Updated error messages from `TransactionError: Error - !Qty` to `DropClaimExceedLimit` in multiple test files for `erc20`, `erc721`, and `erc1155`.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
  • Loading branch information
gregfromstl committed Sep 26, 2024
1 parent 9c58c08 commit 500970e
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/quick-queens-love.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Fixes account logout state
8 changes: 4 additions & 4 deletions packages/thirdweb/src/extensions/erc1155/drop1155.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,10 @@ describe.runIf(process.env.TW_SECRET_KEY)(
}),
}),
).rejects.toThrowErrorMatchingInlineSnapshot(`
[TransactionError: Error - !Qty
[TransactionError: DropClaimExceedLimit - 0,1
contract: ${contract.address}
chainId: 31337]
chainId: ${contract.chain.id}]
`);
});

Expand Down Expand Up @@ -247,7 +247,7 @@ describe.runIf(process.env.TW_SECRET_KEY)(
}),
}),
).rejects.toThrowErrorMatchingInlineSnapshot(`
[TransactionError: Error - !Qty
[TransactionError: DropClaimExceedLimit - 1,2
contract: ${contract.address}
chainId: ${contract.chain.id}]
Expand Down Expand Up @@ -378,7 +378,7 @@ describe.runIf(process.env.TW_SECRET_KEY)(
account: TEST_ACCOUNT_D,
}),
).rejects.toThrowErrorMatchingInlineSnapshot(`
[TransactionError: Error - !Qty
[TransactionError: DropClaimExceedLimit - 1,2
contract: ${contract.address}
chainId: ${contract.chain.id}]
Expand Down
8 changes: 4 additions & 4 deletions packages/thirdweb/src/extensions/erc20/drop20.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,10 @@ describe.runIf(process.env.TW_SECRET_KEY)(
}),
}),
).rejects.toThrowErrorMatchingInlineSnapshot(`
[TransactionError: Error - !Qty
[TransactionError: DropClaimExceedLimit - 0,1000000000000000000
contract: ${contract.address}
chainId: 31337]
chainId: ${contract.chain.id}]
`);
});

Expand Down Expand Up @@ -262,7 +262,7 @@ describe.runIf(process.env.TW_SECRET_KEY)(
}),
}),
).rejects.toThrowErrorMatchingInlineSnapshot(`
[TransactionError: Error - !Qty
[TransactionError: DropClaimExceedLimit - 3000000000000000000,4000000000000000000
contract: ${contract.address}
chainId: ${contract.chain.id}]
Expand Down Expand Up @@ -421,7 +421,7 @@ describe.runIf(process.env.TW_SECRET_KEY)(
account: TEST_ACCOUNT_D,
}),
).rejects.toThrowErrorMatchingInlineSnapshot(`
[TransactionError: Error - !Qty
[TransactionError: DropClaimExceedLimit - 1,2
contract: ${contract.address}
chainId: ${contract.chain.id}]
Expand Down
8 changes: 4 additions & 4 deletions packages/thirdweb/src/extensions/erc721/drop721.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,10 @@ describe.runIf(process.env.TW_SECRET_KEY)(
}),
}),
).rejects.toThrowErrorMatchingInlineSnapshot(`
[TransactionError: Error - !Qty
[TransactionError: DropClaimExceedLimit - 0,1
contract: ${contract.address}
chainId: 31337]
chainId: ${contract.chain.id}]
`);
});

Expand Down Expand Up @@ -279,7 +279,7 @@ describe.runIf(process.env.TW_SECRET_KEY)(
}),
}),
).rejects.toThrowErrorMatchingInlineSnapshot(`
[TransactionError: Error - !Qty
[TransactionError: DropClaimExceedLimit - 3,4
contract: ${contract.address}
chainId: ${contract.chain.id}]
Expand Down Expand Up @@ -405,7 +405,7 @@ describe.runIf(process.env.TW_SECRET_KEY)(
account: TEST_ACCOUNT_D,
}),
).rejects.toThrowErrorMatchingInlineSnapshot(`
[TransactionError: Error - !Qty
[TransactionError: DropClaimExceedLimit - 1,2
contract: ${contract.address}
chainId: ${contract.chain.id}]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe.runIf(process.env.TW_SECRET_KEY)(
},
salt: "test",
});
expect(address).toBe("0x777151741260F8d4098dD492e45FdB536F442672");
expect(address).toBe("0x9A18AD1DdCfA00009C2db7dc78a5746d85feF759");
const isDeployed = await isContractDeployed({
client: TEST_CLIENT,
chain: ANVIL_CHAIN,
Expand Down
5 changes: 4 additions & 1 deletion packages/thirdweb/src/react/web/ui/ConnectWallet/Details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,10 @@ function InAppWalletUserInfo(props: {
const { data: walletInfo } = useWalletInfo(activeWallet?.id);
const isSmartWallet = hasSmartAccount(activeWallet);
const { data: walletName } = useQuery({
queryKey: [activeWallet?.id, "wallet-name"],
queryKey: [
"wallet-name",
{ walletId: activeWallet?.id, walletAddress: account?.address },
],

Check warning on line 1081 in packages/thirdweb/src/react/web/ui/ConnectWallet/Details.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/Details.tsx#L1078-L1081

Added lines #L1078 - L1081 were not covered by tests
queryFn: async () => {
const lastAuthProvider = await getLastAuthProvider(webLocalStorage);
if (lastAuthProvider === "guest") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,13 @@ export class Auth {
* @internal
*/
async logout(): Promise<LogoutReturnType> {
if (this.AuthQuerier) {
await this.AuthQuerier.call<LogoutReturnType>({
procedureName: "logout",
params: undefined,
});
}

const isRemoveAuthCookie = await this.localStorage.removeAuthCookie();
const isRemoveUserId = await this.localStorage.removeWalletUserId();

Expand Down

0 comments on commit 500970e

Please sign in to comment.