Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
RomeroYang committed Feb 9, 2022
2 parents e421a1e + 5a79095 commit 4551bbc
Show file tree
Hide file tree
Showing 24 changed files with 459 additions and 6,880 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## [0.4.1] - 20220209

* bump polkadot-js/api v7.2.1
* update offline-signature api
* update parachains api
* update assets api for statemine
* add plugin.appUtils for auto routing

## [0.4.0] - 20220104

* bump polkadot-js/api v7.1.1
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.3.7"
version: "0.4.0"
process:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion js_api/dist/main.js

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions js_api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
"build-dev": "webpack --mode development"
},
"resolutions": {
"@polkadot/api": "^7.1.1"
"@polkadot/api": "^7.2.1"
},
"dependencies": {
"@polkadot/api": "^7.1.1",
"@polkadot/api": "^7.2.1",
"@polkadot/extension-dapp": "^0.40.3",
"@polkadot/ui-shared": "0.86.7",
"@walletconnect/client": "2.0.0-alpha.26",
Expand All @@ -42,16 +42,14 @@
"@babel/plugin-transform-runtime": "^7.14.5",
"@babel/preset-env": "^7.14.8",
"@babel/preset-typescript": "^7.14.5",
"@webpack-cli/info": "^0.2.0",
"@webpack-cli/init": "^0.3.0",
"babel-loader": "^8.0.6",
"crypto-browserify": "^3.12.0",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.9.0",
"eslint-plugin-prettier": "^3.1.2",
"prettier": "^1.19.1",
"stream-browserify": "^3.0.0",
"webpack": "^5.42.0",
"webpack-cli": "^4.7.2"
"webpack": "^5.65.0",
"webpack-cli": "^4.9.1"
}
}
20 changes: 2 additions & 18 deletions js_api/src/service/parachain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,24 +194,8 @@ async function _queryAuctionInfo(api: ApiPromise) {
* @param {String} pubKey
*/
async function queryUserContributions(api: ApiPromise, paraId: string, pubKey: string) {
const fund = await api.query.crowdloan.funds(paraId) as any;
const childKey = _createChildKey(fund.unwrap().trieIndex);
const value = await api.rpc.childstate.getStorage(childKey, pubKey);
if (value.isSome) {
return api.createType('(Balance, Vec<u8>)' as any, value.unwrap()).toJSON()[0].toString();
}
return '0';
}

function _createChildKey (trieIndex: TrieIndex): string {
return u8aToHex(
u8aConcat(
':child_storage:default:',
blake2AsU8a(
u8aConcat('crowdloan', trieIndex.toU8a())
)
)
);
const res = await api.derive.crowdloan.ownContributions(paraId, [pubKey]);
return res[pubKey];
}

export default {
Expand Down
12 changes: 6 additions & 6 deletions js_api/src/utils/QrSigner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ async function _constructDataFromBytes(bytes: Uint8Array, multipartComplete = fa
data.data["genesisHash"] = genesisHash;
const isOversized = rawPayload.length > 256;
const network = SUBSTRATE_NETWORK_LIST[genesisHash];
if (!network) {
throw new Error(`Signer does not currently support a chain with genesis hash: ${genesisHash}`);
}
// if (!network) {
// throw new Error(`Signer does not currently support a chain with genesis hash: ${genesisHash}`);
// }

switch (secondByte) {
case "00": // sign mortal extrinsic
Expand All @@ -154,15 +154,15 @@ async function _constructDataFromBytes(bytes: Uint8Array, multipartComplete = fa
// ? await blake2b(u8aToHex(payload, -1, false))
// : rawPayload;
data.data["data"] = rawPayload; // ignore oversized data for now
data.data["account"] = encodeAddress(publicKeyAsBytes, network.prefix); // encode to the prefix;
data.data["account"] = encodeAddress(publicKeyAsBytes, network?.prefix || 0); // encode to the prefix;

break;
case "01": // data is a hash
data["action"] = "signData";
data["oversized"] = false;
data["isHash"] = true;
data.data["data"] = hexPayload;
data.data["account"] = encodeAddress(publicKeyAsBytes, network.prefix); // default to Kusama
data.data["account"] = encodeAddress(publicKeyAsBytes, network?.prefix || 0); // default to Kusama
break;
}
} catch (e) {
Expand Down Expand Up @@ -263,7 +263,7 @@ export async function parseQrCode(rawData: string) {
try {
const strippedData = _rawDataToU8A(rawData);
await _setParsedData(strippedData, false);
return { signer: signer.unsignedData.data.account };
return { signer: signer.unsignedData.data.account, genesisHash: signer.unsignedData.data.genesisHash };
} catch (err) {
return { error: err.message };
}
Expand Down
1 change: 1 addition & 0 deletions js_api/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const webpack = require("webpack");
const config = {
entry: "./src/index.ts",
output: {
publicPath: path.resolve(__dirname, ""),
path: path.resolve(__dirname, "dist"),
filename: "main.js",
},
Expand Down
Loading

0 comments on commit 4551bbc

Please sign in to comment.