From c96d9b222a4748532c843d067d0990d6d1d9986c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Florek?= <132075104+LukassF@users.noreply.github.com> Date: Tue, 20 Aug 2024 13:21:16 +0200 Subject: [PATCH] Aptos refactor (#197) * refactor-aptos * aptos-refactor * fix transactions * remove logs * fix code organisation * fix connect --- sdk/apps/modal-example/package.json | 2 +- sdk/apps/modal-example/src/routes/aptos.tsx | 41 ++- .../modal-example/src/routes/aptosCustom.tsx | 73 +++-- sdk/packages/aptos/src/app.ts | 4 +- sdk/packages/selector-aptos/package.json | 2 +- sdk/packages/selector-aptos/src/adapter.ts | 306 ++++++++++-------- sdk/pnpm-lock.yaml | 2 +- 7 files changed, 248 insertions(+), 182 deletions(-) diff --git a/sdk/apps/modal-example/package.json b/sdk/apps/modal-example/package.json index 6e2c019f..f4b1e875 100644 --- a/sdk/apps/modal-example/package.json +++ b/sdk/apps/modal-example/package.json @@ -22,7 +22,7 @@ "@nightlylabs/nightly-connect-polkadot": "0.0.16", "@nightlylabs/nightly-connect-solana": "0.0.29", "@nightlylabs/nightly-connect-sui": "0.1.0", - "@nightlylabs/wallet-selector-aptos": "0.1.6", + "@nightlylabs/wallet-selector-aptos": "0.1.7", "@nightlylabs/wallet-selector-base": "^0.4.1", "@nightlylabs/wallet-selector-polkadot": "0.2.7", "@nightlylabs/wallet-selector-solana": "0.3.6", diff --git a/sdk/apps/modal-example/src/routes/aptos.tsx b/sdk/apps/modal-example/src/routes/aptos.tsx index d9b45302..dcb618cc 100644 --- a/sdk/apps/modal-example/src/routes/aptos.tsx +++ b/sdk/apps/modal-example/src/routes/aptos.tsx @@ -2,15 +2,26 @@ import { AccountAuthenticator, AccountAuthenticatorEd25519, AnyRawTransaction, - Aptos + Aptos, + AccountPublicKey, + Network, + AptosConfig } from '@aptos-labs/ts-sdk' -import { AccountInfo, AptosSignMessageInput, UserResponseStatus } from '@aptos-labs/wallet-standard' +import { + AccountInfo, + AptosSignAndSubmitTransactionInput, + AptosSignMessageInput, + UserResponseStatus +} from '@aptos-labs/wallet-standard' import { NightlyConnectAptosAdapter } from '@nightlylabs/wallet-selector-aptos' import { createEffect, createSignal, onMount, Show } from 'solid-js' import { Title } from '@solidjs/meta' import toast from 'solid-toast' -const aptos = new Aptos() // default to devnet +const aptosConfig = new AptosConfig({ + network: Network.MAINNET +}) +const aptos = new Aptos(aptosConfig) export default function AptosPage() { const [adapter, setAdapter] = createSignal() @@ -35,7 +46,9 @@ export default function AptosPage() { }) adapter.on('connect', (accInfo) => { - setAccountInfo(accInfo) + if (accInfo && 'address' in accInfo) { + setAccountInfo(accInfo) + } }) adapter.on('disconnect', () => { @@ -44,7 +57,9 @@ export default function AptosPage() { }) adapter.on('accountChange', (accInfo) => { - setAccountInfo(accInfo) + if (accInfo && 'address' in accInfo) { + setAccountInfo(accInfo) + } }) setAdapter(adapter) @@ -70,7 +85,7 @@ export default function AptosPage() { Aptos Example
{ @@ -88,12 +103,12 @@ export default function AptosPage() { Connect }> -

Current address: {accountInfo()?.address.toString()}

+

Current address: {accountInfo()?.address?.toString()}

}> -

Current address: {accountInfo()?.address.toString()}

+

Current address: {accountInfo()?.address?.toString()}