Skip to content

Commit

Permalink
@tomo-inc/wallet-connect-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
ty-bt committed Nov 11, 2024
0 parents commit 9c5fa46
Show file tree
Hide file tree
Showing 76 changed files with 9,212 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
43 changes: 43 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"env": {
"browser": true,
"es2020": true,
"jest": true,
"node": true
},
"settings": {
"react": {
"version": "detect"
}
},
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
// "plugin:prettier/recommended",
"plugin:tailwindcss/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 11,
"sourceType": "module"
},
"plugins": ["react", "react-hooks", "@typescript-eslint", "tailwindcss"],
"rules": {
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
"react/prop-types": "off",
"react/react-in-jsx-scope": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"tailwindcss/classnames-order": "warn",
"tailwindcss/no-custom-classname": "warn",
"tailwindcss/no-contradicting-classname": "error",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": "off"
}
}
42 changes: 42 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
dist
dist-ssr
*.local

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build
.vscode
.idea

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

# vercel
.vercel

# pnpm
pnpm-lock.yaml
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"trailingComma": "none",
"semi": false,
"singleQuote": true
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# MIT License

Copyright (c) 2023-present TOMO INC, https://tomo.inc/

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
165 changes: 165 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
# @tomo-inc/wallet-connect-sdk

## What is inside?

### Install

```bash
npm install @tomo-inc/wallet-connect-sdk
```

```bash
yarn add @tomo-inc/wallet-connect-sdk
```

