Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@solana/signers

Package Overview
Dependencies
Maintainers
15
Versions
1004
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solana/signers - npm Package Compare versions

Comparing version 2.0.0-experimental.f8c941c to 2.0.0-experimental.fa2293f

dist/types/fee-payer-signer.d.ts

95

dist/index.browser.js

@@ -0,5 +1,6 @@

import { SolanaError, SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_PARTIAL_SIGNER, SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_PARTIAL_SIGNER, SOLANA_ERROR__SIGNER__EXPECTED_KEY_PAIR_SIGNER, SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_MODIFYING_SIGNER, SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_SIGNER, SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_MODIFYING_SIGNER, SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SENDING_SIGNER, SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SIGNER, SOLANA_ERROR__SIGNER__TRANSACTION_SENDING_SIGNER_MISSING, SOLANA_ERROR__SIGNER__TRANSACTION_CANNOT_HAVE_MULTIPLE_SENDING_SIGNERS, SOLANA_ERROR__SIGNER__ADDRESS_CANNOT_HAVE_MULTIPLE_SIGNERS } from '@solana/errors';
import { isSignerRole } from '@solana/instructions';
import { getUnsignedTransaction, assertTransactionIsFullySigned, partiallySignTransaction } from '@solana/transactions';
import { getAddressFromPublicKey, isAddress } from '@solana/addresses';
import { generateKeyPair, signBytes } from '@solana/keys';
import { assertTransactionIsFullySigned, partiallySignTransaction } from '@solana/transactions';
import { generateKeyPair, createKeyPairFromBytes, signBytes } from '@solana/keys';

@@ -13,5 +14,5 @@ // src/deduplicate-signers.ts

} else if (deduplicated[signer.address] !== signer) {
throw new Error(
`Multiple distinct signers were identified for address "${signer.address}". Please ensure that you are using the same signer instance for each address.`
);
throw new SolanaError(SOLANA_ERROR__SIGNER__ADDRESS_CANNOT_HAVE_MULTIPLE_SIGNERS, {
address: signer.address
});
}

@@ -29,3 +30,6 @@ });

function getSignersFromTransaction(transaction) {
return deduplicateSigners(transaction.instructions.flatMap(getSignersFromInstruction));
return deduplicateSigners([
...transaction.feePayerSigner ? [transaction.feePayerSigner] : [],
...transaction.instructions.flatMap(getSignersFromInstruction)
]);
}

@@ -57,4 +61,18 @@ function addSignersToInstruction(signers, instruction) {

}
// src/message-partial-signer.ts
function setTransactionFeePayerSigner(feePayerSigner, transaction) {
if ("feePayer" in transaction && feePayerSigner.address === transaction.feePayer) {
if ("feePayerSigner" in transaction)
return transaction;
const out2 = { ...transaction, feePayerSigner };
Object.freeze(out2);
return out2;
}
const out = {
...getUnsignedTransaction(transaction),
feePayer: feePayerSigner.address,
feePayerSigner
};
Object.freeze(out);
return out;
}
function isMessagePartialSigner(value) {

@@ -65,7 +83,7 @@ return "signMessages" in value && typeof value.signMessages === "function";

if (!isMessagePartialSigner(value)) {
throw new Error("The provided value does not implement the MessagePartialSigner interface");
throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_PARTIAL_SIGNER, {
address: value.address
});
}
}
// src/transaction-partial-signer.ts
function isTransactionPartialSigner(value) {

@@ -76,3 +94,5 @@ return "signTransactions" in value && typeof value.signTransactions === "function";

if (!isTransactionPartialSigner(value)) {
throw new Error("The provided value does not implement the TransactionPartialSigner interface");
throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_PARTIAL_SIGNER, {
address: value.address
});
}

@@ -87,3 +107,5 @@ }

if (!isKeyPairSigner(value)) {
throw new Error("The provided value does not implement the KeyPairSigner interface");
throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_KEY_PAIR_SIGNER, {
address: value.address
});
}

@@ -113,2 +135,5 @@ }

}
async function createKeyPairSignerFromBytes(bytes, extractable) {
return createSignerFromKeyPair(await createKeyPairFromBytes(bytes, extractable));
}
function isMessageModifyingSigner(value) {

@@ -119,7 +144,7 @@ return isAddress(value.address) && "modifyAndSignMessages" in value && typeof value.modifyAndSignMessages === "function";

if (!isMessageModifyingSigner(value)) {
throw new Error("The provided value does not implement the MessageModifyingSigner interface");
throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_MODIFYING_SIGNER, {
address: value.address
});
}
}
// src/message-signer.ts
function isMessageSigner(value) {

@@ -130,3 +155,5 @@ return isMessagePartialSigner(value) || isMessageModifyingSigner(value);

if (!isMessageSigner(value)) {
throw new Error("The provided value does not implement any of the MessageSigner interfaces");
throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_SIGNER, {
address: value.address
});
}

@@ -144,4 +171,2 @@ }

}
// src/transaction-modifying-signer.ts
function isTransactionModifyingSigner(value) {

@@ -152,7 +177,7 @@ return "modifyAndSignTransactions" in value && typeof value.modifyAndSignTransactions === "function";

if (!isTransactionModifyingSigner(value)) {
throw new Error("The provided value does not implement the TransactionModifyingSigner interface");
throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_MODIFYING_SIGNER, {
address: value.address
});
}
}
// src/transaction-sending-signer.ts
function isTransactionSendingSigner(value) {

@@ -163,7 +188,7 @@ return "signAndSendTransactions" in value && typeof value.signAndSendTransactions === "function";

if (!isTransactionSendingSigner(value)) {
throw new Error("The provided value does not implement the TransactionSendingSigner interface");
throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SENDING_SIGNER, {
address: value.address
});
}
}
// src/transaction-signer.ts
function isTransactionSigner(value) {

@@ -174,3 +199,5 @@ return isTransactionPartialSigner(value) || isTransactionModifyingSigner(value) || isTransactionSendingSigner(value);

if (!isTransactionSigner(value)) {
throw new Error("The provided value does not implement any of the TransactionSigner interfaces");
throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SIGNER, {
address: value.address
});
}

