@solana-mobile/mobile-wallet-adapter-protocol 2.0.1 → 2.1.0-alpha1

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/src/types.ts CHANGED
@@ -1,9 +1,14 @@
1
1
  import type { TransactionVersion } from '@solana/web3.js';
2
+ import type { SolanaSignInInput } from "@solana/wallet-standard";
3
+ import type { IdentifierArray, IdentifierString, WalletAccount, WalletIcon } from '@wallet-standard/core';
2
4
 
3
5
  export type Account = Readonly<{
4
6
  address: Base64EncodedAddress;
5
7
  label?: string;
6
- }>;
8
+ icon?: WalletIcon;
9
+ chains?: IdentifierArray;
10
+ features?: IdentifierArray;
11
+ }> | WalletAccount;
7
12
 
8
13
  /**
9
14
  * Properties that wallets may present to users when an app
@@ -23,6 +28,12 @@ export type AppIdentity = Readonly<{
23
28
  */
24
29
  export type AssociationKeypair = CryptoKeyPair;
25
30
 
31
+ export type ProtocolVersion = 'v1' | 'legacy';
32
+
33
+ export type SessionProperties = Readonly<{
34
+ protocol_version: ProtocolVersion;
35
+ }>;
36
+
26
37
  /**
27
38
  * The context returned from a wallet after having authorized a given
28
39
  * account for use with a given application. You can cache this and
@@ -32,6 +43,7 @@ export type AuthorizationResult = Readonly<{
32
43
  accounts: Account[];
33
44
  auth_token: AuthToken;
34
45
  wallet_uri_base: string;
46
+ sign_in_result?: SignInResult;
35
47
  }>;
36
48
 
37
49
  export type AuthToken = string;
@@ -48,8 +60,13 @@ type Base64EncodedSignedTransaction = string;
48
60
 
49
61
  export type Base64EncodedTransaction = string;
50
62
 
63
+ /**
64
+ * @deprecated Replaced by the 'chain' parameter, which adds multi-chain capability as per MWA 2.0 spec.
65
+ */
51
66
  export type Cluster = 'devnet' | 'testnet' | 'mainnet-beta';
52
67
 
68
+ export type Chain = IdentifierString | Cluster;
69
+
53
70
  export type Finality = 'confirmed' | 'finalized' | 'processed';
54
71
 
55
72
  export type WalletAssociationConfig = Readonly<{
@@ -57,7 +74,19 @@ export type WalletAssociationConfig = Readonly<{
57
74
  }>;
58
75
 
59
76
  export interface AuthorizeAPI {
77
+ /**
78
+ * @deprecated Replaced by updated authorize() method, which adds MWA 2.0 spec support.
79
+ */
60
80
  authorize(params: { cluster: Cluster; identity: AppIdentity }): Promise<AuthorizationResult>;
81
+
82
+ authorize(params: {
83
+ identity: AppIdentity;
84
+ chain?: Chain;
85
+ features?: IdentifierArray;
86
+ addresses?: string[];
87
+ auth_token?: AuthToken;
88
+ sign_in_payload?: SignInPayload;
89
+ }): Promise<AuthorizationResult>;
61
90
  }
62
91
  export interface CloneAuthorizationAPI {
63
92
  cloneAuthorization(params: { auth_token: AuthToken }): Promise<Readonly<{ auth_token: AuthToken }>>;
@@ -69,11 +98,18 @@ export interface DeauthorizeAPI {
69
98
  export interface GetCapabilitiesAPI {
70
99
  getCapabilities(): Promise<
71
100
  Readonly<{
101
+ max_transactions_per_request: number;
102
+ max_messages_per_request: number;
103
+ supported_transaction_versions: ReadonlyArray<TransactionVersion>;
104
+ features: IdentifierArray;
105
+ /**
106
+ * @deprecated Replaced by features array.
107
+ */
72
108
  supports_clone_authorization: boolean;
109
+ /**
110
+ * @deprecated Replaced by features array.
111
+ */
73
112
  supports_sign_and_send_transactions: boolean;
74
- max_transactions_per_request: boolean;
75
- max_messages_per_request: boolean;
76
- supported_transaction_versions: ReadonlyArray<TransactionVersion>;
77
113
  }>
78
114
  >;
79
115
  }
@@ -95,6 +131,10 @@ export interface SignAndSendTransactionsAPI {
95
131
  signAndSendTransactions(params: {
96
132
  options?: Readonly<{
97
133
  min_context_slot?: number;
134
+ commitment?: string;
135
+ skip_preflight?: boolean;
136
+ max_retries?: number;
137
+ wait_for_commitment_to_send_next_transaction?: boolean;
98
138
  }>;
99
139
  payloads: Base64EncodedTransaction[];
100
140
  }): Promise<Readonly<{ signatures: Base64EncodedSignature[] }>>;
@@ -109,3 +149,33 @@ export interface MobileWallet
109
149
  SignMessagesAPI,
110
150
  SignTransactionsAPI,
111
151
  SignAndSendTransactionsAPI {}
152
+
153
+ // optional features
154
+ export const SolanaSignTransactions = 'solana:signTransactions'
155
+ export const SolanaCloneAuthorization = 'solana:cloneAuthorization'
156
+ export const SolanaSignInWithSolana = 'solana:signInWithSolana'
157
+
158
+ export type SignInPayload = Readonly<{
159
+ domain?: string;
160
+ address?: string;
161
+ statement?: string;
162
+ uri?: string;
163
+ version?: string;
164
+ chainId?: string;
165
+ nonce?: string;
166
+ issuedAt?: string;
167
+ expirationTime?: string;
168
+ notBefore?: string;
169
+ requestId?: string;
170
+ resources?: readonly string[];
171
+ }> | SolanaSignInInput;
172
+
173
+ export type SignInPayloadWithRequiredFields = Partial<SignInPayload> &
174
+ Required<Pick<SignInPayload, 'domain' | 'address'>>
175
+
176
+ export type SignInResult = Readonly<{
177
+ address: Base64EncodedAddress;
178
+ signed_message: Base64EncodedSignedMessage;
179
+ signature: Base64EncodedAddress;
180
+ signature_type?: string;
181
+ }>;