Skip to content

Commit ca03210

Browse files
authored
Merge pull request #2 from symbol-blockchain-community/update-documents
update documents
2 parents 7d8ae7b + 943a687 commit ca03210

File tree

3 files changed

+27
-11
lines changed

3 files changed

+27
-11
lines changed

.github/workflows/npm-publish.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ jobs:
1616
with:
1717
node-version: 20
1818
- run: npm ci
19-
- run: npm lint
2019
- run: npm build
2120

2221
publish-npm:

README.md

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
# Symbol SDK Crypto
1+
# expo-symbol-sdk
22

3-
This library is a lightweight SDK extracted from the Symbol SDK’s use of Node.js’s crypto module. To avoid complex dependency resolutions on platforms like Web, Node.js, and React Native, this library serves as the base for SDKs tailored to each platform. This light version of the SDK offers the following features:
3+
expo-symbol-sdk is a symbol-sdk optimized for use on expo managed react native. This sdk can be used by application developers simply by installing it, without the need for complex environment setup.
4+
5+
However, this sdk is a lightweight package that extracts only the functions of symbol-sdk that depend on the node.js core module. Only the following features are provided compared to the original symbol-sdk:
46

57
- Creation and loading of private keys
68
- Encryption and decryption of messages
@@ -32,7 +34,7 @@ console.log(account);
3234
Signing a transaction created with symbol-sdk.
3335

3436
```ts
35-
const account = Account.generateNewAccount(NetworkType.TEST_NET);
37+
import { Account, NetworkType } from '@symbol-blockchain-community/expo-symbol-sdk';
3638

3739
const generationHash = '49D6E1CE276A85B70EAFE52349AACCA389302E7A9754BCF1221E79494FC665A4';
3840
const serializedTransactionPayload =
@@ -43,15 +45,15 @@ const serializedTransactionPayload =
4345
'985441F84300000000000003983E640900000098EC10797B167D59E419781125' +
4446
'EE36676AA61D9E4F90CDAF0E000000000000000048656C6C6F2053796D626F6C21';
4547

48+
const account = Account.generateNewAccount(NetworkType.TEST_NET);
4649
const signedPayload = account.sign(serializedTransactionPayload, generationHash);
4750
console.log(signedPayload);
4851
```
4952

5053
Encryption and decryption of messages.
5154

5255
```ts
53-
import { MessageEncoder, Account } from '@symbol-blockchain-community/expo-symbol-sdk';
54-
import { Account, NetworkType } from 'symbol-sdk';
56+
import { MessageEncoder, Account, NetworkType } from '@symbol-blockchain-community/expo-symbol-sdk';
5557

5658
const alice = Account.generateNewAccount(NetworkType.TEST_NET);
5759
const bob = Account.generateNewAccount(NetworkType.TEST_NET);
@@ -60,14 +62,23 @@ const messageEncoder = new MessageEncoder(alice.privateKey);
6062
const messageDecoder = new MessageEncoder(bob.privateKey);
6163

6264
const encoded = messageEncoder.encode(bob.publicKey, 'Hello, symbol!');
63-
console.log('encoded: ', encoded);
6465
const decoded = messageDecoder.tryDecode(alice.publicKey, encoded);
66+
console.log('encoded: ', encoded);
6567
console.log('decoded: ', decoded);
6668
```
6769

70+
`MessageEncoder.encode` returns a `Uint8Array`. It can be used directly with symbol-sdk@3. However, if you need to handle it as a string, you can convert it to hex with the following implementation.
71+
72+
```javascript
73+
const hex = Array.from(encoded).map(b => b.toString(16).padStart(2, '0')).join('');
74+
```
75+
76+
Application developers do not need to be aware of this, but when an encrypted message is sent to a node and retrieved from the node again, the "01" will be added to the beginning of the hex string. This is a flag to indicate that the message is encrypted.
77+
If you want to send an encrypted message to another application without going through a node and decrypt it using the SDK, you need to add "01" to the beginning of the hex yourself.
78+
6879
## Contributing
6980

70-
expo-symbol-crypto is an open-source project. Contributions are welcome. Please refer to the GitHub repository for details.
81+
`expo-symbol-crypto` is an open-source project. Contributions are welcome. Please refer to the GitHub repository for details.
7182

7283
## License
7384

@@ -76,3 +87,9 @@ This software is provided under the [MIT License](./LICENSE).
7687
## Contact
7788

7889
For questions or feedback, please contact us through the GitHub repository.
90+
91+
## External sites
92+
93+
* [Symbol Community Web](https://symbol-community.com)
94+
* [Symbol Document](https://docs.symbol.dev/ja/index.html)
95+
* [Symbol/NEM Discord](https://discord.gg/xymcity)

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@symbol-blockchain-community/expo-symbol-sdk",
3-
"version": "0.0.1-6",
3+
"version": "1.0.0",
44
"description": "This package is a standalone alternative to symbol-sdk for managed React Native environments with Expo.",
55
"main": "dist/cjs/index.js",
66
"module": "dist/esm/index.js",
@@ -9,7 +9,7 @@
99
"author": "ym.u.ichiro@gmail.com",
1010
"homepage": "https://symbol-community.com",
1111
"repository": {
12-
"url": "https://github.com/Symbol-Blockchain-Community/expo-symbol-sdk"
12+
"url": "https://github.com/symbol-blockchain-community/expo-symbol-sdk"
1313
},
1414
"publishConfig": {
1515
"access": "public"
@@ -58,4 +58,4 @@
5858
"README.md",
5959
"LICENSE"
6060
]
61-
}
61+
}

0 commit comments

Comments
 (0)