Skip to content
This repository has been archived by the owner on Nov 7, 2023. It is now read-only.

Commit

Permalink
Merge pull request #13 from rnsdomains/with-addr
Browse files Browse the repository at this point in the history
Add optional domains registered with addr
  • Loading branch information
ilanolkies authored Jun 11, 2020
2 parents 25e5264 + d15b2ff commit 1c9f0cb
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 6 deletions.
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ Deploy the suite running

```javascript
const RNSSuite = require('@rsksmart/rns-suite');
RNSSuite('http://localhost:8545', ['alice', 'bob', 'charlie'], ['david', 'eve', 'frank'])
RNSSuite('http://localhost:8545', ['alice', 'bob', 'charlie'], ['david', 'eve', 'frank'], ['grace', 'heidi', 'ivan'])
```

1. The first array of names are for .rsk domains to be registered with the current method.
2. The second array of names are for .rsk domains to be registered with the legacy auction method.
3. The third array of names are for .rsk domains to be registered with the current method and also setting an address to it.

### Run from Truffle migrations

```javascript
Expand All @@ -27,7 +31,7 @@ const RNSSuite = require('@rsksmart/rns-suite');

module.exports = function(deployer) {
return deployer.deploy(Migrations).then(() =>
RNSSuite(web3.currentProvider, ['alice', 'bob', 'charlie'], ['david', 'eve', 'frank'])
RNSSuite(web3.currentProvider, [['alice', 'bob', 'charlie'], ['david', 'eve', 'frank'], ['grace', 'heidi', 'ivan'])
)
};
```
Expand All @@ -49,6 +53,19 @@ npx truffle migrate # migrates to :8545 by default

Create your custom `truffle-config.js` file to connect to other networks.

- `ganache-cli` default port accessible via `--network ganache`

This is enables you to operate with the service via command line. For example, you can get/set an address via:

```
truffle(develop)> PublicResolver.at('LOGGED PUBLIC RESOLVER ADDRESS').then(p => p.addr(require('eth-ens-namehash').hash('grace.rsk')))
'0x288B41F66832532AcA5762980EAC237760D8a138'
truffle(develop)> PublicResolver.at('LOGGED PUBLIC RESOLVER ADDRESS').then(p => p.setAddr(require('eth-ens-namehash').hash('grace.rsk'), '0x3e7764DF9B1E5E8bdE4fF2d5E59A46eECAE2A04c'))
{
tx: '0xe7316c16cc1b44f0f16ce6055d8a61f3110945ca86990cffcd1b29688e2478f8',
...
```

## Troubleshot

If you have problems registering domains with the auction ensure you can execute `evm_increaseTime` and `evm_mine` RPC methods in your node.
27 changes: 25 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async function executeTx(tx, options) {
* @param {string[]} registrations labels to be registered with the current registrar (don't append .rsk)
* @param {string[]} auctionRegistrations labels to be registered with the previous registrar (auction) (don't append .rsk)
*/
async function main(provider, registrations, auctionRegistrations) {
async function main(provider, registrations, auctionRegistrations, registrationsWithAddr) {
console.log(figlet.textSync('Deploying RNS'));
console.log(chalk.italic('\nThis can take a while...\n\n'));

Expand Down Expand Up @@ -276,9 +276,15 @@ async function main(provider, registrations, auctionRegistrations) {

let registeredDomainsRSKRegistrar;

if(registrations && registrations.length) {
if (
(registrations && registrations.length) ||
(registrationsWithAddr && registrationsWithAddr.length)
) {
console.log(chalk.bold('Registering domains'));

if(registrationsWithAddr && registrationsWithAddr.length)
registrations = registrations.concat(registrationsWithAddr);

let labels = [];
let domains = [];

Expand All @@ -300,6 +306,20 @@ async function main(provider, registrations, auctionRegistrations) {

console.log(`Registered: ${domains}`);
console.log();

if (registrationsWithAddr && registrationsWithAddr.length) {
console.log(chalk.bold('Setting addrs'));
const allAddrs = [];

for (let i = 0; i < registrationsWithAddr.length; i += 1)
allAddrs.push(
executeTx(publicResolver.methods.setAddr(namehash(`${registrationsWithAddr[i]}.rsk`), from))
);

await Promise.all(allAddrs);
console.log(`Set addr for: ${domains}`);
console.log();
}
}

console.log('Done! Summary:')
Expand Down Expand Up @@ -331,6 +351,9 @@ async function main(provider, registrations, auctionRegistrations) {
if (registeredDomainsRSKRegistrar)
console.log(`Registered domains with the current registrar: ${registeredDomainsRSKRegistrar}`);

if(registrationsWithAddr)
console.log(`Set addr for: ${registrationsWithAddr}`);

console.log()

return {
Expand Down
2 changes: 1 addition & 1 deletion migrations/1_initial_migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ const Migrations = artifacts.require("Migrations");
const deploy = require('../');

module.exports = function(deployer) {
deployer.deploy(Migrations).then(() => deploy(web3.currentProvider, ['alice, bob, charlie'], ['david, eve, frank']));
deployer.deploy(Migrations).then(() => deploy(web3.currentProvider, ['alice', 'bob', 'charlie'], ['david', 'eve', 'frank'], ['grace', 'heidi', 'ivan']));
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rsksmart/rns-suite",
"version": "1.0.5",
"version": "1.0.6",
"description": "RNS suite",
"main": "index.js",
"files": [
Expand Down

0 comments on commit 1c9f0cb

Please sign in to comment.