### Integration Guide
```javascript
import {
TomoContextProvider,
TomoSocial,
useTomoProviders,
useTomoModalControl,
useTomoWalletConnect,
useTomoWalletState
} from '@tomo-inc/wallet-connect-sdk'

export default function Demo() {
return (
<TomoContextProvider
// optional
style={{
rounded: 'medium',
theme: 'light',
primaryColor: '#FF7C2A'
}}
// optional
additionalWallets={[
{
id: 'xyz',
name: 'XYZ BTC Wallet',
chainType: 'bitcoin',
connectProvider: XYZWallet,
type: 'extension',
img: 'https://upload.wikimedia.org/wikipedia/commons/2/2f/Google_2015_logo.svg'
}
]}
// optional
indexWallets={[
'bitcoin_okx',
'bitcoin_unisat',
'bitcoin_tomo',
'bitcoin_onekey',
'bitcoin_bitget',
'bitcoin_keystone',
'bitcoin_imtoken',
'bitcoin_binance',
'xyz'
]}
// optional
connectionHints={[
{
text: 'Subject to Developer’s compliance with the terms and conditions of this Agreement',
logo: (
<img className={'tm-size-5'} src={'https://tomo.inc/favicon.ico'} />
)
},
{
text: 'I certify that there are no Bitcoin inscriptions tokens in my wallet.'
},
{
isRequired: true,
text: (
<span>
I certify that I have read and accept the updated{' '}
<a className={'tm-text-primary'}>Terms of Use</a> and{' '}
<a className={'tm-text-primary'}>Privacy Policy</a>.
</span>
)
}
]}

// optional
uiOptions={{
termsAndServiceUrl: 'https://policies.google.com/terms',
privacyPolicyUrl: 'https://policies.google.com/privacy'
}}
>
<ChildComponent />
</TomoContextProvider>
)
}

export function ChildComponent() {
const tomoModal = useTomoModalControl()
const tomoWalletState = useTomoWalletState()
const tomoClientMap = useTomoProviders()
const tomoWalletConnect = useTomoWalletConnect()
return (
<div className={'tomo-social tm-flex tm-h-screen tm-w-screen'}>
<div
className={
'tm-flex tm-h-full tm-flex-1 tm-flex-col tm-gap-4 tm-border-r tm-border-r-tc1/10 dark:tm-border-r-tc1-dark/10 tm-px-10 tm-py-10 tm-overflow-auto'
}
>
<div className={'tm-flex tm-gap-3 tm-flex-wrap'}>
<LodingButton
onClick={async () => {
await tomoModal.open('connect')
}}
>
Connect
</LodingButton>
<LodingButton
onClick={async () => {
await tomoWalletConnect.disconnect()
}}
>
Disconnect
</LodingButton>
</div>

<ShowJson obj={tomoWalletState} title={'useTomoWalletState'} />
<ShowJson obj={tomoClientMap} title={'useTomoProviders'} />
</div>
<div className={'tm-flex tm-flex-col tm-gap-4 tm-px-20 tm-py-10'}>
<div>tomo social</div>
<TomoSocial />
</div>
</div>
)
}

function LodingButton({
onClick,
disabled,
...otherProps
}: React.DetailedHTMLProps<
React.ButtonHTMLAttributes<HTMLButtonElement>,
HTMLButtonElement
>) {
return (
<button
{...otherProps}
/>
)
}

function ShowJson({ title, obj, rows = 10 }) {
const jsonFn = function jsonValueFn(key, value) {
if (key && this !== obj) {
return 'any'
}
return value
}
return (
<div>
<div>{title}: </div>
<textarea
value={JSON.stringify(obj, jsonFn, '\t')}
className={'tm-w-full'}
rows={rows}
></textarea>
</div>
)
}
```
15 changes: 15 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/logo.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>
tomo social demo
</title>
</head>
<body style="margin: 0; padding:0">
<div id="root"></div>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>
87 changes: 87 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"name": "@tomo-inc/wallet-connect-sdk",
"description": "wallet-connect-sdk",
"version": "0.2.19",
"type": "module",
"exports": {
".": {
"import": "./dist/main.js",
"require": "./dist/main.cjs"
},
"./style.css": "./dist/style.css"
},
"main": "./dist/main.cjs",
"module": "./dist/main.js",
"typings": "./dist/main.d.ts",
"files": [
"dist"
],
"scripts": {
"dev": "vite",
"build": "vite build"
},
"dependencies": {
"@tomo-inc/tomo-wallet-provider": "^1.0.22",
"animate.css": "^4.1.1",
"buffer": "^6.0.3",
"classnames": "^2.5.1",
"clsx": "^2.1.0",
"immutability-helper": "^3.1.1",
"jotai": "^2.9.0",
"long": "^5.2.3",
"react": "^18",
"react-dom": "^18",
"tailwind-merge": "2.2.2"
},
"peerDependencies": {
"react": "^18",
"react-dom": "^18"
},
"devDependencies": {
"@bitcoinerlab/secp256k1": "^1.1.1",
"@cosmjs/launchpad": "^0.27.1",
"@cosmjs/stargate": "^0.32.4",
"@keystonehq/keystone-sdk": "^0.8.1",
"@keystonehq/sdk": "^0.21.3",
"@originjs/vite-plugin-commonjs": "^1.0.3",
"@rollup/plugin-inject": "^5.0.5",
"@rollup/plugin-typescript": "^8.2.1",
"@scure/bip32": "^1.5.0",
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/react": "^14.3.1",
"@types/node": "^20.12.12",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"@vitejs/plugin-basic-ssl": "^1.1.0",
"@vitejs/plugin-react-swc": "^3.7.0",
"@vitest/ui": "^1.6.0",
"autoprefixer": "^10.4.19",
"bignumber.js": "^9.1.2",
"bitcoinjs-lib": "^7.0.0-rc.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-tailwindcss": "^3.17.0",
"happy-dom": "^12.10.3",
"postcss": "^8.4.38",
"prettier": "3.1.1",
"rollup-plugin-typescript-paths": "^1.3.0",
"tailwindcss": "^3.4.3",
"typescript": "^5.4.5",
"vconsole": "^3.15.1",
"vite": "^5.2.11",
"vite-plugin-remove-console": "^2.2.0",
"vite-plugin-vconsole": "^2.1.1",
"vite-plugin-wasm": "^3.3.0",
"vite-require": "^0.2.3",
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^1.6.0"
},
"resolutions": {
"long": "^5.2.3"
}
}
Loading

0 comments on commit 9c5fa46

Please sign in to comment.