@@ -205,5 +232,3 @@ }

if (!sendingSigner) {
throw new Error(
"No `TransactionSendingSigner` was identified. Please provide a valid `ITransactionWithSingleSendingSigner` transaction."
);
throw new SolanaError(SOLANA_ERROR__SIGNER__TRANSACTION_SENDING_SIGNER_MISSING);
}

@@ -281,4 +306,2 @@ abortSignal?.throwIfAborted();

}
// src/transaction-with-single-sending-signer.ts
function isTransactionWithSingleSendingSigner(transaction) {

@@ -296,5 +319,3 @@ try {

if (sendingSigners.length === 0) {
const error = new Error("No `TransactionSendingSigner` was identified.");
error.name = "MissingTransactionSendingSignerError";
throw error;
throw new SolanaError(SOLANA_ERROR__SIGNER__TRANSACTION_SENDING_SIGNER_MISSING);
}

@@ -305,10 +326,8 @@ const sendingOnlySigners = sendingSigners.filter(

if (sendingOnlySigners.length > 1) {
const error = new Error("More than one `TransactionSendingSigner` was identified.");
error.name = "MultipleTransactionSendingSignersError";
throw error;
throw new SolanaError(SOLANA_ERROR__SIGNER__TRANSACTION_CANNOT_HAVE_MULTIPLE_SENDING_SIGNERS);
}
}
export { addSignersToInstruction, addSignersToTransaction, assertIsKeyPairSigner, assertIsMessageModifyingSigner, assertIsMessagePartialSigner, assertIsMessageSigner, assertIsTransactionModifyingSigner, assertIsTransactionPartialSigner, assertIsTransactionSendingSigner, assertIsTransactionSigner, assertIsTransactionWithSingleSendingSigner, createNoopSigner, createSignableMessage, createSignerFromKeyPair, generateKeyPairSigner, getSignersFromInstruction, getSignersFromTransaction, isKeyPairSigner, isMessageModifyingSigner, isMessagePartialSigner, isMessageSigner, isTransactionModifyingSigner, isTransactionPartialSigner, isTransactionSendingSigner, isTransactionSigner, isTransactionWithSingleSendingSigner, partiallySignTransactionWithSigners, signAndSendTransactionWithSigners, signTransactionWithSigners };
export { addSignersToInstruction, addSignersToTransaction, assertIsKeyPairSigner, assertIsMessageModifyingSigner, assertIsMessagePartialSigner, assertIsMessageSigner, assertIsTransactionModifyingSigner, assertIsTransactionPartialSigner, assertIsTransactionSendingSigner, assertIsTransactionSigner, assertIsTransactionWithSingleSendingSigner, createKeyPairSignerFromBytes, createNoopSigner, createSignableMessage, createSignerFromKeyPair, generateKeyPairSigner, getSignersFromInstruction, getSignersFromTransaction, isKeyPairSigner, isMessageModifyingSigner, isMessagePartialSigner, isMessageSigner, isTransactionModifyingSigner, isTransactionPartialSigner, isTransactionSendingSigner, isTransactionSigner, isTransactionWithSingleSendingSigner, partiallySignTransactionWithSigners, setTransactionFeePayerSigner, signAndSendTransactionWithSigners, signTransactionWithSigners };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.browser.js.map

@@ -0,5 +1,6 @@

import { SolanaError, SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_PARTIAL_SIGNER, SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_PARTIAL_SIGNER, SOLANA_ERROR__SIGNER__EXPECTED_KEY_PAIR_SIGNER, SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_MODIFYING_SIGNER, SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_SIGNER, SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_MODIFYING_SIGNER, SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SENDING_SIGNER, SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SIGNER, SOLANA_ERROR__SIGNER__TRANSACTION_SENDING_SIGNER_MISSING, SOLANA_ERROR__SIGNER__TRANSACTION_CANNOT_HAVE_MULTIPLE_SENDING_SIGNERS, SOLANA_ERROR__SIGNER__ADDRESS_CANNOT_HAVE_MULTIPLE_SIGNERS } from '@solana/errors';
import { isSignerRole } from '@solana/instructions';
import { getUnsignedTransaction, assertTransactionIsFullySigned, partiallySignTransaction } from '@solana/transactions';
import { getAddressFromPublicKey, isAddress } from '@solana/addresses';
import { generateKeyPair, signBytes } from '@solana/keys';
import { assertTransactionIsFullySigned, partiallySignTransaction } from '@solana/transactions';
import { generateKeyPair, createKeyPairFromBytes, signBytes } from '@solana/keys';

@@ -13,5 +14,5 @@ // src/deduplicate-signers.ts

} else if (deduplicated[signer.address] !== signer) {
throw new Error(
`Multiple distinct signers were identified for address "${signer.address}". Please ensure that you are using the same signer instance for each address.`
);
throw new SolanaError(SOLANA_ERROR__SIGNER__ADDRESS_CANNOT_HAVE_MULTIPLE_SIGNERS, {
address: signer.address
});
}

@@ -29,3 +30,6 @@ });

