From bff3de04867df74cd431ccde5e885806b0d76ef7 Mon Sep 17 00:00:00 2001 From: yathishram <123yathish.r@gmail.com> Date: Tue, 12 Apr 2022 14:59:24 +0530 Subject: [PATCH 1/6] adds provider support --- src/contracts/Arbitrator.ts | 3 ++- src/contracts/SafientMain.ts | 14 ++++++++++++-- src/utils/{networks.json => networks.js} | 8 +++++++- 3 files changed, 21 insertions(+), 4 deletions(-) rename src/utils/{networks.json => networks.js} (83%) diff --git a/src/contracts/Arbitrator.ts b/src/contracts/Arbitrator.ts index a628b34..3743608 100644 --- a/src/contracts/Arbitrator.ts +++ b/src/contracts/Arbitrator.ts @@ -3,8 +3,9 @@ import { Contract } from '@ethersproject/contracts'; import { BigNumber } from '@ethersproject/bignumber'; import { formatEther } from '@ethersproject/units'; import { Logger } from '@ethersproject/logger'; -import networks from '../utils/networks.json'; +import {networks} from '../utils/networks'; import data from '../abis/AutoAppealableArbitrator.json'; +import { JsonRpcProvider } from '@ethersproject/providers'; /** * This class implements an interface to interact with the arbitrator contract diff --git a/src/contracts/SafientMain.ts b/src/contracts/SafientMain.ts index de84964..1221c1b 100644 --- a/src/contracts/SafientMain.ts +++ b/src/contracts/SafientMain.ts @@ -8,13 +8,13 @@ import { Safe, Signer, } from '../types/Types'; -import { TransactionResponse } from '@ethersproject/providers'; +import { JsonRpcProvider, TransactionResponse } from '@ethersproject/providers'; import { Contract } from '@ethersproject/contracts'; import { BigNumber } from '@ethersproject/bignumber'; import { formatEther, parseEther } from '@ethersproject/units'; import { Logger } from '@ethersproject/logger'; import { Bytes } from 'ethers'; -import networks from '../utils/networks.json'; +import {networks} from '../utils/networks'; import data from '../abis/SafientMain.json'; /** @@ -40,6 +40,9 @@ export class SafientMain { /** @ignore */ private contract: Contract; + /**@ignore */ + private provider: JsonRpcProvider + /** * Arbitrator Constructor * @param signer Signer object @@ -52,6 +55,8 @@ export class SafientMain { const network = Object.values(networks).find((network) => chainId === network.chainId); + this.provider = new JsonRpcProvider(network?.url) + network !== undefined && network.addresses.SafientMain !== '' ? (this.safientMainAddress = network.addresses.SafientMain) : this.logger.throwError(`SafientMain contract not deployed on network with chain id: ${chainId}`); @@ -80,6 +85,11 @@ export class SafientMain { value: string ): Promise => { try { + if(claimType === ClaimType.DDayBased){ + const latestBlockNumber = await this.provider.getBlockNumber(); + const latestBlock = await this.provider.getBlock(latestBlockNumber); + dDay = latestBlock.timestamp + dDay + } this.tx = await this.contract.createSafe( beneficiaryAddress, safeId, diff --git a/src/utils/networks.json b/src/utils/networks.js similarity index 83% rename from src/utils/networks.json rename to src/utils/networks.js index 4c7b654..8abe34c 100644 --- a/src/utils/networks.json +++ b/src/utils/networks.js @@ -1,6 +1,7 @@ -{ +export const networks = { "localhost": { "chainId": 31337, + "url": "http://localhost:8545", "addresses": { "AutoAppealableArbitrator": "0x5FbDB2315678afecb367f032d93F642f64180aa3", "SafientMain": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512" @@ -8,6 +9,7 @@ }, "mainnet": { "chainId": 1, + "url": "http://localhost:8545", "addresses": { "AutoAppealableArbitrator": "", "SafientMain": "" @@ -15,6 +17,7 @@ }, "rinkeby": { "chainId": 4, + "url": "http://localhost:8545", "addresses": { "AutoAppealableArbitrator": "0xf54D6b97749ECD28F9EbF836Ed9cE0C387a2f0A1", "SafientMain": "0x2fF492C5D9d071a2bed17e30418aF128f22e42fA" @@ -22,6 +25,7 @@ }, "kovan": { "chainId": 42, + "url": "http://localhost:8545", "addresses": { "AutoAppealableArbitrator": "0xf54D6b97749ECD28F9EbF836Ed9cE0C387a2f0A1", "SafientMain": "0xF88915c8762aB973b64086221cDFd20Ec104F732" @@ -29,6 +33,7 @@ }, "ropsten": { "chainId": 3, + "url": "http://localhost:8545", "addresses": { "AutoAppealableArbitrator": "0xf54D6b97749ECD28F9EbF836Ed9cE0C387a2f0A1", "SafientMain": "0xC0B0591Eac7887F443cef0f28BB818E454eD6637" @@ -36,6 +41,7 @@ }, "polygontestnet": { "chainId": 80001, + "url": "http://localhost:8545", "addresses": { "AutoAppealableArbitrator": "0xf54D6b97749ECD28F9EbF836Ed9cE0C387a2f0A1", "SafientMain": "0xccA53824ce8944a3cB7b21139bd177DEEe6e27C0" From 8c44d7cde67aa5d22cc711d2c0b731655419b57e Mon Sep 17 00:00:00 2001 From: yathishram <123yathish.r@gmail.com> Date: Tue, 12 Apr 2022 15:05:01 +0530 Subject: [PATCH 2/6] updates network URLs --- package-lock.json | 8 +++++--- src/utils/networks.js | 14 +++++++++----- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0d3ccfb..56b82a0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@safient/contracts", - "version": "0.1.13-alpha", + "version": "0.1.14-alpha", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@safient/contracts", - "version": "0.1.13-alpha", + "version": "0.1.14-alpha", "dependencies": { "@ethersproject/address": "^5.2.0", "@ethersproject/bignumber": "^5.2.0", @@ -18019,7 +18019,9 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/@typechain/ethers-v5/-/ethers-v5-2.0.0.tgz", "integrity": "sha512-0xdCkyGOzdqh4h5JSf+zoWx85IusEjDcPIwNEHP8mrWSnCae4rvrqB+/gtpdNfX7zjlFlZiMeePn2r63EI3Lrw==", - "requires": {} + "requires": { + "ethers": "^5.0.2" + } }, "@types/abstract-leveldown": { "version": "5.0.2", diff --git a/src/utils/networks.js b/src/utils/networks.js index 8abe34c..1ebf11e 100644 --- a/src/utils/networks.js +++ b/src/utils/networks.js @@ -1,3 +1,7 @@ +import dotenv from 'dotenv' +dotenv.config() + + export const networks = { "localhost": { "chainId": 31337, @@ -9,7 +13,7 @@ export const networks = { }, "mainnet": { "chainId": 1, - "url": "http://localhost:8545", + "url": `https://mainnet.infura.io/v3/${process.env.INFURA_API_KEY}`, "addresses": { "AutoAppealableArbitrator": "", "SafientMain": "" @@ -17,7 +21,7 @@ export const networks = { }, "rinkeby": { "chainId": 4, - "url": "http://localhost:8545", + "url": "", "addresses": { "AutoAppealableArbitrator": "0xf54D6b97749ECD28F9EbF836Ed9cE0C387a2f0A1", "SafientMain": "0x2fF492C5D9d071a2bed17e30418aF128f22e42fA" @@ -25,7 +29,7 @@ export const networks = { }, "kovan": { "chainId": 42, - "url": "http://localhost:8545", + "url": `https://kovan.infura.io/v3/${process.env.INFURA_API_KEY}`, "addresses": { "AutoAppealableArbitrator": "0xf54D6b97749ECD28F9EbF836Ed9cE0C387a2f0A1", "SafientMain": "0xF88915c8762aB973b64086221cDFd20Ec104F732" @@ -33,7 +37,7 @@ export const networks = { }, "ropsten": { "chainId": 3, - "url": "http://localhost:8545", + "url": "", "addresses": { "AutoAppealableArbitrator": "0xf54D6b97749ECD28F9EbF836Ed9cE0C387a2f0A1", "SafientMain": "0xC0B0591Eac7887F443cef0f28BB818E454eD6637" @@ -41,7 +45,7 @@ export const networks = { }, "polygontestnet": { "chainId": 80001, - "url": "http://localhost:8545", + "url": `https://matic-mumbai.chainstacklabs.com`, "addresses": { "AutoAppealableArbitrator": "0xf54D6b97749ECD28F9EbF836Ed9cE0C387a2f0A1", "SafientMain": "0xccA53824ce8944a3cB7b21139bd177DEEe6e27C0" From 682050a47d310af422832004c176ceecad829b67 Mon Sep 17 00:00:00 2001 From: yathishram <123yathish.r@gmail.com> Date: Wed, 13 Apr 2022 10:45:36 +0530 Subject: [PATCH 3/6] fixes minor issues --- scripts/deploy.js | 2 +- src/contracts/Arbitrator.ts | 2 +- src/contracts/SafientMain.ts | 2 +- src/utils/networks.js | 8 +++--- src/utils/networks.json | 50 ++++++++++++++++++++++++++++++++++++ 5 files changed, 58 insertions(+), 6 deletions(-) create mode 100644 src/utils/networks.json diff --git a/scripts/deploy.js b/scripts/deploy.js index ef12eb1..19cf35d 100644 --- a/scripts/deploy.js +++ b/scripts/deploy.js @@ -4,7 +4,7 @@ const fs = require('fs'); const R = require('ramda'); const chalk = require('chalk'); const { network, arbitratorContract, arbitrableContract, arbitrationFee, arbitratorAddress } = require('../constants'); -const networks = require('../src/utils/networks.json'); +const networks = require('../src/utils/networks.js'); const abiEncodeArgs = (deployed, contractArgs) => { if (!contractArgs || !deployed || !R.hasPath(['interface', 'deploy'], deployed)) return ''; diff --git a/src/contracts/Arbitrator.ts b/src/contracts/Arbitrator.ts index 3743608..bc3900d 100644 --- a/src/contracts/Arbitrator.ts +++ b/src/contracts/Arbitrator.ts @@ -3,7 +3,7 @@ import { Contract } from '@ethersproject/contracts'; import { BigNumber } from '@ethersproject/bignumber'; import { formatEther } from '@ethersproject/units'; import { Logger } from '@ethersproject/logger'; -import {networks} from '../utils/networks'; +import networks from '../utils/networks'; import data from '../abis/AutoAppealableArbitrator.json'; import { JsonRpcProvider } from '@ethersproject/providers'; diff --git a/src/contracts/SafientMain.ts b/src/contracts/SafientMain.ts index 1221c1b..af5edc4 100644 --- a/src/contracts/SafientMain.ts +++ b/src/contracts/SafientMain.ts @@ -14,7 +14,7 @@ import { BigNumber } from '@ethersproject/bignumber'; import { formatEther, parseEther } from '@ethersproject/units'; import { Logger } from '@ethersproject/logger'; import { Bytes } from 'ethers'; -import {networks} from '../utils/networks'; +import networks from '../utils/networks'; import data from '../abis/SafientMain.json'; /** diff --git a/src/utils/networks.js b/src/utils/networks.js index 1ebf11e..3c8b707 100644 --- a/src/utils/networks.js +++ b/src/utils/networks.js @@ -1,8 +1,8 @@ -import dotenv from 'dotenv' +const dotenv = require('dotenv'); dotenv.config() -export const networks = { +const networks = { "localhost": { "chainId": 31337, "url": "http://localhost:8545", @@ -51,4 +51,6 @@ export const networks = { "SafientMain": "0xccA53824ce8944a3cB7b21139bd177DEEe6e27C0" } } -} \ No newline at end of file +} + +module.exports = networks \ No newline at end of file diff --git a/src/utils/networks.json b/src/utils/networks.json new file mode 100644 index 0000000..40d766b --- /dev/null +++ b/src/utils/networks.json @@ -0,0 +1,50 @@ +{ + "localhost": { + "chainId": 31337, + "url": "http://localhost:8545", + "addresses": { + "AutoAppealableArbitrator": "0x5FbDB2315678afecb367f032d93F642f64180aa3", + "SafientMain": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512" + } + }, + "mainnet": { + "chainId": 1, + "url": "https://mainnet.infura.io/v3/undefined", + "addresses": { + "AutoAppealableArbitrator": "", + "SafientMain": "" + } + }, + "rinkeby": { + "chainId": 4, + "url": "", + "addresses": { + "AutoAppealableArbitrator": "0xf54D6b97749ECD28F9EbF836Ed9cE0C387a2f0A1", + "SafientMain": "0x2fF492C5D9d071a2bed17e30418aF128f22e42fA" + } + }, + "kovan": { + "chainId": 42, + "url": "https://kovan.infura.io/v3/undefined", + "addresses": { + "AutoAppealableArbitrator": "0xf54D6b97749ECD28F9EbF836Ed9cE0C387a2f0A1", + "SafientMain": "0xF88915c8762aB973b64086221cDFd20Ec104F732" + } + }, + "ropsten": { + "chainId": 3, + "url": "", + "addresses": { + "AutoAppealableArbitrator": "0xf54D6b97749ECD28F9EbF836Ed9cE0C387a2f0A1", + "SafientMain": "0xC0B0591Eac7887F443cef0f28BB818E454eD6637" + } + }, + "polygontestnet": { + "chainId": 80001, + "url": "https://matic-mumbai.chainstacklabs.com", + "addresses": { + "AutoAppealableArbitrator": "0xf54D6b97749ECD28F9EbF836Ed9cE0C387a2f0A1", + "SafientMain": "0xccA53824ce8944a3cB7b21139bd177DEEe6e27C0" + } + } +} \ No newline at end of file From f760d4e5c72a0914e2142e809f6455024e3186a5 Mon Sep 17 00:00:00 2001 From: yathishram <123yathish.r@gmail.com> Date: Wed, 13 Apr 2022 11:27:00 +0530 Subject: [PATCH 4/6] updates package --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7c95d89..31c78b1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@safient/contracts", - "version": "0.1.14-alpha", + "version": "0.1.15-alpha", "description": "JavaScript SDK to manage and interact with the safe claims on Safient protocol.", "keywords": [ "Web3", From b00a3b3b255394cb5e4e6de373e8ccddb8108ae3 Mon Sep 17 00:00:00 2001 From: yathishram <123yathish.r@gmail.com> Date: Wed, 13 Apr 2022 12:06:46 +0530 Subject: [PATCH 5/6] fixes minor issues --- scripts/deploy.js | 2 +- src/contracts/Arbitrator.ts | 2 +- src/contracts/SafientMain.ts | 6 ++-- src/utils/networks.js | 65 ++++++++++++------------------------ src/utils/networks.json | 10 ++---- 5 files changed, 29 insertions(+), 56 deletions(-) diff --git a/scripts/deploy.js b/scripts/deploy.js index 19cf35d..ef12eb1 100644 --- a/scripts/deploy.js +++ b/scripts/deploy.js @@ -4,7 +4,7 @@ const fs = require('fs'); const R = require('ramda'); const chalk = require('chalk'); const { network, arbitratorContract, arbitrableContract, arbitrationFee, arbitratorAddress } = require('../constants'); -const networks = require('../src/utils/networks.js'); +const networks = require('../src/utils/networks.json'); const abiEncodeArgs = (deployed, contractArgs) => { if (!contractArgs || !deployed || !R.hasPath(['interface', 'deploy'], deployed)) return ''; diff --git a/src/contracts/Arbitrator.ts b/src/contracts/Arbitrator.ts index bc3900d..1ead398 100644 --- a/src/contracts/Arbitrator.ts +++ b/src/contracts/Arbitrator.ts @@ -3,7 +3,7 @@ import { Contract } from '@ethersproject/contracts'; import { BigNumber } from '@ethersproject/bignumber'; import { formatEther } from '@ethersproject/units'; import { Logger } from '@ethersproject/logger'; -import networks from '../utils/networks'; +import networks from '../utils/networks.json'; import data from '../abis/AutoAppealableArbitrator.json'; import { JsonRpcProvider } from '@ethersproject/providers'; diff --git a/src/contracts/SafientMain.ts b/src/contracts/SafientMain.ts index af5edc4..d34c6d4 100644 --- a/src/contracts/SafientMain.ts +++ b/src/contracts/SafientMain.ts @@ -14,7 +14,8 @@ import { BigNumber } from '@ethersproject/bignumber'; import { formatEther, parseEther } from '@ethersproject/units'; import { Logger } from '@ethersproject/logger'; import { Bytes } from 'ethers'; -import networks from '../utils/networks'; +import networks from '../utils/networks.json'; +import {getNetworkUrl} from "../utils/networks" import data from '../abis/SafientMain.json'; /** @@ -55,7 +56,8 @@ export class SafientMain { const network = Object.values(networks).find((network) => chainId === network.chainId); - this.provider = new JsonRpcProvider(network?.url) + const networkUrl = getNetworkUrl(chainId) + this.provider = new JsonRpcProvider(networkUrl) network !== undefined && network.addresses.SafientMain !== '' ? (this.safientMainAddress = network.addresses.SafientMain) diff --git a/src/utils/networks.js b/src/utils/networks.js index 3c8b707..7c7743b 100644 --- a/src/utils/networks.js +++ b/src/utils/networks.js @@ -3,54 +3,31 @@ dotenv.config() const networks = { - "localhost": { - "chainId": 31337, - "url": "http://localhost:8545", - "addresses": { - "AutoAppealableArbitrator": "0x5FbDB2315678afecb367f032d93F642f64180aa3", - "SafientMain": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512" - } + localhost: { + chainId: 31337, + url: 'http://localhost:8545', }, - "mainnet": { - "chainId": 1, - "url": `https://mainnet.infura.io/v3/${process.env.INFURA_API_KEY}`, - "addresses": { - "AutoAppealableArbitrator": "", - "SafientMain": "" - } + mainnet: { + chainId: 1, + url: `https://mainnet.infura.io/v3/${process.env.INFURA_API_KEY}`, }, - "rinkeby": { - "chainId": 4, - "url": "", - "addresses": { - "AutoAppealableArbitrator": "0xf54D6b97749ECD28F9EbF836Ed9cE0C387a2f0A1", - "SafientMain": "0x2fF492C5D9d071a2bed17e30418aF128f22e42fA" - } + kovan: { + chainId: 42, + url: `https://kovan.infura.io/v3/${process.env.INFURA_API_KEY}`, + }, - "kovan": { - "chainId": 42, - "url": `https://kovan.infura.io/v3/${process.env.INFURA_API_KEY}`, - "addresses": { - "AutoAppealableArbitrator": "0xf54D6b97749ECD28F9EbF836Ed9cE0C387a2f0A1", - "SafientMain": "0xF88915c8762aB973b64086221cDFd20Ec104F732" - } + polygontestnet: { + chainId: 80001, + url: 'https://matic-mumbai.chainstacklabs.com', }, - "ropsten": { - "chainId": 3, - "url": "", - "addresses": { - "AutoAppealableArbitrator": "0xf54D6b97749ECD28F9EbF836Ed9cE0C387a2f0A1", - "SafientMain": "0xC0B0591Eac7887F443cef0f28BB818E454eD6637" - } + polygon : { + chainId: 137, + url: 'https://matic-mumbai.chainstacklabs.com', + }, - "polygontestnet": { - "chainId": 80001, - "url": `https://matic-mumbai.chainstacklabs.com`, - "addresses": { - "AutoAppealableArbitrator": "0xf54D6b97749ECD28F9EbF836Ed9cE0C387a2f0A1", - "SafientMain": "0xccA53824ce8944a3cB7b21139bd177DEEe6e27C0" - } - } } -module.exports = networks \ No newline at end of file +export const getNetworkUrl = (chainId) => { + const network = Object.values(networks).find(network => chainId === network.chainId); + return network.url +} \ No newline at end of file diff --git a/src/utils/networks.json b/src/utils/networks.json index 40d766b..8bcb64c 100644 --- a/src/utils/networks.json +++ b/src/utils/networks.json @@ -1,15 +1,13 @@ { "localhost": { "chainId": 31337, - "url": "http://localhost:8545", "addresses": { - "AutoAppealableArbitrator": "0x5FbDB2315678afecb367f032d93F642f64180aa3", - "SafientMain": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512" + "AutoAppealableArbitrator": "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9", + "SafientMain": "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9" } }, "mainnet": { "chainId": 1, - "url": "https://mainnet.infura.io/v3/undefined", "addresses": { "AutoAppealableArbitrator": "", "SafientMain": "" @@ -17,7 +15,6 @@ }, "rinkeby": { "chainId": 4, - "url": "", "addresses": { "AutoAppealableArbitrator": "0xf54D6b97749ECD28F9EbF836Ed9cE0C387a2f0A1", "SafientMain": "0x2fF492C5D9d071a2bed17e30418aF128f22e42fA" @@ -25,7 +22,6 @@ }, "kovan": { "chainId": 42, - "url": "https://kovan.infura.io/v3/undefined", "addresses": { "AutoAppealableArbitrator": "0xf54D6b97749ECD28F9EbF836Ed9cE0C387a2f0A1", "SafientMain": "0xF88915c8762aB973b64086221cDFd20Ec104F732" @@ -33,7 +29,6 @@ }, "ropsten": { "chainId": 3, - "url": "", "addresses": { "AutoAppealableArbitrator": "0xf54D6b97749ECD28F9EbF836Ed9cE0C387a2f0A1", "SafientMain": "0xC0B0591Eac7887F443cef0f28BB818E454eD6637" @@ -41,7 +36,6 @@ }, "polygontestnet": { "chainId": 80001, - "url": "https://matic-mumbai.chainstacklabs.com", "addresses": { "AutoAppealableArbitrator": "0xf54D6b97749ECD28F9EbF836Ed9cE0C387a2f0A1", "SafientMain": "0xccA53824ce8944a3cB7b21139bd177DEEe6e27C0" From beb7fd6b5d88d7fbffd0229e2e3f9d9383e43f5c Mon Sep 17 00:00:00 2001 From: yathishram <123yathish.r@gmail.com> Date: Fri, 15 Apr 2022 10:21:35 +0530 Subject: [PATCH 6/6] fixes test issues --- src/contracts/SafientMain.ts | 7 +++++++ src/utils/networks.json | 4 ++-- test-sdk/claims.js | 31 +++++++++++++------------------ 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/contracts/SafientMain.ts b/src/contracts/SafientMain.ts index d34c6d4..0c5f262 100644 --- a/src/contracts/SafientMain.ts +++ b/src/contracts/SafientMain.ts @@ -130,6 +130,13 @@ export class SafientMain { value: string ): Promise => { try { + + if(claimType === ClaimType.DDayBased){ + const latestBlockNumber = await this.provider.getBlockNumber(); + const latestBlock = await this.provider.getBlock(latestBlockNumber); + dDay = latestBlock.timestamp + dDay + } + this.tx = await this.contract.syncSafe( creatorAddress, safeId, diff --git a/src/utils/networks.json b/src/utils/networks.json index 8bcb64c..4c7b654 100644 --- a/src/utils/networks.json +++ b/src/utils/networks.json @@ -2,8 +2,8 @@ "localhost": { "chainId": 31337, "addresses": { - "AutoAppealableArbitrator": "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9", - "SafientMain": "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9" + "AutoAppealableArbitrator": "0x5FbDB2315678afecb367f032d93F642f64180aa3", + "SafientMain": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512" } }, "mainnet": { diff --git a/test-sdk/claims.js b/test-sdk/claims.js index 4289774..b460563 100644 --- a/test-sdk/claims.js +++ b/test-sdk/claims.js @@ -123,13 +123,12 @@ describe('safientMain', async () => { const safientMain1 = new SafientMain(beneficiarySigner, chainId); const beforeTotalNumberOfSafes = await safientMain1.getTotalNumberOfSafes(); - // SUCCESS : create a safe(for claimType - SignalBased & signal - won't signal) await safientMain1.syncSafe( safeCreatorAddress, // 2nd account safeId[1], Types.ClaimType.SignalBased, - 6, // 6 seconds because opting SignalBased + 10, // 6 seconds because opting SignalBased 0, '', // no metaevidence because SignalBased '' // no safe maintenence fee because SignalBased @@ -140,7 +139,7 @@ describe('safientMain', async () => { const safe = await safientMain1.getSafeBySafeId(safeId[1]); expect(safe.createdBy).to.equal(safeCreatorAddress); expect(safe.beneficiary).to.equal(beneficiaryAddress); - expect(Number(safe.signalingPeriod)).to.equal(6); // 6 seconds + expect(Number(safe.signalingPeriod)).to.equal(10); // 6 seconds expect(Number(safe.endSignalTime)).to.equal(0); expect(Number(safe.latestSignalTime)).to.equal(0); expect(Number(safe.claimType)).to.equal(0); // SignalBased @@ -151,7 +150,7 @@ describe('safientMain', async () => { beneficiaryAddress, // 2nd account safeId[2], Types.ClaimType.SignalBased, - 6, + 10, 0, '', '' @@ -175,7 +174,7 @@ describe('safientMain', async () => { // SUCCESS : create a claim (ArbitrationBased) on safeId1 const tx = await safientMain.createClaim(safeId[0], metaevidenceOrEvidenceURI); const txReceipt = await tx.wait(); - claimIdOfSafeId0 = txReceipt.events[2].args[2]; + claimIdOfSafeId0 = txReceipt.events[2].args[1]; expect(await safientMain.getTotalNumberOfClaims()).to.equal(beforeTotalNumberOfClaims + 1); @@ -192,7 +191,7 @@ describe('safientMain', async () => { // SUCCESS : create claim on safeId2 tx = await safientMain.createClaim(safeId[1], ''); txReceipt = await tx.wait(); - claimIdOfSafeId1 = txReceipt.events[0].args[2]; + claimIdOfSafeId1 = parseInt(txReceipt.events[0].args[1]._hex) const safeWithSafeId1 = await safientMain.getSafeBySafeId(safeId[1]); expect(safeWithSafeId1.claimsCount).to.equal(1); @@ -204,8 +203,7 @@ describe('safientMain', async () => { // SUCCESS : create claim on safeId3 tx = await safientMain.createClaim(safeId[2], ''); txReceipt = await tx.wait(); - claimIdOfSafeId2 = txReceipt.events[0].args[2]; - + claimIdOfSafeId2 = parseInt(txReceipt.events[0].args[1]._hex) const safeWithSafeId2 = await safientMain.getSafeBySafeId(safeId[2]); expect(safeWithSafeId2.claimsCount).to.equal(1); @@ -227,7 +225,7 @@ describe('safientMain', async () => { const mineNewBlock = new Promise((resolve, reject) => { setTimeout(() => { resolve(provider.send('evm_mine')); - }, 7000); + }, 11000); }); const result = await mineNewBlock; @@ -328,17 +326,14 @@ describe('safientMain', async () => { const safientMainBeneficiary = new SafientMain(beneficiarySigner, chainId); const safientMainAccountX = new SafientMain(accountXSigner, chainId); - const latestBlockNumber = await provider.getBlockNumber(); - const latestBlock = await provider.getBlock(latestBlockNumber); - const now = latestBlock.timestamp; // SUCCESS : create another safe with safeId4 (for claimType - DDayBased) with DDay set to 6 seconds - await safientMainCreator.createSafe(beneficiaryAddress, safeId[3], Types.ClaimType.DDayBased, 0, now + 6, '', ''); + await safientMainCreator.createSafe(beneficiaryAddress, safeId[3], Types.ClaimType.DDayBased, 0, 6, '', ''); // create a claim - before D-Day (claim should fail) const tx1 = await safientMainBeneficiary.createClaim(safeId[3], ''); const txReceipt1 = await tx1.wait(); - const claimId1 = txReceipt1.events[0].args[2]; + const claimId1 = txReceipt1.events[0].args[1]; const claimID1 = parseInt(claimId1._hex); // check claim status (DDayBased) @@ -356,7 +351,7 @@ describe('safientMain', async () => { // create a claim - before D-Day (claim should pass) const tx2 = await safientMainBeneficiary.createClaim(safeId[3], ''); const txReceipt2 = await tx2.wait(); - const claimId2 = txReceipt2.events[0].args[2]; + const claimId2 = txReceipt2.events[0].args[1]; const claimID2 = parseInt(claimId2._hex); // check claim status (DDayBased) @@ -381,7 +376,7 @@ describe('safientMain', async () => { // create a claim - before D-Day (6 seconds) (claim should fail) const tx1 = await safientMainBeneficiary.createClaim(safeId[4], ''); const txReceipt1 = await tx1.wait(); - const claimId1 = txReceipt1.events[0].args[2]; + const claimId1 = txReceipt1.events[0].args[1]; const claimID1 = parseInt(claimId1._hex); // check claim status (DDayBased) @@ -406,7 +401,7 @@ describe('safientMain', async () => { // create a claim - before D-Day (12 seconds) (claim should fail) const tx2 = await safientMainBeneficiary.createClaim(safeId[4], ''); const txReceipt2 = await tx2.wait(); - const claimId2 = txReceipt2.events[0].args[2]; + const claimId2 = txReceipt2.events[0].args[1]; const claimID2 = parseInt(claimId2._hex); // check claim status (DDayBased) @@ -424,7 +419,7 @@ describe('safientMain', async () => { // create a claim - after D-Day (10 + 2 = 12 seconds) (claim should pass) const tx3 = await safientMainBeneficiary.createClaim(safeId[4], ''); const txReceipt3 = await tx3.wait(); - const claimId3 = txReceipt3.events[0].args[2]; + const claimId3 = txReceipt3.events[0].args[1]; const claimID3 = parseInt(claimId3._hex); // check claim status (DDayBased)