@human-protocol/sdk 1.0.26 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -5
- package/src/job.ts +6 -3
- package/src/utils.ts +6 -5
- package/test/job.test.ts +1 -1
- package/test/utils/constants.ts +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@human-protocol/sdk",
|
|
3
3
|
"description": "Human Protocol SDK",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.1.1",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
7
7
|
"dist",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"clean": "rm -rf ./dist",
|
|
15
15
|
"build": "npm run clean && tsc",
|
|
16
16
|
"prepublish": "npm run build",
|
|
17
|
-
"test": "concurrently -k -s first -g --hide 0 \"yarn workspace @human-protocol/core local\" \"sleep
|
|
17
|
+
"test": "concurrently -k -s first -g --hide 0 \"yarn workspace @human-protocol/core local\" \"sleep 10 && jest --runInBand\"",
|
|
18
18
|
"lint": "eslint .",
|
|
19
19
|
"lint:fix": "eslint . --fix",
|
|
20
20
|
"format": "prettier --write '**/*.{ts,json}'"
|
|
@@ -45,8 +45,5 @@
|
|
|
45
45
|
"ethers": "^5.7.2",
|
|
46
46
|
"secp256k1": "^4.0.3",
|
|
47
47
|
"winston": "^3.8.2"
|
|
48
|
-
},
|
|
49
|
-
"peerDependencies": {
|
|
50
|
-
"@human-protocol/core": "^1.0.12"
|
|
51
48
|
}
|
|
52
49
|
}
|
package/src/job.ts
CHANGED
|
@@ -104,7 +104,7 @@ export class Job {
|
|
|
104
104
|
alchemy: alchemyKey,
|
|
105
105
|
infura: infuraKey,
|
|
106
106
|
})
|
|
107
|
-
: new ethers.providers.JsonRpcProvider();
|
|
107
|
+
: new ethers.providers.JsonRpcProvider('http://127.0.0.1:8545');
|
|
108
108
|
|
|
109
109
|
this.providerData = {
|
|
110
110
|
provider,
|
|
@@ -191,7 +191,6 @@ export class Job {
|
|
|
191
191
|
|
|
192
192
|
this._logger.info('Deploying escrow factory...');
|
|
193
193
|
this.contractData.factory = await deployEscrowFactory(
|
|
194
|
-
this.contractData.hmTokenAddr,
|
|
195
194
|
this.contractData.stakingAddr,
|
|
196
195
|
this.providerData?.gasPayer
|
|
197
196
|
);
|
|
@@ -317,6 +316,7 @@ export class Job {
|
|
|
317
316
|
|
|
318
317
|
try {
|
|
319
318
|
const txReceipt = await this.contractData?.factory?.createEscrow(
|
|
319
|
+
this.contractData.hmTokenAddr,
|
|
320
320
|
this.providerData?.trustedHandlers?.map(
|
|
321
321
|
(trustedHandler) => trustedHandler.address
|
|
322
322
|
) || []
|
|
@@ -385,6 +385,8 @@ export class Job {
|
|
|
385
385
|
this.manifestData?.manifest?.reputation_oracle_addr || '';
|
|
386
386
|
const recordingOracleAddr =
|
|
387
387
|
this.manifestData?.manifest?.recording_oracle_addr || '';
|
|
388
|
+
const requestedSolutions =
|
|
389
|
+
this.manifestData?.manifest?.job_total_tasks || 0;
|
|
388
390
|
|
|
389
391
|
this._logger.info(
|
|
390
392
|
`Transferring ${this.amount} HMT to ${this.contractData.escrow.address}...`
|
|
@@ -438,7 +440,8 @@ export class Job {
|
|
|
438
440
|
reputationOracleStake,
|
|
439
441
|
recordingOracleStake,
|
|
440
442
|
this.manifestData?.manifestlink?.url,
|
|
441
|
-
this.manifestData?.manifestlink?.hash
|
|
443
|
+
this.manifestData?.manifestlink?.hash,
|
|
444
|
+
requestedSolutions
|
|
442
445
|
);
|
|
443
446
|
|
|
444
447
|
if (!contractSetup) {
|
package/src/utils.ts
CHANGED
|
@@ -34,19 +34,18 @@ export const getHmToken = async (
|
|
|
34
34
|
/**
|
|
35
35
|
* **Deploy EscrowFactory contract**
|
|
36
36
|
*
|
|
37
|
-
* @param {string} hmTokenAddr HMToken address
|
|
38
37
|
* @param {string} stakingAddr Staking address
|
|
39
38
|
* @param {ethers.Signer | undefined} signer Deployer signer
|
|
40
39
|
* @returns {Promise<EscrowFactory>} Deployed contract instance
|
|
41
40
|
*/
|
|
42
41
|
export const deployEscrowFactory = async (
|
|
43
|
-
hmTokenAddr: string,
|
|
44
42
|
stakingAddr: string,
|
|
45
43
|
signer?: ethers.Signer
|
|
46
44
|
): Promise<EscrowFactory> => {
|
|
47
45
|
const factory = new EscrowFactory__factory(signer);
|
|
48
46
|
|
|
49
|
-
const contract = await factory.deploy(
|
|
47
|
+
const contract = await factory.deploy();
|
|
48
|
+
await contract.initialize(stakingAddr);
|
|
50
49
|
|
|
51
50
|
return contract;
|
|
52
51
|
};
|
|
@@ -103,7 +102,8 @@ export const deployStaking = async (
|
|
|
103
102
|
signer?: ethers.Signer
|
|
104
103
|
): Promise<Staking> => {
|
|
105
104
|
const staking = new Staking__factory(signer);
|
|
106
|
-
const contract = await staking.deploy(
|
|
105
|
+
const contract = await staking.deploy();
|
|
106
|
+
await contract.initialize(hmTokenAddr, minimumStake, lockPeriod);
|
|
107
107
|
|
|
108
108
|
return contract;
|
|
109
109
|
};
|
|
@@ -142,7 +142,8 @@ export const deployRewardPool = async (
|
|
|
142
142
|
signer?: ethers.Signer
|
|
143
143
|
): Promise<RewardPool> => {
|
|
144
144
|
const rewardPool = new RewardPool__factory(signer);
|
|
145
|
-
const contract = await rewardPool.deploy(
|
|
145
|
+
const contract = await rewardPool.deploy();
|
|
146
|
+
await contract.initialize(hmTokenAddr, stakingAddr, fee);
|
|
146
147
|
|
|
147
148
|
return contract;
|
|
148
149
|
};
|
package/test/job.test.ts
CHANGED
package/test/utils/constants.ts
CHANGED
|
@@ -2,7 +2,7 @@ export const DEFAULT_HMTOKEN_ADDR =
|
|
|
2
2
|
'0x5FbDB2315678afecb367f032d93F642f64180aa3';
|
|
3
3
|
|
|
4
4
|
export const DEFAULT_STAKING_ADDR =
|
|
5
|
-
'
|
|
5
|
+
'0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0';
|
|
6
6
|
|
|
7
7
|
export const DEFAULT_GAS_PAYER_ADDR =
|
|
8
8
|
'0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266';
|