@heyanon/sdk 2.4.1 → 2.4.3

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.
@@ -1,10 +1,10 @@
1
1
  import { OpenAI } from 'openai';
2
2
  import { EVM, Solana, TON, WalletType, Chain } from '../blockchain';
3
- import { Hex, PublicClient, SignMessageReturnType, SignTypedDataParameters as ViemSignTypedDataParameters, SignTypedDataReturnType, Address } from 'viem';
3
+ import { PublicClient, SignMessageReturnType, SignTypedDataReturnType, Address } from 'viem';
4
4
  import { Connection, PublicKey, Transaction as SolanaTransaction, VersionedTransaction as SolanaVersionedTransaction } from '@solana/web3.js';
5
5
  import { AdapterTag } from './misc';
6
6
  import { Address as TonAddress } from '@ton/ton';
7
- import { DeployContractProps } from '../blockchain/evm/types';
7
+ import { DeployContractProps, SignMessagesProps, SignTypedDatasProps } from '../blockchain/evm/types';
8
8
  import { Exchange, exchanges } from 'ccxt';
9
9
  /**
10
10
  * Result of adapter function execution
@@ -23,7 +23,6 @@ export interface FunctionReturn {
23
23
  /** Result data as string */
24
24
  readonly data: string;
25
25
  }
26
- type SignTypedDataParameters = Omit<ViemSignTypedDataParameters, 'account'>;
27
26
  /**
28
27
  * Options for working with EVM blockchains
29
28
  * @interface EvmFunctionOptions
@@ -47,9 +46,9 @@ export interface EvmFunctionOptions {
47
46
  /** Deploy smart contracts */
48
47
  readonly deployContracts?: (props: DeployContractProps) => Promise<Address[]>;
49
48
  /** Sign messages (optional) */
50
- readonly signMessages?: (messages: Hex[]) => Promise<SignMessageReturnType[]>;
49
+ readonly signMessages?: (props: SignMessagesProps) => Promise<SignMessageReturnType[]>;
51
50
  /** Sign typed data (optional) */
52
- readonly signTypedDatas?: (args: SignTypedDataParameters[]) => Promise<SignTypedDataReturnType[]>;
51
+ readonly signTypedDatas?: (props: SignTypedDatasProps) => Promise<SignTypedDataReturnType[]>;
53
52
  }
54
53
  /**
55
54
  * Options for working with Solana blockchain
@@ -71,7 +70,7 @@ export interface SolanaFunctionOptions {
71
70
  /** Send transactions */
72
71
  readonly sendTransactions: (props: Solana.types.SendTransactionProps) => Promise<Solana.types.TransactionReturn>;
73
72
  /** Sign transactions (optional) */
74
- readonly signTransactions?: (transactions: Solana.types.SignTransactionProps[]) => Promise<(SolanaTransaction | SolanaVersionedTransaction)[]>;
73
+ readonly signTransactions?: (props: Solana.types.SignTransactionsProps) => Promise<(SolanaTransaction | SolanaVersionedTransaction)[]>;
75
74
  }
76
75
  /**
77
76
  * Options for working with TON blockchain
@@ -92,6 +91,8 @@ export interface UserFunctionOptions {
92
91
  readonly getUserTokens: () => Promise<UserToken[]>;
93
92
  /** Add token to user's token list */
94
93
  readonly addUserToken: (token: UserToken) => Promise<UserToken>;
94
+ /** Get user's password */
95
+ readonly getUserPassword?: () => Promise<string>;
95
96
  }
96
97
  /**
97
98
  * User token information
@@ -183,4 +184,3 @@ export interface AdapterExport {
183
184
  /** Tools for OpenAI integration */
184
185
  readonly tools: OpenAI.Chat.Completions.ChatCompletionTool[];
185
186
  }
186
- export {};
@@ -1,4 +1,4 @@
1
- import { Abi, Address, Hex } from 'viem';
1
+ import { Abi, Address, Hex, SignTypedDataParameters } from 'viem';
2
2
  /**
3
3
  * Parameters for an EVM transaction
4
4
  * @interface TransactionParams
@@ -300,3 +300,96 @@ export interface DeployContractProps {
300
300
  /** Array of contracts to deploy */
301
301
  readonly contracts: ContractProps[];
302
302
  }
