├── .changeset
└── config.json
├── .editorconfig
├── .eslintignore
├── .eslintrc
├── .gitignore
├── .husky
├── commit-msg
└── pre-commit
├── .npmrc
├── .prettierignore
├── .prettierrc.json
├── App.md
├── LICENSE
├── README.md
├── demo.png
├── demos
├── cdn-demo
│ ├── .eslintrc
│ ├── .gitignore
│ ├── .npmrc
│ ├── .prettierrc.json
│ ├── README.md
│ ├── adapters
│ │ └── index.html
│ ├── bitkeep
│ │ └── index.html
│ ├── ledger
│ │ └── index.html
│ ├── metamask
│ │ └── index.html
│ ├── okxwallet
│ │ └── index.html
│ ├── package.json
│ ├── tokenpocket
│ │ └── index.html
│ ├── tronlink-evm
│ │ └── index.html
│ ├── tronlink
│ │ └── index.html
│ └── walletconnect
│ │ └── index.html
├── dev-demo
│ ├── .eslintrc
│ ├── .gitignore
│ ├── .npmrc
│ ├── .prettierrc.json
│ ├── index.html
│ ├── package.json
│ ├── scripts
│ │ └── ganache.cjs
│ ├── src
│ │ ├── App.tsx
│ │ ├── AppWraper.tsx
│ │ ├── BitgetAdapterDemo.tsx
│ │ ├── LedgerAdapterDemo.tsx
│ │ ├── LedgerDemo
│ │ │ ├── ConnectTip.tsx
│ │ │ ├── ConnectedSection.tsx
│ │ │ ├── CustomConnectWithGetAccounts.tsx
│ │ │ ├── CustomConnectWithSelectAccount.tsx
│ │ │ ├── SelectAccountSection.tsx
│ │ │ └── selectAccount.tsx
│ │ ├── Metamask.tsx
│ │ ├── OkxWalletAdapterDemo.tsx
│ │ ├── ReactHooksDemo.tsx
│ │ ├── TokenPocketAdapterDemo.tsx
│ │ ├── TronLinkAdapterDemo.tsx
│ │ ├── TronLinkEvmDemo.tsx
│ │ ├── index.css
│ │ ├── main.tsx
│ │ ├── theme.ts
│ │ ├── tronweb.ts
│ │ └── vite-env.d.ts
│ ├── tsconfig.json
│ ├── tsconfig.node.json
│ └── vite.config.ts
├── react-ui
│ ├── create-react-app
│ │ ├── .gitignore
│ │ ├── .npmrc
│ │ ├── README.md
│ │ ├── config-overrides.js
│ │ ├── package.json
│ │ ├── public
│ │ │ ├── favicon.ico
│ │ │ ├── index.html
│ │ │ ├── logo192.png
│ │ │ ├── logo512.png
│ │ │ ├── manifest.json
│ │ │ └── robots.txt
│ │ ├── src
│ │ │ ├── App.css
│ │ │ ├── App.test.tsx
│ │ │ ├── App.tsx
│ │ │ ├── index.css
│ │ │ ├── index.tsx
│ │ │ ├── logo.svg
│ │ │ ├── react-app-env.d.ts
│ │ │ ├── reportWebVitals.ts
│ │ │ ├── setupTests.ts
│ │ │ ├── theme.ts
│ │ │ └── tronweb.ts
│ │ └── tsconfig.json
│ ├── next-app
│ │ ├── .eslintrc.json
│ │ ├── .gitignore
│ │ ├── .npmrc
│ │ ├── README.md
│ │ ├── next.config.js
│ │ ├── package.json
│ │ ├── pages
│ │ │ ├── _app.tsx
│ │ │ ├── api
│ │ │ │ ├── hello.ts
│ │ │ │ └── tronweb.ts
│ │ │ └── index.tsx
│ │ ├── public
│ │ │ ├── favicon.ico
│ │ │ └── vercel.svg
│ │ ├── styles
│ │ │ ├── Home.module.css
│ │ │ └── globals.css
│ │ └── tsconfig.json
│ └── vite-app
│ │ ├── .gitignore
│ │ ├── .npmrc
│ │ ├── README.md
│ │ ├── index.html
│ │ ├── package.json
│ │ ├── public
│ │ └── vite.svg
│ │ ├── src
│ │ ├── App.tsx
│ │ ├── TronLinkAdapter.tsx
│ │ ├── assets
│ │ │ └── react.svg
│ │ ├── index.css
│ │ ├── main.tsx
│ │ ├── theme.ts
│ │ ├── tronweb.ts
│ │ └── vite-env.d.ts
│ │ ├── tsconfig.json
│ │ ├── tsconfig.node.json
│ │ └── vite.config.ts
└── vue-ui
│ └── vite-app
│ ├── .gitignore
│ ├── README.md
│ ├── index.html
│ ├── package.json
│ ├── public
│ └── vite.svg
│ ├── src
│ ├── App.vue
│ ├── assets
│ │ └── vue.svg
│ ├── components
│ │ ├── HooksDemo.vue
│ │ └── VueUiDemo.vue
│ ├── main.ts
│ ├── style.css
│ ├── tronweb.ts
│ └── vite-env.d.ts
│ ├── tsconfig.json
│ ├── tsconfig.node.json
│ └── vite.config.ts
├── docs
├── action-button.gif
├── index.md
├── wallet-adapter-react-ui.md
├── wallet-adapter-react.md
├── wallet-adapter-vue-ui.md
├── wallet-adapter-vue.md
└── wallet-adapters.md
├── package.json
├── packages
├── adapters
│ ├── abstract-adapter-evm
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── jest.config.js
│ │ ├── package.json
│ │ ├── src
│ │ │ ├── adapter.ts
│ │ │ ├── eip1193-provider.ts
│ │ │ ├── errors.ts
│ │ │ ├── index.ts
│ │ │ └── utils.ts
│ │ ├── tests
│ │ │ └── units
│ │ │ │ ├── adapter.test.ts
│ │ │ │ ├── errors.test.ts
│ │ │ │ └── utils.test.ts
│ │ ├── tsconfig.all.json
│ │ ├── tsconfig.cjs.json
│ │ └── tsconfig.esm.json
│ ├── abstract-adapter
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── package.json
│ │ ├── src
│ │ │ ├── adapter.ts
│ │ │ ├── errors.ts
│ │ │ ├── index.ts
│ │ │ ├── types.ts
│ │ │ └── utils.ts
│ │ ├── tsconfig.all.json
│ │ ├── tsconfig.cjs.json
│ │ └── tsconfig.esm.json
│ ├── adapters
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── package.json
│ │ ├── src
│ │ │ └── index.ts
│ │ ├── tsconfig.all.json
│ │ ├── tsconfig.cjs.json
│ │ └── tsconfig.esm.json
│ ├── bitkeep
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── jest.config.js
│ │ ├── package.json
│ │ ├── src
│ │ │ ├── adapter.ts
│ │ │ ├── index.ts
│ │ │ └── utils.ts
│ │ ├── tests
│ │ │ └── units
│ │ │ │ └── adapter.test.ts
│ │ ├── tsconfig.all.json
│ │ ├── tsconfig.cjs.json
│ │ └── tsconfig.esm.json
│ ├── ledger
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── __mocks__
│ │ │ ├── .eslintrc
│ │ │ └── @ledgerhq
│ │ │ │ ├── hw-app-trx.js
│ │ │ │ └── hw-transport-webhid.js
│ │ ├── jest.config.js
│ │ ├── package.json
│ │ ├── resolver.cjs
│ │ ├── src
│ │ │ ├── LedgerWallet.ts
│ │ │ ├── Modal
│ │ │ │ ├── ConfirmContent.tsx
│ │ │ │ ├── ConnectingContent.tsx
│ │ │ │ ├── LedgerIcon.tsx
│ │ │ │ ├── LoadingIcon.tsx
│ │ │ │ ├── Modal.tsx
│ │ │ │ ├── SelectAccount.tsx
│ │ │ │ ├── lang.ts
│ │ │ │ ├── openModal.tsx
│ │ │ │ └── style.ts
│ │ │ ├── __mocks__
│ │ │ │ └── LedgerWallet.ts
│ │ │ ├── adapter.ts
│ │ │ ├── index.ts
│ │ │ └── polyfills
│ │ │ │ ├── Buffer.ts
│ │ │ │ └── index.ts
│ │ ├── test
│ │ │ └── units
│ │ │ │ ├── LedgerWallet.test.ts
│ │ │ │ ├── adapter.test.ts
│ │ │ │ └── openModal.test.ts
│ │ ├── tsconfig.all.json
│ │ ├── tsconfig.cjs.json
│ │ ├── tsconfig.esm.json
│ │ └── tsconfig.json
│ ├── metamask
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── jest.config.js
│ │ ├── package.json
│ │ ├── src
│ │ │ ├── adapter.ts
│ │ │ ├── index.ts
│ │ │ └── utils.ts
│ │ ├── tests
│ │ │ └── units
│ │ │ │ ├── adapter.test.ts
│ │ │ │ └── metamask-provider.ts
│ │ ├── tsconfig.all.json
│ │ ├── tsconfig.cjs.json
│ │ └── tsconfig.esm.json
│ ├── okxwallet
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── jest.config.js
│ │ ├── package.json
│ │ ├── src
│ │ │ ├── adapter.ts
│ │ │ ├── index.ts
│ │ │ └── utils.ts
│ │ ├── tests
│ │ │ └── units
│ │ │ │ └── adapter.test.ts
│ │ ├── tsconfig.all.json
│ │ ├── tsconfig.cjs.json
│ │ └── tsconfig.esm.json
│ ├── tokenpocket
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── jest.config.js
│ │ ├── package.json
│ │ ├── src
│ │ │ ├── adapter.ts
│ │ │ ├── index.ts
│ │ │ └── utils.ts
│ │ ├── tests
│ │ │ └── units
│ │ │ │ └── adapter.test.ts
│ │ ├── tsconfig.all.json
│ │ ├── tsconfig.cjs.json
│ │ └── tsconfig.esm.json
│ ├── tronlink-evm
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── jest.config.js
│ │ ├── package.json
│ │ ├── src
│ │ │ ├── adapter.ts
│ │ │ ├── index.ts
│ │ │ └── utils.ts
│ │ ├── tests
│ │ │ └── units
│ │ │ │ └── adapter.test.ts
│ │ ├── tsconfig.all.json
│ │ ├── tsconfig.cjs.json
│ │ └── tsconfig.esm.json
│ ├── tronlink
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── jest.config.js
│ │ ├── package.json
│ │ ├── src
│ │ │ ├── adapter.ts
│ │ │ ├── error.ts
│ │ │ ├── index.ts
│ │ │ ├── types.ts
│ │ │ └── utils.ts
│ │ ├── tests
│ │ │ └── units
│ │ │ │ ├── adapter-mobile.test.ts
│ │ │ │ ├── adapter-tron.test.ts
│ │ │ │ ├── adapter-tronweb.test.ts
│ │ │ │ ├── adapter.test.ts
│ │ │ │ ├── mock.ts
│ │ │ │ └── utils.ts
│ │ ├── tsconfig.all.json
│ │ ├── tsconfig.cjs.json
│ │ └── tsconfig.esm.json
│ └── walletconnect
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── package.json
│ │ ├── src
│ │ ├── adapter.ts
│ │ └── index.ts
│ │ ├── tsconfig.all.json
│ │ ├── tsconfig.cjs.json
│ │ └── tsconfig.esm.json
├── react
│ ├── react-hooks
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── jest.config.js
│ │ ├── package.json
│ │ ├── src
│ │ │ ├── WalletProvider.tsx
│ │ │ ├── index.ts
│ │ │ ├── useLocalStorage.ts
│ │ │ └── useWallet.ts
│ │ ├── tests
│ │ │ └── units
│ │ │ │ ├── useLocalStorage.test.tsx
│ │ │ │ └── useWallet.test.tsx
│ │ ├── tsconfig.all.json
│ │ ├── tsconfig.cjs.json
│ │ └── tsconfig.esm.json
│ └── react-ui
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── action-button.gif
│ │ ├── jest.config.js
│ │ ├── package.json
│ │ ├── src
│ │ ├── Button.tsx
│ │ ├── Collapse.tsx
│ │ ├── Modal
│ │ │ ├── ReactPortal.tsx
│ │ │ └── WalletSelectModal.tsx
│ │ ├── WalletActionButton.tsx
│ │ ├── WalletConnectButton.tsx
│ │ ├── WalletDisconnectButton.tsx
│ │ ├── WalletItem.tsx
│ │ ├── WalletModalProvider.tsx
│ │ ├── WalletSelectButton.tsx
│ │ ├── index.ts
│ │ ├── useWalletModal.tsx
│ │ └── utils.tsx
│ │ ├── style.css
│ │ ├── tests
│ │ └── units
│ │ │ ├── Button.test.tsx
│ │ │ ├── MockTronLink.ts
│ │ │ ├── WalletActionButton.test.tsx
│ │ │ ├── WalletConnectButton.test.tsx
│ │ │ ├── WalletDisconnectButton.test.tsx
│ │ │ └── WalletSelectButton.test.tsx
│ │ ├── tsconfig.all.json
│ │ ├── tsconfig.cjs.json
│ │ └── tsconfig.esm.json
└── vue
│ ├── vue-hooks
│ ├── LICENSE
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ ├── WalletProvider.ts
│ │ ├── index.ts
│ │ ├── useLocalStorage.ts
│ │ └── useWallet.ts
│ ├── tests
│ │ └── units
│ │ │ └── useWallet.test.tsx
│ ├── tsconfig.all.json
│ ├── tsconfig.cjs.json
│ ├── tsconfig.esm.json
│ └── vitest.config.ts
│ └── vue-ui
│ ├── LICENSE
│ ├── README.md
│ ├── action-button.gif
│ ├── babel.config.cjs.json
│ ├── babel.config.esm.json
│ ├── package.json
│ ├── src
│ ├── Button.tsx
│ ├── Modal
│ │ ├── VuePortal.tsx
│ │ └── WalletSelectModal.tsx
│ ├── WalletActionButton
│ │ ├── Collapse.tsx
│ │ └── WalletActionButton.tsx
│ ├── WalletConnectButton.tsx
│ ├── WalletDisconnectButton.tsx
│ ├── WalletItem.tsx
│ ├── WalletModalProvider.tsx
│ ├── WalletSelectButton.tsx
│ ├── index.ts
│ ├── useWalletModal.tsx
│ └── utils.tsx
│ ├── style.css
│ ├── tests
│ └── units
│ │ ├── Button.test.tsx
│ │ ├── MockTronLink.ts
│ │ ├── WalletActionButton.test.tsx
│ │ ├── WalletConnectButton.test.tsx
│ │ ├── WalletDisconnectButton.test.tsx
│ │ └── WalletSelectButton.test.tsx
│ ├── tsconfig.all.json
│ ├── tsconfig.cjs.json
│ ├── tsconfig.esm.json
│ ├── tsconfig.json
│ └── vite.config.js
├── pnpm-lock.yaml
├── pnpm-workspace.yaml
├── scripts
├── build-umd.js
├── check-dep-version.js
└── list-pkg-versions.js
├── tsconfig.all.json
├── tsconfig.base.json
├── tsconfig.cjs.json
├── tsconfig.esm.json
├── tsconfig.json
├── tsconfig.root.json
└── tsconfig.tests.json
/.changeset/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://unpkg.com/@changesets/config@2.3.0/schema.json",
3 | "changelog": "@changesets/cli/changelog",
4 | "commit": false,
5 | "fixed": [],
6 | "linked": [],
7 | "access": "restricted",
8 | "baseBranch": "main",
9 | "updateInternalDependencies": "patch",
10 | "ignore": []
11 | }
12 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | indent_style = space
6 | indent_size = 4
7 | end_of_line = lf
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | .github
2 | .next
3 | .parcel-cache
4 | .swc
5 |
6 | docs
7 | lib
8 | build
9 | dist
10 | out
11 | public/
12 |
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "root": true,
3 | "extends": [
4 | "eslint:recommended",
5 | "plugin:@typescript-eslint/recommended",
6 | "plugin:prettier/recommended",
7 | "plugin:react/recommended",
8 | "plugin:react-hooks/recommended",
9 | "plugin:require-extensions/recommended"
10 | ],
11 | "parser": "@typescript-eslint/parser",
12 | "plugins": ["@typescript-eslint", "prettier", "react", "react-hooks", "require-extensions"],
13 | "settings": {
14 | "react": {
15 | "version": "detect"
16 | }
17 | },
18 | "rules": {
19 | "@typescript-eslint/ban-ts-comment": "off",
20 | "@typescript-eslint/no-explicit-any": "off",
21 | "@typescript-eslint/no-unused-vars": "warn",
22 | "@typescript-eslint/no-empty-interface": "off",
23 | "@typescript-eslint/consistent-type-imports": "error",
24 | "react/no-unescaped-entities": ["error", { "forbid": [">"] }]
25 | },
26 | "overrides": [
27 | {
28 | "files": ["demos/**/*"],
29 | "rules": {
30 | "require-extensions/require-extensions": "off",
31 | "react/react-in-jsx-scope": "off",
32 | "@typescript-eslint/no-unused-vars": "off"
33 | }
34 | },
35 | {
36 | "files": ["packages/vue/**/*"],
37 | "rules": {
38 | "react-hooks/rules-of-hooks": "off",
39 | "react-hooks/exhaustive-deps": "off",
40 | "react/react-in-jsx-scope": "off",
41 | "react/no-unknown-property": "off"
42 | }
43 | }
44 | ]
45 | }
46 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea
2 | .vscode
3 | .DS_Store
4 |
5 | node_modules
6 |
7 | package-lock.json
8 | yarn.lock
9 |
10 | .next
11 | .parcel-cache
12 | .swc
13 | build
14 | lib
15 | dist
16 | out
17 | *.tsbuildinfo
18 | *.log
19 | coverage
20 |
--------------------------------------------------------------------------------
/.husky/commit-msg:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 | . "$(dirname -- "$0")/_/husky.sh"
3 |
4 | npx --no -- commitlint --edit ${1}
5 |
--------------------------------------------------------------------------------
/.husky/pre-commit:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 | . "$(dirname -- "$0")/_/husky.sh"
3 |
4 | npx lint-staged
5 |
--------------------------------------------------------------------------------
/.npmrc:
--------------------------------------------------------------------------------
1 | strict-peer-dependencies=false
2 | # not add workspace: to package.json
3 | save-workspace-protocol=false
--------------------------------------------------------------------------------
/.prettierignore:
--------------------------------------------------------------------------------
1 | .github
2 | .next
3 | .parcel-cache
4 | .swc
5 |
6 | docs
7 | lib
8 | build
9 | dist
10 | out
11 | demos/
12 |
--------------------------------------------------------------------------------
/.prettierrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "printWidth": 120,
3 | "trailingComma": "es5",
4 | "tabWidth": 4,
5 | "semi": true,
6 | "singleQuote": true
7 | }
8 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 | Copyright (c) 2022-Present, tronprotocol
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in all
12 | copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | SOFTWARE.
21 |
--------------------------------------------------------------------------------
/demo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tronprotocol/tronwallet-adapter/3b2bdf995a7c3d834a0e3bb5ec71565cd961b2b0/demo.png
--------------------------------------------------------------------------------
/demos/cdn-demo/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | // "extends": [],
3 | "parser": "@typescript-eslint/parser",
4 | "env": {
5 | "node": true
6 | },
7 | "rules": {
8 | "require-extensions/require-extensions": "off"
9 | },
10 | "overrides": [
11 | {
12 | "files": "./scripts/*.cjs",
13 | "rules": {
14 | "@typescript-eslint/no-var-requires": "off"
15 | }
16 | }
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/demos/cdn-demo/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 | pnpm-debug.log*
8 | lerna-debug.log*
9 |
10 | node_modules
11 | dist
12 | dist-ssr
13 | *.local
14 |
15 | # Editor directories and files
16 | .vscode/*
17 | !.vscode/extensions.json
18 | .idea
19 | .DS_Store
20 | *.suo
21 | *.ntvs*
22 | *.njsproj
23 | *.sln
24 | *.sw?
25 |
--------------------------------------------------------------------------------
/demos/cdn-demo/.npmrc:
--------------------------------------------------------------------------------
1 | package-lock=false
--------------------------------------------------------------------------------
/demos/cdn-demo/.prettierrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "printWidth": 180,
3 | "trailingComma": "es5",
4 | "tabWidth": 4,
5 | "semi": true,
6 | "singleQuote": true
7 | }
8 |
--------------------------------------------------------------------------------
/demos/cdn-demo/README.md:
--------------------------------------------------------------------------------
1 | # TronWallet CND Demo
2 | This project shows how to use Tronwallet Adapter with vanilla js.
3 |
4 | ## Usage
5 | 1. Installation
6 | First you should install the npm package to use the `umd` format file:
7 | ```bash
8 | npm i @tronweb3/tronwallet-adapters
9 | ```
10 |
11 | 2. Add script in your HTML file
12 | Put the script in your `head` tag:
13 | ```html
14 |
15 | ```
16 |
17 | **Note**: You should adjust the relative path according to the position of your HTML file.
18 |
19 | 3. Get specified adapter
20 | ```js
21 | const { TronLinkAdapter, BitKeepAdapter, WalletConnectAdapter, OkxWalletAdapter } = window['@tronweb3/tronwallet-adapters'];
22 | const tronlinkAdapter = new TronLinkAdapter({
23 | openTronLinkAppOnMobile: true,
24 | openUrlWhenWalletNotFound: false,
25 | checkTimeout: 3000,
26 | });
27 | ```
28 |
29 | Please refer [here](https://developers.tron.network/docs/tronwallet-adapter) for more detailed documentation.
30 |
31 | ## WalletConnectAdapter
32 | If you want to use `WalletConnectAdapter`, you should install another dependency in addition:
33 | ```bash
34 | npm i @walletconnect/sign-client
35 | ```
36 |
37 | And add a script tag for `@walletconnect/sign-client`:
38 | ```diff
39 | +
40 |
41 | ```
--------------------------------------------------------------------------------
/demos/cdn-demo/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "cdn-demo",
3 | "private": true,
4 | "version": "0.0.1",
5 | "type": "module",
6 | "scripts": {
7 | "dev": "serve"
8 | },
9 | "dependencies": {
10 | "@tronweb3/abstract-adapter-evm": "^1.0.1",
11 | "@tronweb3/tronwallet-abstract-adapter": "^1.1.6",
12 | "@tronweb3/tronwallet-adapter-bitkeep": "^1.0.2",
13 | "@tronweb3/tronwallet-adapter-ledger": "^1.1.8",
14 | "@tronweb3/tronwallet-adapter-metamask": "^1.0.1",
15 | "@tronweb3/tronwallet-adapter-okxwallet": "^1.0.2",
16 | "@tronweb3/tronwallet-adapter-tokenpocket": "^1.0.2",
17 | "@tronweb3/tronwallet-adapter-tronlink": "^1.1.9",
18 | "@tronweb3/tronwallet-adapter-tronlink-evm": "^1.0.0",
19 | "@tronweb3/tronwallet-adapter-walletconnect": "^1.0.5",
20 | "@tronweb3/tronwallet-adapters": "^1.1.9",
21 | "@walletconnect/sign-client": "^2.1.4",
22 | "serve": "^14.2.1"
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/demos/dev-demo/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | // "extends": [],
3 | "parser": "@typescript-eslint/parser",
4 | "env": {
5 | "node": true
6 | },
7 | "rules": {
8 | "require-extensions/require-extensions": "off"
9 | },
10 | "overrides": [
11 | {
12 | "files": "./scripts/*.cjs",
13 | "rules": {
14 | "@typescript-eslint/no-var-requires": "off"
15 | }
16 | }
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/demos/dev-demo/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 | pnpm-debug.log*
8 | lerna-debug.log*
9 |
10 | node_modules
11 | dist
12 | dist-ssr
13 | *.local
14 |
15 | # Editor directories and files
16 | .vscode/*
17 | !.vscode/extensions.json
18 | .idea
19 | .DS_Store
20 | *.suo
21 | *.ntvs*
22 | *.njsproj
23 | *.sln
24 | *.sw?
25 |
--------------------------------------------------------------------------------
/demos/dev-demo/.npmrc:
--------------------------------------------------------------------------------
1 | package-lock=false
--------------------------------------------------------------------------------
/demos/dev-demo/.prettierrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "printWidth": 180,
3 | "trailingComma": "es5",
4 | "tabWidth": 4,
5 | "semi": true,
6 | "singleQuote": true
7 | }
8 |
--------------------------------------------------------------------------------
/demos/dev-demo/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Vite + React + TS
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/demos/dev-demo/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "dev-demo",
3 | "private": true,
4 | "version": "0.0.1",
5 | "type": "module",
6 | "scripts": {
7 | "dev": "vite",
8 | "build": "tsc && vite build",
9 | "preview": "vite preview",
10 | "ganache": "node scripts/ganache.cjs"
11 | },
12 | "dependencies": {
13 | "@emotion/react": "^11.10.4",
14 | "@emotion/styled": "^11.10.4",
15 | "@ethersproject/properties": "^5.7.0",
16 | "@ethersproject/strings": "^5.7.0",
17 | "@metamask/eth-sig-util": "^6.0.0",
18 | "@mui/material": "^5.10.10",
19 | "@tronweb3/abstract-adapter-evm": "^1.0.1",
20 | "@tronweb3/tronwallet-abstract-adapter": "^1.1.6",
21 | "@tronweb3/tronwallet-adapter-bitkeep": "^1.0.2",
22 | "@tronweb3/tronwallet-adapter-ledger": "^1.1.8",
23 | "@tronweb3/tronwallet-adapter-metamask": "^1.0.1",
24 | "@tronweb3/tronwallet-adapter-okxwallet": "^1.0.2",
25 | "@tronweb3/tronwallet-adapter-react-hooks": "^1.1.7",
26 | "@tronweb3/tronwallet-adapter-react-ui": "^1.1.8",
27 | "@tronweb3/tronwallet-adapter-tokenpocket": "^1.0.2",
28 | "@tronweb3/tronwallet-adapter-tronlink-evm": "^1.0.0",
29 | "@tronweb3/tronwallet-adapters": "^1.1.9",
30 | "@types/node": "^18.19.0",
31 | "events": "^3.3.0",
32 | "ganache": "^7.9.0",
33 | "lit-html": "^3.0.0",
34 | "react": "^18.2.0",
35 | "react-dom": "^18.2.0",
36 | "tronweb": "~5.1.0",
37 | "vconsole": "^3.15.1"
38 | },
39 | "devDependencies": {
40 | "@types/react": "^18.0.26",
41 | "@types/react-dom": "^18.0.8",
42 | "@vitejs/plugin-legacy": "^5.4.1",
43 | "@vitejs/plugin-react": "^4.3.1",
44 | "dotenv": "^16.3.1",
45 | "typescript": "^4.6.4",
46 | "vite": "^5.2.11",
47 | "webpack-cli": "^5.0.2"
48 | },
49 | "overrides": {
50 | "@ledgerhq/errors": "6.10.0",
51 | "@ledgerhq/devices": "6.27.1",
52 | "@ledgerhq/hw-transport": "6.27.1",
53 | "@ledgerhq/hw-transport-webhid": "6.27.1"
54 | },
55 | "resolutions": {
56 | "@ledgerhq/errors": "6.10.0",
57 | "@ledgerhq/devices": "6.27.1",
58 | "@ledgerhq/hw-transport": "6.27.1",
59 | "@ledgerhq/hw-transport-webhid": "6.27.1"
60 | }
61 | }
--------------------------------------------------------------------------------
/demos/dev-demo/scripts/ganache.cjs:
--------------------------------------------------------------------------------
1 | const ganache = require('ganache');
2 |
3 | require('dotenv').config({});
4 |
5 | const options = {
6 | fork: process.env.INFURA_PROJECT_ID
7 | ? { url: `https://mainnet.infura.io/v3/${process.env.INFURA_PROJECT_ID}` }
8 | : 'mainnet',
9 | chain: {
10 | // hardfork: 'berlin',
11 | },
12 | };
13 | options.wallet = {
14 | mnemonic:
15 | 'shove comic where catch muscle impulse that fork plunge robust noise subject',
16 | };
17 | const server = ganache.server(options);
18 | const PORT = 8545;
19 |
20 | server.listen(PORT, async (err) => {
21 | if (err) throw err;
22 |
23 | console.log(`ganache listening on port ${PORT}...`);
24 | console.log('accounts created');
25 | const provider = server.provider;
26 |
27 | if (process.env.MNEMONIC_PHRASE) {
28 | const accounts = await provider.request({
29 | method: 'eth_accounts',
30 | params: [],
31 | });
32 | console.log(accounts);
33 | } else {
34 | console.log(`mnemonic used: ${provider.getOptions().wallet?.mnemonic}`);
35 | console.log(provider.getInitialAccounts());
36 | }
37 | });
38 |
--------------------------------------------------------------------------------
/demos/dev-demo/src/AppWraper.tsx:
--------------------------------------------------------------------------------
1 | import App from './App.js';
2 |
3 | export function AppWraper() {
4 | return ();
5 | }
6 |
--------------------------------------------------------------------------------
/demos/dev-demo/src/LedgerDemo/ConnectTip.tsx:
--------------------------------------------------------------------------------
1 | export function ConnectTip() {
2 | return (
3 |
4 |
Note
5 |
6 | - 1. Ledger Firmware versions supported: Nano S: v1.5.5 and above; Nano X: v1.2.4-1 and above
7 | -
8 | 2. Enable these features before you use them:
9 |
10 | - 2.1 Transaction Data: Enable it to add notes to transfers.
11 | - 2.2 Custom Contracts: Enable it to support smart contract transaction, such as TRC20 transfer.
12 | - 2.3 Sign By Hash: Enable it to edit the account access, i.e. set up multi-signature for the account.
13 |
14 |
15 |
16 |
17 | );
18 | }
19 |
--------------------------------------------------------------------------------
/demos/dev-demo/src/index.css:
--------------------------------------------------------------------------------
1 | button {
2 | text-transform: none !important;
3 | }
4 |
--------------------------------------------------------------------------------
/demos/dev-demo/src/main.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import ReactDOM from 'react-dom/client';
3 | import App from './App';
4 | import '@tronweb3/tronwallet-adapter-react-ui/style.css';
5 | import { WalletProvider } from '@tronweb3/tronwallet-adapter-react-hooks';
6 | import { WalletModalProvider } from '@tronweb3/tronwallet-adapter-react-ui';
7 | import { ThemeProvider } from '@mui/material/styles';
8 | import theme from './theme';
9 | import VConsole from 'vconsole';
10 | import './index.css';
11 | import { AppWraper } from './AppWraper.js';
12 | const vConsole = new VConsole();
13 |
14 | ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
15 |
16 |
17 |
18 |
19 |
20 | );
21 |
--------------------------------------------------------------------------------
/demos/dev-demo/src/theme.ts:
--------------------------------------------------------------------------------
1 | import { createTheme } from '@mui/material/styles';
2 | import { red } from '@mui/material/colors';
3 |
4 | // Create a theme instance.
5 | const theme = createTheme({
6 | palette: {
7 | primary: {
8 | main: '#556cd6',
9 | },
10 | secondary: {
11 | main: '#19857b',
12 | },
13 | error: {
14 | main: red.A400,
15 | },
16 | },
17 | components: {
18 | MuiButton: {
19 | styleOverrides: {
20 | root: {
21 | margin: '0 10px'
22 | }
23 | }
24 | }
25 | }
26 | });
27 |
28 | export default theme;
29 |
--------------------------------------------------------------------------------
/demos/dev-demo/src/tronweb.ts:
--------------------------------------------------------------------------------
1 | // @ts-ignore
2 | import TronWeb from 'tronweb';
3 |
4 | export const tronWeb: any = new TronWeb({
5 | fullHost: 'https://api.nileex.io',
6 | // fullHost: 'https://api.trongrid.io'
7 | });
8 | (window as any).tronWeb1 = tronWeb;
9 |
--------------------------------------------------------------------------------
/demos/dev-demo/src/vite-env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
--------------------------------------------------------------------------------
/demos/dev-demo/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ESNext",
4 | "useDefineForClassFields": true,
5 | "lib": ["DOM", "DOM.Iterable", "ESNext"],
6 | "allowJs": false,
7 | "skipLibCheck": true,
8 | "esModuleInterop": false,
9 | "allowSyntheticDefaultImports": true,
10 | "strict": true,
11 | "forceConsistentCasingInFileNames": true,
12 | "module": "ESNext",
13 | "moduleResolution": "Node",
14 | "resolveJsonModule": true,
15 | "isolatedModules": true,
16 | "noEmit": true,
17 | "jsx": "react-jsx",
18 | "types": [
19 | "@types/node"
20 | ]
21 | },
22 | "include": ["src"],
23 | "references": [{ "path": "./tsconfig.node.json" }]
24 | }
25 |
--------------------------------------------------------------------------------
/demos/dev-demo/tsconfig.node.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "composite": true,
4 | "module": "ESNext",
5 | "moduleResolution": "Node",
6 | "allowSyntheticDefaultImports": true
7 | },
8 | "include": ["vite.config.ts"]
9 | }
10 |
--------------------------------------------------------------------------------
/demos/dev-demo/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite';
2 | import react from '@vitejs/plugin-react';
3 | import legacy from '@vitejs/plugin-legacy';
4 |
5 | // https://vitejs.dev/config/
6 | export default defineConfig({
7 | plugins: [
8 | react(),
9 | legacy({
10 | targets: ['IE 11'],
11 | }),
12 | ],
13 | resolve: {
14 | alias: {
15 | eventemitter3: 'eventemitter3/umd/eventemitter3.js',
16 | },
17 | },
18 | server: {
19 | host: '0.0.0.0',
20 | port: 3003,
21 | https: false
22 | },
23 | build: {
24 | minify: false,
25 | },
26 | });
27 |
--------------------------------------------------------------------------------
/demos/react-ui/create-react-app/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/demos/react-ui/create-react-app/.npmrc:
--------------------------------------------------------------------------------
1 | package-lock=false
--------------------------------------------------------------------------------
/demos/react-ui/create-react-app/README.md:
--------------------------------------------------------------------------------
1 | # Getting Started with Create React App
2 |
3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4 |
5 | ## Available Scripts
6 |
7 | In the project directory, you can run:
8 |
9 | ### `npm start`
10 |
11 | Runs the app in the development mode.\
12 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
13 |
14 | The page will reload if you make edits.\
15 | You will also see any lint errors in the console.
16 |
17 | ### `npm test`
18 |
19 | Launches the test runner in the interactive watch mode.\
20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21 |
22 | ### `npm run build`
23 |
24 | Builds the app for production to the `build` folder.\
25 | It correctly bundles React in production mode and optimizes the build for the best performance.
26 |
27 | The build is minified and the filenames include the hashes.\
28 | Your app is ready to be deployed!
29 |
30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31 |
32 | ### `npm run eject`
33 |
34 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
35 |
36 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37 |
38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
39 |
40 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
41 |
42 | ## Learn More
43 |
44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45 |
46 | To learn React, check out the [React documentation](https://reactjs.org/).
47 |
--------------------------------------------------------------------------------
/demos/react-ui/create-react-app/config-overrides.js:
--------------------------------------------------------------------------------
1 | const webpack = require('webpack');
2 |
3 | module.exports = function override(config, env) {
4 | console.log('override');
5 | let loaders = config.resolve;
6 | loaders.fallback = {
7 | 'fs': false,
8 | 'tls': false,
9 | 'net': false,
10 | 'querystring': require.resolve('querystring'),
11 | 'http': require.resolve('stream-http'),
12 | 'https': require.resolve('https-browserify'),
13 | 'zlib': require.resolve('browserify-zlib'),
14 | 'path': require.resolve('path-browserify'),
15 | 'stream': require.resolve('stream-browserify'),
16 | 'crypto': require.resolve('crypto-browserify')
17 | };
18 |
19 | config.plugins.push(
20 | new webpack.ProvidePlugin({
21 | process: 'process/browser',
22 | // Buffer: ['buffer', 'Buffer']
23 | })
24 | );
25 |
26 | // config.stats = { ...config.stats, children: true };
27 |
28 | // react-dnd
29 | config.module.rules.unshift({
30 | test: /\.m?js$/,
31 | resolve: {
32 | fullySpecified: false // disable the behaviour
33 | }
34 | });
35 |
36 | // // react-dnd
37 | // config.resolve.alias = {
38 | // ...config.resolve.alias,
39 | // 'react/jsx-runtime.js': 'react/jsx-runtime',
40 | // 'react/jsx-dev-runtime.js': 'react/jsx-dev-runtime'
41 | // };
42 |
43 | return config;
44 | };
--------------------------------------------------------------------------------
/demos/react-ui/create-react-app/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tronprotocol/tronwallet-adapter/3b2bdf995a7c3d834a0e3bb5ec71565cd961b2b0/demos/react-ui/create-react-app/public/favicon.ico
--------------------------------------------------------------------------------
/demos/react-ui/create-react-app/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
14 |
15 |
24 | React App
25 |
26 |
27 |
28 |
29 |
30 |
40 |
41 |
--------------------------------------------------------------------------------
/demos/react-ui/create-react-app/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tronprotocol/tronwallet-adapter/3b2bdf995a7c3d834a0e3bb5ec71565cd961b2b0/demos/react-ui/create-react-app/public/logo192.png
--------------------------------------------------------------------------------
/demos/react-ui/create-react-app/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tronprotocol/tronwallet-adapter/3b2bdf995a7c3d834a0e3bb5ec71565cd961b2b0/demos/react-ui/create-react-app/public/logo512.png
--------------------------------------------------------------------------------
/demos/react-ui/create-react-app/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/demos/react-ui/create-react-app/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/demos/react-ui/create-react-app/src/App.css:
--------------------------------------------------------------------------------
1 | .App {
2 | text-align: center;
3 | }
4 |
5 | .App-logo {
6 | height: 40vmin;
7 | pointer-events: none;
8 | }
9 |
10 | @media (prefers-reduced-motion: no-preference) {
11 | .App-logo {
12 | animation: App-logo-spin infinite 20s linear;
13 | }
14 | }
15 |
16 | .App-header {
17 | background-color: #282c34;
18 | min-height: 100vh;
19 | display: flex;
20 | flex-direction: column;
21 | align-items: center;
22 | justify-content: center;
23 | font-size: calc(10px + 2vmin);
24 | color: white;
25 | }
26 |
27 | .App-link {
28 | color: #61dafb;
29 | }
30 |
31 | @keyframes App-logo-spin {
32 | from {
33 | transform: rotate(0deg);
34 | }
35 | to {
36 | transform: rotate(360deg);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/demos/react-ui/create-react-app/src/App.test.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { render, screen } from '@testing-library/react';
3 | import { App } from './App';
4 |
5 | test('renders learn react link', () => {
6 | render();
7 | screen.getByText(/learn react/i);
8 | // expect(linkElement).toBeInTheDocument();
9 | });
10 |
--------------------------------------------------------------------------------
/demos/react-ui/create-react-app/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | padding: 30px;
3 | margin: 0;
4 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans',
5 | 'Droid Sans', 'Helvetica Neue', sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;
12 | }
13 |
--------------------------------------------------------------------------------
/demos/react-ui/create-react-app/src/index.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom/client';
3 | import './index.css';
4 | import '@tronweb3/tronwallet-adapter-react-ui/style.css';
5 | import { App } from './App';
6 | import reportWebVitals from './reportWebVitals';
7 | import { Toaster } from 'react-hot-toast';
8 | import { ThemeProvider } from '@mui/material/styles';
9 | import theme from './theme';
10 | import vConsole from 'vconsole'
11 | const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
12 | new vConsole();
13 | root.render(
14 |
15 |
16 |
17 |
18 |
19 |
20 | );
21 |
22 | // If you want to start measuring performance in your app, pass a function
23 | // to log results (for example: reportWebVitals(console.log))
24 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
25 | reportWebVitals();
26 |
--------------------------------------------------------------------------------
/demos/react-ui/create-react-app/src/react-app-env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
--------------------------------------------------------------------------------
/demos/react-ui/create-react-app/src/reportWebVitals.ts:
--------------------------------------------------------------------------------
1 | import { ReportHandler } from 'web-vitals';
2 |
3 | const reportWebVitals = (onPerfEntry?: ReportHandler) => {
4 | if (onPerfEntry && onPerfEntry instanceof Function) {
5 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
6 | getCLS(onPerfEntry);
7 | getFID(onPerfEntry);
8 | getFCP(onPerfEntry);
9 | getLCP(onPerfEntry);
10 | getTTFB(onPerfEntry);
11 | });
12 | }
13 | };
14 |
15 | export default reportWebVitals;
16 |
--------------------------------------------------------------------------------
/demos/react-ui/create-react-app/src/setupTests.ts:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom';
6 |
--------------------------------------------------------------------------------
/demos/react-ui/create-react-app/src/theme.ts:
--------------------------------------------------------------------------------
1 | import { createTheme } from '@mui/material/styles';
2 | import { red } from '@mui/material/colors';
3 |
4 | // Create a theme instance.
5 | const theme = createTheme({
6 | palette: {
7 | primary: {
8 | main: '#556cd6',
9 | },
10 | secondary: {
11 | main: '#19857b',
12 | },
13 | error: {
14 | main: red.A400,
15 | },
16 | },
17 | });
18 |
19 | export default theme;
20 |
--------------------------------------------------------------------------------
/demos/react-ui/create-react-app/src/tronweb.ts:
--------------------------------------------------------------------------------
1 | // @ts-ignore
2 | import TronWeb from 'tronweb';
3 | export const tronWeb: any = new TronWeb({
4 | fullHost: 'https://api.nileex.io',
5 | });
6 | (window as any).tronWeb1 = tronWeb;
7 |
--------------------------------------------------------------------------------
/demos/react-ui/create-react-app/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "lib": ["dom", "dom.iterable", "esnext"],
5 | "allowJs": true,
6 | "skipLibCheck": true,
7 | "esModuleInterop": true,
8 | "allowSyntheticDefaultImports": true,
9 | "strict": false,
10 | "forceConsistentCasingInFileNames": true,
11 | "noFallthroughCasesInSwitch": true,
12 | "module": "esnext",
13 | "moduleResolution": "node",
14 | "resolveJsonModule": true,
15 | "isolatedModules": true,
16 | "noEmit": true,
17 | "jsx": "react-jsx"
18 | },
19 | "include": ["src"]
20 | }
21 |
--------------------------------------------------------------------------------
/demos/react-ui/next-app/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "next/core-web-vitals"
3 | }
4 |
--------------------------------------------------------------------------------
/demos/react-ui/next-app/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # next.js
12 | /.next/
13 | /out/
14 |
15 | # production
16 | /build
17 |
18 | # misc
19 | .DS_Store
20 | *.pem
21 |
22 | # debug
23 | npm-debug.log*
24 | yarn-debug.log*
25 | yarn-error.log*
26 | .pnpm-debug.log*
27 |
28 | # local env files
29 | .env*.local
30 |
31 | # vercel
32 | .vercel
33 |
34 | # typescript
35 | *.tsbuildinfo
36 | next-env.d.ts
37 |
--------------------------------------------------------------------------------
/demos/react-ui/next-app/.npmrc:
--------------------------------------------------------------------------------
1 | package-lock=false
--------------------------------------------------------------------------------
/demos/react-ui/next-app/README.md:
--------------------------------------------------------------------------------
1 | This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
2 |
3 | ## Getting Started
4 |
5 | First, run the development server:
6 |
7 | ```bash
8 | npm run dev
9 | # or
10 | yarn dev
11 | ```
12 |
13 | Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
14 |
15 | You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file.
16 |
17 | [API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.ts`.
18 |
19 | The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
20 |
21 | ## Learn More
22 |
23 | To learn more about Next.js, take a look at the following resources:
24 |
25 | - [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
26 | - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
27 |
28 | You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
29 |
30 | ## Deploy on Vercel
31 |
32 | The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
33 |
34 | Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
35 |
--------------------------------------------------------------------------------
/demos/react-ui/next-app/next.config.js:
--------------------------------------------------------------------------------
1 | /** @type {import('next').NextConfig} */
2 | const nextConfig = {
3 | reactStrictMode: true,
4 | swcMinify: true,
5 | }
6 |
7 | module.exports = nextConfig
8 |
--------------------------------------------------------------------------------
/demos/react-ui/next-app/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-ui-next-app",
3 | "version": "1.0.0",
4 | "private": true,
5 | "scripts": {
6 | "dev": "PORT=5002 next dev",
7 | "build": "next build",
8 | "start": "PORT=5002 next start",
9 | "lint": "next lint"
10 | },
11 | "dependencies": {
12 | "@emotion/react": "^11.10.4",
13 | "@emotion/styled": "^11.10.4",
14 | "@mui/material": "^5.10.10",
15 | "@tronweb3/tronwallet-abstract-adapter": "^1.1.0",
16 | "@tronweb3/tronwallet-adapter-bitkeep": "^1.0.0",
17 | "@tronweb3/tronwallet-adapter-ledger": "^1.1.1",
18 | "@tronweb3/tronwallet-adapter-react-hooks": "^1.0.0",
19 | "@tronweb3/tronwallet-adapter-react-ui": "^1.1.0",
20 | "@tronweb3/tronwallet-adapter-tokenpocket": "^1.0.0",
21 | "@tronweb3/tronwallet-adapters": "^1.1.1",
22 | "@types/node": "18.11.9",
23 | "eslint": "^8.23.1",
24 | "eslint-config-next": "13.0.5",
25 | "next": "14.2.3",
26 | "react": "^18.2.0",
27 | "react-dom": "^18.2.0",
28 | "react-hot-toast": "^2.4.0",
29 | "tronweb": "^4.4.0",
30 | "tslib": "^2.5.0",
31 | "typescript": "4.9.3"
32 | },
33 | "devDependencies": {
34 | "@types/react": "18.0.26",
35 | "@types/react-dom": "^18.0.6",
36 | "lokijs": "^1.5.12",
37 | "pino-pretty": "^10.0.0",
38 | "typescript": "^4.6.4"
39 | },
40 | "overrides": {
41 | "@types/react": "18.0.26",
42 | "@ledgerhq/errors": "6.10.0",
43 | "@ledgerhq/devices": "6.27.1",
44 | "@ledgerhq/hw-transport": "6.27.1",
45 | "@ledgerhq/hw-transport-webhid": "6.27.1"
46 | },
47 | "resolutions": {
48 | "@types/react": "18.0.26",
49 | "@ledgerhq/errors": "6.10.0",
50 | "@ledgerhq/devices": "6.27.1",
51 | "@ledgerhq/hw-transport": "6.27.1",
52 | "@ledgerhq/hw-transport-webhid": "6.27.1"
53 | }
54 | }
--------------------------------------------------------------------------------
/demos/react-ui/next-app/pages/api/hello.ts:
--------------------------------------------------------------------------------
1 | // Next.js API route support: https://nextjs.org/docs/api-routes/introduction
2 | import type { NextApiRequest, NextApiResponse } from 'next';
3 |
4 | type Data = {
5 | name: string;
6 | };
7 |
8 | export default function handler(req: NextApiRequest, res: NextApiResponse) {
9 | res.status(200).json({ name: 'John Doe' });
10 | }
11 |
--------------------------------------------------------------------------------
/demos/react-ui/next-app/pages/api/tronweb.ts:
--------------------------------------------------------------------------------
1 | // @ts-ignore
2 | import TronWeb from 'tronweb';
3 | export const tronWeb: any = new TronWeb({
4 | fullHost: 'https://api.nileex.io',
5 | });
6 | if (typeof window !== 'undefined') {
7 | (window as any).tronWeb1 = tronWeb;
8 | }
9 |
--------------------------------------------------------------------------------
/demos/react-ui/next-app/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tronprotocol/tronwallet-adapter/3b2bdf995a7c3d834a0e3bb5ec71565cd961b2b0/demos/react-ui/next-app/public/favicon.ico
--------------------------------------------------------------------------------
/demos/react-ui/next-app/public/vercel.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/demos/react-ui/next-app/styles/globals.css:
--------------------------------------------------------------------------------
1 | html,
2 | body {
3 | padding: 0;
4 | margin: 0;
5 | font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans,
6 | Helvetica Neue, sans-serif;
7 | }
8 |
9 | body {
10 | padding: 30px;
11 | }
12 |
13 | a {
14 | color: inherit;
15 | text-decoration: none;
16 | }
17 |
18 | * {
19 | box-sizing: border-box;
20 | }
21 |
22 |
--------------------------------------------------------------------------------
/demos/react-ui/next-app/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "lib": ["dom", "dom.iterable", "esnext"],
5 | "allowJs": true,
6 | "skipLibCheck": true,
7 | "strict": true,
8 | "forceConsistentCasingInFileNames": true,
9 | "noEmit": true,
10 | "esModuleInterop": true,
11 | "module": "esnext",
12 | "moduleResolution": "node",
13 | "resolveJsonModule": true,
14 | "isolatedModules": true,
15 | "jsx": "preserve",
16 | "incremental": true
17 | },
18 | "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
19 | "exclude": ["node_modules"]
20 | }
21 |
--------------------------------------------------------------------------------
/demos/react-ui/vite-app/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 | pnpm-debug.log*
8 | lerna-debug.log*
9 |
10 | node_modules
11 | dist
12 | dist-ssr
13 | *.local
14 |
15 | # Editor directories and files
16 | .vscode/*
17 | !.vscode/extensions.json
18 | .idea
19 | .DS_Store
20 | *.suo
21 | *.ntvs*
22 | *.njsproj
23 | *.sln
24 | *.sw?
25 |
--------------------------------------------------------------------------------
/demos/react-ui/vite-app/.npmrc:
--------------------------------------------------------------------------------
1 | package-lock=false
--------------------------------------------------------------------------------
/demos/react-ui/vite-app/README.md:
--------------------------------------------------------------------------------
1 | # adapter-demo-react
2 |
3 | This is the demo of `@tronweb3/tronwallet-adapter-react-ui`. Please refer the introduction [here](https://github.com/tronprotocol/tronwallet-adapter/blob/main/packages/react/react-ui/README.md).
4 |
5 | ## Start
6 |
7 | ```bash
8 | pnpm install
9 | pnpm dev
10 | ```
11 |
--------------------------------------------------------------------------------
/demos/react-ui/vite-app/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Vite + React + TS
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/demos/react-ui/vite-app/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-ui-vite",
3 | "private": true,
4 | "version": "0.0.1",
5 | "type": "module",
6 | "scripts": {
7 | "dev": "vite",
8 | "start": "vite",
9 | "build": "tsc && vite build",
10 | "preview": "vite preview"
11 | },
12 | "dependencies": {
13 | "@emotion/react": "^11.10.4",
14 | "@emotion/styled": "^11.10.4",
15 | "@mui/material": "^5.10.10",
16 | "@tronweb3/tronwallet-abstract-adapter": "^1.1.0",
17 | "@tronweb3/tronwallet-adapter-ledger": "^1.1.1",
18 | "@tronweb3/tronwallet-adapter-react-hooks": "^1.0.0",
19 | "@tronweb3/tronwallet-adapter-react-ui": "^1.1.0",
20 | "@tronweb3/tronwallet-adapter-tronlink": "^1.1.9",
21 | "@tronweb3/tronwallet-adapter-walletconnect": "^1.0.0",
22 | "@tronweb3/tronwallet-adapters": "^1.1.1",
23 | "buffer": "^6.0.3",
24 | "events": "^3.3.0",
25 | "react": "^18.2.0",
26 | "react-dom": "^18.2.0",
27 | "react-hot-toast": "^2.4.0",
28 | "tronweb": "^4.4.0",
29 | "vconsole": "^3.15.0"
30 | },
31 | "devDependencies": {
32 | "@types/react": "^18.0.26",
33 | "@types/react-dom": "^18.0.6",
34 | "@vitejs/plugin-legacy": "^5.4.1",
35 | "@vitejs/plugin-react": "^4.3.1",
36 | "rollup-plugin-polyfill-node": "^0.11.0",
37 | "typescript": "^4.6.4",
38 | "vite": "^5.2.11"
39 | },
40 | "overrides": {
41 | "@ledgerhq/errors": "6.10.0",
42 | "@ledgerhq/devices": "6.27.1",
43 | "@ledgerhq/hw-transport": "6.27.1",
44 | "@ledgerhq/hw-transport-webhid": "6.27.1"
45 | },
46 | "resolutions": {
47 | "@ledgerhq/errors": "6.10.0",
48 | "@ledgerhq/devices": "6.27.1",
49 | "@ledgerhq/hw-transport": "6.27.1",
50 | "@ledgerhq/hw-transport-webhid": "6.27.1"
51 | }
52 | }
--------------------------------------------------------------------------------
/demos/react-ui/vite-app/public/vite.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/demos/react-ui/vite-app/src/index.css:
--------------------------------------------------------------------------------
1 | #root {
2 | max-width: 1280px;
3 | margin: 0 auto;
4 | text-align: left;
5 | width: 100%;
6 | overflow: auto;
7 | }
8 | :root {
9 | font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
10 | font-size: 16px;
11 | line-height: 24px;
12 | font-weight: 400;
13 |
14 | color-scheme: light;
15 | color: rgba(255, 255, 255, 0.87);
16 | background-color: #242424;
17 |
18 | font-synthesis: none;
19 | text-rendering: optimizeLegibility;
20 | -webkit-font-smoothing: antialiased;
21 | -moz-osx-font-smoothing: grayscale;
22 | -webkit-text-size-adjust: 100%;
23 | }
24 |
25 | a {
26 | font-weight: 500;
27 | color: #646cff;
28 | text-decoration: inherit;
29 | }
30 | a:hover {
31 | color: #535bf2;
32 | }
33 |
34 | body {
35 | padding: 10px;
36 | margin: 0;
37 | display: flex;
38 | min-width: 320px;
39 | min-height: 100vh;
40 | }
41 |
42 | h2 {
43 | margin: 30px 0 10px;
44 | }
45 |
46 | button {
47 | border-radius: 8px;
48 | border: 1px solid transparent;
49 | padding: 0.6em 1.2em;
50 | font-size: 1em;
51 | font-weight: 500;
52 | font-family: inherit;
53 | background-color: #1a1a1a;
54 | cursor: pointer;
55 | transition: border-color 0.25s;
56 | }
57 | button:hover {
58 | border-color: #646cff;
59 | }
60 | button:focus,
61 | button:focus-visible {
62 | outline: 4px auto -webkit-focus-ring-color;
63 | }
64 |
65 | p {
66 | display: flex;
67 | font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
68 | word-break: break-all;
69 | margin: 10px 0 ;
70 | }
71 | p span:first-of-type {
72 | width: 160px;
73 | }
74 |
75 | :root {
76 | color: #213547;
77 | background-color: #ffffff;
78 | }
79 | a:hover {
80 | color: #747bff;
81 | }
82 | button {
83 | background-color: #f9f9f9;
84 | }
85 |
86 | @media screen and (max-width: 800px) {
87 | p {
88 | display: flex;
89 | flex-direction: column;
90 | }
91 | .adapter-react-button {
92 | font-size: 14px;
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/demos/react-ui/vite-app/src/main.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import { useWallet } from '@tronweb3/tronwallet-adapter-react-hooks';
3 | import ReactDOM from 'react-dom/client';
4 | import '@tronweb3/tronwallet-adapter-react-ui/style.css';
5 | import './index.css';
6 | import { Toaster } from 'react-hot-toast';
7 | import { App } from './App';
8 | import { ThemeProvider } from '@mui/material/styles';
9 | import theme from './theme';
10 | import vConsole from 'vconsole'
11 | new vConsole();
12 |
13 | ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
14 |
15 |
16 |
17 |
18 |
19 |
20 | );
21 |
--------------------------------------------------------------------------------
/demos/react-ui/vite-app/src/theme.ts:
--------------------------------------------------------------------------------
1 | import { createTheme } from '@mui/material/styles';
2 | import { red } from '@mui/material/colors';
3 |
4 | // Create a theme instance.
5 | const theme = createTheme({
6 | palette: {
7 | primary: {
8 | main: '#556cd6',
9 | },
10 | secondary: {
11 | main: '#19857b',
12 | },
13 | error: {
14 | main: red.A400,
15 | },
16 | },
17 | });
18 |
19 | export default theme;
20 |
--------------------------------------------------------------------------------
/demos/react-ui/vite-app/src/tronweb.ts:
--------------------------------------------------------------------------------
1 | // @ts-ignore
2 | import TronWeb from 'tronweb';
3 |
4 | export const tronWeb: any = new TronWeb({
5 | fullHost: 'https://api.nileex.io',
6 | });
7 | (window as any).tronWeb1 = tronWeb;
8 |
9 |
--------------------------------------------------------------------------------
/demos/react-ui/vite-app/src/vite-env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
--------------------------------------------------------------------------------
/demos/react-ui/vite-app/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ESNext",
4 | "useDefineForClassFields": true,
5 | "lib": ["DOM", "DOM.Iterable", "ESNext"],
6 | "allowJs": false,
7 | "skipLibCheck": true,
8 | "esModuleInterop": false,
9 | "allowSyntheticDefaultImports": true,
10 | "strict": true,
11 | "forceConsistentCasingInFileNames": true,
12 | "module": "ESNext",
13 | "moduleResolution": "Node",
14 | "resolveJsonModule": true,
15 | "isolatedModules": true,
16 | "noEmit": true,
17 | "jsx": "react-jsx"
18 | },
19 | "include": ["src"],
20 | "references": [{ "path": "./tsconfig.node.json" }]
21 | }
22 |
--------------------------------------------------------------------------------
/demos/react-ui/vite-app/tsconfig.node.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "composite": true,
4 | "module": "ESNext",
5 | "moduleResolution": "Node",
6 | "allowSyntheticDefaultImports": true
7 | },
8 | "include": ["vite.config.ts"]
9 | }
10 |
--------------------------------------------------------------------------------
/demos/react-ui/vite-app/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite';
2 | import react from '@vitejs/plugin-react';
3 | import legacy from '@vitejs/plugin-legacy';
4 |
5 | // https://vitejs.dev/config/
6 | export default defineConfig({
7 | plugins: [
8 | react(),
9 | legacy({
10 | targets: ['>0.3%', 'defaults'],
11 | }),
12 | ],
13 | define: {
14 | global: 'window',
15 | },
16 | resolve: {
17 | alias: {
18 | eventemitter3: 'eventemitter3/umd/eventemitter3.js',
19 | },
20 | },
21 | build: {
22 | // Set false to speed up build process, should change to `true` for production mode.
23 | minify: false,
24 | },
25 | optimizeDeps: {
26 | // Clear the array to optimize the dependencies
27 | exclude: [
28 | '@tronweb3/tronwallet-adapters',
29 | '@tronweb3/tronwallet-adapter-tronlink',
30 | '@tronweb3/tronwallet-abstract-adapter',
31 | ],
32 | },
33 | server: {
34 | host: '0.0.0.0',
35 | port: 5003,
36 | },
37 | });
38 |
--------------------------------------------------------------------------------
/demos/vue-ui/vite-app/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 | pnpm-debug.log*
8 | lerna-debug.log*
9 |
10 | node_modules
11 | dist
12 | dist-ssr
13 | *.local
14 |
15 | # Editor directories and files
16 | .vscode/*
17 | !.vscode/extensions.json
18 | .idea
19 | .DS_Store
20 | *.suo
21 | *.ntvs*
22 | *.njsproj
23 | *.sln
24 | *.sw?
25 |
--------------------------------------------------------------------------------
/demos/vue-ui/vite-app/README.md:
--------------------------------------------------------------------------------
1 | # Vue 3 + TypeScript + Vite
2 |
3 | This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `
12 |