-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: grapebaba <[email protected]>
- Loading branch information
Showing
57 changed files
with
1,933 additions
and
1,139 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 |
---|---|---|
|
@@ -18,7 +18,7 @@ upcoming TestNet launch. | |
|
||
## Using | ||
|
||
The latest 0.4.2 version tested with sui devnet-0.24.0 version. | ||
The latest 0.4.3 version tested with sui devnet-0.24.0 version. | ||
|
||
### Maven | ||
|
||
|
@@ -27,15 +27,15 @@ The latest 0.4.2 version tested with sui devnet-0.24.0 version. | |
<dependency> | ||
<groupId>me.grapebaba</groupId> | ||
<artifactId>sui4j</artifactId> | ||
<version>0.4.2</version> | ||
<version>0.4.3</version> | ||
</dependency> | ||
``` | ||
|
||
### Gradle | ||
|
||
```groovy | ||
// https://mvnrepository.com/artifact/me.grapebaba/sui4j | ||
implementation 'me.grapebaba:sui4j:0.4.2' | ||
implementation 'me.grapebaba:sui4j:0.4.3' | ||
``` | ||
|
||
## Building Locally | ||
|
@@ -70,10 +70,7 @@ doc. | |
``` | ||
git clone [email protected]:MystenLabs/sui.git | ||
cd sui | ||
cargo build --release | ||
cd sui/target/release | ||
./sui genesis | ||
./sui start | ||
RUST_LOG="consensus=off" cargo run --bin sui-test-validator | ||
``` | ||
|
||
#### To run Integration tests | ||
|
@@ -82,104 +79,133 @@ cd sui/target/release | |
./gradlew integrationTest | ||
``` | ||
|
||
## Supported APIs (sui SDK 0.25.0) | ||
|
||
- [x] sui_batchTransaction | ||
- [ ] sui_devInspectTransaction | ||
- [x] sui_dryRunTransaction | ||
- [x] sui_executeTransaction | ||
- [x] sui_executeTransactionSerializedSig(same with sui_executeTransaction) | ||
- [x] sui_getAllBalances | ||
- [x] sui_getAllCoins | ||
- [x] sui_getBalance | ||
- [x] sui_getCheckpointContents | ||
- [x] sui_getCheckpointContentsByDigest | ||
- [x] sui_getCheckpointSummary | ||
- [x] sui_getCheckpointSummaryByDigest | ||
- [x] sui_getCoinMetadata | ||
- [x] sui_getCoins | ||
- [x] sui_getCommitteeInfo | ||
- [ ] sui_getDelegatedStakes | ||
- [ ] sui_getDynamicFieldObject | ||
- [ ] sui_getDynamicFields | ||
- [x] sui_getEvents | ||
- [ ] sui_getLatestCheckpointSequenceNumber | ||
- [x] sui_getMoveFunctionArgTypes | ||
- [x] sui_getNormalizedMoveFunction | ||
- [x] sui_getNormalizedMoveModule | ||
- [x] sui_getNormalizedMoveModulesByPackage | ||
- [x] sui_getNormalizedMoveStruct | ||
- [x] sui_getObject | ||
- [x] sui_getObjectsOwnedByAddress | ||
- [x] sui_getObjectsOwnedByObject | ||
- [x] sui_getRawObject | ||
- [x] sui_getReferenceGasPrice | ||
- [x] sui_getSuiSystemState | ||
- [ ] sui_getTotalSupply | ||
- [x] sui_getTotalTransactionNumber | ||
- [x] sui_getTransaction | ||
- [ ] sui_getTransactionAuthSigners | ||
- [x] sui_getTransactions | ||
- [x] sui_getTransactionsInRange | ||
- [ ] sui_getValidators | ||
- [x] sui_mergeCoins | ||
- [x] sui_moveCall | ||
- [x] sui_pay | ||
- [x] sui_payAllSui | ||
- [x] sui_paySui | ||
- [x] sui_publish | ||
- [ ] sui_requestAddDelegation | ||
- [ ] sui_requestSwitchDelegation | ||
- [ ] sui_requestWithdrawDelegation | ||
- [x] sui_splitCoin | ||
- [x] sui_splitCoinEqual | ||
- [x] sui_subscribeEvent | ||
- [ ] sui_tblsSignRandomnessObject | ||
- [x] sui_transferObject | ||
- [x] sui_transferSui | ||
- [x] sui_tryGetPastObject | ||
|
||
|
||
## Examples | ||
## How to use it | ||
|
||
- local-fullnode:http://127.0.0.1:9000 | ||
- local-faucet:http://localhost:9123 | ||
- devnet-fullnode:https://fullnode.devnet.sui.io | ||
- devnet-faucet:https://faucet.devnet.sui.io | ||
|
||
### Connecting to Sui Network | ||
```java | ||
Sui sui = new Sui("<full_node_url>","<faucet_url>","<your_keystore_path>"); | ||
``` | ||
|
||
### New Address | ||
```java | ||
KeyResponse keyRes = sui.newAddress(SignatureScheme.ED25519); | ||
``` | ||
|
||
### Request Faucet | ||
```java | ||
CompletableFuture<FaucetResponse> faucetRes = sui.requestSuiFromFaucet(s); | ||
``` | ||
|
||
### Writing APIs | ||
|
||
#### Move Call | ||
```java | ||
String BASE_URL="http://localhost:9000"; | ||
// It must be a absolute path | ||
String TEST_KEY_STORE_PATH= | ||
System.getProperty("user.home")+"/.sui/sui_config/sui.keystore"; | ||
Sui sui=new Sui(BASE_URL,TEST_KEY_STORE_PATH); | ||
|
||
// query objects | ||
CompletableFuture<List<SuiObjectInfo>>res= | ||
sui.getObjectsOwnedByAddress("0xea79464d86786b7a7a63e3f13f798f29f5e65947"); | ||
List<SuiObjectInfo> objects=res.get(); | ||
String coinObjectId=objects.get(0).getObjectId(); | ||
List<String> addresses=new ArrayList<>(sui.addresses()); | ||
|
||
// Transfer sui | ||
CompletableFuture<ExecuteTransactionResponse> res1= | ||
sui.transferSui( | ||
"0xea79464d86786b7a7a63e3f13f798f29f5e65947", | ||
coinObjectId, | ||
100L, | ||
addresses.get(0), | ||
2000L, | ||
ExecuteTransactionRequestType.WaitForLocalExecution); | ||
|
||
CompletableFuture<ExecuteTransactionResponse> res2= | ||
CompletableFuture<TransactionBlockResponse> callRes = | ||
sui.moveCall( | ||
"0xea79464d86786b7a7a63e3f13f798f29f5e65947", | ||
"0x0000000000000000000000000000000000000002", | ||
"devnet_nft", | ||
"mint", | ||
Lists.newArrayList(), | ||
Lists.newArrayList( | ||
"Example NFT", | ||
"An example NFT.", | ||
"ipfs://bafkreibngqhl3gaa7daob4i2vccziay2jjlp435cf66vhono7nrvww53ty"), | ||
null, | ||
2000L, | ||
ExecuteTransactionRequestType.WaitForLocalExecution); | ||
"0x0a7421363a1f6a82800f7c9340ac02b5905798cb", | ||
"0x02", | ||
"pay", | ||
"split", | ||
Lists.newArrayList(structType), | ||
Lists.newArrayList("0x4b89576d18d500194f14c935bc8b297a8e1556f3217e5f125ae3d1c0f13408f9", 10000L), | ||
null, | ||
3000000L, | ||
null, | ||
null, | ||
transactionBlockResponseOptions, | ||
ExecuteTransactionRequestType.WaitForLocalExecution); | ||
``` | ||
|
||
#### Transfer Object | ||
```java | ||
CompletableFuture<TransactionBlockResponse> res = | ||
sui.transferObjects( | ||
sender.get(), | ||
Lists.newArrayList(objects.get(0).getData().getObjectId()), | ||
recipient.get(), | ||
null, | ||
3000000L, | ||
null, | ||
null, | ||
transactionBlockResponseOptions, | ||
ExecuteTransactionRequestType.WaitForLocalExecution); | ||
``` | ||
|
||
#### Publish | ||
```java | ||
CompletableFuture<TransactionBlockResponse> res = | ||
sui.publish( | ||
sender.get(), | ||
Lists.newArrayList( | ||
"oRzrCwYAAAAKAQAUAhQsA0BJBIkBEgWbAWcHggLNAgjPBGAGrwXCAwrxCC0MngnUAQAMAR4B" | ||
+ "JAIRAh0CHwIlAiYCJwIoAAACAAABDAAAAwQAAQQHAQAAAgYHAAMCDAEIAQQIBAAFBQwABwcCAAkJ" | ||
+ "BwAAFgABAAEcARUBAAEjFBUBAAIpCwwAAwoNAQEIAxoJCgEIBBoSEwAFDgYHAQIGIREBAQwGJREB" | ||
+ "AQgHIg4PAAgXBAUBAgkbCxYACwMHAwUIBAgIEAgHAgwBDAkIAggABwgIAAILBQEIAQgHAQgAAQYJ" | ||
+ "AAEBAgkABwgIAQgHAQgBAgYIBwcICAELBQEJAAEKAgEIBAMHCwUBCQAKCAQKCAQBBggIAQUBCwUB" | ||
+ "CAECCQAFAQcICAEIBgEJAAELAwEJAAEICQVCT0FSUwRCb2FyB0Rpc3BsYXkITWV0YWRhdGEGT3B0" | ||
+ "aW9uCVB1Ymxpc2hlcgZTdHJpbmcJVHhDb250ZXh0A1VJRANVcmwMYWRkX211bHRpcGxlA2FnZQVi" | ||
+ "b2F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ImJUZpcnN0IEJvYXIgZnJvbSB0aGUgQm9hcnMgY29sbGVj" | ||
+ "dGlvbiEKAgYFQ2hyaXMKAiAfaHR0cHM6Ly9nZXQtYS1ib2FyLmZ1bGx1cmwuY29tLwACARIBAQIJ" | ||
+ "FAgGFQgEGQgEEAgEDwsDAQgEIAsDAQgEGAgCDQUTCAkCAgELAwAAAAACXw4AOAAEBAUICwEBBwAn" | ||
+ "CwAKATgBDAMOAwoBOAIMAg0CBwERAwcCEQMHAxEDBwQRAwcFEQMHBhEDBwcRAwcIEQMHCREDBwoR" | ||
+ "A0AMCgAAAAAAAAAHCxEDBwwRAwcNEQMHDhEDBw8RAwcQEQMHEREDBxIRAwcTEQMHFBEDQAwKAAAA" | ||
+ "AAAAADgDCwIKAS4RCjgECwMKAS4RCjgFCgERBgcVEQMHFhEDBxcRAwcYEQM4BjgHBgoAAAAAAAAA" | ||
+ "EgIKAS4RCgcZEQwSAQsBLhEKOAgCAA=="), | ||
Lists.newArrayList( | ||
"0x0000000000000000000000000000000000000000000000000000000000000001", | ||
"0x0000000000000000000000000000000000000000000000000000000000000002"), | ||
null, | ||
30000000L, | ||
null, | ||
null, | ||
transactionBlockResponseOptions, | ||
ExecuteTransactionRequestType.WaitForLocalExecution); | ||
``` | ||
|
||
### Reading APIs | ||
|
||
#### Get Owned Objects | ||
```java | ||
CompletableFuture<PaginatedObjectsResponse> res = | ||
sui.getObjectsOwnedByAddress(sender.get(), null, null, null); | ||
``` | ||
|
||
#### Get Coins | ||
```java | ||
CompletableFuture<PaginatedCoins> res = sui.getAllCoins(sender.get(), null, null); | ||
``` | ||
|
||
#### Get Transaction Block | ||
```java | ||
CompletableFuture<PaginatedTransactionResponse> res = | ||
sui.queryTransactionBlocks(query, null, 10, false); | ||
``` | ||
|
||
### Event APIs | ||
|
||
#### Subscribe | ||
```java | ||
Disposable disposable = | ||
sui.subscribeEvent(eventFilter, System.out::println, System.out::println); | ||
|
||
disposable.dispose(); | ||
``` | ||
|
||
For more examples, you can see [SuiIntTests](src/integrationTest/java/io/sui/SuiIntTests.java) | ||
|
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 |
---|---|---|
|
@@ -11,7 +11,7 @@ plugins { | |
|
||
|
||
group 'me.grapebaba' | ||
version '0.4.2' | ||
version '0.4.3' | ||
|
||
repositories { | ||
mavenCentral() | ||
|
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,17 @@ | ||
## New Address | ||
|
||
### Generate Address | ||
|
||
```java | ||
KeyResponse res1 = sui.newAddress(SignatureScheme.ED25519); | ||
|
||
KeyResponse res2 = sui.newAddress(SignatureScheme.Secp256k1); | ||
``` | ||
|
||
### Request Faucet | ||
|
||
```java | ||
CompletableFuture<FaucetResponse> res = sui.requestSuiFromFaucet(s); | ||
``` | ||
|
||
For more examples, you can see [SuiIntTests](https://github.com/GrapeBaBa/sui4j/blob/main/src/integrationTest/java/io/sui/SuiIntTests.java) |
Oops, something went wrong.