Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@solana/signers

Package Overview
Dependencies
Maintainers
14
Versions
1049
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solana/signers - npm Package Compare versions

Comparing version 2.0.0-experimental.af584fc to 2.0.0-experimental.d085c72

dist/types/account-signer-meta.d.ts.map

48

dist/index.browser.js

@@ -0,1 +1,2 @@

import { isSignerRole } from '@solana/instructions';
import { getAddressFromPublicKey, isAddress } from '@solana/addresses';

@@ -11,2 +12,6 @@ import { generateKeyPair, signBytes } from '@solana/keys';

deduplicated[signer.address] = signer;
} else if (deduplicated[signer.address] !== signer) {
throw new Error(
`Multiple distinct signers were identified for address "${signer.address}". Please ensure that you are using the same signer instance for each address.`
);
}

@@ -26,2 +31,27 @@ });

}
function addSignersToInstruction(signers, instruction) {
if (!instruction.accounts || instruction.accounts.length === 0) {
return instruction;
}
const signerByAddress = new Map(deduplicateSigners(signers).map((signer) => [signer.address, signer]));
return Object.freeze({
...instruction,
accounts: instruction.accounts.map((account) => {
const signer = signerByAddress.get(account.address);
if (!isSignerRole(account.role) || "signer" in account || !signer) {
return account;
}
return Object.freeze({ ...account, signer });
})
});
}
function addSignersToTransaction(signers, transaction) {
if (transaction.instructions.length === 0) {
return transaction;
}
return Object.freeze({
...transaction,
instructions: transaction.instructions.map((instruction) => addSignersToInstruction(signers, instruction))
});
}

@@ -98,2 +128,12 @@ // src/message-partial-signer.ts

// src/noop-signer.ts
function createNoopSigner(address) {
const out = {
address,
signMessages: async (messages) => messages.map(() => Object.freeze({})),
signTransactions: async (transactions) => transactions.map(() => Object.freeze({}))
};
return Object.freeze(out);
}
// src/transaction-modifying-signer.ts

@@ -131,5 +171,4 @@ function isTransactionModifyingSigner(value) {

async function partiallySignTransactionWithSigners(transaction, config = {}) {
const signers = config.signers ?? [];
const { partialSigners, modifyingSigners } = categorizeTransactionSigners(
deduplicateSigners([...getSignersFromTransaction(transaction).filter(isTransactionSigner), ...signers]),
deduplicateSigners(getSignersFromTransaction(transaction).filter(isTransactionSigner)),
{ identifySendingSigner: false }

@@ -145,6 +184,5 @@ );

async function signAndSendTransactionWithSigners(transaction, config = {}) {
const signers = config.signers ?? [];
const abortSignal = config.abortSignal;
const { partialSigners, modifyingSigners, sendingSigner } = categorizeTransactionSigners(
deduplicateSigners([...getSignersFromTransaction(transaction).filter(isTransactionSigner), ...signers])
deduplicateSigners(getSignersFromTransaction(transaction).filter(isTransactionSigner))
);

@@ -233,4 +271,4 @@ abortSignal?.throwIfAborted();

export { assertIsKeyPairSigner, assertIsMessageModifyingSigner, assertIsMessagePartialSigner, assertIsMessageSigner, assertIsTransactionModifyingSigner, assertIsTransactionPartialSigner, assertIsTransactionSendingSigner, assertIsTransactionSigner, createSignableMessage, createSignerFromKeyPair, generateKeyPairSigner, getSignersFromInstruction, getSignersFromTransaction, isKeyPairSigner, isMessageModifyingSigner, isMessagePartialSigner, isMessageSigner, isTransactionModifyingSigner, isTransactionPartialSigner, isTransactionSendingSigner, isTransactionSigner, partiallySignTransactionWithSigners, signAndSendTransactionWithSigners, signTransactionWithSigners };
export { addSignersToInstruction, addSignersToTransaction, assertIsKeyPairSigner, assertIsMessageModifyingSigner, assertIsMessagePartialSigner, assertIsMessageSigner, assertIsTransactionModifyingSigner, assertIsTransactionPartialSigner, assertIsTransactionSendingSigner, assertIsTransactionSigner, createNoopSigner, createSignableMessage, createSignerFromKeyPair, generateKeyPairSigner, getSignersFromInstruction, getSignersFromTransaction, isKeyPairSigner, isMessageModifyingSigner, isMessagePartialSigner, isMessageSigner, isTransactionModifyingSigner, isTransactionPartialSigner, isTransactionSendingSigner, isTransactionSigner, partiallySignTransactionWithSigners, signAndSendTransactionWithSigners, signTransactionWithSigners };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.browser.js.map

@@ -11,2 +11,6 @@ this.globalThis = this.globalThis || {};

deduplicated[signer.address] = signer;
} else if (deduplicated[signer.address] !== signer) {
throw new Error(
`Multiple distinct signers were identified for address "${signer.address}". Please ensure that you are using the same signer instance for each address.`
);
}

@@ -28,2 +32,34 @@ });

// ../instructions/dist/index.browser.js
function isSignerRole(role) {
return role >= 2;
}
// src/add-signers.ts
function addSignersToInstruction(signers, instruction) {
if (!instruction.accounts || instruction.accounts.length === 0) {
return instruction;
}
const signerByAddress = new Map(deduplicateSigners(signers).map((signer) => [signer.address, signer]));
return Object.freeze({
...instruction,
accounts: instruction.accounts.map((account) => {
const signer = signerByAddress.get(account.address);
if (!isSignerRole(account.role) || "signer" in account || !signer) {
return account;
}
return Object.freeze({ ...account, signer });
})
});
}
function addSignersToTransaction(signers, transaction) {
if (transaction.instructions.length === 0) {
return transaction;
}
return Object.freeze({
...transaction,
instructions: transaction.instructions.map((instruction) => addSignersToInstruction(signers, instruction))
});
}
// ../codecs-core/dist/index.browser.js

