@mysten/wallet-standard 0.5.14 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @mysten/wallet-standard
2
2
 
3
+ ## 0.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 8281e3d25: Deprecate `signMessage` method, and introduce the new `signPersonalMessage` method.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [a503cad34]
12
+ - Updated dependencies [8281e3d25]
13
+ - @mysten/sui.js@0.40.0
14
+
3
15
  ## 0.5.14
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -3,152 +3,4 @@
3
3
  A suite of standard utilities for implementing wallets and libraries based on the
4
4
  [Wallet Standard](https://github.com/wallet-standard/wallet-standard/).
5
5
 
6
- ## Implementing the Wallet Standard in an extension wallet
7
-
8
- ### Creating a wallet interface
9
-
10
- You need to create a class that represents your wallet. You can use the `Wallet` interface from
11
- `@mysten/wallet-standard` to help ensure your class adheres to the standard.
12
-
13
- ```typescript
14
- import { Wallet, SUI_DEVNET_CHAIN } from '@mysten/wallet-standard';
15
-
16
- class YourWallet implements Wallet {
17
- get version() {
18
- // Return the version of the Wallet Standard this implements (in this case, 1.0.0).
19
- return '1.0.0';
20
- }
21
- get name() {
22
- return 'Wallet Name';
23
- }
24
- get icon() {
25
- return 'some-icon-data-url';
26
- }
27
-
28
- // Return the Sui chains that your wallet supports.
29
- get chains() {
30
- return [SUI_DEVNET_CHAIN];
31
- }
32
- }
33
- ```
34
-
35
- ### Implementing features
36
-
37
- Features are standard methods consumers can use to interact with a wallet. To be listed in the Sui
38
- wallet adapter, you must implement the following features in your wallet:
39
-
40
- - `standard:connect` - Used to initiate a connection to the wallet.
41
- - `standard:events` - Used to listen for changes that happen within the wallet, such as accounts
42
- being added or removed.
43
- - `sui:signTransactionBlock` - Used to prompt the user to sign a transaction block, and return the
44
- serializated transaction block and signature back to the user. This method does not submit the
45
- transaction block for execution.
46
- - `sui:signAndExecuteTransactionBlock` - Used to prompt the user to sign a transaction block, then
47
- submit it for execution to the blockchain.
48
-
49
- You can implement these features in your wallet class under the `features` property:
50
-
51
- ```typescript
52
- import {
53
- StandardConnectFeature,
54
- StandardConnectMethod,
55
- StandardEventsFeature,
56
- StandardEventsOnMethod,
57
- SuiFeatures,
58
- SuiSignTransactionBlockMethod,
59
- SuiSignAndExecuteTransactionBlockMethod
60
- } from "@mysten/wallet-standard";
61
-
62
- class YourWallet implements Wallet {
63
- get features(): StandardConnectFeature & StandardEventsFeature & SuiFeatures {
64
- return {
65
- "standard:connect": {
66
- version: "1.0.0",
67
- connect: this.#connect,
68
- },
69
- "standard:events": {
70
- version: "1.0.0",
71
- on: this.#on,
72
- },
73
- "sui:signTransactionBlock": {
74
- version: "1.0.0",
75
- signTransactionBlock: this.#signTransactionBlock,
76
- },
77
- "sui:signAndExecuteTransactionBlock": {
78
- version: "1.1.0",
79
- signAndExecuteTransactionBlock: this.#signAndExecuteTransactionBlock,
80
- },
81
- 'sui:signMessage': {
82
- version: '1.0.0',
83
- signMessage: this.#signMessage,
84
- },
85
- };
86
- },
87
-
88
- #on: StandardEventsOnMethod = () => {
89
- // Your wallet's on implementation.
90
- };
91
-
92
- #connect: StandardConnectMethod = () => {
93
- // Your wallet's implementation
94
- };
95
-
96
- #signTransactionBlock: SuiSignTransactionBlockMethod = () => {
97
- // Your wallet's implementation
98
- };
99
-
100
- #signAndExecuteTransactionBlock: SuiSignAndExecuteTransactionBlockMethod = () => {
101
- // Your wallet's implementation
102
- };
103
-
104
- #signMessage: SuiSignMessageMethod = () => {
105
- // Your wallet's implementation
106
- };
107
- }
108
- ```
109
-
110
- ### Exposing accounts
111
-
112
- The last requirement of the wallet interface is to expose an `acccounts` interface. This should
113
- expose all of the accounts that a connected dapp has access to. It can be empty prior to initiating
114
- a connection through the `standard:connect` feature.
115
-
116
- The accounts can use the `ReadonlyWalletAccount` class to easily construct an account matching the
117
- required interface.
118
-
119
- ```typescript
120
- import { ReadonlyWalletAccount } from '@mysten/wallet-standard';
121
-
122
- class YourWallet implements Wallet {
123
- get accounts() {
124
- // Assuming we already have some internal representation of accounts:
125
- return someWalletAccounts.map(
126
- (walletAccount) =>
127
- // Return
128
- new ReadonlyWalletAccount({
129
- address: walletAccount.suiAddress,
130
- publicKey: walletAccount.pubkey,
131
- // The Sui chains that your wallet supports.
132
- chains: [SUI_DEVNET_CHAIN],
133
- // The features that this account supports. This can be a subset of the wallet's supported features.
134
- // These features must exist on the wallet as well.
135
- features: ['sui:signAndExecuteTransactionBlock'],
136
- }),
137
- );
138
- }
139
- }
140
- ```
141
-
142
- ### Registering in the window
143
-
144
- Once you have a compatible interface for your wallet, you can register it using the `registerWallet`
145
- function.
146
-
147
- ```typescript
148
- import { registerWallet } from '@mysten/wallet-standard';
149
-
150
- registerWallet(new YourWallet());
151
- ```
152
-
153
- > If you're interested in the internal implementation of the `registerWallet` method, you can
154
- > [see how it works here](https://github.com/wallet-standard/wallet-standard/blob/b4794e761de688906827829d5380b24cb8ed5fd5/packages/core/wallet/src/register.ts#L9).
6
+ **Documentation:** https://sui-wallet-kit.vercel.app/advanced/wallet-standard
@@ -2,11 +2,13 @@ import type { WalletWithFeatures } from '@wallet-standard/core';
2
2
  import type { SuiSignTransactionBlockFeature } from './suiSignTransactionBlock';
3
3
  import type { SuiSignAndExecuteTransactionBlockFeature } from './suiSignAndExecuteTransactionBlock';
4
4
  import { SuiSignMessageFeature } from './suiSignMessage';
5
+ import { SuiSignPersonalMessageFeature } from './suiSignPersonalMessage';
5
6
  /**
6
7
  * Wallet Standard features that are unique to Sui, and that all Sui wallets are expected to implement.
7
8
  */
8
- export type SuiFeatures = SuiSignTransactionBlockFeature & SuiSignAndExecuteTransactionBlockFeature & SuiSignMessageFeature;
9
+ export type SuiFeatures = SuiSignTransactionBlockFeature & SuiSignAndExecuteTransactionBlockFeature & SuiSignPersonalMessageFeature & Partial<SuiSignMessageFeature>;
9
10
  export type WalletWithSuiFeatures = WalletWithFeatures<SuiFeatures>;
10
11
  export * from './suiSignMessage';
11
12
  export * from './suiSignTransactionBlock';
12
13
  export * from './suiSignAndExecuteTransactionBlock';
14
+ export * from './suiSignPersonalMessage';
@@ -1,10 +1,14 @@
1
- import type { SignedMessage } from '@mysten/sui.js';
2
1
  import type { WalletAccount } from '@wallet-standard/core';
3
- /** The latest API version of the signMessage API. */
2
+ /**
3
+ * The latest API version of the signMessage API.
4
+ * @deprecated Wallets can still implement this method for compatibility, but this has been replaced by the `sui:signPersonalMessage` feature
5
+ */
4
6
  export type SuiSignMessageVersion = '1.0.0';
5
7
  /**
6
8
  * A Wallet Standard feature for signing a personal message, and returning the
7
9
  * message bytes that were signed, and message signature.
10
+ *
11
+ * @deprecated Wallets can still implement this method for compatibility, but this has been replaced by the `sui:signPersonalMessage` feature
8
12
  */
9
13
  export type SuiSignMessageFeature = {
10
14
  /** Namespace for the feature. */
@@ -14,12 +18,21 @@ export type SuiSignMessageFeature = {
14
18
  signMessage: SuiSignMessageMethod;
15
19
  };
16
20
  };
21
+ /** @deprecated Wallets can still implement this method for compatibility, but this has been replaced by the `sui:signPersonalMessage` feature */
17
22
  export type SuiSignMessageMethod = (input: SuiSignMessageInput) => Promise<SuiSignMessageOutput>;
18
- /** Input for signing messages. */
23
+ /**
24
+ * Input for signing messages.
25
+ * @deprecated Wallets can still implement this method for compatibility, but this has been replaced by the `sui:signPersonalMessage` feature
26
+ */
19
27
  export interface SuiSignMessageInput {
20
28
  message: Uint8Array;
21
29
  account: WalletAccount;
22
30
  }
23
- /** Output of signing messages. */
24
- export interface SuiSignMessageOutput extends SignedMessage {
31
+ /**
32
+ * Output of signing messages.
33
+ * @deprecated Wallets can still implement this method for compatibility, but this has been replaced by the `sui:signPersonalMessage` feature
34
+ */
35
+ export interface SuiSignMessageOutput {
36
+ messageBytes: string;
37
+ signature: string;
25
38
  }
@@ -0,0 +1,26 @@
1
+ import type { WalletAccount } from '@wallet-standard/core';
2
+ /** The latest API version of the signPersonalMessage API. */
3
+ export type SuiSignPersonalMessageVersion = '1.0.0';
4
+ /**
5
+ * A Wallet Standard feature for signing a personal message, and returning the
6
+ * message bytes that were signed, and message signature.
7
+ */
8
+ export type SuiSignPersonalMessageFeature = {
9
+ /** Namespace for the feature. */
10
+ 'sui:signPersonalMessage': {
11
+ /** Version of the feature API. */
12
+ version: SuiSignPersonalMessageVersion;
13
+ signPersonalMessage: SuiSignPersonalMessageMethod;
14
+ };
15
+ };
16
+ export type SuiSignPersonalMessageMethod = (input: SuiSignPersonalMessageInput) => Promise<SuiSignPersonalMessageOutput>;
17
+ /** Input for signing personal messages. */
18
+ export interface SuiSignPersonalMessageInput {
19
+ message: Uint8Array;
20
+ account: WalletAccount;
21
+ }
22
+ /** Output of signing personal messages. */
23
+ export interface SuiSignPersonalMessageOutput {
24
+ bytes: string;
25
+ signature: string;
26
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mysten/wallet-standard",
3
- "version": "0.5.14",
3
+ "version": "0.6.0",
4
4
  "description": "A suite of standard utilities for implementing wallets based on the Wallet Standard.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Mysten Labs <build@mystenlabs.com>",
@@ -22,7 +22,7 @@
22
22
  ],
23
23
  "dependencies": {
24
24
  "@wallet-standard/core": "1.0.3",
25
- "@mysten/sui.js": "0.39.0"
25
+ "@mysten/sui.js": "0.40.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "tsup": "^7.1.0",
@@ -5,16 +5,20 @@ import type { WalletWithFeatures } from '@wallet-standard/core';
5
5
  import type { SuiSignTransactionBlockFeature } from './suiSignTransactionBlock';
6
6
  import type { SuiSignAndExecuteTransactionBlockFeature } from './suiSignAndExecuteTransactionBlock';
7
7
  import { SuiSignMessageFeature } from './suiSignMessage';
8
+ import { SuiSignPersonalMessageFeature } from './suiSignPersonalMessage';
8
9
 
9
10
  /**
10
11
  * Wallet Standard features that are unique to Sui, and that all Sui wallets are expected to implement.
11
12
  */
12
13
  export type SuiFeatures = SuiSignTransactionBlockFeature &
13
14
  SuiSignAndExecuteTransactionBlockFeature &
14
- SuiSignMessageFeature;
15
+ SuiSignPersonalMessageFeature &
16
+ // This deprecated feature should be removed once wallets update to the new method:
17
+ Partial<SuiSignMessageFeature>;
15
18
 
16
19
  export type WalletWithSuiFeatures = WalletWithFeatures<SuiFeatures>;
17
20
 
18
21
  export * from './suiSignMessage';
19
22
  export * from './suiSignTransactionBlock';
20
23
  export * from './suiSignAndExecuteTransactionBlock';
24
+ export * from './suiSignPersonalMessage';
@@ -1,15 +1,19 @@
1
1
  // Copyright (c) Mysten Labs, Inc.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import type { SignedMessage } from '@mysten/sui.js';
5
4
  import type { WalletAccount } from '@wallet-standard/core';
6
5
 
7
- /** The latest API version of the signMessage API. */
6
+ /**
7
+ * The latest API version of the signMessage API.
8
+ * @deprecated Wallets can still implement this method for compatibility, but this has been replaced by the `sui:signPersonalMessage` feature
9
+ */
8
10
  export type SuiSignMessageVersion = '1.0.0';
9
11
 
10
12
  /**
11
13
  * A Wallet Standard feature for signing a personal message, and returning the
12
14
  * message bytes that were signed, and message signature.
15
+ *
16
+ * @deprecated Wallets can still implement this method for compatibility, but this has been replaced by the `sui:signPersonalMessage` feature
13
17
  */
14
18
  export type SuiSignMessageFeature = {
15
19
  /** Namespace for the feature. */
@@ -20,13 +24,23 @@ export type SuiSignMessageFeature = {
20
24
  };
21
25
  };
22
26
 
27
+ /** @deprecated Wallets can still implement this method for compatibility, but this has been replaced by the `sui:signPersonalMessage` feature */
23
28
  export type SuiSignMessageMethod = (input: SuiSignMessageInput) => Promise<SuiSignMessageOutput>;
24
29
 
25
- /** Input for signing messages. */
30
+ /**
31
+ * Input for signing messages.
32
+ * @deprecated Wallets can still implement this method for compatibility, but this has been replaced by the `sui:signPersonalMessage` feature
33
+ */
26
34
  export interface SuiSignMessageInput {
27
35
  message: Uint8Array;
28
36
  account: WalletAccount;
29
37
  }
30
38
 
31
- /** Output of signing messages. */
32
- export interface SuiSignMessageOutput extends SignedMessage {}
39
+ /**
40
+ * Output of signing messages.
41
+ * @deprecated Wallets can still implement this method for compatibility, but this has been replaced by the `sui:signPersonalMessage` feature
42
+ */
43
+ export interface SuiSignMessageOutput {
44
+ messageBytes: string;
45
+ signature: string;
46
+ }
@@ -0,0 +1,36 @@
1
+ // Copyright (c) Mysten Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { WalletAccount } from '@wallet-standard/core';
5
+
6
+ /** The latest API version of the signPersonalMessage API. */
7
+ export type SuiSignPersonalMessageVersion = '1.0.0';
8
+
9
+ /**
10
+ * A Wallet Standard feature for signing a personal message, and returning the
11
+ * message bytes that were signed, and message signature.
12
+ */
13
+ export type SuiSignPersonalMessageFeature = {
14
+ /** Namespace for the feature. */
15
+ 'sui:signPersonalMessage': {
16
+ /** Version of the feature API. */
17
+ version: SuiSignPersonalMessageVersion;
18
+ signPersonalMessage: SuiSignPersonalMessageMethod;
19
+ };
20
+ };
21
+
22
+ export type SuiSignPersonalMessageMethod = (
23
+ input: SuiSignPersonalMessageInput,
24
+ ) => Promise<SuiSignPersonalMessageOutput>;
25
+
26
+ /** Input for signing personal messages. */
27
+ export interface SuiSignPersonalMessageInput {
28
+ message: Uint8Array;
29
+ account: WalletAccount;
30
+ }
31
+
32
+ /** Output of signing personal messages. */
33
+ export interface SuiSignPersonalMessageOutput {
34
+ bytes: string;
35
+ signature: string;
36
+ }