{"version":3,"file":"wallet-standard-tx-BP0y4zyT.mjs","sources":["../.rollup-tmp/auth/providers/wallet-standard-tx.js"],"sourcesContent":["// wallet-standard-tx.ts - web3.js-dependent (de)serialization for the Wallet\n// Standard `solana:signTransaction` / `solana:signAndSendTransaction` features,\n// which exchange raw transaction BYTES. Split into its own module so\n// wallet-standard-discovery.ts can lazy-import it only when a transaction is\n// actually signed, keeping wallet listing + SIWS message login off the heavy\n// @solana/web3.js chunk. Mirrors the wire helpers in\n// @solana-mobile/mobile-wallet-adapter-protocol-web3js.\nimport { Transaction, VersionedTransaction, VersionedMessage, } from \"@solana/web3.js\";\nconst ED25519_SIGNATURE_LENGTH = 64;\n/** Serialize an unsigned Transaction/VersionedTransaction to the wire bytes the\n *  wallet-standard sign features expect (legacy skips signature verification). */\nexport function serializeUnsignedTx(tx) {\n    if (\"version\" in tx)\n        return tx.serialize();\n    return tx.serialize({ requireAllSignatures: false, verifySignatures: false });\n}\n/** Deserialize the signed bytes a wallet returns, round-tripping legacy or\n *  versioned transactions correctly. */\nexport function deserializeSignedTx(bytes) {\n    // SIMD-0385 v1 puts the message FIRST (byte 0 = 0x81) with the signatures trailing.\n    // The signature-count arithmetic below would read 0x81 as 129 signatures and fail\n    // with a misleading \"end of buffer\" error, so name the real cause instead. v1\n    // signing lands with the transaction-v1 runtime; until then no v1 bytes are ever\n    // handed to a wallet by this SDK, so this only triggers on a wallet that rewrote\n    // the transaction into a format it was not given.\n    if (bytes.length > 0 && bytes[0] === 0x81) {\n        throw new Error(\"The wallet returned a Solana transaction v1 (SIMD-0385) payload, which this SDK build cannot deserialize yet.\");\n    }\n    const messageOffset = bytes[0] * ED25519_SIGNATURE_LENGTH + 1;\n    const version = VersionedMessage.deserializeMessageVersion(bytes.slice(messageOffset, bytes.length));\n    return version === \"legacy\" ? Transaction.from(bytes) : VersionedTransaction.deserialize(bytes);\n}\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,MAAM,wBAAwB,GAAG,EAAE;AACnC;AACA;AACO,SAAS,mBAAmB,CAAC,EAAE,EAAE;AACxC,IAAI,IAAI,SAAS,IAAI,EAAE;AACvB,QAAQ,OAAO,EAAE,CAAC,SAAS,EAAE;AAC7B,IAAI,OAAO,EAAE,CAAC,SAAS,CAAC,EAAE,oBAAoB,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC;AACjF;AACA;AACA;AACO,SAAS,mBAAmB,CAAC,KAAK,EAAE;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE;AAC/C,QAAQ,MAAM,IAAI,KAAK,CAAC,+GAA+G,CAAC;AACxI,IAAI;AACJ,IAAI,MAAM,aAAa,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,wBAAwB,GAAG,CAAC;AACjE,IAAI,MAAM,OAAO,GAAG,gBAAgB,CAAC,yBAAyB,CAAC,KAAK,CAAC,KAAK,CAAC,aAAa,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;AACxG,IAAI,OAAO,OAAO,KAAK,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,oBAAoB,CAAC,WAAW,CAAC,KAAK,CAAC;AACnG;;;;"}