Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
6a07374
fixed the bug that example/nft build failed
Aug 7, 2024
ed241e4
testing github action
Aug 7, 2024
0a5b1be
test github action
Aug 7, 2024
32dbfbf
github action test
Aug 7, 2024
c1a0637
github action test 4
Aug 7, 2024
3255ffd
github actions fixed
Aug 7, 2024
7a53541
remove non nessery branch pushing of github action
Aug 7, 2024
065debb
enable yarn 2+ for github actions
Aug 7, 2024
5269a0c
for github actions debug
Aug 7, 2024
b75df91
test cicd
Aug 10, 2024
456d21e
github action test
Aug 11, 2024
59f25fb
set YARN_ENABLE_IMMUTABLE_INSTALLS=false in github action config to a…
Aug 11, 2024
540c733
github actions test
Aug 11, 2024
a7ac32e
test github action
Aug 11, 2024
b1e0421
renew /yarn.lock
Aug 11, 2024
f47545f
github action test
Aug 11, 2024
acd3373
upgrade @chain-registry/types
Aug 11, 2024
ffcc616
fix type error while building
Aug 12, 2024
19c65f6
changed @interchain-ui/react from ^1.23.29 to 1.23.29
Aug 12, 2024
052b6dd
run yarn install to modify /yarn.lock to avoid checksum error in cicd
Aug 12, 2024
14f75c7
remove resolutions on nft/packages.json to solve version conflict wit…
Aug 12, 2024
d9307c7
renew package versions
Aug 12, 2024
82c054c
renws checksum
Aug 12, 2024
3e53c40
Merge branch 'feat/chain-template' into eason/bugfixing
Aug 14, 2024
bc8a3a7
add osmosis to chain selection
Aug 14, 2024
6a9a095
added util toBaseAmount
Aug 15, 2024
f3052f2
* fix bug that submit decimals to chain by useing toBaseAmount util
Aug 15, 2024
7d0d829
* replace shiftDigits with toBaseAmount to solve the bugs that submit…
Aug 15, 2024
c238130
delete some dead code
Aug 15, 2024
a38abeb
* replace shiftDigits with toBaseAmount to solve the bug submitting d…
Aug 15, 2024
57a8631
Merge branch 'main' into eason/chain-template
Aug 15, 2024
9e6b1a2
optimise import utils
Aug 15, 2024
faf91b2
ci secipt that passed all tests
Aug 15, 2024
dc7e347
Merge branch 'eason/bugfixing' into eason/chain-template
Aug 15, 2024
b6aa4a0
De-duplicate the tokens in the emptyBalances variable
Aug 16, 2024
634afc8
fix the bug that in asset-list, when click Withdraw on "Your assets",…
Aug 17, 2024
9cd484c
fix the bug that the default selected token is not belong to the sour…
Aug 17, 2024
1edf7dc
fixed the bug that no title on proposal list
Aug 19, 2024
088cff2
fixed the bug that proposal description may be to large, use overflowY
Aug 19, 2024
c1b10e7
bug fixed that the title of proposal dialog showed undefined
Aug 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/run-tests-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,18 @@ jobs:
- name: Set up Yarn
uses: threeal/[email protected]

- name: Get last git commit hash
run: |
echo "DIFF_HASH=$(git log -1 --pretty=format:%H)" >> $GITHUB_ENV

- name: Cache NextJS
uses: actions/cache@v4
with:
path: |
${{ github.workspace }}/.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
#key: ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-${{ env.DIFF_HASH }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ jobs:
run: |
cca --example nft --name nft
cd nft
touch yarn.lock
yarn install
yarn build

- name: authz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ const OverviewTransferWrapper = (
}
return new BigNumber(asset.amount).gt(0);
})
.filter((asset) => {
return asset.symbol !== transferToken.symbol;
})
// .filter((asset) => {
// return asset.symbol !== transferToken.symbol;
// })
.map((asset) => ({
available: new BigNumber(asset.displayAmount).toNumber(),
symbol: asset.symbol,
Expand All @@ -198,6 +198,7 @@ const OverviewTransferWrapper = (
).toNumber(),
}));
}, [assets, isDeposit, transferToken]);
console.log('assetOptions', assetOptions);

