Skip to content

Commit

Permalink
Merge pull request #158 from polkawallet-io/develop
Browse files Browse the repository at this point in the history
fix accountIndex parsing bug
  • Loading branch information
RomeroYang authored Sep 3, 2020
2 parents d4c16b3 + f384e88 commit a5dfbb3
Show file tree
Hide file tree
Showing 21 changed files with 10,139 additions and 91 deletions.
6 changes: 3 additions & 3 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
MARKETING_VERSION = 0.9.9;
MARKETING_VERSION = 0.9.10;
PRODUCT_BUNDLE_IDENTIFIER = io.polkawallet.polkawallet;
PRODUCT_NAME = Runner;
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
Expand Down Expand Up @@ -531,7 +531,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
MARKETING_VERSION = 0.9.9;
MARKETING_VERSION = 0.9.10;
PRODUCT_BUNDLE_IDENTIFIER = io.polkawallet.polkawallet;
PRODUCT_NAME = Runner;
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
Expand Down Expand Up @@ -561,7 +561,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
MARKETING_VERSION = 0.9.9;
MARKETING_VERSION = 0.9.10;
PRODUCT_BUNDLE_IDENTIFIER = io.polkawallet.polkawallet;
PRODUCT_NAME = Runner;
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
Expand Down
17 changes: 8 additions & 9 deletions lib/common/components/AddressInputField.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class _AddressInputFieldState extends State<AddressInputField> {
final listLocal = widget.store.account.accountList.toList();
listLocal.addAll(widget.store.settings.contactList);
// return local account list if input empty
if (input.isEmpty) {
if (input.isEmpty || input.trim().length < 3) {
return listLocal;
}

Expand All @@ -34,7 +34,8 @@ class _AddressInputFieldState extends State<AddressInputField> {
return listLocal;
}

String address = input;
final acc = AccountData();
acc.address = input;
if (input.length < 47) {
// check if input indices in local account list
final int indicesIndex = listLocal.indexWhere((e) {
Expand All @@ -45,10 +46,10 @@ class _AddressInputFieldState extends State<AddressInputField> {
return [listLocal[indicesIndex]];
}
// query account address with account indices
final queryRes = await webApi.account
.queryAddressWithAccountIndex(checkAddress.keys.toList()[0]);
final queryRes = await webApi.account.queryAddressWithAccountIndex(input);
if (queryRes != null) {
address = queryRes[0];
acc.address = queryRes[0];
acc.name = input;
}
} else {
// check if input address in local account list
Expand All @@ -60,12 +61,10 @@ class _AddressInputFieldState extends State<AddressInputField> {
}

// fetch address info if it's a new address
final res = await webApi.account.getAddressIcons([address]);
final res = await webApi.account.getAddressIcons([acc.address]);
if (res != null) {
await webApi.account.fetchAccountsIndex([address]);
await webApi.account.fetchAccountsIndex([acc.address]);
}
final acc = AccountData();
acc.address = address;
return [acc];
}

Expand Down
10 changes: 5 additions & 5 deletions lib/common/consts/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,14 @@ const String cross_chain_transfer_address_laminar =
'5CLaminarAUSDCrossChainTransferxxxxxxxxxxxxxwisu';

/// app versions
const String app_beta_version = '0.9.9-beta.1';
const String app_beta_version = '0.9.10-beta.1';

/// js code versions
const Map<String, int> js_code_version_map = {
network_name_polkadot: 9810,
network_name_kusama: 9810,
network_name_acala_mandala: 9810,
network_name_laminar_turbulence: 9810,
network_name_polkadot: 91010,
network_name_kusama: 91010,
network_name_acala_mandala: 91010,
network_name_laminar_turbulence: 91010,
};

/// graphql for laminar
Expand Down
3 changes: 2 additions & 1 deletion lib/js_service_acala/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"@polkadot/api": "^1.18.1",
"@polkadot/keyring": "^3.1.0-beta.0",
"@polkadot/ui-shared": "^0.51.1",
"bn.js": "^5.1.1"
"bn.js": "^5.1.1",
"oo7-substrate": "^0.8.0"
},
"devDependencies": {
"@babel/core": "^7.8.3",
Expand Down
8 changes: 8 additions & 0 deletions lib/js_service_acala/src/service/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
cryptoWaitReady,
} from "@polkadot/util-crypto";
import { hexToU8a, u8aToHex, hexToString } from "@polkadot/util";
import { ss58Decode } from "oo7-substrate/src/ss58";
import generateIcon from "@polkadot/ui-shared/polkadotIcon";
import BN from "bn.js";
import {
Expand Down Expand Up @@ -165,6 +166,12 @@ async function encodeAddress(pubKeys, ss58Formats) {
return res;
}

async function queryAddressWithAccountIndex(accIndex, ss58) {
const num = ss58Decode(accIndex, ss58).toJSON();
const res = await api.query.indices.accounts(num.data);
return res;
}

async function queryAccountsBonded(pubKeys) {
return Promise.all(
pubKeys
Expand Down Expand Up @@ -490,6 +497,7 @@ export default {
initKeys,
encodeAddress,
decodeAddress,
queryAddressWithAccountIndex,
gen,
genIcons,
genPubKeyIcons,
Expand Down
Loading

0 comments on commit a5dfbb3

Please sign in to comment.