UNPKG

@safient/contracts

Version:

JavaScript SDK to manage and interact with the safe claims on Safient protocol.

149 lines 7.02 kB
import { Claim, ClaimStatus, ClaimType, RecoveryProof, Safe, Signer } from '../types/Types'; import { TransactionResponse } from '@ethersproject/providers'; import { Bytes } from 'ethers'; /** * This class implements an interface for the safient protocol's contract interaction allowing * users to create and interact with the safes and the claims */ export declare class SafientMain { /** @ignore */ private signer; /** @ignore */ private safientMainABI; /** @ignore */ private safientMainAddress; /** @ignore */ private logger; /** @ignore */ private tx; /** @ignore */ private contract; /**@ignore */ private provider; /** * Arbitrator Constructor * @param signer Signer object * @param chainId Provider chainId */ constructor(signer: Signer, chainId: number); /** * This function creates a new safe by the safe creator * @param beneficiaryAddress Address of the beneficiary who can claim to inherit this safe * @param safeId Id of the safe * @param claimType Type of claim the inheritor has go through * @param claimPeriod The value use to vaiditate based on claimType after which the beneficiary can directly claim the safe * @param metaevidenceURI IPFS URI pointing to the metaevidence related to general agreement, arbitration details, actors involved etc * @param value Safe maintanence fee in Gwei, minimum arbitration fee required * @returns A transaction response */ createSafe: (beneficiaryAddress: string, safeId: string, claimType: ClaimType, claimPeriod: number, metaevidenceURI: string, value: string) => Promise<TransactionResponse>; /** * This function creates a new safe by the safe beneficiary * @param creatorAddress Address of the creator who created the safe offchain * @param safeId Id of the safe * @param claimType Type of claim the inheritor has go through * @param claimPeriod The value use to vaiditate based on claimType after which the beneficiary can directly claim the safe * @param metaevidenceURI IPFS URI pointing to the metaevidence related to general agreement, arbitration details, actors involved etc * @param value Safe maintanence fee in Gwei, minimum arbitration fee required * @returns A transaction response */ syncSafe: (creatorAddress: string, safeId: string, claimType: ClaimType, claimPeriod: number, metaevidenceURI: string, value: string) => Promise<TransactionResponse>; /** * This function creates a claim on a safe * @param safeId Id of the safe * @param evidenceURI IPFS URI pointing to the evidence submitted by the claim creator * @returns A transaction response */ createClaim: (safeId: string, evidenceURI: string) => Promise<TransactionResponse>; /** * This function deposits funds into a safe * @param safeId Id of the safe * @param value Funds in Gwei * @returns A transaction response */ depositFunds: (safeId: string, value: string) => Promise<TransactionResponse>; /** * This function withdraws funds from a safe, only safe's current owner can execute this * @param safeId Id of the safe * @returns A transaction response */ withdrawFunds: (safeId: string) => Promise<TransactionResponse>; /** * This function submits the evidence supporting a claim, only claim creator can execute this * @param disputeId Id of the dispute representing the claim * @param evidenceURI IPFS URI pointing to the evidence submitted by the claim creator * @returns A transaction response */ submitEvidence: (disputeId: number, evidenceURI: string) => Promise<TransactionResponse>; /** * This function signals a safe in response to the claim made on that safe * @param safeId Id of the safe * @returns A transaction response */ sendSignal: (safeId: string) => Promise<TransactionResponse>; /** * This function returns the status (0 - Active, 1 - Passed, 2 - Failed or 3 - Refused To Arbitrate) of a claim by it's id * @param safeId Id of the safe * @param claimId Id of the claim * @returns The status of the claim */ getClaimStatus: (safeId: string, claimId: number) => Promise<ClaimStatus>; /** * This function returns a safe by it's id * @param safeId Id of the safe * @returns The Safe object containing safe data */ getSafeBySafeId: (safeId: string) => Promise<Safe>; /** * This function returns a claim by it's id * @param claimId Id of the claim * @returns The Claim object containing claim data */ getClaimByClaimId: (claimId: number) => Promise<Claim>; /** * This function returns the total number of safes created on the SafientMain contract * @returns The total number of safes created on the SafientMain contract */ getTotalNumberOfSafes: () => Promise<number>; /** * This function returns the total number of claims created on the SafientMain contract * @returns The total number of claims created on the SafientMain contract */ getTotalNumberOfClaims: () => Promise<number>; /** * This function returns the balance of the SafientMain contract * @returns The balance of SafientMain contract in ETH */ getContractBalance: () => Promise<number>; /** * This function submits the guardian proof * @param message Message generated during safe creation, also signed by the safe creator * @param signature Signature of the message signed by the creator * @param guardianProof Object containing guardian address and his secret * @param secrets Array of all the secrets of all the guardians, for cross verification * @param safeId Id of the safe * @returns If the guardian proof was true or false */ guardianProof: (message: string, signature: Bytes, guardianProof: RecoveryProof[], secrets: string[], safeId: string) => Promise<TransactionResponse>; /** * This function allows the guardians to claim their rewards * @param funds Total funds need to be claimed in ETH * @returns A transaction response */ claimRewards: (funds: number) => Promise<TransactionResponse>; /** * This function returns the total guardian reward balance of a guardian * @param address The address of the guardian * @returns The total guardian reward balance in ETH */ getGuardianRewards: (address: string) => Promise<number>; /** * This function updates the D-Day of a safe * @param safeId Id of the safe * @param dDay The timestamp in unix epoch milliseconds after which the beneficiary can directly claim the safe * @returns A transaction response */ updateDDay: (safeId: string, dDay: number) => Promise<TransactionResponse>; updateEDay: (safeId: string, eDay: number) => Promise<TransactionResponse>; } //# sourceMappingURL=SafientMain.d.ts.map