@mysten/wallet-standard 0.0.0-experimental-20221011185220
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 +18 -0
- package/LICENSE +201 -0
- package/README.md +127 -0
- package/dist/chains.d.ts +8 -0
- package/dist/detect.d.ts +5 -0
- package/dist/features/index.d.ts +8 -0
- package/dist/features/suiSignAndExecuteTransaction.d.ts +29 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +57 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +27 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +37 -0
- package/src/chains.ts +22 -0
- package/src/detect.ts +28 -0
- package/src/features/index.ts +14 -0
- package/src/features/suiSignAndExecuteTransaction.ts +48 -0
- package/src/index.ts +10 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# @mysten/wallet-standard
|
|
2
|
+
|
|
3
|
+
## 0.0.0-experimental-20221011185220
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 5ac98bc9a: Introduce new wallet adapter based on the Wallet Standard. This wallet adapter automatically detects wallets that adhere to the standard interface.
|
|
8
|
+
- 5ac98bc9a: Introduce new "wallet-standard" package which can be used to build wallets that are compatible with the Wallet Standard.
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies [e0b173b9e]
|
|
13
|
+
- Updated dependencies [059ede517]
|
|
14
|
+
- Updated dependencies [03e6b552b]
|
|
15
|
+
- Updated dependencies [4575c0a02]
|
|
16
|
+
- Updated dependencies [e0b173b9e]
|
|
17
|
+
- Updated dependencies [ccf7f148d]
|
|
18
|
+
- @mysten/sui.js@0.0.0-experimental-20221011185220
|
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# `@mysten/wallet-standard`
|
|
2
|
+
|
|
3
|
+
A suite of standard utilities for implementing wallets and libraries based on the [Wallet Standard](https://github.com/wallet-standard/wallet-standard/).
|
|
4
|
+
|
|
5
|
+
## Implementing the Wallet Standard in an extension wallet
|
|
6
|
+
|
|
7
|
+
### Creating a wallet interface
|
|
8
|
+
|
|
9
|
+
You need to create a class that represents your wallet. You can use the `Wallet` interface from `@mysten/wallet-standard` to help ensure your class adheres to the standard.
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { Wallet, SUI_DEVNET_CHAIN } from "@mysten/wallet-standard";
|
|
13
|
+
|
|
14
|
+
class YourWallet implements Wallet {
|
|
15
|
+
get version() {
|
|
16
|
+
// Return the version of the Wallet Standard this implements (in this case, 1.0.0).
|
|
17
|
+
return "1.0.0";
|
|
18
|
+
}
|
|
19
|
+
get name() {
|
|
20
|
+
return "Wallet Name";
|
|
21
|
+
}
|
|
22
|
+
get icon() {
|
|
23
|
+
return "some-icon-data-url";
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Return the Sui chains that your wallet supports.
|
|
27
|
+
get chains() {
|
|
28
|
+
return [SUI_DEVNET_CHAIN];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Implementing features
|
|
34
|
+
|
|
35
|
+
Features are standard methods consumers can use to interact with a wallet. To be listed in the Sui wallet adapter, you must implement the following features in your wallet:
|
|
36
|
+
|
|
37
|
+
- `standard:connect` - Used to initiate a connection to the wallet.
|
|
38
|
+
- `standard:events` - Used to listen for changes that happen within the wallet, such as accounts being added or removed.
|
|
39
|
+
- `sui:signAndExecuteTransaction` - Used to prompt the user to sign a transaction, then submit it for execution to the blockchain.
|
|
40
|
+
|
|
41
|
+
You can implement these features in your wallet class under the `features` property:
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import {
|
|
45
|
+
ConnectFeature,
|
|
46
|
+
ConnectMethod,
|
|
47
|
+
EventsFeature,
|
|
48
|
+
EventsOnMethod,
|
|
49
|
+
SuiSignAndExecuteTransactionFeature,
|
|
50
|
+
SuiSignAndExecuteTransactionMethod
|
|
51
|
+
} from "@mysten/wallet-standard";
|
|
52
|
+
|
|
53
|
+
class YourWallet implements Wallet {
|
|
54
|
+
get features(): ConnectFeature & EventsFeature & SuiSignAndExecuteTransactionFeature {
|
|
55
|
+
return {
|
|
56
|
+
"standard:connect": {
|
|
57
|
+
version: "1.0.0",
|
|
58
|
+
connect: this.#connect,
|
|
59
|
+
},
|
|
60
|
+
"standard:events": {
|
|
61
|
+
version: "1.0.0",
|
|
62
|
+
on: this.#on,
|
|
63
|
+
}
|
|
64
|
+
"sui:signAndExecuteTransaction": {
|
|
65
|
+
version: "1.0.0",
|
|
66
|
+
signAndExecuteTransaction: this.#signAndExecuteTransaction,
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
#on: EventsOnMethod = () => {
|
|
72
|
+
// Your wallet's events on implementation.
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
#connect: ConnectMethod = () => {
|
|
76
|
+
// Your wallet's connect implementation
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
#signAndExecuteTransaction: SuiSignAndExecuteTransactionMethod = () => {
|
|
80
|
+
// Your wallet's signAndExecuteTransaction implementation
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Exposing accounts
|
|
86
|
+
|
|
87
|
+
The last requirement of the wallet interface is to expose an `acccounts` interface. This should expose all of the accounts that a connected dapp has access to. It can be empty prior to initiating a connection through the `standard:connect` feature.
|
|
88
|
+
|
|
89
|
+
The accounts can use the `ReadonlyWalletAccount` class to easily construct an account matching the required interface.
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
import { ReadonlyWalletAccount } from "@mysten/wallet-standard";
|
|
93
|
+
|
|
94
|
+
class YourWallet implements Wallet {
|
|
95
|
+
get accounts() {
|
|
96
|
+
// Assuming we already have some internal representation of accounts:
|
|
97
|
+
return someWalletAccounts.map(
|
|
98
|
+
(walletAccount) =>
|
|
99
|
+
// Return
|
|
100
|
+
new ReadonlyWalletAccount({
|
|
101
|
+
address: walletAccount.suiAddress,
|
|
102
|
+
publicKey: walletAccount.pubkey,
|
|
103
|
+
// The Sui chains that your wallet supports.
|
|
104
|
+
chains: [SUI_DEVNET_CHAIN],
|
|
105
|
+
// The features that this account supports. This can be a subset of the wallet's supported features.
|
|
106
|
+
// These features must exist on the wallet as well.
|
|
107
|
+
features: ["sui:signAndExecuteTransaction", "standard:signMessage"],
|
|
108
|
+
})
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Registering in the window
|
|
115
|
+
|
|
116
|
+
Once you have a compatible interface for your wallet, you can register it in the window under the `window.navigator.wallets` interface. Wallets self-register by pushing their standard wallet interface to this array-like interface.
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
// This makes TypeScript aware of the `window.navigator.wallets` interface.
|
|
120
|
+
declare const window: import("@mysten/wallet-standard").WalletsWindow;
|
|
121
|
+
|
|
122
|
+
(window.navigator.wallets || []).push(({ register }) => {
|
|
123
|
+
register(new YourWallet());
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
> Note that while this interface is array-like, it is not always an array, and the only method that should be called on it is `push`.
|
package/dist/chains.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Sui Devnet */
|
|
2
|
+
export declare const SUI_DEVNET_CHAIN = "sui:devnet";
|
|
3
|
+
/** Sui Testnet */
|
|
4
|
+
export declare const SUI_TESTNET_CHAIN = "sui:testnet";
|
|
5
|
+
/** Sui Localnet */
|
|
6
|
+
export declare const SUI_LOCALNET_CHAIN = "sui:localnet";
|
|
7
|
+
export declare const SUI_CHAINS: readonly ["sui:devnet", "sui:testnet", "sui:localnet"];
|
|
8
|
+
export declare type SuiChain = typeof SUI_DEVNET_CHAIN | typeof SUI_TESTNET_CHAIN | typeof SUI_LOCALNET_CHAIN;
|
package/dist/detect.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ConnectFeature, DisconnectFeature, EventsFeature } from "@wallet-standard/features";
|
|
2
|
+
import { Wallet, WalletWithFeatures } from "@wallet-standard/standard";
|
|
3
|
+
import { SuiSignAndExecuteTransactionFeature } from "./features";
|
|
4
|
+
export declare type StandardWalletAdapterWallet = WalletWithFeatures<ConnectFeature & EventsFeature & SuiSignAndExecuteTransactionFeature & Partial<DisconnectFeature>>;
|
|
5
|
+
export declare function isStandardWalletAdapterCompatibleWallet(wallet: Wallet): wallet is StandardWalletAdapterWallet;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { WalletWithFeatures } from "@wallet-standard/standard";
|
|
2
|
+
import type { SuiSignAndExecuteTransactionFeature } from "./suiSignAndExecuteTransaction";
|
|
3
|
+
/**
|
|
4
|
+
* Wallet Standard features that are unique to Sui, and that all Sui wallets are expected to implement.
|
|
5
|
+
*/
|
|
6
|
+
export declare type SuiFeatures = SuiSignAndExecuteTransactionFeature;
|
|
7
|
+
export declare type WalletWithSuiFeatures = WalletWithFeatures<SuiFeatures>;
|
|
8
|
+
export * from "./suiSignAndExecuteTransaction";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { SignableTransaction, SuiTransactionResponse } from "@mysten/sui.js";
|
|
2
|
+
import type { SignAndSendTransactionInput } from "@wallet-standard/features";
|
|
3
|
+
/** The latest API version of the signAndExecuteTransaction API. */
|
|
4
|
+
export declare type SuiSignAndExecuteTransactionVersion = "1.0.0";
|
|
5
|
+
/**
|
|
6
|
+
* A Wallet Standard feature for signing a transaction, and submitting it to the
|
|
7
|
+
* network. The wallet is expected to submit the transaction to the network via RPC,
|
|
8
|
+
* and return the transaction response.
|
|
9
|
+
*/
|
|
10
|
+
export declare type SuiSignAndExecuteTransactionFeature = {
|
|
11
|
+
/** Namespace for the feature. */
|
|
12
|
+
"sui:signAndExecuteTransaction": {
|
|
13
|
+
/** Version of the feature API. */
|
|
14
|
+
version: SuiSignAndExecuteTransactionVersion;
|
|
15
|
+
signAndExecuteTransaction: SuiSignAndExecuteTransactionMethod;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export declare type SuiSignAndExecuteTransactionMethod = (input: SuiSignAndExecuteTransactionInput) => Promise<SuiSignAndExecuteTransactionOutput>;
|
|
19
|
+
/** Input for signing and sending transactions. */
|
|
20
|
+
export interface SuiSignAndExecuteTransactionInput extends Omit<SignAndSendTransactionInput, "transaction" | "chain" | "account"> {
|
|
21
|
+
options?: SuiSignAndExecuteTransactionOptions;
|
|
22
|
+
transaction: SignableTransaction;
|
|
23
|
+
}
|
|
24
|
+
/** Output of signing and sending transactions. */
|
|
25
|
+
export interface SuiSignAndExecuteTransactionOutput extends SuiTransactionResponse {
|
|
26
|
+
}
|
|
27
|
+
/** Options for signing and sending transactions. */
|
|
28
|
+
export interface SuiSignAndExecuteTransactionOptions {
|
|
29
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/index.ts
|
|
22
|
+
var src_exports = {};
|
|
23
|
+
__export(src_exports, {
|
|
24
|
+
SUI_CHAINS: () => SUI_CHAINS,
|
|
25
|
+
SUI_DEVNET_CHAIN: () => SUI_DEVNET_CHAIN,
|
|
26
|
+
SUI_LOCALNET_CHAIN: () => SUI_LOCALNET_CHAIN,
|
|
27
|
+
SUI_TESTNET_CHAIN: () => SUI_TESTNET_CHAIN,
|
|
28
|
+
isStandardWalletAdapterCompatibleWallet: () => isStandardWalletAdapterCompatibleWallet
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(src_exports);
|
|
31
|
+
__reExport(src_exports, require("@wallet-standard/standard"), module.exports);
|
|
32
|
+
__reExport(src_exports, require("@wallet-standard/features"), module.exports);
|
|
33
|
+
__reExport(src_exports, require("@wallet-standard/util"), module.exports);
|
|
34
|
+
|
|
35
|
+
// src/detect.ts
|
|
36
|
+
function isStandardWalletAdapterCompatibleWallet(wallet) {
|
|
37
|
+
return "standard:connect" in wallet.features && "standard:events" in wallet.features && "sui:signAndExecuteTransaction" in wallet.features;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// src/chains.ts
|
|
41
|
+
var SUI_DEVNET_CHAIN = "sui:devnet";
|
|
42
|
+
var SUI_TESTNET_CHAIN = "sui:testnet";
|
|
43
|
+
var SUI_LOCALNET_CHAIN = "sui:localnet";
|
|
44
|
+
var SUI_CHAINS = [
|
|
45
|
+
SUI_DEVNET_CHAIN,
|
|
46
|
+
SUI_TESTNET_CHAIN,
|
|
47
|
+
SUI_LOCALNET_CHAIN
|
|
48
|
+
];
|
|
49
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
+
0 && (module.exports = {
|
|
51
|
+
SUI_CHAINS,
|
|
52
|
+
SUI_DEVNET_CHAIN,
|
|
53
|
+
SUI_LOCALNET_CHAIN,
|
|
54
|
+
SUI_TESTNET_CHAIN,
|
|
55
|
+
isStandardWalletAdapterCompatibleWallet
|
|
56
|
+
});
|
|
57
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/detect.ts","../src/chains.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nexport * from '@wallet-standard/standard';\nexport * from '@wallet-standard/features';\nexport * from '@wallet-standard/util';\n\nexport * from \"./features\";\nexport * from \"./detect\";\nexport * from './chains';\n","// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n ConnectFeature,\n DisconnectFeature,\n EventsFeature,\n} from \"@wallet-standard/features\";\nimport { Wallet, WalletWithFeatures } from \"@wallet-standard/standard\";\nimport { SuiSignAndExecuteTransactionFeature } from \"./features\";\n\nexport type StandardWalletAdapterWallet = WalletWithFeatures<\n ConnectFeature &\n EventsFeature &\n SuiSignAndExecuteTransactionFeature &\n // Disconnect is an optional feature:\n Partial<DisconnectFeature>\n>;\n\nexport function isStandardWalletAdapterCompatibleWallet(\n wallet: Wallet\n): wallet is StandardWalletAdapterWallet {\n return (\n \"standard:connect\" in wallet.features &&\n \"standard:events\" in wallet.features &&\n \"sui:signAndExecuteTransaction\" in wallet.features\n );\n}\n","// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\n/** Sui Devnet */\nexport const SUI_DEVNET_CHAIN = \"sui:devnet\";\n\n/** Sui Testnet */\nexport const SUI_TESTNET_CHAIN = \"sui:testnet\";\n\n/** Sui Localnet */\nexport const SUI_LOCALNET_CHAIN = \"sui:localnet\";\n\nexport const SUI_CHAINS = [\n SUI_DEVNET_CHAIN,\n SUI_TESTNET_CHAIN,\n SUI_LOCALNET_CHAIN,\n] as const;\n\nexport type SuiChain =\n | typeof SUI_DEVNET_CHAIN\n | typeof SUI_TESTNET_CHAIN\n | typeof SUI_LOCALNET_CHAIN;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAAc,sCAHd;AAIA,wBAAc,sCAJd;AAKA,wBAAc,kCALd;;;ACmBO,SAAS,wCACd,QACuC;AACvC,SACE,sBAAsB,OAAO,YAC7B,qBAAqB,OAAO,YAC5B,mCAAmC,OAAO;AAE9C;;;ACvBO,IAAM,mBAAmB;AAGzB,IAAM,oBAAoB;AAG1B,IAAM,qBAAqB;AAE3B,IAAM,aAAa;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AACF;","names":[]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
export * from "@wallet-standard/standard";
|
|
3
|
+
export * from "@wallet-standard/features";
|
|
4
|
+
export * from "@wallet-standard/util";
|
|
5
|
+
|
|
6
|
+
// src/detect.ts
|
|
7
|
+
function isStandardWalletAdapterCompatibleWallet(wallet) {
|
|
8
|
+
return "standard:connect" in wallet.features && "standard:events" in wallet.features && "sui:signAndExecuteTransaction" in wallet.features;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// src/chains.ts
|
|
12
|
+
var SUI_DEVNET_CHAIN = "sui:devnet";
|
|
13
|
+
var SUI_TESTNET_CHAIN = "sui:testnet";
|
|
14
|
+
var SUI_LOCALNET_CHAIN = "sui:localnet";
|
|
15
|
+
var SUI_CHAINS = [
|
|
16
|
+
SUI_DEVNET_CHAIN,
|
|
17
|
+
SUI_TESTNET_CHAIN,
|
|
18
|
+
SUI_LOCALNET_CHAIN
|
|
19
|
+
];
|
|
20
|
+
export {
|
|
21
|
+
SUI_CHAINS,
|
|
22
|
+
SUI_DEVNET_CHAIN,
|
|
23
|
+
SUI_LOCALNET_CHAIN,
|
|
24
|
+
SUI_TESTNET_CHAIN,
|
|
25
|
+
isStandardWalletAdapterCompatibleWallet
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/detect.ts","../src/chains.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nexport * from '@wallet-standard/standard';\nexport * from '@wallet-standard/features';\nexport * from '@wallet-standard/util';\n\nexport * from \"./features\";\nexport * from \"./detect\";\nexport * from './chains';\n","// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n ConnectFeature,\n DisconnectFeature,\n EventsFeature,\n} from \"@wallet-standard/features\";\nimport { Wallet, WalletWithFeatures } from \"@wallet-standard/standard\";\nimport { SuiSignAndExecuteTransactionFeature } from \"./features\";\n\nexport type StandardWalletAdapterWallet = WalletWithFeatures<\n ConnectFeature &\n EventsFeature &\n SuiSignAndExecuteTransactionFeature &\n // Disconnect is an optional feature:\n Partial<DisconnectFeature>\n>;\n\nexport function isStandardWalletAdapterCompatibleWallet(\n wallet: Wallet\n): wallet is StandardWalletAdapterWallet {\n return (\n \"standard:connect\" in wallet.features &&\n \"standard:events\" in wallet.features &&\n \"sui:signAndExecuteTransaction\" in wallet.features\n );\n}\n","// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\n/** Sui Devnet */\nexport const SUI_DEVNET_CHAIN = \"sui:devnet\";\n\n/** Sui Testnet */\nexport const SUI_TESTNET_CHAIN = \"sui:testnet\";\n\n/** Sui Localnet */\nexport const SUI_LOCALNET_CHAIN = \"sui:localnet\";\n\nexport const SUI_CHAINS = [\n SUI_DEVNET_CHAIN,\n SUI_TESTNET_CHAIN,\n SUI_LOCALNET_CHAIN,\n] as const;\n\nexport type SuiChain =\n | typeof SUI_DEVNET_CHAIN\n | typeof SUI_TESTNET_CHAIN\n | typeof SUI_LOCALNET_CHAIN;\n"],"mappings":";AAGA,cAAc;AACd,cAAc;AACd,cAAc;;;ACcP,SAAS,wCACd,QACuC;AACvC,SACE,sBAAsB,OAAO,YAC7B,qBAAqB,OAAO,YAC5B,mCAAmC,OAAO;AAE9C;;;ACvBO,IAAM,mBAAmB;AAGzB,IAAM,oBAAoB;AAG1B,IAAM,qBAAqB;AAE3B,IAAM,aAAa;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AACF;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mysten/wallet-standard",
|
|
3
|
+
"version": "0.0.0-experimental-20221011185220",
|
|
4
|
+
"description": "A suite of standard utilities for implementing wallets based on the Wallet Standard.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": "Mysten Labs <build@mystenlabs.com>",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"module": "./dist/index.mjs",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./dist/index.mjs",
|
|
13
|
+
"require": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"src",
|
|
19
|
+
"CHANGELOG.md"
|
|
20
|
+
],
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@mysten/sui.js": "0.0.0-experimental-20221011185220",
|
|
23
|
+
"@wallet-standard/features": "0.1.0-alpha.4",
|
|
24
|
+
"@wallet-standard/standard": "0.1.0-alpha.5",
|
|
25
|
+
"@wallet-standard/util": "0.1.0-alpha.6"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"tsup": "^6.2.2",
|
|
29
|
+
"typescript": "^4.8.3"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
33
|
+
"clean": "rm -rf tsconfig.tsbuildinfo ./dist",
|
|
34
|
+
"build": "pnpm build:types && tsup ./src/index.ts --format esm,cjs --sourcemap",
|
|
35
|
+
"build:types": "tsc --build"
|
|
36
|
+
}
|
|
37
|
+
}
|
package/src/chains.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/** Sui Devnet */
|
|
5
|
+
export const SUI_DEVNET_CHAIN = "sui:devnet";
|
|
6
|
+
|
|
7
|
+
/** Sui Testnet */
|
|
8
|
+
export const SUI_TESTNET_CHAIN = "sui:testnet";
|
|
9
|
+
|
|
10
|
+
/** Sui Localnet */
|
|
11
|
+
export const SUI_LOCALNET_CHAIN = "sui:localnet";
|
|
12
|
+
|
|
13
|
+
export const SUI_CHAINS = [
|
|
14
|
+
SUI_DEVNET_CHAIN,
|
|
15
|
+
SUI_TESTNET_CHAIN,
|
|
16
|
+
SUI_LOCALNET_CHAIN,
|
|
17
|
+
] as const;
|
|
18
|
+
|
|
19
|
+
export type SuiChain =
|
|
20
|
+
| typeof SUI_DEVNET_CHAIN
|
|
21
|
+
| typeof SUI_TESTNET_CHAIN
|
|
22
|
+
| typeof SUI_LOCALNET_CHAIN;
|
package/src/detect.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
ConnectFeature,
|
|
6
|
+
DisconnectFeature,
|
|
7
|
+
EventsFeature,
|
|
8
|
+
} from "@wallet-standard/features";
|
|
9
|
+
import { Wallet, WalletWithFeatures } from "@wallet-standard/standard";
|
|
10
|
+
import { SuiSignAndExecuteTransactionFeature } from "./features";
|
|
11
|
+
|
|
12
|
+
export type StandardWalletAdapterWallet = WalletWithFeatures<
|
|
13
|
+
ConnectFeature &
|
|
14
|
+
EventsFeature &
|
|
15
|
+
SuiSignAndExecuteTransactionFeature &
|
|
16
|
+
// Disconnect is an optional feature:
|
|
17
|
+
Partial<DisconnectFeature>
|
|
18
|
+
>;
|
|
19
|
+
|
|
20
|
+
export function isStandardWalletAdapterCompatibleWallet(
|
|
21
|
+
wallet: Wallet
|
|
22
|
+
): wallet is StandardWalletAdapterWallet {
|
|
23
|
+
return (
|
|
24
|
+
"standard:connect" in wallet.features &&
|
|
25
|
+
"standard:events" in wallet.features &&
|
|
26
|
+
"sui:signAndExecuteTransaction" in wallet.features
|
|
27
|
+
);
|
|
28
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type { WalletWithFeatures } from "@wallet-standard/standard";
|
|
5
|
+
import type { SuiSignAndExecuteTransactionFeature } from "./suiSignAndExecuteTransaction";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Wallet Standard features that are unique to Sui, and that all Sui wallets are expected to implement.
|
|
9
|
+
*/
|
|
10
|
+
export type SuiFeatures = SuiSignAndExecuteTransactionFeature;
|
|
11
|
+
|
|
12
|
+
export type WalletWithSuiFeatures = WalletWithFeatures<SuiFeatures>;
|
|
13
|
+
|
|
14
|
+
export * from "./suiSignAndExecuteTransaction";
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
SignableTransaction,
|
|
6
|
+
SuiTransactionResponse,
|
|
7
|
+
} from "@mysten/sui.js";
|
|
8
|
+
import type { SignAndSendTransactionInput } from "@wallet-standard/features";
|
|
9
|
+
|
|
10
|
+
/** The latest API version of the signAndExecuteTransaction API. */
|
|
11
|
+
export type SuiSignAndExecuteTransactionVersion = "1.0.0";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A Wallet Standard feature for signing a transaction, and submitting it to the
|
|
15
|
+
* network. The wallet is expected to submit the transaction to the network via RPC,
|
|
16
|
+
* and return the transaction response.
|
|
17
|
+
*/
|
|
18
|
+
export type SuiSignAndExecuteTransactionFeature = {
|
|
19
|
+
/** Namespace for the feature. */
|
|
20
|
+
"sui:signAndExecuteTransaction": {
|
|
21
|
+
/** Version of the feature API. */
|
|
22
|
+
version: SuiSignAndExecuteTransactionVersion;
|
|
23
|
+
signAndExecuteTransaction: SuiSignAndExecuteTransactionMethod;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type SuiSignAndExecuteTransactionMethod = (
|
|
28
|
+
input: SuiSignAndExecuteTransactionInput
|
|
29
|
+
) => Promise<SuiSignAndExecuteTransactionOutput>;
|
|
30
|
+
|
|
31
|
+
/** Input for signing and sending transactions. */
|
|
32
|
+
export interface SuiSignAndExecuteTransactionInput
|
|
33
|
+
extends Omit<
|
|
34
|
+
SignAndSendTransactionInput,
|
|
35
|
+
// TODO: Right now, we don't have intent signing, but eventually we'll need to re-introduce
|
|
36
|
+
// the concept of chains + account during the signing here.
|
|
37
|
+
"transaction" | "chain" | "account"
|
|
38
|
+
> {
|
|
39
|
+
options?: SuiSignAndExecuteTransactionOptions;
|
|
40
|
+
transaction: SignableTransaction;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Output of signing and sending transactions. */
|
|
44
|
+
export interface SuiSignAndExecuteTransactionOutput
|
|
45
|
+
extends SuiTransactionResponse {}
|
|
46
|
+
|
|
47
|
+
/** Options for signing and sending transactions. */
|
|
48
|
+
export interface SuiSignAndExecuteTransactionOptions {}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
export * from '@wallet-standard/standard';
|
|
5
|
+
export * from '@wallet-standard/features';
|
|
6
|
+
export * from '@wallet-standard/util';
|
|
7
|
+
|
|
8
|
+
export * from "./features";
|
|
9
|
+
export * from "./detect";
|
|
10
|
+
export * from './chains';
|