-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(test-d): add test-d files for vitest typechecking: (#1248)
# Pull Request Checklist - [x] Did you add new tests and confirm existing tests pass? (`yarn test`) - [x] Did you update relevant docs? (docs are found in the `site` folder, and guidelines for updating/adding docs can be found in the [contribution guide](https://github.com/alchemyplatform/aa-sdk/blob/main/CONTRIBUTING.md)) - [x] Do your commits follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard? - [x] Does your PR title also follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard? - [x] If you have a breaking change, is it [correctly reflected in your commit message](https://www.conventionalcommits.org/en/v1.0.0/#examples)? (e.g. `feat!: breaking change`) - [x] Did you run lint (`yarn lint:check`) and fix any issues? (`yarn lint:write`) - [x] Did you follow the [contribution guidelines](https://github.com/alchemyplatform/aa-sdk/blob/main/CONTRIBUTING.md)? <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on enhancing type checking and testing for the `account-kit` packages, particularly by adding `test-d.ts` files and updating test commands. It also removes unused code related to Alchemy transport. ### Detailed summary - Added `test-d.ts` files for type definitions in multiple packages. - Updated `.github/workflows/on-pull-request.yml` to include type checking in tests. - Modified `package.json` to add a new `test:typecheck` script. - Updated `CONTRIBUTING.md` to reflect changes in testing commands. - Removed Alchemy-related code from `client.test.ts`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
- Loading branch information
Showing
28 changed files
with
157 additions
and
129 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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
125 changes: 125 additions & 0 deletions
125
account-kit/smart-contracts/src/light-account/clients/client.test-d.ts
This file contains 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,125 @@ | ||
import { | ||
erc7677Middleware, | ||
LocalAccountSigner, | ||
type SmartAccountClient, | ||
type SmartAccountSigner, | ||
} from "@aa-sdk/core"; | ||
import { | ||
custom, | ||
type Address, | ||
type Chain, | ||
type Client, | ||
type CustomTransport, | ||
} from "viem"; | ||
import { accounts } from "~test/constants.js"; | ||
import { local060Instance } from "~test/instances.js"; | ||
import type { LightAccountVersion } from "../types.js"; | ||
import { createLightAccountClient } from "./client.js"; | ||
import { | ||
alchemy, | ||
polygonMumbai, | ||
alchemyEnhancedApiActions, | ||
type AlchemyTransport, | ||
type AlchemySmartAccountClient, | ||
type AlchemyEnhancedApis, | ||
} from "@account-kit/infra"; | ||
import { Alchemy, Network } from "alchemy-sdk"; | ||
|
||
describe("Types: Light Account Tests", () => { | ||
const instance = local060Instance; | ||
const signer: SmartAccountSigner = new LocalAccountSigner( | ||
accounts.fundedAccountOwner | ||
); | ||
|
||
const givenConnectedProvider = ({ | ||
signer, | ||
version = "v1.1.0", | ||
accountAddress, | ||
usePaymaster = false, | ||
}: { | ||
signer: SmartAccountSigner; | ||
version?: LightAccountVersion<"LightAccount">; | ||
usePaymaster?: boolean; | ||
accountAddress?: Address; | ||
}) => | ||
createLightAccountClient({ | ||
signer, | ||
accountAddress, | ||
version, | ||
transport: custom(instance.getClient()), | ||
chain: instance.chain, | ||
...(usePaymaster ? erc7677Middleware() : {}), | ||
}); | ||
|
||
const givenAlchemyConnectedProvider = async ({ | ||
signer, | ||
chain, | ||
}: { | ||
signer: SmartAccountSigner; | ||
chain: Chain; | ||
}) => | ||
createLightAccountClient({ | ||
transport: alchemy({ | ||
jwt: "test", | ||
}), | ||
chain, | ||
signer, | ||
accountAddress: "0x86f3B0211764971Ad0Fc8C8898d31f5d792faD84", | ||
}); | ||
it("Should have some alchemy specific types", async () => { | ||
const alchemy = new Alchemy({ | ||
network: Network.MATIC_MUMBAI, | ||
apiKey: "test", | ||
}); | ||
const chain = polygonMumbai; | ||
|
||
const provider = ( | ||
await givenAlchemyConnectedProvider({ signer, chain }) | ||
).extend(alchemyEnhancedApiActions(alchemy)); | ||
|
||
assertType<Client<AlchemyTransport>>(provider); | ||
assertType<AlchemySmartAccountClient>(provider); | ||
assertType<SmartAccountClient>(provider); | ||
assertType<AlchemyEnhancedApis>(provider); | ||
assertType<AlchemyEnhancedApis>( | ||
// @ts-expect-error | ||
await givenAlchemyConnectedProvider({ signer, chain }) | ||
); | ||
// @ts-expect-error | ||
assertType<Client<CustomTransport>>(provider); | ||
}); | ||
it("Should have some non-alchemy specific types", async () => { | ||
const chain = polygonMumbai; | ||
|
||
const signer: SmartAccountSigner = new LocalAccountSigner( | ||
accounts.fundedAccountOwner | ||
); | ||
const provider = await givenConnectedProvider({ | ||
signer, | ||
version: "v1.0.1", | ||
}); | ||
|
||
assertType<SmartAccountClient>(provider); | ||
assertType<Client<CustomTransport>>(provider); | ||
assertType<AlchemyEnhancedApis>( | ||
// @ts-expect-error | ||
await givenAlchemyConnectedProvider({ signer, chain }) | ||
); | ||
// @ts-expect-error | ||
assertType<Client<AlchemyTransport>>(provider); | ||
// @ts-expect-error | ||
assertType<AlchemySmartAccountClient>(provider); | ||
// @ts-expect-error | ||
assertType<AlchemyEnhancedApis>(provider); | ||
|
||
expect(() => { | ||
const alchemy = new Alchemy({ | ||
network: Network.MATIC_MUMBAI, | ||
apiKey: "test", | ||
}); | ||
|
||
// @ts-expect-error | ||
provider.extend(alchemyEnhancedApiActions(alchemy)); | ||
}).not.toBeFalsy(); | ||
}); | ||
}); |
Oops, something went wrong.