@tiplink/util
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

TipLink Util

Shared TypeScript code accross TipLink products.

Notes

This is an evolving package but some initial proposals:

  • This package is meant for internal use, published on npm for convenience, not maintained for third parties
  • Keep a low dependency footprint; that said, we'll have core libraries like @solana/web3.js
  • Libraries of functions over classes
  • Higher code quality
    • JSDocs over complicated functions
    • Performant, reliable, clean functions
    • Good test coverage, linting

Style Guide

  • For exported functions, params, constants, fields, etc., use full words

Examples

Common transaction

Custom transaction using modular parts

try {
  const instructions = [
    SystemProgram.transfer({
      fromPubkey,
      toPubkey: to,
      lamports: amount,
    }),
  ];

  const { transaction } = await buildTransaction({
    connection,
    instructions,
    feePayer: fromPubkey,
    priorityFeesConfig: prioFeesConfig,
    signers,
    signTransaction: signFn,
  });

  await simulateTransaction({
    connection,
    transaction,
    simulateTransactionConfig: {
      sigVerify: true,
    },
  });

  const { signature } = await sendTransaction({
    connection,
    rawTransaction: transaction.serialize(),
  });
} catch (err) {
  if (err instanceof TxnError) {
    if (err instanceof InsufficientFundsError) {
      // Handle
    }
    if (err instanceof UnexpectedSendError) {
    // Handle
    }

    // etc.
  }
}

Pre-built common transaction

try {
  const { sig } = await sendLamports({
    connection: CONNECTION,
    from: TEST_KEYPAIR,
    to,
    amount,
    prioFeesConfig: { cuPrice: DEFAULT_CU_PRICE },
  });
} catch (err) {
  // Similar to above
}

Readme

Keywords

none

Package Sidebar

Install

npm i @tiplink/util

Weekly Downloads

0

Version

0.0.1

License

LicenseRef-LICENSE

Unpacked Size

121 kB

Total Files

49

Last publish

Collaborators

  • wisefool769
  • jac0xb
  • joeypereira
  • alex-tiplink
  • jackson-techne-xyz