Skip to content

Commit

Permalink
Revert "Specify packages as ESM and extract common TS configs (#262)" (
Browse files Browse the repository at this point in the history
…#270)

This reverts commit ba27d87.
  • Loading branch information
broody authored Apr 15, 2024
1 parent b98ab47 commit 5ea4f52
Show file tree
Hide file tree
Showing 49 changed files with 7,677 additions and 3,886 deletions.
29 changes: 28 additions & 1 deletion examples/get-starknet/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,35 @@
{
"extends": "../../tsconfig.react.json",
"compilerOptions": {
"baseUrl": ".",
"rootDir": "./src",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"declaration": true,
"target": "ES2022",
"module": "ES2022",
"strict": false,
"jsx": "preserve",
"jsxImportSource": "@emotion/react",
"allowJs": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"incremental": true,
"esModuleInterop": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"downlevelIteration": true,
"noEmit": true,
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
],
"exclude": [
"node_modules"
],
}
3 changes: 1 addition & 2 deletions examples/starknet-react-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"@types/react": "^18.2.21",
"@types/react-dom": "^18.2.7",
"eslint": "^8.23.0",
"eslint-config-next": "^12.2.5",
"typescript": "^5.4.5"
"eslint-config-next": "^12.2.5"
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import ControllerConnector from "@cartridge/connector";
import { useAccount, useConnect, useDisconnect } from "@starknet-react/core";

export function ConnectWallet() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import {
useContractWrite,
useExplorer,
} from "@starknet-react/core";
import { useState } from "react";
import { useEffect, useState } from "react";

// const worldAddress =
// "0x426bf51e62109e5c98e7d36dddf813881b610a1ff7c241e51ec3533ce58778c";
const worldAddress =
"0x426bf51e62109e5c98e7d36dddf813881b610a1ff7c241e51ec3533ce58778c";
const actionsAddress =
"0x6823753387c85935c6a3d141fb273e35ea9114a5f6e1c2b69d7c5bc3916c7f2";

Expand Down
6 changes: 1 addition & 5 deletions examples/starknet-react-next/src/components/SignMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ import { useState } from "react";
import { typedData } from "starknet";

export function SignMessage() {
const {
// address,
account,
} = useAccount();
const { address, account } = useAccount();
// const { contract } = useContract({
// address,
// });
Expand Down Expand Up @@ -102,7 +99,6 @@ export function SignMessage() {
);
}

// @ts-expect-error workaround to parse json with bigint
BigInt.prototype["toJSON"] = function () {
return this.toString();
};
10 changes: 0 additions & 10 deletions examples/starknet-react-next/src/components/TransferEth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ export const TransferEth = () => {
const [txnHash, setTxnHash] = useState<string>();

const executePointOne = useCallback(async () => {
if (!account) {
return;
}

const res = await account.execute(
[
{
Expand All @@ -44,9 +40,6 @@ export const TransferEth = () => {
.finally(() => console.log("done"));
}, [account, chainId]);
const executeOne = useCallback(async () => {
if (!account) {
return;
}
setTxnHash(undefined);
const res = await account.execute(
[
Expand Down Expand Up @@ -74,9 +67,6 @@ export const TransferEth = () => {
.finally(() => console.log("done"));
}, [account, chainId]);
const execute005 = useCallback(async () => {
if (!account) {
return;
}
setTxnHash(undefined);
const res = await account.execute(
[
Expand Down
1 change: 0 additions & 1 deletion examples/starknet-react-next/src/pages/token.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ function UserBalance() {
return <div>Error!</div>;
}

// @ts-expect-error TODO: fix type
const balance = uint256.uint256ToBN(cairo.uint256(data[0]));
return <div>{balance.toString(10)}</div>;
}, [data, isLoading, error]);
Expand Down
20 changes: 19 additions & 1 deletion examples/starknet-react-next/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
{
"extends": "../../tsconfig.react.json",
"compilerOptions": {
"baseUrl": "./src",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"declaration": true,
"target": "ES2022",
"module": "esnext",
"strict": false,
"jsx": "preserve",
"allowJs": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"incremental": true,
"esModuleInterop": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"downlevelIteration": true,
"noEmit": true
},
"include": [
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
"ui": "pnpm --filter @cartridge/ui",
"ui:next": "pnpm --filter @cartridge/ui-next",
"example:next": "pnpm --filter starknet-react-next",
"example:get-starknet": "pnpm --filter get-starknet",
"test": "pnpm keychain test",
"test:ci": "pnpm keychain test:ci"
},
"devDependencies": {
"@changesets/changelog-github": "^0.4.2",
"@changesets/cli": "^2.20.0",
"prettier": "^2.7.1",
"turbo": "^1.10.11"
"turbo": "^1.10.11",
"typescript": "^5.2.2"
}
}
4 changes: 2 additions & 2 deletions packages/account-wasm/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"compilerOptions": {
"target": "ES2020",
"target": "ESNext",
"module": "ESNext",
"declaration": true,
"outDir": "./dist",
"sourceMap": true,
"noImplicitAny": true,
"noUnusedLocals": true,
"moduleResolution": "Bundler",
"moduleResolution": "node",
"skipLibCheck": true,
"strict": true,
"strictNullChecks": true,
Expand Down
18 changes: 13 additions & 5 deletions packages/connector/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,28 @@
"description": "Cartridge Controler Connector",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"type": "module",
"scripts": {
"build": "tsc",
"build": "tsc -b",
"prepublish": "pnpm build",
"dev": "tsc --watch",
"format": "prettier --write \"src/**/*.ts\""
"format": "prettier --write \"src/**/*.ts\"",
"test:watch": "jest --watchAll",
"test": "jest --ci --runInBand"
},
"files": [
"lib"
],
"devDependencies": {
"@types/jest": "^26.0.18",
"@types/node": "^17.0.23",
"jest": "^26.6.3",
"ts-jest": "^26.5.1",
"ts-node": "^10.4.0",
"tslib": "^2.3.1"
},
"dependencies": {
"@cartridge/controller": "workspace:^",
"@starknet-react/core": "^2.1.5",
"starknet": "^6.6.0",
"typescript": "^5.4.5"
"starknet": "^6.6.0"
}
}
14 changes: 4 additions & 10 deletions packages/connector/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,16 @@ class ControllerConnector extends Connector {
};

async chainId() {
if (!this._account) {
return Promise.reject("Account is not connected");
}
const val = await this._account.getChainId();
const val = await this.controller.account.getChainId();
return Promise.resolve(BigInt(val));
}

available(): boolean {
return true;
}

ready() {
return this.controller.ready();
async ready() {
return await this.controller.ready();
}

async register(
Expand Down Expand Up @@ -83,14 +80,11 @@ class ControllerConnector extends Connector {
};
}

disconnect(): Promise<void> {
async disconnect(): Promise<void> {
return this.controller.disconnect();
}

account() {
if (!this._account) {
return Promise.reject("account not found");
}
return Promise.resolve(this._account);
}

Expand Down
26 changes: 24 additions & 2 deletions packages/connector/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"baseUrl": ".",
"rootDir": "./src",
"outDir": "./lib"
"outDir": "lib",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"declaration": true,
"target": "ES2022",
"module": "ES2022",
"strict": false,
"jsx": "preserve",
"allowJs": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"incremental": true,
"esModuleInterop": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"downlevelIteration": true,
"sourceMap": true,
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules"
]
}
16 changes: 10 additions & 6 deletions packages/controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,29 @@
"description": "Cartridge Controller",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"type": "module",
"scripts": {
"build": "tsc",
"build": "tsc -b",
"dev": "tsc --watch",
"format": "prettier --write \"src/**/*.ts\""
},
"files": [
"lib"
],
"devDependencies": {
"@types/bn.js": "^5.1.1",
"@types/jest": "^26.0.18",
"@types/node": "^17.0.23",
"jest": "^26.6.3",
"ts-jest": "^26.5.1",
"ts-node": "^10.4.0",
"tslib": "^2.3.1"
},
"dependencies": {
"@cartridge/penpal": "^6.2.3",
"base64url": "^3.0.1",
"cbor-x": "^1.5.0",
"fast-deep-equal": "^3.1.3",
"query-string": "^7.1.1",
"starknet": "^6.6.0"
},
"devDependencies": {
"@types/node": "^20.6.0",
"typescript": "^5.4.5"
}
}
Loading

0 comments on commit 5ea4f52

Please sign in to comment.