Skip to content

Commit

Permalink
Update signTransaction interface
Browse files Browse the repository at this point in the history
  • Loading branch information
gtsonevv committed Oct 29, 2024
1 parent de49ad1 commit 1fd5864
Showing 1 changed file with 8 additions and 52 deletions.
60 changes: 8 additions & 52 deletions packages/core/src/lib/wallet/wallet.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ import type { Modify, Optional } from "../utils.types";
import type { FinalExecutionOutcome } from "near-api-js/lib/providers";
import type {
SignedTransaction,
Transaction as Tx,
Signature,
} from "near-api-js/lib/transaction";
import type { Signer } from "near-api-js/lib/signer";
import type { PublicKey } from "near-api-js/lib/utils";

interface BaseWalletMetadata {
Expand Down Expand Up @@ -129,45 +127,14 @@ interface SignAndSendTransactionsParams {
}

interface SignTransactionParams {
/**
* The Transaction object to sign
*/
transaction: Tx;
/**
* The {Signer} object that assists with signing keys
*/
signer: Signer;
/**
* The human-readable NEAR account name
*/
accountId?: string;
/**
* The targeted network. (ex. default, betanet, etc…)
*/
networkId?: string;
}

interface SignTransactionActionsParams {
/**
* The NEAR account ID of the transaction receiver.
*/
receiverId: string;
/**
* Tx nonce.
*/
nonce: bigint;
/**
* 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>;
/**
* Block hash
*/
blockHash: Uint8Array;
/**
* The {Signer} object that assists with signing keys
*/
signer: Signer;
/**
* The human-readable NEAR account name
*/
Expand All @@ -176,10 +143,7 @@ interface SignTransactionActionsParams {
* The targeted network. (ex. default, betanet, etc…)
*/
networkId?: string;
}

interface MessageSigner {
sign(message: Uint8Array): Promise<Uint8Array>;
callbackUrl?: string;
}

interface DelegateAction {
Expand Down Expand Up @@ -213,17 +177,6 @@ interface DelegateAction {
publicKey: PublicKey;
}

interface SignDelegateOptions {
/**
* Delegate action to be signed by the meta transaction sender
*/
delegateAction: DelegateAction;
/**
* Signer instance for the meta transaction sender
*/
signer: MessageSigner;
}

interface SignedDelegate {
delegateAction: DelegateAction;
signature: Signature;
Expand Down Expand Up @@ -273,14 +226,17 @@ interface BaseWalletBehaviour {
* The user must be signed in to call this method.
*/
signTransaction?(
params: SignTransactionParams | SignTransactionActionsParams
): Promise<[Uint8Array, SignedTransaction]>;
params: SignTransactionParams
): Promise<[Uint8Array, SignedTransaction] | void>;
/**
* Composes and signs a SignedDelegate action to be executed in a transaction
*/
signDelegateAction?(
params: SignDelegateOptions
): Promise<SignedDelegateWithHash>;
senderId: string,
receiverId: string,
actions: Array<Action>,
callbackUrl?: string
): Promise<SignedDelegateWithHash | void>;
}

type BaseWallet<
Expand Down

0 comments on commit 1fd5864

Please sign in to comment.