Skip to content

Commit eee3f4b

Browse files
committed
Initial
0 parents  commit eee3f4b

36 files changed

+13494
-0
lines changed

.babelrc

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"presets": [
3+
"env",
4+
"flow",
5+
"react",
6+
"stage-2",
7+
],
8+
"plugins": [
9+
"transform-class-properties",
10+
"transform-function-bind",
11+
"transform-runtime",
12+
]
13+
}

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist/

.eslintrc.js

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
module.exports = {
2+
// eslint-disable-line import/no-commonjs
3+
env: {
4+
browser: true,
5+
es6: true,
6+
node: true,
7+
},
8+
plugins: ['react'],
9+
extends: [
10+
'eslint:recommended',
11+
'plugin:import/errors',
12+
'plugin:import/warnings',
13+
'plugin:react/recommended',
14+
],
15+
parser: 'babel-eslint',
16+
parserOptions: {
17+
sourceType: 'module',
18+
ecmaVersion: 8,
19+
},
20+
rules: {
21+
'no-trailing-spaces': ['error'],
22+
'import/first': ['error'],
23+
'import/no-commonjs': ['error'],
24+
'import/order': [
25+
'error',
26+
{
27+
groups: [
28+
['internal', 'external', 'builtin'],
29+
['index', 'sibling', 'parent'],
30+
],
31+
'newlines-between': 'always',
32+
},
33+
],
34+
indent: [
35+
'error',
36+
2,
37+
{
38+
MemberExpression: 1,
39+
SwitchCase: 1,
40+
},
41+
],
42+
'linebreak-style': ['error', 'unix'],
43+
'no-console': [0],
44+
quotes: [
45+
'error',
46+
'single',
47+
{avoidEscape: true, allowTemplateLiterals: true},
48+
],
49+
'require-await': ['error'],
50+
semi: ['error', 'always'],
51+
},
52+
};

