Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let there be docs 📖! #16

Merged
merged 16 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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