Skip to content

Commit ef1bcd1

Browse files
authored
Merge pull request #200 from cosmology-tech/eason/chain-template
bug fixed for chain-template
2 parents 0f4ba5d + c1b10e7 commit ef1bcd1

File tree

17 files changed

+14394
-87
lines changed

17 files changed

+14394
-87
lines changed

.github/workflows/run-tests-build.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,18 @@ jobs:
6161
- name: Set up Yarn
6262
uses: threeal/[email protected]
6363

64+
- name: Get last git commit hash
65+
run: |
66+
echo "DIFF_HASH=$(git log -1 --pretty=format:%H)" >> $GITHUB_ENV
67+
6468
- name: Cache NextJS
6569
uses: actions/cache@v4
6670
with:
6771
path: |
6872
${{ github.workspace }}/.next/cache
6973
# Generate a new cache whenever packages or source files change.
70-
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
74+
#key: ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
75+
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-${{ env.DIFF_HASH }}
7176
# If source files changed but packages didn't, rebuild from a prior cache.
7277
restore-keys: |
7378
${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-

.github/workflows/run-tests.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ jobs:
6060
run: |
6161
cca --example nft --name nft
6262
cd nft
63+
touch yarn.lock
64+
yarn install
6365
yarn build
6466
6567
- name: authz

examples/chain-template/components/asset-list/DropdownTransferModal.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,9 @@ const OverviewTransferWrapper = (
184184
}
185185
return new BigNumber(asset.amount).gt(0);
186186
})
187-
.filter((asset) => {
188-
return asset.symbol !== transferToken.symbol;
189-
})
187+
// .filter((asset) => {
188+
// return asset.symbol !== transferToken.symbol;
189+
// })
190190
.map((asset) => ({
191191
available: new BigNumber(asset.displayAmount).toNumber(),
192192
symbol: asset.symbol,
@@ -198,6 +198,7 @@ const OverviewTransferWrapper = (
198198
).toNumber(),
199199
}));
200200
}, [assets, isDeposit, transferToken]);
201+
console.log('assetOptions', assetOptions);
201202

