Socket
Socket
Sign inDemoInstall

@solana/transactions

Package Overview
Dependencies
Maintainers
13
Versions
1162
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solana/transactions - npm Package Compare versions

Comparing version 2.0.0-experimental.c2d0ddc to 2.0.0-experimental.c5061ae

dist/types/unsigned-transaction.d.ts

143

dist/index.browser.js

@@ -6,2 +6,18 @@ import { base58, struct, array, bytes, shortU16, mapSerializer, string, u8 } from '@metaplex-foundation/umi-serializers';

var __DEV__ = /* @__PURE__ */ (() => process["env"].NODE_ENV === "development")();
// src/unsigned-transaction.ts
function getUnsignedTransaction(transaction) {
if ("signatures" in transaction) {
const {
signatures: _,
// eslint-disable-line @typescript-eslint/no-unused-vars
...unsignedTransaction
} = transaction;
return unsignedTransaction;
} else {
return transaction;
}
}
// src/blockhash.ts
function assertIsBlockhash(putativeBlockhash) {

@@ -27,2 +43,13 @@ try {

}
function setTransactionLifetimeUsingBlockhash(blockhashLifetimeConstraint, transaction) {
if ("lifetimeConstraint" in transaction && transaction.lifetimeConstraint.blockhash === blockhashLifetimeConstraint.blockhash && transaction.lifetimeConstraint.lastValidBlockHeight === blockhashLifetimeConstraint.lastValidBlockHeight) {
return transaction;
}
const out = {
...getUnsignedTransaction(transaction),
lifetimeConstraint: blockhashLifetimeConstraint
};
Object.freeze(out);
return out;
}

@@ -41,62 +68,2 @@ // src/create-transaction.ts

// src/fee-payer.ts
function setTransactionFeePayer(feePayer, transaction) {
if ("feePayer" in transaction && feePayer === transaction.feePayer) {
return transaction;
}
let out;
if ("signatures" in transaction) {
const {
signatures: _,
// eslint-disable-line @typescript-eslint/no-unused-vars
...unsignedTransaction
} = transaction;
out = {
...unsignedTransaction,
feePayer
};
} else {
out = {
...transaction,
feePayer
};
}
Object.freeze(out);
return out;
}
// src/instructions.ts
function replaceInstructions(transaction, nextInstructions) {
let out;
if ("signatures" in transaction) {
const {
signatures: _,
// eslint-disable-line @typescript-eslint/no-unused-vars
...unsignedTransaction
} = transaction;
out = {
...unsignedTransaction,
instructions: nextInstructions
};
} else {
out = {
...transaction,
instructions: nextInstructions
};
}
return out;
}
function appendTransactionInstruction(instruction, transaction) {
const nextInstructions = [...transaction.instructions, instruction];
const out = replaceInstructions(transaction, nextInstructions);
Object.freeze(out);
return out;
}
function prependTransactionInstruction(instruction, transaction) {
const nextInstructions = [instruction, ...transaction.instructions];
const out = replaceInstructions(transaction, nextInstructions);
Object.freeze(out);
return out;
}
// ../instructions/dist/index.browser.js

@@ -124,2 +91,56 @@ var AccountRole = /* @__PURE__ */ ((AccountRole2) => {

}
// src/durable-nonce.ts
var RECENT_BLOCKHASHES_SYSVAR_ADDRESS = "SysvarRecentB1ockHashes11111111111111111111";
var SYSTEM_PROGRAM_ADDRESS = "11111111111111111111111111111111";
function assertIsDurableNonceTransaction(transaction) {
if (!isDurableNonceTransaction(transaction)) {
throw new Error("Transaction is not a durable nonce transaction");
}
}
function isAdvanceNonceAccountInstruction(instruction) {
return instruction.programAddress === SYSTEM_PROGRAM_ADDRESS && // Test for `AdvanceNonceAccount` instruction data
instruction.data != null && isAdvanceNonceAccountInstructionData(instruction.data) && // Test for exactly 3 accounts
instruction.accounts?.length === 3 && // First account is nonce account address
instruction.accounts[0].address != null && instruction.accounts[0].role === AccountRole.WRITABLE && // Second account is recent blockhashes sysvar
instruction.accounts[1].address === RECENT_BLOCKHASHES_SYSVAR_ADDRESS && instruction.accounts[1].role === AccountRole.READONLY && // Third account is nonce authority account
instruction.accounts[2].address != null && instruction.accounts[2].role === AccountRole.READONLY_SIGNER;
}
function isAdvanceNonceAccountInstructionData(data) {
return data.byteLength === 4 && data[0] === 4 && data[1] === 0 && data[2] === 0 && data[3] === 0;
}
function isDurableNonceTransaction(transaction) {
return "lifetimeConstraint" in transaction && typeof transaction.lifetimeConstraint.nonce === "string" && transaction.instructions[0] != null && isAdvanceNonceAccountInstruction(transaction.instructions[0]);
}
// src/fee-payer.ts
function setTransactionFeePayer(feePayer, transaction) {
if ("feePayer" in transaction && feePayer === transaction.feePayer) {
return transaction;
}
const out = {
...getUnsignedTransaction(transaction),
feePayer
};
Object.freeze(out);
return out;
}
// src/instructions.ts
function appendTransactionInstruction(instruction, transaction) {
const out = {
...getUnsignedTransaction(transaction),
instructions: [...transaction.instructions, instruction]
};
Object.freeze(out);
return out;
}
function prependTransactionInstruction(instruction, transaction) {
const out = {
...getUnsignedTransaction(transaction),
instructions: [instruction, ...transaction.instructions]
};
Object.freeze(out);
return out;
}
function upsert(addressMap, address, update) {

@@ -706,4 +727,4 @@ addressMap[address] = update(addressMap[address] ?? { role: AccountRole.READONLY });

export { appendTransactionInstruction, assertIsBlockhash, createTransaction, getBase64EncodedWireTransaction, prependTransactionInstruction, setTransactionFeePayer, signTransaction };
export { appendTransactionInstruction, assertIsBlockhash, assertIsDurableNonceTransaction, createTransaction, getBase64EncodedWireTransaction, prependTransactionInstruction, setTransactionFeePayer, setTransactionLifetimeUsingBlockhash, signTransaction };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.browser.js.map

@@ -496,2 +496,16 @@ this.globalThis = this.globalThis || {};

// src/unsigned-transaction.ts
function getUnsignedTransaction(transaction) {
if ("signatures" in transaction) {
const {
signatures: _,
// eslint-disable-line @typescript-eslint/no-unused-vars
...unsignedTransaction
} = transaction;
return unsignedTransaction;
} else {
return transaction;
}
}
// src/blockhash.ts

@@ -518,2 +532,13 @@ function assertIsBlockhash(putativeBlockhash) {

}
function setTransactionLifetimeUsingBlockhash(blockhashLifetimeConstraint, transaction) {
if ("lifetimeConstraint" in transaction && transaction.lifetimeConstraint.blockhash === blockhashLifetimeConstraint.blockhash && transaction.lifetimeConstraint.lastValidBlockHeight === blockhashLifetimeConstraint.lastValidBlockHeight) {
return transaction;
}
const out = {
...getUnsignedTransaction(transaction),
lifetimeConstraint: blockhashLifetimeConstraint
};
Object.freeze(out);
return out;
}

@@ -532,2 +557,48 @@ // src/create-transaction.ts

// ../instructions/dist/index.browser.js
var AccountRole = /* @__PURE__ */ ((AccountRole2) => {
AccountRole2[AccountRole2["WRITABLE_SIGNER"] = /* 3 */
3] = "WRITABLE_SIGNER";
AccountRole2[AccountRole2["READONLY_SIGNER"] = /* 2 */
2] = "READONLY_SIGNER";
AccountRole2[AccountRole2["WRITABLE"] = /* 1 */
1] = "WRITABLE";
AccountRole2[AccountRole2["READONLY"] = /* 0 */
0] = "READONLY";
return AccountRole2;
})(AccountRole || {});
var IS_WRITABLE_BITMASK = 1;
function isSignerRole(role) {
return role >= 2;
}
function isWritableRole(role) {
return (role & IS_WRITABLE_BITMASK) !== 0;
}
function mergeRoles(roleA, roleB) {
return roleA | roleB;
}
// src/durable-nonce.ts
var RECENT_BLOCKHASHES_SYSVAR_ADDRESS = "SysvarRecentB1ockHashes11111111111111111111";
var SYSTEM_PROGRAM_ADDRESS = "11111111111111111111111111111111";
function assertIsDurableNonceTransaction(transaction) {
if (!isDurableNonceTransaction(transaction)) {
throw new Error("Transaction is not a durable nonce transaction");
}
}
function isAdvanceNonceAccountInstruction(instruction) {
return instruction.programAddress === SYSTEM_PROGRAM_ADDRESS && // Test for `AdvanceNonceAccount` instruction data
instruction.data != null && isAdvanceNonceAccountInstructionData(instruction.data) && // Test for exactly 3 accounts
instruction.accounts?.length === 3 && // First account is nonce account address
instruction.accounts[0].address != null && instruction.accounts[0].role === AccountRole.WRITABLE && // Second account is recent blockhashes sysvar
instruction.accounts[1].address === RECENT_BLOCKHASHES_SYSVAR_ADDRESS && instruction.accounts[1].role === AccountRole.READONLY && // Third account is nonce authority account
instruction.accounts[2].address != null && instruction.accounts[2].role === AccountRole.READONLY_SIGNER;
}
function isAdvanceNonceAccountInstructionData(data) {
return data.byteLength === 4 && data[0] === 4 && data[1] === 0 && data[2] === 0 && data[3] === 0;
}
function isDurableNonceTransaction(transaction) {
return "lifetimeConstraint" in transaction && typeof transaction.lifetimeConstraint.nonce === "string" && transaction.instructions[0] != null && isAdvanceNonceAccountInstruction(transaction.instructions[0]);
}
// src/fee-payer.ts

@@ -538,19 +609,6 @@ function setTransactionFeePayer(feePayer, transaction) {

}
let out;
if ("signatures" in transaction) {
const {
signatures: _,
// eslint-disable-line @typescript-eslint/no-unused-vars
...unsignedTransaction
} = transaction;
out = {
...unsignedTransaction,
feePayer
};
} else {
out = {
...transaction,
feePayer
};
}
const out = {
...getUnsignedTransaction(transaction),
feePayer
};
Object.freeze(out);

@@ -561,25 +619,7 @@ return out;

// src/instructions.ts
function replaceInstructions(transaction, nextInstructions) {
let out;
if ("signatures" in transaction) {
const {
signatures: _,
// eslint-disable-line @typescript-eslint/no-unused-vars
...unsignedTransaction
} = transaction;
out = {
...unsignedTransaction,
instructions: nextInstructions
};
} else {
out = {
...transaction,
instructions: nextInstructions
};
}
return out;
}
function appendTransactionInstruction(instruction, transaction) {
const nextInstructions = [...transaction.instructions, instruction];
const out = replaceInstructions(transaction, nextInstructions);
const out = {
...getUnsignedTransaction(transaction),
instructions: [...transaction.instructions, instruction]
};
Object.freeze(out);

@@ -589,4 +629,6 @@ return out;

function prependTransactionInstruction(instruction, transaction) {
const nextInstructions = [instruction, ...transaction.instructions];
const out = replaceInstructions(transaction, nextInstructions);
const out = {
...getUnsignedTransaction(transaction),
instructions: [instruction, ...transaction.instructions]
};
Object.freeze(out);

@@ -646,25 +688,2 @@ return out;

// ../instructions/dist/index.browser.js
var AccountRole = /* @__PURE__ */ ((AccountRole2) => {
AccountRole2[AccountRole2["WRITABLE_SIGNER"] = /* 3 */
3] = "WRITABLE_SIGNER";
AccountRole2[AccountRole2["READONLY_SIGNER"] = /* 2 */
2] = "READONLY_SIGNER";
AccountRole2[AccountRole2["WRITABLE"] = /* 1 */
1] = "WRITABLE";
AccountRole2[AccountRole2["READONLY"] = /* 0 */
0] = "READONLY";
return AccountRole2;
})(AccountRole || {});
var IS_WRITABLE_BITMASK = 1;
function isSignerRole(role) {
return role >= 2;
}
function isWritableRole(role) {
return (role & IS_WRITABLE_BITMASK) !== 0;
}
function mergeRoles(roleA, roleB) {
return roleA | roleB;
}
// src/accounts.ts

@@ -1262,2 +1281,3 @@ function upsert(addressMap, address, update) {

exports.assertIsBlockhash = assertIsBlockhash;
exports.assertIsDurableNonceTransaction = assertIsDurableNonceTransaction;
exports.createTransaction = createTransaction;

@@ -1267,2 +1287,3 @@ exports.getBase64EncodedWireTransaction = getBase64EncodedWireTransaction;

exports.setTransactionFeePayer = setTransactionFeePayer;
exports.setTransactionLifetimeUsingBlockhash = setTransactionLifetimeUsingBlockhash;
exports.signTransaction = signTransaction;

@@ -1269,0 +1290,0 @@

@@ -6,2 +6,18 @@ import { base58, struct, array, bytes, shortU16, mapSerializer, string, u8 } from '@metaplex-foundation/umi-serializers';

var __DEV__ = /* @__PURE__ */ (() => process["env"].NODE_ENV === "development")();
// src/unsigned-transaction.ts
function getUnsignedTransaction(transaction) {
if ("signatures" in transaction) {
const {
signatures: _,
// eslint-disable-line @typescript-eslint/no-unused-vars
...unsignedTransaction
} = transaction;
return unsignedTransaction;
} else {
return transaction;
}
}
// src/blockhash.ts
function assertIsBlockhash(putativeBlockhash) {

@@ -27,2 +43,13 @@ try {

}
function setTransactionLifetimeUsingBlockhash(blockhashLifetimeConstraint, transaction) {
if ("lifetimeConstraint" in transaction && transaction.lifetimeConstraint.blockhash === blockhashLifetimeConstraint.blockhash && transaction.lifetimeConstraint.lastValidBlockHeight === blockhashLifetimeConstraint.lastValidBlockHeight) {
return transaction;
}
const out = {
...getUnsignedTransaction(transaction),
lifetimeConstraint: blockhashLifetimeConstraint
};
Object.freeze(out);
return out;
}

@@ -41,62 +68,2 @@ // src/create-transaction.ts

// src/fee-payer.ts
function setTransactionFeePayer(feePayer, transaction) {
if ("feePayer" in transaction && feePayer === transaction.feePayer) {
return transaction;
}
let out;
if ("signatures" in transaction) {
const {
signatures: _,
// eslint-disable-line @typescript-eslint/no-unused-vars
...unsignedTransaction
} = transaction;
out = {
...unsignedTransaction,
feePayer
};
} else {
out = {
...transaction,
feePayer
};
}
Object.freeze(out);
return out;
}
// src/instructions.ts
function replaceInstructions(transaction, nextInstructions) {
let out;
if ("signatures" in transaction) {
const {
signatures: _,
// eslint-disable-line @typescript-eslint/no-unused-vars
...unsignedTransaction
} = transaction;
out = {
...unsignedTransaction,
instructions: nextInstructions
};
} else {
out = {
...transaction,
instructions: nextInstructions
};
}
return out;
}
function appendTransactionInstruction(instruction, transaction) {
const nextInstructions = [...transaction.instructions, instruction];
const out = replaceInstructions(transaction, nextInstructions);
Object.freeze(out);
return out;
}
function prependTransactionInstruction(instruction, transaction) {
const nextInstructions = [instruction, ...transaction.instructions];
const out = replaceInstructions(transaction, nextInstructions);
Object.freeze(out);
return out;
}
// ../instructions/dist/index.browser.js

@@ -124,2 +91,56 @@ var AccountRole = /* @__PURE__ */ ((AccountRole2) => {

}
// src/durable-nonce.ts
var RECENT_BLOCKHASHES_SYSVAR_ADDRESS = "SysvarRecentB1ockHashes11111111111111111111";
var SYSTEM_PROGRAM_ADDRESS = "11111111111111111111111111111111";
function assertIsDurableNonceTransaction(transaction) {
if (!isDurableNonceTransaction(transaction)) {
throw new Error("Transaction is not a durable nonce transaction");
}
}
function isAdvanceNonceAccountInstruction(instruction) {
return instruction.programAddress === SYSTEM_PROGRAM_ADDRESS && // Test for `AdvanceNonceAccount` instruction data
instruction.data != null && isAdvanceNonceAccountInstructionData(instruction.data) && // Test for exactly 3 accounts
instruction.accounts?.length === 3 && // First account is nonce account address
instruction.accounts[0].address != null && instruction.accounts[0].role === AccountRole.WRITABLE && // Second account is recent blockhashes sysvar
instruction.accounts[1].address === RECENT_BLOCKHASHES_SYSVAR_ADDRESS && instruction.accounts[1].role === AccountRole.READONLY && // Third account is nonce authority account
instruction.accounts[2].address != null && instruction.accounts[2].role === AccountRole.READONLY_SIGNER;
}
function isAdvanceNonceAccountInstructionData(data) {
return data.byteLength === 4 && data[0] === 4 && data[1] === 0 && data[2] === 0 && data[3] === 0;
}
function isDurableNonceTransaction(transaction) {
return "lifetimeConstraint" in transaction && typeof transaction.lifetimeConstraint.nonce === "string" && transaction.instructions[0] != null && isAdvanceNonceAccountInstruction(transaction.instructions[0]);
}
// src/fee-payer.ts
function setTransactionFeePayer(feePayer, transaction) {
if ("feePayer" in transaction && feePayer === transaction.feePayer) {
return transaction;
}
const out = {
...getUnsignedTransaction(transaction),
feePayer
};
Object.freeze(out);
return out;
}
// src/instructions.ts
function appendTransactionInstruction(instruction, transaction) {
const out = {
...getUnsignedTransaction(transaction),
instructions: [...transaction.instructions, instruction]
};
Object.freeze(out);
return out;
}
function prependTransactionInstruction(instruction, transaction) {
const out = {
...getUnsignedTransaction(transaction),
instructions: [instruction, ...transaction.instructions]
};
Object.freeze(out);
return out;
}
function upsert(addressMap, address, update) {

@@ -706,2 +727,4 @@ addressMap[address] = update(addressMap[address] ?? { role: AccountRole.READONLY });

export { appendTransactionInstruction, assertIsBlockhash, createTransaction, getBase64EncodedWireTransaction, prependTransactionInstruction, setTransactionFeePayer, signTransaction };
export { appendTransactionInstruction, assertIsBlockhash, assertIsDurableNonceTransaction, createTransaction, getBase64EncodedWireTransaction, prependTransactionInstruction, setTransactionFeePayer, setTransactionLifetimeUsingBlockhash, signTransaction };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.native.js.map

@@ -6,2 +6,18 @@ import { base58, struct, array, bytes, shortU16, mapSerializer, string, u8 } from '@metaplex-foundation/umi-serializers';

var __DEV__ = /* @__PURE__ */ (() => process["env"].NODE_ENV === "development")();
// src/unsigned-transaction.ts
function getUnsignedTransaction(transaction) {
if ("signatures" in transaction) {
const {
signatures: _,
// eslint-disable-line @typescript-eslint/no-unused-vars
...unsignedTransaction
} = transaction;
return unsignedTransaction;
} else {
return transaction;
}
}
// src/blockhash.ts
function assertIsBlockhash(putativeBlockhash) {

@@ -27,2 +43,13 @@ try {

}
function setTransactionLifetimeUsingBlockhash(blockhashLifetimeConstraint, transaction) {
if ("lifetimeConstraint" in transaction && transaction.lifetimeConstraint.blockhash === blockhashLifetimeConstraint.blockhash && transaction.lifetimeConstraint.lastValidBlockHeight === blockhashLifetimeConstraint.lastValidBlockHeight) {
return transaction;
}
const out = {
...getUnsignedTransaction(transaction),
lifetimeConstraint: blockhashLifetimeConstraint
};
Object.freeze(out);
return out;
}

@@ -41,62 +68,2 @@ // src/create-transaction.ts

// src/fee-payer.ts
function setTransactionFeePayer(feePayer, transaction) {
if ("feePayer" in transaction && feePayer === transaction.feePayer) {
return transaction;
}
let out;
if ("signatures" in transaction) {
const {
signatures: _,
// eslint-disable-line @typescript-eslint/no-unused-vars
...unsignedTransaction
} = transaction;
out = {
...unsignedTransaction,
feePayer
};
} else {
out = {
...transaction,
feePayer
};
}
Object.freeze(out);
return out;
}
// src/instructions.ts
function replaceInstructions(transaction, nextInstructions) {
let out;
if ("signatures" in transaction) {
const {
signatures: _,
// eslint-disable-line @typescript-eslint/no-unused-vars
...unsignedTransaction
} = transaction;
out = {
...unsignedTransaction,
instructions: nextInstructions
};
} else {
out = {
...transaction,
instructions: nextInstructions
};
}
return out;
}
function appendTransactionInstruction(instruction, transaction) {
const nextInstructions = [...transaction.instructions, instruction];
const out = replaceInstructions(transaction, nextInstructions);
Object.freeze(out);
return out;
}
function prependTransactionInstruction(instruction, transaction) {
const nextInstructions = [instruction, ...transaction.instructions];
const out = replaceInstructions(transaction, nextInstructions);
Object.freeze(out);
return out;
}
// ../instructions/dist/index.node.js

@@ -124,2 +91,56 @@ var AccountRole = /* @__PURE__ */ ((AccountRole2) => {

}
// src/durable-nonce.ts
var RECENT_BLOCKHASHES_SYSVAR_ADDRESS = "SysvarRecentB1ockHashes11111111111111111111";
var SYSTEM_PROGRAM_ADDRESS = "11111111111111111111111111111111";
function assertIsDurableNonceTransaction(transaction) {
if (!isDurableNonceTransaction(transaction)) {
throw new Error("Transaction is not a durable nonce transaction");
}
}
function isAdvanceNonceAccountInstruction(instruction) {
return instruction.programAddress === SYSTEM_PROGRAM_ADDRESS && // Test for `AdvanceNonceAccount` instruction data
instruction.data != null && isAdvanceNonceAccountInstructionData(instruction.data) && // Test for exactly 3 accounts
instruction.accounts?.length === 3 && // First account is nonce account address
instruction.accounts[0].address != null && instruction.accounts[0].role === AccountRole.WRITABLE && // Second account is recent blockhashes sysvar
instruction.accounts[1].address === RECENT_BLOCKHASHES_SYSVAR_ADDRESS && instruction.accounts[1].role === AccountRole.READONLY && // Third account is nonce authority account
instruction.accounts[2].address != null && instruction.accounts[2].role === AccountRole.READONLY_SIGNER;
}
function isAdvanceNonceAccountInstructionData(data) {
return data.byteLength === 4 && data[0] === 4 && data[1] === 0 && data[2] === 0 && data[3] === 0;
}
function isDurableNonceTransaction(transaction) {
return "lifetimeConstraint" in transaction && typeof transaction.lifetimeConstraint.nonce === "string" && transaction.instructions[0] != null && isAdvanceNonceAccountInstruction(transaction.instructions[0]);
}
// src/fee-payer.ts
function setTransactionFeePayer(feePayer, transaction) {
if ("feePayer" in transaction && feePayer === transaction.feePayer) {
return transaction;
}
const out = {
...getUnsignedTransaction(transaction),
feePayer
};
Object.freeze(out);
return out;
}
// src/instructions.ts
function appendTransactionInstruction(instruction, transaction) {
const out = {
...getUnsignedTransaction(transaction),
instructions: [...transaction.instructions, instruction]
};
Object.freeze(out);
return out;
}
function prependTransactionInstruction(instruction, transaction) {
const out = {
...getUnsignedTransaction(transaction),
instructions: [instruction, ...transaction.instructions]
};
Object.freeze(out);
return out;
}
function upsert(addressMap, address, update) {

@@ -706,4 +727,2 @@ addressMap[address] = update(addressMap[address] ?? { role: AccountRole.READONLY });

export { appendTransactionInstruction, assertIsBlockhash, createTransaction, getBase64EncodedWireTransaction, prependTransactionInstruction, setTransactionFeePayer, signTransaction };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.node.js.map
export { appendTransactionInstruction, assertIsBlockhash, assertIsDurableNonceTransaction, createTransaction, getBase64EncodedWireTransaction, prependTransactionInstruction, setTransactionFeePayer, setTransactionLifetimeUsingBlockhash, signTransaction };

@@ -5,11 +5,13 @@ this.globalThis = this.globalThis || {};

var xe=Object.defineProperty;var Se=(e,r,t)=>r in e?xe(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var g=(e,r,t)=>(Se(e,typeof r!="symbol"?r+"":r,t),t);var A=e=>{let r=e.reduce((o,i)=>o+i.length,0),t=new Uint8Array(r),n=0;return e.forEach(o=>{t.set(o,n),n+=o.length;}),t},Z=(e,r)=>{if(e.length>=r)return e;let t=new Uint8Array(r).fill(0);return t.set(e),t},v=(e,r)=>Z(e.slice(0,r),r);var E=class extends Error{constructor(t){super(`Serializer [${t}] cannot deserialize empty buffers.`);g(this,"name","DeserializingEmptyBufferError");}},h=class extends Error{constructor(t,n,o){super(`Serializer [${t}] expected ${n} bytes, got ${o}.`);g(this,"name","NotEnoughBytesError");}},x=class extends Error{constructor(t){t??(t="Expected a fixed-size serializer, got a variable-size one.");super(t);g(this,"name","ExpectedFixedSizeSerializerError");}};function B(e,r,t){return {description:t??`fixed(${r}, ${e.description})`,fixedSize:r,maxSize:r,serialize:n=>v(e.serialize(n),r),deserialize:(n,o=0)=>{if(n=n.slice(o,o+r),n.length<r)throw new h("fixSerializer",r,n.length);e.fixedSize!==null&&(n=v(n,e.fixedSize));let[i]=e.deserialize(n,0);return [i,o+r]}}}function k(e,r,t){return {description:e.description,fixedSize:e.fixedSize,maxSize:e.maxSize,serialize:n=>e.serialize(r(n)),deserialize:(n,o=0)=>{let[i,s]=e.deserialize(n,o);return t?[t(i,n,o),s]:[i,s]}}}var D=class extends Error{constructor(t,n,o){let i=`Expected a string of base ${n}, got [${t}].`;super(i);g(this,"name","InvalidBaseStringError");this.cause=o;}};var Q=e=>{let r=e.length,t=BigInt(r);return {description:`base${r}`,fixedSize:null,maxSize:null,serialize(n){if(!n.match(new RegExp(`^[${e}]*$`)))throw new D(n,r);if(n==="")return new Uint8Array;let o=[...n],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),l=0n,d=1n;for(let f=c.length-1;f>=0;f-=1)l+=d*BigInt(e.indexOf(c[f])),d*=t;let u=[];for(;l>0n;)u.unshift(Number(l%256n)),l/=256n;return Uint8Array.from(s.concat(u))},deserialize(n,o=0){if(n.length===0)return ["",0];let i=n.slice(o),s=i.findIndex(u=>u!==0);s=s===-1?i.length:s;let c=e[0].repeat(s);if(s===i.length)return [c,n.length];let l=i.slice(s).reduce((u,f)=>u*256n+BigInt(f),0n),d=[];for(;l>0n;)d.unshift(e[Number(l%t)]),l/=t;return [c+d.join(""),n.length]}}};var S=Q("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");var ee=e=>e.replace(/\u0000/g,"");var G={description:"utf8",fixedSize:null,maxSize:null,serialize(e){return new TextEncoder().encode(e)},deserialize(e,r=0){let t=new TextDecoder().decode(e.slice(r));return [ee(t),e.length]}};var V;(function(e){e.Little="le",e.Big="be";})(V||(V={}));var N=class extends RangeError{constructor(t,n,o,i){super(`Serializer [${t}] expected number to be between ${n} and ${o}, got ${i}.`);g(this,"name","NumberOutOfRangeError");}};function W(e){let r,t=e.name;return e.size>1&&(r=!("endian"in e.options)||e.options.endian===V.Little,t+=r?"(le)":"(be)"),{description:e.options.description??t,fixedSize:e.size,maxSize:e.size,serialize(n){e.range&&H(e.name,e.range[0],e.range[1],n);let o=new ArrayBuffer(e.size);return e.set(new DataView(o),n,r),new Uint8Array(o)},deserialize(n,o=0){let i=n.slice(o,o+e.size);we("i8",i,e.size);let s=Ie(i);return [e.get(s,r),o+e.size]}}}var ze=e=>e.buffer.slice(e.byteOffset,e.byteLength+e.byteOffset),Ie=e=>new DataView(ze(e)),H=(e,r,t,n)=>{if(n<r||n>t)throw new N(e,r,t,n)},we=(e,r,t)=>{if(r.length===0)throw new E(e);if(r.length<t)throw new h(e,t,r.length)};var b=(e={})=>W({name:"u8",size:1,range:[0,+"0xff"],set:(r,t)=>r.setUint8(0,Number(t)),get:r=>r.getUint8(0),options:e});var M=(e={})=>W({name:"u32",size:4,range:[0,+"0xffffffff"],set:(r,t,n)=>r.setUint32(0,Number(t),n),get:(r,t)=>r.getUint32(0,t),options:e});var m=(e={})=>({description:e.description??"shortU16",fixedSize:null,maxSize:3,serialize:r=>{H("shortU16",0,65535,r);let t=[0];for(let n=0;;n+=1){let o=r>>n*7;if(o===0)break;let i=127&o;t[n]=i,n>0&&(t[n-1]|=128);}return new Uint8Array(t)},deserialize:(r,t=0)=>{let n=0,o=0;for(;++o;){let i=o-1,s=r[t+i],c=127&s;if(n|=c<<i*7,!(s&128))break}return [n,t+o]}});var $=class extends Error{constructor(t,n,o){super(`Expected [${t}] to have ${n} items, got ${o}.`);g(this,"name","InvalidNumberOfItemsError");}},U=class extends Error{constructor(t,n){super(`The remainder of the buffer (${t} bytes) cannot be split into chunks of ${n} bytes. Serializers of "remainder" size must have a remainder that is a multiple of its item size. In other words, ${t} modulo ${n} should be equal to zero.`);g(this,"name","InvalidArrayLikeRemainderSizeError");}},F=class extends Error{constructor(t){super(`Unrecognized array-like serializer size: ${JSON.stringify(t)}`);g(this,"name","UnrecognizedArrayLikeSerializerSizeError");}};function _(e){return e.reduce((r,t)=>r===null||t===null?null:r+t,0)}function re(e,r,t,n){if(typeof e=="number")return [e,n];if(typeof e=="object")return e.deserialize(t,n);if(e==="remainder"){let o=_(r);if(o===null)throw new x('Serializers of "remainder" size must have fixed-size items.');let i=t.slice(n).length;if(i%o!==0)throw new U(i,o);return [i/o,n]}throw new F(e)}function C(e){return typeof e=="object"?e.description:`${e}`}function q(e,r){if(typeof e!="number")return null;if(e===0)return 0;let t=_(r);return t===null?null:t*e}function te(e,r){return typeof e=="object"?e.serialize(r):new Uint8Array}function y(e,r={}){let t=r.size??M();if(t==="remainder"&&e.fixedSize===null)throw new x('Serializers of "remainder" size must have fixed-size items.');return {description:r.description??`array(${e.description}; ${C(t)})`,fixedSize:q(t,[e.fixedSize]),maxSize:q(t,[e.maxSize]),serialize:n=>{if(typeof t=="number"&&n.length!==t)throw new $("array",t,n.length);return A([te(t,n.length),...n.map(o=>e.serialize(o))])},deserialize:(n,o=0)=>{if(typeof t=="object"&&n.slice(o).length===0)return [[],o];let[i,s]=re(t,[e.fixedSize],n,o);o=s;let c=[];for(let l=0;l<i;l+=1){let[d,u]=e.deserialize(n,o);c.push(d),o=u;}return [c,o]}}}function R(e={}){let r=e.size??"variable",t=e.description??`bytes(${C(r)})`,n={description:t,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"?n:typeof r=="number"?B(n,r,t):{description:t,fixedSize:null,maxSize:null,serialize:o=>{let i=n.serialize(o),s=r.serialize(i.length);return A([s,i])},deserialize:(o,i=0)=>{if(o.slice(i).length===0)throw new E("bytes");let[s,c]=r.deserialize(o,i),l=Number(s);i=c;let d=o.slice(i,i+l);if(d.length<l)throw new h("bytes",l,d.length);let[u,f]=n.deserialize(d);return i+=f,[u,i]}}}function L(e={}){let r=e.size??M(),t=e.encoding??G,n=e.description??`string(${t.description}; ${C(r)})`;return r==="variable"?{...t,description:n}:typeof r=="number"?B(t,r,n):{description:n,fixedSize:null,maxSize:null,serialize:o=>{let i=t.serialize(o),s=r.serialize(i.length);return A([s,i])},deserialize:(o,i=0)=>{if(o.slice(i).length===0)throw new E("string");let[s,c]=r.deserialize(o,i),l=Number(s);i=c;let d=o.slice(i,i+l);if(d.length<l)throw new h("string",l,d.length);let[u,f]=t.deserialize(d);return i+=f,[u,i]}}}function T(e,r={}){let t=e.map(([n,o])=>`${String(n)}: ${o.description}`).join(", ");return {description:r.description??`struct(${t})`,fixedSize:_(e.map(([,n])=>n.fixedSize)),maxSize:_(e.map(([,n])=>n.maxSize)),serialize:n=>{let o=e.map(([i,s])=>s.serialize(n[i]));return A(o)},deserialize:(n,o=0)=>{let i={};return e.forEach(([s,c])=>{let[l,d]=c.deserialize(n,o);o=d,i[s]=l;}),[i,o]}}}function Pt(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=S.serialize(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 blockhash`,{cause:r})}}function Vt({version:e}){let r={instructions:[],version:e};return Object.freeze(r),r}function $t(e,r){if("feePayer"in r&&e===r.feePayer)return r;let t;if("signatures"in r){let{signatures:n,...o}=r;t={...o,feePayer:e};}else t={...r,feePayer:e};return Object.freeze(t),t}function ne(e,r){let t;if("signatures"in e){let{signatures:n,...o}=e;t={...o,instructions:r};}else t={...e,instructions:r};return t}function Kt(e,r){let t=[...r.instructions,e],n=ne(r,t);return Object.freeze(n),n}function Yt(e,r){let t=[e,...r.instructions],n=ne(r,t);return Object.freeze(n),n}function O(e){return L({description:e?.description??(""),encoding:S,size:32})}function P(){return new Intl.Collator("en",{caseFirst:"lower",ignorePunctuation:!1,localeMatcher:"best fit",numeric:!1,sensitivity:"variant",usage:"sort"}).compare}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 Ce(){if(oe(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.exportKey!="function")throw new Error("No key export implementation could be found")}async function Be(){if(oe(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.sign!="function")throw new Error("No signing implementation could be found")}async function ie(e){if(await Ce(),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),[t]=O().deserialize(new Uint8Array(r));return t}async function se(e,r){await Be();let t=await crypto.subtle.sign("Ed25519",e,r);return new Uint8Array(t)}var z=(e=>(e[e.WRITABLE_SIGNER=3]="WRITABLE_SIGNER",e[e.READONLY_SIGNER=2]="READONLY_SIGNER",e[e.WRITABLE=1]="WRITABLE",e[e.READONLY=0]="READONLY",e))(z||{});var ke=1;function I(e){return e>=2}function w(e){return (e&ke)!==0}function X(e,r){return e|r}function ae(e,r,t){e[r]=t(e[r]??{role:z.READONLY});}var p=Symbol("AddressMapTypeProperty");function ce(e,r){let t={[e]:{[p]:0,role:z.WRITABLE_SIGNER}},n=new Set;for(let o of r){ae(t,o.programAddress,s=>{if(n.add(o.programAddress),p in s){if(w(s.role))switch(s[p]){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[p]===2)return s}return {[p]:2,role:z.READONLY}});let i;if(o.accounts)for(let s of o.accounts)ae(t,s.address,c=>{let{address:l,...d}=s;if(p in c)switch(c[p]){case 0:return c;case 1:{let u=X(c.role,d.role);if("lookupTableAddress"in d){if(c.lookupTableAddress!==d.lookupTableAddress&&(i||(i=P()))(d.lookupTableAddress,c.lookupTableAddress)<0)return {[p]:1,...d,role:u}}else if(I(d.role))return {[p]:2,role:u};return c.role!==u?{...c,role:u}:c}case 2:{let u=X(c.role,d.role);if(n.has(s.address)){if(w(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!==u?{...c,role:u}:c}else return "lookupTableAddress"in d&&!I(c.role)?{...d,[p]:1,role:u}:c.role!==u?{...c,role:u}:c}}return "lookupTableAddress"in d?{...d,[p]:1}:{...d,[p]:2}});}return t}function de(e){let r;return Object.entries(e).sort(([n,o],[i,s])=>{if(o[p]!==s[p]){if(o[p]===0)return -1;if(s[p]===0)return 1;if(o[p]===2)return -1;if(s[p]===2)return 1}let c=I(o.role);if(c!==I(s.role))return c?-1:1;let l=w(o.role);return l!==w(s.role)?l?-1:1:(r||(r=P()),o[p]===1&&s[p]===1&&o.lookupTableAddress!==s.lookupTableAddress?r(o.lookupTableAddress,s.lookupTableAddress):r(n,i))}).map(([n,o])=>({address:n,...o}))}function le(e){var t;let r={};for(let n of e){if(!("lookupTableAddress"in n))continue;let o=r[t=n.lookupTableAddress]||(r[t]={readableIndices:[],writableIndices:[]});n.role===z.WRITABLE?o.writableIndices.push(n.addressIndex):o.readableIndices.push(n.addressIndex);}return Object.keys(r).sort(P()).map(n=>({lookupTableAddress:n,...r[n]}))}function ue(e){let r=0,t=0,n=0;for(let o of e){if("lookupTableAddress"in o)break;let i=w(o.role);I(o.role)?(n++,i||t++):i||r++;}return {numReadonlyNonSignerAccounts:r,numReadonlySignerAccounts:t,numSignerAccounts:n}}function Me(e){let r={};for(let[t,n]of e.entries())r[n.address]=t;return r}function pe(e,r){let t=Me(r);return e.map(({accounts:n,data:o,programAddress:i})=>({programAddressIndex:t[i],...n?{accountIndices:n.map(({address:s})=>t[s])}:null,...o?{data:o}:null}))}function me(e){return "nonce"in e?e.nonce:e.blockhash}function fe(e){let r=e.findIndex(n=>"lookupTableAddress"in n);return (r===-1?e:e.slice(0,r)).map(({address:n})=>n)}function K(e){let r=ce(e.feePayer,e.instructions),t=de(r);return {...e.version!=="legacy"?{addressTableLookups:le(t)}:null,header:ue(t),instructions:pe(e.instructions,t),lifetimeToken:me(e.lifetimeConstraint),staticAccounts:fe(t),version:e.version}}function ge(){return T([["lookupTableAddress",O(void 0)],["writableIndices",y(b(),{size:m()})],["readableIndices",y(b(),{size:m()})]],void 0)}function ye(){return T([["numSignerAccounts",b(void 0)],["numReadonlySignerAccounts",b(void 0)],["numReadonlyNonSignerAccounts",b(void 0)]],void 0)}function Te(){return k(T([["programAddressIndex",b(void 0)],["addressIndices",y(b({description:""}),{description:"",size:m()})],["data",R({description:"",size:m()})]]),e=>e.addressIndices!==void 0&&e.data!==void 0?e:{...e,addressIndices:e.addressIndices??[],data:e.data??new Uint8Array(0)},e=>{if(e.addressIndices.length&&e.data.byteLength)return e;let{addressIndices:r,data:t,...n}=e;return {...n,...r.length?{addressIndices:r}:null,...t.byteLength?{data:t}:null}})}function Re(e,r){let t=r+e[0].toUpperCase()+e.slice(1);return new Error(`No ${e} exists for ${r}. Use \`get${t}()\` if you need a ${e}, and \`get${r}Codec()\` if you need to both encode and decode ${r}`)}function Y(e){return ()=>{throw Re("decoder",e)}}var J=128,Le={description:"",fixedSize:null,maxSize:1};function Oe(e,r=0){let t=e[r];return t&J?[t^J,r+1]:["legacy",r]}function Pe(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|J])}function he(){return {...Le,deserialize:Oe,serialize:Pe}}var ve={description:"",fixedSize:null,maxSize:null};function De(e){return e.version==="legacy"?T(be()).serialize(e):k(T([...be(),["addressTableLookups",Ve()]]),r=>r.version==="legacy"?r:{...r,addressTableLookups:r.addressTableLookups??[]}).serialize(e)}function be(){return [["version",he()],["header",ye()],["staticAccounts",y(O(),{description:"",size:m()})],["lifetimeToken",L({description:"",encoding:S,size:32})],["instructions",y(Te(),{description:"",size:m()})]]}function Ve(){return y(ge(),{size:m()})}function j(){return {...ve,deserialize:Y("CompiledMessage"),serialize:De}}async function Ne(e,r){let t=j().serialize(e);return await se(r,t)}async function bo(e,r){let t=K(r),[n,o]=await Promise.all([ie(e.publicKey),Ne(t,e.privateKey)]),i={..."signatures"in r?r.signatures:null,[n]:o},s={...r,signatures:i};return Object.freeze(s),s}function Ae(e){let r=K(e),t;if("signatures"in e){t=[];for(let n=0;n<r.header.numSignerAccounts;n++)t[n]=e.signatures[r.staticAccounts[n]]??new Uint8Array(Array(64).fill(0));}else t=Array(r.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));return {compiledMessage:r,signatures:t}}var We={description:"",fixedSize:null,maxSize:null};function $e(e){let r=Ae(e);return T([["signatures",y(R({size:64}),{size:m()})],["compiledMessage",j()]]).serialize(r)}function Ee(){return {...We,deserialize:Y("CompiledMessage"),serialize:$e}}function Oo(e){let r=Ee().serialize(e);return btoa(String.fromCharCode(...r))}
var xe=Object.defineProperty;var Se=(e,r,t)=>r in e?xe(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var g=(e,r,t)=>(Se(e,typeof r!="symbol"?r+"":r,t),t);var E=e=>{let r=e.reduce((o,i)=>o+i.length,0),t=new Uint8Array(r),n=0;return e.forEach(o=>{t.set(o,n),n+=o.length;}),t},Q=(e,r)=>{if(e.length>=r)return e;let t=new Uint8Array(r).fill(0);return t.set(e),t},W=(e,r)=>Q(e.slice(0,r),r);var x=class extends Error{constructor(t){super(`Serializer [${t}] cannot deserialize empty buffers.`);g(this,"name","DeserializingEmptyBufferError");}},h=class extends Error{constructor(t,n,o){super(`Serializer [${t}] expected ${n} bytes, got ${o}.`);g(this,"name","NotEnoughBytesError");}},S=class extends Error{constructor(t){t??(t="Expected a fixed-size serializer, got a variable-size one.");super(t);g(this,"name","ExpectedFixedSizeSerializerError");}};function k(e,r,t){return {description:t??`fixed(${r}, ${e.description})`,fixedSize:r,maxSize:r,serialize:n=>W(e.serialize(n),r),deserialize:(n,o=0)=>{if(n=n.slice(o,o+r),n.length<r)throw new h("fixSerializer",r,n.length);e.fixedSize!==null&&(n=W(n,e.fixedSize));let[i]=e.deserialize(n,0);return [i,o+r]}}}function R(e,r,t){return {description:e.description,fixedSize:e.fixedSize,maxSize:e.maxSize,serialize:n=>e.serialize(r(n)),deserialize:(n,o=0)=>{let[i,s]=e.deserialize(n,o);return t?[t(i,n,o),s]:[i,s]}}}var v=class extends Error{constructor(t,n,o){let i=`Expected a string of base ${n}, got [${t}].`;super(i);g(this,"name","InvalidBaseStringError");this.cause=o;}};var ee=e=>{let r=e.length,t=BigInt(r);return {description:`base${r}`,fixedSize:null,maxSize:null,serialize(n){if(!n.match(new RegExp(`^[${e}]*$`)))throw new v(n,r);if(n==="")return new Uint8Array;let o=[...n],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),l=0n,d=1n;for(let f=c.length-1;f>=0;f-=1)l+=d*BigInt(e.indexOf(c[f])),d*=t;let u=[];for(;l>0n;)u.unshift(Number(l%256n)),l/=256n;return Uint8Array.from(s.concat(u))},deserialize(n,o=0){if(n.length===0)return ["",0];let i=n.slice(o),s=i.findIndex(u=>u!==0);s=s===-1?i.length:s;let c=e[0].repeat(s);if(s===i.length)return [c,n.length];let l=i.slice(s).reduce((u,f)=>u*256n+BigInt(f),0n),d=[];for(;l>0n;)d.unshift(e[Number(l%t)]),l/=t;return [c+d.join(""),n.length]}}};var I=ee("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");var re=e=>e.replace(/\u0000/g,"");var G={description:"utf8",fixedSize:null,maxSize:null,serialize(e){return new TextEncoder().encode(e)},deserialize(e,r=0){let t=new TextDecoder().decode(e.slice(r));return [re(t),e.length]}};var P;(function(e){e.Little="le",e.Big="be";})(P||(P={}));var V=class extends RangeError{constructor(t,n,o,i){super(`Serializer [${t}] expected number to be between ${n} and ${o}, got ${i}.`);g(this,"name","NumberOutOfRangeError");}};function U(e){let r,t=e.name;return e.size>1&&(r=!("endian"in e.options)||e.options.endian===P.Little,t+=r?"(le)":"(be)"),{description:e.options.description??t,fixedSize:e.size,maxSize:e.size,serialize(n){e.range&&q(e.name,e.range[0],e.range[1],n);let o=new ArrayBuffer(e.size);return e.set(new DataView(o),n,r),new Uint8Array(o)},deserialize(n,o=0){let i=n.slice(o,o+e.size);we("i8",i,e.size);let s=ze(i);return [e.get(s,r),o+e.size]}}}var Ie=e=>e.buffer.slice(e.byteOffset,e.byteLength+e.byteOffset),ze=e=>new DataView(Ie(e)),q=(e,r,t,n)=>{if(n<r||n>t)throw new V(e,r,t,n)},we=(e,r,t)=>{if(r.length===0)throw new x(e);if(r.length<t)throw new h(e,t,r.length)};var A=(e={})=>U({name:"u8",size:1,range:[0,+"0xff"],set:(r,t)=>r.setUint8(0,Number(t)),get:r=>r.getUint8(0),options:e});var L=(e={})=>U({name:"u32",size:4,range:[0,+"0xffffffff"],set:(r,t,n)=>r.setUint32(0,Number(t),n),get:(r,t)=>r.getUint32(0,t),options:e});var m=(e={})=>({description:e.description??"shortU16",fixedSize:null,maxSize:3,serialize:r=>{q("shortU16",0,65535,r);let t=[0];for(let n=0;;n+=1){let o=r>>n*7;if(o===0)break;let i=127&o;t[n]=i,n>0&&(t[n-1]|=128);}return new Uint8Array(t)},deserialize:(r,t=0)=>{let n=0,o=0;for(;++o;){let i=o-1,s=r[t+i],c=127&s;if(n|=c<<i*7,!(s&128))break}return [n,t+o]}});var $=class extends Error{constructor(t,n,o){super(`Expected [${t}] to have ${n} items, got ${o}.`);g(this,"name","InvalidNumberOfItemsError");}},F=class extends Error{constructor(t,n){super(`The remainder of the buffer (${t} bytes) cannot be split into chunks of ${n} bytes. Serializers of "remainder" size must have a remainder that is a multiple of its item size. In other words, ${t} modulo ${n} should be equal to zero.`);g(this,"name","InvalidArrayLikeRemainderSizeError");}},K=class extends Error{constructor(t){super(`Unrecognized array-like serializer size: ${JSON.stringify(t)}`);g(this,"name","UnrecognizedArrayLikeSerializerSizeError");}};function C(e){return e.reduce((r,t)=>r===null||t===null?null:r+t,0)}function te(e,r,t,n){if(typeof e=="number")return [e,n];if(typeof e=="object")return e.deserialize(t,n);if(e==="remainder"){let o=C(r);if(o===null)throw new S('Serializers of "remainder" size must have fixed-size items.');let i=t.slice(n).length;if(i%o!==0)throw new F(i,o);return [i/o,n]}throw new K(e)}function _(e){return typeof e=="object"?e.description:`${e}`}function X(e,r){if(typeof e!="number")return null;if(e===0)return 0;let t=C(r);return t===null?null:t*e}function ne(e,r){return typeof e=="object"?e.serialize(r):new Uint8Array}function T(e,r={}){let t=r.size??L();if(t==="remainder"&&e.fixedSize===null)throw new S('Serializers of "remainder" size must have fixed-size items.');return {description:r.description??`array(${e.description}; ${_(t)})`,fixedSize:X(t,[e.fixedSize]),maxSize:X(t,[e.maxSize]),serialize:n=>{if(typeof t=="number"&&n.length!==t)throw new $("array",t,n.length);return E([ne(t,n.length),...n.map(o=>e.serialize(o))])},deserialize:(n,o=0)=>{if(typeof t=="object"&&n.slice(o).length===0)return [[],o];let[i,s]=te(t,[e.fixedSize],n,o);o=s;let c=[];for(let l=0;l<i;l+=1){let[d,u]=e.deserialize(n,o);c.push(d),o=u;}return [c,o]}}}function N(e={}){let r=e.size??"variable",t=e.description??`bytes(${_(r)})`,n={description:t,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"?n:typeof r=="number"?k(n,r,t):{description:t,fixedSize:null,maxSize:null,serialize:o=>{let i=n.serialize(o),s=r.serialize(i.length);return E([s,i])},deserialize:(o,i=0)=>{if(o.slice(i).length===0)throw new x("bytes");let[s,c]=r.deserialize(o,i),l=Number(s);i=c;let d=o.slice(i,i+l);if(d.length<l)throw new h("bytes",l,d.length);let[u,f]=n.deserialize(d);return i+=f,[u,i]}}}function M(e={}){let r=e.size??L(),t=e.encoding??G,n=e.description??`string(${t.description}; ${_(r)})`;return r==="variable"?{...t,description:n}:typeof r=="number"?k(t,r,n):{description:n,fixedSize:null,maxSize:null,serialize:o=>{let i=t.serialize(o),s=r.serialize(i.length);return E([s,i])},deserialize:(o,i=0)=>{if(o.slice(i).length===0)throw new x("string");let[s,c]=r.deserialize(o,i),l=Number(s);i=c;let d=o.slice(i,i+l);if(d.length<l)throw new h("string",l,d.length);let[u,f]=t.deserialize(d);return i+=f,[u,i]}}}function y(e,r={}){let t=e.map(([n,o])=>`${String(n)}: ${o.description}`).join(", ");return {description:r.description??`struct(${t})`,fixedSize:C(e.map(([,n])=>n.fixedSize)),maxSize:C(e.map(([,n])=>n.maxSize)),serialize:n=>{let o=e.map(([i,s])=>s.serialize(n[i]));return E(o)},deserialize:(n,o=0)=>{let i={};return e.forEach(([s,c])=>{let[l,d]=c.deserialize(n,o);o=d,i[s]=l;}),[i,o]}}}function z(e){if("signatures"in e){let{signatures:r,...t}=e;return t}else return e}function Ft(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=I.serialize(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 blockhash`,{cause:r})}}function Kt(e,r){if("lifetimeConstraint"in r&&r.lifetimeConstraint.blockhash===e.blockhash&&r.lifetimeConstraint.lastValidBlockHeight===e.lastValidBlockHeight)return r;let t={...z(r),lifetimeConstraint:e};return Object.freeze(t),t}function jt({version:e}){let r={instructions:[],version:e};return Object.freeze(r),r}var b=(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))(b||{});var Be=1;function w(e){return e>=2}function B(e){return (e&Be)!==0}function J(e,r){return e|r}var Ce="SysvarRecentB1ockHashes11111111111111111111",_e="11111111111111111111111111111111";function tn(e){if(!Le(e))throw new Error("Transaction is not a durable nonce transaction")}function ke(e){return e.programAddress===_e&&e.data!=null&&Re(e.data)&&e.accounts?.length===3&&e.accounts[0].address!=null&&e.accounts[0].role===b.WRITABLE&&e.accounts[1].address===Ce&&e.accounts[1].role===b.READONLY&&e.accounts[2].address!=null&&e.accounts[2].role===b.READONLY_SIGNER}function Re(e){return e.byteLength===4&&e[0]===4&&e[1]===0&&e[2]===0&&e[3]===0}function Le(e){return "lifetimeConstraint"in e&&typeof e.lifetimeConstraint.nonce=="string"&&e.instructions[0]!=null&&ke(e.instructions[0])}function an(e,r){if("feePayer"in r&&e===r.feePayer)return r;let t={...z(r),feePayer:e};return Object.freeze(t),t}function un(e,r){let t={...z(r),instructions:[...r.instructions,e]};return Object.freeze(t),t}function pn(e,r){let t={...z(r),instructions:[e,...r.instructions]};return Object.freeze(t),t}function O(e){return M({description:e?.description??(""),encoding:I,size:32})}function D(){return new Intl.Collator("en",{caseFirst:"lower",ignorePunctuation:!1,localeMatcher:"best fit",numeric:!1,sensitivity:"variant",usage:"sort"}).compare}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 Me(){if(oe(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.exportKey!="function")throw new Error("No key export implementation could be found")}async function Oe(){if(oe(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.sign!="function")throw new Error("No signing implementation could be found")}async function ie(e){if(await Me(),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),[t]=O().deserialize(new Uint8Array(r));return t}async function se(e,r){await Oe();let t=await crypto.subtle.sign("Ed25519",e,r);return new Uint8Array(t)}function ae(e,r,t){e[r]=t(e[r]??{role:b.READONLY});}var p=Symbol("AddressMapTypeProperty");function ce(e,r){let t={[e]:{[p]:0,role:b.WRITABLE_SIGNER}},n=new Set;for(let o of r){ae(t,o.programAddress,s=>{if(n.add(o.programAddress),p in s){if(B(s.role))switch(s[p]){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[p]===2)return s}return {[p]:2,role:b.READONLY}});let i;if(o.accounts)for(let s of o.accounts)ae(t,s.address,c=>{let{address:l,...d}=s;if(p in c)switch(c[p]){case 0:return c;case 1:{let u=J(c.role,d.role);if("lookupTableAddress"in d){if(c.lookupTableAddress!==d.lookupTableAddress&&(i||(i=D()))(d.lookupTableAddress,c.lookupTableAddress)<0)return {[p]:1,...d,role:u}}else if(w(d.role))return {[p]:2,role:u};return c.role!==u?{...c,role:u}:c}case 2:{let u=J(c.role,d.role);if(n.has(s.address)){if(B(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!==u?{...c,role:u}:c}else return "lookupTableAddress"in d&&!w(c.role)?{...d,[p]:1,role:u}:c.role!==u?{...c,role:u}:c}}return "lookupTableAddress"in d?{...d,[p]:1}:{...d,[p]:2}});}return t}function de(e){let r;return Object.entries(e).sort(([n,o],[i,s])=>{if(o[p]!==s[p]){if(o[p]===0)return -1;if(s[p]===0)return 1;if(o[p]===2)return -1;if(s[p]===2)return 1}let c=w(o.role);if(c!==w(s.role))return c?-1:1;let l=B(o.role);return l!==B(s.role)?l?-1:1:(r||(r=D()),o[p]===1&&s[p]===1&&o.lookupTableAddress!==s.lookupTableAddress?r(o.lookupTableAddress,s.lookupTableAddress):r(n,i))}).map(([n,o])=>({address:n,...o}))}function le(e){var t;let r={};for(let n of e){if(!("lookupTableAddress"in n))continue;let o=r[t=n.lookupTableAddress]||(r[t]={readableIndices:[],writableIndices:[]});n.role===b.WRITABLE?o.writableIndices.push(n.addressIndex):o.readableIndices.push(n.addressIndex);}return Object.keys(r).sort(D()).map(n=>({lookupTableAddress:n,...r[n]}))}function ue(e){let r=0,t=0,n=0;for(let o of e){if("lookupTableAddress"in o)break;let i=B(o.role);w(o.role)?(n++,i||t++):i||r++;}return {numReadonlyNonSignerAccounts:r,numReadonlySignerAccounts:t,numSignerAccounts:n}}function De(e){let r={};for(let[t,n]of e.entries())r[n.address]=t;return r}function pe(e,r){let t=De(r);return e.map(({accounts:n,data:o,programAddress:i})=>({programAddressIndex:t[i],...n?{accountIndices:n.map(({address:s})=>t[s])}:null,...o?{data:o}:null}))}function me(e){return "nonce"in e?e.nonce:e.blockhash}function fe(e){let r=e.findIndex(n=>"lookupTableAddress"in n);return (r===-1?e:e.slice(0,r)).map(({address:n})=>n)}function Y(e){let r=ce(e.feePayer,e.instructions),t=de(r);return {...e.version!=="legacy"?{addressTableLookups:le(t)}:null,header:ue(t),instructions:pe(e.instructions,t),lifetimeToken:me(e.lifetimeConstraint),staticAccounts:fe(t),version:e.version}}function ge(){return y([["lookupTableAddress",O(void 0)],["writableIndices",T(A(),{size:m()})],["readableIndices",T(A(),{size:m()})]],void 0)}function Te(){return y([["numSignerAccounts",A(void 0)],["numReadonlySignerAccounts",A(void 0)],["numReadonlyNonSignerAccounts",A(void 0)]],void 0)}function ye(){return R(y([["programAddressIndex",A(void 0)],["addressIndices",T(A({description:""}),{description:"",size:m()})],["data",N({description:"",size:m()})]]),e=>e.addressIndices!==void 0&&e.data!==void 0?e:{...e,addressIndices:e.addressIndices??[],data:e.data??new Uint8Array(0)},e=>{if(e.addressIndices.length&&e.data.byteLength)return e;let{addressIndices:r,data:t,...n}=e;return {...n,...r.length?{addressIndices:r}:null,...t.byteLength?{data:t}:null}})}function We(e,r){let t=r+e[0].toUpperCase()+e.slice(1);return new Error(`No ${e} exists for ${r}. Use \`get${t}()\` if you need a ${e}, and \`get${r}Codec()\` if you need to both encode and decode ${r}`)}function H(e){return ()=>{throw We("decoder",e)}}var Z=128,ve={description:"",fixedSize:null,maxSize:1};function Pe(e,r=0){let t=e[r];return t&Z?[t^Z,r+1]:["legacy",r]}function Ve(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|Z])}function he(){return {...ve,deserialize:Pe,serialize:Ve}}var Ue={description:"",fixedSize:null,maxSize:null};function $e(e){return e.version==="legacy"?y(Ae()).serialize(e):R(y([...Ae(),["addressTableLookups",Fe()]]),r=>r.version==="legacy"?r:{...r,addressTableLookups:r.addressTableLookups??[]}).serialize(e)}function Ae(){return [["version",he()],["header",Te()],["staticAccounts",T(O(),{description:"",size:m()})],["lifetimeToken",M({description:"",encoding:I,size:32})],["instructions",T(ye(),{description:"",size:m()})]]}function Fe(){return T(ge(),{size:m()})}function j(){return {...Ue,deserialize:H("CompiledMessage"),serialize:$e}}async function Ke(e,r){let t=j().serialize(e);return await se(r,t)}async function Wo(e,r){let t=Y(r),[n,o]=await Promise.all([ie(e.publicKey),Ke(t,e.privateKey)]),i={..."signatures"in r?r.signatures:null,[n]:o},s={...r,signatures:i};return Object.freeze(s),s}function be(e){let r=Y(e),t;if("signatures"in e){t=[];for(let n=0;n<r.header.numSignerAccounts;n++)t[n]=e.signatures[r.staticAccounts[n]]??new Uint8Array(Array(64).fill(0));}else t=Array(r.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));return {compiledMessage:r,signatures:t}}var Ye={description:"",fixedSize:null,maxSize:null};function He(e){let r=be(e);return y([["signatures",T(N({size:64}),{size:m()})],["compiledMessage",j()]]).serialize(r)}function Ee(){return {...Ye,deserialize:H("CompiledMessage"),serialize:He}}function Zo(e){let r=Ee().serialize(e);return btoa(String.fromCharCode(...r))}
exports.appendTransactionInstruction = Kt;
exports.assertIsBlockhash = Pt;
exports.createTransaction = Vt;
exports.getBase64EncodedWireTransaction = Oo;
exports.prependTransactionInstruction = Yt;
exports.setTransactionFeePayer = $t;
exports.signTransaction = bo;
exports.appendTransactionInstruction = un;
exports.assertIsBlockhash = Ft;
exports.assertIsDurableNonceTransaction = tn;
exports.createTransaction = jt;
exports.getBase64EncodedWireTransaction = Zo;
exports.prependTransactionInstruction = pn;
exports.setTransactionFeePayer = an;
exports.setTransactionLifetimeUsingBlockhash = Kt;
exports.signTransaction = Wo;

@@ -16,0 +18,0 @@ return exports;

@@ -0,1 +1,4 @@

import { IDurableNonceTransaction } from './durable-nonce';
import { ITransactionWithSignatures } from './signatures';
import { BaseTransaction } from './types';
export type Blockhash = string & {

@@ -12,3 +15,5 @@ readonly __blockhash: unique symbol;

export declare function assertIsBlockhash(putativeBlockhash: string): asserts putativeBlockhash is Blockhash;
export declare function setTransactionLifetimeUsingBlockhash<TTransaction extends BaseTransaction & IDurableNonceTransaction>(blockhashLifetimeConstraint: BlockhashLifetimeConstraint, transaction: TTransaction | (TTransaction & ITransactionWithSignatures)): Omit<TTransaction, keyof ITransactionWithSignatures | 'lifetimeConstraint'> & ITransactionWithBlockhashLifetime;
export declare function setTransactionLifetimeUsingBlockhash<TTransaction extends BaseTransaction | (BaseTransaction & ITransactionWithBlockhashLifetime)>(blockhashLifetimeConstraint: BlockhashLifetimeConstraint, transaction: TTransaction | (TTransaction & ITransactionWithSignatures)): Omit<TTransaction, keyof ITransactionWithSignatures> & ITransactionWithBlockhashLifetime;
export {};
//# sourceMappingURL=blockhash.d.ts.map
import { IInstruction, IInstructionWithAccounts, IInstructionWithData } from '@solana/instructions';
import { ReadonlyAccount, ReadonlySignerAccount, WritableAccount } from '@solana/instructions/dist/types/accounts';
type AdvanceNonceAccountInstruction<TNonceAccountAddress extends string = string, TNonceAuthorityAddress extends string = string> = IInstruction<'11111111111111111111111111111111'> & IInstructionWithAccounts<[
import { BaseTransaction } from './types';
type AdvanceNonceAccountInstruction<TNonceAccountAddress extends string = string, TNonceAuthorityAddress extends string = string> = IInstruction<'11111111111111111111111111111111'> & IInstructionWithAccounts<readonly [
WritableAccount<TNonceAccountAddress>,

@@ -11,13 +12,17 @@ ReadonlyAccount<'SysvarRecentB1ockHashes11111111111111111111'>,

};
type NonceLifetimeConstraint = Readonly<{
nonce: string;
export type Nonce<TNonceValue extends string = string> = TNonceValue & {
readonly __nonce: unique symbol;
};
type NonceLifetimeConstraint<TNonceValue extends string = string> = Readonly<{
nonce: Nonce<TNonceValue>;
}>;
export interface IDurableNonceTransaction<TNonceAccountAddress extends string = string, TNonceAuthorityAddress extends string = string> {
readonly instructions: [
export interface IDurableNonceTransaction<TNonceAccountAddress extends string = string, TNonceAuthorityAddress extends string = string, TNonceValue extends string = string> {
readonly instructions: readonly [
AdvanceNonceAccountInstruction<TNonceAccountAddress, TNonceAuthorityAddress>,
...IInstruction[]
];
readonly lifetimeConstraint: NonceLifetimeConstraint;
readonly lifetimeConstraint: NonceLifetimeConstraint<TNonceValue>;
}
export declare function assertIsDurableNonceTransaction(transaction: BaseTransaction | (BaseTransaction & IDurableNonceTransaction)): asserts transaction is BaseTransaction & IDurableNonceTransaction;
export {};
//# sourceMappingURL=durable-nonce.d.ts.map

@@ -7,7 +7,5 @@ import { Base58EncodedAddress, Ed25519Signature } from '@solana/keys';

export interface ITransactionWithSignatures {
readonly signatures: {
readonly [publicKey: Base58EncodedAddress]: Ed25519Signature;
};
readonly signatures: Readonly<Record<Base58EncodedAddress, Ed25519Signature>>;
}
export declare function signTransaction<TTransaction extends Parameters<typeof compileMessage>[0]>(keyPair: CryptoKeyPair, transaction: TTransaction | (TTransaction & ITransactionWithSignatures)): Promise<TTransaction & ITransactionWithSignatures>;
//# sourceMappingURL=signatures.d.ts.map
{
"name": "@solana/transactions",
"version": "2.0.0-experimental.c2d0ddc",
"version": "2.0.0-experimental.c5061ae",
"description": "Helpers for creating and serializing transactions",

@@ -50,3 +50,3 @@ "exports": {

"@metaplex-foundation/umi-serializers": "^0.8.5",
"@solana/keys": "2.0.0-experimental.c2d0ddc"
"@solana/keys": "2.0.0-experimental.c5061ae"
},

@@ -57,3 +57,3 @@ "devDependencies": {

"@swc/jest": "^0.2.23",
"@types/jest": "^29.5.2",
"@types/jest": "^29.5.3",
"@typescript-eslint/eslint-plugin": "^6.0.0",

@@ -73,3 +73,3 @@ "@typescript-eslint/parser": "^6.0.0",

"version-from-git": "^1.1.1",
"@solana/instructions": "2.0.0-experimental.c2d0ddc",
"@solana/instructions": "2.0.0-experimental.c5061ae",
"build-scripts": "0.0.0",

@@ -76,0 +76,0 @@ "test-config": "0.0.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc