Skip to content

Commit

Permalink
#67 - Makes IPFS persistence optional (#68)
Browse files Browse the repository at this point in the history
* makes IPFS persistence optional

* moves fee inside condition
  • Loading branch information
koshikraj authored Apr 27, 2022
1 parent 762c3cb commit 623aa50
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 51 deletions.
103 changes: 69 additions & 34 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@safient/core",
"version": "0.1.17-alpha",
"version": "0.1.18-alpha",
"description": "JavaScript SDK to manage safes and interact with Safient protocol.",
"keywords": [
"Web3",
Expand Down Expand Up @@ -37,7 +37,7 @@
"@ceramicstudio/idx": "^0.12.0",
"@ceramicstudio/idx-tools": "^0.10.0",
"@ethersproject/providers": "^5.4.4",
"@safient/contracts": "^0.1.15-alpha",
"@safient/contracts": "^0.1.16-alpha",
"@stablelib/random": "^1.0.1",
"@textile/hub": "^6.3.1",
"bcryptjs": "^2.4.3",
Expand Down
29 changes: 15 additions & 14 deletions src/SafientCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ export class SafientCore {
claimType: number,
signalingPeriod: number,
dDay: number,
beneficiary: { email?: string, did?: string}
beneficiary: { email?: string, did?: string},
persist: boolean = false,
): Promise<SafientResponse<EventResponse>> => {
try {

Expand Down Expand Up @@ -326,7 +327,8 @@ export class SafientCore {
timeStamp: Date.now()
}

const safeLink = await createIpfsSafeLink(safeLinkData);
const safeLink = persist ? await createIpfsSafeLink(safeLinkData) : null;


const data: SafeCreation = {
safeName: safeName,
Expand All @@ -351,15 +353,13 @@ export class SafientCore {
const safe: string[] = await createSafe(data);

if (onChain === true) {
const metaDataEvidenceUri: string = await createMetaData(
'0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512',
creatorUser[0].userAddress
);

const arbitrationFee: number = await this.arbitrator.getArbitrationFee();



if (claimType === Types.ClaimType.ArbitrationBased) {
const arbitrationFee: number = await this.arbitrator.getArbitrationFee();
const metaDataEvidenceUri: string = await createMetaData(
'0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512',
creatorUser[0].userAddress
);
const totalFee: string = String(ethers.utils.parseEther(String(arbitrationFee + this.guardianFee)));
const tx: TransactionResponse = await this.contract.createSafe(
beneficiaryUser!.userAddress,
Expand Down Expand Up @@ -554,12 +554,13 @@ export class SafientCore {
}

if (safe.onChain === false) {
const metaDataEvidenceUri: string = await createMetaData(
'0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512',
creatorUser[0].userAddress
);


if (safe.claimType === Types.ClaimType.ArbitrationBased) {
const metaDataEvidenceUri: string = await createMetaData(
'0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512',
creatorUser[0].userAddress
);
if (safe.stage === SafeStages.ACTIVE) {
const arbitrationFee: number = await this.arbitrator.getArbitrationFee();
const totalFee: string = String(ethers.utils.parseEther(String(arbitrationFee + this.guardianFee)));
Expand Down
2 changes: 1 addition & 1 deletion src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export type SafeCreation = {
dDay: number,
timeStamp: number,
proofSubmission: boolean,
cid: string
cid: string | null
};


Expand Down

0 comments on commit 623aa50

Please sign in to comment.