@mysten/wallet-standard 0.3.1 → 0.4.1
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 +27 -0
- package/README.md +15 -5
- package/dist/detect.d.ts +2 -2
- package/dist/features/index.d.ts +3 -1
- package/dist/features/suiSignTransaction.d.ts +27 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/detect.ts +5 -2
- package/src/features/index.ts +4 -1
- package/src/features/suiSignTransaction.ts +36 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @mysten/wallet-standard
|
|
2
2
|
|
|
3
|
+
## 0.4.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [a67cc044b]
|
|
8
|
+
- Updated dependencies [24bdb66c6]
|
|
9
|
+
- Updated dependencies [a67cc044b]
|
|
10
|
+
- Updated dependencies [a67cc044b]
|
|
11
|
+
- @mysten/sui.js@0.28.0
|
|
12
|
+
|
|
13
|
+
## 0.4.0
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- 473005d8f: Add protocol_version to CheckpointSummary and SuiSystemObject. Consolidate end-of-epoch information in CheckpointSummary.
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies [473005d8f]
|
|
22
|
+
- Updated dependencies [fcba70206]
|
|
23
|
+
- Updated dependencies [59641dc29]
|
|
24
|
+
- Updated dependencies [ebe6c3945]
|
|
25
|
+
- Updated dependencies [629804d26]
|
|
26
|
+
- Updated dependencies [f51c85e85]
|
|
27
|
+
- Updated dependencies [e630f6832]
|
|
28
|
+
- @mysten/sui.js@0.27.0
|
|
29
|
+
|
|
3
30
|
## 0.3.1
|
|
4
31
|
|
|
5
32
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -36,6 +36,7 @@ Features are standard methods consumers can use to interact with a wallet. To be
|
|
|
36
36
|
|
|
37
37
|
- `standard:connect` - Used to initiate a connection to the wallet.
|
|
38
38
|
- `standard:events` - Used to listen for changes that happen within the wallet, such as accounts being added or removed.
|
|
39
|
+
- `sui:signTransaction` - Used to prompt the user to sign a transaction, and return the serializated transaction and transaction signature back to the user. This method does not submit the transaction for execution.
|
|
39
40
|
- `sui:signAndExecuteTransaction` - Used to prompt the user to sign a transaction, then submit it for execution to the blockchain.
|
|
40
41
|
|
|
41
42
|
You can implement these features in your wallet class under the `features` property:
|
|
@@ -46,12 +47,13 @@ import {
|
|
|
46
47
|
ConnectMethod,
|
|
47
48
|
EventsFeature,
|
|
48
49
|
EventsOnMethod,
|
|
49
|
-
|
|
50
|
+
SuiFeatures,
|
|
51
|
+
SuiTransactionMethod,
|
|
50
52
|
SuiSignAndExecuteTransactionMethod
|
|
51
53
|
} from "@mysten/wallet-standard";
|
|
52
54
|
|
|
53
55
|
class YourWallet implements Wallet {
|
|
54
|
-
get features(): ConnectFeature & EventsFeature &
|
|
56
|
+
get features(): ConnectFeature & EventsFeature & SuiFeatures {
|
|
55
57
|
return {
|
|
56
58
|
"standard:connect": {
|
|
57
59
|
version: "1.0.0",
|
|
@@ -60,9 +62,13 @@ class YourWallet implements Wallet {
|
|
|
60
62
|
"standard:events": {
|
|
61
63
|
version: "1.0.0",
|
|
62
64
|
on: this.#on,
|
|
63
|
-
}
|
|
64
|
-
"sui:
|
|
65
|
+
},
|
|
66
|
+
"sui:signTransaction": {
|
|
65
67
|
version: "1.0.0",
|
|
68
|
+
signTransaction: this.#signTransaction,
|
|
69
|
+
},
|
|
70
|
+
"sui:signAndExecuteTransaction": {
|
|
71
|
+
version: "1.1.0",
|
|
66
72
|
signAndExecuteTransaction: this.#signAndExecuteTransaction,
|
|
67
73
|
},
|
|
68
74
|
};
|
|
@@ -76,6 +82,10 @@ class YourWallet implements Wallet {
|
|
|
76
82
|
// Your wallet's connect implementation
|
|
77
83
|
};
|
|
78
84
|
|
|
85
|
+
#signTransaction: SuiTransactionMethod = () => {
|
|
86
|
+
// Your wallet's signTransaction implementation
|
|
87
|
+
};
|
|
88
|
+
|
|
79
89
|
#signAndExecuteTransaction: SuiSignAndExecuteTransactionMethod = () => {
|
|
80
90
|
// Your wallet's signAndExecuteTransaction implementation
|
|
81
91
|
};
|
|
@@ -116,7 +126,7 @@ class YourWallet implements Wallet {
|
|
|
116
126
|
Once you have a compatible interface for your wallet, you can register it using the `registerWallet` function.
|
|
117
127
|
|
|
118
128
|
```typescript
|
|
119
|
-
import { registerWallet } from
|
|
129
|
+
import { registerWallet } from "@mysten/wallet-standard";
|
|
120
130
|
|
|
121
131
|
registerWallet(new YourWallet());
|
|
122
132
|
```
|
package/dist/detect.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ConnectFeature, DisconnectFeature, EventsFeature, Wallet, WalletWithFeatures } from "@wallet-standard/core";
|
|
2
|
-
import {
|
|
3
|
-
export type StandardWalletAdapterWallet = WalletWithFeatures<ConnectFeature & EventsFeature &
|
|
2
|
+
import { SuiFeatures } from "./features";
|
|
3
|
+
export type StandardWalletAdapterWallet = WalletWithFeatures<ConnectFeature & EventsFeature & SuiFeatures & Partial<DisconnectFeature>>;
|
|
4
4
|
export declare function isStandardWalletAdapterCompatibleWallet(wallet: Wallet): wallet is StandardWalletAdapterWallet;
|
package/dist/features/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { WalletWithFeatures } from "@wallet-standard/core";
|
|
2
|
+
import type { SuiSignTransactionFeature } from "./suiSignTransaction";
|
|
2
3
|
import type { SuiSignAndExecuteTransactionFeature } from "./suiSignAndExecuteTransaction";
|
|
3
4
|
/**
|
|
4
5
|
* Wallet Standard features that are unique to Sui, and that all Sui wallets are expected to implement.
|
|
5
6
|
*/
|
|
6
|
-
export type SuiFeatures = SuiSignAndExecuteTransactionFeature;
|
|
7
|
+
export type SuiFeatures = SuiSignTransactionFeature & SuiSignAndExecuteTransactionFeature;
|
|
7
8
|
export type WalletWithSuiFeatures = WalletWithFeatures<SuiFeatures>;
|
|
9
|
+
export * from "./suiSignTransaction";
|
|
8
10
|
export * from "./suiSignAndExecuteTransaction";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { SignableTransaction, SignedTransaction } from "@mysten/sui.js";
|
|
2
|
+
/** The latest API version of the signTransaction API. */
|
|
3
|
+
export type SuiSignTransactionVersion = "1.0.0";
|
|
4
|
+
/**
|
|
5
|
+
* A Wallet Standard feature for signing a transaction, and returning the
|
|
6
|
+
* serialized transaction and transaction signature.
|
|
7
|
+
*/
|
|
8
|
+
export type SuiSignTransactionFeature = {
|
|
9
|
+
/** Namespace for the feature. */
|
|
10
|
+
"sui:signTransaction": {
|
|
11
|
+
/** Version of the feature API. */
|
|
12
|
+
version: SuiSignTransactionVersion;
|
|
13
|
+
signTransaction: SuiSignTransactionMethod;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export type SuiSignTransactionMethod = (input: SuiSignTransactionInput) => Promise<SuiSignTransactionOutput>;
|
|
17
|
+
/** Input for signing transactions. */
|
|
18
|
+
export interface SuiSignTransactionInput {
|
|
19
|
+
transaction: SignableTransaction;
|
|
20
|
+
options?: SuiSignTransactionOptions;
|
|
21
|
+
}
|
|
22
|
+
/** Output of signing transactions. */
|
|
23
|
+
export interface SuiSignTransactionOutput extends SignedTransaction {
|
|
24
|
+
}
|
|
25
|
+
/** Options for signing transactions. */
|
|
26
|
+
export interface SuiSignTransactionOptions {
|
|
27
|
+
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +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/core';\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 Wallet,\n WalletWithFeatures,\n} from \"@wallet-standard/core\";\nimport {
|
|
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/core';\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 Wallet,\n WalletWithFeatures,\n} from \"@wallet-standard/core\";\nimport { SuiFeatures } from \"./features\";\n\nexport type StandardWalletAdapterWallet = WalletWithFeatures<\n ConnectFeature &\n EventsFeature &\n SuiFeatures &\n // Disconnect is an optional feature:\n Partial<DisconnectFeature>\n>;\n\n// TODO: Enable filtering by subset of features:\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 // TODO: Enable once ecosystem wallets adopt this:\n // \"sui:signTransaction\" 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,kCAHd;;;ACqBO,SAAS,wCACd,QACuC;AACvC,SACE,sBAAsB,OAAO,YAC7B,qBAAqB,OAAO,YAG5B,mCAAmC,OAAO;AAE9C;;;AC3BO,IAAM,mBAAmB;AAGzB,IAAM,oBAAoB;AAG1B,IAAM,qBAAqB;AAE3B,IAAM,aAAa;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AACF;","names":[]}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +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/core';\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 Wallet,\n WalletWithFeatures,\n} from \"@wallet-standard/core\";\nimport {
|
|
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/core';\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 Wallet,\n WalletWithFeatures,\n} from \"@wallet-standard/core\";\nimport { SuiFeatures } from \"./features\";\n\nexport type StandardWalletAdapterWallet = WalletWithFeatures<\n ConnectFeature &\n EventsFeature &\n SuiFeatures &\n // Disconnect is an optional feature:\n Partial<DisconnectFeature>\n>;\n\n// TODO: Enable filtering by subset of features:\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 // TODO: Enable once ecosystem wallets adopt this:\n // \"sui:signTransaction\" 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;;;ACkBP,SAAS,wCACd,QACuC;AACvC,SACE,sBAAsB,OAAO,YAC7B,qBAAqB,OAAO,YAG5B,mCAAmC,OAAO;AAE9C;;;AC3BO,IAAM,mBAAmB;AAGzB,IAAM,oBAAoB;AAG1B,IAAM,qBAAqB;AAE3B,IAAM,aAAa;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mysten/wallet-standard",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
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>",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@wallet-standard/core": "1.0.1",
|
|
24
|
-
"@mysten/sui.js": "0.
|
|
24
|
+
"@mysten/sui.js": "0.28.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"tsup": "^6.5.0",
|
package/src/detect.ts
CHANGED
|
@@ -8,22 +8,25 @@ import {
|
|
|
8
8
|
Wallet,
|
|
9
9
|
WalletWithFeatures,
|
|
10
10
|
} from "@wallet-standard/core";
|
|
11
|
-
import {
|
|
11
|
+
import { SuiFeatures } from "./features";
|
|
12
12
|
|
|
13
13
|
export type StandardWalletAdapterWallet = WalletWithFeatures<
|
|
14
14
|
ConnectFeature &
|
|
15
15
|
EventsFeature &
|
|
16
|
-
|
|
16
|
+
SuiFeatures &
|
|
17
17
|
// Disconnect is an optional feature:
|
|
18
18
|
Partial<DisconnectFeature>
|
|
19
19
|
>;
|
|
20
20
|
|
|
21
|
+
// TODO: Enable filtering by subset of features:
|
|
21
22
|
export function isStandardWalletAdapterCompatibleWallet(
|
|
22
23
|
wallet: Wallet
|
|
23
24
|
): wallet is StandardWalletAdapterWallet {
|
|
24
25
|
return (
|
|
25
26
|
"standard:connect" in wallet.features &&
|
|
26
27
|
"standard:events" in wallet.features &&
|
|
28
|
+
// TODO: Enable once ecosystem wallets adopt this:
|
|
29
|
+
// "sui:signTransaction" in wallet.features &&
|
|
27
30
|
"sui:signAndExecuteTransaction" in wallet.features
|
|
28
31
|
);
|
|
29
32
|
}
|
package/src/features/index.ts
CHANGED
|
@@ -2,13 +2,16 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import type { WalletWithFeatures } from "@wallet-standard/core";
|
|
5
|
+
import type { SuiSignTransactionFeature } from "./suiSignTransaction";
|
|
5
6
|
import type { SuiSignAndExecuteTransactionFeature } from "./suiSignAndExecuteTransaction";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Wallet Standard features that are unique to Sui, and that all Sui wallets are expected to implement.
|
|
9
10
|
*/
|
|
10
|
-
export type SuiFeatures =
|
|
11
|
+
export type SuiFeatures = SuiSignTransactionFeature &
|
|
12
|
+
SuiSignAndExecuteTransactionFeature;
|
|
11
13
|
|
|
12
14
|
export type WalletWithSuiFeatures = WalletWithFeatures<SuiFeatures>;
|
|
13
15
|
|
|
16
|
+
export * from "./suiSignTransaction";
|
|
14
17
|
export * from "./suiSignAndExecuteTransaction";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type { SignableTransaction, SignedTransaction } from "@mysten/sui.js";
|
|
5
|
+
|
|
6
|
+
/** The latest API version of the signTransaction API. */
|
|
7
|
+
export type SuiSignTransactionVersion = "1.0.0";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A Wallet Standard feature for signing a transaction, and returning the
|
|
11
|
+
* serialized transaction and transaction signature.
|
|
12
|
+
*/
|
|
13
|
+
export type SuiSignTransactionFeature = {
|
|
14
|
+
/** Namespace for the feature. */
|
|
15
|
+
"sui:signTransaction": {
|
|
16
|
+
/** Version of the feature API. */
|
|
17
|
+
version: SuiSignTransactionVersion;
|
|
18
|
+
signTransaction: SuiSignTransactionMethod;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type SuiSignTransactionMethod = (
|
|
23
|
+
input: SuiSignTransactionInput
|
|
24
|
+
) => Promise<SuiSignTransactionOutput>;
|
|
25
|
+
|
|
26
|
+
/** Input for signing transactions. */
|
|
27
|
+
export interface SuiSignTransactionInput {
|
|
28
|
+
transaction: SignableTransaction;
|
|
29
|
+
options?: SuiSignTransactionOptions;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Output of signing transactions. */
|
|
33
|
+
export interface SuiSignTransactionOutput extends SignedTransaction {}
|
|
34
|
+
|
|
35
|
+
/** Options for signing transactions. */
|
|
36
|
+
export interface SuiSignTransactionOptions {}
|