.flowconfig

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[ignore]
2+
<PROJECT_ROOT>/node_modules/*
3+
4+
[include]
5+
6+
[libs]
7+
node_modules/@solana/web3.js/module.flow.js
8+
flow-typed/
9+
10+
[options]
11+
12+
emoji=true
13+
esproposal.class_instance_fields=enable
14+
esproposal.class_static_fields=enable
15+
esproposal.decorators=ignore
16+
esproposal.export_star_as=enable
17+
module.system.node.resolve_dirname=./src
18+
module.use_strict=true
19+
experimental.const_params=true
20+
include_warnings=true
21+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe
22+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/node_modules
2+
*.sw[po]
3+
/store
4+
/.cargo

.prettierrc.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
arrowParens: "avoid"
2+
bracketSpacing: false
3+
jsxBracketSameLine: false
4+
semi: true
5+
singleQuote: true
6+
tabWidth: 2
7+
trailingComma: "all"

.travis.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
dist: bionic
2+
sudo: required
3+
language: rust
4+
services:
5+
- docker
6+
cache:
7+
cargo: true
8+
directories:
9+
- "~/.npm"
10+
notifications:
11+
email: false
12+
13+
install:
14+
- cargo --version
15+
- docker --version
16+
- wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
17+
- sudo apt-add-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main"
18+
- sudo apt-get update
19+
- sudo apt-get install -y clang-7 --allow-unauthenticated
20+
- sudo apt-get install -y openssl --allow-unauthenticated
21+
- sudo apt-get install -y libssl-dev --allow-unauthenticated
22+
- sudo apt-get install -y libssl1.1 --allow-unauthenticated
23+
- clang-7 --version
24+
- nvm install node
25+
- node --version
26+
- npm install
27+
28+
script:
29+
- npm run build:program
30+
- cargo test --manifest-path=src/program-test/Cargo.toml
31+
- npm run test

LICENSE

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright (c) 2018 Solana Labs, Inc
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
[![Build status][travis-image]][travis-url]
2+
3+
[travis-image]: https://travis-ci.org/solana-labs/example-helloworld.svg?branch=master
4+
[travis-url]: https://travis-ci.org/solana-labs/example-helloworld
5+
6+
# Hello world on Solana
7+
8+
This project demonstrates how to use the [Solana Javascript API](https://github.com/solana-labs/solana-web3.js)
9+
to build, deploy, and interact with programs on the Solana blockchain.
10+
11+
The project comprises of:
12+
13+
* An on-chain hello world program
14+
* Client that can send a "hello" to an account and get back the number of times hello has been sent
15+
16+
## Table of Contents
17+
- [Hello world on Solana](#hello-world-on-solana)
18+
- [Table of Contents](#table-of-contents)
19+
- [Getting Started](#getting-started)
20+
- [Start local Solana cluster](#start-local-solana-cluster)
21+
- [Build the on-chain program](#build-the-on-chain-program)
22+
- [Run client](#run-client)
23+
- [Customizing the Program](#customizing-the-program)
24+
- [Learn about Solana](#learn-about-solana)
25+
- [Learn about the on-chain program](#learn-about-the-on-chain-program)
26+
- [Learn about the client](#learn-about-the-client)
27+
- [Public Solana cluster](#public-solana-cluster)
28+
29+
## Getting Started
30+
31+
The following dependencies are required to build and run this example,
32+
depending on your OS they may already be installed:
33+
34+
```bash
35+
$ npm --version
36+
$ docker -v
37+
$ wget --version
38+
$ rustc --version
39+
```
40+
41+
Next fetch the `npm` dependencies, including `@solana/web3.js`, by running:
42+
```bash
43+
$ npm install
44+
```
45+
46+
### Start local Solana cluster
47+
48+
This example connects to a local Solana cluster by default.
49+
50+
Enable on-chain program logs:
51+
```bash
52+
$ export RUST_LOG=solana_runtime::native_loader=trace,solana_runtime::system_instruction_processor=trace,solana_runtime::bank=debug,solana_bpf_loader=debug,solana_rbpf=debug
53+
```
54+
55+
Start a local Solana cluster:
56+
```bash
57+
$ npm run localnet:update
58+
$ npm run localnet:up
59+
```
60+
61+
Get cluster log:
62+
```bash
63+
$ npm run localnet:logs
64+
```
65+
66+
To stop the local Solana cluster run:
67+
```bash
68+
$ npm run localnet:down
69+
```
70+
71+
### Build the on-chain program
72+
73+
```bash
74+
$ npm run build:program
75+
```
76+
77+
### Run client
78+
79+
```bash
80+
$ npm run start
81+
```
82+
83+
### Customizing the Program
84+
85+
To customize the example, make changes to the files under `/src`. If you change source under `/src/program` you will need to [rebuild the on-chain program](#Build-the-on-chain-program)
86+
87+
Now when you rerun `npm run start`, you should see the results of your changes.
88+
89+
## Learn about Solana
90+
91+
More information about how Solana works is available in the [Book](https://docs.solana.com/book/)
92+
93+
## Learn about the on-chain program
94+
95+
TODO
96+
97+
## Learn about the client
98+
99+
TODO
100+
101+
## Public Solana cluster
102+
103+
Solana maintains a public development cluster called devnet. To connect to the devnet instead of the local cluster set the environment variable `LIVE` to 1, unset to point back to the local cluster
104+
```bash
105+
$ export LIVE=1
106+
```

flow-typed/bn.js.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare module 'bn.js' {
2+
// TODO: Fill in types
3+
declare module.exports: any;
4+
}

flow-typed/bs58.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
declare module 'bs58' {
2+
declare module.exports: {
3+
encode(input: Buffer): string;
4+
decode(input: string): Buffer;
5+
};
6+
}

flow-typed/buffer-layout.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare module 'buffer-layout' {
2+
// TODO: Fill in types
3+
declare module.exports: any;
4+
}

flow-typed/cbor.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
declare module 'cbor' {
2+
declare module.exports: {
3+
decode(input: Buffer): Object;
4+
encode(input: any): Buffer;
5+
};
6+
}

0 commit comments

Comments
 (0)