const handleOnChange = (
assetOption: Unpacked<OverviewTransferProps['dropdownList']>,
Expand Down Expand Up @@ -269,7 +270,7 @@ export const DropdownTransferModal = (props: OverviewTransferWrapperProps) => {
return (
<BasicModal
isOpen={modalControl.isOpen}
title="Deposit"
title={transferInfoState.transferInfo.type}
onClose={() => closeModal()}
>
{transferInfoState ? (
Expand Down
9 changes: 5 additions & 4 deletions examples/chain-template/components/staking/DelegateModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ import {
isGreaterThanZero,
shiftDigits,
calcDollarValue,
getCoin,
getExponent,
toBaseAmount,
} from '@/utils';
import { getCoin, getExponent } from '@/utils';
import { Prices, UseDisclosureReturn, useTx } from '@/hooks';

const { delegate } = cosmos.staking.v1beta1.MessageComposer.fromPartial;
Expand Down Expand Up @@ -84,7 +86,7 @@ export const DelegateModal = ({
delegatorAddress: address,
validatorAddress: selectedValidator.address,
amount: {
amount: shiftDigits(amount, exp),
amount: toBaseAmount(amount, exp), // shiftDigits(amount, exp),
denom: coin.base,
},
});
Expand Down Expand Up @@ -220,8 +222,7 @@ export const DelegateModal = ({
},
{
label: 'Max',
onClick: handleMaxClick,
isLoading: isSimulating,
onClick: () => setAmount(Number(balance)),
},
],
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
getAssetLogoUrl,
isGreaterThanZero,
shiftDigits,
toBaseAmount,
type ExtendedValidator as Validator,
} from '@/utils';
import { getCoin, getExponent } from '@/utils';
Expand Down Expand Up @@ -67,7 +68,7 @@ export const RedelegateModal = ({
validatorDstAddress: validatorToRedelegate.address,
amount: {
denom: coin.base,
amount: shiftDigits(amount, exp),
amount: toBaseAmount(amount, exp),
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
getAssetLogoUrl,
isGreaterThanZero,
shiftDigits,
toBaseAmount,
type ExtendedValidator as Validator,
} from '@/utils';

Expand Down Expand Up @@ -68,7 +69,7 @@ export const UndelegateModal = ({
delegatorAddress: address,
validatorAddress: selectedValidator.address,
amount: {
amount: shiftDigits(amount, exp),
amount: toBaseAmount(amount, exp),
denom: coin.base,
},
});
Expand Down
21 changes: 13 additions & 8 deletions examples/chain-template/components/voting/Proposal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function Proposal({
proposal,
chainName,
bondedTokens,
onVoteSuccess = () => {},
onVoteSuccess = () => { },
}: ProposalProps) {
const vote = votes?.[proposal.id.toString()];

Expand Down Expand Up @@ -92,9 +92,9 @@ export function Proposal({

const total = proposal.finalTallyResult
? Object.values(proposal.finalTallyResult).reduce(
(sum, val) => sum + Number(val),
0
)
(sum, val) => sum + Number(val),
0
)
: 0;

const turnout = total / Number(bondedTokens);
Expand Down Expand Up @@ -248,9 +248,8 @@ export function Proposal({
px: '$2',
}}
>
{`Minimum of staked ${minStakedTokens} ${coin.symbol}(${
quorum * 100
}%) need to vote
{`Minimum of staked ${minStakedTokens} ${coin.symbol}(${quorum * 100
}%) need to vote
for this proposal to pass.`}
</Text>
</Text>
Expand Down Expand Up @@ -347,14 +346,20 @@ export function Proposal({
</Text>

<Text fontSize="$sm" fontWeight="$normal" color="$textSecondary">
<div style={{ maxHeight: '128px', overflowY: 'scroll' }}>
<Markdown>{description}</Markdown>
</div>
</Text>

{/* <Text fontSize="$sm" fontWeight="$normal" color="$textSecondary">
{showMore ? <Markdown>{description}</Markdown> : renderedDescription}
</Text>

<Box mt="$8" width="100%" display="flex" justifyContent="center">
<Button intent="secondary" variant="ghost" onClick={toggleShowMore}>
{showMore ? 'Show less' : 'Show more'}
</Button>
</Box>
</Box> */}
</Box>
</Box>
);
Expand Down
4 changes: 2 additions & 2 deletions examples/chain-template/components/voting/Voting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function Voting({ chainName }: VotingProps) {
openModal();
setProposal(proposal);
// @ts-ignore
setTitle(`#${proposal.proposalId?.toString()} ${proposal.content?.title}`);
setTitle(`#${proposal.id?.toString()} ${proposal?.title}`);
}

const content = (
Expand Down Expand Up @@ -93,7 +93,7 @@ export function Voting({ chainName }: VotingProps) {
id={`# ${proposal.id?.toString()}`}
key={proposal.submitTime?.getTime()}
// @ts-ignore
title={proposal.content?.title || ""}
title={proposal.content?.title || proposal.title || ''}
status={status(proposal.status)}
votes={votes(proposal.finalTallyResult!)}
endTime={formatDate(proposal.votingEndTime)!}
Expand Down
2 changes: 1 addition & 1 deletion examples/chain-template/config/chains.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { chains } from 'chain-registry';
import osmosis from 'chain-registry/mainnet/osmosis/chain';

const chainNames = ['osmosistestnet', 'juno', 'stargaze'];
const chainNames = ['osmosistestnet', 'juno', 'stargaze', 'osmosis'];

export const chainOptions = chainNames.map(
(chainName) => chains.find((chain) => chain.chain_name === chainName)!
Expand Down
9 changes: 7 additions & 2 deletions examples/chain-template/hooks/asset-list/useAssets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,13 @@ export const useAssets = (chainName: string) => {
const isWithinLimit = ibcAssets.length <= MAX_TOKENS_TO_SHOW;
return isWithinLimit || topTokens.includes(asset.symbol);
})
.map((asset) => ({ denom: asset.base, amount: '0' }));

.map((asset) => ({ denom: asset.base, amount: '0' }))
.reduce((acc: { denom: string, amount: string }[], current) => {
if (!acc.some(balance => balance.denom === current.denom)) {
acc.push(current);
}
return acc;
}, []);
const finalAssets = [...(nativeAndIbcBalances ?? []), ...emptyBalances]
.map(({ amount, denom }) => {
const asset = getAssetByDenom(denom);
Expand Down
10 changes: 10 additions & 0 deletions examples/chain-template/utils/staking/math.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,13 @@ export const calcDollarValue = (
.decimalPlaces(2)
.toNumber();
};

export const toBaseAmount = (
num: string | number,
places: number
) => {
return new BigNumber(num)
.shiftedBy(places)
.integerValue(BigNumber.ROUND_DOWN)
.toString();
};
14 changes: 4 additions & 10 deletions examples/nft/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,14 @@
"locks": "npm run locks:remove && npm run locks:create",
"watch:codegen": "npx graphql-code-generator --config ./config/codegen.ts --watch"
},
"resolutions": {
"react": "18.2.0",
"react-dom": "18.2.0",
"@types/react": "18.0.25",
"@types/react-dom": "18.0.9"
},
"dependencies": {
"@chain-registry/types": "0.17.0",
"@chain-registry/types": "^0.16.0",
"@cosmjs/cosmwasm-stargate": "0.31.3",
"@cosmjs/stargate": "0.32.3",
"@cosmos-kit/react": "2.17.0",
"@emotion/react": "11.10.6",
"@emotion/styled": "11.10.6",
"@interchain-ui/react": "^1.23.29",
"@interchain-ui/react": "1.23.29",
"@interchain-ui/react-no-ssr": "^0.1.6",
"@tanstack/react-query": "4.32.0",
"bignumber.js": "9.1.0",
Expand All @@ -49,8 +43,8 @@
"@types/node": "^20.14.6",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"eslint": "8.56.0",
"eslint-config-next": "14.1.0",
"eslint": "8.57.0",
"eslint-config-next": "14.2.3",
"generate-lockfile": "0.0.12",
"typescript": "^5.1.6"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/nft/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export function getLogo(from: Asset | Chain) {

export function getChainLogo(name: string) {
const chain = chains.find(chain => chain.chain_name === name)
return chain ? getLogo(chain) : null;
return chain ? getLogo(chain as any) : null;
}

export function getStargazeProfileLink(address: string | undefined) {
Expand Down
Loading