202203
const handleOnChange = (
203204
assetOption: Unpacked<OverviewTransferProps['dropdownList']>,
@@ -269,7 +270,7 @@ export const DropdownTransferModal = (props: OverviewTransferWrapperProps) => {
269270
return (
270271
<BasicModal
271272
isOpen={modalControl.isOpen}
272-
title="Deposit"
273+
title={transferInfoState.transferInfo.type}
273274
onClose={() => closeModal()}
274275
>
275276
{transferInfoState ? (

examples/chain-template/components/staking/DelegateModal.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ import {
2020
isGreaterThanZero,
2121
shiftDigits,
2222
calcDollarValue,
23+
getCoin,
24+
getExponent,
25+
toBaseAmount,
2326
} from '@/utils';
24-
import { getCoin, getExponent } from '@/utils';
2527
import { Prices, UseDisclosureReturn, useTx } from '@/hooks';
2628

2729
const { delegate } = cosmos.staking.v1beta1.MessageComposer.fromPartial;
@@ -84,7 +86,7 @@ export const DelegateModal = ({
8486
delegatorAddress: address,
8587
validatorAddress: selectedValidator.address,
8688
amount: {
87-
amount: shiftDigits(amount, exp),
89+
amount: toBaseAmount(amount, exp), // shiftDigits(amount, exp),
8890
denom: coin.base,
8991
},
9092
});
@@ -220,8 +222,7 @@ export const DelegateModal = ({
220222
},
221223
{
222224
label: 'Max',
223-
onClick: handleMaxClick,
224-
isLoading: isSimulating,
225+
onClick: () => setAmount(Number(balance)),
225226
},
226227
],
227228
}}

examples/chain-template/components/staking/RedelegateModal.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
getAssetLogoUrl,
1818
isGreaterThanZero,
1919
shiftDigits,
20+
toBaseAmount,
2021
type ExtendedValidator as Validator,
2122
} from '@/utils';
2223
import { getCoin, getExponent } from '@/utils';
@@ -67,7 +68,7 @@ export const RedelegateModal = ({
6768
validatorDstAddress: validatorToRedelegate.address,
6869
amount: {
6970
denom: coin.base,
70-
amount: shiftDigits(amount, exp),
71+
amount: toBaseAmount(amount, exp),
7172
},
7273
});
7374

examples/chain-template/components/staking/UndelegateModal.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
getAssetLogoUrl,
2020
isGreaterThanZero,
2121
shiftDigits,
22+
toBaseAmount,
2223
type ExtendedValidator as Validator,
2324
} from '@/utils';
2425

@@ -68,7 +69,7 @@ export const UndelegateModal = ({
6869
delegatorAddress: address,
6970
validatorAddress: selectedValidator.address,
7071
amount: {
71-
amount: shiftDigits(amount, exp),
72+
amount: toBaseAmount(amount, exp),
7273
denom: coin.base,
7374
},
7475
});

examples/chain-template/components/voting/Proposal.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export function Proposal({
5656
proposal,
5757
chainName,
5858
bondedTokens,
59-
onVoteSuccess = () => {},
59+
onVoteSuccess = () => { },
6060
}: ProposalProps) {
6161
const vote = votes?.[proposal.id.toString()];
6262

@@ -92,9 +92,9 @@ export function Proposal({
9292

9393
const total = proposal.finalTallyResult
9494
? Object.values(proposal.finalTallyResult).reduce(
95-
(sum, val) => sum + Number(val),
96-
0
97-
)
95+
(sum, val) => sum + Number(val),
96+
0
97+
)
9898
: 0;
9999

100100
const turnout = total / Number(bondedTokens);
@@ -248,9 +248,8 @@ export function Proposal({
248248
px: '$2',
249249
}}
250250
>
251-
{`Minimum of staked ${minStakedTokens} ${coin.symbol}(${
252-
quorum * 100
253-
}%) need to vote
251+
{`Minimum of staked ${minStakedTokens} ${coin.symbol}(${quorum * 100
252+
}%) need to vote
254253
for this proposal to pass.`}
255254
</Text>
256255
</Text>
@@ -347,14 +346,20 @@ export function Proposal({
347346
</Text>
348347

349348
<Text fontSize="$sm" fontWeight="$normal" color="$textSecondary">
349+
<div style={{ maxHeight: '128px', overflowY: 'scroll' }}>
350+
<Markdown>{description}</Markdown>
351+
</div>
352+
</Text>
353+
354+
{/* <Text fontSize="$sm" fontWeight="$normal" color="$textSecondary">
350355
{showMore ? <Markdown>{description}</Markdown> : renderedDescription}
351356
</Text>
352357
353358
<Box mt="$8" width="100%" display="flex" justifyContent="center">
354359
<Button intent="secondary" variant="ghost" onClick={toggleShowMore}>
355360
{showMore ? 'Show less' : 'Show more'}
356361
</Button>
357-
</Box>
362+
</Box> */}
358363
</Box>
359364
</Box>
360365
);

examples/chain-template/components/voting/Voting.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export function Voting({ chainName }: VotingProps) {
6060
openModal();
6161
setProposal(proposal);
6262
// @ts-ignore
63-
setTitle(`#${proposal.proposalId?.toString()} ${proposal.content?.title}`);
63+
setTitle(`#${proposal.id?.toString()} ${proposal?.title}`);
6464
}
6565

6666
const content = (
@@ -93,7 +93,7 @@ export function Voting({ chainName }: VotingProps) {
9393
id={`# ${proposal.id?.toString()}`}
9494
key={proposal.submitTime?.getTime()}
9595
// @ts-ignore
96-
title={proposal.content?.title || ""}
96+
title={proposal.content?.title || proposal.title || ''}
9797
status={status(proposal.status)}
9898
votes={votes(proposal.finalTallyResult!)}
9999
endTime={formatDate(proposal.votingEndTime)!}

examples/chain-template/config/chains.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { chains } from 'chain-registry';
22
import osmosis from 'chain-registry/mainnet/osmosis/chain';
33

4-
const chainNames = ['osmosistestnet', 'juno', 'stargaze'];
4+
const chainNames = ['osmosistestnet', 'juno', 'stargaze', 'osmosis'];
55

66
export const chainOptions = chainNames.map(
77
(chainName) => chains.find((chain) => chain.chain_name === chainName)!

examples/chain-template/hooks/asset-list/useAssets.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,13 @@ export const useAssets = (chainName: string) => {
9494
const isWithinLimit = ibcAssets.length <= MAX_TOKENS_TO_SHOW;
9595
return isWithinLimit || topTokens.includes(asset.symbol);
9696
})
97-
.map((asset) => ({ denom: asset.base, amount: '0' }));
98-
97+
.map((asset) => ({ denom: asset.base, amount: '0' }))
98+
.reduce((acc: { denom: string, amount: string }[], current) => {
99+
if (!acc.some(balance => balance.denom === current.denom)) {
100+
acc.push(current);
101+
}
102+
return acc;
103+
}, []);
99104
const finalAssets = [...(nativeAndIbcBalances ?? []), ...emptyBalances]
100105
.map(({ amount, denom }) => {
101106
const asset = getAssetByDenom(denom);

0 commit comments

Comments
 (0)