This repository has been archived by the owner on Jan 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 371
/
addressing.js
88 lines (74 loc) · 2 KB
/
addressing.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
'use strict';
const { createHash } = require('crypto');
const NAMESPACE = '5f4d76';
const PREFIXES = {
COLLECTION: '00',
MOJI: '01',
SIRE_LISTING: '02',
OFFER: '03'
};
/**
* A function that takes a public key and returns the corresponding collection
* address.
*
* This is simpler than the client version, as the public key is not optional.
* Processor addressing methods always return a full address.
*
* Example:
* const address = getCollectionAddress(publicKey);
* console.log(address);
* // '5f4d7600ecd7ef459ec82a01211983551c3ed82169ca5fa0703ec98e17f9b534ffb797'
*/
const getCollectionAddress = publicKey => {
// Enter your solution here
};
/**
* A function that takes a public key and a moji dna string, returning the
* corresponding moji address.
*/
const getMojiAddress = (ownerKey, dna) => {
// Your code here
};
/**
* A function that takes a public key, and returns the corresponding sire
* listing address.
*/
const getSireAddress = ownerKey => {
// Your code here
};
/**
* EXTRA CREDIT
* Only needed if you add trading cryptomoji to your transaction processor.
* Remove the `.skip` from line 184 of tests/01-Services.js to test.
*
* A function that takes a public key and one or more moji addresses,
* returning the corresponding offer address.
*
* Unlike the client version, moji may only be identified by addresses, not
* dna strings.
*/
const getOfferAddress = (ownerKey, addresses) => {
// Your code here
};
/**
* A function that takes an address and returns true or false depending on
* whether or not it is a valid Cryptomoji address. It should reject an
* address if:
* - it is not a string
* - it is not 70 hex characters
* - it does not start with the correct namespace
*
* Example:
* const isValid = isValidAddress('00000000');
* console.log(isValid); // false
*/
const isValidAddress = address => {
// Your code here
};
module.exports = {
getCollectionAddress,
getMojiAddress,
getSireAddress,
getOfferAddress,
isValidAddress
};