@solana/transaction-messages
Advanced tools
Comparing version 2.0.0-preview.1.20240408102000.ab044e4b4f8458f4c1d833ef9dd87900017be890 to 2.0.0-preview.1.20240408102359.1bb084fa1a000c52fb7e48683164eabc912f8fef
import { SolanaError, SOLANA_ERROR__TRANSACTION__EXPECTED_BLOCKHASH_LIFETIME, SOLANA_ERROR__TRANSACTION__EXPECTED_NONCE_LIFETIME, SOLANA_ERROR__TRANSACTION__INVOKED_PROGRAMS_MUST_NOT_BE_WRITABLE, SOLANA_ERROR__TRANSACTION__INVOKED_PROGRAMS_CANNOT_PAY_FEES } from '@solana/errors'; | ||
import { assertIsBlockhash } from '@solana/rpc-types'; | ||
import { getAddressEncoder, getAddressDecoder, getAddressComparator } from '@solana/addresses'; | ||
import { combineCodec } from '@solana/codecs-core'; | ||
import { getStructEncoder, getArrayEncoder, getStructDecoder, getArrayDecoder } from '@solana/codecs-data-structures'; | ||
import { getU8Encoder, getShortU16Encoder, getU8Decoder, getShortU16Decoder } from '@solana/codecs-numbers'; | ||
import { combineCodec, transformEncoder, addEncoderSizePrefix, transformDecoder, addDecoderSizePrefix } from '@solana/codecs-core'; | ||
import { getStructEncoder, getArrayEncoder, getStructDecoder, getArrayDecoder, getStructCodec, getBytesEncoder, getBytesDecoder } from '@solana/codecs-data-structures'; | ||
import { getU8Encoder, getShortU16Encoder, getU8Decoder, getShortU16Decoder, getU8Codec } from '@solana/codecs-numbers'; | ||
import { AccountRole, isSignerRole, isWritableRole, mergeRoles } from '@solana/instructions'; | ||
@@ -68,2 +68,96 @@ | ||
} | ||
var memoizedU8Encoder; | ||
function getMemoizedU8Encoder() { | ||
if (!memoizedU8Encoder) | ||
memoizedU8Encoder = getU8Encoder(); | ||
return memoizedU8Encoder; | ||
} | ||
var memoizedU8Decoder; | ||
function getMemoizedU8Decoder() { | ||
if (!memoizedU8Decoder) | ||
memoizedU8Decoder = getU8Decoder(); | ||
return memoizedU8Decoder; | ||
} | ||
var memoizedU8Codec; | ||
function getMemoizedU8Codec() { | ||
if (!memoizedU8Codec) | ||
memoizedU8Codec = getU8Codec(); | ||
return memoizedU8Codec; | ||
} | ||
function getMessageHeaderEncoder() { | ||
return getStructEncoder([ | ||
["numSignerAccounts", getMemoizedU8Encoder()], | ||
["numReadonlySignerAccounts", getMemoizedU8Encoder()], | ||
["numReadonlyNonSignerAccounts", getMemoizedU8Encoder()] | ||
]); | ||
} | ||
function getMessageHeaderDecoder() { | ||
return getStructDecoder([ | ||
["numSignerAccounts", getMemoizedU8Decoder()], | ||
["numReadonlySignerAccounts", getMemoizedU8Decoder()], | ||
["numReadonlyNonSignerAccounts", getMemoizedU8Decoder()] | ||
]); | ||
} | ||
function getMessageHeaderCodec() { | ||
return getStructCodec([ | ||
["numSignerAccounts", getMemoizedU8Codec()], | ||
["numReadonlySignerAccounts", getMemoizedU8Codec()], | ||
["numReadonlyNonSignerAccounts", getMemoizedU8Codec()] | ||
]); | ||
} | ||
var memoizedGetInstructionEncoder; | ||
function getInstructionEncoder() { | ||
if (!memoizedGetInstructionEncoder) { | ||
memoizedGetInstructionEncoder = transformEncoder( | ||
getStructEncoder([ | ||
["programAddressIndex", getU8Encoder()], | ||
["accountIndices", getArrayEncoder(getU8Encoder(), { size: getShortU16Encoder() })], | ||
["data", addEncoderSizePrefix(getBytesEncoder(), getShortU16Encoder())] | ||
]), | ||
// Convert an instruction to have all fields defined | ||
(instruction) => { | ||
if (instruction.accountIndices !== void 0 && instruction.data !== void 0) { | ||
return instruction; | ||
} | ||
return { | ||
...instruction, | ||
accountIndices: instruction.accountIndices ?? [], | ||
data: instruction.data ?? new Uint8Array(0) | ||
}; | ||
} | ||
); | ||
} | ||
return memoizedGetInstructionEncoder; | ||
} | ||
var memoizedGetInstructionDecoder; | ||
function getInstructionDecoder() { | ||
if (!memoizedGetInstructionDecoder) { | ||
memoizedGetInstructionDecoder = transformDecoder( | ||
getStructDecoder([ | ||
["programAddressIndex", getU8Decoder()], | ||
["accountIndices", getArrayDecoder(getU8Decoder(), { size: getShortU16Decoder() })], | ||
[ | ||
"data", | ||
addDecoderSizePrefix(getBytesDecoder(), getShortU16Decoder()) | ||
] | ||
]), | ||
// Convert an instruction to exclude optional fields if they are empty | ||
(instruction) => { | ||
if (instruction.accountIndices.length && instruction.data.byteLength) { | ||
return instruction; | ||
} | ||
const { accountIndices, data, ...rest } = instruction; | ||
return { | ||
...rest, | ||
...accountIndices.length ? { accountIndices } : null, | ||
...data.byteLength ? { data } : null | ||
}; | ||
} | ||
); | ||
} | ||
return memoizedGetInstructionDecoder; | ||
} | ||
function getInstructionCodec() { | ||
return combineCodec(getInstructionEncoder(), getInstructionDecoder()); | ||
} | ||
var AddressMapEntryType = /* @__PURE__ */ ((AddressMapEntryType2) => { | ||
@@ -270,3 +364,46 @@ AddressMapEntryType2[AddressMapEntryType2["FEE_PAYER"] = 0] = "FEE_PAYER"; | ||
} | ||
function getCompiledMessageHeader(orderedAccounts) { | ||
let numReadonlyNonSignerAccounts = 0; | ||
let numReadonlySignerAccounts = 0; | ||
let numSignerAccounts = 0; | ||
for (const account of orderedAccounts) { | ||
if ("lookupTableAddress" in account) { | ||
break; | ||
} | ||
const accountIsWritable = isWritableRole(account.role); | ||
if (isSignerRole(account.role)) { | ||
numSignerAccounts++; | ||
if (!accountIsWritable) { | ||
numReadonlySignerAccounts++; | ||
} | ||
} else if (!accountIsWritable) { | ||
numReadonlyNonSignerAccounts++; | ||
} | ||
} | ||
return { | ||
numReadonlyNonSignerAccounts, | ||
numReadonlySignerAccounts, | ||
numSignerAccounts | ||
}; | ||
} | ||
// src/compile/instructions.ts | ||
function getAccountIndex(orderedAccounts) { | ||
const out = {}; | ||
for (const [index, account] of orderedAccounts.entries()) { | ||
out[account.address] = index; | ||
} | ||
return out; | ||
} | ||
function getCompiledInstructions(instructions, orderedAccounts) { | ||
const accountIndex = getAccountIndex(orderedAccounts); | ||
return instructions.map(({ accounts, data, programAddress }) => { | ||
return { | ||
programAddressIndex: accountIndex[programAddress], | ||
...accounts ? { accountIndices: accounts.map(({ address }) => accountIndex[address]) } : null, | ||
...data ? { data } : null | ||
}; | ||
}); | ||
} | ||
// src/create-transaction-message.ts | ||
@@ -395,4 +532,4 @@ function createTransactionMessage({ | ||
export { ADDRESS_MAP_TYPE_PROPERTY, AddressMapEntryType, appendTransactionMessageInstruction, appendTransactionMessageInstructions, assertIsDurableNonceTransactionMessage, assertIsTransactionMessageWithBlockhashLifetime, createTransactionMessage, getAddressMapFromInstructions, getAddressTableLookupCodec, getAddressTableLookupDecoder, getAddressTableLookupEncoder, getCompiledAddressTableLookups, getOrderedAccountsFromAddressMap, newIsAdvanceNonceAccountInstruction, prependTransactionMessageInstruction, prependTransactionMessageInstructions, setTransactionMessageFeePayer, setTransactionMessageLifetimeUsingBlockhash, setTransactionMessageLifetimeUsingDurableNonce }; | ||
export { ADDRESS_MAP_TYPE_PROPERTY, AddressMapEntryType, appendTransactionMessageInstruction, appendTransactionMessageInstructions, assertIsDurableNonceTransactionMessage, assertIsTransactionMessageWithBlockhashLifetime, createTransactionMessage, getAddressMapFromInstructions, getAddressTableLookupCodec, getAddressTableLookupDecoder, getAddressTableLookupEncoder, getCompiledAddressTableLookups, getCompiledInstructions, getCompiledMessageHeader, getInstructionCodec, getInstructionDecoder, getInstructionEncoder, getMessageHeaderCodec, getMessageHeaderDecoder, getMessageHeaderEncoder, getOrderedAccountsFromAddressMap, newIsAdvanceNonceAccountInstruction, prependTransactionMessageInstruction, prependTransactionMessageInstructions, setTransactionMessageFeePayer, setTransactionMessageLifetimeUsingBlockhash, setTransactionMessageLifetimeUsingDurableNonce }; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.browser.js.map |
import { SolanaError, SOLANA_ERROR__TRANSACTION__EXPECTED_BLOCKHASH_LIFETIME, SOLANA_ERROR__TRANSACTION__EXPECTED_NONCE_LIFETIME, SOLANA_ERROR__TRANSACTION__INVOKED_PROGRAMS_MUST_NOT_BE_WRITABLE, SOLANA_ERROR__TRANSACTION__INVOKED_PROGRAMS_CANNOT_PAY_FEES } from '@solana/errors'; | ||
import { assertIsBlockhash } from '@solana/rpc-types'; | ||
import { getAddressEncoder, getAddressDecoder, getAddressComparator } from '@solana/addresses'; | ||
import { combineCodec } from '@solana/codecs-core'; | ||
import { getStructEncoder, getArrayEncoder, getStructDecoder, getArrayDecoder } from '@solana/codecs-data-structures'; | ||
import { getU8Encoder, getShortU16Encoder, getU8Decoder, getShortU16Decoder } from '@solana/codecs-numbers'; | ||
import { combineCodec, transformEncoder, addEncoderSizePrefix, transformDecoder, addDecoderSizePrefix } from '@solana/codecs-core'; | ||
import { getStructEncoder, getArrayEncoder, getStructDecoder, getArrayDecoder, getStructCodec, getBytesEncoder, getBytesDecoder } from '@solana/codecs-data-structures'; | ||
import { getU8Encoder, getShortU16Encoder, getU8Decoder, getShortU16Decoder, getU8Codec } from '@solana/codecs-numbers'; | ||
import { AccountRole, isSignerRole, isWritableRole, mergeRoles } from '@solana/instructions'; | ||
@@ -68,2 +68,96 @@ | ||
} | ||
var memoizedU8Encoder; | ||
function getMemoizedU8Encoder() { | ||
if (!memoizedU8Encoder) | ||
memoizedU8Encoder = getU8Encoder(); | ||
return memoizedU8Encoder; | ||
} | ||
var memoizedU8Decoder; | ||
function getMemoizedU8Decoder() { | ||
if (!memoizedU8Decoder) | ||
memoizedU8Decoder = getU8Decoder(); | ||
return memoizedU8Decoder; | ||
} | ||
var memoizedU8Codec; | ||
function getMemoizedU8Codec() { | ||
if (!memoizedU8Codec) | ||
memoizedU8Codec = getU8Codec(); | ||
return memoizedU8Codec; | ||
} | ||
function getMessageHeaderEncoder() { | ||
return getStructEncoder([ | ||
["numSignerAccounts", getMemoizedU8Encoder()], | ||
["numReadonlySignerAccounts", getMemoizedU8Encoder()], | ||
["numReadonlyNonSignerAccounts", getMemoizedU8Encoder()] | ||
]); | ||
} | ||
function getMessageHeaderDecoder() { | ||
return getStructDecoder([ | ||
["numSignerAccounts", getMemoizedU8Decoder()], | ||
["numReadonlySignerAccounts", getMemoizedU8Decoder()], | ||
["numReadonlyNonSignerAccounts", getMemoizedU8Decoder()] | ||
]); | ||
} | ||
function getMessageHeaderCodec() { | ||
return getStructCodec([ | ||
["numSignerAccounts", getMemoizedU8Codec()], | ||
["numReadonlySignerAccounts", getMemoizedU8Codec()], | ||
["numReadonlyNonSignerAccounts", getMemoizedU8Codec()] | ||
]); | ||
} | ||
var memoizedGetInstructionEncoder; | ||
function getInstructionEncoder() { | ||
if (!memoizedGetInstructionEncoder) { | ||
memoizedGetInstructionEncoder = transformEncoder( | ||
getStructEncoder([ | ||
["programAddressIndex", getU8Encoder()], | ||
["accountIndices", getArrayEncoder(getU8Encoder(), { size: getShortU16Encoder() })], | ||
["data", addEncoderSizePrefix(getBytesEncoder(), getShortU16Encoder())] | ||
]), | ||
// Convert an instruction to have all fields defined | ||
(instruction) => { | ||
if (instruction.accountIndices !== void 0 && instruction.data !== void 0) { | ||
return instruction; | ||
} | ||
return { | ||
...instruction, | ||
accountIndices: instruction.accountIndices ?? [], | ||
data: instruction.data ?? new Uint8Array(0) | ||
}; | ||
} | ||
); | ||
} | ||
return memoizedGetInstructionEncoder; | ||
} | ||
var memoizedGetInstructionDecoder; | ||
function getInstructionDecoder() { | ||
if (!memoizedGetInstructionDecoder) { | ||
memoizedGetInstructionDecoder = transformDecoder( | ||
getStructDecoder([ | ||
["programAddressIndex", getU8Decoder()], | ||
["accountIndices", getArrayDecoder(getU8Decoder(), { size: getShortU16Decoder() })], | ||
[ | ||
"data", | ||
addDecoderSizePrefix(getBytesDecoder(), getShortU16Decoder()) | ||
] | ||
]), | ||
// Convert an instruction to exclude optional fields if they are empty | ||
(instruction) => { | ||
if (instruction.accountIndices.length && instruction.data.byteLength) { | ||
return instruction; | ||
} | ||
const { accountIndices, data, ...rest } = instruction; | ||
return { | ||
...rest, | ||
...accountIndices.length ? { accountIndices } : null, | ||
...data.byteLength ? { data } : null | ||
}; | ||
} | ||
); | ||
} | ||
return memoizedGetInstructionDecoder; | ||
} | ||
function getInstructionCodec() { | ||
return combineCodec(getInstructionEncoder(), getInstructionDecoder()); | ||
} | ||
var AddressMapEntryType = /* @__PURE__ */ ((AddressMapEntryType2) => { | ||
@@ -270,3 +364,46 @@ AddressMapEntryType2[AddressMapEntryType2["FEE_PAYER"] = 0] = "FEE_PAYER"; | ||
} | ||
function getCompiledMessageHeader(orderedAccounts) { | ||
let numReadonlyNonSignerAccounts = 0; | ||
let numReadonlySignerAccounts = 0; | ||
let numSignerAccounts = 0; | ||
for (const account of orderedAccounts) { | ||
if ("lookupTableAddress" in account) { | ||
break; | ||
} | ||
const accountIsWritable = isWritableRole(account.role); | ||
if (isSignerRole(account.role)) { | ||
numSignerAccounts++; | ||
if (!accountIsWritable) { | ||
numReadonlySignerAccounts++; | ||
} | ||
} else if (!accountIsWritable) { | ||
numReadonlyNonSignerAccounts++; | ||
} | ||
} | ||
return { | ||
numReadonlyNonSignerAccounts, | ||
numReadonlySignerAccounts, | ||
numSignerAccounts | ||
}; | ||
} | ||
// src/compile/instructions.ts | ||
function getAccountIndex(orderedAccounts) { | ||
const out = {}; | ||
for (const [index, account] of orderedAccounts.entries()) { | ||
out[account.address] = index; | ||
} | ||
return out; | ||
} | ||
function getCompiledInstructions(instructions, orderedAccounts) { | ||
const accountIndex = getAccountIndex(orderedAccounts); | ||
return instructions.map(({ accounts, data, programAddress }) => { | ||
return { | ||
programAddressIndex: accountIndex[programAddress], | ||
...accounts ? { accountIndices: accounts.map(({ address }) => accountIndex[address]) } : null, | ||
...data ? { data } : null | ||
}; | ||
}); | ||
} | ||
// src/create-transaction-message.ts | ||
@@ -395,4 +532,4 @@ function createTransactionMessage({ | ||
export { ADDRESS_MAP_TYPE_PROPERTY, AddressMapEntryType, appendTransactionMessageInstruction, appendTransactionMessageInstructions, assertIsDurableNonceTransactionMessage, assertIsTransactionMessageWithBlockhashLifetime, createTransactionMessage, getAddressMapFromInstructions, getAddressTableLookupCodec, getAddressTableLookupDecoder, getAddressTableLookupEncoder, getCompiledAddressTableLookups, getOrderedAccountsFromAddressMap, newIsAdvanceNonceAccountInstruction, prependTransactionMessageInstruction, prependTransactionMessageInstructions, setTransactionMessageFeePayer, setTransactionMessageLifetimeUsingBlockhash, setTransactionMessageLifetimeUsingDurableNonce }; | ||
export { ADDRESS_MAP_TYPE_PROPERTY, AddressMapEntryType, appendTransactionMessageInstruction, appendTransactionMessageInstructions, assertIsDurableNonceTransactionMessage, assertIsTransactionMessageWithBlockhashLifetime, createTransactionMessage, getAddressMapFromInstructions, getAddressTableLookupCodec, getAddressTableLookupDecoder, getAddressTableLookupEncoder, getCompiledAddressTableLookups, getCompiledInstructions, getCompiledMessageHeader, getInstructionCodec, getInstructionDecoder, getInstructionEncoder, getMessageHeaderCodec, getMessageHeaderDecoder, getMessageHeaderEncoder, getOrderedAccountsFromAddressMap, newIsAdvanceNonceAccountInstruction, prependTransactionMessageInstruction, prependTransactionMessageInstructions, setTransactionMessageFeePayer, setTransactionMessageLifetimeUsingBlockhash, setTransactionMessageLifetimeUsingDurableNonce }; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.native.js.map |
import { SolanaError, SOLANA_ERROR__TRANSACTION__EXPECTED_BLOCKHASH_LIFETIME, SOLANA_ERROR__TRANSACTION__EXPECTED_NONCE_LIFETIME, SOLANA_ERROR__TRANSACTION__INVOKED_PROGRAMS_MUST_NOT_BE_WRITABLE, SOLANA_ERROR__TRANSACTION__INVOKED_PROGRAMS_CANNOT_PAY_FEES } from '@solana/errors'; | ||
import { assertIsBlockhash } from '@solana/rpc-types'; | ||
import { getAddressEncoder, getAddressDecoder, getAddressComparator } from '@solana/addresses'; | ||
import { combineCodec } from '@solana/codecs-core'; | ||
import { getStructEncoder, getArrayEncoder, getStructDecoder, getArrayDecoder } from '@solana/codecs-data-structures'; | ||
import { getU8Encoder, getShortU16Encoder, getU8Decoder, getShortU16Decoder } from '@solana/codecs-numbers'; | ||
import { combineCodec, transformEncoder, addEncoderSizePrefix, transformDecoder, addDecoderSizePrefix } from '@solana/codecs-core'; | ||
import { getStructEncoder, getArrayEncoder, getStructDecoder, getArrayDecoder, getStructCodec, getBytesEncoder, getBytesDecoder } from '@solana/codecs-data-structures'; | ||
import { getU8Encoder, getShortU16Encoder, getU8Decoder, getShortU16Decoder, getU8Codec } from '@solana/codecs-numbers'; | ||
import { AccountRole, isSignerRole, isWritableRole, mergeRoles } from '@solana/instructions'; | ||
@@ -68,2 +68,96 @@ | ||
} | ||
var memoizedU8Encoder; | ||
function getMemoizedU8Encoder() { | ||
if (!memoizedU8Encoder) | ||
memoizedU8Encoder = getU8Encoder(); | ||
return memoizedU8Encoder; | ||
} | ||
var memoizedU8Decoder; | ||
function getMemoizedU8Decoder() { | ||
if (!memoizedU8Decoder) | ||
memoizedU8Decoder = getU8Decoder(); | ||
return memoizedU8Decoder; | ||
} | ||
var memoizedU8Codec; | ||
function getMemoizedU8Codec() { | ||
if (!memoizedU8Codec) | ||
memoizedU8Codec = getU8Codec(); | ||
return memoizedU8Codec; | ||
} | ||
function getMessageHeaderEncoder() { | ||
return getStructEncoder([ | ||
["numSignerAccounts", getMemoizedU8Encoder()], | ||
["numReadonlySignerAccounts", getMemoizedU8Encoder()], | ||
["numReadonlyNonSignerAccounts", getMemoizedU8Encoder()] | ||
]); | ||
} | ||
function getMessageHeaderDecoder() { | ||
return getStructDecoder([ | ||
["numSignerAccounts", getMemoizedU8Decoder()], | ||
["numReadonlySignerAccounts", getMemoizedU8Decoder()], | ||
["numReadonlyNonSignerAccounts", getMemoizedU8Decoder()] | ||
]); | ||
} | ||
function getMessageHeaderCodec() { | ||
return getStructCodec([ | ||
["numSignerAccounts", getMemoizedU8Codec()], | ||
["numReadonlySignerAccounts", getMemoizedU8Codec()], | ||
["numReadonlyNonSignerAccounts", getMemoizedU8Codec()] | ||
]); | ||
} | ||
var memoizedGetInstructionEncoder; | ||
function getInstructionEncoder() { | ||
if (!memoizedGetInstructionEncoder) { | ||
memoizedGetInstructionEncoder = transformEncoder( | ||
getStructEncoder([ | ||
["programAddressIndex", getU8Encoder()], | ||
["accountIndices", getArrayEncoder(getU8Encoder(), { size: getShortU16Encoder() })], | ||
["data", addEncoderSizePrefix(getBytesEncoder(), getShortU16Encoder())] | ||
]), | ||
// Convert an instruction to have all fields defined | ||
(instruction) => { | ||
if (instruction.accountIndices !== void 0 && instruction.data !== void 0) { | ||
return instruction; | ||
} | ||
return { | ||
...instruction, | ||
accountIndices: instruction.accountIndices ?? [], | ||
data: instruction.data ?? new Uint8Array(0) | ||
}; | ||
} | ||
); | ||
} | ||
return memoizedGetInstructionEncoder; | ||
} | ||
var memoizedGetInstructionDecoder; | ||
function getInstructionDecoder() { | ||
if (!memoizedGetInstructionDecoder) { | ||
memoizedGetInstructionDecoder = transformDecoder( | ||
getStructDecoder([ | ||
["programAddressIndex", getU8Decoder()], | ||
["accountIndices", getArrayDecoder(getU8Decoder(), { size: getShortU16Decoder() })], | ||
[ | ||
"data", | ||
addDecoderSizePrefix(getBytesDecoder(), getShortU16Decoder()) | ||
] | ||
]), | ||
// Convert an instruction to exclude optional fields if they are empty | ||
(instruction) => { | ||
if (instruction.accountIndices.length && instruction.data.byteLength) { | ||
return instruction; | ||
} | ||
const { accountIndices, data, ...rest } = instruction; | ||
return { | ||
...rest, | ||
...accountIndices.length ? { accountIndices } : null, | ||
...data.byteLength ? { data } : null | ||
}; | ||
} | ||
); | ||
} | ||
return memoizedGetInstructionDecoder; | ||
} | ||
function getInstructionCodec() { | ||
return combineCodec(getInstructionEncoder(), getInstructionDecoder()); | ||
} | ||
var AddressMapEntryType = /* @__PURE__ */ ((AddressMapEntryType2) => { | ||
@@ -270,3 +364,46 @@ AddressMapEntryType2[AddressMapEntryType2["FEE_PAYER"] = 0] = "FEE_PAYER"; | ||
} | ||
function getCompiledMessageHeader(orderedAccounts) { | ||
let numReadonlyNonSignerAccounts = 0; | ||
let numReadonlySignerAccounts = 0; | ||
let numSignerAccounts = 0; | ||
for (const account of orderedAccounts) { | ||
if ("lookupTableAddress" in account) { | ||
break; | ||
} | ||
const accountIsWritable = isWritableRole(account.role); | ||
if (isSignerRole(account.role)) { | ||
numSignerAccounts++; | ||
if (!accountIsWritable) { | ||
numReadonlySignerAccounts++; | ||
} | ||
} else if (!accountIsWritable) { | ||
numReadonlyNonSignerAccounts++; | ||
} | ||
} | ||
return { | ||
numReadonlyNonSignerAccounts, | ||
numReadonlySignerAccounts, | ||
numSignerAccounts | ||
}; | ||
} | ||
// src/compile/instructions.ts | ||
function getAccountIndex(orderedAccounts) { | ||
const out = {}; | ||
for (const [index, account] of orderedAccounts.entries()) { | ||
out[account.address] = index; | ||
} | ||
return out; | ||
} | ||
function getCompiledInstructions(instructions, orderedAccounts) { | ||
const accountIndex = getAccountIndex(orderedAccounts); | ||
return instructions.map(({ accounts, data, programAddress }) => { | ||
return { | ||
programAddressIndex: accountIndex[programAddress], | ||
...accounts ? { accountIndices: accounts.map(({ address }) => accountIndex[address]) } : null, | ||
...data ? { data } : null | ||
}; | ||
}); | ||
} | ||
// src/create-transaction-message.ts | ||
@@ -395,4 +532,4 @@ function createTransactionMessage({ | ||
export { ADDRESS_MAP_TYPE_PROPERTY, AddressMapEntryType, appendTransactionMessageInstruction, appendTransactionMessageInstructions, assertIsDurableNonceTransactionMessage, assertIsTransactionMessageWithBlockhashLifetime, createTransactionMessage, getAddressMapFromInstructions, getAddressTableLookupCodec, getAddressTableLookupDecoder, getAddressTableLookupEncoder, getCompiledAddressTableLookups, getOrderedAccountsFromAddressMap, newIsAdvanceNonceAccountInstruction, prependTransactionMessageInstruction, prependTransactionMessageInstructions, setTransactionMessageFeePayer, setTransactionMessageLifetimeUsingBlockhash, setTransactionMessageLifetimeUsingDurableNonce }; | ||
export { ADDRESS_MAP_TYPE_PROPERTY, AddressMapEntryType, appendTransactionMessageInstruction, appendTransactionMessageInstructions, assertIsDurableNonceTransactionMessage, assertIsTransactionMessageWithBlockhashLifetime, createTransactionMessage, getAddressMapFromInstructions, getAddressTableLookupCodec, getAddressTableLookupDecoder, getAddressTableLookupEncoder, getCompiledAddressTableLookups, getCompiledInstructions, getCompiledMessageHeader, getInstructionCodec, getInstructionDecoder, getInstructionEncoder, getMessageHeaderCodec, getMessageHeaderDecoder, getMessageHeaderEncoder, getOrderedAccountsFromAddressMap, newIsAdvanceNonceAccountInstruction, prependTransactionMessageInstruction, prependTransactionMessageInstructions, setTransactionMessageFeePayer, setTransactionMessageLifetimeUsingBlockhash, setTransactionMessageLifetimeUsingDurableNonce }; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.node.js.map |
export * from './address-table-lookup.js'; | ||
export * from './header.js'; | ||
export * from './instruction.js'; | ||
//# sourceMappingURL=index.d.ts.map |
export * from './accounts.js'; | ||
export * from './address-table-lookups.js'; | ||
export * from './header.js'; | ||
export * from './instructions.js'; | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "@solana/transaction-messages", | ||
"version": "2.0.0-preview.1.20240408102000.ab044e4b4f8458f4c1d833ef9dd87900017be890", | ||
"version": "2.0.0-preview.1.20240408102359.1bb084fa1a000c52fb7e48683164eabc912f8fef", | ||
"description": "Helpers for creating transaction messages", | ||
@@ -49,9 +49,9 @@ "exports": { | ||
"dependencies": { | ||
"@solana/addresses": "2.0.0-preview.1.20240408102000.ab044e4b4f8458f4c1d833ef9dd87900017be890", | ||
"@solana/codecs-core": "2.0.0-preview.1.20240408102000.ab044e4b4f8458f4c1d833ef9dd87900017be890", | ||
"@solana/codecs-data-structures": "2.0.0-preview.1.20240408102000.ab044e4b4f8458f4c1d833ef9dd87900017be890", | ||
"@solana/codecs-numbers": "2.0.0-preview.1.20240408102000.ab044e4b4f8458f4c1d833ef9dd87900017be890", | ||
"@solana/errors": "2.0.0-preview.1.20240408102000.ab044e4b4f8458f4c1d833ef9dd87900017be890", | ||
"@solana/instructions": "2.0.0-preview.1.20240408102000.ab044e4b4f8458f4c1d833ef9dd87900017be890", | ||
"@solana/rpc-types": "2.0.0-preview.1.20240408102000.ab044e4b4f8458f4c1d833ef9dd87900017be890" | ||
"@solana/addresses": "2.0.0-preview.1.20240408102359.1bb084fa1a000c52fb7e48683164eabc912f8fef", | ||
"@solana/codecs-core": "2.0.0-preview.1.20240408102359.1bb084fa1a000c52fb7e48683164eabc912f8fef", | ||
"@solana/codecs-data-structures": "2.0.0-preview.1.20240408102359.1bb084fa1a000c52fb7e48683164eabc912f8fef", | ||
"@solana/codecs-numbers": "2.0.0-preview.1.20240408102359.1bb084fa1a000c52fb7e48683164eabc912f8fef", | ||
"@solana/errors": "2.0.0-preview.1.20240408102359.1bb084fa1a000c52fb7e48683164eabc912f8fef", | ||
"@solana/instructions": "2.0.0-preview.1.20240408102359.1bb084fa1a000c52fb7e48683164eabc912f8fef", | ||
"@solana/rpc-types": "2.0.0-preview.1.20240408102359.1bb084fa1a000c52fb7e48683164eabc912f8fef" | ||
}, | ||
@@ -58,0 +58,0 @@ "bundlewatch": { |
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
382322
10824
45
2862
+ Added@solana/addresses@2.0.0-preview.1.20240408102359.1bb084fa1a000c52fb7e48683164eabc912f8fef(transitive)
+ Added@solana/assertions@2.0.0-preview.1.20240408102359.1bb084fa1a000c52fb7e48683164eabc912f8fef(transitive)
+ Added@solana/codecs-core@2.0.0-preview.1.20240408102359.1bb084fa1a000c52fb7e48683164eabc912f8fef(transitive)
+ Added@solana/codecs-data-structures@2.0.0-preview.1.20240408102359.1bb084fa1a000c52fb7e48683164eabc912f8fef(transitive)
+ Added@solana/codecs-numbers@2.0.0-preview.1.20240408102359.1bb084fa1a000c52fb7e48683164eabc912f8fef(transitive)
+ Added@solana/codecs-strings@2.0.0-preview.1.20240408102359.1bb084fa1a000c52fb7e48683164eabc912f8fef(transitive)
+ Added@solana/errors@2.0.0-preview.1.20240408102359.1bb084fa1a000c52fb7e48683164eabc912f8fef(transitive)
+ Added@solana/instructions@2.0.0-preview.1.20240408102359.1bb084fa1a000c52fb7e48683164eabc912f8fef(transitive)
+ Added@solana/rpc-types@2.0.0-preview.1.20240408102359.1bb084fa1a000c52fb7e48683164eabc912f8fef(transitive)
- Removed@solana/addresses@2.0.0-preview.1.20240408102000.ab044e4b4f8458f4c1d833ef9dd87900017be890(transitive)
- Removed@solana/assertions@2.0.0-preview.1.20240408102000.ab044e4b4f8458f4c1d833ef9dd87900017be890(transitive)
- Removed@solana/codecs-core@2.0.0-preview.1.20240408102000.ab044e4b4f8458f4c1d833ef9dd87900017be890(transitive)
- Removed@solana/codecs-data-structures@2.0.0-preview.1.20240408102000.ab044e4b4f8458f4c1d833ef9dd87900017be890(transitive)
- Removed@solana/codecs-numbers@2.0.0-preview.1.20240408102000.ab044e4b4f8458f4c1d833ef9dd87900017be890(transitive)
- Removed@solana/codecs-strings@2.0.0-preview.1.20240408102000.ab044e4b4f8458f4c1d833ef9dd87900017be890(transitive)
- Removed@solana/errors@2.0.0-preview.1.20240408102000.ab044e4b4f8458f4c1d833ef9dd87900017be890(transitive)
- Removed@solana/instructions@2.0.0-preview.1.20240408102000.ab044e4b4f8458f4c1d833ef9dd87900017be890(transitive)
- Removed@solana/rpc-types@2.0.0-preview.1.20240408102000.ab044e4b4f8458f4c1d833ef9dd87900017be890(transitive)
Updated@solana/addresses@2.0.0-preview.1.20240408102359.1bb084fa1a000c52fb7e48683164eabc912f8fef
Updated@solana/codecs-core@2.0.0-preview.1.20240408102359.1bb084fa1a000c52fb7e48683164eabc912f8fef
Updated@solana/codecs-numbers@2.0.0-preview.1.20240408102359.1bb084fa1a000c52fb7e48683164eabc912f8fef
Updated@solana/errors@2.0.0-preview.1.20240408102359.1bb084fa1a000c52fb7e48683164eabc912f8fef
Updated@solana/instructions@2.0.0-preview.1.20240408102359.1bb084fa1a000c52fb7e48683164eabc912f8fef
Updated@solana/rpc-types@2.0.0-preview.1.20240408102359.1bb084fa1a000c52fb7e48683164eabc912f8fef