solana-agent-kit-plugin-madeonsol 0.2.0 → 0.2.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.
- package/README.md +56 -54
- package/dist/actions/deployerAlerts.d.ts +41 -41
- package/dist/actions/deployerAlerts.js +24 -24
- package/dist/actions/kolCoordination.d.ts +42 -42
- package/dist/actions/kolCoordination.js +24 -24
- package/dist/actions/kolFeed.d.ts +42 -42
- package/dist/actions/kolFeed.js +24 -24
- package/dist/actions/kolLeaderboard.d.ts +38 -38
- package/dist/actions/kolLeaderboard.js +23 -23
- package/dist/index.d.ts +179 -174
- package/dist/index.js +31 -26
- package/dist/tools/index.d.ts +39 -26
- package/dist/tools/index.js +92 -57
- package/package.json +13 -3
- package/LICENSE +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,174 +1,179 @@
|
|
|
1
|
-
import { kolFeedAction } from "./actions/kolFeed.js";
|
|
2
|
-
import { kolCoordinationAction } from "./actions/kolCoordination.js";
|
|
3
|
-
import { kolLeaderboardAction } from "./actions/kolLeaderboard.js";
|
|
4
|
-
import { deployerAlertsAction } from "./actions/deployerAlerts.js";
|
|
5
|
-
import { kolFeed, kolCoordination, kolLeaderboard, deployerAlerts } from "./tools/index.js";
|
|
6
|
-
declare const MadeOnSolPlugin: {
|
|
7
|
-
name: string;
|
|
8
|
-
methods: {
|
|
9
|
-
kolFeed: typeof kolFeed;
|
|
10
|
-
kolCoordination: typeof kolCoordination;
|
|
11
|
-
kolLeaderboard: typeof kolLeaderboard;
|
|
12
|
-
deployerAlerts: typeof deployerAlerts;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
limit?: number;
|
|
43
|
-
action?:
|
|
44
|
-
kol?: string;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
result
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
period: "
|
|
75
|
-
min_kols:
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
result
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
limit
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
limit?: number;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
result
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
limit?: number;
|
|
158
|
-
offset?: number;
|
|
159
|
-
since?: string;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
result
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
1
|
+
import { kolFeedAction } from "./actions/kolFeed.js";
|
|
2
|
+
import { kolCoordinationAction } from "./actions/kolCoordination.js";
|
|
3
|
+
import { kolLeaderboardAction } from "./actions/kolLeaderboard.js";
|
|
4
|
+
import { deployerAlertsAction } from "./actions/deployerAlerts.js";
|
|
5
|
+
import { kolFeed, kolCoordination, kolLeaderboard, deployerAlerts, createWebhook, listWebhooks, deleteWebhook, testWebhook, getStreamToken } from "./tools/index.js";
|
|
6
|
+
declare const MadeOnSolPlugin: {
|
|
7
|
+
name: string;
|
|
8
|
+
methods: {
|
|
9
|
+
kolFeed: typeof kolFeed;
|
|
10
|
+
kolCoordination: typeof kolCoordination;
|
|
11
|
+
kolLeaderboard: typeof kolLeaderboard;
|
|
12
|
+
deployerAlerts: typeof deployerAlerts;
|
|
13
|
+
createWebhook: typeof createWebhook;
|
|
14
|
+
listWebhooks: typeof listWebhooks;
|
|
15
|
+
deleteWebhook: typeof deleteWebhook;
|
|
16
|
+
testWebhook: typeof testWebhook;
|
|
17
|
+
getStreamToken: typeof getStreamToken;
|
|
18
|
+
};
|
|
19
|
+
actions: ({
|
|
20
|
+
name: string;
|
|
21
|
+
similes: string[];
|
|
22
|
+
description: string;
|
|
23
|
+
examples: {
|
|
24
|
+
input: {
|
|
25
|
+
limit: number;
|
|
26
|
+
action: string;
|
|
27
|
+
};
|
|
28
|
+
output: {
|
|
29
|
+
status: string;
|
|
30
|
+
};
|
|
31
|
+
explanation: string;
|
|
32
|
+
}[][];
|
|
33
|
+
schema: import("zod").ZodObject<{
|
|
34
|
+
limit: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
35
|
+
action: import("zod").ZodOptional<import("zod").ZodEnum<["buy", "sell"]>>;
|
|
36
|
+
kol: import("zod").ZodOptional<import("zod").ZodString>;
|
|
37
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
38
|
+
limit: number;
|
|
39
|
+
action?: "buy" | "sell" | undefined;
|
|
40
|
+
kol?: string | undefined;
|
|
41
|
+
}, {
|
|
42
|
+
limit?: number | undefined;
|
|
43
|
+
action?: "buy" | "sell" | undefined;
|
|
44
|
+
kol?: string | undefined;
|
|
45
|
+
}>;
|
|
46
|
+
handler: (agent: unknown, input: {
|
|
47
|
+
limit?: number;
|
|
48
|
+
action?: string;
|
|
49
|
+
kol?: string;
|
|
50
|
+
}) => Promise<{
|
|
51
|
+
status: string;
|
|
52
|
+
result: any;
|
|
53
|
+
message?: undefined;
|
|
54
|
+
} | {
|
|
55
|
+
status: string;
|
|
56
|
+
message: string;
|
|
57
|
+
result?: undefined;
|
|
58
|
+
}>;
|
|
59
|
+
} | {
|
|
60
|
+
name: string;
|
|
61
|
+
similes: string[];
|
|
62
|
+
description: string;
|
|
63
|
+
examples: {
|
|
64
|
+
input: {
|
|
65
|
+
period: string;
|
|
66
|
+
min_kols: number;
|
|
67
|
+
};
|
|
68
|
+
output: {
|
|
69
|
+
status: string;
|
|
70
|
+
};
|
|
71
|
+
explanation: string;
|
|
72
|
+
}[][];
|
|
73
|
+
schema: import("zod").ZodObject<{
|
|
74
|
+
period: import("zod").ZodDefault<import("zod").ZodEnum<["1h", "6h", "24h", "7d"]>>;
|
|
75
|
+
min_kols: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
76
|
+
limit: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
77
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
78
|
+
limit: number;
|
|
79
|
+
period: "24h" | "1h" | "6h" | "7d";
|
|
80
|
+
min_kols: number;
|
|
81
|
+
}, {
|
|
82
|
+
limit?: number | undefined;
|
|
83
|
+
period?: "24h" | "1h" | "6h" | "7d" | undefined;
|
|
84
|
+
min_kols?: number | undefined;
|
|
85
|
+
}>;
|
|
86
|
+
handler: (agent: unknown, input: {
|
|
87
|
+
period?: string;
|
|
88
|
+
min_kols?: number;
|
|
89
|
+
limit?: number;
|
|
90
|
+
}) => Promise<{
|
|
91
|
+
status: string;
|
|
92
|
+
result: any;
|
|
93
|
+
message?: undefined;
|
|
94
|
+
} | {
|
|
95
|
+
status: string;
|
|
96
|
+
message: string;
|
|
97
|
+
result?: undefined;
|
|
98
|
+
}>;
|
|
99
|
+
} | {
|
|
100
|
+
name: string;
|
|
101
|
+
similes: string[];
|
|
102
|
+
description: string;
|
|
103
|
+
examples: {
|
|
104
|
+
input: {
|
|
105
|
+
period: string;
|
|
106
|
+
limit: number;
|
|
107
|
+
};
|
|
108
|
+
output: {
|
|
109
|
+
status: string;
|
|
110
|
+
};
|
|
111
|
+
explanation: string;
|
|
112
|
+
}[][];
|
|
113
|
+
schema: import("zod").ZodObject<{
|
|
114
|
+
period: import("zod").ZodDefault<import("zod").ZodEnum<["today", "7d", "30d"]>>;
|
|
115
|
+
limit: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
116
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
117
|
+
limit: number;
|
|
118
|
+
period: "7d" | "today" | "30d";
|
|
119
|
+
}, {
|
|
120
|
+
limit?: number | undefined;
|
|
121
|
+
period?: "7d" | "today" | "30d" | undefined;
|
|
122
|
+
}>;
|
|
123
|
+
handler: (agent: unknown, input: {
|
|
124
|
+
period?: string;
|
|
125
|
+
limit?: number;
|
|
126
|
+
}) => Promise<{
|
|
127
|
+
status: string;
|
|
128
|
+
result: any;
|
|
129
|
+
message?: undefined;
|
|
130
|
+
} | {
|
|
131
|
+
status: string;
|
|
132
|
+
message: string;
|
|
133
|
+
result?: undefined;
|
|
134
|
+
}>;
|
|
135
|
+
} | {
|
|
136
|
+
name: string;
|
|
137
|
+
similes: string[];
|
|
138
|
+
description: string;
|
|
139
|
+
examples: {
|
|
140
|
+
input: {
|
|
141
|
+
limit: number;
|
|
142
|
+
};
|
|
143
|
+
output: {
|
|
144
|
+
status: string;
|
|
145
|
+
};
|
|
146
|
+
explanation: string;
|
|
147
|
+
}[][];
|
|
148
|
+
schema: import("zod").ZodObject<{
|
|
149
|
+
limit: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
150
|
+
offset: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
151
|
+
since: import("zod").ZodOptional<import("zod").ZodString>;
|
|
152
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
153
|
+
limit: number;
|
|
154
|
+
offset: number;
|
|
155
|
+
since?: string | undefined;
|
|
156
|
+
}, {
|
|
157
|
+
limit?: number | undefined;
|
|
158
|
+
offset?: number | undefined;
|
|
159
|
+
since?: string | undefined;
|
|
160
|
+
}>;
|
|
161
|
+
handler: (agent: unknown, input: {
|
|
162
|
+
limit?: number;
|
|
163
|
+
offset?: number;
|
|
164
|
+
since?: string;
|
|
165
|
+
}) => Promise<{
|
|
166
|
+
status: string;
|
|
167
|
+
result: any;
|
|
168
|
+
message?: undefined;
|
|
169
|
+
} | {
|
|
170
|
+
status: string;
|
|
171
|
+
message: string;
|
|
172
|
+
result?: undefined;
|
|
173
|
+
}>;
|
|
174
|
+
})[];
|
|
175
|
+
initialize(_agent: unknown): void;
|
|
176
|
+
};
|
|
177
|
+
export default MadeOnSolPlugin;
|
|
178
|
+
export { kolFeed, kolCoordination, kolLeaderboard, deployerAlerts, createWebhook, listWebhooks, deleteWebhook, testWebhook, getStreamToken };
|
|
179
|
+
export { kolFeedAction, kolCoordinationAction, kolLeaderboardAction, deployerAlertsAction };
|
package/dist/index.js
CHANGED
|
@@ -1,26 +1,31 @@
|
|
|
1
|
-
import { kolFeedAction } from "./actions/kolFeed.js";
|
|
2
|
-
import { kolCoordinationAction } from "./actions/kolCoordination.js";
|
|
3
|
-
import { kolLeaderboardAction } from "./actions/kolLeaderboard.js";
|
|
4
|
-
import { deployerAlertsAction } from "./actions/deployerAlerts.js";
|
|
5
|
-
import { kolFeed, kolCoordination, kolLeaderboard, deployerAlerts } from "./tools/index.js";
|
|
6
|
-
const MadeOnSolPlugin = {
|
|
7
|
-
name: "madeonsol",
|
|
8
|
-
methods: {
|
|
9
|
-
kolFeed,
|
|
10
|
-
kolCoordination,
|
|
11
|
-
kolLeaderboard,
|
|
12
|
-
deployerAlerts,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
import { kolFeedAction } from "./actions/kolFeed.js";
|
|
2
|
+
import { kolCoordinationAction } from "./actions/kolCoordination.js";
|
|
3
|
+
import { kolLeaderboardAction } from "./actions/kolLeaderboard.js";
|
|
4
|
+
import { deployerAlertsAction } from "./actions/deployerAlerts.js";
|
|
5
|
+
import { kolFeed, kolCoordination, kolLeaderboard, deployerAlerts, createWebhook, listWebhooks, deleteWebhook, testWebhook, getStreamToken } from "./tools/index.js";
|
|
6
|
+
const MadeOnSolPlugin = {
|
|
7
|
+
name: "madeonsol",
|
|
8
|
+
methods: {
|
|
9
|
+
kolFeed,
|
|
10
|
+
kolCoordination,
|
|
11
|
+
kolLeaderboard,
|
|
12
|
+
deployerAlerts,
|
|
13
|
+
createWebhook,
|
|
14
|
+
listWebhooks,
|
|
15
|
+
deleteWebhook,
|
|
16
|
+
testWebhook,
|
|
17
|
+
getStreamToken,
|
|
18
|
+
},
|
|
19
|
+
actions: [
|
|
20
|
+
kolFeedAction,
|
|
21
|
+
kolCoordinationAction,
|
|
22
|
+
kolLeaderboardAction,
|
|
23
|
+
deployerAlertsAction,
|
|
24
|
+
],
|
|
25
|
+
initialize(_agent) {
|
|
26
|
+
// No-op — payment setup is lazy in tool functions
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
export default MadeOnSolPlugin;
|
|
30
|
+
export { kolFeed, kolCoordination, kolLeaderboard, deployerAlerts, createWebhook, listWebhooks, deleteWebhook, testWebhook, getStreamToken };
|
|
31
|
+
export { kolFeedAction, kolCoordinationAction, kolLeaderboardAction, deployerAlertsAction };
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -1,26 +1,39 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tool functions — pure logic that calls MadeOnSol x402 API.
|
|
3
|
-
* These are called by Action handlers and can also be used directly via agent.methods.
|
|
4
|
-
*/
|
|
5
|
-
type Agent = any;
|
|
6
|
-
export declare function initPaidFetch(agent: Agent): Promise<typeof fetch>;
|
|
7
|
-
export declare function kolFeed(agent: Agent, params?: {
|
|
8
|
-
limit?: number;
|
|
9
|
-
action?: string;
|
|
10
|
-
kol?: string;
|
|
11
|
-
}): Promise<any>;
|
|
12
|
-
export declare function kolCoordination(agent: Agent, params?: {
|
|
13
|
-
period?: string;
|
|
14
|
-
min_kols?: number;
|
|
15
|
-
limit?: number;
|
|
16
|
-
}): Promise<any>;
|
|
17
|
-
export declare function kolLeaderboard(agent: Agent, params?: {
|
|
18
|
-
period?: string;
|
|
19
|
-
limit?: number;
|
|
20
|
-
}): Promise<any>;
|
|
21
|
-
export declare function deployerAlerts(agent: Agent, params?: {
|
|
22
|
-
limit?: number;
|
|
23
|
-
since?: string;
|
|
24
|
-
offset?: number;
|
|
25
|
-
}): Promise<any>;
|
|
26
|
-
export {
|
|
1
|
+
/**
|
|
2
|
+
* Tool functions — pure logic that calls MadeOnSol x402 API.
|
|
3
|
+
* These are called by Action handlers and can also be used directly via agent.methods.
|
|
4
|
+
*/
|
|
5
|
+
type Agent = any;
|
|
6
|
+
export declare function initPaidFetch(agent: Agent): Promise<typeof fetch>;
|
|
7
|
+
export declare function kolFeed(agent: Agent, params?: {
|
|
8
|
+
limit?: number;
|
|
9
|
+
action?: string;
|
|
10
|
+
kol?: string;
|
|
11
|
+
}): Promise<any>;
|
|
12
|
+
export declare function kolCoordination(agent: Agent, params?: {
|
|
13
|
+
period?: string;
|
|
14
|
+
min_kols?: number;
|
|
15
|
+
limit?: number;
|
|
16
|
+
}): Promise<any>;
|
|
17
|
+
export declare function kolLeaderboard(agent: Agent, params?: {
|
|
18
|
+
period?: string;
|
|
19
|
+
limit?: number;
|
|
20
|
+
}): Promise<any>;
|
|
21
|
+
export declare function deployerAlerts(agent: Agent, params?: {
|
|
22
|
+
limit?: number;
|
|
23
|
+
since?: string;
|
|
24
|
+
offset?: number;
|
|
25
|
+
}): Promise<any>;
|
|
26
|
+
export declare function createWebhook(agent: Agent, params: {
|
|
27
|
+
url: string;
|
|
28
|
+
events: string[];
|
|
29
|
+
filters?: Record<string, unknown>;
|
|
30
|
+
}): Promise<any>;
|
|
31
|
+
export declare function listWebhooks(agent: Agent): Promise<any>;
|
|
32
|
+
export declare function deleteWebhook(agent: Agent, params: {
|
|
33
|
+
id: number;
|
|
34
|
+
}): Promise<any>;
|
|
35
|
+
export declare function testWebhook(agent: Agent, params: {
|
|
36
|
+
webhook_id: number;
|
|
37
|
+
}): Promise<any>;
|
|
38
|
+
export declare function getStreamToken(agent: Agent): Promise<any>;
|
|
39
|
+
export {};
|
package/dist/tools/index.js
CHANGED
|
@@ -1,57 +1,92 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tool functions — pure logic that calls MadeOnSol x402 API.
|
|
3
|
-
* These are called by Action handlers and can also be used directly via agent.methods.
|
|
4
|
-
*/
|
|
5
|
-
const BASE_URL = "https://madeonsol.com";
|
|
6
|
-
async function query(paidFetch, path, params) {
|
|
7
|
-
const url = new URL(path, BASE_URL);
|
|
8
|
-
if (params) {
|
|
9
|
-
for (const [k, v] of Object.entries(params)) {
|
|
10
|
-
if (v !== undefined)
|
|
11
|
-
url.searchParams.set(k, String(v));
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
const res = await paidFetch(url.toString());
|
|
15
|
-
if (!res.ok) {
|
|
16
|
-
const body = await res.text().catch(() => "");
|
|
17
|
-
throw new Error(`MadeOnSol API error ${res.status}: ${body}`);
|
|
18
|
-
}
|
|
19
|
-
return res.json();
|
|
20
|
-
}
|
|
21
|
-
let _paidFetch = null;
|
|
22
|
-
export async function initPaidFetch(agent) {
|
|
23
|
-
if (_paidFetch)
|
|
24
|
-
return _paidFetch;
|
|
25
|
-
const privateKey = agent.config?.SVM_PRIVATE_KEY || agent.config?.OTHER_API_KEYS?.SVM_PRIVATE_KEY;
|
|
26
|
-
if (!privateKey) {
|
|
27
|
-
console.warn("[madeonsol] No SVM_PRIVATE_KEY in agent config — x402 payments disabled");
|
|
28
|
-
_paidFetch = fetch;
|
|
29
|
-
return _paidFetch;
|
|
30
|
-
}
|
|
31
|
-
const { wrapFetchWithPayment } = await import("@x402/fetch");
|
|
32
|
-
const { x402Client } = await import("@x402/core/client");
|
|
33
|
-
const { ExactSvmScheme } = await import("@x402/svm/exact/client");
|
|
34
|
-
const { createKeyPairSignerFromBytes } = await import("@solana/kit");
|
|
35
|
-
const { base58 } = await import("@scure/base");
|
|
36
|
-
const signer = await createKeyPairSignerFromBytes(base58.decode(privateKey));
|
|
37
|
-
const client = new x402Client();
|
|
38
|
-
client.register("solana:*", new ExactSvmScheme(signer));
|
|
39
|
-
_paidFetch = wrapFetchWithPayment(fetch, client);
|
|
40
|
-
return _paidFetch;
|
|
41
|
-
}
|
|
42
|
-
export async function kolFeed(agent, params = {}) {
|
|
43
|
-
const f = await initPaidFetch(agent);
|
|
44
|
-
return query(f, "/api/x402/kol/feed", params);
|
|
45
|
-
}
|
|
46
|
-
export async function kolCoordination(agent, params = {}) {
|
|
47
|
-
const f = await initPaidFetch(agent);
|
|
48
|
-
return query(f, "/api/x402/kol/coordination", params);
|
|
49
|
-
}
|
|
50
|
-
export async function kolLeaderboard(agent, params = {}) {
|
|
51
|
-
const f = await initPaidFetch(agent);
|
|
52
|
-
return query(f, "/api/x402/kol/leaderboard", params);
|
|
53
|
-
}
|
|
54
|
-
export async function deployerAlerts(agent, params = {}) {
|
|
55
|
-
const f = await initPaidFetch(agent);
|
|
56
|
-
return query(f, "/api/x402/deployer-hunter/alerts", params);
|
|
57
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Tool functions — pure logic that calls MadeOnSol x402 API.
|
|
3
|
+
* These are called by Action handlers and can also be used directly via agent.methods.
|
|
4
|
+
*/
|
|
5
|
+
const BASE_URL = "https://madeonsol.com";
|
|
6
|
+
async function query(paidFetch, path, params) {
|
|
7
|
+
const url = new URL(path, BASE_URL);
|
|
8
|
+
if (params) {
|
|
9
|
+
for (const [k, v] of Object.entries(params)) {
|
|
10
|
+
if (v !== undefined)
|
|
11
|
+
url.searchParams.set(k, String(v));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const res = await paidFetch(url.toString());
|
|
15
|
+
if (!res.ok) {
|
|
16
|
+
const body = await res.text().catch(() => "");
|
|
17
|
+
throw new Error(`MadeOnSol API error ${res.status}: ${body}`);
|
|
18
|
+
}
|
|
19
|
+
return res.json();
|
|
20
|
+
}
|
|
21
|
+
let _paidFetch = null;
|
|
22
|
+
export async function initPaidFetch(agent) {
|
|
23
|
+
if (_paidFetch)
|
|
24
|
+
return _paidFetch;
|
|
25
|
+
const privateKey = agent.config?.SVM_PRIVATE_KEY || agent.config?.OTHER_API_KEYS?.SVM_PRIVATE_KEY;
|
|
26
|
+
if (!privateKey) {
|
|
27
|
+
console.warn("[madeonsol] No SVM_PRIVATE_KEY in agent config — x402 payments disabled");
|
|
28
|
+
_paidFetch = fetch;
|
|
29
|
+
return _paidFetch;
|
|
30
|
+
}
|
|
31
|
+
const { wrapFetchWithPayment } = await import("@x402/fetch");
|
|
32
|
+
const { x402Client } = await import("@x402/core/client");
|
|
33
|
+
const { ExactSvmScheme } = await import("@x402/svm/exact/client");
|
|
34
|
+
const { createKeyPairSignerFromBytes } = await import("@solana/kit");
|
|
35
|
+
const { base58 } = await import("@scure/base");
|
|
36
|
+
const signer = await createKeyPairSignerFromBytes(base58.decode(privateKey));
|
|
37
|
+
const client = new x402Client();
|
|
38
|
+
client.register("solana:*", new ExactSvmScheme(signer));
|
|
39
|
+
_paidFetch = wrapFetchWithPayment(fetch, client);
|
|
40
|
+
return _paidFetch;
|
|
41
|
+
}
|
|
42
|
+
export async function kolFeed(agent, params = {}) {
|
|
43
|
+
const f = await initPaidFetch(agent);
|
|
44
|
+
return query(f, "/api/x402/kol/feed", params);
|
|
45
|
+
}
|
|
46
|
+
export async function kolCoordination(agent, params = {}) {
|
|
47
|
+
const f = await initPaidFetch(agent);
|
|
48
|
+
return query(f, "/api/x402/kol/coordination", params);
|
|
49
|
+
}
|
|
50
|
+
export async function kolLeaderboard(agent, params = {}) {
|
|
51
|
+
const f = await initPaidFetch(agent);
|
|
52
|
+
return query(f, "/api/x402/kol/leaderboard", params);
|
|
53
|
+
}
|
|
54
|
+
export async function deployerAlerts(agent, params = {}) {
|
|
55
|
+
const f = await initPaidFetch(agent);
|
|
56
|
+
return query(f, "/api/x402/deployer-hunter/alerts", params);
|
|
57
|
+
}
|
|
58
|
+
// ── Webhook & Streaming (RapidAPI key required) ──
|
|
59
|
+
async function restQuery(agent, method, path, body) {
|
|
60
|
+
const apiKey = agent.config?.RAPIDAPI_KEY || agent.config?.OTHER_API_KEYS?.RAPIDAPI_KEY;
|
|
61
|
+
if (!apiKey)
|
|
62
|
+
throw new Error("RAPIDAPI_KEY required for webhook/streaming features");
|
|
63
|
+
const res = await fetch(`${BASE_URL}/api/v1${path}`, {
|
|
64
|
+
method,
|
|
65
|
+
headers: {
|
|
66
|
+
"Content-Type": "application/json",
|
|
67
|
+
"x-rapidapi-key": apiKey,
|
|
68
|
+
"x-rapidapi-host": "madeonsol-solana-kol-tracker-tools-api.p.rapidapi.com",
|
|
69
|
+
},
|
|
70
|
+
...(body ? { body: JSON.stringify(body) } : {}),
|
|
71
|
+
});
|
|
72
|
+
if (!res.ok) {
|
|
73
|
+
const text = await res.text().catch(() => "");
|
|
74
|
+
throw new Error(`MadeOnSol API error ${res.status}: ${text}`);
|
|
75
|
+
}
|
|
76
|
+
return res.json();
|
|
77
|
+
}
|
|
78
|
+
export async function createWebhook(agent, params) {
|
|
79
|
+
return restQuery(agent, "POST", "/webhooks", params);
|
|
80
|
+
}
|
|
81
|
+
export async function listWebhooks(agent) {
|
|
82
|
+
return restQuery(agent, "GET", "/webhooks");
|
|
83
|
+
}
|
|
84
|
+
export async function deleteWebhook(agent, params) {
|
|
85
|
+
return restQuery(agent, "DELETE", `/webhooks/${params.id}`);
|
|
86
|
+
}
|
|
87
|
+
export async function testWebhook(agent, params) {
|
|
88
|
+
return restQuery(agent, "POST", "/webhooks/test", params);
|
|
89
|
+
}
|
|
90
|
+
export async function getStreamToken(agent) {
|
|
91
|
+
return restQuery(agent, "POST", "/stream/token");
|
|
92
|
+
}
|