Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: rename package 'ln.v2' -> 'sdk' #6

Merged
merged 4 commits into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Added

### Changed
* [\#6](https://github.com/Finschia/finschia-kt/pull/6) Rename package 'ln.v2' -> 'sdk'

### Deprecated

Expand All @@ -52,9 +53,9 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Build, CI

* (build) [\#4](https://github.com/line/finschia-kt/pull/4) Add gradle `updateSubmodule` task and `checkoutSubModule` task to run `git submodule update --init --remote` with specific version before `build task`
* (build) [\#4](https://github.com/Finschia/finschia-kt/pull/4) Add gradle `updateSubmodule` task and `checkoutSubModule` task to run `git submodule update --init --remote` with specific version before `build task`

### Document Updates

<!-- Release links -->
[Unreleased]: https://github.com/line/finschia-kt/compare/8aa2005...HEAD
[Unreleased]: https://github.com/Finschia/finschia-kt/compare/8aa2005...HEAD
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# finschia-kt

gRPC client library in kotlin for finschia (https://github.com/line/finschia).
gRPC client library in kotlin for finschia (https://github.com/Finschia/finschia).

Requires [lbm-sdk v0.47.0-alpha1](https://github.com/line/lbm-sdk/tree/v0.47.0-alpha1)
Requires [lbm-sdk v0.47.0-alpha1](https://github.com/Finschia/finschia-sdk/tree/v0.47.0-alpha1)

Current lbm-sdk version applied to finschia-kt/protobuf is [lbm-sdk v0.47.0-alpha1](https://github.com/line/lbm-sdk/tree/v0.47.0-alpha1)
Current finschia-sdk version applied to finschia-kt/protobuf is [finschia-sdk v0.47.0-alpha1](https://github.com/Finschia/finschia-sdk/tree/v0.47.0-alpha1)

## Build

Expand Down Expand Up @@ -90,7 +90,7 @@ The former is using the tx wrapper, while the latter does not use the wrapper.

### 1. Run lbm-sdk simapp

Build with reference to [Quick Start build](https://github.com/line/lbm-sdk/tree/v0.47.0-alpha1#quick-start).
Build with reference to [Quick Start build](https://github.com/Finschia/finschia-sdk/tree/v0.47.0-alpha1#quick-start).

Initialize and configure simapp.

Expand All @@ -114,7 +114,7 @@ $ simd start --home ~/simapp
### 2. Replace hard-coded arguments

To confirm it's possible to send transactions to the chain created above using finschia-kt, replace the following
three parts of the [without-tx-wrapper-example/src/main/kotlin/network/link/ln/v2/example/Client.kt](https://github.com/line/finschia-kt/blob/main/examples/without-tx-wrapper-example/src/main/kotlin/network/link/ln/v2/example/Client.kt).
three parts of the [without-tx-wrapper-example/src/main/kotlin/network/link/sdk/example/Client.kt](https://github.com/Finschia/finschia-kt/blob/main/examples/without-tx-wrapper-example/src/main/kotlin/network/link/sdk/example/Client.kt).

1. **Chain ID**: constant of the name `CHAIN_ID` in `ConcreteScenarios`
```go
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

plugins {
// Apply the common convention plugin for shared build configuration between library and application projects.
id("network.finschia.ln.v2.kotlin-common-conventions")
id("network.finschia.sdk.kotlin-common-conventions")

// Apply the application plugin to add support for building a CLI application in Java.
application
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

plugins {
// Apply the common convention plugin for shared build configuration between library and application projects.
id("network.finschia.ln.v2.kotlin-common-conventions")
id("network.finschia.sdk.kotlin-common-conventions")

// Apply the java-library plugin for API and implementation separation.
`java-library`
Expand Down
2 changes: 1 addition & 1 deletion crypto/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("network.finschia.ln.v2.kotlin-library-conventions")
id("network.finschia.sdk.kotlin-library-conventions")
}

val guavaVersion = "28.1-jre"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package network.finschia.ln.v2.crypto;
package network.finschia.sdk.crypto;

import java.util.Arrays;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package network.finschia.ln.v2.crypto;
package network.finschia.sdk.crypto;

import java.io.ByteArrayOutputStream;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package network.finschia.ln.v2.crypto;
package network.finschia.sdk.crypto;

import static network.finschia.ln.v2.crypto.LinkKeys.PRIVATE_KEY_SIZE;
import static network.finschia.ln.v2.crypto.SecureRandomUtils.secureRandom;
import static org.web3j.crypto.Bip32ECKeyPair.HARDENED_BIT;

import org.bouncycastle.util.BigIntegers;
Expand All @@ -19,15 +17,15 @@ private Bip44WalletUtils() {}

public static String generateMnemonic() {
final byte[] initialEntropy = new byte[16];
secureRandom().nextBytes(initialEntropy);
SecureRandomUtils.secureRandom().nextBytes(initialEntropy);
return MnemonicUtils.generateMnemonic(initialEntropy);
}

public static byte[] generatePrivateKey(String mnemonic, int accountNumber, int index) {
final byte[] seed = MnemonicUtils.generateSeed(mnemonic, null);
final Bip32ECKeyPair masterKeypair = Bip32ECKeyPair.generateKeyPair(seed);
final Bip32ECKeyPair bip44Keypair = generateBip44KeyPair(masterKeypair, accountNumber, index);
return BigIntegers.asUnsignedByteArray(PRIVATE_KEY_SIZE, bip44Keypair.getPrivateKey());
return BigIntegers.asUnsignedByteArray(LinkKeys.PRIVATE_KEY_SIZE, bip44Keypair.getPrivateKey());
}

static Bip32ECKeyPair generateBip44KeyPair(Bip32ECKeyPair master, int accountNumber, int index) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package network.finschia.ln.v2.crypto;
package network.finschia.sdk.crypto;

import java.math.BigInteger;
import java.nio.ByteBuffer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package network.finschia.ln.v2.crypto;
package network.finschia.sdk.crypto;

import static network.finschia.ln.v2.crypto.Amino.addAminoPrefix;
import static network.finschia.ln.v2.crypto.Amino.removeAminoPrefix;
import static network.finschia.ln.v2.crypto.SecureRandomUtils.secureRandom;
import static network.finschia.sdk.crypto.Amino.addAminoPrefix;
import static network.finschia.sdk.crypto.Amino.removeAminoPrefix;
import static network.finschia.sdk.crypto.SecureRandomUtils.secureRandom;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package network.finschia.ln.v2.crypto;
package network.finschia.sdk.crypto;

import static network.finschia.ln.v2.crypto.SecureRandomUtils.secureRandom;
import static network.finschia.sdk.crypto.SecureRandomUtils.secureRandom;

import java.math.BigInteger;
import java.security.InvalidAlgorithmParameterException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package network.finschia.ln.v2.crypto;
package network.finschia.sdk.crypto;

import java.security.SecureRandom;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package network.finschia.ln.v2.crypto;
package network.finschia.sdk.crypto;

import java.io.IOException;
import java.io.OutputStream;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package network.finschia.ln.v2.crypto;
package network.finschia.sdk.crypto;

import java.util.Arrays;
import java.util.Optional;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package network.finschia.ln.v2.account
package network.finschia.sdk.account

/**
* Account interface represents the account information such as address, account number, sequence number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package network.finschia.ln.v2.account
package network.finschia.sdk.account

import network.finschia.ln.v2.account.Type.ACCOUNT
import network.finschia.ln.v2.account.Type.Companion.DEFAULT_BECH32_HRP_PREFIX
import network.finschia.ln.v2.account.Type.Companion.toHrpPrefix
import network.finschia.ln.v2.crypto.Bech32Utils
import network.finschia.sdk.account.Type.ACCOUNT
import network.finschia.sdk.account.Type.Companion.DEFAULT_BECH32_HRP_PREFIX
import network.finschia.sdk.account.Type.Companion.toHrpPrefix
import network.finschia.sdk.crypto.Bech32Utils
import org.bitcoinj.core.Bech32
import org.bouncycastle.jcajce.provider.digest.RIPEMD160
import org.bouncycastle.jcajce.provider.digest.SHA256
Expand Down Expand Up @@ -118,7 +118,8 @@ class Address private constructor(val type: Type, val body: ByteArray) {
*/
@JvmStatic
@JvmName("of")
operator fun invoke(body: ByteArray): Address = invoke(ACCOUNT, body)
operator fun invoke(body: ByteArray): Address =
invoke(ACCOUNT, body)

/**
* initiates an address from [bech32Address]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package network.finschia.ln.v2.account
package network.finschia.sdk.account

import java.math.BigInteger

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package network.finschia.ln.v2.account
package network.finschia.sdk.account

import network.finschia.ln.v2.crypto.Bip44WalletUtils.generateMnemonic
import network.finschia.ln.v2.crypto.Bip44WalletUtils.generatePrivateKey
import network.finschia.sdk.crypto.Bip44WalletUtils.generateMnemonic
import network.finschia.sdk.crypto.Bip44WalletUtils.generatePrivateKey
import java.security.InvalidAlgorithmParameterException
import java.security.NoSuchAlgorithmException
import java.security.NoSuchProviderException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package network.finschia.ln.v2.account
package network.finschia.sdk.account

import network.finschia.ln.v2.account.PubKey.Companion.createFromPrivateKey
import network.finschia.ln.v2.crypto.ECDSASignature
import network.finschia.ln.v2.crypto.KeyStore
import network.finschia.ln.v2.crypto.LinkKeys
import network.finschia.sdk.account.PubKey.Companion.createFromPrivateKey
import network.finschia.sdk.crypto.ECDSASignature
import network.finschia.sdk.crypto.KeyStore
import network.finschia.sdk.crypto.LinkKeys
import java.io.InputStream
import java.io.OutputStream
import java.io.Reader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package network.finschia.ln.v2.account

import network.finschia.ln.v2.account.Type.Companion.DEFAULT_BECH32_HRP_PREFIX
import network.finschia.ln.v2.account.Type.Companion.toHrpPrefix
import network.finschia.ln.v2.common.TypedValue
import network.finschia.ln.v2.crypto.Amino
import network.finschia.ln.v2.crypto.Bech32Utils
import network.finschia.ln.v2.crypto.LinkKeys
package network.finschia.sdk.account

import network.finschia.sdk.account.Type.Companion.DEFAULT_BECH32_HRP_PREFIX
import network.finschia.sdk.account.Type.Companion.toHrpPrefix
import network.finschia.sdk.common.TypedValue
import network.finschia.sdk.crypto.Amino
import network.finschia.sdk.crypto.Bech32Utils
import network.finschia.sdk.crypto.LinkKeys
import org.bitcoinj.core.Bech32
import org.bouncycastle.util.encoders.Hex

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package network.finschia.ln.v2.account
package network.finschia.sdk.account

/**
* Defines the types of Addresses and PubKeys
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package network.finschia.ln.v2.account
package network.finschia.sdk.account

/**
* Wallet class signs the message using own keys
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package network.finschia.ln.v2.common
package network.finschia.sdk.common

import com.fasterxml.jackson.core.JsonGenerator
import com.fasterxml.jackson.databind.JsonSerializer
import com.fasterxml.jackson.databind.PropertyNamingStrategy
import com.fasterxml.jackson.databind.SerializerProvider
import com.fasterxml.jackson.databind.module.SimpleModule
import com.fasterxml.jackson.module.kotlin.KotlinModule
import network.finschia.ln.v2.account.Type
import network.finschia.sdk.account.Type

/**
* Predefined basic JSON serializing and deserializing rules for Jackson-databind
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package network.finschia.ln.v2.common
package network.finschia.sdk.common

/**
* An interface of converter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package network.finschia.ln.v2.common
package network.finschia.sdk.common

import org.bouncycastle.util.encoders.Hex

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package network.finschia.ln.v2.common
package network.finschia.sdk.common

/**
* Container to ease passing around a key and value pair
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
* limitations under the License.
*/

package network.finschia.ln.v2.common
package network.finschia.sdk.common

import network.finschia.ln.v2.account.Address
import network.finschia.ln.v2.account.PubKey
import network.finschia.ln.v2.account.Type.Companion.DEFAULT_BECH32_HRP_PREFIX
import network.finschia.sdk.account.Address
import network.finschia.sdk.account.PubKey
import network.finschia.sdk.account.Type.Companion.DEFAULT_BECH32_HRP_PREFIX
import java.lang.reflect.Type
import java.math.BigInteger

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package network.finschia.ln.v2.common
package network.finschia.sdk.common

/**
* Wraps an object with type to recognize struct to unmarshal.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package network.finschia.ln.v2.account;
package network.finschia.sdk.account;

import static com.google.common.truth.Truth.assertThat;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package network.finschia.ln.v2.account;
package network.finschia.sdk.account;

import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package network.finschia.ln.v2.account;
package network.finschia.sdk.account;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package network.finschia.ln.v2.account;
package network.finschia.sdk.account;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
Expand Down
Loading