@solana/signers
Advanced tools
Comparing version 2.0.0-experimental.9741939 to 2.0.0-experimental.025ef21
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'; | ||
@@ -28,3 +28,6 @@ // src/deduplicate-signers.ts | ||
function getSignersFromTransaction(transaction) { | ||
return deduplicateSigners(transaction.instructions.flatMap(getSignersFromInstruction)); | ||
return deduplicateSigners([ | ||
...transaction.feePayerSigner ? [transaction.feePayerSigner] : [], | ||
...transaction.instructions.flatMap(getSignersFromInstruction) | ||
]); | ||
} | ||
@@ -56,2 +59,18 @@ function addSignersToInstruction(signers, instruction) { | ||
} | ||
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; | ||
} | ||
@@ -297,4 +316,4 @@ // src/message-partial-signer.ts | ||
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, 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 |
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'; | ||
@@ -28,3 +28,6 @@ // src/deduplicate-signers.ts | ||
function getSignersFromTransaction(transaction) { | ||
return deduplicateSigners(transaction.instructions.flatMap(getSignersFromInstruction)); | ||
return deduplicateSigners([ | ||
...transaction.feePayerSigner ? [transaction.feePayerSigner] : [], | ||
...transaction.instructions.flatMap(getSignersFromInstruction) | ||
]); | ||
} | ||
@@ -56,2 +59,18 @@ function addSignersToInstruction(signers, instruction) { | ||
} | ||
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; | ||
} | ||
@@ -297,4 +316,4 @@ // src/message-partial-signer.ts | ||
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, 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 |
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'; | ||
@@ -28,3 +28,6 @@ // src/deduplicate-signers.ts | ||
function getSignersFromTransaction(transaction) { | ||
return deduplicateSigners(transaction.instructions.flatMap(getSignersFromInstruction)); | ||
return deduplicateSigners([ | ||
...transaction.feePayerSigner ? [transaction.feePayerSigner] : [], | ||
...transaction.instructions.flatMap(getSignersFromInstruction) | ||
]); | ||
} | ||
@@ -56,2 +59,18 @@ function addSignersToInstruction(signers, instruction) { | ||
} | ||
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; | ||
} | ||
@@ -297,4 +316,4 @@ // src/message-partial-signer.ts | ||
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, 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> = IAccountMeta | IAccountLookupMeta | 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[]; |
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'; |
{ | ||
"name": "@solana/signers", | ||
"version": "2.0.0-experimental.9741939", | ||
"version": "2.0.0-experimental.025ef21", | ||
"description": "An abstraction layer over signing messages and transactions in Solana", | ||
@@ -52,6 +52,7 @@ "exports": { | ||
"dependencies": { | ||
"@solana/addresses": "2.0.0-experimental.9741939", | ||
"@solana/instructions": "2.0.0-experimental.9741939", | ||
"@solana/keys": "2.0.0-experimental.9741939", | ||
"@solana/transactions": "2.0.0-experimental.9741939" | ||
"@solana/addresses": "2.0.0-experimental.025ef21", | ||
"@solana/errors": "2.0.0-experimental.025ef21", | ||
"@solana/keys": "2.0.0-experimental.025ef21", | ||
"@solana/transactions": "2.0.0-experimental.025ef21", | ||
"@solana/instructions": "2.0.0-experimental.025ef21" | ||
}, | ||
@@ -76,2 +77,3 @@ "devDependencies": { | ||
"version-from-git": "^1.1.1", | ||
"@solana/rpc-types": "2.0.0-experimental.025ef21", | ||
"build-scripts": "0.0.0", | ||
@@ -96,3 +98,3 @@ "test-config": "0.0.0", | ||
"publish-packages": "pnpm publish --tag experimental --access public --no-git-checks", | ||
"style:fix": "pnpm eslint --fix src/* && pnpm prettier -w src/*", | ||
"style:fix": "pnpm eslint --fix src/* && pnpm prettier -w src/* package.json", | ||
"test:lint": "jest -c node_modules/test-config/jest-lint.config.ts --rootDir . --silent", | ||
@@ -99,0 +101,0 @@ "test:prettier": "jest -c node_modules/test-config/jest-prettier.config.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
359920
50
2179
5
23
+ Added@solana/addresses@2.0.0-experimental.025ef21(transitive)
+ Added@solana/assertions@2.0.0-experimental.025ef21(transitive)
+ Added@solana/codecs-core@2.0.0-experimental.025ef21(transitive)
+ Added@solana/codecs-data-structures@2.0.0-experimental.025ef21(transitive)
+ Added@solana/codecs-numbers@2.0.0-experimental.025ef21(transitive)
+ Added@solana/codecs-strings@2.0.0-experimental.025ef21(transitive)
+ Added@solana/errors@2.0.0-experimental.025ef21(transitive)
+ Added@solana/functional@2.0.0-experimental.025ef21(transitive)
+ Added@solana/instructions@2.0.0-experimental.025ef21(transitive)
+ Added@solana/keys@2.0.0-experimental.025ef21(transitive)
+ Added@solana/transactions@2.0.0-experimental.025ef21(transitive)
+ Addedchalk@5.4.1(transitive)
+ Addedcommander@11.1.0(transitive)
- Removed@solana/addresses@2.0.0-experimental.9741939(transitive)
- Removed@solana/assertions@2.0.0-experimental.9741939(transitive)
- Removed@solana/codecs-core@2.0.0-experimental.9741939(transitive)
- Removed@solana/codecs-data-structures@2.0.0-experimental.9741939(transitive)
- Removed@solana/codecs-numbers@2.0.0-experimental.9741939(transitive)
- Removed@solana/codecs-strings@2.0.0-experimental.9741939(transitive)
- Removed@solana/functional@2.0.0-experimental.9741939(transitive)
- Removed@solana/instructions@2.0.0-experimental.9741939(transitive)
- Removed@solana/keys@2.0.0-experimental.9741939(transitive)
- Removed@solana/transactions@2.0.0-experimental.9741939(transitive)