303
+ /**
304
+ * Properties for signing one or multiple messages
305
+ * @interface SignMessagesProps
306
+ * @example
307
+ * ```typescript
308
+ * // Single message
309
+ * const signProps: SignMessagesProps = {
310
+ * account: '0x742d35Cc6634C0532925a3b8D4C2CA1c1DfF0bE8',
311
+ * messages: ['0x1234567890abcdef...']
312
+ * };
313
+ *
314
+ * // Batch messages (multi-sig)
315
+ * const batchSignProps: SignMessagesProps = {
316
+ * account: '0x742d35Cc6634C0532925a3b8D4C2CA1c1DfF0bE8',
317
+ * messages: ['0x1111...', '0x2222...', '0x3333...']
318
+ * };
319
+ * ```
320
+ */
321
+ export interface SignMessagesProps {
322
+ /** Account address that will sign the messages */
323
+ readonly account: Address;
324
+ /** Array of messages to sign */
325
+ readonly messages: Hex[];
326
+ }
327
+ /**
328
+ * Properties for signing one or multiple typed data
329
+ * @interface SignTypedDatasProps
330
+ * @example
331
+ * ```typescript
332
+ * // Single typed data
333
+ * const signProps: SignTypedDatasProps = {
334
+ * account: '0x742d35Cc6634C0532925a3b8D4C2CA1c1DfF0bE8',
335
+ * datas: [{
336
+ * domain: {
337
+ * name: 'My Token',
338
+ * version: '1.0.0',
339
+ * chainId: 1,
340
+ * verifyingContract: '0x1234567890abcdef...'
341
+ * },
342
+ * primaryType: 'MyToken',
343
+ * message: {
344
+ * name: 'My Token',
345
+ * symbol: 'MTK',
346
+ * decimals: 18,
347
+ * totalSupply: parseUnits('1000000', 18)
348
+ * }
349
+ * }]
350
+ * };
351
+ *
352
+ * // Batch typed data (multi-sig)
353
+ * const batchSignProps: SignTypedDatasProps = {
354
+ * account: '0x742d35Cc6634C0532925a3b8D4C2CA1c1DfF0bE8',
355
+ * datas: [
356
+ * {
357
+ * domain: {
358
+ * name: 'My Token',
359
+ * version: '1.0.0',
360
+ * chainId: 1,
361
+ * verifyingContract: '0x1234567890abcdef...'
362
+ * },
363
+ * primaryType: 'MyToken',
364
+ * message: {
365
+ * name: 'My Token',
366
+ * symbol: 'MTK',
367
+ * decimals: 18,
368
+ * totalSupply: parseUnits('1000000', 18)
369
+ * }
370
+ * },
371
+ * {
372
+ * domain: {
373
+ * name: 'My Token',
374
+ * version: '1.0.0',
375
+ * chainId: 1,
376
+ * verifyingContract: '0x1234567890abcdef...'
377
+ * },
378
+ * primaryType: 'MyToken',
379
+ * message: {
380
+ * name: 'My Token',
381
+ * symbol: 'MTK',
382
+ * decimals: 18,
383
+ * totalSupply: parseUnits('1000000', 18)
384
+ * }
385
+ * }
386
+ * ]
387
+ * };
388
+ * ```
389
+ */
390
+ export interface SignTypedDatasProps {
391
+ /** Account address that will sign the typed data */
392
+ readonly account: Address;
393
+ /** Array of typed data to sign */
394
+ readonly datas: Omit<SignTypedDataParameters, 'account'>[];
395
+ }
@@ -187,121 +187,44 @@ export interface SendTransactionProps {
187
187
  readonly transactions: VersionedTransaction[];
188
188
  }
