forked from trustwallet/wallet-core
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from trustwallet/master
IOS-3972-Merge-latest-upstream-master-3.2.4
- Loading branch information
Showing
83 changed files
with
1,896 additions
and
1,427 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
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
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
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
28 changes: 28 additions & 0 deletions
28
...d/app/src/androidTest/java/com/trustwallet/core/app/blockchains/acala/TestAcalaAddress.kt
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,28 @@ | ||
// Copyright © 2017-2023 Trust Wallet. | ||
// | ||
// This file is part of Trust. The full Trust copyright notice, including | ||
// terms governing use, modification, and redistribution, is contained in the | ||
// file LICENSE at the root of the source code distribution tree. | ||
|
||
package com.trustwallet.core.app.blockchains.acala | ||
|
||
import com.trustwallet.core.app.utils.toHex | ||
import com.trustwallet.core.app.utils.toHexByteArray | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
import wallet.core.jni.* | ||
|
||
class TestAcalaAddress { | ||
|
||
init { | ||
System.loadLibrary("TrustWalletCore") | ||
} | ||
|
||
@Test | ||
fun testAddress() { | ||
val key = PrivateKey("0x9066aa168c379a403becb235c15e7129c133c244e56a757ab07bc369288bcab0".toHexByteArray()) | ||
val pubkey = key.publicKeyEd25519 | ||
val address = AnyAddress(pubkey, CoinType.ACALA) | ||
assertEquals(address.description(), "269ZCS3WLGydTN8ynhyhZfzJrXkePUcdhwgLQs6TWFs5wVL5") | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
...id/app/src/androidTest/java/com/trustwallet/core/app/blockchains/acala/TestAcalaSigner.kt
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,65 @@ | ||
// Copyright © 2017-2023 Trust Wallet. | ||
// | ||
// This file is part of Trust. The full Trust copyright notice, including | ||
// terms governing use, modification, and redistribution, is contained in the | ||
// file LICENSE at the root of the source code distribution tree. | ||
|
||
package com.trustwallet.core.app.blockchains.acala | ||
|
||
import com.trustwallet.core.app.utils.Numeric | ||
import com.trustwallet.core.app.utils.toHexBytesInByteString | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
import wallet.core.java.AnySigner | ||
import wallet.core.jni.CoinType | ||
import wallet.core.jni.proto.Polkadot | ||
|
||
class TestAcalaSigner { | ||
|
||
init { | ||
System.loadLibrary("TrustWalletCore") | ||
} | ||
|
||
@Test | ||
fun AcalaTransactionSigning() { | ||
val transferCallIndices = Polkadot.CallIndices.newBuilder().apply { | ||
custom = Polkadot.CustomCallIndices.newBuilder().apply { | ||
moduleIndex = 0x0a | ||
methodIndex = 0x00 | ||
}.build() | ||
} | ||
|
||
val call = Polkadot.Balance.Transfer.newBuilder().apply { | ||
value = "0xe8d4a51000".toHexBytesInByteString() // 1 ACA | ||
toAddress = "25Qqz3ARAvnZbahGZUzV3xpP1bB3eRrupEprK7f2FNbHbvsz" | ||
callIndices = transferCallIndices.build() | ||
} | ||
|
||
val acalaGenesisHashStr = "0xfc41b9bd8ef8fe53d58c7ea67c794c7ec9a73daf05e6d54b14ff6342c99ba64c".toHexBytesInByteString() | ||
|
||
val input = Polkadot.SigningInput.newBuilder().apply { | ||
genesisHash = acalaGenesisHashStr | ||
blockHash = "0x707ffa05b7dc6cdb6356bd8bd51ff20b2757c3214a76277516080a10f1bc7537".toHexBytesInByteString() | ||
nonce = 0 | ||
specVersion = 2170 | ||
network = CoinType.ACALA.ss58Prefix() | ||
transactionVersion = 2 | ||
privateKey = "9066aa168c379a403becb235c15e7129c133c244e56a757ab07bc369288bcab0".toHexBytesInByteString() | ||
era = Polkadot.Era.newBuilder().apply { | ||
blockNumber = 3893613 | ||
period = 64 | ||
}.build() | ||
balanceCall = Polkadot.Balance.newBuilder().apply { | ||
transfer = call.build() | ||
}.build() | ||
multiAddress = true | ||
} | ||
|
||
val output = AnySigner.sign(input.build(), CoinType.ACALA, Polkadot.SigningOutput.parser()) | ||
val encoded = Numeric.toHexString(output.encoded.toByteArray()) | ||
|
||
// https://acala.subscan.io/extrinsic/3893620-3 | ||
val expected = "0x41028400e9590e4d99264a14a85e21e69537e4a64f66a875d38cb8f76b305f41fabe24a900dd54466dffd1e3c80b76013e9459fbdcd17805bd5fdbca0961a643bad1cbd2b7fe005c62c51c18b67f31eb9e61b187a911952fee172ef18402d07c703eec3100d50200000a0000c8c602ded977c56076ae38d98026fa669ca10d6a2b5a0bfc4086ae7668ed1c60070010a5d4e8" | ||
assertEquals(encoded, expected) | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...src/androidTest/java/com/trustwallet/core/app/blockchains/acalaevm/TestAcalaEVMAddress.kt
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,29 @@ | ||
// Copyright © 2017-2023 Trust Wallet. | ||
// | ||
// This file is part of Trust. The full Trust copyright notice, including | ||
// terms governing use, modification, and redistribution, is contained in the | ||
// file LICENSE at the root of the source code distribution tree. | ||
|
||
package com.trustwallet.core.app.blockchains.acalaevm | ||
|
||
import com.trustwallet.core.app.utils.toHexByteArray | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
import wallet.core.jni.* | ||
|
||
class TestAcalaEVMAddress { | ||
|
||
init { | ||
System.loadLibrary("TrustWalletCore") | ||
} | ||
|
||
@Test | ||
fun testAddress() { | ||
val key = PrivateKey("828c4c48c2cef521f0251920891ed79e871faa24f64f43cde83d07bc99f8dbf0".toHexByteArray()) | ||
val pubkey = key.getPublicKeySecp256k1(false) | ||
val address = AnyAddress(pubkey, CoinType.ACALAEVM) | ||
val expected = AnyAddress("0xe32DC46bfBF78D1eada7b0a68C96903e01418D64", CoinType.ACALAEVM) | ||
|
||
assertEquals(address.description(), expected.description()) | ||
} | ||
} |
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
16 changes: 6 additions & 10 deletions
16
android/app/src/androidTest/java/com/trustwallet/core/app/blockchains/ethereum/TestBarz.kt
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
Oops, something went wrong.