|
| 1 | +// types copied over from @solana/wallet-standard-features and @wallet-standard/base so this library doesn't depend on them |
| 2 | + |
| 3 | +/** |
| 4 | + * A namespaced identifier in the format `${namespace}:${reference}`. |
| 5 | + * |
| 6 | + * Used by {@link IdentifierArray} and {@link IdentifierRecord}. |
| 7 | + * |
| 8 | + * @group Identifier |
| 9 | + */ |
| 10 | +export type IdentifierString = `${string}:${string}` |
| 11 | + |
| 12 | +/** |
| 13 | + * A read-only array of namespaced identifiers in the format `${namespace}:${reference}`. |
| 14 | + * |
| 15 | + * Used by {@link Wallet.chains | Wallet::chains}, {@link WalletAccount.chains | WalletAccount::chains}, and |
| 16 | + * {@link WalletAccount.features | WalletAccount::features}. |
| 17 | + * |
| 18 | + * @group Identifier |
| 19 | + */ |
| 20 | +export type IdentifierArray = readonly IdentifierString[] |
| 21 | + |
| 22 | +/** |
| 23 | + * Version of the Wallet Standard implemented by a {@link Wallet}. |
| 24 | + * |
| 25 | + * Used by {@link Wallet.version | Wallet::version}. |
| 26 | + * |
| 27 | + * Note that this is _NOT_ a version of the Wallet, but a version of the Wallet Standard itself that the Wallet |
| 28 | + * supports. |
| 29 | + * |
| 30 | + * This may be used by the app to determine compatibility and feature detect. |
| 31 | + * |
| 32 | + * @group Wallet |
| 33 | + */ |
| 34 | +export type WalletVersion = '1.0.0' |
| 35 | + |
| 36 | +/** |
| 37 | + * A data URI containing a base64-encoded SVG, WebP, PNG, or GIF image. |
| 38 | + * |
| 39 | + * Used by {@link Wallet.icon | Wallet::icon} and {@link WalletAccount.icon | WalletAccount::icon}. |
| 40 | + * |
| 41 | + * @group Wallet |
| 42 | + */ |
| 43 | +export type WalletIcon = `data:image/${'svg+xml' | 'webp' | 'png' | 'gif'};base64,${string}` |
| 44 | + |
| 45 | +/** |
| 46 | + * Interface of a **WalletAccount**, also referred to as an **Account**. |
| 47 | + * |
| 48 | + * An account is a _read-only data object_ that is provided from the Wallet to the app, authorizing the app to use it. |
| 49 | + * |
| 50 | + * The app can use an account to display and query information from a chain. |
| 51 | + * |
| 52 | + * The app can also act using an account by passing it to {@link Wallet.features | features} of the Wallet. |
| 53 | + * |
| 54 | + * Wallets may use or extend {@link "@wallet-standard/wallet".ReadonlyWalletAccount} which implements this interface. |
| 55 | + * |
| 56 | + * @group Wallet |
| 57 | + */ |
| 58 | +export interface WalletAccount { |
| 59 | + /** Address of the account, corresponding with a public key. */ |
| 60 | + readonly address: string |
| 61 | + |
| 62 | + /** Public key of the account, corresponding with a secret key to use. */ |
| 63 | + readonly publicKey: Uint8Array |
| 64 | + |
| 65 | + /** |
| 66 | + * Chains supported by the account. |
| 67 | + * |
| 68 | + * This must be a subset of the {@link Wallet.chains | chains} of the Wallet. |
| 69 | + */ |
| 70 | + readonly chains: IdentifierArray |
| 71 | + |
| 72 | + /** |
| 73 | + * Feature names supported by the account. |
| 74 | + * |
| 75 | + * This must be a subset of the names of {@link Wallet.features | features} of the Wallet. |
| 76 | + */ |
| 77 | + readonly features: IdentifierArray |
| 78 | + |
| 79 | + /** Optional user-friendly descriptive label or name for the account. This may be displayed by the app. */ |
| 80 | + readonly label?: string |
| 81 | + |
| 82 | + /** Optional user-friendly icon for the account. This may be displayed by the app. */ |
| 83 | + readonly icon?: WalletIcon |
| 84 | +} |
| 85 | + |
| 86 | +/** Input for signing in. */ |
| 87 | +export interface SolanaSignInInput { |
| 88 | + /** |
| 89 | + * Optional EIP-4361 Domain. |
| 90 | + * If not provided, the wallet must determine the Domain to include in the message. |
| 91 | + */ |
| 92 | + readonly domain?: string |
| 93 | + |
| 94 | + /** |
| 95 | + * Optional EIP-4361 Address. |
| 96 | + * If not provided, the wallet must determine the Address to include in the message. |
| 97 | + */ |
| 98 | + readonly address?: string |
| 99 | + |
| 100 | + /** |
| 101 | + * Optional EIP-4361 Statement. |
| 102 | + * If not provided, the wallet must not include Statement in the message. |
| 103 | + */ |
| 104 | + readonly statement?: string |
| 105 | + |
| 106 | + /** |
| 107 | + * Optional EIP-4361 URI. |
| 108 | + * If not provided, the wallet must not include URI in the message. |
| 109 | + */ |
| 110 | + readonly uri?: string |
| 111 | + |
| 112 | + /** |
| 113 | + * Optional EIP-4361 Version. |
| 114 | + * If not provided, the wallet must not include Version in the message. |
| 115 | + */ |
| 116 | + readonly version?: string |
| 117 | + |
| 118 | + /** |
| 119 | + * Optional EIP-4361 Chain ID. |
| 120 | + * If not provided, the wallet must not include Chain ID in the message. |
| 121 | + */ |
| 122 | + readonly chainId?: string |
| 123 | + |
| 124 | + /** |
| 125 | + * Optional EIP-4361 Nonce. |
| 126 | + * If not provided, the wallet must not include Nonce in the message. |
| 127 | + */ |
| 128 | + readonly nonce?: string |
| 129 | + |
| 130 | + /** |
| 131 | + * Optional EIP-4361 Issued At. |
| 132 | + * If not provided, the wallet must not include Issued At in the message. |
| 133 | + */ |
| 134 | + readonly issuedAt?: string |
| 135 | + |
| 136 | + /** |
| 137 | + * Optional EIP-4361 Expiration Time. |
| 138 | + * If not provided, the wallet must not include Expiration Time in the message. |
| 139 | + */ |
| 140 | + readonly expirationTime?: string |
| 141 | + |
| 142 | + /** |
| 143 | + * Optional EIP-4361 Not Before. |
| 144 | + * If not provided, the wallet must not include Not Before in the message. |
| 145 | + */ |
| 146 | + readonly notBefore?: string |
| 147 | + |
| 148 | + /** |
| 149 | + * Optional EIP-4361 Request ID. |
| 150 | + * If not provided, the wallet must not include Request ID in the message. |
| 151 | + */ |
| 152 | + readonly requestId?: string |
| 153 | + |
| 154 | + /** |
| 155 | + * Optional EIP-4361 Resources. |
| 156 | + * If not provided, the wallet must not include Resources in the message. |
| 157 | + */ |
| 158 | + readonly resources?: readonly string[] |
| 159 | +} |
| 160 | + |
| 161 | +/** Output of signing in. */ |
| 162 | +export interface SolanaSignInOutput { |
| 163 | + /** |
| 164 | + * Account that was signed in. |
| 165 | + * The address of the account may be different from the provided input Address. |
| 166 | + */ |
| 167 | + readonly account: WalletAccount |
| 168 | + |
| 169 | + /** |
| 170 | + * Message bytes that were signed. |
| 171 | + * The wallet may prefix or otherwise modify the message before signing it. |
| 172 | + */ |
| 173 | + readonly signedMessage: Uint8Array |
| 174 | + |
| 175 | + /** |
| 176 | + * Message signature produced. |
| 177 | + * If the signature type is provided, the signature must be Ed25519. |
| 178 | + */ |
| 179 | + readonly signature: Uint8Array |
| 180 | + |
| 181 | + /** |
| 182 | + * Optional type of the message signature produced. |
| 183 | + * If not provided, the signature must be Ed25519. |
| 184 | + */ |
| 185 | + readonly signatureType?: 'ed25519' |
| 186 | +} |
0 commit comments