189
189
  /**
190
- * Properties for signing Solana transactions
191
- * @interface SignTransactionProps
190
+ * Properties for signing a single transaction
191
+ * @interface SignTransaction
192
192
  * @example
193
193
  * ```typescript
194
- * // Sign a versioned transaction (default)
195
- * const signProps: SignTransactionProps = {
194
+ * const signTransaction: SignTransaction = {
196
195
  * transaction: await buildV0Transaction({
197
196
  * connection: options.solana.getConnection(),
198
197
  * payer: userPublicKey,
199
- * instructions: [transferInstruction]
200
- * })
201
- * };
202
- *
203
- * // Sign with specific method
204
- * const partialSignProps: SignTransactionProps = {
205
- * transaction: versionedTransaction,
206
- * signName: 'partialSign' // For multi-sig scenarios
207
- * };
208
- *
209
- * // Sign legacy transaction
210
- * const legacySignProps: SignTransactionProps = {
211
- * transaction: new Transaction().add(transferInstruction),
198
+ * instructions: [SystemProgram.transfer({
199
+ * fromPubkey: userPublicKey,
200
+ * toPubkey: recipientPublicKey,
201
+ * lamports: 0.1 * LAMPORTS_PER_SOL
202
+ * })]
203
+ * }),
212
204
  * signName: 'sign'
213
205
  * };
214
- *
215
- * // Multi-signature workflow
216
- * async function multiSigTransactionFlow(
217
- * transaction: VersionedTransaction,
218
- * signers: PublicKey[]
219
- * ) {
220
- * const signatures: (VersionedTransaction | Transaction)[] = [];
221
- *
222
- * // Each signer partially signs the transaction
223
- * for (const signer of signers) {
224
- * const signedTx = await options.solana.signTransactions([{
225
- * transaction,
226
- * signName: 'partialSign'
227
- * }]);
228
- *
229
- * signatures.push(signedTx[0]);
230
- * }
231
- *
232
- * return signatures;
233
- * }
234
- *
235
- * // Batch signing
236
- * async function signMultipleTransactions(
237
- * transactions: (VersionedTransaction | Transaction)[]
238
- * ) {
239
- * const signProps = transactions.map(tx => ({
240
- * transaction: tx,
241
- * signName: 'sign' as const
242
- * }));
243
- *
244
- * return await options.solana.signTransactions(signProps);
245
- * }
246
- *
247
- * // Conditional signing based on transaction type
248
- * function createSignProps(
249
- * transaction: VersionedTransaction | Transaction,
250
- * isMultiSig: boolean = false
251
- * ): SignTransactionProps {
252
- * return {
253
- * transaction,
254
- * signName: isMultiSig ? 'partialSign' : 'sign'
255
- * };
256
- * }
257
- *
258
- * // Prepare transaction for signing
259
- * async function prepareAndSignTransaction(
260
- * instructions: TransactionInstruction[],
261
- * requiresPartialSign: boolean = false
262
- * ) {
263
- * const transaction = await buildV0Transaction({
264
- * connection: options.solana.getConnection(),
265
- * payer: await options.solana.getPublicKey(),
266
- * instructions
267
- * });
268
- *
269
- * const signProps: SignTransactionProps = {
270
- * transaction,
271
- * signName: requiresPartialSign ? 'partialSign' : 'sign'
272
- * };
273
- *
274
- * const [signedTransaction] = await options.solana.signTransactions([signProps]);
275
- * return signedTransaction;
276
- * }
277
- *
278
- * // Integration with wallet adapters
279
- * async function signTransactionWithWallet(
280
- * transaction: VersionedTransaction,
281
- * walletType: 'phantom' | 'solflare' | 'backpack'
282
- * ) {
283
- * const signProps: SignTransactionProps = {
284
- * transaction,
285
- * signName: 'sign'
286
- * };
287
- *
288
- * // Different wallets might have different signing patterns
289
- * switch (walletType) {
290
- * case 'phantom':
291
- * return await options.solana.signTransactions([signProps]);
292
- * case 'solflare':
293
- * return await options.solana.signTransactions([signProps]);
294
- * case 'backpack':
295
- * return await options.solana.signTransactions([signProps]);
296
- * default:
297
- * throw new Error(`Unsupported wallet: ${walletType}`);
298
- * }
299
- * }
300
206
  * ```
301
207
  */
302
- export interface SignTransactionProps {
208
+ export interface SignTransaction {
303
209
  /** Transaction to sign (versioned or legacy) */
304
210
  readonly transaction: VersionedTransaction | Transaction;
305
211
  /** Signing method - 'sign' for full signature, 'partialSign' for multi-sig scenarios */
306
212
  readonly signName?: 'sign' | 'partialSign';
307
213
  }
214
+ /**
215
+ * Properties for signing one or multiple transactions
216
+ * @interface SignTransactionsProps
217
+ * @example
218
+ * ```typescript
219
+ * const signTransactions: SignTransactionsProps = {
220
+ * account: userPublicKey,
221
+ * transactions: [signTransaction]
222
+ * };
223
+ * ```
224
+ */
225
+ export interface SignTransactionsProps {
226
+ /** Account that will sign the transactions */
227
+ readonly account: PublicKey;
228
+ /** Array of transactions to sign */
229
+ readonly transactions: SignTransaction[];
230
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heyanon/sdk",
3
- "version": "2.4.1",
3
+ "version": "2.4.3",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",