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

completing artifacts from artifacts folder in deployments #204

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
22 changes: 22 additions & 0 deletions docs/sdk/lib-ethers.populatableethersliquity.findhints.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@sovryn-zero/lib-ethers](./lib-ethers.md) &gt; [PopulatableEthersLiquity](./lib-ethers.populatableethersliquity.md) &gt; [findHints](./lib-ethers.populatableethersliquity.findhints.md)

## PopulatableEthersLiquity.findHints() method

<b>Signature:</b>

```typescript
findHints(trove: Trove): Promise<[string, string]>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| trove | [Trove](./lib-base.trove.md) | |

<b>Returns:</b>

Promise&lt;\[string, string\]&gt;

1 change: 1 addition & 0 deletions docs/sdk/lib-ethers.populatableethersliquity.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export declare class PopulatableEthersLiquity implements PopulatableLiquity<Ethe
| [closeTrove(overrides)](./lib-ethers.populatableethersliquity.closetrove.md) | | Close existing Trove by repaying all debt and withdrawing all collateral. |
| [depositCollateral(amount, overrides)](./lib-ethers.populatableethersliquity.depositcollateral.md) | | Adjust existing Trove by depositing more collateral. |
| [depositZUSDInStabilityPool(amount, frontendTag, overrides)](./lib-ethers.populatableethersliquity.depositzusdinstabilitypool.md) | | Make a new Stability Deposit, or top up existing one. |
| [findHints(trove)](./lib-ethers.populatableethersliquity.findhints.md) | | |
| [liquidate(address, overrides)](./lib-ethers.populatableethersliquity.liquidate.md) | | Liquidate one or more undercollateralized Troves. |
| [liquidateUpTo(maximumNumberOfTrovesToLiquidate, overrides)](./lib-ethers.populatableethersliquity.liquidateupto.md) | | Liquidate the least collateralized Troves up to a maximum number. |
| [openNueTrove(params, maxBorrowingRate, overrides)](./lib-ethers.populatableethersliquity.opennuetrove.md) | | |
Expand Down
12 changes: 12 additions & 0 deletions packages/contracts/deployment/deployments/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## SCRIPTS TO HELP LOADING DEPLOYED ARTIFACTS

Scripts that helps to load callable contract objects:

### FIRST: Execute loadMainnetArtifacts

It keeps pre-existent artifacts in the `rskSovrynMainnet` folder. If there is any upgrade, the artifacts can be erased, then execute: `$ node loadMainnetArtifacts`

#### THEN: Execute loadTestnetArtifacts

It takes from `artifacts` folder or from `rskSovrynMainnet` folder the abis of contracts and from `testnetAddressListQA.json`, the addresses.
To execute the loading after any fresh upgrade: `$ node loadTestnetArtifacts`
91 changes: 91 additions & 0 deletions packages/contracts/deployment/deployments/loadMainnetArtifacts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
const fs = require('fs');
const path = require('path');

const files = fs.readdirSync('./rskSovrynMainnet');
const alphas = require('./mainnetAddressListQA.json');
const proxy = require('./rskSovrynMainnet/GeneralZero_Proxy.json')

for(let i = 0; i < Object.keys(alphas).length; i++){

let alpha = Object.keys(alphas)[i];
let found = false;

for(let j = 0; j < files.length; j++){

let file = files[j];
let fileExt = path.extname(file);
if (fileExt == '.json') {

let fileName = path.basename(file, '.json');
if(fileName.includes(alpha)){

let subStrProxy = 'Proxy';
let subStrImpl = 'Impl';
let subStrSpecial = 'RedeemOps';
if(fileName.includes(subStrProxy) ||
(!fileName.includes(subStrImpl) && !fileName.includes(subStrSpecial))){

found = true;
console.log(fileName);

} else {

console.log(' untouched ' + fileName);

}

}

}

}

if(!found){

let artifactPath =
alpha == "CommunityIssuance" ?
path.join('../../artifacts/contracts/ZERO/', alpha + '.sol/', alpha + '.json') :
path.join('../../artifacts/contracts/', alpha + '.sol/', alpha + '.json');

if (fs.existsSync(artifactPath)) {

let artifactProxy = proxy;
let artifactLogicProxy = require(artifactPath);

let artifactProxyPath = path.join('./rskSovrynMainnet/', alpha + '_Proxy.json');
let artifactLogicProxyPath = path.join('./rskSovrynMainnet/', alpha + '.json');

artifactProxy.address = artifactLogicProxy.address = Object.values(alphas)[i];

let entriesArtifactProxy = Object.entries(artifactProxy);
let entriesArtifactLogicProxy = Object.entries(artifactLogicProxy);

entriesArtifactProxy.unshift(
entriesArtifactProxy.splice(
entriesArtifactProxy.findIndex(
([key, value]) => key === 'address'), 1)[0]);

entriesArtifactLogicProxy.unshift(
entriesArtifactLogicProxy.splice(
entriesArtifactLogicProxy.findIndex(
([key, value]) => key === 'address'), 1)[0]);

let reorderedArtifactProxy = Object.fromEntries(entriesArtifactProxy);
let reorderedArtifactLogicProxy = Object.fromEntries(entriesArtifactLogicProxy);

fs.writeFileSync(artifactProxyPath, JSON.stringify(reorderedArtifactProxy, null, 2), {flag: 'w+'});
fs.writeFileSync(artifactLogicProxyPath, JSON.stringify(reorderedArtifactLogicProxy, null, 2), {flag: 'w+'});

console.log(alpha);
console.log(alpha + '_Proxy.json');

} else {

console.log(alpha + ' not available');
console.log(alpha + '_Proxy.json not available');

}

}

}
150 changes: 150 additions & 0 deletions packages/contracts/deployment/deployments/loadTestnetArtifacts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
const fs = require('fs');
const path = require('path');

const filesInMainnet = fs.readdirSync('./rskSovrynMainnet');
const filesInTestnet = fs.readdirSync('./rskSovrynTestnet');
const alphas = require('./testnetAddressListQA.json');
const proxy = require('./rskSovrynTestnet/GeneralZero_Proxy.json')

for(let i = 0; i < Object.keys(alphas).length; i++){

let alpha = Object.keys(alphas)[i];
var foundInMainnet = false;
let foundInTestnet = false;

for(let j = 0; j < filesInTestnet.length; j++){

let testnetFile = filesInTestnet[j];
let fileExt = path.extname(testnetFile);

if (fileExt == '.json') {

let fileName = path.basename(testnetFile, '.json');

if(fileName.includes(alpha)){

let subStrProxy = 'Proxy';
if(fileName.includes(subStrProxy)){

foundInTestnet = true;
console.log(fileName);

} else {

let subStrImpl = 'Impl';
let subStrRedeemOps = 'RedeemOps';
if(!fileName.includes(subStrImpl)&&
!fileName.includes(subStrRedeemOps)){

foundInTestnet = true;
console.log(fileName);

} else {
console.log(' untouched ' + fileName);
}

}

}

}

}

if(!foundInTestnet) {

var artifactPath;

for(let k = 0; k < filesInMainnet.length; k++){

let mainnetFile = filesInMainnet[k];
let fileExt = path.extname(mainnetFile);

if (fileExt == '.json') {

let fileName = path.basename(mainnetFile, '.json');

if(fileName.includes(alpha)){

let subStrProxy = 'Proxy';
let subStrImpl = 'Impl';
let subStrRedeemOps = 'RedeemOps';
if(fileName.includes(subStrProxy)||
(!fileName.includes(subStrImpl)&&
!fileName.includes(subStrRedeemOps))
){

foundInMainnet = true;
artifactPath = './rskSovrynMainnet/' + fileName + '.json';
let artifact = require(artifactPath);
let artifactTestnetPath = './rskSovrynTestnet/' + artifactPath.slice(19);
artifact.address = Object.values(alphas)[i];
let entriesArtifact = Object.entries(artifact);
entriesArtifact.unshift(
entriesArtifact.splice(
entriesArtifact.findIndex(
([key, value]) => key === 'address'), 1)[0]);
let reorderedArtifact = Object.fromEntries(entriesArtifact);
fs.writeFileSync(artifactTestnetPath, JSON.stringify(reorderedArtifact, null, 2), {flag: 'w+'});
console.log(fileName);

} else {
console.log(' untouched ' + fileName);
}

}

}

}

}

if(!foundInMainnet && !foundInTestnet) {

let artifactPath = alpha == "CommunityIssuance" ?
path.join('../../artifacts/contracts/ZERO/', alpha + '.sol/', alpha + '.json') :
path.join('../../artifacts/contracts/', alpha + '.sol/', alpha + '.json');

if (fs.existsSync(artifactPath)) {

let artifactProxy = proxy;
let artifactLogicProxy = require(artifactPath);

let artifactProxyPath = path.join('./rskSovrynTestnet/', alpha + '_Proxy.json');
let artifactLogicProxyPath = path.join('./rskSovrynTestnet/', alpha + '.json');

artifactProxy.address = artifactLogicProxy.address = Object.values(alphas)[i];

let entriesArtifactProxy = Object.entries(artifactProxy);
let entriesArtifactLogicProxy = Object.entries(artifactLogicProxy);

entriesArtifactProxy.unshift(
entriesArtifactProxy.splice(
entriesArtifactProxy.findIndex(
([key, value]) => key === 'address'), 1)[0]);

entriesArtifactLogicProxy.unshift(
entriesArtifactLogicProxy.splice(
entriesArtifactLogicProxy.findIndex(
([key, value]) => key === 'address'), 1)[0]);

let reorderedArtifactProxy = Object.fromEntries(entriesArtifactProxy);
let reorderedArtifactLogicProxy = Object.fromEntries(entriesArtifactLogicProxy);

fs.writeFileSync(artifactProxyPath, JSON.stringify(reorderedArtifactProxy, null, 2), {flag: 'w+'});
fs.writeFileSync(artifactLogicProxyPath, JSON.stringify(reorderedArtifactLogicProxy, null, 2), {flag: 'w+'});

console.log(alpha);
console.log(alpha + '_Proxy.json');

} else {

console.log(alpha + ' not available');
console.log(alpha + '_Proxy.json not available');

}

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"ActivePool": "0xf294ea272d6f8FedC08aCf8E93ff50fe99E1f7E8",
"BorrowerOperations": "0x5B9dB4B8bdeF3e57323187a9AC2639C5DEe5FD39",
"TroveManager": "0x82B09695ee4F214f3A0803683C4AaEc332E4E0a3",
"CollSurplusPool": "0x310ec7Fe6e4943DA773De8948255E37CC45e34bb",
"CommunityIssuance": "0x9398131Dee201c7B530c5E3bAeeEB2e5B10F231c",
"DefaultPool": "0xcdbA14ca707B99afb8CA93E178aD614Db422a030",
"HintHelpers": "0x1D7DaC5a63A35540bE9e031212ecf39584AE5595",
"PriceFeed": "0x6D1d9574d67e04cf35Fa1d916F763eDDae03b75d",
"MoCMedianizer": "0x87d7fd2e0baac4ae61cc7e728647e2f6d80118a0",
"RskOracle": "0x46cfec2cd43fc514eb1bec2868027dedf15f1d08",
"SortedTroves": "0xdeEB95480B94f9395514Fe35CAF692A1C788DfE9",
"StabilityPool": "0xd46C0225D1331B46700d64fF8c906709D15C9202",
"LiquityBaseParams": "0xf8B04A36c36d5DbD1a9Fe7B74897c609d6A17aa2",
"FeeDistributor": "0x1261d5872d56e2Ab61B3C68451D015b752105027",
"ZUSDToken": "0xdB107FA69E33f05180a4C2cE9c2E7CB481645C2d",
"MultiTroveGetter": "0xF265a169191348c02829B62650B025BdeAf00AE4"
}
Loading