npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@actalink/sdk

v0.0.22

Published

ActaLink Account Abstraction SDK

Downloads

102

Readme

ActaLink account abstraction SDK

Usage

import { SmartAccount, type SmartAccountConfig } from "@actalink/sdk";
...
...
// define configurations for smart account
const config: SmartAccountConfig = {
  chainId,
  provider,
  owner: wallet,
  bundlerUrl: "<bundler URL>",
  paymasterUrl: "<paymaster URL>"
};

const smartWallet = new SmartAccount(config);

// send transaction
const userOpHash = await smartWallet.sendTransaction({
  to: "<contract address>", // Address of contract which we are interacting to. Here USDC contract address.
  data: "<transaction data>",
  value: 0n,
});

Usage with React or NextJS

Note: if you are using SDK in React or Next.js app and using wagmi connector for connecting with wallets then you should configure your provider and signer in ethers.js format.

// hook.ts
import * as React from "react";
import {
  type PublicClient,
  usePublicClient,
  useWalletClient,
  type WalletClient,
} from "wagmi";
import {
  FallbackProvider,
  JsonRpcProvider,
  BrowserProvider,
  JsonRpcSigner,
} from "ethers"; //use ethersv6
import { type HttpTransport } from "viem";

function publicClientToProvider(publicClient: PublicClient) {
  const { chain, transport } = publicClient;
  const network = {
    chainId: chain.id,
    name: chain.name,
    ensAddress: chain.contracts?.ensRegistry?.address,
  };
  if (transport.type === "fallback") {
    const providers = (transport.transports as ReturnType<HttpTransport>[]).map(
      ({ value }) => new JsonRpcProvider(value?.url, network)
    );
    if (providers.length === 1) return providers[0];
    return new FallbackProvider(providers);
  }
  return new JsonRpcProvider(transport.url, network);
}

/**
 * Hook to use a viem Public Client with ethers.js Provider.
 */
export function useEthersProvider({ chainId }: { chainId?: number } = {}) {
  const publicClient = usePublicClient({ chainId });
  return React.useMemo(
    () => publicClientToProvider(publicClient),
    [publicClient]
  );
}

function walletClientToSigner(walletClient: WalletClient) {
  const { account, chain, transport } = walletClient;
  const network = {
    chainId: chain.id,
    name: chain.name,
    ensAddress: chain.contracts?.ensRegistry?.address,
  };
  const provider = new BrowserProvider(transport, network);
  const signer = new JsonRpcSigner(provider, account.address);
  return signer;
}

/**
 * Hook to use a viem Wallet Client with ethers.js Signer.
 */
export function useEthersSigner({ chainId }: { chainId?: number } = {}) {
  const { data: walletClient } = useWalletClient({ chainId });
  return React.useMemo(
    () => (walletClient ? walletClientToSigner(walletClient) : undefined),
    [walletClient]
  );
}
// App.tsx
import {
  useEthersProvider,
  useEthersSigner,
} from "./hooks.ts"; // import hooks from above file
...
const provider = useEthersProvider();
const signer = useEthersSigner();
const config: SmartAccountConfig = {
  chainId,
  provider,
  owner: signer,
  bundlerUrl: "<bundler URL>",
  paymasterUrl: "<paymaster URL>"
};
const smartAccount = new SmartAccount(config);