Skip to content

Commit 62369c9

Browse files
author
Xiao Li
authored
rename to diem, regen code and fix tests (#61)
* rename to diem, regen code and fix tests * update version to 1.0.0 for publish new version * fix git submodule * rename account identifier hrp
1 parent db54aa5 commit 62369c9

File tree

110 files changed

+4189
-2805
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+4189
-2805
lines changed

.gitmodules

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
[submodule "libra"]
2-
path = libra
3-
url = https://github.com/libra/libra.git
1+
[submodule "diem"]
2+
path = diem
3+
url = https://github.com/diem/diem.git

CHECKLIST.md

-104
This file was deleted.

CODE_OF_CONDUCT.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Code of Conduct
22

3-
The project has adopted a Code of Conduct that we expect project participants to adhere to. Please [read the full text](https://developers.libra.org/docs/policies/code-of-conduct) so that you can understand what actions will and will not be tolerated.
3+
The project has adopted a Code of Conduct that we expect project participants to adhere to. Please [read the full text](https://developers.diem.com/docs/policies/code-of-conduct) so that you can understand what actions will and will not be tolerated.

CONTRIBUTING.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ This project welcomes contributions.
44

55
## Contributor License Agreement
66

7-
For pull request to be accepted by any Libra projects, a CLA must be signed.
8-
You will only need to do this once to work on any of Libra's open source
7+
For pull request to be accepted by any Diem projects, a CLA must be signed.
8+
You will only need to do this once to work on any of Diem's open source
99
projects.
1010

11-
When submitting a PR, the libra-github-bot will check your comment for a valid CLA. If one is not found, then you will need to submit an Individual CLA for yourself or a Corporate CLA for your company.
11+
When submitting a PR, the diem-github-bot will check your comment for a valid CLA. If one is not found, then you will need to submit an Individual CLA for yourself or a Corporate CLA for your company.
1212

1313
## Issues
1414

15-
client-sdk-java uses [GitHub issues](https://github.com/libra/client-sdk-java/issues) to track
15+
client-sdk-java uses [GitHub issues](https://github.com/diem/client-sdk-java/issues) to track
1616
bugs. Please include necessary information and instructions to reproduce your
1717
issue.

README.md

+19-25
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,44 @@
1-
> **Note to readers:** On December 1, 2020, the Libra Association was renamed to Diem Association. The project repos are in the process of being migrated. All projects will remain available for use here until the migration to a new GitHub Organization is complete.
2-
31
# client-sdk-java
42

5-
![Java CI with Gradle](https://github.com/libra/client-sdk-java/workflows/Java%20CI%20with%20Gradle/badge.svg) [![API Reference](https://img.shields.io/badge/api-reference-blue.svg)](https://github.com/libra/libra/blob/master/json-rpc/json-rpc-spec.md) [![Apache V2 License](https://img.shields.io/badge/license-Apache%20V2-blue.svg)](../master/LICENSE) [![javadoc](https://javadoc.io/badge2/org.libra/client-sdk-java/javadoc.svg)](https://javadoc.io/doc/org.libra/client-sdk-java)
3+
![Java CI with Gradle](https://github.com/diem/client-sdk-java/workflows/Java%20CI%20with%20Gradle/badge.svg) [![API Reference](https://img.shields.io/badge/api-reference-blue.svg)](https://github.com/diem/diem/blob/master/json-rpc/json-rpc-spec.md) [![Apache V2 License](https://img.shields.io/badge/license-Apache%20V2-blue.svg)](../master/LICENSE) [![javadoc](https://javadoc.io/badge2/org.diem/client-sdk-java/javadoc.svg)](https://javadoc.io/doc/org.diem/client-sdk-java)
64

7-
`client-sdk-java` is the official Libra Client SDK for the Java programming language.
5+
`client-sdk-java` is the official diem Client SDK for the Java programming language.
86

97
## Overview of SDK's Packages
108

11-
### [`org.libra`](./src/main/java/com/org/libra/)
9+
### [`com.diem`](./src/main/java/com/com/diem/)
1210

1311
> SPEC = specification
14-
> LIP-X = Libra Improvement Protocol
12+
> LIP-X = Diem Improvement Protocol
1513
16-
- `jsonrpc`: libra JSON-RPC APIs client. [SPEC](https://github.com/libra/libra/blob/master/json-rpc/json-rpc-spec.md)
17-
- `jsonrpctypes`: generated code, JSON-RPC API response data object classes generated from protobuf definition.
14+
- `jsonrpc`: diem JSON-RPC APIs client. [SPEC](https://github.com/diem/diem/blob/master/json-rpc/json-rpc-spec.md)
1815
- `stdlib`: generated code, move stdlib script utils for constructing transaction script playload.
19-
- `types`: generated code, Libra on-chain data structure types. Mostly generated code with small extension code for attaching handy functions to generated types.
16+
- `types`: generated code, diem on-chain data structure types. Mostly generated code with small extension code for attaching handy functions to generated types.
2017
- `utils`: utility functions, account address utils, currency code, hashing, hex encoding / decoding, transaction utils.
21-
- `AccountIdentifier` & `IntentIdentifier`: encoding & decoding Libra Account Identifier and Intent URL. [LIP-5](https://lip.libra.org/lip-5/)
22-
- `LibraClient`: interface of JSON-RPC client.
23-
- `LibraException`: root exception of all checked exceptions defined in SDK.
18+
- `AccountIdentifier` & `IntentIdentifier`: encoding & decoding diem Account Identifier and Intent URL. [LIP-5](https://dip.diem.com/dip-5/)
19+
- `DiemClient`: interface of JSON-RPC client.
20+
- `DiemException`: root exception of all checked exceptions defined in SDK.
2421
- `PrivateKey`: abstraction for hiding private key details, implement this interface for plugin your customized private key signing logic.
2522
- `Signer`: sign transaction logic.
2623
- `Testnet`: Testnet utility, minting coins, create Testnet client, chain id, Testnet JSON-RPC URL.
27-
- `TransactionMetadata`: utils for creating peer to peer transaction metadata. [LIP-4](https://lip.libra.org/lip-4/)
24+
- `TransactionMetadata`: utils for creating peer to peer transaction metadata. [LIP-4](https://dip.diem.com/dip-4/)
2825
- `Constants`: static data and JSON-RPC response enum type values.
2926

3027
## Examples
3128

32-
You can find all of the example code under the [`src/test/java/org/libra/examples`](./src/test/java/org/libra/examples/) directory:
29+
You can find all of the example code under the [`src/test/java/com/diem/examples`](./src/test/java/com/diem/examples/) directory:
3330

34-
* [Create Child VASP Account](./src/test/java/org/libra/examples/CreateChildVASP.java)
35-
* [All Types Peer To Peer Transfer](./src/test/java/org/libra/examples/PeerToPeerTransfer.java)
36-
* [Intent Identifier](./src/test/java/org/libra/examples/IntentId.java)
37-
* [Refund](./src/test/java/org/libra/examples/Refund.java)
31+
* [Create Child VASP Account](./src/test/java/com/diem/examples/CreateChildVASP.java)
32+
* [All Types Peer To Peer Transfer](./src/test/java/com/diem/examples/PeerToPeerTransfer.java)
33+
* [Intent Identifier](./src/test/java/com/diem/examples/IntentId.java)
34+
* [Refund](./src/test/java/com/diem/examples/Refund.java)
3835

3936
## Download
4037

4138
**Gradle**
4239

4340
```gradle
44-
implementation 'org.libra:libra-client-sdk-java:0.1.0'
41+
implementation 'com.diem:client-sdk-java:1.0.0'
4542
```
4643

4744
**Maven**
@@ -50,7 +47,7 @@ implementation 'org.libra:libra-client-sdk-java:0.1.0'
5047
<dependency>
5148
<groupId>com.diem</groupId>
5249
<artifactId>client-sdk-java</artifactId>
53-
<version>0.1.0</version>
50+
<version>1.0.0</version>
5451
</dependency>
5552
```
5653
[Download Jars on Maven](https://repo1.maven.org/maven2/com/diem/client-sdk-java/)
@@ -76,10 +73,10 @@ Jar file location: build/libs/client-sdk-java.jar
7673
gradle test
7774
```
7875

79-
## Upgrade to latest libra testnet release
76+
## Upgrade to latest diem testnet release
8077

8178
```
82-
// reset libra submodule to testnet branch, re-generate stdlib and lcs type classes
79+
// reset diem submodule to testnet branch, re-generate stdlib and lcs type classes
8380
gradle gen
8481
8582
// generate jsonrpc types from protobuf definition
@@ -98,6 +95,3 @@ gradle test
9895

9996
[CONTRIBUTING](./CONTRIBUTING.md)
10097

101-
# Features, Roadmap and Development Plan
102-
103-
[CHECKLIST](./CHECKLIST.md)

SECURITY.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Security Policies and Procedures
22

3-
Please see Libra's
4-
[security policies](https://developers.libra.org/docs/policies/security) and
3+
Please see Diem's
4+
[security policies](https://developers.diem.com/docs/policies/security) and
55
procedures for reporting vulnerabilities.

build.gradle

+9-9
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repositories {
1111
}
1212

1313
group 'com.diem'
14-
version '0.1.0'
14+
version '1.0.0'
1515

1616
apply plugin: 'java-library'
1717
apply plugin: 'java'
@@ -34,7 +34,7 @@ publishing {
3434
pom {
3535
name = 'Diem Client SDK'
3636
description = 'The official Diem Client SDK for the Java programming language.'
37-
url = 'https://github.com/libra/client-sdk-java'
37+
url = 'https://github.com/diem/client-sdk-java'
3838
licenses {
3939
license {
4040
name = 'The Apache License, Version 2.0'
@@ -44,12 +44,12 @@ publishing {
4444
developers {
4545
developer {
4646
name = 'Diem Open Source'
47-
url = 'https://developers.diem.org'
47+
url = 'https://developers.diem.com'
4848
}
4949
}
5050
scm {
51-
connection = 'scm:git:[email protected]:libra/client-sdk-java.git'
52-
url = 'https://github.com/libra/client-sdk-java'
51+
connection = 'scm:git:[email protected]:diem/client-sdk-java.git'
52+
url = 'https://github.com/diem/client-sdk-java'
5353
}
5454
}
5555
tasks.withType(Jar) {
@@ -107,17 +107,17 @@ signing {
107107
task gen {
108108
doLast {
109109
exec {
110-
workingDir 'libra'
110+
workingDir 'diem'
111111
executable "sh"
112112
args "-c", "cargo build -p transaction-builder-generator"
113113
}
114114
exec {
115-
workingDir 'libra'
115+
workingDir 'diem'
116116
executable "sh"
117117
args '-c', 'target/debug/generate-transaction-builders' +
118118
' --language java' +
119-
' --module-name org.libra.stdlib' +
120-
' --with-libra-types "testsuite/generate-format/tests/staged/libra.yaml"' +
119+
' --module-name com.diem.stdlib' +
120+
' --with-diem-types "testsuite/generate-format/tests/staged/diem.yaml"' +
121121
' --target-source-dir "./../src/main/java"' +
122122
' "language/stdlib/compiled/transaction_scripts/abi"'
123123
}

diem

Submodule diem added at 838a46d

libra

-1
This file was deleted.

src/main/java/org/diem/AccountIdentifier.java src/main/java/com/diem/AccountIdentifier.java

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
1-
// Copyright (c) The Libra Core Contributors
1+
// Copyright (c) The Diem Core Contributors
22
// SPDX-License-Identifier: Apache-2.0
33

4-
package org.diem;
4+
package com.diem;
55

6+
import com.diem.types.AccountAddress;
7+
import com.diem.utils.AccountAddressUtils;
68
import com.google.common.primitives.Bytes;
79
import org.apache.commons.lang3.ArrayUtils;
810
import org.bitcoinj.core.Bech32;
9-
import org.diem.types.AccountAddress;
10-
import org.diem.utils.AccountAddressUtils;
1111

1212
import java.io.ByteArrayOutputStream;
13+
import java.util.ArrayList;
1314
import java.util.Arrays;
1415
import java.util.Objects;
1516

16-
import static org.diem.SubAddress.SUB_ADDRESS_LENGTH;
17+
import static com.diem.SubAddress.SUB_ADDRESS_LENGTH;
1718

1819
/**
19-
* AccountIdentifier implements Libra Account Identifier encoding and decoding.
20-
* @see <a href="https://github.com/libra/lip/blob/master/lips/lip-5.md">LIP-5 Address formatting</a>
20+
* AccountIdentifier implements Diem Account Identifier encoding and decoding.
21+
* @see <a href="https://github.com/diem/lip/blob/master/lips/lip-5.md">LIP-5 Address formatting</a>
2122
*/
2223
public class AccountIdentifier {
2324

@@ -53,7 +54,7 @@ public static AccountIdentifier decode(NetworkPrefix prefix, String encodedAccou
5354
byte[] subAddressChars = Arrays.copyOfRange(bytes, AccountAddressUtils.ACCOUNT_ADDRESS_LENGTH, AccountAddressUtils.ACCOUNT_ADDRESS_LENGTH + SUB_ADDRESS_LENGTH);
5455

5556
Byte[] addressBytes = ArrayUtils.toObject(addressChars);
56-
AccountAddress accountAddress = new AccountAddress(addressBytes);
57+
AccountAddress accountAddress = new AccountAddress(Arrays.asList(addressBytes));
5758
SubAddress subAddress = new SubAddress(subAddressChars);
5859

5960
return new AccountIdentifier(prefix, accountAddress, subAddress);
@@ -98,10 +99,10 @@ public static byte[] convertBits(final byte[] inputs, final int fromBits, final
9899
}
99100

100101
/**
101-
* NetworkPrefix is network prefix of a Libra Account Identifier.
102+
* NetworkPrefix is network prefix of a Diem Account Identifier.
102103
*/
103104
public enum NetworkPrefix {
104-
MainnetPrefix("lbr"), TestnetPrefix("tlb");
105+
MainnetPrefix("dm"), TestnetPrefix("tdm"), PreMainnetPrefix("pdm"), DryRunMainnetPrefix("ddm");
105106

106107
private final String value;
107108

@@ -175,8 +176,8 @@ public boolean equals(Object o) {
175176
if (o == null || getClass() != o.getClass()) return false;
176177
AccountIdentifier that = (AccountIdentifier) o;
177178
return prefix == that.prefix &&
178-
Arrays.equals(accountAddress.value, that.accountAddress.value) &&
179-
Arrays.equals(subAddress.getBytes(), that.subAddress.getBytes());
179+
Objects.equals(accountAddress, that.accountAddress) &&
180+
Objects.equals(subAddress, that.subAddress);
180181
}
181182

182183
@Override

src/main/java/org/diem/AuthKey.java src/main/java/com/diem/AuthKey.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
// Copyright (c) The Libra Core Contributors
1+
// Copyright (c) The Diem Core Contributors
22
// SPDX-License-Identifier: Apache-2.0
33

4-
package org.diem;
4+
package com.diem;
55

6+
import com.diem.types.AccountAddress;
7+
import com.diem.utils.AccountAddressUtils;
68
import com.novi.serde.Bytes;
7-
import org.diem.types.AccountAddress;
8-
import org.diem.utils.AccountAddressUtils;
9-
import org.diem.utils.HashUtils;
10-
import org.diem.utils.Hex;
9+
import com.diem.utils.HashUtils;
10+
import com.diem.utils.Hex;
1111

1212
import java.util.Arrays;
1313

0 commit comments

Comments
 (0)