function getSignersFromTransaction(transaction) {
return deduplicateSigners(transaction.instructions.flatMap(getSignersFromInstruction));
return deduplicateSigners([
...transaction.feePayerSigner ? [transaction.feePayerSigner] : [],
...transaction.instructions.flatMap(getSignersFromInstruction)
]);
}

@@ -57,4 +61,18 @@ function addSignersToInstruction(signers, instruction) {

}
// src/message-partial-signer.ts
function setTransactionFeePayerSigner(feePayerSigner, transaction) {
if ("feePayer" in transaction && feePayerSigner.address === transaction.feePayer) {
if ("feePayerSigner" in transaction)
return transaction;
const out2 = { ...transaction, feePayerSigner };
Object.freeze(out2);
return out2;
}
const out = {
...getUnsignedTransaction(transaction),
feePayer: feePayerSigner.address,
feePayerSigner
};
Object.freeze(out);
return out;
}
function isMessagePartialSigner(value) {

@@ -65,7 +83,7 @@ return "signMessages" in value && typeof value.signMessages === "function";

if (!isMessagePartialSigner(value)) {
throw new Error("The provided value does not implement the MessagePartialSigner interface");
throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_PARTIAL_SIGNER, {
address: value.address
});
}
}
// src/transaction-partial-signer.ts
function isTransactionPartialSigner(value) {

@@ -76,3 +94,5 @@ return "signTransactions" in value && typeof value.signTransactions === "function";

if (!isTransactionPartialSigner(value)) {
throw new Error("The provided value does not implement the TransactionPartialSigner interface");
throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_PARTIAL_SIGNER, {
address: value.address
});
}

@@ -87,3 +107,5 @@ }

if (!isKeyPairSigner(value)) {
throw new Error("The provided value does not implement the KeyPairSigner interface");
throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_KEY_PAIR_SIGNER, {
address: value.address
});
}

@@ -113,2 +135,5 @@ }

}
async function createKeyPairSignerFromBytes(bytes, extractable) {
return createSignerFromKeyPair(await createKeyPairFromBytes(bytes, extractable));
}
function isMessageModifyingSigner(value) {

@@ -119,7 +144,7 @@ return isAddress(value.address) && "modifyAndSignMessages" in value && typeof value.modifyAndSignMessages === "function";

if (!isMessageModifyingSigner(value)) {
throw new Error("The provided value does not implement the MessageModifyingSigner interface");
throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_MODIFYING_SIGNER, {
address: value.address
});
}
}
// src/message-signer.ts
function isMessageSigner(value) {

@@ -130,3 +155,5 @@ return isMessagePartialSigner(value) || isMessageModifyingSigner(value);

if (!isMessageSigner(value)) {
throw new Error("The provided value does not implement any of the MessageSigner interfaces");
throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_SIGNER, {
address: value.address
});
}

@@ -144,4 +171,2 @@ }

}
// src/transaction-modifying-signer.ts
function isTransactionModifyingSigner(value) {

@@ -152,7 +177,7 @@ return "modifyAndSignTransactions" in value && typeof value.modifyAndSignTransactions === "function";

if (!isTransactionModifyingSigner(value)) {
throw new Error("The provided value does not implement the TransactionModifyingSigner interface");
throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_MODIFYING_SIGNER, {
address: value.address
});
}
}
// src/transaction-sending-signer.ts
function isTransactionSendingSigner(value) {

@@ -163,7 +188,7 @@ return "signAndSendTransactions" in value && typeof value.signAndSendTransactions === "function";

if (!isTransactionSendingSigner(value)) {
throw new Error("The provided value does not implement the TransactionSendingSigner interface");
throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SENDING_SIGNER, {
address: value.address
});
}
}
// src/transaction-signer.ts
function isTransactionSigner(value) {

@@ -174,3 +199,5 @@ return isTransactionPartialSigner(value) || isTransactionModifyingSigner(value) || isTransactionSendingSigner(value);

if (!isTransactionSigner(value)) {
throw new Error("The provided value does not implement any of the TransactionSigner interfaces");
throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SIGNER, {
address: value.address
});
}

@@ -205,5 +232,3 @@ }

if (!sendingSigner) {
throw new Error(
"No `TransactionSendingSigner` was identified. Please provide a valid `ITransactionWithSingleSendingSigner` transaction."
);
throw new SolanaError(SOLANA_ERROR__SIGNER__TRANSACTION_SENDING_SIGNER_MISSING);
}

