Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-nameservice
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-nameservice
Commits
7964d8cc
Commit
7964d8cc
authored
9 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
initial commit
parents
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
index.js
+25
-0
25 additions, 0 deletions
index.js
package.json
+13
-0
13 additions, 0 deletions
package.json
registrar.sol
+83
-0
83 additions, 0 deletions
registrar.sol
with
121 additions
and
0 deletions
index.js
0 → 100644
+
25
−
0
View file @
7964d8cc
#!/usr/bin/env node
var
connect
=
require
(
'
connect
'
);
var
express
=
require
(
'
express
'
);
var
http
=
require
(
'
http
'
);
var
Web3
=
require
(
'
web3
'
);
var
web3
=
new
Web3
();
web3
.
setProvider
(
new
web3
.
providers
.
HttpProvider
(
'
http://localhost:8545
'
));
//console.log(web3);
var
coinbase
=
web3
.
eth
.
coinbase
;
console
.
log
(
coinbase
);
var
balance
=
web3
.
eth
.
getBalance
(
coinbase
);
console
.
log
(
balance
.
toString
(
10
));
var
REG_ADDR
=
"
0xcd4f2482b34a7391fa6f39e01b5c6a4b2e97e69e
"
;
var
REG_ABI
=
[{
"
constant
"
:
true
,
"
inputs
"
:[{
"
name
"
:
"
_owner
"
,
"
type
"
:
"
address
"
}],
"
name
"
:
"
name
"
,
"
outputs
"
:[{
"
name
"
:
"
o_name
"
,
"
type
"
:
"
bytes32
"
}],
"
type
"
:
"
function
"
},{
"
constant
"
:
true
,
"
inputs
"
:[{
"
name
"
:
"
_name
"
,
"
type
"
:
"
bytes32
"
}],
"
name
"
:
"
owner
"
,
"
outputs
"
:[{
"
name
"
:
""
,
"
type
"
:
"
address
"
}],
"
type
"
:
"
function
"
},{
"
constant
"
:
true
,
"
inputs
"
:[{
"
name
"
:
"
_name
"
,
"
type
"
:
"
bytes32
"
}],
"
name
"
:
"
content
"
,
"
outputs
"
:[{
"
name
"
:
""
,
"
type
"
:
"
bytes32
"
}],
"
type
"
:
"
function
"
},{
"
constant
"
:
true
,
"
inputs
"
:[{
"
name
"
:
"
_name
"
,
"
type
"
:
"
bytes32
"
}],
"
name
"
:
"
addr
"
,
"
outputs
"
:[{
"
name
"
:
""
,
"
type
"
:
"
address
"
}],
"
type
"
:
"
function
"
},{
"
constant
"
:
false
,
"
inputs
"
:[{
"
name
"
:
"
_name
"
,
"
type
"
:
"
bytes32
"
}],
"
name
"
:
"
reserve
"
,
"
outputs
"
:[],
"
type
"
:
"
function
"
},{
"
constant
"
:
true
,
"
inputs
"
:[{
"
name
"
:
"
_name
"
,
"
type
"
:
"
bytes32
"
}],
"
name
"
:
"
subRegistrar
"
,
"
outputs
"
:[{
"
name
"
:
"
o_subRegistrar
"
,
"
type
"
:
"
address
"
}],
"
type
"
:
"
function
"
},{
"
constant
"
:
false
,
"
inputs
"
:[{
"
name
"
:
"
_name
"
,
"
type
"
:
"
bytes32
"
},{
"
name
"
:
"
_newOwner
"
,
"
type
"
:
"
address
"
}],
"
name
"
:
"
transfer
"
,
"
outputs
"
:[],
"
type
"
:
"
function
"
},{
"
constant
"
:
false
,
"
inputs
"
:[{
"
name
"
:
"
_name
"
,
"
type
"
:
"
bytes32
"
},{
"
name
"
:
"
_registrar
"
,
"
type
"
:
"
address
"
}],
"
name
"
:
"
setSubRegistrar
"
,
"
outputs
"
:[],
"
type
"
:
"
function
"
},{
"
constant
"
:
false
,
"
inputs
"
:[],
"
name
"
:
"
Registrar
"
,
"
outputs
"
:[],
"
type
"
:
"
function
"
},{
"
constant
"
:
false
,
"
inputs
"
:[{
"
name
"
:
"
_name
"
,
"
type
"
:
"
bytes32
"
},{
"
name
"
:
"
_a
"
,
"
type
"
:
"
address
"
},{
"
name
"
:
"
_primary
"
,
"
type
"
:
"
bool
"
}],
"
name
"
:
"
setAddress
"
,
"
outputs
"
:[],
"
type
"
:
"
function
"
},{
"
constant
"
:
false
,
"
inputs
"
:[{
"
name
"
:
"
_name
"
,
"
type
"
:
"
bytes32
"
},{
"
name
"
:
"
_content
"
,
"
type
"
:
"
bytes32
"
}],
"
name
"
:
"
setContent
"
,
"
outputs
"
:[],
"
type
"
:
"
function
"
},{
"
constant
"
:
false
,
"
inputs
"
:[{
"
name
"
:
"
_name
"
,
"
type
"
:
"
bytes32
"
}],
"
name
"
:
"
disown
"
,
"
outputs
"
:[],
"
type
"
:
"
function
"
},{
"
constant
"
:
true
,
"
inputs
"
:[{
"
name
"
:
"
_name
"
,
"
type
"
:
"
bytes32
"
}],
"
name
"
:
"
register
"
,
"
outputs
"
:[{
"
name
"
:
""
,
"
type
"
:
"
address
"
}],
"
type
"
:
"
function
"
},{
"
anonymous
"
:
false
,
"
inputs
"
:[{
"
indexed
"
:
true
,
"
name
"
:
"
name
"
,
"
type
"
:
"
bytes32
"
}],
"
name
"
:
"
Changed
"
,
"
type
"
:
"
event
"
},{
"
anonymous
"
:
false
,
"
inputs
"
:[{
"
indexed
"
:
true
,
"
name
"
:
"
name
"
,
"
type
"
:
"
bytes32
"
},{
"
indexed
"
:
true
,
"
name
"
:
"
addr
"
,
"
type
"
:
"
address
"
}],
"
name
"
:
"
PrimaryChanged
"
,
"
type
"
:
"
event
"
}];
var
reg
=
web3
.
eth
.
contract
(
REG_ABI
).
at
(
REG_ADDR
);
var
app
=
express
();
app
.
get
(
"
/name/:name
"
,
function
(
req
,
res
){
var
r
=
reg
.
addr
(
req
.
params
.
name
)
res
.
end
(
JSON
.
stringify
({
"
addr
"
:
r
}));
});
http
.
createServer
(
app
).
listen
(
3000
);
This diff is collapsed.
Click to expand it.
package.json
0 → 100644
+
13
−
0
View file @
7964d8cc
{
"name"
:
"ringns"
,
"version"
:
"1.0.0"
,
"description"
:
"Ring name service"
,
"main"
:
"index.js"
,
"keywords"
:
[],
"author"
:
"Adrien Béraud <adrien.beraud@savoirfairelinux.com>"
,
"license"
:
"
GPL-3.0
"
,
"dependencies"
:
{
"
web3
"
:
"
>=0.15
"
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
registrar.sol
0 → 100644
+
83
−
0
View file @
7964d8cc
import "owned";
contract NameRegister {
function addr(bytes32 _name) constant returns (address o_owner) {}
function name(address _owner) constant returns (bytes32 o_name) {}
}
contract Registrar is NameRegister {
event Changed(bytes32 indexed name);
event PrimaryChanged(bytes32 indexed name, address indexed addr);
function owner(bytes32 _name) constant returns (address o_owner) {}
function addr(bytes32 _name) constant returns (address o_address) {}
function subRegistrar(bytes32 _name) constant returns (address o_subRegistrar) {}
function content(bytes32 _name) constant returns (bytes32 o_content) {}
function name(address _owner) constant returns (bytes32 o_name) {}
}
contract GlobalRegistrar is Registrar {
struct Record {
address owner;
address primary;
address subRegistrar;
bytes32 content;
uint value;
uint renewalDate;
}
function Registrar() {
}
function reserve(bytes32 _name) {
if (m_toRecord[_name].owner == 0) {
m_toRecord[_name].owner = msg.sender;
Changed(_name);
}
}
modifier onlyrecordowner(bytes32 _name) { if (m_toRecord[_name].owner == msg.sender) _ }
function transfer(bytes32 _name, address _newOwner) onlyrecordowner(_name) {
m_toRecord[_name].owner = _newOwner;
Changed(_name);
}
function disown(bytes32 _name) onlyrecordowner(_name) {
if (m_toName[m_toRecord[_name].primary] == _name)
{
PrimaryChanged(_name, m_toRecord[_name].primary);
m_toName[m_toRecord[_name].primary] = "";
}
delete m_toRecord[_name];
Changed(_name);
}
function setAddress(bytes32 _name, address _a, bool _primary) onlyrecordowner(_name) {
m_toRecord[_name].primary = _a;
if (_primary)
{
PrimaryChanged(_name, _a);
m_toName[_a] = _name;
}
Changed(_name);
}
function setSubRegistrar(bytes32 _name, address _registrar) onlyrecordowner(_name) {
m_toRecord[_name].subRegistrar = _registrar;
Changed(_name);
}
function setContent(bytes32 _name, bytes32 _content) onlyrecordowner(_name) {
m_toRecord[_name].content = _content;
Changed(_name);
}
function owner(bytes32 _name) constant returns (address) { return m_toRecord[_name].owner; }
function addr(bytes32 _name) constant returns (address) { return m_toRecord[_name].primary; }
function register(bytes32 _name) constant returns (address) { return m_toRecord[_name].subRegistrar; }
function content(bytes32 _name) constant returns (bytes32) { return m_toRecord[_name].content; }
function name(address _owner) constant returns (bytes32 o_name) { return m_toName[_owner]; }
mapping (address => bytes32) m_toName;
mapping (bytes32 => Record) m_toRecord;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment