@funkit/solana-web3 0.0.0-stage → 0.0.0
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.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +103 -0
- package/dist/index.js.map +7 -0
- package/dist/index.mjs +74 -0
- package/dist/index.mjs.map +7 -0
- package/dist/src/solanaAdapter.d.ts +34 -0
- package/dist/src/solanaAdapter.d.ts.map +1 -0
- package/package.json +63 -3
- package/README.md +0 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,yBAAyB,EAC9B,KAAK,gBAAgB,EACrB,KAAK,4BAA4B,EACjC,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAC1B,mBAAmB,GACpB,MAAM,qBAAqB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
createSolanaAdapter: () => createSolanaAdapter
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(index_exports);
|
|
36
|
+
|
|
37
|
+
// src/solanaAdapter.ts
|
|
38
|
+
var import_fun_relay = require("@funkit/fun-relay");
|
|
39
|
+
var import_relay_svm_wallet_adapter = require("@relayprotocol/relay-svm-wallet-adapter");
|
|
40
|
+
var import_web3 = require("@solana/web3.js");
|
|
41
|
+
var import_bs58 = __toESM(require("bs58"));
|
|
42
|
+
var SIGNATURE_BYTE_LENGTH = 64;
|
|
43
|
+
function resolveSubmit(signer, connection) {
|
|
44
|
+
const signTransaction = signer.signTransaction?.bind(signer);
|
|
45
|
+
const signAndSendTransaction = signer.signAndSendTransaction?.bind(signer);
|
|
46
|
+
if (signTransaction) {
|
|
47
|
+
return async (transaction, options) => {
|
|
48
|
+
const signed = await signTransaction(transaction);
|
|
49
|
+
try {
|
|
50
|
+
const signature = await connection.sendTransaction(signed, {
|
|
51
|
+
...options,
|
|
52
|
+
maxRetries: 5
|
|
53
|
+
});
|
|
54
|
+
return { signature };
|
|
55
|
+
} catch (error) {
|
|
56
|
+
if (error instanceof import_web3.SendTransactionError) {
|
|
57
|
+
console.error(
|
|
58
|
+
"Failed transaction logs:",
|
|
59
|
+
error,
|
|
60
|
+
await error.getLogs(connection).catch(() => void 0)
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
if (signAndSendTransaction) {
|
|
68
|
+
return async (transaction) => {
|
|
69
|
+
const signature = await signAndSendTransaction(transaction);
|
|
70
|
+
if (!(signature instanceof Uint8Array) || signature.length !== SIGNATURE_BYTE_LENGTH) {
|
|
71
|
+
throw new Error(
|
|
72
|
+
`signAndSendTransaction must resolve a ${SIGNATURE_BYTE_LENGTH}-byte signature. The transaction may already have been submitted.`
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
return { signature: import_bs58.default.encode(signature) };
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
throw new Error("Solana signer supplied no way to sign a transaction");
|
|
79
|
+
}
|
|
80
|
+
function resolveSigningMethod(params) {
|
|
81
|
+
if (params.signTransaction) {
|
|
82
|
+
return "signTransaction";
|
|
83
|
+
}
|
|
84
|
+
if (params.signAndSendTransaction) {
|
|
85
|
+
return "signAndSendTransaction";
|
|
86
|
+
}
|
|
87
|
+
return void 0;
|
|
88
|
+
}
|
|
89
|
+
function createSolanaAdapter(params) {
|
|
90
|
+
return {
|
|
91
|
+
engine: "web3",
|
|
92
|
+
address: params.address,
|
|
93
|
+
signingMethod: resolveSigningMethod(params),
|
|
94
|
+
createRelayWallet: () => (0, import_relay_svm_wallet_adapter.adaptSolanaWallet)(
|
|
95
|
+
params.address,
|
|
96
|
+
import_fun_relay.RELAY_SOLANA_CHAIN_ID_NUMBER,
|
|
97
|
+
params.connection,
|
|
98
|
+
resolveSubmit(params, params.connection),
|
|
99
|
+
params.payerKey
|
|
100
|
+
)
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../index.ts", "../src/solanaAdapter.ts"],
|
|
4
|
+
"sourcesContent": ["// @funkit/solana-web3\n//\n// Builds the FunkitSolanaAdapter for hosts on @solana/web3.js, wrapping\n// Relay's SVM adapter. relay-sdk is a peer because the adapter reads its\n// module-level client: a second copy has no client and every transaction throws.\nexport {\n type CreateSolanaAdapterParams,\n type SolanaConnection,\n type SolanaSignAndSendTransaction,\n type SolanaSigner,\n type SolanaSignTransaction,\n createSolanaAdapter,\n} from './src/solanaAdapter'\n", "import {\n type FunkitSolanaAdapter,\n RELAY_SOLANA_CHAIN_ID_NUMBER,\n type SolanaWallet,\n} from '@funkit/fun-relay'\nimport { adaptSolanaWallet } from '@relayprotocol/relay-svm-wallet-adapter'\nimport {\n type Connection,\n type SendOptions,\n SendTransactionError,\n type TransactionSignature,\n type VersionedTransaction,\n} from '@solana/web3.js'\nimport bs58 from 'bs58'\n\n/** Ed25519, so the transaction id is always these many bytes. */\nconst SIGNATURE_BYTE_LENGTH = 64\n\n/** The host's web3.js connection, used for blockhashes and funkit's own submits. */\nexport type SolanaConnection = Connection\n\n/** Signs and hands the transaction back, for funkit to submit. */\nexport type SolanaSignTransaction = (\n transaction: VersionedTransaction,\n) => Promise<VersionedTransaction>\n\n/** Signs and submits, resolving the transaction's 64-byte signature. */\nexport type SolanaSignAndSendTransaction = (\n transaction: VersionedTransaction,\n) => Promise<Uint8Array>\n\n/**\n * At least one of the two. `signTransaction` wins when both are supplied, since\n * submitting through funkit is what applies the rebroadcast retries and logs.\n */\nexport type SolanaSigner =\n | {\n signTransaction: SolanaSignTransaction\n signAndSendTransaction?: SolanaSignAndSendTransaction\n }\n | {\n signTransaction?: SolanaSignTransaction\n signAndSendTransaction: SolanaSignAndSendTransaction\n }\n\nexport type CreateSolanaAdapterParams = {\n /** Base58 address of the connected wallet. funkit validates it, not this factory. */\n address: string\n /** Use an endpoint you trust for write traffic; public RPCs rate-limit. */\n connection: SolanaConnection\n /** Base58 fee payer when it isn't `address`, e.g. a sponsor that co-signs. */\n payerKey?: string\n} & SolanaSigner\n\n/** Relay's submission hook: sign (or sign-and-send) and return the signature. */\ntype RelaySubmit = (\n transaction: VersionedTransaction,\n options?: SendOptions,\n) => Promise<{ signature: TransactionSignature }>\n\nfunction resolveSubmit(\n signer: SolanaSigner,\n connection: Connection,\n): RelaySubmit {\n // Bound to the host's object: a class-based signer loses `this` when its\n // methods are pulled off or spread.\n const signTransaction = signer.signTransaction?.bind(signer)\n const signAndSendTransaction = signer.signAndSendTransaction?.bind(signer)\n\n // Submitting here is what applies the rebroadcast retries and failure logs.\n if (signTransaction) {\n return async (transaction, options) => {\n const signed = await signTransaction(transaction)\n try {\n const signature = await connection.sendTransaction(signed, {\n ...options,\n maxRetries: 5,\n })\n\n return { signature }\n } catch (error) {\n if (error instanceof SendTransactionError) {\n console.error(\n 'Failed transaction logs:',\n error,\n await error.getLogs(connection).catch(() => undefined),\n )\n }\n\n throw error\n }\n }\n }\n\n if (signAndSendTransaction) {\n return async (transaction) => {\n const signature = await signAndSendTransaction(transaction)\n\n // Relay asserts base58 on submit and again on confirm, so a host that\n // forwards its wallet's result unmapped has to fail here instead.\n if (\n !(signature instanceof Uint8Array) ||\n signature.length !== SIGNATURE_BYTE_LENGTH\n ) {\n throw new Error(\n `signAndSendTransaction must resolve a ${SIGNATURE_BYTE_LENGTH}-byte signature. The transaction may already have been submitted.`,\n )\n }\n\n return { signature: bs58.encode(signature) }\n }\n }\n\n throw new Error('Solana signer supplied no way to sign a transaction')\n}\n\n/** Matches `resolveSubmit`: `signTransaction` wins, and neither means it can't sign. */\nfunction resolveSigningMethod(\n params: CreateSolanaAdapterParams,\n): FunkitSolanaAdapter['signingMethod'] {\n if (params.signTransaction) {\n return 'signTransaction'\n }\n if (params.signAndSendTransaction) {\n return 'signAndSendTransaction'\n }\n return undefined\n}\n\n/**\n * Never throws, so hosts can call it during render. With no signing method\n * `signingMethod` is undefined, and funkit disables Solana flows instead of\n * calling `createRelayWallet()`, which would throw.\n */\nexport function createSolanaAdapter(\n params: CreateSolanaAdapterParams,\n): FunkitSolanaAdapter {\n return {\n engine: 'web3',\n address: params.address,\n signingMethod: resolveSigningMethod(params),\n createRelayWallet: () =>\n adaptSolanaWallet(\n params.address,\n RELAY_SOLANA_CHAIN_ID_NUMBER,\n params.connection,\n resolveSubmit(params, params.connection),\n params.payerKey,\n ) as SolanaWallet,\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,uBAIO;AACP,sCAAkC;AAClC,kBAMO;AACP,kBAAiB;AAGjB,IAAM,wBAAwB;AA4C9B,SAAS,cACP,QACA,YACa;AAGb,QAAM,kBAAkB,OAAO,iBAAiB,KAAK,MAAM;AAC3D,QAAM,yBAAyB,OAAO,wBAAwB,KAAK,MAAM;AAGzE,MAAI,iBAAiB;AACnB,WAAO,OAAO,aAAa,YAAY;AACrC,YAAM,SAAS,MAAM,gBAAgB,WAAW;AAChD,UAAI;AACF,cAAM,YAAY,MAAM,WAAW,gBAAgB,QAAQ;AAAA,UACzD,GAAG;AAAA,UACH,YAAY;AAAA,QACd,CAAC;AAED,eAAO,EAAE,UAAU;AAAA,MACrB,SAAS,OAAO;AACd,YAAI,iBAAiB,kCAAsB;AACzC,kBAAQ;AAAA,YACN;AAAA,YACA;AAAA,YACA,MAAM,MAAM,QAAQ,UAAU,EAAE,MAAM,MAAM,MAAS;AAAA,UACvD;AAAA,QACF;AAEA,cAAM;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,MAAI,wBAAwB;AAC1B,WAAO,OAAO,gBAAgB;AAC5B,YAAM,YAAY,MAAM,uBAAuB,WAAW;AAI1D,UACE,EAAE,qBAAqB,eACvB,UAAU,WAAW,uBACrB;AACA,cAAM,IAAI;AAAA,UACR,yCAAyC,qBAAqB;AAAA,QAChE;AAAA,MACF;AAEA,aAAO,EAAE,WAAW,YAAAA,QAAK,OAAO,SAAS,EAAE;AAAA,IAC7C;AAAA,EACF;AAEA,QAAM,IAAI,MAAM,qDAAqD;AACvE;AAGA,SAAS,qBACP,QACsC;AACtC,MAAI,OAAO,iBAAiB;AAC1B,WAAO;AAAA,EACT;AACA,MAAI,OAAO,wBAAwB;AACjC,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAOO,SAAS,oBACd,QACqB;AACrB,SAAO;AAAA,IACL,QAAQ;AAAA,IACR,SAAS,OAAO;AAAA,IAChB,eAAe,qBAAqB,MAAM;AAAA,IAC1C,mBAAmB,UACjB;AAAA,MACE,OAAO;AAAA,MACP;AAAA,MACA,OAAO;AAAA,MACP,cAAc,QAAQ,OAAO,UAAU;AAAA,MACvC,OAAO;AAAA,IACT;AAAA,EACJ;AACF;",
|
|
6
|
+
"names": ["bs58"]
|
|
7
|
+
}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// src/solanaAdapter.ts
|
|
2
|
+
import {
|
|
3
|
+
RELAY_SOLANA_CHAIN_ID_NUMBER
|
|
4
|
+
} from "@funkit/fun-relay";
|
|
5
|
+
import { adaptSolanaWallet } from "@relayprotocol/relay-svm-wallet-adapter";
|
|
6
|
+
import {
|
|
7
|
+
SendTransactionError
|
|
8
|
+
} from "@solana/web3.js";
|
|
9
|
+
import bs58 from "bs58";
|
|
10
|
+
var SIGNATURE_BYTE_LENGTH = 64;
|
|
11
|
+
function resolveSubmit(signer, connection) {
|
|
12
|
+
const signTransaction = signer.signTransaction?.bind(signer);
|
|
13
|
+
const signAndSendTransaction = signer.signAndSendTransaction?.bind(signer);
|
|
14
|
+
if (signTransaction) {
|
|
15
|
+
return async (transaction, options) => {
|
|
16
|
+
const signed = await signTransaction(transaction);
|
|
17
|
+
try {
|
|
18
|
+
const signature = await connection.sendTransaction(signed, {
|
|
19
|
+
...options,
|
|
20
|
+
maxRetries: 5
|
|
21
|
+
});
|
|
22
|
+
return { signature };
|
|
23
|
+
} catch (error) {
|
|
24
|
+
if (error instanceof SendTransactionError) {
|
|
25
|
+
console.error(
|
|
26
|
+
"Failed transaction logs:",
|
|
27
|
+
error,
|
|
28
|
+
await error.getLogs(connection).catch(() => void 0)
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
if (signAndSendTransaction) {
|
|
36
|
+
return async (transaction) => {
|
|
37
|
+
const signature = await signAndSendTransaction(transaction);
|
|
38
|
+
if (!(signature instanceof Uint8Array) || signature.length !== SIGNATURE_BYTE_LENGTH) {
|
|
39
|
+
throw new Error(
|
|
40
|
+
`signAndSendTransaction must resolve a ${SIGNATURE_BYTE_LENGTH}-byte signature. The transaction may already have been submitted.`
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
return { signature: bs58.encode(signature) };
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
throw new Error("Solana signer supplied no way to sign a transaction");
|
|
47
|
+
}
|
|
48
|
+
function resolveSigningMethod(params) {
|
|
49
|
+
if (params.signTransaction) {
|
|
50
|
+
return "signTransaction";
|
|
51
|
+
}
|
|
52
|
+
if (params.signAndSendTransaction) {
|
|
53
|
+
return "signAndSendTransaction";
|
|
54
|
+
}
|
|
55
|
+
return void 0;
|
|
56
|
+
}
|
|
57
|
+
function createSolanaAdapter(params) {
|
|
58
|
+
return {
|
|
59
|
+
engine: "web3",
|
|
60
|
+
address: params.address,
|
|
61
|
+
signingMethod: resolveSigningMethod(params),
|
|
62
|
+
createRelayWallet: () => adaptSolanaWallet(
|
|
63
|
+
params.address,
|
|
64
|
+
RELAY_SOLANA_CHAIN_ID_NUMBER,
|
|
65
|
+
params.connection,
|
|
66
|
+
resolveSubmit(params, params.connection),
|
|
67
|
+
params.payerKey
|
|
68
|
+
)
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export {
|
|
72
|
+
createSolanaAdapter
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/solanaAdapter.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n type FunkitSolanaAdapter,\n RELAY_SOLANA_CHAIN_ID_NUMBER,\n type SolanaWallet,\n} from '@funkit/fun-relay'\nimport { adaptSolanaWallet } from '@relayprotocol/relay-svm-wallet-adapter'\nimport {\n type Connection,\n type SendOptions,\n SendTransactionError,\n type TransactionSignature,\n type VersionedTransaction,\n} from '@solana/web3.js'\nimport bs58 from 'bs58'\n\n/** Ed25519, so the transaction id is always these many bytes. */\nconst SIGNATURE_BYTE_LENGTH = 64\n\n/** The host's web3.js connection, used for blockhashes and funkit's own submits. */\nexport type SolanaConnection = Connection\n\n/** Signs and hands the transaction back, for funkit to submit. */\nexport type SolanaSignTransaction = (\n transaction: VersionedTransaction,\n) => Promise<VersionedTransaction>\n\n/** Signs and submits, resolving the transaction's 64-byte signature. */\nexport type SolanaSignAndSendTransaction = (\n transaction: VersionedTransaction,\n) => Promise<Uint8Array>\n\n/**\n * At least one of the two. `signTransaction` wins when both are supplied, since\n * submitting through funkit is what applies the rebroadcast retries and logs.\n */\nexport type SolanaSigner =\n | {\n signTransaction: SolanaSignTransaction\n signAndSendTransaction?: SolanaSignAndSendTransaction\n }\n | {\n signTransaction?: SolanaSignTransaction\n signAndSendTransaction: SolanaSignAndSendTransaction\n }\n\nexport type CreateSolanaAdapterParams = {\n /** Base58 address of the connected wallet. funkit validates it, not this factory. */\n address: string\n /** Use an endpoint you trust for write traffic; public RPCs rate-limit. */\n connection: SolanaConnection\n /** Base58 fee payer when it isn't `address`, e.g. a sponsor that co-signs. */\n payerKey?: string\n} & SolanaSigner\n\n/** Relay's submission hook: sign (or sign-and-send) and return the signature. */\ntype RelaySubmit = (\n transaction: VersionedTransaction,\n options?: SendOptions,\n) => Promise<{ signature: TransactionSignature }>\n\nfunction resolveSubmit(\n signer: SolanaSigner,\n connection: Connection,\n): RelaySubmit {\n // Bound to the host's object: a class-based signer loses `this` when its\n // methods are pulled off or spread.\n const signTransaction = signer.signTransaction?.bind(signer)\n const signAndSendTransaction = signer.signAndSendTransaction?.bind(signer)\n\n // Submitting here is what applies the rebroadcast retries and failure logs.\n if (signTransaction) {\n return async (transaction, options) => {\n const signed = await signTransaction(transaction)\n try {\n const signature = await connection.sendTransaction(signed, {\n ...options,\n maxRetries: 5,\n })\n\n return { signature }\n } catch (error) {\n if (error instanceof SendTransactionError) {\n console.error(\n 'Failed transaction logs:',\n error,\n await error.getLogs(connection).catch(() => undefined),\n )\n }\n\n throw error\n }\n }\n }\n\n if (signAndSendTransaction) {\n return async (transaction) => {\n const signature = await signAndSendTransaction(transaction)\n\n // Relay asserts base58 on submit and again on confirm, so a host that\n // forwards its wallet's result unmapped has to fail here instead.\n if (\n !(signature instanceof Uint8Array) ||\n signature.length !== SIGNATURE_BYTE_LENGTH\n ) {\n throw new Error(\n `signAndSendTransaction must resolve a ${SIGNATURE_BYTE_LENGTH}-byte signature. The transaction may already have been submitted.`,\n )\n }\n\n return { signature: bs58.encode(signature) }\n }\n }\n\n throw new Error('Solana signer supplied no way to sign a transaction')\n}\n\n/** Matches `resolveSubmit`: `signTransaction` wins, and neither means it can't sign. */\nfunction resolveSigningMethod(\n params: CreateSolanaAdapterParams,\n): FunkitSolanaAdapter['signingMethod'] {\n if (params.signTransaction) {\n return 'signTransaction'\n }\n if (params.signAndSendTransaction) {\n return 'signAndSendTransaction'\n }\n return undefined\n}\n\n/**\n * Never throws, so hosts can call it during render. With no signing method\n * `signingMethod` is undefined, and funkit disables Solana flows instead of\n * calling `createRelayWallet()`, which would throw.\n */\nexport function createSolanaAdapter(\n params: CreateSolanaAdapterParams,\n): FunkitSolanaAdapter {\n return {\n engine: 'web3',\n address: params.address,\n signingMethod: resolveSigningMethod(params),\n createRelayWallet: () =>\n adaptSolanaWallet(\n params.address,\n RELAY_SOLANA_CHAIN_ID_NUMBER,\n params.connection,\n resolveSubmit(params, params.connection),\n params.payerKey,\n ) as SolanaWallet,\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAAA;AAAA,EAEE;AAAA,OAEK;AACP,SAAS,yBAAyB;AAClC;AAAA,EAGE;AAAA,OAGK;AACP,OAAO,UAAU;AAGjB,IAAM,wBAAwB;AA4C9B,SAAS,cACP,QACA,YACa;AAGb,QAAM,kBAAkB,OAAO,iBAAiB,KAAK,MAAM;AAC3D,QAAM,yBAAyB,OAAO,wBAAwB,KAAK,MAAM;AAGzE,MAAI,iBAAiB;AACnB,WAAO,OAAO,aAAa,YAAY;AACrC,YAAM,SAAS,MAAM,gBAAgB,WAAW;AAChD,UAAI;AACF,cAAM,YAAY,MAAM,WAAW,gBAAgB,QAAQ;AAAA,UACzD,GAAG;AAAA,UACH,YAAY;AAAA,QACd,CAAC;AAED,eAAO,EAAE,UAAU;AAAA,MACrB,SAAS,OAAO;AACd,YAAI,iBAAiB,sBAAsB;AACzC,kBAAQ;AAAA,YACN;AAAA,YACA;AAAA,YACA,MAAM,MAAM,QAAQ,UAAU,EAAE,MAAM,MAAM,MAAS;AAAA,UACvD;AAAA,QACF;AAEA,cAAM;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,MAAI,wBAAwB;AAC1B,WAAO,OAAO,gBAAgB;AAC5B,YAAM,YAAY,MAAM,uBAAuB,WAAW;AAI1D,UACE,EAAE,qBAAqB,eACvB,UAAU,WAAW,uBACrB;AACA,cAAM,IAAI;AAAA,UACR,yCAAyC,qBAAqB;AAAA,QAChE;AAAA,MACF;AAEA,aAAO,EAAE,WAAW,KAAK,OAAO,SAAS,EAAE;AAAA,IAC7C;AAAA,EACF;AAEA,QAAM,IAAI,MAAM,qDAAqD;AACvE;AAGA,SAAS,qBACP,QACsC;AACtC,MAAI,OAAO,iBAAiB;AAC1B,WAAO;AAAA,EACT;AACA,MAAI,OAAO,wBAAwB;AACjC,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAOO,SAAS,oBACd,QACqB;AACrB,SAAO;AAAA,IACL,QAAQ;AAAA,IACR,SAAS,OAAO;AAAA,IAChB,eAAe,qBAAqB,MAAM;AAAA,IAC1C,mBAAmB,MACjB;AAAA,MACE,OAAO;AAAA,MACP;AAAA,MACA,OAAO;AAAA,MACP,cAAc,QAAQ,OAAO,UAAU;AAAA,MACvC,OAAO;AAAA,IACT;AAAA,EACJ;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type FunkitSolanaAdapter } from '@funkit/fun-relay';
|
|
2
|
+
import { type Connection, type VersionedTransaction } from '@solana/web3.js';
|
|
3
|
+
/** The host's web3.js connection, used for blockhashes and funkit's own submits. */
|
|
4
|
+
export type SolanaConnection = Connection;
|
|
5
|
+
/** Signs and hands the transaction back, for funkit to submit. */
|
|
6
|
+
export type SolanaSignTransaction = (transaction: VersionedTransaction) => Promise<VersionedTransaction>;
|
|
7
|
+
/** Signs and submits, resolving the transaction's 64-byte signature. */
|
|
8
|
+
export type SolanaSignAndSendTransaction = (transaction: VersionedTransaction) => Promise<Uint8Array>;
|
|
9
|
+
/**
|
|
10
|
+
* At least one of the two. `signTransaction` wins when both are supplied, since
|
|
11
|
+
* submitting through funkit is what applies the rebroadcast retries and logs.
|
|
12
|
+
*/
|
|
13
|
+
export type SolanaSigner = {
|
|
14
|
+
signTransaction: SolanaSignTransaction;
|
|
15
|
+
signAndSendTransaction?: SolanaSignAndSendTransaction;
|
|
16
|
+
} | {
|
|
17
|
+
signTransaction?: SolanaSignTransaction;
|
|
18
|
+
signAndSendTransaction: SolanaSignAndSendTransaction;
|
|
19
|
+
};
|
|
20
|
+
export type CreateSolanaAdapterParams = {
|
|
21
|
+
/** Base58 address of the connected wallet. funkit validates it, not this factory. */
|
|
22
|
+
address: string;
|
|
23
|
+
/** Use an endpoint you trust for write traffic; public RPCs rate-limit. */
|
|
24
|
+
connection: SolanaConnection;
|
|
25
|
+
/** Base58 fee payer when it isn't `address`, e.g. a sponsor that co-signs. */
|
|
26
|
+
payerKey?: string;
|
|
27
|
+
} & SolanaSigner;
|
|
28
|
+
/**
|
|
29
|
+
* Never throws, so hosts can call it during render. With no signing method
|
|
30
|
+
* `signingMethod` is undefined, and funkit disables Solana flows instead of
|
|
31
|
+
* calling `createRelayWallet()`, which would throw.
|
|
32
|
+
*/
|
|
33
|
+
export declare function createSolanaAdapter(params: CreateSolanaAdapterParams): FunkitSolanaAdapter;
|
|
34
|
+
//# sourceMappingURL=solanaAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solanaAdapter.d.ts","sourceRoot":"","sources":["../../src/solanaAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,mBAAmB,EAGzB,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EACL,KAAK,UAAU,EAIf,KAAK,oBAAoB,EAC1B,MAAM,iBAAiB,CAAA;AAMxB,oFAAoF;AACpF,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAA;AAEzC,kEAAkE;AAClE,MAAM,MAAM,qBAAqB,GAAG,CAClC,WAAW,EAAE,oBAAoB,KAC9B,OAAO,CAAC,oBAAoB,CAAC,CAAA;AAElC,wEAAwE;AACxE,MAAM,MAAM,4BAA4B,GAAG,CACzC,WAAW,EAAE,oBAAoB,KAC9B,OAAO,CAAC,UAAU,CAAC,CAAA;AAExB;;;GAGG;AACH,MAAM,MAAM,YAAY,GACpB;IACE,eAAe,EAAE,qBAAqB,CAAA;IACtC,sBAAsB,CAAC,EAAE,4BAA4B,CAAA;CACtD,GACD;IACE,eAAe,CAAC,EAAE,qBAAqB,CAAA;IACvC,sBAAsB,EAAE,4BAA4B,CAAA;CACrD,CAAA;AAEL,MAAM,MAAM,yBAAyB,GAAG;IACtC,qFAAqF;IACrF,OAAO,EAAE,MAAM,CAAA;IACf,2EAA2E;IAC3E,UAAU,EAAE,gBAAgB,CAAA;IAC5B,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,GAAG,YAAY,CAAA;AA6EhB;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,yBAAyB,GAChC,mBAAmB,CAcrB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,66 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@funkit/solana-web3",
|
|
3
|
-
"version": "0.0.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Runs funkit's Solana flows on a host's @solana/web3.js connection and wallet.",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist",
|
|
7
|
+
"CHANGELOG.md"
|
|
8
|
+
],
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"module": "./dist/index.mjs",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.mjs",
|
|
15
|
+
"require": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"sideEffects": false,
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=18"
|
|
20
|
+
},
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"funkit",
|
|
26
|
+
"relay",
|
|
27
|
+
"solana",
|
|
28
|
+
"web3.js"
|
|
29
|
+
],
|
|
30
|
+
"author": "https://fun.xyz/",
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@relayprotocol/relay-svm-wallet-adapter": "^22.0.2",
|
|
34
|
+
"bs58": "^6.0.0"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"@funkit/fun-relay": "^3.3.1",
|
|
38
|
+
"@relayprotocol/relay-sdk": "^8.0.2",
|
|
39
|
+
"@solana/web3.js": "~1.98.2"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@funkit/fun-relay": "3.3.1",
|
|
43
|
+
"@relayprotocol/relay-sdk": "^8.0.2",
|
|
44
|
+
"@solana/web3.js": "1.98.4",
|
|
45
|
+
"viem": "2.29.4",
|
|
46
|
+
"vitest": "^4.1.6"
|
|
47
|
+
},
|
|
48
|
+
"repository": {
|
|
49
|
+
"type": "git",
|
|
50
|
+
"url": "git+https://github.com/fun-xyz/funkit.git",
|
|
51
|
+
"directory": "packages/solana-web3"
|
|
52
|
+
},
|
|
53
|
+
"homepage": "https://github.com/fun-xyz/funkit/tree/main/packages/solana-web3",
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "node build.mjs && pnpm typecheck",
|
|
56
|
+
"build:watch": "node build.mjs --watch",
|
|
57
|
+
"dev": "pnpm build:watch & pnpm typegen:watch",
|
|
58
|
+
"prebuild": "rm -rf dist && pnpm typegen",
|
|
59
|
+
"typecheck": "pnpm tsrs --noEmit",
|
|
60
|
+
"typegen": "tsrs --project tsconfig.build.json --emitDeclarationOnly",
|
|
61
|
+
"typegen:watch": "tsrs --project tsconfig.build.json --emitDeclarationOnly --watch",
|
|
62
|
+
"lint": "oxlint",
|
|
63
|
+
"lint:fix": "oxlint --fix",
|
|
64
|
+
"test": "vitest"
|
|
65
|
+
}
|
|
6
66
|
}
|
package/README.md
DELETED