@talismn/solana 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,17 +1,12 @@
1
1
  import { Instruction, Transaction, TransactionMessageBytesBase64 } from "@solana/kit";
2
- //#region src/utils/chains.d.ts
3
2
  export declare const SOLANA_CHAINS: readonly ["solana:mainnet", "solana:devnet", "solana:testnet", "solana:localnet"];
4
3
  export type SolanaChainId = (typeof SOLANA_CHAINS)[number];
5
4
  export declare const getSolNetworkId: (chain: SolanaChainId) => "solana-devnet" | "solana-localnet" | "solana-mainnet" | "solana-testnet";
6
- //#endregion
7
- //#region src/utils/offchainMessage.d.ts
8
5
  /**
9
6
  * Wraps a raw message in the off-chain message envelope that hardware wallets sign.
10
7
  * Returns `null` if the message cannot be wrapped (binary content, empty, or too long).
11
8
  */
12
9
  export declare const serializeOffchainMessage: (message: Uint8Array, signerPublicKey: Uint8Array) => Uint8Array | null;
13
- //#endregion
14
- //#region ../../node_modules/.pnpm/@solana+nominal-types@8.3.0_typescript@7.0.2/node_modules/@solana/nominal-types/dist/types/index.d.ts
15
10
  type StringEncoding = 'base58' | 'base64';
16
11
  /**
17
12
  * Use this to produce a new type that satisfies the original type, but not the other way around.
@@ -81,8 +76,6 @@ type EncodedString<T extends string, TEncoding extends StringEncoding> = Nominal
81
76
  * ```
82
77
  */
83
78
  type NominalType<TKey extends string, TMarker extends string> = { readonly [K in `__${TKey}:@solana/kit`]: TMarker; };
84
- //#endregion
85
- //#region ../../node_modules/.pnpm/@solana+addresses@8.3.0_fastestsmallesttextencoderdecoder@1.0.22_typescript@7.0.2/node_modules/@solana/addresses/dist/types/address.d.ts
86
79
  /**
87
80
  * Represents a string that validates as a Solana address. Functions that require well-formed
88
81
  * addresses should specify their inputs in terms of this type.
@@ -91,8 +84,6 @@ type NominalType<TKey extends string, TMarker extends string> = { readonly [K in
91
84
  * {@link address}, {@link assertIsAddress}, or {@link isAddress} functions in this package.
92
85
  */
93
86
  type Address<TAddress extends string = string> = Brand<EncodedString<TAddress, 'base58'>, 'Address'>;
94
- //#endregion
95
- //#region src/utils/transaction.d.ts
96
87
  /**
97
88
  * A Solana transaction: raw wire message bytes plus a signer-address → signature map.
98
89
  * Kit's decoder/encoder handles both legacy and v0 wire formats transparently.
@@ -119,8 +110,6 @@ export type SolTransactionInfo = {
119
110
  signature: string | null;
120
111
  };
121
112
  export declare const parseTransactionInfo: (tx: SolTransaction) => SolTransactionInfo;
122
- //#endregion
123
- //#region src/utils/serialization.d.ts
124
113
  export declare const transactionFromBytes: (bytes: Uint8Array) => SolTransaction;
125
114
  export declare const transactionToBytes: (tx: SolTransaction) => Uint8Array;
126
115
  /** base58 of the wire-format transaction — both legacy and v0, wire-compatible with web3.js */
@@ -175,8 +164,6 @@ export declare const txToHumanJSON: (tx: string | SolTransaction) => {
175
164
  data: string;
176
165
  }[];
177
166
  };
178
- //#endregion
179
- //#region src/utils/signing.d.ts
180
167
  /**
181
168
  * Returns a copy of the transaction with `signature` attached for `address`.
182
169
  * Throws if `address` is not a required signer of the transaction (the signatures
@@ -195,5 +182,5 @@ export declare const getVerifiedTransactionSignature: (tx: SolTransaction, addre
195
182
  * not WebCrypto — Ed25519 subtle crypto is too recent for the extension's support matrix.
196
183
  */
197
184
  export declare const signTransactionWithSecretKey: (tx: SolTransaction, secretKey: Uint8Array, expectedAddress?: string) => SolTransaction;
198
- //#endregion
185
+ export {};
199
186
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/utils/chains.ts","../src/utils/offchainMessage.ts","../../../node_modules/.pnpm/@solana+nominal-types@8.3.0_typescript@7.0.2/node_modules/@solana/nominal-types/dist/types/index.d.ts","../../../node_modules/.pnpm/@solana+addresses@8.3.0_fastestsmallesttextencoderdecoder@1.0.22_typescript@7.0.2/node_modules/@solana/addresses/dist/types/address.d.ts","../src/utils/transaction.ts","../src/utils/serialization.ts","../src/utils/signing.ts"],"x_google_ignoreList":[2,3],"mappings":";;qBAAa;YAOD,wBAAwB;qBAEvB,kBAAe,OAAW;;;;;;;qBCoC1B,2BAAwB,SAC1B,YAAU,iBACF,eAChB;;;KCzBE;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAiDO,MAAM,GAAG,6BAA6B,qBAAqB,cAAc;;;;;;;;;;;;;;;;;;;KAoCzE,cAAc,kBAAkB,kBAAkB,kBAAkB,8BAA8B,aAAa;;;;;;;;;;;;;;;;;;;;;KAqB/G,YAAY,qBAAqB,sCAC/B,UAAU,qBAAqB;;;;;;;;;;KCzHjC,QAAQ,oCAAoC,MAAM,cAAc;;;;;;;YCChE,iBAAiB;YAEjB;EACV;;EAEA;;EAEA;;EAEA;;;;;;EAMA;;;;;EAKA;;qBAGW,uBAAoB,IAAQ,mBAAiB;;;qBCR7C,uBAAoB,OAAW,eAAa;qBAG5C,qBAAkB,IAAQ,mBAAiB;;qBAI3C,uBAAoB,IAAQ;qBAG5B,yBAAsB,wBAA0B;;qBAIhD,qBAAkB,IAAQ,yCAAc,6BAAA;;;;;;;;;qBASxC,+BAA4B,OAAW;;qBAUvC,mBAAgB,IAAQ,mBAAiB;qBAGzC,6BAAwB,UAAA,WAAA,sBAAA,cAAA;EAOnC;EACA;EACA;EACA,cAAc;EACd;MACE;;;;;;qBAkBS,0BAAuB,IAAQ,gBAAc,sBAAsB;qBAenE,gBAAa,aAAiB;EAavC;EACA;EACA,UAfuC;EAgBvC;EACA;EAEA;IAEwC;;;;EAIxC;;eAVQ;;;;;;;;;;;;;;;;;qBC/GC,6BAA0B,IACjC,gBAAc,iBACH,WACJ,eACV;;;;;;qBAeU,kCAA+B,IACtC,gBAAc,oBAEjB;;;;;;qBAaU,+BAA4B,IACnC,gBAAc,WACP,YAAU,6BAEpB"}
1
+ {"version":3,"file":"index.d.mts","names":["_$_solana_addresses0.Address"],"sources":["../src/utils/chains.ts","../src/utils/offchainMessage.ts","../../../node_modules/.pnpm/@solana+nominal-types@8.6.0_typescript@7.0.2/node_modules/@solana/nominal-types/dist/types/index.d.ts","../../../node_modules/.pnpm/@solana+addresses@8.6.0_fastestsmallesttextencoderdecoder@1.0.22_typescript@7.0.2/node_modules/@solana/addresses/dist/types/address.d.ts","../src/utils/transaction.ts","../src/utils/serialization.ts","../src/utils/signing.ts"],"ignoreList":[2,3],"mappings":";qBAAa;YAOD,wBAAwB;qBAEvB,kBAAe,OAAW;;;;;qBCoC1B,2BAAwB,SAC1B,YAAU,iBACF,eAChB;KCzBE;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAiDO,MAAM,GAAG,6BAA6B,qBAAqB,cAAc;;;;;;;;;;;;;;;;;;;KAoCzE,cAAc,kBAAkB,kBAAkB,kBAAkB,8BAA8B,aAAa;;;;;;;;;;;;;;;;;;;;;KAqB/G,YAAY,qBAAqB,sCAC/B,UAAU,qBAAqB;;;;;;;;KCzHjC,QAAQ,oCAAoC,MAAM,cAAc;;;;;YCChE,iBAAiB;YAEjB;EACV;;EAEA;;EAEA;;EAEA;;;;;;EAMA;;;;;EAKA;;qBAGW,uBAAoB,IAAQ,mBAAiB;qBCR7C,uBAAoB,OAAW,eAAa;qBAG5C,qBAAkB,IAAQ,mBAAiB;;qBAI3C,uBAAoB,IAAQ;qBAG5B,yBAAsB,wBAA0B;;qBAIhD,qBAAkB,IAAQ,yCAAc,6BAAA;;;;;;;;;qBASxC,+BAA4B,OAAW;;qBAUvC,mBAAgB,IAAQ,mBAAiB;qBAGzC,6BAAwB,UAAA,WAAA,sBAAA,cAAA;EAOnC;EACA;EACA;EACA,cAAc;EACd;MACE;;;;;;qBAkBS,0BAAuB,IAAQ,gBAAc,sBAAsB;qBAenE,gBAAa,aAAiB;EAavC;EACA;EACA,UAfuCA;EAgBvC;EACA;EAEA;IAEwC;;;;EAIxC;;I,WAVQA;;;;;;;;;;;;;;;qBC/GC,6BAA0B,IACjC,gBAAc,iBACH,WACJ,eACV;;;;;;qBAeU,kCAA+B,IACtC,gBAAc,oBAEjB;;;;;;qBAaU,+BAA4B,IACnC,gBAAc,WACP,YAAU,6BAEpB"}
package/dist/index.d.ts CHANGED
@@ -1,17 +1,12 @@
1
1
  import { Instruction, Transaction, TransactionMessageBytesBase64 } from "@solana/kit";
2
- //#region src/utils/chains.d.ts
3
2
  export declare const SOLANA_CHAINS: readonly ["solana:mainnet", "solana:devnet", "solana:testnet", "solana:localnet"];
4
3
  export type SolanaChainId = (typeof SOLANA_CHAINS)[number];
5
4
  export declare const getSolNetworkId: (chain: SolanaChainId) => "solana-devnet" | "solana-localnet" | "solana-mainnet" | "solana-testnet";
6
- //#endregion
7
- //#region src/utils/offchainMessage.d.ts
8
5
  /**
9
6
  * Wraps a raw message in the off-chain message envelope that hardware wallets sign.
10
7
  * Returns `null` if the message cannot be wrapped (binary content, empty, or too long).
11
8
  */
12
9
  export declare const serializeOffchainMessage: (message: Uint8Array, signerPublicKey: Uint8Array) => Uint8Array | null;
13
- //#endregion
14
- //#region ../../node_modules/.pnpm/@solana+nominal-types@8.3.0_typescript@7.0.2/node_modules/@solana/nominal-types/dist/types/index.d.ts
15
10
  type StringEncoding = 'base58' | 'base64';
16
11
  /**
17
12
  * Use this to produce a new type that satisfies the original type, but not the other way around.
@@ -81,8 +76,6 @@ type EncodedString<T extends string, TEncoding extends StringEncoding> = Nominal
81
76
  * ```
82
77
  */
83
78
  type NominalType<TKey extends string, TMarker extends string> = { readonly [K in `__${TKey}:@solana/kit`]: TMarker; };