@@ -281,4 +306,2 @@ abortSignal?.throwIfAborted();

}
// src/transaction-with-single-sending-signer.ts
function isTransactionWithSingleSendingSigner(transaction) {

@@ -296,5 +319,3 @@ try {

if (sendingSigners.length === 0) {
const error = new Error("No `TransactionSendingSigner` was identified.");
error.name = "MissingTransactionSendingSignerError";
throw error;
throw new SolanaError(SOLANA_ERROR__SIGNER__TRANSACTION_SENDING_SIGNER_MISSING);
}

@@ -305,10 +326,8 @@ const sendingOnlySigners = sendingSigners.filter(

if (sendingOnlySigners.length > 1) {
const error = new Error("More than one `TransactionSendingSigner` was identified.");
error.name = "MultipleTransactionSendingSignersError";
throw error;
throw new SolanaError(SOLANA_ERROR__SIGNER__TRANSACTION_CANNOT_HAVE_MULTIPLE_SENDING_SIGNERS);
}
}
export { addSignersToInstruction, addSignersToTransaction, assertIsKeyPairSigner, assertIsMessageModifyingSigner, assertIsMessagePartialSigner, assertIsMessageSigner, assertIsTransactionModifyingSigner, assertIsTransactionPartialSigner, assertIsTransactionSendingSigner, assertIsTransactionSigner, assertIsTransactionWithSingleSendingSigner, createNoopSigner, createSignableMessage, createSignerFromKeyPair, generateKeyPairSigner, getSignersFromInstruction, getSignersFromTransaction, isKeyPairSigner, isMessageModifyingSigner, isMessagePartialSigner, isMessageSigner, isTransactionModifyingSigner, isTransactionPartialSigner, isTransactionSendingSigner, isTransactionSigner, isTransactionWithSingleSendingSigner, partiallySignTransactionWithSigners, signAndSendTransactionWithSigners, signTransactionWithSigners };
export { addSignersToInstruction, addSignersToTransaction, assertIsKeyPairSigner, assertIsMessageModifyingSigner, assertIsMessagePartialSigner, assertIsMessageSigner, assertIsTransactionModifyingSigner, assertIsTransactionPartialSigner, assertIsTransactionSendingSigner, assertIsTransactionSigner, assertIsTransactionWithSingleSendingSigner, createKeyPairSignerFromBytes, createNoopSigner, createSignableMessage, createSignerFromKeyPair, generateKeyPairSigner, getSignersFromInstruction, getSignersFromTransaction, isKeyPairSigner, isMessageModifyingSigner, isMessagePartialSigner, isMessageSigner, isTransactionModifyingSigner, isTransactionPartialSigner, isTransactionSendingSigner, isTransactionSigner, isTransactionWithSingleSendingSigner, partiallySignTransactionWithSigners, setTransactionFeePayerSigner, signAndSendTransactionWithSigners, signTransactionWithSigners };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.native.js.map

@@ -0,5 +1,6 @@

import { SolanaError, SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_PARTIAL_SIGNER, SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_PARTIAL_SIGNER, SOLANA_ERROR__SIGNER__EXPECTED_KEY_PAIR_SIGNER, SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_MODIFYING_SIGNER, SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_SIGNER, SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_MODIFYING_SIGNER, SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SENDING_SIGNER, SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SIGNER, SOLANA_ERROR__SIGNER__TRANSACTION_SENDING_SIGNER_MISSING, SOLANA_ERROR__SIGNER__TRANSACTION_CANNOT_HAVE_MULTIPLE_SENDING_SIGNERS, SOLANA_ERROR__SIGNER__ADDRESS_CANNOT_HAVE_MULTIPLE_SIGNERS } from '@solana/errors';
import { isSignerRole } from '@solana/instructions';
import { getUnsignedTransaction, assertTransactionIsFullySigned, partiallySignTransaction } from '@solana/transactions';
import { getAddressFromPublicKey, isAddress } from '@solana/addresses';
import { generateKeyPair, signBytes } from '@solana/keys';
import { assertTransactionIsFullySigned, partiallySignTransaction } from '@solana/transactions';
import { generateKeyPair, createKeyPairFromBytes, signBytes } from '@solana/keys';

@@ -13,5 +14,5 @@ // src/deduplicate-signers.ts

} else if (deduplicated[signer.address] !== signer) {
throw new Error(
`Multiple distinct signers were identified for address "${signer.address}". Please ensure that you are using the same signer instance for each address.`
);
throw new SolanaError(SOLANA_ERROR__SIGNER__ADDRESS_CANNOT_HAVE_MULTIPLE_SIGNERS, {
address: signer.address
});
}

@@ -29,3 +30,6 @@ });

function getSignersFromTransaction(transaction) {
return deduplicateSigners(transaction.instructions.flatMap(getSignersFromInstruction));
return deduplicateSigners([
...transaction.feePayerSigner ? [transaction.feePayerSigner] : [],
...transaction.instructions.flatMap(getSignersFromInstruction)
]);
}

@@ -57,4 +61,18 @@ function addSignersToInstruction(signers, instruction) {

}
// src/message-partial-signer.ts
function setTransactionFeePayerSigner(feePayerSigner, transaction) {
if ("feePayer" in transaction && feePayerSigner.address === transaction.feePayer) {
if ("feePayerSigner" in transaction)
return transaction;
const out2 = { ...transaction, feePayerSigner };
Object.freeze(out2);
return out2;
}
const out = {
...getUnsignedTransaction(transaction),
feePayer: feePayerSigner.address,
feePayerSigner
};
Object.freeze(out);
return out;
}
function isMessagePartialSigner(value) {

@@ -65,7 +83,7 @@ return "signMessages" in value && typeof value.signMessages === "function";

if (!isMessagePartialSigner(value)) {
throw new Error("The provided value does not implement the MessagePartialSigner interface");
throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_PARTIAL_SIGNER, {
address: value.address
});
}
}
// src/transaction-partial-signer.ts
function isTransactionPartialSigner(value) {

@@ -76,3 +94,5 @@ return "signTransactions" in value && typeof value.signTransactions === "function";

if (!isTransactionPartialSigner(value)) {
throw new Error("The provided value does not implement the TransactionPartialSigner interface");
throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_PARTIAL_SIGNER, {
address: value.address
});
}

@@ -87,3 +107,5 @@ }

if (!isKeyPairSigner(value)) {
throw new Error("The provided value does not implement the KeyPairSigner interface");
throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_KEY_PAIR_SIGNER, {
address: value.address
});
}

