Skip to content

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
satoshiotomakan committed Jan 16, 2025
2 parents 8b2cdb7 + af7c6a5 commit 28ced94
Show file tree
Hide file tree
Showing 150 changed files with 4,747 additions and 347 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/android-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
uses: actions/cache@v3
with:
path: build/local
key: ${{ runner.os }}-${{ runner.arch }}-internal-${{ hashFiles('tools/install-dependencies') }}
key: ${{ runner.os }}-${{ runner.arch }}-internal-${{ hashFiles('tools/install-dependencies') }}-${{ hashFiles('tools/dependencies-version') }}

- name: Install internal dependencies
run: tools/install-dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ios-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
uses: actions/cache@v3
with:
path: build/local
key: ${{ runner.os }}-internal-${{ hashFiles('tools/install-dependencies') }}
key: ${{ runner.os }}-${{ runner.arch }}-internal-${{ hashFiles('tools/install-dependencies') }}-${{ hashFiles('tools/dependencies-version') }}

- name: Install internal dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/kotlin-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
uses: actions/cache@v3
with:
path: build/local
key: ${{ runner.os }}-internal-${{ hashFiles('tools/install-dependencies') }}
key: ${{ runner.os }}-${{ runner.arch }}-internal-${{ hashFiles('tools/install-dependencies') }}-${{ hashFiles('tools/dependencies-version') }}

- name: Install internal dependencies
run: tools/install-dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linux-ci-sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
uses: actions/cache@v3
with:
path: build/local
key: ${{ runner.os }}-internal-${{ hashFiles('tools/install-dependencies') }}
key: ${{ runner.os }}-${{ runner.arch }}-internal-${{ hashFiles('tools/install-dependencies') }}-${{ hashFiles('tools/dependencies-version') }}

- name: Install internal dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linux-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
uses: actions/cache@v3
with:
path: build/local
key: ${{ runner.os }}-internal-${{ hashFiles('tools/install-sys-dependencies-linux') }}-${{ hashFiles('tools/install-dependencies') }}
key: ${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('tools/install-sys-dependencies-linux') }}-internal-${{ hashFiles('tools/install-dependencies') }}-${{ hashFiles('tools/dependencies-version') }}
- name: Install internal dependencies
run: |
tools/install-dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linux-sampleapp-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
uses: actions/cache@v3
with:
path: build/local
key: ${{ runner.os }}-internal-${{ hashFiles('tools/install-sys-dependencies-linux') }}-${{ hashFiles('tools/install-dependencies') }}
key: ${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('tools/install-sys-dependencies-linux') }}-internal-${{ hashFiles('tools/install-dependencies') }}-${{ hashFiles('tools/dependencies-version') }}
- name: Install internal dependencies
run: |
tools/install-dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wasm-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
uses: actions/cache@v3
with:
path: build/local
key: ${{ runner.os }}-internal-${{ hashFiles('tools/install-dependencies') }}
key: ${{ runner.os }}-${{ runner.arch }}-internal-${{ hashFiles('tools/install-dependencies') }}-${{ hashFiles('tools/dependencies-version') }}

- name: Install internal dependencies
run: tools/install-dependencies
Expand Down
8 changes: 6 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ apply plugin: 'kotlin-android'

