Skip to content

Commit

Permalink
First cut of token program (solana-labs#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackcmay authored May 29, 2020
1 parent 8d09e0b commit 539fdfc
Show file tree
Hide file tree
Showing 48 changed files with 17,897 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
dist: bionic
sudo: required
language: rust
services:
- docker
cache:
cargo: true
directories:
- "~/.npm"
notifications:
email: false

install:
- cargo --version
- docker --version
- wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
- sudo apt-add-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main"
- sudo apt-get update
- sudo apt-get install -y clang-7 --allow-unauthenticated
- sudo apt-get install -y openssl --allow-unauthenticated
- sudo apt-get install -y libssl-dev --allow-unauthenticated
- sudo apt-get install -y libssl1.1 --allow-unauthenticated
- clang-7 --version
- nvm install node
- node --version

script:
- npm install --prefix token
- npm run build:program --prefix token
- cargo test --manifest-path=token/src/program-test/Cargo.toml
- npm run test --prefix token
- npm run cluster:devnet --prefix token
- npm run start --prefix token
20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (c) 2018 Solana Labs, Inc

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.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
[![Build status][travis-image]][travis-url]

[travis-image]: https://travis-ci.org/solana-labs/solana-program-library.svg?branch=master
[travis-url]: https://travis-ci.org/solana-labs/solana-program-library

# Solana Program Library

The Solana Program Library (SPL) is a collection of Solana-maintained
Expand Down
13 changes: 13 additions & 0 deletions token/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"presets": [
"env",
"flow",
"react",
"stage-2",
],
"plugins": [
"transform-class-properties",
"transform-function-bind",
"transform-runtime",
]
}
1 change: 1 addition & 0 deletions token/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
52 changes: 52 additions & 0 deletions token/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
module.exports = {
// eslint-disable-line import/no-commonjs
env: {
browser: true,
es6: true,
node: true,
},
plugins: ['react'],
extends: [
'eslint:recommended',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:react/recommended',
],
parser: 'babel-eslint',
parserOptions: {
sourceType: 'module',
ecmaVersion: 8,
},
rules: {
'no-trailing-spaces': ['error'],
'import/first': ['error'],
'import/no-commonjs': ['error'],
'import/order': [
'error',
{
groups: [
['internal', 'external', 'builtin'],
['index', 'sibling', 'parent'],
],
'newlines-between': 'always',
},
],
indent: [
'error',
2,
{
MemberExpression: 1,
SwitchCase: 1,
},
],
'linebreak-style': ['error', 'unix'],
'no-console': [0],
quotes: [
'error',
'single',
{avoidEscape: true, allowTemplateLiterals: true},
],
'require-await': ['error'],
semi: ['error', 'always'],
},
};
22 changes: 22 additions & 0 deletions token/.flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[ignore]
<PROJECT_ROOT>/node_modules/*

[include]

[libs]
node_modules/@solana/web3.js/module.flow.js
flow-typed/

[options]

emoji=true
esproposal.class_instance_fields=enable
esproposal.class_static_fields=enable
esproposal.decorators=ignore
esproposal.export_star_as=enable
module.system.node.resolve_dirname=./src
module.use_strict=true
experimental.const_params=true
include_warnings=true
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue
2 changes: 2 additions & 0 deletions token/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.env
7 changes: 7 additions & 0 deletions token/.prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
arrowParens: "avoid"
bracketSpacing: false
jsxBracketSameLine: false
semi: true
singleQuote: true
tabWidth: 2
trailingComma: "all"
63 changes: 63 additions & 0 deletions token/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Token program

An ERC20-like Token program on the Solana blockchain.

The project comprises of:

* A library to interact with the on-chain program
* Client that exercises the program

## Getting Started

First fetch the npm dependencies, including `@solana/web3.js`, by running:
```sh
$ npm install
```

### Select a Network

The client connects to a local Solana cluster by default.

To enable on-chain program logs, set the `RUST_LOG` environment variable:

```bash
$ 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
```

To start a local Solana cluster run:
```bash
$ npm run localnet:update
$ npm run localnet:up
```

Solana cluster logs are available with:
```bash
$ npm run localnet:logs
```

For more details on working with a local cluster, see the [full instructions](https://github.com/solana-labs/solana-web3.js#local-network).

### Run the test client

```sh
$ npm run start
```

## Pointing to a public Solana cluster

Solana maintains three public clusters:
- `devnet` - Development cluster with airdrops enabled
- `testnet` - Tour De Sol test cluster without airdrops enabled
- `mainnet-beta` - Main cluster

Use npm scripts to configure which cluster.

To point to `devnet`:
```bash
$ npm run cluster:devnet
```

To point back to the local cluster:
```bash
$ npm run cluster:localnet
```
2 changes: 2 additions & 0 deletions token/cluster-devnet.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
LIVE=1
CLUSTER=devnet
2 changes: 2 additions & 0 deletions token/cluster-mainnet-beta.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
LIVE=1
CLUSTER=mainnet-beta
2 changes: 2 additions & 0 deletions token/cluster-testnet.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
LIVE=1
CLUSTER=testnet
4 changes: 4 additions & 0 deletions token/flow-typed/bn.js.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module 'bn.js' {
// TODO: Fill in types
declare module.exports: any;
}
6 changes: 6 additions & 0 deletions token/flow-typed/bs58.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
declare module 'bs58' {
declare module.exports: {
encode(input: Buffer): string;
decode(input: string): Buffer;
};
}
4 changes: 4 additions & 0 deletions token/flow-typed/buffer-layout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module 'buffer-layout' {
// TODO: Fill in types
declare module.exports: any;
}
6 changes: 6 additions & 0 deletions token/flow-typed/cbor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
declare module 'cbor' {
declare module.exports: {
decode(input: Buffer): Object;
encode(input: any): Buffer;
};
}
122 changes: 122 additions & 0 deletions token/flow-typed/event-emitter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
// flow-typed signature: 4f92d81ee3831cb415b4b216cc0679d9
// flow-typed version: <<STUB>>/event-emitter_v0.3.5/flow_v0.84.0

/**
* This is an autogenerated libdef stub for:
*
* 'event-emitter'
*
* Fill this stub out by replacing all the `any` types.
*
* Once filled out, we encourage you to share your work with the
* community by sending a pull request to:
* https://github.com/flowtype/flow-typed
*/

