Skip to content
This repository was archived by the owner on May 14, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
22a9ab8
Add half of the code for the account linking api.
May 26, 2019
9c84105
Add more code for the account linking api.
May 28, 2019
dfecec8
1. Fix the transaction exception message because it was printing the …
May 29, 2019
5dfd4c8
Merge branch 'master' into DP-492_one_wallet_account_linking_api
May 29, 2019
bfb111c
1. Add 'aggregateBalance', 'controlledAccounts' 'accountData'
Jun 2, 2019
619340f
Add a TODO
Jun 2, 2019
2c11801
Merge branch 'master' into DP-492_one_wallet_account_linking_api
Jun 2, 2019
6179ebb
Add more java doc and some more unit tests
Jun 3, 2019
15f4883
Add and change some java docs
Jun 3, 2019
6fc0377
remove 2 TODOs
Jun 3, 2019
3f60ff7
Add another test which was written in the tech design
Jun 3, 2019
0ccfcb4
Show txResultCode even if no opResultCode
Jun 6, 2019
d59e43c
Add more java doc
Jun 6, 2019
5a6cd33
Add java doc in order to explain a bit on c=aggregated balance, contr…
Jun 6, 2019
e6cbd3e
Indent the java doc
Jun 6, 2019
d4589e6
Add a DecodeTransactionException and throw it if decode transaction f…
Jun 6, 2019
66e2ccd
Add javadocs to our Transaction object and also remove the id/hash fr…
Jun 6, 2019
46b2fec
1. Add validation to the memo when build method is called
Jun 6, 2019
5ce9959
Remove and add some java docs and also validate fee is not negative
Jun 7, 2019
c1b404f
Remove aappId form setMemo and add it to the constructor so it will b…
Jun 7, 2019
5bf88a8
Update and fix tests
Jun 7, 2019
e05b46e
Rename the fee in some places
Jun 7, 2019
739e47b
remove the get prefix
Jun 10, 2019
9d74c93
As a result from removing the get prefix then the code here changed
Jun 10, 2019
ed2b90c
Add missing methods nad remove the get prefix
Jun 10, 2019
229e92c
As a result from removing the get prefix then the code here changed
Jun 10, 2019
4a598e4
As a result from removing the get prefix then the code here changed
Jun 10, 2019
51d71f4
As a result from removing the get prefix then the code here changed
Jun 10, 2019
2e4e703
As a result from removing the get prefix then the code here changed
Jun 10, 2019
d4405df
Remove stellar docs
Jun 10, 2019
bf80b37
1. Add base transaction class and change th older one to be payment t…
Jun 10, 2019
8baa5da
1. Add base transaction class and change the older one to be payment …
Jun 11, 2019
0f3fdb9
1. Add memo appId to memo only after validation of the memo
Jun 11, 2019
e3d2819
1. Fix the tests because change the transaction creation
Jun 11, 2019
f46ccc3
Merge branch 'master' into DP-492_one_wallet_account_linking_api
Jun 11, 2019
9cf68ab
1. Rename all the variations of buildTransaction to be buildPaymentTr…
Jun 12, 2019
e5cd9f3
1. change the base unit to quark in the docs
Jun 12, 2019
9cdb1e4
1. format the class
Jun 13, 2019
1fc216d
1. Change the code style settings
Jun 13, 2019
0d98639
Update README.md
drEfrati Jun 13, 2019
33d266b
Edited by Sasha
sbeskin Jun 13, 2019
d4c7eaf
Edited by Sasha 2
sbeskin Jun 13, 2019
dacfeda
Update README.md
drEfrati Jun 13, 2019
6edd97e
Update README.md
drEfrati Jun 13, 2019
a8b1d14
Update README.md
drEfrati Jun 13, 2019
7bbe684
Sasha
sbeskin Jun 13, 2019
cd63473
1. Change the code style settings
Jun 13, 2019
e8ad994
Merge branch 'DP-492_one_wallet_account_linking_api' of github.com:ki…
Jun 13, 2019
6d5173c
Remove get prefix
Jun 16, 2019
660e19b
rename the controlled account url and fix whitelist test because of t…
Jun 16, 2019
27f4504
Update README.md
drEfrati Jun 16, 2019
8379cfa
Merge branch 'master' into DP-492_one_wallet_account_linking_api
Jun 16, 2019
83570ae
Update README.md
drEfrati Jun 16, 2019
b2e13c6
Use regular test-net instead of the one wallet url (which we used onl…
Jun 17, 2019
e8e28eb
Add more java docs
Jun 17, 2019
e4feb56
Fix the tests because now we accept Memo and not just a string in Tra…
Jun 17, 2019
6cc4208
Fix the sample app because the removal of the 'get' prefix in the Whi…
Jun 17, 2019
c590fba
Add getAggregatedBalance(String publicAddress) and same for getAggreg…
Jun 18, 2019
00fcd49
Merge branch 'master' into DP-492_one_wallet_account_linking_api
Jun 18, 2019
ce3d16e
Remove any related code of getAggregatedBalance and getControlledAcco…
Jul 21, 2019
08c03bd
Merge branch 'master' into DP-492_one_wallet_account_linking_api
Jul 21, 2019
82c12e8
Rename WhitelistPayload instead of WhitelistableTransaction
Jul 25, 2019
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
12 changes: 6 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ services:
- docker

before_install:
- yes | sdkmanager "platforms;android-26"
- yes | sdkmanager "platforms;android-28"
- yes | sdkmanager "platforms;android-26"
- yes | sdkmanager "platforms;android-28"

before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
Expand All @@ -23,10 +23,10 @@ cache:
- node_modules

env:
- TEST_MATRIX=assemble
- TEST_MATRIX=units
- TEST_MATRIX=android_test_kin_sdk
- TEST_MATRIX=android_test_backup_restore
- TEST_MATRIX=assemble
- TEST_MATRIX=units
- TEST_MATRIX=android_test_kin_sdk
- TEST_MATRIX=android_test_backup_restore

android:
components:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="kin.backupandrestore.test">

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -17,91 +17,91 @@

public class QRBarcodeGeneratorImplTest {

private static final String TEST_DATA = "{\n"
+ " \"pkey\": \"GCJS54LFY5H5UXSAKLWP3GXCNKAZZLRAPO45B6PLAAINRVKJSWZGZAF4\",\n"
+ " \"seed\": \"cb60a6afa2427194f4fbdc19969dd2b34677e2cae5108d34f51970a43f47eacf36520ebe26c34064ab6d1cd29e9e8c362685651a81f0ce0525dd728028b7956e037545ec223b72d8\",\n"
+ " \"salt\": \"f16fa85a112efdd00eb0134239f53c37\"\n"
+ "}";

private static final String EXPECTED_TEXT_QR_IMAGE = "{\n"
+ " \"pkey\": \"GCJS54LFY5H5UXSAKLWP3GXCNKAZZLRAPO45B6PLAAINRVKJSWZGZAF4\",\n"
+ " \"seed\": \"c71d8965df716fb0a6edb53b5f4215f9f5b29552aef761e44b0d3fd9a26eb8fae3001e5be27e1d0df1f3baf72b2ddea38075cd0783d14e842c555d1b7264211546503fab7b647b09\",\n"
+ " \"salt\": \"ad1b920b16e4f7b519ac5117af77069d\"\n"
+ "}";

private static final String EXPECTED_TEXT_QR_IMAGE_TRY_HARDER = "{\n"
+ " \"pkey\": \"GCSFMCRAJ7UQU7MDA5TUBY3ROFYU6L6D2JPKXUM4YGSL2SLZOTKCS647\",\n"
+ " \"seed\": \"6f9e2fe953d37a0122347df582e57f9f7a2a7a91eccb3c5b13450c4ac7b94987ebd330e546b020e930062ed01c32d228f557e74979d3170d66644a6407ba56f70d9d508e2f4c5b7a\",\n"
+ " \"salt\": \"0586cdddfa57a2cfa8d02ca78103f3c7\"\n"
+ "}";

@Rule
public ExpectedException expectedEx = ExpectedException.none();
private QRBarcodeGeneratorImpl qrBarcodeGenerator;

private FakeQRFileUriHandler fakeQRFileHandler;

class FakeQRFileUriHandler implements QRFileUriHandler {

private int counter = 0;
private HashMap<Uri, Bitmap> map = new HashMap<>();

@NonNull
@Override
public Bitmap loadFile(@NonNull Uri uri) {
return map.get(uri);
}

@NonNull
@Override
public Uri saveFile(@NonNull Bitmap image) {
Uri fakeUri = Uri.parse("file://test/" + counter + ".png");
map.put(fakeUri, image);
return fakeUri;
}
}

@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
fakeQRFileHandler = new FakeQRFileUriHandler();
qrBarcodeGenerator = new QRBarcodeGeneratorImpl(fakeQRFileHandler);
}

@Test
public void generate_success() throws Exception {
Uri uri = qrBarcodeGenerator.generate(TEST_DATA);
assertNotNull(uri);
assertNotNull(fakeQRFileHandler.loadFile(uri));
}

@Test
public void decodeQR_success() throws Exception {
// test a QR that was being able to be decoded only with TRY_HARDER flag in zxing library
Bitmap bitmap = TestUtils.loadBitmapFromResource(this.getClass(), "backup_qr_try_harder.png");
Uri uri = fakeQRFileHandler.saveFile(bitmap);
String decodedQR = qrBarcodeGenerator.decodeQR(uri);
assertThat(decodedQR, equalTo(EXPECTED_TEXT_QR_IMAGE_TRY_HARDER));

Bitmap bitmap2 = TestUtils.loadBitmapFromResource(this.getClass(), "qr_test.png");
Uri uri2 = fakeQRFileHandler.saveFile(bitmap2);
String decodedQR2 = qrBarcodeGenerator.decodeQR(uri2);
assertThat(decodedQR2, equalTo(EXPECTED_TEXT_QR_IMAGE));
}

@Test
public void decodeQR_EmptyImage_NotFoundException() throws Exception {
expectedEx.expect(QRNotFoundInImageException.class);
Bitmap bitmap = Bitmap.createBitmap(300, 300, Bitmap.Config.ARGB_8888);
Uri uri = fakeQRFileHandler.saveFile(bitmap);
qrBarcodeGenerator.decodeQR(uri);
}

@Test
public void generateAndDecode_success() throws Exception {
Uri uri = qrBarcodeGenerator.generate(TEST_DATA);
String decodedQR = qrBarcodeGenerator.decodeQR(uri);
assertThat(decodedQR, equalTo(TEST_DATA));
}
private static final String TEST_DATA = "{\n"
+ " \"pkey\": \"GCJS54LFY5H5UXSAKLWP3GXCNKAZZLRAPO45B6PLAAINRVKJSWZGZAF4\",\n"
+ " \"seed\": \"cb60a6afa2427194f4fbdc19969dd2b34677e2cae5108d34f51970a43f47eacf36520ebe26c34064ab6d1cd29e9e8c362685651a81f0ce0525dd728028b7956e037545ec223b72d8\",\n"
+ " \"salt\": \"f16fa85a112efdd00eb0134239f53c37\"\n"
+ "}";

private static final String EXPECTED_TEXT_QR_IMAGE = "{\n"
+ " \"pkey\": \"GCJS54LFY5H5UXSAKLWP3GXCNKAZZLRAPO45B6PLAAINRVKJSWZGZAF4\",\n"
+ " \"seed\": \"c71d8965df716fb0a6edb53b5f4215f9f5b29552aef761e44b0d3fd9a26eb8fae3001e5be27e1d0df1f3baf72b2ddea38075cd0783d14e842c555d1b7264211546503fab7b647b09\",\n"
+ " \"salt\": \"ad1b920b16e4f7b519ac5117af77069d\"\n"
+ "}";

private static final String EXPECTED_TEXT_QR_IMAGE_TRY_HARDER = "{\n"
+ " \"pkey\": \"GCSFMCRAJ7UQU7MDA5TUBY3ROFYU6L6D2JPKXUM4YGSL2SLZOTKCS647\",\n"
+ " \"seed\": \"6f9e2fe953d37a0122347df582e57f9f7a2a7a91eccb3c5b13450c4ac7b94987ebd330e546b020e930062ed01c32d228f557e74979d3170d66644a6407ba56f70d9d508e2f4c5b7a\",\n"
+ " \"salt\": \"0586cdddfa57a2cfa8d02ca78103f3c7\"\n"
+ "}";

@Rule
public ExpectedException expectedEx = ExpectedException.none();
private QRBarcodeGeneratorImpl qrBarcodeGenerator;

private FakeQRFileUriHandler fakeQRFileHandler;

class FakeQRFileUriHandler implements QRFileUriHandler {

private int counter = 0;
private HashMap<Uri, Bitmap> map = new HashMap<>();

@NonNull
@Override
public Bitmap loadFile(@NonNull Uri uri) {
return map.get(uri);
}

@NonNull
@Override
public Uri saveFile(@NonNull Bitmap image) {
Uri fakeUri = Uri.parse("file://test/" + counter + ".png");
map.put(fakeUri, image);
return fakeUri;
}
}

@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
fakeQRFileHandler = new FakeQRFileUriHandler();
qrBarcodeGenerator = new QRBarcodeGeneratorImpl(fakeQRFileHandler);
}

