Skip to content

Commit

Permalink
Let there be docs 📖! (#16)
Browse files Browse the repository at this point in the history
* added more tests; realigned the jest config

* increased coverage for profile/index.ts

* added tests for all functions in profile class

* added tests for disputes class

* removed extra comments and only

* added ci.yml

* added tests for Escrow class

* added tests for platform and proposals

* added tests for escrow services and utils

* removed extra log

* added specs for client main file and reviews

* added typedoc

* added docs to gitignore

* added a few more tsdoc tags

* added docs for all the sub-domains
  • Loading branch information
pranav-singhal authored Dec 18, 2023
1 parent 96400f7 commit 592176f
Show file tree
Hide file tree
Showing 18 changed files with 443 additions and 26 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ build
# client
dist

# docs
docs

# misc
.DS_Store
*.pem
Expand Down
78 changes: 77 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
{
"private": true,
"workspaces": [
"apps/*",
"packages/*"
],
"scripts": {
"build": "turbo run build",
"dev": "turbo run dev",
"lint": "turbo run lint",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"test": "turbo test"
"test": "turbo test",
"docs": "typedoc",
"docs-all": "npm run docs --workspaces --if-present --verbose"
},
"devDependencies": {
"@types/jest": "^29.5.8",
Expand All @@ -14,14 +20,11 @@
"prettier": "^3.0.3",
"ts-jest": "^29.1.1",
"tsconfig": "*",
"turbo": "latest"
"turbo": "latest",
"typedoc": "0.25.3"
},
"name": "talentlayer-sdk",
"packageManager": "yarn@1.22.19",
"workspaces": [
"apps/*",
"packages/*"
],
"dependencies": {
"@changesets/cli": "^2.26.2"
}
Expand Down
3 changes: 2 additions & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"prepare": "npm run build",
"build": "tsup src/index.ts --format cjs,esm --dts",
"dev": "npm run build -- --watch",
"test": "jest --verbose --coverage"
"test": "jest --verbose --coverage",
"docs": "typedoc --out docs"
},
"devDependencies": {
"@turbo/gen": "^1.10.12",
Expand Down
20 changes: 17 additions & 3 deletions packages/client/src/disputes/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { parseEther, toHex, zeroAddress } from 'viem';
import { Hash, parseEther, toHex, zeroAddress } from 'viem';
import { getChainConfig } from '../config';
import GraphQLClient from '../graphql';
import { getPlatformById } from '../platform/graphql/queries';
import { NetworkEnum, TransactionHash } from '../types';
import { NetworkEnum } from '../types';
import { ViemClient } from '../viem';

/**
* Get arbitration cost. Set price of arbitration
*
* @group TalentLayerClient Modules
*/
export class Disputes {
wallet: ViemClient;
platformID: number;
Expand All @@ -22,6 +27,10 @@ export class Disputes {
this.chainId = chainId;
}

/**
* getArbitrationCost - Retrieves the current cost of arbitration. This function is useful for understanding the financial implications of initiating an arbitration process.
* @returns {Promise<any>} - Returns a Promise that resolves to the arbitration cost, typically in a numerical or string format representing the cost value.
*/
public async getArbitrationCost(): Promise<any> {
const platformResponse = await this.subgraph.get(getPlatformById(this.platformID.toString()));

Expand Down Expand Up @@ -52,7 +61,12 @@ export class Disputes {
});
}

public async setPrice(value: number | string): Promise<TransactionHash> {
/**
* setPrice - Sets the price of arbitration. This function allows for modifying the arbitration cost for the current platform
* @param {number | string} value - The new price value for arbitration, which can be specified as a number or a string representing the price.
* @returns {Promise<Hash>} - A promise that resolves to the transaction hash of the set operation.
*/
public async setPrice(value: number | string): Promise<Hash> {
const transformedPrice = parseEther(value.toString());
console.log('SDK: setting arbitration price');
const tx = await this.wallet.writeContract('talentLayerArbitrator', 'setArbitrationPrice', [
Expand Down
15 changes: 15 additions & 0 deletions packages/client/src/escrow/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,29 @@ import { calculateApprovalAmount } from '../utils/fees';
import { ViemClient } from '../viem';
import { getPaymentsByService, getProtocolAndPlatformsFees } from './graphql/queries';



/**
* Release and reimburse payments using TalentLayer escrow
*
* @group TalentLayerClient Modules
*/
export class Escrow {

/** @hidden */
graphQlClient: GraphQLClient;
/** @hidden */
ipfsClient: IPFSClient;
/** @hidden */
viemClient: ViemClient;
/** @hidden */
platformID: number;
/** @hidden */
chainId: NetworkEnum;
/** @hidden */
erc20: IERC20;

/** @hidden */
constructor(
graphQlClient: GraphQLClient,
ipfsClient: IPFSClient,
Expand Down
11 changes: 7 additions & 4 deletions packages/client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,20 @@ import { Review } from './reviews';
* Main client for interacting with the TalentLayer protocol.
*/
export class TalentLayerClient {
/** @hidden */
graphQlClient: GraphQLClient;
/** @hidden */
ipfsClient: IPFSClient;
/** @hidden */
viemClient: ViemClient;
/** @hidden */
platformID: number;
/** @hidden */
chainId: NetworkEnum;
/** @hidden */
signatureApiUrl?: string;

/**
* Initializes a new instance of the TalentLayerClient.
* @param {TalentLayerClientConfig} config - Configuration options for the client.
*/
/** @hidden */
constructor(config: TalentLayerClientConfig) {
console.log('SDK: client initialising', config);
this.platformID = config.platformId;
Expand Down
Loading

0 comments on commit 592176f

Please sign in to comment.