84
- //#endregion
85
- //#region ../../node_modules/.pnpm/@solana+addresses@8.3.0_fastestsmallesttextencoderdecoder@1.0.22_typescript@7.0.2/node_modules/@solana/addresses/dist/types/address.d.ts
86
79
  /**
87
80
  * Represents a string that validates as a Solana address. Functions that require well-formed
88
81
  * addresses should specify their inputs in terms of this type.
@@ -91,8 +84,6 @@ type NominalType<TKey extends string, TMarker extends string> = { readonly [K in
91
84
  * {@link address}, {@link assertIsAddress}, or {@link isAddress} functions in this package.
92
85
  */
93
86
  type Address<TAddress extends string = string> = Brand<EncodedString<TAddress, 'base58'>, 'Address'>;
94
- //#endregion
95
- //#region src/utils/transaction.d.ts
96
87
  /**
97
88
  * A Solana transaction: raw wire message bytes plus a signer-address → signature map.
98
89
  * Kit's decoder/encoder handles both legacy and v0 wire formats transparently.
@@ -119,8 +110,6 @@ export type SolTransactionInfo = {
119
110
  signature: string | null;
120
111
  };
121
112
  export declare const parseTransactionInfo: (tx: SolTransaction) => SolTransactionInfo;
122
- //#endregion
123
- //#region src/utils/serialization.d.ts
124
113
  export declare const transactionFromBytes: (bytes: Uint8Array) => SolTransaction;
125
114
  export declare const transactionToBytes: (tx: SolTransaction) => Uint8Array;
126
115
  /** base58 of the wire-format transaction — both legacy and v0, wire-compatible with web3.js */
@@ -175,8 +164,6 @@ export declare const txToHumanJSON: (tx: string | SolTransaction) => {
175
164
  data: string;
176
165
  }[];
177
166
  };
178
- //#endregion
179
- //#region src/utils/signing.d.ts
180
167
  /**
181
168
  * Returns a copy of the transaction with `signature` attached for `address`.
182
169
  * Throws if `address` is not a required signer of the transaction (the signatures
@@ -195,5 +182,5 @@ export declare const getVerifiedTransactionSignature: (tx: SolTransaction, addre
195
182
  * not WebCrypto — Ed25519 subtle crypto is too recent for the extension's support matrix.
196
183
  */
197
184
  export declare const signTransactionWithSecretKey: (tx: SolTransaction, secretKey: Uint8Array, expectedAddress?: string) => SolTransaction;
198
- //#endregion
185
+ export {};
199
186
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/utils/chains.ts","../src/utils/offchainMessage.ts","../../../node_modules/.pnpm/@solana+nominal-types@8.3.0_typescript@7.0.2/node_modules/@solana/nominal-types/dist/types/index.d.ts","../../../node_modules/.pnpm/@solana+addresses@8.3.0_fastestsmallesttextencoderdecoder@1.0.22_typescript@7.0.2/node_modules/@solana/addresses/dist/types/address.d.ts","../src/utils/transaction.ts","../src/utils/serialization.ts","../src/utils/signing.ts"],"x_google_ignoreList":[2,3],"mappings":";;qBAAa;YAOD,wBAAwB;qBAEvB,kBAAe,OAAW;;;;;;;qBCoC1B,2BAAwB,SAC1B,YAAU,iBACF,eAChB;;;KCzBE;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAiDO,MAAM,GAAG,6BAA6B,qBAAqB,cAAc;;;;;;;;;;;;;;;;;;;KAoCzE,cAAc,kBAAkB,kBAAkB,kBAAkB,8BAA8B,aAAa;;;;;;;;;;;;;;;;;;;;;KAqB/G,YAAY,qBAAqB,sCAC/B,UAAU,qBAAqB;;;;;;;;;;KCzHjC,QAAQ,oCAAoC,MAAM,cAAc;;;;;;;YCChE,iBAAiB;YAEjB;EACV;;EAEA;;EAEA;;EAEA;;;;;;EAMA;;;;;EAKA;;qBAGW,uBAAoB,IAAQ,mBAAiB;;;qBCR7C,uBAAoB,OAAW,eAAa;qBAG5C,qBAAkB,IAAQ,mBAAiB;;qBAI3C,uBAAoB,IAAQ;qBAG5B,yBAAsB,wBAA0B;;qBAIhD,qBAAkB,IAAQ,yCAAc,6BAAA;;;;;;;;;qBASxC,+BAA4B,OAAW;;qBAUvC,mBAAgB,IAAQ,mBAAiB;qBAGzC,6BAAwB,UAAA,WAAA,sBAAA,cAAA;EAOnC;EACA;EACA;EACA,cAAc;EACd;MACE;;;;;;qBAkBS,0BAAuB,IAAQ,gBAAc,sBAAsB;qBAenE,gBAAa,aAAiB;EAavC;EACA;EACA,UAfuC;EAgBvC;EACA;EAEA;IAEwC;;;;EAIxC;;eAVQ;;;;;;;;;;;;;;;;;qBC/GC,6BAA0B,IACjC,gBAAc,iBACH,WACJ,eACV;;;;;;qBAeU,kCAA+B,IACtC,gBAAc,oBAEjB;;;;;;qBAaU,+BAA4B,IACnC,gBAAc,WACP,YAAU,6BAEpB"}
1
+ {"version":3,"file":"index.d.ts","names":["_$_solana_addresses0.Address"],"sources":["../src/utils/chains.ts","../src/utils/offchainMessage.ts","../../../node_modules/.pnpm/@solana+nominal-types@8.6.0_typescript@7.0.2/node_modules/@solana/nominal-types/dist/types/index.d.ts","../../../node_modules/.pnpm/@solana+addresses@8.6.0_fastestsmallesttextencoderdecoder@1.0.22_typescript@7.0.2/node_modules/@solana/addresses/dist/types/address.d.ts","../src/utils/transaction.ts","../src/utils/serialization.ts","../src/utils/signing.ts"],"ignoreList":[2,3],"mappings":";qBAAa;YAOD,wBAAwB;qBAEvB,kBAAe,OAAW;;;;;qBCoC1B,2BAAwB,SAC1B,YAAU,iBACF,eAChB;KCzBE;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAiDO,MAAM,GAAG,6BAA6B,qBAAqB,cAAc;;;;;;;;;;;;;;;;;;;KAoCzE,cAAc,kBAAkB,kBAAkB,kBAAkB,8BAA8B,aAAa;;;;;;;;;;;;;;;;;;;;;KAqB/G,YAAY,qBAAqB,sCAC/B,UAAU,qBAAqB;;;;;;;;KCzHjC,QAAQ,oCAAoC,MAAM,cAAc;;;;;YCChE,iBAAiB;YAEjB;EACV;;EAEA;;EAEA;;EAEA;;;;;;EAMA;;;;;EAKA;;qBAGW,uBAAoB,IAAQ,mBAAiB;qBCR7C,uBAAoB,OAAW,eAAa;qBAG5C,qBAAkB,IAAQ,mBAAiB;;qBAI3C,uBAAoB,IAAQ;qBAG5B,yBAAsB,wBAA0B;;qBAIhD,qBAAkB,IAAQ,yCAAc,6BAAA;;;;;;;;;qBASxC,+BAA4B,OAAW;;qBAUvC,mBAAgB,IAAQ,mBAAiB;qBAGzC,6BAAwB,UAAA,WAAA,sBAAA,cAAA;EAOnC;EACA;EACA;EACA,cAAc;EACd;MACE;;;;;;qBAkBS,0BAAuB,IAAQ,gBAAc,sBAAsB;qBAenE,gBAAa,aAAiB;EAavC;EACA;EACA,UAfuCA;EAgBvC;EACA;EAEA;IAEwC;;;;EAIxC;;I,WAVQA;;;;;;;;;;;;;;;qBC/GC,6BAA0B,IACjC,gBAAc,iBACH,WACJ,eACV;;;;;;qBAeU,kCAA+B,IACtC,gBAAc,oBAEjB;;;;;;qBAaU,+BAA4B,IACnC,gBAAc,WACP,YAAU,6BAEpB"}
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  let _solana_kit = require("@solana/kit");
3
3
  let _talismn_crypto = require("@talismn/crypto");
4
- //#region src/utils/chains.ts
4
+ // src/utils/chains.ts
5
5
  const SOLANA_CHAINS = [
6
6
  "solana:mainnet",
7
7
  "solana:devnet",
@@ -17,8 +17,7 @@ const getSolNetworkId = (chain) => {
17
17
  default: throw new Error(`Unknown Solana chain: ${chain}`);
18
18
  }
19
19
  };
20
- //#endregion
21
- //#region src/utils/offchainMessage.ts
20
+ // src/utils/offchainMessage.ts
22
21
  const SIGNING_DOMAIN = new Uint8Array([255, ...Array.from("solana offchain", (c) => c.charCodeAt(0))]);
23
22
  const APPLICATION_DOMAIN_LENGTH = 32;
24
23
  const PUBLIC_KEY_LENGTH = 32;
@@ -60,8 +59,7 @@ const serializeOffchainMessage = (message, signerPublicKey) => {
60
59
  envelope.set(message, offset);
61
60
  return envelope;
62
61
  };
63
- //#endregion
64
- //#region src/utils/serialization.ts
62
+ // src/utils/serialization.ts
65
63
  const transactionFromBytes = (bytes) => (0, _solana_kit.getTransactionDecoder)().decode(bytes);
66
64
  const transactionToBytes = (tx) => new Uint8Array((0, _solana_kit.getTransactionEncoder)().encode(tx));
67
65
  /** base58 of the wire-format transaction — both legacy and v0, wire-compatible with web3.js */
@@ -135,8 +133,7 @@ const txToHumanJSON = (tx) => {
135
133
  }))
136
134
  };
137
135
  };