android {
namespace 'com.trustwallet.core.app'
compileSdkVersion 32
ndkVersion '23.1.7779620'
compileSdk 35
ndkVersion '28.0.12674087'
defaultConfig {
applicationId "com.trustwallet.core.app"
minSdkVersion 23
Expand All @@ -25,6 +25,10 @@ android {
}
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,59 @@ class TestAptosSigner {
)
}

@Test
fun AptosTransactionBlindSigningWithABI() {
// Successfully broadcasted: https://explorer.aptoslabs.com/txn/0x1ee2aa55382bf6b5a9f7a7f2b2066e16979489c6b2868704a2cf2c482f12b5ca/payload?network=mainnet
val key =
"5d996aa76b3212142792d9130796cd2e11e3c445a93118c08414df4f66bc60ec".toHexBytesInByteString()

val payloadJson = """
{
"function": "0x9770fa9c725cbd97eb50b2be5f7416efdfd1f1554beb0750d4dae4c64e860da3::controller::deposit",
"type_arguments": [
"0x1::aptos_coin::AptosCoin"
],
"arguments": [
"0x4d61696e204163636f756e74",
"10000000",
false
],
"type": "entry_function_payload"
}
""".trimIndent()
val signingInput = Aptos.SigningInput.newBuilder()
.setChainId(1)
.setExpirationTimestampSecs(1735902711)
.setGasUnitPrice(100)
.setMaxGasAmount(50000)
.setSender("0x07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f30")
.setSequenceNumber(69)
.setAnyEncoded(payloadJson)
.setPrivateKey(key)
.setAbi("""
[
"vector<u8>",
"u64",
"bool"
]
""".trimIndent())
.build()

val result = AnySigner.sign(signingInput, CoinType.APTOS, Aptos.SigningOutput.parser())
assertEquals(
Numeric.cleanHexPrefix(Numeric.toHexString(result.rawTxn.toByteArray())),
"07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f304500000000000000029770fa9c725cbd97eb50b2be5f7416efdfd1f1554beb0750d4dae4c64e860da30a636f6e74726f6c6c6572076465706f736974010700000000000000000000000000000000000000000000000000000000000000010a6170746f735f636f696e094170746f73436f696e00030d0c4d61696e204163636f756e74088096980000000000010050c30000000000006400000000000000f7c577670000000001"
)
assertEquals(
Numeric.cleanHexPrefix(Numeric.toHexString(result.authenticator.signature.toByteArray())),
"13dcf1636abd31996729ded4d3bf56e9c7869a7188df4f185cbcce42f0dc74b6e1b54d31703ee3babbea2ef72b3338b8c2866cec68cbd761ccc7f80910124304"
)
assertEquals(
Numeric.cleanHexPrefix(Numeric.toHexString(result.encoded.toByteArray())),
"07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f304500000000000000029770fa9c725cbd97eb50b2be5f7416efdfd1f1554beb0750d4dae4c64e860da30a636f6e74726f6c6c6572076465706f736974010700000000000000000000000000000000000000000000000000000000000000010a6170746f735f636f696e094170746f73436f696e00030d0c4d61696e204163636f756e74088096980000000000010050c30000000000006400000000000000f7c5776700000000010020ea526ba1710343d953461ff68641f1b7df5f23b9042ffa2d2a798d3adb3f3d6c4013dcf1636abd31996729ded4d3bf56e9c7869a7188df4f185cbcce42f0dc74b6e1b54d31703ee3babbea2ef72b3338b8c2866cec68cbd761ccc7f80910124304"
)
}

@Test
fun AptosTransactionSigning() {
// Successfully broadcasted https://explorer.aptoslabs.com/txn/0xb4d62afd3862116e060dd6ad9848ccb50c2bc177799819f1d29c059ae2042467?network=devnet
Expand Down Expand Up @@ -144,4 +197,41 @@ class TestAptosSigner {
"1869b853768f0ba935d67f837a66b172dd39a60ca2315f8d4e0e669bbd35cf2502000000000000000200000000000000000000000000000000000000000000000000000000000000010d6170746f735f6163636f756e740e7472616e736665725f636f696e730107e9c192ff55cffab3963c695cff6dbf9dad6aff2bb5ac19a6415cad26a81860d9086d65655f636f696e074d6565436f696e000220b7c7d12080209e9dc14498c80200706e760363fb31782247e82cf57d1d6e5d6c081027000000000000d0070000000000006400000000000000c2276ada0000000001002062e7a6a486553b56a53e89dfae3f780693e537e5b0a7ed33290780e581ca83694030ebd7e95cb464677f411868e2cbfcb22bc01cc63cded36c459dff45e6d2f1354ae4e090e7dfbb509851c0368b343e0e5ecaf6b08e7c1b94c186530b0f7dee0d"
)
}

@Test
fun AptosFungibleAssetTransfer() {
// Successfully broadcasted https://explorer.aptoslabs.com/txn/0x475fc97bcba87907166a720676e1b2f5320e613fd13014df37dcf17b09ff0e98/balanceChange?network=mainnet
val key =
"5d996aa76b3212142792d9130796cd2e11e3c445a93118c08414df4f66bc60ec".toHexBytesInByteString()

val fungibleAssetTransferMessage = Aptos.FungibleAssetTransferMessage.newBuilder()
.setAmount(100000000)
.setTo("0x2d92d71078f11d923c2b703b95a288c0e2ae63c0d29154e6278bf8004f9b4e52")
.setMetadataAddress("0x2ebb2ccac5e027a87fa0e2e5f656a3a4238d6a48d93ec9b610d570fc0aa0df12")
.build()
val signingInput = Aptos.SigningInput.newBuilder()
.setChainId(1)
.setSender("0x07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f30")
.setSequenceNumber(74)
.setGasUnitPrice(100)
.setMaxGasAmount(20)
.setExpirationTimestampSecs(1736060099)
.setFungibleAssetTransfer(fungibleAssetTransferMessage)
.setPrivateKey(key)
.build()

val result = AnySigner.sign(signingInput, CoinType.APTOS, Aptos.SigningOutput.parser())
assertEquals(
Numeric.cleanHexPrefix(Numeric.toHexString(result.rawTxn.toByteArray())),
"07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f304a00000000000000020000000000000000000000000000000000000000000000000000000000000001167072696d6172795f66756e6769626c655f73746f7265087472616e73666572010700000000000000000000000000000000000000000000000000000000000000010e66756e6769626c655f6173736574084d657461646174610003202ebb2ccac5e027a87fa0e2e5f656a3a4238d6a48d93ec9b610d570fc0aa0df12202d92d71078f11d923c2b703b95a288c0e2ae63c0d29154e6278bf8004f9b4e520800e1f5050000000014000000000000006400000000000000c32c7a670000000001"
)
assertEquals(
Numeric.cleanHexPrefix(Numeric.toHexString(result.authenticator.signature.toByteArray())),
"2d4c5cbb710b6ef92813597054dbf8d3014529a7d85f6393f01e2a3e978c461c6aa656475b98b453ed3faebf7aa1fdd912bfc59a0c1b6fc44330793994b2e40c"
)
assertEquals(
Numeric.cleanHexPrefix(Numeric.toHexString(result.encoded.toByteArray())),
"07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f304a00000000000000020000000000000000000000000000000000000000000000000000000000000001167072696d6172795f66756e6769626c655f73746f7265087472616e73666572010700000000000000000000000000000000000000000000000000000000000000010e66756e6769626c655f6173736574084d657461646174610003202ebb2ccac5e027a87fa0e2e5f656a3a4238d6a48d93ec9b610d570fc0aa0df12202d92d71078f11d923c2b703b95a288c0e2ae63c0d29154e6278bf8004f9b4e520800e1f5050000000014000000000000006400000000000000c32c7a6700000000010020ea526ba1710343d953461ff68641f1b7df5f23b9042ffa2d2a798d3adb3f3d6c402d4c5cbb710b6ef92813597054dbf8d3014529a7d85f6393f01e2a3e978c461c6aa656475b98b453ed3faebf7aa1fdd912bfc59a0c1b6fc44330793994b2e40c"
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,31 @@ class TestEthereumAbiDecoder {
assertEquals(decodingOutput.getTokens(0).name, "name")
assertEquals(decodingOutput.getTokens(0).stringValue, "deadbeef")
}

@Test
fun testEthereumAbiGetFunctionSignature() {
val abiJson = """
{
"constant": false,
"inputs": [
{
"name": "_to",
"type": "address"
},
{
"name": "_value",
"type": "uint256"
}
],
"name": "transfer",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
}
""".trimIndent()

val functionSignature = wallet.core.jni.EthereumAbi.getFunctionSignature(abiJson)
assertEquals(functionSignature, "transfer(address,uint256)")
}
}
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
buildscript {
ext.kotlin_version = '1.6.10'
ext.kotlin_version = '2.1.0'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.0.0'
classpath 'com.android.tools.build:gradle:8.8.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
19 changes: 11 additions & 8 deletions android/wallet-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,17 @@ group = 'com.trustwallet'

android {
namespace 'wallet.core'
compileSdkVersion 32
ndkVersion '23.1.7779620'
compileSdk 35
ndkVersion '28.0.12674087'
defaultConfig {
minSdkVersion 23
versionCode 1
versionName "1.0"
externalNativeBuild {
cmake {
arguments "-DCMAKE_BUILD_TYPE=Release", "-DTW_UNITY_BUILD=ON"
}
}
}

lintOptions {
abortOnError false
disable 'InvalidPackage'
}

buildTypes {
release {
Expand Down Expand Up @@ -52,6 +46,15 @@ android {
withSourcesJar()
}
}
lint {
abortOnError false
disable 'InvalidPackage'
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
}

dependencies {
Expand Down
15 changes: 15 additions & 0 deletions codegen-v2/manifest/TWEthereumAbi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,18 @@ functions:
is_constant: true
is_nullable: false
is_pointer: true
- name: TWEthereumAbiGetFunctionSignature
is_public: true
is_static: true
params:
- name: abi
type:
variant: string
is_constant: true
is_nullable: false
is_pointer: true
return_type:
variant: string
is_constant: true
is_nullable: true
is_pointer: true
2 changes: 1 addition & 1 deletion codegen/lib/templates/jni/compare_to.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<% less = locals[:less] -%>
<% equal = locals[:equal] -%>
<% compareMethod = JNIHelper.compareMethod(entity) -%>
<%= render('jni/method_prototype.erb', { method: compareMethod }) %> {
<%= render('jni/method_prototype.erb', { method: compareMethod, maybe_unused: true }) %> {
<%= render('jni/instance_access.erb', { entity: entity }) %>
<%= render('jni/parameter_access.erb', { method: compareMethod }) -%>
<% if entity.struct? -%>
Expand Down
2 changes: 1 addition & 1 deletion codegen/lib/templates/jni/method.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% method = locals[:method] -%>
<%= render('jni/method_prototype.erb', { method: method }) %> {
<%= render('jni/method_prototype.erb', { method: method, maybe_unused: true }) %> {
<% if !method.static -%>
<%= render('jni/instance_access.erb', { entity: entity }) %>
<% end -%>
Expand Down
13 changes: 10 additions & 3 deletions codegen/lib/templates/jni/method_prototype.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
<%
method = locals[:method]
maybe_unused = locals[:maybe_unused]

maybe_unused_str = ''
if maybe_unused
maybe_unused_str = '[[maybe_unused]] '
end

if method.static
parameters = 'jclass thisClass' + JNIHelper.parameters(method.parameters)
parameters = maybe_unused_str + 'jclass thisClass' + JNIHelper.parameters(method.parameters)
else
parameters = 'jobject thisObject' + JNIHelper.parameters(method.parameters.drop(1))
parameters = maybe_unused_str + 'jobject thisObject' + JNIHelper.parameters(method.parameters.drop(1))
end
-%>
<%= JNIHelper.type(method.return_type) %> JNICALL <%= JNIHelper.function_name(entity: entity, function: method) %>(JNIEnv *env, <%= parameters %>)<% -%>
<%= JNIHelper.type(method.return_type) %> JNICALL <%= JNIHelper.function_name(entity: entity, function: method) %>(<%= maybe_unused_str %>JNIEnv *env, <%= parameters %>)<% -%>
6 changes: 3 additions & 3 deletions codegen/lib/templates/jni_c.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<%# Constructors -%>
<% entity.static_methods.each do |method| -%>
<% next unless method.name.start_with?('Create') -%>
jlong JNICALL <%= JNIHelper.function_name(entity: entity, function: method, native_prefix: true) %>(JNIEnv *env, jclass thisClass<%= JNIHelper.parameters(method.parameters) %>) {
jlong JNICALL <%= JNIHelper.function_name(entity: entity, function: method, native_prefix: true) %>([[maybe_unused]] JNIEnv *env, [[maybe_unused]] jclass thisClass<%= JNIHelper.parameters(method.parameters) %>) {
<%= render('jni/parameter_access.erb', { method: method }) -%>
struct TW<%= entity.name %> *instance = TW<%= entity.name %><%= method.name %>(<%= JNIHelper.arguments(method.parameters).join(', ') %>);
<%= render('jni/parameter_release.erb', { method: method }) -%>
Expand All @@ -31,15 +31,15 @@ jlong JNICALL <%= JNIHelper.function_name(entity: entity, function: method, nati
<%# Destructors -%>
<% entity.methods.each do |method| -%>
<% next unless method.name.start_with?('Delete') -%>
void JNICALL <%= JNIHelper.function_name(entity: entity, function: method, native_prefix: true) %>(JNIEnv *env, jclass thisClass, jlong handle) {
void JNICALL <%= JNIHelper.function_name(entity: entity, function: method, native_prefix: true) %>([[maybe_unused]] JNIEnv *env, [[maybe_unused]] jclass thisClass, jlong handle) {
TW<%= entity.name %>Delete((struct TW<%= entity.name %> *) handle);
}

<% end -%>
<%# Initializers -%>
<% entity.static_methods.each do |method| -%>
<% next unless method.name.start_with?('Init') -%>
jbyteArray JNICALL <%= JNIHelper.function_name(entity: entity, function: method) %>(JNIEnv *env, jclass thisClass<%= JNIHelper.parameters(method.parameters.drop(1)) %>) {
jbyteArray JNICALL <%= JNIHelper.function_name(entity: entity, function: method) %>(JNIEnv *env, [[maybe_unused]] jclass thisClass<%= JNIHelper.parameters(method.parameters.drop(1)) %>) {
jbyteArray array = (*env)->NewByteArray(env, sizeof(struct TW<%= entity.name %>));
jbyte* bytesBuffer = (*env)->GetByteArrayElements(env, array, NULL);
struct TW<%= entity.name %> *instance = (struct TW<%= entity.name %> *) bytesBuffer;
Expand Down
Loading

0 comments on commit 28ced94

Please sign in to comment.