Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
lastmeta committed Jul 8, 2022
0 parents commit 774f685
Show file tree
Hide file tree
Showing 51 changed files with 3,944 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/ISSUE_TEMPLATE/bucket.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Bucket
description: Suggest a broad idea for this project
labels: ['Bucket']
body:
- type: markdown
attributes:
value: Thanks for taking the time to suggest a broad idea!
- type: textarea
id: broad-idea
attributes:
label: Describe The Broad Idea
description: A clear and concise description of what you want to happen.
placeholder: Tell us what you want to see!
value: 'As a... I want... So that...'
validations:
required: true
- type: textarea
id: alternatives
attributes:
label: Alternatives You've Considered
description: A clear and concise description of any alternative you've considered.
placeholder: Tell us some alternatives!
validations:
required: false
- type: textarea
id: additional-context
attributes:
label: Additional Context
description: Add any other context about the bucket here.
validations:
required: false
- type: textarea
id: story
attributes:
label: Stories For This Bucket
description: Add any stories that are required for this bucket.
placeholder: Create a list of stories!
value: ' - [ ] https://github.com/moontreeapp/raven_front/issues/???'
validations:
required: false
- type: textarea
id: bug
attributes:
label: Bugs For This Bucket
description: Add any stories that are replaced/fixed by this bucket.
placeholder: Create a list of bugs!
value: ' - [ ] https://github.com/moontreeapp/raven_front/issues/???'
validations:
required: false
64 changes: 64 additions & 0 deletions .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Bug
description: File a bug report
labels: ['Bug']
body:
- type: markdown
attributes:
value: Thanks for taking the time to fill out this bug report!
- type: textarea
id: describe-the-bug
attributes:
label: Describe The Bug
description: A clear and concise description of the bug.
placeholder: Tell us what you see!
# value: 'A bug happened!'
validations:
required: true
- type: textarea
id: to-reproduce
attributes:
label: To Reproduce
description: Steps to reproduce the behavior.
placeholder: Tell us the steps you took!
# value: "1. Go To '...'\ 2. Tap On '...'\ 3. See Error"
validations:
required: true
- type: textarea
id: expected-behavior
attributes:
label: Expected Behavior
description: A clear and concise description of what you expected to happen.
placeholder: Tell us what you expected!
# value: 'I expected...'
validations:
required: true
- type: textarea
id: log-output
attributes:
label: Log Output
description: If applicable, provide relevant log output. No need for backticks here.
render: shell
- type: textarea
id: additional-context
attributes:
label: Additional Context
description: Add any other context about the problem here.
validations:
required: false
- type: textarea
id: screenshots
attributes:
label: Screenshots
description: Add screenshots to help explain the problem.
placeholder: Drag-and-drop screenshots or screen recordings here!
validations:
required: false
- type: textarea
id: tasks
attributes:
label: Tasks For This Bug
description: Add any tasks that are required for this bug.
placeholder: Create a list of tasks!
value: ' - [ ] https://github.com/moontreeapp/raven_front/issues/???'
validations:
required: false
49 changes: 49 additions & 0 deletions .github/ISSUE_TEMPLATE/story.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Story
description: Suggest an idea for this project
labels: ['Story']
body:
- type: markdown
attributes:
value: Thanks for taking the time to suggest an idea!
- type: textarea
id: user-story
attributes:
label: Describe The User Story
description: A clear and concise description of what you want to happen.
placeholder: Tell us what you want to see!
value: 'As a... I want... So that...'
validations:
required: true
- type: textarea
id: alternatives
attributes:
label: Alternatives You've Considered
description: A clear and concise description of any alternative you've considered.
placeholder: Tell us some alternatives!
validations:
required: false
- type: textarea
id: additional-context
attributes:
label: Additional Context
description: Add any other context about the story here.
validations:
required: false
- type: textarea
id: tasks
attributes:
label: Tasks For This Story
description: Add any tasks that are required for this story.
placeholder: Create a list of tasks!
value: ' - [ ] https://github.com/moontreeapp/raven_front/issues/???'
validations:
required: false
- type: textarea
id: bugs
attributes:
label: Bugs For This Story
description: Add any bugs that are replaced/fixed by this story.
placeholder: Create a list of bugs!
value: ' - [ ] https://github.com/moontreeapp/raven_front/issues/???'
validations:
required: false
23 changes: 23 additions & 0 deletions .github/ISSUE_TEMPLATE/task.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Task
description: Add a new task for this project
labels: ['Task']
body:
- type: markdown
attributes:
value: Thanks for taking the time to add a new task!
- type: textarea
id: task
attributes:
label: Describe The Task
description: A clear and concise description of what needs to happen.
placeholder: Tell us what you are going to do!
# value: 'As a... I want... So that...'
validations:
required: true
- type: textarea
id: additional-context
attributes:
label: Additional Context
description: Add any other context about the task here.
validations:
required: false
17 changes: 17 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
**Types of Changes**

<!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.

<!-- **Issue(s) Addressed** -->

