@solana/transactions 2.0.0-experimental.fc4e943 → 2.0.0-experimental.fcff844
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +272 -5
- package/dist/index.browser.cjs +411 -334
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +405 -337
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +941 -1142
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +405 -335
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +411 -336
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +405 -335
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +23 -16
- package/dist/types/accounts.d.ts +2 -2
- package/dist/types/accounts.d.ts.map +1 -0
- package/dist/types/blockhash.d.ts +1 -0
- package/dist/types/blockhash.d.ts.map +1 -0
- package/dist/types/compilable-transaction.d.ts +7 -0
- package/dist/types/compilable-transaction.d.ts.map +1 -0
- package/dist/types/compile-address-table-lookups.d.ts +2 -2
- package/dist/types/compile-address-table-lookups.d.ts.map +1 -0
- package/dist/types/compile-header.d.ts.map +1 -0
- package/dist/types/compile-instructions.d.ts.map +1 -0
- package/dist/types/compile-lifetime-token.d.ts.map +1 -0
- package/dist/types/compile-static-accounts.d.ts +2 -2
- package/dist/types/compile-static-accounts.d.ts.map +1 -0
- package/dist/types/compile-transaction.d.ts +5 -6
- package/dist/types/compile-transaction.d.ts.map +1 -0
- package/dist/types/create-transaction.d.ts.map +1 -0
- package/dist/types/decompile-transaction.d.ts +5 -0
- package/dist/types/decompile-transaction.d.ts.map +1 -0
- package/dist/types/durable-nonce.d.ts +6 -6
- package/dist/types/durable-nonce.d.ts.map +1 -0
- package/dist/types/fee-payer.d.ts +4 -4
- package/dist/types/fee-payer.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/instructions.d.ts.map +1 -0
- package/dist/types/message.d.ts +1 -5
- package/dist/types/message.d.ts.map +1 -0
- package/dist/types/serializers/address-table-lookup.d.ts +5 -3
- package/dist/types/serializers/address-table-lookup.d.ts.map +1 -0
- package/dist/types/serializers/header.d.ts +4 -4
- package/dist/types/serializers/header.d.ts.map +1 -0
- package/dist/types/serializers/index.d.ts +1 -0
- package/dist/types/serializers/index.d.ts.map +1 -0
- package/dist/types/serializers/instruction.d.ts +4 -2
- package/dist/types/serializers/instruction.d.ts.map +1 -0
- package/dist/types/serializers/message.d.ts +4 -4
- package/dist/types/serializers/message.d.ts.map +1 -0
- package/dist/types/serializers/transaction-version.d.ts +4 -4
- package/dist/types/serializers/transaction-version.d.ts.map +1 -0
- package/dist/types/serializers/transaction.d.ts +6 -5
- package/dist/types/serializers/transaction.d.ts.map +1 -0
- package/dist/types/signatures.d.ts +8 -12
- package/dist/types/signatures.d.ts.map +1 -0
- package/dist/types/types.d.ts +6 -13
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/unsigned-transaction.d.ts.map +1 -0
- package/dist/types/wire-transaction.d.ts +1 -1
- package/dist/types/wire-transaction.d.ts.map +1 -0
- package/package.json +15 -14
- package/dist/types/serializers/unimplemented.d.ts +0 -3
package/dist/index.node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../build-scripts/env-shim.ts","../src/blockhash.ts","../src/unsigned-transaction.ts","../src/create-transaction.ts","../../instructions/src/roles.ts","../src/durable-nonce.ts","../src/fee-payer.ts","../src/instructions.ts","../src/serializers/transaction.ts","../src/accounts.ts","../src/compile-address-table-lookups.ts","../src/compile-header.ts","../src/compile-instructions.ts","../src/compile-lifetime-token.ts","../src/compile-static-accounts.ts","../src/message.ts","../src/compile-transaction.ts","../src/serializers/message.ts","../src/serializers/address-table-lookup.ts","../src/serializers/header.ts","../src/serializers/instruction.ts","../src/serializers/transaction-version.ts","../src/serializers/unimplemented.ts","../src/signatures.ts","../src/wire-transaction.ts"],"names":["bytes","AccountRole","array","shortU16","struct","getAddressComparator","base58","mapSerializer","getAddressCodec","u8","BASE_CONFIG","serialize"],"mappings":";AACO,IAAM,UAA2B,uBAAO,QAAgB,KAAU,EAAE,aAAa,eAAe;;;ACDvG,SAAS,cAAc;;;ACGhB,SAAS,uBACZ,aACgG;AAChG,MAAI,gBAAgB,aAAa;AAE7B,UAAM;AAAA,MACF,YAAY;AAAA;AAAA,MACZ,GAAG;AAAA,IACP,IAAI;AACJ,WAAO;AAAA,EACX,OAAO;AACH,WAAO;AAAA,EACX;AACJ;;;ADEO,SAAS,kBAAkB,mBAAmE;AACjG,MAAI;AAEA;AAAA;AAAA,MAEI,kBAAkB,SAAS;AAAA,MAE3B,kBAAkB,SAAS;AAAA,MAC7B;AACE,YAAM,IAAI,MAAM,+DAA+D;AAAA,IACnF;AAEA,UAAMA,SAAQ,OAAO,UAAU,iBAAiB;AAChD,UAAM,WAAWA,OAAM;AACvB,QAAI,aAAa,IAAI;AACjB,YAAM,IAAI,MAAM,gFAAgF,QAAQ,EAAE;AAAA,IAC9G;AAAA,EACJ,SAAS,GAAG;AACR,UAAM,IAAI,MAAM,KAAK,iBAAiB,yBAAyB;AAAA,MAC3D,OAAO;AAAA,IACX,CAAC;AAAA,EACL;AACJ;AAcO,SAAS,qCACZ,6BACA,aACF;AACE,MACI,wBAAwB,eACxB,YAAY,mBAAmB,cAAc,4BAA4B,aACzE,YAAY,mBAAmB,yBAAyB,4BAA4B,sBACtF;AACE,WAAO;AAAA,EACX;AACA,QAAM,MAAM;AAAA,IACR,GAAG,uBAAuB,WAAW;AAAA,IACrC,oBAAoB;AAAA,EACxB;AACA,SAAO,OAAO,GAAG;AACjB,SAAO;AACX;;;AE9DO,SAAS,kBAAuD;AAAA,EACnE;AACJ,GAA6C;AACzC,QAAM,MAAmB;AAAA,IACrB,cAAc,CAAC;AAAA,IACf;AAAA,EACJ;AACA,SAAO,OAAO,GAAG;AACjB,SAAO;AACX;;;ACdO,IAAK,cAAL,kBAAKC,iBAAL;A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AAsB,EAAE,UAAU,WAAW;AAC1E,MAAI,MAAY;AACZ,WAAO,OAAO,KAAK,oBAAoB,EAAE,SAAS,QAAQ;AAAA,EAC9D,OAAO;AACH,WAAQ,KAAwB,OAAO,aAAa,GAAG,oBAAoB,CAAC;AAAA,EAChF;AACJ","sourcesContent":["// Clever obfuscation to prevent the build system from inlining the value of `NODE_ENV`\nexport const __DEV__ = /* @__PURE__ */ (() => (process as any)['en' + 'v'].NODE_ENV === 'development')();\n","import { base58 } from '@metaplex-foundation/umi-serializers';\n\nimport { IDurableNonceTransaction } from './durable-nonce';\nimport { ITransactionWithSignatures } from './signatures';\nimport { BaseTransaction } from './types';\nimport { getUnsignedTransaction } from './unsigned-transaction';\n\nexport type Blockhash = string & { readonly __brand: unique symbol };\n\ntype BlockhashLifetimeConstraint = Readonly<{\n blockhash: Blockhash;\n lastValidBlockHeight: bigint;\n}>;\n\nexport interface ITransactionWithBlockhashLifetime {\n readonly lifetimeConstraint: BlockhashLifetimeConstraint;\n}\n\nexport function assertIsBlockhash(putativeBlockhash: string): asserts putativeBlockhash is Blockhash {\n try {\n // Fast-path; see if the input string is of an acceptable length.\n if (\n // Lowest value (32 bytes of zeroes)\n putativeBlockhash.length < 32 ||\n // Highest value (32 bytes of 255)\n putativeBlockhash.length > 44\n ) {\n throw new Error('Expected input string to decode to a byte array of length 32.');\n }\n // Slow-path; actually attempt to decode the input string.\n const bytes = base58.serialize(putativeBlockhash);\n const numBytes = bytes.byteLength;\n if (numBytes !== 32) {\n throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);\n }\n } catch (e) {\n throw new Error(`\\`${putativeBlockhash}\\` is not a blockhash`, {\n cause: e,\n });\n }\n}\n\nexport function setTransactionLifetimeUsingBlockhash<TTransaction extends BaseTransaction & IDurableNonceTransaction>(\n blockhashLifetimeConstraint: BlockhashLifetimeConstraint,\n transaction: TTransaction | (TTransaction & ITransactionWithSignatures)\n): Omit<TTransaction, keyof ITransactionWithSignatures | 'lifetimeConstraint'> & ITransactionWithBlockhashLifetime;\n\nexport function setTransactionLifetimeUsingBlockhash<\n TTransaction extends BaseTransaction | (BaseTransaction & ITransactionWithBlockhashLifetime)\n>(\n blockhashLifetimeConstraint: BlockhashLifetimeConstraint,\n transaction: TTransaction | (TTransaction & ITransactionWithSignatures)\n): Omit<TTransaction, keyof ITransactionWithSignatures> & ITransactionWithBlockhashLifetime;\n\nexport function setTransactionLifetimeUsingBlockhash(\n blockhashLifetimeConstraint: BlockhashLifetimeConstraint,\n transaction: BaseTransaction | (BaseTransaction & ITransactionWithBlockhashLifetime)\n) {\n if (\n 'lifetimeConstraint' in transaction &&\n transaction.lifetimeConstraint.blockhash === blockhashLifetimeConstraint.blockhash &&\n transaction.lifetimeConstraint.lastValidBlockHeight === blockhashLifetimeConstraint.lastValidBlockHeight\n ) {\n return transaction;\n }\n const out = {\n ...getUnsignedTransaction(transaction),\n lifetimeConstraint: blockhashLifetimeConstraint,\n };\n Object.freeze(out);\n return out;\n}\n","import { ITransactionWithSignatures } from '.';\nimport { BaseTransaction } from './types';\n\nexport function getUnsignedTransaction<TTransaction extends BaseTransaction>(\n transaction: TTransaction | (TTransaction & ITransactionWithSignatures)\n): TTransaction | Omit<TTransaction & ITransactionWithSignatures, keyof ITransactionWithSignatures> {\n if ('signatures' in transaction) {\n // The implication of the lifetime constraint changing is that any existing signatures are invalid.\n const {\n signatures: _, // eslint-disable-line @typescript-eslint/no-unused-vars\n ...unsignedTransaction\n } = transaction;\n return unsignedTransaction;\n } else {\n return transaction;\n }\n}\n","import { Transaction, TransactionVersion } from './types';\n\ntype TransactionConfig<TVersion extends TransactionVersion> = Readonly<{\n version: TVersion;\n}>;\n\nexport function createTransaction<TVersion extends TransactionVersion>(\n config: TransactionConfig<TVersion>\n): Extract<Transaction, { version: TVersion }>;\nexport function createTransaction<TVersion extends TransactionVersion>({\n version,\n}: TransactionConfig<TVersion>): Transaction {\n const out: Transaction = {\n instructions: [],\n version,\n };\n Object.freeze(out);\n return out;\n}\n","/**\n * Quick primer on bitwise operations: https://stackoverflow.com/a/1436448/802047\n */\n\nexport enum AccountRole {\n // Bitflag guide: is signer ⌄⌄ is writable\n WRITABLE_SIGNER = /* 3 */ 0b11, // prettier-ignore\n READONLY_SIGNER = /* 2 */ 0b10, // prettier-ignore\n WRITABLE = /* 1 */ 0b01, // prettier-ignore\n READONLY = /* 0 */ 0b00, // prettier-ignore\n}\n\nconst IS_SIGNER_BITMASK = 0b10;\nconst IS_WRITABLE_BITMASK = 0b01;\n\nexport function downgradeRoleToNonSigner(role: AccountRole.READONLY_SIGNER): AccountRole.READONLY;\nexport function downgradeRoleToNonSigner(role: AccountRole.WRITABLE_SIGNER): AccountRole.WRITABLE;\nexport function downgradeRoleToNonSigner(role: AccountRole): AccountRole;\nexport function downgradeRoleToNonSigner(role: AccountRole): AccountRole {\n return role & ~IS_SIGNER_BITMASK;\n}\n\nexport function downgradeRoleToReadonly(role: AccountRole.WRITABLE): AccountRole.READONLY;\nexport function downgradeRoleToReadonly(role: AccountRole.WRITABLE_SIGNER): AccountRole.READONLY_SIGNER;\nexport function downgradeRoleToReadonly(role: AccountRole): AccountRole;\nexport function downgradeRoleToReadonly(role: AccountRole): AccountRole {\n return role & ~IS_WRITABLE_BITMASK;\n}\n\nexport function isSignerRole(role: AccountRole): role is AccountRole.READONLY_SIGNER | AccountRole.WRITABLE_SIGNER {\n return role >= AccountRole.READONLY_SIGNER;\n}\n\nexport function isWritableRole(role: AccountRole): role is AccountRole.WRITABLE | AccountRole.WRITABLE_SIGNER {\n return (role & IS_WRITABLE_BITMASK) !== 0;\n}\n\nexport function mergeRoles(roleA: AccountRole.WRITABLE, roleB: AccountRole.READONLY_SIGNER): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY_SIGNER, roleB: AccountRole.WRITABLE): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.WRITABLE_SIGNER): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.WRITABLE_SIGNER, roleB: AccountRole): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.READONLY_SIGNER): AccountRole.READONLY_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY_SIGNER, roleB: AccountRole): AccountRole.READONLY_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.WRITABLE): AccountRole.WRITABLE; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.WRITABLE, roleB: AccountRole): AccountRole.WRITABLE; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY, roleB: AccountRole.READONLY): AccountRole.READONLY; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole): AccountRole; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole): AccountRole {\n return roleA | roleB;\n}\n\nexport function upgradeRoleToSigner(role: AccountRole.READONLY): AccountRole.READONLY_SIGNER;\nexport function upgradeRoleToSigner(role: AccountRole.WRITABLE): AccountRole.WRITABLE_SIGNER;\nexport function upgradeRoleToSigner(role: AccountRole): AccountRole;\nexport function upgradeRoleToSigner(role: AccountRole): AccountRole {\n return role | IS_SIGNER_BITMASK;\n}\n\nexport function upgradeRoleToWritable(role: AccountRole.READONLY): AccountRole.WRITABLE;\nexport function upgradeRoleToWritable(role: AccountRole.READONLY_SIGNER): AccountRole.WRITABLE_SIGNER;\nexport function upgradeRoleToWritable(role: AccountRole): AccountRole;\nexport function upgradeRoleToWritable(role: AccountRole): AccountRole {\n return role | IS_WRITABLE_BITMASK;\n}\n","import { Base58EncodedAddress } from '@solana/addresses';\nimport { AccountRole, IInstruction, IInstructionWithAccounts, IInstructionWithData } from '@solana/instructions';\nimport { ReadonlyAccount, ReadonlySignerAccount, WritableAccount } from '@solana/instructions/dist/types/accounts';\n\nimport { ITransactionWithSignatures } from './signatures';\nimport { BaseTransaction } from './types';\nimport { getUnsignedTransaction } from './unsigned-transaction';\n\ntype AdvanceNonceAccountInstruction<\n TNonceAccountAddress extends string = string,\n TNonceAuthorityAddress extends string = string\n> = IInstruction<'11111111111111111111111111111111'> &\n IInstructionWithAccounts<\n readonly [\n WritableAccount<TNonceAccountAddress>,\n ReadonlyAccount<'SysvarRecentB1ockHashes11111111111111111111'>,\n ReadonlySignerAccount<TNonceAuthorityAddress>\n ]\n > &\n IInstructionWithData<AdvanceNonceAccountInstructionData>;\ntype AdvanceNonceAccountInstructionData = Uint8Array & {\n readonly __brand: unique symbol;\n};\ntype DurableNonceConfig<\n TNonceAccountAddress extends string = string,\n TNonceAuthorityAddress extends string = string,\n TNonceValue extends string = string\n> = Readonly<{\n readonly nonce: Nonce<TNonceValue>;\n readonly nonceAccountAddress: Base58EncodedAddress<TNonceAccountAddress>;\n readonly nonceAuthorityAddress: Base58EncodedAddress<TNonceAuthorityAddress>;\n}>;\nexport type Nonce<TNonceValue extends string = string> = TNonceValue & { readonly __brand: unique symbol };\ntype NonceLifetimeConstraint<TNonceValue extends string = string> = Readonly<{\n nonce: Nonce<TNonceValue>;\n}>;\n\nconst RECENT_BLOCKHASHES_SYSVAR_ADDRESS =\n 'SysvarRecentB1ockHashes11111111111111111111' as Base58EncodedAddress<'SysvarRecentB1ockHashes11111111111111111111'>;\nconst SYSTEM_PROGRAM_ADDRESS =\n '11111111111111111111111111111111' as Base58EncodedAddress<'11111111111111111111111111111111'>;\n\nexport interface IDurableNonceTransaction<\n TNonceAccountAddress extends string = string,\n TNonceAuthorityAddress extends string = string,\n TNonceValue extends string = string\n> {\n readonly instructions: readonly [\n // The first instruction *must* be the system program's `AdvanceNonceAccount` instruction.\n AdvanceNonceAccountInstruction<TNonceAccountAddress, TNonceAuthorityAddress>,\n ...IInstruction[]\n ];\n readonly lifetimeConstraint: NonceLifetimeConstraint<TNonceValue>;\n}\n\nexport function assertIsDurableNonceTransaction(\n transaction: BaseTransaction | (BaseTransaction & IDurableNonceTransaction)\n): asserts transaction is BaseTransaction & IDurableNonceTransaction {\n if (!isDurableNonceTransaction(transaction)) {\n // TODO: Coded error.\n throw new Error('Transaction is not a durable nonce transaction');\n }\n}\n\nfunction createAdvanceNonceAccountInstruction<\n TNonceAccountAddress extends string = string,\n TNonceAuthorityAddress extends string = string\n>(\n nonceAccountAddress: Base58EncodedAddress<TNonceAccountAddress>,\n nonceAuthorityAddress: Base58EncodedAddress<TNonceAuthorityAddress>\n): AdvanceNonceAccountInstruction<TNonceAccountAddress, TNonceAuthorityAddress> {\n return {\n accounts: [\n { address: nonceAccountAddress, role: AccountRole.WRITABLE },\n {\n address: RECENT_BLOCKHASHES_SYSVAR_ADDRESS,\n role: AccountRole.READONLY,\n },\n { address: nonceAuthorityAddress, role: AccountRole.READONLY_SIGNER },\n ],\n data: new Uint8Array([4, 0, 0, 0]) as AdvanceNonceAccountInstructionData,\n programAddress: SYSTEM_PROGRAM_ADDRESS,\n };\n}\n\nfunction isAdvanceNonceAccountInstruction(instruction: IInstruction): instruction is AdvanceNonceAccountInstruction {\n return (\n instruction.programAddress === SYSTEM_PROGRAM_ADDRESS &&\n // Test for `AdvanceNonceAccount` instruction data\n instruction.data != null &&\n isAdvanceNonceAccountInstructionData(instruction.data) &&\n // Test for exactly 3 accounts\n instruction.accounts?.length === 3 &&\n // First account is nonce account address\n instruction.accounts[0].address != null &&\n instruction.accounts[0].role === AccountRole.WRITABLE &&\n // Second account is recent blockhashes sysvar\n instruction.accounts[1].address === RECENT_BLOCKHASHES_SYSVAR_ADDRESS &&\n instruction.accounts[1].role === AccountRole.READONLY &&\n // Third account is nonce authority account\n instruction.accounts[2].address != null &&\n instruction.accounts[2].role === AccountRole.READONLY_SIGNER\n );\n}\n\nfunction isAdvanceNonceAccountInstructionData(data: Uint8Array): data is AdvanceNonceAccountInstructionData {\n // AdvanceNonceAccount is the fifth instruction in the System Program (index 4)\n return data.byteLength === 4 && data[0] === 4 && data[1] === 0 && data[2] === 0 && data[3] === 0;\n}\n\nfunction isDurableNonceTransaction(\n transaction: BaseTransaction | (BaseTransaction & IDurableNonceTransaction)\n): transaction is BaseTransaction & IDurableNonceTransaction {\n return (\n 'lifetimeConstraint' in transaction &&\n typeof transaction.lifetimeConstraint.nonce === 'string' &&\n transaction.instructions[0] != null &&\n isAdvanceNonceAccountInstruction(transaction.instructions[0])\n );\n}\n\nexport function setTransactionLifetimeUsingDurableNonce<\n TTransaction extends BaseTransaction,\n TNonceAccountAddress extends string = string,\n TNonceAuthorityAddress extends string = string,\n TNonceValue extends string = string\n>(\n {\n nonce,\n nonceAccountAddress,\n nonceAuthorityAddress,\n }: DurableNonceConfig<TNonceAccountAddress, TNonceAuthorityAddress, TNonceValue>,\n transaction: TTransaction | (TTransaction & IDurableNonceTransaction)\n): Omit<TTransaction, keyof ITransactionWithSignatures> &\n IDurableNonceTransaction<TNonceAccountAddress, TNonceAuthorityAddress, TNonceValue> {\n const isAlreadyDurableNonceTransaction = isDurableNonceTransaction(transaction);\n if (\n isAlreadyDurableNonceTransaction &&\n transaction.lifetimeConstraint.nonce === nonce &&\n transaction.instructions[0].accounts[0].address === nonceAccountAddress &&\n transaction.instructions[0].accounts[2].address === nonceAuthorityAddress\n ) {\n return transaction as TTransaction &\n IDurableNonceTransaction<TNonceAccountAddress, TNonceAuthorityAddress, TNonceValue>;\n }\n const out = {\n ...getUnsignedTransaction(transaction),\n instructions: [\n createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),\n ...(isAlreadyDurableNonceTransaction ? transaction.instructions.slice(1) : transaction.instructions),\n ],\n lifetimeConstraint: {\n nonce,\n },\n } as TTransaction & IDurableNonceTransaction<TNonceAccountAddress, TNonceAuthorityAddress, TNonceValue>;\n Object.freeze(out);\n return out;\n}\n","import { Base58EncodedAddress } from '@solana/addresses';\n\nimport { ITransactionWithSignatures } from './signatures';\nimport { BaseTransaction } from './types';\nimport { getUnsignedTransaction } from './unsigned-transaction';\n\nexport interface ITransactionWithFeePayer<TAddress extends string = string> {\n readonly feePayer: Base58EncodedAddress<TAddress>;\n}\n\nexport function setTransactionFeePayer<TFeePayerAddress extends string, TTransaction extends BaseTransaction>(\n feePayer: Base58EncodedAddress<TFeePayerAddress>,\n transaction:\n | (TTransaction & ITransactionWithSignatures)\n | (TTransaction & ITransactionWithFeePayer<string> & ITransactionWithSignatures)\n): Omit<TTransaction, keyof ITransactionWithSignatures> & ITransactionWithFeePayer<TFeePayerAddress>;\n\nexport function setTransactionFeePayer<TFeePayerAddress extends string, TTransaction extends BaseTransaction>(\n feePayer: Base58EncodedAddress<TFeePayerAddress>,\n transaction: TTransaction | (TTransaction & ITransactionWithFeePayer<string>)\n): TTransaction & ITransactionWithFeePayer<TFeePayerAddress>;\n\nexport function setTransactionFeePayer<TFeePayerAddress extends string, TTransaction extends BaseTransaction>(\n feePayer: Base58EncodedAddress<TFeePayerAddress>,\n transaction:\n | TTransaction\n | (TTransaction & ITransactionWithFeePayer<string>)\n | (TTransaction & ITransactionWithSignatures)\n | (TTransaction & ITransactionWithFeePayer<string> & ITransactionWithSignatures)\n) {\n if ('feePayer' in transaction && feePayer === transaction.feePayer) {\n return transaction;\n }\n const out = {\n ...getUnsignedTransaction(transaction),\n feePayer,\n };\n Object.freeze(out);\n return out;\n}\n","import { ITransactionWithSignatures } from './signatures';\nimport { BaseTransaction } from './types';\nimport { getUnsignedTransaction } from './unsigned-transaction';\n\nexport function appendTransactionInstruction<TTransaction extends BaseTransaction>(\n instruction: TTransaction['instructions'][number],\n transaction: TTransaction | (TTransaction & ITransactionWithSignatures)\n): TTransaction | Omit<TTransaction, keyof ITransactionWithSignatures> {\n const out = {\n ...getUnsignedTransaction(transaction),\n instructions: [...transaction.instructions, instruction],\n };\n Object.freeze(out);\n return out;\n}\n\nexport function prependTransactionInstruction<TTransaction extends BaseTransaction>(\n instruction: TTransaction['instructions'][number],\n transaction: TTransaction | (TTransaction & ITransactionWithSignatures)\n): TTransaction | Omit<TTransaction, keyof ITransactionWithSignatures> {\n const out = {\n ...getUnsignedTransaction(transaction),\n instructions: [instruction, ...transaction.instructions],\n };\n Object.freeze(out);\n return out;\n}\n","import { array, bytes, Serializer, shortU16, struct } from '@metaplex-foundation/umi-serializers';\n\nimport { getCompiledTransaction } from '../compile-transaction';\nimport { getCompiledMessageEncoder } from './message';\nimport { getUnimplementedDecoder } from './unimplemented';\n\nconst BASE_CONFIG = {\n description: __DEV__ ? 'The wire format of a Solana transaction' : '',\n fixedSize: null,\n maxSize: null,\n} as const;\n\ntype SerializableTransaction = Parameters<typeof getCompiledTransaction>[0];\n\nfunction serialize(transaction: SerializableTransaction) {\n const compiledTransaction = getCompiledTransaction(transaction);\n return struct([\n [\n 'signatures',\n array(bytes({ size: 64 }), {\n ...(__DEV__ ? { description: 'A compact array of 64-byte, base-64 encoded Ed25519 signatures' } : null),\n size: shortU16(),\n }),\n ],\n ['compiledMessage', getCompiledMessageEncoder()],\n ]).serialize(compiledTransaction);\n}\n\nexport function getTransactionEncoder(): Serializer<SerializableTransaction> {\n return {\n ...BASE_CONFIG,\n deserialize: getUnimplementedDecoder('CompiledMessage'),\n serialize,\n };\n}\n","import { Base58EncodedAddress, getAddressComparator } from '@solana/addresses';\nimport {\n AccountRole,\n IAccountLookupMeta,\n IAccountMeta,\n IInstruction,\n isSignerRole,\n isWritableRole,\n mergeRoles,\n ReadonlyAccount,\n ReadonlyAccountLookup,\n ReadonlySignerAccount,\n WritableAccount,\n WritableAccountLookup,\n WritableSignerAccount,\n} from '@solana/instructions';\n\nexport const enum AddressMapEntryType {\n FEE_PAYER,\n LOOKUP_TABLE,\n STATIC,\n}\n\ntype AddressMap = {\n [address: string]: FeePayerAccountEntry | LookupTableAccountEntry | StaticAccountEntry;\n};\ntype FeePayerAccountEntry = Omit<WritableSignerAccount, 'address'> & {\n [TYPE]: AddressMapEntryType.FEE_PAYER;\n};\ntype LookupTableAccountEntry = Omit<ReadonlyAccountLookup | WritableAccountLookup, 'address'> & {\n [TYPE]: AddressMapEntryType.LOOKUP_TABLE;\n};\nexport type OrderedAccounts = (IAccountMeta | IAccountLookupMeta)[] & { readonly __brand: unique symbol };\ntype StaticAccountEntry = Omit<\n ReadonlyAccount | ReadonlySignerAccount | WritableAccount | WritableSignerAccount,\n 'address'\n> & { [TYPE]: AddressMapEntryType.STATIC };\n\nfunction upsert(\n addressMap: AddressMap,\n address: Base58EncodedAddress,\n update: (\n entry: FeePayerAccountEntry | LookupTableAccountEntry | StaticAccountEntry | Record<never, never>\n ) => AddressMap[Base58EncodedAddress]\n) {\n addressMap[address] = update(addressMap[address] ?? { role: AccountRole.READONLY });\n}\n\nconst TYPE = Symbol('AddressMapTypeProperty');\nexport const ADDRESS_MAP_TYPE_PROPERTY: typeof TYPE = TYPE;\n\nexport function getAddressMapFromInstructions(\n feePayer: Base58EncodedAddress,\n instructions: readonly IInstruction[]\n): AddressMap {\n const addressMap: AddressMap = {\n [feePayer]: { [TYPE]: AddressMapEntryType.FEE_PAYER, role: AccountRole.WRITABLE_SIGNER },\n };\n const addressesOfInvokedPrograms = new Set<Base58EncodedAddress>();\n for (const instruction of instructions) {\n upsert(addressMap, instruction.programAddress, entry => {\n addressesOfInvokedPrograms.add(instruction.programAddress);\n if (TYPE in entry) {\n if (isWritableRole(entry.role)) {\n switch (entry[TYPE]) {\n case AddressMapEntryType.FEE_PAYER:\n // TODO: Coded error.\n throw new Error(\n 'This transaction includes an address ' +\n `(\\`${instruction.programAddress}\\`) which is both invoked ` +\n 'and set as the fee payer. Program addresses may not pay fees.'\n );\n default:\n // TODO: Coded error.\n throw new Error(\n 'This transaction includes an address ' +\n `(\\`${instruction.programAddress}\\`) which is both invoked ` +\n 'and marked writable. Program addresses may not be writable.'\n );\n }\n }\n if (entry[TYPE] === AddressMapEntryType.STATIC) {\n return entry;\n }\n }\n return { [TYPE]: AddressMapEntryType.STATIC, role: AccountRole.READONLY };\n });\n let addressComparator: ReturnType<typeof getAddressComparator>;\n if (!instruction.accounts) {\n continue;\n }\n for (const account of instruction.accounts) {\n upsert(addressMap, account.address, entry => {\n const {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n address: _,\n ...accountMeta\n } = account;\n if (TYPE in entry) {\n switch (entry[TYPE]) {\n case AddressMapEntryType.FEE_PAYER:\n // The fee payer already has the highest rank -- it is by definition\n // writable-signer. Return it, no matter how `account` is configured\n return entry as FeePayerAccountEntry;\n case AddressMapEntryType.LOOKUP_TABLE: {\n const nextRole = mergeRoles(entry.role, accountMeta.role);\n if ('lookupTableAddress' in accountMeta) {\n const shouldReplaceEntry =\n // Consider using the new LOOKUP_TABLE if its address is different...\n entry.lookupTableAddress !== accountMeta.lookupTableAddress &&\n // ...and sorts before the existing one.\n (addressComparator ||= getAddressComparator())(\n accountMeta.lookupTableAddress,\n entry.lookupTableAddress\n ) < 0;\n if (shouldReplaceEntry) {\n return {\n [TYPE]: AddressMapEntryType.LOOKUP_TABLE,\n ...accountMeta,\n role: nextRole,\n } as LookupTableAccountEntry;\n }\n } else if (isSignerRole(accountMeta.role)) {\n // Upgrade this LOOKUP_TABLE entry to a static entry if it must sign.\n return {\n [TYPE]: AddressMapEntryType.STATIC,\n role: nextRole,\n } as StaticAccountEntry;\n }\n if (entry.role !== nextRole) {\n return {\n ...entry,\n role: nextRole,\n } as LookupTableAccountEntry;\n } else {\n return entry as LookupTableAccountEntry;\n }\n }\n case AddressMapEntryType.STATIC: {\n const nextRole = mergeRoles(entry.role, accountMeta.role);\n if (\n // Check to see if this address represents a program that is invoked\n // in this transaction.\n addressesOfInvokedPrograms.has(account.address)\n ) {\n if (isWritableRole(accountMeta.role)) {\n // TODO: Coded error.\n throw new Error(\n 'This transaction includes an address ' +\n `(\\`${account.address}\\`) which is both invoked and ` +\n 'marked writable. Program addresses may not be ' +\n 'writable.'\n );\n }\n if (entry.role !== nextRole) {\n return {\n ...entry,\n role: nextRole,\n } as StaticAccountEntry;\n } else {\n return entry as StaticAccountEntry;\n }\n } else if (\n 'lookupTableAddress' in accountMeta &&\n // Static accounts can be 'upgraded' to lookup table accounts as\n // long as they are not require to sign the transaction.\n !isSignerRole(entry.role)\n ) {\n return {\n ...accountMeta,\n [TYPE]: AddressMapEntryType.LOOKUP_TABLE,\n role: nextRole,\n } as LookupTableAccountEntry;\n } else {\n if (entry.role !== nextRole) {\n // The account's role ranks higher than the current entry's.\n return {\n ...entry,\n role: nextRole,\n } as StaticAccountEntry;\n } else {\n return entry as StaticAccountEntry;\n }\n }\n }\n }\n }\n if ('lookupTableAddress' in accountMeta) {\n return {\n ...accountMeta,\n [TYPE]: AddressMapEntryType.LOOKUP_TABLE,\n };\n } else {\n return {\n ...accountMeta,\n [TYPE]: AddressMapEntryType.STATIC,\n };\n }\n });\n }\n }\n return addressMap;\n}\n\nexport function getOrderedAccountsFromAddressMap(addressMap: AddressMap): OrderedAccounts {\n let addressComparator: ReturnType<typeof getAddressComparator>;\n const orderedAccounts: (IAccountMeta | IAccountLookupMeta)[] = Object.entries(addressMap)\n .sort(([leftAddress, leftEntry], [rightAddress, rightEntry]) => {\n // STEP 1: Rapid precedence check. Fee payer, then static addresses, then lookups.\n if (leftEntry[TYPE] !== rightEntry[TYPE]) {\n if (leftEntry[TYPE] === AddressMapEntryType.FEE_PAYER) {\n return -1;\n } else if (rightEntry[TYPE] === AddressMapEntryType.FEE_PAYER) {\n return 1;\n } else if (leftEntry[TYPE] === AddressMapEntryType.STATIC) {\n return -1;\n } else if (rightEntry[TYPE] === AddressMapEntryType.STATIC) {\n return 1;\n }\n }\n // STEP 2: Sort by signer-writability.\n const leftIsSigner = isSignerRole(leftEntry.role);\n if (leftIsSigner !== isSignerRole(rightEntry.role)) {\n return leftIsSigner ? -1 : 1;\n }\n const leftIsWritable = isWritableRole(leftEntry.role);\n if (leftIsWritable !== isWritableRole(rightEntry.role)) {\n return leftIsWritable ? -1 : 1;\n }\n // STEP 3: Sort by address.\n addressComparator ||= getAddressComparator();\n if (\n leftEntry[TYPE] === AddressMapEntryType.LOOKUP_TABLE &&\n rightEntry[TYPE] === AddressMapEntryType.LOOKUP_TABLE &&\n leftEntry.lookupTableAddress !== rightEntry.lookupTableAddress\n ) {\n return addressComparator(leftEntry.lookupTableAddress, rightEntry.lookupTableAddress);\n } else {\n return addressComparator(leftAddress, rightAddress);\n }\n })\n .map(([address, addressMeta]) => ({\n address: address as Base58EncodedAddress<typeof address>,\n ...addressMeta,\n }));\n return orderedAccounts as unknown as OrderedAccounts;\n}\n","import { Base58EncodedAddress, getAddressComparator } from '@solana/addresses';\nimport { AccountRole } from '@solana/instructions';\n\nimport { OrderedAccounts } from './accounts';\n\ntype AddressTableLookup = Readonly<{\n lookupTableAddress: Base58EncodedAddress;\n readableIndices: readonly number[];\n writableIndices: readonly number[];\n}>;\n\nexport function getCompiledAddressTableLookups(orderedAccounts: OrderedAccounts): AddressTableLookup[] {\n const index: Record<\n Base58EncodedAddress,\n { readonly readableIndices: number[]; readonly writableIndices: number[] }\n > = {};\n for (const account of orderedAccounts) {\n if (!('lookupTableAddress' in account)) {\n continue;\n }\n const entry = (index[account.lookupTableAddress] ||= {\n readableIndices: [],\n writableIndices: [],\n });\n if (account.role === AccountRole.WRITABLE) {\n entry.writableIndices.push(account.addressIndex);\n } else {\n entry.readableIndices.push(account.addressIndex);\n }\n }\n return Object.keys(index)\n .sort(getAddressComparator())\n .map(lookupTableAddress => ({\n lookupTableAddress: lookupTableAddress as Base58EncodedAddress,\n ...index[lookupTableAddress as unknown as Base58EncodedAddress],\n }));\n}\n","import { isSignerRole, isWritableRole } from '@solana/instructions';\n\nimport { OrderedAccounts } from './accounts';\n\ntype MessageHeader = Readonly<{\n numReadonlyNonSignerAccounts: number;\n numReadonlySignerAccounts: number;\n numSignerAccounts: number;\n}>;\n\nexport function getCompiledMessageHeader(orderedAccounts: OrderedAccounts): MessageHeader {\n let numReadonlyNonSignerAccounts = 0;\n let numReadonlySignerAccounts = 0;\n let numSignerAccounts = 0;\n for (const account of orderedAccounts) {\n if ('lookupTableAddress' in account) {\n break;\n }\n const accountIsWritable = isWritableRole(account.role);\n if (isSignerRole(account.role)) {\n numSignerAccounts++;\n if (!accountIsWritable) {\n numReadonlySignerAccounts++;\n }\n } else if (!accountIsWritable) {\n numReadonlyNonSignerAccounts++;\n }\n }\n return {\n numReadonlyNonSignerAccounts,\n numReadonlySignerAccounts,\n numSignerAccounts,\n };\n}\n","import { Base58EncodedAddress } from '@solana/addresses';\nimport { IInstruction } from '@solana/instructions';\n\nimport { OrderedAccounts } from './accounts';\n\ntype CompiledInstruction = Readonly<{\n accountIndices?: number[];\n data?: Uint8Array;\n programAddressIndex: number;\n}>;\n\nfunction getAccountIndex(orderedAccounts: OrderedAccounts) {\n const out: Record<Base58EncodedAddress, number> = {};\n for (const [index, account] of orderedAccounts.entries()) {\n out[account.address] = index;\n }\n return out;\n}\n\nexport function getCompiledInstructions(\n instructions: readonly IInstruction[],\n orderedAccounts: OrderedAccounts\n): CompiledInstruction[] {\n const accountIndex = getAccountIndex(orderedAccounts);\n return instructions.map(({ accounts, data, programAddress }) => {\n return {\n programAddressIndex: accountIndex[programAddress],\n ...(accounts ? { accountIndices: accounts.map(({ address }) => accountIndex[address]) } : null),\n ...(data ? { data } : null),\n };\n });\n}\n","import { IDurableNonceTransaction, ITransactionWithBlockhashLifetime } from './index';\n\nexport function getCompiledLifetimeToken(\n lifetimeConstraint: (ITransactionWithBlockhashLifetime | IDurableNonceTransaction)['lifetimeConstraint']\n): string {\n if ('nonce' in lifetimeConstraint) {\n return lifetimeConstraint.nonce;\n }\n return lifetimeConstraint.blockhash;\n}\n","import { Base58EncodedAddress } from '@solana/addresses';\n\nimport { OrderedAccounts } from './accounts';\n\nexport function getCompiledStaticAccounts(orderedAccounts: OrderedAccounts): Base58EncodedAddress[] {\n const firstLookupTableAccountIndex = orderedAccounts.findIndex(account => 'lookupTableAddress' in account);\n const orderedStaticAccounts =\n firstLookupTableAccountIndex === -1 ? orderedAccounts : orderedAccounts.slice(0, firstLookupTableAccountIndex);\n return orderedStaticAccounts.map(({ address }) => address);\n}\n","import { getAddressMapFromInstructions, getOrderedAccountsFromAddressMap } from './accounts';\nimport { ITransactionWithBlockhashLifetime } from './blockhash';\nimport { getCompiledAddressTableLookups } from './compile-address-table-lookups';\nimport { getCompiledMessageHeader } from './compile-header';\nimport { getCompiledInstructions } from './compile-instructions';\nimport { getCompiledLifetimeToken } from './compile-lifetime-token';\nimport { getCompiledStaticAccounts } from './compile-static-accounts';\nimport { IDurableNonceTransaction } from './durable-nonce';\nimport { ITransactionWithFeePayer } from './fee-payer';\nimport { BaseTransaction } from './types';\n\ntype BaseCompiledMessage = Readonly<{\n header: ReturnType<typeof getCompiledMessageHeader>;\n instructions: ReturnType<typeof getCompiledInstructions>;\n lifetimeToken: ReturnType<typeof getCompiledLifetimeToken>;\n staticAccounts: ReturnType<typeof getCompiledStaticAccounts>;\n}>;\n\ntype CompilableTransaction = BaseTransaction &\n ITransactionWithFeePayer &\n (ITransactionWithBlockhashLifetime | IDurableNonceTransaction);\n\nexport type CompiledMessage = LegacyCompiledMessage | VersionedCompiledMessage;\n\ntype LegacyCompiledMessage = BaseCompiledMessage &\n Readonly<{\n version: 'legacy';\n }>;\n\ntype VersionedCompiledMessage = BaseCompiledMessage &\n Readonly<{\n addressTableLookups?: ReturnType<typeof getCompiledAddressTableLookups>;\n version: number;\n }>;\n\nexport function compileMessage(\n transaction: CompilableTransaction & Readonly<{ version: 'legacy' }>\n): LegacyCompiledMessage;\nexport function compileMessage(transaction: CompilableTransaction): VersionedCompiledMessage;\nexport function compileMessage(transaction: CompilableTransaction): CompiledMessage {\n const addressMap = getAddressMapFromInstructions(transaction.feePayer, transaction.instructions);\n const orderedAccounts = getOrderedAccountsFromAddressMap(addressMap);\n return {\n ...(transaction.version !== 'legacy'\n ? { addressTableLookups: getCompiledAddressTableLookups(orderedAccounts) }\n : null),\n header: getCompiledMessageHeader(orderedAccounts),\n instructions: getCompiledInstructions(transaction.instructions, orderedAccounts),\n lifetimeToken: getCompiledLifetimeToken(transaction.lifetimeConstraint),\n staticAccounts: getCompiledStaticAccounts(orderedAccounts),\n version: transaction.version,\n };\n}\n","import { Ed25519Signature } from '@solana/keys';\n\nimport { CompiledMessage, compileMessage } from './message';\nimport { ITransactionWithSignatures } from './signatures';\n\ntype CompiledTransaction = Readonly<{\n compiledMessage: CompiledMessage;\n signatures: Ed25519Signature[];\n}>;\n\ntype CompilableTransaction = Parameters<typeof compileMessage>[0];\n\nexport function getCompiledTransaction(\n transaction: CompilableTransaction | (CompilableTransaction & ITransactionWithSignatures)\n): CompiledTransaction {\n const compiledMessage = compileMessage(transaction);\n let signatures;\n if ('signatures' in transaction) {\n signatures = [];\n for (let ii = 0; ii < compiledMessage.header.numSignerAccounts; ii++) {\n signatures[ii] =\n transaction.signatures[compiledMessage.staticAccounts[ii]] ?? new Uint8Array(Array(64).fill(0));\n }\n } else {\n signatures = Array(compiledMessage.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));\n }\n return {\n compiledMessage,\n signatures,\n };\n}\n","import {\n array,\n base58,\n mapSerializer,\n Serializer,\n shortU16,\n string,\n struct,\n StructToSerializerTuple,\n} from '@metaplex-foundation/umi-serializers';\nimport { getAddressCodec } from '@solana/addresses';\nimport { Codec } from '@solana/codecs-core';\n\nimport { CompiledMessage } from '../message';\nimport { SerializedMessageBytes } from '../types';\nimport { getAddressTableLookupCodec } from './address-table-lookup';\nimport { getMessageHeaderCodec } from './header';\nimport { getInstructionCodec } from './instruction';\nimport { getTransactionVersionCodec } from './transaction-version';\nimport { getUnimplementedDecoder, getUnimplementedEncoder } from './unimplemented';\n\nconst BASE_CONFIG = {\n description: __DEV__ ? 'The wire format of a Solana transaction message' : '',\n fixedSize: null,\n maxSize: null,\n} as const;\n\nfunction deserialize(bytes: Uint8Array, offset = 0): [CompiledMessage, number] {\n const preludeAndOffset = struct(getPreludeStructSerializerTuple()).deserialize(bytes, offset);\n const [prelude, endOfPreludeOffset] = preludeAndOffset;\n if (prelude.version === 'legacy') {\n return preludeAndOffset;\n }\n const [addressTableLookups, finalOffset] = getAddressTableLookupsSerializer().deserialize(\n bytes,\n endOfPreludeOffset\n );\n return [\n {\n ...prelude,\n ...(addressTableLookups.length ? { addressTableLookups } : null),\n },\n finalOffset,\n ];\n}\n\nfunction serialize(compiledMessage: CompiledMessage): SerializedMessageBytes {\n if (compiledMessage.version === 'legacy') {\n return struct(getPreludeStructSerializerTuple()).serialize(compiledMessage) as SerializedMessageBytes;\n } else {\n return mapSerializer(\n struct([\n ...getPreludeStructSerializerTuple(),\n ['addressTableLookups', getAddressTableLookupsSerializer()],\n ] as StructToSerializerTuple<CompiledMessage, CompiledMessage>),\n (value: CompiledMessage) => {\n if (value.version === 'legacy') {\n return value;\n }\n return {\n ...value,\n addressTableLookups: value.addressTableLookups ?? [],\n } as Exclude<CompiledMessage, { readonly version: 'legacy' }>;\n }\n ).serialize(compiledMessage) as SerializedMessageBytes;\n }\n}\n\n// Temporary, convert a codec to a serializer for compatiblity for now\nfunction toSerializer<T>(codec: Codec<T>): Serializer<T> {\n return {\n description: codec.description,\n deserialize: codec.decode,\n fixedSize: codec.fixedSize,\n maxSize: codec.maxSize,\n serialize: codec.encode,\n };\n}\n\nfunction getPreludeStructSerializerTuple(): StructToSerializerTuple<CompiledMessage, CompiledMessage> {\n return [\n ['version', toSerializer(getTransactionVersionCodec())],\n ['header', toSerializer(getMessageHeaderCodec())],\n [\n 'staticAccounts',\n array(toSerializer(getAddressCodec()), {\n description: __DEV__ ? 'A compact-array of static account addresses belonging to this transaction' : '',\n size: shortU16(),\n }),\n ],\n [\n 'lifetimeToken',\n string({\n description: __DEV__\n ? 'A 32-byte token that specifies the lifetime of this transaction (eg. a ' +\n 'recent blockhash, or a durable nonce)'\n : '',\n encoding: base58,\n size: 32,\n }),\n ],\n [\n 'instructions',\n array(getInstructionCodec(), {\n description: __DEV__ ? 'A compact-array of instructions belonging to this transaction' : '',\n size: shortU16(),\n }),\n ],\n ];\n}\n\nfunction getAddressTableLookupsSerializer() {\n return array(getAddressTableLookupCodec(), {\n ...(__DEV__ ? { description: 'A compact array of address table lookups belonging to this transaction' } : null),\n size: shortU16(),\n });\n}\n\nexport function getCompiledMessageEncoder(): Serializer<CompiledMessage> {\n return {\n ...BASE_CONFIG,\n deserialize: getUnimplementedDecoder('CompiledMessage'),\n serialize,\n };\n}\n\nexport function getCompiledMessageDecoder(): Serializer<CompiledMessage> {\n return {\n ...BASE_CONFIG,\n deserialize,\n serialize: getUnimplementedEncoder('CompiledMessage'),\n };\n}\n\nexport function getCompiledMessageCodec(): Serializer<CompiledMessage> {\n return {\n ...BASE_CONFIG,\n deserialize,\n serialize,\n };\n}\n","import { array, Serializer, shortU16, struct, StructToSerializerTuple, u8 } from '@metaplex-foundation/umi-serializers';\nimport { Base58EncodedAddress, getAddressCodec } from '@solana/addresses';\n\nimport { getCompiledAddressTableLookups } from '../compile-address-table-lookups';\n\ntype AddressTableLookup = ReturnType<typeof getCompiledAddressTableLookups>[number];\n\n// Temporary, will use getAddressCodec directly when everything else is migrated\nfunction addressSerializerCompat(compat?: { description: string }): Serializer<Base58EncodedAddress> {\n const codec = getAddressCodec();\n return {\n description: compat?.description ?? codec.description,\n deserialize: codec.decode,\n fixedSize: codec.fixedSize,\n maxSize: codec.maxSize,\n serialize: codec.encode,\n };\n}\n\nexport function getAddressTableLookupCodec(): Serializer<AddressTableLookup> {\n return struct(\n [\n [\n 'lookupTableAddress',\n addressSerializerCompat(\n __DEV__\n ? {\n description:\n 'The address of the address lookup table account from which ' +\n 'instruction addresses should be looked up',\n }\n : undefined\n ),\n ],\n [\n 'writableIndices',\n array(u8(), {\n ...(__DEV__\n ? {\n description:\n 'The indices of the accounts in the lookup table that should ' +\n 'be loaded as writeable',\n }\n : null),\n size: shortU16(),\n }),\n ],\n [\n 'readableIndices',\n array(u8(), {\n ...(__DEV__\n ? {\n description:\n 'The indices of the accounts in the lookup table that should ' +\n 'be loaded as read-only',\n }\n : undefined),\n size: shortU16(),\n }),\n ],\n ] as StructToSerializerTuple<AddressTableLookup, AddressTableLookup>,\n __DEV__\n ? {\n description:\n 'A pointer to the address of an address lookup table, along with the ' +\n 'readonly/writeable indices of the addresses that should be loaded from it',\n }\n : undefined\n );\n}\n","import { Codec, Decoder, Encoder } from '@solana/codecs-core';\nimport { getStructCodec, getStructDecoder, getStructEncoder } from '@solana/codecs-data-structures';\nimport { getU8Codec, getU8Decoder, getU8Encoder } from '@solana/codecs-numbers';\n\nimport { getCompiledMessageHeader } from '../compile-header';\n\ntype MessageHeader = ReturnType<typeof getCompiledMessageHeader>;\n\nlet memoizedU8Encoder: Encoder<number> | undefined;\nfunction getMemoizedU8Encoder(): Encoder<number> {\n if (!memoizedU8Encoder) memoizedU8Encoder = getU8Encoder();\n return memoizedU8Encoder;\n}\n\nfunction getMemoizedU8EncoderDescription(description?: string): Encoder<number> {\n const encoder = getMemoizedU8Encoder();\n return {\n ...encoder,\n description: description ?? encoder.description,\n };\n}\n\nlet memoizedU8Decoder: Decoder<number> | undefined;\nfunction getMemoizedU8Decoder(): Decoder<number> {\n if (!memoizedU8Decoder) memoizedU8Decoder = getU8Decoder();\n return memoizedU8Decoder;\n}\n\nfunction getMemoizedU8DecoderDescription(description?: string): Decoder<number> {\n const decoder = getMemoizedU8Decoder();\n return {\n ...decoder,\n description: description ?? decoder.description,\n };\n}\n\nlet memoizedU8Codec: Codec<number> | undefined;\nfunction getMemoizedU8Codec(): Codec<number> {\n if (!memoizedU8Codec) memoizedU8Codec = getU8Codec();\n return memoizedU8Codec;\n}\n\nfunction getMemoizedU8CodecDescription(description?: string): Codec<number> {\n const codec = getMemoizedU8Codec();\n return {\n ...codec,\n description: description ?? codec.description,\n };\n}\n\nconst numSignerAccountsDescription = __DEV__\n ? 'The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction'\n : undefined;\n\nconst numReadonlySignerAccountsDescription = __DEV__\n ? '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'\n : undefined;\n\nconst numReadonlyNonSignerAccountsDescription = __DEV__\n ? 'The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable'\n : undefined;\n\nconst messageHeaderDescription = __DEV__\n ? 'The transaction message header containing counts of the signer, readonly-signer, and readonly-nonsigner account addresses'\n : undefined;\n\nexport function getMessageHeaderEncoder(): Encoder<MessageHeader> {\n return getStructEncoder(\n [\n ['numSignerAccounts', getMemoizedU8EncoderDescription(numSignerAccountsDescription)],\n ['numReadonlySignerAccounts', getMemoizedU8EncoderDescription(numReadonlySignerAccountsDescription)],\n ['numReadonlyNonSignerAccounts', getMemoizedU8EncoderDescription(numReadonlyNonSignerAccountsDescription)],\n ],\n {\n description: messageHeaderDescription,\n }\n );\n}\n\nexport function getMessageHeaderDecoder(): Decoder<MessageHeader> {\n return getStructDecoder(\n [\n ['numSignerAccounts', getMemoizedU8DecoderDescription(numSignerAccountsDescription)],\n ['numReadonlySignerAccounts', getMemoizedU8DecoderDescription(numReadonlySignerAccountsDescription)],\n ['numReadonlyNonSignerAccounts', getMemoizedU8DecoderDescription(numReadonlyNonSignerAccountsDescription)],\n ],\n {\n description: messageHeaderDescription,\n }\n );\n}\n\nexport function getMessageHeaderCodec(): Codec<MessageHeader> {\n return getStructCodec(\n [\n ['numSignerAccounts', getMemoizedU8CodecDescription(numSignerAccountsDescription)],\n ['numReadonlySignerAccounts', getMemoizedU8CodecDescription(numReadonlySignerAccountsDescription)],\n ['numReadonlyNonSignerAccounts', getMemoizedU8CodecDescription(numReadonlyNonSignerAccountsDescription)],\n ],\n {\n description: messageHeaderDescription,\n }\n );\n}\n","import { array, bytes, mapSerializer, Serializer, shortU16, struct, u8 } from '@metaplex-foundation/umi-serializers';\n\nimport { getCompiledInstructions } from '../compile-instructions';\n\ntype Instruction = ReturnType<typeof getCompiledInstructions>[number];\n\nexport function getInstructionCodec(): Serializer<Instruction> {\n return mapSerializer<Instruction, Required<Instruction>>(\n struct([\n [\n 'programAddressIndex',\n u8(\n __DEV__\n ? {\n description:\n 'The index of the program being called, according to the ' +\n 'well-ordered accounts list for this transaction',\n }\n : undefined\n ),\n ],\n [\n 'accountIndices',\n array(\n u8({\n description: __DEV__\n ? 'The index of an account, according to the well-ordered accounts ' +\n 'list for this transaction'\n : '',\n }),\n {\n description: __DEV__\n ? 'An optional list of account indices, according to the ' +\n 'well-ordered accounts list for this transaction, in the order in ' +\n 'which the program being called expects them'\n : '',\n size: shortU16(),\n }\n ),\n ],\n [\n 'data',\n bytes({\n description: __DEV__ ? 'An optional buffer of data passed to the instruction' : '',\n size: shortU16(),\n }),\n ],\n ]),\n (value: Instruction) => {\n if (value.accountIndices !== undefined && value.data !== undefined) {\n return value as Required<Instruction>;\n }\n return {\n ...value,\n accountIndices: value.accountIndices ?? [],\n data: value.data ?? new Uint8Array(0),\n } as Required<Instruction>;\n },\n (value: Required<Instruction>) => {\n if (value.accountIndices.length && value.data.byteLength) {\n return value;\n }\n const { accountIndices, data, ...rest } = value;\n return {\n ...rest,\n ...(accountIndices.length ? { accountIndices } : null),\n ...(data.byteLength ? { data } : null),\n };\n }\n );\n}\n","import { Codec, combineCodec, Decoder, Encoder } from '@solana/codecs-core';\n\nimport { TransactionVersion } from '../types';\n\nconst VERSION_FLAG_MASK = 0x80;\n\nconst BASE_CONFIG = {\n description: __DEV__ ? 'A single byte that encodes the version of the transaction' : '',\n fixedSize: null,\n maxSize: 1,\n} as const;\n\nfunction decode(bytes: Uint8Array, offset = 0): [TransactionVersion, number] {\n const firstByte = bytes[offset];\n if ((firstByte & VERSION_FLAG_MASK) === 0) {\n // No version flag set; it's a legacy (unversioned) transaction.\n return ['legacy', offset];\n } else {\n const version = (firstByte ^ VERSION_FLAG_MASK) as TransactionVersion;\n return [version, offset + 1];\n }\n}\n\nfunction encode(value: TransactionVersion): Uint8Array {\n if (value === 'legacy') {\n return new Uint8Array();\n }\n if (value < 0 || value > 127) {\n // TODO: Coded error.\n throw new Error(`Transaction version must be in the range [0, 127]. \\`${value}\\` given.`);\n }\n return new Uint8Array([value | VERSION_FLAG_MASK]);\n}\n\nexport function getTransactionVersionDecoder(): Decoder<TransactionVersion> {\n return {\n ...BASE_CONFIG,\n decode,\n };\n}\n\nexport function getTransactionVersionEncoder(): Encoder<TransactionVersion> {\n return {\n ...BASE_CONFIG,\n encode,\n };\n}\n\nexport function getTransactionVersionCodec(): Codec<TransactionVersion> {\n return combineCodec(getTransactionVersionEncoder(), getTransactionVersionDecoder());\n}\n","function getError(type: 'decoder' | 'encoder', name: string) {\n const functionSuffix = name + type[0].toUpperCase() + type.slice(1);\n return new Error(\n `No ${type} exists for ${name}. Use \\`get${functionSuffix}()\\` if you need a ${type}, and \\`get${name}Codec()\\` if you need to both encode and decode ${name}`\n );\n}\n\nexport function getUnimplementedDecoder(name: string): () => never {\n return () => {\n throw getError('decoder', name);\n };\n}\n\nexport function getUnimplementedEncoder(name: string): () => never {\n return () => {\n throw getError('encoder', name);\n };\n}\n","import { base58 } from '@metaplex-foundation/umi-serializers';\nimport { Base58EncodedAddress, getAddressFromPublicKey } from '@solana/addresses';\nimport { Ed25519Signature, signBytes } from '@solana/keys';\n\nimport { ITransactionWithFeePayer } from './fee-payer';\nimport { CompiledMessage, compileMessage } from './message';\nimport { getCompiledMessageEncoder } from './serializers/message';\n\nexport interface IFullySignedTransaction extends ITransactionWithSignatures {\n readonly __brand: unique symbol;\n}\nexport interface ITransactionWithSignatures {\n readonly signatures: Readonly<Record<Base58EncodedAddress, Ed25519Signature>>;\n}\n\nexport type TransactionSignature = string & { readonly __brand: unique symbol };\n\nexport function assertIsTransactionSignature(\n putativeTransactionSignature: string\n): asserts putativeTransactionSignature is TransactionSignature {\n try {\n // Fast-path; see if the input string is of an acceptable length.\n if (\n // Lowest value (64 bytes of zeroes)\n putativeTransactionSignature.length < 64 ||\n // Highest value (64 bytes of 255)\n putativeTransactionSignature.length > 88\n ) {\n throw new Error('Expected input string to decode to a byte array of length 64.');\n }\n // Slow-path; actually attempt to decode the input string.\n const bytes = base58.serialize(putativeTransactionSignature);\n const numBytes = bytes.byteLength;\n if (numBytes !== 64) {\n throw new Error(`Expected input string to decode to a byte array of length 64. Actual length: ${numBytes}`);\n }\n } catch (e) {\n throw new Error(`\\`${putativeTransactionSignature}\\` is not a transaction signature`, {\n cause: e,\n });\n }\n}\n\nexport function isTransactionSignature(\n putativeTransactionSignature: string\n): putativeTransactionSignature is TransactionSignature {\n // Fast-path; see if the input string is of an acceptable length.\n if (\n // Lowest value (64 bytes of zeroes)\n putativeTransactionSignature.length < 64 ||\n // Highest value (64 bytes of 255)\n putativeTransactionSignature.length > 88\n ) {\n return false;\n }\n // Slow-path; actually attempt to decode the input string.\n const bytes = base58.serialize(putativeTransactionSignature);\n const numBytes = bytes.byteLength;\n if (numBytes !== 64) {\n return false;\n }\n return true;\n}\n\nasync function getCompiledMessageSignature(message: CompiledMessage, secretKey: CryptoKey) {\n const wireMessageBytes = getCompiledMessageEncoder().serialize(message);\n const signature = await signBytes(secretKey, wireMessageBytes);\n return signature;\n}\n\nexport function getSignatureFromTransaction(\n transaction: ITransactionWithFeePayer & ITransactionWithSignatures\n): TransactionSignature {\n const signature = transaction.signatures[transaction.feePayer];\n if (!signature) {\n // TODO: Coded error.\n throw new Error(\n \"Could not determine this transaction's signature. Make sure that the transaction \" +\n 'has been signed by its fee payer.'\n );\n }\n return signature as unknown as TransactionSignature;\n}\n\nexport async function signTransaction<TTransaction extends Parameters<typeof compileMessage>[0]>(\n keyPairs: CryptoKeyPair[],\n transaction: TTransaction | (TTransaction & ITransactionWithSignatures)\n): Promise<TTransaction & ITransactionWithSignatures> {\n const compiledMessage = compileMessage(transaction);\n const nextSignatures: Record<Base58EncodedAddress, Ed25519Signature> =\n 'signatures' in transaction ? { ...transaction.signatures } : {};\n const publicKeySignaturePairs = await Promise.all(\n keyPairs.map(keyPair =>\n Promise.all([\n getAddressFromPublicKey(keyPair.publicKey),\n getCompiledMessageSignature(compiledMessage, keyPair.privateKey),\n ])\n )\n );\n for (const [signerPublicKey, signature] of publicKeySignaturePairs) {\n nextSignatures[signerPublicKey] = signature;\n }\n const out = {\n ...transaction,\n signatures: nextSignatures,\n };\n Object.freeze(out);\n return out;\n}\n\nexport function transactionSignature(putativeTransactionSignature: string): TransactionSignature {\n assertIsTransactionSignature(putativeTransactionSignature);\n return putativeTransactionSignature;\n}\n","import { getTransactionEncoder } from './serializers/transaction';\n\nexport type Base64EncodedWireTransaction = string & {\n readonly __brand: unique symbol;\n};\n\nexport function getBase64EncodedWireTransaction(\n transaction: Parameters<ReturnType<typeof getTransactionEncoder>['serialize']>[0]\n): Base64EncodedWireTransaction {\n const wireTransactionBytes = getTransactionEncoder().serialize(transaction);\n if (__NODEJS__) {\n return Buffer.from(wireTransactionBytes).toString('base64') as Base64EncodedWireTransaction;\n } else {\n return (btoa as Window['btoa'])(String.fromCharCode(...wireTransactionBytes)) as Base64EncodedWireTransaction;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/blockhash.ts","../src/unsigned-transaction.ts","../src/create-transaction.ts","../../instructions/src/roles.ts","../src/durable-nonce.ts","../src/fee-payer.ts","../src/instructions.ts","../src/accounts.ts","../src/compile-address-table-lookups.ts","../src/compile-header.ts","../src/compile-instructions.ts","../src/compile-lifetime-token.ts","../src/compile-static-accounts.ts","../src/message.ts","../src/serializers/message.ts","../src/serializers/address-table-lookup.ts","../src/serializers/header.ts","../src/serializers/instruction.ts","../src/serializers/transaction-version.ts","../src/serializers/transaction.ts","../src/compile-transaction.ts","../src/decompile-transaction.ts","../src/signatures.ts","../src/wire-transaction.ts"],"names":["AccountRole","getAddressComparator","getAddressDecoder","getAddressEncoder","combineCodec","createEncoder","mapDecoder","mapEncoder","getArrayDecoder","getArrayEncoder","getStructDecoder","getStructEncoder","getShortU16Decoder","getShortU16Encoder","getBase58Encoder","getU8Decoder","getU8Encoder","getBytesDecoder","getBytesEncoder","getBase58Decoder"],"mappings":";AACA,SAAS,wBAAwB;;;ACE1B,SAAS,uBACZ,aACgG;AAChG,MAAI,gBAAgB,a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,IAC1C,SAAS;AAAA,MAAI,aACT,QAAQ,IAAI,CAAC,wBAAwB,QAAQ,SAAS,GAAG,UAAU,QAAQ,YAAY,gBAAgB,CAAC,CAAC;AAAA,IAC7G;AAAA,EACJ;AACA,aAAW,CAAC,iBAAiB,SAAS,KAAK,yBAAyB;AAChE,mBAAe,eAAe,IAAI;AAAA,EACtC;AACA,QAAM,MAAM;AAAA,IACR,GAAG;AAAA,IACH,YAAY;AAAA,EAChB;AACA,SAAO,OAAO,GAAG;AACjB,SAAO;AACX;AAEA,eAAsB,gBAClB,UACA,aAC+C;AAC/C,QAAM,MAAM,MAAM,yBAAyB,UAAU,WAAW;AAChE,iCAA+B,GAAG;AAClC,SAAO,OAAO,GAAG;AACjB,SAAO;AACX;AAEO,SAAS,+BACZ,aAC6D;AAC7D,QAAM,kCAAkC,YAAY,aAC/C,QAAQ,OAAK,EAAE,UAAU,OAAO,OAAK,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAChE,IAAI,OAAK,EAAE,OAAO;AACvB,QAAM,kBAAkB,oBAAI,IAAI,CAAC,YAAY,UAAU,GAAG,+BAA+B,CAAC;AAE1F,kBAAgB,QAAQ,aAAW;AAC/B,QAAI,CAAC,YAAY,WAAW,OAAO,GAAG;AAElC,YAAM,IAAI,MAAM,kDAAkD,OAAO,IAAI;AAAA,IACjF;AAAA,EACJ,CAAC;AACL;;;ACrFA,SAAS,wBAAwB;AAQ1B,SAAS,gCACZ,aAC4B;AAC5B,QAAM,uBAAuB,sBAAsB,EAAE,OAAO,WAAW;AACvE,SAAO,iBAAiB,EAAE,OAAO,oBAAoB;AACzD","sourcesContent":["import { Encoder } from '@solana/codecs-core';\nimport { getBase58Encoder } from '@solana/codecs-strings';\n\nimport { IDurableNonceTransaction } from './durable-nonce';\nimport { ITransactionWithSignatures } from './signatures';\nimport { BaseTransaction } from './types';\nimport { getUnsignedTransaction } from './unsigned-transaction';\n\nexport type Blockhash = string & { readonly __brand: unique symbol };\n\ntype BlockhashLifetimeConstraint = Readonly<{\n blockhash: Blockhash;\n lastValidBlockHeight: bigint;\n}>;\n\nexport interface ITransactionWithBlockhashLifetime {\n readonly lifetimeConstraint: BlockhashLifetimeConstraint;\n}\n\nlet base58Encoder: Encoder<string> | undefined;\n\nexport function assertIsBlockhash(putativeBlockhash: string): asserts putativeBlockhash is Blockhash {\n if (!base58Encoder) base58Encoder = getBase58Encoder();\n try {\n // Fast-path; see if the input string is of an acceptable length.\n if (\n // Lowest value (32 bytes of zeroes)\n putativeBlockhash.length < 32 ||\n // Highest value (32 bytes of 255)\n putativeBlockhash.length > 44\n ) {\n throw new Error('Expected input string to decode to a byte array of length 32.');\n }\n // Slow-path; actually attempt to decode the input string.\n const bytes = base58Encoder.encode(putativeBlockhash);\n const numBytes = bytes.byteLength;\n if (numBytes !== 32) {\n throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);\n }\n } catch (e) {\n throw new Error(`\\`${putativeBlockhash}\\` is not a blockhash`, {\n cause: e,\n });\n }\n}\n\nfunction isTransactionWithBlockhashLifetime(\n transaction: BaseTransaction | (BaseTransaction & ITransactionWithBlockhashLifetime),\n): transaction is BaseTransaction & ITransactionWithBlockhashLifetime {\n const lifetimeConstraintShapeMatches =\n 'lifetimeConstraint' in transaction &&\n typeof transaction.lifetimeConstraint.blockhash === 'string' &&\n typeof transaction.lifetimeConstraint.lastValidBlockHeight === 'bigint';\n if (!lifetimeConstraintShapeMatches) return false;\n try {\n assertIsBlockhash(transaction.lifetimeConstraint.blockhash);\n return true;\n } catch {\n return false;\n }\n}\n\nexport function assertIsTransactionWithBlockhashLifetime(\n transaction: BaseTransaction | (BaseTransaction & ITransactionWithBlockhashLifetime),\n): asserts transaction is BaseTransaction & ITransactionWithBlockhashLifetime {\n if (!isTransactionWithBlockhashLifetime(transaction)) {\n // TODO: Coded error.\n throw new Error('Transaction does not have a blockhash lifetime');\n }\n}\n\nexport function setTransactionLifetimeUsingBlockhash<TTransaction extends BaseTransaction & IDurableNonceTransaction>(\n blockhashLifetimeConstraint: BlockhashLifetimeConstraint,\n transaction: TTransaction | (TTransaction & ITransactionWithSignatures),\n): Omit<TTransaction, keyof ITransactionWithSignatures | 'lifetimeConstraint'> & ITransactionWithBlockhashLifetime;\n\nexport function setTransactionLifetimeUsingBlockhash<\n TTransaction extends BaseTransaction | (BaseTransaction & ITransactionWithBlockhashLifetime),\n>(\n blockhashLifetimeConstraint: BlockhashLifetimeConstraint,\n transaction: TTransaction | (TTransaction & ITransactionWithSignatures),\n): Omit<TTransaction, keyof ITransactionWithSignatures> & ITransactionWithBlockhashLifetime;\n\nexport function setTransactionLifetimeUsingBlockhash(\n blockhashLifetimeConstraint: BlockhashLifetimeConstraint,\n transaction: BaseTransaction | (BaseTransaction & ITransactionWithBlockhashLifetime),\n) {\n if (\n 'lifetimeConstraint' in transaction &&\n transaction.lifetimeConstraint.blockhash === blockhashLifetimeConstraint.blockhash &&\n transaction.lifetimeConstraint.lastValidBlockHeight === blockhashLifetimeConstraint.lastValidBlockHeight\n ) {\n return transaction;\n }\n const out = {\n ...getUnsignedTransaction(transaction),\n lifetimeConstraint: blockhashLifetimeConstraint,\n };\n Object.freeze(out);\n return out;\n}\n","import { ITransactionWithSignatures } from '.';\nimport { BaseTransaction } from './types';\n\nexport function getUnsignedTransaction<TTransaction extends BaseTransaction>(\n transaction: TTransaction | (TTransaction & ITransactionWithSignatures),\n): TTransaction | Omit<TTransaction & ITransactionWithSignatures, keyof ITransactionWithSignatures> {\n if ('signatures' in transaction) {\n // The implication of the lifetime constraint changing is that any existing signatures are invalid.\n const {\n signatures: _, // eslint-disable-line @typescript-eslint/no-unused-vars\n ...unsignedTransaction\n } = transaction;\n return unsignedTransaction;\n } else {\n return transaction;\n }\n}\n","import { Transaction, TransactionVersion } from './types';\n\ntype TransactionConfig<TVersion extends TransactionVersion> = Readonly<{\n version: TVersion;\n}>;\n\nexport function createTransaction<TVersion extends TransactionVersion>(\n config: TransactionConfig<TVersion>,\n): Extract<Transaction, { version: TVersion }>;\nexport function createTransaction<TVersion extends TransactionVersion>({\n version,\n}: TransactionConfig<TVersion>): Transaction {\n const out: Transaction = {\n instructions: [],\n version,\n };\n Object.freeze(out);\n return out;\n}\n","/**\n * Quick primer on bitwise operations: https://stackoverflow.com/a/1436448/802047\n */\n\nexport enum AccountRole {\n // Bitflag guide: is signer ⌄⌄ is writable\n WRITABLE_SIGNER = /* 3 */ 0b11, // prettier-ignore\n READONLY_SIGNER = /* 2 */ 0b10, // prettier-ignore\n WRITABLE = /* 1 */ 0b01, // prettier-ignore\n READONLY = /* 0 */ 0b00, // prettier-ignore\n}\n\nconst IS_SIGNER_BITMASK = 0b10;\nconst IS_WRITABLE_BITMASK = 0b01;\n\nexport function downgradeRoleToNonSigner(role: AccountRole.READONLY_SIGNER): AccountRole.READONLY;\nexport function downgradeRoleToNonSigner(role: AccountRole.WRITABLE_SIGNER): AccountRole.WRITABLE;\nexport function downgradeRoleToNonSigner(role: AccountRole): AccountRole;\nexport function downgradeRoleToNonSigner(role: AccountRole): AccountRole {\n return role & ~IS_SIGNER_BITMASK;\n}\n\nexport function downgradeRoleToReadonly(role: AccountRole.WRITABLE): AccountRole.READONLY;\nexport function downgradeRoleToReadonly(role: AccountRole.WRITABLE_SIGNER): AccountRole.READONLY_SIGNER;\nexport function downgradeRoleToReadonly(role: AccountRole): AccountRole;\nexport function downgradeRoleToReadonly(role: AccountRole): AccountRole {\n return role & ~IS_WRITABLE_BITMASK;\n}\n\nexport function isSignerRole(role: AccountRole): role is AccountRole.READONLY_SIGNER | AccountRole.WRITABLE_SIGNER {\n return role >= AccountRole.READONLY_SIGNER;\n}\n\nexport function isWritableRole(role: AccountRole): role is AccountRole.WRITABLE | AccountRole.WRITABLE_SIGNER {\n return (role & IS_WRITABLE_BITMASK) !== 0;\n}\n\nexport function mergeRoles(roleA: AccountRole.WRITABLE, roleB: AccountRole.READONLY_SIGNER): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY_SIGNER, roleB: AccountRole.WRITABLE): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.WRITABLE_SIGNER): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.WRITABLE_SIGNER, roleB: AccountRole): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.READONLY_SIGNER): AccountRole.READONLY_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY_SIGNER, roleB: AccountRole): AccountRole.READONLY_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.WRITABLE): AccountRole.WRITABLE; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.WRITABLE, roleB: AccountRole): AccountRole.WRITABLE; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY, roleB: AccountRole.READONLY): AccountRole.READONLY; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole): AccountRole; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole): AccountRole {\n return roleA | roleB;\n}\n\nexport function upgradeRoleToSigner(role: AccountRole.READONLY): AccountRole.READONLY_SIGNER;\nexport function upgradeRoleToSigner(role: AccountRole.WRITABLE): AccountRole.WRITABLE_SIGNER;\nexport function upgradeRoleToSigner(role: AccountRole): AccountRole;\nexport function upgradeRoleToSigner(role: AccountRole): AccountRole {\n return role | IS_SIGNER_BITMASK;\n}\n\nexport function upgradeRoleToWritable(role: AccountRole.READONLY): AccountRole.WRITABLE;\nexport function upgradeRoleToWritable(role: AccountRole.READONLY_SIGNER): AccountRole.WRITABLE_SIGNER;\nexport function upgradeRoleToWritable(role: AccountRole): AccountRole;\nexport function upgradeRoleToWritable(role: AccountRole): AccountRole {\n return role | IS_WRITABLE_BITMASK;\n}\n","import { Address } from '@solana/addresses';\nimport {\n AccountRole,\n IInstruction,\n IInstructionWithAccounts,\n IInstructionWithData,\n isSignerRole,\n ReadonlyAccount,\n ReadonlySignerAccount,\n WritableAccount,\n WritableSignerAccount,\n} from '@solana/instructions';\n\nimport { ITransactionWithSignatures } from './signatures';\nimport { BaseTransaction } from './types';\nimport { getUnsignedTransaction } from './unsigned-transaction';\n\ntype AdvanceNonceAccountInstruction<\n TNonceAccountAddress extends string = string,\n TNonceAuthorityAddress extends string = string,\n> = IInstruction<'11111111111111111111111111111111'> &\n IInstructionWithAccounts<\n readonly [\n WritableAccount<TNonceAccountAddress>,\n ReadonlyAccount<'SysvarRecentB1ockHashes11111111111111111111'>,\n ReadonlySignerAccount<TNonceAuthorityAddress> | WritableSignerAccount<TNonceAuthorityAddress>,\n ]\n > &\n IInstructionWithData<AdvanceNonceAccountInstructionData>;\ntype AdvanceNonceAccountInstructionData = Uint8Array & {\n readonly __brand: unique symbol;\n};\ntype DurableNonceConfig<\n TNonceAccountAddress extends string = string,\n TNonceAuthorityAddress extends string = string,\n TNonceValue extends string = string,\n> = Readonly<{\n readonly nonce: Nonce<TNonceValue>;\n readonly nonceAccountAddress: Address<TNonceAccountAddress>;\n readonly nonceAuthorityAddress: Address<TNonceAuthorityAddress>;\n}>;\nexport type Nonce<TNonceValue extends string = string> = TNonceValue & { readonly __brand: unique symbol };\ntype NonceLifetimeConstraint<TNonceValue extends string = string> = Readonly<{\n nonce: Nonce<TNonceValue>;\n}>;\n\nconst RECENT_BLOCKHASHES_SYSVAR_ADDRESS =\n 'SysvarRecentB1ockHashes11111111111111111111' as Address<'SysvarRecentB1ockHashes11111111111111111111'>;\nconst SYSTEM_PROGRAM_ADDRESS = '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>;\n\nexport interface IDurableNonceTransaction<\n TNonceAccountAddress extends string = string,\n TNonceAuthorityAddress extends string = string,\n TNonceValue extends string = string,\n> {\n readonly instructions: readonly [\n // The first instruction *must* be the system program's `AdvanceNonceAccount` instruction.\n AdvanceNonceAccountInstruction<TNonceAccountAddress, TNonceAuthorityAddress>,\n ...IInstruction[],\n ];\n readonly lifetimeConstraint: NonceLifetimeConstraint<TNonceValue>;\n}\n\nexport function assertIsDurableNonceTransaction(\n transaction: BaseTransaction | (BaseTransaction & IDurableNonceTransaction),\n): asserts transaction is BaseTransaction & IDurableNonceTransaction {\n if (!isDurableNonceTransaction(transaction)) {\n // TODO: Coded error.\n throw new Error('Transaction is not a durable nonce transaction');\n }\n}\n\nfunction createAdvanceNonceAccountInstruction<\n TNonceAccountAddress extends string = string,\n TNonceAuthorityAddress extends string = string,\n>(\n nonceAccountAddress: Address<TNonceAccountAddress>,\n nonceAuthorityAddress: Address<TNonceAuthorityAddress>,\n): AdvanceNonceAccountInstruction<TNonceAccountAddress, TNonceAuthorityAddress> {\n return {\n accounts: [\n { address: nonceAccountAddress, role: AccountRole.WRITABLE },\n {\n address: RECENT_BLOCKHASHES_SYSVAR_ADDRESS,\n role: AccountRole.READONLY,\n },\n { address: nonceAuthorityAddress, role: AccountRole.READONLY_SIGNER },\n ],\n data: new Uint8Array([4, 0, 0, 0]) as AdvanceNonceAccountInstructionData,\n programAddress: SYSTEM_PROGRAM_ADDRESS,\n };\n}\n\nexport function isAdvanceNonceAccountInstruction(\n instruction: IInstruction,\n): instruction is AdvanceNonceAccountInstruction {\n return (\n instruction.programAddress === SYSTEM_PROGRAM_ADDRESS &&\n // Test for `AdvanceNonceAccount` instruction data\n instruction.data != null &&\n isAdvanceNonceAccountInstructionData(instruction.data) &&\n // Test for exactly 3 accounts\n instruction.accounts?.length === 3 &&\n // First account is nonce account address\n instruction.accounts[0].address != null &&\n instruction.accounts[0].role === AccountRole.WRITABLE &&\n // Second account is recent blockhashes sysvar\n instruction.accounts[1].address === RECENT_BLOCKHASHES_SYSVAR_ADDRESS &&\n instruction.accounts[1].role === AccountRole.READONLY &&\n // Third account is nonce authority account\n instruction.accounts[2].address != null &&\n isSignerRole(instruction.accounts[2].role)\n );\n}\n\nfunction isAdvanceNonceAccountInstructionData(data: Uint8Array): data is AdvanceNonceAccountInstructionData {\n // AdvanceNonceAccount is the fifth instruction in the System Program (index 4)\n return data.byteLength === 4 && data[0] === 4 && data[1] === 0 && data[2] === 0 && data[3] === 0;\n}\n\nfunction isDurableNonceTransaction(\n transaction: BaseTransaction | (BaseTransaction & IDurableNonceTransaction),\n): transaction is BaseTransaction & IDurableNonceTransaction {\n return (\n 'lifetimeConstraint' in transaction &&\n typeof transaction.lifetimeConstraint.nonce === 'string' &&\n transaction.instructions[0] != null &&\n isAdvanceNonceAccountInstruction(transaction.instructions[0])\n );\n}\n\nfunction isAdvanceNonceAccountInstructionForNonce<\n TNonceAccountAddress extends Address = Address,\n TNonceAuthorityAddress extends Address = Address,\n>(\n instruction: AdvanceNonceAccountInstruction,\n nonceAccountAddress: TNonceAccountAddress,\n nonceAuthorityAddress: TNonceAuthorityAddress,\n): instruction is AdvanceNonceAccountInstruction<TNonceAccountAddress, TNonceAuthorityAddress> {\n return (\n instruction.accounts[0].address === nonceAccountAddress &&\n instruction.accounts[2].address === nonceAuthorityAddress\n );\n}\n\nexport function setTransactionLifetimeUsingDurableNonce<\n TTransaction extends BaseTransaction,\n TNonceAccountAddress extends string = string,\n TNonceAuthorityAddress extends string = string,\n TNonceValue extends string = string,\n>(\n {\n nonce,\n nonceAccountAddress,\n nonceAuthorityAddress,\n }: DurableNonceConfig<TNonceAccountAddress, TNonceAuthorityAddress, TNonceValue>,\n transaction: TTransaction | (TTransaction & IDurableNonceTransaction),\n): Omit<TTransaction, keyof ITransactionWithSignatures> &\n IDurableNonceTransaction<TNonceAccountAddress, TNonceAuthorityAddress, TNonceValue> {\n let newInstructions: [\n AdvanceNonceAccountInstruction<TNonceAccountAddress, TNonceAuthorityAddress>,\n ...IInstruction[],\n ];\n\n const firstInstruction = transaction.instructions[0];\n if (firstInstruction && isAdvanceNonceAccountInstruction(firstInstruction)) {\n if (isAdvanceNonceAccountInstructionForNonce(firstInstruction, nonceAccountAddress, nonceAuthorityAddress)) {\n if (isDurableNonceTransaction(transaction) && transaction.lifetimeConstraint.nonce === nonce) {\n return transaction as TTransaction &\n IDurableNonceTransaction<TNonceAccountAddress, TNonceAuthorityAddress, TNonceValue>;\n } else {\n // we already have the right first instruction, leave it as-is\n newInstructions = [firstInstruction, ...transaction.instructions.slice(1)];\n }\n } else {\n // we have a different advance nonce instruction as the first instruction, replace it\n newInstructions = [\n createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),\n ...transaction.instructions.slice(1),\n ];\n }\n } else {\n // we don't have an existing advance nonce instruction as the first instruction, prepend one\n newInstructions = [\n createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),\n ...transaction.instructions,\n ];\n }\n\n const out = {\n ...getUnsignedTransaction(transaction),\n instructions: newInstructions,\n lifetimeConstraint: {\n nonce,\n },\n } as TTransaction & IDurableNonceTransaction<TNonceAccountAddress, TNonceAuthorityAddress, TNonceValue>;\n Object.freeze(out);\n return out;\n}\n","import { Address } from '@solana/addresses';\n\nimport { ITransactionWithSignatures } from './signatures';\nimport { BaseTransaction } from './types';\nimport { getUnsignedTransaction } from './unsigned-transaction';\n\nexport interface ITransactionWithFeePayer<TAddress extends string = string> {\n readonly feePayer: Address<TAddress>;\n}\n\nexport function setTransactionFeePayer<TFeePayerAddress extends string, TTransaction extends BaseTransaction>(\n feePayer: Address<TFeePayerAddress>,\n transaction:\n | (TTransaction & ITransactionWithSignatures)\n | (TTransaction & ITransactionWithFeePayer<string> & ITransactionWithSignatures),\n): Omit<TTransaction, keyof ITransactionWithSignatures> & ITransactionWithFeePayer<TFeePayerAddress>;\n\nexport function setTransactionFeePayer<TFeePayerAddress extends string, TTransaction extends BaseTransaction>(\n feePayer: Address<TFeePayerAddress>,\n transaction: TTransaction | (TTransaction & ITransactionWithFeePayer<string>),\n): TTransaction & ITransactionWithFeePayer<TFeePayerAddress>;\n\nexport function setTransactionFeePayer<TFeePayerAddress extends string, TTransaction extends BaseTransaction>(\n feePayer: Address<TFeePayerAddress>,\n transaction:\n | TTransaction\n | (TTransaction & ITransactionWithFeePayer<string>)\n | (TTransaction & ITransactionWithSignatures)\n | (TTransaction & ITransactionWithFeePayer<string> & ITransactionWithSignatures),\n) {\n if ('feePayer' in transaction && feePayer === transaction.feePayer) {\n return transaction;\n }\n const out = {\n ...getUnsignedTransaction(transaction),\n feePayer,\n };\n Object.freeze(out);\n return out;\n}\n","import { ITransactionWithSignatures } from './signatures';\nimport { BaseTransaction } from './types';\nimport { getUnsignedTransaction } from './unsigned-transaction';\n\nexport function appendTransactionInstruction<TTransaction extends BaseTransaction>(\n instruction: TTransaction['instructions'][number],\n transaction: TTransaction | (TTransaction & ITransactionWithSignatures),\n): TTransaction | Omit<TTransaction, keyof ITransactionWithSignatures> {\n const out = {\n ...getUnsignedTransaction(transaction),\n instructions: [...transaction.instructions, instruction],\n };\n Object.freeze(out);\n return out;\n}\n\nexport function prependTransactionInstruction<TTransaction extends BaseTransaction>(\n instruction: TTransaction['instructions'][number],\n transaction: TTransaction | (TTransaction & ITransactionWithSignatures),\n): TTransaction | Omit<TTransaction, keyof ITransactionWithSignatures> {\n const out = {\n ...getUnsignedTransaction(transaction),\n instructions: [instruction, ...transaction.instructions],\n };\n Object.freeze(out);\n return out;\n}\n","import { Address, getAddressComparator } from '@solana/addresses';\nimport {\n AccountRole,\n IAccountLookupMeta,\n IAccountMeta,\n IInstruction,\n isSignerRole,\n isWritableRole,\n mergeRoles,\n ReadonlyAccount,\n ReadonlyAccountLookup,\n ReadonlySignerAccount,\n WritableAccount,\n WritableAccountLookup,\n WritableSignerAccount,\n} from '@solana/instructions';\n\nexport const enum AddressMapEntryType {\n FEE_PAYER,\n LOOKUP_TABLE,\n STATIC,\n}\n\ntype AddressMap = {\n [address: string]: FeePayerAccountEntry | LookupTableAccountEntry | StaticAccountEntry;\n};\ntype FeePayerAccountEntry = Omit<WritableSignerAccount, 'address'> & {\n [TYPE]: AddressMapEntryType.FEE_PAYER;\n};\ntype LookupTableAccountEntry = Omit<ReadonlyAccountLookup | WritableAccountLookup, 'address'> & {\n [TYPE]: AddressMapEntryType.LOOKUP_TABLE;\n};\nexport type OrderedAccounts = (IAccountMeta | IAccountLookupMeta)[] & { readonly __brand: unique symbol };\ntype StaticAccountEntry = Omit<\n ReadonlyAccount | ReadonlySignerAccount | WritableAccount | WritableSignerAccount,\n 'address'\n> & { [TYPE]: AddressMapEntryType.STATIC };\n\nfunction upsert(\n addressMap: AddressMap,\n address: Address,\n update: (\n entry: FeePayerAccountEntry | LookupTableAccountEntry | StaticAccountEntry | Record<never, never>,\n ) => AddressMap[Address],\n) {\n addressMap[address] = update(addressMap[address] ?? { role: AccountRole.READONLY });\n}\n\nconst TYPE = Symbol('AddressMapTypeProperty');\nexport const ADDRESS_MAP_TYPE_PROPERTY: typeof TYPE = TYPE;\n\nexport function getAddressMapFromInstructions(feePayer: Address, instructions: readonly IInstruction[]): AddressMap {\n const addressMap: AddressMap = {\n [feePayer]: { [TYPE]: AddressMapEntryType.FEE_PAYER, role: AccountRole.WRITABLE_SIGNER },\n };\n const addressesOfInvokedPrograms = new Set<Address>();\n for (const instruction of instructions) {\n upsert(addressMap, instruction.programAddress, entry => {\n addressesOfInvokedPrograms.add(instruction.programAddress);\n if (TYPE in entry) {\n if (isWritableRole(entry.role)) {\n switch (entry[TYPE]) {\n case AddressMapEntryType.FEE_PAYER:\n // TODO: Coded error.\n throw new Error(\n 'This transaction includes an address ' +\n `(\\`${instruction.programAddress}\\`) which is both invoked ` +\n 'and set as the fee payer. Program addresses may not pay fees.',\n );\n default:\n // TODO: Coded error.\n throw new Error(\n 'This transaction includes an address ' +\n `(\\`${instruction.programAddress}\\`) which is both invoked ` +\n 'and marked writable. Program addresses may not be writable.',\n );\n }\n }\n if (entry[TYPE] === AddressMapEntryType.STATIC) {\n return entry;\n }\n }\n return { [TYPE]: AddressMapEntryType.STATIC, role: AccountRole.READONLY };\n });\n let addressComparator: ReturnType<typeof getAddressComparator>;\n if (!instruction.accounts) {\n continue;\n }\n for (const account of instruction.accounts) {\n upsert(addressMap, account.address, entry => {\n const {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n address: _,\n ...accountMeta\n } = account;\n if (TYPE in entry) {\n switch (entry[TYPE]) {\n case AddressMapEntryType.FEE_PAYER:\n // The fee payer already has the highest rank -- it is by definition\n // writable-signer. Return it, no matter how `account` is configured\n return entry as FeePayerAccountEntry;\n case AddressMapEntryType.LOOKUP_TABLE: {\n const nextRole = mergeRoles(entry.role, accountMeta.role);\n if ('lookupTableAddress' in accountMeta) {\n const shouldReplaceEntry =\n // Consider using the new LOOKUP_TABLE if its address is different...\n entry.lookupTableAddress !== accountMeta.lookupTableAddress &&\n // ...and sorts before the existing one.\n (addressComparator ||= getAddressComparator())(\n accountMeta.lookupTableAddress,\n entry.lookupTableAddress,\n ) < 0;\n if (shouldReplaceEntry) {\n return {\n [TYPE]: AddressMapEntryType.LOOKUP_TABLE,\n ...accountMeta,\n role: nextRole,\n } as LookupTableAccountEntry;\n }\n } else if (isSignerRole(accountMeta.role)) {\n // Upgrade this LOOKUP_TABLE entry to a static entry if it must sign.\n return {\n [TYPE]: AddressMapEntryType.STATIC,\n role: nextRole,\n } as StaticAccountEntry;\n }\n if (entry.role !== nextRole) {\n return {\n ...entry,\n role: nextRole,\n } as LookupTableAccountEntry;\n } else {\n return entry as LookupTableAccountEntry;\n }\n }\n case AddressMapEntryType.STATIC: {\n const nextRole = mergeRoles(entry.role, accountMeta.role);\n if (\n // Check to see if this address represents a program that is invoked\n // in this transaction.\n addressesOfInvokedPrograms.has(account.address)\n ) {\n if (isWritableRole(accountMeta.role)) {\n // TODO: Coded error.\n throw new Error(\n 'This transaction includes an address ' +\n `(\\`${account.address}\\`) which is both invoked and ` +\n 'marked writable. Program addresses may not be ' +\n 'writable.',\n );\n }\n if (entry.role !== nextRole) {\n return {\n ...entry,\n role: nextRole,\n } as StaticAccountEntry;\n } else {\n return entry as StaticAccountEntry;\n }\n } else if (\n 'lookupTableAddress' in accountMeta &&\n // Static accounts can be 'upgraded' to lookup table accounts as\n // long as they are not require to sign the transaction.\n !isSignerRole(entry.role)\n ) {\n return {\n ...accountMeta,\n [TYPE]: AddressMapEntryType.LOOKUP_TABLE,\n role: nextRole,\n } as LookupTableAccountEntry;\n } else {\n if (entry.role !== nextRole) {\n // The account's role ranks higher than the current entry's.\n return {\n ...entry,\n role: nextRole,\n } as StaticAccountEntry;\n } else {\n return entry as StaticAccountEntry;\n }\n }\n }\n }\n }\n if ('lookupTableAddress' in accountMeta) {\n return {\n ...accountMeta,\n [TYPE]: AddressMapEntryType.LOOKUP_TABLE,\n };\n } else {\n return {\n ...accountMeta,\n [TYPE]: AddressMapEntryType.STATIC,\n };\n }\n });\n }\n }\n return addressMap;\n}\n\nexport function getOrderedAccountsFromAddressMap(addressMap: AddressMap): OrderedAccounts {\n let addressComparator: ReturnType<typeof getAddressComparator>;\n const orderedAccounts: (IAccountMeta | IAccountLookupMeta)[] = Object.entries(addressMap)\n .sort(([leftAddress, leftEntry], [rightAddress, rightEntry]) => {\n // STEP 1: Rapid precedence check. Fee payer, then static addresses, then lookups.\n if (leftEntry[TYPE] !== rightEntry[TYPE]) {\n if (leftEntry[TYPE] === AddressMapEntryType.FEE_PAYER) {\n return -1;\n } else if (rightEntry[TYPE] === AddressMapEntryType.FEE_PAYER) {\n return 1;\n } else if (leftEntry[TYPE] === AddressMapEntryType.STATIC) {\n return -1;\n } else if (rightEntry[TYPE] === AddressMapEntryType.STATIC) {\n return 1;\n }\n }\n // STEP 2: Sort by signer-writability.\n const leftIsSigner = isSignerRole(leftEntry.role);\n if (leftIsSigner !== isSignerRole(rightEntry.role)) {\n return leftIsSigner ? -1 : 1;\n }\n const leftIsWritable = isWritableRole(leftEntry.role);\n if (leftIsWritable !== isWritableRole(rightEntry.role)) {\n return leftIsWritable ? -1 : 1;\n }\n // STEP 3: Sort by address.\n addressComparator ||= getAddressComparator();\n if (\n leftEntry[TYPE] === AddressMapEntryType.LOOKUP_TABLE &&\n rightEntry[TYPE] === AddressMapEntryType.LOOKUP_TABLE &&\n leftEntry.lookupTableAddress !== rightEntry.lookupTableAddress\n ) {\n return addressComparator(leftEntry.lookupTableAddress, rightEntry.lookupTableAddress);\n } else {\n return addressComparator(leftAddress, rightAddress);\n }\n })\n .map(([address, addressMeta]) => ({\n address: address as Address<typeof address>,\n ...addressMeta,\n }));\n return orderedAccounts as unknown as OrderedAccounts;\n}\n","import { Address, getAddressComparator } from '@solana/addresses';\nimport { AccountRole } from '@solana/instructions';\n\nimport { OrderedAccounts } from './accounts';\n\ntype AddressTableLookup = Readonly<{\n lookupTableAddress: Address;\n readableIndices: readonly number[];\n writableIndices: readonly number[];\n}>;\n\nexport function getCompiledAddressTableLookups(orderedAccounts: OrderedAccounts): AddressTableLookup[] {\n const index: Record<Address, { readonly readableIndices: number[]; readonly writableIndices: number[] }> = {};\n for (const account of orderedAccounts) {\n if (!('lookupTableAddress' in account)) {\n continue;\n }\n const entry = (index[account.lookupTableAddress] ||= {\n readableIndices: [],\n writableIndices: [],\n });\n if (account.role === AccountRole.WRITABLE) {\n entry.writableIndices.push(account.addressIndex);\n } else {\n entry.readableIndices.push(account.addressIndex);\n }\n }\n return Object.keys(index)\n .sort(getAddressComparator())\n .map(lookupTableAddress => ({\n lookupTableAddress: lookupTableAddress as Address,\n ...index[lookupTableAddress as unknown as Address],\n }));\n}\n","import { isSignerRole, isWritableRole } from '@solana/instructions';\n\nimport { OrderedAccounts } from './accounts';\n\ntype MessageHeader = Readonly<{\n numReadonlyNonSignerAccounts: number;\n numReadonlySignerAccounts: number;\n numSignerAccounts: number;\n}>;\n\nexport function getCompiledMessageHeader(orderedAccounts: OrderedAccounts): MessageHeader {\n let numReadonlyNonSignerAccounts = 0;\n let numReadonlySignerAccounts = 0;\n let numSignerAccounts = 0;\n for (const account of orderedAccounts) {\n if ('lookupTableAddress' in account) {\n break;\n }\n const accountIsWritable = isWritableRole(account.role);\n if (isSignerRole(account.role)) {\n numSignerAccounts++;\n if (!accountIsWritable) {\n numReadonlySignerAccounts++;\n }\n } else if (!accountIsWritable) {\n numReadonlyNonSignerAccounts++;\n }\n }\n return {\n numReadonlyNonSignerAccounts,\n numReadonlySignerAccounts,\n numSignerAccounts,\n };\n}\n","import { Address } from '@solana/addresses';\nimport { IInstruction } from '@solana/instructions';\n\nimport { OrderedAccounts } from './accounts';\n\ntype CompiledInstruction = Readonly<{\n accountIndices?: number[];\n data?: Uint8Array;\n programAddressIndex: number;\n}>;\n\nfunction getAccountIndex(orderedAccounts: OrderedAccounts) {\n const out: Record<Address, number> = {};\n for (const [index, account] of orderedAccounts.entries()) {\n out[account.address] = index;\n }\n return out;\n}\n\nexport function getCompiledInstructions(\n instructions: readonly IInstruction[],\n orderedAccounts: OrderedAccounts,\n): CompiledInstruction[] {\n const accountIndex = getAccountIndex(orderedAccounts);\n return instructions.map(({ accounts, data, programAddress }) => {\n return {\n programAddressIndex: accountIndex[programAddress],\n ...(accounts ? { accountIndices: accounts.map(({ address }) => accountIndex[address]) } : null),\n ...(data ? { data } : null),\n };\n });\n}\n","import { IDurableNonceTransaction, ITransactionWithBlockhashLifetime } from './index';\n\nexport function getCompiledLifetimeToken(\n lifetimeConstraint: (ITransactionWithBlockhashLifetime | IDurableNonceTransaction)['lifetimeConstraint'],\n): string {\n if ('nonce' in lifetimeConstraint) {\n return lifetimeConstraint.nonce;\n }\n return lifetimeConstraint.blockhash;\n}\n","import { Address } from '@solana/addresses';\n\nimport { OrderedAccounts } from './accounts';\n\nexport function getCompiledStaticAccounts(orderedAccounts: OrderedAccounts): Address[] {\n const firstLookupTableAccountIndex = orderedAccounts.findIndex(account => 'lookupTableAddress' in account);\n const orderedStaticAccounts =\n firstLookupTableAccountIndex === -1 ? orderedAccounts : orderedAccounts.slice(0, firstLookupTableAccountIndex);\n return orderedStaticAccounts.map(({ address }) => address);\n}\n","import { getAddressMapFromInstructions, getOrderedAccountsFromAddressMap } from './accounts';\nimport { CompilableTransaction } from './compilable-transaction';\nimport { getCompiledAddressTableLookups } from './compile-address-table-lookups';\nimport { getCompiledMessageHeader } from './compile-header';\nimport { getCompiledInstructions } from './compile-instructions';\nimport { getCompiledLifetimeToken } from './compile-lifetime-token';\nimport { getCompiledStaticAccounts } from './compile-static-accounts';\n\ntype BaseCompiledMessage = Readonly<{\n header: ReturnType<typeof getCompiledMessageHeader>;\n instructions: ReturnType<typeof getCompiledInstructions>;\n lifetimeToken: ReturnType<typeof getCompiledLifetimeToken>;\n staticAccounts: ReturnType<typeof getCompiledStaticAccounts>;\n}>;\n\nexport type CompiledMessage = LegacyCompiledMessage | VersionedCompiledMessage;\n\ntype LegacyCompiledMessage = BaseCompiledMessage &\n Readonly<{\n version: 'legacy';\n }>;\n\ntype VersionedCompiledMessage = BaseCompiledMessage &\n Readonly<{\n addressTableLookups?: ReturnType<typeof getCompiledAddressTableLookups>;\n version: number;\n }>;\n\nexport function compileMessage(\n transaction: CompilableTransaction & Readonly<{ version: 'legacy' }>,\n): LegacyCompiledMessage;\nexport function compileMessage(transaction: CompilableTransaction): VersionedCompiledMessage;\nexport function compileMessage(transaction: CompilableTransaction): CompiledMessage {\n const addressMap = getAddressMapFromInstructions(transaction.feePayer, transaction.instructions);\n const orderedAccounts = getOrderedAccountsFromAddressMap(addressMap);\n return {\n ...(transaction.version !== 'legacy'\n ? { addressTableLookups: getCompiledAddressTableLookups(orderedAccounts) }\n : null),\n header: getCompiledMessageHeader(orderedAccounts),\n instructions: getCompiledInstructions(transaction.instructions, orderedAccounts),\n lifetimeToken: getCompiledLifetimeToken(transaction.lifetimeConstraint),\n staticAccounts: getCompiledStaticAccounts(orderedAccounts),\n version: transaction.version,\n };\n}\n","import { getAddressDecoder, getAddressEncoder } from '@solana/addresses';\nimport {\n combineCodec,\n createEncoder,\n Decoder,\n mapDecoder,\n mapEncoder,\n VariableSizeCodec,\n VariableSizeDecoder,\n VariableSizeEncoder,\n} from '@solana/codecs-core';\nimport {\n getArrayDecoder,\n getArrayEncoder,\n getStructDecoder,\n getStructEncoder,\n StructToDecoderTuple,\n StructToEncoderTuple,\n} from '@solana/codecs-data-structures';\nimport { getShortU16Decoder, getShortU16Encoder } from '@solana/codecs-numbers';\nimport { getBase58Decoder, getBase58Encoder, getStringDecoder, getStringEncoder } from '@solana/codecs-strings';\n\nimport { getCompiledAddressTableLookups } from '../compile-address-table-lookups';\nimport { CompiledMessage } from '../message';\nimport { getAddressTableLookupDecoder, getAddressTableLookupEncoder } from './address-table-lookup';\nimport { getMessageHeaderDecoder, getMessageHeaderEncoder } from './header';\nimport { getInstructionDecoder, getInstructionEncoder } from './instruction';\nimport { getTransactionVersionDecoder, getTransactionVersionEncoder } from './transaction-version';\n\nfunction getCompiledMessageLegacyEncoder(): VariableSizeEncoder<CompiledMessage> {\n return getStructEncoder(getPreludeStructEncoderTuple());\n}\n\nfunction getCompiledMessageVersionedEncoder(): VariableSizeEncoder<CompiledMessage> {\n return mapEncoder(\n getStructEncoder([\n ...getPreludeStructEncoderTuple(),\n ['addressTableLookups', getAddressTableLookupArrayEncoder()],\n ] as StructToEncoderTuple<CompiledMessage>),\n (value: CompiledMessage) => {\n if (value.version === 'legacy') {\n return value;\n }\n return {\n ...value,\n addressTableLookups: value.addressTableLookups ?? [],\n } as Exclude<CompiledMessage, { readonly version: 'legacy' }>;\n },\n );\n}\n\nfunction getPreludeStructEncoderTuple(): StructToEncoderTuple<CompiledMessage> {\n return [\n ['version', getTransactionVersionEncoder()],\n ['header', getMessageHeaderEncoder()],\n ['staticAccounts', getArrayEncoder(getAddressEncoder(), { size: getShortU16Encoder() })],\n ['lifetimeToken', getStringEncoder({ encoding: getBase58Encoder(), size: 32 })],\n ['instructions', getArrayEncoder(getInstructionEncoder(), { size: getShortU16Encoder() })],\n ];\n}\n\nfunction getPreludeStructDecoderTuple(): StructToDecoderTuple<\n CompiledMessage & { addressTableLookups?: ReturnType<typeof getCompiledAddressTableLookups> }\n> {\n return [\n ['version', getTransactionVersionDecoder() as Decoder<number>],\n ['header', getMessageHeaderDecoder()],\n ['staticAccounts', getArrayDecoder(getAddressDecoder(), { size: getShortU16Decoder() })],\n ['lifetimeToken', getStringDecoder({ encoding: getBase58Decoder(), size: 32 })],\n ['instructions', getArrayDecoder(getInstructionDecoder(), { size: getShortU16Decoder() })],\n ['addressTableLookups', getAddressTableLookupArrayDecoder()],\n ];\n}\n\nfunction getAddressTableLookupArrayEncoder() {\n return getArrayEncoder(getAddressTableLookupEncoder(), { size: getShortU16Encoder() });\n}\n\nfunction getAddressTableLookupArrayDecoder() {\n return getArrayDecoder(getAddressTableLookupDecoder(), { size: getShortU16Decoder() });\n}\n\nexport function getCompiledMessageEncoder(): VariableSizeEncoder<CompiledMessage> {\n return createEncoder({\n getSizeFromValue: (compiledMessage: CompiledMessage) => {\n if (compiledMessage.version === 'legacy') {\n return getCompiledMessageLegacyEncoder().getSizeFromValue(compiledMessage);\n } else {\n return getCompiledMessageVersionedEncoder().getSizeFromValue(compiledMessage);\n }\n },\n write: (compiledMessage, bytes, offset) => {\n if (compiledMessage.version === 'legacy') {\n return getCompiledMessageLegacyEncoder().write(compiledMessage, bytes, offset);\n } else {\n return getCompiledMessageVersionedEncoder().write(compiledMessage, bytes, offset);\n }\n },\n });\n}\n\nexport function getCompiledMessageDecoder(): VariableSizeDecoder<CompiledMessage> {\n return mapDecoder(getStructDecoder(getPreludeStructDecoderTuple()), ({ addressTableLookups, ...restOfMessage }) => {\n if (restOfMessage.version === 'legacy' || !addressTableLookups?.length) {\n return restOfMessage;\n }\n return { ...restOfMessage, addressTableLookups } as Exclude<CompiledMessage, { readonly version: 'legacy' }>;\n });\n}\n\nexport function getCompiledMessageCodec(): VariableSizeCodec<CompiledMessage> {\n return combineCodec(getCompiledMessageEncoder(), getCompiledMessageDecoder());\n}\n","import { getAddressDecoder, getAddressEncoder } from '@solana/addresses';\nimport {\n combineCodec,\n type Encoder,\n type VariableSizeCodec,\n type VariableSizeDecoder,\n type VariableSizeEncoder,\n} from '@solana/codecs-core';\nimport { getArrayDecoder, getArrayEncoder, getStructDecoder, getStructEncoder } from '@solana/codecs-data-structures';\nimport { getShortU16Decoder, getShortU16Encoder, getU8Decoder, getU8Encoder } from '@solana/codecs-numbers';\n\nimport type { getCompiledAddressTableLookups } from '../compile-address-table-lookups';\n\ntype AddressTableLookup = ReturnType<typeof getCompiledAddressTableLookups>[number];\n\nlet memoizedAddressTableLookupEncoder: VariableSizeEncoder<AddressTableLookup> | undefined;\nexport function getAddressTableLookupEncoder(): VariableSizeEncoder<AddressTableLookup> {\n if (!memoizedAddressTableLookupEncoder) {\n memoizedAddressTableLookupEncoder = getStructEncoder([\n ['lookupTableAddress', getAddressEncoder()],\n [\n 'writableIndices',\n getArrayEncoder(getU8Encoder(), { size: getShortU16Encoder() }) as Encoder<readonly number[]>,\n ],\n [\n 'readableIndices',\n getArrayEncoder(getU8Encoder(), { size: getShortU16Encoder() }) as Encoder<readonly number[]>,\n ],\n ]);\n }\n\n return memoizedAddressTableLookupEncoder;\n}\n\nlet memoizedAddressTableLookupDecoder: VariableSizeDecoder<AddressTableLookup> | undefined;\nexport function getAddressTableLookupDecoder(): VariableSizeDecoder<AddressTableLookup> {\n if (!memoizedAddressTableLookupDecoder) {\n memoizedAddressTableLookupDecoder = getStructDecoder([\n ['lookupTableAddress', getAddressDecoder()],\n ['writableIndices', getArrayDecoder(getU8Decoder(), { size: getShortU16Decoder() })],\n ['readableIndices', getArrayDecoder(getU8Decoder(), { size: getShortU16Decoder() })],\n ]);\n }\n\n return memoizedAddressTableLookupDecoder;\n}\n\nexport function getAddressTableLookupCodec(): VariableSizeCodec<AddressTableLookup> {\n return combineCodec(getAddressTableLookupEncoder(), getAddressTableLookupDecoder());\n}\n","import { FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder } from '@solana/codecs-core';\nimport { getStructCodec, getStructDecoder, getStructEncoder } from '@solana/codecs-data-structures';\nimport { getU8Codec, getU8Decoder, getU8Encoder } from '@solana/codecs-numbers';\n\nimport { getCompiledMessageHeader } from '../compile-header';\n\ntype MessageHeader = ReturnType<typeof getCompiledMessageHeader>;\n\nlet memoizedU8Encoder: FixedSizeEncoder<number, 1> | undefined;\nfunction getMemoizedU8Encoder(): FixedSizeEncoder<number, 1> {\n if (!memoizedU8Encoder) memoizedU8Encoder = getU8Encoder();\n return memoizedU8Encoder;\n}\n\nlet memoizedU8Decoder: FixedSizeDecoder<number, 1> | undefined;\nfunction getMemoizedU8Decoder(): FixedSizeDecoder<number, 1> {\n if (!memoizedU8Decoder) memoizedU8Decoder = getU8Decoder();\n return memoizedU8Decoder;\n}\n\nlet memoizedU8Codec: FixedSizeCodec<number, number, 1> | undefined;\nfunction getMemoizedU8Codec(): FixedSizeCodec<number, number, 1> {\n if (!memoizedU8Codec) memoizedU8Codec = getU8Codec();\n return memoizedU8Codec;\n}\n\nexport function getMessageHeaderEncoder(): FixedSizeEncoder<MessageHeader, 3> {\n return getStructEncoder([\n ['numSignerAccounts', getMemoizedU8Encoder()],\n ['numReadonlySignerAccounts', getMemoizedU8Encoder()],\n ['numReadonlyNonSignerAccounts', getMemoizedU8Encoder()],\n ]) as FixedSizeEncoder<MessageHeader, 3>;\n}\n\nexport function getMessageHeaderDecoder(): FixedSizeDecoder<MessageHeader, 3> {\n return getStructDecoder([\n ['numSignerAccounts', getMemoizedU8Decoder()],\n ['numReadonlySignerAccounts', getMemoizedU8Decoder()],\n ['numReadonlyNonSignerAccounts', getMemoizedU8Decoder()],\n ]) as FixedSizeDecoder<MessageHeader, 3>;\n}\n\nexport function getMessageHeaderCodec(): FixedSizeCodec<MessageHeader, MessageHeader, 3> {\n return getStructCodec([\n ['numSignerAccounts', getMemoizedU8Codec()],\n ['numReadonlySignerAccounts', getMemoizedU8Codec()],\n ['numReadonlyNonSignerAccounts', getMemoizedU8Codec()],\n ]) as FixedSizeCodec<MessageHeader, MessageHeader, 3>;\n}\n","import {\n combineCodec,\n mapDecoder,\n mapEncoder,\n VariableSizeCodec,\n VariableSizeDecoder,\n VariableSizeEncoder,\n} from '@solana/codecs-core';\nimport {\n getArrayDecoder,\n getArrayEncoder,\n getBytesDecoder,\n getBytesEncoder,\n getStructDecoder,\n getStructEncoder,\n} from '@solana/codecs-data-structures';\nimport { getShortU16Decoder, getShortU16Encoder, getU8Decoder, getU8Encoder } from '@solana/codecs-numbers';\n\nimport { getCompiledInstructions } from '../compile-instructions';\n\ntype Instruction = ReturnType<typeof getCompiledInstructions>[number];\n\nlet memoizedGetInstructionEncoder: VariableSizeEncoder<Instruction> | undefined;\nexport function getInstructionEncoder(): VariableSizeEncoder<Instruction> {\n if (!memoizedGetInstructionEncoder) {\n memoizedGetInstructionEncoder = mapEncoder<Required<Instruction>, Instruction>(\n getStructEncoder([\n ['programAddressIndex', getU8Encoder()],\n ['accountIndices', getArrayEncoder(getU8Encoder(), { size: getShortU16Encoder() })],\n ['data', getBytesEncoder({ size: getShortU16Encoder() })],\n ]),\n // Convert an instruction to have all fields defined\n (instruction: Instruction): Required<Instruction> => {\n if (instruction.accountIndices !== undefined && instruction.data !== undefined) {\n return instruction as Required<Instruction>;\n }\n return {\n ...instruction,\n accountIndices: instruction.accountIndices ?? [],\n data: instruction.data ?? new Uint8Array(0),\n } as Required<Instruction>;\n },\n );\n }\n\n return memoizedGetInstructionEncoder;\n}\n\nlet memoizedGetInstructionDecoder: VariableSizeDecoder<Instruction> | undefined;\nexport function getInstructionDecoder(): VariableSizeDecoder<Instruction> {\n if (!memoizedGetInstructionDecoder) {\n memoizedGetInstructionDecoder = mapDecoder<Required<Instruction>, Instruction>(\n getStructDecoder([\n ['programAddressIndex', getU8Decoder()],\n ['accountIndices', getArrayDecoder(getU8Decoder(), { size: getShortU16Decoder() })],\n ['data', getBytesDecoder({ size: getShortU16Decoder() })],\n ]),\n // Convert an instruction to exclude optional fields if they are empty\n (instruction: Required<Instruction>): Instruction => {\n if (instruction.accountIndices.length && instruction.data.byteLength) {\n return instruction;\n }\n const { accountIndices, data, ...rest } = instruction;\n return {\n ...rest,\n ...(accountIndices.length ? { accountIndices } : null),\n ...(data.byteLength ? { data } : null),\n };\n },\n );\n }\n return memoizedGetInstructionDecoder;\n}\n\nexport function getInstructionCodec(): VariableSizeCodec<Instruction> {\n return combineCodec(getInstructionEncoder(), getInstructionDecoder());\n}\n","import {\n combineCodec,\n createDecoder,\n createEncoder,\n VariableSizeCodec,\n VariableSizeDecoder,\n VariableSizeEncoder,\n} from '@solana/codecs-core';\n\nimport { TransactionVersion } from '../types';\n\nconst VERSION_FLAG_MASK = 0x80;\n\nexport function getTransactionVersionEncoder(): VariableSizeEncoder<TransactionVersion> {\n return createEncoder({\n getSizeFromValue: value => (value === 'legacy' ? 0 : 1),\n maxSize: 1,\n write: (value, bytes, offset) => {\n if (value === 'legacy') {\n return offset;\n }\n if (value < 0 || value > 127) {\n // TODO: Coded error.\n throw new Error(`Transaction version must be in the range [0, 127]. \\`${value}\\` given.`);\n }\n bytes.set([value | VERSION_FLAG_MASK], offset);\n return offset + 1;\n },\n });\n}\n\nexport function getTransactionVersionDecoder(): VariableSizeDecoder<TransactionVersion> {\n return createDecoder({\n maxSize: 1,\n read: (bytes, offset) => {\n const firstByte = bytes[offset];\n if ((firstByte & VERSION_FLAG_MASK) === 0) {\n // No version flag set; it's a legacy (unversioned) transaction.\n return ['legacy', offset];\n } else {\n const version = (firstByte ^ VERSION_FLAG_MASK) as TransactionVersion;\n return [version, offset + 1];\n }\n },\n });\n}\n\nexport function getTransactionVersionCodec(): VariableSizeCodec<TransactionVersion> {\n return combineCodec(getTransactionVersionEncoder(), getTransactionVersionDecoder());\n}\n","import {\n combineCodec,\n FixedSizeDecoder,\n mapDecoder,\n mapEncoder,\n VariableSizeCodec,\n VariableSizeDecoder,\n VariableSizeEncoder,\n} from '@solana/codecs-core';\nimport {\n getArrayDecoder,\n getArrayEncoder,\n getBytesDecoder,\n getBytesEncoder,\n getStructDecoder,\n getStructEncoder,\n} from '@solana/codecs-data-structures';\nimport { getShortU16Decoder, getShortU16Encoder } from '@solana/codecs-numbers';\nimport { SignatureBytes } from '@solana/keys';\n\nimport { CompilableTransaction } from '../compilable-transaction';\nimport { CompiledTransaction, getCompiledTransaction } from '../compile-transaction';\nimport { decompileTransaction } from '../decompile-transaction';\nimport { ITransactionWithSignatures } from '../signatures';\nimport { getCompiledMessageDecoder, getCompiledMessageEncoder } from './message';\n\nfunction getCompiledTransactionEncoder(): VariableSizeEncoder<CompiledTransaction> {\n return getStructEncoder([\n ['signatures', getArrayEncoder(getBytesEncoder({ size: 64 }), { size: getShortU16Encoder() })],\n ['compiledMessage', getCompiledMessageEncoder()],\n ]);\n}\n\nfunction getCompiledTransactionDecoder(): VariableSizeDecoder<CompiledTransaction> {\n return getStructDecoder([\n [\n 'signatures',\n getArrayDecoder(getBytesDecoder({ size: 64 }) as FixedSizeDecoder<SignatureBytes, 64>, {\n size: getShortU16Decoder(),\n }),\n ],\n ['compiledMessage', getCompiledMessageDecoder()],\n ]);\n}\n\nexport function getTransactionEncoder(): VariableSizeEncoder<\n CompilableTransaction | (CompilableTransaction & ITransactionWithSignatures)\n> {\n return mapEncoder(getCompiledTransactionEncoder(), getCompiledTransaction);\n}\n\nexport function getTransactionDecoder(\n lastValidBlockHeight?: bigint,\n): VariableSizeDecoder<CompilableTransaction | (CompilableTransaction & ITransactionWithSignatures)> {\n return mapDecoder(getCompiledTransactionDecoder(), compiledTransaction =>\n decompileTransaction(compiledTransaction, lastValidBlockHeight),\n );\n}\n\nexport function getTransactionCodec(\n lastValidBlockHeight?: bigint,\n): VariableSizeCodec<CompilableTransaction | (CompilableTransaction & ITransactionWithSignatures)> {\n return combineCodec(getTransactionEncoder(), getTransactionDecoder(lastValidBlockHeight));\n}\n","import { SignatureBytes } from '@solana/keys';\n\nimport { CompilableTransaction } from './compilable-transaction';\nimport { CompiledMessage, compileMessage } from './message';\nimport { ITransactionWithSignatures } from './signatures';\n\nexport type CompiledTransaction = Readonly<{\n compiledMessage: CompiledMessage;\n signatures: SignatureBytes[];\n}>;\n\nexport function getCompiledTransaction(\n transaction: CompilableTransaction | (CompilableTransaction & ITransactionWithSignatures),\n): CompiledTransaction {\n const compiledMessage = compileMessage(transaction);\n let signatures;\n if ('signatures' in transaction) {\n signatures = [];\n for (let ii = 0; ii < compiledMessage.header.numSignerAccounts; ii++) {\n signatures[ii] =\n transaction.signatures[compiledMessage.staticAccounts[ii]] ?? new Uint8Array(Array(64).fill(0));\n }\n } else {\n signatures = Array(compiledMessage.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));\n }\n return {\n compiledMessage,\n signatures,\n };\n}\n","import { Address, assertIsAddress } from '@solana/addresses';\nimport { pipe } from '@solana/functional';\nimport { AccountRole, IAccountMeta, IInstruction } from '@solana/instructions';\nimport { SignatureBytes } from '@solana/keys';\n\nimport { Blockhash, setTransactionLifetimeUsingBlockhash } from './blockhash';\nimport { CompilableTransaction } from './compilable-transaction';\nimport { CompiledTransaction } from './compile-transaction';\nimport { createTransaction } from './create-transaction';\nimport { isAdvanceNonceAccountInstruction, Nonce, setTransactionLifetimeUsingDurableNonce } from './durable-nonce';\nimport { setTransactionFeePayer } from './fee-payer';\nimport { appendTransactionInstruction } from './instructions';\nimport { CompiledMessage } from './message';\nimport { ITransactionWithSignatures } from './signatures';\nimport { TransactionVersion } from './types';\n\nfunction getAccountMetas(message: CompiledMessage): IAccountMeta[] {\n const { header } = message;\n const numWritableSignerAccounts = header.numSignerAccounts - header.numReadonlySignerAccounts;\n const numWritableNonSignerAccounts =\n message.staticAccounts.length - header.numSignerAccounts - header.numReadonlyNonSignerAccounts;\n\n const accountMetas: IAccountMeta[] = [];\n\n let accountIndex = 0;\n for (let i = 0; i < numWritableSignerAccounts; i++) {\n accountMetas.push({\n address: message.staticAccounts[accountIndex],\n role: AccountRole.WRITABLE_SIGNER,\n });\n accountIndex++;\n }\n\n for (let i = 0; i < header.numReadonlySignerAccounts; i++) {\n accountMetas.push({\n address: message.staticAccounts[accountIndex],\n role: AccountRole.READONLY_SIGNER,\n });\n accountIndex++;\n }\n\n for (let i = 0; i < numWritableNonSignerAccounts; i++) {\n accountMetas.push({\n address: message.staticAccounts[accountIndex],\n role: AccountRole.WRITABLE,\n });\n accountIndex++;\n }\n\n for (let i = 0; i < header.numReadonlyNonSignerAccounts; i++) {\n accountMetas.push({\n address: message.staticAccounts[accountIndex],\n role: AccountRole.READONLY,\n });\n accountIndex++;\n }\n\n return accountMetas;\n}\n\nfunction convertInstruction(\n instruction: CompiledMessage['instructions'][0],\n accountMetas: IAccountMeta[],\n): IInstruction {\n const programAddress = accountMetas[instruction.programAddressIndex]?.address;\n if (!programAddress) {\n // TODO coded error\n throw new Error(`Could not find program address at index ${instruction.programAddressIndex}`);\n }\n\n const accounts = instruction.accountIndices?.map(accountIndex => accountMetas[accountIndex]);\n const { data } = instruction;\n\n return {\n programAddress,\n ...(accounts && accounts.length ? { accounts } : {}),\n ...(data && data.length ? { data } : {}),\n };\n}\n\ntype LifetimeConstraint =\n | {\n blockhash: Blockhash;\n lastValidBlockHeight: bigint;\n }\n | {\n nonce: Nonce;\n nonceAccountAddress: Address;\n nonceAuthorityAddress: Address;\n };\n\nfunction getLifetimeConstraint(\n messageLifetimeToken: string,\n firstInstruction?: IInstruction,\n lastValidBlockHeight?: bigint,\n): LifetimeConstraint {\n if (!firstInstruction || !isAdvanceNonceAccountInstruction(firstInstruction)) {\n // first instruction is not advance durable nonce, so use blockhash lifetime constraint\n return {\n blockhash: messageLifetimeToken as Blockhash,\n lastValidBlockHeight: lastValidBlockHeight ?? 2n ** 64n - 1n, // U64 MAX\n };\n } else {\n // We know these accounts are defined because we checked `isAdvanceNonceAccountInstruction`\n const nonceAccountAddress = firstInstruction.accounts![0].address;\n assertIsAddress(nonceAccountAddress);\n\n const nonceAuthorityAddress = firstInstruction.accounts![2].address;\n assertIsAddress(nonceAuthorityAddress);\n\n return {\n nonce: messageLifetimeToken as Nonce,\n nonceAccountAddress,\n nonceAuthorityAddress,\n };\n }\n}\n\nfunction convertSignatures(compiledTransaction: CompiledTransaction): ITransactionWithSignatures['signatures'] {\n const {\n compiledMessage: { staticAccounts },\n signatures,\n } = compiledTransaction;\n return signatures.reduce((acc, sig, index) => {\n // compiled transaction includes a fake all 0 signature if it hasn't been signed\n // we don't store those for the new tx model. So just skip if it's all 0s\n const allZeros = sig.every(byte => byte === 0);\n if (allZeros) return acc;\n\n const address = staticAccounts[index];\n return { ...acc, [address]: sig as SignatureBytes };\n }, {});\n}\n\nexport function decompileTransaction(\n compiledTransaction: CompiledTransaction,\n lastValidBlockHeight?: bigint,\n): CompilableTransaction | (CompilableTransaction & ITransactionWithSignatures) {\n const { compiledMessage } = compiledTransaction;\n\n // TODO: add support for address lookup tables\n if ('addressTableLookups' in compiledMessage && compiledMessage.addressTableLookups!.length > 0) {\n // TODO: coded error\n throw new Error('Cannot convert transaction with addressTableLookups');\n }\n\n const feePayer = compiledMessage.staticAccounts[0];\n // TODO: coded error\n if (!feePayer) throw new Error('No fee payer set in CompiledTransaction');\n\n const accountMetas = getAccountMetas(compiledMessage);\n\n const instructions: IInstruction[] = compiledMessage.instructions.map(compiledInstruction =>\n convertInstruction(compiledInstruction, accountMetas),\n );\n\n const firstInstruction = instructions[0];\n const lifetimeConstraint = getLifetimeConstraint(\n compiledMessage.lifetimeToken,\n firstInstruction,\n lastValidBlockHeight,\n );\n\n const signatures = convertSignatures(compiledTransaction);\n\n return pipe(\n createTransaction({ version: compiledMessage.version as TransactionVersion }),\n tx => setTransactionFeePayer(feePayer, tx),\n tx =>\n instructions.reduce((acc, instruction) => {\n return appendTransactionInstruction(instruction, acc);\n }, tx),\n tx =>\n 'blockhash' in lifetimeConstraint\n ? setTransactionLifetimeUsingBlockhash(lifetimeConstraint, tx)\n : setTransactionLifetimeUsingDurableNonce(lifetimeConstraint, tx),\n tx => (compiledTransaction.signatures.length ? { ...tx, signatures } : tx),\n );\n}\n","import { Address, getAddressFromPublicKey } from '@solana/addresses';\nimport { Decoder } from '@solana/codecs-core';\nimport { getBase58Decoder } from '@solana/codecs-strings';\nimport { isSignerRole } from '@solana/instructions';\nimport { Signature, SignatureBytes, signBytes } from '@solana/keys';\n\nimport { CompilableTransaction } from './compilable-transaction';\nimport { ITransactionWithFeePayer } from './fee-payer';\nimport { compileMessage } from './message';\nimport { getCompiledMessageEncoder } from './serializers/message';\n\nexport interface IFullySignedTransaction extends ITransactionWithSignatures {\n readonly __brand: unique symbol;\n}\nexport interface ITransactionWithSignatures {\n readonly signatures: Readonly<Record<Address, SignatureBytes>>;\n}\n\nlet base58Decoder: Decoder<string> | undefined;\n\nexport function getSignatureFromTransaction(\n transaction: ITransactionWithFeePayer & ITransactionWithSignatures,\n): Signature {\n if (!base58Decoder) base58Decoder = getBase58Decoder();\n\n const signatureBytes = transaction.signatures[transaction.feePayer];\n if (!signatureBytes) {\n // TODO: Coded error.\n throw new Error(\n \"Could not determine this transaction's signature. Make sure that the transaction \" +\n 'has been signed by its fee payer.',\n );\n }\n const transactionSignature = base58Decoder.decode(signatureBytes);\n return transactionSignature as Signature;\n}\n\nexport async function partiallySignTransaction<TTransaction extends CompilableTransaction>(\n keyPairs: CryptoKeyPair[],\n transaction: TTransaction | (TTransaction & ITransactionWithSignatures),\n): Promise<TTransaction & ITransactionWithSignatures> {\n const compiledMessage = compileMessage(transaction);\n const nextSignatures: Record<Address, SignatureBytes> =\n 'signatures' in transaction ? { ...transaction.signatures } : {};\n const wireMessageBytes = getCompiledMessageEncoder().encode(compiledMessage);\n const publicKeySignaturePairs = await Promise.all(\n keyPairs.map(keyPair =>\n Promise.all([getAddressFromPublicKey(keyPair.publicKey), signBytes(keyPair.privateKey, wireMessageBytes)]),\n ),\n );\n for (const [signerPublicKey, signature] of publicKeySignaturePairs) {\n nextSignatures[signerPublicKey] = signature;\n }\n const out = {\n ...transaction,\n signatures: nextSignatures,\n };\n Object.freeze(out);\n return out;\n}\n\nexport async function signTransaction<TTransaction extends CompilableTransaction>(\n keyPairs: CryptoKeyPair[],\n transaction: TTransaction | (TTransaction & ITransactionWithSignatures),\n): Promise<TTransaction & IFullySignedTransaction> {\n const out = await partiallySignTransaction(keyPairs, transaction);\n assertTransactionIsFullySigned(out);\n Object.freeze(out);\n return out;\n}\n\nexport function assertTransactionIsFullySigned<TTransaction extends CompilableTransaction>(\n transaction: TTransaction & ITransactionWithSignatures,\n): asserts transaction is TTransaction & IFullySignedTransaction {\n const signerAddressesFromInstructions = transaction.instructions\n .flatMap(i => i.accounts?.filter(a => isSignerRole(a.role)) ?? [])\n .map(a => a.address);\n const requiredSigners = new Set([transaction.feePayer, ...signerAddressesFromInstructions]);\n\n requiredSigners.forEach(address => {\n if (!transaction.signatures[address]) {\n // TODO coded error\n throw new Error(`Transaction is missing signature for address \\`${address}\\``);\n }\n });\n}\n","import { getBase64Decoder } from '@solana/codecs-strings';\n\nimport { getTransactionEncoder } from './serializers/transaction';\n\nexport type Base64EncodedWireTransaction = string & {\n readonly __brand: unique symbol;\n};\n\nexport function getBase64EncodedWireTransaction(\n transaction: Parameters<ReturnType<typeof getTransactionEncoder>['encode']>[0],\n): Base64EncodedWireTransaction {\n const wireTransactionBytes = getTransactionEncoder().encode(transaction);\n return getBase64Decoder().decode(wireTransactionBytes) as Base64EncodedWireTransaction;\n}\n"]}
|
|
@@ -2,23 +2,30 @@ this.globalThis = this.globalThis || {};
|
|
|
2
2
|
this.globalThis.solanaWeb3 = (function (exports) {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
-
var dr=Object.defineProperty;var ur=(e,r,n)=>r in e?dr(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n;var y=(e,r,n)=>(ur(e,typeof r!="symbol"?r+"":r,n),n);var S=e=>{let r=e.reduce((o,i)=>o+i.length,0),n=new Uint8Array(r),t=0;return e.forEach(o=>{n.set(o,t),t+=o.length;}),n},le=(e,r)=>{if(e.length>=r)return e;let n=new Uint8Array(r).fill(0);return n.set(e),n},L=(e,r)=>le(e.slice(0,r),r);var b=class extends Error{constructor(n){super(`Serializer [${n}] cannot deserialize empty buffers.`);y(this,"name","DeserializingEmptyBufferError");}},x=class extends Error{constructor(n,t,o){super(`Serializer [${n}] expected ${t} bytes, got ${o}.`);y(this,"name","NotEnoughBytesError");}},I=class extends Error{constructor(n){n??(n="Expected a fixed-size serializer, got a variable-size one.");super(n);y(this,"name","ExpectedFixedSizeSerializerError");}};function _(e,r,n){return {description:n??`fixed(${r}, ${e.description})`,fixedSize:r,maxSize:r,serialize:t=>L(e.serialize(t),r),deserialize:(t,o=0)=>{if(t=t.slice(o,o+r),t.length<r)throw new x("fixSerializer",r,t.length);e.fixedSize!==null&&(t=L(t,e.fixedSize));let[i]=e.deserialize(t,0);return [i,o+r]}}}function k(e,r,n){return {description:e.description,fixedSize:e.fixedSize,maxSize:e.maxSize,serialize:t=>e.serialize(r(t)),deserialize:(t,o=0)=>{let[i,s]=e.deserialize(t,o);return n?[n(i,t,o),s]:[i,s]}}}var M=class extends Error{constructor(n,t,o){let i=`Expected a string of base ${t}, got [${n}].`;super(i);y(this,"name","InvalidBaseStringError");this.cause=o;}};var fe=e=>{let r=e.length,n=BigInt(r);return {description:`base${r}`,fixedSize:null,maxSize:null,serialize(t){if(!t.match(new RegExp(`^[${e}]*$`)))throw new M(t,r);if(t==="")return new Uint8Array;let o=[...t],i=o.findIndex(f=>f!==e[0]);i=i===-1?o.length:i;let s=Array(i).fill(0);if(i===o.length)return Uint8Array.from(s);let c=o.slice(i),u=0n,d=1n;for(let f=c.length-1;f>=0;f-=1)u+=d*BigInt(e.indexOf(c[f])),d*=n;let l=[];for(;u>0n;)l.unshift(Number(u%256n)),u/=256n;return Uint8Array.from(s.concat(l))},deserialize(t,o=0){if(t.length===0)return ["",0];let i=t.slice(o),s=i.findIndex(l=>l!==0);s=s===-1?i.length:s;let c=e[0].repeat(s);if(s===i.length)return [c,t.length];let u=i.slice(s).reduce((l,f)=>l*256n+BigInt(f),0n),d=[];for(;u>0n;)d.unshift(e[Number(u%n)]),u/=n;return [c+d.join(""),t.length]}}};var E=fe("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");var me=e=>e.replace(/\u0000/g,"");var Z={description:"utf8",fixedSize:null,maxSize:null,serialize(e){return new TextEncoder().encode(e)},deserialize(e,r=0){let n=new TextDecoder().decode(e.slice(r));return [me(n),e.length]}};var P;(function(e){e.Little="le",e.Big="be";})(P||(P={}));var V=class extends RangeError{constructor(n,t,o,i){super(`Serializer [${n}] expected number to be between ${t} and ${o}, got ${i}.`);y(this,"name","NumberOutOfRangeError");}};function F(e){let r,n=e.name;return e.size>1&&(r=!("endian"in e.options)||e.options.endian===P.Little,n+=r?"(le)":"(be)"),{description:e.options.description??n,fixedSize:e.size,maxSize:e.size,serialize(t){e.range&&J(e.name,e.range[0],e.range[1],t);let o=new ArrayBuffer(e.size);return e.set(new DataView(o),t,r),new Uint8Array(o)},deserialize(t,o=0){let i=t.slice(o,o+e.size);mr("i8",i,e.size);let s=fr(i);return [e.get(s,r),o+e.size]}}}var lr=e=>e.buffer.slice(e.byteOffset,e.byteLength+e.byteOffset),fr=e=>new DataView(lr(e)),J=(e,r,n,t)=>{if(t<r||t>n)throw new V(e,r,n,t)},mr=(e,r,n)=>{if(r.length===0)throw new b(e);if(r.length<n)throw new x(e,n,r.length)};var w=(e={})=>F({name:"u8",size:1,range:[0,+"0xff"],set:(r,n)=>r.setUint8(0,Number(n)),get:r=>r.getUint8(0),options:e});var R=(e={})=>F({name:"u32",size:4,range:[0,+"0xffffffff"],set:(r,n,t)=>r.setUint32(0,Number(n),t),get:(r,n)=>r.getUint32(0,n),options:e});var p=(e={})=>({description:e.description??"shortU16",fixedSize:null,maxSize:3,serialize:r=>{J("shortU16",0,65535,r);let n=[0];for(let t=0;;t+=1){let o=r>>t*7;if(o===0)break;let i=127&o;n[t]=i,t>0&&(n[t-1]|=128);}return new Uint8Array(n)},deserialize:(r,n=0)=>{let t=0,o=0;for(;++o;){let i=o-1,s=r[n+i],c=127&s;if(t|=c<<i*7,!(s&128))break}return [t,n+o]}});var W=class extends Error{constructor(n,t,o){super(`Expected [${n}] to have ${t} items, got ${o}.`);y(this,"name","InvalidNumberOfItemsError");}},H=class extends Error{constructor(n,t){super(`The remainder of the buffer (${n} bytes) cannot be split into chunks of ${t} bytes. Serializers of "remainder" size must have a remainder that is a multiple of its item size. In other words, ${n} modulo ${t} should be equal to zero.`);y(this,"name","InvalidArrayLikeRemainderSizeError");}},j=class extends Error{constructor(n){super(`Unrecognized array-like serializer size: ${JSON.stringify(n)}`);y(this,"name","UnrecognizedArrayLikeSerializerSizeError");}};function v(e){return e.reduce((r,n)=>r===null||n===null?null:r+n,0)}function ge(e,r,n,t){if(typeof e=="number")return [e,t];if(typeof e=="object")return e.deserialize(n,t);if(e==="remainder"){let o=v(r);if(o===null)throw new I('Serializers of "remainder" size must have fixed-size items.');let i=n.slice(t).length;if(i%o!==0)throw new H(i,o);return [i/o,t]}throw new j(e)}function D(e){return typeof e=="object"?e.description:`${e}`}function Q(e,r){if(typeof e!="number")return null;if(e===0)return 0;let n=v(r);return n===null?null:n*e}function pe(e,r){return typeof e=="object"?e.serialize(r):new Uint8Array}function h(e,r={}){let n=r.size??R();if(n==="remainder"&&e.fixedSize===null)throw new I('Serializers of "remainder" size must have fixed-size items.');return {description:r.description??`array(${e.description}; ${D(n)})`,fixedSize:Q(n,[e.fixedSize]),maxSize:Q(n,[e.maxSize]),serialize:t=>{if(typeof n=="number"&&t.length!==n)throw new W("array",n,t.length);return S([pe(n,t.length),...t.map(o=>e.serialize(o))])},deserialize:(t,o=0)=>{if(typeof n=="object"&&t.slice(o).length===0)return [[],o];let[i,s]=ge(n,[e.fixedSize],t,o);o=s;let c=[];for(let u=0;u<i;u+=1){let[d,l]=e.deserialize(t,o);c.push(d),o=l;}return [c,o]}}}function U(e={}){let r=e.size??"variable",n=e.description??`bytes(${D(r)})`,t={description:n,fixedSize:null,maxSize:null,serialize:o=>new Uint8Array(o),deserialize:(o,i=0)=>{let s=o.slice(i);return [s,i+s.length]}};return r==="variable"?t:typeof r=="number"?_(t,r,n):{description:n,fixedSize:null,maxSize:null,serialize:o=>{let i=t.serialize(o),s=r.serialize(i.length);return S([s,i])},deserialize:(o,i=0)=>{if(o.slice(i).length===0)throw new b("bytes");let[s,c]=r.deserialize(o,i),u=Number(s);i=c;let d=o.slice(i,i+u);if(d.length<u)throw new x("bytes",u,d.length);let[l,f]=t.deserialize(d);return i+=f,[l,i]}}}function ee(e={}){let r=e.size??R(),n=e.encoding??Z,t=e.description??`string(${n.description}; ${D(r)})`;return r==="variable"?{...n,description:t}:typeof r=="number"?_(n,r,t):{description:t,fixedSize:null,maxSize:null,serialize:o=>{let i=n.serialize(o),s=r.serialize(i.length);return S([s,i])},deserialize:(o,i=0)=>{if(o.slice(i).length===0)throw new b("string");let[s,c]=r.deserialize(o,i),u=Number(s);i=c;let d=o.slice(i,i+u);if(d.length<u)throw new x("string",u,d.length);let[l,f]=n.deserialize(d);return i+=f,[l,i]}}}function T(e,r={}){let n=e.map(([t,o])=>`${String(t)}: ${o.description}`).join(", ");return {description:r.description??`struct(${n})`,fixedSize:v(e.map(([,t])=>t.fixedSize)),maxSize:v(e.map(([,t])=>t.maxSize)),serialize:t=>{let o=e.map(([i,s])=>s.serialize(t[i]));return S(o)},deserialize:(t,o=0)=>{let i={};return e.forEach(([s,c])=>{let[u,d]=c.deserialize(t,o);o=d,i[s]=u;}),[i,o]}}}function A(e){if("signatures"in e){let{signatures:r,...n}=e;return n}else return e}function qt(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 n=E.serialize(e).byteLength;if(n!==32)throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${n}`)}catch(r){throw new Error(`\`${e}\` is not a blockhash`,{cause:r})}}function Xt(e,r){if("lifetimeConstraint"in r&&r.lifetimeConstraint.blockhash===e.blockhash&&r.lifetimeConstraint.lastValidBlockHeight===e.lastValidBlockHeight)return r;let n={...A(r),lifetimeConstraint:e};return Object.freeze(n),n}function Qt({version:e}){let r={instructions:[],version:e};return Object.freeze(r),r}var g=(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))(g||{});var gr=1;function B(e){return e>=2}function C(e){return (e&gr)!==0}function re(e,r){return e|r}var ye="SysvarRecentB1ockHashes11111111111111111111",he="11111111111111111111111111111111";function uo(e){if(!xe(e))throw new Error("Transaction is not a durable nonce transaction")}function pr(e,r){return {accounts:[{address:e,role:g.WRITABLE},{address:ye,role:g.READONLY},{address:r,role:g.READONLY_SIGNER}],data:new Uint8Array([4,0,0,0]),programAddress:he}}function yr(e){return e.programAddress===he&&e.data!=null&&hr(e.data)&&e.accounts?.length===3&&e.accounts[0].address!=null&&e.accounts[0].role===g.WRITABLE&&e.accounts[1].address===ye&&e.accounts[1].role===g.READONLY&&e.accounts[2].address!=null&&e.accounts[2].role===g.READONLY_SIGNER}function hr(e){return e.byteLength===4&&e[0]===4&&e[1]===0&&e[2]===0&&e[3]===0}function xe(e){return "lifetimeConstraint"in e&&typeof e.lifetimeConstraint.nonce=="string"&&e.instructions[0]!=null&&yr(e.instructions[0])}function lo({nonce:e,nonceAccountAddress:r,nonceAuthorityAddress:n},t){let o=xe(t);if(o&&t.lifetimeConstraint.nonce===e&&t.instructions[0].accounts[0].address===r&&t.instructions[0].accounts[2].address===n)return t;let i={...A(t),instructions:[pr(r,n),...o?t.instructions.slice(1):t.instructions],lifetimeConstraint:{nonce:e}};return Object.freeze(i),i}function po(e,r){if("feePayer"in r&&e===r.feePayer)return r;let n={...A(r),feePayer:e};return Object.freeze(n),n}function To(e,r){let n={...A(r),instructions:[...r.instructions,e]};return Object.freeze(n),n}function So(e,r){let n={...A(r),instructions:[e,...r.instructions]};return Object.freeze(n),n}function $(e,r,n=0){if(r.length-n<=0)throw new Error(`Codec [${e}] cannot decode empty byte arrays.`)}function N(e,r,n,t=0){let o=n.length-t;if(o<r)throw new Error(`Codec [${e}] expected ${r} bytes, got ${o}.`)}var K=e=>{let r=e.filter(i=>i.length);if(r.length===0)return e.length?e[0]:new Uint8Array;if(r.length===1)return r[0];let n=r.reduce((i,s)=>i+s.length,0),t=new Uint8Array(n),o=0;return r.forEach(i=>{t.set(i,o),o+=i.length;}),t},xr=(e,r)=>{if(e.length>=r)return e;let n=new Uint8Array(r).fill(0);return n.set(e),n},ne=(e,r)=>xr(e.length<=r?e:e.slice(0,r),r);function z(e,r,n){if(e.fixedSize!==r.fixedSize)throw new Error(`Encoder and decoder must have the same fixed size, got [${e.fixedSize}] and [${r.fixedSize}].`);if(e.maxSize!==r.maxSize)throw new Error(`Encoder and decoder must have the same max size, got [${e.maxSize}] and [${r.maxSize}].`);if(n===void 0&&e.description!==r.description)throw new Error(`Encoder and decoder must have the same description, got [${e.description}] and [${r.description}]. Pass a custom description as a third argument if you want to override the description and bypass this error.`);return {decode:r.decode,description:n??e.description,encode:e.encode,fixedSize:e.fixedSize,maxSize:e.maxSize}}function Te(e,r,n){return {description:n??`fixed(${r}, ${e.description})`,fixedSize:r,maxSize:r}}function te(e,r,n){return {...Te(e,r,n),encode:t=>ne(e.encode(t),r)}}function oe(e,r,n){return {...Te(e,r,n),decode:(t,o=0)=>{N("fixCodec",r,t,o),(o>0||t.length>r)&&(t=t.slice(o,o+r)),e.fixedSize!==null&&(t=ne(t,e.fixedSize));let[i]=e.decode(t,0);return [i,o+r]}}}function Se(e,r){return {description:e.description,encode:n=>e.encode(r(n)),fixedSize:e.fixedSize,maxSize:e.maxSize}}function Tr(e,r,n,t){if(t<r||t>n)throw new Error(`Codec [${e}] expected number to be in the range [${r}, ${n}], got ${t}.`)}function be(e){let r,n=e.name;return e.size>1&&(r=!("endian"in e.options)||e.options.endian===0,n+=r?"(le)":"(be)"),{description:e.options.description??n,fixedSize:e.size,littleEndian:r,maxSize:e.size}}function Ae(e){let r=be(e);return {description:r.description,encode(n){e.range&&Tr(e.name,e.range[0],e.range[1],n);let t=new ArrayBuffer(e.size);return e.set(new DataView(t),n,r.littleEndian),new Uint8Array(t)},fixedSize:r.fixedSize,maxSize:r.maxSize}}function ze(e){let r=be(e);return {decode(n,t=0){$(r.description,n,t),N(r.description,e.size,n,t);let o=new DataView(Sr(n,t,e.size));return [e.get(o,r.littleEndian),t+e.size]},description:r.description,fixedSize:r.fixedSize,maxSize:r.maxSize}}function Sr(e,r,n){let t=e.byteOffset+(r??0),o=n??e.byteLength;return e.buffer.slice(t,t+o)}var Ee=(e={})=>Ae({name:"u32",options:e,range:[0,+"0xffffffff"],set:(r,n,t)=>r.setUint32(0,n,t),size:4}),Ie=(e={})=>ze({get:(r,n)=>r.getUint32(0,n),name:"u32",options:e,size:4});var we=(e={})=>Ae({name:"u8",options:e,range:[0,+"0xff"],set:(r,n)=>r.setUint8(0,n),size:1}),Be=(e={})=>ze({get:r=>r.getUint8(0),name:"u8",options:e,size:1}),Ce=(e={})=>z(we(e),Be(e));function br(e,r,n=r){if(!r.match(new RegExp(`^[${e}]*$`)))throw new Error(`Expected a string of base ${e.length}, got [${n}].`)}var Ar=e=>{let r=e.length,n=BigInt(r);return {description:`base${r}`,encode(t){if(br(e,t),t==="")return new Uint8Array;let o=[...t],i=o.findIndex(f=>f!==e[0]);i=i===-1?o.length:i;let s=Array(i).fill(0);if(i===o.length)return Uint8Array.from(s);let c=o.slice(i),u=0n,d=1n;for(let f=c.length-1;f>=0;f-=1)u+=d*BigInt(e.indexOf(c[f])),d*=n;let l=[];for(;u>0n;)l.unshift(Number(u%256n)),u/=256n;return Uint8Array.from(s.concat(l))},fixedSize:null,maxSize:null}},zr=e=>{let r=e.length,n=BigInt(r);return {decode(t,o=0){let i=o===0?t:t.slice(o);if(i.length===0)return ["",0];let s=i.findIndex(l=>l!==0);s=s===-1?i.length:s;let c=e[0].repeat(s);if(s===i.length)return [c,t.length];let u=i.slice(s).reduce((l,f)=>l*256n+BigInt(f),0n),d=[];for(;u>0n;)d.unshift(e[Number(u%n)]),u/=n;return [c+d.join(""),t.length]},description:`base${r}`,fixedSize:null,maxSize:null}};var ve="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",De=()=>Ar(ve),Ne=()=>zr(ve);var Er=e=>e.replace(/\u0000/g,"");var Ir=globalThis.TextDecoder,wr=globalThis.TextEncoder,Br=()=>{let e;return {description:"utf8",encode:r=>new Uint8Array((e||(e=new wr)).encode(r)),fixedSize:null,maxSize:null}},Cr=()=>{let e;return {decode(r,n=0){let t=(e||(e=new Ir)).decode(r.slice(n));return [Er(t),r.length]},description:"utf8",fixedSize:null,maxSize:null}};var _e=(e={})=>{let r=e.size??Ee(),n=e.encoding??Br(),t=e.description??`string(${n.description}; ${Re(r)})`;return r==="variable"?{...n,description:t}:typeof r=="number"?te(n,r,t):{description:t,encode:o=>{let i=n.encode(o),s=r.encode(i.length);return K([s,i])},fixedSize:null,maxSize:null}},ke=(e={})=>{let r=e.size??Ie(),n=e.encoding??Cr(),t=e.description??`string(${n.description}; ${Re(r)})`;return r==="variable"?{...n,description:t}:typeof r=="number"?oe(n,r,t):{decode:(o,i=0)=>{$("string",o,i);let[s,c]=r.decode(o,i),u=Number(s);i=c;let d=o.slice(i,i+u);N("string",u,d);let[l,f]=n.decode(d);return i+=f,[l,i]},description:t,fixedSize:null,maxSize:null}};function Re(e){return typeof e=="object"?e.description:`${e}`}function Ue(){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")}async function $e(){if(Ue(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.exportKey!="function")throw new Error("No key export implementation could be found")}async function Oe(){if(Ue(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.sign!="function")throw new Error("No signing implementation could be found")}var ie,se;function Le(){return ie||(ie=De()),ie}function vr(){return se||(se=Ne()),se}function Dr(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=Le().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(r){throw new Error(`\`${e}\` is not a base-58 encoded address`,{cause:r})}}function Nr(e){return Dr(e),e}function _r(e){return Se(_e({description:e?.description??"Base58EncodedAddress",encoding:Le(),size:32}),r=>Nr(r))}function Me(e){return ke({description:e?.description??"Base58EncodedAddress",encoding:vr(),size:32})}function Y(e){return z(_r(e),Me(e))}function O(){return new Intl.Collator("en",{caseFirst:"lower",ignorePunctuation:!1,localeMatcher:"best fit",numeric:!1,sensitivity:"variant",usage:"sort"}).compare}async function Pe(e){if(await $e(),e.type!=="public"||e.algorithm.name!=="Ed25519")throw new Error("The `CryptoKey` must be an `Ed25519` public key");let r=await crypto.subtle.exportKey("raw",e),[n]=Me().decode(new Uint8Array(r));return n}function Ve(e,r,n){e[r]=n(e[r]??{role:g.READONLY});}var m=Symbol("AddressMapTypeProperty");function Fe(e,r){let n={[e]:{[m]:0,role:g.WRITABLE_SIGNER}},t=new Set;for(let o of r){Ve(n,o.programAddress,s=>{if(t.add(o.programAddress),m in s){if(C(s.role))switch(s[m]){case 0:throw new Error(`This transaction includes an address (\`${o.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 (\`${o.programAddress}\`) which is both invoked and marked writable. Program addresses may not be writable.`)}if(s[m]===2)return s}return {[m]:2,role:g.READONLY}});let i;if(o.accounts)for(let s of o.accounts)Ve(n,s.address,c=>{let{address:u,...d}=s;if(m in c)switch(c[m]){case 0:return c;case 1:{let l=re(c.role,d.role);if("lookupTableAddress"in d){if(c.lookupTableAddress!==d.lookupTableAddress&&(i||(i=O()))(d.lookupTableAddress,c.lookupTableAddress)<0)return {[m]:1,...d,role:l}}else if(B(d.role))return {[m]:2,role:l};return c.role!==l?{...c,role:l}:c}case 2:{let l=re(c.role,d.role);if(t.has(s.address)){if(C(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 c.role!==l?{...c,role:l}:c}else return "lookupTableAddress"in d&&!B(c.role)?{...d,[m]:1,role:l}:c.role!==l?{...c,role:l}:c}}return "lookupTableAddress"in d?{...d,[m]:1}:{...d,[m]:2}});}return n}function We(e){let r;return Object.entries(e).sort(([t,o],[i,s])=>{if(o[m]!==s[m]){if(o[m]===0)return -1;if(s[m]===0)return 1;if(o[m]===2)return -1;if(s[m]===2)return 1}let c=B(o.role);if(c!==B(s.role))return c?-1:1;let u=C(o.role);return u!==C(s.role)?u?-1:1:(r||(r=O()),o[m]===1&&s[m]===1&&o.lookupTableAddress!==s.lookupTableAddress?r(o.lookupTableAddress,s.lookupTableAddress):r(t,i))}).map(([t,o])=>({address:t,...o}))}function He(e){var n;let r={};for(let t of e){if(!("lookupTableAddress"in t))continue;let o=r[n=t.lookupTableAddress]||(r[n]={readableIndices:[],writableIndices:[]});t.role===g.WRITABLE?o.writableIndices.push(t.addressIndex):o.readableIndices.push(t.addressIndex);}return Object.keys(r).sort(O()).map(t=>({lookupTableAddress:t,...r[t]}))}function je(e){let r=0,n=0,t=0;for(let o of e){if("lookupTableAddress"in o)break;let i=C(o.role);B(o.role)?(t++,i||n++):i||r++;}return {numReadonlyNonSignerAccounts:r,numReadonlySignerAccounts:n,numSignerAccounts:t}}function kr(e){let r={};for(let[n,t]of e.entries())r[t.address]=n;return r}function Ke(e,r){let n=kr(r);return e.map(({accounts:t,data:o,programAddress:i})=>({programAddressIndex:n[i],...t?{accountIndices:t.map(({address:s})=>n[s])}:null,...o?{data:o}:null}))}function Ye(e){return "nonce"in e?e.nonce:e.blockhash}function Ge(e){let r=e.findIndex(t=>"lookupTableAddress"in t);return (r===-1?e:e.slice(0,r)).map(({address:t})=>t)}function G(e){let r=Fe(e.feePayer,e.instructions),n=We(r);return {...e.version!=="legacy"?{addressTableLookups:He(n)}:null,header:je(n),instructions:Ke(e.instructions,n),lifetimeToken:Ye(e.lifetimeConstraint),staticAccounts:Ge(n),version:e.version}}function qe(e){let r=G(e),n;if("signatures"in e){n=[];for(let t=0;t<r.header.numSignerAccounts;t++)n[t]=e.signatures[r.staticAccounts[t]]??new Uint8Array(Array(64).fill(0));}else n=Array(r.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));return {compiledMessage:r,signatures:n}}function Rr(e){let r=Y();return {description:e?.description??r.description,deserialize:r.decode,fixedSize:r.fixedSize,maxSize:r.maxSize,serialize:r.encode}}function Xe(){return T([["lookupTableAddress",Rr(void 0)],["writableIndices",h(w(),{size:p()})],["readableIndices",h(w(),{size:p()})]],void 0)}function Ze(e){return e.reduce((r,n)=>r===null||n===null?null:r+n,0)}function Je(e,r){let n=e.map(([t,o])=>`${String(t)}: ${o.description}`).join(", ");return {description:r??`struct(${n})`,fixedSize:Ze(e.map(([,t])=>t.fixedSize)),maxSize:Ze(e.map(([,t])=>t.maxSize))}}function Qe(e,r={}){return {...Je(e,r.description),encode:n=>{let t=e.map(([o,i])=>i.encode(n[o]));return K(t)}}}function er(e,r={}){return {...Je(e,r.description),decode:(n,t=0)=>{let o={};return e.forEach(([i,s])=>{let[c,u]=s.decode(n,t);t=u,o[i]=c;}),[o,t]}}}function rr(e,r={}){return z(Qe(e,r),er(e,r))}var ae;function Ur(){return ae||(ae=Ce()),ae}function ce(e){let r=Ur();return {...r,description:e??r.description}}var $r=void 0,Or=void 0,Lr=void 0,Mr=void 0;function nr(){return rr([["numSignerAccounts",ce($r)],["numReadonlySignerAccounts",ce(Or)],["numReadonlyNonSignerAccounts",ce(Lr)]],{description:Mr})}function tr(){return k(T([["programAddressIndex",w(void 0)],["accountIndices",h(w({description:""}),{description:"",size:p()})],["data",U({description:"",size:p()})]]),e=>e.accountIndices!==void 0&&e.data!==void 0?e:{...e,accountIndices:e.accountIndices??[],data:e.data??new Uint8Array(0)},e=>{if(e.accountIndices.length&&e.data.byteLength)return e;let{accountIndices:r,data:n,...t}=e;return {...t,...r.length?{accountIndices:r}:null,...n.byteLength?{data:n}:null}})}var de=128,or={description:"",fixedSize:null,maxSize:1};function Pr(e,r=0){let n=e[r];return n&de?[n^de,r+1]:["legacy",r]}function Vr(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|de])}function Fr(){return {...or,decode:Pr}}function Wr(){return {...or,encode:Vr}}function ir(){return z(Wr(),Fr())}function Hr(e,r){let n=r+e[0].toUpperCase()+e.slice(1);return new Error(`No ${e} exists for ${r}. Use \`get${n}()\` if you need a ${e}, and \`get${r}Codec()\` if you need to both encode and decode ${r}`)}function q(e){return ()=>{throw Hr("decoder",e)}}var jr={description:"",fixedSize:null,maxSize:null};function Kr(e){return e.version==="legacy"?T(sr()).serialize(e):k(T([...sr(),["addressTableLookups",Yr()]]),r=>r.version==="legacy"?r:{...r,addressTableLookups:r.addressTableLookups??[]}).serialize(e)}function ue(e){return {description:e.description,deserialize:e.decode,fixedSize:e.fixedSize,maxSize:e.maxSize,serialize:e.encode}}function sr(){return [["version",ue(ir())],["header",ue(nr())],["staticAccounts",h(ue(Y()),{description:"",size:p()})],["lifetimeToken",ee({description:"",encoding:E,size:32})],["instructions",h(tr(),{description:"",size:p()})]]}function Yr(){return h(Xe(),{size:p()})}function X(){return {...jr,deserialize:q("CompiledMessage"),serialize:Kr}}var Gr={description:"",fixedSize:null,maxSize:null};function qr(e){let r=qe(e);return T([["signatures",h(U({size:64}),{size:p()})],["compiledMessage",X()]]).serialize(r)}function ar(){return {...Gr,deserialize:q("CompiledMessage"),serialize:qr}}async function cr(e,r){await Oe();let n=await crypto.subtle.sign("Ed25519",e,r);return new Uint8Array(n)}function Xr(e){try{if(e.length<64||e.length>88)throw new Error("Expected input string to decode to a byte array of length 64.");let n=E.serialize(e).byteLength;if(n!==64)throw new Error(`Expected input string to decode to a byte array of length 64. Actual length: ${n}`)}catch(r){throw new Error(`\`${e}\` is not a transaction signature`,{cause:r})}}function Ns(e){return !(e.length<64||e.length>88||E.serialize(e).byteLength!==64)}async function Zr(e,r){let n=X().serialize(e);return await cr(r,n)}function _s(e){let r=e.signatures[e.feePayer];if(!r)throw new Error("Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.");return r}async function ks(e,r){let n=G(r),t="signatures"in r?{...r.signatures}:{},o=await Promise.all(e.map(s=>Promise.all([Pe(s.publicKey),Zr(n,s.privateKey)])));for(let[s,c]of o)t[s]=c;let i={...r,signatures:t};return Object.freeze(i),i}function Rs(e){return Xr(e),e}function Ls(e){let r=ar().serialize(e);return btoa(String.fromCharCode(...r))}
|
|
5
|
+
function R(e,r,n=0){if(r.length-n<=0)throw new Error(`Codec [${e}] cannot decode empty byte arrays.`)}function v(e,r,n,t=0){let o=n.length-t;if(o<r)throw new Error(`Codec [${e}] expected ${r} bytes, got ${o}.`)}var pr=(e,r)=>{if(e.length>=r)return e;let n=new Uint8Array(r).fill(0);return n.set(e),n},Tr=(e,r)=>pr(e.length<=r?e:e.slice(0,r),r);function x(e,r){return "fixedSize"in r?r.fixedSize:r.getSizeFromValue(e)}function g(e){return Object.freeze({...e,encode:r=>{let n=new Uint8Array(x(r,e));return e.write(r,n,0),n}})}function p(e){return Object.freeze({...e,decode:(r,n=0)=>e.read(r,n)[0]})}function T(e){return "fixedSize"in e&&typeof e.fixedSize=="number"}function te(e,r){if(!T(e))throw new Error(r!=null?r:"Expected a fixed-size codec, got a variable-size one.")}function yr(e){return !T(e)}function C(e,r){if(T(e)!==T(r))throw new Error("Encoder and decoder must either both be fixed-size or variable-size.");if(T(e)&&T(r)&&e.fixedSize!==r.fixedSize)throw new Error(`Encoder and decoder must have the same fixed size, got [${e.fixedSize}] and [${r.fixedSize}].`);if(!T(e)&&!T(r)&&e.maxSize!==r.maxSize)throw new Error(`Encoder and decoder must have the same max size, got [${e.maxSize}] and [${r.maxSize}].`);return {...r,...e,decode:r.decode,encode:e.encode,read:r.read,write:e.write}}function W(e,r){return g({fixedSize:r,write:(n,t,o)=>{let s=e.encode(n),i=s.length>r?s.slice(0,r):s;return t.set(i,o),o+r}})}function P(e,r){return p({fixedSize:r,read:(n,t)=>{v("fixCodec",r,n,t),(t>0||n.length>r)&&(n=n.slice(t,t+r)),T(e)&&(n=Tr(n,e.fixedSize));let[o]=e.read(n,0);return [o,t+r]}})}function z(e,r){return g({...yr(e)?{...e,getSizeFromValue:n=>e.getSizeFromValue(r(n))}:e,write:(n,t,o)=>e.write(r(n),t,o)})}function k(e,r){return p({...e,read:(n,t)=>{let[o,s]=e.read(n,t);return [r(o,n,t),s]}})}function Se(e,r,n,t){if(t<r||t>n)throw new Error(`Codec [${e}] expected number to be in the range [${r}, ${n}], got ${t}.`)}function Ee(e){return (e==null?void 0:e.endian)!==1}function Ie(e){return g({fixedSize:e.size,write(r,n,t){e.range&&Se(e.name,e.range[0],e.range[1],r);let o=new ArrayBuffer(e.size);return e.set(new DataView(o),r,Ee(e.config)),n.set(new Uint8Array(o),t),t+e.size}})}function xe(e){return p({fixedSize:e.size,read(r,n=0){R(e.name,r,n),v(e.name,e.size,r,n);let t=new DataView(Ar(r,n,e.size));return [e.get(t,Ee(e.config)),n+e.size]}})}function Ar(e,r,n){let t=e.byteOffset+(r!=null?r:0),o=n!=null?n:e.byteLength;return e.buffer.slice(t,t+o)}var y=()=>g({getSizeFromValue:e=>e<=127?1:e<=16383?2:3,maxSize:3,write:(e,r,n)=>{Se("shortU16",0,65535,e);let t=[0];for(let o=0;;o+=1){let s=e>>o*7;if(s===0)break;let i=127&s;t[o]=i,o>0&&(t[o-1]|=128);}return r.set(t,n),n+t.length}}),A=()=>p({maxSize:3,read:(e,r)=>{let n=0,t=0;for(;++t;){let o=t-1,s=e[r+o],i=127&s;if(n|=i<<o*7,!(s&128))break}return [n,r+t]}});var _=(e={})=>Ie({config:e,name:"u32",range:[0,+"0xffffffff"],set:(r,n,t)=>r.setUint32(0,n,t),size:4}),$=(e={})=>xe({config:e,get:(r,n)=>r.getUint32(0,n),name:"u32",size:4});var B=()=>Ie({name:"u8",range:[0,+"0xff"],set:(e,r)=>e.setUint8(0,r),size:1}),D=()=>xe({get:e=>e.getUint8(0),name:"u8",size:1});function hr(e,r,n=r){if(!r.match(new RegExp(`^[${e}]*$`)))throw new Error(`Expected a string of base ${e.length}, got [${n}].`)}var br=e=>g({getSizeFromValue:r=>{let[n,t]=Ce(r,e[0]);if(t==="")return r.length;let o=we(t,e);return n.length+Math.ceil(o.toString(16).length/2)},write(r,n,t){if(hr(e,r),r==="")return t;let[o,s]=Ce(r,e[0]);if(s==="")return n.set(new Uint8Array(o.length).fill(0),t),t+o.length;let i=we(s,e),a=[];for(;i>0n;)a.unshift(Number(i%256n)),i/=256n;let d=[...Array(o.length).fill(0),...a];return n.set(d,t),t+d.length}}),Sr=e=>p({read(r,n){let t=n===0?r:r.slice(n);if(t.length===0)return ["",0];let o=t.findIndex(d=>d!==0);o=o===-1?t.length:o;let s=e[0].repeat(o);if(o===t.length)return [s,r.length];let i=t.slice(o).reduce((d,c)=>d*256n+BigInt(c),0n),a=Er(i,e);return [s+a,r.length]}});function Ce(e,r){let n=[...e].findIndex(t=>t!==r);return n===-1?[e,""]:[e.slice(0,n),e.slice(n)]}function we(e,r){let n=BigInt(r.length);return [...e].reduce((t,o)=>t*n+BigInt(r.indexOf(o)),0n)}function Er(e,r){let n=BigInt(r.length),t=[];for(;e>0n;)t.unshift(r[Number(e%n)]),e/=n;return t.join("")}var Be="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",M=()=>br(Be),F=()=>Sr(Be);var De=()=>p({read(e,r=0){let n=e.slice(r);return [btoa(String.fromCharCode(...n)),e.length]}});var Ir=e=>e.replace(/\u0000/g,"");var xr=globalThis.TextDecoder,ze=globalThis.TextEncoder,Cr=()=>{let e;return g({getSizeFromValue:r=>(e||(e=new ze)).encode(r).length,write:(r,n,t)=>{let o=(e||(e=new ze)).encode(r);return n.set(o,t),t+o.length}})},wr=()=>{let e;return p({read(r,n){let t=(e||(e=new xr)).decode(r.slice(n));return [Ir(t),r.length]}})};function H(e={}){var t,o;let r=(t=e.size)!=null?t:_(),n=(o=e.encoding)!=null?o:Cr();return r==="variable"?n:typeof r=="number"?W(n,r):g({getSizeFromValue:s=>{let i=x(s,n);return x(i,r)+i},write:(s,i,a)=>{let d=x(s,n);return a=r.write(d,i,a),n.write(s,i,a)}})}function K(e={}){var t,o;let r=(t=e.size)!=null?t:$(),n=(o=e.encoding)!=null?o:wr();return r==="variable"?n:typeof r=="number"?P(n,r):p({read:(s,i=0)=>{R("string",s,i);let[a,d]=r.read(s,i),c=Number(a);i=d;let l=s.slice(i,i+c);v("string",c,l);let[I,ne]=n.read(l,0);return i+=ne,[I,i]}})}function N(e){if("signatures"in e){let{signatures:r,...n}=e;return n}else return e}var oe;function zr(e){oe||(oe=M());try{if(e.length<32||e.length>44)throw new Error("Expected input string to decode to a byte array of length 32.");let n=oe.encode(e).byteLength;if(n!==32)throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${n}`)}catch(r){throw new Error(`\`${e}\` is not a blockhash`,{cause:r})}}function Br(e){if(!("lifetimeConstraint"in e&&typeof e.lifetimeConstraint.blockhash=="string"&&typeof e.lifetimeConstraint.lastValidBlockHeight=="bigint"))return !1;try{return zr(e.lifetimeConstraint.blockhash),!0}catch{return !1}}function un(e){if(!Br(e))throw new Error("Transaction does not have a blockhash lifetime")}function Ne(e,r){if("lifetimeConstraint"in r&&r.lifetimeConstraint.blockhash===e.blockhash&&r.lifetimeConstraint.lastValidBlockHeight===e.lastValidBlockHeight)return r;let n={...N(r),lifetimeConstraint:e};return Object.freeze(n),n}function ve({version:e}){let r={instructions:[],version:e};return Object.freeze(r),r}var m=(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))(m||{});var Dr=1;function h(e){return e>=2}function L(e){return (e&Dr)!==0}function ie(e,r){return e|r}var Le="SysvarRecentB1ockHashes11111111111111111111",Re="11111111111111111111111111111111";function wn(e){if(!Me(e))throw new Error("Transaction is not a durable nonce transaction")}function ke(e,r){return {accounts:[{address:e,role:m.WRITABLE},{address:Le,role:m.READONLY},{address:r,role:m.READONLY_SIGNER}],data:new Uint8Array([4,0,0,0]),programAddress:Re}}function Y(e){var r;return e.programAddress===Re&&e.data!=null&&Nr(e.data)&&((r=e.accounts)==null?void 0:r.length)===3&&e.accounts[0].address!=null&&e.accounts[0].role===m.WRITABLE&&e.accounts[1].address===Le&&e.accounts[1].role===m.READONLY&&e.accounts[2].address!=null&&h(e.accounts[2].role)}function Nr(e){return e.byteLength===4&&e[0]===4&&e[1]===0&&e[2]===0&&e[3]===0}function Me(e){return "lifetimeConstraint"in e&&typeof e.lifetimeConstraint.nonce=="string"&&e.instructions[0]!=null&&Y(e.instructions[0])}function vr(e,r,n){return e.accounts[0].address===r&&e.accounts[2].address===n}function Fe({nonce:e,nonceAccountAddress:r,nonceAuthorityAddress:n},t){let o,s=t.instructions[0];if(s&&Y(s))if(vr(s,r,n)){if(Me(t)&&t.lifetimeConstraint.nonce===e)return t;o=[s,...t.instructions.slice(1)];}else o=[ke(r,n),...t.instructions.slice(1)];else o=[ke(r,n),...t.instructions];let i={...N(t),instructions:o,lifetimeConstraint:{nonce:e}};return Object.freeze(i),i}function Ve(e,r){if("feePayer"in r&&e===r.feePayer)return r;let n={...N(r),feePayer:e};return Object.freeze(n),n}function Ue(e,r){let n={...N(r),instructions:[...r.instructions,e]};return Object.freeze(n),n}function Ln(e,r){let n={...N(r),instructions:[e,...r.instructions]};return Object.freeze(n),n}function Oe(){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")}async function We(){var e;if(Oe(),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 Pe(){var e;if(Oe(),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 se,ae;function _e(){return se||(se=M()),se}function kr(){return ae||(ae=F()),ae}function j(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=_e().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(r){throw new Error(`\`${e}\` is not a base-58 encoded address`,{cause:r})}}function Lr(e){return j(e),e}function G(){return z(H({encoding:_e(),size:32}),e=>Lr(e))}function V(){return K({encoding:kr(),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 $e(e){if(await We(),e.type!=="public"||e.algorithm.name!=="Ed25519")throw new Error("The `CryptoKey` must be an `Ed25519` public key");let r=await crypto.subtle.exportKey("raw",e);return V().decode(new Uint8Array(r))}function He(e,r,n){var t;e[r]=n((t=e[r])!=null?t:{role:m.READONLY});}var f=Symbol("AddressMapTypeProperty");function Ke(e,r){let n={[e]:{[f]:0,role:m.WRITABLE_SIGNER}},t=new Set;for(let o of r){He(n,o.programAddress,i=>{if(t.add(o.programAddress),f in i){if(L(i.role))switch(i[f]){case 0:throw new Error(`This transaction includes an address (\`${o.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 (\`${o.programAddress}\`) which is both invoked and marked writable. Program addresses may not be writable.`)}if(i[f]===2)return i}return {[f]:2,role:m.READONLY}});let s;if(o.accounts)for(let i of o.accounts)He(n,i.address,a=>{let{address:d,...c}=i;if(f in a)switch(a[f]){case 0:return a;case 1:{let l=ie(a.role,c.role);if("lookupTableAddress"in c){if(a.lookupTableAddress!==c.lookupTableAddress&&(s||(s=U()))(c.lookupTableAddress,a.lookupTableAddress)<0)return {[f]:1,...c,role:l}}else if(h(c.role))return {[f]:2,role:l};return a.role!==l?{...a,role:l}:a}case 2:{let l=ie(a.role,c.role);if(t.has(i.address)){if(L(c.role))throw new Error(`This transaction includes an address (\`${i.address}\`) which is both invoked and marked writable. Program addresses may not be writable.`);return a.role!==l?{...a,role:l}:a}else return "lookupTableAddress"in c&&!h(a.role)?{...c,[f]:1,role:l}:a.role!==l?{...a,role:l}:a}}return "lookupTableAddress"in c?{...c,[f]:1}:{...c,[f]:2}});}return n}function Ye(e){let r;return Object.entries(e).sort(([t,o],[s,i])=>{if(o[f]!==i[f]){if(o[f]===0)return -1;if(i[f]===0)return 1;if(o[f]===2)return -1;if(i[f]===2)return 1}let a=h(o.role);if(a!==h(i.role))return a?-1:1;let d=L(o.role);return d!==L(i.role)?d?-1:1:(r||(r=U()),o[f]===1&&i[f]===1&&o.lookupTableAddress!==i.lookupTableAddress?r(o.lookupTableAddress,i.lookupTableAddress):r(t,s))}).map(([t,o])=>({address:t,...o}))}function je(e){var n;let r={};for(let t of e){if(!("lookupTableAddress"in t))continue;let o=r[n=t.lookupTableAddress]||(r[n]={readableIndices:[],writableIndices:[]});t.role===m.WRITABLE?o.writableIndices.push(t.addressIndex):o.readableIndices.push(t.addressIndex);}return Object.keys(r).sort(U()).map(t=>({lookupTableAddress:t,...r[t]}))}function Ge(e){let r=0,n=0,t=0;for(let o of e){if("lookupTableAddress"in o)break;let s=L(o.role);h(o.role)?(t++,s||n++):s||r++;}return {numReadonlyNonSignerAccounts:r,numReadonlySignerAccounts:n,numSignerAccounts:t}}function Rr(e){let r={};for(let[n,t]of e.entries())r[t.address]=n;return r}function qe(e,r){let n=Rr(r);return e.map(({accounts:t,data:o,programAddress:s})=>({programAddressIndex:n[s],...t?{accountIndices:t.map(({address:i})=>n[i])}:null,...o?{data:o}:null}))}function Xe(e){return "nonce"in e?e.nonce:e.blockhash}function Ze(e){let r=e.findIndex(t=>"lookupTableAddress"in t);return (r===-1?e:e.slice(0,r)).map(({address:t})=>t)}function q(e){let r=Ke(e.feePayer,e.instructions),n=Ye(r);return {...e.version!=="legacy"?{addressTableLookups:je(n)}:null,header:Ge(n),instructions:qe(e.instructions,n),lifetimeToken:Xe(e.lifetimeConstraint),staticAccounts:Ze(n),version:e.version}}function Mr(e,r,n){if(r!==n)throw new Error(`Expected [${e}] to have ${r} items, got ${n}.`)}function X(e){return e.reduce((r,n)=>r===null||n===null?null:r+n,0)}function J(e){return T(e)?e.fixedSize:null}function Q(e){var r;return T(e)?e.fixedSize:(r=e.maxSize)!=null?r:null}function b(e,r={}){var s,i;let n=(s=r.size)!=null?s:_();n==="remainder"&&te(e,'Codecs of "remainder" size must have fixed-size items.');let t=Z(n,J(e)),o=(i=Z(n,Q(e)))!=null?i:void 0;return g({...t!==null?{fixedSize:t}:{getSizeFromValue:a=>(typeof n=="object"?x(a.length,n):0)+[...a].reduce((c,l)=>c+x(l,e),0),maxSize:o},write:(a,d,c)=>(typeof n=="number"&&Mr("array",n,a.length),typeof n=="object"&&(c=n.write(a.length,d,c)),a.forEach(l=>{c=e.write(l,d,c);}),c)})}function S(e,r={}){var i,a;let n=(i=r.size)!=null?i:$();n==="remainder"&&te(e,'Codecs of "remainder" size must have fixed-size items.');let t=J(e),o=Z(n,t),s=(a=Z(n,Q(e)))!=null?a:void 0;return p({...o!==null?{fixedSize:o}:{maxSize:s},read:(d,c)=>{let l=[];if(typeof n=="object"&&d.slice(c).length===0)return [l,c];let[I,ne]=Fr(n,t,d,c);c=ne;for(let be=0;be<I;be+=1){let[gr,mr]=e.read(d,c);c=mr,l.push(gr);}return [l,c]}})}function Fr(e,r,n,t){if(typeof e=="number")return [e,t];if(typeof e=="object")return e.read(n,t);if(e==="remainder"){if(r===null)throw new Error('Codecs of "remainder" size must have fixed-size items.');let o=Math.max(0,n.length-t);if(o%r!==0)throw new Error(`The remainder of the byte array (${o} bytes) cannot be split into chunks of ${r} bytes. Codecs of "remainder" size must have a remainder that is a multiple of its item size. In other words, ${o} modulo ${r} should be equal to zero.`);return [o/r,t]}throw new Error(`Unrecognized array-like codec size: ${JSON.stringify(e)}`)}function Z(e,r){return typeof e!="number"?null:e===0?0:r===null?null:r*e}function ee(e={}){var t;let r=(t=e.size)!=null?t:"variable",n=g({getSizeFromValue:o=>o.length,write:(o,s,i)=>(s.set(o,i),i+o.length)});return r==="variable"?n:typeof r=="number"?W(n,r):g({getSizeFromValue:o=>x(o.length,r)+o.length,write:(o,s,i)=>(i=r.write(o.length,s,i),n.write(o,s,i))})}function re(e={}){var t;let r=(t=e.size)!=null?t:"variable",n=p({read:(o,s)=>{let i=o.slice(s);return [i,s+i.length]}});return r==="variable"?n:typeof r=="number"?P(n,r):p({read:(o,s)=>{R("bytes",o,s);let[i,a]=r.read(o,s),d=Number(i);s=a;let c=o.slice(s,s+d);v("bytes",d,c);let[l,I]=n.read(c,0);return s+=I,[l,s]}})}function E(e){var o;let r=e.map(([,s])=>s),n=X(r.map(J)),t=(o=X(r.map(Q)))!=null?o:void 0;return g({...n===null?{getSizeFromValue:s=>e.map(([i,a])=>x(s[i],a)).reduce((i,a)=>i+a,0),maxSize:t}:{fixedSize:n},write:(s,i,a)=>(e.forEach(([d,c])=>{a=c.write(s[d],i,a);}),a)})}function w(e){var o;let r=e.map(([,s])=>s),n=X(r.map(J)),t=(o=X(r.map(Q)))!=null?o:void 0;return p({...n===null?{maxSize:t}:{fixedSize:n},read:(s,i)=>{let a={};return e.forEach(([d,c])=>{let[l,I]=c.read(s,i);i=I,a[d]=l;}),[a,i]}})}var ce;function Je(){return ce||(ce=E([["lookupTableAddress",G()],["writableIndices",b(B(),{size:y()})],["readableIndices",b(B(),{size:y()})]])),ce}var de;function Qe(){return de||(de=w([["lookupTableAddress",V()],["writableIndices",S(D(),{size:A()})],["readableIndices",S(D(),{size:A()})]])),de}var ue;function le(){return ue||(ue=B()),ue}var fe;function ge(){return fe||(fe=D()),fe}function er(){return E([["numSignerAccounts",le()],["numReadonlySignerAccounts",le()],["numReadonlyNonSignerAccounts",le()]])}function rr(){return w([["numSignerAccounts",ge()],["numReadonlySignerAccounts",ge()],["numReadonlyNonSignerAccounts",ge()]])}var me;function nr(){return me||(me=z(E([["programAddressIndex",B()],["accountIndices",b(B(),{size:y()})],["data",ee({size:y()})]]),e=>{var r,n;return e.accountIndices!==void 0&&e.data!==void 0?e:{...e,accountIndices:(r=e.accountIndices)!=null?r:[],data:(n=e.data)!=null?n:new Uint8Array(0)}})),me}var pe;function tr(){return pe||(pe=k(w([["programAddressIndex",D()],["accountIndices",S(D(),{size:A()})],["data",re({size:A()})]]),e=>{if(e.accountIndices.length&&e.data.byteLength)return e;let{accountIndices:r,data:n,...t}=e;return {...t,...r.length?{accountIndices:r}:null,...n.byteLength?{data:n}:null}})),pe}var Te=128;function or(){return g({getSizeFromValue:e=>e==="legacy"?0:1,maxSize:1,write:(e,r,n)=>{if(e==="legacy")return n;if(e<0||e>127)throw new Error(`Transaction version must be in the range [0, 127]. \`${e}\` given.`);return r.set([e|Te],n),n+1}})}function ir(){return p({maxSize:1,read:(e,r)=>{let n=e[r];return n&Te?[n^Te,r+1]:["legacy",r]}})}function sr(){return E(cr())}function ar(){return z(E([...cr(),["addressTableLookups",Ur()]]),e=>{var r;return e.version==="legacy"?e:{...e,addressTableLookups:(r=e.addressTableLookups)!=null?r:[]}})}function cr(){return [["version",or()],["header",er()],["staticAccounts",b(G(),{size:y()})],["lifetimeToken",H({encoding:M(),size:32})],["instructions",b(nr(),{size:y()})]]}function Vr(){return [["version",ir()],["header",rr()],["staticAccounts",S(V(),{size:A()})],["lifetimeToken",K({encoding:F(),size:32})],["instructions",S(tr(),{size:A()})],["addressTableLookups",Or()]]}function Ur(){return b(Je(),{size:y()})}function Or(){return S(Qe(),{size:A()})}function O(){return g({getSizeFromValue:e=>e.version==="legacy"?sr().getSizeFromValue(e):ar().getSizeFromValue(e),write:(e,r,n)=>e.version==="legacy"?sr().write(e,r,n):ar().write(e,r,n)})}function ye(){return k(w(Vr()),({addressTableLookups:e,...r})=>r.version==="legacy"||!(e!=null&&e.length)?r:{...r,addressTableLookups:e})}function yo(){return C(O(),ye())}function dr(e){var t;let r=q(e),n;if("signatures"in e){n=[];for(let o=0;o<r.header.numSignerAccounts;o++)n[o]=(t=e.signatures[r.staticAccounts[o]])!=null?t:new Uint8Array(Array(64).fill(0));}else n=Array(r.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));return {compiledMessage:r,signatures:n}}function ur(e,...r){return r.reduce((n,t)=>t(n),e)}function Wr(e){let{header:r}=e,n=r.numSignerAccounts-r.numReadonlySignerAccounts,t=e.staticAccounts.length-r.numSignerAccounts-r.numReadonlyNonSignerAccounts,o=[],s=0;for(let i=0;i<n;i++)o.push({address:e.staticAccounts[s],role:m.WRITABLE_SIGNER}),s++;for(let i=0;i<r.numReadonlySignerAccounts;i++)o.push({address:e.staticAccounts[s],role:m.READONLY_SIGNER}),s++;for(let i=0;i<t;i++)o.push({address:e.staticAccounts[s],role:m.WRITABLE}),s++;for(let i=0;i<r.numReadonlyNonSignerAccounts;i++)o.push({address:e.staticAccounts[s],role:m.READONLY}),s++;return o}function Pr(e,r){var s,i;let n=(s=r[e.programAddressIndex])==null?void 0:s.address;if(!n)throw new Error(`Could not find program address at index ${e.programAddressIndex}`);let t=(i=e.accountIndices)==null?void 0:i.map(a=>r[a]),{data:o}=e;return {programAddress:n,...t&&t.length?{accounts:t}:{},...o&&o.length?{data:o}:{}}}function _r(e,r,n){if(!r||!Y(r))return {blockhash:e,lastValidBlockHeight:n!=null?n:2n**64n-1n};{let t=r.accounts[0].address;j(t);let o=r.accounts[2].address;return j(o),{nonce:e,nonceAccountAddress:t,nonceAuthorityAddress:o}}}function $r(e){let{compiledMessage:{staticAccounts:r},signatures:n}=e;return n.reduce((t,o,s)=>{if(o.every(d=>d===0))return t;let a=r[s];return {...t,[a]:o}},{})}function lr(e,r){let{compiledMessage:n}=e;if("addressTableLookups"in n&&n.addressTableLookups.length>0)throw new Error("Cannot convert transaction with addressTableLookups");let t=n.staticAccounts[0];if(!t)throw new Error("No fee payer set in CompiledTransaction");let o=Wr(n),s=n.instructions.map(c=>Pr(c,o)),i=s[0],a=_r(n.lifetimeToken,i,r),d=$r(e);return ur(ve({version:n.version}),c=>Ve(t,c),c=>s.reduce((l,I)=>Ue(I,l),c),c=>"blockhash"in a?Ne(a,c):Fe(a,c),c=>e.signatures.length?{...c,signatures:d}:c)}function Hr(){return E([["signatures",b(ee({size:64}),{size:y()})],["compiledMessage",O()]])}function Kr(){return w([["signatures",S(re({size:64}),{size:A()})],["compiledMessage",ye()]])}function Ae(){return z(Hr(),dr)}function Yr(e){return k(Kr(),r=>lr(r,e))}function Jo(e){return C(Ae(),Yr(e))}async function fr(e,r){await Pe();let n=await crypto.subtle.sign("Ed25519",e,r);return new Uint8Array(n)}var he;function pi(e){he||(he=F());let r=e.signatures[e.feePayer];if(!r)throw new Error("Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.");return he.decode(r)}async function jr(e,r){let n=q(r),t="signatures"in r?{...r.signatures}:{},o=O().encode(n),s=await Promise.all(e.map(a=>Promise.all([$e(a.publicKey),fr(a.privateKey,o)])));for(let[a,d]of s)t[a]=d;let i={...r,signatures:t};return Object.freeze(i),i}async function Ti(e,r){let n=await jr(e,r);return Gr(n),Object.freeze(n),n}function Gr(e){let r=e.instructions.flatMap(t=>{var o,s;return (s=(o=t.accounts)==null?void 0:o.filter(i=>h(i.role)))!=null?s:[]}).map(t=>t.address);new Set([e.feePayer,...r]).forEach(t=>{if(!e.signatures[t])throw new Error(`Transaction is missing signature for address \`${t}\``)});}function Si(e){let r=Ae().encode(e);return De().decode(r)}
|
|
6
6
|
|
|
7
|
-
exports.appendTransactionInstruction =
|
|
8
|
-
exports.assertIsBlockhash =
|
|
9
|
-
exports.assertIsDurableNonceTransaction =
|
|
10
|
-
exports.
|
|
11
|
-
exports.
|
|
12
|
-
exports.
|
|
13
|
-
exports.
|
|
14
|
-
exports.
|
|
15
|
-
exports.
|
|
16
|
-
exports.
|
|
17
|
-
exports.
|
|
18
|
-
exports.
|
|
19
|
-
exports.
|
|
20
|
-
exports.
|
|
21
|
-
exports.
|
|
7
|
+
exports.appendTransactionInstruction = Ue;
|
|
8
|
+
exports.assertIsBlockhash = zr;
|
|
9
|
+
exports.assertIsDurableNonceTransaction = wn;
|
|
10
|
+
exports.assertIsTransactionWithBlockhashLifetime = un;
|
|
11
|
+
exports.assertTransactionIsFullySigned = Gr;
|
|
12
|
+
exports.compileMessage = q;
|
|
13
|
+
exports.createTransaction = ve;
|
|
14
|
+
exports.getBase64EncodedWireTransaction = Si;
|
|
15
|
+
exports.getCompiledMessageCodec = yo;
|
|
16
|
+
exports.getCompiledMessageDecoder = ye;
|
|
17
|
+
exports.getCompiledMessageEncoder = O;
|
|
18
|
+
exports.getSignatureFromTransaction = pi;
|
|
19
|
+
exports.getTransactionCodec = Jo;
|
|
20
|
+
exports.getTransactionDecoder = Yr;
|
|
21
|
+
exports.getTransactionEncoder = Ae;
|
|
22
|
+
exports.isAdvanceNonceAccountInstruction = Y;
|
|
23
|
+
exports.partiallySignTransaction = jr;
|
|
24
|
+
exports.prependTransactionInstruction = Ln;
|
|
25
|
+
exports.setTransactionFeePayer = Ve;
|
|
26
|
+
exports.setTransactionLifetimeUsingBlockhash = Ne;
|
|
27
|
+
exports.setTransactionLifetimeUsingDurableNonce = Fe;
|
|
28
|
+
exports.signTransaction = Ti;
|
|
22
29
|
|
|
23
30
|
return exports;
|
|
24
31
|
|
package/dist/types/accounts.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Address } from '@solana/addresses';
|
|
2
2
|
import { IAccountLookupMeta, IAccountMeta, IInstruction, ReadonlyAccount, ReadonlyAccountLookup, ReadonlySignerAccount, WritableAccount, WritableAccountLookup, WritableSignerAccount } from '@solana/instructions';
|
|
3
3
|
export declare const enum AddressMapEntryType {
|
|
4
4
|
FEE_PAYER = 0,
|
|
@@ -22,7 +22,7 @@ type StaticAccountEntry = Omit<ReadonlyAccount | ReadonlySignerAccount | Writabl
|
|
|
22
22
|
};
|
|
23
23
|
declare const TYPE: unique symbol;
|
|
24
24
|
export declare const ADDRESS_MAP_TYPE_PROPERTY: typeof TYPE;
|
|
25
|
-
export declare function getAddressMapFromInstructions(feePayer:
|
|
25
|
+
export declare function getAddressMapFromInstructions(feePayer: Address, instructions: readonly IInstruction[]): AddressMap;
|
|
26
26
|
export declare function getOrderedAccountsFromAddressMap(addressMap: AddressMap): OrderedAccounts;
|
|
27
27
|
export {};
|
|
28
28
|
//# sourceMappingURL=accounts.d.ts.map
|