Skip to content

Commit

Permalink
Update signDelegateAction interface
Browse files Browse the repository at this point in the history
  • Loading branch information
gtsonevv committed Dec 9, 2024
1 parent f94f9a3 commit bce9451
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
13 changes: 12 additions & 1 deletion packages/core/src/lib/wallet/transactions.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ export interface DeleteAccountAction {
};
}

export interface SignDelegateAction {
type: "SignDelegateAction";
params: {
blockHeightTtl: number;
receiverId: string;
actions: Array<Action>;
callbackUrl?: string;
};
}

export type Action =
| CreateAccountAction
| DeployContractAction
Expand All @@ -75,7 +85,8 @@ export type Action =
| StakeAction
| AddKeyAction
| DeleteKeyAction
| DeleteAccountAction;
| DeleteAccountAction
| SignDelegateAction;

export type ActionType = Action["type"];

Expand Down
22 changes: 8 additions & 14 deletions packages/core/src/lib/wallet/wallet.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ interface SignTransactionParams {
callbackUrl?: string;
}

interface SignDelegateActionParams {
senderId: string;
export interface SignDelegateActionParams {
blockHeightTtl: number;
receiverId: string;
actions: Array<Action>;
callbackUrl?: string;
Expand All @@ -159,10 +159,6 @@ interface DelegateAction {
* The set of actions to be included in the meta transaction
*/
actions: Array<Action>;
/**
* Number of blocks past the current block height for which the SignedDelegate action may be included in a meta transaction
*/
blockHeightTtl: number;
/**
* Account ID for the intended receiver of the meta transaction
*/
Expand All @@ -181,16 +177,11 @@ interface DelegateAction {
publicKey: PublicKey;
}

interface SignedDelegate {
export interface SignedDelegate {
delegateAction: DelegateAction;
signature: Signature;
}

interface SignedDelegateWithHash {
hash: Uint8Array;
signedDelegateAction: SignedDelegate;
}

interface BaseWalletBehaviour {
/**
* Programmatically sign in. Hardware wallets (e.g. Ledger) require `derivationPaths` to validate access key permissions.
Expand Down Expand Up @@ -248,11 +239,11 @@ interface BaseWalletBehaviour {
callbackUrl?: string;
}): Promise<providers.FinalExecutionOutcome>;
/**
* Composes and signs a SignedDelegate action to be executed in a transaction
* Composes and signs a Signed Delegate Action to be executed in a transaction
*/
signDelegateAction?(
params: SignDelegateActionParams
): Promise<SignedDelegateWithHash | void>;
): Promise<SignedDelegate | void>;
}

type BaseWallet<
Expand Down Expand Up @@ -354,6 +345,9 @@ export type BrowserWalletBehaviour = Modify<
signedTransaction: SignedTransaction;
callbackUrl?: string;
}): Promise<FinalExecutionOutcome | void>;
signDelegateAction?(
params: SignDelegateActionParams
): Promise<SignedDelegate | void>;
}
>;

Expand Down

0 comments on commit bce9451

Please sign in to comment.