- [Issue: # ](www.github.com/moontreeapp/ravencoin_electrum/issues/???)
- [Issue: # ](www.github.com/moontreeapp/ravencoin_electrum/issues/???)
- [Issue: # ](www.github.com/moontreeapp/ravencoin_electrum/issues/???)
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Files and directories created by pub.
.dart_tool/
.packages
.vscode

# Conventional directory for build outputs.
build/

# Omit committing pubspec.lock for library packages; see
# https://dart.dev/guides/libraries/private-files#pubspeclock.
pubspec.lock

18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## 2.0.0

- Rename package from ravencoin_electrum_client to ravencoin_electrum

## 1.2.1

- Fix type returned by subscribe

## 1.2.0
- Add getAssetBalance(s)
- Add getAssetUnspent(s)
- Add getOurStats (experimental)

## 1.1.0
- Add subscribeAsset, subscribeScripthash

## 1.0.0
- Initial version.
18 changes: 18 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Copyright 2021 MoonTree, LLC

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
A Dart-based client for Ravencoin ElectrumX servers

## Notes

The Ravencoin ElectrumX server is quite similar to the Bitcion Electrum server, but has additional methods that allow clients to handle asset issuance and transferral.

## Usage

```dart
import 'package:ravencoin_electrum/ravencoin_electrum.dart';
void main() async {
var client =
await RavenElectrumClient.connect('testnet.rvn.rocks', port: 50002);
var features = await client.features();
print(features);
await client.close();
}
```

## Features and bugs

Please file feature requests and bugs at the [issue tracker][tracker].

[tracker]: https://github.com/moontreeapp/ravencoin_electrum/issues
30 changes: 30 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This file configures the static analysis results for your project (errors,
# warnings, and lints).
#
# This enables the 'recommended' set of lints from `package:lints`.
# This set helps identify many issues that may lead to problems when running
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
# style and format.
#
# If you want a smaller set of lints you can change this to specify
# 'package:lints/core.yaml'. These are just the most critical lints
# (the recommended set includes the core lints).
# The core lints are also what is used by pub.dev for scoring packages.

include: package:lints/recommended.yaml

# Uncomment the following section to specify additional rules.

# linter:
# rules:
# - camel_case_types

# analyzer:
# exclude:
# - path/to/excluded/files/**

# For more information about the core and recommended set of lints, see
# https://dart.dev/go/core-lints

# For additional information about configuring this file, see
# https://dart.dev/guides/language/analysis-options
9 changes: 9 additions & 0 deletions example/raven_electrum_example.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import 'package:ravencoin_electrum/ravencoin_electrum.dart';

void main() async {
var client =
await RavenElectrumClient.connect('testnet.rvn.rocks', port: 50002);
var features = await client.features();
print(features);
await client.close();
}
60 changes: 60 additions & 0 deletions lib/client/base_client.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import 'dart:async';

import 'package:pedantic/pedantic.dart';
import 'package:json_rpc_2/json_rpc_2.dart' as rpc;
import 'package:stream_channel/stream_channel.dart';
import 'package:stack_trace/stack_trace.dart';

/// The BaseClient class must be given an open channel to the server, which it
/// will use to make requests (or close the channel). We intentionally keep the
/// channel generic so that we can, for example, inject a mock server and write
/// tests against it. Normally, the channel will be derived from a SecureSocket
/// via TCP (see [connect.dart]).
///
/// Example:
/// var client = BaseClient(await connect('testnet.rvn.rocks'));
///
class BaseClient {
/// We use a Peer here--which implements both Server and Client sides of a
/// Remote Procedure Call (RPC) interface--to communicate with an ElectrumX
/// Ravencoin server. We do so because we need:
///
/// - the Client side for the basic ability to call 'procedures' on the
/// remote server (e.g. 'blockchain.scripthash.get_balance');
///
/// - the Server side so that when we can subscribe to an ongoing stream of
/// updates (e.g. 'blockchain.headers.subscribe'). The remote server can
/// notify us of an update by calling our registered 'procedures'.
///
/// The ElectrumX specification requires that notifications from the server
/// use procedure names that match the initiating subscribe call. For example:
///
/// We can start a subscription by calling `blockchain.scripthash.subscribe`
/// and the server will subsequently notify us uf status changes by
/// calling this client's matching `blockchain.scripthash.subscribe`
/// procedure.
///
/// Note that the BaseClient class does not implement subscriptions.
///
late rpc.Peer peer;

BaseClient(StreamChannel channel, {rpc.ErrorCallback? onUnhandledError}) {
peer = rpc.Peer.withoutJson(channel,
onUnhandledError: onUnhandledError ?? handleError);
unawaited(peer.listen());
}

Future<void> close() async {
return peer.close();
}

Future request(String method, [parameters]) async {
return await peer.sendRequest(method, parameters);
}

void handleError(error, trace) {
print(error + ' 1');
var simpleTrace = Trace.from(trace);
print(simpleTrace.terse);
}
}
Loading

0 comments on commit 774f685

Please sign in to comment.