@solana/compat 2.0.0-canary-20240731173615

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/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2023 Solana Labs, Inc
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,49 @@
1
+ [![npm][npm-image]][npm-url]
2
+ [![npm-downloads][npm-downloads-image]][npm-url]
3
+ [![semantic-release][semantic-release-image]][semantic-release-url]
4
+ <br />
5
+ [![code-style-prettier][code-style-prettier-image]][code-style-prettier-url]
6
+
7
+ [code-style-prettier-image]: https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square
8
+ [code-style-prettier-url]: https://github.com/prettier/prettier
9
+ [npm-downloads-image]: https://img.shields.io/npm/dm/@solana/compat/experimental.svg?style=flat
10
+ [npm-image]: https://img.shields.io/npm/v/@solana/compat/experimental.svg?style=flat
11
+ [npm-url]: https://www.npmjs.com/package/@solana/compat/v/experimental
12
+ [semantic-release-image]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg
13
+ [semantic-release-url]: https://github.com/semantic-release/semantic-release
14
+
15
+ # @solana/compat
16
+
17
+ This package contains utilities for converting from legacy web3js classes to the new data structures. It can be used standalone, but it is also exported as part of the Solana JavaScript SDK [`@solana/web3.js@experimental`](https://github.com/solana-labs/solana-web3.js/tree/master/packages/library).
18
+
19
+ ## Functions
20
+
21
+ ### `fromLegacyPublicKey()`
22
+
23
+ This can be used to convert a legacy `PublicKey` object to an `Address` type
24
+
25
+ ```ts
26
+ import { fromLegacyPublicKey } from '@solana/compat';
27
+ const address = fromLegacyPublicKey(new PublicKey('49XBVQsvSW44ULKL9qufS9YqQPbdcps1TQRijx4FQ9sH'));
28
+ ```
29
+
30
+ ### `fromLegacyKeypair()`
31
+
32
+ This can be used to convert a legacy `Keypair` object to a native Ed25519 `CryptoKeyPair` object
33
+
34
+ ```ts
35
+ import { fromLegacyKeypair } from '@solana/compat';
36
+ const { privateKey, publicKey } = await fromLegacyKeypair(Keypair.generate());
37
+ ```
38
+
39
+ ### `fromVersionedTransaction`
40
+
41
+ This can be used to convert a legacy `VersionedTransaction` object to a `Transaction` object.
42
+
43
+ ```ts
44
+ import { fromVersionedTransaction } from '@solana/compat';
45
+
46
+ // imagine a function that returns a legacy `VersionedTransaction`
47
+ const legacyVersionedTransaction = getMyLegacyVersionedTransaction();
48
+ const transaction = fromVersionedTransaction(legacyVersionedTransaction);
49
+ ```
@@ -0,0 +1,55 @@
1
+ 'use strict';
2
+
3
+ var keys = require('@solana/keys');
4
+ var errors = require('@solana/errors');
5
+
6
+ // src/address.ts
7
+ function fromLegacyPublicKey(publicKey) {
8
+ return publicKey.toBase58();
9
+ }
10
+ async function fromLegacyKeypair(keypair, extractable) {
11
+ const bytes = new Uint8Array(64);
12
+ bytes.set(keypair.secretKey);
13
+ bytes.set(
14
+ keypair.publicKey.toBytes(),
15
+ /* offset */
16
+ 32
17
+ );
18
+ return await keys.createKeyPairFromBytes(bytes, extractable);
19
+ }
20
+ function convertSignatures(transaction, staticAccountKeys) {
21
+ return Object.fromEntries(
22
+ transaction.signatures.map((sig, index) => {
23
+ const address = staticAccountKeys[index];
24
+ if (sig.every((b) => b === 0)) {
25
+ return [address, null];
26
+ } else {
27
+ return [address, sig];
28
+ }
29
+ })
30
+ );
31
+ }
32
+ function fromVersionedTransaction(transaction) {
33
+ const { message } = transaction;
34
+ const { staticAccountKeys } = message.getAccountKeys();
35
+ const { numRequiredSignatures } = message.header;
36
+ if (numRequiredSignatures !== transaction.signatures.length) {
37
+ throw new errors.SolanaError(errors.SOLANA_ERROR__TRANSACTION__MESSAGE_SIGNATURES_MISMATCH, {
38
+ numRequiredSignatures: transaction.message.header.numRequiredSignatures,
39
+ signaturesLength: transaction.signatures.length,
40
+ signerAddresses: staticAccountKeys.slice(0, numRequiredSignatures).map((p) => p.toBase58())
41
+ });
42
+ }
43
+ const messageBytes = message.serialize();
44
+ const signatures = convertSignatures(transaction, staticAccountKeys);
45
+ return {
46
+ messageBytes,
47
+ signatures: Object.freeze(signatures)
48
+ };
49
+ }
50
+
51
+ exports.fromLegacyKeypair = fromLegacyKeypair;
52
+ exports.fromLegacyPublicKey = fromLegacyPublicKey;
53
+ exports.fromVersionedTransaction = fromVersionedTransaction;
54
+ //# sourceMappingURL=index.browser.cjs.map
55
+ //# sourceMappingURL=index.browser.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/address.ts","../src/keypair.ts","../src/transaction.ts"],"names":["createKeyPairFromBytes","SolanaError","SOLANA_ERROR__TRANSACTION__MESSAGE_SIGNATURES_MISMATCH"],"mappings":";;;;;;AAQO,SAAS,oBAA6C,SAAyC,EAAA;AAClG,EAAA,OAAO,UAAU,QAAS,EAAA,CAAA;AAC9B,CAAA;ACFA,eAAsB,iBAAA,CAAkB,SAAkB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,qBAAA;AAAA,MAClD,gBAAA,EAAkB,YAAY,UAAW,CAAA,MAAA;AAAA,MACzC,eAAA,EAAiB,iBAAkB,CAAA,KAAA,CAAM,CAAG,EAAA,qBAAqB,EAAE,GAAI,CAAA,CAAA,CAAA,KAAK,CAAE,CAAA,QAAA,EAAU,CAAA;AAAA,KAC3F,CAAA,CAAA;AAAA,GACL;AAEA,EAAM,MAAA,YAAA,GAAe,QAAQ,SAAU,EAAA,CAAA;AACvC,EAAM,MAAA,UAAA,GAAa,iBAAkB,CAAA,WAAA,EAAa,iBAAiB,CAAA,CAAA;AAEnE,EAAO,OAAA;AAAA,IACH,YAAA;AAAA,IACA,UAAA,EAAY,MAAO,CAAA,MAAA,CAAO,UAAU,CAAA;AAAA,GACxC,CAAA;AACJ","file":"index.browser.cjs","sourcesContent":["import { Address } from '@solana/addresses';\nimport { PublicKey } from '@solana/web3.js';\n\n/**\n * Convert from a Legacy Web3 JS PublicKey to a base58 encoded address\n * @param publicKey The PublicKey to convert\n * @returns An Address\n */\nexport function fromLegacyPublicKey<TAddress extends string>(publicKey: PublicKey): Address<TAddress> {\n return publicKey.toBase58() as Address<TAddress>;\n}\n","import { createKeyPairFromBytes } from '@solana/keys';\nimport { Keypair } from '@solana/web3.js';\n\n/**\n * Convert from a Legacy Web3 JS Keypair to a CryptoKeyPair\n * @param keypair The Keypair to convert\n * @returns A CryptoKeyPair\n */\nexport async function fromLegacyKeypair(keypair: Keypair, extractable?: boolean): Promise<CryptoKeyPair> {\n const bytes = new Uint8Array(64);\n bytes.set(keypair.secretKey);\n bytes.set(keypair.publicKey.toBytes(), /* offset */ 32);\n return await createKeyPairFromBytes(bytes, extractable);\n}\n","import { ReadonlyUint8Array } from '@solana/codecs-core';\nimport { SOLANA_ERROR__TRANSACTION__MESSAGE_SIGNATURES_MISMATCH, SolanaError } from '@solana/errors';\nimport type { SignatureBytes } from '@solana/keys';\nimport { type SignaturesMap, Transaction, TransactionMessageBytes } from '@solana/transactions';\nimport type { PublicKey, VersionedTransaction } from '@solana/web3.js';\n\nfunction convertSignatures(transaction: VersionedTransaction, staticAccountKeys: PublicKey[]): SignaturesMap {\n return Object.fromEntries(\n transaction.signatures.map((sig, index) => {\n const address = staticAccountKeys[index];\n if (sig.every(b => b === 0)) {\n // all-0 signatures are stored as null\n return [address, null];\n } else {\n return [address, sig as ReadonlyUint8Array as SignatureBytes];\n }\n }),\n );\n}\n\nexport function fromVersionedTransaction(transaction: VersionedTransaction): Transaction {\n const { message } = transaction;\n const { staticAccountKeys } = message.getAccountKeys();\n\n const { numRequiredSignatures } = message.header;\n if (numRequiredSignatures !== transaction.signatures.length) {\n throw new SolanaError(SOLANA_ERROR__TRANSACTION__MESSAGE_SIGNATURES_MISMATCH, {\n numRequiredSignatures: transaction.message.header.numRequiredSignatures,\n signaturesLength: transaction.signatures.length,\n signerAddresses: staticAccountKeys.slice(0, numRequiredSignatures).map(p => p.toBase58()),\n });\n }\n\n const messageBytes = message.serialize() as ReadonlyUint8Array as TransactionMessageBytes;\n const signatures = convertSignatures(transaction, staticAccountKeys);\n\n return {\n messageBytes,\n signatures: Object.freeze(signatures),\n };\n}\n"]}
@@ -0,0 +1,51 @@
1
+ import { createKeyPairFromBytes } from '@solana/keys';
2
+ import { SolanaError, SOLANA_ERROR__TRANSACTION__MESSAGE_SIGNATURES_MISMATCH } from '@solana/errors';
3
+
4
+ // src/address.ts
5
+ function fromLegacyPublicKey(publicKey) {
6
+ return publicKey.toBase58();
7
+ }
8
+ async function fromLegacyKeypair(keypair, extractable) {
9
+ const bytes = new Uint8Array(64);
10
+ bytes.set(keypair.secretKey);
11
+ bytes.set(
12
+ keypair.publicKey.toBytes(),
13
+ /* offset */
14
+ 32
15
+ );
16
+ return await createKeyPairFromBytes(bytes, extractable);
17
+ }
18
+ function convertSignatures(transaction, staticAccountKeys) {
19
+ return Object.fromEntries(
20
+ transaction.signatures.map((sig, index) => {
21
+ const address = staticAccountKeys[index];
22
+ if (sig.every((b) => b === 0)) {
23
+ return [address, null];
24
+ } else {
25
+ return [address, sig];
26
+ }
27
+ })
28
+ );
29
+ }
30
+ function fromVersionedTransaction(transaction) {
31
+ const { message } = transaction;
32
+ const { staticAccountKeys } = message.getAccountKeys();
33
+ const { numRequiredSignatures } = message.header;
34
+ if (numRequiredSignatures !== transaction.signatures.length) {
35
+ throw new SolanaError(SOLANA_ERROR__TRANSACTION__MESSAGE_SIGNATURES_MISMATCH, {
36
+ numRequiredSignatures: transaction.message.header.numRequiredSignatures,
37
+ signaturesLength: transaction.signatures.length,
38
+ signerAddresses: staticAccountKeys.slice(0, numRequiredSignatures).map((p) => p.toBase58())
39
+ });
40
+ }
41
+ const messageBytes = message.serialize();
42
+ const signatures = convertSignatures(transaction, staticAccountKeys);
43
+ return {
44
+ messageBytes,
45
+ signatures: Object.freeze(signatures)
46
+ };
47
+ }
48
+
49
+ export { fromLegacyKeypair, fromLegacyPublicKey, fromVersionedTransaction };
50
+ //# sourceMappingURL=index.browser.mjs.map
51
+ //# sourceMappingURL=index.browser.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/address.ts","../src/keypair.ts","../src/transaction.ts"],"names":[],"mappings":";;;;AAQO,SAAS,oBAA6C,SAAyC,EAAA;AAClG,EAAA,OAAO,UAAU,QAAS,EAAA,CAAA;AAC9B,CAAA;ACFA,eAAsB,iBAAA,CAAkB,SAAkB,WAA+C,EAAA;AACrG,EAAM,MAAA,KAAA,GAAQ,IAAI,UAAA,CAAW,EAAE,CAAA,CAAA;AAC/B,EAAM,KAAA,CAAA,GAAA,CAAI,QAAQ,SAAS,CAAA,CAAA;AAC3B,EAAM,KAAA,CAAA,GAAA;AAAA,IAAI,OAAA,CAAQ,UAAU,OAAQ,EAAA;AAAA;AAAA,IAAgB,EAAA;AAAA,GAAE,CAAA;AACtD,EAAO,OAAA,MAAM,sBAAuB,CAAA,KAAA,EAAO,WAAW,CAAA,CAAA;AAC1D,CAAA;ACPA,SAAS,iBAAA,CAAkB,aAAmC,iB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AAA,IACH,YAAA;AAAA,IACA,UAAA,EAAY,MAAO,CAAA,MAAA,CAAO,UAAU,CAAA;AAAA,GACxC,CAAA;AACJ","file":"index.browser.mjs","sourcesContent":["import { Address } from '@solana/addresses';\nimport { PublicKey } from '@solana/web3.js';\n\n/**\n * Convert from a Legacy Web3 JS PublicKey to a base58 encoded address\n * @param publicKey The PublicKey to convert\n * @returns An Address\n */\nexport function fromLegacyPublicKey<TAddress extends string>(publicKey: PublicKey): Address<TAddress> {\n return publicKey.toBase58() as Address<TAddress>;\n}\n","import { createKeyPairFromBytes } from '@solana/keys';\nimport { Keypair } from '@solana/web3.js';\n\n/**\n * Convert from a Legacy Web3 JS Keypair to a CryptoKeyPair\n * @param keypair The Keypair to convert\n * @returns A CryptoKeyPair\n */\nexport async function fromLegacyKeypair(keypair: Keypair, extractable?: boolean): Promise<CryptoKeyPair> {\n const bytes = new Uint8Array(64);\n bytes.set(keypair.secretKey);\n bytes.set(keypair.publicKey.toBytes(), /* offset */ 32);\n return await createKeyPairFromBytes(bytes, extractable);\n}\n","import { ReadonlyUint8Array } from '@solana/codecs-core';\nimport { SOLANA_ERROR__TRANSACTION__MESSAGE_SIGNATURES_MISMATCH, SolanaError } from '@solana/errors';\nimport type { SignatureBytes } from '@solana/keys';\nimport { type SignaturesMap, Transaction, TransactionMessageBytes } from '@solana/transactions';\nimport type { PublicKey, VersionedTransaction } from '@solana/web3.js';\n\nfunction convertSignatures(transaction: VersionedTransaction, staticAccountKeys: PublicKey[]): SignaturesMap {\n return Object.fromEntries(\n transaction.signatures.map((sig, index) => {\n const address = staticAccountKeys[index];\n if (sig.every(b => b === 0)) {\n // all-0 signatures are stored as null\n return [address, null];\n } else {\n return [address, sig as ReadonlyUint8Array as SignatureBytes];\n }\n }),\n );\n}\n\nexport function fromVersionedTransaction(transaction: VersionedTransaction): Transaction {\n const { message } = transaction;\n const { staticAccountKeys } = message.getAccountKeys();\n\n const { numRequiredSignatures } = message.header;\n if (numRequiredSignatures !== transaction.signatures.length) {\n throw new SolanaError(SOLANA_ERROR__TRANSACTION__MESSAGE_SIGNATURES_MISMATCH, {\n numRequiredSignatures: transaction.message.header.numRequiredSignatures,\n signaturesLength: transaction.signatures.length,\n signerAddresses: staticAccountKeys.slice(0, numRequiredSignatures).map(p => p.toBase58()),\n });\n }\n\n const messageBytes = message.serialize() as ReadonlyUint8Array as TransactionMessageBytes;\n const signatures = convertSignatures(transaction, staticAccountKeys);\n\n return {\n messageBytes,\n signatures: Object.freeze(signatures),\n };\n}\n"]}
@@ -0,0 +1,51 @@
1
+ import { createKeyPairFromBytes } from '@solana/keys';
2
+ import { SolanaError, SOLANA_ERROR__TRANSACTION__MESSAGE_SIGNATURES_MISMATCH } from '@solana/errors';
3
+
4
+ // src/address.ts
5
+ function fromLegacyPublicKey(publicKey) {
6
+ return publicKey.toBase58();
7
+ }
8
+ async function fromLegacyKeypair(keypair, extractable) {
9
+ const bytes = new Uint8Array(64);
10
+ bytes.set(keypair.secretKey);
11
+ bytes.set(
12
+ keypair.publicKey.toBytes(),
13
+ /* offset */
14
+ 32
15
+ );
16
+ return await createKeyPairFromBytes(bytes, extractable);
17
+ }
18
+ function convertSignatures(transaction, staticAccountKeys) {
19
+ return Object.fromEntries(
20
+ transaction.signatures.map((sig, index) => {
21
+ const address = staticAccountKeys[index];
22
+ if (sig.every((b) => b === 0)) {
23
+ return [address, null];
24
+ } else {
25
+ return [address, sig];
26
+ }
27
+ })
28
+ );
29
+ }
30
+ function fromVersionedTransaction(transaction) {
31
+ const { message } = transaction;
32
+ const { staticAccountKeys } = message.getAccountKeys();
33
+ const { numRequiredSignatures } = message.header;
34
+ if (numRequiredSignatures !== transaction.signatures.length) {
35
+ throw new SolanaError(SOLANA_ERROR__TRANSACTION__MESSAGE_SIGNATURES_MISMATCH, {
36
+ numRequiredSignatures: transaction.message.header.numRequiredSignatures,
37
+ signaturesLength: transaction.signatures.length,
38
+ signerAddresses: staticAccountKeys.slice(0, numRequiredSignatures).map((p) => p.toBase58())
39
+ });
40
+ }
41
+ const messageBytes = message.serialize();
42
+ const signatures = convertSignatures(transaction, staticAccountKeys);
43
+ return {
44
+ messageBytes,
45
+ signatures: Object.freeze(signatures)
46
+ };
47
+ }
48
+
49
+ export { fromLegacyKeypair, fromLegacyPublicKey, fromVersionedTransaction };
50
+ //# sourceMappingURL=index.native.mjs.map
51
+ //# sourceMappingURL=index.native.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/address.ts","../src/keypair.ts","../src/transaction.ts"],"names":[],"mappings":";;;;AAQO,SAAS,oBAA6C,SAAyC,EAAA;AAClG,EAAA,OAAO,UAAU,QAAS,EAAA,CAAA;AAC9B,CAAA;ACFA,eAAsB,iBAAA,CAAkB,SAAkB,WAA+C,EAAA;AACrG,EAAM,MAAA,KAAA,GAAQ,IAAI,UAAA,CAAW,EAAE,CAAA,CAAA;AAC/B,EAAM,KAAA,CAAA,GAAA,CAAI,QAAQ,SAAS,CAAA,CAAA;AAC3B,EAAM,KAAA,CAAA,GAAA;AAAA,IAAI,OAAA,CAAQ,UAAU,OAAQ,EAAA;AAAA;AAAA,IAAgB,EAAA;AAAA,GAAE,CAAA;AACtD,EAAO,OAAA,MAAM,sBAAuB,CAAA,KAAA,EAAO,WAAW,CAAA,CAAA;AAC1D,CAAA;ACPA,SAAS,iBAAA,CAAkB,aAAmC,iBAA+C,EAAA;AACzG,EAAA,OAAO,MAAO,CAAA,WAAA;AAAA,IACV,WAAY,CAAA,UAAA,CAAW,GAAI,CAAA,CAAC,KAAK,KAAU,KAAA;AACvC,MAAM,MAAA,OAAA,GAAU,kBAAkB,KAAK,CAAA,CAAA;AACvC,MAAA,IAAI,GAAI,CAAA,KAAA,CAAM,CAAK,CAAA,KAAA,CAAA,KAAM,CAAC,CAAG,EAAA;AAEzB,QAAO,OAAA,CAAC,SAAS,IAAI,CAAA,CAAA;AAAA,OAClB,MAAA;AACH,QAAO,OAAA,CAAC,SAAS,GAA2C,CAAA,CAAA;AAAA,OAChE;AAAA,KACH,CAAA;AAAA,GACL,CAAA;AACJ,CAAA;AAEO,SAAS,yBAAyB,WAAgD,EAAA;AACrF,EAAM,MAAA,EAAE,SAAY,GAAA,WAAA,CAAA;AACpB,EAAA,MAAM,EAAE,iBAAA,EAAsB,GAAA,OAAA,CAAQ,cAAe,EAAA,CAAA;AAErD,EAAM,MAAA,EAAE,qBAAsB,EAAA,GAAI,OAAQ,CAAA,MAAA,CAAA;AAC1C,EAAI,IAAA,qBAAA,KAA0B,WAAY,CAAA,UAAA,CAAW,MAAQ,EAAA;AACzD,IAAM,MAAA,IAAI,YAAY,sDAAwD,EAAA;AAAA,MAC1E,qBAAA,EAAuB,WAAY,CAAA,OAAA,CAAQ,MAAO,CAAA,qBAAA;AAAA,MAClD,gBAAA,EAAkB,YAAY,UAAW,CAAA,MAAA;AAAA,MACzC,eAAA,EAAiB,iBAAkB,CAAA,KAAA,CAAM,CAAG,EAAA,qBAAqB,EAAE,GAAI,CAAA,CAAA,CAAA,KAAK,CAAE,CAAA,QAAA,EAAU,CAAA;AAAA,KAC3F,CAAA,CAAA;AAAA,GACL;AAEA,EAAM,MAAA,YAAA,GAAe,QAAQ,SAAU,EAAA,CAAA;AACvC,EAAM,MAAA,UAAA,GAAa,iBAAkB,CAAA,WAAA,EAAa,iBAAiB,CAAA,CAAA;AAEnE,EAAO,OAAA;AAAA,IACH,YAAA;AAAA,IACA,UAAA,EAAY,MAAO,CAAA,MAAA,CAAO,UAAU,CAAA;AAAA,GACxC,CAAA;AACJ","file":"index.native.mjs","sourcesContent":["import { Address } from '@solana/addresses';\nimport { PublicKey } from '@solana/web3.js';\n\n/**\n * Convert from a Legacy Web3 JS PublicKey to a base58 encoded address\n * @param publicKey The PublicKey to convert\n * @returns An Address\n */\nexport function fromLegacyPublicKey<TAddress extends string>(publicKey: PublicKey): Address<TAddress> {\n return publicKey.toBase58() as Address<TAddress>;\n}\n","import { createKeyPairFromBytes } from '@solana/keys';\nimport { Keypair } from '@solana/web3.js';\n\n/**\n * Convert from a Legacy Web3 JS Keypair to a CryptoKeyPair\n * @param keypair The Keypair to convert\n * @returns A CryptoKeyPair\n */\nexport async function fromLegacyKeypair(keypair: Keypair, extractable?: boolean): Promise<CryptoKeyPair> {\n const bytes = new Uint8Array(64);\n bytes.set(keypair.secretKey);\n bytes.set(keypair.publicKey.toBytes(), /* offset */ 32);\n return await createKeyPairFromBytes(bytes, extractable);\n}\n","import { ReadonlyUint8Array } from '@solana/codecs-core';\nimport { SOLANA_ERROR__TRANSACTION__MESSAGE_SIGNATURES_MISMATCH, SolanaError } from '@solana/errors';\nimport type { SignatureBytes } from '@solana/keys';\nimport { type SignaturesMap, Transaction, TransactionMessageBytes } from '@solana/transactions';\nimport type { PublicKey, VersionedTransaction } from '@solana/web3.js';\n\nfunction convertSignatures(transaction: VersionedTransaction, staticAccountKeys: PublicKey[]): SignaturesMap {\n return Object.fromEntries(\n transaction.signatures.map((sig, index) => {\n const address = staticAccountKeys[index];\n if (sig.every(b => b === 0)) {\n // all-0 signatures are stored as null\n return [address, null];\n } else {\n return [address, sig as ReadonlyUint8Array as SignatureBytes];\n }\n }),\n );\n}\n\nexport function fromVersionedTransaction(transaction: VersionedTransaction): Transaction {\n const { message } = transaction;\n const { staticAccountKeys } = message.getAccountKeys();\n\n const { numRequiredSignatures } = message.header;\n if (numRequiredSignatures !== transaction.signatures.length) {\n throw new SolanaError(SOLANA_ERROR__TRANSACTION__MESSAGE_SIGNATURES_MISMATCH, {\n numRequiredSignatures: transaction.message.header.numRequiredSignatures,\n signaturesLength: transaction.signatures.length,\n signerAddresses: staticAccountKeys.slice(0, numRequiredSignatures).map(p => p.toBase58()),\n });\n }\n\n const messageBytes = message.serialize() as ReadonlyUint8Array as TransactionMessageBytes;\n const signatures = convertSignatures(transaction, staticAccountKeys);\n\n return {\n messageBytes,\n signatures: Object.freeze(signatures),\n };\n}\n"]}
@@ -0,0 +1,55 @@
1
+ 'use strict';
2
+
3
+ var keys = require('@solana/keys');
4
+ var errors = require('@solana/errors');
5
+
6
+ // src/address.ts
7
+ function fromLegacyPublicKey(publicKey) {
8
+ return publicKey.toBase58();
9
+ }
10
+ async function fromLegacyKeypair(keypair, extractable) {
11
+ const bytes = new Uint8Array(64);
12
+ bytes.set(keypair.secretKey);
13
+ bytes.set(
14
+ keypair.publicKey.toBytes(),
15
+ /* offset */
16
+ 32
17
+ );
18
+ return await keys.createKeyPairFromBytes(bytes, extractable);
19
+ }
20
+ function convertSignatures(transaction, staticAccountKeys) {
21
+ return Object.fromEntries(
22
+ transaction.signatures.map((sig, index) => {
23
+ const address = staticAccountKeys[index];
24
+ if (sig.every((b) => b === 0)) {
25
+ return [address, null];
26
+ } else {
27
+ return [address, sig];
28
+ }
29
+ })
30
+ );
31
+ }
32
+ function fromVersionedTransaction(transaction) {
33
+ const { message } = transaction;
34
+ const { staticAccountKeys } = message.getAccountKeys();
35
+ const { numRequiredSignatures } = message.header;
36
+ if (numRequiredSignatures !== transaction.signatures.length) {
37
+ throw new errors.SolanaError(errors.SOLANA_ERROR__TRANSACTION__MESSAGE_SIGNATURES_MISMATCH, {
38
+ numRequiredSignatures: transaction.message.header.numRequiredSignatures,
39
+ signaturesLength: transaction.signatures.length,
40
+ signerAddresses: staticAccountKeys.slice(0, numRequiredSignatures).map((p) => p.toBase58())
41
+ });
42
+ }
43
+ const messageBytes = message.serialize();
44
+ const signatures = convertSignatures(transaction, staticAccountKeys);
45
+ return {
46
+ messageBytes,
47
+ signatures: Object.freeze(signatures)
48
+ };
49
+ }
50
+
51
+ exports.fromLegacyKeypair = fromLegacyKeypair;
52
+ exports.fromLegacyPublicKey = fromLegacyPublicKey;
53
+ exports.fromVersionedTransaction = fromVersionedTransaction;
54
+ //# sourceMappingURL=index.node.cjs.map
55
+ //# sourceMappingURL=index.node.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/address.ts","../src/keypair.ts","../src/transaction.ts"],"names":["createKeyPairFromBytes","SolanaError","SOLANA_ERROR__TRAN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IAAA,qBAAA,KAA0B,WAAY,CAAA,UAAA,CAAW,MAAQ,EAAA;AACzD,IAAM,MAAA,IAAIC,mBAAYC,6DAAwD,EAAA;AAAA,MAC1E,qBAAA,EAAuB,WAAY,CAAA,OAAA,CAAQ,MAAO,CAAA,qBAAA;AAAA,MAClD,gBAAA,EAAkB,YAAY,UAAW,CAAA,MAAA;AAAA,MACzC,eAAA,EAAiB,iBAAkB,CAAA,KAAA,CAAM,CAAG,EAAA,qBAAqB,EAAE,GAAI,CAAA,CAAA,CAAA,KAAK,CAAE,CAAA,QAAA,EAAU,CAAA;AAAA,KAC3F,CAAA,CAAA;AAAA,GACL;AAEA,EAAM,MAAA,YAAA,GAAe,QAAQ,SAAU,EAAA,CAAA;AACvC,EAAM,MAAA,UAAA,GAAa,iBAAkB,CAAA,WAAA,EAAa,iBAAiB,CAAA,CAAA;AAEnE,EAAO,OAAA;AAAA,IACH,YAAA;AAAA,IACA,UAAA,EAAY,MAAO,CAAA,MAAA,CAAO,UAAU,CAAA;AAAA,GACxC,CAAA;AACJ","file":"index.node.cjs","sourcesContent":["import { Address } from '@solana/addresses';\nimport { PublicKey } from '@solana/web3.js';\n\n/**\n * Convert from a Legacy Web3 JS PublicKey to a base58 encoded address\n * @param publicKey The PublicKey to convert\n * @returns An Address\n */\nexport function fromLegacyPublicKey<TAddress extends string>(publicKey: PublicKey): Address<TAddress> {\n return publicKey.toBase58() as Address<TAddress>;\n}\n","import { createKeyPairFromBytes } from '@solana/keys';\nimport { Keypair } from '@solana/web3.js';\n\n/**\n * Convert from a Legacy Web3 JS Keypair to a CryptoKeyPair\n * @param keypair The Keypair to convert\n * @returns A CryptoKeyPair\n */\nexport async function fromLegacyKeypair(keypair: Keypair, extractable?: boolean): Promise<CryptoKeyPair> {\n const bytes = new Uint8Array(64);\n bytes.set(keypair.secretKey);\n bytes.set(keypair.publicKey.toBytes(), /* offset */ 32);\n return await createKeyPairFromBytes(bytes, extractable);\n}\n","import { ReadonlyUint8Array } from '@solana/codecs-core';\nimport { SOLANA_ERROR__TRANSACTION__MESSAGE_SIGNATURES_MISMATCH, SolanaError } from '@solana/errors';\nimport type { SignatureBytes } from '@solana/keys';\nimport { type SignaturesMap, Transaction, TransactionMessageBytes } from '@solana/transactions';\nimport type { PublicKey, VersionedTransaction } from '@solana/web3.js';\n\nfunction convertSignatures(transaction: VersionedTransaction, staticAccountKeys: PublicKey[]): SignaturesMap {\n return Object.fromEntries(\n transaction.signatures.map((sig, index) => {\n const address = staticAccountKeys[index];\n if (sig.every(b => b === 0)) {\n // all-0 signatures are stored as null\n return [address, null];\n } else {\n return [address, sig as ReadonlyUint8Array as SignatureBytes];\n }\n }),\n );\n}\n\nexport function fromVersionedTransaction(transaction: VersionedTransaction): Transaction {\n const { message } = transaction;\n const { staticAccountKeys } = message.getAccountKeys();\n\n const { numRequiredSignatures } = message.header;\n if (numRequiredSignatures !== transaction.signatures.length) {\n throw new SolanaError(SOLANA_ERROR__TRANSACTION__MESSAGE_SIGNATURES_MISMATCH, {\n numRequiredSignatures: transaction.message.header.numRequiredSignatures,\n signaturesLength: transaction.signatures.length,\n signerAddresses: staticAccountKeys.slice(0, numRequiredSignatures).map(p => p.toBase58()),\n });\n }\n\n const messageBytes = message.serialize() as ReadonlyUint8Array as TransactionMessageBytes;\n const signatures = convertSignatures(transaction, staticAccountKeys);\n\n return {\n messageBytes,\n signatures: Object.freeze(signatures),\n };\n}\n"]}
@@ -0,0 +1,51 @@
1
+ import { createKeyPairFromBytes } from '@solana/keys';
2
+ import { SolanaError, SOLANA_ERROR__TRANSACTION__MESSAGE_SIGNATURES_MISMATCH } from '@solana/errors';
3
+
4
+ // src/address.ts
5
+ function fromLegacyPublicKey(publicKey) {
6
+ return publicKey.toBase58();
7
+ }
8
+ async function fromLegacyKeypair(keypair, extractable) {
9
+ const bytes = new Uint8Array(64);
10
+ bytes.set(keypair.secretKey);
11
+ bytes.set(
12
+ keypair.publicKey.toBytes(),
13
+ /* offset */
14
+ 32
15
+ );
16
+ return await createKeyPairFromBytes(bytes, extractable);
17
+ }
18
+ function convertSignatures(transaction, staticAccountKeys) {
19
+ return Object.fromEntries(
20
+ transaction.signatures.map((sig, index) => {
21
+ const address = staticAccountKeys[index];
22
+ if (sig.every((b) => b === 0)) {
23
+ return [address, null];
24
+ } else {
25
+ return [address, sig];
26
+ }
27
+ })
28
+ );
29
+ }
30
+ function fromVersionedTransaction(transaction) {
31
+ const { message } = transaction;
32
+ const { staticAccountKeys } = message.getAccountKeys();
33
+ const { numRequiredSignatures } = message.header;
34
+ if (numRequiredSignatures !== transaction.signatures.length) {
35
+ throw new SolanaError(SOLANA_ERROR__TRANSACTION__MESSAGE_SIGNATURES_MISMATCH, {
36
+ numRequiredSignatures: transaction.message.header.numRequiredSignatures,
37
+ signaturesLength: transaction.signatures.length,
38
+ signerAddresses: staticAccountKeys.slice(0, numRequiredSignatures).map((p) => p.toBase58())
39
+ });
40
+ }
41
+ const messageBytes = message.serialize();
42
+ const signatures = convertSignatures(transaction, staticAccountKeys);
43
+ return {
44
+ messageBytes,
45
+ signatures: Object.freeze(signatures)
46
+ };
47
+ }
48
+
49
+ export { fromLegacyKeypair, fromLegacyPublicKey, fromVersionedTransaction };
50
+ //# sourceMappingURL=index.node.mjs.map
51
+ //# sourceMappingURL=index.node.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/address.ts","../src/keypair.ts","../src/transaction.ts"],"names":[],"mappings":";;;;AAQO,SAAS,oBAA6C,SAAyC,EAAA;AAClG,EAAA,OAAO,UAAU,QAAS,EAAA,CAAA;AAC9B,CAAA;ACFA,eAAsB,iBAAA,CAAkB,SAAkB,WAA+C,EAAA;AACrG,EAAM,MAAA,KAAA,GAAQ,IAAI,UAAA,CAAW,EAAE,CAAA,CAAA;AAC/B,EAAM,KAAA,CAAA,GAAA,CAAI,QAAQ,SAAS,CAAA,CAAA;AAC3B,EAAM,KAAA,CAAA,GAAA;AAAA,IAAI,OAAA,CAAQ,UAAU,OAAQ,E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A;AAAA,GACL;AAEA,EAAM,MAAA,YAAA,GAAe,QAAQ,SAAU,EAAA,CAAA;AACvC,EAAM,MAAA,UAAA,GAAa,iBAAkB,CAAA,WAAA,EAAa,iBAAiB,CAAA,CAAA;AAEnE,EAAO,OAAA;AAAA,IACH,YAAA;AAAA,IACA,UAAA,EAAY,MAAO,CAAA,MAAA,CAAO,UAAU,CAAA;AAAA,GACxC,CAAA;AACJ","file":"index.node.mjs","sourcesContent":["import { Address } from '@solana/addresses';\nimport { PublicKey } from '@solana/web3.js';\n\n/**\n * Convert from a Legacy Web3 JS PublicKey to a base58 encoded address\n * @param publicKey The PublicKey to convert\n * @returns An Address\n */\nexport function fromLegacyPublicKey<TAddress extends string>(publicKey: PublicKey): Address<TAddress> {\n return publicKey.toBase58() as Address<TAddress>;\n}\n","import { createKeyPairFromBytes } from '@solana/keys';\nimport { Keypair } from '@solana/web3.js';\n\n/**\n * Convert from a Legacy Web3 JS Keypair to a CryptoKeyPair\n * @param keypair The Keypair to convert\n * @returns A CryptoKeyPair\n */\nexport async function fromLegacyKeypair(keypair: Keypair, extractable?: boolean): Promise<CryptoKeyPair> {\n const bytes = new Uint8Array(64);\n bytes.set(keypair.secretKey);\n bytes.set(keypair.publicKey.toBytes(), /* offset */ 32);\n return await createKeyPairFromBytes(bytes, extractable);\n}\n","import { ReadonlyUint8Array } from '@solana/codecs-core';\nimport { SOLANA_ERROR__TRANSACTION__MESSAGE_SIGNATURES_MISMATCH, SolanaError } from '@solana/errors';\nimport type { SignatureBytes } from '@solana/keys';\nimport { type SignaturesMap, Transaction, TransactionMessageBytes } from '@solana/transactions';\nimport type { PublicKey, VersionedTransaction } from '@solana/web3.js';\n\nfunction convertSignatures(transaction: VersionedTransaction, staticAccountKeys: PublicKey[]): SignaturesMap {\n return Object.fromEntries(\n transaction.signatures.map((sig, index) => {\n const address = staticAccountKeys[index];\n if (sig.every(b => b === 0)) {\n // all-0 signatures are stored as null\n return [address, null];\n } else {\n return [address, sig as ReadonlyUint8Array as SignatureBytes];\n }\n }),\n );\n}\n\nexport function fromVersionedTransaction(transaction: VersionedTransaction): Transaction {\n const { message } = transaction;\n const { staticAccountKeys } = message.getAccountKeys();\n\n const { numRequiredSignatures } = message.header;\n if (numRequiredSignatures !== transaction.signatures.length) {\n throw new SolanaError(SOLANA_ERROR__TRANSACTION__MESSAGE_SIGNATURES_MISMATCH, {\n numRequiredSignatures: transaction.message.header.numRequiredSignatures,\n signaturesLength: transaction.signatures.length,\n signerAddresses: staticAccountKeys.slice(0, numRequiredSignatures).map(p => p.toBase58()),\n });\n }\n\n const messageBytes = message.serialize() as ReadonlyUint8Array as TransactionMessageBytes;\n const signatures = convertSignatures(transaction, staticAccountKeys);\n\n return {\n messageBytes,\n signatures: Object.freeze(signatures),\n };\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import { Address } from '@solana/addresses';
2
+ import { PublicKey } from '@solana/web3.js';
3
+ /**
4
+ * Convert from a Legacy Web3 JS PublicKey to a base58 encoded address
5
+ * @param publicKey The PublicKey to convert
6
+ * @returns An Address
7
+ */
8
+ export declare function fromLegacyPublicKey<TAddress extends string>(publicKey: PublicKey): Address<TAddress>;
9
+ //# sourceMappingURL=address.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../src/address.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,SAAS,MAAM,EAAE,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC,CAEpG"}
@@ -0,0 +1,4 @@
1
+ export * from './address';
2
+ export * from './keypair';
3
+ export * from './transaction';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { Keypair } from '@solana/web3.js';
2
+ /**
3
+ * Convert from a Legacy Web3 JS Keypair to a CryptoKeyPair
4
+ * @param keypair The Keypair to convert
5
+ * @returns A CryptoKeyPair
6
+ */
7
+ export declare function fromLegacyKeypair(keypair: Keypair, extractable?: boolean): Promise<CryptoKeyPair>;
8
+ //# sourceMappingURL=keypair.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keypair.d.ts","sourceRoot":"","sources":["../../src/keypair.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAKvG"}
@@ -0,0 +1,4 @@
1
+ import { Transaction } from '@solana/transactions';
2
+ import type { VersionedTransaction } from '@solana/web3.js';
3
+ export declare function fromVersionedTransaction(transaction: VersionedTransaction): Transaction;
4
+ //# sourceMappingURL=transaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../src/transaction.ts"],"names":[],"mappings":"AAGA,OAAO,EAAsB,WAAW,EAA2B,MAAM,sBAAsB,CAAC;AAChG,OAAO,KAAK,EAAa,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAgBvE,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,oBAAoB,GAAG,WAAW,CAoBvF"}
package/package.json ADDED
@@ -0,0 +1,85 @@
1
+ {
2
+ "name": "@solana/compat",
3
+ "version": "2.0.0-canary-20240731173615",
4
+ "description": "Helpers for converting from legacy web3js classes",
5
+ "exports": {
6
+ "browser": {
7
+ "import": "./dist/index.browser.mjs",
8
+ "require": "./dist/index.browser.cjs"
9
+ },
10
+ "node": {
11
+ "import": "./dist/index.node.mjs",
12
+ "require": "./dist/index.node.cjs"
13
+ },
14
+ "react-native": "./dist/index.native.mjs",
15
+ "types": "./dist/types/index.d.ts"
16
+ },
17
+ "browser": {
18
+ "./dist/index.node.cjs": "./dist/index.browser.cjs",
19
+ "./dist/index.node.mjs": "./dist/index.browser.mjs"
20
+ },
21
+ "main": "./dist/index.node.cjs",
22
+ "module": "./dist/index.node.mjs",
23
+ "react-native": "./dist/index.native.mjs",
24
+ "types": "./dist/types/index.d.ts",
25
+ "type": "commonjs",
26
+ "files": [
27
+ "./dist/"
28
+ ],
29
+ "sideEffects": false,
30
+ "keywords": [
31
+ "blockchain",
32
+ "solana",
33
+ "web3"
34
+ ],
35
+ "author": "Solana Labs Maintainers <maintainers@solanalabs.com>",
36
+ "license": "MIT",
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "https://github.com/solana-labs/solana-web3.js"
40
+ },
41
+ "bugs": {
42
+ "url": "http://github.com/solana-labs/solana-web3.js/issues"
43
+ },
44
+ "browserslist": [
45
+ "supports bigint and not dead",
46
+ "maintained node versions"
47
+ ],
48
+ "engine": {
49
+ "node": ">=17.4"
50
+ },
51
+ "dependencies": {
52
+ "@solana/addresses": "2.0.0-canary-20240731173615",
53
+ "@solana/codecs-core": "2.0.0-canary-20240731173615",
54
+ "@solana/errors": "2.0.0-canary-20240731173615",
55
+ "@solana/keys": "2.0.0-canary-20240731173615",
56
+ "@solana/transactions": "2.0.0-canary-20240731173615"
57
+ },
58
+ "peerDependencies": {
59
+ "typescript": ">=5"
60
+ },
61
+ "bundlewatch": {
62
+ "defaultCompression": "gzip",
63
+ "files": [
64
+ {
65
+ "path": "./dist/index*.js"
66
+ }
67
+ ]
68
+ },
69
+ "scripts": {
70
+ "compile:js": "tsup --config build-scripts/tsup.config.package.ts",
71
+ "compile:typedefs": "tsc -p ./tsconfig.declarations.json",
72
+ "dev": "jest -c ../../node_modules/@solana/test-config/jest-dev.config.ts --rootDir . --watch",
73
+ "publish-impl": "npm view $npm_package_name@$npm_package_version > /dev/null 2>&1 || pnpm publish --tag ${PUBLISH_TAG:-canary} --access public --no-git-checks",
74
+ "publish-packages": "pnpm prepublishOnly && pnpm publish-impl",
75
+ "style:fix": "pnpm eslint --fix src/* && pnpm prettier --log-level warn --ignore-unknown --write ./*",
76
+ "test:lint": "TERM_OVERRIDE=\"${TURBO_HASH:+dumb}\" TERM=${TERM_OVERRIDE:-$TERM} jest -c ../../node_modules/@solana/test-config/jest-lint.config.ts --rootDir . --silent",
77
+ "test:prettier": "TERM_OVERRIDE=\"${TURBO_HASH:+dumb}\" TERM=${TERM_OVERRIDE:-$TERM} jest -c ../../node_modules/@solana/test-config/jest-prettier.config.ts --rootDir . --silent",
78
+ "test:treeshakability:browser": "agadoo dist/index.browser.mjs",
79
+ "test:treeshakability:native": "agadoo dist/index.node.mjs",
80
+ "test:treeshakability:node": "agadoo dist/index.native.mjs",
81
+ "test:typecheck": "tsc --noEmit",
82
+ "test:unit:browser": "TERM_OVERRIDE=\"${TURBO_HASH:+dumb}\" TERM=${TERM_OVERRIDE:-$TERM} jest -c ../../node_modules/@solana/test-config/jest-unit.config.browser.ts --rootDir . --silent",
83
+ "test:unit:node": "TERM_OVERRIDE=\"${TURBO_HASH:+dumb}\" TERM=${TERM_OVERRIDE:-$TERM} jest -c ../../node_modules/@solana/test-config/jest-unit.config.node.ts --rootDir . --silent"
84
+ }
85
+ }