-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add types for sep-43 interface (#185)
* add types for sep-43 interface * make signerAddress a required return value * make all returned signerAddress required
- Loading branch information
Showing
1 changed file
with
92 additions
and
0 deletions.
There are no files selected for viewing
92 changes: 92 additions & 0 deletions
92
@stellar/typescript-wallet-sdk/src/walletSdk/Types/sep43.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
interface Error { | ||
message: string; // general description message returned to the client app | ||
code: number; // unique error code | ||
ext?: Array<string>; // 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 } | ||
>; | ||
} |