@@ -113,2 +135,5 @@ }

}
async function createKeyPairSignerFromBytes(bytes, extractable) {
return createSignerFromKeyPair(await createKeyPairFromBytes(bytes, extractable));
}
function isMessageModifyingSigner(value) {

@@ -119,7 +144,7 @@ return isAddress(value.address) && "modifyAndSignMessages" in value && typeof value.modifyAndSignMessages === "function";

if (!isMessageModifyingSigner(value)) {
throw new Error("The provided value does not implement the MessageModifyingSigner interface");
throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_MODIFYING_SIGNER, {
address: value.address
});
}
}
// src/message-signer.ts
function isMessageSigner(value) {

@@ -130,3 +155,5 @@ return isMessagePartialSigner(value) || isMessageModifyingSigner(value);

if (!isMessageSigner(value)) {
throw new Error("The provided value does not implement any of the MessageSigner interfaces");
throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_SIGNER, {
address: value.address
});
}

@@ -144,4 +171,2 @@ }

}
// src/transaction-modifying-signer.ts
function isTransactionModifyingSigner(value) {

@@ -152,7 +177,7 @@ return "modifyAndSignTransactions" in value && typeof value.modifyAndSignTransactions === "function";

if (!isTransactionModifyingSigner(value)) {
throw new Error("The provided value does not implement the TransactionModifyingSigner interface");
throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_MODIFYING_SIGNER, {
address: value.address
});
}
}
// src/transaction-sending-signer.ts
function isTransactionSendingSigner(value) {

@@ -163,7 +188,7 @@ return "signAndSendTransactions" in value && typeof value.signAndSendTransactions === "function";

if (!isTransactionSendingSigner(value)) {
throw new Error("The provided value does not implement the TransactionSendingSigner interface");
throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SENDING_SIGNER, {
address: value.address
});
}
}
// src/transaction-signer.ts
function isTransactionSigner(value) {

@@ -174,3 +199,5 @@ return isTransactionPartialSigner(value) || isTransactionModifyingSigner(value) || isTransactionSendingSigner(value);

if (!isTransactionSigner(value)) {
throw new Error("The provided value does not implement any of the TransactionSigner interfaces");
throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SIGNER, {
address: value.address
});
}

@@ -205,5 +232,3 @@ }

if (!sendingSigner) {
throw new Error(
"No `TransactionSendingSigner` was identified. Please provide a valid `ITransactionWithSingleSendingSigner` transaction."
);
throw new SolanaError(SOLANA_ERROR__SIGNER__TRANSACTION_SENDING_SIGNER_MISSING);
}

