-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor(dw): transactions * chore: clean up * feat(dw): faund button
- Loading branch information
Showing
18 changed files
with
860 additions
and
984 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/apps/dev-wallet/src/Components/AccountBalanceDistribution/processChainAccounts.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
packages/apps/dev-wallet/src/Components/FundOnTestnet/FundOnTestnet.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { IAccount } from '@/modules/account/account.repository'; | ||
import { syncAccount } from '@/modules/account/account.service'; | ||
import { ITransaction } from '@/modules/transaction/transaction.repository'; | ||
import { useWallet } from '@/modules/wallet/wallet.hook'; | ||
import { TxContainer } from '@/pages/transaction/components/TxContainer'; | ||
import { ChainId } from '@kadena/client'; | ||
import { Button } from '@kadena/kode-ui'; | ||
import { useState } from 'react'; | ||
|
||
export function FundOnTestnetButton({ | ||
account, | ||
chainId, | ||
fundAccountHandler, | ||
}: { | ||
account?: IAccount; | ||
chainId?: ChainId; | ||
fundAccountHandler: (chainId: ChainId) => Promise<ITransaction>; | ||
}) { | ||
const [fundTx, setFundTx] = useState<ITransaction>(); | ||
const { syncAllAccounts } = useWallet(); | ||
|
||
return ( | ||
<> | ||
{!fundTx && ( | ||
<Button | ||
variant="outlined" | ||
onPress={async () => { | ||
const ftx = await fundAccountHandler( | ||
chainId ?? (Math.floor(Math.random() * 20).toString() as ChainId), | ||
); | ||
setFundTx(ftx); | ||
}} | ||
> | ||
Fund on Testnet | ||
</Button> | ||
)} | ||
|
||
{fundTx && ( | ||
<TxContainer | ||
transaction={fundTx} | ||
as="minimized" | ||
onDone={(tx) => { | ||
setFundTx(tx); | ||
if (account) { | ||
syncAccount(account); | ||
} else { | ||
syncAllAccounts(); | ||
} | ||
if (tx.result?.result.status === 'success') { | ||
setTimeout(() => setFundTx(undefined), 2000); | ||
} | ||
}} | ||
/> | ||
)} | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.