138
- //#endregion
139
- //#region src/utils/signing.ts
136
+ // src/utils/signing.ts
140
137
  /**
141
138
  * Returns a copy of the transaction with `signature` attached for `address`.
142
139
  * Throws if `address` is not a required signer of the transaction (the signatures
@@ -172,8 +169,7 @@ const signTransactionWithSecretKey = (tx, secretKey, expectedAddress) => {
172
169
  const signature = _talismn_crypto.ed25519.sign(tx.messageBytes, secretKey);
173
170
  return attachTransactionSignature(tx, address, signature);
174
171
  };
175
- //#endregion
176
- //#region src/utils/transaction.ts
172
+ // src/utils/transaction.ts
177
173
  const parseTransactionInfo = (tx) => {
178
174
  const message = getCompiledMessage(tx);
179
175
  const signerAddresses = Object.keys(tx.signatures);
@@ -189,7 +185,6 @@ const parseTransactionInfo = (tx) => {
189
185
  signature: sigBytes ? _talismn_crypto.base58.encode(sigBytes) : null
190
186
  };
191
187
  };
192
- //#endregion
193
188
  exports.SOLANA_CHAINS = SOLANA_CHAINS;
194
189
  exports.attachTransactionSignature = attachTransactionSignature;
195
190
  exports.buildUnsignedTransaction = buildUnsignedTransaction;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["getTransactionDecoder","getTransactionEncoder","base58","getCompiledTransactionMessageDecoder","getBase64Decoder","pipe","createTransactionMessage","setTransactionMessageFeePayer","solAddress","setTransactionMessageLifetimeUsingBlockhash","appendTransactionMessageInstructions","compileTransaction","getCompiledTransactionMessageEncoder","ed25519","base58","getPublicKeyFromSecret","base58"],"sources":["../src/utils/chains.ts","../src/utils/offchainMessage.ts","../src/utils/serialization.ts","../src/utils/signing.ts","../src/utils/transaction.ts"],"sourcesContent":["export const SOLANA_CHAINS = [\n \"solana:mainnet\",\n \"solana:devnet\",\n \"solana:testnet\",\n \"solana:localnet\",\n] as const\n\nexport type SolanaChainId = (typeof SOLANA_CHAINS)[number]\n\nexport const getSolNetworkId = (chain: SolanaChainId) => {\n switch (chain) {\n case \"solana:mainnet\":\n return \"solana-mainnet\"\n case \"solana:devnet\":\n return \"solana-devnet\"\n case \"solana:testnet\":\n return \"solana-testnet\"\n case \"solana:localnet\":\n return \"solana-localnet\"\n default:\n throw new Error(`Unknown Solana chain: ${chain}`)\n }\n}\n","// Solana off-chain message envelope (v0), as specified by Anza and enforced by the Ledger app\n// (1.8.0+): https://github.com/anza-xyz/agave/blob/master/docs/src/proposals/off-chain-message-signing.md\n//\n// signing domain \"\\xffsolana offchain\" (16 bytes) || header version (1 byte, 0) ||\n// application domain (32 bytes, zeros = not provided) || message format (1 byte) ||\n// signer count (1 byte) || signers (32 bytes each) || message length (2 bytes LE) || message\n//\n// Hardware wallets refuse to sign arbitrary raw bytes - only transactions and messages wrapped\n// in this envelope, and the derivation path's public key must appear in the signers list.\n// Note this is NOT the format implemented by @solana/offchain-messages (kit), whose codec\n// details differ from what the Ledger app validates.\n\nconst SIGNING_DOMAIN = new Uint8Array([\n 0xff,\n ...Array.from(\"solana offchain\", (c) => c.charCodeAt(0)),\n])\n\nconst APPLICATION_DOMAIN_LENGTH = 32\nconst PUBLIC_KEY_LENGTH = 32\n\n// domain + version + application domain + format + signer count + one signer + length\nconst HEADER_LENGTH =\n SIGNING_DOMAIN.length + 1 + APPLICATION_DOMAIN_LENGTH + 1 + 1 + PUBLIC_KEY_LENGTH + 2\n\n/** Hardware wallet compatible v0 messages are capped at 1232 bytes total, header included */\nconst MAX_MESSAGE_LENGTH = 1232 - HEADER_LENGTH\n\nconst FORMAT_RESTRICTED_ASCII = 0\nconst FORMAT_LIMITED_UTF8 = 1\n\nconst getMessageFormat = (message: Uint8Array): number | null => {\n if (message.every((byte) => byte >= 0x20 && byte <= 0x7e)) return FORMAT_RESTRICTED_ASCII\n\n try {\n new TextDecoder(\"utf-8\", { fatal: true }).decode(message)\n return FORMAT_LIMITED_UTF8\n } catch {\n return null // binary content cannot be wrapped\n }\n}\n\n/**\n * Wraps a raw message in the off-chain message envelope that hardware wallets sign.\n * Returns `null` if the message cannot be wrapped (binary content, empty, or too long).\n */\nexport const serializeOffchainMessage = (\n message: Uint8Array,\n signerPublicKey: Uint8Array\n): Uint8Array | null => {\n if (message.length === 0 || message.length > MAX_MESSAGE_LENGTH) return null\n if (signerPublicKey.length !== PUBLIC_KEY_LENGTH) return null\n\n const format = getMessageFormat(message)\n if (format === null) return null\n\n const envelope = new Uint8Array(HEADER_LENGTH + message.length)\n let offset = 0\n\n envelope.set(SIGNING_DOMAIN, offset)\n offset += SIGNING_DOMAIN.length\n\n envelope[offset++] = 0 // header version\n\n offset += APPLICATION_DOMAIN_LENGTH // application domain: zeros = not provided\n\n envelope[offset++] = format\n envelope[offset++] = 1 // signer count\n\n envelope.set(signerPublicKey, offset)\n offset += PUBLIC_KEY_LENGTH\n\n envelope[offset++] = message.length & 0xff\n envelope[offset++] = message.length >> 8\n\n envelope.set(message, offset)\n\n return envelope\n}\n","import type {\n Blockhash,\n Instruction,\n SignaturesMap,\n TransactionMessageBytes,\n TransactionMessageBytesBase64,\n} from \"@solana/kit\"\nimport {\n appendTransactionMessageInstructions,\n compileTransaction,\n createTransactionMessage,\n getBase64Decoder,\n getCompiledTransactionMessageDecoder,\n getCompiledTransactionMessageEncoder,\n getTransactionDecoder,\n getTransactionEncoder,\n pipe,\n setTransactionMessageFeePayer,\n setTransactionMessageLifetimeUsingBlockhash,\n address as solAddress,\n} from \"@solana/kit\"\nimport { base58 } from \"@talismn/crypto\"\n\nimport type { SolTransaction } from \"./transaction\"\n\nexport const transactionFromBytes = (bytes: Uint8Array): SolTransaction =>\n getTransactionDecoder().decode(bytes)\n\nexport const transactionToBytes = (tx: SolTransaction): Uint8Array =>\n new Uint8Array(getTransactionEncoder().encode(tx))\n\n/** base58 of the wire-format transaction — both legacy and v0, wire-compatible with web3.js */\nexport const serializeTransaction = (tx: SolTransaction): string =>\n base58.encode(transactionToBytes(tx))\n\nexport const deserializeTransaction = (transaction: string): SolTransaction =>\n transactionFromBytes(base58.decode(transaction))\n\n/** decoded compiled message — legacy and v0 wire formats are handled transparently */\nexport const getCompiledMessage = (tx: SolTransaction) =>\n getCompiledTransactionMessageDecoder().decode(tx.messageBytes)\n\n/**\n * Whether the bytes parse as a complete compiled transaction message (legacy or v0).\n * Wallets must refuse to sign such a payload as a \"message\": Solana software accounts sign raw\n * message bytes with no domain separator, so the resulting ed25519 signature would double as a\n * valid transaction signature.\n */\nexport const isCompiledTransactionMessage = (bytes: Uint8Array): boolean => {\n try {\n const [, offset] = getCompiledTransactionMessageDecoder().read(bytes, 0)\n return offset === bytes.length\n } catch {\n return false\n }\n}\n\n/** base64 of the compiled message bytes, the format `getFeeForMessage` expects */\nexport const getMessageBase64 = (tx: SolTransaction): TransactionMessageBytesBase64 =>\n getBase64Decoder().decode(tx.messageBytes) as TransactionMessageBytesBase64\n\nexport const buildUnsignedTransaction = ({\n feePayer,\n blockhash,\n lastValidBlockHeight,\n instructions,\n version = \"legacy\",\n}: {\n feePayer: string\n blockhash: string\n lastValidBlockHeight: bigint\n instructions: Instruction[]\n version?: \"legacy\" | 0\n}): SolTransaction =>\n pipe(\n createTransactionMessage({ version }),\n (m) => setTransactionMessageFeePayer(solAddress(feePayer), m),\n (m) =>\n setTransactionMessageLifetimeUsingBlockhash(\n { blockhash: blockhash as Blockhash, lastValidBlockHeight },\n m\n ),\n (m) => appendTransactionMessageInstructions(instructions, m),\n compileTransaction\n )\n\n/**\n * Returns a copy of the transaction with its lifetime token (recent blockhash) replaced,\n * re-encoding the compiled message. Existing signatures are reset to null — changing the\n * blockhash invalidates them.\n */\nexport const setTransactionBlockhash = (tx: SolTransaction, blockhash: string): SolTransaction => {\n const compiled = getCompiledTransactionMessageDecoder().decode(tx.messageBytes)\n const messageBytes = getCompiledTransactionMessageEncoder().encode({\n ...compiled,\n lifetimeToken: blockhash,\n }) as TransactionMessageBytes\n\n return Object.freeze({\n messageBytes,\n signatures: Object.freeze(\n Object.fromEntries(Object.keys(tx.signatures).map((address) => [address, null]))\n ) as SignaturesMap,\n })\n}\n\nexport const txToHumanJSON = (tx: string | SolTransaction) => {\n if (typeof tx === \"string\") tx = deserializeTransaction(tx)\n const message = getCompiledMessage(tx)\n const { header, staticAccounts } = message\n\n // standard account ordering: writable signers, readonly signers, writable non-signers, readonly non-signers\n const isSigner = (index: number) => index < header.numSignerAccounts\n const isWritable = (index: number) =>\n index < header.numSignerAccounts\n ? index < header.numSignerAccounts - header.numReadonlySignerAccounts\n : index < staticAccounts.length - header.numReadonlyNonSignerAccounts\n\n return {\n version: message.version,\n signatures: Object.values(tx.signatures).map((sig) => (sig ? base58.encode(sig) : null)),\n feePayer: staticAccounts[0] ?? null,\n recentBlockhash: \"lifetimeToken\" in message ? message.lifetimeToken : null,\n staticAccountKeys: staticAccounts as readonly string[],\n // ⚠️ NOTE: without address lookup table accounts we only have static keys.\n addressTableLookups:\n (\"addressTableLookups\" in message ? message.addressTableLookups : undefined)?.map((l) => ({\n accountKey: l.lookupTableAddress as string,\n writableIndexes: Array.from(l.writableIndexes),\n readonlyIndexes: Array.from(l.readonlyIndexes),\n })) ?? [],\n instructions: (\"instructions\" in message ? message.instructions : []).map((ix) => ({\n programIdIndex: ix.programAddressIndex,\n programId: staticAccounts[ix.programAddressIndex] ?? null,\n accounts: (ix.accountIndices ?? []).map((i) => ({\n index: i,\n pubkey: staticAccounts[i] ?? null,\n isSigner: isSigner(i),\n isWritable: isWritable(i),\n })),\n data: base58.encode((ix.data as Uint8Array | undefined) ?? new Uint8Array()),\n })),\n }\n}\n","import type { SignatureBytes } from \"@solana/kit\"\nimport { base58, ed25519, getPublicKeyFromSecret } from \"@talismn/crypto\"\n\nimport type { SolTransaction } from \"./transaction\"\n\n/**\n * Returns a copy of the transaction with `signature` attached for `address`.\n * Throws if `address` is not a required signer of the transaction (the signatures\n * map is keyed in wire order at decode time — adding a key would corrupt re-encoding).\n */\nexport const attachTransactionSignature = (\n tx: SolTransaction,\n address: string,\n signature: Uint8Array\n): SolTransaction => {\n if (!(address in tx.signatures))\n throw new Error(`Address ${address} is not a signer of this transaction`)\n\n return Object.freeze({\n ...tx,\n signatures: Object.freeze({ ...tx.signatures, [address]: signature as SignatureBytes }),\n })\n}\n\n/**\n * Returns the signature attached for `address`, verified against the transaction's message\n * bytes; null when missing, all-zeros, or invalid. Unlike `parseTransactionInfo`, this checks\n * a specific signer's slot, so it works on transactions with co-signers.\n */\nexport const getVerifiedTransactionSignature = (\n tx: SolTransaction,\n address: string\n): Uint8Array | null => {\n const signature = tx.signatures[address as keyof typeof tx.signatures]\n return signature &&\n ed25519.verify(signature, tx.messageBytes as unknown as Uint8Array, base58.decode(address))\n ? signature\n : null\n}\n\n/**\n * Signs the transaction's message bytes with the given ed25519 secret key and\n * attaches the signature. Signing happens with @noble/curves (via @talismn/crypto),\n * not WebCrypto — Ed25519 subtle crypto is too recent for the extension's support matrix.\n */\nexport const signTransactionWithSecretKey = (\n tx: SolTransaction,\n secretKey: Uint8Array,\n expectedAddress?: string\n): SolTransaction => {\n const address = base58.encode(getPublicKeyFromSecret(secretKey, \"solana\"))\n\n if (expectedAddress && address !== expectedAddress) throw new Error(\"Address mismatch\")\n\n const signature = ed25519.sign(tx.messageBytes as unknown as Uint8Array, secretKey)\n\n return attachTransactionSignature(tx, address, signature)\n}\n","import type { Transaction } from \"@solana/kit\"\nimport { base58 } from \"@talismn/crypto\"\n\nimport { getCompiledMessage } from \"./serialization\"\nimport { getVerifiedTransactionSignature } from \"./signing\"\n\n/**\n * A Solana transaction: raw wire message bytes plus a signer-address → signature map.\n * Kit's decoder/encoder handles both legacy and v0 wire formats transparently.\n */\nexport type SolTransaction = Transaction\n\nexport type SolTransactionInfo = {\n version: \"legacy\" | 0 | 1\n /** compiled lifetime token — the recent blockhash (or nonce for durable-nonce transactions) */\n recentBlockhash: string\n /** first static account, the account that pays the transaction fee */\n feePayer: string\n /** all required signer addresses, in wire order */\n signerAddresses: string[]\n /**\n * The account expected to sign in wallet flows.\n * `undefined` when the transaction has several signers (e.g. sponsored/partially-signed\n * dapp transactions) — callers use this to fall back to the dapp-provided address.\n */\n address: string | undefined\n /**\n * canonical (fee payer) base58 transaction signature, verified against the message bytes;\n * null when the fee payer hasn't signed\n */\n signature: string | null\n}\n\nexport const parseTransactionInfo = (tx: SolTransaction): SolTransactionInfo => {\n const message = getCompiledMessage(tx)\n const signerAddresses = Object.keys(tx.signatures)\n const feePayer = message.staticAccounts[0] as string\n\n // Behavior preserved from the web3.js implementation: legacy transactions always\n // resolve to the fee payer, versioned ones only when there is a single signer.\n const address =\n message.version === \"legacy\"\n ? signerAddresses[0]\n : signerAddresses.length === 1\n ? signerAddresses[0]\n : undefined\n\n // the canonical transaction signature is the fee payer's — may be missing or\n // all-zeros, so always verify against the message bytes\n const sigBytes = getVerifiedTransactionSignature(tx, feePayer)\n\n return {\n version: message.version,\n recentBlockhash: \"lifetimeToken\" in message ? message.lifetimeToken : \"\",\n feePayer,\n signerAddresses,\n address,\n signature: sigBytes ? base58.encode(sigBytes) : null,\n }\n}\n"],"mappings":";;;;AAAA,MAAa,gBAAgB;CAC3B;CACA;CACA;CACA;AACF;AAIA,MAAa,mBAAmB,UAAyB;CACvD,QAAQ,OAAR;EACE,KAAK,kBACH,OAAO;EACT,KAAK,iBACH,OAAO;EACT,KAAK,kBACH,OAAO;EACT,KAAK,mBACH,OAAO;EACT,SACE,MAAM,IAAI,MAAM,yBAAyB,OAAO;CACpD;AACF;;;ACVA,MAAM,iBAAiB,IAAI,WAAW,CACpC,KACA,GAAG,MAAM,KAAK,oBAAoB,MAAM,EAAE,WAAW,CAAC,CAAC,CACzD,CAAC;AAED,MAAM,4BAA4B;AAClC,MAAM,oBAAoB;AAG1B,MAAM,gBACJ,eAAe,SAAS,IAAI,4BAA4B,IAAI,IAAI,oBAAoB;;AAGtF,MAAM,qBAAqB,OAAO;AAElC,MAAM,0BAA0B;AAChC,MAAM,sBAAsB;AAE5B,MAAM,oBAAoB,YAAuC;CAC/D,IAAI,QAAQ,OAAO,SAAS,QAAQ,MAAQ,QAAQ,GAAI,GAAG,OAAO;CAElE,IAAI;EACF,IAAI,YAAY,SAAS,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,OAAO,OAAO;EACxD,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF;;;;;AAMA,MAAa,4BACX,SACA,oBACsB;CACtB,IAAI,QAAQ,WAAW,KAAK,QAAQ,SAAS,oBAAoB,OAAO;CACxE,IAAI,gBAAgB,WAAW,mBAAmB,OAAO;CAEzD,MAAM,SAAS,iBA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AE;CACrC,MAAM,kBAAkB,OAAO,KAAK,GAAG,UAAU;CACjD,MAAM,WAAW,QAAQ,eAAe;CAIxC,MAAM,UACJ,QAAQ,YAAY,WAChB,gBAAgB,KAChB,gBAAgB,WAAW,IACzB,gBAAgB,KAChB,KAAA;CAIR,MAAM,WAAW,gCAAgC,IAAI,QAAQ;CAE7D,OAAO;EACL,SAAS,QAAQ;EACjB,iBAAiB,mBAAmB,UAAU,QAAQ,gBAAgB;EACtE;EACA;EACA;EACA,WAAW,WAAWG,gBAAAA,OAAO,OAAO,QAAQ,IAAI;CAClD;AACF"}
1
+ {"version":3,"file":"index.js","names":["getTransactionDecoder","getTransactionEncoder","base58","getCompiledTransactionMessageDecoder","getBase64Decoder","pipe","createTransactionMessage","setTransactionMessageFeePayer","solAddress","setTransactionMessageLifetimeUsingBlockhash","appendTransactionMessageInstructions","compileTransaction","getCompiledTransactionMessageEncoder","ed25519","base58","getPublicKeyFromSecret","base58"],"sources":["../src/utils/chains.ts","../src/utils/offchainMessage.ts","../src/utils/serialization.ts","../src/utils/signing.ts","../src/utils/transaction.ts"],"sourcesContent":["export const SOLANA_CHAINS = [\n \"solana:mainnet\",\n \"solana:devnet\",\n \"solana:testnet\",\n \"solana:localnet\",\n] as const\n\nexport type SolanaChainId = (typeof SOLANA_CHAINS)[number]\n\nexport const getSolNetworkId = (chain: SolanaChainId) => {\n switch (chain) {\n case \"solana:mainnet\":\n return \"solana-mainnet\"\n case \"solana:devnet\":\n return \"solana-devnet\"\n case \"solana:testnet\":\n return \"solana-testnet\"\n case \"solana:localnet\":\n return \"solana-localnet\"\n default:\n throw new Error(`Unknown Solana chain: ${chain}`)\n }\n}\n","// Solana off-chain message envelope (v0), as specified by Anza and enforced by the Ledger app\n// (1.8.0+): https://github.com/anza-xyz/agave/blob/master/docs/src/proposals/off-chain-message-signing.md\n//\n// signing domain \"\\xffsolana offchain\" (16 bytes) || header version (1 byte, 0) ||\n// application domain (32 bytes, zeros = not provided) || message format (1 byte) ||\n// signer count (1 byte) || signers (32 bytes each) || message length (2 bytes LE) || message\n//\n// Hardware wallets refuse to sign arbitrary raw bytes - only transactions and messages wrapped\n// in this envelope, and the derivation path's public key must appear in the signers list.\n// Note this is NOT the format implemented by @solana/offchain-messages (kit), whose codec\n// details differ from what the Ledger app validates.\n\nconst SIGNING_DOMAIN = new Uint8Array([\n 0xff,\n ...Array.from(\"solana offchain\", (c) => c.charCodeAt(0)),\n])\n\nconst APPLICATION_DOMAIN_LENGTH = 32\nconst PUBLIC_KEY_LENGTH = 32\n\n// domain + version + application domain + format + signer count + one signer + length\nconst HEADER_LENGTH =\n SIGNING_DOMAIN.length + 1 + APPLICATION_DOMAIN_LENGTH + 1 + 1 + PUBLIC_KEY_LENGTH + 2\n\n/** Hardware wallet compatible v0 messages are capped at 1232 bytes total, header included */\nconst MAX_MESSAGE_LENGTH = 1232 - HEADER_LENGTH\n\nconst FORMAT_RESTRICTED_ASCII = 0\nconst FORMAT_LIMITED_UTF8 = 1\n\nconst getMessageFormat = (message: Uint8Array): number | null => {\n if (message.every((byte) => byte >= 0x20 && byte <= 0x7e)) return FORMAT_RESTRICTED_ASCII\n\n try {\n new TextDecoder(\"utf-8\", { fatal: true }).decode(message)\n return FORMAT_LIMITED_UTF8\n } catch {\n return null // binary content cannot be wrapped\n }\n}\n\n/**\n * Wraps a raw message in the off-chain message envelope that hardware wallets sign.\n * Returns `null` if the message cannot be wrapped (binary content, empty, or too long).\n */\nexport const serializeOffchainMessage = (\n message: Uint8Array,\n signerPublicKey: Uint8Array\n): Uint8Array | null => {\n if (message.length === 0 || message.length > MAX_MESSAGE_LENGTH) return null\n if (signerPublicKey.length !== PUBLIC_KEY_LENGTH) return null\n\n const format = getMessageFormat(message)\n if (format === null) return null\n\n const envelope = new Uint8Array(HEADER_LENGTH + message.length)\n let offset = 0\n\n envelope.set(SIGNING_DOMAIN, offset)\n offset += SIGNING_DOMAIN.length\n\n envelope[offset++] = 0 // header version\n\n offset += APPLICATION_DOMAIN_LENGTH // application domain: zeros = not provided\n\n envelope[offset++] = format\n envelope[offset++] = 1 // signer count\n\n envelope.set(signerPublicKey, offset)\n offset += PUBLIC_KEY_LENGTH\n\n envelope[offset++] = message.length & 0xff\n envelope[offset++] = message.length >> 8\n\n envelope.set(message, offset)\n\n return envelope\n}\n","import type {\n Blockhash,\n Instruction,\n SignaturesMap,\n TransactionMessageBytes,\n TransactionMessageBytesBase64,\n} from \"@solana/kit\"\nimport {\n appendTransactionMessageInstructions,\n compileTransaction,\n createTransactionMessage,\n getBase64Decoder,\n getCompiledTransactionMessageDecoder,\n getCompiledTransactionMessageEncoder,\n getTransactionDecoder,\n getTransactionEncoder,\n pipe,\n setTransactionMessageFeePayer,\n setTransactionMessageLifetimeUsingBlockhash,\n address as solAddress,\n} from \"@solana/kit\"\nimport { base58 } from \"@talismn/crypto\"\n\nimport type { SolTransaction } from \"./transaction\"\n\nexport const transactionFromBytes = (bytes: Uint8Array): SolTransaction =>\n getTransactionDecoder().decode(bytes)\n\nexport const transactionToBytes = (tx: SolTransaction): Uint8Array =>\n new Uint8Array(getTransactionEncoder().encode(tx))\n\n/** base58 of the wire-format transaction — both legacy and v0, wire-compatible with web3.js */\nexport const serializeTransaction = (tx: SolTransaction): string =>\n base58.encode(transactionToBytes(tx))\n\nexport const deserializeTransaction = (transaction: string): SolTransaction =>\n transactionFromBytes(base58.decode(transaction))\n\n/** decoded compiled message — legacy and v0 wire formats are handled transparently */\nexport const getCompiledMessage = (tx: SolTransaction) =>\n getCompiledTransactionMessageDecoder().decode(tx.messageBytes)\n\n/**\n * Whether the bytes parse as a complete compiled transaction message (legacy or v0).\n * Wallets must refuse to sign such a payload as a \"message\": Solana software accounts sign raw\n * message bytes with no domain separator, so the resulting ed25519 signature would double as a\n * valid transaction signature.\n */\nexport const isCompiledTransactionMessage = (bytes: Uint8Array): boolean => {\n try {\n const [, offset] = getCompiledTransactionMessageDecoder().read(bytes, 0)\n return offset === bytes.length\n } catch {\n return false\n }\n}\n\n/** base64 of the compiled message bytes, the format `getFeeForMessage` expects */\nexport const getMessageBase64 = (tx: SolTransaction): TransactionMessageBytesBase64 =>\n getBase64Decoder().decode(tx.messageBytes) as TransactionMessageBytesBase64\n\nexport const buildUnsignedTransaction = ({\n feePayer,\n blockhash,\n lastValidBlockHeight,\n instructions,\n version = \"legacy\",\n}: {\n feePayer: string\n blockhash: string\n lastValidBlockHeight: bigint\n instructions: Instruction[]\n version?: \"legacy\" | 0\n}): SolTransaction =>\n pipe(\n createTransactionMessage({ version }),\n (m) => setTransactionMessageFeePayer(solAddress(feePayer), m),\n (m) =>\n setTransactionMessageLifetimeUsingBlockhash(\n { blockhash: blockhash as Blockhash, lastValidBlockHeight },\n m\n ),\n (m) => appendTransactionMessageInstructions(instructions, m),\n compileTransaction\n )\n\n/**\n * Returns a copy of the transaction with its lifetime token (recent blockhash) replaced,\n * re-encoding the compiled message. Existing signatures are reset to null — changing the\n * blockhash invalidates them.\n */\nexport const setTransactionBlockhash = (tx: SolTransaction, blockhash: string): SolTransaction => {\n const compiled = getCompiledTransactionMessageDecoder().decode(tx.messageBytes)\n const messageBytes = getCompiledTransactionMessageEncoder().encode({\n ...compiled,\n lifetimeToken: blockhash,\n }) as TransactionMessageBytes\n\n return Object.freeze({\n messageBytes,\n signatures: Object.freeze(\n Object.fromEntries(Object.keys(tx.signatures).map((address) => [address, null]))\n ) as SignaturesMap,\n })\n}\n\nexport const txToHumanJSON = (tx: string | SolTransaction) => {\n if (typeof tx === \"string\") tx = deserializeTransaction(tx)\n const message = getCompiledMessage(tx)\n const { header, staticAccounts } = message\n\n // standard account ordering: writable signers, readonly signers, writable non-signers, readonly non-signers\n const isSigner = (index: number) => index < header.numSignerAccounts\n const isWritable = (index: number) =>\n index < header.numSignerAccounts\n ? index < header.numSignerAccounts - header.numReadonlySignerAccounts\n : index < staticAccounts.length - header.numReadonlyNonSignerAccounts\n\n return {\n version: message.version,\n signatures: Object.values(tx.signatures).map((sig) => (sig ? base58.encode(sig) : null)),\n feePayer: staticAccounts[0] ?? null,\n recentBlockhash: \"lifetimeToken\" in message ? message.lifetimeToken : null,\n staticAccountKeys: staticAccounts as readonly string[],\n // ⚠️ NOTE: without address lookup table accounts we only have static keys.\n addressTableLookups:\n (\"addressTableLookups\" in message ? message.addressTableLookups : undefined)?.map((l) => ({\n accountKey: l.lookupTableAddress as string,\n writableIndexes: Array.from(l.writableIndexes),\n readonlyIndexes: Array.from(l.readonlyIndexes),\n })) ?? [],\n instructions: (\"instructions\" in message ? message.instructions : []).map((ix) => ({\n programIdIndex: ix.programAddressIndex,\n programId: staticAccounts[ix.programAddressIndex] ?? null,\n accounts: (ix.accountIndices ?? []).map((i) => ({\n index: i,\n pubkey: staticAccounts[i] ?? null,\n isSigner: isSigner(i),\n isWritable: isWritable(i),\n })),\n data: base58.encode((ix.data as Uint8Array | undefined) ?? new Uint8Array()),\n })),\n }\n}\n","import type { SignatureBytes } from \"@solana/kit\"\nimport { base58, ed25519, getPublicKeyFromSecret } from \"@talismn/crypto\"\n\nimport type { SolTransaction } from \"./transaction\"\n\n/**\n * Returns a copy of the transaction with `signature` attached for `address`.\n * Throws if `address` is not a required signer of the transaction (the signatures\n * map is keyed in wire order at decode time — adding a key would corrupt re-encoding).\n */\nexport const attachTransactionSignature = (\n tx: SolTransaction,\n address: string,\n signature: Uint8Array\n): SolTransaction => {\n if (!(address in tx.signatures))\n throw new Error(`Address ${address} is not a signer of this transaction`)\n\n return Object.freeze({\n ...tx,\n signatures: Object.freeze({ ...tx.signatures, [address]: signature as SignatureBytes }),\n })\n}\n\n/**\n * Returns the signature attached for `address`, verified against the transaction's message\n * bytes; null when missing, all-zeros, or invalid. Unlike `parseTransactionInfo`, this checks\n * a specific signer's slot, so it works on transactions with co-signers.\n */\nexport const getVerifiedTransactionSignature = (\n tx: SolTransaction,\n address: string\n): Uint8Array | null => {\n const signature = tx.signatures[address as keyof typeof tx.signatures]\n return signature &&\n ed25519.verify(signature, tx.messageBytes as unknown as Uint8Array, base58.decode(address))\n ? signature\n : null\n}\n\n/**\n * Signs the transaction's message bytes with the given ed25519 secret key and\n * attaches the signature. Signing happens with @noble/curves (via @talismn/crypto),\n * not WebCrypto — Ed25519 subtle crypto is too recent for the extension's support matrix.\n */\nexport const signTransactionWithSecretKey = (\n tx: SolTransaction,\n secretKey: Uint8Array,\n expectedAddress?: string\n): SolTransaction => {\n const address = base58.encode(getPublicKeyFromSecret(secretKey, \"solana\"))\n\n if (expectedAddress && address !== expectedAddress) throw new Error(\"Address mismatch\")\n\n const signature = ed25519.sign(tx.messageBytes as unknown as Uint8Array, secretKey)\n\n return attachTransactionSignature(tx, address, signature)\n}\n","import type { Transaction } from \"@solana/kit\"\nimport { base58 } from \"@talismn/crypto\"\n\nimport { getCompiledMessage } from \"./serialization\"\nimport { getVerifiedTransactionSignature } from \"./signing\"\n\n/**\n * A Solana transaction: raw wire message bytes plus a signer-address → signature map.\n * Kit's decoder/encoder handles both legacy and v0 wire formats transparently.\n */\nexport type SolTransaction = Transaction\n\nexport type SolTransactionInfo = {\n version: \"legacy\" | 0 | 1\n /** compiled lifetime token — the recent blockhash (or nonce for durable-nonce transactions) */\n recentBlockhash: string\n /** first static account, the account that pays the transaction fee */\n feePayer: string\n /** all required signer addresses, in wire order */\n signerAddresses: string[]\n /**\n * The account expected to sign in wallet flows.\n * `undefined` when the transaction has several signers (e.g. sponsored/partially-signed\n * dapp transactions) — callers use this to fall back to the dapp-provided address.\n */\n address: string | undefined\n /**\n * canonical (fee payer) base58 transaction signature, verified against the message bytes;\n * null when the fee payer hasn't signed\n */\n signature: string | null\n}\n\nexport const parseTransactionInfo = (tx: SolTransaction): SolTransactionInfo => {\n const message = getCompiledMessage(tx)\n const signerAddresses = Object.keys(tx.signatures)\n const feePayer = message.staticAccounts[0] as string\n\n // Behavior preserved from the web3.js implementation: legacy transactions always\n // resolve to the fee payer, versioned ones only when there is a single signer.\n const address =\n message.version === \"legacy\"\n ? signerAddresses[0]\n : signerAddresses.length === 1\n ? signerAddresses[0]\n : undefined\n\n // the canonical transaction signature is the fee payer's — may be missing or\n // all-zeros, so always verify against the message bytes\n const sigBytes = getVerifiedTransactionSignature(tx, feePayer)\n\n return {\n version: message.version,\n recentBlockhash: \"lifetimeToken\" in message ? message.lifetimeToken : \"\",\n feePayer,\n signerAddresses,\n address,\n signature: sigBytes ? base58.encode(sigBytes) : null,\n }\n}\n"],"mappings":";;;;AAAA,MAAa,gBAAgB;CAC3B;CACA;CACA;CACA;AACF;AAIA,MAAa,mBAAmB,UAAyB;CACvD,QAAQ,OAAR;EACE,KAAK,kBACH,OAAO;EACT,KAAK,iBACH,OAAO;EACT,KAAK,kBACH,OAAO;EACT,KAAK,mBACH,OAAO;EACT,SACE,MAAM,IAAI,MAAM,yBAAyB,OAAO;CACpD;AACF;;ACVA,MAAM,iBAAiB,IAAI,WAAW,CACpC,KACA,GAAG,MAAM,KAAK,oBAAoB,MAAM,EAAE,WAAW,CAAC,CAAC,CACzD,CAAC;AAED,MAAM,4BAA4B;AAClC,MAAM,oBAAoB;AAG1B,MAAM,gBACJ,eAAe,SAAS,IAAI,4BAA4B,IAAI,IAAI,oBAAoB;;AAGtF,MAAM,qBAAqB,OAAO;AAElC,MAAM,0BAA0B;AAChC,MAAM,sBAAsB;AAE5B,MAAM,oBAAoB,YAAuC;CAC/D,IAAI,QAAQ,OAAO,SAAS,QAAQ,MAAQ,QAAQ,GAAI,GAAG,OAAO;CAElE,IAAI;EACF,IAAI,YAAY,SAAS,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,OAAO,OAAO;EACxD,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF;;;;;AAMA,MAAa,4BACX,SACA,oBACsB;CACtB,IAAI,QAAQ,WAAW,KAAK,QAAQ,SAAS,oBAAoB,OAAO;CACxE,IAAI,gBAAgB,WAAW,mBAAmB,OAAO;CAEzD,MAAM,SAAS,iBAAiB,OAAO;CACvC,IAAI,WAAW,MAAM,OAAO;CAE5B,MAAM,WAAW,IAAI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AQ,eAAe;CAIxC,MAAM,UACJ,QAAQ,YAAY,WAChB,gBAAgB,KAChB,gBAAgB,WAAW,IACzB,gBAAgB,KAChB,KAAA;CAIR,MAAM,WAAW,gCAAgC,IAAI,QAAQ;CAE7D,OAAO;EACL,SAAS,QAAQ;EACjB,iBAAiB,mBAAmB,UAAU,QAAQ,gBAAgB;EACtE;EACA;EACA;EACA,WAAW,WAAWG,gBAAAA,OAAO,OAAO,QAAQ,IAAI;CAClD;AACF"}
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { address, appendTransactionMessageInstructions, compileTransaction, createTransactionMessage, getBase64Decoder, getCompiledTransactionMessageDecoder, getCompiledTransactionMessageEncoder, getTransactionDecoder, getTransactionEncoder, pipe, setTransactionMessageFeePayer, setTransactionMessageLifetimeUsingBlockhash } from "@solana/kit";
2
2
  import { base58, ed25519, getPublicKeyFromSecret } from "@talismn/crypto";
3
- //#region src/utils/chains.ts
3
+ // src/utils/chains.ts
4
4
  const SOLANA_CHAINS = [
5
5
  "solana:mainnet",
6
6
  "solana:devnet",
@@ -16,8 +16,7 @@ const getSolNetworkId = (chain) => {
16
16
  default: throw new Error(`Unknown Solana chain: ${chain}`);
17
17
  }
18
18
  };
19
- //#endregion
20
- //#region src/utils/offchainMessage.ts
19
+ // src/utils/offchainMessage.ts
21
20
  const SIGNING_DOMAIN = new Uint8Array([255, ...Array.from("solana offchain", (c) => c.charCodeAt(0))]);
22
21
  const APPLICATION_DOMAIN_LENGTH = 32;
23
22
  const PUBLIC_KEY_LENGTH = 32;
@@ -59,8 +58,7 @@ const serializeOffchainMessage = (message, signerPublicKey) => {
59
58
  envelope.set(message, offset);
60
59
  return envelope;
61
60
  };
62
- //#endregion
63
- //#region src/utils/serialization.ts
61
+ // src/utils/serialization.ts
64
62
  const transactionFromBytes = (bytes) => getTransactionDecoder().decode(bytes);
65
63
  const transactionToBytes = (tx) => new Uint8Array(getTransactionEncoder().encode(tx));
66
64
  /** base58 of the wire-format transaction — both legacy and v0, wire-compatible with web3.js */
@@ -134,8 +132,7 @@ const txToHumanJSON = (tx) => {
134
132
  }))