@@ -281,4 +306,2 @@ abortSignal?.throwIfAborted();

}
// src/transaction-with-single-sending-signer.ts
function isTransactionWithSingleSendingSigner(transaction) {

@@ -296,5 +319,3 @@ try {

if (sendingSigners.length === 0) {
const error = new Error("No `TransactionSendingSigner` was identified.");
error.name = "MissingTransactionSendingSignerError";
throw error;
throw new SolanaError(SOLANA_ERROR__SIGNER__TRANSACTION_SENDING_SIGNER_MISSING);
}

@@ -305,10 +326,8 @@ const sendingOnlySigners = sendingSigners.filter(

if (sendingOnlySigners.length > 1) {
const error = new Error("More than one `TransactionSendingSigner` was identified.");
error.name = "MultipleTransactionSendingSignersError";
throw error;
throw new SolanaError(SOLANA_ERROR__SIGNER__TRANSACTION_CANNOT_HAVE_MULTIPLE_SENDING_SIGNERS);
}
}
export { addSignersToInstruction, addSignersToTransaction, assertIsKeyPairSigner, assertIsMessageModifyingSigner, assertIsMessagePartialSigner, assertIsMessageSigner, assertIsTransactionModifyingSigner, assertIsTransactionPartialSigner, assertIsTransactionSendingSigner, assertIsTransactionSigner, assertIsTransactionWithSingleSendingSigner, createNoopSigner, createSignableMessage, createSignerFromKeyPair, generateKeyPairSigner, getSignersFromInstruction, getSignersFromTransaction, isKeyPairSigner, isMessageModifyingSigner, isMessagePartialSigner, isMessageSigner, isTransactionModifyingSigner, isTransactionPartialSigner, isTransactionSendingSigner, isTransactionSigner, isTransactionWithSingleSendingSigner, partiallySignTransactionWithSigners, signAndSendTransactionWithSigners, signTransactionWithSigners };
export { addSignersToInstruction, addSignersToTransaction, assertIsKeyPairSigner, assertIsMessageModifyingSigner, assertIsMessagePartialSigner, assertIsMessageSigner, assertIsTransactionModifyingSigner, assertIsTransactionPartialSigner, assertIsTransactionSendingSigner, assertIsTransactionSigner, assertIsTransactionWithSingleSendingSigner, createKeyPairSignerFromBytes, createNoopSigner, createSignableMessage, createSignerFromKeyPair, generateKeyPairSigner, getSignersFromInstruction, getSignersFromTransaction, isKeyPairSigner, isMessageModifyingSigner, isMessagePartialSigner, isMessageSigner, isTransactionModifyingSigner, isTransactionPartialSigner, isTransactionSendingSigner, isTransactionSigner, isTransactionWithSingleSendingSigner, partiallySignTransactionWithSigners, setTransactionFeePayerSigner, signAndSendTransactionWithSigners, signTransactionWithSigners };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.node.js.map

@@ -5,11 +5,13 @@ import { AccountRole, IAccountLookupMeta, IAccountMeta, IInstruction } from '@solana/instructions';

/** An extension of the IAccountMeta type that keeps track of its transaction signer. */
export interface IAccountSignerMeta<TAddress extends string = string, TSigner extends TransactionSigner = TransactionSigner> extends IAccountMeta<TAddress> {
export interface IAccountSignerMeta<TAddress extends string = string, TSigner extends TransactionSigner<TAddress> = TransactionSigner<TAddress>> extends IAccountMeta<TAddress> {
readonly role: AccountRole.READONLY_SIGNER | AccountRole.WRITABLE_SIGNER;
readonly signer: TSigner;
}
type IAccountMetaWithWithSigner<TSigner extends TransactionSigner = TransactionSigner> = IAccountMeta | IAccountLookupMeta | IAccountSignerMeta<string, TSigner>;
type IAccountMetaWithSigner<TSigner extends TransactionSigner = TransactionSigner> = IAccountLookupMeta | IAccountMeta | IAccountSignerMeta<string, TSigner>;
/** A variation of the instruction type that allows IAccountSignerMeta in its account metas. */
export type IInstructionWithSigners<TSigner extends TransactionSigner = TransactionSigner, TAccounts extends readonly IAccountMetaWithWithSigner<TSigner>[] = readonly IAccountMetaWithWithSigner<TSigner>[]> = Pick<IInstruction<string, TAccounts>, 'accounts'>;
export type IInstructionWithSigners<TSigner extends TransactionSigner = TransactionSigner, TAccounts extends readonly IAccountMetaWithSigner<TSigner>[] = readonly IAccountMetaWithSigner<TSigner>[]> = Pick<IInstruction<string, TAccounts>, 'accounts'>;
/** A variation of the transaction type that allows IAccountSignerMeta in its account metas. */
export type ITransactionWithSigners<TSigner extends TransactionSigner = TransactionSigner, TAccounts extends readonly IAccountMetaWithWithSigner<TSigner>[] = readonly IAccountMetaWithWithSigner<TSigner>[]> = Pick<BaseTransaction<TransactionVersion, IInstruction & IInstructionWithSigners<TSigner, TAccounts>>, 'instructions'>;
export type ITransactionWithSigners<TSigner extends TransactionSigner = TransactionSigner, TAccounts extends readonly IAccountMetaWithSigner<TSigner>[] = readonly IAccountMetaWithSigner<TSigner>[]> = Pick<BaseTransaction<TransactionVersion, IInstruction & IInstructionWithSigners<TSigner, TAccounts>>, 'instructions'> & {
feePayerSigner?: TSigner;
};
/** Extract all signers from an instruction that may contain IAccountSignerMeta accounts. */

@@ -16,0 +18,0 @@ export declare function getSignersFromInstruction<TSigner extends TransactionSigner = TransactionSigner>(instruction: IInstructionWithSigners<TSigner>): readonly TSigner[];

4

dist/types/add-signers.d.ts

@@ -6,5 +6,5 @@ import { IInstruction } from '@solana/instructions';

/** Attaches the provided signers to the account metas of an instruction when applicable. */
export declare function addSignersToInstruction<TInstruction extends IInstruction>(signers: TransactionSigner[], instruction: TInstruction | (TInstruction & IInstructionWithSigners)): TInstruction & IInstructionWithSigners;
export declare function addSignersToInstruction<TInstruction extends IInstruction>(signers: TransactionSigner[], instruction: TInstruction | (IInstructionWithSigners & TInstruction)): IInstructionWithSigners & TInstruction;
/** Attaches the provided signers to the account metas of a transaction when applicable. */
export declare function addSignersToTransaction<TTransaction extends BaseTransaction>(signers: TransactionSigner[], transaction: TTransaction | (TTransaction & ITransactionWithSigners)): TTransaction & ITransactionWithSigners;
export declare function addSignersToTransaction<TTransaction extends BaseTransaction>(signers: TransactionSigner[], transaction: TTransaction | (ITransactionWithSigners & TTransaction)): ITransactionWithSigners & TTransaction;
//# sourceMappingURL=add-signers.d.ts.map
export * from './account-signer-meta.js';
export * from './add-signers.js';
export * from './fee-payer-signer.js';
export * from './keypair-signer.js';

@@ -4,0 +5,0 @@ export * from './message-modifying-signer.js';

@@ -10,9 +10,9 @@ import { Address } from '@solana/addresses';

export declare function isKeyPairSigner<TAddress extends string>(value: {
[key: string]: unknown;
address: Address<TAddress>;
[key: string]: unknown;
}): value is KeyPairSigner<TAddress>;
/** Asserts that the provided value implements the {@link KeyPairSigner} interface. */
export declare function assertIsKeyPairSigner<TAddress extends string>(value: {
[key: string]: unknown;
address: Address<TAddress>;
[key: string]: unknown;
}): asserts value is KeyPairSigner<TAddress>;

@@ -23,2 +23,4 @@ /** Creates a KeyPairSigner from the provided Crypto KeyPair. */

export declare function generateKeyPairSigner(): Promise<KeyPairSigner>;
/** Creates a signer capable of signing messages and transactions using the 64 bytes of a KeyPair. */
export declare function createKeyPairSignerFromBytes(bytes: Uint8Array, extractable?: boolean): Promise<KeyPairSigner>;
//# sourceMappingURL=keypair-signer.d.ts.map

@@ -12,10 +12,10 @@ import { Address } from '@solana/addresses';

export declare function isMessageModifyingSigner<TAddress extends string>(value: {
[key: string]: unknown;
address: Address<TAddress>;
[key: string]: unknown;
}): value is MessageModifyingSigner<TAddress>;
/** Asserts that the provided value implements the {@link MessageModifyingSigner} interface. */
export declare function assertIsMessageModifyingSigner<TAddress extends string>(value: {
[key: string]: unknown;
address: Address<TAddress>;
[key: string]: unknown;
}): asserts value is MessageModifyingSigner<TAddress>;
//# sourceMappingURL=message-modifying-signer.d.ts.map

@@ -12,10 +12,10 @@ import { Address } from '@solana/addresses';

export declare function isMessagePartialSigner<TAddress extends string>(value: {
[key: string]: unknown;
address: Address<TAddress>;
[key: string]: unknown;
}): value is MessagePartialSigner<TAddress>;
/** Asserts that the provided value implements the {@link MessagePartialSigner} interface. */
export declare function assertIsMessagePartialSigner<TAddress extends string>(value: {
[key: string]: unknown;
address: Address<TAddress>;
[key: string]: unknown;
}): asserts value is MessagePartialSigner<TAddress>;
//# sourceMappingURL=message-partial-signer.d.ts.map

@@ -5,13 +5,13 @@ import { Address } from '@solana/addresses';

/** Defines a signer capable of signing messages. */
export type MessageSigner<TAddress extends string = string> = MessagePartialSigner<TAddress> | MessageModifyingSigner<TAddress>;
export type MessageSigner<TAddress extends string = string> = MessageModifyingSigner<TAddress> | MessagePartialSigner<TAddress>;
/** Checks whether the provided value implements the {@link MessageSigner} interface. */
export declare function isMessageSigner<TAddress extends string>(value: {
[key: string]: unknown;
address: Address<TAddress>;
[key: string]: unknown;
}): value is MessageSigner<TAddress>;
/** Asserts that the provided value implements the {@link MessageSigner} interface. */
export declare function assertIsMessageSigner<TAddress extends string>(value: {
[key: string]: unknown;
address: Address<TAddress>;
[key: string]: unknown;
}): asserts value is MessageSigner<TAddress>;
//# sourceMappingURL=message-signer.d.ts.map

@@ -13,3 +13,3 @@ import { SignatureBytes } from '@solana/keys';

abortSignal?: AbortSignal;
}): Promise<TTransaction & ITransactionWithSignatures>;
}): Promise<ITransactionWithSignatures & TTransaction>;
/**

@@ -23,3 +23,3 @@ * Signs a transaction using any signers that may be stored in IAccountSignerMeta instruction accounts

abortSignal?: AbortSignal;
}): Promise<TTransaction & IFullySignedTransaction>;
}): Promise<IFullySignedTransaction & TTransaction>;
/**

@@ -26,0 +26,0 @@ * Signs and sends a transaction using any signers that may be stored in IAccountSignerMeta

@@ -11,3 +11,3 @@ import { SignatureDictionary } from './types.js';

*/
export declare function createSignableMessage(content: string | Uint8Array, signatures?: SignatureDictionary): SignableMessage;
export declare function createSignableMessage(content: Uint8Array | string, signatures?: SignatureDictionary): SignableMessage;
//# sourceMappingURL=signable-message.d.ts.map