@@ -628,3 +664,3 @@ function assertByteArrayIsNotEmptyForCodec(codecDescription, bytes, offset = 0) {

var IS_WRITABLE_BITMASK = 1;
function isSignerRole(role) {
function isSignerRole2(role) {
return role >= 2;

@@ -703,3 +739,3 @@ }

}
} else if (isSignerRole(accountMeta.role)) {
} else if (isSignerRole2(accountMeta.role)) {
return {

@@ -741,3 +777,3 @@ [TYPE]: 2,

// long as they are not require to sign the transaction.
!isSignerRole(entry.role)) {
!isSignerRole2(entry.role)) {
return {

@@ -793,4 +829,4 @@ ...accountMeta,

}
const leftIsSigner = isSignerRole(leftEntry.role);
if (leftIsSigner !== isSignerRole(rightEntry.role)) {
const leftIsSigner = isSignerRole2(leftEntry.role);
if (leftIsSigner !== isSignerRole2(rightEntry.role)) {
return leftIsSigner ? -1 : 1;

@@ -845,3 +881,3 @@ }

const accountIsWritable = isWritableRole(account.role);
if (isSignerRole(account.role)) {
if (isSignerRole2(account.role)) {
numSignerAccounts++;

@@ -1112,3 +1148,3 @@ if (!accountIsWritable) {

var _a, _b;
return (_b = (_a = i.accounts) == null ? void 0 : _a.filter((a) => isSignerRole(a.role))) != null ? _b : [];
return (_b = (_a = i.accounts) == null ? void 0 : _a.filter((a) => isSignerRole2(a.role))) != null ? _b : [];
}).map((a) => a.address);

@@ -1195,2 +1231,12 @@ const requiredSigners = /* @__PURE__ */ new Set([transaction.feePayer, ...signerAddressesFromInstructions]);

// src/noop-signer.ts
function createNoopSigner(address2) {
const out = {
address: address2,
signMessages: async (messages) => messages.map(() => Object.freeze({})),
signTransactions: async (transactions) => transactions.map(() => Object.freeze({}))
};
return Object.freeze(out);
}
// src/transaction-modifying-signer.ts

@@ -1228,6 +1274,4 @@ function isTransactionModifyingSigner(value) {

async function partiallySignTransactionWithSigners(transaction, config = {}) {
var _a;
const signers = (_a = config.signers) != null ? _a : [];
const { partialSigners, modifyingSigners } = categorizeTransactionSigners(
deduplicateSigners([...getSignersFromTransaction(transaction).filter(isTransactionSigner), ...signers]),
deduplicateSigners(getSignersFromTransaction(transaction).filter(isTransactionSigner)),
{ identifySendingSigner: false }

@@ -1243,7 +1287,5 @@ );

async function signAndSendTransactionWithSigners(transaction, config = {}) {
var _a;
const signers = (_a = config.signers) != null ? _a : [];
const abortSignal = config.abortSignal;
const { partialSigners, modifyingSigners, sendingSigner } = categorizeTransactionSigners(
deduplicateSigners([...getSignersFromTransaction(transaction).filter(isTransactionSigner), ...signers])
deduplicateSigners(getSignersFromTransaction(transaction).filter(isTransactionSigner))
);

@@ -1334,2 +1376,4 @@ abortSignal == null ? void 0 : abortSignal.throwIfAborted();

exports.addSignersToInstruction = addSignersToInstruction;
exports.addSignersToTransaction = addSignersToTransaction;
exports.assertIsKeyPairSigner = assertIsKeyPairSigner;

@@ -1343,2 +1387,3 @@ exports.assertIsMessageModifyingSigner = assertIsMessageModifyingSigner;

exports.assertIsTransactionSigner = assertIsTransactionSigner;
exports.createNoopSigner = createNoopSigner;
exports.createSignableMessage = createSignableMessage;

@@ -1345,0 +1390,0 @@ exports.createSignerFromKeyPair = createSignerFromKeyPair;

@@ -0,1 +1,2 @@

import { isSignerRole } from '@solana/instructions';
import { getAddressFromPublicKey, isAddress } from '@solana/addresses';

@@ -11,2 +12,6 @@ import { generateKeyPair, signBytes } from '@solana/keys';

deduplicated[signer.address] = signer;
} else if (deduplicated[signer.address] !== signer) {
throw new Error(
`Multiple distinct signers were identified for address "${signer.address}". Please ensure that you are using the same signer instance for each address.`
);
}

@@ -26,2 +31,27 @@ });

}
function addSignersToInstruction(signers, instruction) {
if (!instruction.accounts || instruction.accounts.length === 0) {
return instruction;
}
const signerByAddress = new Map(deduplicateSigners(signers).map((signer) => [signer.address, signer]));
return Object.freeze({
...instruction,
accounts: instruction.accounts.map((account) => {
const signer = signerByAddress.get(account.address);
if (!isSignerRole(account.role) || "signer" in account || !signer) {
return account;
}
return Object.freeze({ ...account, signer });
})
});
}
function addSignersToTransaction(signers, transaction) {
if (transaction.instructions.length === 0) {
return transaction;
}
return Object.freeze({
...transaction,
instructions: transaction.instructions.map((instruction) => addSignersToInstruction(signers, instruction))
});
}

@@ -98,2 +128,12 @@ // src/message-partial-signer.ts

// src/noop-signer.ts
function createNoopSigner(address) {
const out = {
address,
signMessages: async (messages) => messages.map(() => Object.freeze({})),
signTransactions: async (transactions) => transactions.map(() => Object.freeze({}))
};
return Object.freeze(out);
}
// src/transaction-modifying-signer.ts

@@ -131,5 +171,4 @@ function isTransactionModifyingSigner(value) {

async function partiallySignTransactionWithSigners(transaction, config = {}) {
const signers = config.signers ?? [];
const { partialSigners, modifyingSigners } = categorizeTransactionSigners(
deduplicateSigners([...getSignersFromTransaction(transaction).filter(isTransactionSigner), ...signers]),
deduplicateSigners(getSignersFromTransaction(transaction).filter(isTransactionSigner)),
{ identifySendingSigner: false }

@@ -145,6 +184,5 @@ );

async function signAndSendTransactionWithSigners(transaction, config = {}) {
const signers = config.signers ?? [];
const abortSignal = config.abortSignal;
const { partialSigners, modifyingSigners, sendingSigner } = categorizeTransactionSigners(
deduplicateSigners([...getSignersFromTransaction(transaction).filter(isTransactionSigner), ...signers])
deduplicateSigners(getSignersFromTransaction(transaction).filter(isTransactionSigner))
);

@@ -233,4 +271,2 @@ abortSignal?.throwIfAborted();

export { assertIsKeyPairSigner, assertIsMessageModifyingSigner, assertIsMessagePartialSigner, assertIsMessageSigner, assertIsTransactionModifyingSigner, assertIsTransactionPartialSigner, assertIsTransactionSendingSigner, assertIsTransactionSigner, createSignableMessage, createSignerFromKeyPair, generateKeyPairSigner, getSignersFromInstruction, getSignersFromTransaction, isKeyPairSigner, isMessageModifyingSigner, isMessagePartialSigner, isMessageSigner, isTransactionModifyingSigner, isTransactionPartialSigner, isTransactionSendingSigner, isTransactionSigner, partiallySignTransactionWithSigners, signAndSendTransactionWithSigners, signTransactionWithSigners };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.native.js.map
export { addSignersToInstruction, addSignersToTransaction, assertIsKeyPairSigner, assertIsMessageModifyingSigner, assertIsMessagePartialSigner, assertIsMessageSigner, assertIsTransactionModifyingSigner, assertIsTransactionPartialSigner, assertIsTransactionSendingSigner, assertIsTransactionSigner, createNoopSigner, createSignableMessage, createSignerFromKeyPair, generateKeyPairSigner, getSignersFromInstruction, getSignersFromTransaction, isKeyPairSigner, isMessageModifyingSigner, isMessagePartialSigner, isMessageSigner, isTransactionModifyingSigner, isTransactionPartialSigner, isTransactionSendingSigner, isTransactionSigner, partiallySignTransactionWithSigners, signAndSendTransactionWithSigners, signTransactionWithSigners };

@@ -0,1 +1,2 @@

import { isSignerRole } from '@solana/instructions';
import { getAddressFromPublicKey, isAddress } from '@solana/addresses';

@@ -11,2 +12,6 @@ import { generateKeyPair, signBytes } from '@solana/keys';

deduplicated[signer.address] = signer;
} else if (deduplicated[signer.address] !== signer) {
throw new Error(
`Multiple distinct signers were identified for address "${signer.address}". Please ensure that you are using the same signer instance for each address.`
);
}

@@ -26,2 +31,27 @@ });

}
function addSignersToInstruction(signers, instruction) {
if (!instruction.accounts || instruction.accounts.length === 0) {
return instruction;
}
const signerByAddress = new Map(deduplicateSigners(signers).map((signer) => [signer.address, signer]));
return Object.freeze({
...instruction,
accounts: instruction.accounts.map((account) => {
const signer = signerByAddress.get(account.address);
if (!isSignerRole(account.role) || "signer" in account || !signer) {
return account;
}
return Object.freeze({ ...account, signer });
})
});
}
function addSignersToTransaction(signers, transaction) {
if (transaction.instructions.length === 0) {
return transaction;
}
return Object.freeze({
...transaction,
instructions: transaction.instructions.map((instruction) => addSignersToInstruction(signers, instruction))
});
}

@@ -98,2 +128,12 @@ // src/message-partial-signer.ts

// src/noop-signer.ts
function createNoopSigner(address) {
const out = {
address,
signMessages: async (messages) => messages.map(() => Object.freeze({})),
signTransactions: async (transactions) => transactions.map(() => Object.freeze({}))
};
return Object.freeze(out);
}
// src/transaction-modifying-signer.ts

@@ -131,5 +171,4 @@ function isTransactionModifyingSigner(value) {

async function partiallySignTransactionWithSigners(transaction, config = {}) {
const signers = config.signers ?? [];
const { partialSigners, modifyingSigners } = categorizeTransactionSigners(
deduplicateSigners([...getSignersFromTransaction(transaction).filter(isTransactionSigner), ...signers]),
deduplicateSigners(getSignersFromTransaction(transaction).filter(isTransactionSigner)),
{ identifySendingSigner: false }

@@ -145,6 +184,5 @@ );

async function signAndSendTransactionWithSigners(transaction, config = {}) {
const signers = config.signers ?? [];
const abortSignal = config.abortSignal;
const { partialSigners, modifyingSigners, sendingSigner } = categorizeTransactionSigners(
deduplicateSigners([...getSignersFromTransaction(transaction).filter(isTransactionSigner), ...signers])
deduplicateSigners(getSignersFromTransaction(transaction).filter(isTransactionSigner))
);

@@ -233,4 +271,4 @@ abortSignal?.throwIfAborted();

export { assertIsKeyPairSigner, assertIsMessageModifyingSigner, assertIsMessagePartialSigner, assertIsMessageSigner, assertIsTransactionModifyingSigner, assertIsTransactionPartialSigner, assertIsTransactionSendingSigner, assertIsTransactionSigner, createSignableMessage, createSignerFromKeyPair, generateKeyPairSigner, getSignersFromInstruction, getSignersFromTransaction, isKeyPairSigner, isMessageModifyingSigner, isMessagePartialSigner, isMessageSigner, isTransactionModifyingSigner, isTransactionPartialSigner, isTransactionSendingSigner, isTransactionSigner, partiallySignTransactionWithSigners, signAndSendTransactionWithSigners, signTransactionWithSigners };
export { addSignersToInstruction, addSignersToTransaction, assertIsKeyPairSigner, assertIsMessageModifyingSigner, assertIsMessagePartialSigner, assertIsMessageSigner, assertIsTransactionModifyingSigner, assertIsTransactionPartialSigner, assertIsTransactionSendingSigner, assertIsTransactionSigner, createNoopSigner, createSignableMessage, createSignerFromKeyPair, generateKeyPairSigner, getSignersFromInstruction, getSignersFromTransaction, isKeyPairSigner, isMessageModifyingSigner, isMessagePartialSigner, isMessageSigner, isTransactionModifyingSigner, isTransactionPartialSigner, isTransactionSendingSigner, isTransactionSigner, partiallySignTransactionWithSigners, signAndSendTransactionWithSigners, signTransactionWithSigners };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.node.js.map

43

dist/index.production.min.js

@@ -5,32 +5,35 @@ this.globalThis = this.globalThis || {};

function A(e){let n={};return e.forEach(r=>{n[r.address]||(n[r.address]=r);}),Object.values(n)}function De(e){var n;return A(((n=e.accounts)!=null?n:[]).flatMap(r=>"signer"in r?r.signer:[]))}function _(e){return A(e.instructions.flatMap(De))}function I(e,n,r=0){if(n.length-r<=0)throw new Error(`Codec [${e}] cannot decode empty byte arrays.`)}function b(e,n,r,t=0){let i=r.length-t;if(i<n)throw new Error(`Codec [${e}] expected ${n} bytes, got ${i}.`)}var w=e=>{let n=e.filter(o=>o.length);if(n.length===0)return e.length?e[0]:new Uint8Array;if(n.length===1)return n[0];let r=n.reduce((o,s)=>o+s.length,0),t=new Uint8Array(r),i=0;return n.forEach(o=>{t.set(o,i),i+=o.length;}),t},Me=(e,n)=>{if(e.length>=n)return e;let r=new Uint8Array(n).fill(0);return r.set(e),r},W=(e,n)=>Me(e.length<=n?e:e.slice(0,n),n);function se(e,n,r){return {description:r!=null?r:`fixed(${n}, ${e.description})`,fixedSize:n,maxSize:n}}function k(e,n,r){return {...se(e,n,r),encode:t=>W(e.encode(t),n)}}function j(e,n,r){return {...se(e,n,r),decode:(t,i=0)=>{b("fixCodec",n,t,i),(i>0||t.length>n)&&(t=t.slice(i,i+n)),e.fixedSize!==null&&(t=W(t,e.fixedSize));let[o]=e.decode(t,0);return [o,i+n]}}}function v(e,n){return {description:e.description,encode:r=>e.encode(n(r)),fixedSize:e.fixedSize,maxSize:e.maxSize}}function ae(e,n,r,t){if(t<n||t>r)throw new Error(`Codec [${e}] expected number to be in the range [${n}, ${r}], got ${t}.`)}function ce(e){var t;let n,r=e.name;return e.size>1&&(n=!("endian"in e.config)||e.config.endian===0,r+=n?"(le)":"(be)"),{description:(t=e.config.description)!=null?t:r,fixedSize:e.size,littleEndian:n,maxSize:e.size}}function de(e){let n=ce(e);return {description:n.description,encode(r){e.range&&ae(e.name,e.range[0],e.range[1],r);let t=new ArrayBuffer(e.size);return e.set(new DataView(t),r,n.littleEndian),new Uint8Array(t)},fixedSize:n.fixedSize,maxSize:n.maxSize}}function ke(e){let n=ce(e);return {decode(r,t=0){I(n.description,r,t),b(n.description,e.size,r,t);let i=new DataView(Pe(r,t,e.size));return [e.get(i,n.littleEndian),t+e.size]},description:n.description,fixedSize:n.fixedSize,maxSize:n.maxSize}}function Pe(e,n,r){let t=e.byteOffset+(n!=null?n:0),i=r!=null?r:e.byteLength;return e.buffer.slice(t,t+i)}var S=(e={})=>{var n;return {description:(n=e.description)!=null?n:"shortU16",encode:r=>{ae("shortU16",0,65535,r);let t=[0];for(let i=0;;i+=1){let o=r>>i*7;if(o===0)break;let s=127&o;t[i]=s,i>0&&(t[i-1]|=128);}return new Uint8Array(t)},fixedSize:null,maxSize:3}};var $=(e={})=>de({config:e,name:"u32",range:[0,+"0xffffffff"],set:(n,r,t)=>n.setUint32(0,r,t),size:4}),K=(e={})=>ke({config:e,get:(n,r)=>n.getUint32(0,r),name:"u32",size:4});var y=(e={})=>de({config:e,name:"u8",range:[0,+"0xff"],set:(n,r)=>n.setUint8(0,r),size:1});function $e(e,n,r=n){if(!n.match(new RegExp(`^[${e}]*$`)))throw new Error(`Expected a string of base ${e.length}, got [${r}].`)}var Ue=e=>{let n=e.length,r=BigInt(n);return {description:`base${n}`,encode(t){if($e(e,t),t==="")return new Uint8Array;let i=[...t],o=i.findIndex(m=>m!==e[0]);o=o===-1?i.length:o;let s=Array(o).fill(0);if(o===i.length)return Uint8Array.from(s);let a=i.slice(o),c=0n,d=1n;for(let m=a.length-1;m>=0;m-=1)c+=d*BigInt(e.indexOf(a[m])),d*=r;let u=[];for(;c>0n;)u.unshift(Number(c%256n)),c/=256n;return Uint8Array.from(s.concat(u))},fixedSize:null,maxSize:null}},Ne=e=>{let n=e.length,r=BigInt(n);return {decode(t,i=0){let o=i===0?t:t.slice(i);if(o.length===0)return ["",0];let s=o.findIndex(u=>u!==0);s=s===-1?o.length:s;let a=e[0].repeat(s);if(s===o.length)return [a,t.length];let c=o.slice(s).reduce((u,m)=>u*256n+BigInt(m),0n),d=[];for(;c>0n;)d.unshift(e[Number(c%r)]),c/=r;return [a+d.join(""),t.length]},description:`base${n}`,fixedSize:null,maxSize:null}};var ue="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",U=()=>Ue(ue),V=()=>Ne(ue);var Re=e=>e.replace(/\u0000/g,"");var Oe=globalThis.TextDecoder,Le=globalThis.TextEncoder,Fe=()=>{let e;return {description:"utf8",encode:n=>new Uint8Array((e||(e=new Le)).encode(n)),fixedSize:null,maxSize:null}},_e=()=>{let e;return {decode(n,r=0){let t=(e||(e=new Oe)).decode(n.slice(r));return [Re(t),n.length]},description:"utf8",fixedSize:null,maxSize:null}};var N=(e={})=>{var i,o,s;let n=(i=e.size)!=null?i:$(),r=(o=e.encoding)!=null?o:Fe(),t=(s=e.description)!=null?s:`string(${r.description}; ${ge(n)})`;return n==="variable"?{...r,description:t}:typeof n=="number"?k(r,n,t):{description:t,encode:a=>{let c=r.encode(a),d=n.encode(c.length);return w([d,c])},fixedSize:null,maxSize:null}},H=(e={})=>{var i,o,s;let n=(i=e.size)!=null?i:K(),r=(o=e.encoding)!=null?o:_e(),t=(s=e.description)!=null?s:`string(${r.description}; ${ge(n)})`;return n==="variable"?{...r,description:t}:typeof n=="number"?j(r,n,t):{decode:(a,c=0)=>{I("string",a,c);let[d,u]=n.decode(a,c),m=Number(d);c=u;let oe=a.slice(c,c+m);b("string",m,oe);let[Ce,Be]=r.decode(oe);return c+=Be,[Ce,c]},description:t,fixedSize:null,maxSize:null}};function ge(e){return typeof e=="object"?e.description:`${e}`}function G(){if(!globalThis.isSecureContext)throw new Error("Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts")}var h;async function We(e){return h===void 0&&(h=new Promise(n=>{e.generateKey("Ed25519",!1,["sign","verify"]).catch(()=>{n(h=!1);}).then(()=>{n(h=!0);});})),typeof h=="boolean"?h:await h}async function fe(){var e;if(G(),typeof globalThis.crypto>"u"||typeof((e=globalThis.crypto.subtle)==null?void 0:e.generateKey)!="function")throw new Error("No key generation implementation could be found");if(!await We(globalThis.crypto.subtle))throw new Error(`This runtime does not support the generation of Ed25519 key pairs.
function S(e){let n={};return e.forEach(r=>{if(!n[r.address])n[r.address]=r;else if(n[r.address]!==r)throw new Error(`Multiple distinct signers were identified for address "${r.address}". Please ensure that you are using the same signer instance for each address.`)}),Object.values(n)}function Me(e){var n;return S(((n=e.accounts)!=null?n:[]).flatMap(r=>"signer"in r?r.signer:[]))}function _(e){return S(e.instructions.flatMap(Me))}function se(e){return e>=2}function ke(e,n){if(!n.accounts||n.accounts.length===0)return n;let r=new Map(S(e).map(t=>[t.address,t]));return Object.freeze({...n,accounts:n.accounts.map(t=>{let i=r.get(t.address);return !se(t.role)||"signer"in t||!i?t:Object.freeze({...t,signer:i})})})}function rr(e,n){return n.instructions.length===0?n:Object.freeze({...n,instructions:n.instructions.map(r=>ke(e,r))})}function I(e,n,r=0){if(n.length-r<=0)throw new Error(`Codec [${e}] cannot decode empty byte arrays.`)}function b(e,n,r,t=0){let i=r.length-t;if(i<n)throw new Error(`Codec [${e}] expected ${n} bytes, got ${i}.`)}var w=e=>{let n=e.filter(o=>o.length);if(n.length===0)return e.length?e[0]:new Uint8Array;if(n.length===1)return n[0];let r=n.reduce((o,s)=>o+s.length,0),t=new Uint8Array(r),i=0;return n.forEach(o=>{t.set(o,i),i+=o.length;}),t},Pe=(e,n)=>{if(e.length>=n)return e;let r=new Uint8Array(n).fill(0);return r.set(e),r},F=(e,n)=>Pe(e.length<=n?e:e.slice(0,n),n);function ae(e,n,r){return {description:r!=null?r:`fixed(${n}, ${e.description})`,fixedSize:n,maxSize:n}}function k(e,n,r){return {...ae(e,n,r),encode:t=>F(e.encode(t),n)}}function j(e,n,r){return {...ae(e,n,r),decode:(t,i=0)=>{b("fixCodec",n,t,i),(i>0||t.length>n)&&(t=t.slice(i,i+n)),e.fixedSize!==null&&(t=F(t,e.fixedSize));let[o]=e.decode(t,0);return [o,i+n]}}}function v(e,n){return {description:e.description,encode:r=>e.encode(n(r)),fixedSize:e.fixedSize,maxSize:e.maxSize}}function ce(e,n,r,t){if(t<n||t>r)throw new Error(`Codec [${e}] expected number to be in the range [${n}, ${r}], got ${t}.`)}function de(e){var t;let n,r=e.name;return e.size>1&&(n=!("endian"in e.config)||e.config.endian===0,r+=n?"(le)":"(be)"),{description:(t=e.config.description)!=null?t:r,fixedSize:e.size,littleEndian:n,maxSize:e.size}}function ue(e){let n=de(e);return {description:n.description,encode(r){e.range&&ce(e.name,e.range[0],e.range[1],r);let t=new ArrayBuffer(e.size);return e.set(new DataView(t),r,n.littleEndian),new Uint8Array(t)},fixedSize:n.fixedSize,maxSize:n.maxSize}}function Ne(e){let n=de(e);return {decode(r,t=0){I(n.description,r,t),b(n.description,e.size,r,t);let i=new DataView(Re(r,t,e.size));return [e.get(i,n.littleEndian),t+e.size]},description:n.description,fixedSize:n.fixedSize,maxSize:n.maxSize}}function Re(e,n,r){let t=e.byteOffset+(n!=null?n:0),i=r!=null?r:e.byteLength;return e.buffer.slice(t,t+i)}var y=(e={})=>{var n;return {description:(n=e.description)!=null?n:"shortU16",encode:r=>{ce("shortU16",0,65535,r);let t=[0];for(let i=0;;i+=1){let o=r>>i*7;if(o===0)break;let s=127&o;t[i]=s,i>0&&(t[i-1]|=128);}return new Uint8Array(t)},fixedSize:null,maxSize:3}};var N=(e={})=>ue({config:e,name:"u32",range:[0,+"0xffffffff"],set:(n,r,t)=>n.setUint32(0,r,t),size:4}),K=(e={})=>Ne({config:e,get:(n,r)=>n.getUint32(0,r),name:"u32",size:4});var h=(e={})=>ue({config:e,name:"u8",range:[0,+"0xff"],set:(n,r)=>n.setUint8(0,r),size:1});function $e(e,n,r=n){if(!n.match(new RegExp(`^[${e}]*$`)))throw new Error(`Expected a string of base ${e.length}, got [${r}].`)}var Ue=e=>{let n=e.length,r=BigInt(n);return {description:`base${n}`,encode(t){if($e(e,t),t==="")return new Uint8Array;let i=[...t],o=i.findIndex(m=>m!==e[0]);o=o===-1?i.length:o;let s=Array(o).fill(0);if(o===i.length)return Uint8Array.from(s);let a=i.slice(o),c=0n,d=1n;for(let m=a.length-1;m>=0;m-=1)c+=d*BigInt(e.indexOf(a[m])),d*=r;let g=[];for(;c>0n;)g.unshift(Number(c%256n)),c/=256n;return Uint8Array.from(s.concat(g))},fixedSize:null,maxSize:null}},Oe=e=>{let n=e.length,r=BigInt(n);return {decode(t,i=0){let o=i===0?t:t.slice(i);if(o.length===0)return ["",0];let s=o.findIndex(g=>g!==0);s=s===-1?o.length:s;let a=e[0].repeat(s);if(s===o.length)return [a,t.length];let c=o.slice(s).reduce((g,m)=>g*256n+BigInt(m),0n),d=[];for(;c>0n;)d.unshift(e[Number(c%r)]),c/=r;return [a+d.join(""),t.length]},description:`base${n}`,fixedSize:null,maxSize:null}};var ge="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",R=()=>Ue(ge),V=()=>Oe(ge);var Le=e=>e.replace(/\u0000/g,"");var We=globalThis.TextDecoder,_e=globalThis.TextEncoder,Fe=()=>{let e;return {description:"utf8",encode:n=>new Uint8Array((e||(e=new _e)).encode(n)),fixedSize:null,maxSize:null}},je=()=>{let e;return {decode(n,r=0){let t=(e||(e=new We)).decode(n.slice(r));return [Le(t),n.length]},description:"utf8",fixedSize:null,maxSize:null}};var $=(e={})=>{var i,o,s;let n=(i=e.size)!=null?i:N(),r=(o=e.encoding)!=null?o:Fe(),t=(s=e.description)!=null?s:`string(${r.description}; ${fe(n)})`;return n==="variable"?{...r,description:t}:typeof n=="number"?k(r,n,t):{description:t,encode:a=>{let c=r.encode(a),d=n.encode(c.length);return w([d,c])},fixedSize:null,maxSize:null}},G=(e={})=>{var i,o,s;let n=(i=e.size)!=null?i:K(),r=(o=e.encoding)!=null?o:je(),t=(s=e.description)!=null?s:`string(${r.description}; ${fe(n)})`;return n==="variable"?{...r,description:t}:typeof n=="number"?j(r,n,t):{decode:(a,c=0)=>{I("string",a,c);let[d,g]=n.decode(a,c),m=Number(d);c=g;let oe=a.slice(c,c+m);b("string",m,oe);let[Be,De]=r.decode(oe);return c+=De,[Be,c]},description:t,fixedSize:null,maxSize:null}};function fe(e){return typeof e=="object"?e.description:`${e}`}function H(){if(!globalThis.isSecureContext)throw new Error("Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts")}var T;async function Ke(e){return T===void 0&&(T=new Promise(n=>{e.generateKey("Ed25519",!1,["sign","verify"]).catch(()=>{n(T=!1);}).then(()=>{n(T=!0);});})),typeof T=="boolean"?T:await T}async function le(){var e;if(H(),typeof globalThis.crypto>"u"||typeof((e=globalThis.crypto.subtle)==null?void 0:e.generateKey)!="function")throw new Error("No key generation implementation could be found");if(!await Ke(globalThis.crypto.subtle))throw new Error(`This runtime does not support the generation of Ed25519 key pairs.
Install and import \`@solana/webcrypto-ed25519-polyfill\` before generating keys in environments that do not support Ed25519.
For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20`)}async function le(){var e;if(G(),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 me(){var e;if(G(),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 Y,X;function q(){return Y||(Y=U()),Y}function je(){return X||(X=V()),X}function pe(e){return !(e.length<32||e.length>44||q().encode(e).byteLength!==32)}function Se(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=q().encode(e).byteLength;if(t!==32)throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${t}`)}catch(n){throw new Error(`\`${e}\` is not a base-58 encoded address`,{cause:n})}}function Ke(e){return Se(e),e}function Z(e){var n;return v(N({description:(n=e==null?void 0:e.description)!=null?n:"Address",encoding:q(),size:32}),r=>Ke(r))}function ye(e){var n;return H({description:(n=e==null?void 0:e.description)!=null?n:"Address",encoding:je(),size:32})}function R(){return new Intl.Collator("en",{caseFirst:"lower",ignorePunctuation:!1,localeMatcher:"best fit",numeric:!1,sensitivity:"variant",usage:"sort"}).compare}async function O(e){if(await le(),e.type!=="public"||e.algorithm.name!=="Ed25519")throw new Error("The `CryptoKey` must be an `Ed25519` public key");let n=await crypto.subtle.exportKey("raw",e),[r]=ye().decode(new Uint8Array(n));return r}async function he(){return await fe(),await crypto.subtle.generateKey("Ed25519",!1,["sign","verify"])}async function L(e,n){await me();let r=await crypto.subtle.sign("Ed25519",e,n);return new Uint8Array(r)}function J(e){return e.reduce((n,r)=>n===null||r===null?null:n+r,0)}function He(e){return typeof e=="object"?e.description:`${e}`}function Te(e,n){if(typeof e!="number")return null;if(e===0)return 0;let r=J(n);return r===null?null:r*e}function Ge(e,n){return typeof e=="object"?e.encode(n):new Uint8Array}function Ye(e,n,r){if(n!==r)throw new Error(`Expected [${e}] to have ${n} items, got ${r}.`)}function Xe(e,n,r){if(n==="remainder"&&e.fixedSize===null)throw new Error('Codecs of "remainder" size must have fixed-size items.');return {description:r!=null?r:`array(${e.description}; ${He(n)})`,fixedSize:Te(n,[e.fixedSize]),maxSize:Te(n,[e.maxSize])}}function T(e,n={}){var t;let r=(t=n.size)!=null?t:$();return {...Xe(e,r,n.description),encode:i=>(typeof r=="number"&&Ye("array",r,i.length),w([Ge(r,i.length),...i.map(o=>e.encode(o))]))}}function xe(e={}){var o,s;let n=(o=e.size)!=null?o:"variable",r=typeof n=="object"?n.description:`${n}`,t=(s=e.description)!=null?s:`bytes(${r})`,i={description:t,encode:a=>a,fixedSize:null,maxSize:null};return n==="variable"?i:typeof n=="number"?k(i,n,t):{...i,encode:a=>{let c=i.encode(a),d=n.encode(c.length);return w([d,c])}}}function qe(e,n){let r=e.map(([t,i])=>`${String(t)}: ${i.description}`).join(", ");return {description:n!=null?n:`struct(${r})`,fixedSize:J(e.map(([,t])=>t.fixedSize)),maxSize:J(e.map(([,t])=>t.maxSize))}}function z(e,n={}){return {...qe(e,n.description),encode:r=>{let t=e.map(([i,o])=>o.encode(r[i]));return w(t)}}}var C=(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))(C||{}),Ze=1;function E(e){return e>=2}function B(e){return (e&Ze)!==0}function Ae(e,n){return e|n}function be(e,n,r){var t;e[n]=r((t=e[n])!=null?t:{role:C.READONLY});}var f=Symbol("AddressMapTypeProperty");function Je(e,n){let r={[e]:{[f]:0,role:C.WRITABLE_SIGNER}},t=new Set;for(let i of n){be(r,i.programAddress,s=>{if(t.add(i.programAddress),f in s){if(B(s.role))switch(s[f]){case 0:throw new Error(`This transaction includes an address (\`${i.programAddress}\`) which is both invoked and set as the fee payer. Program addresses may not pay fees.`);default:throw new Error(`This transaction includes an address (\`${i.programAddress}\`) which is both invoked and marked writable. Program addresses may not be writable.`)}if(s[f]===2)return s}return {[f]:2,role:C.READONLY}});let o;if(i.accounts)for(let s of i.accounts)be(r,s.address,a=>{let{address:c,...d}=s;if(f in a)switch(a[f]){case 0:return a;case 1:{let u=Ae(a.role,d.role);if("lookupTableAddress"in d){if(a.lookupTableAddress!==d.lookupTableAddress&&(o||(o=R()))(d.lookupTableAddress,a.lookupTableAddress)<0)return {[f]:1,...d,role:u}}else if(E(d.role))return {[f]:2,role:u};return a.role!==u?{...a,role:u}:a}case 2:{let u=Ae(a.role,d.role);if(t.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 a.role!==u?{...a,role:u}:a}else return "lookupTableAddress"in d&&!E(a.role)?{...d,[f]:1,role:u}:a.role!==u?{...a,role:u}:a}}return "lookupTableAddress"in d?{...d,[f]:1}:{...d,[f]:2}});}return r}function Qe(e){let n;return Object.entries(e).sort(([t,i],[o,s])=>{if(i[f]!==s[f]){if(i[f]===0)return -1;if(s[f]===0)return 1;if(i[f]===2)return -1;if(s[f]===2)return 1}let a=E(i.role);if(a!==E(s.role))return a?-1:1;let c=B(i.role);return c!==B(s.role)?c?-1:1:(n||(n=R()),i[f]===1&&s[f]===1&&i.lookupTableAddress!==s.lookupTableAddress?n(i.lookupTableAddress,s.lookupTableAddress):n(t,o))}).map(([t,i])=>({address:t,...i}))}function en(e){var r;let n={};for(let t of e){if(!("lookupTableAddress"in t))continue;let i=n[r=t.lookupTableAddress]||(n[r]={readableIndices:[],writableIndices:[]});t.role===C.WRITABLE?i.writableIndices.push(t.addressIndex):i.readableIndices.push(t.addressIndex);}return Object.keys(n).sort(R()).map(t=>({lookupTableAddress:t,...n[t]}))}function nn(e){let n=0,r=0,t=0;for(let i of e){if("lookupTableAddress"in i)break;let o=B(i.role);E(i.role)?(t++,o||r++):o||n++;}return {numReadonlyNonSignerAccounts:n,numReadonlySignerAccounts:r,numSignerAccounts:t}}function rn(e){let n={};for(let[r,t]of e.entries())n[t.address]=r;return n}function tn(e,n){let r=rn(n);return e.map(({accounts:t,data:i,programAddress:o})=>({programAddressIndex:r[o],...t?{accountIndices:t.map(({address:s})=>r[s])}:null,...i?{data:i}:null}))}function on(e){return "nonce"in e?e.nonce:e.blockhash}function sn(e){let n=e.findIndex(t=>"lookupTableAddress"in t);return (n===-1?e:e.slice(0,n)).map(({address:t})=>t)}function an(e){let n=Je(e.feePayer,e.instructions),r=Qe(n);return {...e.version!=="legacy"?{addressTableLookups:en(r)}:null,header:nn(r),instructions:tn(e.instructions,r),lifetimeToken:on(e.lifetimeConstraint),staticAccounts:sn(r),version:e.version}}var cn="lookupTableAddress",dn="writableIndices",un="readableIndices",gn="addressTableLookup",Q;function fn(){return Q||(Q=z([["lookupTableAddress",Z({description:cn})],["writableIndices",T(y(),{description:dn,size:S()})],["readableIndices",T(y(),{description:un,size:S()})]],{description:gn})),Q}var ee;function ln(){return ee||(ee=y()),ee}function ne(e){let n=ln();return {...n,description:e!=null?e:n.description}}var mn=void 0,pn=void 0,Sn=void 0,yn=void 0;function hn(){return z([["numSignerAccounts",ne(mn)],["numReadonlySignerAccounts",ne(pn)],["numReadonlyNonSignerAccounts",ne(Sn)]],{description:yn})}var Tn="programAddressIndex",xn=void 0,An="accountIndices",bn="data",re;function wn(){return re||(re=v(z([["programAddressIndex",y({description:Tn})],["accountIndices",T(y({description:xn}),{description:An,size:S()})],["data",xe({description:bn,size:S()})]]),e=>{var n,r;return e.accountIndices!==void 0&&e.data!==void 0?e:{...e,accountIndices:(n=e.accountIndices)!=null?n:[],data:(r=e.data)!=null?r:new Uint8Array(0)}})),re}var zn=128,En={description:"",fixedSize:null,maxSize:1};function In(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|zn])}function vn(){return {...En,encode:In}}var Cn="staticAccounts",Bn="lifetimeToken",Dn="instructions",Mn="addressTableLookups";function kn(){return z(we())}function Pn(){return v(z([...we(),["addressTableLookups",$n()]]),e=>{var n;return e.version==="legacy"?e:{...e,addressTableLookups:(n=e.addressTableLookups)!=null?n:[]}})}function we(){return [["version",vn()],["header",hn()],["staticAccounts",T(Z(),{description:Cn,size:S()})],["lifetimeToken",N({description:Bn,encoding:U(),size:32})],["instructions",T(wn(),{description:Dn,size:S()})]]}function $n(){return T(fn(),{description:Mn,size:S()})}var Un="message";function Nn(){return {description:Un,encode:e=>e.version==="legacy"?kn().encode(e):Pn().encode(e),fixedSize:null,maxSize:null}}async function ze(e,n){let r=an(n),t="signatures"in n?{...n.signatures}:{},i=Nn().encode(r),o=await Promise.all(e.map(a=>Promise.all([O(a.publicKey),L(a.privateKey,i)])));for(let[a,c]of o)t[a]=c;let s={...n,signatures:t};return Object.freeze(s),s}function te(e){let n=e.instructions.flatMap(t=>{var i,o;return (o=(i=t.accounts)==null?void 0:i.filter(s=>E(s.role)))!=null?o:[]}).map(t=>t.address);new Set([e.feePayer,...n]).forEach(t=>{if(!e.signatures[t])throw new Error(`Transaction is missing signature for address \`${t}\``)});}function D(e){return "signMessages"in e&&typeof e.signMessages=="function"}function Ur(e){if(!D(e))throw new Error("The provided value does not implement the MessagePartialSigner interface")}function p(e){return "signTransactions"in e&&typeof e.signTransactions=="function"}function Or(e){if(!p(e))throw new Error("The provided value does not implement the TransactionPartialSigner interface")}function Rn(e){return "keyPair"in e&&typeof e.keyPair=="object"&&D(e)&&p(e)}function Xr(e){if(!Rn(e))throw new Error("The provided value does not implement the KeyPairSigner interface")}async function On(e){let n=await O(e.publicKey);return Object.freeze({address:n,keyPair:e,signMessages:t=>Promise.all(t.map(async i=>Object.freeze({[n]:await L(e.privateKey,i.content)}))),signTransactions:t=>Promise.all(t.map(async i=>{let o=await ze([e],i);return Object.freeze({[n]:o.signatures[n]})}))})}async function qr(){return On(await he())}function ie(e){return pe(e.address)&&"modifyAndSignMessages"in e&&typeof e.modifyAndSignMessages=="function"}function nt(e){if(!ie(e))throw new Error("The provided value does not implement the MessageModifyingSigner interface")}function Ln(e){return D(e)||ie(e)}function ct(e){if(!Ln(e))throw new Error("The provided value does not implement any of the MessageSigner interfaces")}function x(e){return "modifyAndSignTransactions"in e&&typeof e.modifyAndSignTransactions=="function"}function gt(e){if(!x(e))throw new Error("The provided value does not implement the TransactionModifyingSigner interface")}function M(e){return "signAndSendTransactions"in e&&typeof e.signAndSendTransactions=="function"}function mt(e){if(!M(e))throw new Error("The provided value does not implement the TransactionSendingSigner interface")}function F(e){return p(e)||x(e)||M(e)}function wt(e){if(!F(e))throw new Error("The provided value does not implement any of the TransactionSigner interfaces")}async function Fn(e,n={}){var o;let r=(o=n.signers)!=null?o:[],{partialSigners:t,modifyingSigners:i}=Ee(A([..._(e).filter(F),...r]),{identifySendingSigner:!1});return Ie(e,i,t,n.abortSignal)}async function Wt(e,n={}){let r=await Fn(e,n);return te(r),r}async function jt(e,n={}){var c;let r=(c=n.signers)!=null?c:[],t=n.abortSignal,{partialSigners:i,modifyingSigners:o,sendingSigner:s}=Ee(A([..._(e).filter(F),...r]));t==null||t.throwIfAborted();let a=await Ie(e,o,i,t);if(s){t==null||t.throwIfAborted();let[d]=await s.signAndSendTransactions([a],{abortSignal:t});return d}if(n.fallbackSender)return te(a),n.fallbackSender(a);throw new Error("No TransactionSendingSigner was identified and no fallback sender was provided.")}function Ee(e,n={}){var a;let t=((a=n.identifySendingSigner)!=null?a:!0)?_n(e):null,i=e.filter(c=>c!==t&&(x(c)||p(c))),o=Wn(i),s=i.filter(p).filter(c=>!o.includes(c));return Object.freeze({modifyingSigners:o,partialSigners:s,sendingSigner:t})}function _n(e){let n=e.filter(M);if(n.length===0)return null;let r=n.filter(t=>!x(t)&&!p(t));return r.length>0?r[0]:n[0]}function Wn(e){let n=e.filter(x);if(n.length===0)return [];let r=n.filter(t=>!p(t));return r.length>0?r:[n[0]]}async function Ie(e,n=[],r=[],t){var a;let i=await n.reduce(async(c,d)=>{t==null||t.throwIfAborted();let[u]=await d.modifyAndSignTransactions([await c],{abortSignal:t});return Object.freeze(u)},Promise.resolve(e));t==null||t.throwIfAborted();let o=await Promise.all(r.map(async c=>{let[d]=await c.signTransactions([i],{abortSignal:t});return d})),s={...i,signatures:Object.freeze(o.reduce((c,d)=>({...c,...d}),(a=i.signatures)!=null?a:{}))};return Object.freeze(s)}var ve=globalThis.TextEncoder;function qt(e,n={}){return Object.freeze({content:typeof e=="string"?new ve().encode(e):e,signatures:Object.freeze({...n})})}
For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20`)}async function me(){var e;if(H(),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(H(),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 Y,X;function q(){return Y||(Y=R()),Y}function Ve(){return X||(X=V()),X}function Se(e){return !(e.length<32||e.length>44||q().encode(e).byteLength!==32)}function ye(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=q().encode(e).byteLength;if(t!==32)throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${t}`)}catch(n){throw new Error(`\`${e}\` is not a base-58 encoded address`,{cause:n})}}function Ge(e){return ye(e),e}function Z(e){var n;return v($({description:(n=e==null?void 0:e.description)!=null?n:"Address",encoding:q(),size:32}),r=>Ge(r))}function he(e){var n;return G({description:(n=e==null?void 0:e.description)!=null?n:"Address",encoding:Ve(),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 O(e){if(await me(),e.type!=="public"||e.algorithm.name!=="Ed25519")throw new Error("The `CryptoKey` must be an `Ed25519` public key");let n=await crypto.subtle.exportKey("raw",e),[r]=he().decode(new Uint8Array(n));return r}async function Te(){return await le(),await crypto.subtle.generateKey("Ed25519",!1,["sign","verify"])}async function L(e,n){await pe();let r=await crypto.subtle.sign("Ed25519",e,n);return new Uint8Array(r)}function J(e){return e.reduce((n,r)=>n===null||r===null?null:n+r,0)}function Ye(e){return typeof e=="object"?e.description:`${e}`}function xe(e,n){if(typeof e!="number")return null;if(e===0)return 0;let r=J(n);return r===null?null:r*e}function Xe(e,n){return typeof e=="object"?e.encode(n):new Uint8Array}function qe(e,n,r){if(n!==r)throw new Error(`Expected [${e}] to have ${n} items, got ${r}.`)}function Ze(e,n,r){if(n==="remainder"&&e.fixedSize===null)throw new Error('Codecs of "remainder" size must have fixed-size items.');return {description:r!=null?r:`array(${e.description}; ${Ye(n)})`,fixedSize:xe(n,[e.fixedSize]),maxSize:xe(n,[e.maxSize])}}function x(e,n={}){var t;let r=(t=n.size)!=null?t:N();return {...Ze(e,r,n.description),encode:i=>(typeof r=="number"&&qe("array",r,i.length),w([Xe(r,i.length),...i.map(o=>e.encode(o))]))}}function Ae(e={}){var o,s;let n=(o=e.size)!=null?o:"variable",r=typeof n=="object"?n.description:`${n}`,t=(s=e.description)!=null?s:`bytes(${r})`,i={description:t,encode:a=>a,fixedSize:null,maxSize:null};return n==="variable"?i:typeof n=="number"?k(i,n,t):{...i,encode:a=>{let c=i.encode(a),d=n.encode(c.length);return w([d,c])}}}function Je(e,n){let r=e.map(([t,i])=>`${String(t)}: ${i.description}`).join(", ");return {description:n!=null?n:`struct(${r})`,fixedSize:J(e.map(([,t])=>t.fixedSize)),maxSize:J(e.map(([,t])=>t.maxSize))}}function z(e,n={}){return {...Je(e,n.description),encode:r=>{let t=e.map(([i,o])=>o.encode(r[i]));return w(t)}}}var C=(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))(C||{}),Qe=1;function E(e){return e>=2}function B(e){return (e&Qe)!==0}function be(e,n){return e|n}function we(e,n,r){var t;e[n]=r((t=e[n])!=null?t:{role:C.READONLY});}var f=Symbol("AddressMapTypeProperty");function en(e,n){let r={[e]:{[f]:0,role:C.WRITABLE_SIGNER}},t=new Set;for(let i of n){we(r,i.programAddress,s=>{if(t.add(i.programAddress),f in s){if(B(s.role))switch(s[f]){case 0:throw new Error(`This transaction includes an address (\`${i.programAddress}\`) which is both invoked and set as the fee payer. Program addresses may not pay fees.`);default:throw new Error(`This transaction includes an address (\`${i.programAddress}\`) which is both invoked and marked writable. Program addresses may not be writable.`)}if(s[f]===2)return s}return {[f]:2,role:C.READONLY}});let o;if(i.accounts)for(let s of i.accounts)we(r,s.address,a=>{let{address:c,...d}=s;if(f in a)switch(a[f]){case 0:return a;case 1:{let g=be(a.role,d.role);if("lookupTableAddress"in d){if(a.lookupTableAddress!==d.lookupTableAddress&&(o||(o=U()))(d.lookupTableAddress,a.lookupTableAddress)<0)return {[f]:1,...d,role:g}}else if(E(d.role))return {[f]:2,role:g};return a.role!==g?{...a,role:g}:a}case 2:{let g=be(a.role,d.role);if(t.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 a.role!==g?{...a,role:g}:a}else return "lookupTableAddress"in d&&!E(a.role)?{...d,[f]:1,role:g}:a.role!==g?{...a,role:g}:a}}return "lookupTableAddress"in d?{...d,[f]:1}:{...d,[f]:2}});}return r}function nn(e){let n;return Object.entries(e).sort(([t,i],[o,s])=>{if(i[f]!==s[f]){if(i[f]===0)return -1;if(s[f]===0)return 1;if(i[f]===2)return -1;if(s[f]===2)return 1}let a=E(i.role);if(a!==E(s.role))return a?-1:1;let c=B(i.role);return c!==B(s.role)?c?-1:1:(n||(n=U()),i[f]===1&&s[f]===1&&i.lookupTableAddress!==s.lookupTableAddress?n(i.lookupTableAddress,s.lookupTableAddress):n(t,o))}).map(([t,i])=>({address:t,...i}))}function rn(e){var r;let n={};for(let t of e){if(!("lookupTableAddress"in t))continue;let i=n[r=t.lookupTableAddress]||(n[r]={readableIndices:[],writableIndices:[]});t.role===C.WRITABLE?i.writableIndices.push(t.addressIndex):i.readableIndices.push(t.addressIndex);}return Object.keys(n).sort(U()).map(t=>({lookupTableAddress:t,...n[t]}))}function tn(e){let n=0,r=0,t=0;for(let i of e){if("lookupTableAddress"in i)break;let o=B(i.role);E(i.role)?(t++,o||r++):o||n++;}return {numReadonlyNonSignerAccounts:n,numReadonlySignerAccounts:r,numSignerAccounts:t}}function on(e){let n={};for(let[r,t]of e.entries())n[t.address]=r;return n}function sn(e,n){let r=on(n);return e.map(({accounts:t,data:i,programAddress:o})=>({programAddressIndex:r[o],...t?{accountIndices:t.map(({address:s})=>r[s])}:null,...i?{data:i}:null}))}function an(e){return "nonce"in e?e.nonce:e.blockhash}function cn(e){let n=e.findIndex(t=>"lookupTableAddress"in t);return (n===-1?e:e.slice(0,n)).map(({address:t})=>t)}function dn(e){let n=en(e.feePayer,e.instructions),r=nn(n);return {...e.version!=="legacy"?{addressTableLookups:rn(r)}:null,header:tn(r),instructions:sn(e.instructions,r),lifetimeToken:an(e.lifetimeConstraint),staticAccounts:cn(r),version:e.version}}var un="lookupTableAddress",gn="writableIndices",fn="readableIndices",ln="addressTableLookup",Q;function mn(){return Q||(Q=z([["lookupTableAddress",Z({description:un})],["writableIndices",x(h(),{description:gn,size:y()})],["readableIndices",x(h(),{description:fn,size:y()})]],{description:ln})),Q}var ee;function pn(){return ee||(ee=h()),ee}function ne(e){let n=pn();return {...n,description:e!=null?e:n.description}}var Sn=void 0,yn=void 0,hn=void 0,Tn=void 0;function xn(){return z([["numSignerAccounts",ne(Sn)],["numReadonlySignerAccounts",ne(yn)],["numReadonlyNonSignerAccounts",ne(hn)]],{description:Tn})}var An="programAddressIndex",bn=void 0,wn="accountIndices",zn="data",re;function En(){return re||(re=v(z([["programAddressIndex",h({description:An})],["accountIndices",x(h({description:bn}),{description:wn,size:y()})],["data",Ae({description:zn,size:y()})]]),e=>{var n,r;return e.accountIndices!==void 0&&e.data!==void 0?e:{...e,accountIndices:(n=e.accountIndices)!=null?n:[],data:(r=e.data)!=null?r:new Uint8Array(0)}})),re}var In=128,vn={description:"",fixedSize:null,maxSize:1};function Cn(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|In])}function Bn(){return {...vn,encode:Cn}}var Dn="staticAccounts",Mn="lifetimeToken",kn="instructions",Pn="addressTableLookups";function Nn(){return z(ze())}function Rn(){return v(z([...ze(),["addressTableLookups",$n()]]),e=>{var n;return e.version==="legacy"?e:{...e,addressTableLookups:(n=e.addressTableLookups)!=null?n:[]}})}function ze(){return [["version",Bn()],["header",xn()],["staticAccounts",x(Z(),{description:Dn,size:y()})],["lifetimeToken",$({description:Mn,encoding:R(),size:32})],["instructions",x(En(),{description:kn,size:y()})]]}function $n(){return x(mn(),{description:Pn,size:y()})}var Un="message";function On(){return {description:Un,encode:e=>e.version==="legacy"?Nn().encode(e):Rn().encode(e),fixedSize:null,maxSize:null}}async function Ee(e,n){let r=dn(n),t="signatures"in n?{...n.signatures}:{},i=On().encode(r),o=await Promise.all(e.map(a=>Promise.all([O(a.publicKey),L(a.privateKey,i)])));for(let[a,c]of o)t[a]=c;let s={...n,signatures:t};return Object.freeze(s),s}function te(e){let n=e.instructions.flatMap(t=>{var i,o;return (o=(i=t.accounts)==null?void 0:i.filter(s=>E(s.role)))!=null?o:[]}).map(t=>t.address);new Set([e.feePayer,...n]).forEach(t=>{if(!e.signatures[t])throw new Error(`Transaction is missing signature for address \`${t}\``)});}function D(e){return "signMessages"in e&&typeof e.signMessages=="function"}function Vr(e){if(!D(e))throw new Error("The provided value does not implement the MessagePartialSigner interface")}function p(e){return "signTransactions"in e&&typeof e.signTransactions=="function"}function Yr(e){if(!p(e))throw new Error("The provided value does not implement the TransactionPartialSigner interface")}function Ln(e){return "keyPair"in e&&typeof e.keyPair=="object"&&D(e)&&p(e)}function ot(e){if(!Ln(e))throw new Error("The provided value does not implement the KeyPairSigner interface")}async function Wn(e){let n=await O(e.publicKey);return Object.freeze({address:n,keyPair:e,signMessages:t=>Promise.all(t.map(async i=>Object.freeze({[n]:await L(e.privateKey,i.content)}))),signTransactions:t=>Promise.all(t.map(async i=>{let o=await Ee([e],i);return Object.freeze({[n]:o.signatures[n]})}))})}async function st(){return Wn(await Te())}function ie(e){return Se(e.address)&&"modifyAndSignMessages"in e&&typeof e.modifyAndSignMessages=="function"}function gt(e){if(!ie(e))throw new Error("The provided value does not implement the MessageModifyingSigner interface")}function _n(e){return D(e)||ie(e)}function ht(e){if(!_n(e))throw new Error("The provided value does not implement any of the MessageSigner interfaces")}function At(e){return Object.freeze({address:e,signMessages:async r=>r.map(()=>Object.freeze({})),signTransactions:async r=>r.map(()=>Object.freeze({}))})}function A(e){return "modifyAndSignTransactions"in e&&typeof e.modifyAndSignTransactions=="function"}function zt(e){if(!A(e))throw new Error("The provided value does not implement the TransactionModifyingSigner interface")}function M(e){return "signAndSendTransactions"in e&&typeof e.signAndSendTransactions=="function"}function vt(e){if(!M(e))throw new Error("The provided value does not implement the TransactionSendingSigner interface")}function W(e){return p(e)||A(e)||M(e)}function $t(e){if(!W(e))throw new Error("The provided value does not implement any of the TransactionSigner interfaces")}async function Fn(e,n={}){let{partialSigners:r,modifyingSigners:t}=Ie(S(_(e).filter(W)),{identifySendingSigner:!1});return ve(e,t,r,n.abortSignal)}async function ei(e,n={}){let r=await Fn(e,n);return te(r),r}async function ni(e,n={}){let r=n.abortSignal,{partialSigners:t,modifyingSigners:i,sendingSigner:o}=Ie(S(_(e).filter(W)));r==null||r.throwIfAborted();let s=await ve(e,i,t,r);if(o){r==null||r.throwIfAborted();let[a]=await o.signAndSendTransactions([s],{abortSignal:r});return a}if(n.fallbackSender)return te(s),n.fallbackSender(s);throw new Error("No TransactionSendingSigner was identified and no fallback sender was provided.")}function Ie(e,n={}){var a;let t=((a=n.identifySendingSigner)!=null?a:!0)?jn(e):null,i=e.filter(c=>c!==t&&(A(c)||p(c))),o=Kn(i),s=i.filter(p).filter(c=>!o.includes(c));return Object.freeze({modifyingSigners:o,partialSigners:s,sendingSigner:t})}function jn(e){let n=e.filter(M);if(n.length===0)return null;let r=n.filter(t=>!A(t)&&!p(t));return r.length>0?r[0]:n[0]}function Kn(e){let n=e.filter(A);if(n.length===0)return [];let r=n.filter(t=>!p(t));return r.length>0?r:[n[0]]}async function ve(e,n=[],r=[],t){var a;let i=await n.reduce(async(c,d)=>{t==null||t.throwIfAborted();let[g]=await d.modifyAndSignTransactions([await c],{abortSignal:t});return Object.freeze(g)},Promise.resolve(e));t==null||t.throwIfAborted();let o=await Promise.all(r.map(async c=>{let[d]=await c.signTransactions([i],{abortSignal:t});return d})),s={...i,signatures:Object.freeze(o.reduce((c,d)=>({...c,...d}),(a=i.signatures)!=null?a:{}))};return Object.freeze(s)}var Ce=globalThis.TextEncoder;function ci(e,n={}){return Object.freeze({content:typeof e=="string"?new Ce().encode(e):e,signatures:Object.freeze({...n})})}
exports.assertIsKeyPairSigner = Xr;
exports.assertIsMessageModifyingSigner = nt;
exports.assertIsMessagePartialSigner = Ur;
exports.assertIsMessageSigner = ct;
exports.assertIsTransactionModifyingSigner = gt;
exports.assertIsTransactionPartialSigner = Or;
exports.assertIsTransactionSendingSigner = mt;
exports.assertIsTransactionSigner = wt;
exports.createSignableMessage = qt;
exports.createSignerFromKeyPair = On;
exports.generateKeyPairSigner = qr;
exports.getSignersFromInstruction = De;
exports.addSignersToInstruction = ke;
exports.addSignersToTransaction = rr;
exports.assertIsKeyPairSigner = ot;
exports.assertIsMessageModifyingSigner = gt;
exports.assertIsMessagePartialSigner = Vr;
exports.assertIsMessageSigner = ht;
exports.assertIsTransactionModifyingSigner = zt;
exports.assertIsTransactionPartialSigner = Yr;
exports.assertIsTransactionSendingSigner = vt;
exports.assertIsTransactionSigner = $t;
exports.createNoopSigner = At;
exports.createSignableMessage = ci;
exports.createSignerFromKeyPair = Wn;
exports.generateKeyPairSigner = st;
exports.getSignersFromInstruction = Me;
exports.getSignersFromTransaction = _;
exports.isKeyPairSigner = Rn;
exports.isKeyPairSigner = Ln;
exports.isMessageModifyingSigner = ie;
exports.isMessagePartialSigner = D;
exports.isMessageSigner = Ln;
exports.isTransactionModifyingSigner = x;
exports.isMessageSigner = _n;
exports.isTransactionModifyingSigner = A;
exports.isTransactionPartialSigner = p;
exports.isTransactionSendingSigner = M;
exports.isTransactionSigner = F;
exports.isTransactionSigner = W;
exports.partiallySignTransactionWithSigners = Fn;
exports.signAndSendTransactionWithSigners = jt;
exports.signTransactionWithSigners = Wt;
exports.signAndSendTransactionWithSigners = ni;
exports.signTransactionWithSigners = ei;

@@ -37,0 +40,0 @@ return exports;

@@ -9,10 +9,12 @@ import { AccountRole, IAccountLookupMeta, IAccountMeta, IInstruction } from '@solana/instructions';

}
/** A variation of the IInstruction type that allows IAccountSignerMeta in its accounts array. */
type IAccountMetaWithWithSigner<TSigner extends TransactionSigner = TransactionSigner> = IAccountMeta | IAccountLookupMeta | IAccountSignerMeta<string, TSigner>;
export type IInstructionWithSigners<TProgramAddress extends string = string, TSigner extends TransactionSigner = TransactionSigner, TAccounts extends readonly IAccountMetaWithWithSigner<TSigner>[] = readonly IAccountMetaWithWithSigner<TSigner>[]> = IInstruction<TProgramAddress, TAccounts>;
/** A variation of the instruction type that allows IAccountSignerMeta in its account metas. */
export type IInstructionWithSigners<TSigner extends TransactionSigner = TransactionSigner, TAccounts extends readonly IAccountMetaWithWithSigner<TSigner>[] = readonly IAccountMetaWithWithSigner<TSigner>[]> = Pick<IInstruction<string, TAccounts>, 'accounts'>;
/** A variation of the transaction type that allows IAccountSignerMeta in its account metas. */
export type ITransactionWithSigners<TSigner extends TransactionSigner = TransactionSigner, TAccounts extends readonly IAccountMetaWithWithSigner<TSigner>[] = readonly IAccountMetaWithWithSigner<TSigner>[]> = Pick<BaseTransaction<TransactionVersion, IInstruction & IInstructionWithSigners<TSigner, TAccounts>>, 'instructions'>;
/** Extract all signers from an instruction that may contain IAccountSignerMeta accounts. */
export declare function getSignersFromInstruction<TSigner extends TransactionSigner = TransactionSigner>(instruction: IInstructionWithSigners<string, TSigner>): readonly TSigner[];
export declare function getSignersFromInstruction<TSigner extends TransactionSigner = TransactionSigner>(instruction: IInstructionWithSigners<TSigner>): readonly TSigner[];
/** Extract all signers from a transaction that may contain IAccountSignerMeta accounts. */
export declare function getSignersFromTransaction<TSigner extends TransactionSigner = TransactionSigner, TInstruction extends IInstructionWithSigners<string, TSigner> = IInstructionWithSigners<string, TSigner>>(transaction: BaseTransaction<TransactionVersion, TInstruction>): readonly TSigner[];
export declare function getSignersFromTransaction<TSigner extends TransactionSigner = TransactionSigner, TTransaction extends ITransactionWithSigners<TSigner> = ITransactionWithSigners<TSigner>>(transaction: TTransaction): readonly TSigner[];
export {};
//# sourceMappingURL=account-signer-meta.d.ts.map
export * from './account-signer-meta';
export * from './add-signers';
export * from './keypair-signer';