@Test
public void generate_success() throws Exception {
Uri uri = qrBarcodeGenerator.generate(TEST_DATA);
assertNotNull(uri);
assertNotNull(fakeQRFileHandler.loadFile(uri));
}

@Test
public void decodeQR_success() throws Exception {
// test a QR that was being able to be decoded only with TRY_HARDER flag in zxing library
Bitmap bitmap = TestUtils.loadBitmapFromResource(this.getClass(), "backup_qr_try_harder.png");
Uri uri = fakeQRFileHandler.saveFile(bitmap);
String decodedQR = qrBarcodeGenerator.decodeQR(uri);
assertThat(decodedQR, equalTo(EXPECTED_TEXT_QR_IMAGE_TRY_HARDER));

Bitmap bitmap2 = TestUtils.loadBitmapFromResource(this.getClass(), "qr_test.png");
Uri uri2 = fakeQRFileHandler.saveFile(bitmap2);
String decodedQR2 = qrBarcodeGenerator.decodeQR(uri2);
assertThat(decodedQR2, equalTo(EXPECTED_TEXT_QR_IMAGE));
}

@Test
public void decodeQR_EmptyImage_NotFoundException() throws Exception {
expectedEx.expect(QRNotFoundInImageException.class);
Bitmap bitmap = Bitmap.createBitmap(300, 300, Bitmap.Config.ARGB_8888);
Uri uri = fakeQRFileHandler.saveFile(bitmap);
qrBarcodeGenerator.decodeQR(uri);
}

@Test
public void generateAndDecode_success() throws Exception {
Uri uri = qrBarcodeGenerator.generate(TEST_DATA);
String decodedQR = qrBarcodeGenerator.decodeQR(uri);
assertThat(decodedQR, equalTo(TEST_DATA));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,28 @@

public class QRFileUriHandlerImplTest {

private QRFileUriHandlerImpl fileUriHandler;

@Before
public void setup() {
fileUriHandler = new QRFileUriHandlerImpl(InstrumentationRegistry.getContext());
}

@Test
public void saveAndLoad() throws Exception {
Bitmap bitmap = TestUtils.loadBitmapFromResource(this.getClass(), "qr_test.png");
Uri uri = fileUriHandler.saveFile(bitmap);
Bitmap loadedBitmap = fileUriHandler.loadFile(uri);
assertThat(bitmap.sameAs(loadedBitmap), equalTo(true));
}

@Test
public void saveFile_Success() throws Exception {
Bitmap bitmap = TestUtils.loadBitmapFromResource(this.getClass(), "qr_test.png");
Uri uri = fileUriHandler.saveFile(bitmap);
assertThat(uri, notNullValue());
assertThat(uri.toString(), equalTo("content://kin.backupandrestore.test.KinRecoveryFileProvider/qr_codes/backup_qr.png"));
}
private QRFileUriHandlerImpl fileUriHandler;

@Before
public void setup() {
fileUriHandler = new QRFileUriHandlerImpl(InstrumentationRegistry.getContext());
}

@Test
public void saveAndLoad() throws Exception {
Bitmap bitmap = TestUtils.loadBitmapFromResource(this.getClass(), "qr_test.png");
Uri uri = fileUriHandler.saveFile(bitmap);
Bitmap loadedBitmap = fileUriHandler.loadFile(uri);
assertThat(bitmap.sameAs(loadedBitmap), equalTo(true));
}

@Test
public void saveFile_Success() throws Exception {
Bitmap bitmap = TestUtils.loadBitmapFromResource(this.getClass(), "qr_test.png");
Uri uri = fileUriHandler.saveFile(bitmap);
assertThat(uri, notNullValue());
assertThat(uri.toString(),
equalTo("content://kin.backupandrestore.test.KinRecoveryFileProvider/qr_codes/backup_qr.png"));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

public class TestUtils {

static Bitmap loadBitmapFromResource(Class clazz, String res) {
InputStream is = clazz.getClassLoader().getResourceAsStream(res);
return BitmapFactory.decodeStream(is);
}
static Bitmap loadBitmapFromResource(Class clazz, String res) {
InputStream is = clazz.getClassLoader().getResourceAsStream(res);
return BitmapFactory.decodeStream(is);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@

public class AccountExtractor {

@Nullable
public static KinAccount getKinAccount(KinClient kinClient, String publicAddress) {
KinAccount kinAccount = null;
if (kinClient != null && !TextUtils.isEmpty(publicAddress)) {
int numOfAccounts = kinClient.getAccountCount();
for (int i = 0; i < numOfAccounts; i++) {
KinAccount account = kinClient.getAccount(i);
if (account != null && account.getPublicAddress().equals(publicAddress)) {
kinAccount = account;
break;
}
}
}
return kinAccount;
}
@Nullable
public static KinAccount getKinAccount(KinClient kinClient, String publicAddress) {
KinAccount kinAccount = null;
if (kinClient != null && !TextUtils.isEmpty(publicAddress)) {
int numOfAccounts = kinClient.getAccountCount();
for (int i = 0; i < numOfAccounts; i++) {
KinAccount account = kinClient.getAccount(i);
if (account != null && account.getPublicAddress().equals(publicAddress)) {
kinAccount = account;
break;
}
}
}
return kinAccount;
}
}
Loading