Skip to content

Commit

Permalink
Update crowdloan logic
Browse files Browse the repository at this point in the history
  • Loading branch information
saltict committed Oct 19, 2023
1 parent 850de9b commit 16fd194
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"@polkadot/types": "^10.9.1",
"@polkadot/util": "^12.3.2",
"@polkadot/util-crypto": "^12.3.2",
"@subwallet/chain-list": "0.2.18-beta.0",
"@subwallet/chain-list": "0.2.18-beta.2",
"@subwallet/keyring": "^0.1.1",
"@subwallet/ui-keyring": "^0.1.1",
"babel-core": "^7.0.0-bridge.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/extension-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@reduxjs/toolkit": "^1.9.1",
"@sora-substrate/type-definitions": "^1.17.7",
"@substrate/connect": "^0.7.26",
"@subwallet/chain-list": "0.2.18-beta.0",
"@subwallet/chain-list": "0.2.18-beta.2",
"@subwallet/extension-base": "^1.1.12-1",
"@subwallet/extension-chains": "^1.1.12-1",
"@subwallet/extension-dapp": "^1.1.12-1",
Expand Down
8 changes: 6 additions & 2 deletions packages/extension-base/src/koni/api/dotsama/crowdloan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export type CrowdloanFundInfo = _CrowdloanFund & {
}

const getOnlineFundList = (async () => {
const request = await axios.get<CrowdloanFundInfo[]>('https://static-data.subwallet.app/crowdloan-funds/list.json');
const request = await axios.get<CrowdloanFundInfo[]>('https://content.subwallet.app/api/list/crowdloan-fund');

return request.data;
})();
Expand All @@ -36,6 +36,7 @@ function getRPCCrowdloan (parentAPI: _SubstrateApi, fundInfo: _CrowdloanFund, he
let contribute = new BN(0);

Object.values(result).forEach((item) => {
console.log(fundId, item.toBn().toString());
contribute = contribute.add(item.toBn());
});

Expand Down Expand Up @@ -161,12 +162,15 @@ export async function subscribeCrowdloan (addresses: string[], substrateApiMap:
const chainSlug = fundInfo.chain;
const endTime = new Date(fundInfo.endTime).getTime();
const parentChain = fundInfo.relayChain;
const substrateInfo = chainInfoMap[chainSlug]?.substrateInfo;

if (chainSlug && parentChain && STATUS_MAP[fundInfo.status] && fundInfo.paraId && endTime > now && chainInfoMap[chainSlug]) {
if (chainSlug && parentChain && STATUS_MAP[fundInfo.status] && fundInfo.paraId && endTime > now && substrateInfo) {
const crowdloanCb = (rs: CrowdloanItem) => {
callback(chainSlug, rs);
};

fundInfo.paraId = substrateInfo.crowdloanParaId || substrateInfo.paraId || fundInfo.paraId;

if (chainSlug === COMMON_CHAIN_SLUGS.ACALA) {
const acalaAddresses = substrateAddresses.map((address) => reformatAddress(address, 10, false));

Expand Down
2 changes: 1 addition & 1 deletion packages/extension-koni-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@polkadot/util-crypto": "^12.3.2",
"@ramonak/react-progress-bar": "^5.0.3",
"@reduxjs/toolkit": "^1.9.1",
"@subwallet/chain-list": "0.2.18-beta.0",
"@subwallet/chain-list": "0.2.18-beta.2",
"@subwallet/extension-base": "^1.1.12-1",
"@subwallet/extension-chains": "^1.1.12-1",
"@subwallet/extension-dapp": "^1.1.12-1",
Expand Down
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5863,14 +5863,14 @@ __metadata:
languageName: node
linkType: hard

"@subwallet/chain-list@npm:0.2.18-beta.0":
version: 0.2.18-beta.0
resolution: "@subwallet/chain-list@npm:0.2.18-beta.0"
"@subwallet/chain-list@npm:0.2.18-beta.2":
version: 0.2.18-beta.2
resolution: "@subwallet/chain-list@npm:0.2.18-beta.2"
dependencies:
"@polkadot/dev": 0.67.167
"@polkadot/util": ^12.5.1
eventemitter3: ^5.0.1
checksum: ed19fa4ad2954e9407846bae484156116e67d6471beb9fdb09c7aa7c204dccbe1c9c6f3dcf33b6d63cbd352f1a1a7b4833746c3b75ee59d1f99fc666f2ed7b1a
checksum: b1b9817df8d1659566dcdd87755f07c64123d2ddd5a1c204d08e1ecf0128282a0513f3896e8ced072877597d24701a6419068adc18e83e51f6731ac0184001ff
languageName: node
linkType: hard

Expand Down Expand Up @@ -5905,7 +5905,7 @@ __metadata:
"@reduxjs/toolkit": ^1.9.1
"@sora-substrate/type-definitions": ^1.17.7
"@substrate/connect": ^0.7.26
"@subwallet/chain-list": 0.2.18-beta.0
"@subwallet/chain-list": 0.2.18-beta.2
"@subwallet/extension-base": ^1.1.12-1
"@subwallet/extension-chains": ^1.1.12-1
"@subwallet/extension-dapp": ^1.1.12-1
Expand Down Expand Up @@ -6035,7 +6035,7 @@ __metadata:
"@polkadot/util-crypto": ^12.3.2
"@ramonak/react-progress-bar": ^5.0.3
"@reduxjs/toolkit": ^1.9.1
"@subwallet/chain-list": 0.2.18-beta.0
"@subwallet/chain-list": 0.2.18-beta.2
"@subwallet/extension-base": ^1.1.12-1
"@subwallet/extension-chains": ^1.1.12-1
"@subwallet/extension-dapp": ^1.1.12-1
Expand Down

0 comments on commit 16fd194

Please sign in to comment.