@@ -6,2 +7,3 @@ export * from './message-modifying-signer';

export * from './message-signer';
export * from './noop-signer';
export * from './sign-transaction';

@@ -8,0 +10,0 @@ export * from './signable-message';

import { SignatureBytes } from '@solana/keys';
import { CompilableTransaction, IFullySignedTransaction, ITransactionWithSignatures, TransactionVersion } from '@solana/transactions';
import { IInstructionWithSigners } from './account-signer-meta';
import { TransactionSigner } from './transaction-signer';
type CompilableTransactionWithSigners = CompilableTransaction<TransactionVersion, IInstructionWithSigners<string, TransactionSigner>> & Partial<ITransactionWithSignatures>;
import { CompilableTransaction, IFullySignedTransaction, ITransactionWithSignatures } from '@solana/transactions';
import { ITransactionWithSigners } from './account-signer-meta';
type CompilableTransactionWithSigners = CompilableTransaction & ITransactionWithSigners & Partial<ITransactionWithSignatures>;
/**

@@ -13,3 +12,2 @@ * Signs a transaction using any signers that may be stored in IAccountSignerMeta instruction accounts

abortSignal?: AbortSignal;
signers?: readonly TransactionSigner[];
}): Promise<TTransaction & ITransactionWithSignatures>;

@@ -24,3 +22,2 @@ /**

abortSignal?: AbortSignal;
signers?: readonly TransactionSigner[];
}): Promise<TTransaction & IFullySignedTransaction>;

@@ -36,5 +33,4 @@ /**

fallbackSender?: (transaction: TTransaction & IFullySignedTransaction) => Promise<SignatureBytes>;
signers?: readonly TransactionSigner[];
}): Promise<SignatureBytes>;
export {};
//# sourceMappingURL=sign-transaction.d.ts.map
{
"name": "@solana/signers",
"version": "2.0.0-experimental.af584fc",
"version": "2.0.0-experimental.d085c72",
"description": "An abstraction layer over signing messages and transactions in Solana",

@@ -52,6 +52,6 @@ "exports": {

"dependencies": {
"@solana/addresses": "2.0.0-experimental.af584fc",
"@solana/instructions": "2.0.0-experimental.af584fc",
"@solana/keys": "2.0.0-experimental.af584fc",
"@solana/transactions": "2.0.0-experimental.af584fc"
"@solana/addresses": "2.0.0-experimental.d085c72",
"@solana/instructions": "2.0.0-experimental.d085c72",
"@solana/keys": "2.0.0-experimental.d085c72",
"@solana/transactions": "2.0.0-experimental.d085c72"
},

@@ -58,0 +58,0 @@ "devDependencies": {

@@ -339,10 +339,4 @@ [![npm][npm-image]][npm-url]

### Functions
For a given address, a Noop (No-Operation) signer can be created to offer an implementation of both the `MessagePartialSigner` and `TransactionPartialSigner` interfaces such that they do not sign anything. Namely, signing a transaction or a message with a `NoopSigner` will return an empty `SignatureDictionary`.
#### `createNoopSigner()`
_Coming soon..._
Creates a Noop (No-Operation) signer from a given address. It will return an implementation of both the `MessagePartialSigner` and `TransactionPartialSigner` interfaces that do not sign anything. Namely, signing a transaction or a message will return an empty `SignatureDictionary`.
This signer may be useful:

@@ -353,8 +347,26 @@

### Types
#### `NoopSigner<TAddress>`
Defines a Noop (No-Operation) signer.
```ts
const myNoopSigner: NoopSigner;
myNoopSigner satisfies MessagePartialSigner;
myNoopSigner satisfies TransactionPartialSigner;
```
### Functions
#### `createNoopSigner()`
Creates a Noop (No-Operation) signer from a given address.
```ts
import { createNoopSigner } from '@solana/signers';
const myAddress = address('1234..5678');
const myNoopSigner = createNoopSigner(myAddress);
// ^ MessagePartialSigner<'1234..5678'> & TransactionPartialSigner<'1234..5678'>
const myNoopSigner = createNoopSigner(address('1234..5678'));
const [myMessageSignatures] = await myNoopSigner.signMessages([myMessage]); // <- Empty signature dictionary.
const [myTransactionSignatures] = await myNoopSigner.signTransactions([myTransaction]); // <- Empty signature dictionary.
```

@@ -384,6 +396,6 @@

Extends the `IInstruction` type to allow `IAccountSignerMetas` to be used inside the instruction's `accounts` array.
Composable type that allows `IAccountSignerMetas` to be used inside the instruction's `accounts` array.
```ts
const myInstructionWithSigners: IInstructionWithSigners = {
const myInstructionWithSigners: IInstruction & IInstructionWithSigners = {
programAddress: address('1234..5678'),

@@ -400,2 +412,17 @@ accounts: [

#### `ITransactionWithSigners`
Composable type that allows `IAccountSignerMetas` to be used inside all of the transaction's account metas.
```ts
const myTransactionWithSigners: BaseTransaction & ITransactionWithSigners = {
instructions: [
myInstructionA as IInstruction & IInstructionWithSigners,
myInstructionB as IInstruction & IInstructionWithSigners,
myInstructionC as IInstruction,
],
version: 0,
};
```
### Functions

@@ -431,2 +458,35 @@

#### `addSignersToInstruction()`
Helper function that adds the provided signers to any of the applicable account metas. For an account meta to match a provided signer it:
- Must have a signer role (`AccountRole.READONLY_SIGNER` or `AccountRole.WRITABLE_SIGNER`).
- Must have the same address as the provided signer.
- Must not have an attached signer already.
```ts
const myInstruction: IInstruction = {
accounts: [
{ address: '1111' as Address, role: AccountRole.READONLY_SIGNER },
{ address: '2222' as Address, role: AccountRole.WRITABLE_SIGNER },
],
// ...
};
const signerA: TransactionSigner<'1111'>;
const signerB: TransactionSigner<'2222'>;
const myInstructionWithSigners = addSignersToInstruction([mySignerA, mySignerB], myInstruction);
// myInstructionWithSigners.accounts[0].signer === mySignerA
// myInstructionWithSigners.accounts[1].signer === mySignerB
```
#### `addSignersToTransaction()`
Similarly to `addSignersToInstruction`, this function adds signer to all the applicable account metas of all the instructions inside a transaction.
```ts
const myTransactionWithSigners = addSignersToTransaction(mySigners, myTransaction);
```
## Signing transactions with signers

@@ -448,3 +508,3 @@

It also accepts an optional `AbortSignal` and an additional array of signers that will be merged with the ones extracted from the transaction, if any.
It also accepts an optional `AbortSignal` that will be propagated to all signers.

@@ -454,3 +514,2 @@ ```ts

abortSignal: myAbortController.signal,
signers: [myOtherSigner],
});

@@ -471,3 +530,2 @@ ```

abortSignal: myAbortController.signal,
signers: [myOtherSigner],
});

@@ -489,3 +547,2 @@

abortSignal: myAbortController.signal,
signers: [myOtherSigner],
});

@@ -492,0 +549,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