Initialize TypeScript library for Telegram Web App wallet integration
- Added configuration files: .eslintrc.js, .gitignore, .npmrc, .prettierrc, and multiple tsconfig files for different module systems. - Created package.json with dependencies and scripts for building, testing, and publishing. - Implemented core functionality in src/ directory, including wallet management, encryption, and storage handling. - Added README.md for documentation on installation, usage, and development setup. - Introduced initial types and constants for better type safety and code organization.
This commit is contained in:
commit
a21ea39c36
19 files changed
+5094
No files matched your search
@@ -0,0 +1,21 @@
|
||||
import { decodeResult } from "./encryption";
|
||||
import type { ConnectResult, SignTransactionResult, WebApp } from "./types";
|
||||
|
||||
export const parseWalletsFromStartParam = (webApp: WebApp): ConnectResult['wallets'] | null => {
|
||||
const startParam = webApp.initDataUnsafe?.start_param;
|
||||
if (!startParam) return null;
|
||||
|
||||
const result = decodeResult(startParam);
|
||||
console.log('parseWalletsFromStartParam', result);
|
||||
return 'wallets' in result ? result.wallets : null;
|
||||
};
|
||||
|
||||
export const parseSignedTxFromStartParam = (webApp: WebApp): SignTransactionResult | null => {
|
||||
const startParam = webApp.initDataUnsafe?.start_param;
|
||||
if (!startParam) return null;
|
||||
|
||||
const result = decodeResult(startParam);
|
||||
return 'signedTx' in result ? result : null;
|
||||
};
|
||||
|
||||
export const generateRequestId = (): number => Math.floor(Math.random() * 90000) + 10000;
|
||||
Reference in new issue
Block a user