@solana/signers
Advanced tools
Comparing version 2.0.0-experimental.efe6f4d to 2.0.0-experimental.fb88a79
@@ -0,7 +1,56 @@ | ||
import { isSignerRole } from '@solana/instructions'; | ||
import { getAddressFromPublicKey, isAddress } from '@solana/addresses'; | ||
import { generateKeyPair, signBytes } from '@solana/keys'; | ||
import { partiallySignTransaction } from '@solana/transactions'; | ||
import { assertTransactionIsFullySigned, partiallySignTransaction } from '@solana/transactions'; | ||
// src/keypair-signer.ts | ||
// src/deduplicate-signers.ts | ||
function deduplicateSigners(signers) { | ||
const deduplicated = {}; | ||
signers.forEach((signer) => { | ||
if (!deduplicated[signer.address]) { | ||
deduplicated[signer.address] = signer; | ||
} 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.` | ||
); | ||
} | ||
}); | ||
return Object.values(deduplicated); | ||
} | ||
// src/account-signer-meta.ts | ||
function getSignersFromInstruction(instruction) { | ||
return deduplicateSigners( | ||
(instruction.accounts ?? []).flatMap((account) => "signer" in account ? account.signer : []) | ||
); | ||
} | ||
function getSignersFromTransaction(transaction) { | ||
return deduplicateSigners(transaction.instructions.flatMap(getSignersFromInstruction)); | ||
} | ||
function addSignersToInstruction(signers, instruction) { | ||
if (!instruction.accounts || instruction.accounts.length === 0) { | ||
return instruction; | ||
} | ||
const signerByAddress = new Map(deduplicateSigners(signers).map((signer) => [signer.address, signer])); | ||
return Object.freeze({ | ||
...instruction, | ||
accounts: instruction.accounts.map((account) => { | ||
const signer = signerByAddress.get(account.address); | ||
if (!isSignerRole(account.role) || "signer" in account || !signer) { | ||
return account; | ||
} | ||
return Object.freeze({ ...account, signer }); | ||
}) | ||
}); | ||
} | ||
function addSignersToTransaction(signers, transaction) { | ||
if (transaction.instructions.length === 0) { | ||
return transaction; | ||
} | ||
return Object.freeze({ | ||
...transaction, | ||
instructions: transaction.instructions.map((instruction) => addSignersToInstruction(signers, instruction)) | ||
}); | ||
} | ||
// src/message-partial-signer.ts | ||
@@ -76,10 +125,11 @@ function isMessagePartialSigner(value) { | ||
} | ||
var o = globalThis.TextEncoder; | ||
// src/signable-message.ts | ||
function createSignableMessage(content, signatures = {}) { | ||
return Object.freeze({ | ||
content: typeof content === "string" ? new o().encode(content) : content, | ||
signatures: Object.freeze({ ...signatures }) | ||
}); | ||
// src/noop-signer.ts | ||
function createNoopSigner(address) { | ||
const out = { | ||
address, | ||
signMessages: async (messages) => messages.map(() => Object.freeze({})), | ||
signTransactions: async (transactions) => transactions.map(() => Object.freeze({})) | ||
}; | ||
return Object.freeze(out); | ||
} | ||
@@ -117,4 +167,133 @@ | ||
export { assertIsKeyPairSigner, assertIsMessageModifyingSigner, assertIsMessagePartialSigner, assertIsMessageSigner, assertIsTransactionModifyingSigner, assertIsTransactionPartialSigner, assertIsTransactionSendingSigner, assertIsTransactionSigner, createSignableMessage, createSignerFromKeyPair, generateKeyPairSigner, isKeyPairSigner, isMessageModifyingSigner, isMessagePartialSigner, isMessageSigner, isTransactionModifyingSigner, isTransactionPartialSigner, isTransactionSendingSigner, isTransactionSigner }; | ||
// src/sign-transaction.ts | ||
async function partiallySignTransactionWithSigners(transaction, config = {}) { | ||
const { partialSigners, modifyingSigners } = categorizeTransactionSigners( | ||
deduplicateSigners(getSignersFromTransaction(transaction).filter(isTransactionSigner)), | ||
{ identifySendingSigner: false } | ||
); | ||
return signModifyingAndPartialTransactionSigners(transaction, modifyingSigners, partialSigners, config.abortSignal); | ||
} | ||
async function signTransactionWithSigners(transaction, config = {}) { | ||
const signedTransaction = await partiallySignTransactionWithSigners(transaction, config); | ||
assertTransactionIsFullySigned(signedTransaction); | ||
return signedTransaction; | ||
} | ||
async function signAndSendTransactionWithSigners(transaction, config = {}) { | ||
const abortSignal = config.abortSignal; | ||
const { partialSigners, modifyingSigners, sendingSigner } = categorizeTransactionSigners( | ||
deduplicateSigners(getSignersFromTransaction(transaction).filter(isTransactionSigner)) | ||
); | ||
abortSignal?.throwIfAborted(); | ||
const signedTransaction = await signModifyingAndPartialTransactionSigners( | ||
transaction, | ||
modifyingSigners, | ||
partialSigners, | ||
abortSignal | ||
); | ||
if (!sendingSigner) { | ||
throw new Error( | ||
"No `TransactionSendingSigner` was identified. Please provide a valid `ITransactionWithSingleSendingSigner` transaction." | ||
); | ||
} | ||
abortSignal?.throwIfAborted(); | ||
const [signature] = await sendingSigner.signAndSendTransactions([signedTransaction], { abortSignal }); | ||
abortSignal?.throwIfAborted(); | ||
return signature; | ||
} | ||
function categorizeTransactionSigners(signers, config = {}) { | ||
const identifySendingSigner = config.identifySendingSigner ?? true; | ||
const sendingSigner = identifySendingSigner ? identifyTransactionSendingSigner(signers) : null; | ||
const otherSigners = signers.filter( | ||
(signer) => signer !== sendingSigner && (isTransactionModifyingSigner(signer) || isTransactionPartialSigner(signer)) | ||
); | ||
const modifyingSigners = identifyTransactionModifyingSigners(otherSigners); | ||
const partialSigners = otherSigners.filter(isTransactionPartialSigner).filter((signer) => !modifyingSigners.includes(signer)); | ||
return Object.freeze({ modifyingSigners, partialSigners, sendingSigner }); | ||
} | ||
function identifyTransactionSendingSigner(signers) { | ||
const sendingSigners = signers.filter(isTransactionSendingSigner); | ||
if (sendingSigners.length === 0) | ||
return null; | ||
const sendingOnlySigners = sendingSigners.filter( | ||
(signer) => !isTransactionModifyingSigner(signer) && !isTransactionPartialSigner(signer) | ||
); | ||
if (sendingOnlySigners.length > 0) { | ||
return sendingOnlySigners[0]; | ||
} | ||
return sendingSigners[0]; | ||
} | ||
function identifyTransactionModifyingSigners(signers) { | ||
const modifyingSigners = signers.filter(isTransactionModifyingSigner); | ||
if (modifyingSigners.length === 0) | ||
return []; | ||
const nonPartialSigners = modifyingSigners.filter((signer) => !isTransactionPartialSigner(signer)); | ||
if (nonPartialSigners.length > 0) | ||
return nonPartialSigners; | ||
return [modifyingSigners[0]]; | ||
} | ||
async function signModifyingAndPartialTransactionSigners(transaction, modifyingSigners = [], partialSigners = [], abortSignal) { | ||
const modifiedTransaction = await modifyingSigners.reduce( | ||
async (transaction2, modifyingSigner) => { | ||
abortSignal?.throwIfAborted(); | ||
const [tx] = await modifyingSigner.modifyAndSignTransactions([await transaction2], { abortSignal }); | ||
return Object.freeze(tx); | ||
}, | ||
Promise.resolve(transaction) | ||
); | ||
abortSignal?.throwIfAborted(); | ||
const signatureDictionaries = await Promise.all( | ||
partialSigners.map(async (partialSigner) => { | ||
const [signatures] = await partialSigner.signTransactions([modifiedTransaction], { abortSignal }); | ||
return signatures; | ||
}) | ||
); | ||
const signedTransaction = { | ||
...modifiedTransaction, | ||
signatures: Object.freeze( | ||
signatureDictionaries.reduce((signatures, signatureDictionary) => { | ||
return { ...signatures, ...signatureDictionary }; | ||
}, modifiedTransaction.signatures ?? {}) | ||
) | ||
}; | ||
return Object.freeze(signedTransaction); | ||
} | ||
var o = globalThis.TextEncoder; | ||
// src/signable-message.ts | ||
function createSignableMessage(content, signatures = {}) { | ||
return Object.freeze({ | ||
content: typeof content === "string" ? new o().encode(content) : content, | ||
signatures: Object.freeze({ ...signatures }) | ||
}); | ||
} | ||
// src/transaction-with-single-sending-signer.ts | ||
function isTransactionWithSingleSendingSigner(transaction) { | ||
try { | ||
assertIsTransactionWithSingleSendingSigner(transaction); | ||
return true; | ||
} catch { | ||
return false; | ||
} | ||
} | ||
function assertIsTransactionWithSingleSendingSigner(transaction) { | ||
const signers = getSignersFromTransaction(transaction); | ||
const sendingSigners = signers.filter(isTransactionSendingSigner); | ||
if (sendingSigners.length === 0) { | ||
const error = new Error("No `TransactionSendingSigner` was identified."); | ||
error.name = "MissingTransactionSendingSignerError"; | ||
throw error; | ||
} | ||
const sendingOnlySigners = sendingSigners.filter( | ||
(signer) => !isTransactionPartialSigner(signer) && !isTransactionModifyingSigner(signer) | ||
); | ||
if (sendingOnlySigners.length > 1) { | ||
const error = new Error("More than one `TransactionSendingSigner` was identified."); | ||
error.name = "MultipleTransactionSendingSignersError"; | ||
throw error; | ||
} | ||
} | ||
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 }; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.browser.js.map |
@@ -5,2 +5,60 @@ this.globalThis = this.globalThis || {}; | ||
// src/deduplicate-signers.ts | ||
function deduplicateSigners(signers) { | ||
const deduplicated = {}; | ||
signers.forEach((signer) => { | ||
if (!deduplicated[signer.address]) { | ||
deduplicated[signer.address] = signer; | ||
} 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.` | ||
); | ||
} | ||
}); | ||
return Object.values(deduplicated); | ||
} | ||
// src/account-signer-meta.ts | ||
function getSignersFromInstruction(instruction) { | ||
var _a; | ||
return deduplicateSigners( | ||
((_a = instruction.accounts) != null ? _a : []).flatMap((account) => "signer" in account ? account.signer : []) | ||
); | ||
} | ||
function getSignersFromTransaction(transaction) { | ||
return deduplicateSigners(transaction.instructions.flatMap(getSignersFromInstruction)); | ||
} | ||
// ../instructions/dist/index.browser.js | ||
function isSignerRole(role) { | ||
return role >= 2; | ||
} | ||
// src/add-signers.ts | ||
function addSignersToInstruction(signers, instruction) { | ||
if (!instruction.accounts || instruction.accounts.length === 0) { | ||
return instruction; | ||
} | ||
const signerByAddress = new Map(deduplicateSigners(signers).map((signer) => [signer.address, signer])); | ||
return Object.freeze({ | ||
...instruction, | ||
accounts: instruction.accounts.map((account) => { | ||
const signer = signerByAddress.get(account.address); | ||
if (!isSignerRole(account.role) || "signer" in account || !signer) { | ||
return account; | ||
} | ||
return Object.freeze({ ...account, signer }); | ||
}) | ||
}); | ||
} | ||
function addSignersToTransaction(signers, transaction) { | ||
if (transaction.instructions.length === 0) { | ||
return transaction; | ||
} | ||
return Object.freeze({ | ||
...transaction, | ||
instructions: transaction.instructions.map((instruction) => addSignersToInstruction(signers, instruction)) | ||
}); | ||
} | ||
// ../codecs-core/dist/index.browser.js | ||
@@ -18,19 +76,2 @@ function assertByteArrayIsNotEmptyForCodec(codecDescription, bytes, offset = 0) { | ||
} | ||
var mergeBytes = (byteArrays) => { | ||
const nonEmptyByteArrays = byteArrays.filter((arr) => arr.length); | ||
if (nonEmptyByteArrays.length === 0) { | ||
return byteArrays.length ? byteArrays[0] : new Uint8Array(); | ||
} | ||
if (nonEmptyByteArrays.length === 1) { | ||
return nonEmptyByteArrays[0]; | ||
} | ||
const totalLength = nonEmptyByteArrays.reduce((total, arr) => total + arr.length, 0); | ||
const result = new Uint8Array(totalLength); | ||
let offset = 0; | ||
nonEmptyByteArrays.forEach((arr) => { | ||
result.set(arr, offset); | ||
offset += arr.length; | ||
}); | ||
return result; | ||
}; | ||
var padBytes = (bytes, length) => { | ||
@@ -44,19 +85,47 @@ if (bytes.length >= length) | ||
var fixBytes = (bytes, length) => padBytes(bytes.length <= length ? bytes : bytes.slice(0, length), length); | ||
function fixCodecHelper(data, fixedBytes, description) { | ||
return { | ||
description: description ?? `fixed(${fixedBytes}, ${data.description})`, | ||
function getEncodedSize(value, encoder) { | ||
return "fixedSize" in encoder ? encoder.fixedSize : encoder.getSizeFromValue(value); | ||
} | ||
function createEncoder(encoder) { | ||
return Object.freeze({ | ||
...encoder, | ||
encode: (value) => { | ||
const bytes = new Uint8Array(getEncodedSize(value, encoder)); | ||
encoder.write(value, bytes, 0); | ||
return bytes; | ||
} | ||
}); | ||
} | ||
function createDecoder(decoder) { | ||
return Object.freeze({ | ||
...decoder, | ||
decode: (bytes, offset = 0) => decoder.read(bytes, offset)[0] | ||
}); | ||
} | ||
function isFixedSize(codec) { | ||
return "fixedSize" in codec && typeof codec.fixedSize === "number"; | ||
} | ||
function assertIsFixedSize(codec, message) { | ||
if (!isFixedSize(codec)) { | ||
throw new Error(message != null ? message : "Expected a fixed-size codec, got a variable-size one."); | ||
} | ||
} | ||
function isVariableSize(codec) { | ||
return !isFixedSize(codec); | ||
} | ||
function fixEncoder(encoder, fixedBytes) { | ||
return createEncoder({ | ||
fixedSize: fixedBytes, | ||
maxSize: fixedBytes | ||
}; | ||
write: (value, bytes, offset) => { | ||
const variableByteArray = encoder.encode(value); | ||
const fixedByteArray = variableByteArray.length > fixedBytes ? variableByteArray.slice(0, fixedBytes) : variableByteArray; | ||
bytes.set(fixedByteArray, offset); | ||
return offset + fixedBytes; | ||
} | ||
}); | ||
} | ||
function fixEncoder(encoder, fixedBytes, description) { | ||
return { | ||
...fixCodecHelper(encoder, fixedBytes, description), | ||
encode: (value) => fixBytes(encoder.encode(value), fixedBytes) | ||
}; | ||
} | ||
function fixDecoder(decoder, fixedBytes, description) { | ||
return { | ||
...fixCodecHelper(decoder, fixedBytes, description), | ||
decode: (bytes, offset = 0) => { | ||
function fixDecoder(decoder, fixedBytes) { | ||
return createDecoder({ | ||
fixedSize: fixedBytes, | ||
read: (bytes, offset) => { | ||
assertByteArrayHasEnoughBytesForCodec("fixCodec", fixedBytes, bytes, offset); | ||
@@ -66,17 +135,15 @@ if (offset > 0 || bytes.length > fixedBytes) { | ||
} | ||
if (decoder.fixedSize !== null) { | ||
if (isFixedSize(decoder)) { | ||
bytes = fixBytes(bytes, decoder.fixedSize); | ||
} | ||
const [value] = decoder.decode(bytes, 0); | ||
const [value] = decoder.read(bytes, 0); | ||
return [value, offset + fixedBytes]; | ||
} | ||
}; | ||
}); | ||
} | ||
function mapEncoder(encoder, unmap) { | ||
return { | ||
description: encoder.description, | ||
encode: (value) => encoder.encode(unmap(value)), | ||
fixedSize: encoder.fixedSize, | ||
maxSize: encoder.maxSize | ||
}; | ||
return createEncoder({ | ||
...isVariableSize(encoder) ? { ...encoder, getSizeFromValue: (value) => encoder.getSizeFromValue(unmap(value)) } : encoder, | ||
write: (value, bytes, offset) => encoder.write(unmap(value), bytes, offset) | ||
}); | ||
} | ||
@@ -92,21 +159,9 @@ | ||
} | ||
function sharedNumberFactory(input) { | ||
let littleEndian; | ||
let defaultDescription = input.name; | ||
if (input.size > 1) { | ||
littleEndian = !("endian" in input.config) || input.config.endian === 0; | ||
defaultDescription += littleEndian ? "(le)" : "(be)"; | ||
} | ||
return { | ||
description: input.config.description ?? defaultDescription, | ||
fixedSize: input.size, | ||
littleEndian, | ||
maxSize: input.size | ||
}; | ||
function isLittleEndian(config) { | ||
return (config == null ? void 0 : config.endian) === 1 ? false : true; | ||
} | ||
function numberEncoderFactory(input) { | ||
const codecData = sharedNumberFactory(input); | ||
return { | ||
description: codecData.description, | ||
encode(value) { | ||
return createEncoder({ | ||
fixedSize: input.size, | ||
write(value, bytes, offset) { | ||
if (input.range) { | ||
@@ -116,33 +171,36 @@ assertNumberIsBetweenForCodec(input.name, input.range[0], input.range[1], value); | ||
const arrayBuffer = new ArrayBuffer(input.size); | ||
input.set(new DataView(arrayBuffer), value, codecData.littleEndian); | ||
return new Uint8Array(arrayBuffer); | ||
}, | ||
fixedSize: codecData.fixedSize, | ||
maxSize: codecData.maxSize | ||
}; | ||
input.set(new DataView(arrayBuffer), value, isLittleEndian(input.config)); | ||
bytes.set(new Uint8Array(arrayBuffer), offset); | ||
return offset + input.size; | ||
} | ||
}); | ||
} | ||
function numberDecoderFactory(input) { | ||
const codecData = sharedNumberFactory(input); | ||
return { | ||
decode(bytes, offset = 0) { | ||
assertByteArrayIsNotEmptyForCodec(codecData.description, bytes, offset); | ||
assertByteArrayHasEnoughBytesForCodec(codecData.description, input.size, bytes, offset); | ||
return createDecoder({ | ||
fixedSize: input.size, | ||
read(bytes, offset = 0) { | ||
assertByteArrayIsNotEmptyForCodec(input.name, bytes, offset); | ||
assertByteArrayHasEnoughBytesForCodec(input.name, input.size, bytes, offset); | ||
const view = new DataView(toArrayBuffer(bytes, offset, input.size)); | ||
return [input.get(view, codecData.littleEndian), offset + input.size]; | ||
}, | ||
description: codecData.description, | ||
fixedSize: codecData.fixedSize, | ||
maxSize: codecData.maxSize | ||
}; | ||
return [input.get(view, isLittleEndian(input.config)), offset + input.size]; | ||
} | ||
}); | ||
} | ||
function toArrayBuffer(bytes, offset, length) { | ||
const bytesOffset = bytes.byteOffset + (offset ?? 0); | ||
const bytesLength = length ?? bytes.byteLength; | ||
const bytesOffset = bytes.byteOffset + (offset != null ? offset : 0); | ||
const bytesLength = length != null ? length : bytes.byteLength; | ||
return bytes.buffer.slice(bytesOffset, bytesOffset + bytesLength); | ||
} | ||
var getShortU16Encoder = (config = {}) => ({ | ||
description: config.description ?? "shortU16", | ||
encode: (value) => { | ||
var getShortU16Encoder = () => createEncoder({ | ||
getSizeFromValue: (value) => { | ||
if (value <= 127) | ||
return 1; | ||
if (value <= 16383) | ||
return 2; | ||
return 3; | ||
}, | ||
maxSize: 3, | ||
write: (value, bytes, offset) => { | ||
assertNumberIsBetweenForCodec("shortU16", 0, 65535, value); | ||
const bytes = [0]; | ||
const shortU16Bytes = [0]; | ||
for (let ii = 0; ; ii += 1) { | ||
@@ -154,11 +212,10 @@ const alignedValue = value >> ii * 7; | ||
const nextSevenBits = 127 & alignedValue; | ||
bytes[ii] = nextSevenBits; | ||
shortU16Bytes[ii] = nextSevenBits; | ||
if (ii > 0) { | ||
bytes[ii - 1] |= 128; | ||
shortU16Bytes[ii - 1] |= 128; | ||
} | ||
} | ||
return new Uint8Array(bytes); | ||
}, | ||
fixedSize: null, | ||
maxSize: 3 | ||
bytes.set(shortU16Bytes, offset); | ||
return offset + shortU16Bytes.length; | ||
} | ||
}); | ||
@@ -178,4 +235,3 @@ var getU32Encoder = (config = {}) => numberEncoderFactory({ | ||
}); | ||
var getU8Encoder = (config = {}) => numberEncoderFactory({ | ||
config, | ||
var getU8Encoder = () => numberEncoderFactory({ | ||
name: "u8", | ||
@@ -194,23 +250,20 @@ range: [0, Number("0xff")], | ||
var getBaseXEncoder = (alphabet4) => { | ||
const base = alphabet4.length; | ||
const baseBigInt = BigInt(base); | ||
return { | ||
description: `base${base}`, | ||
encode(value) { | ||
return createEncoder({ | ||
getSizeFromValue: (value) => { | ||
const [leadingZeroes, tailChars] = partitionLeadingZeroes(value, alphabet4[0]); | ||
if (tailChars === "") | ||
return value.length; | ||
const base10Number = getBigIntFromBaseX(tailChars, alphabet4); | ||
return leadingZeroes.length + Math.ceil(base10Number.toString(16).length / 2); | ||
}, | ||
write(value, bytes, offset) { | ||
assertValidBaseString(alphabet4, value); | ||
if (value === "") | ||
return new Uint8Array(); | ||
const chars = [...value]; | ||
let trailIndex = chars.findIndex((c) => c !== alphabet4[0]); | ||
trailIndex = trailIndex === -1 ? chars.length : trailIndex; | ||
const leadingZeroes = Array(trailIndex).fill(0); | ||
if (trailIndex === chars.length) | ||
return Uint8Array.from(leadingZeroes); | ||
const tailChars = chars.slice(trailIndex); | ||
let base10Number = 0n; | ||
let baseXPower = 1n; | ||
for (let i = tailChars.length - 1; i >= 0; i -= 1) { | ||
base10Number += baseXPower * BigInt(alphabet4.indexOf(tailChars[i])); | ||
baseXPower *= baseBigInt; | ||
return offset; | ||
const [leadingZeroes, tailChars] = partitionLeadingZeroes(value, alphabet4[0]); | ||
if (tailChars === "") { | ||
bytes.set(new Uint8Array(leadingZeroes.length).fill(0), offset); | ||
return offset + leadingZeroes.length; | ||
} | ||
let base10Number = getBigIntFromBaseX(tailChars, alphabet4); | ||
const tailBytes = []; | ||
@@ -221,13 +274,11 @@ while (base10Number > 0n) { | ||
} | ||
return Uint8Array.from(leadingZeroes.concat(tailBytes)); | ||
}, | ||
fixedSize: null, | ||
maxSize: null | ||
}; | ||
const bytesToAdd = [...Array(leadingZeroes.length).fill(0), ...tailBytes]; | ||
bytes.set(bytesToAdd, offset); | ||
return offset + bytesToAdd.length; | ||
} | ||
}); | ||
}; | ||
var getBaseXDecoder = (alphabet4) => { | ||
const base = alphabet4.length; | ||
const baseBigInt = BigInt(base); | ||
return { | ||
decode(rawBytes, offset = 0) { | ||
return createDecoder({ | ||
read(rawBytes, offset) { | ||
const bytes = offset === 0 ? rawBytes : rawBytes.slice(offset); | ||
@@ -241,15 +292,25 @@ if (bytes.length === 0) | ||
return [leadingZeroes, rawBytes.length]; | ||
let base10Number = bytes.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n); | ||
const tailChars = []; | ||
while (base10Number > 0n) { | ||
tailChars.unshift(alphabet4[Number(base10Number % baseBigInt)]); | ||
base10Number /= baseBigInt; | ||
} | ||
return [leadingZeroes + tailChars.join(""), rawBytes.length]; | ||
}, | ||
description: `base${base}`, | ||
fixedSize: null, | ||
maxSize: null | ||
}; | ||
const base10Number = bytes.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n); | ||
const tailChars = getBaseXFromBigInt(base10Number, alphabet4); | ||
return [leadingZeroes + tailChars, rawBytes.length]; | ||
} | ||
}); | ||
}; | ||
function partitionLeadingZeroes(value, zeroCharacter) { | ||
const leadingZeroIndex = [...value].findIndex((c) => c !== zeroCharacter); | ||
return leadingZeroIndex === -1 ? [value, ""] : [value.slice(0, leadingZeroIndex), value.slice(leadingZeroIndex)]; | ||
} | ||
function getBigIntFromBaseX(value, alphabet4) { | ||
const base = BigInt(alphabet4.length); | ||
return [...value].reduce((sum, char) => sum * base + BigInt(alphabet4.indexOf(char)), 0n); | ||
} | ||
function getBaseXFromBigInt(value, alphabet4) { | ||
const base = BigInt(alphabet4.length); | ||
const tailChars = []; | ||
while (value > 0n) { | ||
tailChars.unshift(alphabet4[Number(value % base)]); | ||
value /= base; | ||
} | ||
return tailChars.join(""); | ||
} | ||
var alphabet2 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; | ||
@@ -266,56 +327,56 @@ var getBase58Encoder = () => getBaseXEncoder(alphabet2); | ||
let textEncoder; | ||
return { | ||
description: "utf8", | ||
encode: (value) => new Uint8Array((textEncoder || (textEncoder = new o())).encode(value)), | ||
fixedSize: null, | ||
maxSize: null | ||
}; | ||
return createEncoder({ | ||
getSizeFromValue: (value) => (textEncoder || (textEncoder = new o())).encode(value).length, | ||
write: (value, bytes, offset) => { | ||
const bytesToAdd = (textEncoder || (textEncoder = new o())).encode(value); | ||
bytes.set(bytesToAdd, offset); | ||
return offset + bytesToAdd.length; | ||
} | ||
}); | ||
}; | ||
var getUtf8Decoder = () => { | ||
let textDecoder; | ||
return { | ||
decode(bytes, offset = 0) { | ||
return createDecoder({ | ||
read(bytes, offset) { | ||
const value = (textDecoder || (textDecoder = new e())).decode(bytes.slice(offset)); | ||
return [removeNullCharacters(value), bytes.length]; | ||
}, | ||
description: "utf8", | ||
fixedSize: null, | ||
maxSize: null | ||
}; | ||
} | ||
}); | ||
}; | ||
var getStringEncoder = (config = {}) => { | ||
const size = config.size ?? getU32Encoder(); | ||
const encoding = config.encoding ?? getUtf8Encoder(); | ||
const description = config.description ?? `string(${encoding.description}; ${getSizeDescription(size)})`; | ||
function getStringEncoder(config = {}) { | ||
var _a, _b; | ||
const size = (_a = config.size) != null ? _a : getU32Encoder(); | ||
const encoding = (_b = config.encoding) != null ? _b : getUtf8Encoder(); | ||
if (size === "variable") { | ||
return { ...encoding, description }; | ||
return encoding; | ||
} | ||
if (typeof size === "number") { | ||
return fixEncoder(encoding, size, description); | ||
return fixEncoder(encoding, size); | ||
} | ||
return { | ||
description, | ||
encode: (value) => { | ||
const contentBytes = encoding.encode(value); | ||
const lengthBytes = size.encode(contentBytes.length); | ||
return mergeBytes([lengthBytes, contentBytes]); | ||
return createEncoder({ | ||
getSizeFromValue: (value) => { | ||
const contentSize = getEncodedSize(value, encoding); | ||
return getEncodedSize(contentSize, size) + contentSize; | ||
}, | ||
fixedSize: null, | ||
maxSize: null | ||
}; | ||
}; | ||
var getStringDecoder = (config = {}) => { | ||
const size = config.size ?? getU32Decoder(); | ||
const encoding = config.encoding ?? getUtf8Decoder(); | ||
const description = config.description ?? `string(${encoding.description}; ${getSizeDescription(size)})`; | ||
write: (value, bytes, offset) => { | ||
const contentSize = getEncodedSize(value, encoding); | ||
offset = size.write(contentSize, bytes, offset); | ||
return encoding.write(value, bytes, offset); | ||
} | ||
}); | ||
} | ||
function getStringDecoder(config = {}) { | ||
var _a, _b; | ||
const size = (_a = config.size) != null ? _a : getU32Decoder(); | ||
const encoding = (_b = config.encoding) != null ? _b : getUtf8Decoder(); | ||
if (size === "variable") { | ||
return { ...encoding, description }; | ||
return encoding; | ||
} | ||
if (typeof size === "number") { | ||
return fixDecoder(encoding, size, description); | ||
return fixDecoder(encoding, size); | ||
} | ||
return { | ||
decode: (bytes, offset = 0) => { | ||
return createDecoder({ | ||
read: (bytes, offset = 0) => { | ||
assertByteArrayIsNotEmptyForCodec("string", bytes, offset); | ||
const [lengthBigInt, lengthOffset] = size.decode(bytes, offset); | ||
const [lengthBigInt, lengthOffset] = size.read(bytes, offset); | ||
const length = Number(lengthBigInt); | ||
@@ -325,13 +386,7 @@ offset = lengthOffset; | ||
assertByteArrayHasEnoughBytesForCodec("string", length, contentBytes); | ||
const [value, contentOffset] = encoding.decode(contentBytes); | ||
const [value, contentOffset] = encoding.read(contentBytes, 0); | ||
offset += contentOffset; | ||
return [value, offset]; | ||
}, | ||
description, | ||
fixedSize: null, | ||
maxSize: null | ||
}; | ||
}; | ||
function getSizeDescription(size) { | ||
return typeof size === "object" ? size.description : `${size}`; | ||
} | ||
}); | ||
} | ||
@@ -370,4 +425,5 @@ | ||
async function assertKeyGenerationIsAvailable() { | ||
var _a; | ||
assertIsSecureContext(); | ||
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.generateKey !== "function") { | ||
if (typeof globalThis.crypto === "undefined" || typeof ((_a = globalThis.crypto.subtle) == null ? void 0 : _a.generateKey) !== "function") { | ||
throw new Error("No key generation implementation could be found"); | ||
@@ -382,4 +438,5 @@ } | ||
async function assertKeyExporterIsAvailable() { | ||
var _a; | ||
assertIsSecureContext(); | ||
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.exportKey !== "function") { | ||
if (typeof globalThis.crypto === "undefined" || typeof ((_a = globalThis.crypto.subtle) == null ? void 0 : _a.exportKey) !== "function") { | ||
throw new Error("No key export implementation could be found"); | ||
@@ -389,4 +446,5 @@ } | ||
async function assertSigningCapabilityIsAvailable() { | ||
var _a; | ||
assertIsSecureContext(); | ||
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.sign !== "function") { | ||
if (typeof globalThis.crypto === "undefined" || typeof ((_a = globalThis.crypto.subtle) == null ? void 0 : _a.sign) !== "function") { | ||
throw new Error("No signing implementation could be found"); | ||
@@ -450,18 +508,10 @@ } | ||
} | ||
function getAddressEncoder(config) { | ||
function getAddressEncoder() { | ||
return mapEncoder( | ||
getStringEncoder({ | ||
description: config?.description ?? "Address", | ||
encoding: getMemoizedBase58Encoder(), | ||
size: 32 | ||
}), | ||
getStringEncoder({ encoding: getMemoizedBase58Encoder(), size: 32 }), | ||
(putativeAddress) => address(putativeAddress) | ||
); | ||
} | ||
function getAddressDecoder(config) { | ||
return getStringDecoder({ | ||
description: config?.description ?? "Address", | ||
encoding: getMemoizedBase58Decoder(), | ||
size: 32 | ||
}); | ||
function getAddressDecoder() { | ||
return getStringDecoder({ encoding: getMemoizedBase58Decoder(), size: 32 }); | ||
} | ||
@@ -484,4 +534,3 @@ function getAddressComparator() { | ||
const publicKeyBytes = await crypto.subtle.exportKey("raw", publicKey); | ||
const [base58EncodedAddress] = getAddressDecoder().decode(new Uint8Array(publicKeyBytes)); | ||
return base58EncodedAddress; | ||
return getAddressDecoder().decode(new Uint8Array(publicKeyBytes)); | ||
} | ||
@@ -511,19 +560,2 @@ | ||
// ../codecs-data-structures/dist/index.browser.js | ||
function sumCodecSizes(sizes) { | ||
return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0); | ||
} | ||
function getArrayLikeCodecSizeDescription(size) { | ||
return typeof size === "object" ? size.description : `${size}`; | ||
} | ||
function getArrayLikeCodecSizeFromChildren(size, childrenSizes) { | ||
if (typeof size !== "number") | ||
return null; | ||
if (size === 0) | ||
return 0; | ||
const childrenSize = sumCodecSizes(childrenSizes); | ||
return childrenSize === null ? null : childrenSize * size; | ||
} | ||
function getArrayLikeCodecSizePrefix(size, realSize) { | ||
return typeof size === "object" ? size.encode(realSize) : new Uint8Array(); | ||
} | ||
function assertValidNumberOfItemsForCodec(codecDescription, expected, actual) { | ||
@@ -534,34 +566,59 @@ if (expected !== actual) { | ||
} | ||
function arrayCodecHelper(item, size, description) { | ||
if (size === "remainder" && item.fixedSize === null) { | ||
throw new Error('Codecs of "remainder" size must have fixed-size items.'); | ||
} | ||
return { | ||
description: description ?? `array(${item.description}; ${getArrayLikeCodecSizeDescription(size)})`, | ||
fixedSize: getArrayLikeCodecSizeFromChildren(size, [item.fixedSize]), | ||
maxSize: getArrayLikeCodecSizeFromChildren(size, [item.maxSize]) | ||
}; | ||
function sumCodecSizes(sizes) { | ||
return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0); | ||
} | ||
function getFixedSize(codec) { | ||
return isFixedSize(codec) ? codec.fixedSize : null; | ||
} | ||
function getMaxSize(codec) { | ||
var _a; | ||
return isFixedSize(codec) ? codec.fixedSize : (_a = codec.maxSize) != null ? _a : null; | ||
} | ||
function getArrayEncoder(item, config = {}) { | ||
const size = config.size ?? getU32Encoder(); | ||
return { | ||
...arrayCodecHelper(item, size, config.description), | ||
encode: (value) => { | ||
var _a, _b; | ||
const size = (_a = config.size) != null ? _a : getU32Encoder(); | ||
if (size === "remainder") { | ||
assertIsFixedSize(item, 'Codecs of "remainder" size must have fixed-size items.'); | ||
} | ||
const fixedSize = computeArrayLikeCodecSize(size, getFixedSize(item)); | ||
const maxSize = (_b = computeArrayLikeCodecSize(size, getMaxSize(item))) != null ? _b : void 0; | ||
return createEncoder({ | ||
...fixedSize !== null ? { fixedSize } : { | ||
getSizeFromValue: (array) => { | ||
const prefixSize = typeof size === "object" ? getEncodedSize(array.length, size) : 0; | ||
return prefixSize + [...array].reduce((all, value) => all + getEncodedSize(value, item), 0); | ||
}, | ||
maxSize | ||
}, | ||
write: (array, bytes, offset) => { | ||
if (typeof size === "number") { | ||
assertValidNumberOfItemsForCodec("array", size, value.length); | ||
assertValidNumberOfItemsForCodec("array", size, array.length); | ||
} | ||
return mergeBytes([getArrayLikeCodecSizePrefix(size, value.length), ...value.map((v) => item.encode(v))]); | ||
if (typeof size === "object") { | ||
offset = size.write(array.length, bytes, offset); | ||
} | ||
array.forEach((value) => { | ||
offset = item.write(value, bytes, offset); | ||
}); | ||
return offset; | ||
} | ||
}; | ||
}); | ||
} | ||
function computeArrayLikeCodecSize(size, itemSize) { | ||
if (typeof size !== "number") | ||
return null; | ||
if (size === 0) | ||
return 0; | ||
return itemSize === null ? null : itemSize * size; | ||
} | ||
function getBytesEncoder(config = {}) { | ||
const size = config.size ?? "variable"; | ||
const sizeDescription = typeof size === "object" ? size.description : `${size}`; | ||
const description = config.description ?? `bytes(${sizeDescription})`; | ||
const byteEncoder = { | ||
description, | ||
encode: (value) => value, | ||
fixedSize: null, | ||
maxSize: null | ||
}; | ||
var _a; | ||
const size = (_a = config.size) != null ? _a : "variable"; | ||
const byteEncoder = createEncoder({ | ||
getSizeFromValue: (value) => value.length, | ||
write: (value, bytes, offset) => { | ||
bytes.set(value, offset); | ||
return offset + value.length; | ||
} | ||
}); | ||
if (size === "variable") { | ||
@@ -571,30 +628,32 @@ return byteEncoder; | ||
if (typeof size === "number") { | ||
return fixEncoder(byteEncoder, size, description); | ||
return fixEncoder(byteEncoder, size); | ||
} | ||
return { | ||
...byteEncoder, | ||
encode: (value) => { | ||
const contentBytes = byteEncoder.encode(value); | ||
const lengthBytes = size.encode(contentBytes.length); | ||
return mergeBytes([lengthBytes, contentBytes]); | ||
return createEncoder({ | ||
getSizeFromValue: (value) => getEncodedSize(value.length, size) + value.length, | ||
write: (value, bytes, offset) => { | ||
offset = size.write(value.length, bytes, offset); | ||
return byteEncoder.write(value, bytes, offset); | ||
} | ||
}; | ||
}); | ||
} | ||
function structCodecHelper(fields, description) { | ||
const fieldDescriptions = fields.map(([name, codec]) => `${String(name)}: ${codec.description}`).join(", "); | ||
return { | ||
description: description ?? `struct(${fieldDescriptions})`, | ||
fixedSize: sumCodecSizes(fields.map(([, field]) => field.fixedSize)), | ||
maxSize: sumCodecSizes(fields.map(([, field]) => field.maxSize)) | ||
}; | ||
} | ||
function getStructEncoder(fields, config = {}) { | ||
return { | ||
...structCodecHelper(fields, config.description), | ||
encode: (struct) => { | ||
const fieldBytes = fields.map(([key, codec]) => codec.encode(struct[key])); | ||
return mergeBytes(fieldBytes); | ||
function getStructEncoder(fields) { | ||
var _a; | ||
const fieldCodecs = fields.map(([, codec]) => codec); | ||
const fixedSize = sumCodecSizes(fieldCodecs.map(getFixedSize)); | ||
const maxSize = (_a = sumCodecSizes(fieldCodecs.map(getMaxSize))) != null ? _a : void 0; | ||
return createEncoder({ | ||
...fixedSize === null ? { | ||
getSizeFromValue: (value) => fields.map(([key, codec]) => getEncodedSize(value[key], codec)).reduce((all, one) => all + one, 0), | ||
maxSize | ||
} : { fixedSize }, | ||
write: (struct, bytes, offset) => { | ||
fields.forEach(([key, codec]) => { | ||
offset = codec.write(struct[key], bytes, offset); | ||
}); | ||
return offset; | ||
} | ||
}; | ||
}); | ||
} | ||
// ../transactions/dist/index.browser.js | ||
var AccountRole = /* @__PURE__ */ ((AccountRole2) => { | ||
@@ -612,3 +671,3 @@ AccountRole2[AccountRole2["WRITABLE_SIGNER"] = /* 3 */ | ||
var IS_WRITABLE_BITMASK = 1; | ||
function isSignerRole(role) { | ||
function isSignerRole2(role) { | ||
return role >= 2; | ||
@@ -623,3 +682,4 @@ } | ||
function upsert(addressMap, address2, update) { | ||
addressMap[address2] = update(addressMap[address2] ?? { role: AccountRole.READONLY }); | ||
var _a; | ||
addressMap[address2] = update((_a = addressMap[address2]) != null ? _a : { role: AccountRole.READONLY }); | ||
} | ||
@@ -687,3 +747,3 @@ var TYPE = Symbol("AddressMapTypeProperty"); | ||
} | ||
} else if (isSignerRole(accountMeta.role)) { | ||
} else if (isSignerRole2(accountMeta.role)) { | ||
return { | ||
@@ -725,3 +785,3 @@ [TYPE]: 2, | ||
// long as they are not require to sign the transaction. | ||
!isSignerRole(entry.role)) { | ||
!isSignerRole2(entry.role)) { | ||
return { | ||
@@ -777,4 +837,4 @@ ...accountMeta, | ||
} | ||
const leftIsSigner = isSignerRole(leftEntry.role); | ||
if (leftIsSigner !== isSignerRole(rightEntry.role)) { | ||
const leftIsSigner = isSignerRole2(leftEntry.role); | ||
if (leftIsSigner !== isSignerRole2(rightEntry.role)) { | ||
return leftIsSigner ? -1 : 1; | ||
@@ -829,3 +889,3 @@ } | ||
const accountIsWritable = isWritableRole(account.role); | ||
if (isSignerRole(account.role)) { | ||
if (isSignerRole2(account.role)) { | ||
numSignerAccounts++; | ||
@@ -885,29 +945,16 @@ if (!accountIsWritable) { | ||
} | ||
var lookupTableAddressDescription = "The address of the address lookup table account from which instruction addresses should be looked up" ; | ||
var writableIndicesDescription = "The indices of the accounts in the lookup table that should be loaded as writeable" ; | ||
var readableIndicesDescription = "The indices of the accounts in the lookup table that should be loaded as read-only" ; | ||
var addressTableLookupDescription = "A pointer to the address of an address lookup table, along with the readonly/writeable indices of the addresses that should be loaded from it" ; | ||
var memoizedAddressTableLookupEncoder; | ||
function getAddressTableLookupEncoder() { | ||
if (!memoizedAddressTableLookupEncoder) { | ||
memoizedAddressTableLookupEncoder = getStructEncoder( | ||
memoizedAddressTableLookupEncoder = getStructEncoder([ | ||
["lookupTableAddress", getAddressEncoder()], | ||
[ | ||
["lookupTableAddress", getAddressEncoder({ description: lookupTableAddressDescription })], | ||
[ | ||
"writableIndices", | ||
getArrayEncoder(getU8Encoder(), { | ||
description: writableIndicesDescription, | ||
size: getShortU16Encoder() | ||
}) | ||
], | ||
[ | ||
"readableIndices", | ||
getArrayEncoder(getU8Encoder(), { | ||
description: readableIndicesDescription, | ||
size: getShortU16Encoder() | ||
}) | ||
] | ||
"writableIndices", | ||
getArrayEncoder(getU8Encoder(), { size: getShortU16Encoder() }) | ||
], | ||
{ description: addressTableLookupDescription } | ||
); | ||
[ | ||
"readableIndices", | ||
getArrayEncoder(getU8Encoder(), { size: getShortU16Encoder() }) | ||
] | ||
]); | ||
} | ||
@@ -922,29 +969,9 @@ return memoizedAddressTableLookupEncoder; | ||
} | ||
function getMemoizedU8EncoderDescription(description) { | ||
const encoder = getMemoizedU8Encoder(); | ||
return { | ||
...encoder, | ||
description: description ?? encoder.description | ||
}; | ||
} | ||
var numSignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction" ; | ||
var numReadonlySignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction, but may not be writable" ; | ||
var numReadonlyNonSignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable" ; | ||
var messageHeaderDescription = "The transaction message header containing counts of the signer, readonly-signer, and readonly-nonsigner account addresses" ; | ||
function getMessageHeaderEncoder() { | ||
return getStructEncoder( | ||
[ | ||
["numSignerAccounts", getMemoizedU8EncoderDescription(numSignerAccountsDescription)], | ||
["numReadonlySignerAccounts", getMemoizedU8EncoderDescription(numReadonlySignerAccountsDescription)], | ||
["numReadonlyNonSignerAccounts", getMemoizedU8EncoderDescription(numReadonlyNonSignerAccountsDescription)] | ||
], | ||
{ | ||
description: messageHeaderDescription | ||
} | ||
); | ||
return getStructEncoder([ | ||
["numSignerAccounts", getMemoizedU8Encoder()], | ||
["numReadonlySignerAccounts", getMemoizedU8Encoder()], | ||
["numReadonlyNonSignerAccounts", getMemoizedU8Encoder()] | ||
]); | ||
} | ||
var programAddressIndexDescription = "The index of the program being called, according to the well-ordered accounts list for this transaction" ; | ||
var accountIndexDescription = "The index of an account, according to the well-ordered accounts list for this transaction" ; | ||
var accountIndicesDescription = "An optional list of account indices, according to the well-ordered accounts list for this transaction, in the order in which the program being called expects them" ; | ||
var dataDescription = "An optional buffer of data passed to the instruction" ; | ||
var memoizedGetInstructionEncoder; | ||
@@ -955,14 +982,9 @@ function getInstructionEncoder() { | ||
getStructEncoder([ | ||
["programAddressIndex", getU8Encoder({ description: programAddressIndexDescription })], | ||
[ | ||
"accountIndices", | ||
getArrayEncoder(getU8Encoder({ description: accountIndexDescription }), { | ||
description: accountIndicesDescription, | ||
size: getShortU16Encoder() | ||
}) | ||
], | ||
["data", getBytesEncoder({ description: dataDescription, size: getShortU16Encoder() })] | ||
["programAddressIndex", getU8Encoder()], | ||
["accountIndices", getArrayEncoder(getU8Encoder(), { size: getShortU16Encoder() })], | ||
["data", getBytesEncoder({ size: getShortU16Encoder() })] | ||
]), | ||
// Convert an instruction to have all fields defined | ||
(instruction) => { | ||
var _a, _b; | ||
if (instruction.accountIndices !== void 0 && instruction.data !== void 0) { | ||
@@ -973,4 +995,4 @@ return instruction; | ||
...instruction, | ||
accountIndices: instruction.accountIndices ?? [], | ||
data: instruction.data ?? new Uint8Array(0) | ||
accountIndices: (_a = instruction.accountIndices) != null ? _a : [], | ||
data: (_b = instruction.data) != null ? _b : new Uint8Array(0) | ||
}; | ||
@@ -983,26 +1005,18 @@ } | ||
var VERSION_FLAG_MASK = 128; | ||
var BASE_CONFIG = { | ||
description: "A single byte that encodes the version of the transaction" , | ||
fixedSize: null, | ||
maxSize: 1 | ||
}; | ||
function encode(value) { | ||
if (value === "legacy") { | ||
return new Uint8Array(); | ||
} | ||
if (value < 0 || value > 127) { | ||
throw new Error(`Transaction version must be in the range [0, 127]. \`${value}\` given.`); | ||
} | ||
return new Uint8Array([value | VERSION_FLAG_MASK]); | ||
} | ||
function getTransactionVersionEncoder() { | ||
return { | ||
...BASE_CONFIG, | ||
encode | ||
}; | ||
return createEncoder({ | ||
getSizeFromValue: (value) => value === "legacy" ? 0 : 1, | ||
maxSize: 1, | ||
write: (value, bytes, offset) => { | ||
if (value === "legacy") { | ||
return offset; | ||
} | ||
if (value < 0 || value > 127) { | ||
throw new Error(`Transaction version must be in the range [0, 127]. \`${value}\` given.`); | ||
} | ||
bytes.set([value | VERSION_FLAG_MASK], offset); | ||
return offset + 1; | ||
} | ||
}); | ||
} | ||
var staticAccountsDescription = "A compact-array of static account addresses belonging to this transaction" ; | ||
var lifetimeTokenDescription = "A 32-byte token that specifies the lifetime of this transaction (eg. a recent blockhash, or a durable nonce)" ; | ||
var instructionsDescription = "A compact-array of instructions belonging to this transaction" ; | ||
var addressTableLookupsDescription = "A compact array of address table lookups belonging to this transaction" ; | ||
function getCompiledMessageLegacyEncoder() { | ||
@@ -1018,2 +1032,3 @@ return getStructEncoder(getPreludeStructEncoderTuple()); | ||
(value) => { | ||
var _a; | ||
if (value.version === "legacy") { | ||
@@ -1024,3 +1039,3 @@ return value; | ||
...value, | ||
addressTableLookups: value.addressTableLookups ?? [] | ||
addressTableLookups: (_a = value.addressTableLookups) != null ? _a : [] | ||
}; | ||
@@ -1034,46 +1049,27 @@ } | ||
["header", getMessageHeaderEncoder()], | ||
[ | ||
"staticAccounts", | ||
getArrayEncoder(getAddressEncoder(), { | ||
description: staticAccountsDescription, | ||
size: getShortU16Encoder() | ||
}) | ||
], | ||
[ | ||
"lifetimeToken", | ||
getStringEncoder({ | ||
description: lifetimeTokenDescription, | ||
encoding: getBase58Encoder(), | ||
size: 32 | ||
}) | ||
], | ||
[ | ||
"instructions", | ||
getArrayEncoder(getInstructionEncoder(), { | ||
description: instructionsDescription, | ||
size: getShortU16Encoder() | ||
}) | ||
] | ||
["staticAccounts", getArrayEncoder(getAddressEncoder(), { size: getShortU16Encoder() })], | ||
["lifetimeToken", getStringEncoder({ encoding: getBase58Encoder(), size: 32 })], | ||
["instructions", getArrayEncoder(getInstructionEncoder(), { size: getShortU16Encoder() })] | ||
]; | ||
} | ||
function getAddressTableLookupArrayEncoder() { | ||
return getArrayEncoder(getAddressTableLookupEncoder(), { | ||
description: addressTableLookupsDescription, | ||
size: getShortU16Encoder() | ||
}); | ||
return getArrayEncoder(getAddressTableLookupEncoder(), { size: getShortU16Encoder() }); | ||
} | ||
var messageDescription = "The wire format of a Solana transaction message" ; | ||
function getCompiledMessageEncoder() { | ||
return { | ||
description: messageDescription, | ||
encode: (compiledMessage) => { | ||
return createEncoder({ | ||
getSizeFromValue: (compiledMessage) => { | ||
if (compiledMessage.version === "legacy") { | ||
return getCompiledMessageLegacyEncoder().encode(compiledMessage); | ||
return getCompiledMessageLegacyEncoder().getSizeFromValue(compiledMessage); | ||
} else { | ||
return getCompiledMessageVersionedEncoder().encode(compiledMessage); | ||
return getCompiledMessageVersionedEncoder().getSizeFromValue(compiledMessage); | ||
} | ||
}, | ||
fixedSize: null, | ||
maxSize: null | ||
}; | ||
write: (compiledMessage, bytes, offset) => { | ||
if (compiledMessage.version === "legacy") { | ||
return getCompiledMessageLegacyEncoder().write(compiledMessage, bytes, offset); | ||
} else { | ||
return getCompiledMessageVersionedEncoder().write(compiledMessage, bytes, offset); | ||
} | ||
} | ||
}); | ||
} | ||
@@ -1099,2 +1095,14 @@ async function partiallySignTransaction(keyPairs, transaction) { | ||
} | ||
function assertTransactionIsFullySigned(transaction) { | ||
const signerAddressesFromInstructions = transaction.instructions.flatMap((i) => { | ||
var _a, _b; | ||
return (_b = (_a = i.accounts) == null ? void 0 : _a.filter((a) => isSignerRole2(a.role))) != null ? _b : []; | ||
}).map((a) => a.address); | ||
const requiredSigners = /* @__PURE__ */ new Set([transaction.feePayer, ...signerAddressesFromInstructions]); | ||
requiredSigners.forEach((address2) => { | ||
if (!transaction.signatures[address2]) { | ||
throw new Error(`Transaction is missing signature for address \`${address2}\``); | ||
} | ||
}); | ||
} | ||
@@ -1172,10 +1180,11 @@ // src/message-partial-signer.ts | ||
} | ||
var o2 = globalThis.TextEncoder; | ||
// src/signable-message.ts | ||
function createSignableMessage(content, signatures = {}) { | ||
return Object.freeze({ | ||
content: typeof content === "string" ? new o2().encode(content) : content, | ||
signatures: Object.freeze({ ...signatures }) | ||
}); | ||
// src/noop-signer.ts | ||
function createNoopSigner(address2) { | ||
const out = { | ||
address: address2, | ||
signMessages: async (messages) => messages.map(() => Object.freeze({})), | ||
signTransactions: async (transactions) => transactions.map(() => Object.freeze({})) | ||
}; | ||
return Object.freeze(out); | ||
} | ||
@@ -1213,2 +1222,135 @@ | ||
// src/sign-transaction.ts | ||
async function partiallySignTransactionWithSigners(transaction, config = {}) { | ||
const { partialSigners, modifyingSigners } = categorizeTransactionSigners( | ||
deduplicateSigners(getSignersFromTransaction(transaction).filter(isTransactionSigner)), | ||
{ identifySendingSigner: false } | ||
); | ||
return signModifyingAndPartialTransactionSigners(transaction, modifyingSigners, partialSigners, config.abortSignal); | ||
} | ||
async function signTransactionWithSigners(transaction, config = {}) { | ||
const signedTransaction = await partiallySignTransactionWithSigners(transaction, config); | ||
assertTransactionIsFullySigned(signedTransaction); | ||
return signedTransaction; | ||
} | ||
async function signAndSendTransactionWithSigners(transaction, config = {}) { | ||
const abortSignal = config.abortSignal; | ||
const { partialSigners, modifyingSigners, sendingSigner } = categorizeTransactionSigners( | ||
deduplicateSigners(getSignersFromTransaction(transaction).filter(isTransactionSigner)) | ||
); | ||
abortSignal == null ? void 0 : abortSignal.throwIfAborted(); | ||
const signedTransaction = await signModifyingAndPartialTransactionSigners( | ||
transaction, | ||
modifyingSigners, | ||
partialSigners, | ||
abortSignal | ||
); | ||
if (!sendingSigner) { | ||
throw new Error( | ||
"No `TransactionSendingSigner` was identified. Please provide a valid `ITransactionWithSingleSendingSigner` transaction." | ||
); | ||
} | ||
abortSignal == null ? void 0 : abortSignal.throwIfAborted(); | ||
const [signature] = await sendingSigner.signAndSendTransactions([signedTransaction], { abortSignal }); | ||
abortSignal == null ? void 0 : abortSignal.throwIfAborted(); | ||
return signature; | ||
} | ||
function categorizeTransactionSigners(signers, config = {}) { | ||
var _a; | ||
const identifySendingSigner = (_a = config.identifySendingSigner) != null ? _a : true; | ||
const sendingSigner = identifySendingSigner ? identifyTransactionSendingSigner(signers) : null; | ||
const otherSigners = signers.filter( | ||
(signer) => signer !== sendingSigner && (isTransactionModifyingSigner(signer) || isTransactionPartialSigner(signer)) | ||
); | ||
const modifyingSigners = identifyTransactionModifyingSigners(otherSigners); | ||
const partialSigners = otherSigners.filter(isTransactionPartialSigner).filter((signer) => !modifyingSigners.includes(signer)); | ||
return Object.freeze({ modifyingSigners, partialSigners, sendingSigner }); | ||
} | ||
function identifyTransactionSendingSigner(signers) { | ||
const sendingSigners = signers.filter(isTransactionSendingSigner); | ||
if (sendingSigners.length === 0) | ||
return null; | ||
const sendingOnlySigners = sendingSigners.filter( | ||
(signer) => !isTransactionModifyingSigner(signer) && !isTransactionPartialSigner(signer) | ||
); | ||
if (sendingOnlySigners.length > 0) { | ||
return sendingOnlySigners[0]; | ||
} | ||
return sendingSigners[0]; | ||
} | ||
function identifyTransactionModifyingSigners(signers) { | ||
const modifyingSigners = signers.filter(isTransactionModifyingSigner); | ||
if (modifyingSigners.length === 0) | ||
return []; | ||
const nonPartialSigners = modifyingSigners.filter((signer) => !isTransactionPartialSigner(signer)); | ||
if (nonPartialSigners.length > 0) | ||
return nonPartialSigners; | ||
return [modifyingSigners[0]]; | ||
} | ||
async function signModifyingAndPartialTransactionSigners(transaction, modifyingSigners = [], partialSigners = [], abortSignal) { | ||
var _a; | ||
const modifiedTransaction = await modifyingSigners.reduce( | ||
async (transaction2, modifyingSigner) => { | ||
abortSignal == null ? void 0 : abortSignal.throwIfAborted(); | ||
const [tx] = await modifyingSigner.modifyAndSignTransactions([await transaction2], { abortSignal }); | ||
return Object.freeze(tx); | ||
}, | ||
Promise.resolve(transaction) | ||
); | ||
abortSignal == null ? void 0 : abortSignal.throwIfAborted(); | ||
const signatureDictionaries = await Promise.all( | ||
partialSigners.map(async (partialSigner) => { | ||
const [signatures] = await partialSigner.signTransactions([modifiedTransaction], { abortSignal }); | ||
return signatures; | ||
}) | ||
); | ||
const signedTransaction = { | ||
...modifiedTransaction, | ||
signatures: Object.freeze( | ||
signatureDictionaries.reduce((signatures, signatureDictionary) => { | ||
return { ...signatures, ...signatureDictionary }; | ||
}, (_a = modifiedTransaction.signatures) != null ? _a : {}) | ||
) | ||
}; | ||
return Object.freeze(signedTransaction); | ||
} | ||
var o2 = globalThis.TextEncoder; | ||
// src/signable-message.ts | ||
function createSignableMessage(content, signatures = {}) { | ||
return Object.freeze({ | ||
content: typeof content === "string" ? new o2().encode(content) : content, | ||
signatures: Object.freeze({ ...signatures }) | ||
}); | ||
} | ||
// src/transaction-with-single-sending-signer.ts | ||
function isTransactionWithSingleSendingSigner(transaction) { | ||
try { | ||
assertIsTransactionWithSingleSendingSigner(transaction); | ||
return true; | ||
} catch { | ||
return false; | ||
} | ||
} | ||
function assertIsTransactionWithSingleSendingSigner(transaction) { | ||
const signers = getSignersFromTransaction(transaction); | ||
const sendingSigners = signers.filter(isTransactionSendingSigner); | ||
if (sendingSigners.length === 0) { | ||
const error = new Error("No `TransactionSendingSigner` was identified."); | ||
error.name = "MissingTransactionSendingSignerError"; | ||
throw error; | ||
} | ||
const sendingOnlySigners = sendingSigners.filter( | ||
(signer) => !isTransactionPartialSigner(signer) && !isTransactionModifyingSigner(signer) | ||
); | ||
if (sendingOnlySigners.length > 1) { | ||
const error = new Error("More than one `TransactionSendingSigner` was identified."); | ||
error.name = "MultipleTransactionSendingSignersError"; | ||
throw error; | ||
} | ||
} | ||
exports.addSignersToInstruction = addSignersToInstruction; | ||
exports.addSignersToTransaction = addSignersToTransaction; | ||
exports.assertIsKeyPairSigner = assertIsKeyPairSigner; | ||
@@ -1222,5 +1364,9 @@ exports.assertIsMessageModifyingSigner = assertIsMessageModifyingSigner; | ||
exports.assertIsTransactionSigner = assertIsTransactionSigner; | ||
exports.assertIsTransactionWithSingleSendingSigner = assertIsTransactionWithSingleSendingSigner; | ||
exports.createNoopSigner = createNoopSigner; | ||
exports.createSignableMessage = createSignableMessage; | ||
exports.createSignerFromKeyPair = createSignerFromKeyPair; | ||
exports.generateKeyPairSigner = generateKeyPairSigner; | ||
exports.getSignersFromInstruction = getSignersFromInstruction; | ||
exports.getSignersFromTransaction = getSignersFromTransaction; | ||
exports.isKeyPairSigner = isKeyPairSigner; | ||
@@ -1234,2 +1380,6 @@ exports.isMessageModifyingSigner = isMessageModifyingSigner; | ||
exports.isTransactionSigner = isTransactionSigner; | ||
exports.isTransactionWithSingleSendingSigner = isTransactionWithSingleSendingSigner; | ||
exports.partiallySignTransactionWithSigners = partiallySignTransactionWithSigners; | ||
exports.signAndSendTransactionWithSigners = signAndSendTransactionWithSigners; | ||
exports.signTransactionWithSigners = signTransactionWithSigners; | ||
@@ -1236,0 +1386,0 @@ return exports; |
@@ -0,7 +1,56 @@ | ||
import { isSignerRole } from '@solana/instructions'; | ||
import { getAddressFromPublicKey, isAddress } from '@solana/addresses'; | ||
import { generateKeyPair, signBytes } from '@solana/keys'; | ||
import { partiallySignTransaction } from '@solana/transactions'; | ||
import { assertTransactionIsFullySigned, partiallySignTransaction } from '@solana/transactions'; | ||
// src/keypair-signer.ts | ||
// src/deduplicate-signers.ts | ||
function deduplicateSigners(signers) { | ||
const deduplicated = {}; | ||
signers.forEach((signer) => { | ||
if (!deduplicated[signer.address]) { | ||
deduplicated[signer.address] = signer; | ||
} 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.` | ||
); | ||
} | ||
}); | ||
return Object.values(deduplicated); | ||
} | ||
// src/account-signer-meta.ts | ||
function getSignersFromInstruction(instruction) { | ||
return deduplicateSigners( | ||
(instruction.accounts ?? []).flatMap((account) => "signer" in account ? account.signer : []) | ||
); | ||
} | ||
function getSignersFromTransaction(transaction) { | ||
return deduplicateSigners(transaction.instructions.flatMap(getSignersFromInstruction)); | ||
} | ||
function addSignersToInstruction(signers, instruction) { | ||
if (!instruction.accounts || instruction.accounts.length === 0) { | ||
return instruction; | ||
} | ||
const signerByAddress = new Map(deduplicateSigners(signers).map((signer) => [signer.address, signer])); | ||
return Object.freeze({ | ||
...instruction, | ||
accounts: instruction.accounts.map((account) => { | ||
const signer = signerByAddress.get(account.address); | ||
if (!isSignerRole(account.role) || "signer" in account || !signer) { | ||
return account; | ||
} | ||
return Object.freeze({ ...account, signer }); | ||
}) | ||
}); | ||
} | ||
function addSignersToTransaction(signers, transaction) { | ||
if (transaction.instructions.length === 0) { | ||
return transaction; | ||
} | ||
return Object.freeze({ | ||
...transaction, | ||
instructions: transaction.instructions.map((instruction) => addSignersToInstruction(signers, instruction)) | ||
}); | ||
} | ||
// src/message-partial-signer.ts | ||
@@ -76,10 +125,11 @@ function isMessagePartialSigner(value) { | ||
} | ||
var o = globalThis.TextEncoder; | ||
// src/signable-message.ts | ||
function createSignableMessage(content, signatures = {}) { | ||
return Object.freeze({ | ||
content: typeof content === "string" ? new o().encode(content) : content, | ||
signatures: Object.freeze({ ...signatures }) | ||
}); | ||
// src/noop-signer.ts | ||
function createNoopSigner(address) { | ||
const out = { | ||
address, | ||
signMessages: async (messages) => messages.map(() => Object.freeze({})), | ||
signTransactions: async (transactions) => transactions.map(() => Object.freeze({})) | ||
}; | ||
return Object.freeze(out); | ||
} | ||
@@ -117,4 +167,133 @@ | ||
export { assertIsKeyPairSigner, assertIsMessageModifyingSigner, assertIsMessagePartialSigner, assertIsMessageSigner, assertIsTransactionModifyingSigner, assertIsTransactionPartialSigner, assertIsTransactionSendingSigner, assertIsTransactionSigner, createSignableMessage, createSignerFromKeyPair, generateKeyPairSigner, isKeyPairSigner, isMessageModifyingSigner, isMessagePartialSigner, isMessageSigner, isTransactionModifyingSigner, isTransactionPartialSigner, isTransactionSendingSigner, isTransactionSigner }; | ||
// src/sign-transaction.ts | ||
async function partiallySignTransactionWithSigners(transaction, config = {}) { | ||
const { partialSigners, modifyingSigners } = categorizeTransactionSigners( | ||
deduplicateSigners(getSignersFromTransaction(transaction).filter(isTransactionSigner)), | ||
{ identifySendingSigner: false } | ||
); | ||
return signModifyingAndPartialTransactionSigners(transaction, modifyingSigners, partialSigners, config.abortSignal); | ||
} | ||
async function signTransactionWithSigners(transaction, config = {}) { | ||
const signedTransaction = await partiallySignTransactionWithSigners(transaction, config); | ||
assertTransactionIsFullySigned(signedTransaction); | ||
return signedTransaction; | ||
} | ||
async function signAndSendTransactionWithSigners(transaction, config = {}) { | ||
const abortSignal = config.abortSignal; | ||
const { partialSigners, modifyingSigners, sendingSigner } = categorizeTransactionSigners( | ||
deduplicateSigners(getSignersFromTransaction(transaction).filter(isTransactionSigner)) | ||
); | ||
abortSignal?.throwIfAborted(); | ||
const signedTransaction = await signModifyingAndPartialTransactionSigners( | ||
transaction, | ||
modifyingSigners, | ||
partialSigners, | ||
abortSignal | ||
); | ||
if (!sendingSigner) { | ||
throw new Error( | ||
"No `TransactionSendingSigner` was identified. Please provide a valid `ITransactionWithSingleSendingSigner` transaction." | ||
); | ||
} | ||
abortSignal?.throwIfAborted(); | ||
const [signature] = await sendingSigner.signAndSendTransactions([signedTransaction], { abortSignal }); | ||
abortSignal?.throwIfAborted(); | ||
return signature; | ||
} | ||
function categorizeTransactionSigners(signers, config = {}) { | ||
const identifySendingSigner = config.identifySendingSigner ?? true; | ||
const sendingSigner = identifySendingSigner ? identifyTransactionSendingSigner(signers) : null; | ||
const otherSigners = signers.filter( | ||
(signer) => signer !== sendingSigner && (isTransactionModifyingSigner(signer) || isTransactionPartialSigner(signer)) | ||
); | ||
const modifyingSigners = identifyTransactionModifyingSigners(otherSigners); | ||
const partialSigners = otherSigners.filter(isTransactionPartialSigner).filter((signer) => !modifyingSigners.includes(signer)); | ||
return Object.freeze({ modifyingSigners, partialSigners, sendingSigner }); | ||
} | ||
function identifyTransactionSendingSigner(signers) { | ||
const sendingSigners = signers.filter(isTransactionSendingSigner); | ||
if (sendingSigners.length === 0) | ||
return null; | ||
const sendingOnlySigners = sendingSigners.filter( | ||
(signer) => !isTransactionModifyingSigner(signer) && !isTransactionPartialSigner(signer) | ||
); | ||
if (sendingOnlySigners.length > 0) { | ||
return sendingOnlySigners[0]; | ||
} | ||
return sendingSigners[0]; | ||
} | ||
function identifyTransactionModifyingSigners(signers) { | ||
const modifyingSigners = signers.filter(isTransactionModifyingSigner); | ||
if (modifyingSigners.length === 0) | ||
return []; | ||
const nonPartialSigners = modifyingSigners.filter((signer) => !isTransactionPartialSigner(signer)); | ||
if (nonPartialSigners.length > 0) | ||
return nonPartialSigners; | ||
return [modifyingSigners[0]]; | ||
} | ||
async function signModifyingAndPartialTransactionSigners(transaction, modifyingSigners = [], partialSigners = [], abortSignal) { | ||
const modifiedTransaction = await modifyingSigners.reduce( | ||
async (transaction2, modifyingSigner) => { | ||
abortSignal?.throwIfAborted(); | ||
const [tx] = await modifyingSigner.modifyAndSignTransactions([await transaction2], { abortSignal }); | ||
return Object.freeze(tx); | ||
}, | ||
Promise.resolve(transaction) | ||
); | ||
abortSignal?.throwIfAborted(); | ||
const signatureDictionaries = await Promise.all( | ||
partialSigners.map(async (partialSigner) => { | ||
const [signatures] = await partialSigner.signTransactions([modifiedTransaction], { abortSignal }); | ||
return signatures; | ||
}) | ||
); | ||
const signedTransaction = { | ||
...modifiedTransaction, | ||
signatures: Object.freeze( | ||
signatureDictionaries.reduce((signatures, signatureDictionary) => { | ||
return { ...signatures, ...signatureDictionary }; | ||
}, modifiedTransaction.signatures ?? {}) | ||
) | ||
}; | ||
return Object.freeze(signedTransaction); | ||
} | ||
var o = globalThis.TextEncoder; | ||
// src/signable-message.ts | ||
function createSignableMessage(content, signatures = {}) { | ||
return Object.freeze({ | ||
content: typeof content === "string" ? new o().encode(content) : content, | ||
signatures: Object.freeze({ ...signatures }) | ||
}); | ||
} | ||
// src/transaction-with-single-sending-signer.ts | ||
function isTransactionWithSingleSendingSigner(transaction) { | ||
try { | ||
assertIsTransactionWithSingleSendingSigner(transaction); | ||
return true; | ||
} catch { | ||
return false; | ||
} | ||
} | ||
function assertIsTransactionWithSingleSendingSigner(transaction) { | ||
const signers = getSignersFromTransaction(transaction); | ||
const sendingSigners = signers.filter(isTransactionSendingSigner); | ||
if (sendingSigners.length === 0) { | ||
const error = new Error("No `TransactionSendingSigner` was identified."); | ||
error.name = "MissingTransactionSendingSignerError"; | ||
throw error; | ||
} | ||
const sendingOnlySigners = sendingSigners.filter( | ||
(signer) => !isTransactionPartialSigner(signer) && !isTransactionModifyingSigner(signer) | ||
); | ||
if (sendingOnlySigners.length > 1) { | ||
const error = new Error("More than one `TransactionSendingSigner` was identified."); | ||
error.name = "MultipleTransactionSendingSignersError"; | ||
throw error; | ||
} | ||
} | ||
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 }; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.native.js.map |
@@ -0,7 +1,56 @@ | ||
import { isSignerRole } from '@solana/instructions'; | ||
import { getAddressFromPublicKey, isAddress } from '@solana/addresses'; | ||
import { generateKeyPair, signBytes } from '@solana/keys'; | ||
import { partiallySignTransaction } from '@solana/transactions'; | ||
import { assertTransactionIsFullySigned, partiallySignTransaction } from '@solana/transactions'; | ||
// src/keypair-signer.ts | ||
// src/deduplicate-signers.ts | ||
function deduplicateSigners(signers) { | ||
const deduplicated = {}; | ||
signers.forEach((signer) => { | ||
if (!deduplicated[signer.address]) { | ||
deduplicated[signer.address] = signer; | ||
} 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.` | ||
); | ||
} | ||
}); | ||
return Object.values(deduplicated); | ||
} | ||
// src/account-signer-meta.ts | ||
function getSignersFromInstruction(instruction) { | ||
return deduplicateSigners( | ||
(instruction.accounts ?? []).flatMap((account) => "signer" in account ? account.signer : []) | ||
); | ||
} | ||
function getSignersFromTransaction(transaction) { | ||
return deduplicateSigners(transaction.instructions.flatMap(getSignersFromInstruction)); | ||
} | ||
function addSignersToInstruction(signers, instruction) { | ||
if (!instruction.accounts || instruction.accounts.length === 0) { | ||
return instruction; | ||
} | ||
const signerByAddress = new Map(deduplicateSigners(signers).map((signer) => [signer.address, signer])); | ||
return Object.freeze({ | ||
...instruction, | ||
accounts: instruction.accounts.map((account) => { | ||
const signer = signerByAddress.get(account.address); | ||
if (!isSignerRole(account.role) || "signer" in account || !signer) { | ||
return account; | ||
} | ||
return Object.freeze({ ...account, signer }); | ||
}) | ||
}); | ||
} | ||
function addSignersToTransaction(signers, transaction) { | ||
if (transaction.instructions.length === 0) { | ||
return transaction; | ||
} | ||
return Object.freeze({ | ||
...transaction, | ||
instructions: transaction.instructions.map((instruction) => addSignersToInstruction(signers, instruction)) | ||
}); | ||
} | ||
// src/message-partial-signer.ts | ||
@@ -76,10 +125,11 @@ function isMessagePartialSigner(value) { | ||
} | ||
var o = globalThis.TextEncoder; | ||
// src/signable-message.ts | ||
function createSignableMessage(content, signatures = {}) { | ||
return Object.freeze({ | ||
content: typeof content === "string" ? new o().encode(content) : content, | ||
signatures: Object.freeze({ ...signatures }) | ||
}); | ||
// src/noop-signer.ts | ||
function createNoopSigner(address) { | ||
const out = { | ||
address, | ||
signMessages: async (messages) => messages.map(() => Object.freeze({})), | ||
signTransactions: async (transactions) => transactions.map(() => Object.freeze({})) | ||
}; | ||
return Object.freeze(out); | ||
} | ||
@@ -117,4 +167,133 @@ | ||
export { assertIsKeyPairSigner, assertIsMessageModifyingSigner, assertIsMessagePartialSigner, assertIsMessageSigner, assertIsTransactionModifyingSigner, assertIsTransactionPartialSigner, assertIsTransactionSendingSigner, assertIsTransactionSigner, createSignableMessage, createSignerFromKeyPair, generateKeyPairSigner, isKeyPairSigner, isMessageModifyingSigner, isMessagePartialSigner, isMessageSigner, isTransactionModifyingSigner, isTransactionPartialSigner, isTransactionSendingSigner, isTransactionSigner }; | ||
// src/sign-transaction.ts | ||
async function partiallySignTransactionWithSigners(transaction, config = {}) { | ||
const { partialSigners, modifyingSigners } = categorizeTransactionSigners( | ||
deduplicateSigners(getSignersFromTransaction(transaction).filter(isTransactionSigner)), | ||
{ identifySendingSigner: false } | ||
); | ||
return signModifyingAndPartialTransactionSigners(transaction, modifyingSigners, partialSigners, config.abortSignal); | ||
} | ||
async function signTransactionWithSigners(transaction, config = {}) { | ||
const signedTransaction = await partiallySignTransactionWithSigners(transaction, config); | ||
assertTransactionIsFullySigned(signedTransaction); | ||
return signedTransaction; | ||
} | ||
async function signAndSendTransactionWithSigners(transaction, config = {}) { | ||
const abortSignal = config.abortSignal; | ||
const { partialSigners, modifyingSigners, sendingSigner } = categorizeTransactionSigners( | ||
deduplicateSigners(getSignersFromTransaction(transaction).filter(isTransactionSigner)) | ||
); | ||
abortSignal?.throwIfAborted(); | ||
const signedTransaction = await signModifyingAndPartialTransactionSigners( | ||
transaction, | ||
modifyingSigners, | ||
partialSigners, | ||
abortSignal | ||
); | ||
if (!sendingSigner) { | ||
throw new Error( | ||
"No `TransactionSendingSigner` was identified. Please provide a valid `ITransactionWithSingleSendingSigner` transaction." | ||
); | ||
} | ||
abortSignal?.throwIfAborted(); | ||
const [signature] = await sendingSigner.signAndSendTransactions([signedTransaction], { abortSignal }); | ||
abortSignal?.throwIfAborted(); | ||
return signature; | ||
} | ||
function categorizeTransactionSigners(signers, config = {}) { | ||
const identifySendingSigner = config.identifySendingSigner ?? true; | ||
const sendingSigner = identifySendingSigner ? identifyTransactionSendingSigner(signers) : null; | ||
const otherSigners = signers.filter( | ||
(signer) => signer !== sendingSigner && (isTransactionModifyingSigner(signer) || isTransactionPartialSigner(signer)) | ||
); | ||
const modifyingSigners = identifyTransactionModifyingSigners(otherSigners); | ||
const partialSigners = otherSigners.filter(isTransactionPartialSigner).filter((signer) => !modifyingSigners.includes(signer)); | ||
return Object.freeze({ modifyingSigners, partialSigners, sendingSigner }); | ||
} | ||
function identifyTransactionSendingSigner(signers) { | ||
const sendingSigners = signers.filter(isTransactionSendingSigner); | ||
if (sendingSigners.length === 0) | ||
return null; | ||
const sendingOnlySigners = sendingSigners.filter( | ||
(signer) => !isTransactionModifyingSigner(signer) && !isTransactionPartialSigner(signer) | ||
); | ||
if (sendingOnlySigners.length > 0) { | ||
return sendingOnlySigners[0]; | ||
} | ||
return sendingSigners[0]; | ||
} | ||
function identifyTransactionModifyingSigners(signers) { | ||
const modifyingSigners = signers.filter(isTransactionModifyingSigner); | ||
if (modifyingSigners.length === 0) | ||
return []; | ||
const nonPartialSigners = modifyingSigners.filter((signer) => !isTransactionPartialSigner(signer)); | ||
if (nonPartialSigners.length > 0) | ||
return nonPartialSigners; | ||
return [modifyingSigners[0]]; | ||
} | ||
async function signModifyingAndPartialTransactionSigners(transaction, modifyingSigners = [], partialSigners = [], abortSignal) { | ||
const modifiedTransaction = await modifyingSigners.reduce( | ||
async (transaction2, modifyingSigner) => { | ||
abortSignal?.throwIfAborted(); | ||
const [tx] = await modifyingSigner.modifyAndSignTransactions([await transaction2], { abortSignal }); | ||
return Object.freeze(tx); | ||
}, | ||
Promise.resolve(transaction) | ||
); | ||
abortSignal?.throwIfAborted(); | ||
const signatureDictionaries = await Promise.all( | ||
partialSigners.map(async (partialSigner) => { | ||
const [signatures] = await partialSigner.signTransactions([modifiedTransaction], { abortSignal }); | ||
return signatures; | ||
}) | ||
); | ||
const signedTransaction = { | ||
...modifiedTransaction, | ||
signatures: Object.freeze( | ||
signatureDictionaries.reduce((signatures, signatureDictionary) => { | ||
return { ...signatures, ...signatureDictionary }; | ||
}, modifiedTransaction.signatures ?? {}) | ||
) | ||
}; | ||
return Object.freeze(signedTransaction); | ||
} | ||
var o = globalThis.TextEncoder; | ||
// src/signable-message.ts | ||
function createSignableMessage(content, signatures = {}) { | ||
return Object.freeze({ | ||
content: typeof content === "string" ? new o().encode(content) : content, | ||
signatures: Object.freeze({ ...signatures }) | ||
}); | ||
} | ||
// src/transaction-with-single-sending-signer.ts | ||
function isTransactionWithSingleSendingSigner(transaction) { | ||
try { | ||
assertIsTransactionWithSingleSendingSigner(transaction); | ||
return true; | ||
} catch { | ||
return false; | ||
} | ||
} | ||
function assertIsTransactionWithSingleSendingSigner(transaction) { | ||
const signers = getSignersFromTransaction(transaction); | ||
const sendingSigners = signers.filter(isTransactionSendingSigner); | ||
if (sendingSigners.length === 0) { | ||
const error = new Error("No `TransactionSendingSigner` was identified."); | ||
error.name = "MissingTransactionSendingSignerError"; | ||
throw error; | ||
} | ||
const sendingOnlySigners = sendingSigners.filter( | ||
(signer) => !isTransactionPartialSigner(signer) && !isTransactionModifyingSigner(signer) | ||
); | ||
if (sendingOnlySigners.length > 1) { | ||
const error = new Error("More than one `TransactionSendingSigner` was identified."); | ||
error.name = "MultipleTransactionSendingSignersError"; | ||
throw error; | ||
} | ||
} | ||
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 }; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.node.js.map |
@@ -5,27 +5,37 @@ this.globalThis = this.globalThis || {}; | ||
function w(e,n,r=0){if(n.length-r<=0)throw new Error(`Codec [${e}] cannot decode empty byte arrays.`)}function x(e,n,r,t=0){let i=r.length-t;if(i<n)throw new Error(`Codec [${e}] expected ${n} bytes, got ${i}.`)}var b=e=>{let n=e.filter(o=>o.length);if(n.length===0)return e.length?e[0]:new Uint8Array;if(n.length===1)return n[0];let r=n.reduce((o,s)=>o+s.length,0),t=new Uint8Array(r),i=0;return n.forEach(o=>{t.set(o,i),i+=o.length;}),t},Ae=(e,n)=>{if(e.length>=n)return e;let r=new Uint8Array(n).fill(0);return r.set(e),r},R=(e,n)=>Ae(e.length<=n?e:e.slice(0,n),n);function ne(e,n,r){return {description:r??`fixed(${n}, ${e.description})`,fixedSize:n,maxSize:n}}function C(e,n,r){return {...ne(e,n,r),encode:t=>R(e.encode(t),n)}}function O(e,n,r){return {...ne(e,n,r),decode:(t,i=0)=>{x("fixCodec",n,t,i),(i>0||t.length>n)&&(t=t.slice(i,i+n)),e.fixedSize!==null&&(t=R(t,e.fixedSize));let[o]=e.decode(t,0);return [o,i+n]}}}function T(e,n){return {description:e.description,encode:r=>e.encode(n(r)),fixedSize:e.fixedSize,maxSize:e.maxSize}}function re(e,n,r,t){if(t<n||t>r)throw new Error(`Codec [${e}] expected number to be in the range [${n}, ${r}], got ${t}.`)}function te(e){let n,r=e.name;return e.size>1&&(n=!("endian"in e.config)||e.config.endian===0,r+=n?"(le)":"(be)"),{description:e.config.description??r,fixedSize:e.size,littleEndian:n,maxSize:e.size}}function ie(e){let n=te(e);return {description:n.description,encode(r){e.range&&re(e.name,e.range[0],e.range[1],r);let t=new ArrayBuffer(e.size);return e.set(new DataView(t),r,n.littleEndian),new Uint8Array(t)},fixedSize:n.fixedSize,maxSize:n.maxSize}}function we(e){let n=te(e);return {decode(r,t=0){w(n.description,r,t),x(n.description,e.size,r,t);let i=new DataView(Te(r,t,e.size));return [e.get(i,n.littleEndian),t+e.size]},description:n.description,fixedSize:n.fixedSize,maxSize:n.maxSize}}function Te(e,n,r){let t=e.byteOffset+(n??0),i=r??e.byteLength;return e.buffer.slice(t,t+i)}var m=(e={})=>({description:e.description??"shortU16",encode:n=>{re("shortU16",0,65535,n);let r=[0];for(let t=0;;t+=1){let i=n>>t*7;if(i===0)break;let o=127&i;r[t]=o,t>0&&(r[t-1]|=128);}return new Uint8Array(r)},fixedSize:null,maxSize:3});var k=(e={})=>ie({config:e,name:"u32",range:[0,+"0xffffffff"],set:(n,r,t)=>n.setUint32(0,r,t),size:4}),L=(e={})=>we({config:e,get:(n,r)=>n.getUint32(0,r),name:"u32",size:4});var h=(e={})=>ie({config:e,name:"u8",range:[0,+"0xff"],set:(n,r)=>n.setUint8(0,r),size:1});function ze(e,n,r=n){if(!n.match(new RegExp(`^[${e}]*$`)))throw new Error(`Expected a string of base ${e.length}, got [${r}].`)}var Ee=e=>{let n=e.length,r=BigInt(n);return {description:`base${n}`,encode(t){if(ze(e,t),t==="")return new Uint8Array;let i=[...t],o=i.findIndex(p=>p!==e[0]);o=o===-1?i.length:o;let s=Array(o).fill(0);if(o===i.length)return Uint8Array.from(s);let a=i.slice(o),l=0n,d=1n;for(let p=a.length-1;p>=0;p-=1)l+=d*BigInt(e.indexOf(a[p])),d*=r;let u=[];for(;l>0n;)u.unshift(Number(l%256n)),l/=256n;return Uint8Array.from(s.concat(u))},fixedSize:null,maxSize:null}},ve=e=>{let n=e.length,r=BigInt(n);return {decode(t,i=0){let o=i===0?t:t.slice(i);if(o.length===0)return ["",0];let s=o.findIndex(u=>u!==0);s=s===-1?o.length:s;let a=e[0].repeat(s);if(s===o.length)return [a,t.length];let l=o.slice(s).reduce((u,p)=>u*256n+BigInt(p),0n),d=[];for(;l>0n;)d.unshift(e[Number(l%r)]),l/=r;return [a+d.join(""),t.length]},description:`base${n}`,fixedSize:null,maxSize:null}};var oe="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",M=()=>Ee(oe),_=()=>ve(oe);var Ie=e=>e.replace(/\u0000/g,"");var De=globalThis.TextDecoder,Ce=globalThis.TextEncoder,Be=()=>{let e;return {description:"utf8",encode:n=>new Uint8Array((e||(e=new Ce)).encode(n)),fixedSize:null,maxSize:null}},ke=()=>{let e;return {decode(n,r=0){let t=(e||(e=new De)).decode(n.slice(r));return [Ie(t),n.length]},description:"utf8",fixedSize:null,maxSize:null}};var $=(e={})=>{let n=e.size??k(),r=e.encoding??Be(),t=e.description??`string(${r.description}; ${se(n)})`;return n==="variable"?{...r,description:t}:typeof n=="number"?C(r,n,t):{description:t,encode:i=>{let o=r.encode(i),s=n.encode(o.length);return b([s,o])},fixedSize:null,maxSize:null}},F=(e={})=>{let n=e.size??L(),r=e.encoding??ke(),t=e.description??`string(${r.description}; ${se(n)})`;return n==="variable"?{...r,description:t}:typeof n=="number"?O(r,n,t):{decode:(i,o=0)=>{w("string",i,o);let[s,a]=n.decode(i,o),l=Number(s);o=a;let d=i.slice(o,o+l);x("string",l,d);let[u,p]=r.decode(d);return o+=p,[u,o]},description:t,fixedSize:null,maxSize:null}};function se(e){return typeof e=="object"?e.description:`${e}`}function K(){if(!globalThis.isSecureContext)throw new Error("Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts")}var S;async function Me(e){return S===void 0&&(S=new Promise(n=>{e.generateKey("Ed25519",!1,["sign","verify"]).catch(()=>{n(S=!1);}).then(()=>{n(S=!0);});})),typeof S=="boolean"?S:await S}async function ae(){if(K(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.generateKey!="function")throw new Error("No key generation implementation could be found");if(!await Me(globalThis.crypto.subtle))throw new Error(`This runtime does not support the generation of Ed25519 key pairs. | ||
function y(e){let n={};return e.forEach(r=>{if(!n[r.address])n[r.address]=r;else if(n[r.address]!==r)throw new Error(`Multiple distinct signers were identified for address "${r.address}". Please ensure that you are using the same signer instance for each address.`)}),Object.values(n)}function Oe(e){var n;return y(((n=e.accounts)!=null?n:[]).flatMap(r=>"signer"in r?r.signer:[]))}function B(e){return y(e.instructions.flatMap(Oe))}function ie(e){return e>=2}function We(e,n){if(!n.accounts||n.accounts.length===0)return n;let r=new Map(y(e).map(t=>[t.address,t]));return Object.freeze({...n,accounts:n.accounts.map(t=>{let i=r.get(t.address);return !ie(t.role)||"signer"in t||!i?t:Object.freeze({...t,signer:i})})})}function Fn(e,n){return n.instructions.length===0?n:Object.freeze({...n,instructions:n.instructions.map(r=>We(e,r))})}function M(e,n,r=0){if(n.length-r<=0)throw new Error(`Codec [${e}] cannot decode empty byte arrays.`)}function E(e,n,r,t=0){let i=r.length-t;if(i<n)throw new Error(`Codec [${e}] expected ${n} bytes, got ${i}.`)}var Ue=(e,n)=>{if(e.length>=n)return e;let r=new Uint8Array(n).fill(0);return r.set(e),r},Fe=(e,n)=>Ue(e.length<=n?e:e.slice(0,n),n);function S(e,n){return "fixedSize"in n?n.fixedSize:n.getSizeFromValue(e)}function l(e){return Object.freeze({...e,encode:n=>{let r=new Uint8Array(S(n,e));return e.write(n,r,0),r}})}function p(e){return Object.freeze({...e,decode:(n,r=0)=>e.read(n,r)[0]})}function I(e){return "fixedSize"in e&&typeof e.fixedSize=="number"}function se(e,n){if(!I(e))throw new Error(n!=null?n:"Expected a fixed-size codec, got a variable-size one.")}function Le(e){return !I(e)}function N(e,n){return l({fixedSize:n,write:(r,t,i)=>{let o=e.encode(r),s=o.length>n?o.slice(0,n):o;return t.set(s,i),i+n}})}function V(e,n){return p({fixedSize:n,read:(r,t)=>{E("fixCodec",n,r,t),(t>0||r.length>n)&&(r=r.slice(t,t+n)),I(e)&&(r=Fe(r,e.fixedSize));let[i]=e.read(r,0);return [i,t+n]}})}function z(e,n){return l({...Le(e)?{...e,getSizeFromValue:r=>e.getSizeFromValue(n(r))}:e,write:(r,t,i)=>e.write(n(r),t,i)})}function oe(e,n,r,t){if(t<n||t>r)throw new Error(`Codec [${e}] expected number to be in the range [${n}, ${r}], got ${t}.`)}function ae(e){return (e==null?void 0:e.endian)!==1}function ce(e){return l({fixedSize:e.size,write(n,r,t){e.range&&oe(e.name,e.range[0],e.range[1],n);let i=new ArrayBuffer(e.size);return e.set(new DataView(i),n,ae(e.config)),r.set(new Uint8Array(i),t),t+e.size}})}function _e(e){return p({fixedSize:e.size,read(n,r=0){M(e.name,n,r),E(e.name,e.size,n,r);let t=new DataView($e(n,r,e.size));return [e.get(t,ae(e.config)),r+e.size]}})}function $e(e,n,r){let t=e.byteOffset+(n!=null?n:0),i=r!=null?r:e.byteLength;return e.buffer.slice(t,t+i)}var h=()=>l({getSizeFromValue:e=>e<=127?1:e<=16383?2:3,maxSize:3,write:(e,n,r)=>{oe("shortU16",0,65535,e);let t=[0];for(let i=0;;i+=1){let o=e>>i*7;if(o===0)break;let s=127&o;t[i]=s,i>0&&(t[i-1]|=128);}return n.set(t,r),r+t.length}});var O=(e={})=>ce({config:e,name:"u32",range:[0,+"0xffffffff"],set:(n,r,t)=>n.setUint32(0,r,t),size:4}),K=(e={})=>_e({config:e,get:(n,r)=>n.getUint32(0,r),name:"u32",size:4});var A=()=>ce({name:"u8",range:[0,+"0xff"],set:(e,n)=>e.setUint8(0,n),size:1});function Ve(e,n,r=n){if(!n.match(new RegExp(`^[${e}]*$`)))throw new Error(`Expected a string of base ${e.length}, got [${r}].`)}var Ke=e=>l({getSizeFromValue:n=>{let[r,t]=de(n,e[0]);if(t==="")return n.length;let i=ge(t,e);return r.length+Math.ceil(i.toString(16).length/2)},write(n,r,t){if(Ve(e,n),n==="")return t;let[i,o]=de(n,e[0]);if(o==="")return r.set(new Uint8Array(i.length).fill(0),t),t+i.length;let s=ge(o,e),a=[];for(;s>0n;)a.unshift(Number(s%256n)),s/=256n;let c=[...Array(i.length).fill(0),...a];return r.set(c,t),t+c.length}}),je=e=>p({read(n,r){let t=r===0?n:n.slice(r);if(t.length===0)return ["",0];let i=t.findIndex(c=>c!==0);i=i===-1?t.length:i;let o=e[0].repeat(i);if(i===t.length)return [o,n.length];let s=t.slice(i).reduce((c,d)=>c*256n+BigInt(d),0n),a=Ge(s,e);return [o+a,n.length]}});function de(e,n){let r=[...e].findIndex(t=>t!==n);return r===-1?[e,""]:[e.slice(0,r),e.slice(r)]}function ge(e,n){let r=BigInt(n.length);return [...e].reduce((t,i)=>t*r+BigInt(n.indexOf(i)),0n)}function Ge(e,n){let r=BigInt(n.length),t=[];for(;e>0n;)t.unshift(n[Number(e%r)]),e/=r;return t.join("")}var fe="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",W=()=>Ke(fe),j=()=>je(fe);var Ye=e=>e.replace(/\u0000/g,"");var He=globalThis.TextDecoder,ue=globalThis.TextEncoder,Xe=()=>{let e;return l({getSizeFromValue:n=>(e||(e=new ue)).encode(n).length,write:(n,r,t)=>{let i=(e||(e=new ue)).encode(n);return r.set(i,t),t+i.length}})},Ze=()=>{let e;return p({read(n,r){let t=(e||(e=new He)).decode(n.slice(r));return [Ye(t),n.length]}})};function U(e={}){var t,i;let n=(t=e.size)!=null?t:O(),r=(i=e.encoding)!=null?i:Xe();return n==="variable"?r:typeof n=="number"?N(r,n):l({getSizeFromValue:o=>{let s=S(o,r);return S(s,n)+s},write:(o,s,a)=>{let c=S(o,r);return a=n.write(c,s,a),r.write(o,s,a)}})}function G(e={}){var t,i;let n=(t=e.size)!=null?t:K(),r=(i=e.encoding)!=null?i:Ze();return n==="variable"?r:typeof n=="number"?V(r,n):p({read:(o,s=0)=>{M("string",o,s);let[a,c]=n.read(o,s),d=Number(a);s=c;let f=o.slice(s,s+d);E("string",d,f);let[te,Re]=r.read(f,0);return s+=Re,[te,s]}})}function Y(){if(!globalThis.isSecureContext)throw new Error("Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts")}var b;async function qe(e){return b===void 0&&(b=new Promise(n=>{e.generateKey("Ed25519",!1,["sign","verify"]).catch(()=>{n(b=!1);}).then(()=>{n(b=!0);});})),typeof b=="boolean"?b:await b}async function le(){var e;if(Y(),typeof globalThis.crypto>"u"||typeof((e=globalThis.crypto.subtle)==null?void 0:e.generateKey)!="function")throw new Error("No key generation implementation could be found");if(!await qe(globalThis.crypto.subtle))throw new Error(`This runtime does not support the generation of Ed25519 key pairs. | ||
Install and import \`@solana/webcrypto-ed25519-polyfill\` before generating keys in environments that do not support Ed25519. | ||
For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20`)}async function de(){if(K(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.exportKey!="function")throw new Error("No key export implementation could be found")}async function ce(){if(K(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.sign!="function")throw new Error("No signing implementation could be found")}var j,V;function H(){return j||(j=M()),j}function $e(){return V||(V=_()),V}function ue(e){return !(e.length<32||e.length>44||H().encode(e).byteLength!==32)}function fe(e){try{if(e.length<32||e.length>44)throw new Error("Expected input string to decode to a byte array of length 32.");let t=H().encode(e).byteLength;if(t!==32)throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${t}`)}catch(n){throw new Error(`\`${e}\` is not a base-58 encoded address`,{cause:n})}}function Ue(e){return fe(e),e}function W(e){return T($({description:e?.description??"Address",encoding:H(),size:32}),n=>Ue(n))}function le(e){return F({description:e?.description??"Address",encoding:$e(),size:32})}function U(){return new Intl.Collator("en",{caseFirst:"lower",ignorePunctuation:!1,localeMatcher:"best fit",numeric:!1,sensitivity:"variant",usage:"sort"}).compare}async function P(e){if(await de(),e.type!=="public"||e.algorithm.name!=="Ed25519")throw new Error("The `CryptoKey` must be an `Ed25519` public key");let n=await crypto.subtle.exportKey("raw",e),[r]=le().decode(new Uint8Array(n));return r}async function ge(){return await ae(),await crypto.subtle.generateKey("Ed25519",!1,["sign","verify"])}async function N(e,n){await ce();let r=await crypto.subtle.sign("Ed25519",e,n);return new Uint8Array(r)}function G(e){return e.reduce((n,r)=>n===null||r===null?null:n+r,0)}function Ne(e){return typeof e=="object"?e.description:`${e}`}function pe(e,n){if(typeof e!="number")return null;if(e===0)return 0;let r=G(n);return r===null?null:r*e}function Re(e,n){return typeof e=="object"?e.encode(n):new Uint8Array}function Oe(e,n,r){if(n!==r)throw new Error(`Expected [${e}] to have ${n} items, got ${r}.`)}function Le(e,n,r){if(n==="remainder"&&e.fixedSize===null)throw new Error('Codecs of "remainder" size must have fixed-size items.');return {description:r??`array(${e.description}; ${Ne(n)})`,fixedSize:pe(n,[e.fixedSize]),maxSize:pe(n,[e.maxSize])}}function y(e,n={}){let r=n.size??k();return {...Le(e,r,n.description),encode:t=>(typeof r=="number"&&Oe("array",r,t.length),b([Re(r,t.length),...t.map(i=>e.encode(i))]))}}function me(e={}){let n=e.size??"variable",r=typeof n=="object"?n.description:`${n}`,t=e.description??`bytes(${r})`,i={description:t,encode:o=>o,fixedSize:null,maxSize:null};return n==="variable"?i:typeof n=="number"?C(i,n,t):{...i,encode:o=>{let s=i.encode(o),a=n.encode(s.length);return b([a,s])}}}function _e(e,n){let r=e.map(([t,i])=>`${String(t)}: ${i.description}`).join(", ");return {description:n??`struct(${r})`,fixedSize:G(e.map(([,t])=>t.fixedSize)),maxSize:G(e.map(([,t])=>t.maxSize))}}function A(e,n={}){return {..._e(e,n.description),encode:r=>{let t=e.map(([i,o])=>o.encode(r[i]));return b(t)}}}var z=(e=>(e[e.WRITABLE_SIGNER=3]="WRITABLE_SIGNER",e[e.READONLY_SIGNER=2]="READONLY_SIGNER",e[e.WRITABLE=1]="WRITABLE",e[e.READONLY=0]="READONLY",e))(z||{}),Fe=1;function E(e){return e>=2}function v(e){return (e&Fe)!==0}function he(e,n){return e|n}function Se(e,n,r){e[n]=r(e[n]??{role:z.READONLY});}var c=Symbol("AddressMapTypeProperty");function Ke(e,n){let r={[e]:{[c]:0,role:z.WRITABLE_SIGNER}},t=new Set;for(let i of n){Se(r,i.programAddress,s=>{if(t.add(i.programAddress),c in s){if(v(s.role))switch(s[c]){case 0:throw new Error(`This transaction includes an address (\`${i.programAddress}\`) which is both invoked and set as the fee payer. Program addresses may not pay fees.`);default:throw new Error(`This transaction includes an address (\`${i.programAddress}\`) which is both invoked and marked writable. Program addresses may not be writable.`)}if(s[c]===2)return s}return {[c]:2,role:z.READONLY}});let o;if(i.accounts)for(let s of i.accounts)Se(r,s.address,a=>{let{address:l,...d}=s;if(c in a)switch(a[c]){case 0:return a;case 1:{let u=he(a.role,d.role);if("lookupTableAddress"in d){if(a.lookupTableAddress!==d.lookupTableAddress&&(o||(o=U()))(d.lookupTableAddress,a.lookupTableAddress)<0)return {[c]:1,...d,role:u}}else if(E(d.role))return {[c]:2,role:u};return a.role!==u?{...a,role:u}:a}case 2:{let u=he(a.role,d.role);if(t.has(s.address)){if(v(d.role))throw new Error(`This transaction includes an address (\`${s.address}\`) which is both invoked and marked writable. Program addresses may not be writable.`);return a.role!==u?{...a,role:u}:a}else return "lookupTableAddress"in d&&!E(a.role)?{...d,[c]:1,role:u}:a.role!==u?{...a,role:u}:a}}return "lookupTableAddress"in d?{...d,[c]:1}:{...d,[c]:2}});}return r}function je(e){let n;return Object.entries(e).sort(([t,i],[o,s])=>{if(i[c]!==s[c]){if(i[c]===0)return -1;if(s[c]===0)return 1;if(i[c]===2)return -1;if(s[c]===2)return 1}let a=E(i.role);if(a!==E(s.role))return a?-1:1;let l=v(i.role);return l!==v(s.role)?l?-1:1:(n||(n=U()),i[c]===1&&s[c]===1&&i.lookupTableAddress!==s.lookupTableAddress?n(i.lookupTableAddress,s.lookupTableAddress):n(t,o))}).map(([t,i])=>({address:t,...i}))}function Ve(e){var n;let r={};for(let t of e){if(!("lookupTableAddress"in t))continue;let i=r[n=t.lookupTableAddress]||(r[n]={readableIndices:[],writableIndices:[]});t.role===z.WRITABLE?i.writableIndices.push(t.addressIndex):i.readableIndices.push(t.addressIndex);}return Object.keys(r).sort(U()).map(t=>({lookupTableAddress:t,...r[t]}))}function He(e){let n=0,r=0,t=0;for(let i of e){if("lookupTableAddress"in i)break;let o=v(i.role);E(i.role)?(t++,o||r++):o||n++;}return {numReadonlyNonSignerAccounts:n,numReadonlySignerAccounts:r,numSignerAccounts:t}}function We(e){let n={};for(let[r,t]of e.entries())n[t.address]=r;return n}function Ge(e,n){let r=We(n);return e.map(({accounts:t,data:i,programAddress:o})=>({programAddressIndex:r[o],...t?{accountIndices:t.map(({address:s})=>r[s])}:null,...i?{data:i}:null}))}function Ye(e){return "nonce"in e?e.nonce:e.blockhash}function Xe(e){let n=e.findIndex(t=>"lookupTableAddress"in t);return (n===-1?e:e.slice(0,n)).map(({address:t})=>t)}function qe(e){let n=Ke(e.feePayer,e.instructions),r=je(n);return {...e.version!=="legacy"?{addressTableLookups:Ve(r)}:null,header:He(r),instructions:Ge(e.instructions,r),lifetimeToken:Ye(e.lifetimeConstraint),staticAccounts:Xe(r),version:e.version}}var Ze="lookupTableAddress",Je="writableIndices",Qe="readableIndices",en="addressTableLookup",Y;function nn(){return Y||(Y=A([["lookupTableAddress",W({description:Ze})],["writableIndices",y(h(),{description:Je,size:m()})],["readableIndices",y(h(),{description:Qe,size:m()})]],{description:en})),Y}var X;function rn(){return X||(X=h()),X}function q(e){let n=rn();return {...n,description:e??n.description}}var tn=void 0,on=void 0,sn=void 0,an=void 0;function dn(){return A([["numSignerAccounts",q(tn)],["numReadonlySignerAccounts",q(on)],["numReadonlyNonSignerAccounts",q(sn)]],{description:an})}var cn="programAddressIndex",un=void 0,fn="accountIndices",ln="data",Z;function gn(){return Z||(Z=T(A([["programAddressIndex",h({description:cn})],["accountIndices",y(h({description:un}),{description:fn,size:m()})],["data",me({description:ln,size:m()})]]),e=>e.accountIndices!==void 0&&e.data!==void 0?e:{...e,accountIndices:e.accountIndices??[],data:e.data??new Uint8Array(0)})),Z}var pn=128,mn={description:"",fixedSize:null,maxSize:1};function hn(e){if(e==="legacy")return new Uint8Array;if(e<0||e>127)throw new Error(`Transaction version must be in the range [0, 127]. \`${e}\` given.`);return new Uint8Array([e|pn])}function Sn(){return {...mn,encode:hn}}var yn="staticAccounts",xn="lifetimeToken",bn="instructions",An="addressTableLookups";function wn(){return A(ye())}function Tn(){return T(A([...ye(),["addressTableLookups",zn()]]),e=>e.version==="legacy"?e:{...e,addressTableLookups:e.addressTableLookups??[]})}function ye(){return [["version",Sn()],["header",dn()],["staticAccounts",y(W(),{description:yn,size:m()})],["lifetimeToken",$({description:xn,encoding:M(),size:32})],["instructions",y(gn(),{description:bn,size:m()})]]}function zn(){return y(nn(),{description:An,size:m()})}var En="message";function vn(){return {description:En,encode:e=>e.version==="legacy"?wn().encode(e):Tn().encode(e),fixedSize:null,maxSize:null}}async function xe(e,n){let r=qe(n),t="signatures"in n?{...n.signatures}:{},i=vn().encode(r),o=await Promise.all(e.map(a=>Promise.all([P(a.publicKey),N(a.privateKey,i)])));for(let[a,l]of o)t[a]=l;let s={...n,signatures:t};return Object.freeze(s),s}function I(e){return "signMessages"in e&&typeof e.signMessages=="function"}function yr(e){if(!I(e))throw new Error("The provided value does not implement the MessagePartialSigner interface")}function D(e){return "signTransactions"in e&&typeof e.signTransactions=="function"}function Ar(e){if(!D(e))throw new Error("The provided value does not implement the TransactionPartialSigner interface")}function In(e){return "keyPair"in e&&typeof e.keyPair=="object"&&I(e)&&D(e)}function Mr(e){if(!In(e))throw new Error("The provided value does not implement the KeyPairSigner interface")}async function Dn(e){let n=await P(e.publicKey);return Object.freeze({address:n,keyPair:e,signMessages:t=>Promise.all(t.map(async i=>Object.freeze({[n]:await N(e.privateKey,i.content)}))),signTransactions:t=>Promise.all(t.map(async i=>{let o=await xe([e],i);return Object.freeze({[n]:o.signatures[n]})}))})}async function $r(){return Dn(await ge())}function J(e){return ue(e.address)&&"modifyAndSignMessages"in e&&typeof e.modifyAndSignMessages=="function"}function Or(e){if(!J(e))throw new Error("The provided value does not implement the MessageModifyingSigner interface")}function Cn(e){return I(e)||J(e)}function Hr(e){if(!Cn(e))throw new Error("The provided value does not implement any of the MessageSigner interfaces")}var be=globalThis.TextEncoder;function Jr(e,n={}){return Object.freeze({content:typeof e=="string"?new be().encode(e):e,signatures:Object.freeze({...n})})}function Q(e){return "modifyAndSignTransactions"in e&&typeof e.modifyAndSignTransactions=="function"}function nt(e){if(!Q(e))throw new Error("The provided value does not implement the TransactionModifyingSigner interface")}function ee(e){return "signAndSendTransactions"in e&&typeof e.signAndSendTransactions=="function"}function it(e){if(!ee(e))throw new Error("The provided value does not implement the TransactionSendingSigner interface")}function Bn(e){return D(e)||Q(e)||ee(e)}function gt(e){if(!Bn(e))throw new Error("The provided value does not implement any of the TransactionSigner interfaces")} | ||
For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20`)}async function me(){var e;if(Y(),typeof globalThis.crypto>"u"||typeof((e=globalThis.crypto.subtle)==null?void 0:e.exportKey)!="function")throw new Error("No key export implementation could be found")}async function Se(){var e;if(Y(),typeof globalThis.crypto>"u"||typeof((e=globalThis.crypto.subtle)==null?void 0:e.sign)!="function")throw new Error("No signing implementation could be found")}var H,X;function Z(){return H||(H=W()),H}function Je(){return X||(X=j()),X}function pe(e){return !(e.length<32||e.length>44||Z().encode(e).byteLength!==32)}function Te(e){try{if(e.length<32||e.length>44)throw new Error("Expected input string to decode to a byte array of length 32.");let t=Z().encode(e).byteLength;if(t!==32)throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${t}`)}catch(n){throw new Error(`\`${e}\` is not a base-58 encoded address`,{cause:n})}}function Qe(e){return Te(e),e}function q(){return z(U({encoding:Z(),size:32}),e=>Qe(e))}function ye(){return G({encoding:Je(),size:32})}function F(){return new Intl.Collator("en",{caseFirst:"lower",ignorePunctuation:!1,localeMatcher:"best fit",numeric:!1,sensitivity:"variant",usage:"sort"}).compare}async function L(e){if(await me(),e.type!=="public"||e.algorithm.name!=="Ed25519")throw new Error("The `CryptoKey` must be an `Ed25519` public key");let n=await crypto.subtle.exportKey("raw",e);return ye().decode(new Uint8Array(n))}async function he(){return await le(),await crypto.subtle.generateKey("Ed25519",!1,["sign","verify"])}async function _(e,n){await Se();let r=await crypto.subtle.sign("Ed25519",e,n);return new Uint8Array(r)}function rn(e,n,r){if(n!==r)throw new Error(`Expected [${e}] to have ${n} items, got ${r}.`)}function Ae(e){return e.reduce((n,r)=>n===null||r===null?null:n+r,0)}function we(e){return I(e)?e.fixedSize:null}function xe(e){var n;return I(e)?e.fixedSize:(n=e.maxSize)!=null?n:null}function w(e,n={}){var o,s;let r=(o=n.size)!=null?o:O();r==="remainder"&&se(e,'Codecs of "remainder" size must have fixed-size items.');let t=be(r,we(e)),i=(s=be(r,xe(e)))!=null?s:void 0;return l({...t!==null?{fixedSize:t}:{getSizeFromValue:a=>(typeof r=="object"?S(a.length,r):0)+[...a].reduce((d,f)=>d+S(f,e),0),maxSize:i},write:(a,c,d)=>(typeof r=="number"&&rn("array",r,a.length),typeof r=="object"&&(d=r.write(a.length,c,d)),a.forEach(f=>{d=e.write(f,c,d);}),d)})}function be(e,n){return typeof e!="number"?null:e===0?0:n===null?null:n*e}function Ee(e={}){var t;let n=(t=e.size)!=null?t:"variable",r=l({getSizeFromValue:i=>i.length,write:(i,o,s)=>(o.set(i,s),s+i.length)});return n==="variable"?r:typeof n=="number"?N(r,n):l({getSizeFromValue:i=>S(i.length,n)+i.length,write:(i,o,s)=>(s=n.write(i.length,o,s),r.write(i,o,s))})}function v(e){var i;let n=e.map(([,o])=>o),r=Ae(n.map(we)),t=(i=Ae(n.map(xe)))!=null?i:void 0;return l({...r===null?{getSizeFromValue:o=>e.map(([s,a])=>S(o[s],a)).reduce((s,a)=>s+a,0),maxSize:t}:{fixedSize:r},write:(o,s,a)=>(e.forEach(([c,d])=>{a=d.write(o[c],s,a);}),a)})}var D=(e=>(e[e.WRITABLE_SIGNER=3]="WRITABLE_SIGNER",e[e.READONLY_SIGNER=2]="READONLY_SIGNER",e[e.WRITABLE=1]="WRITABLE",e[e.READONLY=0]="READONLY",e))(D||{}),tn=1;function C(e){return e>=2}function P(e){return (e&tn)!==0}function Ie(e,n){return e|n}function ze(e,n,r){var t;e[n]=r((t=e[n])!=null?t:{role:D.READONLY});}var u=Symbol("AddressMapTypeProperty");function sn(e,n){let r={[e]:{[u]:0,role:D.WRITABLE_SIGNER}},t=new Set;for(let i of n){ze(r,i.programAddress,s=>{if(t.add(i.programAddress),u in s){if(P(s.role))switch(s[u]){case 0:throw new Error(`This transaction includes an address (\`${i.programAddress}\`) which is both invoked and set as the fee payer. Program addresses may not pay fees.`);default:throw new Error(`This transaction includes an address (\`${i.programAddress}\`) which is both invoked and marked writable. Program addresses may not be writable.`)}if(s[u]===2)return s}return {[u]:2,role:D.READONLY}});let o;if(i.accounts)for(let s of i.accounts)ze(r,s.address,a=>{let{address:c,...d}=s;if(u in a)switch(a[u]){case 0:return a;case 1:{let f=Ie(a.role,d.role);if("lookupTableAddress"in d){if(a.lookupTableAddress!==d.lookupTableAddress&&(o||(o=F()))(d.lookupTableAddress,a.lookupTableAddress)<0)return {[u]:1,...d,role:f}}else if(C(d.role))return {[u]:2,role:f};return a.role!==f?{...a,role:f}:a}case 2:{let f=Ie(a.role,d.role);if(t.has(s.address)){if(P(d.role))throw new Error(`This transaction includes an address (\`${s.address}\`) which is both invoked and marked writable. Program addresses may not be writable.`);return a.role!==f?{...a,role:f}:a}else return "lookupTableAddress"in d&&!C(a.role)?{...d,[u]:1,role:f}:a.role!==f?{...a,role:f}:a}}return "lookupTableAddress"in d?{...d,[u]:1}:{...d,[u]:2}});}return r}function on(e){let n;return Object.entries(e).sort(([t,i],[o,s])=>{if(i[u]!==s[u]){if(i[u]===0)return -1;if(s[u]===0)return 1;if(i[u]===2)return -1;if(s[u]===2)return 1}let a=C(i.role);if(a!==C(s.role))return a?-1:1;let c=P(i.role);return c!==P(s.role)?c?-1:1:(n||(n=F()),i[u]===1&&s[u]===1&&i.lookupTableAddress!==s.lookupTableAddress?n(i.lookupTableAddress,s.lookupTableAddress):n(t,o))}).map(([t,i])=>({address:t,...i}))}function an(e){var r;let n={};for(let t of e){if(!("lookupTableAddress"in t))continue;let i=n[r=t.lookupTableAddress]||(n[r]={readableIndices:[],writableIndices:[]});t.role===D.WRITABLE?i.writableIndices.push(t.addressIndex):i.readableIndices.push(t.addressIndex);}return Object.keys(n).sort(F()).map(t=>({lookupTableAddress:t,...n[t]}))}function cn(e){let n=0,r=0,t=0;for(let i of e){if("lookupTableAddress"in i)break;let o=P(i.role);C(i.role)?(t++,o||r++):o||n++;}return {numReadonlyNonSignerAccounts:n,numReadonlySignerAccounts:r,numSignerAccounts:t}}function dn(e){let n={};for(let[r,t]of e.entries())n[t.address]=r;return n}function gn(e,n){let r=dn(n);return e.map(({accounts:t,data:i,programAddress:o})=>({programAddressIndex:r[o],...t?{accountIndices:t.map(({address:s})=>r[s])}:null,...i?{data:i}:null}))}function un(e){return "nonce"in e?e.nonce:e.blockhash}function fn(e){let n=e.findIndex(t=>"lookupTableAddress"in t);return (n===-1?e:e.slice(0,n)).map(({address:t})=>t)}function ln(e){let n=sn(e.feePayer,e.instructions),r=on(n);return {...e.version!=="legacy"?{addressTableLookups:an(r)}:null,header:cn(r),instructions:gn(e.instructions,r),lifetimeToken:un(e.lifetimeConstraint),staticAccounts:fn(r),version:e.version}}var J;function mn(){return J||(J=v([["lookupTableAddress",q()],["writableIndices",w(A(),{size:h()})],["readableIndices",w(A(),{size:h()})]])),J}var Q;function ee(){return Q||(Q=A()),Q}function Sn(){return v([["numSignerAccounts",ee()],["numReadonlySignerAccounts",ee()],["numReadonlyNonSignerAccounts",ee()]])}var ne;function pn(){return ne||(ne=z(v([["programAddressIndex",A()],["accountIndices",w(A(),{size:h()})],["data",Ee({size:h()})]]),e=>{var n,r;return e.accountIndices!==void 0&&e.data!==void 0?e:{...e,accountIndices:(n=e.accountIndices)!=null?n:[],data:(r=e.data)!=null?r:new Uint8Array(0)}})),ne}var Tn=128;function yn(){return l({getSizeFromValue:e=>e==="legacy"?0:1,maxSize:1,write:(e,n,r)=>{if(e==="legacy")return r;if(e<0||e>127)throw new Error(`Transaction version must be in the range [0, 127]. \`${e}\` given.`);return n.set([e|Tn],r),r+1}})}function ve(){return v(Be())}function Ce(){return z(v([...Be(),["addressTableLookups",hn()]]),e=>{var n;return e.version==="legacy"?e:{...e,addressTableLookups:(n=e.addressTableLookups)!=null?n:[]}})}function Be(){return [["version",yn()],["header",Sn()],["staticAccounts",w(q(),{size:h()})],["lifetimeToken",U({encoding:W(),size:32})],["instructions",w(pn(),{size:h()})]]}function hn(){return w(mn(),{size:h()})}function An(){return l({getSizeFromValue:e=>e.version==="legacy"?ve().getSizeFromValue(e):Ce().getSizeFromValue(e),write:(e,n,r)=>e.version==="legacy"?ve().write(e,n,r):Ce().write(e,n,r)})}async function Me(e,n){let r=ln(n),t="signatures"in n?{...n.signatures}:{},i=An().encode(r),o=await Promise.all(e.map(a=>Promise.all([L(a.publicKey),_(a.privateKey,i)])));for(let[a,c]of o)t[a]=c;let s={...n,signatures:t};return Object.freeze(s),s}function De(e){let n=e.instructions.flatMap(t=>{var i,o;return (o=(i=t.accounts)==null?void 0:i.filter(s=>C(s.role)))!=null?o:[]}).map(t=>t.address);new Set([e.feePayer,...n]).forEach(t=>{if(!e.signatures[t])throw new Error(`Transaction is missing signature for address \`${t}\``)});}function k(e){return "signMessages"in e&&typeof e.signMessages=="function"}function zr(e){if(!k(e))throw new Error("The provided value does not implement the MessagePartialSigner interface")}function m(e){return "signTransactions"in e&&typeof e.signTransactions=="function"}function Br(e){if(!m(e))throw new Error("The provided value does not implement the TransactionPartialSigner interface")}function bn(e){return "keyPair"in e&&typeof e.keyPair=="object"&&k(e)&&m(e)}function Lr(e){if(!bn(e))throw new Error("The provided value does not implement the KeyPairSigner interface")}async function wn(e){let n=await L(e.publicKey);return Object.freeze({address:n,keyPair:e,signMessages:t=>Promise.all(t.map(async i=>Object.freeze({[n]:await _(e.privateKey,i.content)}))),signTransactions:t=>Promise.all(t.map(async i=>{let o=await Me([e],i);return Object.freeze({[n]:o.signatures[n]})}))})}async function _r(){return wn(await he())}function re(e){return pe(e.address)&&"modifyAndSignMessages"in e&&typeof e.modifyAndSignMessages=="function"}function Gr(e){if(!re(e))throw new Error("The provided value does not implement the MessageModifyingSigner interface")}function xn(e){return k(e)||re(e)}function Qr(e){if(!xn(e))throw new Error("The provided value does not implement any of the MessageSigner interfaces")}function rt(e){return Object.freeze({address:e,signMessages:async r=>r.map(()=>Object.freeze({})),signTransactions:async r=>r.map(()=>Object.freeze({}))})}function T(e){return "modifyAndSignTransactions"in e&&typeof e.modifyAndSignTransactions=="function"}function st(e){if(!T(e))throw new Error("The provided value does not implement the TransactionModifyingSigner interface")}function x(e){return "signAndSendTransactions"in e&&typeof e.signAndSendTransactions=="function"}function ct(e){if(!x(e))throw new Error("The provided value does not implement the TransactionSendingSigner interface")}function $(e){return m(e)||T(e)||x(e)}function Tt(e){if(!$(e))throw new Error("The provided value does not implement any of the TransactionSigner interfaces")}async function En(e,n={}){let{partialSigners:r,modifyingSigners:t}=Pe(y(B(e).filter($)),{identifySendingSigner:!1});return ke(e,t,r,n.abortSignal)}async function Rt(e,n={}){let r=await En(e,n);return De(r),r}async function Ot(e,n={}){let r=n.abortSignal,{partialSigners:t,modifyingSigners:i,sendingSigner:o}=Pe(y(B(e).filter($)));r==null||r.throwIfAborted();let s=await ke(e,i,t,r);if(!o)throw new Error("No `TransactionSendingSigner` was identified. Please provide a valid `ITransactionWithSingleSendingSigner` transaction.");r==null||r.throwIfAborted();let[a]=await o.signAndSendTransactions([s],{abortSignal:r});return r==null||r.throwIfAborted(),a}function Pe(e,n={}){var a;let t=((a=n.identifySendingSigner)!=null?a:!0)?In(e):null,i=e.filter(c=>c!==t&&(T(c)||m(c))),o=zn(i),s=i.filter(m).filter(c=>!o.includes(c));return Object.freeze({modifyingSigners:o,partialSigners:s,sendingSigner:t})}function In(e){let n=e.filter(x);if(n.length===0)return null;let r=n.filter(t=>!T(t)&&!m(t));return r.length>0?r[0]:n[0]}function zn(e){let n=e.filter(T);if(n.length===0)return [];let r=n.filter(t=>!m(t));return r.length>0?r:[n[0]]}async function ke(e,n=[],r=[],t){var a;let i=await n.reduce(async(c,d)=>{t==null||t.throwIfAborted();let[f]=await d.modifyAndSignTransactions([await c],{abortSignal:t});return Object.freeze(f)},Promise.resolve(e));t==null||t.throwIfAborted();let o=await Promise.all(r.map(async c=>{let[d]=await c.signTransactions([i],{abortSignal:t});return d})),s={...i,signatures:Object.freeze(o.reduce((c,d)=>({...c,...d}),(a=i.signatures)!=null?a:{}))};return Object.freeze(s)}var Ne=globalThis.TextEncoder;function Vt(e,n={}){return Object.freeze({content:typeof e=="string"?new Ne().encode(e):e,signatures:Object.freeze({...n})})}function qt(e){try{return vn(e),!0}catch{return !1}}function vn(e){let r=B(e).filter(x);if(r.length===0){let i=new Error("No `TransactionSendingSigner` was identified.");throw i.name="MissingTransactionSendingSignerError",i}if(r.filter(i=>!m(i)&&!T(i)).length>1){let i=new Error("More than one `TransactionSendingSigner` was identified.");throw i.name="MultipleTransactionSendingSignersError",i}} | ||
exports.assertIsKeyPairSigner = Mr; | ||
exports.assertIsMessageModifyingSigner = Or; | ||
exports.assertIsMessagePartialSigner = yr; | ||
exports.assertIsMessageSigner = Hr; | ||
exports.assertIsTransactionModifyingSigner = nt; | ||
exports.assertIsTransactionPartialSigner = Ar; | ||
exports.assertIsTransactionSendingSigner = it; | ||
exports.assertIsTransactionSigner = gt; | ||
exports.createSignableMessage = Jr; | ||
exports.createSignerFromKeyPair = Dn; | ||
exports.generateKeyPairSigner = $r; | ||
exports.isKeyPairSigner = In; | ||
exports.isMessageModifyingSigner = J; | ||
exports.isMessagePartialSigner = I; | ||
exports.isMessageSigner = Cn; | ||
exports.isTransactionModifyingSigner = Q; | ||
exports.isTransactionPartialSigner = D; | ||
exports.isTransactionSendingSigner = ee; | ||
exports.isTransactionSigner = Bn; | ||
exports.addSignersToInstruction = We; | ||
exports.addSignersToTransaction = Fn; | ||
exports.assertIsKeyPairSigner = Lr; | ||
exports.assertIsMessageModifyingSigner = Gr; | ||
exports.assertIsMessagePartialSigner = zr; | ||
exports.assertIsMessageSigner = Qr; | ||
exports.assertIsTransactionModifyingSigner = st; | ||
exports.assertIsTransactionPartialSigner = Br; | ||
exports.assertIsTransactionSendingSigner = ct; | ||
exports.assertIsTransactionSigner = Tt; | ||
exports.assertIsTransactionWithSingleSendingSigner = vn; | ||
exports.createNoopSigner = rt; | ||
exports.createSignableMessage = Vt; | ||
exports.createSignerFromKeyPair = wn; | ||
exports.generateKeyPairSigner = _r; | ||
exports.getSignersFromInstruction = Oe; | ||
exports.getSignersFromTransaction = B; | ||
exports.isKeyPairSigner = bn; | ||
exports.isMessageModifyingSigner = re; | ||
exports.isMessagePartialSigner = k; | ||
exports.isMessageSigner = xn; | ||
exports.isTransactionModifyingSigner = T; | ||
exports.isTransactionPartialSigner = m; | ||
exports.isTransactionSendingSigner = x; | ||
exports.isTransactionSigner = $; | ||
exports.isTransactionWithSingleSendingSigner = qt; | ||
exports.partiallySignTransactionWithSigners = En; | ||
exports.signAndSendTransactionWithSigners = Ot; | ||
exports.signTransactionWithSigners = Rt; | ||
@@ -32,0 +42,0 @@ return exports; |
@@ -0,1 +1,3 @@ | ||
export * from './account-signer-meta'; | ||
export * from './add-signers'; | ||
export * from './keypair-signer'; | ||
@@ -5,2 +7,4 @@ export * from './message-modifying-signer'; | ||
export * from './message-signer'; | ||
export * from './noop-signer'; | ||
export * from './sign-transaction'; | ||
export * from './signable-message'; | ||
@@ -11,3 +15,4 @@ export * from './transaction-modifying-signer'; | ||
export * from './transaction-signer'; | ||
export * from './transaction-with-single-sending-signer'; | ||
export * from './types'; | ||
//# sourceMappingURL=index.d.ts.map |
import { Address } from '@solana/addresses'; | ||
import { SignableMessage } from './signable-message'; | ||
import { BaseSignerConfig } from './types'; | ||
export type MessageModifyingSignerConfig = BaseSignerConfig; | ||
/** Defines a signer capable of signing messages. */ | ||
export type MessageModifyingSigner<TAddress extends string = string> = Readonly<{ | ||
address: Address<TAddress>; | ||
modifyAndSignMessages(messages: readonly SignableMessage[]): Promise<readonly SignableMessage[]>; | ||
modifyAndSignMessages(messages: readonly SignableMessage[], config?: MessageModifyingSignerConfig): Promise<readonly SignableMessage[]>; | ||
}>; | ||
@@ -8,0 +10,0 @@ /** Checks whether the provided value implements the {@link MessageModifyingSigner} interface. */ |
import { Address } from '@solana/addresses'; | ||
import { SignableMessage } from './signable-message'; | ||
import { SignatureDictionary } from './types'; | ||
import { BaseSignerConfig, SignatureDictionary } from './types'; | ||
export type MessagePartialSignerConfig = BaseSignerConfig; | ||
/** Defines a signer capable of signing messages. */ | ||
export type MessagePartialSigner<TAddress extends string = string> = Readonly<{ | ||
address: Address<TAddress>; | ||
signMessages(messages: readonly SignableMessage[]): Promise<readonly SignatureDictionary[]>; | ||
signMessages(messages: readonly SignableMessage[], config?: MessagePartialSignerConfig): Promise<readonly SignatureDictionary[]>; | ||
}>; | ||
@@ -9,0 +10,0 @@ /** Checks whether the provided value implements the {@link MessagePartialSigner} interface. */ |
import { Address } from '@solana/addresses'; | ||
import { CompilableTransaction } from '@solana/transactions'; | ||
import { BaseSignerConfig } from './types'; | ||
export type TransactionModifyingSignerConfig = BaseSignerConfig; | ||
/** Defines a signer capable of signing transactions. */ | ||
export type TransactionModifyingSigner<TAddress extends string = string> = Readonly<{ | ||
address: Address<TAddress>; | ||
modifyAndSignTransactions<TTransaction extends CompilableTransaction>(transactions: readonly TTransaction[]): Promise<readonly TTransaction[]>; | ||
modifyAndSignTransactions<TTransaction extends CompilableTransaction>(transactions: readonly TTransaction[], config?: TransactionModifyingSignerConfig): Promise<readonly TTransaction[]>; | ||
}>; | ||
@@ -8,0 +10,0 @@ /** Checks whether the provided value implements the {@link TransactionModifyingSigner} interface. */ |
import { Address } from '@solana/addresses'; | ||
import { CompilableTransaction } from '@solana/transactions'; | ||
import { SignatureDictionary } from './types'; | ||
import { BaseSignerConfig, SignatureDictionary } from './types'; | ||
export type TransactionPartialSignerConfig = BaseSignerConfig; | ||
/** Defines a signer capable of signing transactions. */ | ||
export type TransactionPartialSigner<TAddress extends string = string> = Readonly<{ | ||
address: Address<TAddress>; | ||
signTransactions(transactions: readonly CompilableTransaction[]): Promise<readonly SignatureDictionary[]>; | ||
signTransactions(transactions: readonly CompilableTransaction[], config?: TransactionPartialSignerConfig): Promise<readonly SignatureDictionary[]>; | ||
}>; | ||
@@ -9,0 +10,0 @@ /** Checks whether the provided value implements the {@link TransactionPartialSigner} interface. */ |
import { Address } from '@solana/addresses'; | ||
import { SignatureBytes } from '@solana/keys'; | ||
import { CompilableTransaction } from '@solana/transactions'; | ||
import { BaseSignerConfig } from './types'; | ||
export type TransactionSendingSignerConfig = BaseSignerConfig; | ||
/** Defines a signer capable of signing and sending transactions simultaneously. */ | ||
export type TransactionSendingSigner<TAddress extends string = string> = Readonly<{ | ||
address: Address<TAddress>; | ||
signAndSendTransactions(transactions: readonly CompilableTransaction[]): Promise<readonly SignatureBytes[]>; | ||
signAndSendTransactions(transactions: readonly CompilableTransaction[], config?: TransactionSendingSignerConfig): Promise<readonly SignatureBytes[]>; | ||
}>; | ||
@@ -9,0 +11,0 @@ /** Checks whether the provided value implements the {@link TransactionSendingSigner} interface. */ |
import { Address } from '@solana/addresses'; | ||
import { SignatureBytes } from '@solana/keys'; | ||
export type SignatureDictionary = Readonly<Record<Address, SignatureBytes>>; | ||
export type BaseSignerConfig = Readonly<{ | ||
abortSignal?: AbortSignal; | ||
}>; | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "@solana/signers", | ||
"version": "2.0.0-experimental.efe6f4d", | ||
"version": "2.0.0-experimental.fb88a79", | ||
"description": "An abstraction layer over signing messages and transactions in Solana", | ||
@@ -52,5 +52,6 @@ "exports": { | ||
"dependencies": { | ||
"@solana/addresses": "2.0.0-experimental.efe6f4d", | ||
"@solana/transactions": "2.0.0-experimental.efe6f4d", | ||
"@solana/keys": "2.0.0-experimental.efe6f4d" | ||
"@solana/addresses": "2.0.0-experimental.fb88a79", | ||
"@solana/instructions": "2.0.0-experimental.fb88a79", | ||
"@solana/keys": "2.0.0-experimental.fb88a79", | ||
"@solana/transactions": "2.0.0-experimental.fb88a79" | ||
}, | ||
@@ -71,4 +72,4 @@ "devDependencies": { | ||
"jest-runner-prettier": "^1.0.0", | ||
"prettier": "^2.8", | ||
"tsup": "7.2.0", | ||
"prettier": "^3.1", | ||
"tsup": "^8.0.1", | ||
"typescript": "^5.2.2", | ||
@@ -75,0 +76,0 @@ "version-from-git": "^1.1.1", |
226
README.md
@@ -339,10 +339,4 @@ [![npm][npm-image]][npm-url] | ||
### Functions | ||
For a given address, a Noop (No-Operation) signer can be created to offer an implementation of both the `MessagePartialSigner` and `TransactionPartialSigner` interfaces such that they do not sign anything. Namely, signing a transaction or a message with a `NoopSigner` will return an empty `SignatureDictionary`. | ||
#### `createNoopSigner()` | ||
_Coming soon..._ | ||
Creates a Noop (No-Operation) signer from a given address. It will return an implementation of both the `MessagePartialSigner` and `TransactionPartialSigner` interfaces that do not sign anything. Namely, signing a transaction or a message will return an empty `SignatureDictionary`. | ||
This signer may be useful: | ||
@@ -353,8 +347,26 @@ | ||
### Types | ||
#### `NoopSigner<TAddress>` | ||
Defines a Noop (No-Operation) signer. | ||
```ts | ||
const myNoopSigner: NoopSigner; | ||
myNoopSigner satisfies MessagePartialSigner; | ||
myNoopSigner satisfies TransactionPartialSigner; | ||
``` | ||
### Functions | ||
#### `createNoopSigner()` | ||
Creates a Noop (No-Operation) signer from a given address. | ||
```ts | ||
import { createNoopSigner } from '@solana/signers'; | ||
const myAddress = address('1234..5678'); | ||
const myNoopSigner = createNoopSigner(myAddress); | ||
// ^ MessagePartialSigner<'1234..5678'> & TransactionPartialSigner<'1234..5678'> | ||
const myNoopSigner = createNoopSigner(address('1234..5678')); | ||
const [myMessageSignatures] = await myNoopSigner.signMessages([myMessage]); // <- Empty signature dictionary. | ||
const [myTransactionSignatures] = await myNoopSigner.signTransactions([myTransaction]); // <- Empty signature dictionary. | ||
``` | ||
@@ -364,8 +376,198 @@ | ||
This package defines an alternative definition for account metas that allows us to store `TransactionSigners` inside them. This means each instruction can keep track of its own set of signers and, by extension, so can transactions. | ||
It also provides helper functions that deduplicate and extract signers from instructions and transactions which makes it possible to sign an entire transaction automatically as we will see in the next section. | ||
### Types | ||
_Coming soon..._ | ||
#### `IAccountSignerMeta` | ||
Alternative `IAccountMeta` definition for signer accounts that allows us to store `TransactionSigners` inside it. | ||
```ts | ||
const mySignerMeta: IAccountSignerMeta = { | ||
address: myTransactionSigner.address, | ||
role: AccountRole.READONLY_SIGNER, | ||
signer: myTransactionSigner, | ||
}; | ||
``` | ||
#### `IInstructionWithSigners` | ||
Composable type that allows `IAccountSignerMetas` to be used inside the instruction's `accounts` array. | ||
```ts | ||
const myInstructionWithSigners: IInstruction & IInstructionWithSigners = { | ||
programAddress: address('1234..5678'), | ||
accounts: [ | ||
{ | ||
address: myTransactionSigner.address, | ||
role: AccountRole.READONLY_SIGNER, | ||
signer: myTransactionSigner, | ||
}, | ||
], | ||
}; | ||
``` | ||
#### `ITransactionWithSigners` | ||
Composable type that allows `IAccountSignerMetas` to be used inside all of the transaction's account metas. | ||
```ts | ||
const myTransactionWithSigners: BaseTransaction & ITransactionWithSigners = { | ||
instructions: [ | ||
myInstructionA as IInstruction & IInstructionWithSigners, | ||
myInstructionB as IInstruction & IInstructionWithSigners, | ||
myInstructionC as IInstruction, | ||
], | ||
version: 0, | ||
}; | ||
``` | ||
### Functions | ||
_Coming soon..._ | ||
#### `getSignersFromInstruction()` | ||
Extracts and deduplicates all signers stored inside the account metas of an instruction. | ||
```ts | ||
const mySignerA = { address: address('1111..1111'), signTransactions: async () => {} }; | ||
const mySignerB = { address: address('2222..2222'), signTransactions: async () => {} }; | ||
const myInstructionWithSigners: IInstructionWithSigners = { | ||
programAddress: address('1234..5678'), | ||
accounts: [ | ||
{ address: mySignerA.address, role: AccountRole.READONLY_SIGNER, signer: mySignerA }, | ||
{ address: mySignerB.address, role: AccountRole.WRITABLE_SIGNER, signer: mySignerB }, | ||
{ address: mySignerA.address, role: AccountRole.WRITABLE_SIGNER, signer: mySignerA }, | ||
], | ||
}; | ||
const instructionSigners = getSignersFromInstruction(myInstructionWithSigners); | ||
// ^ [mySignerA, mySignerB] | ||
``` | ||
#### `getSignersFromTransaction()` | ||
Similarly to `getSignersFromInstruction`, this function extracts and deduplicates all signers stored inside the account metas of all the instructions inside a transaction. | ||
```ts | ||
const transactionSigners = getSignersFromTransaction(myTransactionWithSigners); | ||
``` | ||
#### `addSignersToInstruction()` | ||
Helper function that adds the provided signers to any of the applicable account metas. For an account meta to match a provided signer it: | ||
- Must have a signer role (`AccountRole.READONLY_SIGNER` or `AccountRole.WRITABLE_SIGNER`). | ||
- Must have the same address as the provided signer. | ||
- Must not have an attached signer already. | ||
```ts | ||
const myInstruction: IInstruction = { | ||
accounts: [ | ||
{ address: '1111' as Address, role: AccountRole.READONLY_SIGNER }, | ||
{ address: '2222' as Address, role: AccountRole.WRITABLE_SIGNER }, | ||
], | ||
// ... | ||
}; | ||
const signerA: TransactionSigner<'1111'>; | ||
const signerB: TransactionSigner<'2222'>; | ||
const myInstructionWithSigners = addSignersToInstruction([mySignerA, mySignerB], myInstruction); | ||
// myInstructionWithSigners.accounts[0].signer === mySignerA | ||
// myInstructionWithSigners.accounts[1].signer === mySignerB | ||
``` | ||
#### `addSignersToTransaction()` | ||
Similarly to `addSignersToInstruction`, this function adds signer to all the applicable account metas of all the instructions inside a transaction. | ||
```ts | ||
const myTransactionWithSigners = addSignersToTransaction(mySigners, myTransaction); | ||
``` | ||
## Signing transactions with signers | ||
As we've seen in the previous section, we can store and extract `TransactionSigners` from instructions and transactions. This allows us to provide helper methods that sign transactions using the signers stored inside them. | ||
### Functions | ||
#### `partiallySignTransactionWithSigners()` | ||
Extracts all signers inside the provided transaction and uses them to sign it. It first uses all `TransactionModifyingSigners` sequentially before using all `TransactionPartialSigners` in parallel. | ||
If a composite signer implements both interfaces, it will be used as a modifying signer if no other signer implements that interface. Otherwise, it will be used as a partial signer. | ||
```ts | ||
const mySignedTransaction = await partiallySignTransactionWithSigners(myTransaction); | ||
``` | ||
It also accepts an optional `AbortSignal` that will be propagated to all signers. | ||
```ts | ||
const mySignedTransaction = await partiallySignTransactionWithSigners(myTransaction, { | ||
abortSignal: myAbortController.signal, | ||
}); | ||
``` | ||
Finally, note that this function ignores `TransactionSendingSigners` as it does not send the transaction. See the `signAndSendTransactionWithSigners` function below for more details on how to use sending signers. | ||
#### `signTransactionWithSigners()` | ||
This function works the same as the `partiallySignTransactionWithSigners` function described above except that it also ensures the transaction is fully signed before returning it. An error will be thrown if that's not the case. | ||
```ts | ||
const mySignedTransaction = await signTransactionWithSigners(myTransaction); | ||
// With additional config. | ||
const mySignedTransaction = await signTransactionWithSigners(myTransaction, { | ||
abortSignal: myAbortController.signal, | ||
}); | ||
// We now know the transaction is fully signed. | ||
mySignedTransaction satisfies IFullySignedTransaction; | ||
``` | ||
#### `signAndSendTransactionWithSigners()` | ||
Extracts all signers inside the provided transaction and uses them to sign it before sending it immediately to the blockchain. It returns the signature of the sent transaction (i.e. its identifier). | ||
```ts | ||
const myTransactionSignature = await signAndSendTransactionWithSigners(myTransaction); | ||
// With additional config. | ||
const myTransactionSignature = await signAndSendTransactionWithSigners(myTransaction, { | ||
abortSignal: myAbortController.signal, | ||
}); | ||
``` | ||
Similarly to the `partiallySignTransactionWithSigners` function, it first uses all `TransactionModifyingSigners` sequentially before using all `TransactionPartialSigners` in parallel. It then sends the transaction using the `TransactionSendingSigner` it identified. | ||
Here as well, composite transaction signers are treated such that at least one sending signer is used if any. When a `TransactionSigner` implements more than one interface, use it as a: | ||
- `TransactionSendingSigner`, if no other `TransactionSendingSigner` exists. | ||
- `TransactionModifyingSigner`, if no other `TransactionModifyingSigner` exists. | ||
- `TransactionPartialSigner`, otherwise. | ||
The provided transaction must be of type `ITransactionWithSingleSendingSigner` meaning that it must contain exactly one `TransactionSendingSigner` inside its account metas. If more than one composite signers implement the `TransactionSendingSigner` interface, one of them will be selected as the sending signer. | ||
Therefore, you may use the `assertIsTransactionWithSingleSendingSigner()` function to ensure the transaction is of the expected type. | ||
```ts | ||
assertIsTransactionWithSingleSendingSigner(myTransaction); | ||
const myTransactionSignature = await signAndSendTransactionWithSigners(myTransaction); | ||
``` | ||
Alternatively, you may use the `isTransactionWithSingleSendingSigner()` function to provide a fallback in case the transaction does not contain any sending signer. | ||
```ts | ||
let transactionSignature: SignatureBytes; | ||
if (isTransactionWithSingleSendingSigner(transaction)) { | ||
transactionSignature = await signAndSendTransactionWithSigners(transaction); | ||
} else { | ||
const signedTransaction = await signTransactionWithSigners(transaction); | ||
const encodedTransaction = getBase64EncodedWireTransaction(signedTransaction); | ||
transactionSignature = await rpc.sendTransaction(encodedTransaction).send(); | ||
} | ||
``` |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
606147
26137
51
3477
571
4
48
+ Added@solana/addresses@2.0.0-experimental.fb88a79(transitive)
+ Added@solana/assertions@2.0.0-experimental.fb88a79(transitive)
+ Added@solana/codecs-core@2.0.0-experimental.fb88a79(transitive)
+ Added@solana/codecs-data-structures@2.0.0-experimental.fb88a79(transitive)
+ Added@solana/codecs-numbers@2.0.0-experimental.fb88a79(transitive)
+ Added@solana/codecs-strings@2.0.0-experimental.fb88a79(transitive)
+ Added@solana/functional@2.0.0-experimental.fb88a79(transitive)
+ Added@solana/instructions@2.0.0-experimental.fb88a79(transitive)
+ Added@solana/keys@2.0.0-experimental.fb88a79(transitive)
+ Added@solana/transactions@2.0.0-experimental.fb88a79(transitive)
- Removed@solana/addresses@2.0.0-experimental.efe6f4d(transitive)
- Removed@solana/assertions@2.0.0-experimental.efe6f4d(transitive)
- Removed@solana/codecs-core@2.0.0-experimental.efe6f4d(transitive)
- Removed@solana/codecs-data-structures@2.0.0-experimental.efe6f4d(transitive)
- Removed@solana/codecs-numbers@2.0.0-experimental.efe6f4d(transitive)
- Removed@solana/codecs-strings@2.0.0-experimental.efe6f4d(transitive)
- Removed@solana/functional@2.0.0-experimental.efe6f4d(transitive)
- Removed@solana/keys@2.0.0-experimental.efe6f4d(transitive)
- Removed@solana/transactions@2.0.0-experimental.efe6f4d(transitive)