From 88d81d1c035866f7b10e832d0a1da5948df5084e Mon Sep 17 00:00:00 2001 From: sven Tan Date: Fri, 23 Aug 2024 18:08:52 +0800 Subject: [PATCH] add sdk kit wallet info (#2492) --- pnpm-lock.yaml | 116 +++++++++++++++++- sdk/typescript/rooch-sdk-kit/package.json | 3 +- .../rooch-sdk-kit/src/feature/index.ts | 2 +- .../src/provider/walletProvider.tsx | 2 +- .../rooch-sdk-kit/src/utils/walletUtils.ts | 17 +-- .../rooch-sdk-kit/src/wellet/okx.ts | 18 ++- .../src/wellet/onekey-hardware.ts | 2 - .../rooch-sdk-kit/src/wellet/onekey.ts | 18 ++- .../rooch-sdk-kit/src/wellet/unisat.ts | 14 ++- .../rooch-sdk-kit/src/wellet/wallet.ts | 7 ++ .../rooch-sdk-kit/src/wellet/xverse.ts | 81 ++++++++++++ sdk/typescript/rooch-sdk/package.json | 3 +- .../templates/react-counter/src/App.tsx | 100 ++++++++++----- .../templates/react-counter/src/main.tsx | 2 +- 14 files changed, 324 insertions(+), 61 deletions(-) delete mode 100644 sdk/typescript/rooch-sdk-kit/src/wellet/onekey-hardware.ts create mode 100644 sdk/typescript/rooch-sdk-kit/src/wellet/xverse.ts diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ae6d584a94..7aa5105f90 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -405,6 +405,9 @@ importers: bs58check: specifier: 2.1.2 version: 2.1.2 + buffer: + specifier: 6.0.3 + version: 6.0.3 tweetnacl: specifier: ^1.0.3 version: 1.0.3 @@ -447,7 +450,7 @@ importers: version: 4.5.3(@types/node@20.14.14)(terser@5.31.1) vitest: specifier: ^1.6.0 - version: 1.6.0(@types/node@20.14.14)(happy-dom@14.12.0)(jsdom@23.2.0(bufferutil@4.0.8)(utf-8-validate@6.0.4))(terser@5.31.1) + version: 1.6.0(@types/node@20.14.14)(happy-dom@14.12.0)(jsdom@23.2.0)(terser@5.31.1) wait-on: specifier: ^7.0.1 version: 7.2.0 @@ -518,6 +521,9 @@ importers: react-dom: specifier: ^18.2.0 version: 18.2.0(react@18.2.0) + sats-connect: + specifier: 2.7.0 + version: 2.7.0(typescript@5.4.5)(valibot@0.25.0) size-limit: specifier: ^8.2.6 version: 8.2.6 @@ -529,7 +535,7 @@ importers: version: 4.5.3(@types/node@20.14.14)(terser@5.31.1) vitest: specifier: ^1.6.0 - version: 1.6.0(@types/node@20.14.14)(happy-dom@14.12.0)(jsdom@23.2.0(bufferutil@4.0.8)(utf-8-validate@6.0.4))(terser@5.31.1) + version: 1.6.0(@types/node@20.14.14)(happy-dom@14.12.0)(jsdom@23.2.0)(terser@5.31.1) sdk/typescript/templates/react-counter: dependencies: @@ -617,7 +623,7 @@ importers: version: 4.5.3(@types/node@20.14.14)(terser@5.31.1) vitest: specifier: ^1.6.0 - version: 1.6.0(@types/node@20.14.14)(happy-dom@14.12.0)(jsdom@23.2.0(bufferutil@4.0.8)(utf-8-validate@6.0.4))(terser@5.31.1) + version: 1.6.0(@types/node@20.14.14)(happy-dom@14.12.0)(jsdom@23.2.0)(terser@5.31.1) packages: @@ -2233,6 +2239,9 @@ packages: resolution: {integrity: sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==} engines: {node: '>= 16'} + '@noble/secp256k1@1.7.1': + resolution: {integrity: sha512-hOUk6AyBFmqVrv7k5WAw/LpszxVbj9gGN4JRkIX52fdFAj1UA61KXmZDvqVEm+pOyec3+fIeZB02LYa/pWOArw==} + '@nodelib/fs.scandir@2.1.5': resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} @@ -3223,6 +3232,20 @@ packages: '@rushstack/eslint-patch@1.10.3': resolution: {integrity: sha512-qC/xYId4NMebE6w/V33Fh9gWxLgURiNYgVNObbJl2LZv0GUUItCcCqC5axQSwRaAgaxl2mELq1rMzlswaQ0Zxg==} + '@sats-connect/core@0.2.1': + resolution: {integrity: sha512-e7ARFqN4JE8kBiSUNOcEvBffiBK9v7k+/PlwgYY5lGyanmBOMj5twBn/f/4+52GBLZXkwhJtidIWZ8LgnBdlbw==} + peerDependencies: + valibot: 0.33.2 + + '@sats-connect/make-default-provider-config@0.0.5': + resolution: {integrity: sha512-b/v4IeDEde5DqFOdMbMmf3B0t/lxlKnY04f3YIUWe1khOg3S6VdcK9Mqva+WUOsJHBTIA5b4hK7CqfMjx1Ic+w==} + peerDependencies: + '@sats-connect/core': '*' + typescript: 5.4.4 + + '@sats-connect/ui@0.0.6': + resolution: {integrity: sha512-H3bFFhr9CcY1oNosNi/QJszmMHSht4U19bUWfM3vzayAKgV4ebY6iUnRK5g3p2rVLLWVzlpaw1J9m+7JWwyBfA==} + '@scure/base@1.1.7': resolution: {integrity: sha512-PPNYBslrLNNUQ/Yad37MHYsNQtK67EhWb6WtSvNLLPo7SdVZgkUjD6Dg+5On7zNwmskf8OX7I7Nx5oN+MIWE0g==} @@ -4001,6 +4024,9 @@ packages: resolution: {integrity: sha512-M0JtH+hlOL5pLQwHOLNYZaXuhqmvS8oExsqB1SBYgA4Dk7u/xx+YdGHXaK5pyUfed5mYXdlYiphWq3G8cRi5JQ==} engines: {node: '>=4'} + axios@1.6.8: + resolution: {integrity: sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==} + axios@1.7.2: resolution: {integrity: sha512-2A8QhOMrbomlDuiLeK9XibIBzuHeRcqqNOHp0Cyp5EoJ1IFDh+XZH3A6BkXtv0K4gFGCI0Y4BM7B1wOEi0Rmgw==} @@ -4070,6 +4096,10 @@ packages: base-x@4.0.0: resolution: {integrity: sha512-FuwxlW4H5kh37X/oW59pwTzzTKRzfrrQwhmyspRM7swOEZcHtDZSCt45U6oKgtuFE+WYPblePMVIPR4RZrh/hw==} + base58-js@1.0.5: + resolution: {integrity: sha512-LkkAPP8Zu+c0SVNRTRVDyMfKVORThX+rCViget00xdgLRrKkClCTz1T7cIrpr69ShwV5XJuuoZvMvJ43yURwkA==} + engines: {node: '>= 8'} + base64-js@1.5.1: resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} @@ -4094,6 +4124,9 @@ packages: resolution: {integrity: sha512-mdFV5+/v0XyNYXjBS6CQPLo9ekCx4gtKZFnJm5PMto7Fs9hTTDpkkzOB7/FtluRI6JbUUAu+snTYfJRgHLZbZQ==} engines: {node: '>=8.0.0'} + bitcoin-address-validation@2.2.3: + resolution: {integrity: sha512-1uGCGl26Ye8JG5qcExtFLQfuib6qEZWNDo1ZlLlwp/z7ygUFby3IxolgEfgMGaC+LG9csbVASLcH8fRLv7DIOg==} + bitcoinjs-lib@6.1.6: resolution: {integrity: sha512-Fk8+Vc+e2rMoDU5gXkW9tD+313rhkm5h6N9HfZxXvYU9LedttVvmXKTgd9k5rsQJjkSfsv6XRM8uhJv94SrvcA==} engines: {node: '>=8.0.0'} @@ -4107,6 +4140,9 @@ packages: bn.js@5.2.1: resolution: {integrity: sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==} + bowser@2.11.0: + resolution: {integrity: sha512-AlcaJBi/pqqJBIQ8U9Mcpc9i8Aqxn88Skv5d+xBX006BY5u8N3mGLHa5Lgppa7L/HfwgwLgZ6NYs+Ag6uUmJRA==} + brace-expansion@1.1.11: resolution: {integrity: sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==} @@ -6288,6 +6324,9 @@ packages: jsonfile@4.0.0: resolution: {integrity: sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==} + jsontokens@4.0.1: + resolution: {integrity: sha512-+MO415LEN6M+3FGsRz4wU20g7N2JA+2j9d9+pGaNJHviG4L8N0qzavGyENw6fJqsq9CcrHOIL6iWX5yeTZ86+Q==} + jsx-ast-utils@3.3.5: resolution: {integrity: sha512-ZZow9HBI5O6EPgSJLUb8n2NKgmVWTwCvHGwFuJlMjvLFqlGG6pjirPhtdsseaLZjSibD8eegzmYpUZwoIlj2cQ==} engines: {node: '>=4.0'} @@ -6391,6 +6430,9 @@ packages: lodash.merge@4.6.2: resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==} + lodash.omit@4.5.0: + resolution: {integrity: sha512-XeqSp49hNGmlkj2EJlfrQFIzQ6lXdNro9sddtQzcJY8QaoC2GO0DT7xaIokHeyM+mIT0mPMlPvkYzg2xCuHdZg==} + lodash.startcase@4.4.0: resolution: {integrity: sha512-+WKqsK294HMSc2jEbNgpHpd0JfIBhp7rEV4aqXWqFr6AlXov+SlcgB1Fv01y2kGe3Gc8nMW7VA0SrGuSkRfIEg==} @@ -7994,6 +8036,9 @@ packages: safer-buffer@2.1.2: resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==} + sats-connect@2.7.0: + resolution: {integrity: sha512-hQ09n5DNJeryUl3szgHkziMM81nFn97BwzJuRXEjViOAbQRrET/mFCIRJ9NPtEE7h8lUYrBKumSeYip/7H3Vyg==} + saxes@6.0.0: resolution: {integrity: sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==} engines: {node: '>=v12.22.7'} @@ -8072,6 +8117,9 @@ packages: resolution: {integrity: sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==} hasBin: true + sha256-uint8array@0.10.7: + resolution: {integrity: sha512-1Q6JQU4tX9NqsDGodej6pkrUVQVNapLZnvkwIhddH/JqzBZF1fSaxSWNY6sziXBE8aEa2twtGkXUrwzGeZCMpQ==} + shallow-clone@3.0.1: resolution: {integrity: sha512-/6KqX+GVUdqPuPPd2LxDDxzX6CAbjJehAAOKlNpqqUpAqPM6HeL8f+o3a+JsyGjn2lv0WY8UsTgUJjU9Ok55NA==} engines: {node: '>=8'} @@ -10992,6 +11040,8 @@ snapshots: '@noble/hashes@1.4.0': {} + '@noble/secp256k1@1.7.1': {} + '@nodelib/fs.scandir@2.1.5': dependencies: '@nodelib/fs.stat': 2.0.5 @@ -12297,6 +12347,26 @@ snapshots: '@rushstack/eslint-patch@1.10.3': {} + '@sats-connect/core@0.2.1(valibot@0.25.0)': + dependencies: + axios: 1.6.8 + bitcoin-address-validation: 2.2.3 + buffer: 6.0.3 + jsontokens: 4.0.1 + lodash.omit: 4.5.0 + valibot: 0.25.0 + transitivePeerDependencies: + - debug + + '@sats-connect/make-default-provider-config@0.0.5(@sats-connect/core@0.2.1(valibot@0.25.0))(typescript@5.4.5)': + dependencies: + '@sats-connect/core': 0.2.1(valibot@0.25.0) + '@sats-connect/ui': 0.0.6 + bowser: 2.11.0 + typescript: 5.4.5 + + '@sats-connect/ui@0.0.6': {} + '@scure/base@1.1.7': {} '@scure/bip32@1.4.0': @@ -13301,6 +13371,14 @@ snapshots: axe-core@4.7.0: {} + axios@1.6.8: + dependencies: + follow-redirects: 1.15.6 + form-data: 4.0.0 + proxy-from-env: 1.1.0 + transitivePeerDependencies: + - debug + axios@1.7.2: dependencies: follow-redirects: 1.15.6 @@ -13412,6 +13490,8 @@ snapshots: base-x@4.0.0: {} + base58-js@1.0.5: {} + base64-js@1.5.1: {} bcrypt-pbkdf@1.0.2: @@ -13432,6 +13512,12 @@ snapshots: bip174@2.1.1: {} + bitcoin-address-validation@2.2.3: + dependencies: + base58-js: 1.0.5 + bech32: 2.0.0 + sha256-uint8array: 0.10.7 + bitcoinjs-lib@6.1.6: dependencies: '@noble/hashes': 1.4.0 @@ -13451,6 +13537,8 @@ snapshots: bn.js@5.2.1: {} + bowser@2.11.0: {} + brace-expansion@1.1.11: dependencies: balanced-match: 1.0.2 @@ -16160,6 +16248,12 @@ snapshots: optionalDependencies: graceful-fs: 4.2.11 + jsontokens@4.0.1: + dependencies: + '@noble/hashes': 1.4.0 + '@noble/secp256k1': 1.7.1 + base64-js: 1.5.1 + jsx-ast-utils@3.3.5: dependencies: array-includes: 3.1.8 @@ -16261,6 +16355,8 @@ snapshots: lodash.merge@4.6.2: {} + lodash.omit@4.5.0: {} + lodash.startcase@4.4.0: {} lodash.throttle@4.1.1: {} @@ -18407,6 +18503,16 @@ snapshots: safer-buffer@2.1.2: {} + sats-connect@2.7.0(typescript@5.4.5)(valibot@0.25.0): + dependencies: + '@sats-connect/core': 0.2.1(valibot@0.25.0) + '@sats-connect/make-default-provider-config': 0.0.5(@sats-connect/core@0.2.1(valibot@0.25.0))(typescript@5.4.5) + '@sats-connect/ui': 0.0.6 + transitivePeerDependencies: + - debug + - typescript + - valibot + saxes@6.0.0: dependencies: xmlchars: 2.2.0 @@ -18508,6 +18614,8 @@ snapshots: inherits: 2.0.4 safe-buffer: 5.2.1 + sha256-uint8array@0.10.7: {} + shallow-clone@3.0.1: dependencies: kind-of: 6.0.3 @@ -19445,7 +19553,7 @@ snapshots: fsevents: 2.3.3 terser: 5.31.1 - vitest@1.6.0(@types/node@20.14.14)(happy-dom@14.12.0)(jsdom@23.2.0(bufferutil@4.0.8)(utf-8-validate@6.0.4))(terser@5.31.1): + vitest@1.6.0(@types/node@20.14.14)(happy-dom@14.12.0)(jsdom@23.2.0)(terser@5.31.1): dependencies: '@vitest/expect': 1.6.0 '@vitest/runner': 1.6.0 diff --git a/sdk/typescript/rooch-sdk-kit/package.json b/sdk/typescript/rooch-sdk-kit/package.json index 5e05e29c73..879960c856 100644 --- a/sdk/typescript/rooch-sdk-kit/package.json +++ b/sdk/typescript/rooch-sdk-kit/package.json @@ -72,7 +72,8 @@ "size-limit": "^8.2.6", "typescript": "^5.3.3", "vite": "^4.4.4", - "vitest": "^1.6.0" + "vitest": "^1.6.0", + "sats-connect": "2.7.0" }, "dependencies": { "clsx": "^2.0.0", diff --git a/sdk/typescript/rooch-sdk-kit/src/feature/index.ts b/sdk/typescript/rooch-sdk-kit/src/feature/index.ts index c3be80530e..bf0bd199e1 100644 --- a/sdk/typescript/rooch-sdk-kit/src/feature/index.ts +++ b/sdk/typescript/rooch-sdk-kit/src/feature/index.ts @@ -2,4 +2,4 @@ // SPDX-License-Identifier: Apache-2.0 export type SupportChain = 'rooch' | 'bitcoin' -export type SupportWallet = 'unisat' | 'okx' | 'onekey' //| 'onekey-hardware' +export type SupportWallet = 'UniSat' | 'OKX' | 'OneKey' //| 'onekey-hardware' diff --git a/sdk/typescript/rooch-sdk-kit/src/provider/walletProvider.tsx b/sdk/typescript/rooch-sdk-kit/src/provider/walletProvider.tsx index 93c727f7f2..dc68eab65b 100644 --- a/sdk/typescript/rooch-sdk-kit/src/provider/walletProvider.tsx +++ b/sdk/typescript/rooch-sdk-kit/src/provider/walletProvider.tsx @@ -42,7 +42,7 @@ const DEFAULT_STORAGE_KEY = 'rooch-sdk-kit:wallet-connect-info' export const WalletContext = createContext(null) export function WalletProvider({ - preferredWallets = ['unisat', 'okx'], + preferredWallets = ['UniSat', 'OKX'], chain = 'bitcoin', storage, storageKey = DEFAULT_STORAGE_KEY, diff --git a/sdk/typescript/rooch-sdk-kit/src/utils/walletUtils.ts b/sdk/typescript/rooch-sdk-kit/src/utils/walletUtils.ts index f0557d6890..9e4737776e 100644 --- a/sdk/typescript/rooch-sdk-kit/src/utils/walletUtils.ts +++ b/sdk/typescript/rooch-sdk-kit/src/utils/walletUtils.ts @@ -2,21 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 import { SupportChain } from '../feature/index.js' -import { - Wallet, - UniSatWallet, - // OkxWallet, - // OnekeyWallet, - // OnekeyHardwareWallet, -} from '../wellet/index.js' +import { Wallet, UniSatWallet, OkxWallet, OnekeyWallet } from '../wellet/index.js' export async function checkWallets(filter?: SupportChain) { - const wallets: Wallet[] = [ - new UniSatWallet(), - // new OkxWallet(), - // new OnekeyWallet(), - // new OnekeyHardwareWallet(), - ].filter((wallet) => wallet.getChain() === filter || !filter) + const wallets: Wallet[] = [new UniSatWallet(), new OkxWallet(), new OnekeyWallet()].filter( + (wallet) => wallet.getChain() === filter || !filter, + ) return await Promise.all(wallets.filter(async (w) => await w.checkInstalled())) } diff --git a/sdk/typescript/rooch-sdk-kit/src/wellet/okx.ts b/sdk/typescript/rooch-sdk-kit/src/wellet/okx.ts index 186724e0a7..cd5b8e3382 100644 --- a/sdk/typescript/rooch-sdk-kit/src/wellet/okx.ts +++ b/sdk/typescript/rooch-sdk-kit/src/wellet/okx.ts @@ -6,7 +6,23 @@ import { BitcoinWallet } from '../wellet/index.js' export class OkxWallet extends BitcoinWallet { getName(): string { - return 'okx' + return 'OKX' + } + + getIcon(_?: 'dark' | 'light'): string { + // if (theme === 'dark') { + // return '' + // } + + return 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48c3ZnIGlkPSJhIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxNTAgMTUwIj48ZGVmcz48c3R5bGU+LmV7ZmlsbDpub25lO308L3N0eWxlPjwvZGVmcz48ZyBpZD0iYiI+PGcgaWQ9ImMiPjxwYXRoIGlkPSJkIiBjbGFzcz0iZSIgZD0iTTAsMEgxNTBWMTUwSDBWMFoiLz48L2c+PC9nPjxwYXRoIGQ9Ik0xMy44MSwxMy41N3YxMjMuOThoMTIzLjk4VjEzLjU3SDEzLjgxWm0yNi44MiwyOC42NGMwLS44NywuNzEtMS41OCwxLjU4LTEuNThoMjAuM2MuODcsMCwxLjU4LC43MSwxLjU4LDEuNTh2MjAuM2MwLC44OC0uNzEsMS41OS0xLjU4LDEuNTloLTIwLjNjLS44NywwLTEuNTgtLjcxLTEuNTgtMS41OXYtMjAuM1ptMjMuNDYsNjYuN2MwLC44Ny0uNzEsMS41OC0xLjU4LDEuNThoLTIwLjNjLS44NywwLTEuNTgtLjcxLTEuNTgtMS41OHYtMjAuM2MwLS44OCwuNzEtMS41OSwxLjU4LTEuNTloMjAuM2MuODcsMCwxLjU4LC43MSwxLjU4LDEuNTl2MjAuM1ptMjEuODYtMjEuNjJoLTIwLjNjLS44NywwLTEuNTktLjcxLTEuNTktMS41OXYtMjAuM2MwLS44NywuNzEtMS41OSwxLjU5LTEuNTloMjAuM2MuODcsMCwxLjU5LC43MSwxLjU5LDEuNTl2MjAuM2MwLC44Ny0uNzEsMS41OS0xLjU5LDEuNTlabTI1LjA1LDIxLjYyYzAsLjg3LS43MSwxLjU4LTEuNTksMS41OGgtMjAuM2MtLjg3LDAtMS41OC0uNzEtMS41OC0xLjU4di0yMC4zYzAtLjg4LC43MS0xLjU5LDEuNTgtMS41OWgyMC4zYy44NywwLDEuNTksLjcxLDEuNTksMS41OXYyMC4zWm0wLTQ2LjQxYzAsLjg4LS43MSwxLjU5LTEuNTksMS41OWgtMjAuM2MtLjg3LDAtMS41OC0uNzEtMS41OC0xLjU5di0yMC4zYzAtLjg3LC43MS0xLjU4LDEuNTgtMS41OGgyMC4zYy44NywwLDEuNTksLjcxLDEuNTksMS41OHYyMC4zWiIvPjwvc3ZnPg==' + } + + getDescription(): string { + return 'OKX Wallet' + } + + getInstallUrl(): string { + return 'https://chromewebstore.google.com/detail/okx-wallet/mcohilncbfahbmgdjkbpemcciiolgcge' } async sign(msg: Bytes): Promise { diff --git a/sdk/typescript/rooch-sdk-kit/src/wellet/onekey-hardware.ts b/sdk/typescript/rooch-sdk-kit/src/wellet/onekey-hardware.ts deleted file mode 100644 index 776dcb51d2..0000000000 --- a/sdk/typescript/rooch-sdk-kit/src/wellet/onekey-hardware.ts +++ /dev/null @@ -1,2 +0,0 @@ -// Copyright (c) RoochNetwork -// SPDX-License-Identifier: Apache-2.0 diff --git a/sdk/typescript/rooch-sdk-kit/src/wellet/onekey.ts b/sdk/typescript/rooch-sdk-kit/src/wellet/onekey.ts index 7b23cb4461..91ed6cbfce 100644 --- a/sdk/typescript/rooch-sdk-kit/src/wellet/onekey.ts +++ b/sdk/typescript/rooch-sdk-kit/src/wellet/onekey.ts @@ -6,7 +6,23 @@ import { BitcoinWallet } from '../wellet/index.js' export class OnekeyWallet extends BitcoinWallet { getName(): string { - return 'onekey' + return 'OneKey' + } + + getIcon(theme?: 'dark' | 'light'): string { + if (theme === 'dark') { + return 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTQ0IiBoZWlnaHQ9IjE0NCIgdmlld0JveD0iMCAwIDE0NCAxNDQiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNNzIgMTQ0QzEyMS43MDYgMTQ0IDE0NCAxMjEuNzA2IDE0NCA3MkMxNDQgMjIuMjk0NCAxMjEuNzA2IDAgNzIgMEMyMi4yOTQ0IDAgMCAyMi4yOTQ0IDAgNzJDMCAxMjEuNzA2IDIyLjI5NDQgMTQ0IDcyIDE0NFpNNTguNDc1MyAzMC41MzA1SDc4LjUwNTNWNjMuNTM4MUg2Ni4wODY1VjQxLjE1NjJINTQuOTYxM0w1OC40NzUzIDMwLjUzMDVaTTcyLjAwMDQgMTEzLjQ2OUM4NC42MTY0IDExMy40NjkgOTQuODQzNyAxMDM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1OC40NzUzIDMwLjUzMDVaTTcyLjAwMDQgMTEzLjQ2OUM4NC42MTY0IDExMy40NjkgOTQuODQzNyAxMDMuMjQyIDk0Ljg0MzcgOTAuNjI2MUM5NC44NDM3IDc4LjAxMDEgODQuNjE2NCA2Ny43ODI4IDcyLjAwMDQgNjcuNzgyOEM1OS4zODQ0IDY3Ljc4MjggNDkuMTU3MSA3OC4wMTAxIDQ5LjE1NzEgOTAuNjI2MUM0OS4xNTcxIDEwMy4yNDIgNTkuMzg0NCAxMTMuNDY5IDcyLjAwMDQgMTEzLjQ2OVpNNzIuMDAwNCAxMDMuMDk5Qzc4Ljg4ODkgMTAzLjA5OSA4NC40NzMxIDk3LjUxNDUgODQuNDczMSA5MC42MjZDODQuNDczMSA4My43Mzc1IDc4Ljg4ODkgNzguMTUzMyA3Mi4wMDA0IDc4LjE1MzNDNjUuMTExOSA3OC4xNTMzIDU5LjUyNzYgODMuNzM3NSA1OS41Mjc2IDkwLjYyNkM1OS41Mjc2IDk3LjUxNDUgNjUuMTExOSAxMDMuMDk5IDcyLjAwMDQgMTAzLjA5OVoiIGZpbGw9IiM0NEQ2MkMiIHN0eWxlPSJmaWxsOiM0NEQ2MkM7ZmlsbDpjb2xvcihkaXNwbGF5LXAzIDAuMjY2NyAwLjgzOTIgMC4xNzI1KTtmaWxsLW9wYWNpdHk6MTsiLz4KPC9zdmc+Cg==' + } + + getDescription(): string { + return 'OneKey Wallet' + } + + getInstallUrl(): string { + return 'https://chromewebstore.google.com/detail/onekey/jnmbobjmhlngoefaiojfljckilhhlhcj' } async sign(msg: Bytes): Promise { diff --git a/sdk/typescript/rooch-sdk-kit/src/wellet/unisat.ts b/sdk/typescript/rooch-sdk-kit/src/wellet/unisat.ts index dc7e487acd..62bfe76f1f 100644 --- a/sdk/typescript/rooch-sdk-kit/src/wellet/unisat.ts +++ b/sdk/typescript/rooch-sdk-kit/src/wellet/unisat.ts @@ -9,7 +9,19 @@ const UNISAT_SUPPORT_NETWORKS = ['livenet', 'testnet'] export class UniSatWallet extends BitcoinWallet { getName(): string { - return 'unisat' + return 'UniSat' + } + + getIcon(_?: 'dark' | 'light'): string { + return 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyBpZD0iX2ZyYW1lXzIiIGRhdGEtbmFtZT0iZnJhbWUgMiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmlld0JveD0iLTE1IDAgMTAwIDEwMCI+CiAgPGRlZnM+CiAgICA8c3R5bGU+CiAgICAgIC5jbHMtMSB7CiAgICAgICAgZmlsbDogdXJsKCNfbGxfMTI2KTsKICAgICAgfQoKICAgICAgLmNscy0yIHsKICAgICAgICBmaWxsOiB1cmwoI19sbF8xMjMpOwogICAgICB9CgogICAgICAuY2xzLTMgewogICAgICAgIGZpbGw6IHVybCgjX2xsXzEyMSk7CiAgICAgIH0KCiAgICAgIC5jbHMtNCB7CiAgICAgICAgZmlsbDogI2ZmZjsKICAgICAgICBmb250LWZhbWlseTogSmV0QnJhaW5zTW9ub1JvbWFuLU1lZGl1bSwgJ0pldEJyYWlucyBNb25vJzsKICAgICAgICBmb250LXNpemU6IDI0Ljc5cHg7CiAgICAgICAgZm9udC12YXJpYXRpb24tc2V0dGluZ3M6ICd3Z2h0JyA1MDA7CiAgICAgIH0KICAgIDwvc3R5bGU+CiAgICA8bGluZWFyR3JhZGllbnQgaWQ9Il9sbF8xMjYiICB4MT0iOTYxLjY4IiB5MT0iLTQ1LjU3IiB4Mj0iOTg2LjE0IiB5Mj0iLTExMC4wNiIgZ3JhZGllbnRUcmFuc2Zvcm09InRyYW5zbGF0ZSg3ODAuOTkgNjcxLjcpIHJvdGF0ZSgtMTM0LjczKSIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiPgogICAgICA8c3RvcCBvZmZzZ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Ny40NyIvPgogICAgICA8L2c+CiAgICA8L2c+CiAgPC9nPgo8L3N2Zz4K' + } + + getDescription(): string { + return 'UniSat Wallet' + } + + getInstallUrl(): string { + return '' } getTarget(): any { diff --git a/sdk/typescript/rooch-sdk-kit/src/wellet/wallet.ts b/sdk/typescript/rooch-sdk-kit/src/wellet/wallet.ts index c0ec4e1339..b48d691294 100644 --- a/sdk/typescript/rooch-sdk-kit/src/wellet/wallet.ts +++ b/sdk/typescript/rooch-sdk-kit/src/wellet/wallet.ts @@ -17,6 +17,13 @@ export abstract class Wallet extends Signer { abstract connect(): Promise abstract getName(): string + + abstract getIcon(theme?: 'dark' | 'light'): string + + abstract getInstallUrl(): string + + abstract getDescription(): string + /** * Signs a message. * @param msg - The message to sign. diff --git a/sdk/typescript/rooch-sdk-kit/src/wellet/xverse.ts b/sdk/typescript/rooch-sdk-kit/src/wellet/xverse.ts new file mode 100644 index 0000000000..af60d6c748 --- /dev/null +++ b/sdk/typescript/rooch-sdk-kit/src/wellet/xverse.ts @@ -0,0 +1,81 @@ +// Copyright (c) RoochNetwork +// SPDX-License-Identifier: Apache-2.0 + +// import Wallet from 'sats-connect' +import { BitcoinAddress, Bytes, ThirdPartyAddress, str, bytes } from '@roochnetwork/rooch-sdk' +import { BitcoinWallet } from '../wellet/index.js' + +export class XVerseWallet extends BitcoinWallet { + // private callback : Map void> + + getName(): string { + return 'Xverse' + } + + getIcon(_?: 'dark' | 'light'): string { + // if (theme === 'dark') { + // return '' + // } + + return 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI2MDAiIGhlaWdodD0iNjAwIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGZpbGw9IiMxNzE3MTciIGQ9Ik0wIDBoNjAwdjYwMEgweiIvPjxwYXRoIGZpbGw9IiNGRkYiIGZpbGwtcnVsZT0ibm9uemVybyIgZD0iTTQ0MCA0MzUuNHYtNTFjMC0yLS44LTMuOS0yLjItNS4zTDIyMCAxNjIuMmE3LjYgNy42IDAgMCAwLTUuNC0yLjJoLTUxLjFjLTIuNSAwLTQuNiAyLTQuNiA0LjZ2NDcuM2MwIDIgLjggNCAyLjIgNS40bDc4LjIgNzcuOGE0LjYgNC42IDAgMCAxIDAgNi41bC03OSA3OC43Yy0xIC45LTEuNCAyLTEuNCAzLjJ2NTJjMCAyLjQgMiA0LjUgNC42IDQuNUgyNDljMi42IDAgNC42LTIgNC42LTQuNlY0MDVjMC0xLjIuNS0yLjQgMS40LTMuM2w0Mi40LTQyLjJhNC42IDQuNiAwIDAgMSA2LjQgMGw3OC43IDc4LjRhNy42IDcuNiAwIDAgMCA1LjQgMi4yaDQ3LjVjMi41IDAgNC42LTIgNC42LTQuNloiLz48cGF0aCBmaWxsPSIjRUU3QTMwIiBmaWxsLXJ1bGU9Im5vbnplcm8iIGQ9Ik0zMjUuNiAyMjcuMmg0Mi44YzIuNiAwIDQuNiAyLjEgNC42IDQuNnY0Mi42YzAgNCA1IDYuMSA4IDMuMmw1OC43LTU4LjVjLjgtLjggMS4zLTIgMS4zLTMuMnYtNTEuMmMwLTIuNi0yLTQuNi00LjYtNC42TDM4NCAxNjBjLTEuMiAwLTIuNC41LTMuMyAxLjNsLTU4LjQgNTguMWE0LjYgNC42IDAgMCAwIDMuMiA3LjhaIi8+PC9nPjwvc3ZnPg==' + } + + getDescription(): string { + return 'Xverse Wallet' + } + + getInstallUrl(): string { + return 'https://chrome.google.com/webstore/detail/xverse-wallet/idnnbdplmphpflfnlkomgpfbpcgelopg?hl=en-GB&authuser=1' + } + + async sign(msg: Bytes): Promise { + const msgStr = str('utf8', msg) + const sign = await this.getTarget().signMessage(msgStr, { + from: this.currentAddress?.toStr(), + }) + return bytes('base64', sign).subarray(1) + } + + getTarget(): any { + return (window as any).XverseProviders?.BitcoinProvider + } + + async connect(): Promise { + let objs: any[] = await this.getTarget().getAccounts() + + this.address = objs.map((obj) => new BitcoinAddress(obj.address)) + this.currentAddress = this.address[0] + this.publicKey = objs[0].publicKey + + return this.address + } + + switchNetwork(): void { + // this.getTarget().switchNetwork() + } + + getNetwork(): string { + return 'Mainnet' + // return this.getTarget().getNetwork() + } + + getSupportNetworks(): string[] { + return ['Mainnet', 'Testnet', 'Signet'] + } + + onAccountsChanged(callback: (account: string[]) => void): void { + this.getTarget().on('accountsChanged', callback) + } + + removeAccountsChanged(callback: (account: string[]) => void): void { + this.getTarget().removeListener('accountsChanged', callback) + } + + onNetworkChanged(callback: (network: string) => void): void { + this.getTarget().on('networkChanged', callback) + } + + removeNetworkChanged(callback: (network: string) => void): void { + this.getTarget().removeListener('networkChanged', callback) + } +} diff --git a/sdk/typescript/rooch-sdk/package.json b/sdk/typescript/rooch-sdk/package.json index f872e6e931..4c47234322 100644 --- a/sdk/typescript/rooch-sdk/package.json +++ b/sdk/typescript/rooch-sdk/package.json @@ -71,7 +71,8 @@ "bech32": "^2.0.0", "@mysten/bcs": "1.0.2", "valibot": "^0.25.0", - "bs58check": "2.1.2" + "bs58check": "2.1.2", + "buffer": "6.0.3" }, "publishConfig": { "access": "public", diff --git a/sdk/typescript/templates/react-counter/src/App.tsx b/sdk/typescript/templates/react-counter/src/App.tsx index 6250351740..5d9cf4d7df 100644 --- a/sdk/typescript/templates/react-counter/src/App.tsx +++ b/sdk/typescript/templates/react-counter/src/App.tsx @@ -89,78 +89,110 @@ function App() { py="2" justify="between" style={{ - borderBottom: "1px solid var(--gray-a2)" + borderBottom: "1px solid var(--gray-a2)", }} > dApp Counter Template - - {wallets.length === 0 - ? "Please install the wallet and try again" - : isConnected ? status : ( - - - - ) - } + {wallet ? ( + Unisat Icon + ) : ( + <> + )} + {wallets.length === 0 ? ( + "Please install the wallet and try again" + ) : isConnected ? ( + status + ) : ( + + + + )} - Address: - {wallet?.getBitcoinAddress().toStr()} + Address: + + {wallet?.getBitcoinAddress().toStr()} + - PublicKey: - {wallet?.getPublicKey().toString()} + PublicKey: + + {wallet?.getPublicKey().toString()} + - Session Address: - {sessionKey?.getRoochAddress()?.toStr()} + Session Address: + + {sessionKey?.getRoochAddress()?.toStr()} + - {sessionKey ? "Counter" : "Create session key"} + + {sessionKey ? "Counter" : "Create session key"} + - {devCounterAddress.length !== 0 ? + {devCounterAddress.length !== 0 ? ( {sessionKey ? ( - {isPending ? "loading..." : error ? "counter module not published" : `${data?.return_values?.[0]?.decoded_value}`} + {isPending + ? "loading..." + : error + ? "counter module not published" + : `${data?.return_values?.[0]?.decoded_value}`} ) : null} { } - : <> - Please refer to the contract published by readme before trying again. - - If you have published a contract, enter the contract address correctly into devCounterAddress. + ) : ( + <> + + + Please refer to the contract published by readme before trying + again. + + + + If you have published a contract, enter the contract address + correctly into devCounterAddress. + - - } + )} ); diff --git a/sdk/typescript/templates/react-counter/src/main.tsx b/sdk/typescript/templates/react-counter/src/main.tsx index 2c1b78a9e5..aac2c52eba 100644 --- a/sdk/typescript/templates/react-counter/src/main.tsx +++ b/sdk/typescript/templates/react-counter/src/main.tsx @@ -15,7 +15,7 @@ ReactDOM.createRoot(document.getElementById("root")!).render( - +