Skip to content

Commit

Permalink
[Types] Update the signature types in API types to use their actual `…
Browse files Browse the repository at this point in the history
…type` strings and include Secp256k1 (#76)

* Update signature types in API types

* Update doc comment
  • Loading branch information
xbtmatt authored Oct 17, 2023
1 parent 935b538 commit 2a47af7
Showing 1 changed file with 22 additions and 26 deletions.
48 changes: 22 additions & 26 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -523,20 +523,30 @@ export type MoveScriptBytecode = {
abi?: MoveFunction;
};

/**
* These are the JSON representations of transaction signatures returned from the node API.
*/
export type TransactionSignature =
| TransactionEd25519Signature
| TransactionSecp256k1Signature
| TransactionMultiEd25519Signature
| TransactionMultiAgentSignature
| TransactionFeePayerSignature;

export type TransactionEd25519Signature = {
type: string;
public_key: string;
signature: string;
signature: "ed25519_signature";
};

export type TransactionMultiEd25519Signature = {
export type TransactionSecp256k1Signature = {
type: string;
public_key: string;
signature: "secp256k1_ecdsa_signature";
};

export type TransactionMultiEd25519Signature = {
type: "multi_ed25519_signature";
/**
* The public keys for the Ed25519 signature
*/
Expand All @@ -553,7 +563,7 @@ export type TransactionMultiEd25519Signature = {
};

export type TransactionMultiAgentSignature = {
type: string;
type: "multi_agent_signature";
sender: AccountSignature;
/**
* The other involved parties' addresses
Expand All @@ -566,7 +576,7 @@ export type TransactionMultiAgentSignature = {
};

export type TransactionFeePayerSignature = {
type: string;
type: "fee_payer_signature";
sender: AccountSignature;
/**
* The other involved parties' addresses
Expand All @@ -580,30 +590,16 @@ export type TransactionFeePayerSignature = {
fee_payer_signer: AccountSignature;
};

export type AccountSignature = AccountEd25519Signature | AccountMultiEd25519Signature;
/**
* The union of all single account signatures.
*/
export type AccountSignature = AccountEd25519Signature | AccountSecp256k1Signature | AccountMultiEd25519Signature;

export type AccountEd25519Signature = {
type: string;
public_key: string;
signature: string;
};
export type AccountEd25519Signature = TransactionEd25519Signature;

export type AccountMultiEd25519Signature = {
type: string;
/**
* The public keys for the Ed25519 signature
*/
public_keys: Array<string>;
/**
* Signature associated with the public keys in the same order
*/
signatures: Array<string>;
/**
* The number of signatures required for a successful transaction
*/
threshold: number;
bitmap: string;
};
export type AccountSecp256k1Signature = TransactionSecp256k1Signature;

export type AccountMultiEd25519Signature = TransactionMultiEd25519Signature;

export type WriteSet = ScriptWriteSet | DirectWriteSet;

Expand Down

0 comments on commit 2a47af7

Please sign in to comment.