Skip to content

Commit 3ddc933

Browse files
authored
Fix expired reauthorizations (#979)
* add migrate method to AccountRecordsDaoInterface * implement migrate method in AccountRecordsDao * call migrate when reissuing an authtoken * change method name
1 parent c10eb19 commit 3ddc933

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

android/walletlib/src/main/java/com/solana/mobilewalletadapter/walletlib/authorization/AccountRecordsDao.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
import androidx.annotation.NonNull;
1313
import androidx.annotation.Nullable;
1414

15-
import java.util.ArrayList;
16-
import java.util.List;
17-
1815
public class AccountRecordsDao extends DbContentProvider<AccountRecord>
1916
implements AccountRecordsDaoInterface, AccountRecordsSchema {
2017

@@ -43,6 +40,18 @@ public long insert(@NonNull long parentId,
4340
return super.insert(TABLE_ACCOUNTS, accountContentValues);
4441
}
4542

43+
@Override
44+
public long updateParentId(long oldParentId, long newParentId) {
45+
final ContentValues accountContentValues = new ContentValues(1);
46+
accountContentValues.put(COLUMN_ACCOUNTS_PARENT_ID, newParentId);
47+
return super.update(
48+
TABLE_ACCOUNTS,
49+
accountContentValues,
50+
COLUMN_ACCOUNTS_PARENT_ID + "=?",
51+
new String[] { String.valueOf(oldParentId) }
52+
);
53+
}
54+
4655
@Nullable
4756
@Override
4857
public AccountRecord query(@NonNull byte[] publicKey) {

android/walletlib/src/main/java/com/solana/mobilewalletadapter/walletlib/authorization/AccountRecordsDaoInterface.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ long insert(@NonNull long parentId, @NonNull byte[] publicKey,
1515
@Nullable String accountLabel, @Nullable Uri accountIcon,
1616
@Nullable String[] chains, @Nullable String[] features);
1717

18+
@IntRange(from = 0)
19+
long updateParentId(long oldParentId, long newParentId);
20+
1821
// @Nullable
1922
// List<AccountRecord> query(int parentId);
2023

android/walletlib/src/main/java/com/solana/mobilewalletadapter/walletlib/authorization/AuthRepositoryImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ public synchronized AuthRecord reissue(@NonNull AuthRecord authRecord) {
444444
} else {
445445
final int id = (int) mAuthorizationsDao.insert(authRecord.identity.getId(), now,
446446
authRecord.chain, authRecord.walletUriBaseId, authRecord.scope);
447+
mAccountsDao.updateParentId(authRecord.id, id);
447448
reissued = new AuthRecord(id, authRecord.identity, authRecord.accounts,
448449
authRecord.chain, authRecord.scope, authRecord.walletUriBase,
449450
authRecord.walletUriBaseId, now,

0 commit comments

Comments
 (0)