Skip to content

Commit 1a6d530

Browse files
committed
Splitted examples up in two. One is a port of the official example,
the other is a skeleton for a basic Rosetta Server Implementation.
1 parent 15acdae commit 1a6d530

15 files changed

Lines changed: 170 additions & 7 deletions

File tree

File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2020
*/
2121

22-
const RosettaSDK = require('../..');
22+
const RosettaSDK = require('../../..');
2323
const RosettaClient = RosettaSDK.Client;
2424

2525
// Create an instance of APIClient and configure it.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2020
*/
2121

22-
const RosettaSDK = require('../..');
22+
const RosettaSDK = require('../../..');
2323

2424
// Create an instance of Fetcher
2525
const fetcher = new RosettaSDK.Fetcher({

examples/basic/server/index.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* Copyright (c) 2020 DigiByte Foundation NZ Limited
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
5+
* this software and associated documentation files (the "Software"), to deal in
6+
* the Software without restriction, including without limitation the rights to
7+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8+
* the Software, and to permit persons to whom the Software is furnished to do so,
9+
* subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in all
12+
* copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20+
*/
21+
22+
const RosettaSDK = require('../../..');
23+
24+
const ServiceHandlers = require('./services');
25+
26+
/* Create a server configuration */
27+
const Server = new RosettaSDK.Server({
28+
URL_PORT: 8080,
29+
});
30+
31+
/* Data API: Network */
32+
Server.register('/network/list', ServiceHandlers.Network.networkList);
33+
Server.register('/network/options', ServiceHandlers.Network.networkOptions);
34+
Server.register('/network/status', ServiceHandlers.Network.networkStatus);
35+
36+
/* Data API: Block */
37+
Server.register('/block', ServiceHandlers.Block.block);
38+
Server.register('/block/transaction', ServiceHandlers.Block.blockTransaction);

examples/server/services/BlockService.js renamed to examples/basic/server/services/BlockService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2020
*/
2121

22-
const RosettaSDK = require('../../..');
22+
const RosettaSDK = require('../../../..');
2323

2424
/* Data API: Block */
2525

examples/server/services/NetworkService.js renamed to examples/basic/server/services/NetworkService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2020
*/
2121

22-
const RosettaSDK = require('../../..');
22+
const RosettaSDK = require('../../../..');
2323

2424
/* Data API: Network */
2525
const networkList = async (params) => {
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Copyright (c) 2020 DigiByte Foundation NZ Limited
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
5+
* this software and associated documentation files (the "Software"), to deal in
6+
* the Software without restriction, including without limitation the rights to
7+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8+
* the Software, and to permit persons to whom the Software is furnished to do so,
9+
* subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in all
12+
* copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20+
*/
21+
22+
const Network = require('./NetworkService');
23+
const Block = require('./BlockService');
24+
25+
module.exports = {
26+
Network,
27+
Block,
28+
};

examples/serverSkeleton/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Rosetta Server Skeleton
2+
This directory demonstrates provides a basic skeleton for Rosetta Servers.
3+
4+
## Steps
5+
1. Implement each response in `services/*Service.js`
6+
2. Pack your implementation with a Dockerfile providing your backend
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2020
*/
2121

22-
const RosettaSDK = require('../..');
22+
const RosettaSDK = require('../../..');
2323

2424
const ServiceHandlers = require('./services');
2525

File renamed without changes.

0 commit comments

Comments
 (0)