@solana/client 0.1.0 → 0.1.2
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.browser.cjs +105 -23
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.mjs +103 -24
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.native.mjs +103 -24
- package/dist/index.native.mjs.map +1 -1
- package/dist/index.node.cjs +105 -23
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs +103 -24
- package/dist/index.node.mjs.map +1 -1
- package/dist/server/index.node.cjs +168 -0
- package/dist/server/index.node.cjs.map +1 -0
- package/dist/server/index.node.mjs +155 -0
- package/dist/server/index.node.mjs.map +1 -0
- package/dist/types/client/actions.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/serialization/state.d.ts +13 -0
- package/dist/types/serialization/state.d.ts.map +1 -0
- package/dist/types/server/index.d.ts +3 -0
- package/dist/types/server/index.d.ts.map +1 -0
- package/dist/types/server/signers.d.ts +25 -0
- package/dist/types/server/signers.d.ts.map +1 -0
- package/dist/types/types.d.ts +10 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/cluster.d.ts +14 -0
- package/dist/types/utils/cluster.d.ts.map +1 -0
- package/dist/types/wallet/standard.d.ts.map +1 -1
- package/package.json +24 -17
package/dist/index.browser.cjs
CHANGED
|
@@ -248,11 +248,6 @@ function createActions({ connectors, logger: inputLogger, runtime, store }) {
|
|
|
248
248
|
},
|
|
249
249
|
lastUpdatedAt: now()
|
|
250
250
|
}));
|
|
251
|
-
logger({
|
|
252
|
-
data: { endpoint, latencyMs, websocketEndpoint },
|
|
253
|
-
level: "info",
|
|
254
|
-
message: "cluster ready"
|
|
255
|
-
});
|
|
256
251
|
} catch (error) {
|
|
257
252
|
store.setState((state) => ({
|
|
258
253
|
...state,
|
|
@@ -538,24 +533,30 @@ function createActions({ connectors, logger: inputLogger, runtime, store }) {
|
|
|
538
533
|
}
|
|
539
534
|
__name(sendTransaction, "sendTransaction");
|
|
540
535
|
async function requestAirdrop(address4, lamports2) {
|
|
541
|
-
|
|
542
|
-
|
|
536
|
+
try {
|
|
537
|
+
const factory = kit.airdropFactory({
|
|
538
|
+
rpc: runtime.rpc,
|
|
539
|
+
rpcSubscriptions: runtime.rpcSubscriptions
|
|
540
|
+
});
|
|
541
|
+
const signature4 = await factory({
|
|
542
|
+
commitment: getCommitment("confirmed"),
|
|
543
|
+
lamports: lamports2,
|
|
544
|
+
recipientAddress: address4
|
|
545
|
+
});
|
|
546
|
+
logger({
|
|
547
|
+
data: { address: address4.toString(), lamports: lamports2.toString(), signature: signature4 },
|
|
548
|
+
level: "info",
|
|
549
|
+
message: "airdrop requested"
|
|
550
|
+
});
|
|
551
|
+
return signature4;
|
|
552
|
+
} catch (error) {
|
|
553
|
+
logger({
|
|
554
|
+
data: { address: address4.toString(), lamports: lamports2.toString(), ...formatError(error) },
|
|
555
|
+
level: "error",
|
|
556
|
+
message: "airdrop request failed"
|
|
557
|
+
});
|
|
558
|
+
throw error;
|
|
543
559
|
}
|
|
544
|
-
const factory = kit.airdropFactory({
|
|
545
|
-
rpc: runtime.rpc,
|
|
546
|
-
rpcSubscriptions: runtime.rpcSubscriptions
|
|
547
|
-
});
|
|
548
|
-
const signature4 = await factory({
|
|
549
|
-
commitment: getCommitment("confirmed"),
|
|
550
|
-
lamports: lamports2,
|
|
551
|
-
recipientAddress: address4
|
|
552
|
-
});
|
|
553
|
-
logger({
|
|
554
|
-
data: { address: address4.toString(), lamports: lamports2.toString(), signature: signature4 },
|
|
555
|
-
level: "info",
|
|
556
|
-
message: "airdrop requested"
|
|
557
|
-
});
|
|
558
|
-
return signature4;
|
|
559
560
|
}
|
|
560
561
|
__name(requestAirdrop, "requestAirdrop");
|
|
561
562
|
return {
|
|
@@ -2245,6 +2246,33 @@ function lamportsFromJson(value) {
|
|
|
2245
2246
|
return lamports(value, "lamports");
|
|
2246
2247
|
}
|
|
2247
2248
|
__name(lamportsFromJson, "lamportsFromJson");
|
|
2249
|
+
|
|
2250
|
+
// src/serialization/state.ts
|
|
2251
|
+
var SERIALIZABLE_STATE_VERSION = 1;
|
|
2252
|
+
function getInitialSerializableState(config) {
|
|
2253
|
+
return {
|
|
2254
|
+
autoconnect: false,
|
|
2255
|
+
commitment: config.commitment,
|
|
2256
|
+
endpoint: config.endpoint,
|
|
2257
|
+
lastConnectorId: null,
|
|
2258
|
+
lastPublicKey: null,
|
|
2259
|
+
version: SERIALIZABLE_STATE_VERSION,
|
|
2260
|
+
websocketEndpoint: config.websocketEndpoint
|
|
2261
|
+
};
|
|
2262
|
+
}
|
|
2263
|
+
__name(getInitialSerializableState, "getInitialSerializableState");
|
|
2264
|
+
function applySerializableState(config, state) {
|
|
2265
|
+
if (!state) {
|
|
2266
|
+
return config;
|
|
2267
|
+
}
|
|
2268
|
+
return {
|
|
2269
|
+
...config,
|
|
2270
|
+
commitment: state.commitment ?? config.commitment,
|
|
2271
|
+
endpoint: state.endpoint ?? config.endpoint,
|
|
2272
|
+
websocketEndpoint: state.websocketEndpoint ?? config.websocketEndpoint
|
|
2273
|
+
};
|
|
2274
|
+
}
|
|
2275
|
+
__name(applySerializableState, "applySerializableState");
|
|
2248
2276
|
var COMMITMENT_PRIORITY = {
|
|
2249
2277
|
processed: 0,
|
|
2250
2278
|
confirmed: 1,
|
|
@@ -2557,6 +2585,56 @@ function toAddressString(addressLike) {
|
|
|
2557
2585
|
}
|
|
2558
2586
|
__name(toAddressString, "toAddressString");
|
|
2559
2587
|
|
|
2588
|
+
// src/utils/cluster.ts
|
|
2589
|
+
var MONIKER_ENDPOINTS = {
|
|
2590
|
+
devnet: {
|
|
2591
|
+
endpoint: "https://api.devnet.solana.com",
|
|
2592
|
+
websocketEndpoint: "wss://api.devnet.solana.com"
|
|
2593
|
+
},
|
|
2594
|
+
localhost: {
|
|
2595
|
+
endpoint: "http://127.0.0.1:8899",
|
|
2596
|
+
websocketEndpoint: "ws://127.0.0.1:8900"
|
|
2597
|
+
},
|
|
2598
|
+
localnet: {
|
|
2599
|
+
endpoint: "http://127.0.0.1:8899",
|
|
2600
|
+
websocketEndpoint: "ws://127.0.0.1:8900"
|
|
2601
|
+
},
|
|
2602
|
+
"mainnet-beta": {
|
|
2603
|
+
endpoint: "https://api.mainnet-beta.solana.com",
|
|
2604
|
+
websocketEndpoint: "wss://api.mainnet-beta.solana.com"
|
|
2605
|
+
},
|
|
2606
|
+
mainnet: {
|
|
2607
|
+
endpoint: "https://api.mainnet-beta.solana.com",
|
|
2608
|
+
websocketEndpoint: "wss://api.mainnet-beta.solana.com"
|
|
2609
|
+
},
|
|
2610
|
+
testnet: {
|
|
2611
|
+
endpoint: "https://api.testnet.solana.com",
|
|
2612
|
+
websocketEndpoint: "wss://api.testnet.solana.com"
|
|
2613
|
+
}
|
|
2614
|
+
};
|
|
2615
|
+
function inferWebsocketEndpoint(endpoint) {
|
|
2616
|
+
if (endpoint.startsWith("https://")) {
|
|
2617
|
+
return endpoint.replace("https://", "wss://");
|
|
2618
|
+
}
|
|
2619
|
+
if (endpoint.startsWith("http://")) {
|
|
2620
|
+
return endpoint.replace("http://", "ws://");
|
|
2621
|
+
}
|
|
2622
|
+
return endpoint;
|
|
2623
|
+
}
|
|
2624
|
+
__name(inferWebsocketEndpoint, "inferWebsocketEndpoint");
|
|
2625
|
+
function resolveCluster(config) {
|
|
2626
|
+
const moniker = config.moniker ?? (config.endpoint ? "custom" : "devnet");
|
|
2627
|
+
const mapped = moniker === "custom" ? void 0 : MONIKER_ENDPOINTS[moniker];
|
|
2628
|
+
const endpoint = config.endpoint ?? mapped?.endpoint;
|
|
2629
|
+
const websocketEndpoint = config.websocketEndpoint ?? mapped?.websocketEndpoint ?? inferWebsocketEndpoint(endpoint);
|
|
2630
|
+
return {
|
|
2631
|
+
endpoint,
|
|
2632
|
+
moniker,
|
|
2633
|
+
websocketEndpoint
|
|
2634
|
+
};
|
|
2635
|
+
}
|
|
2636
|
+
__name(resolveCluster, "resolveCluster");
|
|
2637
|
+
|
|
2560
2638
|
// src/utils/stableStringify.ts
|
|
2561
2639
|
function stableStringify(value) {
|
|
2562
2640
|
const result = JSON.stringify(value, (_key, candidate) => {
|
|
@@ -2618,7 +2696,8 @@ function createWalletStandardConnector(wallet, options = {}) {
|
|
|
2618
2696
|
canAutoConnect: options.canAutoConnect ?? Boolean(wallet.features[features.StandardConnect]),
|
|
2619
2697
|
icon: options.icon ?? wallet.icon,
|
|
2620
2698
|
id: options.id ?? deriveConnectorId(wallet),
|
|
2621
|
-
name: options.name ?? wallet.name
|
|
2699
|
+
name: options.name ?? wallet.name,
|
|
2700
|
+
ready: typeof window !== "undefined"
|
|
2622
2701
|
};
|
|
2623
2702
|
async function connect(connectionOptions = {}) {
|
|
2624
2703
|
const connectFeature = wallet.features[features.StandardConnect];
|
|
@@ -2745,6 +2824,7 @@ __name(watchWalletStandardConnectors, "watchWalletStandardConnectors");
|
|
|
2745
2824
|
exports.LAMPORTS_PER_SOL = LAMPORTS_PER_SOL;
|
|
2746
2825
|
exports.SIGNATURE_STATUS_TIMEOUT_MS = SIGNATURE_STATUS_TIMEOUT_MS;
|
|
2747
2826
|
exports.applyRatio = applyRatio;
|
|
2827
|
+
exports.applySerializableState = applySerializableState;
|
|
2748
2828
|
exports.assertDecimals = assertDecimals;
|
|
2749
2829
|
exports.assertNonNegative = assertNonNegative;
|
|
2750
2830
|
exports.bigintFromJson = bigintFromJson;
|
|
@@ -2773,6 +2853,7 @@ exports.createTransactionRecipe = createTransactionRecipe;
|
|
|
2773
2853
|
exports.createWalletRegistry = createWalletRegistry;
|
|
2774
2854
|
exports.createWalletStandardConnector = createWalletStandardConnector;
|
|
2775
2855
|
exports.deriveConfirmationStatus = deriveConfirmationStatus;
|
|
2856
|
+
exports.getInitialSerializableState = getInitialSerializableState;
|
|
2776
2857
|
exports.getWalletStandardConnectors = getWalletStandardConnectors;
|
|
2777
2858
|
exports.insertReferenceKey = insertReferenceKey;
|
|
2778
2859
|
exports.insertReferenceKeys = insertReferenceKeys;
|
|
@@ -2785,6 +2866,7 @@ exports.lamportsToSolString = lamportsToSolString;
|
|
|
2785
2866
|
exports.normalizeSignature = normalizeSignature;
|
|
2786
2867
|
exports.pow10 = pow10;
|
|
2787
2868
|
exports.prepareTransaction = prepareTransaction;
|
|
2869
|
+
exports.resolveCluster = resolveCluster;
|
|
2788
2870
|
exports.stableStringify = stableStringify;
|
|
2789
2871
|
exports.toAddress = toAddress2;
|
|
2790
2872
|
exports.toAddressString = toAddressString;
|