Skip to content

Commit

Permalink
Add TypeScript interfaces for Ed25519SignedPayload signers
Browse files Browse the repository at this point in the history
  • Loading branch information
orbitlens committed Aug 22, 2022
1 parent c39e830 commit f465169
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ export namespace Signer {
preAuthTx: Buffer;
weight: number | undefined;
}
interface Ed25519SignedPayload {
ed25519SignedPayload: string;
weight?: number | string;
}
}
export namespace SignerKeyOptions {
interface Ed25519PublicKey {
Expand All @@ -272,16 +276,21 @@ export namespace SignerKeyOptions {
interface PreAuthTx {
preAuthTx: Buffer | string;
}
interface Ed25519SignedPayload {
ed25519SignedPayload: string;
}
}
export type Signer =
| Signer.Ed25519PublicKey
| Signer.Sha256Hash
| Signer.PreAuthTx;
| Signer.PreAuthTx
| Signer.Ed25519SignedPayload;

export type SignerKeyOptions =
| SignerKeyOptions.Ed25519PublicKey
| SignerKeyOptions.Sha256Hash
| SignerKeyOptions.PreAuthTx;
| SignerKeyOptions.PreAuthTx
| SignerKeyOptions.Ed25519SignedPayload;

export namespace SignerOptions {
interface Ed25519PublicKey {
Expand All @@ -296,11 +305,16 @@ export namespace SignerOptions {
preAuthTx: Buffer | string;
weight?: number | string;
}
interface Ed25519SignedPayload {
ed25519SignedPayload: string;
weight?: number | string;
}
}
export type SignerOptions =
| SignerOptions.Ed25519PublicKey
| SignerOptions.Sha256Hash
| SignerOptions.PreAuthTx;
| SignerOptions.PreAuthTx
| SignerOptions.Ed25519SignedPayload;

export namespace OperationType {
type CreateAccount = 'createAccount';
Expand Down Expand Up @@ -666,6 +680,8 @@ export namespace Operation {
? Signer.Sha256Hash
: T extends { preAuthTx: any }
? Signer.PreAuthTx
: T extends { ed25519SignedPayload: any }
? Signer.Ed25519SignedPayload
: never;
}
function setOptions<T extends SignerOptions = never>(
Expand Down

0 comments on commit f465169

Please sign in to comment.