@@ -12,10 +12,10 @@ import { Address } from '@solana/addresses';

export declare function isTransactionModifyingSigner<TAddress extends string>(value: {
[key: string]: unknown;
address: Address<TAddress>;
[key: string]: unknown;
}): value is TransactionModifyingSigner<TAddress>;
/** Asserts that the provided value implements the {@link TransactionModifyingSigner} interface. */
export declare function assertIsTransactionModifyingSigner<TAddress extends string>(value: {
[key: string]: unknown;
address: Address<TAddress>;
[key: string]: unknown;
}): asserts value is TransactionModifyingSigner<TAddress>;
//# sourceMappingURL=transaction-modifying-signer.d.ts.map

@@ -12,10 +12,10 @@ import { Address } from '@solana/addresses';

export declare function isTransactionPartialSigner<TAddress extends string>(value: {
[key: string]: unknown;
address: Address<TAddress>;
[key: string]: unknown;
}): value is TransactionPartialSigner<TAddress>;
/** Asserts that the provided value implements the {@link TransactionPartialSigner} interface. */
export declare function assertIsTransactionPartialSigner<TAddress extends string>(value: {
[key: string]: unknown;
address: Address<TAddress>;
[key: string]: unknown;
}): asserts value is TransactionPartialSigner<TAddress>;
//# sourceMappingURL=transaction-partial-signer.d.ts.map

@@ -13,10 +13,10 @@ import { Address } from '@solana/addresses';

export declare function isTransactionSendingSigner<TAddress extends string>(value: {
[key: string]: unknown;
address: Address<TAddress>;
[key: string]: unknown;
}): value is TransactionSendingSigner<TAddress>;
/** Asserts that the provided value implements the {@link TransactionSendingSigner} interface. */
export declare function assertIsTransactionSendingSigner<TAddress extends string>(value: {
[key: string]: unknown;
address: Address<TAddress>;
[key: string]: unknown;
}): asserts value is TransactionSendingSigner<TAddress>;
//# sourceMappingURL=transaction-sending-signer.d.ts.map

@@ -6,13 +6,13 @@ import { Address } from '@solana/addresses';

/** Defines a signer capable of signing transactions. */
export type TransactionSigner<TAddress extends string = string> = TransactionPartialSigner<TAddress> | TransactionModifyingSigner<TAddress> | TransactionSendingSigner<TAddress>;
export type TransactionSigner<TAddress extends string = string> = TransactionModifyingSigner<TAddress> | TransactionPartialSigner<TAddress> | TransactionSendingSigner<TAddress>;
/** Checks whether the provided value implements the {@link TransactionSigner} interface. */
export declare function isTransactionSigner<TAddress extends string>(value: {
[key: string]: unknown;
address: Address<TAddress>;
[key: string]: unknown;
}): value is TransactionSigner<TAddress>;
/** Asserts that the provided value implements the {@link TransactionSigner} interface. */
export declare function assertIsTransactionSigner<TAddress extends string>(value: {
[key: string]: unknown;
address: Address<TAddress>;
[key: string]: unknown;
}): asserts value is TransactionSigner<TAddress>;
//# sourceMappingURL=transaction-signer.d.ts.map

