Skip to content

Remove web3 from persist-tokens. #1352

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

Merged
merged 8 commits into from
Jun 29, 2021
43 changes: 8 additions & 35 deletions publish/src/commands/persist-tokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ const fs = require('fs');
const path = require('path');
const util = require('util');
const { confirmAction, ensureNetwork, loadConnections } = require('../util');
const { gray, yellow, red, green } = require('chalk');
const Web3 = require('web3');
const w3utils = require('web3-utils');
const { gray, yellow, red } = require('chalk');
const axios = require('axios');
const { schema } = require('@uniswap/token-lists');

Expand Down Expand Up @@ -39,7 +37,7 @@ const persistTokens = async ({
}) => {
ensureNetwork(network);

const { providerUrl, privateKey: envPrivateKey, explorerLinkPrefix } = loadConnections({
const { privateKey: envPrivateKey } = loadConnections({
network,
});

Expand Down Expand Up @@ -145,41 +143,16 @@ const persistTokens = async ({
process.exit(1);
}

const web3 = new Web3(new Web3.providers.HttpProvider(providerUrl));
web3.eth.accounts.wallet.add(privateKey);
const account = web3.eth.accounts.wallet[0].address;
console.log(gray(`Using account with public key ${account}`));

const ensName = 'synths.snx.eth';
const content = `ipfs://${hash}`;

if (!yes) {
try {
await confirmAction(yellow(`Do you want to set content on ${ensName} to ${content} (y/n) ?`));
} catch (err) {
console.log(gray('Operation cancelled'));
process.exit();
}
}

console.log(gray(`Using Gas Price: ${gasPrice} gwei`));
console.log(red('setContent not emitted. Not supported at the moment.'));
console.log(yellow(`Next step is to manually set content on ${ensName} to ${content} `));

try {
const { transactionHash } = await web3.eth.ens.setContenthash(ensName, content, {
from: account,
gas: Number(gasLimit),
gasPrice: w3utils.toWei(gasPrice.toString(), 'gwei'),
});

console.log(
green(
`Successfully emitted ens setContent with transaction: ${explorerLinkPrefix}/tx/${transactionHash}`
)
);
} catch (err) {
console.log(red(err));
process.exit(1);
}
/* Web3 fails to set the content via code ens.setContenthash().
setContent can be done using ethers.js CLI or we can interact with ENS contract to set the content.
TODO: implement ens.setContenthash() replacement using ethers and use it here
*/
};

module.exports = {
Expand Down