forked from solana-labs/solana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First cut of token program (solana-labs#1)
- Loading branch information
Showing
48 changed files
with
17,897 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
LIVE=1 | ||
CLUSTER=devnet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
LIVE=1 | ||
CLUSTER=mainnet-beta |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
LIVE=1 | ||
CLUSTER=testnet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'>; | ||
} |
Oops, something went wrong.