├── .editorconfig
├── .eslintrc.js
├── .gitignore
├── .npmignore
├── .npmrc
├── .travis.yml
├── CHANGELOG.md
├── LICENSE
├── README.md
├── README_zh-CN.md
├── docs
├── assets
│ ├── css
│ │ └── main.css
│ ├── images
│ │ ├── icons.png
│ │ ├── icons@2x.png
│ │ ├── widgets.png
│ │ └── widgets@2x.png
│ └── js
│ │ ├── main.js
│ │ └── search.js
├── classes
│ ├── account.html
│ ├── contract.html
│ ├── transaction.html
│ ├── xupererror1.html
│ └── xupersdk.html
├── enums
│ ├── cryptography.html
│ ├── language.html
│ ├── resource_type.html
│ └── strength.html
├── index.html
└── interfaces
│ ├── accountinterface.html
│ ├── contractinterface.html
│ ├── errorinterface.html
│ ├── transactioninterface.html
│ └── xupersdkinterface.html
├── jest.config.js
├── package-lock.json
├── package.json
├── scripts
├── webpack.common.js
└── webpack.prod.js
├── src
├── account.ts
├── constants.ts
├── contract.ts
├── error.ts
├── index.ts
├── interfaces.ts
├── plugins
│ ├── endorsement.ts
│ └── index.ts
├── proto
│ ├── xendorser.proto
│ └── xuper.proto
├── requests.ts
├── transaction.ts
├── types.ts
├── utils.ts
└── wordlist.json
├── test
├── account.test.ts
├── cert
│ └── cfca.cert
├── contract.test.ts
├── jest
│ └── custom-test-env.js
├── native
│ ├── counter-native
│ └── counter-native-v2
├── plugins.test.ts
├── transaction.test.ts
├── wasm
│ └── counter.wasm
└── xuper.test.ts
├── tsconfig.json
├── tsdx.config.js
└── typedoc.json
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | indent_style = space
6 | indent_size = 4
7 | end_of_line = lf
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [*.ts|*.js]
12 | max_line_length = 120
13 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | env: {
3 | browser: true,
4 | es6: true,
5 | node: true
6 | },
7 | extends: [
8 | 'plugin:@typescript-eslint/recommended'
9 | ],
10 | globals: {
11 | Atomics: 'readonly',
12 | SharedArrayBuffer: 'readonly'
13 | },
14 | parser: '@typescript-eslint/parser',
15 | parserOptions: {
16 | ecmaVersion: 2018,
17 | sourceType: 'module'
18 | },
19 | plugins: ['@typescript-eslint'],
20 | ignorePatterns: ['node_modules/**', 'scripts/**', 'sdk-1.*/**'],
21 | rules: {
22 | '@typescript-eslint/no-var-requires': 'off',
23 | '@typescript-eslint/ban-ts-ignore': 'off',
24 | '@typescript-eslint/no-explicit-any': 'off',
25 | '@typescript-eslint/indent': ['error', 4],
26 | '@typescript-eslint/camelcase': 'off',
27 | 'indent': ['error', 4],
28 | 'object-curly-spacing': 'off',
29 | 'comma-dangle': 'off',
30 | 'arrow-parens': 'off'
31 | }
32 | };
33 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 | lerna-debug.log*
8 |
9 | # Diagnostic reports (https://nodejs.org/api/report.html)
10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11 |
12 | # Runtime data
13 | pids
14 | *.pid
15 | *.seed
16 | *.pid.lock
17 |
18 | # Directory for instrumented libs generated by jscoverage/JSCover
19 | lib-cov
20 |
21 | # Coverage directory used by tools like istanbul
22 | coverage
23 | *.lcov
24 |
25 | # nyc test coverage
26 | .nyc_output
27 |
28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29 | .grunt
30 |
31 | # Bower dependency directory (https://bower.io/)
32 | bower_components
33 |
34 | # node-waf configuration
35 | .lock-wscript
36 |
37 | # Compiled binary addons (https://nodejs.org/api/addons.html)
38 | build/Release
39 |
40 | # Dependency directories
41 | node_modules/
42 | jspm_packages/
43 |
44 | # TypeScript v1 declaration files
45 | typings/
46 |
47 | # TypeScript cache
48 | *.tsbuildinfo
49 |
50 | # Optional npm cache directory
51 | .npm
52 |
53 | # Optional eslint cache
54 | .eslintcache
55 |
56 | # Microbundle cache
57 | .rpt2_cache/
58 | .rts2_cache_cjs/
59 | .rts2_cache_es/
60 | .rts2_cache_umd/
61 |
62 | # Optional REPL history
63 | .node_repl_history
64 |
65 | # Output of 'npm pack'
66 | *.tgz
67 |
68 | # Yarn Integrity file
69 | .yarn-integrity
70 |
71 | # dotenv environment variables file
72 | .env
73 | .env.test
74 |
75 | # parcel-bundler cache (https://parceljs.org/)
76 | .cache
77 |
78 | # Next.js build output
79 | .next
80 |
81 | # Nuxt.js build / generate output
82 | .nuxt
83 | dist
84 |
85 | # Gatsby files
86 | .cache/
87 | # Comment in the public line in if your project uses Gatsby and *not* Next.js
88 | # https://nextjs.org/blog/next-9-1#public-directory-support
89 | # public
90 |
91 | # vuepress build output
92 | .vuepress/dist
93 |
94 | # Serverless directories
95 | .serverless/
96 |
97 | # FuseBox cache
98 | .fusebox/
99 |
100 | # DynamoDB Local files
101 | .dynamodb/
102 |
103 | # TernJS port file
104 | .tern-port
105 |
106 | # IDE
107 | .idea/
108 |
109 | # Output of build
110 | lib/
111 | example/
112 | dist/
113 |
114 | # OS
115 | .DS_Store
116 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | .idea/
2 | node_nodules/
3 | test/
4 | scripts/
5 | .editorconfig
6 | .gitignore
7 | .npmignore
8 | .travis.yml
9 | package-lock.json
10 |
11 | src/
12 | docs/
13 | scripts/
14 | jest.config.js
15 | tsconfig.json
16 | typedoc.json
17 | .eslintrc.js
18 | CHANGELOG.md
19 |
--------------------------------------------------------------------------------
/.npmrc:
--------------------------------------------------------------------------------
1 | registry=https://registry.npmjs.org
2 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | os: osx
2 | dist: trusty
3 | language: node_js
4 | node_js: v10
5 | install:
6 | - npm i
7 | script:
8 | - npm run build
9 | deploy:
10 | provider: npm
11 | api_key: bab647b5-704a-46d7-a4ba-5e3bce53a9d0
12 | email: smilingxinyi@gmail.com
13 | skip_cleanup: true
14 | on:
15 | tags: true
16 | repo: xuperchain/xuper-sdk-js
17 | branch: master
18 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4 |
5 | ## [2.4.0](https://github.com/xuperchain/xuper-sdk-js/compare/v2.3.0...v2.4.0) (2022-12-08)
6 |
7 | ## [2.3.0](https://github.com/xuperchain/xuper-sdk-js/compare/v2.1.0...v2.3.0) (2022-04-27)
8 |
9 |
10 | ### Features
11 |
12 | * 🎸 obtain public key string ([983ecec](https://github.com/xuperchain/xuper-sdk-js/commit/983ececeeb6c13aa41c6877fac809d8501072595))
13 |
14 | ## [2.2.0](https://github.com/xuperchain/xuper-sdk-js/compare/v2.1.0...v2.2.0) (2021-08-24)
15 |
16 |
17 | ### Features
18 |
19 | * 🎸 get account public key string ([a6d7736](https://github.com/xuperchain/xuper-sdk-js/commit/a6d7736df969f43655f32d9e2f8f456fda73a999))
20 |
21 | ## [2.1.0](https://github.com/xuperchain/xuper-sdk-js/compare/v2.0.0...v2.1.0) (2021-05-14)
22 |
23 | ## [2.0.0](https://github.com/xuperchain/xuper-sdk-js/compare/v2.0.0-beta.11...v2.0.0) (2021-04-02)
24 |
25 |
26 | ### Bug Fixes
27 |
28 | * 🐛 node modules ([425e2d4](https://github.com/xuperchain/xuper-sdk-js/commit/425e2d4b404cde1c28c3b84b16dff72da341f808))
29 |
30 | ## [2.0.0-beta.11](https://github.com/xuperchain/xuper-sdk-js/compare/v2.0.0-beta.10...v2.0.0-beta.11) (2021-03-08)
31 |
32 |
33 | ### Features
34 |
35 | * 🎸 GetBlochchains - query blockchains ([661bac8](https://github.com/xuperchain/xuper-sdk-js/commit/661bac844189548feee1ba6f990bcf7ac0b8d437))
36 | * 🎸 GetBlock & GetBlockByHeight - block info ([e146c35](https://github.com/xuperchain/xuper-sdk-js/commit/e146c3577bc943f3d5e89e74741f365de536f67f))
37 | * 🎸 new gRPC services ([3a3b1fb](https://github.com/xuperchain/xuper-sdk-js/commit/3a3b1fb23d1afa592657ac81261f9e1be6295812))
38 | * 🎸 QueryACL - query some account info ([a00c0a4](https://github.com/xuperchain/xuper-sdk-js/commit/a00c0a4637a477619afd13eb6074ac99b9b23447))
39 | * 🎸 QueryContractStat - contarct stat data ([964642d](https://github.com/xuperchain/xuper-sdk-js/commit/964642d5c0b069a3a8871d01c581099ff209ebad))
40 | * 🎸 support GET method & throw Error Response ([1f1bf54](https://github.com/xuperchain/xuper-sdk-js/commit/1f1bf5499b200a52b3705db27364f09232b3ce6a))
41 |
42 | ## [2.0.0-beta.10](https://github.com/xuperchain/xuper-sdk-js/compare/v2.0.0-beta.9...v2.0.0-beta.10) (2021-02-25)
43 |
44 |
45 | ### Features
46 |
47 | * 🎸 contract payment ([4a0f121](https://github.com/xuperchain/xuper-sdk-js/commit/4a0f121450f8704ac9bea520d7ee4d20df76541e))
48 |
49 | ## [2.0.0-beta.9](https://github.com/xuperchain/xuper-sdk-js/compare/v2.0.0-beta.8...v2.0.0-beta.9) (2021-02-22)
50 |
51 |
52 | ### Bug Fixes
53 |
54 | * 🐛 endorsement service ([c4303b6](https://github.com/xuperchain/xuper-sdk-js/commit/c4303b6e44ebc6e06311fc3181f77935c661f200))
55 |
56 | ## [2.0.0-beta.8](https://github.com/xuperchain/xuper-sdk-js/compare/v2.0.0-beta.7...v2.0.0-beta.8) (2021-02-22)
57 |
58 |
59 | ### Bug Fixes
60 |
61 | * 🐛 endorse service bug ([85db2d9](https://github.com/xuperchain/xuper-sdk-js/commit/85db2d9408670fbe1ca50695e0500bae2b53a489))
62 |
63 | ## [2.0.0-beta.7](https://github.com/xuperchain/xuper-sdk-js/compare/v2.0.0-beta.6...v2.0.0-beta.7) (2021-02-22)
64 |
65 |
66 | ### Features
67 |
68 | * 🎸 support the solidity contract ([079bbe2](https://github.com/xuperchain/xuper-sdk-js/commit/079bbe23e53a5b4e925dd6319128bdbc787d681d))
69 |
70 |
71 | ### Bug Fixes
72 |
73 | * 🐛 deployment contract support plugin ([f783d0e](https://github.com/xuperchain/xuper-sdk-js/commit/f783d0e7c1ae2ee60b6d5588529cffc033170712))
74 |
75 | ## [2.0.0-beta.6](https://github.com/xuperchain/xuper-sdk-js/compare/v2.0.0-beta.5...v2.0.0-beta.6) (2021-02-08)
76 |
77 |
78 | ### Bug Fixes
79 |
80 | * 🐛 preExecWithFee service ([28f9aa0](https://github.com/xuperchain/xuper-sdk-js/commit/28f9aa0eceb251fe68357650043610be6ef9077a))
81 |
82 | ## [2.0.0-beta.5](https://github.com/xuperchain/xuper-sdk-js/compare/v2.0.0-beta.4...v2.0.0-beta.5) (2021-02-03)
83 |
84 |
85 | ### Bug Fixes
86 |
87 | * 🐛 gRPC - postTX service ([37c480e](https://github.com/xuperchain/xuper-sdk-js/commit/37c480e5a15139bd332d2949d5cbdbcd2be455c4))
88 |
89 | ## [2.0.0-beta.4](https://github.com/xuperchain/xuper-sdk-js/compare/v2.0.0-beta.3...v2.0.0-beta.4) (2020-12-17)
90 |
91 |
92 | ### Bug Fixes
93 |
94 | * 🐛 invoke contract without plugin service ([6440c0d](https://github.com/xuperchain/xuper-sdk-js/commit/6440c0dde94d02f2999eb778a3355552b3697bf3))
95 |
96 | ## [2.0.0-beta.3](https://github.com/xuperchain/xuper-sdk-js/compare/v2.0.0-beta.2...v2.0.0-beta.3) (2020-12-14)
97 |
98 |
99 | ### Bug Fixes
100 |
101 | * 🐛 type error & export plugins ([d404c9f](https://github.com/xuperchain/xuper-sdk-js/commit/d404c9fd87ad18d7b786e479146e1eb63efbe0a9))
102 |
103 | ## [2.0.0-beta.2](https://github.com/xuperchain/xuper-sdk-js/compare/v2.0.0-beta.1...v2.0.0-beta.2) (2020-12-10)
104 |
105 |
106 | ### Bug Fixes
107 |
108 | * 🐛 build script ([03f9cf1](https://github.com/xuperchain/xuper-sdk-js/commit/03f9cf193c585ec6818942dac48835a8a86ff27c))
109 |
110 | ## [2.0.0-beta.1](https://github.com/xuperchain/xuper-sdk-js/compare/v1.1.2...v2.0.0-beta.1) (2020-12-08)
111 |
112 |
113 | ### ⚠ BREAKING CHANGES
114 |
115 | * 🧨 v1.x
116 |
117 | ### Features
118 |
119 | * 🎸 account recovery ([2d9c040](https://github.com/xuperchain/xuper-sdk-js/commit/2d9c0409bd3cf79df4e34acfb522220a792c5fb6))
120 | * 🎸 balance ([9677c1b](https://github.com/xuperchain/xuper-sdk-js/commit/9677c1b78153842d7b9d63df9cd304875363d111))
121 | * 🎸 CFCA plugin ([8cfaecc](https://github.com/xuperchain/xuper-sdk-js/commit/8cfaecc8e9f7b79d13d8a43d935425f1b9b665cb))
122 | * 🎸 contract ([4412ff7](https://github.com/xuperchain/xuper-sdk-js/commit/4412ff72a6d191dafe89629654610cd7813fdeb0))
123 | * 🎸 contract invoke ([7bbaeba](https://github.com/xuperchain/xuper-sdk-js/commit/7bbaebac350e538c98da009aa166d8e16a11ce5b))
124 | * 🎸 contract upgrade ([b6c4bc9](https://github.com/xuperchain/xuper-sdk-js/commit/b6c4bc965474537670d78ff662872f39e7635ced))
125 | * 🎸 grpc support ([76827ad](https://github.com/xuperchain/xuper-sdk-js/commit/76827ad1ccee24a199d6c8a118b904ffdd71312b))
126 | * 🎸 interfaces ([5ef9b1a](https://github.com/xuperchain/xuper-sdk-js/commit/5ef9b1a1786e242dbcbdc10ab004af6c5457e41d))
127 | * 🎸 plugins & refactor ([92b0064](https://github.com/xuperchain/xuper-sdk-js/commit/92b0064ddadff47b7d7f4999ce5a59c4ec1167d1))
128 | * 🎸 post request protocol detection and completion ([9cf9105](https://github.com/xuperchain/xuper-sdk-js/commit/9cf9105d48d826a54ebc8a8a8aa95e1f87a5d71a))
129 | * contract list & pre-execution ([2c0285c](https://github.com/xuperchain/xuper-sdk-js/commit/2c0285cf2f77c3e04e239c080063979c124571d9))
130 | * **transaction:** support nodejs & no endorsement service ([27f5dd6](https://github.com/xuperchain/xuper-sdk-js/commit/27f5dd66d216365ea945b54f42518b7ab6387861))
131 | * **xuper account:** export the encrypted private key string ([fdd941a](https://github.com/xuperchain/xuper-sdk-js/commit/fdd941a153f5ac2c8b4909c1e6d7df3f8dc25f90))
132 | * **xuper account:** support to import encrypted private key, restore account by password to decrypt ([85841b4](https://github.com/xuperchain/xuper-sdk-js/commit/85841b4706d9d78c2534138053f1c62550cedb33))
133 | * compatible Node.js ([4d4df29](https://github.com/xuperchain/xuper-sdk-js/commit/4d4df29e3db3f05681453cab4c8a413e21899fea))
134 |
135 |
136 | ### Bug Fixes
137 |
138 | * 🐛 dependencies ([a094994](https://github.com/xuperchain/xuper-sdk-js/commit/a0949948ecee6979e63db77153ad90ddccc9b7a0))
139 | * 🐛 invoke contract in plugin mode ([dcd3fec](https://github.com/xuperchain/xuper-sdk-js/commit/dcd3fec5a34976fca25dd69d7b7798d5d7c1392f))
140 | * function-return-type fix ([86982d8](https://github.com/xuperchain/xuper-sdk-js/commit/86982d8345c5142b26a833e1a0ecd305a9893e0d))
141 | * text-decoder & text-encoder ([44bc939](https://github.com/xuperchain/xuper-sdk-js/commit/44bc939da59af945ffb57a37f4b2a9f22fa07dd8))
142 | * **account:** cryptography error ([04e9768](https://github.com/xuperchain/xuper-sdk-js/commit/04e9768ea367b123c1c2e8f4ac0c2aeb2c6eba1b))
143 | * **account.ts:** generate address - bytes length fix ([1e17a72](https://github.com/xuperchain/xuper-sdk-js/commit/1e17a72d5dbfa0232235aba32f8b3757f4091a2c))
144 |
145 | ### [1.1.2](https://github.com/xuperchain/xuper-sdk-js/compare/v1.1.1...v1.1.2) (2020-04-30)
146 |
147 |
148 | ### Bug Fixes
149 |
150 | * **src/utils.ts:** replace for-in with for-each ([f400e28](https://github.com/xuperchain/xuper-sdk-js/commit/f400e2817e834dee8d6f4f011278df7ce7a944fd))
151 |
152 | ### [1.1.1](https://github.com/xuperchain/xuper-sdk-js/compare/v1.1.0...v1.1.1) (2020-03-16)
153 |
154 | ## [1.1.0](https://github.com/xuperchain/xuper-sdk-js/compare/v1.0.3...v1.1.0) (2020-02-17)
155 |
156 |
157 | ### Features
158 |
159 | * smart contract feature ([a46ea9f](https://github.com/xuperchain/xuper-sdk-js/commit/a46ea9f72d71a316dfac53f31861c33c5e5aa43b))
160 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Xuper SDK JS
2 |
3 | [](https://travis-ci.org/xuperchain/xuper-sdk-js)
4 | [](https://badge.fury.io/js/%40xuperchain%2Fxuper-sdk)
5 |
6 | Xuper SDK (JS/TS) is a software development kit that allows developers to quickly use XuperChain.
7 |
8 | The SDK provides a service interface that includes account, transaction, contract and various query functions. It can be used in a browser and Nodejs environment.
9 |
10 | ---
11 |
12 | English | [简体中文](./README_zh-CN.md)
13 |
14 | ## Usage
15 |
16 | ### Install Npm package
17 |
18 | > npm install --save @xuperchain/xuper-sdk
19 |
20 | ### Quick start
21 |
22 | ```javascript
23 | import XuperSDK from '@xuperchain/xuper-sdk';
24 |
25 | const node = ''; // node
26 | const chain = ''; // chain
27 |
28 | const xsdk = XuperSDK.getInstance({
29 | node,
30 | chain
31 | });
32 |
33 | const start = async () => {
34 | const result = await xsdk.getBlockChains();
35 | console.log(result);
36 | };
37 |
38 | start();
39 | ```
40 |
41 | *[Details - API reference](#api-reference-documentation)*
42 |
43 |
44 | ### Code examples
45 |
46 | [](https://codesandbox.io/s/xuper-sdk-demo-q5m93?fontsize=14&hidenavigation=1&theme=dark)
47 |
48 | ### Environments
49 |
50 | - Browser depends on window.crypto
51 | - Nodejs >= v10.0
52 |
53 | ##### In the Nodejs environment, **gRPC** is supported and used by default, you can choose to close it, and still use Http to request
54 | ```javascript
55 | XuperSDK.getInstance({
56 | ...,
57 | env: {
58 | node: {
59 | disableGRPC: true // disable gRPC
60 | }
61 | }
62 | })
63 | ```
64 |
65 | ### How to build a test environment
66 |
67 | #### Read the [documentation](https://github.com/xuperchain/xuperchain) , compile and deploy XuperChain
68 |
69 | #### Use XuperChain Docker image to build a single-node service
70 |
71 | 1. Pull image (*XuperChian v3.7 - [Repository](https://github.com/SmilingXinyi/xuperchain)*)
72 | > docker pull smilingxinyi/xuperchain
73 |
74 | 2. Start container
75 | > docker run -d -p 8098:8098 -p 37101:37101 -p 47101:47101 --name xc smilingxinyi/xuperchain
76 |
77 | ## API reference documentation
78 |
79 | [Link](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html)
80 |
81 | ## Services
82 |
83 | ### Account
84 |
85 | service|name|link|state
86 | ---|---|---|:---:
87 | Create account|create|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#create)|√
88 | Retrieve account|retrieve|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#retrieve)|√
89 | Import private key|import|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#import)|√
90 | Export private key|export|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#export)|√
91 | Chekc address|checkAddress|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#checkaddress)|√
92 | Check mnemonic|checkMnemonic|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#checkmnemonic)|√
93 | Balance|getBalance|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#getbalance)|√
94 | Balance Detail|getBalanceDetail|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#getbalanceDetail)|√
95 |
96 | ### Blockchain infomation
97 |
98 | service|name|link|state
99 | ---|---|---|:---:
100 | Blockchains|getBlockChains|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#getBlockChains)|√
101 | Status|checkStatus|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#checkStatus)|√
102 | Block by id|getBlockById|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#getBlockById)|√
103 | Block by height|getBlockByHeight|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#getBlockByHeight)|√
104 |
105 | ### Transaction
106 |
107 | service|name|link|state
108 | ---|---|---|:---:
109 | Make transfer|transfer|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#transfer)|√
110 | Post tx|postTransaction|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#postTransaction)|√
111 | Query tx|queryTransaction|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#queryTransaction)|√
112 |
113 | ### Contract
114 |
115 | service|name|link|state
116 | ---|---|---|:---:
117 | New contract account|createContractAccount|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#createContractAccount)|√
118 | Contract list|getContracts|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#getContracts)|√
119 | Deploy Wasm contract|deployWasmContract|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#deployWasmContract)|√
120 | Invoke Wasm contarct|invokeContarct|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#invokeContarct)|√
121 | Deploy Solidity contract|deploySolidityContract|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#deploySolidityContract)|√
122 | Invoke Solidity contarct|invokeSolidityContarct|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#invokeSolidityContarct)|√
123 | Deploy Native contract|deployNativeContract|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#deployNativeContract)|√
124 | Invoke Native contarct|invokeContarct|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#invokeContarct)|√
125 | Query ACL|queryACL|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#queryACL)|√
126 | Query stat data about contract|queryContractStatData|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#queryContractStatData)|√
127 |
128 | ## Plugin
129 |
130 | #### Endorsement service plugin
131 |
132 | > The plugin must be used on the `public network`
133 |
134 | ##### EndorsementPlugin
135 |
136 | Example:
137 |
138 | ```javascript
139 |
140 | const params = {
141 | server: process.env.ENDORSE_SERVER, // ip, port
142 | fee: process.env.FEE, // fee
143 | endorseServiceCheckAddr: process.env.SERVICE_SIGN_ADDRESS, // sign address
144 | endorseServiceFeeAddr: process.env.SERVICE_FEE_ADDRESS // fee address
145 | }
146 |
147 | const xsdk = new XuperSDK({
148 | node,
149 | chain,
150 | plugins: [
151 | EndorsementPlugin({
152 | transfer: params,
153 | makeTransaction: params
154 | })
155 | ]
156 | });
157 |
158 | ```
159 |
--------------------------------------------------------------------------------
/README_zh-CN.md:
--------------------------------------------------------------------------------
1 | # Xuper SDK (JS/TS)
2 |
3 | [](https://travis-ci.org/xuperchain/xuper-sdk-js)
4 | [](https://badge.fury.io/js/%40xuperchain%2Fxuper-sdk)
5 |
6 | Xuper SDK (JS/TS) 是一个在可以让开发者快速使用 XuperChain 的软件开发工具包。
7 |
8 | 该SDK提供包含账号、交易、合约与各类查询功能的服务接口,可以在浏览器与 Nodejs 环境下使用。
9 |
10 | ---
11 |
12 | [English](./README.md) | 简体中文
13 |
14 | ## 使用方式
15 |
16 | ### 安装Npm依赖包
17 |
18 | > npm install --save @xuperchain/xuper-sdk
19 |
20 | ### 快速开始
21 |
22 | ```javascript
23 | import XuperSDK from '@xuperchain/xuper-sdk';
24 |
25 | const node = ''; // 节点
26 | const chain = ''; // 链
27 |
28 | const xsdk = XuperSDK.getInstance({
29 | node,
30 | chain
31 | });
32 |
33 | const start = async () => {
34 | const result = await xsdk.getBlockChains();
35 | console.log(result);
36 | };
37 |
38 | start();
39 | ```
40 |
41 | *[具体API查看详情](#API参考文档)*
42 |
43 | ### 使用示例代码
44 |
45 | [](https://codesandbox.io/s/xuper-sdk-demo-q5m93?fontsize=14&hidenavigation=1&theme=dark)
46 |
47 | ### 支持环境
48 | - Browser 依赖 window.crypto
49 | - Nodejs >= v10.0
50 |
51 | ##### 在Nodejs环境中支持并默认使用**gRPC**,可以选择关闭,依然使用Http方式请求
52 | ```javascript
53 | XuperSDK.getInstance({
54 | ...,
55 | env: {
56 | node: {
57 | disableGRPC: true // 禁用gRPC
58 | }
59 | }
60 | })
61 | ```
62 |
63 | ### 如何搭建一个测试环境
64 |
65 | #### 阅读 [文档](https://github.com/xuperchain/xuperchain) 编译并部署XuperChain
66 |
67 | #### 通过Docker搭建一个搭建单节点服务
68 |
69 | 1. 拉取镜像 (*XuperChian v3.7 - [Repository](https://github.com/SmilingXinyi/xuperchain)*)
70 | > docker pull smilingxinyi/xuperchain
71 |
72 | 2. 启动容器
73 | > docker run -d -p 8098:8098 -p 37101:37101 -p 47101:47101 --name xc smilingxinyi/xuperchain
74 |
75 | ## API参考文档
76 |
77 | [文档链接](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html)
78 |
79 | ## 实现列表
80 |
81 | ### 区块链账号
82 |
83 | 接口|函数名|文档链接|状态
84 | ---|---|---|:---:
85 | 创建区块链账号|create|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#create)|√
86 | 助记词恢复账号|retrieve|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#retrieve)|√
87 | 导入私钥|import|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#import)|√
88 | 导出私钥|export|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#export)|√
89 | 检查地址|checkAddress|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#checkaddress)|√
90 | 检查助记词|checkMnemonic|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#checkmnemonic)|√
91 | 获取余额|balance|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#getbalance)|√
92 | 获取余额详情|getBalanceDetail|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#getbalanceDetail)|√
93 |
94 | ### 链信息
95 |
96 | 接口|函数名|文档链接|状态
97 | ---|---|---|:---:
98 | 获取链|getBlockChains|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#getBlockChains)|√
99 | 查看当前链状态|checkStatus|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#checkStatus)|√
100 | 通过交易ID获取块信息|getBlockById|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#getBlockById)|√
101 | 通过高度获取块信息|getBlockByHeight|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#getBlockByHeight)|√
102 |
103 | ### 交易
104 |
105 | 接口|函数名|文档链接|状态
106 | ---|---|---|:---:
107 | 转账|transfer|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#transfer)|√
108 | 发送交易|postTransaction|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#postTransaction)|√
109 | 查询交易|queryTransaction|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#queryTransaction)|√
110 |
111 | ### 智能合约
112 |
113 | 接口|函数名|文档链接|状态
114 | ---|---|---|:---:
115 | 创建合约账户|createContractAccount|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#createContractAccount)|√
116 | 获取合约|getContracts|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#getContracts)|√
117 | 部署 Wasm 合约|deployWasmContract|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#deployWasmContract)|√
118 | 调用 Wasm 合约|invokeContarct|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#invokeContarct)|√
119 | 部署 Solidity 合约|deploySolidityContract|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#deploySolidityContract)|√
120 | 调用 Solidity 合约|invokeSolidityContarct|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#invokeSolidityContarct)|√
121 | 部署 Native 合约|deployNativeContract|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#deployNativeContract)|√
122 | 调用 Native 合约|invokeContarct|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#invokeContarct)|√
123 | 查询访问控制列表|queryACL|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#queryACL)|√
124 | 查询合约状态|queryContractStatData|[LINK](https://xuperchain.github.io/xuper-sdk-js/classes/xupersdk.html#queryContractStatData)|√
125 |
126 | ## 插件与使用
127 |
128 | #### 背书服务插件
129 |
130 | > `公开网络`必须使用该插件
131 |
132 | ##### EndorsementPlugin
133 |
134 | Example:
135 |
136 | ```javascript
137 |
138 | const params = {
139 | server: process.env.ENDORSE_SERVER, // 服务
140 | fee: process.env.FEE, // 服务费
141 | endorseServiceCheckAddr: process.env.SERVICE_SIGN_ADDRESS, // 背书签名地址
142 | endorseServiceFeeAddr: process.env.SERVICE_FEE_ADDRESS // 背书服务费地址
143 | }
144 |
145 | const xsdk = new XuperSDK({
146 | node,
147 | chain,
148 | plugins: [
149 | EndorsementPlugin({
150 | transfer: params,
151 | makeTransaction: params // 两个一样
152 | })
153 | ]
154 | });
155 |
156 | ```
157 |
--------------------------------------------------------------------------------
/docs/assets/images/icons.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xuperchain/xuper-sdk-js/495d8b61f5ef9f7b2bd3f0826e017ef0b9ec3e62/docs/assets/images/icons.png
--------------------------------------------------------------------------------
/docs/assets/images/icons@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xuperchain/xuper-sdk-js/495d8b61f5ef9f7b2bd3f0826e017ef0b9ec3e62/docs/assets/images/icons@2x.png
--------------------------------------------------------------------------------
/docs/assets/images/widgets.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xuperchain/xuper-sdk-js/495d8b61f5ef9f7b2bd3f0826e017ef0b9ec3e62/docs/assets/images/widgets.png
--------------------------------------------------------------------------------
/docs/assets/images/widgets@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xuperchain/xuper-sdk-js/495d8b61f5ef9f7b2bd3f0826e017ef0b9ec3e62/docs/assets/images/widgets@2x.png
--------------------------------------------------------------------------------
/docs/enums/cryptography.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
Cryptography
73 |