135
133
  };
136
134
  };
137
- //#endregion
138
- //#region src/utils/signing.ts
135
+ // src/utils/signing.ts
139
136
  /**
140
137
  * Returns a copy of the transaction with `signature` attached for `address`.
141
138
  * Throws if `address` is not a required signer of the transaction (the signatures
@@ -171,8 +168,7 @@ const signTransactionWithSecretKey = (tx, secretKey, expectedAddress) => {
171
168
  const signature = ed25519.sign(tx.messageBytes, secretKey);
172
169
  return attachTransactionSignature(tx, address, signature);
173
170
  };
174
- //#endregion
175
- //#region src/utils/transaction.ts
171
+ // src/utils/transaction.ts
176
172
  const parseTransactionInfo = (tx) => {
177
173
  const message = getCompiledMessage(tx);
178
174
  const signerAddresses = Object.keys(tx.signatures);
@@ -188,7 +184,6 @@ const parseTransactionInfo = (tx) => {
188
184
  signature: sigBytes ? base58.encode(sigBytes) : null
189
185
  };
190
186
  };
191
- //#endregion
192
187
  export { SOLANA_CHAINS, attachTransactionSignature, buildUnsignedTransaction, deserializeTransaction, getCompiledMessage, getMessageBase64, getSolNetworkId, getVerifiedTransactionSignature, isCompiledTransactionMessage, parseTransactionInfo, serializeOffchainMessage, serializeTransaction, setTransactionBlockhash, signTransactionWithSecretKey, transactionFromBytes, transactionToBytes, txToHumanJSON };
193
188
 
194
189
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["solAddress"],"sources":["../src/utils/chains.ts","../src/utils/offchainMessage.ts","../src/utils/serialization.ts","../src/utils/signing.ts","../src/utils/transaction.ts"],"sourcesContent":["export const SOLANA_CHAINS = [\n \"solana:mainnet\",\n \"solana:devnet\",\n \"solana:testnet\",\n \"solana:localnet\",\n] as const\n\nexport type SolanaChainId = (typeof SOLANA_CHAINS)[number]\n\nexport const getSolNetworkId = (chain: SolanaChainId) => {\n switch (chain) {\n case \"solana:mainnet\":\n return \"solana-mainnet\"\n case \"solana:devnet\":\n return \"solana-devnet\"\n case \"solana:testnet\":\n return \"solana-testnet\"\n case \"solana:localnet\":\n return \"solana-localnet\"\n default:\n throw new Error(`Unknown Solana chain: ${chain}`)\n }\n}\n","// Solana off-chain message envelope (v0), as specified by Anza and enforced by the Ledger app\n// (1.8.0+): https://github.com/anza-xyz/agave/blob/master/docs/src/proposals/off-chain-message-signing.md\n//\n// signing domain \"\\xffsolana offchain\" (16 bytes) || header version (1 byte, 0) ||\n// application domain (32 bytes, zeros = not provided) || message format (1 byte) ||\n// signer count (1 byte) || signers (32 bytes each) || message length (2 bytes LE) || message\n//\n// Hardware wallets refuse to sign arbitrary raw bytes - only transactions and messages wrapped\n// in this envelope, and the derivation path's public key must appear in the signers list.\n// Note this is NOT the format implemented by @solana/offchain-messages (kit), whose codec\n// details differ from what the Ledger app validates.\n\nconst SIGNING_DOMAIN = new Uint8Array([\n 0xff,\n ...Array.from(\"solana offchain\", (c) => c.charCodeAt(0)),\n])\n\nconst APPLICATION_DOMAIN_LENGTH = 32\nconst PUBLIC_KEY_LENGTH = 32\n\n// domain + version + application domain + format + signer count + one signer + length\nconst HEADER_LENGTH =\n SIGNING_DOMAIN.length + 1 + APPLICATION_DOMAIN_LENGTH + 1 + 1 + PUBLIC_KEY_LENGTH + 2\n\n/** Hardware wallet compatible v0 messages are capped at 1232 bytes total, header included */\nconst MAX_MESSAGE_LENGTH = 1232 - HEADER_LENGTH\n\nconst FORMAT_RESTRICTED_ASCII = 0\nconst FORMAT_LIMITED_UTF8 = 1\n\nconst getMessageFormat = (message: Uint8Array): number | null => {\n if (message.every((byte) => byte >= 0x20 && byte <= 0x7e)) return FORMAT_RESTRICTED_ASCII\n\n try {\n new TextDecoder(\"utf-8\", { fatal: true }).decode(message)\n return FORMAT_LIMITED_UTF8\n } catch {\n return null // binary content cannot be wrapped\n }\n}\n\n/**\n * Wraps a raw message in the off-chain message envelope that hardware wallets sign.\n * Returns `null` if the message cannot be wrapped (binary content, empty, or too long).\n */\nexport const serializeOffchainMessage = (\n message: Uint8Array,\n signerPublicKey: Uint8Array\n): Uint8Array | null => {\n if (message.length === 0 || message.length > MAX_MESSAGE_LENGTH) return null\n if (signerPublicKey.length !== PUBLIC_KEY_LENGTH) return null\n\n const format = getMessageFormat(message)\n if (format === null) return null\n\n const envelope = new Uint8Array(HEADER_LENGTH + message.length)\n let offset = 0\n\n envelope.set(SIGNING_DOMAIN, offset)\n offset += SIGNING_DOMAIN.length\n\n envelope[offset++] = 0 // header version\n\n offset += APPLICATION_DOMAIN_LENGTH // application domain: zeros = not provided\n\n envelope[offset++] = format\n envelope[offset++] = 1 // signer count\n\n envelope.set(signerPublicKey, offset)\n offset += PUBLIC_KEY_LENGTH\n\n envelope[offset++] = message.length & 0xff\n envelope[offset++] = message.length >> 8\n\n envelope.set(message, offset)\n\n return envelope\n}\n","import type {\n Blockhash,\n Instruction,\n SignaturesMap,\n TransactionMessageBytes,\n TransactionMessageBytesBase64,\n} from \"@solana/kit\"\nimport {\n appendTransactionMessageInstructions,\n compileTransaction,\n createTransactionMessage,\n getBase64Decoder,\n getCompiledTransactionMessageDecoder,\n getCompiledTransactionMessageEncoder,\n getTransactionDecoder,\n getTransactionEncoder,\n pipe,\n setTransactionMessageFeePayer,\n setTransactionMessageLifetimeUsingBlockhash,\n address as solAddress,\n} from \"@solana/kit\"\nimport { base58 } from \"@talismn/crypto\"\n\nimport type { SolTransaction } from \"./transaction\"\n\nexport const transactionFromBytes = (bytes: Uint8Array): SolTransaction =>\n getTransactionDecoder().decode(bytes)\n\nexport const transactionToBytes = (tx: SolTransaction): Uint8Array =>\n new Uint8Array(getTransactionEncoder().encode(tx))\n\n/** base58 of the wire-format transaction — both legacy and v0, wire-compatible with web3.js */\nexport const serializeTransaction = (tx: SolTransaction): string =>\n base58.encode(transactionToBytes(tx))\n\nexport const deserializeTransaction = (transaction: string): SolTransaction =>\n transactionFromBytes(base58.decode(transaction))\n\n/** decoded compiled message — legacy and v0 wire formats are handled transparently */\nexport const getCompiledMessage = (tx: SolTransaction) =>\n getCompiledTransactionMessageDecoder().decode(tx.messageBytes)\n\n/**\n * Whether the bytes parse as a complete compiled transaction message (legacy or v0).\n * Wallets must refuse to sign such a payload as a \"message\": Solana software accounts sign raw\n * message bytes with no domain separator, so the resulting ed25519 signature would double as a\n * valid transaction signature.\n */\nexport const isCompiledTransactionMessage = (bytes: Uint8Array): boolean => {\n try {\n const [, offset] = getCompiledTransactionMessageDecoder().read(bytes, 0)\n return offset === bytes.length\n } catch {\n return false\n }\n}\n\n/** base64 of the compiled message bytes, the format `getFeeForMessage` expects */\nexport const getMessageBase64 = (tx: SolTransaction): TransactionMessageBytesBase64 =>\n getBase64Decoder().decode(tx.messageBytes) as TransactionMessageBytesBase64\n\nexport const buildUnsignedTransaction = ({\n feePayer,\n blockhash,\n lastValidBlockHeight,\n instructions,\n version = \"legacy\",\n}: {\n feePayer: string\n blockhash: string\n lastValidBlockHeight: bigint\n instructions: Instruction[]\n version?: \"legacy\" | 0\n}): SolTransaction =>\n pipe(\n createTransactionMessage({ version }),\n (m) => setTransactionMessageFeePayer(solAddress(feePayer), m),\n (m) =>\n setTransactionMessageLifetimeUsingBlockhash(\n { blockhash: blockhash as Blockhash, lastValidBlockHeight },\n m\n ),\n (m) => appendTransactionMessageInstructions(instructions, m),\n compileTransaction\n )\n\n/**\n * Returns a copy of the transaction with its lifetime token (recent blockhash) replaced,\n * re-encoding the compiled message. Existing signatures are reset to null — changing the\n * blockhash invalidates them.\n */\nexport const setTransactionBlockhash = (tx: SolTransaction, blockhash: string): SolTransaction => {\n const compiled = getCompiledTransactionMessageDecoder().decode(tx.messageBytes)\n const messageBytes = getCompiledTransactionMessageEncoder().encode({\n ...compiled,\n lifetimeToken: blockhash,\n }) as TransactionMessageBytes\n\n return Object.freeze({\n messageBytes,\n signatures: Object.freeze(\n Object.fromEntries(Object.keys(tx.signatures).map((address) => [address, null]))\n ) as SignaturesMap,\n })\n}\n\nexport const txToHumanJSON = (tx: string | SolTransaction) => {\n if (typeof tx === \"string\") tx = deserializeTransaction(tx)\n const message = getCompiledMessage(tx)\n const { header, staticAccounts } = message\n\n // standard account ordering: writable signers, readonly signers, writable non-signers, readonly non-signers\n const isSigner = (index: number) => index < header.numSignerAccounts\n const isWritable = (index: number) =>\n index < header.numSignerAccounts\n ? index < header.numSignerAccounts - header.numReadonlySignerAccounts\n : index < staticAccounts.length - header.numReadonlyNonSignerAccounts\n\n return {\n version: message.version,\n signatures: Object.values(tx.signatures).map((sig) => (sig ? base58.encode(sig) : null)),\n feePayer: staticAccounts[0] ?? null,\n recentBlockhash: \"lifetimeToken\" in message ? message.lifetimeToken : null,\n staticAccountKeys: staticAccounts as readonly string[],\n // ⚠️ NOTE: without address lookup table accounts we only have static keys.\n addressTableLookups:\n (\"addressTableLookups\" in message ? message.addressTableLookups : undefined)?.map((l) => ({\n accountKey: l.lookupTableAddress as string,\n writableIndexes: Array.from(l.writableIndexes),\n readonlyIndexes: Array.from(l.readonlyIndexes),\n })) ?? [],\n instructions: (\"instructions\" in message ? message.instructions : []).map((ix) => ({\n programIdIndex: ix.programAddressIndex,\n programId: staticAccounts[ix.programAddressIndex] ?? null,\n accounts: (ix.accountIndices ?? []).map((i) => ({\n index: i,\n pubkey: staticAccounts[i] ?? null,\n isSigner: isSigner(i),\n isWritable: isWritable(i),\n })),\n data: base58.encode((ix.data as Uint8Array | undefined) ?? new Uint8Array()),\n })),\n }\n}\n","import type { SignatureBytes } from \"@solana/kit\"\nimport { base58, ed25519, getPublicKeyFromSecret } from \"@talismn/crypto\"\n\nimport type { SolTransaction } from \"./transaction\"\n\n/**\n * Returns a copy of the transaction with `signature` attached for `address`.\n * Throws if `address` is not a required signer of the transaction (the signatures\n * map is keyed in wire order at decode time — adding a key would corrupt re-encoding).\n */\nexport const attachTransactionSignature = (\n tx: SolTransaction,\n address: string,\n signature: Uint8Array\n): SolTransaction => {\n if (!(address in tx.signatures))\n throw new Error(`Address ${address} is not a signer of this transaction`)\n\n return Object.freeze({\n ...tx,\n signatures: Object.freeze({ ...tx.signatures, [address]: signature as SignatureBytes }),\n })\n}\n\n/**\n * Returns the signature attached for `address`, verified against the transaction's message\n * bytes; null when missing, all-zeros, or invalid. Unlike `parseTransactionInfo`, this checks\n * a specific signer's slot, so it works on transactions with co-signers.\n */\nexport const getVerifiedTransactionSignature = (\n tx: SolTransaction,\n address: string\n): Uint8Array | null => {\n const signature = tx.signatures[address as keyof typeof tx.signatures]\n return signature &&\n ed25519.verify(signature, tx.messageBytes as unknown as Uint8Array, base58.decode(address))\n ? signature\n : null\n}\n\n/**\n * Signs the transaction's message bytes with the given ed25519 secret key and\n * attaches the signature. Signing happens with @noble/curves (via @talismn/crypto),\n * not WebCrypto — Ed25519 subtle crypto is too recent for the extension's support matrix.\n */\nexport const signTransactionWithSecretKey = (\n tx: SolTransaction,\n secretKey: Uint8Array,\n expectedAddress?: string\n): SolTransaction => {\n const address = base58.encode(getPublicKeyFromSecret(secretKey, \"solana\"))\n\n if (expectedAddress && address !== expectedAddress) throw new Error(\"Address mismatch\")\n\n const signature = ed25519.sign(tx.messageBytes as unknown as Uint8Array, secretKey)\n\n return attachTransactionSignature(tx, address, signature)\n}\n","import type { Transaction } from \"@solana/kit\"\nimport { base58 } from \"@talismn/crypto\"\n\nimport { getCompiledMessage } from \"./serialization\"\nimport { getVerifiedTransactionSignature } from \"./signing\"\n\n/**\n * A Solana transaction: raw wire message bytes plus a signer-address → signature map.\n * Kit's decoder/encoder handles both legacy and v0 wire formats transparently.\n */\nexport type SolTransaction = Transaction\n\nexport type SolTransactionInfo = {\n version: \"legacy\" | 0 | 1\n /** compiled lifetime token — the recent blockhash (or nonce for durable-nonce transactions) */\n recentBlockhash: string\n /** first static account, the account that pays the transaction fee */\n feePayer: string\n /** all required signer addresses, in wire order */\n signerAddresses: string[]\n /**\n * The account expected to sign in wallet flows.\n * `undefined` when the transaction has several signers (e.g. sponsored/partially-signed\n * dapp transactions) — callers use this to fall back to the dapp-provided address.\n */\n address: string | undefined\n /**\n * canonical (fee payer) base58 transaction signature, verified against the message bytes;\n * null when the fee payer hasn't signed\n */\n signature: string | null\n}\n\nexport const parseTransactionInfo = (tx: SolTransaction): SolTransactionInfo => {\n const message = getCompiledMessage(tx)\n const signerAddresses = Object.keys(tx.signatures)\n const feePayer = message.staticAccounts[0] as string\n\n // Behavior preserved from the web3.js implementation: legacy transactions always\n // resolve to the fee payer, versioned ones only when there is a single signer.\n const address =\n message.version === \"legacy\"\n ? signerAddresses[0]\n : signerAddresses.length === 1\n ? signerAddresses[0]\n : undefined\n\n // the canonical transaction signature is the fee payer's — may be missing or\n // all-zeros, so always verify against the message bytes\n const sigBytes = getVerifiedTransactionSignature(tx, feePayer)\n\n return {\n version: message.version,\n recentBlockhash: \"lifetimeToken\" in message ? message.lifetimeToken : \"\",\n feePayer,\n signerAddresses,\n address,\n signature: sigBytes ? base58.encode(sigBytes) : null,\n }\n}\n"],"mappings":";;;AAAA,MAAa,gBAAgB;CAC3B;CACA;CACA;CACA;AACF;AAIA,MAAa,mBAAmB,UAAyB;CACvD,QAAQ,OAAR;EACE,KAAK,kBACH,OAAO;EACT,KAAK,iBACH,OAAO;EACT,KAAK,kBACH,OAAO;EACT,KAAK,mBACH,OAAO;EACT,SACE,MAAM,IAAI,MAAM,yBAAyB,OAAO;CACpD;AACF;;;ACVA,MAAM,iBAAiB,IAAI,WAAW,CACpC,KACA,GAAG,MAAM,KAAK,oBAAoB,MAAM,EAAE,WAAW,CAAC,CAAC,CACzD,CAAC;AAED,MAAM,4BAA4B;AAClC,MAAM,oBAAoB;AAG1B,MAAM,gBACJ,eAAe,SAAS,IAAI,4BAA4B,IAAI,IAAI,oBAAoB;;AAGtF,MAAM,qBAAqB,OAAO;AAElC,MAAM,0BAA0B;AAChC,MAAM,sBAAsB;AAE5B,MAAM,oBAAoB,YAAuC;CAC/D,IAAI,QAAQ,OAAO,SAAS,QAAQ,MAAQ,QAAQ,GAAI,GAAG,OAAO;CAElE,IAAI;EACF,IAAI,YAAY,SAAS,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AW,IACzB,gBAAgB,KAChB,KAAA;CAIR,MAAM,WAAW,gCAAgC,IAAI,QAAQ;CAE7D,OAAO;EACL,SAAS,QAAQ;EACjB,iBAAiB,mBAAmB,UAAU,QAAQ,gBAAgB;EACtE;EACA;EACA;EACA,WAAW,WAAW,OAAO,OAAO,QAAQ,IAAI;CAClD;AACF"}
1
+ {"version":3,"file":"index.mjs","names":["solAddress"],"sources":["../src/utils/chains.ts","../src/utils/offchainMessage.ts","../src/utils/serialization.ts","../src/utils/signing.ts","../src/utils/transaction.ts"],"sourcesContent":["export const SOLANA_CHAINS = [\n \"solana:mainnet\",\n \"solana:devnet\",\n \"solana:testnet\",\n \"solana:localnet\",\n] as const\n\nexport type SolanaChainId = (typeof SOLANA_CHAINS)[number]\n\nexport const getSolNetworkId = (chain: SolanaChainId) => {\n switch (chain) {\n case \"solana:mainnet\":\n return \"solana-mainnet\"\n case \"solana:devnet\":\n return \"solana-devnet\"\n case \"solana:testnet\":\n return \"solana-testnet\"\n case \"solana:localnet\":\n return \"solana-localnet\"\n default:\n throw new Error(`Unknown Solana chain: ${chain}`)\n }\n}\n","// Solana off-chain message envelope (v0), as specified by Anza and enforced by the Ledger app\n// (1.8.0+): https://github.com/anza-xyz/agave/blob/master/docs/src/proposals/off-chain-message-signing.md\n//\n// signing domain \"\\xffsolana offchain\" (16 bytes) || header version (1 byte, 0) ||\n// application domain (32 bytes, zeros = not provided) || message format (1 byte) ||\n// signer count (1 byte) || signers (32 bytes each) || message length (2 bytes LE) || message\n//\n// Hardware wallets refuse to sign arbitrary raw bytes - only transactions and messages wrapped\n// in this envelope, and the derivation path's public key must appear in the signers list.\n// Note this is NOT the format implemented by @solana/offchain-messages (kit), whose codec\n// details differ from what the Ledger app validates.\n\nconst SIGNING_DOMAIN = new Uint8Array([\n 0xff,\n ...Array.from(\"solana offchain\", (c) => c.charCodeAt(0)),\n])\n\nconst APPLICATION_DOMAIN_LENGTH = 32\nconst PUBLIC_KEY_LENGTH = 32\n\n// domain + version + application domain + format + signer count + one signer + length\nconst HEADER_LENGTH =\n SIGNING_DOMAIN.length + 1 + APPLICATION_DOMAIN_LENGTH + 1 + 1 + PUBLIC_KEY_LENGTH + 2\n\n/** Hardware wallet compatible v0 messages are capped at 1232 bytes total, header included */\nconst MAX_MESSAGE_LENGTH = 1232 - HEADER_LENGTH\n\nconst FORMAT_RESTRICTED_ASCII = 0\nconst FORMAT_LIMITED_UTF8 = 1\n\nconst getMessageFormat = (message: Uint8Array): number | null => {\n if (message.every((byte) => byte >= 0x20 && byte <= 0x7e)) return FORMAT_RESTRICTED_ASCII\n\n try {\n new TextDecoder(\"utf-8\", { fatal: true }).decode(message)\n return FORMAT_LIMITED_UTF8\n } catch {\n return null // binary content cannot be wrapped\n }\n}\n\n/**\n * Wraps a raw message in the off-chain message envelope that hardware wallets sign.\n * Returns `null` if the message cannot be wrapped (binary content, empty, or too long).\n */\nexport const serializeOffchainMessage = (\n message: Uint8Array,\n signerPublicKey: Uint8Array\n): Uint8Array | null => {\n if (message.length === 0 || message.length > MAX_MESSAGE_LENGTH) return null\n if (signerPublicKey.length !== PUBLIC_KEY_LENGTH) return null\n\n const format = getMessageFormat(message)\n if (format === null) return null\n\n const envelope = new Uint8Array(HEADER_LENGTH + message.length)\n let offset = 0\n\n envelope.set(SIGNING_DOMAIN, offset)\n offset += SIGNING_DOMAIN.length\n\n envelope[offset++] = 0 // header version\n\n offset += APPLICATION_DOMAIN_LENGTH // application domain: zeros = not provided\n\n envelope[offset++] = format\n envelope[offset++] = 1 // signer count\n\n envelope.set(signerPublicKey, offset)\n offset += PUBLIC_KEY_LENGTH\n\n envelope[offset++] = message.length & 0xff\n envelope[offset++] = message.length >> 8\n\n envelope.set(message, offset)\n\n return envelope\n}\n","import type {\n Blockhash,\n Instruction,\n SignaturesMap,\n TransactionMessageBytes,\n TransactionMessageBytesBase64,\n} from \"@solana/kit\"\nimport {\n appendTransactionMessageInstructions,\n compileTransaction,\n createTransactionMessage,\n getBase64Decoder,\n getCompiledTransactionMessageDecoder,\n getCompiledTransactionMessageEncoder,\n getTransactionDecoder,\n getTransactionEncoder,\n pipe,\n setTransactionMessageFeePayer,\n setTransactionMessageLifetimeUsingBlockhash,\n address as solAddress,\n} from \"@solana/kit\"\nimport { base58 } from \"@talismn/crypto\"\n\nimport type { SolTransaction } from \"./transaction\"\n\nexport const transactionFromBytes = (bytes: Uint8Array): SolTransaction =>\n getTransactionDecoder().decode(bytes)\n\nexport const transactionToBytes = (tx: SolTransaction): Uint8Array =>\n new Uint8Array(getTransactionEncoder().encode(tx))\n\n/** base58 of the wire-format transaction — both legacy and v0, wire-compatible with web3.js */\nexport const serializeTransaction = (tx: SolTransaction): string =>\n base58.encode(transactionToBytes(tx))\n\nexport const deserializeTransaction = (transaction: string): SolTransaction =>\n transactionFromBytes(base58.decode(transaction))\n\n/** decoded compiled message — legacy and v0 wire formats are handled transparently */\nexport const getCompiledMessage = (tx: SolTransaction) =>\n getCompiledTransactionMessageDecoder().decode(tx.messageBytes)\n\n/**\n * Whether the bytes parse as a complete compiled transaction message (legacy or v0).\n * Wallets must refuse to sign such a payload as a \"message\": Solana software accounts sign raw\n * message bytes with no domain separator, so the resulting ed25519 signature would double as a\n * valid transaction signature.\n */\nexport const isCompiledTransactionMessage = (bytes: Uint8Array): boolean => {\n try {\n const [, offset] = getCompiledTransactionMessageDecoder().read(bytes, 0)\n return offset === bytes.length\n } catch {\n return false\n }\n}\n\n/** base64 of the compiled message bytes, the format `getFeeForMessage` expects */\nexport const getMessageBase64 = (tx: SolTransaction): TransactionMessageBytesBase64 =>\n getBase64Decoder().decode(tx.messageBytes) as TransactionMessageBytesBase64\n\nexport const buildUnsignedTransaction = ({\n feePayer,\n blockhash,\n lastValidBlockHeight,\n instructions,\n version = \"legacy\",\n}: {\n feePayer: string\n blockhash: string\n lastValidBlockHeight: bigint\n instructions: Instruction[]\n version?: \"legacy\" | 0\n}): SolTransaction =>\n pipe(\n createTransactionMessage({ version }),\n (m) => setTransactionMessageFeePayer(solAddress(feePayer), m),\n (m) =>\n setTransactionMessageLifetimeUsingBlockhash(\n { blockhash: blockhash as Blockhash, lastValidBlockHeight },\n m\n ),\n (m) => appendTransactionMessageInstructions(instructions, m),\n compileTransaction\n )\n\n/**\n * Returns a copy of the transaction with its lifetime token (recent blockhash) replaced,\n * re-encoding the compiled message. Existing signatures are reset to null — changing the\n * blockhash invalidates them.\n */\nexport const setTransactionBlockhash = (tx: SolTransaction, blockhash: string): SolTransaction => {\n const compiled = getCompiledTransactionMessageDecoder().decode(tx.messageBytes)\n const messageBytes = getCompiledTransactionMessageEncoder().encode({\n ...compiled,\n lifetimeToken: blockhash,\n }) as TransactionMessageBytes\n\n return Object.freeze({\n messageBytes,\n signatures: Object.freeze(\n Object.fromEntries(Object.keys(tx.signatures).map((address) => [address, null]))\n ) as SignaturesMap,\n })\n}\n\nexport const txToHumanJSON = (tx: string | SolTransaction) => {\n if (typeof tx === \"string\") tx = deserializeTransaction(tx)\n const message = getCompiledMessage(tx)\n const { header, staticAccounts } = message\n\n // standard account ordering: writable signers, readonly signers, writable non-signers, readonly non-signers\n const isSigner = (index: number) => index < header.numSignerAccounts\n const isWritable = (index: number) =>\n index < header.numSignerAccounts\n ? index < header.numSignerAccounts - header.numReadonlySignerAccounts\n : index < staticAccounts.length - header.numReadonlyNonSignerAccounts\n\n return {\n version: message.version,\n signatures: Object.values(tx.signatures).map((sig) => (sig ? base58.encode(sig) : null)),\n feePayer: staticAccounts[0] ?? null,\n recentBlockhash: \"lifetimeToken\" in message ? message.lifetimeToken : null,\n staticAccountKeys: staticAccounts as readonly string[],\n // ⚠️ NOTE: without address lookup table accounts we only have static keys.\n addressTableLookups:\n (\"addressTableLookups\" in message ? message.addressTableLookups : undefined)?.map((l) => ({\n accountKey: l.lookupTableAddress as string,\n writableIndexes: Array.from(l.writableIndexes),\n readonlyIndexes: Array.from(l.readonlyIndexes),\n })) ?? [],\n instructions: (\"instructions\" in message ? message.instructions : []).map((ix) => ({\n programIdIndex: ix.programAddressIndex,\n programId: staticAccounts[ix.programAddressIndex] ?? null,\n accounts: (ix.accountIndices ?? []).map((i) => ({\n index: i,\n pubkey: staticAccounts[i] ?? null,\n isSigner: isSigner(i),\n isWritable: isWritable(i),\n })),\n data: base58.encode((ix.data as Uint8Array | undefined) ?? new Uint8Array()),\n })),\n }\n}\n","import type { SignatureBytes } from \"@solana/kit\"\nimport { base58, ed25519, getPublicKeyFromSecret } from \"@talismn/crypto\"\n\nimport type { SolTransaction } from \"./transaction\"\n\n/**\n * Returns a copy of the transaction with `signature` attached for `address`.\n * Throws if `address` is not a required signer of the transaction (the signatures\n * map is keyed in wire order at decode time — adding a key would corrupt re-encoding).\n */\nexport const attachTransactionSignature = (\n tx: SolTransaction,\n address: string,\n signature: Uint8Array\n): SolTransaction => {\n if (!(address in tx.signatures))\n throw new Error(`Address ${address} is not a signer of this transaction`)\n\n return Object.freeze({\n ...tx,\n signatures: Object.freeze({ ...tx.signatures, [address]: signature as SignatureBytes }),\n })\n}\n\n/**\n * Returns the signature attached for `address`, verified against the transaction's message\n * bytes; null when missing, all-zeros, or invalid. Unlike `parseTransactionInfo`, this checks\n * a specific signer's slot, so it works on transactions with co-signers.\n */\nexport const getVerifiedTransactionSignature = (\n tx: SolTransaction,\n address: string\n): Uint8Array | null => {\n const signature = tx.signatures[address as keyof typeof tx.signatures]\n return signature &&\n ed25519.verify(signature, tx.messageBytes as unknown as Uint8Array, base58.decode(address))\n ? signature\n : null\n}\n\n/**\n * Signs the transaction's message bytes with the given ed25519 secret key and\n * attaches the signature. Signing happens with @noble/curves (via @talismn/crypto),\n * not WebCrypto — Ed25519 subtle crypto is too recent for the extension's support matrix.\n */\nexport const signTransactionWithSecretKey = (\n tx: SolTransaction,\n secretKey: Uint8Array,\n expectedAddress?: string\n): SolTransaction => {\n const address = base58.encode(getPublicKeyFromSecret(secretKey, \"solana\"))\n\n if (expectedAddress && address !== expectedAddress) throw new Error(\"Address mismatch\")\n\n const signature = ed25519.sign(tx.messageBytes as unknown as Uint8Array, secretKey)\n\n return attachTransactionSignature(tx, address, signature)\n}\n","import type { Transaction } from \"@solana/kit\"\nimport { base58 } from \"@talismn/crypto\"\n\nimport { getCompiledMessage } from \"./serialization\"\nimport { getVerifiedTransactionSignature } from \"./signing\"\n\n/**\n * A Solana transaction: raw wire message bytes plus a signer-address → signature map.\n * Kit's decoder/encoder handles both legacy and v0 wire formats transparently.\n */\nexport type SolTransaction = Transaction\n\nexport type SolTransactionInfo = {\n version: \"legacy\" | 0 | 1\n /** compiled lifetime token — the recent blockhash (or nonce for durable-nonce transactions) */\n recentBlockhash: string\n /** first static account, the account that pays the transaction fee */\n feePayer: string\n /** all required signer addresses, in wire order */\n signerAddresses: string[]\n /**\n * The account expected to sign in wallet flows.\n * `undefined` when the transaction has several signers (e.g. sponsored/partially-signed\n * dapp transactions) — callers use this to fall back to the dapp-provided address.\n */\n address: string | undefined\n /**\n * canonical (fee payer) base58 transaction signature, verified against the message bytes;\n * null when the fee payer hasn't signed\n */\n signature: string | null\n}\n\nexport const parseTransactionInfo = (tx: SolTransaction): SolTransactionInfo => {\n const message = getCompiledMessage(tx)\n const signerAddresses = Object.keys(tx.signatures)\n const feePayer = message.staticAccounts[0] as string\n\n // Behavior preserved from the web3.js implementation: legacy transactions always\n // resolve to the fee payer, versioned ones only when there is a single signer.\n const address =\n message.version === \"legacy\"\n ? signerAddresses[0]\n : signerAddresses.length === 1\n ? signerAddresses[0]\n : undefined\n\n // the canonical transaction signature is the fee payer's — may be missing or\n // all-zeros, so always verify against the message bytes\n const sigBytes = getVerifiedTransactionSignature(tx, feePayer)\n\n return {\n version: message.version,\n recentBlockhash: \"lifetimeToken\" in message ? message.lifetimeToken : \"\",\n feePayer,\n signerAddresses,\n address,\n signature: sigBytes ? base58.encode(sigBytes) : null,\n }\n}\n"],"mappings":";;;AAAA,MAAa,gBAAgB;CAC3B;CACA;CACA;CACA;AACF;AAIA,MAAa,mBAAmB,UAAyB;CACvD,QAAQ,OAA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YAAY,GAAG,WAAW;CAChC,OAAO,aACL,QAAQ,OAAO,WAAW,GAAG,cAAuC,OAAO,OAAO,OAAO,CAAC,IACxF,YACA;AACN;;;;;;AAOA,MAAa,gCACX,IACA,WACA,oBACmB;CACnB,MAAM,UAAU,OAAO,OAAO,uBAAuB,WAAW,QAAQ,CAAC;CAEzE,IAAI,mBAAmB,YAAY,iBAAiB,MAAM,IAAI,MAAM,kBAAkB;CAEtF,MAAM,YAAY,QAAQ,KAAK,GAAG,cAAuC,SAAS;CAElF,OAAO,2BAA2B,IAAI,SAAS,SAAS;AAC1D;;ACxBA,MAAa,wBAAwB,OAA2C;CAC9E,MAAM,UAAU,mBAAmB,EAAE;CACrC,MAAM,kBAAkB,OAAO,KAAK,GAAG,UAAU;CACjD,MAAM,WAAW,QAAQ,eAAe;CAIxC,MAAM,UACJ,QAAQ,YAAY,WAChB,gBAAgB,KAChB,gBAAgB,WAAW,IACzB,gBAAgB,KAChB,KAAA;CAIR,MAAM,WAAW,gCAAgC,IAAI,QAAQ;CAE7D,OAAO;EACL,SAAS,QAAQ;EACjB,iBAAiB,mBAAmB,UAAU,QAAQ,gBAAgB;EACtE;EACA;EACA;EACA,WAAW,WAAW,OAAO,OAAO,QAAQ,IAAI;CAClD;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@talismn/solana",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Types and utilities for Solana, built on @solana/kit",
5
5
  "author": "Talisman",
6
6
  "homepage": "https://talisman.xyz",
@@ -22,12 +22,12 @@
22
22
  "node": ">=20"
23
23
  },
24
24
  "dependencies": {
25
- "@solana/kit": "8.3.0",
26
- "@talismn/crypto": "1.1.1"
25
+ "@solana/kit": "8.6.0",
26
+ "@talismn/crypto": "1.3.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@talismn/tsconfig": "0.0.4",
30
- "@types/node": "^24.13.3",
30
+ "@types/node": "^24.19.2",
31
31
  "typescript": "^7.0.2"
32
32
  },
33
33
  "types": "./dist/index.d.ts",