@@ -8,5 +8,5 @@ import { CompilableTransaction } from '@solana/transactions';

/** Checks whether the provided transaction has exactly one {@link TransactionSendingSigner}. */
export declare function isTransactionWithSingleSendingSigner<TTransaction extends CompilableTransaction>(transaction: TTransaction): transaction is TTransaction & ITransactionWithSingleSendingSigner;
export declare function isTransactionWithSingleSendingSigner<TTransaction extends CompilableTransaction>(transaction: TTransaction): transaction is ITransactionWithSingleSendingSigner & TTransaction;
/** Asserts that the provided transaction has exactly one {@link TransactionSendingSigner}. */
export declare function assertIsTransactionWithSingleSendingSigner<TTransaction extends CompilableTransaction>(transaction: TTransaction): asserts transaction is TTransaction & ITransactionWithSingleSendingSigner;
export declare function assertIsTransactionWithSingleSendingSigner<TTransaction extends CompilableTransaction>(transaction: TTransaction): asserts transaction is ITransactionWithSingleSendingSigner & TTransaction;
//# sourceMappingURL=transaction-with-single-sending-signer.d.ts.map
{
"name": "@solana/signers",
"version": "2.0.0-experimental.f8c941c",
"version": "2.0.0-experimental.fa2293f",
"description": "An abstraction layer over signing messages and transactions in Solana",

@@ -52,32 +52,8 @@ "exports": {

"dependencies": {
"@solana/addresses": "2.0.0-experimental.f8c941c",
"@solana/instructions": "2.0.0-experimental.f8c941c",
"@solana/keys": "2.0.0-experimental.f8c941c",
"@solana/transactions": "2.0.0-experimental.f8c941c"
"@solana/addresses": "2.0.0-experimental.fa2293f",
"@solana/errors": "2.0.0-experimental.fa2293f",
"@solana/instructions": "2.0.0-experimental.fa2293f",
"@solana/keys": "2.0.0-experimental.fa2293f",
"@solana/transactions": "2.0.0-experimental.fa2293f"
},
"devDependencies": {
"@solana/eslint-config-solana": "^1.0.2",
"@swc/jest": "^0.2.29",
"@types/jest": "^29.5.11",
"@typescript-eslint/eslint-plugin": "^6.13.2",
"@typescript-eslint/parser": "^6.3.0",
"agadoo": "^3.0.0",
"eslint": "^8.45.0",
"eslint-plugin-jest": "^27.4.2",
"eslint-plugin-sort-keys-fix": "^1.1.2",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-runner-eslint": "^2.1.2",
"jest-runner-prettier": "^1.0.0",
"prettier": "^3.1",
"tsup": "^8.0.1",
"typescript": "^5.2.2",
"version-from-git": "^1.1.1",
"@solana/rpc-types": "2.0.0-experimental.f8c941c",
"build-scripts": "0.0.0",
"test-config": "0.0.0",
"test-matchers": "0.0.0",
"text-encoding-impl": "0.0.0",
"tsconfig": "0.0.0"
},
"bundlewatch": {

@@ -93,8 +69,9 @@ "defaultCompression": "gzip",

"compile:js": "tsup --config build-scripts/tsup.config.package.ts",
"compile:typedefs": "tsc -p ./tsconfig.declarations.json && node node_modules/build-scripts/add-js-extension-to-types.mjs",
"dev": "jest -c node_modules/test-config/jest-dev.config.ts --rootDir . --watch",
"publish-packages": "pnpm publish --tag experimental --access public --no-git-checks",
"style:fix": "pnpm eslint --fix src/* && pnpm prettier -w src/*",
"test:lint": "jest -c node_modules/test-config/jest-lint.config.ts --rootDir . --silent",
"test:prettier": "jest -c node_modules/test-config/jest-prettier.config.ts --rootDir . --silent",
"compile:typedefs": "tsc -p ./tsconfig.declarations.json && node ../../node_modules/@solana/build-scripts/add-js-extension-to-types.mjs",
"dev": "jest -c ../../node_modules/@solana/test-config/jest-dev.config.ts --rootDir . --watch",
"publish-impl": "npm view $npm_package_name@$npm_package_version > /dev/null 2>&1 || pnpm publish --tag experimental --access public --no-git-checks",
"publish-packages": "pnpm prepublishOnly && pnpm publish-impl",
"style:fix": "pnpm eslint --fix src/* && pnpm prettier -w src/* package.json",
"test:lint": "jest -c ../../node_modules/@solana/test-config/jest-lint.config.ts --rootDir . --silent",
"test:prettier": "jest -c ../../node_modules/@solana/test-config/jest-prettier.config.ts --rootDir . --silent",
"test:treeshakability:browser": "agadoo dist/index.browser.js",

@@ -104,5 +81,5 @@ "test:treeshakability:native": "agadoo dist/index.native.js",

"test:typecheck": "tsc --noEmit",
"test:unit:browser": "jest -c node_modules/test-config/jest-unit.config.browser.ts --rootDir . --silent",
"test:unit:node": "jest -c node_modules/test-config/jest-unit.config.node.ts --rootDir . --silent"
"test:unit:browser": "jest -c ../../node_modules/@solana/test-config/jest-unit.config.browser.ts --rootDir . --silent",
"test:unit:node": "jest -c ../../node_modules/@solana/test-config/jest-unit.config.node.ts --rootDir . --silent"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc