Skip to content
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

Feat/react components #31

Draft
wants to merge 38 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
eacd4e3
chore: update vite and tailwind
bluecco Nov 15, 2023
87dc0b7
chore: configure storybook
bluecco Nov 15, 2023
2dc4d1d
chore: generate icons for react library
bluecco Nov 15, 2023
0f55112
feat: ConnectButton for component library
bluecco Nov 15, 2023
ed740d9
feat: NotificationMenu for component library
bluecco Nov 15, 2023
84f771a
chore: address helper
bluecco Nov 15, 2023
5b9780d
feat: connect button update and add connected menu
bluecco Nov 15, 2023
1b308a1
feat: starknetkit button and wallet context
bluecco Nov 21, 2023
cb633e4
chore: refactor starknetkit button and connected button
bluecco Nov 21, 2023
d551fc8
chore: removed ununsed property
bluecco Nov 21, 2023
02dd0bc
chore: update vite config
bluecco Nov 22, 2023
c839229
chore: update packages
bluecco Nov 22, 2023
a0d04fa
chore: update connect components
bluecco Nov 23, 2023
6a32f6d
chore: refactor connector folder structure
bluecco Nov 23, 2023
565a57e
chore: refactor ui folder structure
bluecco Nov 23, 2023
d4d62d6
chore: clean and update root folder
bluecco Nov 23, 2023
3b1b2de
chore: refactor files structure and update packages
bluecco Nov 24, 2023
39142c6
fix: storybook preview
bluecco Nov 24, 2023
35cdffa
feat: finish connect button and add helper methods
bluecco Nov 24, 2023
0c50c04
chore: add connect button stories
bluecco Nov 24, 2023
525c4b4
Merge pull request #34 from argentlabs/fix/restructure-project
bluecco Nov 27, 2023
34aa353
chore: refactor connect button and remove bigDecimal helper
bluecco Dec 5, 2023
0b07b21
chore: add tests for ui helpers
bluecco Dec 14, 2023
9def1e4
chore: refactor folders for ui
bluecco Dec 14, 2023
290d159
chore: update stories
bluecco Dec 14, 2023
bc56d9e
chore: update balance format helpers
bluecco Dec 14, 2023
8719926
Merge pull request #35 from argentlabs/feat/connect-button-updates
bluecco Dec 14, 2023
b549951
feat: add custom styling to connect buttons
bluecco Dec 28, 2023
001064d
feat: add starknetId hook and helpers
bluecco Jan 4, 2024
f5303f3
feat: add starknetkit to ConnectedButton component
bluecco Jan 4, 2024
7dddfba
chore: use @argent/x-multicall package
bluecco Jan 4, 2024
06f402d
chore: update stories and remove console log
bluecco Jan 4, 2024
a808ef0
chore: remove wrong class
bluecco Jan 4, 2024
014a2ff
Merge pull request #55 from argentlabs/feat/starknetid-info
bluecco Jan 4, 2024
22a352d
Merge branch 'develop' into feat/react-components
bluecco Jan 4, 2024
f24bfba
chore: remove old folder
bluecco Jan 4, 2024
32bfc0d
chore: update starknetkit on ui package and export components
bluecco Jan 4, 2024
368ef1a
chore: address todo
bluecco Jan 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@
"es2021": true,
"node": true
},
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:storybook/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": ["@typescript-eslint"],
"plugins": [
"@typescript-eslint"
],
"rules": {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-extra-semi": "off",
Expand Down
45 changes: 2 additions & 43 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,11 @@
"*.{ts,tsx}": "eslint --cache --ext .ts,.tsx"
},
"type": "module",
"exports": {
".": {
"types": "./dist/starknetkit.d.ts",
"import": "./dist/starknetkit.js",
"require": "./dist/starknetkit.cjs"
},
"./webwallet": {
"types": "./dist/webwalletConnector.d.ts",
"import": "./dist/webwalletConnector.js",
"require": "./dist/webwalletConnector.cjs"
},
"./argentMobile": {
"types": "./dist/argentMobile.d.ts",
"import": "./dist/argentMobile.js",
"require": "./dist/argentMobile.cjs"
},
"./injected": {
"types": "./dist/injectedConnector.d.ts",
"import": "./dist/injectedConnector.js",
"require": "./dist/injectedConnector.cjs"
}
},
"main": "./dist/starknetkit.cjs",
"module": "./dist/starknetkit.js",
"types": "./dist/starknetkit.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "vite build",
"check": "svelte-check --tsconfig ./tsconfig.json",
"dev": "vite build --watch"
"build": "pnpm run -r --parallel --stream build"
},
"dependencies": {
"@trpc/client": "^10.38.1",
Expand All @@ -64,44 +37,30 @@
"events": "^3.3.0",
"get-starknet-core": "^3.1.0",
"lodash-es": "^4.17.21",
"svelte-forms": "^2.3.1",
"trpc-browser": "^1.3.2"
},
"devDependencies": {
"@commitlint/cli": "^17.7.1",
"@commitlint/config-conventional": "^17.7.0",
"@semantic-release/git": "^10.0.1",
"@sveltejs/vite-plugin-svelte": "^2.2.0",
"@tsconfig/svelte": "^5.0.0",
"@types/async-retry": "^1.4.5",
"@types/lodash-es": "^4.17.8",
"@types/node": "^20.5.7",
"@typescript-eslint/eslint-plugin": "^6.5.0",
"@walletconnect/ethereum-provider": "^2.7.7",
"@walletconnect/jsonrpc-provider": "^1.0.13",
"@walletconnect/signer-connection": "^2.7.7",
"@walletconnect/types": "^2.7.7",
"@walletconnect/utils": "^2.10.0",
"autoprefixer": "^10.4.7",
"eslint": "^8.48.0",
"eslint-config-next": "^13.4.19",
"husky": "^8.0.3",
"lint-staged": "^14.0.1",
"postcss": "^8.4.21",
"postcss-load-config": "^4.0.1",
"prettier": "^3.0.3",
"prettier-plugin-import-sort": "^0.0.7",
"semantic-release": "^21.1.1",
"svelte": "^4.0.0",
"svelte-check": "^3.5.1",
"svelte-preprocess": "^5.0.4",
"tailwindcss": "^3.1.6",
"tslib": "^2.4.0",
"typescript": "^5.1.6",
"vite": "^4.3.8",
"vite-plugin-dts": "^3.0.0",
"ws": "^8.8.1",
"zod": "^3.20.6"
"zod": "^3.22.4"
},
"peerDependencies": {
"starknet": "^5.24.3"
Expand Down
90 changes: 90 additions & 0 deletions packages/connectors/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
"name": "starknetkit",
"version": "1.0.20",
"repository": "github:argentlabs/starknetkit",
"private": false,
"browser": {
"crypto": false
},
"keywords": [
"starknet",
"starkware",
"l2",
"zk",
"rollup",
"wallet",
"dapp"
],
"license": "MIT",
"lint-staged": {
"*.{js,jsx,ts,tsx,css,md,yml,json}": "prettier --write",
"*.{ts,tsx}": "eslint --cache --ext .ts,.tsx"
},
"type": "module",
"exports": {
".": {
"types": "./dist/starknetkit.d.ts",
"import": "./dist/starknetkit.js",
"require": "./dist/starknetkit.cjs"
},
"./webwallet": {
"types": "./dist/webwalletConnector.d.ts",
"import": "./dist/webwalletConnector.js",
"require": "./dist/webwalletConnector.cjs"
},
"./argentMobile": {
"types": "./dist/argentMobile.d.ts",
"import": "./dist/argentMobile.js",
"require": "./dist/argentMobile.cjs"
},
"./injected": {
"types": "./dist/injectedConnector.d.ts",
"import": "./dist/injectedConnector.js",
"require": "./dist/injectedConnector.cjs"
}
},
"main": "./dist/starknetkit.cjs",
"module": "./dist/starknetkit.js",
"types": "./dist/starknetkit.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "vite build",
"check": "svelte-check --tsconfig ./tsconfig.json",
"dev": "vite build --watch"
},
"dependencies": {
"@trpc/client": "^10.38.1",
"@trpc/server": "^10.38.1",
"@walletconnect/sign-client": "^2.10.1",
"bowser": "^2.11.0",
"detect-browser": "^5.3.0",
"eventemitter3": "^5.0.1",
"events": "^3.3.0",
"get-starknet-core": "^3.1.0",
"lodash-es": "^4.17.21",
"trpc-browser": "^1.3.2"
},
"devDependencies": {
"@commitlint/cli": "^17.7.1",
"@commitlint/config-conventional": "^17.7.0",
"@sveltejs/vite-plugin-svelte": "^3.0.1",
"@tsconfig/svelte": "^5.0.0",
"@typescript-eslint/eslint-plugin": "^6.5.0",
"@walletconnect/ethereum-provider": "^2.7.7",
"@walletconnect/jsonrpc-provider": "^1.0.13",
"@walletconnect/signer-connection": "^2.7.7",
"@walletconnect/types": "^2.7.7",
"@walletconnect/utils": "^2.10.0",
"autoprefixer": "^10.4.7",
"eslint": "^8.48.0",
"eslint-config-next": "^13.4.19",
"postcss": "^8.4.21",
"postcss-load-config": "^4.0.1",
"svelte": "^4.0.0",
"svelte-check": "^3.5.1",
"svelte-preprocess": "^5.0.4"
},
"gitHead": "b16688a8638cc138938e74e1a39d004760165d75"
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class StarknetAdapter
methods: this.methods,
events: this.events,
}
this.signerConnection = this.getSignerConnection(client)
this.signerConnection = this.getSignerConnection(client as any)
this.rpcProvider = new JsonRpcProvider(this.signerConnection)
this.client = client
this.registerEventListeners()
Expand Down Expand Up @@ -178,7 +178,6 @@ export class StarknetAdapter
super.registerEventListeners()
this.eventEmitter.on("chainChanged", (_chainId: string) => {
throw new Error("Not implemented: chainChanged")
// TODO: update provider
})
}

Expand Down
File renamed without changes.
File renamed without changes.
15 changes: 15 additions & 0 deletions packages/connectors/src/helpers/address.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { encode } from "starknet"

export const formatAddress = (address: string) =>
encode.addHexPrefix(encode.removeHexPrefix(address).padStart(64, "0"))

export const truncateAddress = (address: string) => {
return truncateHex(formatAddress(address))
}

export const truncateHex = (value: string) => {
const hex = value.slice(0, 2)
const start = value.slice(2, 6)
const end = value.slice(-4)
return `${hex}${start}…${end}`
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ export function mapTargetUrlToNetworkId(target: string): constants.NetworkName {
if (origin.includes("staging")) {
return Network.SN_MAIN
}
if (origin.includes("dev")) {
return Network.SN_GOERLI2
}
if (origin.includes("argent.xyz")) {
return Network.SN_MAIN
}
Expand Down
14 changes: 12 additions & 2 deletions src/main.ts → packages/connectors/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ import {
} from "./helpers/lastConnected"
import { mapModalWallets } from "./helpers/mapModalWallets"
import Modal from "./modal/Modal.svelte"
import type { ConnectOptions, ModalWallet } from "./types/modal"
import type {
ConnectOptions,
ModalWallet,
ModalMode,
ModalTheme,
} from "./types/modal"

import { Connector } from "./connectors"
import type { Connector } from "./connectors"
import css from "./theme.css?inline"

let selectedConnector: Connector | null = null
Expand Down Expand Up @@ -153,4 +158,9 @@ export type {
DisconnectOptions,
DisconnectedStarknetWindowObject,
StarknetWindowObject,
Connector,
ModalMode,
ModalTheme,
}

export { DEFAULT_WEBWALLET_URL }
File renamed without changes.
File renamed without changes.
8 changes: 6 additions & 2 deletions src/types/modal.ts → packages/connectors/src/types/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ import { ProviderInterface } from "starknet"

export type StoreVersion = "chrome" | "firefox" | "edge"

export type ModalMode = "alwaysAsk" | "canAsk" | "neverAsk"

export type ModalTheme = "light" | "dark" | "system"

export interface ConnectOptions extends GetWalletOptions {
argentMobileOptions?: ArgentMobileConnectorOptions
dappName?: string
connectors?: Connector[]
modalMode?: "alwaysAsk" | "canAsk" | "neverAsk"
modalTheme?: "light" | "dark" | "system"
modalMode?: ModalMode
modalTheme?: ModalTheme
storeVersion?: StoreVersion | null
webWalletUrl?: string
provider?: ProviderInterface
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions vite.config.ts → packages/connectors/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import dts from "vite-plugin-dts"
export default defineConfig({
build: {
rollupOptions: {
external: ["starknet"],
external: ["starknet",],
},
emptyOutDir: false,
target: "es2020",
Expand All @@ -34,7 +34,6 @@ export default defineConfig({
plugins: [
svelte({ emitCss: false }),
dts({
entryRoot: resolve(__dirname, "src"),
insertTypesEntry: true,
}),
],
Expand Down
14 changes: 14 additions & 0 deletions packages/ui/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:react-hooks/recommended', 'plugin:storybook/recommended'],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
24 changes: 24 additions & 0 deletions packages/ui/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
19 changes: 19 additions & 0 deletions packages/ui/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { StorybookConfig } from "@storybook/react-vite"

const config: StorybookConfig = {
stories: ["../storybook/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-onboarding",
"@storybook/addon-interactions",
],
framework: {
name: "@storybook/react-vite",
options: {},
},
docs: {
autodocs: "tag",
},
}
export default config
16 changes: 16 additions & 0 deletions packages/ui/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import "../src/styles.css"
import type { Preview } from "@storybook/react"

const preview: Preview = {
parameters: {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
},
}

export default preview
Loading