@solard/sdk 0.2.20 → 0.2.22
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/package.json +8 -3
- package/src/browser/index.ts +0 -13
- package/src/client.ts +9 -2
- package/src/default.ts +28 -0
- package/src/export-surface.test.ts +52 -1
- package/src/index.ts +28 -12
- package/src/protocol.ts +11 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solard/sdk",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "Public Solard SDK for wallets,
|
|
3
|
+
"version": "0.2.22",
|
|
4
|
+
"description": "Public Solard SDK for wallets, trading, history, live market subscriptions and token metadata.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
7
7
|
"module": "./src/index.ts",
|
|
@@ -12,6 +12,11 @@
|
|
|
12
12
|
"types": "./src/browser/index.ts",
|
|
13
13
|
"import": "./src/browser/index.ts",
|
|
14
14
|
"default": "./src/browser/index.ts"
|
|
15
|
+
},
|
|
16
|
+
"./protocol": {
|
|
17
|
+
"types": "./src/protocol.ts",
|
|
18
|
+
"import": "./src/protocol.ts",
|
|
19
|
+
"default": "./src/protocol.ts"
|
|
15
20
|
}
|
|
16
21
|
},
|
|
17
22
|
"files": [
|
|
@@ -22,7 +27,7 @@
|
|
|
22
27
|
"license": "MIT",
|
|
23
28
|
"dependencies": {
|
|
24
29
|
"@solana/web3.js": "^1.98.4",
|
|
25
|
-
"@solard/core": "0.2.
|
|
30
|
+
"@solard/core": "0.2.22"
|
|
26
31
|
},
|
|
27
32
|
"scripts": {
|
|
28
33
|
"typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p tsconfig.browser.json",
|
package/src/browser/index.ts
CHANGED
|
@@ -67,16 +67,3 @@ export type {
|
|
|
67
67
|
BrowserTradeSide,
|
|
68
68
|
BrowserWalletSigner,
|
|
69
69
|
} from "./types.ts";
|
|
70
|
-
export { createPriceFeed, connectPriceFeed } from "@solard/core";
|
|
71
|
-
export type {
|
|
72
|
-
LaunchFeedListener,
|
|
73
|
-
PriceFeedClient,
|
|
74
|
-
PriceFeedCommand,
|
|
75
|
-
PriceFeedLaunch,
|
|
76
|
-
PriceFeedListener,
|
|
77
|
-
PriceFeedMessage,
|
|
78
|
-
PriceFeedPrice,
|
|
79
|
-
PriceFeedStatus,
|
|
80
|
-
PriceFeedVenue,
|
|
81
|
-
SharedPriceFeed,
|
|
82
|
-
} from "@solard/core";
|
package/src/client.ts
CHANGED
|
@@ -20,6 +20,8 @@ import {
|
|
|
20
20
|
type TokenHolderSnapshotOptions,
|
|
21
21
|
type TokenRef,
|
|
22
22
|
type WalletRef,
|
|
23
|
+
type WalletPrivateKeyExport,
|
|
24
|
+
type WalletPrivateKeyFormat,
|
|
23
25
|
} from "@solard/core";
|
|
24
26
|
|
|
25
27
|
export type SolardOptions = {
|
|
@@ -78,6 +80,11 @@ export type Solard = {
|
|
|
78
80
|
createVanityWallet: ReturnType<typeof createCoreSolard>["createVanityWallet"];
|
|
79
81
|
importWallet: ReturnType<typeof createCoreSolard>["importWallet"];
|
|
80
82
|
listWallets: ReturnType<typeof createCoreSolard>["listWallets"];
|
|
83
|
+
walletAddress(wallet: WalletRef): string;
|
|
84
|
+
exportWalletPrivateKey(
|
|
85
|
+
wallet: WalletRef,
|
|
86
|
+
format?: WalletPrivateKeyFormat,
|
|
87
|
+
): WalletPrivateKeyExport;
|
|
81
88
|
addToken: ReturnType<typeof createCoreSolard>["addToken"];
|
|
82
89
|
resolveToken: ReturnType<typeof createCoreSolard>["resolveToken"];
|
|
83
90
|
tokenAccounts: ReturnType<typeof createCoreSolard>["tokenAccounts"];
|
|
@@ -127,6 +134,8 @@ export function createSolard(options: SolardOptions = {}): Solard {
|
|
|
127
134
|
createVanityWallet: core.createVanityWallet.bind(core),
|
|
128
135
|
importWallet: core.importWallet.bind(core),
|
|
129
136
|
listWallets: core.listWallets.bind(core),
|
|
137
|
+
walletAddress: core.walletAddress.bind(core),
|
|
138
|
+
exportWalletPrivateKey: core.exportWalletPrivateKey.bind(core),
|
|
130
139
|
addToken: core.addToken.bind(core),
|
|
131
140
|
resolveToken: core.resolveToken.bind(core),
|
|
132
141
|
tokenAccounts: core.tokenAccounts.bind(core),
|
|
@@ -137,5 +146,3 @@ export function createSolard(options: SolardOptions = {}): Solard {
|
|
|
137
146
|
sell: core.sell.bind(core),
|
|
138
147
|
});
|
|
139
148
|
}
|
|
140
|
-
|
|
141
|
-
export const createTraderSolard = createSolard;
|
package/src/default.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createSolard, type Solard } from "./client.ts";
|
|
2
|
+
|
|
3
|
+
let instance: Solard | undefined;
|
|
4
|
+
|
|
5
|
+
function client(): Solard {
|
|
6
|
+
instance ??= createSolard();
|
|
7
|
+
return instance;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const slrd = new Proxy({} as Solard, {
|
|
11
|
+
get(_target, key) {
|
|
12
|
+
if (key === "close") {
|
|
13
|
+
return () => {
|
|
14
|
+
const current = instance;
|
|
15
|
+
instance = undefined;
|
|
16
|
+
current?.close();
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
const current = client();
|
|
20
|
+
const value = Reflect.get(current as object, key, current);
|
|
21
|
+
return typeof value === "function" ? value.bind(current) : value;
|
|
22
|
+
},
|
|
23
|
+
set() {
|
|
24
|
+
return false;
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export default slrd;
|
|
@@ -4,6 +4,8 @@ import { join } from "node:path";
|
|
|
4
4
|
|
|
5
5
|
const source = readFileSync(join(import.meta.dir, "index.ts"), "utf8");
|
|
6
6
|
const client = readFileSync(join(import.meta.dir, "client.ts"), "utf8");
|
|
7
|
+
const protocol = readFileSync(join(import.meta.dir, "protocol.ts"), "utf8");
|
|
8
|
+
const defaultClient = readFileSync(join(import.meta.dir, "default.ts"), "utf8");
|
|
7
9
|
|
|
8
10
|
function exportedNames(value: string) {
|
|
9
11
|
const values: string[] = [];
|
|
@@ -28,8 +30,12 @@ describe("sdk membrane", () => {
|
|
|
28
30
|
expect(exportedNames(source)).toEqual({
|
|
29
31
|
values: [
|
|
30
32
|
"createSolard",
|
|
31
|
-
"
|
|
33
|
+
"fetchTokenMetadata",
|
|
32
34
|
"formatRaw",
|
|
35
|
+
"publicTokenMetadataUrl",
|
|
36
|
+
"subscribeLaunches",
|
|
37
|
+
"subscribeMigrations",
|
|
38
|
+
"subscribeTrades",
|
|
33
39
|
"sol",
|
|
34
40
|
"tokenAmount",
|
|
35
41
|
].sort(),
|
|
@@ -43,7 +49,15 @@ describe("sdk membrane", () => {
|
|
|
43
49
|
"CumulativeDistributionRecipient",
|
|
44
50
|
"CumulativeDistributionState",
|
|
45
51
|
"CumulativeEntitlement",
|
|
52
|
+
"FetchTokenMetadataOptions",
|
|
46
53
|
"HumanAmount",
|
|
54
|
+
"LaunchEvent",
|
|
55
|
+
"LaunchSubscription",
|
|
56
|
+
"LaunchVenue",
|
|
57
|
+
"MigrationDestination",
|
|
58
|
+
"MigrationEvent",
|
|
59
|
+
"MigrationSubscription",
|
|
60
|
+
"MigrationVenue",
|
|
47
61
|
"MarketHistory",
|
|
48
62
|
"MarketHistoryOptions",
|
|
49
63
|
"MarketPrice",
|
|
@@ -60,6 +74,10 @@ describe("sdk membrane", () => {
|
|
|
60
74
|
"SendReceipt",
|
|
61
75
|
"SenderId",
|
|
62
76
|
"SimulationResult",
|
|
77
|
+
"TradeEvent",
|
|
78
|
+
"TradeSide",
|
|
79
|
+
"TradeSubscription",
|
|
80
|
+
"TradeVenue",
|
|
63
81
|
"Solard",
|
|
64
82
|
"SolardCanonicalEvent",
|
|
65
83
|
"SolardClaimAttribution",
|
|
@@ -72,9 +90,15 @@ describe("sdk membrane", () => {
|
|
|
72
90
|
"TokenHolderSnapshot",
|
|
73
91
|
"TokenHolderSnapshotOptions",
|
|
74
92
|
"TokenEventHistoryProgress",
|
|
93
|
+
"TokenMetadata",
|
|
94
|
+
"TokenMetadataHint",
|
|
95
|
+
"TokenMetadataKind",
|
|
96
|
+
"TokenMetadataMode",
|
|
75
97
|
"TokenRef",
|
|
76
98
|
"TokenRow",
|
|
77
99
|
"WalletInfo",
|
|
100
|
+
"WalletPrivateKeyExport",
|
|
101
|
+
"WalletPrivateKeyFormat",
|
|
78
102
|
"WalletRef",
|
|
79
103
|
].sort(),
|
|
80
104
|
});
|
|
@@ -86,8 +110,35 @@ describe("sdk membrane", () => {
|
|
|
86
110
|
expect(client).not.toMatch(/\.\.\/\.\.\/core\/src|@solard\/core\//);
|
|
87
111
|
});
|
|
88
112
|
|
|
113
|
+
test("keeps raw protocol decoders off the root surface", () => {
|
|
114
|
+
expect(source).not.toMatch(
|
|
115
|
+
/decode(?:ProgramDataLogs|PumpProgramData|PumpSwapProgramData|RaydiumLaunchLabProgramData)/,
|
|
116
|
+
);
|
|
117
|
+
expect(exportedNames(protocol)).toEqual({
|
|
118
|
+
values: [
|
|
119
|
+
"decodeProgramDataLogs",
|
|
120
|
+
"decodePumpProgramData",
|
|
121
|
+
"decodePumpSwapProgramData",
|
|
122
|
+
"decodeRaydiumLaunchLabProgramData",
|
|
123
|
+
].sort(),
|
|
124
|
+
types: [
|
|
125
|
+
"PumpDecodedEvent",
|
|
126
|
+
"PumpSwapDecodedEvent",
|
|
127
|
+
"RaydiumLaunchLabDecodedEvent",
|
|
128
|
+
].sort(),
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
test("exports a lazy zero-config default client", () => {
|
|
133
|
+
expect(source).toContain('export { default } from "./default.ts"');
|
|
134
|
+
expect(defaultClient).toContain("instance ??= createSolard()");
|
|
135
|
+
expect(defaultClient).toContain('if (key === "close")');
|
|
136
|
+
expect(defaultClient).not.toContain("export default createSolard()");
|
|
137
|
+
});
|
|
138
|
+
|
|
89
139
|
test("does not create persistence at module import", () => {
|
|
90
140
|
expect(source).not.toMatch(/createCoreSolard|createTraderSolard\(\)/);
|
|
141
|
+
expect(defaultClient).not.toMatch(/^const\s+\w+\s*=\s*createSolard\(\)/m);
|
|
91
142
|
expect(client.indexOf("createCoreSolard(options)")).toBeGreaterThan(
|
|
92
143
|
client.indexOf("export function createSolard"),
|
|
93
144
|
);
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { default } from "./default.ts";
|
|
2
|
+
export { createSolard } from "./client.ts";
|
|
2
3
|
export type {
|
|
3
4
|
Solard,
|
|
4
5
|
SolardEventsApi,
|
|
@@ -46,18 +47,33 @@ export type {
|
|
|
46
47
|
TokenRef,
|
|
47
48
|
TokenRow,
|
|
48
49
|
WalletInfo,
|
|
50
|
+
WalletPrivateKeyExport,
|
|
51
|
+
WalletPrivateKeyFormat,
|
|
49
52
|
WalletRef,
|
|
50
53
|
} from "@solard/core";
|
|
51
|
-
|
|
54
|
+
|
|
55
|
+
export {
|
|
56
|
+
fetchTokenMetadata,
|
|
57
|
+
publicTokenMetadataUrl,
|
|
58
|
+
subscribeLaunches,
|
|
59
|
+
subscribeMigrations,
|
|
60
|
+
subscribeTrades,
|
|
61
|
+
} from "@solard/core";
|
|
52
62
|
export type {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
LaunchEvent,
|
|
64
|
+
LaunchSubscription,
|
|
65
|
+
LaunchVenue,
|
|
66
|
+
MigrationDestination,
|
|
67
|
+
MigrationEvent,
|
|
68
|
+
MigrationSubscription,
|
|
69
|
+
MigrationVenue,
|
|
70
|
+
TradeEvent,
|
|
71
|
+
TradeSide,
|
|
72
|
+
TradeSubscription,
|
|
73
|
+
TradeVenue,
|
|
74
|
+
FetchTokenMetadataOptions,
|
|
75
|
+
TokenMetadata,
|
|
76
|
+
TokenMetadataHint,
|
|
77
|
+
TokenMetadataKind,
|
|
78
|
+
TokenMetadataMode,
|
|
63
79
|
} from "@solard/core";
|
package/src/protocol.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export {
|
|
2
|
+
decodeProgramDataLogs,
|
|
3
|
+
decodePumpProgramData,
|
|
4
|
+
decodePumpSwapProgramData,
|
|
5
|
+
decodeRaydiumLaunchLabProgramData,
|
|
6
|
+
} from "@solard/core";
|
|
7
|
+
export type {
|
|
8
|
+
PumpDecodedEvent,
|
|
9
|
+
PumpSwapDecodedEvent,
|
|
10
|
+
RaydiumLaunchLabDecodedEvent,
|
|
11
|
+
} from "@solard/core";
|