@prb/effect-solana 1.0.0-beta.0 → 1.0.0-beta.1

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.
@@ -0,0 +1,4 @@
1
+ export declare const TEST_KEYPAIR: Keypair;
2
+ export declare function createLegacyTransaction(): LegacyTransaction;
3
+ export declare function createVersionedTransaction(): VersionedTransaction;
4
+ //# sourceMappingURL=_fixtures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_fixtures.d.ts","sourceRoot":"","sources":["../../src/web3.js/_fixtures.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,YAAY,SAKxB,CAAC;AAaF,wBAAgB,uBAAuB,IAAI,iBAAiB,CAY3D;AAaD,wBAAgB,0BAA0B,IAAI,oBAAoB,CAcjE"}
@@ -0,0 +1,30 @@
1
+ import { Keypair, Transaction as LegacyTransaction, PublicKey, SystemProgram, TransactionInstruction, TransactionMessage, VersionedTransaction, } from "@solana/web3.js";
2
+ export const TEST_KEYPAIR = Keypair.fromSeed(new Uint8Array([
3
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
4
+ 27, 28, 29, 30, 31, 32,
5
+ ]));
6
+ export function createLegacyTransaction() {
7
+ const tx = new LegacyTransaction();
8
+ tx.add(new TransactionInstruction({
9
+ data: Buffer.from([0, 0, 0, 0]),
10
+ keys: [],
11
+ programId: SystemProgram.programId,
12
+ }));
13
+ tx.recentBlockhash = "GH7ome3EiwEr7tu9JuTh2dpYWBJK3z69Xm1ZE3MEE6JC";
14
+ tx.feePayer = new PublicKey("11111111111111111111111111111111");
15
+ return tx;
16
+ }
17
+ export function createVersionedTransaction() {
18
+ const instruction = new TransactionInstruction({
19
+ data: Buffer.from([0, 0, 0, 0]),
20
+ keys: [],
21
+ programId: SystemProgram.programId,
22
+ });
23
+ const messageV0 = new TransactionMessage({
24
+ instructions: [instruction],
25
+ payerKey: TEST_KEYPAIR.publicKey,
26
+ recentBlockhash: "GH7ome3EiwEr7tu9JuTh2dpYWBJK3z69Xm1ZE3MEE6JC",
27
+ }).compileToV0Message();
28
+ return new VersionedTransaction(messageV0);
29
+ }
30
+ //# sourceMappingURL=_fixtures.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_fixtures.js","sourceRoot":"","sources":["../../src/web3.js/_fixtures.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,OAAO,EACP,WAAW,IAAI,iBAAiB,EAChC,SAAS,EACT,aAAa,EACb,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AAKzB,MAAM,CAAC,MAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,CAC1C,IAAI,UAAU,CAAC;IACb,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;IAC7F,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;CACvB,CAAC,CACH,CAAC;AAaF,MAAM,UAAU,uBAAuB;IACrC,MAAM,EAAE,GAAG,IAAI,iBAAiB,EAAE,CAAC;IACnC,EAAE,CAAC,GAAG,CACJ,IAAI,sBAAsB,CAAC;QACzB,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAC/B,IAAI,EAAE,EAAE;QACR,SAAS,EAAE,aAAa,CAAC,SAAS;KACnC,CAAC,CACH,CAAC;IACF,EAAE,CAAC,eAAe,GAAG,8CAA8C,CAAC;IACpE,EAAE,CAAC,QAAQ,GAAG,IAAI,SAAS,CAAC,kCAAkC,CAAC,CAAC;IAChE,OAAO,EAAE,CAAC;AACZ,CAAC;AAaD,MAAM,UAAU,0BAA0B;IACxC,MAAM,WAAW,GAAG,IAAI,sBAAsB,CAAC;QAC7C,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAC/B,IAAI,EAAE,EAAE;QACR,SAAS,EAAE,aAAa,CAAC,SAAS;KACnC,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,IAAI,kBAAkB,CAAC;QACvC,YAAY,EAAE,CAAC,WAAW,CAAC;QAC3B,QAAQ,EAAE,YAAY,CAAC,SAAS;QAChC,eAAe,EAAE,8CAA8C;KAChE,CAAC,CAAC,kBAAkB,EAAE,CAAC;IAExB,OAAO,IAAI,oBAAoB,CAAC,SAAS,CAAC,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from "./layers.js";
2
+ export * from "./legacy-signer.js";
3
+ export * from "./transaction-bridge.js";
4
+ export * from "./types.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/web3.js/index.ts"],"names":[],"mappings":"AA2BA,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,YAAY,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from "./layers.js";
2
+ export * from "./legacy-signer.js";
3
+ export * from "./transaction-bridge.js";
4
+ export * from "./types.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/web3.js/index.ts"],"names":[],"mappings":"AA2BA,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,YAAY,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { Layer } from "effect";
2
+ import type { BalanceService } from "../balance/index.js";
3
+ import type { PdaService } from "../pda/index.js";
4
+ import type { SolanaClusterConfig } from "../presets/index.js";
5
+ import type { RpcService } from "../rpc/index.js";
6
+ import type { SignerService } from "../signer/index.js";
7
+ import type { TokenService } from "../token/index.js";
8
+ import type { TransactionService } from "../tx/index.js";
9
+ import type { LegacyWalletAdapter } from "./types.js";
10
+ export declare function makeSolanaLayerWithLegacyAdapter(config: SolanaClusterConfig, getAdapter: () => LegacyWalletAdapter): Layer.Layer<RpcService | SignerService | BalanceService | TokenService | TransactionService | PdaService>;
11
+ //# sourceMappingURL=layers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layers.d.ts","sourceRoot":"","sources":["../../src/web3.js/layers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAElE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AA6BtD,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,mBAAmB,EAC3B,UAAU,EAAE,MAAM,mBAAmB,GACpC,KAAK,CAAC,KAAK,CACZ,UAAU,GAAG,aAAa,GAAG,cAAc,GAAG,YAAY,GAAG,kBAAkB,GAAG,UAAU,CAC7F,CAOA"}
@@ -0,0 +1,10 @@
1
+ import { Layer } from "effect";
2
+ import { effectSolanaServices, makeRpcLayer } from "../presets/index.js";
3
+ import { makeSignerServiceFromLegacyAdapter } from "./legacy-signer.js";
4
+ export function makeSolanaLayerWithLegacyAdapter(config, getAdapter) {
5
+ const rpcLayer = makeRpcLayer(config);
6
+ const signerLayer = makeSignerServiceFromLegacyAdapter(getAdapter);
7
+ const baseLayers = Layer.mergeAll(rpcLayer, signerLayer);
8
+ return Layer.provideMerge(effectSolanaServices, baseLayers);
9
+ }
10
+ //# sourceMappingURL=layers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layers.js","sourceRoot":"","sources":["../../src/web3.js/layers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAI/B,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAK5E,OAAO,EAAE,kCAAkC,EAAE,MAAM,oBAAoB,CAAC;AA8BxE,MAAM,UAAU,gCAAgC,CAC9C,MAA2B,EAC3B,UAAqC;IAIrC,MAAM,QAAQ,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IACtC,MAAM,WAAW,GAAG,kCAAkC,CAAC,UAAU,CAAC,CAAC;IAEnE,MAAM,UAAU,GAAG,KAAK,CAAC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;IAEzD,OAAO,KAAK,CAAC,YAAY,CAAC,oBAAoB,EAAE,UAAU,CAAC,CAAC;AAC9D,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { Layer } from "effect";
2
+ import { SignerService } from "../signer/index.js";
3
+ import type { LegacyWalletAdapter } from "./types.js";
4
+ export declare function makeSignerServiceFromLegacyAdapter(getAdapter: () => LegacyWalletAdapter): Layer.Layer<SignerService>;
5
+ //# sourceMappingURL=legacy-signer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacy-signer.d.ts","sourceRoot":"","sources":["../../src/web3.js/legacy-signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,EAAE,MAAM,QAAQ,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAGtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AA2BtD,wBAAgB,kCAAkC,CAChD,UAAU,EAAE,MAAM,mBAAmB,GACpC,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC,CAiG5B"}
@@ -0,0 +1,59 @@
1
+ import { Effect, Layer } from "effect";
2
+ import { SignatureError, WalletNotConnectedError } from "../core/errors/index.js";
3
+ import { SignerService } from "../signer/index.js";
4
+ import { SpanNames } from "../telemetry/index.js";
5
+ import { fromWeb3Transaction, toWeb3Transaction } from "./transaction-bridge.js";
6
+ import { publicKeyToAddress } from "./types.js";
7
+ export function makeSignerServiceFromLegacyAdapter(getAdapter) {
8
+ return Layer.succeed(SignerService, SignerService.of({
9
+ getAddress: () => Effect.gen(function* () {
10
+ const adapter = getAdapter();
11
+ if (!(adapter.connected && adapter.publicKey)) {
12
+ return yield* Effect.fail(new WalletNotConnectedError({ message: "Wallet not connected" }));
13
+ }
14
+ if (typeof adapter.publicKey !== "object" ||
15
+ adapter.publicKey === null ||
16
+ typeof adapter.publicKey.toBase58 !== "function") {
17
+ return yield* Effect.fail(new WalletNotConnectedError({
18
+ message: "Invalid publicKey: missing toBase58 method",
19
+ }));
20
+ }
21
+ return publicKeyToAddress(adapter.publicKey);
22
+ }).pipe(Effect.withSpan(SpanNames.SIGNER_GET_ADDRESS)),
23
+ isConnected: () => Effect.sync(() => getAdapter().connected),
24
+ signAllTransactions: (txs) => Effect.gen(function* () {
25
+ if (txs.length === 0) {
26
+ return [];
27
+ }
28
+ const adapter = getAdapter();
29
+ if (!adapter.connected) {
30
+ return yield* Effect.fail(new WalletNotConnectedError({ message: "Wallet not connected" }));
31
+ }
32
+ const legacyTxs = yield* Effect.all(txs.map((tx) => Effect.promise(() => toWeb3Transaction(tx))));
33
+ const signedAll = yield* Effect.tryPromise({
34
+ catch: (cause) => new SignatureError({
35
+ cause,
36
+ message: cause instanceof Error ? cause.message : "Failed to sign transactions",
37
+ }),
38
+ try: () => adapter.signAllTransactions(legacyTxs),
39
+ });
40
+ return signedAll.map((signed) => fromWeb3Transaction(signed));
41
+ }).pipe(Effect.withSpan(SpanNames.TX_SIGN)),
42
+ signTransaction: (tx) => Effect.gen(function* () {
43
+ const adapter = getAdapter();
44
+ if (!adapter.connected) {
45
+ return yield* Effect.fail(new WalletNotConnectedError({ message: "Wallet not connected" }));
46
+ }
47
+ const legacyTx = yield* Effect.promise(() => toWeb3Transaction(tx));
48
+ const signed = yield* Effect.tryPromise({
49
+ catch: (cause) => new SignatureError({
50
+ cause,
51
+ message: cause instanceof Error ? cause.message : "Failed to sign transaction",
52
+ }),
53
+ try: () => adapter.signTransaction(legacyTx),
54
+ });
55
+ return fromWeb3Transaction(signed);
56
+ }).pipe(Effect.withSpan(SpanNames.TX_SIGN)),
57
+ }));
58
+ }
59
+ //# sourceMappingURL=legacy-signer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacy-signer.js","sourceRoot":"","sources":["../../src/web3.js/legacy-signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjF,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AA0BhD,MAAM,UAAU,kCAAkC,CAChD,UAAqC;IAErC,OAAO,KAAK,C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G,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC,CAAC;YAGpE,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC;gBACtC,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CACf,IAAI,cAAc,CAAC;oBACjB,KAAK;oBACL,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,4BAA4B;iBAC/E,CAAC;gBACJ,GAAG,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,eAAe,CAAC,QAAQ,CAAC;aAC7C,CAAC,CAAC;YAIH,OAAO,mBAAmB,CACxB,MAAmD,CACvC,CAAC;QACjB,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;KAC9C,CAAC,CACH,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { Transaction, TransactionWithLifetime } from "@solana/transactions";
2
+ export declare function toWeb3Transaction(tx: Transaction & TransactionWithLifetime): Promise<unknown>;
3
+ export declare function fromWeb3Transaction(tx: {
4
+ serialize(opts: {
5
+ requireAllSignatures: boolean;
6
+ verifySignatures: boolean;
7
+ }): Uint8Array;
8
+ }): Transaction & TransactionWithLifetime;
9
+ //# sourceMappingURL=transaction-bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction-bridge.d.ts","sourceRoot":"","sources":["../../src/web3.js/transaction-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAoDjF,wBAAsB,iBAAiB,CACrC,EAAE,EAAE,WAAW,GAAG,uBAAuB,GACxC,OAAO,CAAC,OAAO,CAAC,CAuBlB;AAsBD,wBAAgB,mBAAmB,CAAC,EAAE,EAAE;IACtC,SAAS,CAAC,IAAI,EAAE;QAAE,oBAAoB,EAAE,OAAO,CAAC;QAAC,gBAAgB,EAAE,OAAO,CAAA;KAAE,GAAG,UAAU,CAAC;CAC3F,GAAG,WAAW,GAAG,uBAAuB,CAQxC"}
@@ -0,0 +1,45 @@
1
+ import { getTransactionDecoder, getTransactionEncoder } from "@solana/transactions";
2
+ let _encoder = null;
3
+ let _decoder = null;
4
+ function getEncoder() {
5
+ if (_encoder === null) {
6
+ _encoder = getTransactionEncoder();
7
+ }
8
+ return _encoder;
9
+ }
10
+ function getDecoder() {
11
+ if (_decoder === null) {
12
+ _decoder = getTransactionDecoder();
13
+ }
14
+ return _decoder;
15
+ }
16
+ function isVersionedMessage(messageBytes) {
17
+ return (messageBytes[0] & 0x80) !== 0;
18
+ }
19
+ export async function toWeb3Transaction(tx) {
20
+ const wire = getEncoder().encode(tx);
21
+ let LegacyTransaction;
22
+ let VersionedTransaction;
23
+ try {
24
+ const web3Module = await import("@solana/web3.js");
25
+ LegacyTransaction = web3Module.Transaction;
26
+ VersionedTransaction = web3Module.VersionedTransaction;
27
+ }
28
+ catch (error) {
29
+ throw new Error("@solana/web3.js is required for legacy compatibility. Install it as a peer dependency.", { cause: error });
30
+ }
31
+ const wireBytes = new Uint8Array(wire);
32
+ return isVersionedMessage(wireBytes)
33
+ ? VersionedTransaction.deserialize(wireBytes)
34
+ : LegacyTransaction.from(wireBytes);
35
+ }
36
+ export function fromWeb3Transaction(tx) {
37
+ const wire = tx.serialize({ requireAllSignatures: false, verifySignatures: false });
38
+ try {
39
+ return getDecoder().decode(wire);
40
+ }
41
+ catch (error) {
42
+ throw new Error("Failed to decode transaction from web3.js format", { cause: error });
43
+ }
44
+ }
45
+ //# sourceMappingURL=transaction-bridge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction-bridge.js","sourceRoot":"","sources":["../../src/web3.js/transaction-bridge.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,qBAAqB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,CAAC;AACxC,CAAC;AAsBD,MAAM,UAAU,mBAAmB,CAAC,EAEnC;IACC,MAAM,IAAI,GAAG,EAAE,CAAC,SAAS,CAAC,EAAE,oBAAoB,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC,CAAC;IAEpF,IAAI,CAAC;QACH,OAAO,UAAU,EAAE,CAAC,MAAM,CAAC,IAAI,CAA0C,CAAC;IAC5E,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,kDAAkD,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACxF,CAAC;AACH,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { Address } from "@solana/addresses";
2
+ export type LegacyWalletAdapter = {
3
+ readonly publicKey: unknown | null;
4
+ readonly connected: boolean;
5
+ readonly signTransaction: <T>(tx: T) => Promise<T>;
6
+ readonly signAllTransactions: <T>(txs: T[]) => Promise<T[]>;
7
+ };
8
+ export declare function publicKeyToAddress(pk: {
9
+ toBase58(): string;
10
+ }): Address;
11
+ export declare function addressToPublicKey(addr: Address): Promise<unknown>;
12
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/web3.js/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAoBjD,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,CAAC;IACnC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,eAAe,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,mBAAmB,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;CAC7D,CAAC;AAoBF,wBAAgB,kBAAkB,CAAC,EAAE,EAAE;IAAE,QAAQ,IAAI,MAAM,CAAA;CAAE,GAAG,OAAO,CAEtE;AAqBD,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAUxE"}
@@ -0,0 +1,14 @@
1
+ import { address } from "@solana/addresses";
2
+ export function publicKeyToAddress(pk) {
3
+ return address(pk.toBase58());
4
+ }
5
+ export async function addressToPublicKey(addr) {
6
+ try {
7
+ const { PublicKey } = await import("@solana/web3.js");
8
+ return new PublicKey(addr);
9
+ }
10
+ catch (error) {
11
+ throw new Error("@solana/web3.js is required for legacy compatibility. Install it as a peer dependency.", { cause: error });
12
+ }
13
+ }
14
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/web3.js/types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AA4C5C,MAAM,UAAU,kBAAkB,CAAC,EAA0B;IAC3D,OAAO,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;AAChC,CAAC;AAqBD,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,IAAa;IACpD,IAAI,CAAC;QACH,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,MAAM,CAAC,iBAAiB,CAAC,CAAC;QACtD,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,wFAAwF,EACxF,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;IACJ,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prb/effect-solana",
3
3
  "description": "Effect-TS integration for Solana",
4
- "version": "1.0.0-beta.0",
4
+ "version": "1.0.0-beta.1",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
@@ -28,6 +28,7 @@
28
28
  "@solana-program/system": "^0.8.0",
29
29
  "@solana-program/token": "^0.8.0",
30
30
  "@solana/kit": "^2.2.7",
31
+ "@solana/web3.js": "^1.95.0",
31
32
  "@types/node": "^25.0.3",
32
33
  "@types/react": "catalog:dev",
33
34
  "@types/react-dom": "catalog:dev",
@@ -64,10 +65,14 @@
64
65
  "@solana-program/system": "^0.8.0",
65
66
  "@solana-program/token": "^0.8.0",
66
67
  "@solana-program/compute-budget": "^0.8.0",
68
+ "@solana/web3.js": "^1.95.0",
67
69
  "react": "catalog:peers",
68
70
  "react-dom": "catalog:peers"
69
71
  },
70
72
  "peerDependenciesMeta": {
73
+ "@solana/web3.js": {
74
+ "optional": true
75
+ },
71
76
  "react": {
72
77
  "optional": true
73
78
  },