@adelos/sdk 0.1.7 → 0.1.8
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.mts +6 -3
- package/dist/index.d.ts +6 -3
- package/dist/index.js +41 -5
- package/dist/index.mjs +41 -5
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -13,6 +13,8 @@ interface AdelosOptions {
|
|
|
13
13
|
rpcUrl?: string;
|
|
14
14
|
/** Helius API key for indexer webhooks (optional) */
|
|
15
15
|
heliusApiKey?: string;
|
|
16
|
+
/** Enable debug logging (optional - defaults to false) */
|
|
17
|
+
debug?: boolean;
|
|
16
18
|
}
|
|
17
19
|
/** Result of a registry lookup */
|
|
18
20
|
interface RegistryInfo {
|
|
@@ -115,8 +117,9 @@ declare class AdelosIndexer {
|
|
|
115
117
|
constructor(connection: Connection);
|
|
116
118
|
/** Scan for stealth transfers to this recipient */
|
|
117
119
|
scanForStealthTransfers(metaSk: Uint8Array, metaPk: Uint8Array, limit?: number): Promise<StealthTransaction[]>;
|
|
118
|
-
/**
|
|
119
|
-
*
|
|
120
|
+
/**
|
|
121
|
+
* Trial Decryption: Check if this transaction belongs to the user.
|
|
122
|
+
* Made 'public' for testing purposes.
|
|
120
123
|
*/
|
|
121
124
|
attemptDecryption(tx: ParsedTransactionWithMeta, metaSk: Uint8Array, metaPk: Uint8Array): {
|
|
122
125
|
stealthAddress: PublicKey;
|
|
@@ -124,7 +127,7 @@ declare class AdelosIndexer {
|
|
|
124
127
|
} | null;
|
|
125
128
|
private extractMemo;
|
|
126
129
|
}
|
|
127
|
-
/** Helper
|
|
130
|
+
/** Helper for quick initialization */
|
|
128
131
|
declare function createIndexer(connection: Connection): AdelosIndexer;
|
|
129
132
|
|
|
130
133
|
declare class AdelosSDK {
|
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ interface AdelosOptions {
|
|
|
13
13
|
rpcUrl?: string;
|
|
14
14
|
/** Helius API key for indexer webhooks (optional) */
|
|
15
15
|
heliusApiKey?: string;
|
|
16
|
+
/** Enable debug logging (optional - defaults to false) */
|
|
17
|
+
debug?: boolean;
|
|
16
18
|
}
|
|
17
19
|
/** Result of a registry lookup */
|
|
18
20
|
interface RegistryInfo {
|
|
@@ -115,8 +117,9 @@ declare class AdelosIndexer {
|
|
|
115
117
|
constructor(connection: Connection);
|
|
116
118
|
/** Scan for stealth transfers to this recipient */
|
|
117
119
|
scanForStealthTransfers(metaSk: Uint8Array, metaPk: Uint8Array, limit?: number): Promise<StealthTransaction[]>;
|
|
118
|
-
/**
|
|
119
|
-
*
|
|
120
|
+
/**
|
|
121
|
+
* Trial Decryption: Check if this transaction belongs to the user.
|
|
122
|
+
* Made 'public' for testing purposes.
|
|
120
123
|
*/
|
|
121
124
|
attemptDecryption(tx: ParsedTransactionWithMeta, metaSk: Uint8Array, metaPk: Uint8Array): {
|
|
122
125
|
stealthAddress: PublicKey;
|
|
@@ -124,7 +127,7 @@ declare class AdelosIndexer {
|
|
|
124
127
|
} | null;
|
|
125
128
|
private extractMemo;
|
|
126
129
|
}
|
|
127
|
-
/** Helper
|
|
130
|
+
/** Helper for quick initialization */
|
|
128
131
|
declare function createIndexer(connection: Connection): AdelosIndexer;
|
|
129
132
|
|
|
130
133
|
declare class AdelosSDK {
|
package/dist/index.js
CHANGED
|
@@ -187,40 +187,73 @@ function generateStealthAddress(recipientMetaPk) {
|
|
|
187
187
|
return { stealthPubkey, ephemeralKeypair, sharedSecret, memo };
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
+
// src/logger.ts
|
|
191
|
+
var debugMode = false;
|
|
192
|
+
function setDebugMode(enabled) {
|
|
193
|
+
debugMode = enabled;
|
|
194
|
+
}
|
|
195
|
+
function log(...args) {
|
|
196
|
+
if (debugMode) {
|
|
197
|
+
console.log(...args);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
190
201
|
// src/indexer.ts
|
|
191
202
|
var AdelosIndexer = class {
|
|
192
|
-
//
|
|
203
|
+
// Directly accepts Connection object
|
|
193
204
|
constructor(connection) {
|
|
194
205
|
this.connection = connection;
|
|
195
206
|
}
|
|
196
207
|
/** Scan for stealth transfers to this recipient */
|
|
197
208
|
async scanForStealthTransfers(metaSk, metaPk, limit = 100) {
|
|
209
|
+
log(`[Indexer] Starting scan for stealth transfers (limit: ${limit})`);
|
|
210
|
+
const startTime = Date.now();
|
|
198
211
|
const sigs = await this.connection.getSignaturesForAddress(
|
|
199
212
|
ADELOS_CONFIG.MEMO_PROGRAM_ID,
|
|
200
213
|
{ limit }
|
|
201
214
|
);
|
|
215
|
+
log(`[Indexer] Found ${sigs.length} memo program transactions to check`);
|
|
202
216
|
const results = [];
|
|
217
|
+
let processed = 0;
|
|
218
|
+
let adelosMemos = 0;
|
|
203
219
|
for (const s of sigs) {
|
|
220
|
+
processed++;
|
|
221
|
+
log(`[Indexer] Processing tx ${processed}/${sigs.length}: ${s.signature.substring(0, 10)}...`);
|
|
204
222
|
const tx = await this.connection.getParsedTransaction(s.signature, {
|
|
205
223
|
maxSupportedTransactionVersion: 0
|
|
206
224
|
});
|
|
207
|
-
if (!tx)
|
|
225
|
+
if (!tx) {
|
|
226
|
+
log(` \u21B3 Skipped (tx not found)`);
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
208
229
|
const memo = this.extractMemo(tx);
|
|
209
|
-
if (!memo?.startsWith(ADELOS_CONFIG.MEMO_PREFIX))
|
|
230
|
+
if (!memo?.startsWith(ADELOS_CONFIG.MEMO_PREFIX)) {
|
|
231
|
+
log(` \u21B3 Skipped (not Adelos memo)`);
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
adelosMemos++;
|
|
235
|
+
log(` \u21B3 Found Adelos memo! Attempting trial decryption...`);
|
|
210
236
|
const detected = this.attemptDecryption(tx, metaSk, metaPk);
|
|
211
237
|
if (detected) {
|
|
238
|
+
log(` \u21B3 \u2705 MATCH! Stealth transfer detected: ${Number(detected.amount) / 1e9} SOL`);
|
|
212
239
|
results.push({
|
|
213
240
|
signature: s.signature,
|
|
214
241
|
blockTime: tx.blockTime ?? null,
|
|
215
242
|
stealthAddress: detected.stealthAddress,
|
|
216
243
|
amount: detected.amount
|
|
217
244
|
});
|
|
245
|
+
} else {
|
|
246
|
+
log(` \u21B3 Not for this recipient`);
|
|
218
247
|
}
|
|
219
248
|
}
|
|
249
|
+
const elapsed = ((Date.now() - startTime) / 1e3).toFixed(2);
|
|
250
|
+
log(`[Indexer] Scan complete in ${elapsed}s`);
|
|
251
|
+
log(`[Indexer] Summary: ${processed} total, ${adelosMemos} Adelos memos, ${results.length} matches`);
|
|
220
252
|
return results;
|
|
221
253
|
}
|
|
222
|
-
/**
|
|
223
|
-
*
|
|
254
|
+
/**
|
|
255
|
+
* Trial Decryption: Check if this transaction belongs to the user.
|
|
256
|
+
* Made 'public' for testing purposes.
|
|
224
257
|
*/
|
|
225
258
|
attemptDecryption(tx, metaSk, metaPk) {
|
|
226
259
|
const memo = this.extractMemo(tx);
|
|
@@ -257,6 +290,9 @@ var AdelosSDK = class {
|
|
|
257
290
|
constructor(options = {}) {
|
|
258
291
|
this.connection = new import_web33.Connection(options.rpcUrl ?? ADELOS_CONFIG.RPC_URL, "confirmed");
|
|
259
292
|
this.programId = ADELOS_CONFIG.PROGRAM_ID;
|
|
293
|
+
if (options.debug !== void 0) {
|
|
294
|
+
setDebugMode(options.debug);
|
|
295
|
+
}
|
|
260
296
|
}
|
|
261
297
|
// --- 1. Identity & Registry ---
|
|
262
298
|
async getRegistry(owner) {
|
package/dist/index.mjs
CHANGED
|
@@ -138,40 +138,73 @@ function generateStealthAddress(recipientMetaPk) {
|
|
|
138
138
|
return { stealthPubkey, ephemeralKeypair, sharedSecret, memo };
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
+
// src/logger.ts
|
|
142
|
+
var debugMode = false;
|
|
143
|
+
function setDebugMode(enabled) {
|
|
144
|
+
debugMode = enabled;
|
|
145
|
+
}
|
|
146
|
+
function log(...args) {
|
|
147
|
+
if (debugMode) {
|
|
148
|
+
console.log(...args);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
141
152
|
// src/indexer.ts
|
|
142
153
|
var AdelosIndexer = class {
|
|
143
|
-
//
|
|
154
|
+
// Directly accepts Connection object
|
|
144
155
|
constructor(connection) {
|
|
145
156
|
this.connection = connection;
|
|
146
157
|
}
|
|
147
158
|
/** Scan for stealth transfers to this recipient */
|
|
148
159
|
async scanForStealthTransfers(metaSk, metaPk, limit = 100) {
|
|
160
|
+
log(`[Indexer] Starting scan for stealth transfers (limit: ${limit})`);
|
|
161
|
+
const startTime = Date.now();
|
|
149
162
|
const sigs = await this.connection.getSignaturesForAddress(
|
|
150
163
|
ADELOS_CONFIG.MEMO_PROGRAM_ID,
|
|
151
164
|
{ limit }
|
|
152
165
|
);
|
|
166
|
+
log(`[Indexer] Found ${sigs.length} memo program transactions to check`);
|
|
153
167
|
const results = [];
|
|
168
|
+
let processed = 0;
|
|
169
|
+
let adelosMemos = 0;
|
|
154
170
|
for (const s of sigs) {
|
|
171
|
+
processed++;
|
|
172
|
+
log(`[Indexer] Processing tx ${processed}/${sigs.length}: ${s.signature.substring(0, 10)}...`);
|
|
155
173
|
const tx = await this.connection.getParsedTransaction(s.signature, {
|
|
156
174
|
maxSupportedTransactionVersion: 0
|
|
157
175
|
});
|
|
158
|
-
if (!tx)
|
|
176
|
+
if (!tx) {
|
|
177
|
+
log(` \u21B3 Skipped (tx not found)`);
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
159
180
|
const memo = this.extractMemo(tx);
|
|
160
|
-
if (!memo?.startsWith(ADELOS_CONFIG.MEMO_PREFIX))
|
|
181
|
+
if (!memo?.startsWith(ADELOS_CONFIG.MEMO_PREFIX)) {
|
|
182
|
+
log(` \u21B3 Skipped (not Adelos memo)`);
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
adelosMemos++;
|
|
186
|
+
log(` \u21B3 Found Adelos memo! Attempting trial decryption...`);
|
|
161
187
|
const detected = this.attemptDecryption(tx, metaSk, metaPk);
|
|
162
188
|
if (detected) {
|
|
189
|
+
log(` \u21B3 \u2705 MATCH! Stealth transfer detected: ${Number(detected.amount) / 1e9} SOL`);
|
|
163
190
|
results.push({
|
|
164
191
|
signature: s.signature,
|
|
165
192
|
blockTime: tx.blockTime ?? null,
|
|
166
193
|
stealthAddress: detected.stealthAddress,
|
|
167
194
|
amount: detected.amount
|
|
168
195
|
});
|
|
196
|
+
} else {
|
|
197
|
+
log(` \u21B3 Not for this recipient`);
|
|
169
198
|
}
|
|
170
199
|
}
|
|
200
|
+
const elapsed = ((Date.now() - startTime) / 1e3).toFixed(2);
|
|
201
|
+
log(`[Indexer] Scan complete in ${elapsed}s`);
|
|
202
|
+
log(`[Indexer] Summary: ${processed} total, ${adelosMemos} Adelos memos, ${results.length} matches`);
|
|
171
203
|
return results;
|
|
172
204
|
}
|
|
173
|
-
/**
|
|
174
|
-
*
|
|
205
|
+
/**
|
|
206
|
+
* Trial Decryption: Check if this transaction belongs to the user.
|
|
207
|
+
* Made 'public' for testing purposes.
|
|
175
208
|
*/
|
|
176
209
|
attemptDecryption(tx, metaSk, metaPk) {
|
|
177
210
|
const memo = this.extractMemo(tx);
|
|
@@ -208,6 +241,9 @@ var AdelosSDK = class {
|
|
|
208
241
|
constructor(options = {}) {
|
|
209
242
|
this.connection = new Connection(options.rpcUrl ?? ADELOS_CONFIG.RPC_URL, "confirmed");
|
|
210
243
|
this.programId = ADELOS_CONFIG.PROGRAM_ID;
|
|
244
|
+
if (options.debug !== void 0) {
|
|
245
|
+
setDebugMode(options.debug);
|
|
246
|
+
}
|
|
211
247
|
}
|
|
212
248
|
// --- 1. Identity & Registry ---
|
|
213
249
|
async getRegistry(owner) {
|