declare module 'event-emitter' {
declare module.exports: any;
}

/**
* We include stubs for each file inside this npm package in case you need to
* require those files directly. Feel free to delete any files that aren't
* needed.
*/
declare module 'event-emitter/all-off' {
declare module.exports: any;
}

declare module 'event-emitter/benchmark/many-on' {
declare module.exports: any;
}

declare module 'event-emitter/benchmark/single-on' {
declare module.exports: any;
}

declare module 'event-emitter/emit-error' {
declare module.exports: any;
}

declare module 'event-emitter/has-listeners' {
declare module.exports: any;
}

declare module 'event-emitter/pipe' {
declare module.exports: any;
}

declare module 'event-emitter/test/all-off' {
declare module.exports: any;
}

declare module 'event-emitter/test/emit-error' {
declare module.exports: any;
}

declare module 'event-emitter/test/has-listeners' {
declare module.exports: any;
}

declare module 'event-emitter/test/index' {
declare module.exports: any;
}

declare module 'event-emitter/test/pipe' {
declare module.exports: any;
}

declare module 'event-emitter/test/unify' {
declare module.exports: any;
}

declare module 'event-emitter/unify' {
declare module.exports: any;
}

// Filename aliases
declare module 'event-emitter/all-off.js' {
declare module.exports: $Exports<'event-emitter/all-off'>;
}
declare module 'event-emitter/benchmark/many-on.js' {
declare module.exports: $Exports<'event-emitter/benchmark/many-on'>;
}
declare module 'event-emitter/benchmark/single-on.js' {
declare module.exports: $Exports<'event-emitter/benchmark/single-on'>;
}
declare module 'event-emitter/emit-error.js' {
declare module.exports: $Exports<'event-emitter/emit-error'>;
}
declare module 'event-emitter/has-listeners.js' {
declare module.exports: $Exports<'event-emitter/has-listeners'>;
}
declare module 'event-emitter/index' {
declare module.exports: $Exports<'event-emitter'>;
}
declare module 'event-emitter/index.js' {
declare module.exports: $Exports<'event-emitter'>;
}
declare module 'event-emitter/pipe.js' {
declare module.exports: $Exports<'event-emitter/pipe'>;
}
declare module 'event-emitter/test/all-off.js' {
declare module.exports: $Exports<'event-emitter/test/all-off'>;
}
declare module 'event-emitter/test/emit-error.js' {
declare module.exports: $Exports<'event-emitter/test/emit-error'>;
}
declare module 'event-emitter/test/has-listeners.js' {
declare module.exports: $Exports<'event-emitter/test/has-listeners'>;
}
declare module 'event-emitter/test/index.js' {
declare module.exports: $Exports<'event-emitter/test/index'>;
}
declare module 'event-emitter/test/pipe.js' {
declare module.exports: $Exports<'event-emitter/test/pipe'>;
}
declare module 'event-emitter/test/unify.js' {
declare module.exports: $Exports<'event-emitter/test/unify'>;
}
declare module 'event-emitter/unify.js' {
declare module.exports: $Exports<'event-emitter/unify'>;
}
Loading

0 comments on commit 539fdfc

Please sign in to comment.