SDK
Smart Contract Linear Vesting TypeScript SDK
Smart Contract Linear Vesting TypeScript Package
Install dependencies
Install dependencies with npm:
Write your code
Make necessary changes in package.json (name, version, description, keywords, author, homepage and other URLs).
Write your code in src folder, and unit test in test folder, replacing the original files there.
The VS Code shortcuts for formatting of a code file are: Shift + Alt + F (Windows); Shift + Option (Alt) + F (MacOS); Ctrl + Shift + I (Linux).
Change code linting and formatting settings in .prettierrc.js if you want.
Test
Test your code with Jest framework:
Note: Example TypeScript Package uses husky, pinst and commitlint to automatically execute test and lint commit message before every commit.
Build
Build production (distribution) files in your dist folder:
It generates CommonJS (in dist/cjs folder), ES Modules (in dist/esm folder), bundled and minified UMD (in dist/umd folder), as well as TypeScript declaration files (in dist/types folder).
Try it before publishing
Run:
npm link will create a symlink in the global folder, which may be {prefix}/lib/node_modules/smart-contract-linear-vesting or C:\Users<username>\AppData\Roaming\npm\node_modules\smart-contract-linear-vesting.
Create an empty folder elsewhere, you don't even need to npm init
(to generate package.json). Open the folder with VS Code, open a terminal and just run:
Prepare to publish
Create an npm account.
API doc:
Functions:
handleWeb3Provider: () => Promise;
handleGetDetailInfoAddress: (pool: string, account: string) => Promise<{ address: string; amount: number; claimed: number; claimable: number; remain: number; } | null>;
handleGetErc20Balance: (account: string, token: string) => Promise;
handleClaim: (address?: string) => Promise;
handleChangeStakeholder: (prevStakeholder: string, newStakeholder: string, address?: string) => Promise;
handleApproveStakeholders: (poolAddress: string, token?: string, amount?: number) => Promise;
handleAddStakeholders: (poolAddress: string, amountList?: never[]) => Promise;
handleCreatePool: (name: string, token: string, start: number, duration: number) => Promise;
handleTransferOwnership: (poolAddress: string, valueAddress: string) => Promise;
handleAddManager: (poolAddress: string, token: string, itemManager: string) => Promise;
handleRemoveManager: (poolAddress: string, token: string, itemManager: string) => Promise;
Using:
Last updated