Socket
Book a DemoInstallSign in
Socket

@ccamp/lib

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ccamp/lib

The javascript library for interacting with the ccamp

1.11.3
latest
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

CCAMPClient Documentation

The CCAMPClient is a TypeScript class designed to streamline interactions with various CCAMP canisters, including the Remittance canister, the Data collection canister, and the Protocol data collection canister. This class enables users to engage with Data Collection, Protocol Data Collection, and Remittance canisters on the IC network using Ethereum-based private keys.

Table of Contents

  • Installation
  • Usage
    • Constructor
    • getCanisterInstance
    • approveLockerContract
    • deposit
    • withdraw

Installation

Ensure you have the necessary dependencies installed:

npm install

Usage

The CCAMPClient is versatile, supporting both development and production environments. This flexibility is achieved by providing an optional options parameter to the constructor. The env property within this parameter allows users to specify the environment, determining which network the CCAMP canisters will be instantiated on. By default, the environment is set to prod for production, but users can easily switch to local for development. Example usage:

Constructor

constructor(ethereumPrivateKey: string, options?: { env?: Environment })
  • ethereumPrivateKey: Private key for the Ethereum account.
  • options.env: Environment (default is ENV.prod). Options: prod or local.
const ccampClient = new CCAMPClient('your_ethereum_private_key', { env: ENV.prod });

getCanisterInstance

getCanisterInstance(canisterType: CanisterType, overrides?: { canisterId?: string }): any
  • canisterType: Type of the IC canister (e.g., CANISTER_TYPES.DATA_COLLECTION).
  • overrides.canisterId: Override the default canister ID.
const dataCollectionCanister = ccampClient.getCanisterInstance(CANISTER_TYPES.DATA_COLLECTION);

approveLockerContract

Approve the locker contract to spend tokens on your behalf.

approveLockerContract(erc20TokenAddress: string, amountToApprove: ethers.BigNumberish, signer: ethers.Wallet, overrides?: { lockerContract?: string }): Promise<any>
  • erc20TokenAddress: Ethereum address of the ERC20 token.
  • amountToApprove: Amount to approve for the locker contract.
  • signer: Ethereum Wallet signer.
  • overrides.lockerContract: Override the default locker contract address.
await ccampClient.approveLockerContract('token_address', amount, signer);

deposit

Deposit funds into the protocol.

deposit(amount: ethers.BigNumberish, tokenAddress: string, signer: ethers.Wallet, overrides?: { lockerContract?: string; dcCanister?: string }): Promise<Transaction>
  • amount: Amount to deposit.
  • tokenAddress: Ethereum address of the token.
  • signer: Ethereum Wallet signer.
  • overrides.lockerContract: Override the default locker contract address.
  • overrides.dcCanister: Override the default data collection canister ID.
await ccampClient.deposit(amount, 'token_address', signer);

withdraw

Withdraw funds from the network.

withdraw(amount: ethers.BigNumberish, tokenAddress: string, chain: string ,signer: ethers.Wallet, overrides?: { lockerContract?: string; dcCanister?: string; remittanceCanister?: string }): Promise<Transaction>
  • amount: Amount to withdraw.
  • tokenAddress: Ethereum address of the token.
  • chain: Blockchain identifier.
  • signer: Ethereum Wallet signer.
  • overrides.lockerContract: Override the default locker contract address.
  • overrides.dcCanister: Override the default data collection canister ID.
  • overrides.remittanceCanister: Override the default remittance canister ID.
await ccampClient.withdraw(amount, 'token_address', signer, 'ethereum');

Types

Below are the types used in the CCAMPClient class:

Environment

export type Environment = 'prod' | 'dev';
  • prod: Production environment.
  • dev: Development environment.

CanisterType

export type CanisterType = 'dataCollection' | 'protocolDataCollection' | 'remittance';
  • dataCollection: Type for Data Collection canister.
  • protocolDataCollection: Type for Protocol Data Collection canister.
  • remittance: Type for Remittance canister.

Canister Instances

export type DataCollectionCanister;
export type ProtocolDataCollectionCanister;
export type RemittanceCanister;
  • DataCollectionCanister: Type for Data Collection canister instance.
  • ProtocolDataCollectionCanister: Type for Protocol Data Collection canister instance.
  • RemittanceCanister: Type for Remittance canister instance.

These types are integral to the proper functioning of the CCAMPClient.getCanisterInstance method, providing a more specific interface for the different canister types.

This documentation provides a brief overview of the CCAMPClient class and its methods. Refer to the inline comments in the code for more detailed explanations of each method and its parameters.

FAQs

Package last updated on 08 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.