Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"dependencies": {
"@ant-design/icons": "^4.7.0",
"@babel/core": "^7.16.0",
"@exodus/bitcoin-wallet-standard-chains": "^0.0.0",
"@fortawesome/fontawesome-svg-core": "^6.1.1",
"@fortawesome/free-regular-svg-icons": "^6.1.1",
"@fortawesome/free-solid-svg-icons": "^6.1.1",
Expand All @@ -54,6 +55,7 @@
"@unisat/bitcoin-hd-keyring": "1.0.1",
"@unisat/bitcoinjs-wallet": "^0.1.0",
"@unisat/ord-utils": "0.3.3",
"@wallet-standard/wallet": "^1.0.1",
"antd": "^4.20.4",
"antd-dayjs-webpack-plugin": "1.0.6",
"assert": "^2.0.0",
Expand Down Expand Up @@ -231,6 +233,7 @@
"@types/stylus": "^0.48.38",
"@typescript-eslint/eslint-plugin": "^5.26.0",
"@typescript-eslint/parser": "^5.26.0",
"@wallet-standard/base": "^1.0.1",
"autoprefixer": "^10.4.7",
"babel-plugin-import": "^1.13.5",
"eslint": "^8.16.0",
Expand Down
7 changes: 7 additions & 0 deletions src/content-script/pageProvider/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import { EventEmitter } from 'events';

import { TxType } from '@/shared/types';
import BroadcastChannelMessage from '@/shared/utils/message/broadcastChannelMessage';
import { registerWallet } from '@wallet-standard/wallet';

import PushEventHandlers from './pushEventHandlers';
import ReadyPromise from './readyPromise';
import { $, domReadyCall } from './utils';
import { UnisatWallet } from './wallet-standard';

const log = (event, ...args) => {
if (process.env.NODE_ENV !== 'production') {
Expand Down Expand Up @@ -332,3 +334,8 @@ Object.defineProperty(window, 'unisat', {
});

window.dispatchEvent(new Event('unisat#initialized'));

/** Wallet Standard **/
const wallet = new UnisatWallet(provider)

registerWallet(wallet)
52 changes: 52 additions & 0 deletions src/content-script/pageProvider/wallet-standard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { BITCOIN_CHAINS } from '@exodus/bitcoin-wallet-standard-chains';
import { icon } from '@/shared/constant';

import type { UnisatProvider } from './index';
import type { Wallet, WalletIcon } from '@wallet-standard/base';

export const UnisatNamespace = 'unisat:';

export type UnisatFeature = {
[UnisatNamespace]: {
provider: UnisatProvider;
};
};

export class UnisatWallet implements Wallet {
readonly #version = '1.0.0' as const;
readonly #name = 'UniSat Wallet' as const;
readonly #icon = icon as WalletIcon;
readonly #provider: UnisatProvider;

get version() {
return this.#version;
}

get name() {
return this.#name;
}

get icon() {
return this.#icon;
}

get chains() {
return BITCOIN_CHAINS.slice();
}

get features(): UnisatFeature {
return {
[UnisatNamespace]: {
provider: this.#provider,
},
};
}

get accounts() {
return [];
}

constructor(provider: UnisatProvider) {
this.#provider = provider;
}
}
2 changes: 2 additions & 0 deletions src/shared/constant/index.ts

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,13 @@
minimatch "^3.1.2"
strip-json-comments "^3.1.1"

"@exodus/bitcoin-wallet-standard-chains@^0.0.0":
version "0.0.0"
resolved "https://registry.yarnpkg.com/@exodus/bitcoin-wallet-standard-chains/-/bitcoin-wallet-standard-chains-0.0.0.tgz#f9ee21bfd086a6ea46f68d8a8ea413f9661ce9cf"
integrity sha512-D9ddBdkZZCyX4lMLirqdRchrkDhRzlqhAwmKE1IC/N2mndY0Sz2PayJrhpxvS+vlVbU54ZlBGfSwOhPUQekP/w==
dependencies:
"@wallet-standard/base" "^1.0.1"

"@fortawesome/[email protected]":
version "6.3.0"
resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-common-types/-/fontawesome-common-types-6.3.0.tgz#51f734e64511dbc3674cd347044d02f4dd26e86b"
Expand Down Expand Up @@ -2745,6 +2752,18 @@
ecpair "^2.1.0"
tiny-secp256k1 "^2.2.1"

"@wallet-standard/base@^1.0.1":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@wallet-standard/base/-/base-1.0.1.tgz#860dd94d47c9e3c5c43b79d91c6afdbd7a36264e"
integrity sha512-1To3ekMfzhYxe0Yhkpri+Fedq0SYcfrOfJi3vbLjMwF2qiKPjTGLwZkf2C9ftdQmxES+hmxhBzTwF4KgcOwf8w==

"@wallet-standard/wallet@^1.0.1":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@wallet-standard/wallet/-/wallet-1.0.1.tgz#95438941a2a1ee12a794444357b59d53e19b374c"
integrity sha512-qkhJeuQU2afQTZ02yMZE5SFc91Fo3hyFjFkpQglHudENNyiSG0oUKcIjky8X32xVSaumgTZSQUAzpXnCTWHzKQ==
dependencies:
"@wallet-standard/base" "^1.0.1"

"@webassemblyjs/[email protected]":
version "1.11.1"
resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.11.1.tgz#2bfd767eae1a6996f432ff7e8d7fc75679c0b6a7"
Expand Down