From a0a4a08547d7032c48e2960b2928f2dd4d7631ba Mon Sep 17 00:00:00 2001 From: Piyal Basu Date: Wed, 11 Dec 2024 17:24:44 -0500 Subject: [PATCH 1/2] add types for sep-43 interface (#185) * add types for sep-43 interface * make signerAddress a required return value * make all returned signerAddress required --- .../src/walletSdk/Types/sep43.ts | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 @stellar/typescript-wallet-sdk/src/walletSdk/Types/sep43.ts diff --git a/@stellar/typescript-wallet-sdk/src/walletSdk/Types/sep43.ts b/@stellar/typescript-wallet-sdk/src/walletSdk/Types/sep43.ts new file mode 100644 index 0000000..999023a --- /dev/null +++ b/@stellar/typescript-wallet-sdk/src/walletSdk/Types/sep43.ts @@ -0,0 +1,92 @@ +interface Error { + message: string; // general description message returned to the client app + code: number; // unique error code + ext?: Array; // optional extended details +} + +export interface Sep43Interface { + /** + * Function used to request the public key from the active account + * + * @return Promise<{ address: string } & { error?: Error }> + */ + getAddress(): Promise<{ address: string } & { error?: Error }>; + + /** + * A function to request a wallet to sign a built transaction in its XDR mode + * + * @param xdr - A Transaction or a FeeBumpTransaction + * @param opts - Options compatible with https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0043.md#signtransaction + * @param opts.networkPassphrase - The Stellar network to use when signing + * @param opts.address - The public key of the account that should be used to sign + * @param opts.path - This options is added for special cases like Hardware wallets + * + * @return Promise<{ signedTxXdr: string; signerAddress: string } & { error?: Error }> + */ + signTransaction( + xdr: string, + opts?: { + networkPassphrase?: string; + address?: string; + path?: string; + submit?: boolean; + submitUrl?: string; + }, + ): Promise< + { signedTxXdr: string; signerAddress: string } & { error?: Error } + >; + + /** + * A function to request a wallet to sign an AuthEntry XDR. + * + * @param authEntry - An XDR string version of `HashIdPreimageSorobanAuthorization` + * @param opts - Options compatible with https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0043.md#signauthentry + * @param opts.networkPassphrase - The Stellar network to use when signing + * @param opts.address - The public key of the account that should be used to sign + * @param opts.path - This options is added for special cases like Hardware wallets + * + * @return - Promise<{ signedAuthEntry: string; signerAddress: string } & { error?: Error }> + */ + signAuthEntry( + authEntry: string, + opts?: { + networkPassphrase?: string; + address?: string; + path?: string; + }, + ): Promise< + { signedAuthEntry: string; signerAddress: string } & { error?: Error } + >; + + /** + * A function to request a wallet to sign an AuthEntry XDR. + * + * @param message - An arbitrary string rather than a transaction or auth entry + * @param opts - Options compatible with https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0043.md#signmessage + * @param opts.networkPassphrase - The Stellar network to use when signing + * @param opts.address - The public key of the account that should be used to sign + * @param opts.path - This options is added for special cases like Hardware wallets + * + * @return - Promise<{ signedMessage: string; signerAddress: string } & { error?: Error }> + */ + signMessage( + message: string, + opts?: { + networkPassphrase?: string; + address?: string; + path?: string; + }, + ): Promise< + { signedMessage: string; signerAddress: string } & { error?: Error } + >; + + /** + * A function to request the current selected network in the wallet. This comes + * handy when you are dealing with a wallet that doesn't allow you to specify which network to use (For example Lobstr and Rabet) + * + * @return - Promise<{ network: string; networkPassphrase: string } & { error?: Error }> + */ + getNetwork(): Promise< + { network: string; networkPassphrase: string } & { error?: Error } + >; +} From 0818cfa06d1deb51d9fa035bf251fe5ed093163c Mon Sep 17 00:00:00 2001 From: Piyal Basu Date: Wed, 19 Feb 2025 11:56:24 -0500 Subject: [PATCH 2/2] export sep-43 types (#186) --- @stellar/typescript-wallet-sdk/src/walletSdk/Types/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/@stellar/typescript-wallet-sdk/src/walletSdk/Types/index.ts b/@stellar/typescript-wallet-sdk/src/walletSdk/Types/index.ts index c589f31..480e4c7 100644 --- a/@stellar/typescript-wallet-sdk/src/walletSdk/Types/index.ts +++ b/@stellar/typescript-wallet-sdk/src/walletSdk/Types/index.ts @@ -50,5 +50,6 @@ export * from "./sep7"; export * from "./sep12"; export * from "./sep24"; export * from "./sep38"; +export * from "./sep43"; export * from "./utils"; export * from "./watcher";