-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add signTransaction() and signDelegateAction() to BaseWalletBehaviour interface #1213
Open
gtsonevv
wants to merge
17
commits into
near:dev
Choose a base branch
from
LimeChain:sign-transaction-interface
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
5429380
Add signTransaction() to BaseWalletBehaviour interface
gtsonevv 2676f27
make signTransaction optional
gtsonevv 55623df
Add signTransaction in decorateWallet()
gtsonevv 7465b61
Refactor signTransaction
gtsonevv de49ad1
Add signDelegateAction to BaseWalletBehaviour
gtsonevv 1fd5864
Update signTransaction interface
gtsonevv e5aa0c5
fix signDelegateAction params
gtsonevv 3f94ddf
Add signAndSendTransactionAsync interface
gtsonevv 0e33136
Fix signAndSendTransactionAsync interface
gtsonevv 5808436
Fix build error
gtsonevv d0624e0
Fix return type
gtsonevv e5de64b
Add sendTransactionAsync method in Provuder service
gtsonevv f94f9a3
Add sendTransaction method
gtsonevv bce9451
Update signDelegateAction interface
gtsonevv 0404fc8
Fix delegateAction interface
gtsonevv f57900f
Remoev interface SignDelegateAction
gtsonevv c768b6c
Fix linter error
gtsonevv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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 |
---|---|---|
|
@@ -10,6 +10,8 @@ import type { ReadOnlyStore } from "../store.types"; | |
import type { Transaction, Action } from "./transactions.types"; | ||
import type { Modify, Optional } from "../utils.types"; | ||
import type { FinalExecutionOutcome } from "near-api-js/lib/providers"; | ||
import type { SignedTransaction, Signature } from "near-api-js/lib/transaction"; | ||
import type { PublicKey } from "near-api-js/lib/utils"; | ||
|
||
interface BaseWalletMetadata { | ||
/** | ||
|
@@ -121,6 +123,65 @@ interface SignAndSendTransactionsParams { | |
transactions: Array<Optional<Transaction, "signerId">>; | ||
} | ||
|
||
interface SignTransactionParams { | ||
/** | ||
* The NEAR account ID of the transaction receiver. | ||
*/ | ||
receiverId: string; | ||
/** | ||
* NEAR Action(s) to sign and send to the network (e.g. `FunctionCall`). You can find more information on `Action` {@link https://github.com/near/wallet-selector/blob/main/packages/core/docs/api/transactions.md | here}. | ||
*/ | ||
actions: Array<Action>; | ||
/** | ||
* The human-readable NEAR account name | ||
*/ | ||
accountId?: string; | ||
/** | ||
* The targeted network. (ex. default, betanet, etc…) | ||
*/ | ||
networkId?: string; | ||
callbackUrl?: string; | ||
} | ||
|
||
export interface SignDelegateActionParams { | ||
blockHeightTtl: number; | ||
receiverId: string; | ||
actions: Array<Action>; | ||
callbackUrl?: string; | ||
} | ||
|
||
interface DelegateAction { | ||
/** | ||
* Account ID for the intended signer of the delegate action | ||
*/ | ||
senderId: string; | ||
/** | ||
* The set of actions to be included in the meta transaction | ||
*/ | ||
actions: Array<Action>; | ||
/** | ||
* Account ID for the intended receiver of the meta transaction | ||
*/ | ||
receiverId: string; | ||
/** | ||
* Current nonce on the access key used to sign the delegate action | ||
*/ | ||
nonce: bigint; | ||
Comment on lines
+166
to
+169
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same problem as with transactions, see above |
||
/** | ||
* The maximum block height for which this action can be executed as part of a transaction | ||
*/ | ||
maxBlockHeight: bigint; | ||
/** | ||
* Public key for the access key used to sign the delegate action | ||
*/ | ||
publicKey: PublicKey; | ||
Comment on lines
+174
to
+177
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. App developer does not have the user's public key |
||
} | ||
|
||
export interface SignedDelegate { | ||
delegateAction: DelegateAction; | ||
signature: Signature; | ||
} | ||
|
||
interface BaseWalletBehaviour { | ||
/** | ||
* Programmatically sign in. Hardware wallets (e.g. Ledger) require `derivationPaths` to validate access key permissions. | ||
|
@@ -147,6 +208,13 @@ interface BaseWalletBehaviour { | |
signAndSendTransaction( | ||
params: SignAndSendTransactionParams | ||
): Promise<providers.FinalExecutionOutcome>; | ||
/** | ||
* Signs one or more NEAR Actions before sending to the network. | ||
* The user must be signed in to call this method as there's at least charges for gas spent. | ||
*/ | ||
signAndSendTransactionAsync?( | ||
params: SignAndSendTransactionParams | ||
): Promise<string>; | ||
/** | ||
* Signs one or more transactions before sending to the network. | ||
* The user must be signed in to call this method as there's at least charges for gas spent. | ||
|
@@ -155,6 +223,27 @@ interface BaseWalletBehaviour { | |
params: SignAndSendTransactionsParams | ||
): Promise<Array<providers.FinalExecutionOutcome>>; | ||
signMessage?(params: SignMessageParams): Promise<SignedMessage | void>; | ||
/** | ||
* Signs one or more NEAR Actions which can be broadcasted to the network. | ||
* The user must be signed in to call this method. | ||
*/ | ||
signTransaction?( | ||
params: SignTransactionParams | ||
): Promise<[Uint8Array, SignedTransaction] | void>; | ||
/** | ||
* Sends a signed transaction to the network. | ||
*/ | ||
sendTransaction?(params: { | ||
hash: Uint8Array; | ||
signedTransaction: SignedTransaction; | ||
callbackUrl?: string; | ||
}): Promise<providers.FinalExecutionOutcome>; | ||
/** | ||
* Composes and signs a Signed Delegate Action to be executed in a transaction | ||
*/ | ||
signDelegateAction?( | ||
params: SignDelegateActionParams | ||
): Promise<SignedDelegate | void>; | ||
} | ||
|
||
type BaseWallet< | ||
|
@@ -242,9 +331,23 @@ export type BrowserWalletBehaviour = Modify< | |
signAndSendTransaction( | ||
params: BrowserWalletSignAndSendTransactionParams | ||
): Promise<FinalExecutionOutcome | void>; | ||
signAndSendTransactionAsync?( | ||
params: BrowserWalletSignAndSendTransactionParams | ||
): Promise<string | void>; | ||
signAndSendTransactions( | ||
params: BrowserWalletSignAndSendTransactionsParams | ||
): Promise<void>; | ||
signTransaction?( | ||
params: SignTransactionParams | ||
): Promise<[Uint8Array, SignedTransaction] | void>; | ||
sendTransaction?(params: { | ||
hash: Uint8Array; | ||
signedTransaction: SignedTransaction; | ||
callbackUrl?: string; | ||
}): Promise<FinalExecutionOutcome | void>; | ||
signDelegateAction?( | ||
params: SignDelegateActionParams | ||
): Promise<SignedDelegate | void>; | ||
} | ||
>; | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
App developer does not know the senderId