Skip to content

Commit

Permalink
aptos-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
LukassF committed Aug 19, 2024
1 parent d32ae5d commit 9c41571
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
28 changes: 27 additions & 1 deletion sdk/apps/modal-example/src/routes/aptos.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import {
AccountAuthenticator,
AccountAuthenticatorEd25519,
AnyRawTransaction,
Aptos
Aptos,
AccountPublicKey,
Network
} from '@aptos-labs/ts-sdk'
import { AccountInfo, AptosSignMessageInput, UserResponseStatus } from '@aptos-labs/wallet-standard'
import { NightlyConnectAptosAdapter } from '@nightlylabs/wallet-selector-aptos'
Expand Down Expand Up @@ -92,6 +94,17 @@ export default function AptosPage() {
<button
onClick={async () => {
try {
try {
await aptos.getAccountInfo({
accountAddress: accountInfo()!.address.toString()
})
} catch (error) {
await aptos.fundAccount({
accountAddress: accountInfo()!.address.toString(),
amount: 100_000_000
})
}

const transaction = await aptos.transaction.build.simple({
sender: accountInfo()!.address.toString(),
data: {
Expand All @@ -103,6 +116,8 @@ export default function AptosPage() {
]
}
})

console.log(transaction)
const signedTx = await adapter()!.signAndSubmitTransaction(transaction)
// Verify the transaction was signed
if (signedTx.status !== UserResponseStatus.APPROVED) {
Expand All @@ -121,6 +136,17 @@ export default function AptosPage() {
<button
onClick={async () => {
try {
try {
await aptos.getAccountInfo({
accountAddress: accountInfo()!.address.toString()
})
} catch (error) {
await aptos.fundAccount({
accountAddress: accountInfo()!.address.toString(),
amount: 100_000_000
})
}

const transaction = await aptos.transaction.build.simple({
sender: accountInfo()!.address.toString(),
data: {
Expand Down
4 changes: 2 additions & 2 deletions sdk/packages/aptos/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {
TransactionToSign
} from '@nightlylabs/nightly-connect-base'
import { EventEmitter } from 'eventemitter3'
import { UserDisconnectedEvent } from '../../../bindings/UserDisconnectedEvent'
import { WalletMetadata } from '../../../bindings/WalletMetadata'
import {
AppAptosInitialize,
APTOS_NETWORK,
Expand All @@ -25,8 +27,6 @@ import {
serializeAptosTx,
serializeObject
} from './utils'
import { UserDisconnectedEvent } from '../../../bindings/UserDisconnectedEvent'
import { WalletMetadata } from '../../../bindings/WalletMetadata'

interface AptosAppEvents {
userConnected: (e: AccountInfo, networkInfo: NetworkInfo) => void
Expand Down

0 comments on commit 9c41571

Please sign in to comment.