SDK の最初のグループを構築するときに私たちが持っていた主な目的の 1 つは、開発者がまったく異なる設計に適応することなく、プログラミング言語間で迅速に変更できるようにすることでした。このドキュメントは相互運用性を実現するために、同じ設計を共有する Symbol ベースの SDK を出荷するように開発者をガイドすることを目的としています。
パッケージ構成ダイアグラム
インフラストラクチャ
このパッケージには生成された API クライアントと DTO が含まれています。HTTP リクエストはリポジトリパターンに則しており、これらはオブザーバルパターンを介して Symbol の変更不可なモデルを返します。
モデル
Symbol ドメインモデルは定義によっては不変ですが、開発者はその属性を変更できません。代わりに、開発者は新しいトランザクションを作成して TransactionHTTP 経由でブロックチェーンへ送信する必要があります。
サービス
複数の REST API リクエストを結合する必要がある一般的な操作
Symbol SDK は ReactiveX Library ライブラリを多用しています。
リアクティブアプローチを使用する利点は次のとおりです:
リアクティブプログラミングを初めて使用する場合は、オンラインガイド Learn RxJS から始めることをお勧めします。
#sig-api
チャンネルであなたの意向をコメントしてください。You can base your work on the TypeScript SDK. The TypeScript version is the first SDK getting the latest updates. Check regularly the Changelog to be sure you didn’t miss any code change update.
可能であれば GitHub で新しいリポジトリを作成します:
良好なテストカバレッジのプロジェクトは開発者にとって、より信頼のおけるものとなるでしょう。
We strongly suggest to do Test-Driven Development or Unit-Testing (test last). If you need inspiration, feel free to adapt directly the same tests we did.
travis.yml
configuration fileOnce you have written some tests, setup a Continuous Integration (CI) system to run the test suite and code linter automatically. We use travis-ci, but feel free to use the one that suits you best.
Also, we strive to keep our codebases with a unit test coverage of 80% or higher. We use coveralls to monitor test coverage.
The OpenAPI Generator handles the API and DTOs generation. It supports multiple languages, and hopefully, yours is on the list.
These are the steps we followed to generate the Typescript DTOs (data transfer objects):
openapi-generator generate -i ./openapi3.yml -g typescript-node -o ./symbol-ts-sdk/ && rm -R symbol-ts-sdk/test
注釈
The SDK for TypeScript currently chooses the typescript-node
template from the OpenAPI Generator, but there are also other templates available to fit for other purposes. The SDK has interfaced out all the Http Repositories so that different implementations can be applied.
リポジトリ実装の例:
See the complete list of repositories and implementations.
By default, models are immutable and aim to hide the complexity, like type conversion or relationship between objects.
モデル実装の例:
See the complete list of models.
You will find in the implementations different invariants to ensure the object is well constructed and a nicer API is published.
Particular decisions we considered:
uint64
, use that implementation instead.uint64
id. A specific endpoint returns the Namespace string
name.catbuffer ライブラリ は Symbol のエンティティをシリアライズ/デシリアライズするプロトコルを定義します。
In combination with the catbuffer-generators project, developers can generate builder classes for a given set of programming languages. For example, the Symbol SDK uses the generated code to operate with the entities in binary form.
注釈
If there is no generator for the programming language selected, you will need to develop it first. You can base your work on the generator for TypeScript.
If there is a generator, follow the next steps to generate the builders for all the existent entities:
git clone --recursive [email protected]:nemtech/catbuffer-generators.git
pip install -r requirements.txt
catbuffer-generators
folder.catbuffer-generators
directory, replacing cpp_builder
for the targeted programming language. python scripts/generate_all.sh cpp_builder
The previous command creates a new file for every schema under the catbuffer/_generated/cpp_builder
folder.
Here you can find some examples of how we used transactions builders:
See the complete list of transactions.
注釈
このセクションは未完了です。
Cryptographic functions are required to sign transactions. All the crypto-related functions can be found under the core/crypto module.
SDKs use standard tweetnacl
(ed2559) for key pair generation, address derivation (from public key) and signings:
Finally, pay special attention to the test vectors. The best way to make sure your implementation is correct is to use the test vectors files as inputs and expected outputs.
ベクタテストの例:
Services combine multiple REST API requests and provide developers with handy methods that cannot be retrieved directly from the API.
Services are considered 「nice to have」 features, and these usually are not required to consider the SDK complete. We recommend starting coding services only if you have a fully operational and well-tested SDK first.
サービスの例:
See the complete list of services.
The SDKs need to be adopted by other developers. As the main developer, no one knows better than you how the SDK works. Consider helping others and spread the usage of the SDK by providing the following documentation.
To make an SDK officially supported, submit it as a NIP. The reason behind the Symbol Improvement Proposal is to ensure that the new libraries are reviewed, tested, and shared among Symbol developers.
お探しのものは見つかりましたか? フィードバックをください。